diff --git a/src/atomic.h b/src/atomic.h index 82b86eb4bc21630476496b177f8e7f236d76f00b..882f4288dfc262d7f62d2ad8b25f7a6625ed90b2 100644 --- a/src/atomic.h +++ b/src/atomic.h @@ -18,15 +18,7 @@ ******************************************************************************/ - -/* Get the inlining right. */ -#ifndef INLINE -# if __GNUC__ && !__GNUC_STDC_INLINE__ -# define INLINE extern inline -# else -# define INLINE inline -# endif -#endif +#include "inline.h" #define atomic_add(v,i) __sync_fetch_and_add( v , i ) #define atomic_inc(v) atomic_add( v , 1 ) diff --git a/src/cell.c b/src/cell.c index cf996512939cc39850a7e5ce9af06cec02c42d21..b3612d6909e66984c6454c7af1c873434cad13ed 100644 --- a/src/cell.c +++ b/src/cell.c @@ -35,11 +35,8 @@ #include "task.h" #include "part.h" #include "cell.h" - - -/* Error macro. */ -#define error(s) { fprintf( stderr , "%s:%s:%i: %s\n" , __FILE__ , __FUNCTION__ , __LINE__ , s ); abort(); } - +#include "error.h" +#include "inline.h" /* The timers. */ ticks cell_timer[ cell_timer_count ]; @@ -56,13 +53,6 @@ ticks cell_timer[ cell_timer_count ]; #define TIMER_TOC(t) timer_toc( t , tic ) #define TIMER_TIC2 ticks tic2 = getticks(); #define TIMER_TOC2(t) timer_toc( t , tic2 ) - #ifndef INLINE - # if __GNUC__ && !__GNUC_STDC_INLINE__ - # define INLINE extern inline - # else - # define INLINE inline - # endif - #endif INLINE static ticks timer_toc ( int t , ticks tic ) { ticks d = (getticks() - tic); __sync_add_and_fetch( &cell_timer[t] , d ); diff --git a/src/engine.c b/src/engine.c index 528e6d2fd087beb61667727b18623114f50637b9..c649d00c7ab591cc5fee84d5c10aa7101c8fc579 100644 --- a/src/engine.c +++ b/src/engine.c @@ -46,9 +46,7 @@ #include "engine.h" #include "runner.h" #include "runner_iact.h" - -/* Error macro. */ -#define error(s) { fprintf( stderr , "%s:%s:%i: %s\n" , __FILE__ , __FUNCTION__ , __LINE__ , s ); abort(); } +#include "error.h" /* Convert cell location to ID. */ #define cell_getid( cdim , i , j , k ) ( (int)(k) + (cdim)[2]*( (int)(j) + (cdim)[1]*(int)(i) ) ) diff --git a/src/error.h b/src/error.h new file mode 100644 index 0000000000000000000000000000000000000000..4d4aa5c76c55ba5e1d7c2f6ba6d6b0eb1e38c5da --- /dev/null +++ b/src/error.h @@ -0,0 +1,27 @@ +/******************************************************************************* + * This file is part of SWIFT. + * Coypright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk), + * Matthieu Schaller (matthieu.schaller@durham.ac.uk). + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + ******************************************************************************/ + +#include <stdio.h> + +/** + * @brief Error macro. Prints the message given in argument and aborts. + * + */ +#define error(s) { fprintf( stderr , "%s:%s():%i: %s\n" , __FILE__ , __FUNCTION__ , __LINE__ , s ); abort(); } diff --git a/src/inline.h b/src/inline.h new file mode 100644 index 0000000000000000000000000000000000000000..a9b3059fe7570a9b7bb67cc0d4b9f93181c19ccf --- /dev/null +++ b/src/inline.h @@ -0,0 +1,30 @@ +/******************************************************************************* + * This file is part of SWIFT. + * Coypright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk), + * Matthieu Schaller (matthieu.schaller@durham.ac.uk). + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + ******************************************************************************/ + +/** + * @brief Defines inline + */ +#ifndef INLINE +# if __GNUC__ && !__GNUC_STDC_INLINE__ +# define INLINE extern inline +# else +# define INLINE inline +# endif +#endif diff --git a/src/io.c b/src/io.c index e8c57a256c937b344561bd86a520646c91401e02..4a27d5949075168508b7af48fb2c7f988f6c4170 100644 --- a/src/io.c +++ b/src/io.c @@ -37,12 +37,7 @@ #include "part.h" #include "space.h" #include "engine.h" - -/** - * @brief Error macro - * - */ -#define error(s) { fprintf( stderr , "%s:%s():%i: %s\n" , __FILE__ , __FUNCTION__ , __LINE__ , s ); abort(); } +#include "error.h" /** * @brief The different types of data used in the GADGET IC files. @@ -533,16 +528,12 @@ void writeArrayBackEnd(hid_t grp, char* fileName, FILE* xmfFile, char* name, enu * @brief Writes an HDF5 output file (GADGET-3 type) with its XMF descriptor * * @param fileName The file to write. - * @param dim The dimension of the volume written to the file. - * @param parts The array of #part to write in the file. - * @param N The number of particles to write. - * @param periodic 1 if the volume is periodic, 0 if not. + * @param e The engine containing all the system. * * Creates the HDF5 file fileName and writess the particles contained - * in the parts array. If such a file already exists, it is erased and replaced + * in the engine. If such a file already exists, it is erased and replaced * by the new one. * - * * Calls #error() if an error occurs. * */ diff --git a/src/lock.h b/src/lock.h index efdd0aa94c490ec923e3bd1528f4972aea5c781c..39f80bcdc5a33d8f6fd4e606a3fcd75d430ef583 100644 --- a/src/lock.h +++ b/src/lock.h @@ -19,14 +19,7 @@ -/* Get the inlining right. */ -#ifndef INLINE -# if __GNUC__ && !__GNUC_STDC_INLINE__ -# define INLINE extern inline -# else -# define INLINE inline -# endif -#endif +#include "inline.h" #ifdef PTHREAD_LOCK #define lock_type pthread_spinlock_t diff --git a/src/queue.c b/src/queue.c index 757710ca5208191045a439113d675250c28f8e64..d2c47b4d17833109bed04bfb083d7f5d8db9ea7f 100644 --- a/src/queue.c +++ b/src/queue.c @@ -37,9 +37,8 @@ #include "task.h" #include "cell.h" #include "queue.h" - -/* Error macro. */ -#define error(s) { fprintf( stderr , "%s:%s:%i: %s\n" , __FILE__ , __FUNCTION__ , __LINE__ , s ); abort(); } +#include "error.h" +#include "inline.h" /* Define the timer macros. */ #ifdef TIMER_VERBOSE @@ -52,13 +51,6 @@ #define TIMER_TOC(t) timer_toc( t , tic ) #define TIMER_TIC2 ticks tic2 = getticks(); #define TIMER_TOC2(t) timer_toc( t , tic2 ) - #ifndef INLINE - # if __GNUC__ && !__GNUC_STDC_INLINE__ - # define INLINE extern inline - # else - # define INLINE inline - # endif - #endif INLINE static ticks timer_toc ( int t , ticks tic ) { ticks d = (getticks() - tic); __sync_add_and_fetch( &queue_timer[t] , d ); diff --git a/src/runner.c b/src/runner.c index 8fa2d2fbede7e343b53e69e1f15f2966b09780b5..adbf48ddd2d5de1b094492abfc7e51edbaa25500 100644 --- a/src/runner.c +++ b/src/runner.c @@ -44,9 +44,7 @@ #include "engine.h" #include "runner.h" #include "runner_iact.h" - -/* Error macro. */ -#define error(s) { fprintf( stderr , "%s:%s:%i: %s\n" , __FILE__ , __FUNCTION__ , __LINE__ , s ); abort(); } +#include "error.h" /* Convert cell location to ID. */ #define cell_getid( cdim , i , j , k ) ( (int)(k) + (cdim)[2]*( (int)(j) + (cdim)[1]*(int)(i) ) ) diff --git a/src/runner.h b/src/runner.h index f9a8cfd6b07b5b6a454f4765bd922be315ea39a0..58ecf128f5a0b867745a2b2dee5f2e50418c8f31 100644 --- a/src/runner.h +++ b/src/runner.h @@ -17,6 +17,7 @@ * ******************************************************************************/ +#include "inline.h" /* SID stuff. */ extern const char runner_flip[]; @@ -51,15 +52,6 @@ long long int runner_hist_bins[ runner_hist_N ]; #define runner_hist_hit( x ) __sync_add_and_fetch( &runner_hist_bins[ (int)fmax( 0.0 , fmin( runner_hist_N-1 , ((x) - runner_hist_a) / (runner_hist_b - runner_hist_a) * runner_hist_N ) ) ] , 1 ) -/* Get the inlining right. */ -#ifndef INLINE -# if __GNUC__ && !__GNUC_STDC_INLINE__ -# define INLINE extern inline -# else -# define INLINE inline -# endif -#endif - /* A struct representing a runner's thread and its data. */ struct runner { diff --git a/src/space.c b/src/space.c index 606ebe43875442b5868c9f5350fe3aa4317a54b5..08ac0b81e24fb34b0873f0dfe4b7e3a1f6e17d5b 100644 --- a/src/space.c +++ b/src/space.c @@ -38,9 +38,7 @@ #include "cell.h" #include "space.h" #include "runner.h" - -/* Error macro. */ -#define error(s) { fprintf( stderr , "%s:%s:%i: %s\n" , __FILE__ , __FUNCTION__ , __LINE__ , s ); abort(); } +#include "error.h" /* Split size. */ int space_splitsize = space_splitsize_default; diff --git a/src/task.c b/src/task.c index 8ac476043f46a9188bd9b181fa75d768fc8f3aa7..da5eb3190ddf557d42eeecd8ec1c4678686390b6 100644 --- a/src/task.c +++ b/src/task.c @@ -35,14 +35,11 @@ #include "cycle.h" #include "lock.h" #include "task.h" - +#include "error.h" /* Task type names. */ const char *taskID_names[task_type_count] = { "none" , "sort" , "self" , "pair" , "sub" , "ghost" }; -/* Error macro. */ -#define error(s) { fprintf( stderr , "%s:%s:%i: %s\n" , __FILE__ , __FUNCTION__ , __LINE__ , s ); abort(); } - /** * @brief Remove all unlocks to tasks that are of the given type. diff --git a/src/timers.h b/src/timers.h index a2e50a07371f0cccedccd4086b5c06ea03c5a9e7..eb83b6f43a0f95605a507530b42c83abb4551a43 100644 --- a/src/timers.h +++ b/src/timers.h @@ -17,7 +17,7 @@ * ******************************************************************************/ - +#include "inline.h" /* The timers themselves. */ enum { @@ -62,13 +62,6 @@ extern ticks timers[ timer_count ]; #define TIMER_TOC(t) timers_toc( t , tic ) #define TIMER_TIC2 ticks tic2 = getticks(); #define TIMER_TOC2(t) timers_toc( t , tic2 ) - #ifndef INLINE - # if __GNUC__ && !__GNUC_STDC_INLINE__ - # define INLINE extern inline - # else - # define INLINE inline - # endif - #endif INLINE static ticks timers_toc ( int t , ticks tic ) { ticks d = (getticks() - tic); __sync_add_and_fetch( &timers[t] , d );