Skip to content
This repository has been archived by the owner on Mar 20, 2023. It is now read-only.

Commit

Permalink
clang-format after moving to c++ (#96)
Browse files Browse the repository at this point in the history
- previous PR from Jeremy didn't update source style
- disable indentation of namespaces
  • Loading branch information
pramodk committed Jun 6, 2018
1 parent 02dd866 commit b21da2f
Show file tree
Hide file tree
Showing 102 changed files with 352 additions and 351 deletions.
2 changes: 1 addition & 1 deletion .clang-format
Expand Up @@ -63,7 +63,7 @@ KeepEmptyLinesAtTheStartOfBlocks: false
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: All
NamespaceIndentation: None
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: false
Expand Down
12 changes: 11 additions & 1 deletion CMakeLists.txt
Expand Up @@ -185,7 +185,17 @@ if(CLANG_FORMAT_FOUND)

# exclude ezoption header file
list(REMOVE_ITEM SRC_FILES_FOR_CLANG_FORMAT
"${PROJECT_SOURCE_DIR}/coreneuron/utils/ezoption/ezOptionParser.hpp")
${PROJECT_SOURCE_DIR}/coreneuron/utils/ezoption/ezOptionParser.hpp
${PROJECT_SOURCE_DIR}/coreneuron/utils/endianness.h
${PROJECT_SOURCE_DIR}/coreneuron/utils/swap_endian.h)

# exclude random123 files
file (GLOB_RECURSE RANDOM123_FILES
${PROJECT_SOURCE_DIR}/coreneuron/utils/randoms/Random123/*.cpp
${PROJECT_SOURCE_DIR}/coreneuron/utils/randoms/Random123/*.h)
foreach (R123_PATH ${RANDOM123_FILES})
list (REMOVE_ITEM SRC_FILES_FOR_CLANG_FORMAT ${R123_PATH})
endforeach(R123_PATH)

add_custom_target(formatsource COMMAND ${CMAKE_COMMAND}
-DSOURCE_FILES:STRING="${SRC_FILES_FOR_CLANG_FORMAT}"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -239,7 +239,7 @@ If you have installed `clang-format`, you can reformat/reindent generated .c fil
make formatbuild
```

The `.clang-format` file in the source repository is compatible with version 3.9 and 4.0.
The `.clang-format` file in the source repository is compatible with version 5.0.

## License
* See LICENSE.txt
Expand Down
2 changes: 1 addition & 1 deletion coreneuron/coreneuron.h
Expand Up @@ -67,6 +67,6 @@ extern void nrn_cur_ion(NrnThread* _nt, Memb_list* ml, int type);
extern void nrn_alloc_ion(double* data, Datum* pdata, int type);
extern void second_order_cur(NrnThread* _nt, int secondorder);

} //namespace coreneuron
} // namespace coreneuron

#endif
4 changes: 2 additions & 2 deletions coreneuron/engine.h
Expand Up @@ -4,9 +4,9 @@
#ifdef __cplusplus
extern "C" {
#endif
extern int solve_core (int argc, char** argv);
extern int solve_core(int argc, char** argv);
#ifdef __cplusplus
}
}
#endif

#endif
3 changes: 1 addition & 2 deletions coreneuron/mech/cfile/cabvars.h
Expand Up @@ -26,7 +26,6 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
THE POSSIBILITY OF SUCH DAMAGE.
*/


namespace coreneuron {

extern void capacitance_reg(void), _passive_reg(void),
Expand All @@ -43,4 +42,4 @@ static void (*mechanism[])(void) = {/* type will start at 3 */
#endif
_stim_reg, _hh_reg, _expsyn_reg, _netstim_reg, _exp2syn_reg, 0};

} //namespace coreneuron
} // namespace coreneuron
2 changes: 1 addition & 1 deletion coreneuron/mech/mod2c_core_thread.h
Expand Up @@ -139,6 +139,6 @@ extern void _modl_set_dt_thread(double, NrnThread*);

void nrn_sparseobj_copyto_device(SparseObj* so);

} // namespace coreneuron
} // namespace coreneuron

#endif
4 changes: 1 addition & 3 deletions coreneuron/nrnconf.h
Expand Up @@ -35,7 +35,6 @@ THE POSSIBILITY OF SUCH DAMAGE.
#include <errno.h>
#include <stdint.h>


