diff --git a/external/libsdf/GNUmakefile b/external/libsdf/GNUmakefile index 0997fee..5ade09d 100644 --- a/external/libsdf/GNUmakefile +++ b/external/libsdf/GNUmakefile @@ -20,7 +20,7 @@ all: All # spell them a little differently in this file... include Make-common/Make.generic -subdirs:= libSDF libmpmy +subdirs:= libSDF libmpmy libsw All: for dir in $(subdirs); do (cd $$dir; $(MAKE) ARCH=$(ARCH) all); done diff --git a/external/libsdf/include/libsdf/abm.h b/external/libsdf/include/libsdf/abm.h new file mode 100644 index 0000000..1e54286 --- /dev/null +++ b/external/libsdf/include/libsdf/abm.h @@ -0,0 +1,91 @@ +#ifndef ABM_dot_H +#define ABM_dot_H + +#include "chn.h" +#include "dll.h" +#include "mpmy.h" +#include "timers.h" + +/* Notice that memcpy is a perfectly good ABMpktz_t. Overzealous + compilers will complain because arg2 isn't const and arg3 is an int + rather than a size_t. AAAARRRRGGGGHHHH.... */ +typedef void (ABMpktz_t)(void *to, void *arg, int sz); +typedef void (ABMhndlr_t)(int src, int len, void *ptr); + +typedef struct { + int nfuncs; + ABMhndlr_t **hndlarray; + Dll undeliveredLL; /* An LL of all messages that have been ISent, but + not Test'ed affirmative. */ + int done; /* I hate these! */ + int doc; + int allbitsdone; + int alldone; + Dll *Enqueued; /* array of DLL's, one for each dest */ + int *destarr; /* which of Enqueued are non-empty? */ + int ndests; /* how many of Enqueued are non-empty? */ + int *cntarr; /* how much data for each dest? */ + Chn undelChn; /* chain for undelivereLL */ + Chn QelmtChn; /* chain for all of the Enqueued Dll's */ + MPMY_Comm_request Recv_Hndl; + int tag; + int pktsize; + char *recvbuf1; + char *recvbuf2; + char *recvbufA; + char *recvbufB; +} ABM ; + +#ifdef __cplusplus +extern "C"{ +#endif +/* Set the whole thing up. State goes into abm */ +void ABMSetup(ABM *abm, int pktsize, int tag, int nfuncs, ABMhndlr_t *hndlarray[]); + +/* Post a message of given size. When it's time to deliver it, + the packetizing func will be called-back with the given arg. + When it arrives, the 'handler' hndlarray[type] on the dest node + will be called to process it. */ +void ABMPost(ABM *abm, int dest, int sz, int type, ABMpktz_t *func, void *arg); + +/* Poll for incoming messages. Handlers get called under here. */ +int ABMPoll(ABM *abm); + +/* Poll for incoming messages. But wait until something arrives. */ +int ABMPollWait(ABM *abm); + +/* Flush any Posted messages to dest. Packetizers get called under here. (but + this may be called by ABMPost if we run out of space) */ +void ABMFlush(ABM *abm); + +/* Assert that we won't be sending out any more 'requests' AND that they, + along with any 'cascades' that they may have generated have been received. + This is automatic with a request/reply type protocol, but requires some + kind of ack if messages do not generate a reply to the originator. + See pqsort.c for one way to do the acks. */ +void ABMIamDone(ABM *abm); + +/* Return true if everybody has called ABMIamDone */ +int ABMAllDone(ABM *abm); + +/* Free all memory. Etc. */ +void ABMShutdown(ABM *abm); + +/* Maintain a bunch of 'informative' Counter_t's. They record the number + of bytes sent in messages of logarithmically binned lenths between + lo and hi. */ +void ABMHistEnable(int log2lo, int log2hi); + +#define ABMHISTFIRST 3 /* don't bother with the hist below 8 bytes */ +#define ABMHISTLEN 16 +extern Counter_t ABMIsendCnt; /* How many 'buffers' did we actualy Isend. */ +extern Counter_t ABMPostCnt; /* How many 'messages' did we Post. */ +extern Counter_t ABMByteCnt; /* How many bytes were Isent. */ +extern Counter_t ABMHistCnt[ABMHISTLEN]; + +#ifdef __cplusplus +} +#endif + + +#endif diff --git a/external/libsdf/include/libsdf/dll.h b/external/libsdf/include/libsdf/dll.h new file mode 100644 index 0000000..5d510d0 --- /dev/null +++ b/external/libsdf/include/libsdf/dll.h @@ -0,0 +1,90 @@ +#ifndef _DLLdotH_ +#define _DLLdotH_ + +#include "chn.h" + +#ifdef __cplusplus +extern "C"{ +#endif + +typedef struct Dll_elmt_s{ + struct Dll_elmt_s *up, *down; + void *stuff[1]; /* Will be alloc'ed to something else! */ + /* DON'T PUT ANYTHING HERE!!! It will be silently mangleded */ +} Dll_elmt; + +typedef struct { + Dll_elmt Sup, Inf; + Chn *chn; + int length; /* why not? */ +} Dll ; + +/* Create a Chain suitable for passing to DllCreate */ +void DllCreateChn(Chn *chn, int sz, int n); +/* Create a new Dll */ +void DllCreate(Dll *dll, Chn *chn); +/* Terminate a Dll */ +void DllTerminate(Dll *dll); +/* Return a new element just above 'DOWN' */ +Dll_elmt *DllInsertAbove(Dll *dll, Dll_elmt *down); +/* Return a new element just below 'UP' */ +Dll_elmt *DllInsertBelow(Dll *dll, Dll_elmt *up); +/* Delete OLD. Return nothing. */ +void DllDelete(Dll *dll, Dll_elmt *old); +/* Delete OLD. Return the entry that used to be above it. */ +Dll_elmt *DllDeleteUp(Dll *dll, Dll_elmt *old); +/* Delete OLD. Return the entry that used to be below it. */ +Dll_elmt *DllDeleteDown(Dll *dll, Dll_elmt *old); +/* Extract the 'mover' and place it immediately above 'down'. + Like DllDelete, followed by DllInsertAbove, but preserve the + data in the object. */ +void DllMoveAbove(Dll *dll, Dll_elmt *mover, Dll_elmt *down); +/* Extract the 'mover' and place it immediately below 'up'. + Like DllDelete, followed by DllInsertBelow, but preserve the + data in the object. */ +void DllMoveBelow(Dll *dll, Dll_elmt *mover, Dll_elmt *up); + +/* These would require __inline__ to be done properly. */ +/* Insert a new element at the bottom, equivalent to: + DllInsertAbove(dll, DllInf(dll)); */ +Dll_elmt *DllInsertAtBottom(Dll *dll); +/* Insert a new element at the top, equivalent to: + DllInsertBelow(dll, DllSup(dll)); */ +Dll_elmt *DllInsertAtTop(Dll *dll); +/* Move to bottom */ +void DllMoveToBottom(Dll *dll, Dll_elmt *mover); +/* Move to top */ +void DllMoveToTop(Dll *dll, Dll_elmt *mover); + +/* Should we bother with __inline__. These are simple enough that #define + is sufficient. */ + +/* How many elements? */ +int DllLength(Dll *dll); +#define DllLength(dll) ((dll)->length) +/* One past the topmost 'user' element */ +Dll_elmt *DllSup(Dll *dll); +#define DllSup(dll) (&((dll)->Sup)) +/* One below the lowest 'user' element */ +Dll_elmt *DllInf(Dll *dll); +#define DllInf(dll) (&((dll)->Inf)) +/* The highest 'user' element */ +Dll_elmt *DllTop(Dll *dll); +#define DllTop(dll) ((dll)->Sup.down) +/* The lowest 'user' element */ +Dll_elmt *DllBottom(Dll *dll); +#define DllBottom(dll) ((dll)->Inf.up) +/* The 'user' data */ +void *DllData(Dll_elmt *elmt); +#define DllData(elmt) ((void *)((elmt)->stuff)) +/* The next elements, both up and down */ +Dll_elmt *DllUp(Dll_elmt *elmt); +#define DllUp(elmt) ((elmt)->up) +Dll_elmt *DllDown(Dll_elmt *elmt); +#define DllDown(elmt) ((elmt)->down) + +#ifdef __cplusplus +} +#endif + +#endif /* _DLLdotH_ */ diff --git a/external/libsdf/include/libsdf/files.h b/external/libsdf/include/libsdf/files.h new file mode 100644 index 0000000..0b3b78b --- /dev/null +++ b/external/libsdf/include/libsdf/files.h @@ -0,0 +1,19 @@ +#ifndef _FILESdotH +#define _FILESdotH + +#ifdef __cplusplus +extern "C"{ +#endif /* __cplusplus */ +int fexists(const char *name); +int fexists_and_unlink(const char *name); +/* These are advisory routines. They don't actually do anything */ +/* They just check for files named "_ForceOutput_" and "_ForceStop_" */ +int ForceCheckpoint(void); +int ForceOutput(void); +int ForceStop(void); +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif + diff --git a/external/libsdf/include/libsdf/gc.h b/external/libsdf/include/libsdf/gc.h new file mode 100644 index 0000000..d3fd667 --- /dev/null +++ b/external/libsdf/include/libsdf/gc.h @@ -0,0 +1,57 @@ +#ifndef _GCdotH +#define _GCdotH + +#include + +/* little functions for doing gray-code stuff. */ + +#ifdef __cplusplus +extern "C"{ +#endif /* __cplusplus */ + +/* Return the parity of num, i.e., parity(0x22)=0 */ +unsigned int parity(unsigned int num); + +/* Return the index of the highest bit in num, i.e., + hibit(3) = 1, hibit(1)=0, hibit(513)=9, hibit(0)=-1 */ +int hibit(unsigned int num); + +/* Return the index of the lowest bit in num, i.e., + lobit(3) = 0, lobit(2)=1, lobit(512)=9, lobit(513)=0, lobit(0)=BITSPERWORD + */ +int lobit(unsigned int num); + +/* Return the integer log2 of the argument. Round down. Return -1 for 0. */ +/* Same as hibit! */ +int ilog2(unsigned int num); + +/* Return the word-wise xor checksum of n bytes in buf. */ +unsigned int cksum(const void *buf, unsigned int n); + +/* Return the number of set bits in num. Is this sometimes called + "popcount"? */ +unsigned int countbits(unsigned int num); + +/* Return the 'up' graycode neighbor of proc (out of nproc) */ +int Gcup(unsigned int proc, unsigned int nproc); + +/* Return the 'down' graycode neighbor of proc (out of nproc) */ +int Gcdown(unsigned int proc, unsigned int nproc); + +/* This isn't really gray-code related, but where else can it go? */ +/* It does the simple-minded "decomposition" of gnobj objects over nproc */ +/* processors. It returns how many to keep and which one to start with. */ +void NobjInitial(int gnobj, int nproc, int procnum, int *nobj, int *start); +void NobjInitial64(int64_t gnobj, int nproc, int procnum, int *nobj, int64_t *start); + +/* These two came from alt.sources */ +/* Return the 'index' of the given gray code (assuming 32-bit longs!) */ +unsigned long gray2bin(unsigned long b); + +/* Return the graycode of a given index */ +unsigned long bin2gray(unsigned long g); +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif diff --git a/external/libsdf/include/libsdf/heap.h b/external/libsdf/include/libsdf/heap.h new file mode 100644 index 0000000..9c36356 --- /dev/null +++ b/external/libsdf/include/libsdf/heap.h @@ -0,0 +1,152 @@ +/* Super-fast priority queue. ? Completely inlined by gcc. */ +/* Assume that each pointer points at */ +/* a key, AND whatever else the caller is interested in keeping. */ +#ifndef HEAPdotH +#define HEAPdotH + + +typedef struct{ + const float **arr; + unsigned int sz; + unsigned int cnt; +} Heap; + +#ifdef __cplusplus +extern "C"{ +#endif /* __cplusplus */ +extern void HeapInit(Heap *hp, unsigned int initial_nelem); +extern void HeapTerminate(Heap *hp); +extern void HeapPush(Heap *hp, const float *ptr); +extern void HeapPop(Heap *hp, const float **keyp); +extern const float *HeapPeek(const Heap *hp); +extern const float **HeapBase(const Heap *hp); +extern const float **HeapEnd(const Heap *hp); +extern unsigned int HeapCnt(const Heap *hp); +extern int HeapIsBad(const Heap *hp); +extern const float HeapMinf; +extern const float HeapInf; +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +/* This is an attempt to get the inline functions into the .h file */ +/* without having to maintain two source files. */ +#if (defined(__GNUC__) || defined(__ICC__)) || defined(HEAPdotC) + +#ifndef assert +#include "Assert.h" +#endif +#include +#include +#include "Malloc.h" + +#undef INLINE +#if (defined (__GNUC__) || defined(__ICC__)) && !defined (HEAPdotC) +#define INLINE extern __inline__ +#else +#define INLINE +#endif + +#ifndef NULL +#define NULL (void *)0 +#endif +#ifndef EXIT_SUCCESS +#define EXIT_SUCCESS 0 +#endif + +#if defined(HeapKey) || defined(HeapParent) || defined(HeapLeft) + # error Problems with conflicting definitions in heap.h +#endif +#define HeapKey(i) (*arr[i]) +#define HeapParent(i) (i>>1) +#define HeapLeft(i) (i<<1) +/* Use left+1 for right */ + +INLINE void HeapPush(Heap *hp, const float *ptr){ + const float **arr = hp->arr; + const float *tmp; + unsigned int i = hp->cnt++; + unsigned int pi; + + if( i == hp->sz ){ + unsigned int newsz = (hp->sz)<<1; + arr = hp->arr = Realloc(hp->arr, (newsz+1)*sizeof(*(hp->arr))); + assert(hp->arr); + hp->sz = newsz; + } + + arr[i] = ptr; + pi = HeapParent(i); + while( HeapKey(pi) <= HeapKey(i) ){ + tmp = arr[pi]; + arr[pi] = arr[i]; + arr[i] = tmp; + i = pi; + pi = HeapParent(i); + } +} + +INLINE void HeapPop(Heap *hp, const float **keyp){ + const float **arr = hp->arr; + const float *save; + unsigned int i, li, ri, ix, n; + float kl, kr, ksave, kx; + + *keyp = arr[1]; + n = --hp->cnt; + assert( n>0 ); + i = 1; + li = 2; + ri = 3; + save = arr[n]; + ksave = *save; + arr[n] = &HeapMinf; + while( li < n ){ + kl = HeapKey(li); + kr = HeapKey(ri); + if( kl >= kr ){ + ix = li; + kx = kl; + }else{ + ix = ri; + kx = kr; + } + if( ksave >= kx ){ + break; + } + + /* Move ix up the heap */ + arr[i] = arr[ix]; + i = ix; + li = HeapLeft(ix); + ri = li+1; + } + arr[i] = save; +} + +INLINE const float *HeapPeek(const Heap *hp){ + return hp->arr[1]; +} + +INLINE const float **HeapBase(const Heap *hp){ + return &hp->arr[1]; +} + +INLINE const float **HeapEnd(const Heap *hp){ + return &hp->arr[hp->cnt]; +} + +INLINE unsigned int HeapCnt(const Heap *hp){ + return hp->cnt-1; +} + +/* Undefine our private macros */ +#ifndef HEAPdotC +#undef HeapKey +#undef HeapParent +#undef HeapLeft +#endif /* HEAPdotC */ +#undef INLINE + +#endif /* __GNUC__ || HEAPdotC */ +#endif /* already included */ diff --git a/external/libsdf/include/libsdf/hwclock.h b/external/libsdf/include/libsdf/hwclock.h new file mode 100644 index 0000000..408a38a --- /dev/null +++ b/external/libsdf/include/libsdf/hwclock.h @@ -0,0 +1,3 @@ +double hwclock(void); +double hwtick(void); +void zero_hwclock(void); diff --git a/external/libsdf/include/libsdf/key.h b/external/libsdf/include/libsdf/key.h new file mode 100644 index 0000000..856e532 --- /dev/null +++ b/external/libsdf/include/libsdf/key.h @@ -0,0 +1,524 @@ +#ifndef _KeyDOTh +#define _KeyDOTh + +#include + +/* Should we use long long keys??? + Compiling tree.c (which does a fair amount of key arith), with + LONG_LONG_KEYS turned on results + in 25% shorter sparc code (12k vs. 9k), and 15% shorter i860 code + (14k vs 12k). + + HOWEVER: in both cases, the LONG_LONG_KEYS code does NOT inline + the leftshift and rightshift operators. They are implemented as + calls to ___lshrdi3 and ___lshldi3 in libgcc.a + + The bottom line: TBD. I-cache vs. call overhead, vs. do the __lsh calls + prevent gcc from doing any optimizations across the call? I'd guess + that the LONG_LONG_KEYS are faster. +*/ +#if defined(KEY96BITS) +#define NK 3 +#define _KTYPE unsigned int +#define KEYBITS 94 +#else +#if defined(LONG_NK1_KEY) +#define NK 1 +#define _KTYPE unsigned long int +#else +#if defined(LONG_LONG_KEYS) +#define NK 2 +#define _KTYPE unsigned long long int +#define KEYBITS 94 +#else +#define NK 2 +#define _KTYPE unsigned long int +#define KEYBITS 94 +#endif + +#endif /* LONG_LONG */ +#endif /* ONE_LONG */ + +/* Test for #if FORCE_KEY_ALIGNMENT, not for #ifdef, which gives + the Make.$(ARCH) the opportunity to do -DFORCE_KEY_ALIGNMENT=0 +*/ +#if !defined(FORCE_KEY_ALIGNMENT) && NK==1 +#define FORCE_KEY_ALIGNMENT 1 +#endif + +/* We have to typedef Key_t as a struct, or else we can't return it from */ +/* a function */ +typedef struct { + _KTYPE k[NK]; +} Key_t; + +/* Be careful! KEYBITS is not necessarily where the "body" bit is located */ +#ifndef KEYBITS +#define KEYBITS (CHAR_BIT*sizeof(Key_t)) +#endif + +#ifdef __cplusplus +extern "C"{ +#endif /* __cplusplus */ +extern char *PrintKey(Key_t key); +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#if (defined(__GNUC__) || defined(__ICC__)) || defined(KEYdotC) + +#if (__STDC_VERSION__ >= 199901L) && !defined (KEYdotC) +#define INLINE inline +#else +#if (defined (__GNUC__) || defined(__ICC__)) && !defined (KEYdotC) +#define INLINE extern __inline__ +#else +#define INLINE +#endif +#endif + +#if NK==1 + +INLINE int +KeyGT(Key_t key1, Key_t key2) +{ + return (key1.k[0] > key2.k[0]); +} + +INLINE int +KeyLT(Key_t key1, Key_t key2) +{ + return (key1.k[0] < key2.k[0]); +} + +INLINE int +KeyGE(Key_t key1, Key_t key2) +{ + return (key1.k[0] >= key2.k[0]); +} + +INLINE int +KeyLE(Key_t key1, Key_t key2) +{ + return (key1.k[0] <= key2.k[0]); +} + +INLINE int +KeyEQ(Key_t key1, Key_t key2) +{ + return (key1.k[0] == key2.k[0]); +} + +INLINE int +KeyNEQ(Key_t key1, Key_t key2) +{ + return (key1.k[0] != key2.k[0]); +} + +INLINE Key_t +KeyXOR(Key_t key1, Key_t key2) +{ + Key_t ret; + ret.k[0] = key1.k[0] ^ key2.k[0]; + return(ret); +} + +INLINE Key_t +KeyAnd(Key_t key1, Key_t key2) +{ + Key_t ret; + ret.k[0] = key1.k[0] & key2.k[0]; + return(ret); +} + +INLINE Key_t +KeyOr(Key_t key1, Key_t key2) +{ + Key_t ret; + ret.k[0] = key1.k[0] | key2.k[0]; + return(ret); +} + +INLINE int +KeyCmp(Key_t key1, Key_t key2) +{ + if(key1.k[0] > key2.k[0] ) + return 1; + else if( key1.k[0] < key2.k[0] ) + return -1; + else + return 0; +} + +INLINE Key_t +KeyNot(Key_t key1) +{ + key1.k[0] = ~key1.k[0]; + return key1; +} + +INLINE Key_t +KeyRshift(Key_t u, int b) +{ + Key_t ret; + if (b >= CHAR_BIT*sizeof(u.k[0])) ret.k[0] = 0; + else ret.k[0] = u.k[0] >> b; + return(ret); +} + +INLINE Key_t +KeyLshift(Key_t u, int b) +{ + Key_t ret; + ret.k[0] = u.k[0] << b; + return(ret); +} + +/* cast int to Key_t */ +INLINE Key_t +KeyInt(int i) +{ + Key_t ret; + ret.k[0] = i; + return(ret); +} + +INLINE Key_t +KeyOrInt(Key_t u, unsigned int i) +{ + Key_t ret; + ret.k[0] = u.k[0] | i; + return(ret); +} + +/* bitwise and key with int */ +/* This is a common operation, and is more efficient than converting the */ +/* int to a key. It returns an int! */ + +INLINE unsigned int +KeyAndInt(Key_t u, unsigned int i) +{ + return(u.k[0] & i); +} + +/* bitwise and key with ~int */ +/* This is also common operation, and is more efficient than converting the */ +/* int to a key. It returns an Key_t (leaving the top bits alone)! */ + +INLINE Key_t +KeyAndNotInt(Key_t u, unsigned int i) +{ + u.k[0] &= ~((_KTYPE)i); + return u; +} + +INLINE Key_t +KeyAdd(Key_t key1, Key_t key2) +{ + Key_t ret; + + ret.k[0] = key1.k[0] + key2.k[0]; + return(ret); +} + +INLINE Key_t +KeySub(Key_t key1, Key_t key2) +{ + Key_t ret; + + ret.k[0] = key1.k[0] - key2.k[0]; + return(ret); +} + +INLINE Key_t +KeyAddInt(Key_t key1, int i) +{ + Key_t ret; + + ret.k[0] = key1.k[0] + i; + return(ret); +} + +#else +#if NK==2 + +INLINE int +KeyGT(Key_t key1, Key_t key2) +{ + if( key1.k[1] > key2.k[1] ) + return 1; + else if( key1.k[1] < key2.k[1] ) + return 0; + else + return (key1.k[0] > key2.k[0]); +} + +INLINE int +KeyLT(Key_t key1, Key_t key2) +{ + if( key1.k[1] < key2.k[1] ) + return 1; + else if( key1.k[1] > key2.k[1] ) + return 0; + else + return (key1.k[0] < key2.k[0]); +} + +INLINE int +KeyGE(Key_t key1, Key_t key2) +{ + if( key1.k[1] > key2.k[1] ) + return 1; + else if( key1.k[1] < key2.k[1] ) + return 0; + else + return (key1.k[0] >= key2.k[0]); +} + +INLINE int +KeyLE(Key_t key1, Key_t key2) +{ + if( key1.k[1] < key2.k[1] ) + return 1; + else if( key1.k[1] > key2.k[1] ) + return 0; + else + return (key1.k[0] <= key2.k[0]); +} + +INLINE int +KeyEQ(Key_t key1, Key_t key2) +{ + return (key1.k[0] == key2.k[0] && key1.k[1] == key2.k[1]); +} + +INLINE int +KeyNEQ(Key_t key1, Key_t key2) +{ + return (key1.k[0] != key2.k[0] || key1.k[1] != key2.k[1]); +} + +INLINE Key_t +KeyXOR(Key_t key1, Key_t key2) +{ + Key_t ret; + ret.k[0] = key1.k[0] ^ key2.k[0]; + ret.k[1] = key1.k[1] ^ key2.k[1]; + return(ret); +} + +INLINE Key_t +KeyAnd(Key_t key1, Key_t key2) +{ + Key_t ret; + ret.k[0] = key1.k[0] & key2.k[0]; + ret.k[1] = key1.k[1] & key2.k[1]; + return(ret); +} + +INLINE Key_t +KeyOr(Key_t key1, Key_t key2) +{ + Key_t ret; + ret.k[0] = key1.k[0] | key2.k[0]; + ret.k[1] = key1.k[1] | key2.k[1]; + return(ret); +} + +INLINE int +KeyCmp(Key_t key1, Key_t key2) +{ + if(key1.k[1] > key2.k[1] ) + return 1; + else if( key1.k[1] < key2.k[1] ) + return -1; + + if(key1.k[0] > key2.k[0] ) + return 1; + else if( key1.k[0] < key2.k[0] ) + return -1; + return 0; +} + +INLINE Key_t +KeyNot(Key_t key1) +{ + key1.k[0] = ~key1.k[0]; + key1.k[1] = ~key1.k[1]; + return key1; +} + +INLINE Key_t +KeyRshift(Key_t u, int b) +{ + Key_t ret; + long bm = CHAR_BIT*sizeof(u.k[0])-b; + + if (b == 0) { + ret = u; + } else if (bm > 0) { + ret.k[0] = (u.k[0] >> b) | (u.k[1] << bm); + ret.k[1] = u.k[1] >> b; + } else { + ret.k[0] = u.k[1] >> -bm; + ret.k[1] = 0; + } + return(ret); +} + +INLINE Key_t +KeyLshift(Key_t u, int b) +{ + Key_t ret; + long bm = CHAR_BIT*sizeof(u.k[0])-b; + + if (b == 0) { + ret = u; + } else if (bm > 0) { + ret.k[1] = (u.k[1] << b) | (u.k[0] >> bm); + ret.k[0] = u.k[0] << b; + } else { + ret.k[1] = u.k[0] << -bm; + ret.k[0] = 0; + } + return(ret); +} + +/* cast int to Key_t */ +INLINE Key_t +KeyInt(int i) +{ + Key_t ret; + ret.k[1] = 0; + ret.k[0] = i; + return(ret); +} + +INLINE Key_t +KeyOrInt(Key_t u, unsigned int i) +{ + Key_t ret; + ret.k[0] = u.k[0] | i; + ret.k[1] = u.k[1]; + return(ret); +} + +/* bitwise and key with int */ +/* This is a common operation, and is more efficient than converting the */ +/* int to a key. It returns an int! */ + +INLINE unsigned int +KeyAndInt(Key_t u, unsigned int i) +{ + return(u.k[0] & i); +} + +/* bitwise and key with ~int */ +/* This is also common operation, and is more efficient than converting the */ +/* int to a key. It returns an Key_t (leaving the top bits alone)! */ + +INLINE Key_t +KeyAndNotInt(Key_t u, unsigned int i) +{ + u.k[0] &= ~((_KTYPE)i); + return u; +} + +INLINE Key_t +KeyAdd(Key_t key1, Key_t key2) +{ + Key_t ret; + + ret.k[0] = key1.k[0] + key2.k[0]; + ret.k[1] = key1.k[1] + key2.k[1]; + /* We assume keys are unsigned quantities */ + if (ret.k[0] < key1.k[0] || ret.k[0] < key2.k[0]) /* carry */ + ret.k[1]++; + return(ret); +} + +INLINE Key_t +KeySub(Key_t key1, Key_t key2) +{ + Key_t ret; + + ret.k[0] = key1.k[0] - key2.k[0]; + ret.k[1] = key1.k[1] - key2.k[1]; + /* We assume keys are unsigned quantities */ + if (ret.k[0] > key1.k[0] || ret.k[0] > key2.k[0]) /* borrow */ + ret.k[1]--; + return(ret); +} + +INLINE Key_t +KeyAddInt(Key_t key1, int i) +{ + Key_t ret; + + ret.k[0] = key1.k[0] + i; + ret.k[1] = key1.k[1]; + if (i >= 0 && ret.k[0] < key1.k[0]) /* carry */ + ret.k[1]++; + else if (i < 0 && ret.k[0] > key1.k[0]) /* borrow */ + ret.k[1]--; + return(ret); +} + +#else + # error NK must be 1 or 2 +#endif /* NK==2 */ +#endif /* NK==1 */ + +INLINE int +TreeLevel(Key_t key, int ndim) +{ + int level; + int chubits = (KEYBITS-1)/ndim; + Key_t testkey; + + /* First check whether it's a 'body' (at the deepest level.) */ + /* This will save considerable time... */ + testkey = KeyLshift(KeyInt(1), chubits*ndim); + if( KeyEQ( testkey, KeyAnd(testkey, key) ) ) + return chubits; + + /* Now start looking from low levels */ + testkey = KeyInt(1); + for (level = 0; level= pos[i]. The equality + can be a headache for float-to-int conversions! Consider using + InflateBbox and or CubeBbox! */ +void TightBbox(float *pstart, int nobj, int pstride, int ndim, tbbox *bb); + +/* Make the bbox a cube by expanding the smaller dimensions. */ +void CubeBbox(tbbox *bb); + +/* Increase the linear dimension by 'factor' on all sides */ +void InflateBbox(tbbox *bb, float factor); + +/* Return 1 if bb1 completely contains bb2 */ +int ContainsBbox(tbbox *bb1, tbbox *bb2); + +/* Construct bbu, the 'union' of bb1 and bb2 */ +void UnionBbox(tbbox *bb1, tbbox *bb2, tbbox *bbu); + +/* Generate keys for an array of positions (imagine sizeof(body) as the + stride argument!) */ +void GenerateKeys(float *pstart, int nobj, int pstride, tbbox *bb, Key_t *kstart, int kstride, int ordering); +/* This will be set when GenerateKeys detects that a key is out of + bounds. GenerateKeys will not crash and burn, but prudent callers + will check KeyOutOfBounds after calling it. It is cumulative. */ +extern int KeyOutOfBounds; + +/* Replacement for CellCorner: you supply the bbox that describes the + Universe, and we return a bbox that describes the cell */ +void CellBBFromKey(Key_t key, tbbox *bb, tbbox *cellbb, int ordering); + +/* Some primitive building blocks. They can be combined with + KeyFromInts and IntsFromKey to do the full conversion... */ +void IntsFromFloats(const float *x, unsigned int *ix, tbbox *bb, int nbits); +void FloatsFromInts(const int *ix, float *x, tbbox *bb, int nbits); + +/* These two names conflict with physics_generic.c. Good. It will + keep me from using physics_generic.c accidentally. */ +Key_t KeyFromInts(unsigned int *xp, int ndim, int nbits); +int IntsFromKey(Key_t key, unsigned int *ip, int ndim); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ +#endif diff --git a/external/libsdf/include/libsdf/lsv.h b/external/libsdf/include/libsdf/lsv.h new file mode 100644 index 0000000..5383e2d --- /dev/null +++ b/external/libsdf/include/libsdf/lsv.h @@ -0,0 +1,27 @@ +#ifndef _LsvDOTh +#define _LsvDOTh + +#define LSV_ANY (-2) + +#ifdef __cplusplus +extern "C"{ +#endif /* __cplusplus */ +extern int LSV_procnum; +extern int LSV_nproc; + +extern char Smy_name[]; /* my hostname or inet address */ + +void Ssend(const void *outb, int outcnt, int dest, int type); +int Srecv_block(void *inb, int size, int type, int *from); +int Srecv(void *inb, int size, int type, int *from); +void Sclose(void); +void Sdiag(int (*)(const char *, ...)); + +void Sinit_host1(int *portp, char **namep); +void Sinit_host(int nproc); +void Sinit_elt(void); +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _LsvDOTh */ diff --git a/external/libsdf/include/libsdf/peano.h b/external/libsdf/include/libsdf/peano.h new file mode 100644 index 0000000..854b0a5 --- /dev/null +++ b/external/libsdf/include/libsdf/peano.h @@ -0,0 +1,8 @@ +#ifndef __PeanoDOt_H_ +#define __PeanoDOt_H_ +#include "key.h" + +Key_t PHKeyFromInts(unsigned int ikey[], int ndim, int depth); +unsigned int IntsFromPHKey(Key_t key, unsigned int ikey[], int ndim); + +#endif diff --git a/external/libsdf/include/libsdf/qromo.h b/external/libsdf/include/libsdf/qromo.h new file mode 100644 index 0000000..c3577fc --- /dev/null +++ b/external/libsdf/include/libsdf/qromo.h @@ -0,0 +1,8 @@ +float qromo(float (*func)(float), float a, float b, + float (*choose)(float (*)(float), float, float, int)); +float midpnt(float (*func)(float), float a, float b, int n); + +double qromod(double (*func)(double), double a, double b, + double (*choose)(double (*)(double), double, double, int)); +double midpntd(double (*func)(double), double a, double b, int n); + diff --git a/external/libsdf/include/libsdf/randoms.h b/external/libsdf/include/libsdf/randoms.h new file mode 100644 index 0000000..663eebf --- /dev/null +++ b/external/libsdf/include/libsdf/randoms.h @@ -0,0 +1,26 @@ +#ifndef Randoms2DOTh +#define Randoms2DOTh + +#define NTAB 32 + +typedef struct{ + long idum, idum2; + long iy, iv[NTAB]; + int did_init; + int next_norml_ok; + float next_norml; +} ran_state; + +#ifdef __cplusplus +extern "C"{ +#endif /* __cplusplus */ +void ran_init(int seed, ran_state *st); +float uniform_rand(ran_state *s); +float normal_rand(ran_state *s); +float sphere_rand(ran_state *st, int ndim, float *x); +float cube_rand(ran_state *st, int ndim, float *x); +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif diff --git a/external/libsdf/include/libsdf/ring.h b/external/libsdf/include/libsdf/ring.h new file mode 100644 index 0000000..e05717c --- /dev/null +++ b/external/libsdf/include/libsdf/ring.h @@ -0,0 +1,19 @@ +#ifndef _RingDOTh +#define _RingDOTh + +#ifdef __cplusplus +extern "C"{ +#endif /* __cplusplus */ +void Ring(void *bptr, int bsize, int bnobj, + void *optr, int osize, int onobj, int oused, + void initf(void *, void *), void interactf(void *, void *, int, int)); + +void Ring2(void *bptr, int bsize, int bnobj, + void *optr, int osize, int onobj, int tsize, + void initf(void *, void *), void interactf(void *, void *, int, int), void finishf(void *, void *)); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _RingDOTh */ diff --git a/external/libsdf/include/libsdf/stk.h b/external/libsdf/include/libsdf/stk.h new file mode 100644 index 0000000..82512f8 --- /dev/null +++ b/external/libsdf/include/libsdf/stk.h @@ -0,0 +1,192 @@ +#ifndef STKdotH +#define STKdotH + +#include +#include +#include "Malloc.h" + +/* A quick and dirty stack implementation. Less functionality than */ +/* the RMS obstack. Is it faster? */ + +/* We could lift the code from obstack to determine proper alignment, + but I think it's easier to just -Define it in Make.$ARCH */ + +/* Use char * so we can do arithmetic without annoying casts. */ +typedef struct stk{ + char *bottom; + char *ptr; + char *top; + int growby; + void *(*realloc_like)(void *, size_t); + unsigned int align_mask; +} Stk; + +#ifdef __cplusplus +extern "C"{ +#endif /* __cplusplus */ +/* StkInitWithData starts with the given DATA ptr */ +void StkInitWithData(struct stk *s, size_t initial_sz, + void *(*realloc_like)(void *, size_t), void *data, + unsigned int alignment); + +/* StkCopy makes a completely new stack, initialized with the data in FROM */ + +void StkCopy(struct stk *to, const struct stk *from); +/* StkInit initializes a stack. */ +void StkInit(struct stk *s, size_t initial_sz, + void *(*realloc_like)(void *, size_t), unsigned int alignment); + +/* StkGrow adds at least nbytes to the available space in the stack. */ +/* FOR INTERNAL USE ONLY */ +void StkGrow(Stk *s, int nbytes); + +/* StkTerminate frees the space and forget about it forever */ +void StkTerminate(struct stk *s); + +#if !(__STDC_VERSION__ >= 199901L) +/* StkInitEz chooses reasonable defaults. */ +extern void StkInitEz(struct stk *s); + +/* StkPush returns a pointer to room for nbytes at the top of the */ +/* stack. It's up to you to put something there. */ +extern void *StkPush(struct stk *s, int nbytes); +/* The 'Align' version makes sure that the stack remains aligned. + Use if WITH AND ONLY WITH StkPopAlign */ +extern void *StkPushAlign(struct stk *s, int nbytes); + +/* StkPushData does a push and a memcpy */ +extern void *StkPushData(struct stk *s, void *p, int nbytes); + +/* StkPop returns a pointer to the beginning of the nbytes at the */ +/* top of the stack. The data under those bytes is guaranteed to */ +/* remain intact ONLY UNTIL THE NEXT StkPush, i.e., the data has been */ +/* popped. */ +extern void *StkPop(struct stk *s, int nbytes); +/* The 'Align' version makes sure that the stack remains aligned. Use + it IF AND ONLY IF with StkPushAlign was used. NOTE: you must use + the StkPushAlign on the push BEFORE the one that requires alignment! */ +extern void *StkPopAlign(struct stk *s, int nbytes); + +/* StkPeek returns the same thing as StkPop, but it doesn't "pop" anything. */ +/* The top of the stack is found by StkPeek(s, 0); */ +extern void *StkPeek(const struct stk *s, int nbytes); + +/* StkBase returns the current base of the stack. Beware, it can move */ +/* around! It is only guaranteed to stay in place until the next StkPush */ +extern void *StkBase(const struct stk *s); + +/* StkSz is the size of the stack. */ +extern size_t StkSz(const struct stk *s); + +/* StkTop is easily constructed from the others, but we provide it anyway. */ +/* It returns a pointer just past the end of the current stack. */ +extern void *StkTop(const struct stk *s); + +/* StkClear is equivalent to StkPop(s, StkSz(s)), but it returns void */ +extern void StkClear(struct stk *s); + +/* StkCrunch realloc's the stack so it doesn't use any more space */ +/* than necessary. Use it if you know you've reached the high-water-mark */ +extern void *StkCrunch(struct stk *s); + +/* Discover the alignment of a given stack. I.e., how would it */ +extern int StkAlign(const struct stk *s, unsigned int nbytes); + +#endif + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +/* Here's a convenient define for popping a known type. */ +#define StkPopType(s, t) (*(t *)StkPop(s, sizeof(t))) + +#define StkPushType(s, val, t) (*(t *)StkPush(s, sizeof(t)) = val) + +/* StkAlign(n) tells you how many bytes will really be pushed if you */ +/* do a StkPush(n) */ +#ifdef STK_FORCE_ALIGNMENT +#define _STK_DEFAULT_ALIGNMENT STK_FORCE_ALIGNMENT +#else +#define _STK_DEFAULT_ALIGNMENT 1 +#endif + +/* Here are all the inlined definitions. Non-inlined functions */ +/* can go in stk.c */ + +#if (defined(__GNUC__) || defined(__ICC__)) || defined(STKdotC) + +#undef INLINE +#if (__STDC_VERSION__ >= 199901L) && !defined (STKdotC) +#define INLINE inline +#else +#if (defined (__GNUC__) || defined(__ICC__)) && !defined (STKdotC) +#define INLINE extern __inline__ +#else +#define INLINE +#endif +#endif + +INLINE int StkAlign(const struct stk *s, unsigned int nbytes){ + return (nbytes + s->align_mask ) & ~s->align_mask; +} + +INLINE void StkInitEz(struct stk *s){ + StkInit(s, 1024, Realloc_f, _STK_DEFAULT_ALIGNMENT); +} + +INLINE void *StkPush(struct stk *s, int nbytes){ + char *ret; + nbytes = StkAlign(s, nbytes); + + if( s->ptr + nbytes > s->top ){ + StkGrow(s, nbytes); + } + ret = s->ptr; + s->ptr += nbytes; + return ret; +} + +INLINE void *StkPushData(struct stk *s, void *p, int nbytes){ + return memcpy(StkPush(s, nbytes), p, nbytes); +} + +INLINE void *StkPop(struct stk *s, int nbytes){ + nbytes = StkAlign(s, nbytes); +#ifdef NO_CHECK + return s->ptr -= nbytes; +#else + s->ptr -= nbytes; + if( s->ptr < s->bottom ){ + s->ptr += nbytes; /* undo the damage */ + return NULL; + }else + return s->ptr; +#endif +} + +INLINE void *StkPeek(const struct stk *s, int nbytes){ + return s->ptr - nbytes; +} + +INLINE void StkClear(struct stk *s){ + s->ptr = s->bottom; +} + +INLINE void *StkBase(const struct stk *s){ + return s->bottom; +} + +INLINE size_t StkSz(const struct stk *s){ + return s->ptr - s->bottom; +} + +INLINE void *StkTop(const struct stk *s){ + /* NOTE that StkTop is NOT s->top !! */ + return s->ptr; +} + +#undef INLINE +#endif /* GNUC || STKdotC */ + +#endif /* STKdotH */ diff --git a/external/libsdf/include/libsdf/swampi.h b/external/libsdf/include/libsdf/swampi.h new file mode 100644 index 0000000..7a11b93 --- /dev/null +++ b/external/libsdf/include/libsdf/swampi.h @@ -0,0 +1,144 @@ +#ifndef _MpiDOTh +#define _MpiDOTh + +#define MPI_Init SWAMPI_Init +#define MPI_Finalize SWAMPI_Finalize +#define MPI_Abort SWAMPI_Abort +#define MPI_Comm_rank SWAMPI_Comm_rank +#define MPI_Comm_size SWAMPI_Comm_size +#define MPI_Comm_free SWAMPI_Comm_free +#define MPI_Get_count SWAMPI_Get_count +#define MPI_Isend SWAMPI_Isend +#define MPI_Irecv SWAMPI_Irecv +#define MPI_Issend SWAMPI_Isend /* can Isend handle Issends? */ +#define MPI_Test SWAMPI_Test +#define MPI_Wait SWAMPI_Wait +#define MPI_Waitall SWAMPI_Waitall +#define MPI_Send SWAMPI_Send +#define MPI_Recv SWAMPI_Recv +#define MPI_Sendrecv SWAMPI_Sendrecv +#define MPI_Bcast SWAMPI_Bcast +#define MPI_Reduce SWAMPI_Reduce +#define MPI_Allreduce SWAMPI_Allreduce +#define MPI_Barrier SWAMPI_Barrier +#define MPI_Alltoallv SWAMPI_Alltoallv +#define MPI_Alltoall SWAMPI_Alltoall +#define MPI_Comm_dup SWAMPI_Comm_dup +#define MPI_Comm_split SWAMPI_Comm_split +#define MPI_Type_contiguous SWAMPI_Type_contiguous +#define MPI_Type_commit SWAMPI_Type_commit +#define MPI_Wtime SWAMPI_Wtime +#define MPI_Wtick SWAMPI_Wtick + +#ifdef __cplusplus +extern "C"{ +#endif /* __cplusplus */ + +typedef struct { + int MPI_SOURCE; + int MPI_TAG; + int MPI_ERROR; + int count; +} MPI_Status; + +/* MAXLOC and MINLOC structures */ +typedef struct { float x; int i;} MPI_float_int; +typedef struct { double x; int i;} MPI_double_int; +typedef struct { long x; int i;} MPI_long_int; +typedef struct { int x; int i;} MPI_2int; +typedef struct { short x; int i;} MPI_short_int; +typedef struct { long double x; int i;} MPI_long_double_int; + +/* Fortran types */ +typedef struct { float real; float imag; } MPI_complex; +typedef struct { double real; double imag; } MPI_double_complex; + +/* must match MPI_Datasize array in swampi.c */ +typedef enum { + MPI_FLOAT, MPI_DOUBLE, MPI_LONG_DOUBLE, + MPI_BYTE, MPI_CHAR, MPI_SHORT, MPI_INT, + MPI_LONG, MPI_LONG_LONG, + MPI_UNSIGNED, MPI_UNSIGNED_INT, MPI_UNSIGNED_CHAR, + MPI_UNSIGNED_SHORT, MPI_UNSIGNED_LONG, MPI_UNSIGNED_LONG_LONG, + MPI_FLOAT_INT, MPI_DOUBLE_INT, MPI_LONG_INT, + MPI_2INT, MPI_SHORT_INT, MPI_LONG_DOUBLE_INT, + MPI_COMPLEX, MPI_DOUBLE_COMPLEX, /* for Fortran */ + MPI_USER_DATA, _MPI_NUMDATATYPES +} MPI_Datatype; + +typedef enum { + MPI_SUM, MPI_PROD, MPI_MAX, MPI_MIN, MPI_BAND, MPI_BOR, + MPI_BXOR, MPI_LAND, MPI_LOR, MPI_LXOR, MPI_MAXLOC, MPI_MINLOC, + _MPI_NUMOPS +} MPI_Op; + + +typedef void (*MPI_user_comb_func)(void *from1, void *from2, void *to); +typedef int MPI_Comm; +typedef void * MPI_Request; + +enum MPI_comm { MPI_COMM_WORLD, MPI_COMM_PRIVATE, MPI_COMM_NULL }; +enum MPI_src { MPI_ANY_SOURCE = -1 }; +enum MPI_tag { MPI_ANY_TAG = -1 }; +enum MPI_ret { MPI_ERR_OTHER = -1, MPI_SUCCESS = 0 }; + +#define MPI_UNDEFINED (-32766) +#define MPI_REQUEST_NULL ((MPI_Request) 0) + +int MPI_Init(int *argcp, char ***argvp); +int MPI_Finalize(void); +int MPI_Abort(MPI_Comm comm, int errorcode); +int MPI_Comm_rank(MPI_Comm comm, int *rank); +int MPI_Comm_size(MPI_Comm comm, int *size); +int MPI_Get_count(MPI_Status *status, MPI_Datatype type, int *cnt); +int MPI_Isend(void *buf, int cnt, MPI_Datatype type, int dest, int tag, + MPI_Comm comm, MPI_Request *req); +int MPI_Irecv(void *buf, int cnt, MPI_Datatype type, int src, int tag, + MPI_Comm comm, MPI_Request *req); +int MPI_Test(MPI_Request *cptr, int *flag, MPI_Status *stat); +int MPI_Wait(MPI_Request *cptr, MPI_Status *status); +int MPI_Waitall(int count, MPI_Request *reqv, MPI_Status *statusv); +int MPI_Send(void *buf, int cnt, MPI_Datatype type, int dest, int tag, + MPI_Comm comm); +int MPI_Recv(void *buf, int cnt, MPI_Datatype type, int src, int tag, + MPI_Comm comm, MPI_Status *status); +int MPI_Sendrecv(void *sendbuf, int sendcount, MPI_Datatype sendtype, + int dest, int sendtag, void *recvbuf, int recvcount, + MPI_Datatype recvtype, int source, int recvtag, + MPI_Comm comm, MPI_Status *status); +int MPI_Bcast(void *buf, int cnt, MPI_Datatype type, int src, MPI_Comm comm); +int MPI_Reduce(void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, + MPI_Op op, int root, MPI_Comm comm); +int MPI_Allreduce(void *sendbuf, void *recvbuf, int count, + MPI_Datatype datatype, MPI_Op op, MPI_Comm comm); +int MPI_Barrier(MPI_Comm comm); +int MPI_Alltoallv(void *sbuf, int *sendcnts, int *sdispls, MPI_Datatype stype, + void *rbuf, int *recvcnts, int *rdispls, MPI_Datatype rtype, + MPI_Comm comm); +int MPI_Alltoall(void *sendbuf, int sendcount, MPI_Datatype sendtype, + void *recvbuf, int recvcount, MPI_Datatype recvtype, + MPI_Comm comm); +int MPI_Comm_dup(MPI_Comm comm, MPI_Comm *newcomm); +int MPI_Comm_split(MPI_Comm comm, int color, int key, MPI_Comm *newcomm); +int MPI_Comm_free(MPI_Comm *comm); +int MPI_Type_contiguous(int len, MPI_Datatype type, MPI_Datatype *ptr); +int MPI_Type_commit(MPI_Datatype *ptr); + +double MPI_Wtime(void); +double MPI_Wtick(void); + +/* These convert the enums to a text description */ +char *mpi_op_name[_MPI_NUMOPS], *mpi_datatype_name[_MPI_NUMDATATYPES]; + +/* These are private for mpi_reduce.c and mpi_bcast.c */ +extern int _MPI_Procnum, _MPI_Nproc; +extern unsigned int *_MPI_Datasize; + +/* These are for mpirun.c */ +void _MPI_init_host1(int *portp, char **namep, int nproc); +void _MPI_init_host(int nproc); +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _MpiDOTh */ diff --git a/external/libsdf/include/libsdf/verify.h b/external/libsdf/include/libsdf/verify.h new file mode 100644 index 0000000..64cb75e --- /dev/null +++ b/external/libsdf/include/libsdf/verify.h @@ -0,0 +1,44 @@ +/* Defines Verify and VerifyX, which verify the truth of the given + expression. Unlike assert, they guarantee that the expression be evaluated + exactly once. Thus, you might say: + + Verify(fp=fopen(name, "w")) + Verify((nwrit=fwrite(p, sz,ni, fp)) >= 0); + VerifyX((nwrit=fwrite(p, sz, ni, fp)) >= 0, Shout("errno=%d, nwrit=%d\n", + errno, nwrit)); + Verify0(stat(path, , &buf)); + Notice that VerifyX allows you to add "Xtra" information in the event of + a failure. +*/ +#undef Verify +#undef VerifyX +/* Is there ever really a good reason to shut this off?? */ +/* You can with -DNVERIFY. */ +# ifndef NVERIFY +#include "error.h" + +#ifndef NO_STRINGIFICATION +/* One can write a really slick version that uses GNU varargs macros, but */ +/* unfortunately, it would break every other pre-processor. It isn't even */ +/* possible to #ifdef __GNUC__ it because the pre-processor complains */ +/* about an incorrect arg count. It might be possible to write it as a */ +/* varargs function, but what's the point? */ +#define VerifyX( expr, xtra) \ + (expr) ? (void)0 : (xtra, Error("%s failed\n" , #expr)) +#define VerifySX( expr, xtra) \ + (expr) ? (void)0 : (xtra, SinglError("%s failed\n" , #expr)) +#else +/* Not only do we not have Stringification, but we assume that we have */ +/* the brain-damaged macro substitution into string constants. */ +#define VerifyX( expr, xtra) \ + (expr) ? (void)0 : (xtra, Error("%s failed\n" , "expr")) +#define VerifySX( expr, xtra) \ + (expr) ? (void)0 : (xtra, SinglError("%s failed\n" , "expr")) +#endif /* NO_STRINGIFICATION */ +# else +# define VerifyX( expr, xtra) ((expr),(void)0) +# endif +#define Verify( expr ) VerifyX(expr, (void)0) +#define VerifyS( expr ) VerifySX(expr, (void)0) +#define Verify0( expr ) Verify(!(expr)) +#define VerifyS0( expr ) VerifyS(!(expr)) diff --git a/external/libsdf/include/libsdf/vop.h b/external/libsdf/include/libsdf/vop.h new file mode 100644 index 0000000..5ec749a --- /dev/null +++ b/external/libsdf/include/libsdf/vop.h @@ -0,0 +1,328 @@ +/* + * Copyright 1991 Michael S. Warren and John K. Salmon. All Rights Reserved. + */ + +#ifndef NDIM + # error NDIM must be defined before reading this file. +#endif + +#if (NDIM!=3) && (NDIM!=2) + #error NDIM must be either 2 or 3 +#endif + +#ifdef __STDC__ +#define GLUE(a,b) a##b +#else +#define GLUE(a,b) a/**/b +#endif + +/* UGLY, but you can use these for parentheses inside the VV macros! */ +#define LPAREN ( +#define RPAREN ) +#define COMMA , +#define Dot(a, b) (VVinfix(a, *b, +)) + +#if (NDIM==3) + +#define Sinfix(s, op) s op s op s +#define Vinfix(a, op) a[0] op a[1] op a[2] +#define VVinfix(a, b, op) a[0] b[0] op a[1] b[1] op a[2] b[2] +/* Usage: printf(Sinfix("%g", " "), Vinfix(pos, COMMA)) */ + +#define VS(a, b) do { \ + a[0] b; \ + a[1] b; \ + a[2] b; \ + } while(0) + +#define VV(a, b) do { \ + a[0] b[0]; \ + a[1] b[1]; \ + a[2] b[2]; \ + } while(0) + +#define VVS(a, b, s) do { \ + a[0] b[0] s; \ + a[1] b[1] s; \ + a[2] b[2] s; \ + } while(0) + +#define VVV(a, b, c) do { \ + a[0] b[0] c[0]; \ + a[1] b[1] c[1]; \ + a[2] b[2] c[2]; \ + } while(0) + +#define VVVV(a, b, c, d) do { \ + a[0] b[0] c[0] d[0]; \ + a[1] b[1] c[1] d[1]; \ + a[2] b[2] c[2] d[2]; \ + } while(0) + + +#define VVVS(a, b, c, s) do { \ + a[0] b[0] c[0] s; \ + a[1] b[1] c[1] s; \ + a[2] b[2] c[2] s; \ + } while(0) + +#define VVVVS(a, b, c, d, s) do { \ + a[0] b[0] c[0] d[0] s; \ + a[1] b[1] c[1] d[1] s; \ + a[2] b[2] c[2] d[2] s; \ + } while(0) + + +#define VVVVV(a, b, c, d, e) do { \ + a[0] b[0] c[0] d[0] e[0]; \ + a[1] b[1] c[1] d[1] e[1]; \ + a[2] b[2] c[2] d[2] e[2]; \ + } while(0) + +#define VVVVVS(a, b, c, d, e, s) do { \ + a[0] b[0] c[0] d[0] e[0] s; \ + a[1] b[1] c[1] d[1] e[1] s; \ + a[2] b[2] c[2] d[2] e[2] s; \ + } while(0) + +#define VVVVVV(a, b, c, d, e, f) do { \ + a[0] b[0] c[0] d[0] e[0] f[0]; \ + a[1] b[1] c[1] d[1] e[1] f[1]; \ + a[2] b[2] c[2] d[2] e[2] f[2]; \ + } while(0) + +/* Eleven args! */ +#define Velv(a, b, c, d, e, f, g, h, i, j, k) do { \ + a[0] b[0] c[0] d[0] e[0] f[0] g[0] h[0] i[0] j[0] k[0]; \ + a[1] b[1] c[1] d[1] e[1] f[1] g[1] h[1] i[1] j[1] k[1]; \ + a[2] b[2] c[2] d[2] e[2] f[2] g[2] h[2] i[2] j[2] k[2]; \ + } while(0) + +/* And a couple of matrix operations to support gsw. */ +#define MS(a, b) do { \ + a[0][0] b; \ + a[0][1] b; \ + a[0][2] b; \ + a[1][0] b; \ + a[1][1] b; \ + a[1][2] b; \ + a[2][0] b; \ + a[2][1] b; \ + a[2][2] b; \ + } while(0) + +#define MVV(a, b, c) do { \ + a[0][0] b[0] c[0]; \ + a[0][1] b[0] c[1]; \ + a[0][2] b[0] c[2]; \ + a[1][0] b[1] c[0]; \ + a[1][1] b[1] c[1]; \ + a[1][2] b[1] c[2]; \ + a[2][0] b[2] c[0]; \ + a[2][1] b[2] c[1]; \ + a[2][2] b[2] c[2]; \ + } while(0) + +#define Vdecl(type, v) type v[NDIM] + +#define Dotx(a, b) \ + (GLUE(a,0)*GLUE(b,0) + GLUE(a,1)*GLUE(b,1) + GLUE(a,2)*GLUE(b,2)) + +/* Use for declarations */ +#define Vxd(a) \ + GLUE(a,0); \ + GLUE(a,1); \ + GLUE(a,2) + +/* Use in prototypes */ +#define Vxp(a) \ + GLUE(a,0), \ + GLUE(a,1), \ + GLUE(a,2) + +#define VxS(a, b) do { \ + GLUE(a,0) b; \ + GLUE(a,1) b; \ + GLUE(a,2) b; \ + } while(0) + +#define VxV(a, b) do { \ + GLUE(a,0) b[0]; \ + GLUE(a,1) b[1]; \ + GLUE(a,2) b[2]; \ + } while(0) + +#define VxdV(a, b) \ + GLUE(a,0) b[0]; \ + GLUE(a,1) b[1]; \ + GLUE(a,2) b[2] + +#define VVx(a, b) do { \ + a[0] GLUE(b,0); \ + a[1] GLUE(b,1); \ + a[2] GLUE(b,2); \ + } while(0) + +#define VxVx(a, b) do { \ + GLUE(a,0) GLUE(b,0); \ + GLUE(a,1) GLUE(b,1); \ + GLUE(a,2) GLUE(b,2); \ + } while(0) + + +#define VxVV(a, b, c) do { \ + GLUE(a,0) b[0] c[0]; \ + GLUE(a,1) b[1] c[1]; \ + GLUE(a,2) b[2] c[2]; \ + } while(0) + +#define VxVVS(a, b, c, s) do { \ + GLUE(a,0) b[0] c[0] s; \ + GLUE(a,1) b[1] c[1] s; \ + GLUE(a,2) b[2] c[2] s; \ + } while(0) + +#define VxVVx(a, b, c) do { \ + GLUE(a,0) b[0] GLUE(c,0); \ + GLUE(a,1) b[1] GLUE(c,1); \ + GLUE(a,2) b[2] GLUE(c,2); \ + } while(0) + +#define VxVxV(a, b, c) do { \ + GLUE(a,0) GLUE(b,0) c[0]; \ + GLUE(a,1) GLUE(b,1) c[1]; \ + GLUE(a,2) GLUE(b,2) c[2]; \ + } while(0) + +#define VxVxVx(a, b, c) do { \ + GLUE(a,0) GLUE(b,0) GLUE(c,0); \ + GLUE(a,1) GLUE(b,1) GLUE(c,1); \ + GLUE(a,2) GLUE(b,2) GLUE(c,2); \ + } while(0) + +#define VVxVx(a, b, c) do{ \ + a[0] GLUE(b,0) GLUE(c,0); \ + a[1] GLUE(b,1) GLUE(c,1); \ + a[2] GLUE(b,2) GLUE(c,2); \ + } while(0) + +#endif /* NDIM == 3 */ + +#if (NDIM==2) + +#define Sinfix(s, op) s op s +#define Vinfix(a, op) a[0] op a[1] +#define VVinfix(a, b, op) a[0] b[0] op a[1] b[1] +/* Usage: printf(Sinfix("%g", " "), Vinfix(pos, COMMA)) */ + +#define VS(a, b) do { \ + a[0] b; \ + a[1] b; \ + } while(0) + +#define VV(a, b) do { \ + a[0] b[0]; \ + a[1] b[1]; \ + } while(0) + +#define VVS(a, b, s) do { \ + a[0] b[0] s; \ + a[1] b[1] s; \ + a[2] b[2] s; \ + } while(0) + +#define VVV(a, b, c) do { \ + a[0] b[0] c[0]; \ + a[1] b[1] c[1]; \ + } while(0) + +#define VVVS(a, b, c, s) do { \ + a[0] b[0] c[0] s; \ + a[1] b[1] c[1] s; \ + } while(0) + +#define VVVVS(a, b, c, d, s) do { \ + a[0] b[0] c[0] d[0] s; \ + a[1] b[1] c[1] d[1] s; \ + } while(0) + +#define VVVV(a, b, c, d) do { \ + a[0] b[0] c[0] d[0]; \ + a[1] b[1] c[1] d[1]; \ + } while(0) + +#define VVVVV(a, b, c, d, e) do { \ + a[0] b[0] c[0] d[0] e[0]; \ + a[1] b[1] c[1] d[1] e[1]; \ + } while(0) + +#define Vdecl(type, v) type v[NDIM] + +#define Dotx(a, b) \ + (GLUE(a,0)*GLUE(b,0) + GLUE(a,1)*GLUE(b,1)) + +#define Vxd(a) \ + GLUE(a,0); \ + GLUE(a,1) + +#define VxS(a, b) do { \ + GLUE(a,0) b; \ + GLUE(a,1) b; \ + } while(0) + +#define VxV(a, b) do { \ + GLUE(a,0) b[0]; \ + GLUE(a,1) b[1]; \ + } while(0) + +#define VxdV(a, b) \ + GLUE(a,0) b[0]; \ + GLUE(a,1) b[1] + +#define VVx(a, b) do { \ + a[0] GLUE(b,0); \ + a[1] GLUE(b,1); \ + } while(0) + +#define VxVx(a, b) do { \ + GLUE(a,0) GLUE(b,0); \ + GLUE(a,1) GLUE(b,1); \ + } while(0) + + +#define VxVV(a, b, c) do { \ + GLUE(a,0) b[0] c[0]; \ + GLUE(a,1) b[1] c[1]; \ + } while(0) + +#define VxVVS(a, b, c, s) do { \ + GLUE(a,0) b[0] c[0] s; \ + GLUE(a,1) b[1] c[1] s; \ + } while(0) + +#define VxVVx(a, b, c) do { \ + GLUE(a,0) b[0] GLUE(c,0); \ + GLUE(a,1) b[1] GLUE(c,1); \ + } while(0) + +#define VxVVS(a, b, c, s) do { \ + GLUE(a,0) b[0] c[0] s; \ + GLUE(a,1) b[1] c[1] s; \ + } while(0) + +#define VVxVx(a, b, c) do{ \ + a[0] GLUE(b,0) GLUE(c,0); \ + a[1] GLUE(b,1) GLUE(c,1); \ + } while(0) + +#define VxVxV(a, b, c) do { \ + GLUE(a,0) GLUE(b,0) c[0]; \ + GLUE(a,1) GLUE(b,1) c[1]; \ + } while(0) + +#define VxVxVx(a, b, c) do { \ + GLUE(a,0) GLUE(b,0) GLUE(c,0); \ + GLUE(a,1) GLUE(b,1) GLUE(c,1); \ + } while(0) + +#endif /* NDIM == 2 */ diff --git a/external/libsdf/libSDF/GNUmakefile b/external/libsdf/libSDF/GNUmakefile index 062b13a..250abfc 100644 --- a/external/libsdf/libSDF/GNUmakefile +++ b/external/libsdf/libSDF/GNUmakefile @@ -16,31 +16,56 @@ include $(treedir)/Make-common/Make.$(ARCH) include $(treedir)/Make-common/Make.generic # These rules are slight modifications of the builtin ones -$(objdir)/%.c : %.y - $(YACC.y) $< - mv -f y.tab.c $@ +%.c : %.y + -($(YACC.y) $<; mv -f y.tab.c $@) -$(objdir)/%.c : %.l +%.c : %.l # commands to execute (built-in): - @$(RM) $@ - $(LEX.l) $< > $@ + -($(LEX.L) $< > y.lex.c; $(RM) $@; mv y.lex.c $@) # Makedepends can't pick these up... -$(objdir)/SDF-parse$(objsuf): SDF-private.h $(objdir)/SDF-lex.c $(objdir)/SDF-parse.c - (cd $(objdir); $(CC) $(CFLAGS) -I../../../include -I../.. -c SDF-parse.c) +$(objdir)/SDF-parse$(objsuf): SDF-private.h SDF-lex.c SDF-parse.c + (cd $(objdir); $(CC) $(CFLAGS) -I../../../include/libsdf -I../.. -c ../../SDF-parse.c) # DO NOT DELETE THIS LINE -- make depend depends on it. $(objdir)/SDF-parse$(objsuf): $(objdir)/SDF-parse$(objsuf): -$(objdir)/SDF-parse$(objsuf): $(treedir)/include/libsdf/protos.h -$(objdir)/SDF-parse$(objsuf): $(treedir)/include/libsdf/Msgs.h +$(objdir)/SDF-parse$(objsuf): +$(objdir)/SDF-parse$(objsuf): +$(objdir)/SDF-parse$(objsuf): +$(objdir)/SDF-parse$(objsuf): +$(objdir)/SDF-parse$(objsuf): +$(objdir)/SDF-parse$(objsuf): +$(objdir)/SDF-parse$(objsuf): +$(objdir)/SDF-parse$(objsuf): +$(objdir)/SDF-parse$(objsuf): +$(objdir)/SDF-parse$(objsuf): +$(objdir)/SDF-parse$(objsuf): +$(objdir)/SDF-parse$(objsuf): $(treedir)/include/libsdf/protos.h $(treedir)/include/libsdf/Msgs.h $(objdir)/SDF-parse$(objsuf): $(treedir)/include/libsdf/gccextensions.h SDF-private.h stdio.h $(objdir)/SDF-parse$(objsuf): $(treedir)/include/libsdf/mpmy_io.h $(objdir)/SDF-parse$(objsuf): $(treedir)/include/libsdf/SDF.h $(treedir)/include/libsdf/Malloc.h $(objdir)/SDF-parse$(objsuf): $(treedir)/include/libsdf/error.h SDF-lex.c $(objdir)/SDF-parse$(objsuf): $(objdir)/SDF-parse$(objsuf): +$(objdir)/SDF-parse$(objsuf): +$(objdir)/SDF-parse$(objsuf): +$(objdir)/SDF-parse$(objsuf): +$(objdir)/SDF-parse$(objsuf): +$(objdir)/SDFfuncs$(objsuf): +$(objdir)/SDFfuncs$(objsuf): +$(objdir)/SDFfuncs$(objsuf): +$(objdir)/SDFfuncs$(objsuf): +$(objdir)/SDFfuncs$(objsuf): +$(objdir)/SDFfuncs$(objsuf): +$(objdir)/SDFfuncs$(objsuf): +$(objdir)/SDFfuncs$(objsuf): +$(objdir)/SDFfuncs$(objsuf): +$(objdir)/SDFfuncs$(objsuf): +$(objdir)/SDFfuncs$(objsuf): +$(objdir)/SDFfuncs$(objsuf): +$(objdir)/SDFfuncs$(objsuf): $(objdir)/SDFfuncs$(objsuf): $(objdir)/SDFfuncs$(objsuf): $(objdir)/SDFfuncs$(objsuf): @@ -53,12 +78,35 @@ $(objdir)/SDFfuncs$(objsuf): $(treedir)/include/libsdf/error.h $(treedir)/includ $(objdir)/SDFfuncs$(objsuf): $(treedir)/include/libsdf/mpmy.h $(treedir)/include/libsdf/timers.h $(objdir)/SDFfuncs$(objsuf): $(objdir)/SDFget$(objsuf): stdio.h $(treedir)/include/libsdf/mpmy_io.h -$(objdir)/SDFget$(objsuf): $(treedir)/include/libsdf/error.h $(treedir)/include/libsdf/gccextensions.h -$(objdir)/SDFget$(objsuf): $(treedir)/include/libsdf/SDF.h +$(objdir)/SDFget$(objsuf): +$(objdir)/SDFget$(objsuf): +$(objdir)/SDFget$(objsuf): +$(objdir)/SDFget$(objsuf): +$(objdir)/SDFget$(objsuf): +$(objdir)/SDFget$(objsuf): +$(objdir)/SDFget$(objsuf): +$(objdir)/SDFget$(objsuf): +$(objdir)/SDFget$(objsuf): +$(objdir)/SDFget$(objsuf): $(treedir)/include/libsdf/error.h +$(objdir)/SDFget$(objsuf): $(treedir)/include/libsdf/gccextensions.h $(treedir)/include/libsdf/SDF.h +$(objdir)/SDFhdrio$(objsuf): +$(objdir)/SDFhdrio$(objsuf): +$(objdir)/SDFhdrio$(objsuf): +$(objdir)/SDFhdrio$(objsuf): +$(objdir)/SDFhdrio$(objsuf): +$(objdir)/SDFhdrio$(objsuf): $(objdir)/SDFhdrio$(objsuf): $(objdir)/SDFhdrio$(objsuf): $(treedir)/include/libsdf/Msgs.h $(treedir)/include/libsdf/gccextensions.h $(objdir)/SDFhdrio$(objsuf): $(treedir)/include/libsdf/error.h SDF-private.h -$(objdir)/SDFhdrio$(objsuf): stdio.h -$(objdir)/SDFhdrio$(objsuf): $(treedir)/include/libsdf/mpmy_io.h +$(objdir)/SDFhdrio$(objsuf): +$(objdir)/SDFhdrio$(objsuf): +$(objdir)/SDFhdrio$(objsuf): +$(objdir)/SDFhdrio$(objsuf): +$(objdir)/SDFhdrio$(objsuf): +$(objdir)/SDFhdrio$(objsuf): +$(objdir)/SDFhdrio$(objsuf): +$(objdir)/SDFhdrio$(objsuf): +$(objdir)/SDFhdrio$(objsuf): +$(objdir)/SDFhdrio$(objsuf): stdio.h $(treedir)/include/libsdf/mpmy_io.h $(objdir)/SDFhdrio$(objsuf): $(objdir)/SDFhdrio$(objsuf): $(treedir)/include/libsdf/SDF.h diff --git a/external/libsdf/libSDF/SDF-lex.c b/external/libsdf/libSDF/SDF-lex.c index 4dd8101..e69de29 100644 --- a/external/libsdf/libSDF/SDF-lex.c +++ b/external/libsdf/libSDF/SDF-lex.c @@ -1,2055 +0,0 @@ - -#line 3 "" - -#define YY_INT_ALIGNED short int - -/* A lexical scanner generated by flex */ - -#define FLEX_SCANNER -#define YY_FLEX_MAJOR_VERSION 2 -#define YY_FLEX_MINOR_VERSION 5 -#define YY_FLEX_SUBMINOR_VERSION 35 -#if YY_FLEX_SUBMINOR_VERSION > 0 -#define FLEX_BETA -#endif - -/* First, we deal with platform-specific or compiler-specific issues. */ - -/* begin standard C headers. */ -#include -#include -#include -#include - -/* end standard C headers. */ - -/* flex integer type definitions */ - -#ifndef FLEXINT_H -#define FLEXINT_H - -/* C99 systems have . Non-C99 systems may or may not. */ - -#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L - -/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, - * if you want the limit (max/min) macros for int types. - */ -#ifndef __STDC_LIMIT_MACROS -#define __STDC_LIMIT_MACROS 1 -#endif - -#include -typedef int8_t flex_int8_t; -typedef uint8_t flex_uint8_t; -typedef int16_t flex_int16_t; -typedef uint16_t flex_uint16_t; -typedef int32_t flex_int32_t; -typedef uint32_t flex_uint32_t; -#else -typedef signed char flex_int8_t; -typedef short int flex_int16_t; -typedef int flex_int32_t; -typedef unsigned char flex_uint8_t; -typedef unsigned short int flex_uint16_t; -typedef unsigned int flex_uint32_t; -#endif /* ! C99 */ - -/* Limits of integral types. */ -#ifndef INT8_MIN -#define INT8_MIN (-128) -#endif -#ifndef INT16_MIN -#define INT16_MIN (-32767-1) -#endif -#ifndef INT32_MIN -#define INT32_MIN (-2147483647-1) -#endif -#ifndef INT8_MAX -#define INT8_MAX (127) -#endif -#ifndef INT16_MAX -#define INT16_MAX (32767) -#endif -#ifndef INT32_MAX -#define INT32_MAX (2147483647) -#endif -#ifndef UINT8_MAX -#define UINT8_MAX (255U) -#endif -#ifndef UINT16_MAX -#define UINT16_MAX (65535U) -#endif -#ifndef UINT32_MAX -#define UINT32_MAX (4294967295U) -#endif - -#endif /* ! FLEXINT_H */ - -#ifdef __cplusplus - -/* The "const" storage-class-modifier is valid. */ -#define YY_USE_CONST - -#else /* ! __cplusplus */ - -/* C99 requires __STDC__ to be defined as 1. */ -#if defined (__STDC__) - -#define YY_USE_CONST - -#endif /* defined (__STDC__) */ -#endif /* ! __cplusplus */ - -#ifdef YY_USE_CONST -#define yyconst const -#else -#define yyconst -#endif - -/* Returned upon end-of-file. */ -#define YY_NULL 0 - -/* Promotes a possibly negative, possibly signed char to an unsigned - * integer for use as an array index. If the signed char is negative, - * we want to instead treat it as an 8-bit unsigned char, hence the - * double cast. - */ -#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) - -/* Enter a start condition. This macro really ought to take a parameter, - * but we do it the disgusting crufty way forced on us by the ()-less - * definition of BEGIN. - */ -#define BEGIN (yy_start) = 1 + 2 * - -/* Translate the current start state into a value that can be later handed - * to BEGIN to return to the state. The YYSTATE alias is for lex - * compatibility. - */ -#define YY_START (((yy_start) - 1) / 2) -#define YYSTATE YY_START - -/* Action number for EOF rule of a given start state. */ -#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) - -/* Special action meaning "start processing a new file". */ -#define YY_NEW_FILE yyrestart(yyin ) - -#define YY_END_OF_BUFFER_CHAR 0 - -/* Size of default input buffer. */ -#ifndef YY_BUF_SIZE -#define YY_BUF_SIZE 16384 -#endif - -/* The state buf must be large enough to hold one state per character in the main buffer. - */ -#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) - -#ifndef YY_TYPEDEF_YY_BUFFER_STATE -#define YY_TYPEDEF_YY_BUFFER_STATE -typedef struct yy_buffer_state *YY_BUFFER_STATE; -#endif - -extern int yyleng; - -extern FILE *yyin, *yyout; - -#define EOB_ACT_CONTINUE_SCAN 0 -#define EOB_ACT_END_OF_FILE 1 -#define EOB_ACT_LAST_MATCH 2 - - #define YY_LESS_LINENO(n) - -/* Return all but the first "n" matched characters back to the input stream. */ -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ - int yyless_macro_arg = (n); \ - YY_LESS_LINENO(yyless_macro_arg);\ - *yy_cp = (yy_hold_char); \ - YY_RESTORE_YY_MORE_OFFSET \ - (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ - YY_DO_BEFORE_ACTION; /* set up yytext again */ \ - } \ - while ( 0 ) - -#define unput(c) yyunput( c, (yytext_ptr) ) - -#ifndef YY_TYPEDEF_YY_SIZE_T -#define YY_TYPEDEF_YY_SIZE_T -typedef size_t yy_size_t; -#endif - -#ifndef YY_STRUCT_YY_BUFFER_STATE -#define YY_STRUCT_YY_BUFFER_STATE -struct yy_buffer_state - { - FILE *yy_input_file; - - char *yy_ch_buf; /* input buffer */ - char *yy_buf_pos; /* current position in input buffer */ - - /* Size of input buffer in bytes, not including room for EOB - * characters. - */ - yy_size_t yy_buf_size; - - /* Number of characters read into yy_ch_buf, not including EOB - * characters. - */ - int yy_n_chars; - - /* Whether we "own" the buffer - i.e., we know we created it, - * and can realloc() it to grow it, and should free() it to - * delete it. - */ - int yy_is_our_buffer; - - /* Whether this is an "interactive" input source; if so, and - * if we're using stdio for input, then we want to use getc() - * instead of fread(), to make sure we stop fetching input after - * each newline. - */ - int yy_is_interactive; - - /* Whether we're considered to be at the beginning of a line. - * If so, '^' rules will be active on the next match, otherwise - * not. - */ - int yy_at_bol; - - int yy_bs_lineno; /**< The line count. */ - int yy_bs_column; /**< The column count. */ - - /* Whether to try to fill the input buffer when we reach the - * end of it. - */ - int yy_fill_buffer; - - int yy_buffer_status; - -#define YY_BUFFER_NEW 0 -#define YY_BUFFER_NORMAL 1 - /* When an EOF's been seen but there's still some text to process - * then we mark the buffer as YY_EOF_PENDING, to indicate that we - * shouldn't try reading from the input source any more. We might - * still have a bunch of tokens to match, though, because of - * possible backing-up. - * - * When we actually see the EOF, we change the status to "new" - * (via yyrestart()), so that the user can continue scanning by - * just pointing yyin at a new input file. - */ -#define YY_BUFFER_EOF_PENDING 2 - - }; -#endif /* !YY_STRUCT_YY_BUFFER_STATE */ - -/* Stack of input buffers. */ -static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */ -static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */ -static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */ - -/* We provide macros for accessing buffer states in case in the - * future we want to put the buffer states in a more general - * "scanner state". - * - * Returns the top of the stack, or NULL. - */ -#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \ - ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ - : NULL) - -/* Same as previous macro, but useful when we know that the buffer stack is not - * NULL or when we need an lvalue. For internal use only. - */ -#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)] - -/* yy_hold_char holds the character lost when yytext is formed. */ -static char yy_hold_char; -static int yy_n_chars; /* number of characters read into yy_ch_buf */ -int yyleng; - -/* Points to current character in buffer. */ -static char *yy_c_buf_p = (char *) 0; -static int yy_init = 0; /* whether we need to initialize */ -static int yy_start = 0; /* start state number */ - -/* Flag which is used to allow yywrap()'s to do buffer switches - * instead of setting up a fresh yyin. A bit of a hack ... - */ -static int yy_did_buffer_switch_on_eof; - -void yyrestart (FILE *input_file ); -void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ); -YY_BUFFER_STATE yy_create_buffer (FILE *file,int size ); -void yy_delete_buffer (YY_BUFFER_STATE b ); -void yy_flush_buffer (YY_BUFFER_STATE b ); -void yypush_buffer_state (YY_BUFFER_STATE new_buffer ); -void yypop_buffer_state (void ); - -static void yyensure_buffer_stack (void ); -static void yy_load_buffer_state (void ); -static void yy_init_buffer (YY_BUFFER_STATE b,FILE *file ); - -#define YY_FLUSH_BUFFER yy_flush_buffer(YY_CURRENT_BUFFER ) - -YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size ); -YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str ); -YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,int len ); - -void *yyalloc (yy_size_t ); -void *yyrealloc (void *,yy_size_t ); -void yyfree (void * ); - -#define yy_new_buffer yy_create_buffer - -#define yy_set_interactive(is_interactive) \ - { \ - if ( ! YY_CURRENT_BUFFER ){ \ - yyensure_buffer_stack (); \ - YY_CURRENT_BUFFER_LVALUE = \ - yy_create_buffer(yyin,YY_BUF_SIZE ); \ - } \ - YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ - } - -#define yy_set_bol(at_bol) \ - { \ - if ( ! YY_CURRENT_BUFFER ){\ - yyensure_buffer_stack (); \ - YY_CURRENT_BUFFER_LVALUE = \ - yy_create_buffer(yyin,YY_BUF_SIZE ); \ - } \ - YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ - } - -#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) - -typedef unsigned char YY_CHAR; - -FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0; - -typedef int yy_state_type; - -extern int yylineno; - -int yylineno = 1; - -extern char *yytext; -#define yytext_ptr yytext - -static yy_state_type yy_get_previous_state (void ); -static yy_state_type yy_try_NUL_trans (yy_state_type current_state ); -static int yy_get_next_buffer (void ); -static void yy_fatal_error (yyconst char msg[] ); - -/* Done after the current pattern has been matched and before the - * corresponding action - sets up yytext. - */ -#define YY_DO_BEFORE_ACTION \ - (yytext_ptr) = yy_bp; \ - yyleng = (size_t) (yy_cp - yy_bp); \ - (yy_hold_char) = *yy_cp; \ - *yy_cp = '\0'; \ - (yy_c_buf_p) = yy_cp; - -#define YY_NUM_RULES 26 -#define YY_END_OF_BUFFER 27 -/* This struct is not used in this scanner, - but its presence is necessary. */ -struct yy_trans_info - { - flex_int32_t yy_verify; - flex_int32_t yy_nxt; - }; -static yyconst flex_int16_t yy_accept[119] = - { 0, - 0, 0, 27, 25, 3, 3, 25, 2, 25, 24, - 25, 25, 23, 23, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 0, 17, 2, 2, 0, 23, - 19, 4, 18, 22, 0, 0, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 2, 0, 18, - 0, 0, 20, 21, 16, 16, 16, 16, 7, 16, - 16, 16, 16, 16, 2, 0, 19, 0, 0, 18, - 16, 5, 16, 16, 16, 8, 16, 16, 16, 16, - 2, 0, 18, 16, 16, 10, 16, 16, 6, 16, - 16, 2, 16, 11, 16, 16, 12, 16, 2, 16, - - 9, 16, 16, 1, 16, 16, 13, 1, 1, 15, - 14, 1, 1, 1, 1, 1, 1, 0 - } ; - -static yyconst flex_int32_t yy_ec[256] = - { 0, - 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, - 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 2, 1, 4, 5, 1, 1, 1, 1, 1, - 1, 6, 7, 8, 9, 10, 11, 12, 13, 13, - 13, 14, 13, 15, 13, 16, 16, 1, 17, 1, - 18, 1, 1, 1, 19, 19, 19, 20, 21, 22, - 23, 24, 23, 23, 23, 23, 23, 23, 25, 23, - 23, 23, 26, 23, 23, 23, 23, 23, 23, 23, - 27, 1, 28, 1, 29, 1, 30, 31, 32, 33, - - 34, 35, 36, 37, 38, 23, 23, 39, 40, 41, - 42, 43, 23, 44, 45, 46, 47, 23, 23, 48, - 49, 23, 50, 1, 51, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1 - } ; - -static yyconst flex_int32_t yy_meta[52] = - { 0, - 1, 1, 2, 1, 1, 1, 1, 1, 1, 3, - 1, 4, 4, 4, 4, 4, 1, 1, 5, 5, - 4, 5, 6, 6, 6, 6, 1, 1, 6, 5, - 5, 5, 5, 4, 5, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, 6, 1, - 1 - } ; - -static yyconst flex_int16_t yy_base[125] = - { 0, - 0, 0, 281, 282, 282, 282, 276, 253, 42, 282, - 47, 272, 54, 55, 0, 228, 239, 233, 235, 232, - 230, 241, 34, 229, 265, 282, 242, 52, 69, 69, - 79, 282, 93, 219, 103, 0, 0, 220, 235, 217, - 221, 216, 220, 216, 217, 214, 212, 51, 116, 121, - 131, 136, 144, 0, 222, 211, 223, 223, 237, 215, - 220, 205, 201, 209, 78, 149, 154, 164, 169, 174, - 204, 0, 206, 198, 229, 0, 202, 195, 208, 203, - 75, 179, 184, 194, 203, 0, 207, 201, 0, 188, - 192, 72, 195, 0, 169, 159, 0, 170, 96, 169, - - 0, 141, 106, 85, 55, 42, 0, 48, 181, 0, - 0, 180, 115, 100, 128, 148, 27, 282, 207, 213, - 217, 218, 221, 226 - } ; - -static yyconst flex_int16_t yy_def[125] = - { 0, - 118, 1, 118, 118, 118, 118, 119, 120, 118, 118, - 118, 118, 118, 121, 122, 122, 122, 122, 122, 122, - 122, 122, 122, 122, 119, 118, 120, 120, 118, 121, - 118, 118, 118, 13, 118, 123, 122, 122, 122, 122, - 122, 122, 122, 122, 122, 122, 122, 120, 118, 118, - 118, 118, 118, 123, 122, 122, 122, 122, 122, 122, - 122, 122, 122, 122, 120, 118, 118, 118, 118, 118, - 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, - 120, 118, 118, 122, 122, 122, 122, 122, 122, 122, - 122, 120, 122, 122, 122, 122, 122, 122, 120, 122, - - 122, 122, 122, 124, 122, 122, 122, 124, 124, 122, - 122, 124, 124, 124, 124, 124, 124, 0, 118, 118, - 118, 118, 118, 118 - } ; - -static yyconst flex_int16_t yy_nxt[334] = - { 0, - 4, 5, 6, 7, 8, 4, 9, 10, 9, 11, - 12, 13, 14, 14, 14, 14, 10, 10, 15, 15, - 15, 15, 15, 15, 15, 15, 10, 10, 15, 15, - 16, 17, 18, 15, 19, 15, 15, 20, 21, 15, - 15, 15, 22, 15, 23, 15, 24, 15, 15, 10, - 10, 29, 109, 30, 30, 30, 30, 30, 31, 31, - 31, 31, 31, 33, 33, 34, 34, 34, 34, 30, - 45, 48, 65, 109, 35, 35, 28, 28, 33, 46, - 31, 31, 31, 31, 31, 111, 81, 35, 35, 35, - 31, 31, 31, 31, 31, 92, 99, 28, 110, 49, - - 28, 36, 35, 28, 50, 50, 50, 50, 50, 52, - 109, 52, 49, 51, 53, 53, 53, 53, 53, 104, - 115, 28, 66, 114, 66, 109, 51, 67, 67, 67, - 67, 67, 50, 50, 50, 50, 50, 69, 107, 69, - 109, 68, 70, 70, 70, 70, 70, 53, 53, 53, - 53, 53, 116, 109, 68, 53, 53, 53, 53, 53, - 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, - 82, 117, 82, 109, 106, 83, 83, 83, 83, 83, - 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, - 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, - - 112, 113, 105, 103, 102, 109, 109, 25, 25, 25, - 25, 25, 25, 27, 101, 27, 27, 27, 27, 30, - 30, 37, 37, 37, 54, 54, 108, 100, 108, 108, - 108, 108, 98, 97, 96, 95, 94, 93, 91, 90, - 89, 88, 87, 86, 85, 84, 80, 79, 78, 77, - 76, 75, 74, 73, 72, 71, 64, 63, 62, 61, - 60, 59, 58, 57, 56, 55, 118, 28, 26, 47, - 44, 43, 42, 41, 40, 39, 38, 32, 28, 26, - 118, 3, 118, 118, 118, 118, 118, 118, 118, 118, - 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, - - 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, - 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, - 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, - 118, 118, 118 - } ; - -static yyconst flex_int16_t yy_chk[334] = - { 0, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 9, 117, 9, 9, 9, 9, 9, 11, 11, - 11, 11, 11, 13, 14, 13, 13, 13, 13, 13, - 23, 28, 48, 108, 13, 14, 48, 28, 30, 23, - 29, 29, 29, 29, 29, 106, 65, 13, 14, 30, - 31, 31, 31, 31, 31, 81, 92, 92, 105, 31, - - 81, 13, 30, 65, 33, 33, 33, 33, 33, 35, - 104, 35, 31, 33, 35, 35, 35, 35, 35, 99, - 114, 99, 49, 113, 49, 114, 33, 49, 49, 49, - 49, 49, 50, 50, 50, 50, 50, 51, 103, 51, - 113, 50, 51, 51, 51, 51, 51, 52, 52, 52, - 52, 52, 115, 115, 50, 53, 53, 53, 53, 53, - 66, 66, 66, 66, 66, 67, 67, 67, 67, 67, - 68, 116, 68, 116, 102, 68, 68, 68, 68, 68, - 69, 69, 69, 69, 69, 70, 70, 70, 70, 70, - 82, 82, 82, 82, 82, 83, 83, 83, 83, 83, - - 109, 112, 100, 98, 96, 112, 109, 119, 119, 119, - 119, 119, 119, 120, 95, 120, 120, 120, 120, 121, - 121, 122, 122, 122, 123, 123, 124, 93, 124, 124, - 124, 124, 91, 90, 88, 87, 85, 84, 80, 79, - 78, 77, 75, 74, 73, 71, 64, 63, 62, 61, - 60, 59, 58, 57, 56, 55, 47, 46, 45, 44, - 43, 42, 41, 40, 39, 38, 34, 27, 25, 24, - 22, 21, 20, 19, 18, 17, 16, 12, 8, 7, - 3, 118, 118, 118, 118, 118, 118, 118, 118, 118, - 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, - - 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, - 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, - 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, - 118, 118, 118 - } ; - -static yy_state_type yy_last_accepting_state; -static char *yy_last_accepting_cpos; - -extern int yy_flex_debug; -int yy_flex_debug = 0; - -/* The intent behind this definition is that it'll catch - * any uses of REJECT which flex missed. - */ -#define REJECT reject_used_but_not_detected -#define yymore() yymore_used_but_not_detected -#define YY_MORE_ADJ 0 -#define YY_RESTORE_YY_MORE_OFFSET -char *yytext; -#line 1 "SDF-lex.l" -#line 2 "SDF-lex.l" -/* - 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. -*/ -#include -/* This define means we don't have to link with the lex library! */ -#define YY_SKIP_YYWRAP -#define yywrap() 1 - -/* This one is ugly. - Lex's output contains fprintf(yyout, of various error messages. - We try here to redirect them to a Msg_doalist. */ -#include -#include "Msgs.h" -#undef fprintf -#define fprintf MYFprintf -void MYFprintf(int *junk, const char *fmt, ...){ - va_list alist; - va_start(alist, fmt); - Msg_doalist(fmt, alist); - va_end(alist); -} - -#ifdef FLEX_SCANNER -/* Flex DOES have a much better way to handle non-standard input strategies. - This doesn't have to be this twisted to work with Flex, but if we are - going to continue to support lex, it's easiest to just follow along */ -#define YY_INPUT(buf, result, maxsize) \ - { \ - int c = SDF_Hdrgetc(); \ - /* Msgf(("YY_INPUT: c=%c\n", c)); */\ - result = (c==EOF) ? YY_NULL : (buf[0] = c, 1); \ - } -/* Flex also has some new-and-different behavior AFTER YY_INPUT has returned - NULL. In particular, all subsequent calls to yylex will immediately - return NULL unless yyrestart is called. If we were always using Flex, - I could attach this to the BEGIN rule, but I can't do that with lex, - so I have to call it from outside, e.g., in SDFyyprepare. */ -void SDFlexprepare(void){ - yyrestart(NULL); -} -#else /* Not FLEX_SCANNER */ -void SDFlexprepare(void){} -#endif -#line 611 "" - -#define INITIAL 0 - -#ifndef YY_NO_UNISTD_H -/* Special case for "unistd.h", since it is non-ANSI. We include it way - * down here because we want the user's section 1 to have been scanned first. - * The user has a chance to override it with an option. - */ -#include -#endif - -#ifndef YY_EXTRA_TYPE -#define YY_EXTRA_TYPE void * -#endif - -static int yy_init_globals (void ); - -/* Accessor methods to globals. - These are made visible to non-reentrant scanners for convenience. */ - -int yylex_destroy (void ); - -int yyget_debug (void ); - -void yyset_debug (int debug_flag ); - -YY_EXTRA_TYPE yyget_extra (void ); - -void yyset_extra (YY_EXTRA_TYPE user_defined ); - -FILE *yyget_in (void ); - -void yyset_in (FILE * in_str ); - -FILE *yyget_out (void ); - -void yyset_out (FILE * out_str ); - -int yyget_leng (void ); - -char *yyget_text (void ); - -int yyget_lineno (void ); - -void yyset_lineno (int line_number ); - -/* Macros after this point can all be overridden by user definitions in - * section 1. - */ - -#ifndef YY_SKIP_YYWRAP -#ifdef __cplusplus -extern "C" int yywrap (void ); -#else -extern int yywrap (void ); -#endif -#endif - - static void yyunput (int c,char *buf_ptr ); - -#ifndef yytext_ptr -static void yy_flex_strncpy (char *,yyconst char *,int ); -#endif - -#ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * ); -#endif - -#ifndef YY_NO_INPUT - -#ifdef __cplusplus -static int yyinput (void ); -#else -static int input (void ); -#endif - -#endif - -/* Amount of stuff to slurp up with each read. */ -#ifndef YY_READ_BUF_SIZE -#define YY_READ_BUF_SIZE 8192 -#endif - -/* Copy whatever the last rule matched to the standard output. */ -#ifndef ECHO -/* This used to be an fputs(), but since the string might contain NUL's, - * we now use fwrite(). - */ -#define ECHO fwrite( yytext, yyleng, 1, yyout ) -#endif - -/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, - * is returned in "result". - */ -#ifndef YY_INPUT -#define YY_INPUT(buf,result,max_size) \ - if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ - { \ - int c = '*'; \ - int n; \ - for ( n = 0; n < max_size && \ - (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ - buf[n] = (char) c; \ - if ( c == '\n' ) \ - buf[n++] = (char) c; \ - if ( c == EOF && ferror( yyin ) ) \ - YY_FATAL_ERROR( "input in flex scanner failed" ); \ - result = n; \ - } \ - else \ - { \ - errno=0; \ - while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \ - { \ - if( errno != EINTR) \ - { \ - YY_FATAL_ERROR( "input in flex scanner failed" ); \ - break; \ - } \ - errno=0; \ - clearerr(yyin); \ - } \ - }\ -\ - -#endif - -/* No semi-colon after return; correct usage is to write "yyterminate();" - - * we don't want an extra ';' after the "return" because that will cause - * some compilers to complain about unreachable statements. - */ -#ifndef yyterminate -#define yyterminate() return YY_NULL -#endif - -/* Number of entries by which start-condition stack grows. */ -#ifndef YY_START_STACK_INCR -#define YY_START_STACK_INCR 25 -#endif - -/* Report a fatal error. */ -#ifndef YY_FATAL_ERROR -#define YY_FATAL_ERROR(msg) yy_fatal_error( msg ) -#endif - -/* end tables serialization structures and prototypes */ - -/* Default declaration of generated scanner - a define so the user can - * easily add parameters. - */ -#ifndef YY_DECL -#define YY_DECL_IS_OURS 1 - -extern int yylex (void); - -#define YY_DECL int yylex (void) -#endif /* !YY_DECL */ - -/* Code executed at the beginning of each rule, after yytext and yyleng - * have been set up. - */ -#ifndef YY_USER_ACTION -#define YY_USER_ACTION -#endif - -/* Code executed at the end of each rule. */ -#ifndef YY_BREAK -#define YY_BREAK break; -#endif - -#define YY_RULE_SETUP \ - YY_USER_ACTION - -/** The main scanner function which does all the work. - */ -YY_DECL -{ - register yy_state_type yy_current_state; - register char *yy_cp, *yy_bp; - register int yy_act; - -#line 60 "SDF-lex.l" - -#line 795 "" - - if ( !(yy_init) ) - { - (yy_init) = 1; - -#ifdef YY_USER_INIT - YY_USER_INIT; -#endif - - if ( ! (yy_start) ) - (yy_start) = 1; /* first start state */ - - if ( ! yyin ) - yyin = stdin; - - if ( ! yyout ) - yyout = stdout; - - if ( ! YY_CURRENT_BUFFER ) { - yyensure_buffer_stack (); - YY_CURRENT_BUFFER_LVALUE = - yy_create_buffer(yyin,YY_BUF_SIZE ); - } - - yy_load_buffer_state( ); - } - - while ( 1 ) /* loops until end-of-file is reached */ - { - yy_cp = (yy_c_buf_p); - - /* Support of yytext. */ - *yy_cp = (yy_hold_char); - - /* yy_bp points to the position in yy_ch_buf of the start of - * the current run. - */ - yy_bp = yy_cp; - - yy_current_state = (yy_start); -yy_match: - do - { - register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; - if ( yy_accept[yy_current_state] ) - { - (yy_last_accepting_state) = yy_current_state; - (yy_last_accepting_cpos) = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 119 ) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - ++yy_cp; - } - while ( yy_base[yy_current_state] != 282 ); - -yy_find_action: - yy_act = yy_accept[yy_current_state]; - if ( yy_act == 0 ) - { /* have to back up */ - yy_cp = (yy_last_accepting_cpos); - yy_current_state = (yy_last_accepting_state); - yy_act = yy_accept[yy_current_state]; - } - - YY_DO_BEFORE_ACTION; - -do_action: /* This label is used only to access EOF actions. */ - - switch ( yy_act ) - { /* beginning of action switch */ - case 0: /* must back up */ - /* undo the effects of YY_DO_BEFORE_ACTION */ - *yy_cp = (yy_hold_char); - yy_cp = (yy_last_accepting_cpos); - yy_current_state = (yy_last_accepting_state); - goto yy_find_action; - -case 1: -YY_RULE_SETUP -#line 61 "SDF-lex.l" -{SDFlineno++; return EOHDR;} /* Terminate the header on a comment line */ - YY_BREAK -case 2: -YY_RULE_SETUP -#line 62 "SDF-lex.l" -{SDFlineno++;} /* Otherwise, skip comments from '#' to eol. */ - YY_BREAK -case 3: -/* rule 3 can match eol */ -YY_RULE_SETUP -#line 63 "SDF-lex.l" -{if(yytext[0] == '\n') SDFlineno++;} /* skip white space. count lines*/ - YY_BREAK -case 4: -YY_RULE_SETUP -#line 64 "SDF-lex.l" -{ int c; - loop: - while((c=input()) != '*') {if(c=='\n') SDFlineno++;} - switch(input()){ - case '/': break; - case '*': unput('*'); - default: goto loop; - } - } /* Skip normal C comments. (no nesting) */ - YY_BREAK -case 5: -YY_RULE_SETUP -#line 73 "SDF-lex.l" -{yylval.type = SDF_CHAR; return TYPE;} - YY_BREAK -case 6: -YY_RULE_SETUP -#line 74 "SDF-lex.l" -{yylval.type = SDF_SHORT; return TYPE;} - YY_BREAK -case 7: -YY_RULE_SETUP -#line 75 "SDF-lex.l" -{yylval.type = SDF_INT; return TYPE;} - YY_BREAK -case 8: -YY_RULE_SETUP -#line 76 "SDF-lex.l" -{yylval.type = SDF_LONG; return TYPE;} - YY_BREAK -case 9: -YY_RULE_SETUP -#line 77 "SDF-lex.l" -{yylval.type = SDF_INT64; return TYPE;} - YY_BREAK -case 10: -YY_RULE_SETUP -#line 78 "SDF-lex.l" -{yylval.type = SDF_FLOAT; return TYPE;} - YY_BREAK -case 11: -YY_RULE_SETUP -#line 79 "SDF-lex.l" -{yylval.type = SDF_DOUBLE; return TYPE;} - YY_BREAK -case 12: -YY_RULE_SETUP -#line 80 "SDF-lex.l" -{return STRUCT;} - YY_BREAK -case 13: -YY_RULE_SETUP -#line 81 "SDF-lex.l" -; /* WARNING. The keyword 'unsigned' is skipped entirely. */ - YY_BREAK -case 14: -YY_RULE_SETUP -#line 82 "SDF-lex.l" -{return PARAMETER;} - YY_BREAK -case 15: -YY_RULE_SETUP -#line 83 "SDF-lex.l" -{yylval.valueparam = BYTEORDER; return VALUEPARAM;} - YY_BREAK -case 16: -YY_RULE_SETUP -#line 84 "SDF-lex.l" -{yylval.string = Malloc(yyleng+1); - strcpy(yylval.string, (char *)yytext); -#if YYDEBUG - if(yydebug) - printf("lex-malloc(%d) at 0x%lx\n", - yyleng+1, (unsigned long)yylval.string); -#endif - return NAME;} - YY_BREAK -case 17: -/* rule 17 can match eol */ -YY_RULE_SETUP -#line 92 "SDF-lex.l" -{ - /* strings extend to the next double-quote. */ - /* there are no escapes, and no exceptions. */ - /* We fiddle with the yyleng so we only get the contents in yylval. */ - /* Newlines embedded in strings will be missed by SDFlineno! */ - yylval.constant.u.stringval = Malloc(yyleng-1); - strncpy(yylval.constant.u.stringval, (char *)yytext+1, yyleng-2); - yylval.constant.u.stringval[yyleng-2] = '\0'; - yylval.constant.type = SDF_STRING; -#if YYDEBUG - if(yydebug) - printf("lex-malloc(%d) = 0x%lx\n", yyleng-1, - (unsigned long)yylval.constant.u.stringval); -#endif - return CONST;} - YY_BREAK -case 18: -#line 108 "SDF-lex.l" -case 19: -#line 109 "SDF-lex.l" -case 20: -YY_RULE_SETUP -#line 109 "SDF-lex.l" -{ - yylval.constant.type = SDF_DOUBLE; - sscanf((char *)yytext, "%lf", &yylval.constant.u.doubleval); - return CONST;} - YY_BREAK -case 21: -YY_RULE_SETUP -#line 113 "SDF-lex.l" -{ - yylval.constant.type = SDF_INT64; -#if __WORDSIZE==64 - sscanf((char *)yytext+2, "%lx", &yylval.constant.u.int64val); -#else - sscanf((char *)yytext+2, "%llx", &yylval.constant.u.int64val); -#endif - return CONST;} - YY_BREAK -case 22: -YY_RULE_SETUP -#line 121 "SDF-lex.l" -{ - yylval.constant.type = SDF_INT64; -#if __WORDSIZE==64 - sscanf((char *)yytext+1, "%lo", &yylval.constant.u.int64val); -#else - sscanf((char *)yytext+1, "%llo", &yylval.constant.u.int64val); -#endif - return CONST;} - YY_BREAK -case 23: -YY_RULE_SETUP -#line 129 "SDF-lex.l" -{ - yylval.constant.type = SDF_INT64; -#if __WORDSIZE==64 - sscanf((char *)yytext, "%ld", &yylval.constant.u.int64val); -#else - sscanf((char *)yytext, "%lld", &yylval.constant.u.int64val); -#endif - return CONST;} - YY_BREAK -case 24: -YY_RULE_SETUP -#line 137 "SDF-lex.l" -{return yytext[0];} - YY_BREAK -case 25: -YY_RULE_SETUP -#line 138 "SDF-lex.l" -{yyerror("lexer confusion on char: <%c>, line: %d\n", (yytext[0])?yytext[0]:'?', - SDFlineno); return LEXERROR;} - YY_BREAK -case 26: -YY_RULE_SETUP -#line 140 "SDF-lex.l" -ECHO; - YY_BREAK -#line 1058 "" -case YY_STATE_EOF(INITIAL): - yyterminate(); - - case YY_END_OF_BUFFER: - { - /* Amount of text matched not including the EOB char. */ - int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1; - - /* Undo the effects of YY_DO_BEFORE_ACTION. */ - *yy_cp = (yy_hold_char); - YY_RESTORE_YY_MORE_OFFSET - - if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) - { - /* We're scanning a new file or input source. It's - * possible that this happened because the user - * just pointed yyin at a new source and called - * yylex(). If so, then we have to assure - * consistency between YY_CURRENT_BUFFER and our - * globals. Here is the right place to do so, because - * this is the first action (other than possibly a - * back-up) that will match for the new input source. - */ - (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; - YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; - YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; - } - - /* Note that here we test for yy_c_buf_p "<=" to the position - * of the first EOB in the buffer, since yy_c_buf_p will - * already have been incremented past the NUL character - * (since all states make transitions on EOB to the - * end-of-buffer state). Contrast this with the test - * in input(). - */ - if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) - { /* This was really a NUL. */ - yy_state_type yy_next_state; - - (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state( ); - - /* Okay, we're now positioned to make the NUL - * transition. We couldn't have - * yy_get_previous_state() go ahead and do it - * for us because it doesn't know how to deal - * with the possibility of jamming (and we don't - * want to build jamming into it because then it - * will run more slowly). - */ - - yy_next_state = yy_try_NUL_trans( yy_current_state ); - - yy_bp = (yytext_ptr) + YY_MORE_ADJ; - - if ( yy_next_state ) - { - /* Consume the NUL. */ - yy_cp = ++(yy_c_buf_p); - yy_current_state = yy_next_state; - goto yy_match; - } - - else - { - yy_cp = (yy_c_buf_p); - goto yy_find_action; - } - } - - else switch ( yy_get_next_buffer( ) ) - { - case EOB_ACT_END_OF_FILE: - { - (yy_did_buffer_switch_on_eof) = 0; - - if ( yywrap( ) ) - { - /* Note: because we've taken care in - * yy_get_next_buffer() to have set up - * yytext, we can now set up - * yy_c_buf_p so that if some total - * hoser (like flex itself) wants to - * call the scanner after we return the - * YY_NULL, it'll still work - another - * YY_NULL will get returned. - */ - (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ; - - yy_act = YY_STATE_EOF(YY_START); - goto do_action; - } - - else - { - if ( ! (yy_did_buffer_switch_on_eof) ) - YY_NEW_FILE; - } - break; - } - - case EOB_ACT_CONTINUE_SCAN: - (yy_c_buf_p) = - (yytext_ptr) + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state( ); - - yy_cp = (yy_c_buf_p); - yy_bp = (yytext_ptr) + YY_MORE_ADJ; - goto yy_match; - - case EOB_ACT_LAST_MATCH: - (yy_c_buf_p) = - &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)]; - - yy_current_state = yy_get_previous_state( ); - - yy_cp = (yy_c_buf_p); - yy_bp = (yytext_ptr) + YY_MORE_ADJ; - goto yy_find_action; - } - break; - } - - default: - YY_FATAL_ERROR( - "fatal flex scanner internal error--no action found" ); - } /* end of action switch */ - } /* end of scanning one token */ -} /* end of yylex */ - -/* yy_get_next_buffer - try to read in a new buffer - * - * Returns a code representing an action: - * EOB_ACT_LAST_MATCH - - * EOB_ACT_CONTINUE_SCAN - continue scanning from current position - * EOB_ACT_END_OF_FILE - end of file - */ -static int yy_get_next_buffer (void) -{ - register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; - register char *source = (yytext_ptr); - register int number_to_move, i; - int ret_val; - - if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) - YY_FATAL_ERROR( - "fatal flex scanner internal error--end of buffer missed" ); - - if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) - { /* Don't try to fill the buffer, so this is an EOF. */ - if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 ) - { - /* We matched a single character, the EOB, so - * treat this as a final EOF. - */ - return EOB_ACT_END_OF_FILE; - } - - else - { - /* We matched some text prior to the EOB, first - * process it. - */ - return EOB_ACT_LAST_MATCH; - } - } - - /* Try to read more data. */ - - /* First move last chars to start of buffer. */ - number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1; - - for ( i = 0; i < number_to_move; ++i ) - *(dest++) = *(source++); - - if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) - /* don't do the read, it's not guaranteed to return an EOF, - * just force an EOF - */ - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0; - - else - { - int num_to_read = - YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; - - while ( num_to_read <= 0 ) - { /* Not enough room in the buffer - grow it. */ - - /* just a shorter name for the current buffer */ - YY_BUFFER_STATE b = YY_CURRENT_BUFFER; - - int yy_c_buf_p_offset = - (int) ((yy_c_buf_p) - b->yy_ch_buf); - - if ( b->yy_is_our_buffer ) - { - int new_size = b->yy_buf_size * 2; - - if ( new_size <= 0 ) - b->yy_buf_size += b->yy_buf_size / 8; - else - b->yy_buf_size *= 2; - - b->yy_ch_buf = (char *) - /* Include room in for 2 EOB chars. */ - yyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ); - } - else - /* Can't grow it, we don't own it. */ - b->yy_ch_buf = 0; - - if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( - "fatal error - scanner input buffer overflow" ); - - (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset]; - - num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - - number_to_move - 1; - - } - - if ( num_to_read > YY_READ_BUF_SIZE ) - num_to_read = YY_READ_BUF_SIZE; - - /* Read in more data. */ - YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), - (yy_n_chars), (size_t) num_to_read ); - - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); - } - - if ( (yy_n_chars) == 0 ) - { - if ( number_to_move == YY_MORE_ADJ ) - { - ret_val = EOB_ACT_END_OF_FILE; - yyrestart(yyin ); - } - - else - { - ret_val = EOB_ACT_LAST_MATCH; - YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = - YY_BUFFER_EOF_PENDING; - } - } - - else - ret_val = EOB_ACT_CONTINUE_SCAN; - - if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { - /* Extend the array by 50%, plus the number we really need. */ - yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ); - if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); - } - - (yy_n_chars) += number_to_move; - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; - - (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; - - return ret_val; -} - -/* yy_get_previous_state - get the state just before the EOB char was reached */ - - static yy_state_type yy_get_previous_state (void) -{ - register yy_state_type yy_current_state; - register char *yy_cp; - - yy_current_state = (yy_start); - - for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) - { - register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); - if ( yy_accept[yy_current_state] ) - { - (yy_last_accepting_state) = yy_current_state; - (yy_last_accepting_cpos) = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 119 ) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - } - - return yy_current_state; -} - -/* yy_try_NUL_trans - try to make a transition on the NUL character - * - * synopsis - * next_state = yy_try_NUL_trans( current_state ); - */ - static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state ) -{ - register int yy_is_jam; - register char *yy_cp = (yy_c_buf_p); - - register YY_CHAR yy_c = 1; - if ( yy_accept[yy_current_state] ) - { - (yy_last_accepting_state) = yy_current_state; - (yy_last_accepting_cpos) = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 119 ) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - yy_is_jam = (yy_current_state == 118); - - return yy_is_jam ? 0 : yy_current_state; -} - - static void yyunput (int c, register char * yy_bp ) -{ - register char *yy_cp; - - yy_cp = (yy_c_buf_p); - - /* undo effects of setting up yytext */ - *yy_cp = (yy_hold_char); - - if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) - { /* need to shift things up to make room */ - /* +2 for EOB chars. */ - register int number_to_move = (yy_n_chars) + 2; - register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ - YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; - register char *source = - &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; - - while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) - *--dest = *--source; - - yy_cp += (int) (dest - source); - yy_bp += (int) (dest - source); - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = - (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size; - - if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) - YY_FATAL_ERROR( "flex scanner push-back overflow" ); - } - - *--yy_cp = (char) c; - - (yytext_ptr) = yy_bp; - (yy_hold_char) = *yy_cp; - (yy_c_buf_p) = yy_cp; -} - -#ifndef YY_NO_INPUT -#ifdef __cplusplus - static int yyinput (void) -#else - static int input (void) -#endif - -{ - int c; - - *(yy_c_buf_p) = (yy_hold_char); - - if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR ) - { - /* yy_c_buf_p now points to the character we want to return. - * If this occurs *before* the EOB characters, then it's a - * valid NUL; if not, then we've hit the end of the buffer. - */ - if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) - /* This was really a NUL. */ - *(yy_c_buf_p) = '\0'; - - else - { /* need more input */ - int offset = (yy_c_buf_p) - (yytext_ptr); - ++(yy_c_buf_p); - - switch ( yy_get_next_buffer( ) ) - { - case EOB_ACT_LAST_MATCH: - /* This happens because yy_g_n_b() - * sees that we've accumulated a - * token and flags that we need to - * try matching the token before - * proceeding. But for input(), - * there's no matching to consider. - * So convert the EOB_ACT_LAST_MATCH - * to EOB_ACT_END_OF_FILE. - */ - - /* Reset buffer status. */ - yyrestart(yyin ); - - /*FALLTHROUGH*/ - - case EOB_ACT_END_OF_FILE: - { - if ( yywrap( ) ) - return EOF; - - if ( ! (yy_did_buffer_switch_on_eof) ) - YY_NEW_FILE; -#ifdef __cplusplus - return yyinput(); -#else - return input(); -#endif - } - - case EOB_ACT_CONTINUE_SCAN: - (yy_c_buf_p) = (yytext_ptr) + offset; - break; - } - } - } - - c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */ - *(yy_c_buf_p) = '\0'; /* preserve yytext */ - (yy_hold_char) = *++(yy_c_buf_p); - - return c; -} -#endif /* ifndef YY_NO_INPUT */ - -/** Immediately switch to a different input stream. - * @param input_file A readable stream. - * - * @note This function does not reset the start condition to @c INITIAL . - */ - void yyrestart (FILE * input_file ) -{ - - if ( ! YY_CURRENT_BUFFER ){ - yyensure_buffer_stack (); - YY_CURRENT_BUFFER_LVALUE = - yy_create_buffer(yyin,YY_BUF_SIZE ); - } - - yy_init_buffer(YY_CURRENT_BUFFER,input_file ); - yy_load_buffer_state( ); -} - -/** Switch to a different input buffer. - * @param new_buffer The new input buffer. - * - */ - void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ) -{ - - /* TODO. We should be able to replace this entire function body - * with - * yypop_buffer_state(); - * yypush_buffer_state(new_buffer); - */ - yyensure_buffer_stack (); - if ( YY_CURRENT_BUFFER == new_buffer ) - return; - - if ( YY_CURRENT_BUFFER ) - { - /* Flush out information for old buffer. */ - *(yy_c_buf_p) = (yy_hold_char); - YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); - } - - YY_CURRENT_BUFFER_LVALUE = new_buffer; - yy_load_buffer_state( ); - - /* We don't actually know whether we did this switch during - * EOF (yywrap()) processing, but the only time this flag - * is looked at is after yywrap() is called, so it's safe - * to go ahead and always set it. - */ - (yy_did_buffer_switch_on_eof) = 1; -} - -static void yy_load_buffer_state (void) -{ - (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; - (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; - yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; - (yy_hold_char) = *(yy_c_buf_p); -} - -/** Allocate and initialize an input buffer state. - * @param file A readable stream. - * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. - * - * @return the allocated buffer state. - */ - YY_BUFFER_STATE yy_create_buffer (FILE * file, int size ) -{ - YY_BUFFER_STATE b; - - b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) ); - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); - - b->yy_buf_size = size; - - /* yy_ch_buf has to be 2 characters longer than the size given because - * we need to put in 2 end-of-buffer characters. - */ - b->yy_ch_buf = (char *) yyalloc(b->yy_buf_size + 2 ); - if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); - - b->yy_is_our_buffer = 1; - - yy_init_buffer(b,file ); - - return b; -} - -/** Destroy the buffer. - * @param b a buffer created with yy_create_buffer() - * - */ - void yy_delete_buffer (YY_BUFFER_STATE b ) -{ - - if ( ! b ) - return; - - if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ - YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; - - if ( b->yy_is_our_buffer ) - yyfree((void *) b->yy_ch_buf ); - - yyfree((void *) b ); -} - -#ifndef __cplusplus -extern int isatty (int ); -#endif /* __cplusplus */ - -/* Initializes or reinitializes a buffer. - * This function is sometimes called more than once on the same buffer, - * such as during a yyrestart() or at EOF. - */ - static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file ) - -{ - int oerrno = errno; - - yy_flush_buffer(b ); - - b->yy_input_file = file; - b->yy_fill_buffer = 1; - - /* If b is the current buffer, then yy_init_buffer was _probably_ - * called from yyrestart() or through yy_get_next_buffer. - * In that case, we don't want to reset the lineno or column. - */ - if (b != YY_CURRENT_BUFFER){ - b->yy_bs_lineno = 1; - b->yy_bs_column = 0; - } - - b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; - - errno = oerrno; -} - -/** Discard all buffered characters. On the next scan, YY_INPUT will be called. - * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. - * - */ - void yy_flush_buffer (YY_BUFFER_STATE b ) -{ - if ( ! b ) - return; - - b->yy_n_chars = 0; - - /* We always need two end-of-buffer characters. The first causes - * a transition to the end-of-buffer state. The second causes - * a jam in that state. - */ - b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; - b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; - - b->yy_buf_pos = &b->yy_ch_buf[0]; - - b->yy_at_bol = 1; - b->yy_buffer_status = YY_BUFFER_NEW; - - if ( b == YY_CURRENT_BUFFER ) - yy_load_buffer_state( ); -} - -/** Pushes the new state onto the stack. The new state becomes - * the current state. This function will allocate the stack - * if necessary. - * @param new_buffer The new state. - * - */ -void yypush_buffer_state (YY_BUFFER_STATE new_buffer ) -{ - if (new_buffer == NULL) - return; - - yyensure_buffer_stack(); - - /* This block is copied from yy_switch_to_buffer. */ - if ( YY_CURRENT_BUFFER ) - { - /* Flush out information for old buffer. */ - *(yy_c_buf_p) = (yy_hold_char); - YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); - } - - /* Only push if top exists. Otherwise, replace top. */ - if (YY_CURRENT_BUFFER) - (yy_buffer_stack_top)++; - YY_CURRENT_BUFFER_LVALUE = new_buffer; - - /* copied from yy_switch_to_buffer. */ - yy_load_buffer_state( ); - (yy_did_buffer_switch_on_eof) = 1; -} - -/** Removes and deletes the top of the stack, if present. - * The next element becomes the new top. - * - */ -void yypop_buffer_state (void) -{ - if (!YY_CURRENT_BUFFER) - return; - - yy_delete_buffer(YY_CURRENT_BUFFER ); - YY_CURRENT_BUFFER_LVALUE = NULL; - if ((yy_buffer_stack_top) > 0) - --(yy_buffer_stack_top); - - if (YY_CURRENT_BUFFER) { - yy_load_buffer_state( ); - (yy_did_buffer_switch_on_eof) = 1; - } -} - -/* Allocates the stack if it does not exist. - * Guarantees space for at least one push. - */ -static void yyensure_buffer_stack (void) -{ - int num_to_alloc; - - if (!(yy_buffer_stack)) { - - /* First allocation is just for 2 elements, since we don't know if this - * scanner will even need a stack. We use 2 instead of 1 to avoid an - * immediate realloc on the next call. - */ - num_to_alloc = 1; - (yy_buffer_stack) = (struct yy_buffer_state**)yyalloc - (num_to_alloc * sizeof(struct yy_buffer_state*) - ); - if ( ! (yy_buffer_stack) ) - YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); - - memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); - - (yy_buffer_stack_max) = num_to_alloc; - (yy_buffer_stack_top) = 0; - return; - } - - if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ - - /* Increase the buffer to prepare for a possible push. */ - int grow_size = 8 /* arbitrary grow size */; - - num_to_alloc = (yy_buffer_stack_max) + grow_size; - (yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc - ((yy_buffer_stack), - num_to_alloc * sizeof(struct yy_buffer_state*) - ); - if ( ! (yy_buffer_stack) ) - YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); - - /* zero only the new slots.*/ - memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); - (yy_buffer_stack_max) = num_to_alloc; - } -} - -/** Setup the input buffer state to scan directly from a user-specified character buffer. - * @param base the character buffer - * @param size the size in bytes of the character buffer - * - * @return the newly allocated buffer state object. - */ -YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size ) -{ - YY_BUFFER_STATE b; - - if ( size < 2 || - base[size-2] != YY_END_OF_BUFFER_CHAR || - base[size-1] != YY_END_OF_BUFFER_CHAR ) - /* They forgot to leave room for the EOB's. */ - return 0; - - b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) ); - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); - - b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ - b->yy_buf_pos = b->yy_ch_buf = base; - b->yy_is_our_buffer = 0; - b->yy_input_file = 0; - b->yy_n_chars = b->yy_buf_size; - b->yy_is_interactive = 0; - b->yy_at_bol = 1; - b->yy_fill_buffer = 0; - b->yy_buffer_status = YY_BUFFER_NEW; - - yy_switch_to_buffer(b ); - - return b; -} - -/** Setup the input buffer state to scan a string. The next call to yylex() will - * scan from a @e copy of @a str. - * @param yystr a NUL-terminated string to scan - * - * @return the newly allocated buffer state object. - * @note If you want to scan bytes that may contain NUL values, then use - * yy_scan_bytes() instead. - */ -YY_BUFFER_STATE yy_scan_string (yyconst char * yystr ) -{ - - return yy_scan_bytes(yystr,strlen(yystr) ); -} - -/** Setup the input buffer state to scan the given bytes. The next call to yylex() will - * scan from a @e copy of @a bytes. - * @param bytes the byte buffer to scan - * @param len the number of bytes in the buffer pointed to by @a bytes. - * - * @return the newly allocated buffer state object. - */ -YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, int _yybytes_len ) -{ - YY_BUFFER_STATE b; - char *buf; - yy_size_t n; - int i; - - /* Get memory for full buffer, including space for trailing EOB's. */ - n = _yybytes_len + 2; - buf = (char *) yyalloc(n ); - if ( ! buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); - - for ( i = 0; i < _yybytes_len; ++i ) - buf[i] = yybytes[i]; - - buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; - - b = yy_scan_buffer(buf,n ); - if ( ! b ) - YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); - - /* It's okay to grow etc. this buffer, and we should throw it - * away when we're done. - */ - b->yy_is_our_buffer = 1; - - return b; -} - -#ifndef YY_EXIT_FAILURE -#define YY_EXIT_FAILURE 2 -#endif - -static void yy_fatal_error (yyconst char* msg ) -{ - (void) fprintf( stderr, "%s\n", msg ); - exit( YY_EXIT_FAILURE ); -} - -/* Redefine yyless() so it works in section 3 code. */ - -#undef yyless -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ - int yyless_macro_arg = (n); \ - YY_LESS_LINENO(yyless_macro_arg);\ - yytext[yyleng] = (yy_hold_char); \ - (yy_c_buf_p) = yytext + yyless_macro_arg; \ - (yy_hold_char) = *(yy_c_buf_p); \ - *(yy_c_buf_p) = '\0'; \ - yyleng = yyless_macro_arg; \ - } \ - while ( 0 ) - -/* Accessor methods (get/set functions) to struct members. */ - -/** Get the current line number. - * - */ -int yyget_lineno (void) -{ - - return yylineno; -} - -/** Get the input stream. - * - */ -FILE *yyget_in (void) -{ - return yyin; -} - -/** Get the output stream. - * - */ -FILE *yyget_out (void) -{ - return yyout; -} - -/** Get the length of the current token. - * - */ -int yyget_leng (void) -{ - return yyleng; -} - -/** Get the current token. - * - */ - -char *yyget_text (void) -{ - return yytext; -} - -/** Set the current line number. - * @param line_number - * - */ -void yyset_lineno (int line_number ) -{ - - yylineno = line_number; -} - -/** Set the input stream. This does not discard the current - * input buffer. - * @param in_str A readable stream. - * - * @see yy_switch_to_buffer - */ -void yyset_in (FILE * in_str ) -{ - yyin = in_str ; -} - -void yyset_out (FILE * out_str ) -{ - yyout = out_str ; -} - -int yyget_debug (void) -{ - return yy_flex_debug; -} - -void yyset_debug (int bdebug ) -{ - yy_flex_debug = bdebug ; -} - -static int yy_init_globals (void) -{ - /* Initialization is the same as for the non-reentrant scanner. - * This function is called from yylex_destroy(), so don't allocate here. - */ - - (yy_buffer_stack) = 0; - (yy_buffer_stack_top) = 0; - (yy_buffer_stack_max) = 0; - (yy_c_buf_p) = (char *) 0; - (yy_init) = 0; - (yy_start) = 0; - -/* Defined in main.c */ -#ifdef YY_STDINIT - yyin = stdin; - yyout = stdout; -#else - yyin = (FILE *) 0; - yyout = (FILE *) 0; -#endif - - /* For future reference: Set errno on error, since we are called by - * yylex_init() - */ - return 0; -} - -/* yylex_destroy is for both reentrant and non-reentrant scanners. */ -int yylex_destroy (void) -{ - - /* Pop the buffer stack, destroying each element. */ - while(YY_CURRENT_BUFFER){ - yy_delete_buffer(YY_CURRENT_BUFFER ); - YY_CURRENT_BUFFER_LVALUE = NULL; - yypop_buffer_state(); - } - - /* Destroy the stack itself. */ - yyfree((yy_buffer_stack) ); - (yy_buffer_stack) = NULL; - - /* Reset the globals. This is important in a non-reentrant scanner so the next time - * yylex() is called, initialization will occur. */ - yy_init_globals( ); - - return 0; -} - -/* - * Internal utility routines. - */ - -#ifndef yytext_ptr -static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) -{ - register int i; - for ( i = 0; i < n; ++i ) - s1[i] = s2[i]; -} -#endif - -#ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * s ) -{ - register int n; - for ( n = 0; s[n]; ++n ) - ; - - return n; -} -#endif - -void *yyalloc (yy_size_t size ) -{ - return (void *) malloc( size ); -} - -void *yyrealloc (void * ptr, yy_size_t size ) -{ - /* The cast to (char *) in the following accommodates both - * implementations that use char* generic pointers, and those - * that use void* generic pointers. It works with the latter - * because both ANSI C and C++ allow castless assignment from - * any pointer type to void*, and deal with argument conversions - * as though doing an assignment. - */ - return (void *) realloc( (char *) ptr, size ); -} - -void yyfree (void * ptr ) -{ - free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ -} - -#define YYTABLES_NAME "yytables" - -#line 140 "SDF-lex.l" diff --git a/external/libsdf/libSDF/SDF-parse.c b/external/libsdf/libSDF/SDF-parse.c index 0e8c1e3..f1a2fc7 100644 --- a/external/libsdf/libSDF/SDF-parse.c +++ b/external/libsdf/libSDF/SDF-parse.c @@ -1,24 +1,21 @@ -/* A Bison parser, made by GNU Bison 2.3. */ +/* A Bison parser, made by GNU Bison 2.5. */ -/* Skeleton implementation for Bison's Yacc-like parsers in C - - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 - Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify +/* Bison implementation for Yacc-like parsers in C + + Copyright (C) 1984, 1989-1990, 2000-2011 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - + 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 General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. */ + along with this program. If not, see . */ /* As a special exception, you may create a larger work that contains part or all of the Bison parser skeleton and distribute that work @@ -29,7 +26,7 @@ special exception, which will cause the skeleton and the resulting Bison output files to be licensed under the GNU General Public License without this special exception. - + This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ @@ -47,7 +44,7 @@ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "2.3" +#define YYBISON_VERSION "2.5" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -55,41 +52,20 @@ /* Pure parsers. */ #define YYPURE 0 +/* Push parsers. */ +#define YYPUSH 0 + +/* Pull parsers. */ +#define YYPULL 1 + /* Using locations. */ #define YYLSP_NEEDED 0 -/* Tokens. */ -#ifndef YYTOKENTYPE -# define YYTOKENTYPE - /* Put the tokens into the symbol table, so that GDB and other debuggers - know about them. */ - enum yytokentype { - STRUCT = 258, - NAME = 259, - TYPE = 260, - CONST = 261, - VALUEPARAM = 262, - PARAMETER = 263, - EOHDR = 264, - LEXERROR = 265 - }; -#endif -/* Tokens. */ -#define STRUCT 258 -#define NAME 259 -#define TYPE 260 -#define CONST 261 -#define VALUEPARAM 262 -#define PARAMETER 263 -#define EOHDR 264 -#define LEXERROR 265 - - - - /* Copy the first part of user declarations. */ + +/* Line 268 of yacc.c */ #line 1 "SDF-parse.y" /* @@ -168,6 +144,9 @@ static int finish_parse(void); +/* Line 268 of yacc.c */ +#line 149 "y.tab.c" + /* Enabling traces. */ #ifndef YYDEBUG # define YYDEBUG 0 @@ -186,10 +165,43 @@ static int finish_parse(void); # define YYTOKEN_TABLE 0 #endif + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + STRUCT = 258, + NAME = 259, + TYPE = 260, + CONST = 261, + VALUEPARAM = 262, + PARAMETER = 263, + EOHDR = 264, + LEXERROR = 265 + }; +#endif +/* Tokens. */ +#define STRUCT 258 +#define NAME 259 +#define TYPE 260 +#define CONST 261 +#define VALUEPARAM 262 +#define PARAMETER 263 +#define EOHDR 264 +#define LEXERROR 265 + + + + #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED typedef union YYSTYPE -#line 90 "SDF-parse.y" { + +/* Line 293 of yacc.c */ +#line 90 "SDF-parse.y" + enum SDF_type_enum type; enum value_param_enum valueparam; char *string; @@ -198,22 +210,23 @@ typedef union YYSTYPE dcl_list_t dcl_list; one_dcl_t one_dcl; const_list_t const_list; -} -/* Line 193 of yacc.c. */ -#line 204 "y.tab.c" - YYSTYPE; + + + +/* Line 293 of yacc.c */ +#line 218 "y.tab.c" +} YYSTYPE; +# define YYSTYPE_IS_TRIVIAL 1 # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 -# define YYSTYPE_IS_TRIVIAL 1 #endif - /* Copy the second part of user declarations. */ -/* Line 216 of yacc.c. */ -#line 217 "y.tab.c" +/* Line 343 of yacc.c */ +#line 230 "y.tab.c" #ifdef short # undef short @@ -263,7 +276,7 @@ typedef short int yytype_int16; #define YYSIZE_MAXIMUM ((YYSIZE_T) -1) #ifndef YY_ -# if YYENABLE_NLS +# if defined YYENABLE_NLS && YYENABLE_NLS # if ENABLE_NLS # include /* INFRINGES ON USER NAME SPACE */ # define YY_(msgid) dgettext ("bison-runtime", msgid) @@ -288,14 +301,14 @@ typedef short int yytype_int16; #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static int -YYID (int i) +YYID (int yyi) #else static int -YYID (i) - int i; +YYID (yyi) + int yyi; #endif { - return i; + return yyi; } #endif @@ -316,11 +329,11 @@ YYID (i) # define alloca _alloca # else # define YYSTACK_ALLOC alloca -# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ +# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) # include /* INFRINGES ON USER NAME SPACE */ -# ifndef _STDLIB_H -# define _STDLIB_H 1 +# ifndef EXIT_SUCCESS +# define EXIT_SUCCESS 0 # endif # endif # endif @@ -343,24 +356,24 @@ YYID (i) # ifndef YYSTACK_ALLOC_MAXIMUM # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM # endif -# if (defined __cplusplus && ! defined _STDLIB_H \ +# if (defined __cplusplus && ! defined EXIT_SUCCESS \ && ! ((defined YYMALLOC || defined malloc) \ && (defined YYFREE || defined free))) # include /* INFRINGES ON USER NAME SPACE */ -# ifndef _STDLIB_H -# define _STDLIB_H 1 +# ifndef EXIT_SUCCESS +# define EXIT_SUCCESS 0 # endif # endif # ifndef YYMALLOC # define YYMALLOC malloc -# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ +# if ! defined malloc && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ # endif # endif # ifndef YYFREE # define YYFREE free -# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ +# if ! defined free && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) void free (void *); /* INFRINGES ON USER NAME SPACE */ # endif @@ -376,9 +389,9 @@ void free (void *); /* INFRINGES ON USER NAME SPACE */ /* A type that is properly aligned for any stack member. */ union yyalloc { - yytype_int16 yyss; - YYSTYPE yyvs; - }; + yytype_int16 yyss_alloc; + YYSTYPE yyvs_alloc; +}; /* The size of the maximum gap between one aligned stack and the next. */ # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) @@ -389,6 +402,27 @@ union yyalloc ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ + YYSTACK_GAP_MAXIMUM) +# define YYCOPY_NEEDED 1 + +/* Relocate STACK from its old location to the new one. The + local variables YYSIZE and YYSTACKSIZE give the old and new number of + elements in the stack, and YYPTR gives the new location of the + stack. Advance YYPTR to a properly aligned location for the next + stack. */ +# define YYSTACK_RELOCATE(Stack_alloc, Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ + Stack = &yyptr->Stack_alloc; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ + while (YYID (0)) + +#endif + +#if defined YYCOPY_NEEDED && YYCOPY_NEEDED /* Copy COUNT objects from FROM to TO. The source and destination do not overlap. */ # ifndef YYCOPY @@ -406,24 +440,7 @@ union yyalloc while (YYID (0)) # endif # endif - -/* Relocate STACK from its old location to the new one. The - local variables YYSIZE and YYSTACKSIZE give the old and new number of - elements in the stack, and YYPTR gives the new location of the - stack. Advance YYPTR to a properly aligned location for the next - stack. */ -# define YYSTACK_RELOCATE(Stack) \ - do \ - { \ - YYSIZE_T yynewbytes; \ - YYCOPY (&yyptr->Stack, Stack, yysize); \ - Stack = &yyptr->Stack; \ - yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ - yyptr += yynewbytes / sizeof (*yyptr); \ - } \ - while (YYID (0)) - -#endif +#endif /* !YYCOPY_NEEDED */ /* YYFINAL -- State number of the termination state. */ #define YYFINAL 13 @@ -520,7 +537,7 @@ static const char *const yytname[] = "$end", "error", "$undefined", "STRUCT", "NAME", "TYPE", "CONST", "VALUEPARAM", "PARAMETER", "EOHDR", "LEXERROR", "';'", "'='", "'['", "']'", "'{'", "'}'", "','", "$accept", "hdr", "hdr1", "stmt", - "declaration", "many_typed_dcl_list", "typed_dcl_list", "@1", + "declaration", "many_typed_dcl_list", "typed_dcl_list", "$@1", "comma_sep_dcls", "dcl1", "const_lst", "comma_sep_consts", 0 }; #endif @@ -551,8 +568,8 @@ static const yytype_uint8 yyr2[] = 1, 4, 3, 1, 3, 1, 3 }; -/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state - STATE-NUM when YYTABLE doesn't specify something else to do. Zero +/* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM. + Performed when YYTABLE doesn't specify something else to do. Zero means the default is an error. */ static const yytype_uint8 yydefact[] = { @@ -591,8 +608,7 @@ static const yytype_int8 yypgoto[] = /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If positive, shift that token. If negative, reduce the rule which - number is the opposite. If zero, do what YYDEFACT says. - If YYTABLE_NINF, syntax error. */ + number is the opposite. If YYTABLE_NINF, syntax error. */ #define YYTABLE_NINF -1 static const yytype_uint8 yytable[] = { @@ -603,6 +619,12 @@ static const yytype_uint8 yytable[] = 0, 47, 0, 0, 38 }; +#define yypact_value_is_default(yystate) \ + ((yystate) == (-14)) + +#define yytable_value_is_error(yytable_value) \ + YYID (0) + static const yytype_int8 yycheck[] = { 10, 5, 15, 6, 6, 0, 6, 16, 17, 7, @@ -635,9 +657,18 @@ static const yytype_uint8 yystos[] = /* Like YYERROR except do call yyerror. This remains here temporarily to ease the transition to the new meaning of YYERROR, for GCC. - Once GCC version 2 has supplanted version 1, this can go. */ + Once GCC version 2 has supplanted version 1, this can go. However, + YYFAIL appears to be in use. Nevertheless, it is formally deprecated + in Bison 2.4.2's NEWS entry, where a plan to phase it out is + discussed. */ #define YYFAIL goto yyerrlab +#if defined YYFAIL + /* This is here to suppress warnings from the GCC cpp's + -Wunused-macros. Normally we don't worry about that warning, but + some users do, and we want to make it easy for users to remove + YYFAIL uses, which will produce warnings from Bison 2.5. */ +#endif #define YYRECOVERING() (!!yyerrstatus) @@ -647,7 +678,6 @@ do \ { \ yychar = (Token); \ yylval = (Value); \ - yytoken = YYTRANSLATE (yychar); \ YYPOPSTACK (1); \ goto yybackup; \ } \ @@ -689,19 +719,10 @@ while (YYID (0)) #endif -/* YY_LOCATION_PRINT -- Print the location on the stream. - This macro was not mandated originally: define only if we know - we won't break user code: when these are the locations we know. */ +/* This macro is provided for backward compatibility. */ #ifndef YY_LOCATION_PRINT -# if YYLTYPE_IS_TRIVIAL -# define YY_LOCATION_PRINT(File, Loc) \ - fprintf (File, "%d.%d-%d.%d", \ - (Loc).first_line, (Loc).first_column, \ - (Loc).last_line, (Loc).last_column) -# else -# define YY_LOCATION_PRINT(File, Loc) ((void) 0) -# endif +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) #endif @@ -805,17 +826,20 @@ yy_symbol_print (yyoutput, yytype, yyvaluep) #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static void -yy_stack_print (yytype_int16 *bottom, yytype_int16 *top) +yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) #else static void -yy_stack_print (bottom, top) - yytype_int16 *bottom; - yytype_int16 *top; +yy_stack_print (yybottom, yytop) + yytype_int16 *yybottom; + yytype_int16 *yytop; #endif { YYFPRINTF (stderr, "Stack now"); - for (; bottom <= top; ++bottom) - YYFPRINTF (stderr, " %d", *bottom); + for (; yybottom <= yytop; yybottom++) + { + int yybot = *yybottom; + YYFPRINTF (stderr, " %d", yybot); + } YYFPRINTF (stderr, "\n"); } @@ -849,11 +873,11 @@ yy_reduce_print (yyvsp, yyrule) /* The symbols being reduced. */ for (yyi = 0; yyi < yynrhs; yyi++) { - fprintf (stderr, " $%d = ", yyi + 1); + YYFPRINTF (stderr, " $%d = ", yyi + 1); yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], &(yyvsp[(yyi + 1) - (yynrhs)]) ); - fprintf (stderr, "\n"); + YYFPRINTF (stderr, "\n"); } } @@ -890,7 +914,6 @@ int yydebug; # define YYMAXDEPTH 10000 #endif - #if YYERROR_VERBOSE @@ -993,115 +1016,142 @@ yytnamerr (char *yyres, const char *yystr) } # endif -/* Copy into YYRESULT an error message about the unexpected token - YYCHAR while in state YYSTATE. Return the number of bytes copied, - including the terminating null byte. If YYRESULT is null, do not - copy anything; just return the number of bytes that would be - copied. As a special case, return 0 if an ordinary "syntax error" - message will do. Return YYSIZE_MAXIMUM if overflow occurs during - size calculation. */ -static YYSIZE_T -yysyntax_error (char *yyresult, int yystate, int yychar) +/* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message + about the unexpected token YYTOKEN for the state stack whose top is + YYSSP. + + Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is + not large enough to hold the message. In that case, also set + *YYMSG_ALLOC to the required number of bytes. Return 2 if the + required number of bytes is too large to store. */ +static int +yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, + yytype_int16 *yyssp, int yytoken) { - int yyn = yypact[yystate]; + YYSIZE_T yysize0 = yytnamerr (0, yytname[yytoken]); + YYSIZE_T yysize = yysize0; + YYSIZE_T yysize1; + enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; + /* Internationalized format string. */ + const char *yyformat = 0; + /* Arguments of yyformat. */ + char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; + /* Number of reported tokens (one for the "unexpected", one per + "expected"). */ + int yycount = 0; - if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) - return 0; - else + /* There are many possibilities here to consider: + - Assume YYFAIL is not used. It's too flawed to consider. See + + for details. YYERROR is fine as it does not invoke this + function. + - If this state is a consistent state with a default action, then + the only way this function was invoked is if the default action + is an error action. In that case, don't check for expected + tokens because there are none. + - The only way there can be no lookahead present (in yychar) is if + this state is a consistent state with a default action. Thus, + detecting the absence of a lookahead is sufficient to determine + that there is no unexpected or expected token to report. In that + case, just report a simple "syntax error". + - Don't assume there isn't a lookahead just because this state is a + consistent state with a default action. There might have been a + previous inconsistent state, consistent state with a non-default + action, or user semantic action that manipulated yychar. + - Of course, the expected token list depends on states to have + correct lookahead information, and it depends on the parser not + to perform extra reductions after fetching a lookahead from the + scanner and before detecting a syntax error. Thus, state merging + (from LALR or IELR) and default reductions corrupt the expected + token list. However, the list is correct for canonical LR with + one exception: it will still contain any token that will not be + accepted due to an error action in a later state. + */ + if (yytoken != YYEMPTY) { - int yytype = YYTRANSLATE (yychar); - YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); - YYSIZE_T yysize = yysize0; - YYSIZE_T yysize1; - int yysize_overflow = 0; - enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; - char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; - int yyx; + int yyn = yypact[*yyssp]; + yyarg[yycount++] = yytname[yytoken]; + if (!yypact_value_is_default (yyn)) + { + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. In other words, skip the first -YYN actions for + this state because they are default actions. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = YYLAST - yyn + 1; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yyx; -# if 0 - /* This is so xgettext sees the translatable formats that are - constructed on the fly. */ - YY_("syntax error, unexpected %s"); - YY_("syntax error, unexpected %s, expecting %s"); - YY_("syntax error, unexpected %s, expecting %s or %s"); - YY_("syntax error, unexpected %s, expecting %s or %s or %s"); - YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); -# endif - char *yyfmt; - char const *yyf; - static char const yyunexpected[] = "syntax error, unexpected %s"; - static char const yyexpecting[] = ", expecting %s"; - static char const yyor[] = " or %s"; - char yyformat[sizeof yyunexpected - + sizeof yyexpecting - 1 - + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) - * (sizeof yyor - 1))]; - char const *yyprefix = yyexpecting; - - /* Start YYX at -YYN if negative to avoid negative indexes in - YYCHECK. */ - int yyxbegin = yyn < 0 ? -yyn : 0; - - /* Stay within bounds of both yycheck and yytname. */ - int yychecklim = YYLAST - yyn + 1; - int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; - int yycount = 1; - - yyarg[0] = yytname[yytype]; - yyfmt = yystpcpy (yyformat, yyunexpected); - - for (yyx = yyxbegin; yyx < yyxend; ++yyx) - if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) - { - if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) - { - yycount = 1; - yysize = yysize0; - yyformat[sizeof yyunexpected - 1] = '\0'; - break; - } - yyarg[yycount++] = yytname[yyx]; - yysize1 = yysize + yytnamerr (0, yytname[yyx]); - yysize_overflow |= (yysize1 < yysize); - yysize = yysize1; - yyfmt = yystpcpy (yyfmt, yyprefix); - yyprefix = yyor; - } - - yyf = YY_(yyformat); - yysize1 = yysize + yystrlen (yyf); - yysize_overflow |= (yysize1 < yysize); - yysize = yysize1; - - if (yysize_overflow) - return YYSIZE_MAXIMUM; - - if (yyresult) - { - /* Avoid sprintf, as that infringes on the user's name space. - Don't have undefined behavior even if the translation - produced a string with the wrong number of "%s"s. */ - char *yyp = yyresult; - int yyi = 0; - while ((*yyp = *yyf) != '\0') - { - if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) - { - yyp += yytnamerr (yyp, yyarg[yyi++]); - yyf += 2; - } - else - { - yyp++; - yyf++; - } - } - } - return yysize; + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR + && !yytable_value_is_error (yytable[yyx + yyn])) + { + if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) + { + yycount = 1; + yysize = yysize0; + break; + } + yyarg[yycount++] = yytname[yyx]; + yysize1 = yysize + yytnamerr (0, yytname[yyx]); + if (! (yysize <= yysize1 + && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) + return 2; + yysize = yysize1; + } + } } + + switch (yycount) + { +# define YYCASE_(N, S) \ + case N: \ + yyformat = S; \ + break + YYCASE_(0, YY_("syntax error")); + YYCASE_(1, YY_("syntax error, unexpected %s")); + YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); + YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s")); + YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s")); + YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s")); +# undef YYCASE_ + } + + yysize1 = yysize + yystrlen (yyformat); + if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) + return 2; + yysize = yysize1; + + if (*yymsg_alloc < yysize) + { + *yymsg_alloc = 2 * yysize; + if (! (yysize <= *yymsg_alloc + && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM)) + *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM; + return 1; + } + + /* Avoid sprintf, as that infringes on the user's name space. + Don't have undefined behavior even if the translation + produced a string with the wrong number of "%s"s. */ + { + char *yyp = *yymsg; + int yyi = 0; + while ((*yyp = *yyformat) != '\0') + if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount) + { + yyp += yytnamerr (yyp, yyarg[yyi++]); + yyformat += 2; + } + else + { + yyp++; + yyformat++; + } + } + return 0; } #endif /* YYERROR_VERBOSE */ - /*-----------------------------------------------. | Release the memory associated to this symbol. | @@ -1133,10 +1183,9 @@ yydestruct (yymsg, yytype, yyvaluep) break; } } - + /* Prevent warnings from -Wmissing-prototypes. */ - #ifdef YYPARSE_PARAM #if defined __STDC__ || defined __cplusplus int yyparse (void *YYPARSE_PARAM); @@ -1152,18 +1201,16 @@ int yyparse (); #endif /* ! YYPARSE_PARAM */ - -/* The look-ahead symbol. */ +/* The lookahead symbol. */ int yychar; -/* The semantic value of the look-ahead symbol. */ +/* The semantic value of the lookahead symbol. */ YYSTYPE yylval; /* Number of syntax errors so far. */ int yynerrs; - /*----------. | yyparse. | `----------*/ @@ -1190,14 +1237,37 @@ yyparse () #endif #endif { - - int yystate; + int yystate; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + + /* The stacks and their tools: + `yyss': related to states. + `yyvs': related to semantic values. + + Refer to the stacks thru separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* The state stack. */ + yytype_int16 yyssa[YYINITDEPTH]; + yytype_int16 *yyss; + yytype_int16 *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs; + YYSTYPE *yyvsp; + + YYSIZE_T yystacksize; + int yyn; int yyresult; - /* Number of tokens to shift before error messages enabled. */ - int yyerrstatus; - /* Look-ahead token as an internal (translated) token number. */ - int yytoken = 0; + /* Lookahead token as an internal (translated) token number. */ + int yytoken; + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + #if YYERROR_VERBOSE /* Buffer for error messages, and its allocated size. */ char yymsgbuf[128]; @@ -1205,51 +1275,28 @@ yyparse () YYSIZE_T yymsg_alloc = sizeof yymsgbuf; #endif - /* Three stacks and their tools: - `yyss': related to states, - `yyvs': related to semantic values, - `yyls': related to locations. - - Refer to the stacks thru separate pointers, to allow yyoverflow - to reallocate them elsewhere. */ - - /* The state stack. */ - yytype_int16 yyssa[YYINITDEPTH]; - yytype_int16 *yyss = yyssa; - yytype_int16 *yyssp; - - /* The semantic value stack. */ - YYSTYPE yyvsa[YYINITDEPTH]; - YYSTYPE *yyvs = yyvsa; - YYSTYPE *yyvsp; - - - #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) - YYSIZE_T yystacksize = YYINITDEPTH; - - /* The variables used to return semantic value and location from the - action routines. */ - YYSTYPE yyval; - - /* The number of symbols on the RHS of the reduced rule. Keep to zero when no symbol should be popped. */ int yylen = 0; + yytoken = 0; + yyss = yyssa; + yyvs = yyvsa; + yystacksize = YYINITDEPTH; + YYDPRINTF ((stderr, "Starting parse\n")); yystate = 0; yyerrstatus = 0; yynerrs = 0; - yychar = YYEMPTY; /* Cause a token to be read. */ + yychar = YYEMPTY; /* Cause a token to be read. */ /* Initialize stack pointers. Waste one element of value and location stack so that they stay on the same level as the state stack. The wasted elements are never initialized. */ - yyssp = yyss; yyvsp = yyvs; @@ -1279,7 +1326,6 @@ yyparse () YYSTYPE *yyvs1 = yyvs; yytype_int16 *yyss1 = yyss; - /* Each stack pointer address is followed by the size of the data in use in that stack, in bytes. This used to be a conditional around just the two extra args, but that might @@ -1287,7 +1333,6 @@ yyparse () yyoverflow (YY_("memory exhausted"), &yyss1, yysize * sizeof (*yyssp), &yyvs1, yysize * sizeof (*yyvsp), - &yystacksize); yyss = yyss1; @@ -1310,9 +1355,8 @@ yyparse () (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); if (! yyptr) goto yyexhaustedlab; - YYSTACK_RELOCATE (yyss); - YYSTACK_RELOCATE (yyvs); - + YYSTACK_RELOCATE (yyss_alloc, yyss); + YYSTACK_RELOCATE (yyvs_alloc, yyvs); # undef YYSTACK_RELOCATE if (yyss1 != yyssa) YYSTACK_FREE (yyss1); @@ -1323,7 +1367,6 @@ yyparse () yyssp = yyss + yysize - 1; yyvsp = yyvs + yysize - 1; - YYDPRINTF ((stderr, "Stack size increased to %lu\n", (unsigned long int) yystacksize)); @@ -1333,6 +1376,9 @@ yyparse () YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + if (yystate == YYFINAL) + YYACCEPT; + goto yybackup; /*-----------. @@ -1341,16 +1387,16 @@ yyparse () yybackup: /* Do appropriate processing given the current state. Read a - look-ahead token if we need one and don't already have one. */ + lookahead token if we need one and don't already have one. */ - /* First try to decide what to do without reference to look-ahead token. */ + /* First try to decide what to do without reference to lookahead token. */ yyn = yypact[yystate]; - if (yyn == YYPACT_NINF) + if (yypact_value_is_default (yyn)) goto yydefault; - /* Not known => get a look-ahead token if don't already have one. */ + /* Not known => get a lookahead token if don't already have one. */ - /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ + /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ if (yychar == YYEMPTY) { YYDPRINTF ((stderr, "Reading a token: ")); @@ -1376,26 +1422,22 @@ yybackup: yyn = yytable[yyn]; if (yyn <= 0) { - if (yyn == 0 || yyn == YYTABLE_NINF) - goto yyerrlab; + if (yytable_value_is_error (yyn)) + goto yyerrlab; yyn = -yyn; goto yyreduce; } - if (yyn == YYFINAL) - YYACCEPT; - /* Count tokens shifted since error; after three, turn off error status. */ if (yyerrstatus) yyerrstatus--; - /* Shift the look-ahead token. */ + /* Shift the lookahead token. */ YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); - /* Discard the shifted token unless it is eof. */ - if (yychar != YYEOF) - yychar = YYEMPTY; + /* Discard the shifted token. */ + yychar = YYEMPTY; yystate = yyn; *++yyvsp = yylval; @@ -1435,46 +1477,64 @@ yyreduce: switch (yyn) { case 2: + +/* Line 1806 of yacc.c */ #line 101 "SDF-parse.y" {if(finish_parse()) YYERROR;} break; case 3: + +/* Line 1806 of yacc.c */ #line 102 "SDF-parse.y" {if(finish_parse()) YYERROR; else YYACCEPT;} break; case 4: + +/* Line 1806 of yacc.c */ #line 103 "SDF-parse.y" {YYERROR;} break; case 7: + +/* Line 1806 of yacc.c */ #line 110 "SDF-parse.y" {if(data_dcl((yyvsp[(1) - (2)].declaration))) YYERROR;} break; case 8: + +/* Line 1806 of yacc.c */ #line 111 "SDF-parse.y" {if(const_dcl((yyvsp[(1) - (4)].declaration), (yyvsp[(3) - (4)].const_list))) YYERROR;} break; case 9: + +/* Line 1806 of yacc.c */ #line 112 "SDF-parse.y" {if(do_value_param((yyvsp[(2) - (5)].valueparam), (yyvsp[(4) - (5)].constant))) YYERROR;} break; case 10: + +/* Line 1806 of yacc.c */ #line 115 "SDF-parse.y" {(yyval.declaration).dcl_list = (yyvsp[(1) - (1)].dcl_list); (yyval.declaration).Nrec = 1;} break; case 11: + +/* Line 1806 of yacc.c */ #line 116 "SDF-parse.y" {(yyval.declaration).dcl_list=(yyvsp[(3) - (5)].dcl_list); (yyval.declaration).Nrec=1;} break; case 12: + +/* Line 1806 of yacc.c */ #line 118 "SDF-parse.y" { if( (yyvsp[(7) - (8)].constant).type != SDF_INT64 ){ @@ -1487,16 +1547,22 @@ yyreduce: break; case 13: + +/* Line 1806 of yacc.c */ #line 127 "SDF-parse.y" { (yyval.declaration).dcl_list = (yyvsp[(3) - (7)].dcl_list); (yyval.declaration).Nrec = 0;} break; case 14: + +/* Line 1806 of yacc.c */ #line 130 "SDF-parse.y" {(yyval.dcl_list) = (yyvsp[(1) - (1)].dcl_list);} break; case 15: + +/* Line 1806 of yacc.c */ #line 132 "SDF-parse.y" { int sz; @@ -1510,16 +1576,22 @@ yyreduce: break; case 16: + +/* Line 1806 of yacc.c */ #line 143 "SDF-parse.y" {curtype = (yyvsp[(1) - (1)].type);} break; case 17: + +/* Line 1806 of yacc.c */ #line 143 "SDF-parse.y" {(yyval.dcl_list) = (yyvsp[(3) - (3)].dcl_list);} break; case 18: + +/* Line 1806 of yacc.c */ #line 147 "SDF-parse.y" { obstack_begin(&(yyval.dcl_list).obs, 16*sizeof((yyvsp[(1) - (1)].one_dcl))); @@ -1529,6 +1601,8 @@ yyreduce: break; case 19: + +/* Line 1806 of yacc.c */ #line 153 "SDF-parse.y" { (yyval.dcl_list) = (yyvsp[(1) - (3)].dcl_list); @@ -1538,11 +1612,15 @@ yyreduce: break; case 20: + +/* Line 1806 of yacc.c */ #line 160 "SDF-parse.y" {(yyval.one_dcl).name = (yyvsp[(1) - (1)].string); (yyval.one_dcl).type = curtype; (yyval.one_dcl).arrcnt = 1;} break; case 21: + +/* Line 1806 of yacc.c */ #line 162 "SDF-parse.y" { if( (yyvsp[(3) - (4)].constant).type != SDF_INT64 ){ @@ -1555,11 +1633,15 @@ yyreduce: break; case 22: + +/* Line 1806 of yacc.c */ #line 170 "SDF-parse.y" {(yyval.one_dcl).name=(yyvsp[(1) - (3)].string); (yyval.one_dcl).type=curtype; (yyval.one_dcl).arrcnt = 0;} break; case 23: + +/* Line 1806 of yacc.c */ #line 174 "SDF-parse.y" { (yyval.const_list).nconst = 1; @@ -1569,11 +1651,15 @@ yyreduce: break; case 24: + +/* Line 1806 of yacc.c */ #line 179 "SDF-parse.y" {(yyval.const_list) = (yyvsp[(2) - (3)].const_list);} break; case 25: + +/* Line 1806 of yacc.c */ #line 183 "SDF-parse.y" { (yyval.const_list).nconst = 1; @@ -1583,6 +1669,8 @@ yyreduce: break; case 26: + +/* Line 1806 of yacc.c */ #line 189 "SDF-parse.y" { (yyval.const_list) = (yyvsp[(1) - (3)].const_list); @@ -1592,10 +1680,22 @@ yyreduce: break; -/* Line 1267 of yacc.c. */ -#line 1597 "y.tab.c" + +/* Line 1806 of yacc.c */ +#line 1686 "y.tab.c" default: break; } + /* User semantic actions sometimes alter yychar, and that requires + that yytoken be updated with the new translation. We take the + approach of translating immediately before every use of yytoken. + One alternative is translating here after every semantic action, + but that translation would be missed if the semantic action invokes + YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or + if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an + incorrect destructor might then be invoked immediately. In the + case of YYERROR or YYBACKUP, subsequent parser actions might lead + to an incorrect destructor call or verbose syntax error message + before the lookahead is translated. */ YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); YYPOPSTACK (yylen); @@ -1604,7 +1704,6 @@ yyreduce: *++yyvsp = yyval; - /* Now `shift' the result of the reduction. Determine what state that goes to, based on the state we popped back to and the rule number reduced by. */ @@ -1624,6 +1723,10 @@ yyreduce: | yyerrlab -- here on detecting error | `------------------------------------*/ yyerrlab: + /* Make sure we have latest lookahead translation. See comments at + user semantic actions for why this is necessary. */ + yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar); + /* If not already recovering from an error, report this error. */ if (!yyerrstatus) { @@ -1631,37 +1734,36 @@ yyerrlab: #if ! YYERROR_VERBOSE yyerror (YY_("syntax error")); #else +# define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \ + yyssp, yytoken) { - YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); - if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) - { - YYSIZE_T yyalloc = 2 * yysize; - if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) - yyalloc = YYSTACK_ALLOC_MAXIMUM; - if (yymsg != yymsgbuf) - YYSTACK_FREE (yymsg); - yymsg = (char *) YYSTACK_ALLOC (yyalloc); - if (yymsg) - yymsg_alloc = yyalloc; - else - { - yymsg = yymsgbuf; - yymsg_alloc = sizeof yymsgbuf; - } - } - - if (0 < yysize && yysize <= yymsg_alloc) - { - (void) yysyntax_error (yymsg, yystate, yychar); - yyerror (yymsg); - } - else - { - yyerror (YY_("syntax error")); - if (yysize != 0) - goto yyexhaustedlab; - } + char const *yymsgp = YY_("syntax error"); + int yysyntax_error_status; + yysyntax_error_status = YYSYNTAX_ERROR; + if (yysyntax_error_status == 0) + yymsgp = yymsg; + else if (yysyntax_error_status == 1) + { + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); + yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc); + if (!yymsg) + { + yymsg = yymsgbuf; + yymsg_alloc = sizeof yymsgbuf; + yysyntax_error_status = 2; + } + else + { + yysyntax_error_status = YYSYNTAX_ERROR; + yymsgp = yymsg; + } + } + yyerror (yymsgp); + if (yysyntax_error_status == 2) + goto yyexhaustedlab; } +# undef YYSYNTAX_ERROR #endif } @@ -1669,7 +1771,7 @@ yyerrlab: if (yyerrstatus == 3) { - /* If just tried and failed to reuse look-ahead token after an + /* If just tried and failed to reuse lookahead token after an error, discard it. */ if (yychar <= YYEOF) @@ -1686,7 +1788,7 @@ yyerrlab: } } - /* Else will try to reuse look-ahead token after shifting the error + /* Else will try to reuse lookahead token after shifting the error token. */ goto yyerrlab1; @@ -1720,7 +1822,7 @@ yyerrlab1: for (;;) { yyn = yypact[yystate]; - if (yyn != YYPACT_NINF) + if (!yypact_value_is_default (yyn)) { yyn += YYTERROR; if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) @@ -1743,9 +1845,6 @@ yyerrlab1: YY_STACK_PRINT (yyss, yyssp); } - if (yyn == YYFINAL) - YYACCEPT; - *++yyvsp = yylval; @@ -1770,7 +1869,7 @@ yyabortlab: yyresult = 1; goto yyreturn; -#ifndef yyoverflow +#if !defined(yyoverflow) || YYERROR_VERBOSE /*-------------------------------------------------. | yyexhaustedlab -- memory exhaustion comes here. | `-------------------------------------------------*/ @@ -1781,9 +1880,14 @@ yyexhaustedlab: #endif yyreturn: - if (yychar != YYEOF && yychar != YYEMPTY) - yydestruct ("Cleanup: discarding lookahead", - yytoken, &yylval); + if (yychar != YYEMPTY) + { + /* Make sure we have latest lookahead translation. See comments at + user semantic actions for why this is necessary. */ + yytoken = YYTRANSLATE (yychar); + yydestruct ("Cleanup: discarding lookahead", + yytoken, &yylval); + } /* Do not reclaim the symbols of the rule which action triggered this YYABORT or YYACCEPT. */ YYPOPSTACK (yylen); @@ -1807,6 +1911,8 @@ yyreturn: } + +/* Line 2067 of yacc.c */ #line 196 "SDF-parse.y" static int SDFlineno; @@ -1835,11 +1941,15 @@ main(int argc, char **argv) } #endif -static int SDF_iomode = SDF_SYNC; +static int SDF_iomode = MPMY_RDONLY | MPMY_MULTI; -void SDF_Setiomode(int mode) +void SDFsetiomode(int mode) { - SDF_iomode = mode; + if (mode == SDF_SINGL) { + SDF_iomode = MPMY_RDONLY | MPMY_SINGL; + } else { + SDF_iomode = MPMY_RDONLY | MPMY_MULTI; + } } @@ -1914,7 +2024,7 @@ static int finish_parse(void) /* cur_hdr->datafp = MPMY_Fopen(Dataname, MPMY_RDONLY); */ /* If we come up with a better model for IO, call it here.. */ - cur_hdr->datafp = MPMY_Fopen(Dataname, MPMY_RDONLY | MPMY_MULTI); + cur_hdr->datafp = MPMY_Fopen(Dataname, SDF_iomode); Msgf(("cur_hdr->datafp = %p\n", cur_hdr->datafp)); diff --git a/external/libsdf/libmpmy/GNUmakefile b/external/libsdf/libmpmy/GNUmakefile index 1d4bd32..69ab885 100644 --- a/external/libsdf/libmpmy/GNUmakefile +++ b/external/libsdf/libmpmy/GNUmakefile @@ -68,39 +68,84 @@ endif # DO NOT DELETE THIS LINE -- make depend depends on it. $(objdir)/mpmy_seq$(objsuf): -$(objdir)/mpmy_seq$(objsuf): $(treedir)/include/libsdf/Msgs.h -$(objdir)/mpmy_seq$(objsuf): $(treedir)/include/libsdf/gccextensions.h $(treedir)/include/libsdf/mpmy.h -$(objdir)/mpmy_seq$(objsuf): $(treedir)/include/libsdf/timers.h +$(objdir)/mpmy_seq$(objsuf): +$(objdir)/mpmy_seq$(objsuf): +$(objdir)/mpmy_seq$(objsuf): +$(objdir)/mpmy_seq$(objsuf): $(treedir)/include/libsdf/Msgs.h $(treedir)/include/libsdf/gccextensions.h +$(objdir)/mpmy_seq$(objsuf): $(treedir)/include/libsdf/mpmy.h $(treedir)/include/libsdf/timers.h +$(objdir)/mpmy_seq$(objsuf): $(objdir)/mpmy_seq$(objsuf): $(treedir)/include/libsdf/Assert.h $(treedir)/include/libsdf/error.h -$(objdir)/mpmy_seq$(objsuf): $(treedir)/include/libsdf/mpmy_io.h $(treedir)/include/libsdf/mpmy_time.h +$(objdir)/mpmy_seq$(objsuf): $(treedir)/include/libsdf/mpmy_io.h +$(objdir)/mpmy_seq$(objsuf): +$(objdir)/mpmy_seq$(objsuf): +$(objdir)/mpmy_seq$(objsuf): +$(objdir)/mpmy_seq$(objsuf): +$(objdir)/mpmy_seq$(objsuf): +$(objdir)/mpmy_seq$(objsuf): +$(objdir)/mpmy_seq$(objsuf): +$(objdir)/mpmy_seq$(objsuf): $(treedir)/include/libsdf/mpmy_time.h $(objdir)/mpmy_seq$(objsuf): $(treedir)/include/libsdf/mpmy_abnormal.h timers_hwclock.c -$(objdir)/mpmy_seq$(objsuf): $(treedir)/include/libsdf/Malloc.h -$(objdir)/mpmy_seq$(objsuf): $(treedir)/include/libsdf/chn.h mpmy_io.c +$(objdir)/mpmy_seq$(objsuf): $(treedir)/include/libsdf/Malloc.h $(treedir)/include/libsdf/chn.h +$(objdir)/mpmy_seq$(objsuf): mpmy_io.c $(objdir)/mpmy_seq$(objsuf): $(objdir)/mpmy_seq$(objsuf): $(objdir)/mpmy_seq$(objsuf): $(objdir)/mpmy_seq$(objsuf): -$(objdir)/mpmy_seq$(objsuf): $(treedir)/include/libsdf/protos.h iozero.h -$(objdir)/mpmy_seq$(objsuf): iozero.c io_generic.c mpmy_abnormal.c $(objdir)/mpmy_seq$(objsuf): -$(objdir)/mpmy_seq$(objsuf): $(treedir)/include/libsdf/singlio.h -$(objdir)/mpmy_seq$(objsuf): mpmy_generic.c +$(objdir)/mpmy_seq$(objsuf): +$(objdir)/mpmy_seq$(objsuf): +$(objdir)/mpmy_seq$(objsuf): +$(objdir)/mpmy_seq$(objsuf): +$(objdir)/mpmy_seq$(objsuf): +$(objdir)/mpmy_seq$(objsuf): $(treedir)/include/libsdf/protos.h +$(objdir)/mpmy_seq$(objsuf): iozero.h iozero.c io_generic.c mpmy_abnormal.c +$(objdir)/mpmy_seq$(objsuf): +$(objdir)/mpmy_seq$(objsuf): +$(objdir)/mpmy_seq$(objsuf): +$(objdir)/mpmy_seq$(objsuf): +$(objdir)/mpmy_seq$(objsuf): +$(objdir)/mpmy_seq$(objsuf): +$(objdir)/mpmy_seq$(objsuf): +$(objdir)/mpmy_seq$(objsuf): $(treedir)/include/libsdf/singlio.h mpmy_generic.c $(objdir)/mpmy_mpi$(objsuf): $(treedir)/include/libsdf/mpmy_abnormal.h $(objdir)/mpmy_mpi$(objsuf): $(treedir)/include/libsdf/gccextensions.h $(objdir)/mpmy_mpi$(objsuf): $(treedir)/include/libsdf/Malloc.h $(treedir)/include/libsdf/error.h -$(objdir)/mpmy_mpi$(objsuf): $(treedir)/include/libsdf/chn.h $(treedir)/include/libsdf/Assert.h -$(objdir)/mpmy_mpi$(objsuf): $(treedir)/include/libsdf/mpmy.h $(treedir)/include/libsdf/timers.h +$(objdir)/mpmy_mpi$(objsuf): $(treedir)/include/libsdf/chn.h $(treedir)/include/libsdf/mpmy.h +$(objdir)/mpmy_mpi$(objsuf): $(treedir)/include/libsdf/timers.h $(objdir)/mpmy_mpi$(objsuf): +$(objdir)/mpmy_mpi$(objsuf): +$(objdir)/mpmy_mpi$(objsuf): +$(objdir)/mpmy_mpi$(objsuf): $(treedir)/include/libsdf/Assert.h $(objdir)/mpmy_mpi$(objsuf): $(treedir)/include/libsdf/Msgs.h $(treedir)/include/libsdf/memfile.h $(objdir)/mpmy_mpi$(objsuf): timers_hwclock.c -$(objdir)/mpmy_mpi$(objsuf): $(treedir)/include/libsdf/mpmy_time.h -$(objdir)/mpmy_mpi$(objsuf): mpmy_mpiio.c +$(objdir)/mpmy_mpi$(objsuf): +$(objdir)/mpmy_mpi$(objsuf): $(treedir)/include/libsdf/mpmy_time.h mpmy_mpiio.c $(objdir)/mpmy_mpi$(objsuf): $(objdir)/mpmy_mpi$(objsuf): $(objdir)/mpmy_mpi$(objsuf): $(objdir)/mpmy_mpi$(objsuf): $(objdir)/mpmy_mpi$(objsuf): -$(objdir)/mpmy_mpi$(objsuf): $(treedir)/include/libsdf/protos.h -$(objdir)/mpmy_mpi$(objsuf): $(treedir)/include/libsdf/mpmy_io.h io_generic.c mpmy_abnormal.c +$(objdir)/mpmy_mpi$(objsuf): +$(objdir)/mpmy_mpi$(objsuf): +$(objdir)/mpmy_mpi$(objsuf): +$(objdir)/mpmy_mpi$(objsuf): +$(objdir)/mpmy_mpi$(objsuf): +$(objdir)/mpmy_mpi$(objsuf): +$(objdir)/mpmy_mpi$(objsuf): +$(objdir)/mpmy_mpi$(objsuf): +$(objdir)/mpmy_mpi$(objsuf): +$(objdir)/mpmy_mpi$(objsuf): +$(objdir)/mpmy_mpi$(objsuf): +$(objdir)/mpmy_mpi$(objsuf): +$(objdir)/mpmy_mpi$(objsuf): +$(objdir)/mpmy_mpi$(objsuf): +$(objdir)/mpmy_mpi$(objsuf): +$(objdir)/mpmy_mpi$(objsuf): +$(objdir)/mpmy_mpi$(objsuf): $(treedir)/include/libsdf/protos.h $(treedir)/include/libsdf/mpmy_io.h +$(objdir)/mpmy_mpi$(objsuf): io_generic.c mpmy_abnormal.c +$(objdir)/mpmy_mpi$(objsuf): +$(objdir)/mpmy_mpi$(objsuf): +$(objdir)/mpmy_mpi$(objsuf): +$(objdir)/mpmy_mpi$(objsuf): $(objdir)/mpmy_mpi$(objsuf): $(treedir)/include/libsdf/singlio.h $(objdir)/mpmy_mpi$(objsuf): mpmy_generic.c