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 @@
******************************************************************************/
/* 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 )
......@@ -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 );
......
......@@ -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) ) )
......
/*******************************************************************************
* 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 @@
#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.
*
*/
......
......@@ -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
......
......@@ -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 );
......
......@@ -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) ) )
......
......@@ -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 {
......
......@@ -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;
......
......@@ -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.
......
......@@ -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 );
......
Markdown is supported
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