namespace coreneuron {

#define NRNBBCORE 1
Expand All @@ -57,7 +56,6 @@ typedef char Symbol;
#define VEC_AREA(i) (_nt->_actual_area[(i)])
#define VECTORIZE 1


extern double celsius;

extern double t, dt;
Expand Down Expand Up @@ -93,6 +91,6 @@ typedef struct Point_process {

extern char* pnt_name(Point_process* pnt);

} //namespace coreneuron
} // namespace coreneuron

#endif
2 changes: 1 addition & 1 deletion coreneuron/nrniv/balance.cpp
Expand Up @@ -103,4 +103,4 @@ size_t warp_balance(size_t ncell, VecTNode& nodevec) {

return nwarp;
}
} //namespace coreneuron
} // namespace coreneuron
2 changes: 1 addition & 1 deletion coreneuron/nrniv/cellorder.cpp
Expand Up @@ -683,5 +683,5 @@ void solve_interleaved(int ith) {
solve_interleaved1(ith);
}
}
} //namespace coreneuron
} // namespace coreneuron
#endif
2 changes: 1 addition & 1 deletion coreneuron/nrniv/cellorder.h
Expand Up @@ -57,5 +57,5 @@ void copy_array(T*& dest, T* src, size_t n) {
#if INTERLEAVE_DEBUG
void mk_cell_indices();
#endif
} //namespace coreneuron
} // namespace coreneuron
#endif
2 changes: 1 addition & 1 deletion coreneuron/nrniv/cellorder1.cpp
Expand Up @@ -669,4 +669,4 @@ for (int i = 0; i <= nwarp; ++i){
}
#endif
}
} //namespace coreneuron
} // namespace coreneuron
2 changes: 1 addition & 1 deletion coreneuron/nrniv/cellorder2.cpp
Expand Up @@ -530,4 +530,4 @@ void group_order2(VecTNode& nodevec, size_t groupsize, size_t ncell) {
std::sort(nodevec.begin() + ncell, nodevec.end(), final_nodevec_cmp);
set_nodeindex(nodevec);
}
} //namespace coreneuron
} // namespace coreneuron
4 changes: 2 additions & 2 deletions coreneuron/nrniv/cvodestb.cpp
Expand Up @@ -35,7 +35,7 @@ THE POSSIBILITY OF SUCH DAMAGE.

#include "coreneuron/nrniv/nrn_acc_manager.h"

namespace coreneuron{
namespace coreneuron {

// for fixed step thread
// check thresholds and deliver all (including binqueue) events
Expand Down Expand Up @@ -112,4 +112,4 @@ int at_time(NrnThread* nt, double te) {
}
return 0;
}
} //namespace coreneuron
} // namespace coreneuron
2 changes: 1 addition & 1 deletion coreneuron/nrniv/global_vars.cpp
Expand Up @@ -106,4 +106,4 @@ void set_globals(const char* path) {
delete n2v;
n2v = NULL;
}
} //namespace coreneuron
} // namespace coreneuron
2 changes: 1 addition & 1 deletion coreneuron/nrniv/have2want.h
Expand Up @@ -260,4 +260,4 @@ static void have_to_want(HAVEWANT_t* have,
recv_from_have_cnt = want_s_cnt;
recv_from_have_displ = want_s_displ;
}
} //namespace coreneuron
} // namespace coreneuron
4 changes: 2 additions & 2 deletions coreneuron/nrniv/ivocvect.cpp
Expand Up @@ -42,7 +42,7 @@ double* vector_vec(IvocVect* v) {
* Retro-compatibility implementations
*/
void* vector_new1(int n) {
return (void*) (new IvocVect(n));
return (void*)(new IvocVect(n));
}

int vector_capacity(void* v) {
Expand All @@ -52,4 +52,4 @@ double* vector_vec(void* v) {
return ((IvocVect*)v)->data();
}

} //namespace coreneuron
} // namespace coreneuron
3 changes: 1 addition & 2 deletions coreneuron/nrniv/ivocvect.h
Expand Up @@ -29,7 +29,6 @@ THE POSSIBILITY OF SUCH DAMAGE.
#ifndef ivoc_vector_h
#define ivoc_vector_h


