Commit 10014e35 authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Merged some common definitions in two files, error.h and inline.h to avoid duplicates.


Former-commit-id: 6c12d97f251222dda4fc10fea1ef50aca667a52c
parent 9b6ea606
...@@ -18,15 +18,7 @@ ...@@ -18,15 +18,7 @@
******************************************************************************/ ******************************************************************************/
#include "inline.h"
/* Get the inlining right. */
#ifndef INLINE
# if __GNUC__ && !__GNUC_STDC_INLINE__
# define INLINE extern inline
# else
# define INLINE inline
# endif
#endif
#define atomic_add(v,i) __sync_fetch_and_add( v , i ) #define atomic_add(v,i) __sync_fetch_and_add( v , i )
#define atomic_inc(v) atomic_add( v , 1 ) #define atomic_inc(v) atomic_add( v , 1 )
...@@ -35,11 +35,8 @@ ...@@ -35,11 +35,8 @@
#include "task.h" #include "task.h"
#include "part.h" #include "part.h"
#include "cell.h" #include "cell.h"
#include "error.h"
#include "inline.h"
/* Error macro. */
#define error(s) { fprintf( stderr , "%s:%s:%i: %s\n" , __FILE__ , __FUNCTION__ , __LINE__ , s ); abort(); }
/* The timers. */ /* The timers. */
ticks cell_timer[ cell_timer_count ]; ticks cell_timer[ cell_timer_count ];
...@@ -56,13 +53,6 @@ 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_TOC(t) timer_toc( t , tic )
#define TIMER_TIC2 ticks tic2 = getticks(); #define TIMER_TIC2 ticks tic2 = getticks();
#define TIMER_TOC2(t) timer_toc( t , tic2 ) #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 ) { INLINE static ticks timer_toc ( int t , ticks tic ) {
ticks d = (getticks() - tic); ticks d = (getticks() - tic);
__sync_add_and_fetch( &cell_timer[t] , d ); __sync_add_and_fetch( &cell_timer[t] , d );
......
...@@ -46,9 +46,7 @@ ...@@ -46,9 +46,7 @@
#include "engine.h" #include "engine.h"
#include "runner.h" #include "runner.h"
#include "runner_iact.h" #include "runner_iact.h"
#include "error.h"
/* Error macro. */
#define error(s) { fprintf( stderr , "%s:%s:%i: %s\n" , __FILE__ , __FUNCTION__ , __LINE__ , s ); abort(); }
/* Convert cell location to ID. */ /* Convert cell location to ID. */
#define cell_getid( cdim , i , j , k ) ( (int)(k) + (cdim)[2]*( (int)(j) + (cdim)[1]*(int)(i) ) ) #define cell_getid( cdim , i , j , k ) ( (int)(k) + (cdim)[2]*( (int)(j) + (cdim)[1]*(int)(i) ) )
......
/*******************************************************************************
* 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(); }
/*******************************************************************************
* 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
...@@ -37,12 +37,7 @@ ...@@ -37,12 +37,7 @@
#include "part.h" #include "part.h"
#include "space.h" #include "space.h"
#include "engine.h" #include "engine.h"
#include "error.h"
/**
* @brief Error macro
*
*/
#define error(s) { fprintf( stderr , "%s:%s():%i: %s\n" , __FILE__ , __FUNCTION__ , __LINE__ , s ); abort(); }
/** /**
* @brief The different types of data used in the GADGET IC files. * @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 ...@@ -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 * @brief Writes an HDF5 output file (GADGET-3 type) with its XMF descriptor
* *
* @param fileName The file to write. * @param fileName The file to write.
* @param dim The dimension of the volume written to the file. * @param e The engine containing all the system.
* @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.
* *
* Creates the HDF5 file fileName and writess the particles contained * 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. * by the new one.
* *
*
* Calls #error() if an error occurs. * Calls #error() if an error occurs.
* *
*/ */
......
...@@ -19,14 +19,7 @@ ...@@ -19,14 +19,7 @@
/* Get the inlining right. */ #include "inline.h"
#ifndef INLINE
# if __GNUC__ && !__GNUC_STDC_INLINE__
# define INLINE extern inline
# else
# define INLINE inline
# endif
#endif
#ifdef PTHREAD_LOCK #ifdef PTHREAD_LOCK
#define lock_type pthread_spinlock_t #define lock_type pthread_spinlock_t
......
...@@ -37,9 +37,8 @@ ...@@ -37,9 +37,8 @@
#include "task.h" #include "task.h"
#include "cell.h" #include "cell.h"
#include "queue.h" #include "queue.h"
#include "error.h"
/* Error macro. */ #include "inline.h"
#define error(s) { fprintf( stderr , "%s:%s:%i: %s\n" , __FILE__ , __FUNCTION__ , __LINE__ , s ); abort(); }
/* Define the timer macros. */ /* Define the timer macros. */
#ifdef TIMER_VERBOSE #ifdef TIMER_VERBOSE
...@@ -52,13 +51,6 @@ ...@@ -52,13 +51,6 @@
#define TIMER_TOC(t) timer_toc( t , tic ) #define TIMER_TOC(t) timer_toc( t , tic )
#define TIMER_TIC2 ticks tic2 = getticks(); #define TIMER_TIC2 ticks tic2 = getticks();
#define TIMER_TOC2(t) timer_toc( t , tic2 ) #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 ) { INLINE static ticks timer_toc ( int t , ticks tic ) {
ticks d = (getticks() - tic); ticks d = (getticks() - tic);
__sync_add_and_fetch( &queue_timer[t] , d ); __sync_add_and_fetch( &queue_timer[t] , d );
......
...@@ -44,9 +44,7 @@ ...@@ -44,9 +44,7 @@
#include "engine.h" #include "engine.h"
#include "runner.h" #include "runner.h"
#include "runner_iact.h" #include "runner_iact.h"
#include "error.h"
/* Error macro. */
#define error(s) { fprintf( stderr , "%s:%s:%i: %s\n" , __FILE__ , __FUNCTION__ , __LINE__ , s ); abort(); }
/* Convert cell location to ID. */ /* Convert cell location to ID. */
#define cell_getid( cdim , i , j , k ) ( (int)(k) + (cdim)[2]*( (int)(j) + (cdim)[1]*(int)(i) ) ) #define cell_getid( cdim , i , j , k ) ( (int)(k) + (cdim)[2]*( (int)(j) + (cdim)[1]*(int)(i) ) )
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
* *
******************************************************************************/ ******************************************************************************/
#include "inline.h"
/* SID stuff. */ /* SID stuff. */
extern const char runner_flip[]; extern const char runner_flip[];
...@@ -51,15 +52,6 @@ long long int runner_hist_bins[ runner_hist_N ]; ...@@ -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 ) #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. */ /* A struct representing a runner's thread and its data. */
struct runner { struct runner {
......
...@@ -38,9 +38,7 @@ ...@@ -38,9 +38,7 @@
#include "cell.h" #include "cell.h"
#include "space.h" #include "space.h"
#include "runner.h" #include "runner.h"
#include "error.h"
/* Error macro. */
#define error(s) { fprintf( stderr , "%s:%s:%i: %s\n" , __FILE__ , __FUNCTION__ , __LINE__ , s ); abort(); }
/* Split size. */ /* Split size. */
int space_splitsize = space_splitsize_default; int space_splitsize = space_splitsize_default;
......
...@@ -35,14 +35,11 @@ ...@@ -35,14 +35,11 @@
#include "cycle.h" #include "cycle.h"
#include "lock.h" #include "lock.h"
#include "task.h" #include "task.h"
#include "error.h"
/* Task type names. */ /* Task type names. */
const char *taskID_names[task_type_count] = { "none" , "sort" , "self" , "pair" , "sub" , "ghost" }; 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. * @brief Remove all unlocks to tasks that are of the given type.
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
* *
******************************************************************************/ ******************************************************************************/
#include "inline.h"
/* The timers themselves. */ /* The timers themselves. */
enum { enum {
...@@ -62,13 +62,6 @@ extern ticks timers[ timer_count ]; ...@@ -62,13 +62,6 @@ extern ticks timers[ timer_count ];
#define TIMER_TOC(t) timers_toc( t , tic ) #define TIMER_TOC(t) timers_toc( t , tic )
#define TIMER_TIC2 ticks tic2 = getticks(); #define TIMER_TIC2 ticks tic2 = getticks();
#define TIMER_TOC2(t) timers_toc( t , tic2 ) #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 ) { INLINE static ticks timers_toc ( int t , ticks tic ) {
ticks d = (getticks() - tic); ticks d = (getticks() - tic);
__sync_add_and_fetch( &timers[t] , d ); __sync_add_and_fetch( &timers[t] , d );
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment