Imported libSDF into VOID tree

This commit is contained in:
Guilhem Lavaux 2013-02-27 13:27:23 -05:00
parent c6dd08bd7d
commit 2d09cb68df
55 changed files with 12667 additions and 0 deletions

23
external/libsdf/include/libsdf/Assert.h vendored Normal file
View file

@ -0,0 +1,23 @@
/* A drop-in replacement for assert.h, but it calls "error" which */
/* deposits a message in the msgbuf, the terminal, your home answering */
/* machine, and in skywriting at Malibu beach. */
#undef assert
# ifndef NDEBUG
/* Error may be #defined */
#include "error.h"
#ifndef NO_STRINGIFICATION
# define assert(ex) ((void)((ex)?0 :\
((SWError)("Assertion (%s) failed: file \"%s\", line %d\n",\
#ex, __FILE__, __LINE__),0)))
#else
/* Not only do we not have Stringification, but we assume that we have */
/* the brain-damaged macro substitution into "..." */
/* Note that this breaks if the substituted string has " " in it!, e.g.
assert(SDFhasname("x", sdfp));
*/
# define assert(ex) ((void)((ex)?0 : ((SWError)("Assertion (%s) failed: file \"%s\", line %d\n", "ex", __FILE__, __LINE__), 0)))
#endif /* NO_STRINGIFICATION */
# else
# define assert(ex) ((void)0)
# endif

37
external/libsdf/include/libsdf/Malloc.h vendored Normal file
View file

@ -0,0 +1,37 @@
#ifndef _MAlloCDOTh
#define _MAlloCDOTh
#include <stddef.h>
#include "error.h"
#ifdef __cplusplus
extern "C"{
#endif
/* Set the default behavior of the Malloc family when encountering */
/* errors, e.g., NULL returns, etc. */
Error_t MallocHandler(Error_t);
void xFree (void *ptr, const char *file, int lineno);
void *xMalloc (size_t, const char *file, int lineno);
void *xRealloc (void *ptr, size_t, const char *file, int lineno);
void *xCalloc (size_t, size_t, const char *file, int lineno);
/* No extra parens needed ?? */
void Free_f (void *ptr);
void *Malloc_f (size_t);
void *Realloc_f (void *ptr, size_t);
void *Calloc_f (size_t, size_t);
#ifdef __cplusplus
}
#endif
/* Some pre-processors are so stupid that they will convert
foo(Realloc);
into
foo(xRealloc(,,__FILE__, __LINE__));
Thus, we can't use Realloc as function name.
*/
#define Free(p) xFree(p, __FILE__, __LINE__)
#define Malloc(n) xMalloc(n, __FILE__, __LINE__)
#define Calloc(n,s) xCalloc(n, s, __FILE__, __LINE__)
#define Realloc(p, n) xRealloc(p, n, __FILE__, __LINE__)
#endif /* _MAllocDOTh */

88
external/libsdf/include/libsdf/Msgs.h vendored Normal file
View file

@ -0,0 +1,88 @@
/* Declarations for the functions defined in Msgs.c */
#ifndef MsgsDOTh
#define MsgsDOTh
#include <stdarg.h>
#include "gccextensions.h"
/* These two typedefs simplify the task of casting function ptrs */
/* to the appropriate type when calling Msg_addfile */
typedef int (*Msgvfprintf_t)(void *, const char *, va_list);
typedef int (*Msgfflush_t)(void *);
#ifdef __cplusplus
extern "C" {
#endif
/* The fflush_like function pointer MUST BE ASYNCHRONOUSLY CALLABLE */
/* If you don't have one, don't worry. Pass NULL instead. */
int Msg_addfile(void *fp, /* add fp to the list of msg files */
int (*vfprintf_like)(void *, const char *, va_list),
int (*fflush_like)(void *));
int Msg_delfile(void *fp); /* fp should no longer receive msgs */
int Msg_on(const char *); /* turn on a specific type of msgs */
int Msg_off(const char *); /* turn off a specific type of msgs */
/* Normally, you should use the Msg_test macro instead. */
int _Msg_test(const char *); /* is a specific type on or off? */
int Msg_set_enable(int); /* enable (1) or disable (0) all message */
/* return the previous state. */
void Msg_turnon(const char *msg_turn_on); /* an interface to Msg_on */
/* that calls Msg_on for every file */
/* in a comma-whitespace delimited list */
/* of names. If a name is specified as */
/* NAME:lo-hi or NAME:procnum, then */
/* messages are on only in the corresponding */
/* processors. If the string is "nomsgs", */
/* then msgs are totally disabled. */
void MsgdirInit(const char *path); /* tries to do a mkdir and open */
/* msg files for each process */
int Msg_do(const char *fmt, ...) /* Unconditionally say something. */
__attribute__ ((format (printf, 1, 2))) ; /* it's printf-like! */
int Msg_doalist(const char *fmt, va_list)
/* this is broken in gcc2.4.0 through 2.4.4 */
#ifndef BROKEN_GCC_FORMAT_ATTRIBUTE
__attribute__ ((format (printf, 1, 0)))
#endif
;
int Msg_flush(void); /* flush all the buffers now. */
int Msg_flushalways(int newval);/* flush buffers after every Msg_do.
return the previous value.*/
#ifdef __cplusplus
}
#endif
/* Don't use these! _Msg_enabled */
extern int _Msg_enabled;
/* Msg is called with an extra set of parentheses, to hide */
/* the variadic arguments, e.g.
Msg("foo", ("Hello world this is a \"foo\" message\n"));
or
Msg(__FILE__, ("Hello from file: %s, line: %d\n", __FILE__, __LINE__));
The macro 'Msgf' is a shorthand for the Msg(__FILE__, ...) construction.
The macro 'Msglno' is a shorthand for:
Msg(name, "%s(%d):" <fmt> , __FILE__, __LINE__, <otherargs>);
The macro 'Msgfunc' is a shorthand for Msg(__FUNCTION__, ...).
Thus, you can turn on messaging at the function level.
*/
#define Msglno(name, args) Msg(name, ("%s(%d): ", __FILE__, __LINE__)),Msg(name, args)
#define Msgf(args) Msg(__FILE__, args)
#define Msglnof(args) Msglno(__FILE__, args)
#ifdef __FUNCTION__
#define Msgfunc(args) Msg(__FUNCTION__, args)
#else
#define Msgfunc(args)
#endif
#ifndef NO_MSGS
#define Msg_test(name) (_Msg_enabled && _Msg_test(name))
#define Msg(name, args) ((void)((Msg_test(name))? Msg_do args : 0 ))
#else
#define Msg_test(name) (0)
#define Msg(name, args) ((void)0)
#endif
#endif /* MsgsDOTh */

165
external/libsdf/include/libsdf/SDF.h vendored Normal file
View file

@ -0,0 +1,165 @@
/*
SDF Library for reading Self-Describing Files
Copyright (C) 1991,1992 John K. Salmon
Terms and conditions are specified in the file "copyright.h",
and more precisely in the file COPYING.LIB which you should have
received with this library.
*/
#ifndef sdfDOTh
#define sdfDOTh
#include <stdarg.h>
#include <sys/types.h>
#define SDF_SEEK_SET 0
#define SDF_SEEK_CUR 1
#define SDF_SEEK_END 2
#define SDF_SYNC 0
#define SDF_ASYNC 1
#define SDF_SINGL 0
#define SDF_MULTI 1
#ifndef INT64_MAX
#if __WORDSIZE==64
#define INT64_MAX LONG_MAX
#else
/* #define INT64_MAX LLONG_MAX Why doesn't this work? */
#define INT64_MAX 9223372036854775807LL
#endif
#endif
#ifndef sdfprivateDOTh
/* It isn't really this, but I don't want to tell you what it is. */
/* If you believe it's this, then your compiler can check prototypes */
/* for you. */
typedef char *SDF[32];
/* Identical to declaration in SDF-private.h */
enum SDF_type_enum{SDF_NOTYPE,
SDF_CHAR,
SDF_SHORT,
SDF_INT,
SDF_LONG,
SDF_INT64,
SDF_FLOAT,
SDF_DOUBLE,
SDF_STRING};
#endif
/* Provided for backwards compatibility. Not recommended! */
#ifdef SDF_OLD_ENUM_NAMES
#define CHAR SDF_CHAR
#define SHORT SDF_SHORT
#define INT SDF_INT
#define FLOAT SDF_FLOAT
#define DOUBLE SDF_DOUBLE
#define STRING SDF_STRING
#endif
#ifdef __cplusplus
extern "C" {
#endif
/* Two arrays indexed by a type_enum */
extern char *SDFtype_names[];
extern int SDFtype_sizes[];
extern char SDFerrstring[];
int SDFissdf(const char *filename); /* Not guaranteed correct! */
SDF *SDFopen(const char *hdrfname, const char *datafname);
int SDFseekable(SDF *hdr); /* are non-sequential reads allowed? */
int SDFclose(SDF *hdr);
int SDFnvecs(SDF *hdr);
int SDFhasname(const char *name, SDF *hdr);
char **SDFvecnames(SDF *hdr);
int64_t SDFnrecs(const char *name, SDF *hdr);
int SDFarrcnt(const char *name, SDF *hdr);
enum SDF_type_enum SDFtype(const char *name, SDF *hdr);
int SDFseek(const char *name, int64_t offset, int whence, SDF *hdr);
int SDFtell(const char *name, SDF *hdr);
unsigned int SDFcpubyteorder(void);
unsigned int SDFbyteorder(SDF *hdr);
int SDFswap(SDF *hdr);
int SDFnoswap(SDF *hdr);
int SDFisswapping(SDF *hdr);
int SDFsetmaxbufsz(int new_size);
int SDFrdvecs(SDF *hdr, ...
/* char *name, int n, void *address, int stride,
... ,
NULL */ );
int SDFrdvecsv(SDF *hdr, va_list ap);
/* Where is the const supposed to go? */
int SDFrdvecsarr(SDF *hdr, int nreq,
char **names, int *ns, void **addresses, int *strides);
int SDFseekrdvecs(SDF *hdr, ...
/* char *name, int start, int n, void *addr, int stride,
... ,
NULL */ );
int SDFseekrdvecsv(SDF *hdr, va_list ap);
int SDFseekrdvecsarr(SDF *hdr, int nreq,
char **names, int64_t *starts, int *ns, void **addresses, int *strides);
void SDFsetiomode(int mode);
/* These two subvert the SDF "abstraction" and tell you about */
/* the actual layout of the file. Are you absolutely sure you need */
/* to call these? */
int64_t SDFfileoffset(const char *name, SDF *hdr);
int64_t SDFfilestride(const char *name, SDF *hdr);
/* These four are harder to write than one might guess. */
/* They're in the library to avoid duplicating code. */
int SDFgetint(SDF *sdfp, char *name, int *value);
int SDFgetint64(SDF *sdfp, char *name, int64_t *value);
int SDFgetfloat(SDF *sdfp, char *name, float *value);
int SDFgetdouble(SDF *sdfp, char *name, double *value);
int SDFgetstring(SDF *sdfp, const char *name, char *string, int size);
#ifdef __cplusplus
}
#endif
/* four macros that call SDFget and bail out if the value isn't there */
#define SDFgetintOrDie(sdfp, name, value) \
do{ if( SDFgetint(sdfp, name, value) ) \
Error("SDFgetint(\"%s\") failed\n", name); } while(0)
#define SDFgetint64OrDie(sdfp, name, value) \
do{ if( SDFgetint64(sdfp, name, value) ) \
Error("SDFgetint64(\"%s\") failed\n", name); } while(0)
#define SDFgetfloatOrDie(sdfp, name, value) \
do{ if( SDFgetfloat(sdfp, name, value) ) \
Error("SDFgetfloat(\"%s\") failed\n", name); } while(0)
#define SDFgetdoubleOrDie(sdfp, name, value) \
do{ if( SDFgetdouble(sdfp, name, value) ) \
Error("SDFgetdouble(\"%s\") failed\n", name); } while(0)
#define SDFgetstringOrDie(sdfp, name, string, size) \
do{ if( SDFgetstring(sdfp, name, string, size) ) \
Error("SDFgetstring(\"%s\") failed", name); } while(0)
/* And four more that use a default if the value isn't there */
#define SDFgetintOrDefault(sdfp, name, value, def) \
do{ if( SDFgetint(sdfp, name, value) ){ \
*value = def;}} while(0)
#define SDFgetint64OrDefault(sdfp, name, value, def) \
do{ if( SDFgetint64(sdfp, name, value) ){ \
*value = def;}} while(0)
#define SDFgetfloatOrDefault(sdfp, name, value, def) \
do{ if( SDFgetfloat(sdfp, name, value) ){ \
*value = def;} } while(0)
#define SDFgetdoubleOrDefault(sdfp, name, value, def) \
do{ if( SDFgetdouble(sdfp, name, value) ){ \
*value = def;} } while(0)
#define SDFgetstringOrDefault(sdfp, name, value, size, def) \
do{ if( SDFgetstring(sdfp, name, value, size) ){ \
strncpy(value, def, size);} } while(0)
#endif /* sdfDOTh */

View file

@ -0,0 +1,39 @@
#ifndef _RdDataDOTh
#define _RdDataDOTh
#include "timers.h"
#include "SDF.h"
/* Can read distributed datafiles if csdfp contains something like:
struct {char datafiles[64];}[4] = {"foo1", "foo2", "foo3", "foo4"};
*/
#ifdef __cplusplus
extern "C" {
#endif
extern Timer_t SDFreadTm;
/* By default, SDFread will look for a "char datafile[]" in csdfp and
read data from there. The name of the variable to look for is
stored in this variable. I.e., it defaults to "datafile". Set it
to NULL to turn this feature off altogether. */
extern char *SDFread_datafile;
/* Do the same thing with "hdrfile" */
extern char *SDFread_hdrfile;
/* Also by default, SDFread will look for a variable "int npart" in csdfp
and attempt to read that many "particles" from datafile. This variable
storest the name of that variable. Default: "npart"; */
extern char *SDFread_npart;
SDF *SDFread(SDF *csdfp, void **btabp, int *gnobjp, int *nobjp, int stride,
/* char *name, offset_t offset, int *confirm */...);
SDF *SDFread64(SDF *csdfp, void **btabp, int64_t *gnobjp, int *nobjp, int stride,
/* char *name, offset_t offset, int *confirm */...);
SDF *SDFreadf(char *hdr, char *name, void **btabp, int *gnobjp, int *nobjp,
int stride, /* char *name, offset_t offset, int *confirm */...);
SDF *SDFreadf64(char *hdr, char *name, void **btabp, int64_t *gnobjp, int *nobjp,
int stride, /* char *name, offset_t offset, int *confirm */...);
#ifdef __cplusplus
}
#endif
#endif

View file

@ -0,0 +1,28 @@
#ifndef _SDFWriteDOTh
#define _SDFWRiteDOTh
#ifdef __cplusplus
extern "C" {
#endif
void SDFwrite(const char *filename, int gnobj, int nobj, const void *btab,
int bsize, const char *bodydesc,
/* const char *name, SDF_type_enum type, <type> val */ ...);
void SDFwrite64(const char *filename, int64_t gnobj, int64_t nobj, const void *btab,
int bsize, const char *bodydesc,
/* const char *name, SDF_type_enum type, <type> val */ ...);
void SDFappend64(const char *filename, int64_t gnobj, int64_t nobj, const void *btab,
int bsize, const char *bodydesc,
/* const char *name, SDF_type_enum type, <type> val */ ...);
/* A trivial special case, just don't write any body data */
void SDFwritehdr(const char *filename, const char *bodydesc,
/* const char *name, SDF_type_enum type, <type> val */ ...);
void SDFunsetwroteheader(void);
void SDFsetwroteheader(void);
#ifdef __cplusplus
}
#endif
#endif

View file

@ -0,0 +1,21 @@
#ifndef _ByteSwapDOTh
#define _ByteSwapDOTh
/* A general, in-place, byte-swapper. */
/* It swaps a total of unit_len*n_units bytes, unit_len bytes at a time. */
/* Thus, you can use it for arrays of doubles with unit_len=8, or */
/* arrays of chars with unit_len=1 (which is equivalent to memcpy). */
/* It checks for stupid arguments. It works fine when */
/* from and to are identical. It breaks if from and to are */
/* almost the same. */
#ifdef __cplusplus
extern "C" {
#endif
int Byteswap(int unit_len, int n_units, void *from, void *to);
#ifdef __cplusplus
}
#endif
/* It would probalby be worthwhile to inline these! */
#endif

141
external/libsdf/include/libsdf/chn.h vendored Normal file
View file

@ -0,0 +1,141 @@
#ifndef chnDOTh
#define chnDOTh
#include <stddef.h>
/*
CHN.C: Routines for allocating and freeing memory
in fixed length blocks. CHN is mnemonic for either 'chain' or 'chunk'.
The idea is that malloc is called infrequently to get large chunks
which are broken down into smaller pieces which are chained together
to make a freelist. ChnAlloc and ChnFree are very fast O(1), and
use memory efficiently even for small objects. In contrast,
malloc and free are often slow and typically waste several bytes per
allocated object. The down side is that fragmentation problems can be
magnified. Once a large chunk is allocated it never gets freed, even
if all the objects in it have been freed.
Entry points:
void ChnInit(Chn *id, int sz, int nalloc,
void *(realloc_like)(void *, size_t));
void *ChnAlloc(Chn *id);
void ChnFree(Chn *id, Void *p);
void ChnFreeAll(Chn *id);
void ChnTerminate(Chn *id);
int ChnCheck(Chn *id);
int ChnFreeCnt(Chn *id);
int ChnAllocCnt(Chn *id);
It wouldn't be hard to write "ChnCrunch" which would look for chunks
that have been completely freed, and return them to the system. This
has limited utility, but it might be handy when running near the edge
of memory.
For diagnostic purposes, use ChnFreeCnt to get the length of the current
freelist. Note that more space will be dynamically allocated, so this
is NOT an upper limit. ChnAllocCnt is the count of how many chunks
are currently allocated.
*/
typedef struct {
int sz;
int nalloc;
void *free_list;
void *first_chunk;
int free_cnt;
int nmalloced; /* diagnostic purposes only */
int tbl_sz;
void *(*realloc_like)(void *, size_t);
} Chn;
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
extern int ChnMoreMem(Chn *id);
extern void ChnInit(Chn *new, int sz, int nalloc,
void *(*realloc_like)(void *, size_t));
extern void ChnTerminate(Chn *id);
extern void ChnFreeAll(Chn *id);
extern int ChnCheck(Chn *id);
#if !(__STDC_VERSION__ >= 199901L)
extern void *ChnAlloc(Chn *id);
extern void ChnFree(Chn *id, void *p);
extern int ChnFreeCnt(Chn *id);
extern int ChnAllocCnt(Chn *id);
extern size_t ChnUnitSz(Chn *id);
#endif
#ifdef __cplusplus
}
#endif /* __cplusplus */
#if (defined(__GNUC__) || defined(__ICC__)) || defined(CHNdotC)
#undef INLINE
#if (__STDC_VERSION__ >= 199901L) && !defined (CHNdotC)
#define INLINE inline
#else
#if (defined (__GNUC__) || defined(__ICC__)) && !defined (CHNdotC)
#define INLINE extern __inline__
#else
#define INLINE
#endif
#endif
#if defined(ChnNext) || defined(ChnMagic) || defined(ChnMAGIC)
# error define conflict in __FILE__
#endif
#define ChnNext(x) (*(void**)(x))
#define ChnMagic(x) (*(int *)((void**)x+1))
#define ChnMAGIC 0x82345078
#ifndef assert
#include "Assert.h"
#endif
INLINE void *ChnAlloc(Chn *id)
{
void *c;
if (id->free_cnt <= 0) {
if(ChnMoreMem(id))
return 0;
}
c = id->free_list;
assert(c);
assert(ChnMagic(c) == ChnMAGIC);
id->free_cnt--;
id->free_list = ChnNext(c);
return (c);
}
INLINE void ChnFree(Chn *id, void *p)
{
/* This assertion can give a false-error reading if the "user" */
/* has stored the exact value ChnMAGIC in the right location. */
/* assert(ChnMagic(p) != ChnMAGIC); */
ChnNext(p) = id->free_list;
ChnMagic(p) = ChnMAGIC;
id->free_list = p;
id->free_cnt++;
}
INLINE int ChnFreeCnt(Chn *id){
return id->free_cnt;
}
INLINE int ChnAllocCnt(Chn *id){
return id->nmalloced - id->free_cnt;
}
INLINE size_t ChnUnitSz(Chn *id){
return id->sz;
}
#ifndef CHNdotC
#undef ChnNext
#undef ChnMagic
#undef ChnMAGIC
#endif
#undef INLINE
#endif /* __GNUC__ || CHNdotC */
#endif

113
external/libsdf/include/libsdf/cosmo.h vendored Normal file
View file

@ -0,0 +1,113 @@
/* Hide the cosmological parameters in here.
Keep them self-consistent... */
struct cosmo_s {
double t;
double a;
double H0;
double Omega0;
double Omega_m;
double Omega_r;
double Omega_de;
double w0;
double wa;
double Lambda;
double Gnewt;
double Zel_f;/* the 'f' factor for linearly growing modes */
};
/* new struct for CLASS interface */
/* some names have changed definition (Omega_m/Omega_r not constants now) */
typedef struct cosmology {
double z;
double t;
double tau;
double a;
double H;
double Omega_m;
double Omega_r;
double conf_distance;
double kick; /* union with tau? */
double drift;
double growthfac;
double velfac;
double velfac2;
/* constants */
double h_100;
double H0;
double Omega0; /* m+r+lambda+fld */
double Omega0_m; /* cdm+b+ur+some ncdm */
double Omega0_r; /* g+ur+rest of ncdm */
double Omega0_lambda;
double Omega0_cdm;
double Omega0_ncdm_tot;
double Omega0_b;
double Omega0_g;
double Omega0_ur;
double Omega0_fld;
double w0_fld;
double wa_fld;
double Gnewt;
double age;
void *reserved;
void (*background_at_z)(struct cosmology *c, double z);
void (*background_at_t)(struct cosmology *c, double t);
void (*background_at_tau)(struct cosmology *c, double tau);
double (*t_at_z)(struct cosmology *c, double z);
double (*z_at_t)(struct cosmology *c, double t);
double (*a_at_t)(struct cosmology *c, double t);
double (*t_at_a)(struct cosmology *c, double a);
double (*H_at_z)(struct cosmology *c, double z);
double (*H_at_t)(struct cosmology *c, double t);
double (*conformal_distance_at_z)(struct cosmology *c, double z);
double (*conformal_distance_at_t)(struct cosmology *c, double t);
double (*angular_diameter_distance_at_z)(struct cosmology *c, double z);
double (*angular_diameter_distance_at_t)(struct cosmology *c, double t);
double (*luminosity_distance_at_z)(struct cosmology *c, double z);
double (*luminosity_distance_at_t)(struct cosmology *c, double t);
double (*growthfac_at_z)(struct cosmology *c, double z);
double (*growthfac_at_t)(struct cosmology *c, double t);
double (*velfac_at_z)(struct cosmology *c, double z);
double (*velfac_at_t)(struct cosmology *c, double t);
double (*kick_t0_t1)(struct cosmology *c, double t0, double t1);
double (*drift_t0_t1)(struct cosmology *c, double t0, double t1);
void (*free)(struct cosmology *c);
} cosmology;
void class_init(cosmology *c, char *class_ini, char *class_pre, double zmax);
void class_params(cosmology *c, char *class_ini);
void tbl_init(cosmology *c, char *tbl);
double Anow(struct cosmo_s *c, double time);
double Znow(struct cosmo_s *c, double time);
double Hnow(struct cosmo_s *c, double time);
double growthfac_from_Z(struct cosmo_s *c, double z);
double velfac_from_Z(struct cosmo_s *c, double z);
double velfac_approx_from_Z(struct cosmo_s *c, double z);
double t_from_Z(struct cosmo_s *c, double z);
double comoving_distance_from_Z(struct cosmo_s *c, double z);
double dp_from_Z(struct cosmo_s *c, double z);
double hubble_from_Z(struct cosmo_s *c, double z);
double kick_delta(struct cosmo_s *c, double t0, double t1);
double drift_delta(struct cosmo_s *c, double t0, double t1);
void CosmoPush(struct cosmo_s *c, double time);
#define one_kpc 3.08567802e16 /* km */
#define one_Gyr 3.1558149984e16 /* sec */
#define cm_kpc 3.08567802e21
#define sec_Gyr 3.1558149984e16
#define g_Msol 1.98892e33
#define g_Msol10 1.98892e43 /* 10^10 Msol */
/* http://physics.nist.gov/cgi-bin/cuu/Value?bg|search_for=G */
/* #define G_cgs (6.67384e-8) cm3 g-1 s-2 */
#define G_cgs (6.67259e-8)
#define speed_of_light (299792.458) /* km/sec */
/* Gaussian Gravitational Constant */
#define k_cgs 0.01720209895
#define GM_cgs 1.32712442099e26
/* GM_cgs*sec_Gyr*sec_Gyr/cm_kpc*cm_kpc*cm_kpc */
#define GNEWT 44986.564

69
external/libsdf/include/libsdf/error.h vendored Normal file
View file

@ -0,0 +1,69 @@
#ifndef _ErrorDOTh
#define _ErrorDOTh
#include <stdarg.h>
#include "gccextensions.h"
/* Define an Error_t to describe error-like functions. */
typedef void (*Error_t)(const char *, ...);
#ifdef __cplusplus
extern "C"{
#endif /* __cplusplus */
void SWError(const char *, ...)
/* noreturn only works in 2.5 or higher */
#if (__GNUC_MINOR__>=5 && __GNUC__==2)||__GNUC__>2
__attribute__ ((format (printf, 1, 2),noreturn));
#else
__attribute__ ((format (printf, 1, 2)));
#endif
void vError(const char *, va_list)
/* noreturn only works in 2.5 or higher */
#if (__GNUC_MINOR__>=5 && __GNUC__==2)||__GNUC__>2
__attribute__ ((format (printf, 1, 0),noreturn));
#else
;
#endif
void SinglError(const char *, ...)
/* noreturn only works in 2.5 or higher */
#if (__GNUC_MINOR__>=5 && __GNUC__==2)||__GNUC__>2
__attribute__ ((format (printf, 1, 2),noreturn));
#else
__attribute__ ((format (printf, 1, 2)));
#endif
void Warning(const char *, ...)
__attribute__ ((format (printf, 1, 2)));
void SinglWarning(const char *, ...)
__attribute__ ((format (printf, 1, 2)));
void SeriousWarning(const char *, ...)
__attribute__ ((format (printf, 1, 2)));
void Shout(const char *mesg, ...)
__attribute__ ((format (printf, 1, 2)));
void SinglShout(const char *mesg, ...)
__attribute__ ((format (printf, 1, 2)));
#ifdef __cplusplus
}
#endif /* __cplusplus */
#if __GNUC__>1 /* Actually, only 2.4 or higher? */
/* We have varargs macros! */
#define Error(format, args...) \
(SWError)("%s (%d) in %s :\n" format, __FILE__, __LINE__, __FUNCTION__, ##args)
#define SinglError(format, args...) \
(SinglError)("%s (%d) in %s :\n" format, __FILE__, __LINE__, __FUNCTION__, ##args)
#define Warning(format, args...) \
(Warning)("%s (%d) in %s :\n" format, __FILE__, __LINE__, __FUNCTION__, ##args)
#define SinglWarning(format, args...) \
(SinglWarning)("%s (%d) in %s :\n" format, __FILE__, __LINE__, __FUNCTION__, ##args)
#define SeriousWarning(format, args...) \
(SeriousWarning)("%s (%d) in %s :\n" format, __FILE__, __LINE__, __FUNCTION__, ##args)
#else /* No wacky GNUC varargs stuff...*/
/* This prevents namespace collisions when linking SDF into perl5! (really!) */
#define Error SWError
#endif
#endif /* _ErrorDOTh */

View file

@ -0,0 +1,34 @@
#ifndef _GccExtensionsDOTh
#define _GccExtensionsDOTh
/* this is broken in gcc2.4.0 through 2.4.4 */
#if __GNUC__<2 || (__GNUC__== 2 && __GNUC_MINOR__<=4)
#define BROKEN_GCC_FORMAT_ATTRIBUTE
#endif
/* This isn't an entirely perfect way to deal with functions that
don't return because sometimes we want more than one __attribute__.
See, for example, the code in error.h and mpmy_abnormal.h */
#if (__GNUC_MINOR__>=5 && __GNUC__==2)||__GNUC__>2
#define __NORETURN__ __attribute__ ((noreturn))
#else
#define __NORETURN__
#endif
#undef __attribute__
#if !defined(__GNUC__) || defined(printf) || defined(scanf)
#define __attribute__(x)
#endif /* __GNUC__ */
/* NoInline can be used to prevent inlining of function calls at the */
/* calling location. I.e., NoInline(func)(arg) instead of func(arg) */
/* We leave everything alone if we're not optimizing because there */
/* are no inlines in that case anyway. */
#if defined(__GNUC__) && defined(__OPTIMIZE__)
#define NoInline(f) ({typeof(f) *fp = &f; *fp;})
#else
#define NoInline(f) f
#endif
#endif

View file

@ -0,0 +1,15 @@
#ifndef _MemfilEdotH
#define _MemfilEdotH
#ifdef __cplusplus
extern "C"{
#endif
void memfile_init(int sz) ;
void memfile_delete(void) ;
void memfile_vfprintf(void *junk, const char *fmt, va_list args) ;
void PrintMemfile(void);
#ifdef __cplusplus
}
#endif
#endif

164
external/libsdf/include/libsdf/mpmy.h vendored Normal file
View file

@ -0,0 +1,164 @@
#ifndef _MpMYdotH
#define _MpMYdotH
#include "timers.h"
typedef void *MPMY_Comm_request;
typedef struct {
int tag;
int src;
int count;
}MPMY_Status;
#define MPMY_SUCCESS (0)
#define MPMY_FAILED (1)
/* This corresponds to the ANY-source in udp.c. */
/* What about other PAROS??? */
#define MPMY_SOURCE_ANY -2
#define MPMY_TAG_ANY -1
/* Data types and operations supported in MPMY_Combine */
typedef enum {
MPMY_SUM, MPMY_PROD, MPMY_MAX, MPMY_MIN, MPMY_BAND, MPMY_BOR, MPMY_BXOR
} MPMY_Op;
typedef void (*MPMY_user_comb_func)(const void *from1, const void *from2,
void *to);
typedef enum {
MPMY_FLOAT, MPMY_DOUBLE, MPMY_INT, MPMY_CHAR, MPMY_SHORT, MPMY_LONG,
MPMY_UNSIGNED_INT, MPMY_UNSIGNED_CHAR, MPMY_UNSIGNED_SHORT,
MPMY_UNSIGNED_LONG, MPMY_OFFT, MPMY_INT64, MPMY_USER_DATA
} MPMY_Datatype;
extern unsigned int MPMY_Datasize[];
#ifdef __cplusplus
extern "C"{
#endif /* __cplusplus */
/* Reduction prototypes */
int MPMY_Combine(const void *sendbuf, void *recvbuf, const int count,
const MPMY_Datatype datatype, const MPMY_Op op);
int MPMY_ICombine_Init(MPMY_Comm_request *reqp);
int MPMY_ICombine_Wait(MPMY_Comm_request req);
int MPMY_ICombine(const void *sendbuf, void *recvbuf, int count,
MPMY_Datatype datatype, MPMY_Op op,
MPMY_Comm_request req);
/* A separate entry point for the user-specified-function version */
int MPMY_ICombine_func(const void *sendbuf, void *recvbuf, int size,
MPMY_user_comb_func func,
MPMY_Comm_request req);
int MPMY_AllGather(const void *sndbuf, int count, MPMY_Datatype type,
void *rcvbuf);
int MPMY_Gather(const void *sendbuf, int count, MPMY_Datatype type,
void *recvbuf, int recvproc);
int MPMY_NGather(const void *sendbuf, int count, MPMY_Datatype type,
void **recvhndl, int recvproc);
int MPMY_Bcast(void *buf, int count, MPMY_Datatype type, int sendproc);
int MPMY_BcastTag(void *buf, int count, MPMY_Datatype type, int sendproc, int Tag0);
int MPMY_Alltoall(void *sendbuf, int sendcount, MPMY_Datatype sendtype,
void *recvbuf, int recvcount, MPMY_Datatype recvtype);
int MPMY_Alltoallv(void *sendbuf, int *sendcounts, int *sendoffsets, MPMY_Datatype sendtype,
void *recvbuf, int *recvcounts, int *recvoffsets, MPMY_Datatype recvtype);
int Native_MPMY_Allgather(void *sendbuf, int sendcount, MPMY_Datatype type, void *recvbuf);
int Native_MPMY_Allgatherv(void *sendbuf, int sendcount, MPMY_Datatype type, void *recvbuf,
int *rcounts, int *roffsets);
int Native_MPMY_Alltoall(void *sendbuf, int sendcount, MPMY_Datatype sendtype,
void *recvbuf, int recvcount, MPMY_Datatype recvtype);
int Native_MPMY_Alltoallv(void *sendbuf, int *sendcounts, int *sendoffsets, MPMY_Datatype sendtype,
void *recvbuf, int *recvcounts, int *recvoffsets, MPMY_Datatype recvtype);
/*
A NULL stat argument is allowed, indicating that you aren't interested in
the status.
*/
int MPMY_Init(int *argcp, char ***argvp);
int MPMY_Isend(const void *buf, int cnt, int dest, int tag, MPMY_Comm_request *req);
int MPMY_Irsend(const void *buf, int cnt, int dest, int tag, MPMY_Comm_request *req);
int MPMY_Irecv(void *buf, int cnt, int src, int tag, MPMY_Comm_request *req);
int MPMY_Test(MPMY_Comm_request request, int *flag, MPMY_Status *stat);
int MPMY_Wait(MPMY_Comm_request request, MPMY_Status *stat);
/* I don't know how to write the general WaitN, but we seem to use Wait2
often enough that it's worth providing in the library. Note that this
waits for BOTH. Not EITHER. */
int MPMY_Wait2(MPMY_Comm_request req1, MPMY_Status *stat1,
MPMY_Comm_request req2, MPMY_Status *stat2);
/* send with wait */
void MPMY_send(const void *buf, int cnt, int dest, int tag);
/* Blocking recv of exactly cnt bytes */
void MPMY_recvn(void *buf, int cnt, int src, int tag);
int MPMY_Finalize(void);
/* These are occasionally useful and seem to be highly system-dependent */
int MPMY_Sync(void);
int MPMY_Flick(void);
/* Desperate times require desperate measures... (c.f. malloc_print)
Consider using Msg_do or Shout as the argument. Note that, despite
the name, they aren't strictly printf-identical because they don't
return an int. C'est la vie. */
void MPMY_Diagnostic(int (*printflike)(const char *, ...));
/* And a version suitable for passing to OnAbnormal */
void PrintMPMYDiags(void);
/* These don't really have analogues in mpi. MPI does have Sendrecv
and Sendrecv_replace, but those are both more general (allowing
different sources and destinations, allowing tags, allowing *_ANY)
and less general ('replace' instead of 'overlap').
*/
int MPMY_Shift(int proc, void *recvbuf, int recvcnt,
const void *sendbuf, int sendcnt, MPMY_Status *stat);
int MPMY_Shift_overlap(int proc, void *recvbuf, int recvcnt,
const void *sendbuf, int sendcnt, MPMY_Status *stat);
/* In MPI, they actually give you the name of the field element. For backward
compatibility, I'll also give them as macros */
#define MPMY_SOURCE src
#define MPMY_TAG tag
#define MPMY_Source(stat) ((stat)->src)
#define MPMY_Tag(stat) ((stat)->tag)
/* In MPI, this is still a function because it has to deal with typing.
We don't worry about typing... */
#define MPMY_COUNT count
#define MPMY_Count(stat) ((stat)->count)
int MPMY_Nproc(void);
int MPMY_Procnum(void);
/* Returns a pointer to a static char string describing the phys node. */
const char *MPMY_Physnode(void);
/* We call these an awful lot. Let's just set them up in init and
save a function-call */
extern int _MPMY_nproc_;
extern int _MPMY_procnum_;
extern int _MPMY_procs_per_node_;
#define MPMY_Nproc() (_MPMY_nproc_)
#define MPMY_Procnum() (_MPMY_procnum_)
#define MPMY_ProcsPerNode() (_MPMY_procs_per_node_)
/* How can a "subsystem" like SDF know if MPMY has been initialized? */
extern int MPMY_Initialized(void);
extern int _MPMY_initialized_; /* internal use only! */
/* Counters for the number of Isends, Irecvs and (successful Tests + Waits) */
extern Counter_t MPMYSendCnt;
extern Counter_t MPMYRecvCnt;
extern Counter_t MPMYDoneCnt;
void MPMY_CheckpointSetup(int job_seconds, int interval_seconds, int step_seconds);
int MPMY_CheckpointDue(int next_output_seconds);
void MPMY_CheckpointFinished(void);
int MPMY_JobDone(void);
int MPMY_JobRemaining(void);
#ifdef __cplusplus
}
#endif /* __cplusplus */
/* INTERNAL USE ONLY!! */
#endif

View file

@ -0,0 +1,71 @@
#ifndef _MPMYAbnormalDOTh_
#define _MPMYAbnormalDOTh_
#include "gccextensions.h"
/* Abhndlrs are void functions of void. Use them as arguments to
MPMY_OnAbnormal. */
typedef void (*Abhndlr)(void);
#ifdef __cplusplus
extern "C"{
#endif
/* MPMY_Abort will execute MPMY_RaiseAbnormal(SIGABRT) and then call
MPMY_SystemAbort. Don't be surprised if the OnAbnormal functions
themselves call MPMY_SystemAbort first, though. */
void MPMY_Abort(void) __NORETURN__;
extern int MPMY_Abnormal_signum;
extern int MPMY_stop_abnormal_processing;
void MPMY_RaiseAbnormal(int sig); /* fake a signal of type 'sig' */
/* Push a handler to the stack that will be executed on abnormal termination.
Some useful arguments to consider are:
malloc_print();
PrintMemfile();
Msg_flush();
MPMY_abchdir(); (with MPMY_abchdir_arg set beforehand)
MPMY_SystemAbort();
MPMY_SystemExit(); (with MPMY_exit_arg set beforehand)
They are called in the reverse chronological order from the order that
they were requested by MPMY_OnAbnormal, so later functions
might 'override' earlier ones. This isn't perfect, but it's better than
the monolithic handler we had before. The handler can
find out which signal is being handled by looking at
int MPMY_current_signal ;
As a final twist, it is possible to bail out of the stack and just
return from the handler immediately by setting:
int MPMY_stop_abnormal_processing;
to non-zero.
*/
void MPMY_OnAbnormal(Abhndlr hndlr);
/* Really, truly, abort(). Now! */
void MPMY_SystemAbort(void) __NORETURN__;
/* Really, truly, exit(MPMY_exit_arg). Now! */
extern int MPMY_exit_arg;
void MPMY_SystemExit(void) __NORETURN__; /* An Abhndlr */
/* Do a mkdir/chdir to the directory named by MPMY_abchdir_arg.
This can be extremely useful before dumping core... */
extern char MPMY_Abchdir_arg[];
void MPMY_Abchdir(void); /* An Abhndlr */
/* Announce (Shout) that we are handling a signal. Try not to repeat
yourself if it's been said already... */
void MPMY_Abannounce(void);
/* Arrange to crash and burn if n seconds elapse before Reset is called */
void MPMY_TimeoutSet(int n);
void MPMY_TimeoutReset(int n);
void MPMY_TimeoutCancel(void);
/* Not for public use. */
void _MPMY_setup_absigs(void);
#ifdef __cplusplus
}
#endif
#endif /* _MPMYAbnormalDOTh_ */

View file

@ -0,0 +1,62 @@
#ifndef MPMY_IOdotH
#define MPMY_IOdotH
#include <stdarg.h>
#include <sys/types.h>
typedef void MPMYFile;
/* mode flags for open */
/* The first three correspond to the analogous modes O_??? that seem
to be fairly common on different unices (linux, sunos, solaris). I
guess that's a good thing. But who decided that OR'ing zero
(O_RDONLY) with other values should be used as a flag???? The latter
ones show no commonality between other flavors of unix anyway, so
there's nothing to remain analogous to... */
#define MPMY_RDONLY 00000000
#define MPMY_WRONLY 00000001
#define MPMY_RDWR 00000002
#define MPMY_APPEND 00000004
#define MPMY_CREAT 00000010
#define MPMY_TRUNC 00000020
/* io modes */
#define MPMY_SINGL 00010000 /* like cubix single mode */
#define MPMY_MULTI 00020000 /* like cubix multi mode */
/* These four are used by the 'mpmy_pario' implementation, but that is
no longer linked with any of our default systems... */
#define MPMY_UNIX 00040000 /* one file, UNIX multi-process semantics */
#define MPMY_IOZERO 00100000 /* if(procnum==0){...} */
#define MPMY_INDEPENDENT 00200000 /* many files. Complete independence */
#define MPMY_NFILE 00400000 /* many files. Really. */
/* modes for seek */
#define MPMY_SEEK_SET 0
#define MPMY_SEEK_CUR 1
#define MPMY_SEEK_END 2
#ifdef __cplusplus
extern "C"{
#endif /* __cplusplus */
MPMYFile *MPMY_Fopen(const char *path, int flags);
int MPMY_SetIOMode(MPMYFile *fp, int iomode);
int MPMY_Fclose(MPMYFile *fp);
int MPMY_Mkdir(const char *path, int mode);
size_t MPMY_Fread(void *ptr, size_t size, size_t nitems, MPMYFile *fp);
size_t MPMY_Fwrite(const void *ptr, size_t size, size_t nitems, MPMYFile *fp);
off_t MPMY_Fseek(MPMYFile *fp, off_t offset, int whence);
off_t MPMY_Ftell(MPMYFile *fp);
off_t MPMY_Flen(MPMYFile *fp);
int MPMY_Getc(MPMYFile *fp);
int MPMY_Ungetc(char c, MPMYFile *fp);
size_t MPMY_Fseekrd(MPMYFile *fp, off_t offset, int whence, void *buf, size_t reclen,
size_t nrecs);
int MPMY_Fprintf(MPMYFile *fp, const char *fmt, ...);
int MPMY_Vfprintf(MPMYFile *fp, const char *fmt, va_list args);
int MPMY_Fflush(MPMYFile *fp);
int MPMY_Nfileio(int val);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* MPMY_IOdotH */

View file

@ -0,0 +1,23 @@
#ifndef MPMY_timeDOTh
#define MPMY_timeDOTh
/* some simple system-dependent routines to facilitate timing */
#define MPMY_CPU_TIME 1
#define MPMY_WC_TIME 2
#ifdef __cplusplus
extern "C"{
#endif /* __cplusplus */
void *MPMY_CreateTimer(int type);
int MPMY_StartTimer(void *);
int MPMY_CopyTimer(void *, void *);
int MPMY_StopTimer(void *);
int MPMY_ClearTimer(void *);
double MPMY_ReadTimer(void *);
int MPMY_DestroyTimer(void *);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif

128
external/libsdf/include/libsdf/protos.h vendored Normal file
View file

@ -0,0 +1,128 @@
/* This is where we keep the code to shut up warnings about implicit */
/* declarations. */
/*
* Copyright 1991 Michael S. Warren and John K. Salmon. All Rights Reserved.
*/
#ifndef _ProtosDOTh
#define _ProtosDOTh
/* gcc's fixprotos changed in 2.5 so that it is no longer necessary
to have protos for all these. If __GNUC__ and __GNUC_MINOR are undefined,
ANSI says the pre-processor should treat them as 0, so the test should
pass and we should see the prototypes - fingers crossed.
*/
/* AIEEEE!!! The above comment only applied to the short-lived
aberation 2.5.4. It is broken again in 2.5.5. Unfortunately,
there is no __GNUC__SUBMINOR__ so I can't switch on it. The
following conditional worked for 2.5.4...
#if defined(sun) && !defined(__SUN5__) && __GNUC__<=2 && __GNUC_MINOR__<=4
*/
/*------------------------------------------------------*/
/* ----------------BEGIN--SUNOS------------------------ */
/*------------------------------------------------------*/
#if defined(sun)
#include <stddef.h>
/* Sunos4.1.3 sometimes seems to come with prototypes...And they're wrong! */
/* Setting ARCH=sun4proto will activate this */
#ifndef _SUNOS4_PROTOTYPES_
extern int bcopy(const void *from, void *to, size_t);
#if !defined(__SUN5__) && !defined (_SUNACC)
/* Sun's stdio doesn't have protos for fflush, printf, what else?? */
/* I can't predict whether FILE is meaningful, so I use void* */
/* Furthermore, I can't give a prototype for sprintf because gcc complains */
/* about a conflict between old-style decl and one with an ellipsis */
#include "gccextensions.h"
#include <stdarg.h>
/* Sigh... In 2.5.6 and 2.5.7 (at least). fixincludes gives full
prototypes for all the non-integer-return functions in std*.h. */
#if 0
extern char *sprintf();
#endif
extern int printf( const char *, ... )
__attribute__ ((format (printf, 1, 2)));
extern int fprintf(void *, const char *, ...)
__attribute__((format (printf, 2, 3)));
extern int vfprintf(void *, const char *, va_list)
__attribute__((format (printf, 2, 0)));
extern int vsprintf(char *, const char *, va_list)
__attribute__((format (printf, 2, 0)));
extern int scanf(const char *, ...)
__attribute__((format (scanf, 1, 2)));
extern int sscanf(const char *, const char *, ...)
__attribute__((format (scanf, 2, 3)));
extern int fflush(void *);
extern int fwrite(const void *, size_t, size_t, void/*FILE*/ *);
extern int fseek(void/*FILE*/ *, long, int);
extern int fread(void *, size_t, size_t, void/*FILE*/ *);
extern int fclose(void *);
extern int raise(int);
extern int _filbuf(void *);
extern int _flsbuf(int, void *);
#ifndef ungetc
extern int ungetc(int, void*);
#endif
extern int setvbuf(void *, void *, int, size_t);
/* We carefully include stdlib.h when we use these, */
/* but Sun has elected to leave them out of stdlib.h...go figure */
extern void *memmove(void *, const void *, size_t);
extern void *memccpy (void *, const void *, int, size_t );
extern void *memchr (const void *, int, size_t );
extern void *memcpy (void *, const void *, size_t );
extern void *memset (void *, int, size_t );
#endif /* __SUN5__ */
#endif /* _SUNOS4_PROTOTYPES_ */
#endif /* sun */
/*------------------------------------------------------*/
/* ------------------END--SUNOS------------------------ */
/*------------------------------------------------------*/
/*------------------------------------------------------*/
/* ------------------BEGIN--INTEL---------------------- */
/*------------------------------------------------------*/
#if defined(__INTEL_SSD__)
#include <stddef.h>
extern int bcopy(const void *from, void *to, size_t);
/* This should be in nx.h or cube.h or mesh.h */
extern void flick(void);
#if defined(__DELTA__) || defined(__GAMMA__)
/* This should be in fcntl.h */
int open(const char *, int flags, ...);
int creat(const char *, int/* mode_t */);
/* These should be in unistd.h */
int close(int);
int unlink(const char *);
int read(int, void *buf, unsigned int);
int write(int, const void *, unsigned int);
/*off_t*/long lseek(int, long/*off_t*/, int);
/* Should be in sys/stat.h */
int mkdir(const char *, int);
#ifdef S_IRGRP
/* this means we already included <sys/stat.h> */
int fstat(int, struct stat *);
#endif
#endif /* __DELTA__ || __GAMMA__ */
#endif /* !__INTEL_SSD__ */
/*------------------------------------------------------*/
/* ------------------END--INTEL------------------------ */
/*------------------------------------------------------*/
/*------------------------------------------------------*/
/* ------------------BEGIN--SOLARIS/STARDENT----------- */
/*------------------------------------------------------*/
#if defined(__STARDENT__) || defined(__SUN5__)
int finite(double);
#endif
/*------------------------------------------------------*/
/* --------------------END--SOLARIS/STARDENT----------- */
/*------------------------------------------------------*/
#endif /* _PrototDOTh */

View file

@ -0,0 +1,14 @@
#ifndef _SinglIODOTh
#define _SinglIODOTh
#ifdef __cplusplus
extern "C"{
#endif /* __cplusplus */
int singlPrintf(const char *, ...);
void singlFflush(void);
int singlAutoflush(int);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif

78
external/libsdf/include/libsdf/timers.h vendored Normal file
View file

@ -0,0 +1,78 @@
/*
* Copyright 1991, 1992, 1993 Michael S. Warren and John K. Salmon.
* All Rights Reserved.
*/
#ifndef _TimersDOTh
#define _TimersDOTh
#include <stdint.h>
/* This used to look more like a Counter_t, but it was just too much */
/* trouble to deal with the archtecture specific differences, so we */
/* hide all the ugliness behind another layer of indirection. In */
/* fact, it would make more sense if, e.g., EnableTimer returned a void* */
/* but that would require too much changing of "application" code. */
typedef struct {
int enabled;
void *mpmy_tm;
char *name;
double min, max, mean;
} Timer_t;
typedef struct {
int enabled;
int64_t counter;
int64_t max, min;
double mean, sum;
char *name;
} Counter_t;
#ifdef __cplusplus
extern "C"{
#endif /* __cplusplus */
void StartTimer(Timer_t *t);
void StopTimer(Timer_t *t);
void SumTimers(void);
void CopyTimer(Timer_t *src, Timer_t *dest);
void EnableWCTimer(Timer_t *t, char *name);
void EnableCPUTimer(Timer_t *t, char *name);
void DisableTimer(Timer_t *t);
void ClearTimer(Timer_t *t);
void ClearEnabledTimers(void);
void OutputTimers(int (*Printf_Like)(const char *, ...));
void OutputTimer(Timer_t *t, int (*Printf_Like)(const char *, ...));
void OutputIndividualTimers(int (*Printf_Like)(const char *, ...));
double ReadTimer(Timer_t *t);
void SumCounters(void);
void EnableCounter(Counter_t *t, char *name);
void DisableCounter(Counter_t *t);
void ClearCounter(Counter_t *c);
void ClearEnabledCounters(void);
void OutputCounters(int (*Printf_Like)(const char *, ...));
void OutputIndividualCounters(int (*Printf_Like)(const char *, ...));
void OutputOneCounter(Counter_t *c, int (*Printf_Like)(const char *, ...));
int64_t ReadCounter(Counter_t *c);
int64_t ReadCounter64(Counter_t *c);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#define EnableTimer(t, name) EnableWCTimer(t, name)
#ifdef NOTIMERS
#define StartTimer(x) /**/
#define StopTimer(x) /**/
#define StartWCTimer(x) /**/
#define StopWCTimer(x) /**/
#endif
#ifndef NOCOUNTERS
#define IncrCounter(c) ((c)->counter++)
#define AddCounter(c, add) ((c)->counter += (add))
#else
#define IncrCounter(c)
#define AddCounter(c, add)
#endif
#endif /* _TimersDOTh */