#include <stdio.h>
#include "coreneuron/nrniv/nrnmutdec.h"
namespace coreneuron {
Expand Down Expand Up @@ -93,6 +92,6 @@ extern void* vector_new1(int n);
extern int vector_capacity(void* v);
extern double* vector_vec(void* v);

} //namespace coreneuron
} // namespace coreneuron

#endif
6 changes: 1 addition & 5 deletions coreneuron/nrniv/main1.cpp
Expand Up @@ -57,7 +57,6 @@ THE POSSIBILITY OF SUCH DAMAGE.
#include <string.h>
#include <climits>


#if 0
#include <fenv.h>
#define NRN_FEEXCEPT (FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW)
Expand Down Expand Up @@ -242,7 +241,6 @@ void call_prcellstate_for_prcellgid(int prcellgid, int compute_gpu, int is_init)
}
}


/* perform forwardskip and call prcellstate for prcellgid */
void handle_forward_skip(double forwardskip, int prcellgid) {
double savedt = dt;
Expand All @@ -267,11 +265,10 @@ void handle_forward_skip(double forwardskip, int prcellgid) {
const char* nrn_version(int) {
return "version id unimplemented";
}
} //namespace coreneuron
} // namespace coreneuron

using namespace coreneuron;
extern "C" int solve_core(int argc, char** argv) {

#if NRNMPI
nrnmpi_init(1, &argc, &argv);
#endif
Expand Down Expand Up @@ -393,4 +390,3 @@ extern "C" int solve_core(int argc, char** argv) {

return 0;
}

72 changes: 36 additions & 36 deletions coreneuron/nrniv/memory.h
Expand Up @@ -34,48 +34,48 @@ THE POSSIBILITY OF SUCH DAMAGE.
#include "coreneuron/nrniv/nrn_assert.h"

namespace coreneuron {
/** Independent function to compute the needed chunkding,
the chunk argument is the number of doubles the chunk is chunkded upon.
*/
template <int chunk>
inline int soa_padded_size(int cnt, int layout) {
int imod = cnt % chunk;
if (layout == 1)
return cnt;
if (imod) {
int idiv = cnt / chunk;
return (idiv + 1) * chunk;
}
/** Independent function to compute the needed chunkding,
the chunk argument is the number of doubles the chunk is chunkded upon.
*/
template <int chunk>
inline int soa_padded_size(int cnt, int layout) {
int imod = cnt % chunk;
if (layout == 1)
return cnt;
if (imod) {
int idiv = cnt / chunk;
return (idiv + 1) * chunk;
}
return cnt;
}

/** Check for the pointer alignment.
*/
inline bool is_aligned(void* pointer, size_t alignment) {
return (((uintptr_t)(const void*)(pointer)) % (alignment) == 0);
}
/** Check for the pointer alignment.
*/
inline bool is_aligned(void* pointer, size_t alignment) {
return (((uintptr_t)(const void*)(pointer)) % (alignment) == 0);
}

/** Allocate the aligned memory.
*/
inline void* emalloc_align(size_t size, size_t alignment) {
void* memptr;
nrn_assert(posix_memalign(&memptr, alignment, size) == 0);
nrn_assert(is_aligned(memptr, alignment));
return memptr;
}
/** Allocate the aligned memory.
*/
inline void* emalloc_align(size_t size, size_t alignment) {
void* memptr;
nrn_assert(posix_memalign(&memptr, alignment, size) == 0);
nrn_assert(is_aligned(memptr, alignment));
return memptr;
}

/** Allocate the aligned memory and set it to 1.
*/
inline void* ecalloc_align(size_t n, size_t alignment, size_t size) {
void* p;
if (n == 0) {
return (void*)0;
}
nrn_assert(posix_memalign(&p, alignment, n * size) == 0);
nrn_assert(is_aligned(p, alignment));
memset(p, 1, n * size); // Avoid native division by zero (cyme...)
return p;
/** Allocate the aligned memory and set it to 1.
*/
inline void* ecalloc_align(size_t n, size_t alignment, size_t size) {
void* p;
if (n == 0) {
return (void*)0;
}
nrn_assert(posix_memalign(&p, alignment, n * size) == 0);
nrn_assert(is_aligned(p, alignment));
memset(p, 1, n * size); // Avoid native division by zero (cyme...)
return p;
}
} // namespace coreneuron

#endif
2 changes: 1 addition & 1 deletion coreneuron/nrniv/mk_mech.cpp
Expand Up @@ -172,4 +172,4 @@ const char* nrn_get_mechname(int type) {
}
return NULL;
}
} //namespace coreneuron
} // namespace coreneuron
2 changes: 1 addition & 1 deletion coreneuron/nrniv/multisend.cpp
Expand Up @@ -466,4 +466,4 @@ void nrn_multisend_setup() {
#endif
}
#endif // NRN_MULTISEND
} // namespace coreneuron
} // namespace coreneuron
2 changes: 1 addition & 1 deletion coreneuron/nrniv/multisend.h
Expand Up @@ -19,5 +19,5 @@ void nrn_multisend_cleanup();
void nrn_multisend_setup();

