From 72aa11ca7df7975f650344e8904a1a690be2480e Mon Sep 17 00:00:00 2001 From: kim Date: Mon, 13 Feb 2012 15:12:43 +0000 Subject: [PATCH] Various fixes: * rename symbols that conflict with libbp (enclose, bits, ...) * allow to build as a standalone library, libTextCollection.a * some fixes to cope with gcc/g++ 4.6 new deprecation list git-svn-id: svn+ssh://idea.nguyen.vg/svn/sxsi/branches/TextCollection/library-split@1206 3cdefd35-fc62-479d-8e8d-bae585ffb9ca --- HeapProfiler.cpp | 2 +- lzindex/lztrie.c | 2 +- lzindex/parentheses.c | 2 +- lzindex/parentheses.h | 2 +- makefile | 32 +++++++++++++++++++++++++++----- swcsa/Makefile | 24 ++++++++++++------------ swcsa/buildFacade.c | 2 +- swcsa/intIndex/Makefile | 34 +++++++++++++++++----------------- swcsa/intIndex/icsa.h | 2 +- swcsa/intIndex/psiGonzalo.c | 4 ++-- swcsa/intIndex/psiHuffmanRLE.c | 12 ++++++------ swcsa/utils/basics.c | 32 +++++++++++++++++++------------- swcsa/utils/basics.h | 21 ++++++++++++++------- 13 files changed, 103 insertions(+), 68 deletions(-) diff --git a/HeapProfiler.cpp b/HeapProfiler.cpp index 348fee6..7091a53 100644 --- a/HeapProfiler.cpp +++ b/HeapProfiler.cpp @@ -27,7 +27,7 @@ unsigned long HeapProfiler::consumption = 0, HeapProfiler::maxConsumption = 0; AllocatedBlocks HeapProfiler::blocks; // Override initialising hook from the C library. -void (*__malloc_initialize_hook) (void) = HeapProfiler::InitHooks; +void (* volatile __malloc_initialize_hook) (void) = HeapProfiler::InitHooks; // Variables to save original hooks. void *(*HeapProfiler::old_malloc_hook)(size_t, const void *); diff --git a/lzindex/lztrie.c b/lzindex/lztrie.c index 7e4453d..2ac090a 100644 --- a/lzindex/lztrie.c +++ b/lzindex/lztrie.c @@ -174,7 +174,7 @@ trieNode parentLZTrie (lztrie T, trieNode i) { if (i == ROOT) return NULLT; // parent of root if (T->boost[T->letters[i-rank(T->pdata->bdata,i)]] == i) return ROOT; - return enclose (T->pdata,i); + return _enclose (T->pdata,i); } // subtree size diff --git a/lzindex/parentheses.c b/lzindex/parentheses.c index 15c8a92..abb0a17 100644 --- a/lzindex/parentheses.c +++ b/lzindex/parentheses.c @@ -275,7 +275,7 @@ uint excess (parentheses P, uint i) // open position of closest parentheses pair that contains the pair // that opens at i, ~0 if no parent -uint enclose (parentheses P, uint i) +uint _enclose (parentheses P, uint i) { if (i == 0) return ~0; // no parent! return findparent (P,i); diff --git a/lzindex/parentheses.h b/lzindex/parentheses.h index 05b6aaa..b1a821a 100644 --- a/lzindex/parentheses.h +++ b/lzindex/parentheses.h @@ -35,7 +35,7 @@ uint findopen (parentheses P, uint i); uint excess (parentheses P, uint i); // open position of closest parentheses pair that contains the pair // that opens at i, ~0 if no parent -uint enclose (parentheses P, uint i); +uint _enclose (parentheses P, uint i); uint sizeofParentheses(parentheses P); #endif diff --git a/makefile b/makefile index 8c88467..92d83d8 100644 --- a/makefile +++ b/makefile @@ -1,24 +1,28 @@ +HIDE=@ CC = g++ LIBCDSPATH = ../libcds -CPPFLAGS = -Wall -ansi -g -I$(LIBCDSPATH)/includes/ -O3 -DNDEBUG +CPPFLAGS = -Wall -ansi -g -I$(LIBCDSPATH)/includes/ -O3 -DNDEBUG -Wno-deprecated-declarations #CPPFLAGS = -Wall -ansi -g -I$(LIBCDSPATH)/includes/ LIBCDSA = $(LIBCDSPATH)/lib/libcds.a LIBRLCSA = incbwt/rlcsa.a LIBLZTRIE = lzindex/lztrie.a LIBSWCSA = swcsa/swcsa.a +LIBS= ${LIBRLCSA} ${LIBCDSA} ${LIBLZTRIE} ${LIBSWCSA} dcover_obs = dcover/difference_cover.o TextCollection_obs = TextCollection.o TextCollectionBuilder.o FMIndexBuilder.o RLCSABuilder.o FMIndex.o Tools.o \ - TextStorage.o Query.o EditDistance.o ResultSet.o ${LIBRLCSA} ${LIBCDSA} ${LIBLZTRIE} ${LIBSWCSA} + TextStorage.o Query.o EditDistance.o ResultSet.o TCDebug_obs = bittree.o rbtree.o dynFMI.o +TEXTCOLLECTION_A=libTextCollection.a + all: testTextCollection -testTextCollection: testTextCollection.o $(TextCollection_obs) $(TCDebug_obs) HeapProfiler.o - $(CC) -o testTextCollection testTextCollection.o $(TextCollection_obs) $(TCDebug_obs) HeapProfiler.o +testTextCollection: testTextCollection.o $(TextCollection_obs) $(LIBS) $(TCDebug_obs) HeapProfiler.o + $(CC) -o testTextCollection testTextCollection.o $(TextCollection_obs) $(LIBS) $(TCDebug_obs) HeapProfiler.o -timeTextCollection: timeTextCollection.o $(TextCollection_obs) $(TCDebug_obs) +timeTextCollection: timeTextCollection.o $(TextCollection_obs) $(LIBS) $(TCDebug_obs) $(CC) -o timeTextCollection timeTextCollection.o $(TextCollection_obs) $(TCDebug_obs) test2dRange: test2dRange.o ${LIBCDSA} @@ -33,6 +37,24 @@ lzindex/lztrie.a: swcsa/swcsa.a: @make -C swcsa +%o: %c + @echo [C] $@ + $(HIDE) (gcc -c $(CPPFLAGS) $< -o $@ + +%o: %cpp + @echo [C++] $@ + $(HIDE) $(CC) -c $(CPPFLAGS) $< -o $@ + + +$(TEXTCOLLECTION_A): $(TextCollection_obs) $(LIBS) + @echo [Link] $@ + $(HIDE) rm -rf .objs + $(HIDE) mkdir .objs + $(HIDE) (cd .objs; ar x ../${LIBRLCSA};ar x ../${LIBLZTRIE}; ar x ../${LIBSWCSA}) + $(HIDE) ar rcs $@ $(TextCollection_obs) .objs/*.o +# $(HIDE) rm -rf .objs + + clean: @make clean -C incbwt @make clean -C lzindex diff --git a/swcsa/Makefile b/swcsa/Makefile index 1d07e36..cdd5672 100644 --- a/swcsa/Makefile +++ b/swcsa/Makefile @@ -32,7 +32,7 @@ wcsa: intIndexPackage buildFacade.o parameters.o hash.o valstring.o MemoryManage mv bitmap.o bitmapswcsa.o mv parameters.o parametswcsa.o ar rc $(LIBINTINDEX) parametswcsa.o buildFacade.o hashswcsa.o valstring.o MemoryManager.o basicsswcsa.o \ - bitmapswcsa.o huffDecswcsa.o huffswcsa.o fileInfo.o + bitmapswcsa.o huffDecswcsa.o huffswcsa.o fileInfo.o mv $(LIBINTINDEX) $(LIBINDEX) ################# SELF INDEX ON INTEGERS ############################## @@ -44,10 +44,10 @@ intIndexPackage: ####################### UTILS MODULES ################################# -parameters.o: - $(CC) $(CFLAGS) -c $(SRCDIRUTILS)/parameters.c +parameters.o: + $(CC) $(CFLAGS) -c $(SRCDIRUTILS)/parameters.c -fileInfo.o: +fileInfo.o: $(CC) $(CFLAGS) -c $(SRCDIRUTILS)/fileInfo.c hash.o: MemoryManager.o @@ -57,28 +57,28 @@ hash.o: MemoryManager.o MemoryManager.o: $(CC) $(CFLAGS) -c $(SRCDIRUTILS)/MemoryManager.c -valstring.o: - $(CC) $(CFLAGS) -c $(SRCDIRUTILS)/valstring.c +valstring.o: + $(CC) $(CFLAGS) -c $(SRCDIRUTILS)/valstring.c -huff.o: +huff.o: $(CC) $(CFLAGS) -c $(SRCDIRUTILS)/huff.c -huffDec.o: +huffDec.o: $(CC) $(CFLAGS) -c $(SRCDIRUTILS)/huffDec.c -basics.o: +basics.o: $(CC) $(CFLAGS) -c $(SRCDIRUTILS)/basics.c -bitmap.o: +bitmap.o: $(CC) $(CFLAGS) -c $(SRCDIRUTILS)/bitmap.c ############################ CLEANING ################################# -cleanO: +cleanO: rm -f *.o - + clean: cd $(SRCDIRCSA) && $(MAKE) clean -w rm -rf *~ *% *.o core *.bak $(LIBINTINDEX) $(LIBINDEX) diff --git a/swcsa/buildFacade.c b/swcsa/buildFacade.c index 3647e99..b581059 100755 --- a/swcsa/buildFacade.c +++ b/swcsa/buildFacade.c @@ -823,7 +823,7 @@ int build_WCSA (uchar *text, ulong length, char *build_options, void **index) { tmpOffsets[zeroNode]=tmpOffset; //setting pointer to the "virtual" word {zeroNode+1}^{th} //kbit encoding of the offsets - uint elemSize = bits(tmpOffset); + uint elemSize = _bits(tmpOffset); wcsa->wordsData.elemSize = elemSize; wcsa->wordsData.words = (uint *) malloc (((((zeroNode +1)*elemSize)+W-1) /W) * sizeof(uint)); //with 1 extra slot !. wcsa->wordsData.words[((((zeroNode +1)*elemSize)+W-1) /W) -1 ] =0000; diff --git a/swcsa/intIndex/Makefile b/swcsa/intIndex/Makefile index 3fb9c0c..8f02954 100755 --- a/swcsa/intIndex/Makefile +++ b/swcsa/intIndex/Makefile @@ -5,7 +5,7 @@ CC = g++ ifndef CFLAGS ##possibly already defined by the "main Makefile". ##CFLAGS = -O9 -m32 - CFLAGS = -O9 -m32 + CFLAGS = -O9 -m32 ##CFLAGS = -g -m32 -O0 endif @@ -15,41 +15,41 @@ all: intIndex cleanO intIndex: icsa.o parameters.o basics.o huff.o bitmap.o psiHuffmanRLE.o psiDeltaCode.o psiGonzalo.o - ar rc $(LIBINTINDEX) icsa.o psiHuffmanRLE.o psiDeltaCode.o psiGonzalo.o + ar rc $(LIBINTINDEX) icsa.o psiHuffmanRLE.o psiDeltaCode.o psiGonzalo.o #not including "parameters.o basics.o bitmap.o huff.o" as they are included by wcsa #they are already included into the library by the presentation layer. -icsa.o: parameters.o basics.o bitmap.o huff.o psiHuffmanRLE.o psiDeltaCode.o psiGonzalo.o - $(CC) $(CFLAGS) -c $(SRCDIR)/$(SRCDIRCSA)/icsa.c +icsa.o: parameters.o basics.o bitmap.o huff.o psiHuffmanRLE.o psiDeltaCode.o psiGonzalo.o + $(CC) $(CFLAGS) -c $(SRCDIR)/$(SRCDIRCSA)/icsa.c psiHuffmanRLE.o: huff.o - $(CC) $(CFLAGS) -c $(SRCDIR)/$(SRCDIRCSA)/psiHuffmanRLE.c + $(CC) $(CFLAGS) -c $(SRCDIR)/$(SRCDIRCSA)/psiHuffmanRLE.c psiDeltaCode.o: - $(CC) $(CFLAGS) -c $(SRCDIR)/$(SRCDIRCSA)/psiDeltaCode.c + $(CC) $(CFLAGS) -c $(SRCDIR)/$(SRCDIRCSA)/psiDeltaCode.c psiGonzalo.o: huff.o - $(CC) $(CFLAGS) -c $(SRCDIR)/$(SRCDIRCSA)/psiGonzalo.c + $(CC) $(CFLAGS) -c $(SRCDIR)/$(SRCDIRCSA)/psiGonzalo.c -parameters.o: - $(CC) $(CFLAGS) -c $(SRCDIR)/$(SRCDIRUTILS)/parameters.c - - -huff.o: +parameters.o: + $(CC) $(CFLAGS) -c $(SRCDIR)/$(SRCDIRUTILS)/parameters.c + + +huff.o: $(CC) $(CFLAGS) -c $(SRCDIR)/$(SRCDIRUTILS)/huff.c -basics.o: +basics.o: $(CC) $(CFLAGS) -c $(SRCDIR)/$(SRCDIRUTILS)/basics.c -bitmap.o: +bitmap.o: $(CC) $(CFLAGS) -c $(SRCDIR)/$(SRCDIRUTILS)/bitmap.c -cleanO: +cleanO: rm -f *.o - + clean: - rm -rf *~ *% *.o core *.bak icsa.a + rm -rf *~ *% *.o core *.bak icsa.a tar: tar czvf icsa.tar.gz Makefile diff --git a/swcsa/intIndex/icsa.h b/swcsa/intIndex/icsa.h index 102832c..523859d 100644 --- a/swcsa/intIndex/icsa.h +++ b/swcsa/intIndex/icsa.h @@ -1 +1 @@ -#include #include #include #include #include #include "defValues.h" #include "../utils/bitmap.h" #include "../utils/huff.h" #include "../utils/parameters.h" #ifdef PSI_HUFFMANRLE #include "psiHuffmanRLE.h" #endif #ifdef PSI_GONZALO #include "psiGonzalo.h" #endif #ifdef PSI_DELTACODES #include "psiDeltaCode.h" #endif typedef struct { uint suffixArraySize; uint T_Psi; uint *D; bitmap bD; uint T_A; uint T_AInv; uint *samplesA; uint samplesASize; uint *BA; bitmap bBA; uint *samplesAInv; uint samplesAInvSize; uint displayCSAState; int displayCSAPrevPosition; #ifdef PSI_HUFFMANRLE HuffmanCompressedPsi hcPsi; #endif #ifdef PSI_GONZALO GonzaloCompressedPsi gcPsi; #endif #ifdef PSI_DELTACODES DeltaCompressedPsi dcPsi; #endif //only needed during "parse_parameters". uint tempNSHUFF; uint psiSearchFactorJump; //factor of the T_Psi value. } ticsa; // FUNCTION PROTOTYPES: BUILDING THE INDEX //Creates the ICSA int buildIntIndex (uint *intVector, uint n, char *build_options, void **index ); //ticsa *createIntegerCSA (uint **aintVector, uint SAsize, char *build_options); //Returns number of elements in the indexed sequence of integers int sourceLenIntIndex(void *index, uint *numInts); //Save the index to disk int saveIntIndex(void *index, char *pathname); //void storeStructsCSA(ticsa *myicsa, char *basename); // Loads the index from disk. int loadIntIndex(char *pathname, void **index); //ticsa *loadCSA(char *basename); // Frees memory int freeIntIndex(void *index); //uint destroyStructsCSA(ticsa *myicsa); //Returns the size (in bytes) of the index over the sequence of integers. int sizeIntIndex(void *index, uint *numBytes); //uint CSA_size(ticsa *myicsa); // Shows detailed summary info of the self-index (memory usage of each structure) int printInfoIntIndex(void *index, const char tab[]); //Number of occurrences of the pattern, and the interval [left,right] in the suffix array. int countIntIndex(void *index, uint *pattern, uint length, ulong *numocc, ulong *left, ulong *right); //uint countCSA(ticsa *myicsa, uint *pattern, uint patternSize, uint *left, uint *right); // Exponential search //uint countCSABin(ticsa *myicsa, uint *pattern, uint patternSize, uint *left, uint *right); // Binary search // Returns an array with integers corresponding offsets to the occurrences of the pattern, // as well as the number of occurrences int locateIntIndex(void *index, uint *pattern, uint length, ulong **occ, ulong *numocc); //uint *locateCSA(ticsa *myicsa, uint *pattern, uint patternSize, uint *occ); //Returns the value of the source (array of integers) at a given offset. // (that is, the element "position" from the original array of uints) int displayIntIndex(void *index, ulong position, uint *value); //uint displayCSA(ticsa *myicsa, uint position); /* Private function prototypes ********************************************/ uint parametersCSA(ticsa *myicsa, char *build_options); uint displayCSAFirst(ticsa *myicsa, uint position); uint displayCSANext(ticsa *myicsa); int SadCSACompare(ticsa *myicsa, uint *pattern, uint patternSize, uint p); uint A(ticsa *myicsa, uint position); uint inverseA(ticsa *myicsa, uint offset); void showStructsCSA(ticsa *myicsa); // For Debugging \ No newline at end of file +//#include #include #include #include #include #include "defValues.h" #include "../utils/bitmap.h" #include "../utils/huff.h" #include "../utils/parameters.h" #ifdef PSI_HUFFMANRLE #include "psiHuffmanRLE.h" #endif #ifdef PSI_GONZALO #include "psiGonzalo.h" #endif #ifdef PSI_DELTACODES #include "psiDeltaCode.h" #endif typedef struct { uint suffixArraySize; uint T_Psi; uint *D; bitmap bD; uint T_A; uint T_AInv; uint *samplesA; uint samplesASize; uint *BA; bitmap bBA; uint *samplesAInv; uint samplesAInvSize; uint displayCSAState; int displayCSAPrevPosition; #ifdef PSI_HUFFMANRLE HuffmanCompressedPsi hcPsi; #endif #ifdef PSI_GONZALO GonzaloCompressedPsi gcPsi; #endif #ifdef PSI_DELTACODES DeltaCompressedPsi dcPsi; #endif //only needed during "parse_parameters". uint tempNSHUFF; uint psiSearchFactorJump; //factor of the T_Psi value. } ticsa; // FUNCTION PROTOTYPES: BUILDING THE INDEX //Creates the ICSA int buildIntIndex (uint *intVector, uint n, char *build_options, void **index ); //ticsa *createIntegerCSA (uint **aintVector, uint SAsize, char *build_options); //Returns number of elements in the indexed sequence of integers int sourceLenIntIndex(void *index, uint *numInts); //Save the index to disk int saveIntIndex(void *index, char *pathname); //void storeStructsCSA(ticsa *myicsa, char *basename); // Loads the index from disk. int loadIntIndex(char *pathname, void **index); //ticsa *loadCSA(char *basename); // Frees memory int freeIntIndex(void *index); //uint destroyStructsCSA(ticsa *myicsa); //Returns the size (in bytes) of the index over the sequence of integers. int sizeIntIndex(void *index, uint *numBytes); //uint CSA_size(ticsa *myicsa); // Shows detailed summary info of the self-index (memory usage of each structure) int printInfoIntIndex(void *index, const char tab[]); //Number of occurrences of the pattern, and the interval [left,right] in the suffix array. int countIntIndex(void *index, uint *pattern, uint length, ulong *numocc, ulong *left, ulong *right); //uint countCSA(ticsa *myicsa, uint *pattern, uint patternSize, uint *left, uint *right); // Exponential search //uint countCSABin(ticsa *myicsa, uint *pattern, uint patternSize, uint *left, uint *right); // Binary search // Returns an array with integers corresponding offsets to the occurrences of the pattern, // as well as the number of occurrences int locateIntIndex(void *index, uint *pattern, uint length, ulong **occ, ulong *numocc); //uint *locateCSA(ticsa *myicsa, uint *pattern, uint patternSize, uint *occ); //Returns the value of the source (array of integers) at a given offset. // (that is, the element "position" from the original array of uints) int displayIntIndex(void *index, ulong position, uint *value); //uint displayCSA(ticsa *myicsa, uint position); /* Private function prototypes ********************************************/ uint parametersCSA(ticsa *myicsa, char *build_options); uint displayCSAFirst(ticsa *myicsa, uint position); uint displayCSANext(ticsa *myicsa); int SadCSACompare(ticsa *myicsa, uint *pattern, uint patternSize, uint p); uint A(ticsa *myicsa, uint position); uint inverseA(ticsa *myicsa, uint offset); void showStructsCSA(ticsa *myicsa); // For Debugging \ No newline at end of file diff --git a/swcsa/intIndex/psiGonzalo.c b/swcsa/intIndex/psiGonzalo.c index ee8f086..f5e4715 100644 --- a/swcsa/intIndex/psiGonzalo.c +++ b/swcsa/intIndex/psiGonzalo.c @@ -71,8 +71,8 @@ GonzaloCompressedPsi gonzaloCompressPsi(uint *Psi, uint psiSize, uint T, uint HU Hacc = createHuff (acc,HUFF-1, UNSORTED); Hlen = createHuff (lacc,samplen-2, UNSORTED); totexc = acc[0]; - pslen = bits(psiSize+1); - _bplen = bits(Hacc.total+Hlen.total+(1+links/samplen+totexc)*pslen); + pslen = _bits(psiSize+1); + _bplen = _bits(Hacc.total+Hlen.total+(1+links/samplen+totexc)*pslen); _bposS = (uint *)malloc ((((1+links/samplen)*_bplen+W-1)/W)*sizeof(uint)); _cPsi = (uint *)malloc (((Hacc.total+Hlen.total+(1+links/samplen+totexc)*pslen+W-1)/W)*sizeof(uint)); diff --git a/swcsa/intIndex/psiHuffmanRLE.c b/swcsa/intIndex/psiHuffmanRLE.c index ac619a1..c5b9451 100644 --- a/swcsa/intIndex/psiHuffmanRLE.c +++ b/swcsa/intIndex/psiHuffmanRLE.c @@ -67,11 +67,11 @@ HuffmanCompressedPsi huffmanCompressPsi(unsigned int *Psi, unsigned int psiSize, else if(diffs[index]<0) { // Valor negativo absolute_value = -diffs[index]; - binaryLenght = bits(absolute_value); + binaryLenght = _bits(absolute_value); huffmanDst[binaryLenght+negStart-1]++; } else { // Valor grande >= 128 absolute_value = diffs[index]; - binaryLenght = bits(absolute_value); + binaryLenght = _bits(absolute_value); huffmanDst[binaryLenght+bigStart-1]++; } } @@ -99,8 +99,8 @@ HuffmanCompressedPsi huffmanCompressPsi(unsigned int *Psi, unsigned int psiSize, // Calculamos o numero de mostras e o espacio ocupado por cada mostra e por cada punteiro numberOfSamples = (psiSize+T-1)/T; - sampleSize = bits(psiSize); - pointerSize = bits(streamSize); + sampleSize = _bits(psiSize); + pointerSize = _bits(streamSize); // Reservamos espacio para a secuencia e para as mostras e punteiros samples = (unsigned int *)malloc(sizeof(uint)*((numberOfSamples*sampleSize+31)/32)); @@ -132,13 +132,13 @@ HuffmanCompressedPsi huffmanCompressPsi(unsigned int *Psi, unsigned int psiSize, else if(diffs[index]<0) { // Valor negativo absolute_value = -diffs[index]; - binaryLenght = bits(absolute_value); + binaryLenght = _bits(absolute_value); ptr = encodeHuff(diffsHT,binaryLenght+negStart-1,stream,ptr); bitwrite(stream,ptr,binaryLenght,absolute_value); ptr += binaryLenght; } else { // Valor grande >= 128 absolute_value = diffs[index]; - binaryLenght = bits(absolute_value); + binaryLenght = _bits(absolute_value); ptr = encodeHuff(diffsHT,binaryLenght+bigStart-1,stream,ptr); bitwrite(stream,ptr,binaryLenght,absolute_value); ptr += binaryLenght; diff --git a/swcsa/utils/basics.c b/swcsa/utils/basics.c index 398e975..c9cb275 100755 --- a/swcsa/utils/basics.c +++ b/swcsa/utils/basics.c @@ -1,3 +1,6 @@ +#ifdef __cplusplus +extern "C" { +#endif // Basics @@ -7,9 +10,9 @@ #include // Memory management - - void *Malloc (int n) - + +static void *Malloc (size_t n) + { void *p; if (n == 0) return NULL; p = (void*) malloc (n); @@ -19,14 +22,14 @@ } return p; } - - void Free (void *p) - - { if (p) free (p); + +static void Free (void *p) + + { if (p) free (p); } - - void *Realloc (void *p, int n) - + +static void *Realloc (void *p, size_t n) + { if (p == NULL) return Malloc (n); if (n == 0) { Free(p); return NULL; } p = (void*) realloc (p,n); @@ -41,7 +44,7 @@ // bits needed to represent a number between 0 and n -uint bits (uint n) +uint _bits (uint n) { uint b = 0; while (n) @@ -68,7 +71,7 @@ uint bitread (uint *e, uint p, uint len) // writes e[p..p+len-1] = s, len <= W -void bitwrite (register uint *e, register uint p, +void bitwrite (register uint *e, register uint p, register uint len, register uint s) { e += p/W; p %= W; @@ -89,7 +92,7 @@ void bitwrite (register uint *e, register uint p, } // writes e[p..p+len-1] = 0 -void bitzero2 (register uint *e, register uint p, +void bitzero2 (register uint *e, register uint p, register uint len) { e += p/W; p %= W; @@ -105,3 +108,6 @@ void bitzero2 (register uint *e, register uint p, if (len > 0) *e &= ~(((1< @@ -19,13 +23,13 @@ // Memory management -#define malloc(n) Malloc(n) -#define free(p) Free(p) -#define realloc(p,n) Realloc(p,n) + //#define malloc(n) Malloc(n) + //#define free(p) Free(p) + //#define realloc(p,n) Realloc(p,n) -void *Malloc (int n); -void Free (void *p); -void *Realloc (void *p, int n); +static void *Malloc (size_t n); +static void Free (void *p); +static void *Realloc (void *p, size_t n); // Data types @@ -49,7 +53,7 @@ void *Realloc (void *p, int n); #define W (32) // bits needed to represent a number between 0 and n -uint bits (uint n); +uint _bits (uint n); // returns e[p..p+len-1], assuming len <= W uint bitread (uint *e, uint p, uint len); // writes e[p..p+len-1] = s, assuming len <= W @@ -108,5 +112,8 @@ void bitzero2 (uint *e, uint p, uint len); } \ } \ } +#ifdef __cplusplus + } +#endif #endif -- 2.17.1