void nrn_multisend_setup_targets(int use_phase2, int*& targets_phase1, int*& targets_phase2);
} //namespace coreneuron
} // namespace coreneuron
#endif // nrnmultisend_h
2 changes: 1 addition & 1 deletion coreneuron/nrniv/multisend_setup.cpp
Expand Up @@ -702,5 +702,5 @@ static int setup_target_lists(int use_phase2, int** r_return) {
*r_return = r;
return sz;
}
} //namespace coreneuron
} // namespace coreneuron
#endif // NRN_MULTISEND
2 changes: 1 addition & 1 deletion coreneuron/nrniv/netcon.h
Expand Up @@ -183,5 +183,5 @@ class NetParEvent : public DiscreteEvent {

virtual void pr(const char*, double t, NetCvode*);
};
} //namespace coreneuron
} // namespace coreneuron
#endif
2 changes: 1 addition & 1 deletion coreneuron/nrniv/netcvode.cpp
Expand Up @@ -810,4 +810,4 @@ void NetCvode::deliver_net_events(NrnThread* nt) { // for default method
(*net_buf_receive_[i])(nt);
}
}
} //namespace coreneuron
} // namespace coreneuron
2 changes: 1 addition & 1 deletion coreneuron/nrniv/netcvode.h
Expand Up @@ -92,5 +92,5 @@ class NetCvode {
void init_events();
void point_receive(int, Point_process*, double*, double);
};
} //namespace coreneuron
} // namespace coreneuron
#endif
2 changes: 1 addition & 1 deletion coreneuron/nrniv/netpar.cpp
Expand Up @@ -914,4 +914,4 @@ int nrnmpi_spike_compress(int nspike, bool gid_compress, int xchng_meth) {
return 0;
#endif
}
} //namespace coreneuron
} // namespace coreneuron
2 changes: 1 addition & 1 deletion coreneuron/nrniv/node_permute.cpp
Expand Up @@ -329,4 +329,4 @@ void permute_nodeindices(Memb_list* ml, int* p) {
invert_permute(ml->_permute, ml->nodecount);
permute_ptr(ml->nodeindices, ml->nodecount, ml->_permute);
}
} //namespace coreneuron
} // namespace coreneuron
2 changes: 1 addition & 1 deletion coreneuron/nrniv/node_permute.h
Expand Up @@ -18,5 +18,5 @@ void permute_ml(Memb_list* ml, int type, NrnThread& nt);
int nrn_index_permute(int, int type, Memb_list* ml);

int* inverse_permute(int* p, int n);
} //namespace coreneuron
} // namespace coreneuron
#endif
3 changes: 1 addition & 2 deletions coreneuron/nrniv/nrn_acc_manager.cpp
Expand Up @@ -991,5 +991,4 @@ void nrn_sparseobj_copyto_device(SparseObj* so) {
}
#endif
}
} //namespace coreneuron

} // namespace coreneuron
2 changes: 1 addition & 1 deletion coreneuron/nrniv/nrn_acc_manager.h
Expand Up @@ -20,5 +20,5 @@ void update_net_receive_buffer(NrnThread* _nt);
void realloc_net_receive_buffer(NrnThread* nt, Memb_list* ml);
void update_net_send_buffer_on_host(NrnThread* nt, NetSendBuffer_t* nsb);

} //namespace coreneuron
} // namespace coreneuron
#endif // _nrn_device_manager_

0 comments on commit b21da2f

Please sign in to comment.