From: <cli...@li...> - 2005-01-29 14:57:57
|
Send clisp-cvs mailing list submissions to cli...@li... To subscribe or unsubscribe via the World Wide Web, visit https://lists.sourceforge.net/lists/listinfo/clisp-cvs or, via email, send a message with subject or body 'help' to cli...@li... You can reach the person managing the list at cli...@li... When replying, please edit your Subject line so it is more specific than "Re: Contents of clisp-cvs digest..." CLISP CVS commits for today Today's Topics: 1. clisp/src io.d,1.281,1.282 ChangeLog,1.4169,1.4170 (Bruno Haible) 2. clisp/src intserial.d,NONE,1.1 lisparit.d,1.74,1.75 makemake.in,1.510,1.511 stream.d,1.503,1.504 lispbibl.d,1.609,1.610 genclisph.d,1.167,1.168 ChangeLog,1.4170,1.4171 (Bruno Haible) 3. clisp/src/po Makefile.devel,1.37,1.38 (Bruno Haible) 4. clisp/src lispbibl.d,1.610,1.611 genclisph.d,1.168,1.169 intelem.d,1.29,1.30 socket.d,1.89,1.90 ChangeLog,1.4171,1.4172 (Bruno Haible) --__--__-- Message: 1 From: Bruno Haible <ha...@us...> To: cli...@li... Subject: clisp/src io.d,1.281,1.282 ChangeLog,1.4169,1.4170 Date: Sat, 29 Jan 2005 14:50:30 +0000 Reply-To: cli...@li... Update of /cvsroot/clisp/clisp/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23339/src Modified Files: io.d ChangeLog Log Message: Fix compilation in DEBUG_GCSAFETY mode. Index: io.d =================================================================== RCS file: /cvsroot/clisp/clisp/src/io.d,v retrieving revision 1.281 retrieving revision 1.282 diff -u -d -r1.281 -r1.282 --- io.d 26 Jan 2005 13:25:29 -0000 1.281 +++ io.d 29 Jan 2005 14:50:06 -0000 1.282 @@ -8452,7 +8452,7 @@ JUSTIFY_SPACE; JUSTIFY_LAST(true); var object n = (orecordp(obj) # BigReadLabel or Small-Read-Label? - ? TheBigReadLabel(obj)->brl_value + ? (object)TheBigReadLabel(obj)->brl_value : small_read_label_value(obj)); print_integer(n,10,stream_); # print n in decimal JUSTIFY_END_FILL; Index: ChangeLog =================================================================== RCS file: /cvsroot/clisp/clisp/src/ChangeLog,v retrieving revision 1.4169 retrieving revision 1.4170 diff -u -d -r1.4169 -r1.4170 --- ChangeLog 28 Jan 2005 17:22:43 -0000 1.4169 +++ ChangeLog 29 Jan 2005 14:50:09 -0000 1.4170 @@ -1,5 +1,9 @@ 2005-01-28 Bruno Haible <br...@cl...> + * io.d (pr_readlabel): Fix C++ compilation. + +2005-01-28 Bruno Haible <br...@cl...> + * makemake.in (check-fresh-line): Reduce the scope of the test on Woe32. --__--__-- Message: 2 From: Bruno Haible <ha...@us...> To: cli...@li... Subject: clisp/src intserial.d,NONE,1.1 lisparit.d,1.74,1.75 makemake.in,1.510,1.511 stream.d,1.503,1.504 lispbibl.d,1.609,1.610 genclisph.d,1.167,1.168 ChangeLog,1.4170,1.4171 Date: Sat, 29 Jan 2005 14:55:13 +0000 Reply-To: cli...@li... Update of /cvsroot/clisp/clisp/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24689/src Modified Files: lisparit.d makemake.in stream.d lispbibl.d genclisph.d ChangeLog Added Files: intserial.d Log Message: New primitives for serializing and deserializing integers. Index: lisparit.d =================================================================== RCS file: /cvsroot/clisp/clisp/src/lisparit.d,v retrieving revision 1.74 retrieving revision 1.75 diff -u -d -r1.74 -r1.75 --- lisparit.d 5 Jan 2005 12:12:30 -0000 1.74 +++ lisparit.d 29 Jan 2005 14:55:06 -0000 1.75 @@ -39,6 +39,7 @@ #include "intsqrt.c" /* Root, ISQRT */ #include "intprint.c" /* auxiliary function for output of integers */ #include "intread.c" /* auxiliary function for input of integers */ +#include "intserial.c" /* serialization of integers */ /* for rational numbers: */ #include "rational.c" /* rational numbers */ /* for floats: */ Index: genclisph.d =================================================================== RCS file: /cvsroot/clisp/clisp/src/genclisph.d,v retrieving revision 1.167 retrieving revision 1.168 diff -u -d -r1.167 -r1.168 --- genclisph.d 25 Jan 2005 14:35:09 -0000 1.167 +++ genclisph.d 29 Jan 2005 14:55:10 -0000 1.168 @@ -1,6 +1,6 @@ /* * Export CLISP internals for modules - * Bruno Haible 1994-2004 + * Bruno Haible 1994-2005 * Sam Steingold 1998-2005 */ @@ -2221,6 +2221,10 @@ printf("extern object I_I_plus_I (object x, object y);\n"); printf("extern object I_I_minus_I (object x, object y);\n"); #endif + printf("extern object LEbytes_to_UI (uintL bytesize, const uintB* bufferptr);\n"); + printf("extern object LEbytes_to_I (uintL bytesize, const uintB* bufferptr);\n"); + printf("extern bool UI_to_LEbytes (object obj, uintL bitsize, uintB* bufferptr);\n"); + printf("extern bool I_to_LEbytes (object obj, uintL bitsize, uintB* bufferptr);\n"); printf("extern object c_float_to_FF (const ffloatjanus* val_);\n"); printf("extern void FF_to_c_float (object obj, ffloatjanus* val_);\n"); printf("extern object c_double_to_DF (const dfloatjanus* val_);\n"); Index: stream.d =================================================================== RCS file: /cvsroot/clisp/clisp/src/stream.d,v retrieving revision 1.503 retrieving revision 1.504 diff -u -d -r1.503 -r1.504 --- stream.d 28 Jan 2005 15:07:43 -0000 1.503 +++ stream.d 29 Jan 2005 14:55:07 -0000 1.504 @@ -4406,65 +4406,12 @@ # ------------------------------ local maygc object bitbuff_iu_I (object bitbuffer, uintL bitsize, uintL bytesize) { - # normalize number in bitbuffer: var uintB* bitbufferptr = &TheSbvector(bitbuffer)->data[bytesize-1]; *bitbufferptr &= (bit(((bitsize-1)%8)+1)-1); # mask High byte - var uintL count = bytesize; - while ((!(count==0)) && (*bitbufferptr==0)) { count--; bitbufferptr--; } - # make number: - if # at most oint_data_len Bits ? - ((count <= floor(oint_data_len,8)) - || ((count == floor(oint_data_len,8)+1) - && (*bitbufferptr < bit(oint_data_len%8)))) { - # yes -> build Fixnum >=0 : - var uintL wert = 0; - until (count==0) { wert = (wert<<8) | *bitbufferptr--; count--; } - return fixnum(wert); - } - # no -> build Bignum >0 : pushSTACK(bitbuffer); - var uintL digitcount = floor(count,(intDsize/8)); - if (((count%(intDsize/8)) > 0) || (*bitbufferptr & bit(7))) - digitcount++; - # As bitsize < intDsize*uintWC_max, - # digitcount <= ceiling((bitsize+1)/intDsize) <= uintWC_max . - var object big = allocate_bignum(digitcount,0); # new Bignum >0 - TheBignum(big)->data[0] = 0; # set highest Digit to 0 - # fill remaining Digits from right to left, - # thereby translate sequence of Bytes into sequence of uintD: - bitbuffer = popSTACK(); - bitbufferptr = &TheSbvector(bitbuffer)->data[0]; - #if BIG_ENDIAN_P - { - var uintB* bigptr = (uintB*)(&TheBignum(big)->data[digitcount]); - dotimespL(count,count, { *--bigptr = *bitbufferptr++; } ); - } - #else - { - var uintD* bigptr = &TheBignum(big)->data[digitcount]; - var uintL count2; -#define GET_NEXT_BYTE(i) digit |= ((uintD)(*bitbufferptr++) << (8*i)); - dotimespL(count2,floor(count,intDsize/8), { - var uintD digit = 0; - DOCONSTTIMES(intDsize/8,GET_NEXT_BYTE); # GET_NEXT_BYTE(0..intDsize/8-1) - *--bigptr = digit; - }); -#undef GET_NEXT_BYTE - count2 = count % (intDsize/8); - if (count2>0) { - var uintL shiftcount = 0; - var uintD digit = (uintD)(*bitbufferptr++); - dotimesL(count2,count2-1, { - shiftcount += 8; - digit |= ((uintD)(*bitbufferptr++) << shiftcount); - }); - *--bigptr = digit; - } - } - #endif - # since (intDsize/8)*(digitcount-1) <= count <= (intDsize/8)*digitcount - # everything is filled. - return big; + var object result = LESbvector_to_UI(bytesize,&STACK_0); + skipSTACK(1); + return result; } # UP for READ-BYTE on File-Streams of Integers, Type u : @@ -4475,90 +4422,17 @@ } local maygc object bitbuff_is_I (object bitbuffer, uintL bitsize, uintL bytesize) { - # normalize number in bitbuffer: var uintB* bitbufferptr = &TheSbvector(bitbuffer)->data[bytesize-1]; - var sintD sign; var uintL signbitnr = (bitsize-1)%8; - var uintL count = bytesize; if (!(*bitbufferptr & bit(signbitnr))) { - sign = 0; *bitbufferptr &= (bitm(signbitnr+1)-1); # sign-extend High byte - # normalize, highest Bit must remain 0: - while ((count>=2) && (*bitbufferptr==0) - && !(*(bitbufferptr-1) & bit(7))) { - count--; bitbufferptr--; - } - # build number: - if # at most oint_data_len+1 Bits, count <2^oint_data_len ? - ((count <= floor(oint_data_len,8)) - || ((count == floor(oint_data_len,8)+1) - && (*bitbufferptr < bit(oint_data_len%8)))) { - # yes -> build Fixnum >=0: - var uintL wert = 0; - until (count==0) { wert = (wert<<8) | *bitbufferptr--; count--; } - return posfixnum(wert); - } } else { - sign = -1; *bitbufferptr |= minus_bitm(signbitnr+1); # sign-extend High byte - # normalize, highest Bit must remain 1: - while ((count>=2) && (*bitbufferptr==(uintB)(-1)) - && (*(bitbufferptr-1) & bit(7))) { - count--; bitbufferptr--; - } - # make number: - if # at most oint_data_len+1 Bits, count >=-2^oint_data_len ? - ((count <= floor(oint_data_len,8)) - || ((count == floor(oint_data_len,8)+1) - && (*bitbufferptr >= (uintB)(-bit(oint_data_len%8))))) { - # yes -> build Fixnum <0: - var uintL wert = (uintL)(-1); - until (count==0) { wert = (wert<<8) | *bitbufferptr--; count--; } - return negfixnum(-wbitm(intLsize)+(oint)wert); - } } - # make bignum: pushSTACK(bitbuffer); - var uintL digitcount = ceiling(count,(intDsize/8)); - # As bitsize < intDsize*uintWC_max, - # digitcount <= ceiling(bitsize/intDsize) <= uintWC_max . - var object big = allocate_bignum(digitcount,(sintB)sign); - TheBignum(big)->data[0] = sign; # set highest Word to sign - # fill the remaining Digits from right to left, - # thereby translate sequence of Bytes into sequence of uintD: - bitbuffer = popSTACK(); - bitbufferptr = &TheSbvector(bitbuffer)->data[0]; - #if BIG_ENDIAN_P - { - var uintB* bigptr = (uintB*)(TheBignum(big)->data+digitcount); - dotimespL(count,count, { *--bigptr = *bitbufferptr++; } ); - } - #else - { - var uintD* bigptr = TheBignum(big)->data+digitcount; - var uintL count2; -#define GET_NEXT_BYTE(i) digit |= ((uintD)(*bitbufferptr++) << (8*i)); - dotimespL(count2,floor(count,intDsize/8), { - var uintD digit = 0; - DOCONSTTIMES(intDsize/8,GET_NEXT_BYTE); # GET_NEXT_BYTE(0..intDsize/8-1) - *--bigptr = digit; - }); -#undef GET_NEXT_BYTE - count2 = count % (intDsize/8); - if (count2>0) { - var uintL shiftcount = 0; - var uintD digit = (uintD)(*bitbufferptr++); - dotimesL(count2,count2-1, { - shiftcount += 8; - digit |= ((uintD)(*bitbufferptr++) << shiftcount); - }); - *--bigptr = digit ^ (sign << (shiftcount+8)); - } - } - #endif - # since (intDsize/8)*(digitcount-1) < count <= (intDsize/8)*digitcount - # everything is filled. - return big; + var object result = LESbvector_to_I(bytesize,&STACK_0); + skipSTACK(1); + return result; } # UP for READ-BYTE on File-Streams of Integers, Type s : @@ -4578,69 +4452,10 @@ # stream. typedef void wr_by_aux_ix (object stream, uintL bitsize, uintL bytesize); -local void bitbuff_ixu_sub (object stream, object bitbuffer, - uintL bitsize, uintL bytesize, object obj) { - ASSERT_wr_int(stream,obj); - if (!positivep(obj)) +local inline void bitbuff_ixu_sub (object stream, object bitbuffer, + uintL bitsize, object obj) { + if (UI_to_LEbytes(obj,bitsize,TheSbvector(bitbuffer)->data)) fehler_bad_integer(stream,obj); - # obj is an integer >=0 - # transfer obj into the bitbuffer: - { - var uintB* bitbufferptr = TheSbvector(bitbuffer)->data; - var uintL count = bytesize; - if (posfixnump(obj)) { # obj is a Fixnum >=0 - var uintL wert = posfixnum_to_L(obj); - # check wert < 2^bitsize: - if (!((bitsize>=oint_data_len) || (wert < bit(bitsize)))) - fehler_bad_integer(stream,obj); - # store wert in Bitbuffer: - until (wert==0) { - *bitbufferptr++ = (uint8)wert; wert = wert>>8; count--; - } - } else { # obj is a Bignum >0 - var uintL len = (uintL)Bignum_length(obj); - # check obj < 2^bitsize: - if (!((floor(bitsize,intDsize) >= len) - || ((floor(bitsize,intDsize) == len-1) - && (TheBignum(obj)->data[0] < bit(bitsize%intDsize))))) - fehler_bad_integer(stream,obj); - #if BIG_ENDIAN_P - { - var uintB* ptr = (uintB*)&TheBignum(obj)->data[len]; - # convert Digit-Length in Byte-Length: - len = (intDsize/8)*len; -#define CHECK_NEXT_BYTE(i) \ - if (((uintB*)(&TheBignum(obj)->data[0]))[i] != 0) goto len_ok; len--; - DOCONSTTIMES(intDsize/8,CHECK_NEXT_BYTE); # CHECK_NEXT_BYTE(0..intDsize/8-1) -#undef CHECK_NEXT_BYTE - len_ok: - # store obj in Bitbuffer: - count = count - len; - dotimespL(len,len, { *bitbufferptr++ = *--ptr; } ); - } - #else - { - var uintD* ptr = &TheBignum(obj)->data[len]; - len--; - count -= (intDsize/8)*len; - dotimesL(len,len, { - var uintD digit = *--ptr; - doconsttimes(intDsize/8, { - *bitbufferptr++ = (uintB)digit; digit = digit >> 8; - }); - }); - var uintD digit = *--ptr; - doconsttimes(intDsize/8, { - if (digit==0) goto ok; - *bitbufferptr++ = (uintB)digit; digit = digit >> 8; - count--; - }); - ok: ; - } - #endif - } - memset(bitbufferptr,0,count); - } } # UP for WRITE-BYTE on File-Streams of Integers, Type u : @@ -4651,79 +4466,15 @@ local maygc void wr_by_ixu_sub (object stream, object obj, wr_by_aux_ix* finisher) { var uintL bitsize = ChannelStream_bitsize(stream); var uintL bytesize = ceiling(bitsize,8); - bitbuff_ixu_sub(stream,TheStream(stream)->strm_bitbuffer, - bitsize,bytesize,obj); + ASSERT_wr_int(stream,obj); + bitbuff_ixu_sub(stream,TheStream(stream)->strm_bitbuffer,bitsize,obj); (*finisher)(stream,bitsize,bytesize); } -local void bitbuff_ixs_sub (object stream, object bitbuffer, - uintL bitsize, uintL bytesize, object obj) { - ASSERT_wr_int(stream,obj); - # obj is an integer - # transfer obj into the bitbuffer: - { - var uintB* bitbufferptr = TheSbvector(bitbuffer)->data; - var uintL count = bytesize; - var uintL sign = (sintL)R_sign(obj); - if (fixnump(obj)) { - # obj is a Fixnum - var uintL wert = fixnum_to_L(obj); # >=0 or <0, according to sign - # check 0 <= wert < 2^(bitsize-1) resp. -2^(bitsize-1) <= wert < 0: - wert = wert^sign; - if (!((bitsize>oint_data_len) || (wert < bit(bitsize-1)))) - fehler_bad_integer(stream,obj); - # store wert^sign in Bitbuffer: - until (wert == 0) { - *bitbufferptr++ = (uint8)(wert^sign); wert = wert>>8; count--; - } - memset(bitbufferptr,(uint8)sign,count); - } else { - # obj is a Bignum - var uintL len = (uintL)Bignum_length(obj); - # check -2^(bitsize-1) <= obj < 2^(bitsize-1): - if (!((floor(bitsize,intDsize) >= len) - || ((bitsize > intDsize*(len-1)) - && ((TheBignum(obj)->data[0] ^ (uintD)sign) < - bit((bitsize%intDsize)-1))))) - fehler_bad_integer(stream,obj); - #if BIG_ENDIAN_P - { - var uintB* ptr = (uintB*)&TheBignum(obj)->data[len]; - # convert Digit-Length in Byte-Length: - len = (intDsize/8)*len; -#define CHECK_NEXT_BYTE(i) \ - if (((uintB*)(&TheBignum(obj)->data[0]))[i] != (uintB)sign) goto len_ok; \ - len--; - DOCONSTTIMES(intDsize/8,CHECK_NEXT_BYTE); # CHECK_NEXT_BYTE(0..intDsize/8-1) -#undef CHECK_NEXT_BYTE - len_ok: - # store obj in Bitbuffer: - count = count - len; - dotimespL(len,len, { *bitbufferptr++ = *--ptr; } ); - } - #else - { - var uintD* ptr = &TheBignum(obj)->data[len]; - len--; - count -= (intDsize/8)*len; - dotimesL(len,len, { - var uintD digit = *--ptr; - doconsttimes(intDsize/8, { - *bitbufferptr++ = (uintB)digit; digit = digit >> 8; - }); - }); - var sintD digit = *--ptr; - doconsttimes(intDsize/8, { - if (digit == (sintD)sign) goto ok; - *bitbufferptr++ = (uintB)digit; digit = digit >> 8; - count--; - }); - ok: ; - } - #endif - memset(bitbufferptr,(uintB)sign,count); - } - } +local inline void bitbuff_ixs_sub (object stream, object bitbuffer, + uintL bitsize, object obj) { + if (I_to_LEbytes(obj,bitsize,TheSbvector(bitbuffer)->data)) + fehler_bad_integer(stream,obj); } # UP for WRITE-BYTE on File-Streams of Integers, Type s : @@ -4734,8 +4485,8 @@ local maygc void wr_by_ixs_sub (object stream, object obj, wr_by_aux_ix* finisher) { var uintL bitsize = ChannelStream_bitsize(stream); var uintL bytesize = ceiling(bitsize,8); - bitbuff_ixs_sub(stream,TheStream(stream)->strm_bitbuffer, - bitsize,bytesize,obj); + ASSERT_wr_int(stream,obj); + bitbuff_ixs_sub(stream,TheStream(stream)->strm_bitbuffer,bitsize,obj); (*finisher)(stream,bitsize,bytesize); } @@ -17087,10 +16838,10 @@ # Copy the integer's data into the buffer. switch (eltype.kind) { case eltype_iu: - bitbuff_ixu_sub(STACK_3,bitbuffer,bitsize,bytesize,obj); + bitbuff_ixu_sub(STACK_3,bitbuffer,bitsize,obj); break; case eltype_is: - bitbuff_ixs_sub(STACK_3,bitbuffer,bitsize,bytesize,obj); + bitbuff_ixs_sub(STACK_3,bitbuffer,bitsize,obj); break; default: NOTREACHED; } Index: ChangeLog =================================================================== RCS file: /cvsroot/clisp/clisp/src/ChangeLog,v retrieving revision 1.4170 retrieving revision 1.4171 diff -u -d -r1.4170 -r1.4171 --- ChangeLog 29 Jan 2005 14:50:09 -0000 1.4170 +++ ChangeLog 29 Jan 2005 14:55:10 -0000 1.4171 @@ -1,5 +1,26 @@ 2005-01-28 Bruno Haible <br...@cl...> + * lispbibl.d (FAKE_8BIT_VECTOR): New macro. + (LEbytes_to_UI, LESbvector_to_UI, LEbytes_to_I, LESbvector_to_I, + UI_to_LEbytes, I_to_LEbytes): New declarations. + * intserial.d: New file, mostly extracted from stream.d. + * lisparit.d: Include intserial.c. + * stream.d (bitbuff_iu_I): Use LESbvector_to_UI. + (bitbuff_is_I): Use LESbvector_to_I. + (bitbuff_ixu_sub): Remove bytesize argument. Use UI_to_LEbytes. Don't + call ASSERT_wr_int here. + (wr_by_ixu_sub): Call ASSERT_wr_int here. Update. + (bitbuff_ixs_sub): Remove bytesize argument. Use I_to_LEbytes. Don't + call ASSERT_wr_int here. + (wr_by_ixs_sub): Call ASSERT_wr_int here. Update. + (WRITE-INTEGER): Update. + * genclisph.d (main): Emit declarations for LEbytes_to_UI, LEbytes_to_I, + UI_to_LEbytes, I_to_LEbytes. + * makemake.in (LISPARIT_SUBFILES): Add intserial. + * po/Makefile.devel (DSOURCES): Add intserial. + +2005-01-28 Bruno Haible <br...@cl...> + * io.d (pr_readlabel): Fix C++ compilation. 2005-01-28 Bruno Haible <br...@cl...> Index: makemake.in =================================================================== RCS file: /cvsroot/clisp/clisp/src/makemake.in,v retrieving revision 1.510 retrieving revision 1.511 diff -u -d -r1.510 -r1.511 --- makemake.in 28 Jan 2005 17:22:41 -0000 1.510 +++ makemake.in 29 Jan 2005 14:55:06 -0000 1.511 @@ -1630,7 +1630,7 @@ ERROR_INCLUDES=$ERROR_INCLUDES' errwin32' fi -LISPARIT_SUBFILES=' aridecl arilev0 arilev1 intelem intlog intplus intcomp intbyte intmal intdiv intgcd int2adic intsqrt intprint intread rational' +LISPARIT_SUBFILES=' aridecl arilev0 arilev1 intelem intlog intplus intcomp intbyte intmal intdiv intgcd int2adic intsqrt intprint intread intserial rational' LISPARIT_SUBFILES=$LISPARIT_SUBFILES' sfloat ffloat dfloat lfloat flo_konv flo_rest realelem realrand realtran compelem comptran' LISPARIT_INCLUDES=$LISPARIT_SUBFILES' arilev1c arilev1e arilev1i' Index: lispbibl.d =================================================================== RCS file: /cvsroot/clisp/clisp/src/lispbibl.d,v retrieving revision 1.609 retrieving revision 1.610 diff -u -d -r1.609 -r1.610 --- lispbibl.d 28 Jan 2005 14:09:10 -0000 1.609 +++ lispbibl.d 29 Jan 2005 14:55:07 -0000 1.610 @@ -8656,6 +8656,20 @@ #endif # used by STREAM, PATHNAME +# Macro: Wraps a GC-invariant uintB* pointer in a fake simple-8bit-vector. +# FAKE_8BIT_VECTOR(ptr) +# > uintB* ptr: pointer to GC-invariant data +# < gcv_object_t obj: a fake simple-8bit-vector, +# with TheSbvector(obj)->data == ptr, +# that must *not* be stored in GC-visible locations +#ifdef TYPECODES + #define FAKE_8BIT_VECTOR(ptr) \ + type_pointer_object(0, (const char*)(ptr) - offsetofa(sbvector_,data)) +#else + #define FAKE_8BIT_VECTOR(ptr) \ + fake_gcv_object((aint)((const char*)(ptr) - offsetofa(sbvector_,data)) + varobject_bias) +#endif + #if !defined(UNICODE) || defined(HAVE_SMALL_SSTRING) # UP, provides 8-bit character string # allocate_s8string(len) @@ -14479,6 +14493,57 @@ extern uintL I_integer_length (object x); # is used by ARRAY +# Converts a little-endian byte sequence to an unsigned integer. +# > bytesize: number of given 8-bit bytes of the integer, +# < intDsize/8*uintWC_max +# > bufferptr: address of bytesize bytes of memory +# < result: an integer >= 0 with I_integer_length(result) <= 8*bytesize +extern maygc object LEbytes_to_UI (uintL bytesize, const uintB* bufferptr); + +# Converts a little-endian byte sequence to an unsigned integer. +# > bytesize: number of given 8-bit bytes of the integer, +# < intDsize/8*uintWC_max +# > *buffer_: address of a simple-8bit-vector (or of a fake) +# containing bytesize bytes of memory +# < result: an integer >= 0 with I_integer_length(result) <= 8*bytesize +extern maygc object LESbvector_to_UI (uintL bytesize, const gcv_object_t* buffer_); +# is used by STREAM + +# Converts a little-endian byte sequence to an integer. +# > bytesize: number of given 8-bit bytes of the integer, > 0, +# < intDsize/8*uintWC_max +# > bufferptr: address of bytesize bytes of memory +# < result: an integer with I_integer_length(result) < 8*bytesize +extern maygc object LEbytes_to_I (uintL bytesize, const uintB* bufferptr); + +# Converts a little-endian byte sequence to an integer. +# > bytesize: number of given 8-bit bytes of the integer, > 0, +# < intDsize/8*uintWC_max +# > *buffer_: address of a simple-8bit-vector (or of a fake) +# containing bytesize bytes of memory +# < result: an integer with I_integer_length(result) < 8*bytesize +extern maygc object LESbvector_to_I (uintL bytesize, const gcv_object_t* buffer_); +# is used by STREAM + +# Converts an unsigned integer to a little-endian byte sequence. +# > obj: an integer +# > bitsize: maximum number of bits of the integer +# > bufferptr: pointer to bytesize = ceiling(bitsize,8) bytes of memory +# < false and bufferptr[0..bytesize-1] filled, if obj >= 0 and +# I_integer_length(obj) <= bitsize; +# true, if obj is out of range +extern bool UI_to_LEbytes (object obj, uintL bitsize, uintB* bufferptr); +# is used by STREAM + +# Converts an integer to a little-endian byte sequence. +# > obj: an integer +# > bitsize: maximum number of bits of the integer, including the sign bit +# > bufferptr: pointer to bytesize = ceiling(bitsize,8) bytes of memory +# < false and bufferptr[0..bytesize-1] filled, if I_integer_length(obj) < bitsize; +# true, if obj is out of range +extern bool I_to_LEbytes (object obj, uintL bitsize, uintB* bufferptr); +# is used by STREAM + # c_float_to_FF(&val) converts an IEEE-single-float val into an single-float. # can trigger GC extern maygc object c_float_to_FF (const ffloatjanus* val_); --- NEW FILE: intserial.d --- /* Serialization of integers into a little-endian sequence of bytes */ # Converts a little-endian byte sequence to an unsigned integer. # > bytesize: number of given 8-bit bytes of the integer, # < intDsize/8*uintWC_max # > bufferptr: address of bytesize bytes of memory # < result: an integer >= 0 with I_integer_length(result) <= 8*bytesize global maygc object LEbytes_to_UI (uintL bytesize, const uintB* bufferptr) { var gcv_object_t fake = FAKE_8BIT_VECTOR(bufferptr); return LESbvector_to_UI(bytesize,&fake); } # Converts a little-endian byte sequence to an unsigned integer. # > bytesize: number of given 8-bit bytes of the integer, # < intDsize/8*uintWC_max # > *buffer_: address of a simple-8bit-vector (or of a fake) # containing bytesize bytes of memory # < result: an integer >= 0 with I_integer_length(result) <= 8*bytesize global maygc object LESbvector_to_UI (uintL bytesize, const gcv_object_t* buffer_) { # Normalize number in buffer: var uintB* bufferptr = &TheSbvector(*buffer_)->data[bytesize-1]; var uintL count = bytesize; while ((!(count==0)) && (*bufferptr==0)) { count--; bufferptr--; } # Make number: if # at most oint_data_len Bits ? ((count <= floor(oint_data_len,8)) || ((count == floor(oint_data_len,8)+1) && (*bufferptr < bit(oint_data_len%8)))) { # yes -> build Fixnum >=0 : var uintL wert = 0; until (count==0) { wert = (wert<<8) | *bufferptr--; count--; } return fixnum(wert); } # no -> build Bignum >0 : var uintL digitcount = floor(count,(intDsize/8)); if (((count%(intDsize/8)) > 0) || (*bufferptr & bit(7))) digitcount++; # As bitsize < intDsize*uintWC_max, # digitcount <= ceiling((bitsize+1)/intDsize) <= uintWC_max . var object big = allocate_bignum(digitcount,0); # new Bignum >0 TheBignum(big)->data[0] = 0; # set highest Digit to 0 # Fill remaining Digits from right to left, # thereby translate sequence of Bytes into sequence of uintD: bufferptr = &TheSbvector(*buffer_)->data[0]; #if BIG_ENDIAN_P { var uintB* bigptr = (uintB*)(&TheBignum(big)->data[digitcount]); dotimespL(count,count, { *--bigptr = *bufferptr++; } ); } #else { var uintD* bigptr = &TheBignum(big)->data[digitcount]; var uintL count2; #define GET_NEXT_BYTE(i) digit |= ((uintD)(*bufferptr++) << (8*i)); dotimespL(count2,floor(count,intDsize/8), { var uintD digit = 0; DOCONSTTIMES(intDsize/8,GET_NEXT_BYTE); # GET_NEXT_BYTE(0..intDsize/8-1) *--bigptr = digit; }); #undef GET_NEXT_BYTE count2 = count % (intDsize/8); if (count2>0) { var uintL shiftcount = 0; var uintD digit = (uintD)(*bufferptr++); dotimesL(count2,count2-1, { shiftcount += 8; digit |= ((uintD)(*bufferptr++) << shiftcount); }); *--bigptr = digit; } } #endif # Since (intDsize/8)*(digitcount-1) <= count <= (intDsize/8)*digitcount # everything is filled. return big; } # Converts a little-endian byte sequence to an integer. # > bytesize: number of given 8-bit bytes of the integer, > 0, # < intDsize/8*uintWC_max # > bufferptr: address of bytesize bytes of memory # < result: an integer with I_integer_length(result) < 8*bytesize global maygc object LEbytes_to_I (uintL bytesize, const uintB* bufferptr) { var gcv_object_t fake = FAKE_8BIT_VECTOR(bufferptr); return LESbvector_to_I(bytesize,&fake); } # Converts a little-endian byte sequence to an integer. # > bytesize: number of given 8-bit bytes of the integer, > 0, # < intDsize/8*uintWC_max # > *buffer_: address of a simple-8bit-vector (or of a fake) # containing bytesize bytes of memory # < result: an integer with I_integer_length(result) < 8*bytesize global maygc object LESbvector_to_I (uintL bytesize, const gcv_object_t* buffer_) { # Normalize number in buffer: var uintB* bufferptr = &TheSbvector(*buffer_)->data[bytesize-1]; var sintD sign; var uintL count = bytesize; if (!(*bufferptr & bit(7))) { sign = 0; # Normalize, highest Bit must remain 0: while ((count>=2) && (*bufferptr==0) && !(*(bufferptr-1) & bit(7))) { count--; bufferptr--; } # Make number: if # at most oint_data_len+1 Bits, count <2^oint_data_len ? ((count <= floor(oint_data_len,8)) || ((count == floor(oint_data_len,8)+1) && (*bufferptr < bit(oint_data_len%8)))) { # yes -> build Fixnum >=0: var uintL value = 0; until (count==0) { value = (value<<8) | *bufferptr--; count--; } return posfixnum(value); } } else { sign = -1; # Normalize, highest Bit must remain 1: while ((count>=2) && (*bufferptr==(uintB)(-1)) && (*(bufferptr-1) & bit(7))) { count--; bufferptr--; } # Make number: if # at most oint_data_len+1 Bits, count >=-2^oint_data_len ? ((count <= floor(oint_data_len,8)) || ((count == floor(oint_data_len,8)+1) && (*bufferptr >= (uintB)(-bit(oint_data_len%8))))) { # yes -> build Fixnum <0: var uintL value = (uintL)(-1); until (count==0) { value = (value<<8) | *bufferptr--; count--; } return negfixnum(-wbitm(intLsize)+(oint)value); } } # Make bignum: var uintL digitcount = ceiling(count,(intDsize/8)); # As bitsize < intDsize*uintWC_max, # digitcount <= ceiling(bitsize/intDsize) <= uintWC_max . var object big = allocate_bignum(digitcount,(sintB)sign); TheBignum(big)->data[0] = sign; # set highest Word to sign # Fill the remaining Digits from right to left, # thereby translate sequence of Bytes into sequence of uintD: bufferptr = &TheSbvector(*buffer_)->data[0]; #if BIG_ENDIAN_P { var uintB* bigptr = (uintB*)(TheBignum(big)->data+digitcount); dotimespL(count,count, { *--bigptr = *bufferptr++; } ); } #else { var uintD* bigptr = TheBignum(big)->data+digitcount; var uintL count2; #define GET_NEXT_BYTE(i) digit |= ((uintD)(*bufferptr++) << (8*i)); dotimespL(count2,floor(count,intDsize/8), { var uintD digit = 0; DOCONSTTIMES(intDsize/8,GET_NEXT_BYTE); # GET_NEXT_BYTE(0..intDsize/8-1) *--bigptr = digit; }); #undef GET_NEXT_BYTE count2 = count % (intDsize/8); if (count2>0) { var uintL shiftcount = 0; var uintD digit = (uintD)(*bufferptr++); dotimesL(count2,count2-1, { shiftcount += 8; digit |= ((uintD)(*bufferptr++) << shiftcount); }); *--bigptr = digit ^ (sign << (shiftcount+8)); } } #endif # Since (intDsize/8)*(digitcount-1) < count <= (intDsize/8)*digitcount # everything is filled. return big; } # Converts an unsigned integer to a little-endian byte sequence. # > obj: an integer # > bitsize: maximum number of bits of the integer # > bufferptr: pointer to bytesize = ceiling(bitsize,8) bytes of memory # < false and bufferptr[0..bytesize-1] filled, if obj >= 0 and # I_integer_length(obj) <= bitsize; # true, if obj is out of range global bool UI_to_LEbytes (object obj, uintL bitsize, uintB* bufferptr) { if (!positivep(obj)) return true; # obj is an integer >=0. var uintL bytesize = ceiling(bitsize,8); # Transfer obj into the buffer: { var uintL count = bytesize; if (posfixnump(obj)) { # obj is a Fixnum >=0 var uintL value = posfixnum_to_L(obj); # check value < 2^bitsize: if (!((bitsize>=oint_data_len) || (value < bit(bitsize)))) return true; # store value in Bitbuffer: until (value==0) { *bufferptr++ = (uint8)value; value = value>>8; count--; } } else { # obj is a Bignum >0 var uintL len = (uintL)Bignum_length(obj); # check obj < 2^bitsize: if (!((floor(bitsize,intDsize) >= len) || ((floor(bitsize,intDsize) == len-1) && (TheBignum(obj)->data[0] < bit(bitsize%intDsize))))) return true; #if BIG_ENDIAN_P { var uintB* ptr = (uintB*)&TheBignum(obj)->data[len]; # convert Digit-Length in Byte-Length: len = (intDsize/8)*len; #define CHECK_NEXT_BYTE(i) \ if (((uintB*)(&TheBignum(obj)->data[0]))[i] != 0) goto len_ok; \ len--; DOCONSTTIMES(intDsize/8,CHECK_NEXT_BYTE); # CHECK_NEXT_BYTE(0..intDsize/8-1) #undef CHECK_NEXT_BYTE len_ok: # store obj in Bitbuffer: count = count - len; dotimespL(len,len, { *bufferptr++ = *--ptr; } ); } #else { var uintD* ptr = &TheBignum(obj)->data[len]; len--; count -= (intDsize/8)*len; dotimesL(len,len, { var uintD digit = *--ptr; doconsttimes(intDsize/8, { *bufferptr++ = (uintB)digit; digit = digit >> 8; }); }); var uintD digit = *--ptr; doconsttimes(intDsize/8, { if (digit==0) goto ok; *bufferptr++ = (uintB)digit; digit = digit >> 8; count--; }); ok: ; } #endif } if (count > 0) { begin_system_call(); memset(bufferptr,0,count); end_system_call(); } } return false; } # Converts an integer to a little-endian byte sequence. # > obj: an integer # > bitsize: maximum number of bits of the integer, including the sign bit # > bufferptr: pointer to bytesize = ceiling(bitsize,8) bytes of memory # < false and bufferptr[0..bytesize-1] filled, if I_integer_length(obj) < bitsize; # true, if obj is out of range global bool I_to_LEbytes (object obj, uintL bitsize, uintB* bufferptr) { # obj is an integer. var uintL bytesize = ceiling(bitsize,8); # Transfer obj into the buffer: { var uintL count = bytesize; var uintL sign = (sintL)R_sign(obj); if (fixnump(obj)) { # obj is a Fixnum var uintL value = fixnum_to_L(obj); # >=0 or <0, according to sign # check 0 <= value < 2^(bitsize-1) resp. -2^(bitsize-1) <= value < 0: value = value^sign; if (!((bitsize>oint_data_len) || (value < bit(bitsize-1)))) return true; # store value^sign in Bitbuffer: until (value == 0) { *bufferptr++ = (uint8)(value^sign); value = value>>8; count--; } if (count > 0) { begin_system_call(); memset(bufferptr,(uint8)sign,count); end_system_call(); } } else { # obj is a Bignum var uintL len = (uintL)Bignum_length(obj); # check -2^(bitsize-1) <= obj < 2^(bitsize-1): if (!((floor(bitsize,intDsize) >= len) || ((bitsize > intDsize*(len-1)) && ((TheBignum(obj)->data[0] ^ (uintD)sign) < bit((bitsize%intDsize)-1))))) return true; #if BIG_ENDIAN_P { var uintB* ptr = (uintB*)&TheBignum(obj)->data[len]; # convert Digit-Length in Byte-Length: len = (intDsize/8)*len; #define CHECK_NEXT_BYTE(i) \ if (((uintB*)(&TheBignum(obj)->data[0]))[i] != (uintB)sign) goto len_ok; \ len--; DOCONSTTIMES(intDsize/8,CHECK_NEXT_BYTE); # CHECK_NEXT_BYTE(0..intDsize/8-1) #undef CHECK_NEXT_BYTE len_ok: # store obj in Bitbuffer: count = count - len; dotimespL(len,len, { *bufferptr++ = *--ptr; } ); } #else { var uintD* ptr = &TheBignum(obj)->data[len]; len--; count -= (intDsize/8)*len; dotimesL(len,len, { var uintD digit = *--ptr; doconsttimes(intDsize/8, { *bufferptr++ = (uintB)digit; digit = digit >> 8; }); }); var sintD digit = *--ptr; doconsttimes(intDsize/8, { if (digit == (sintD)sign) goto ok; *bufferptr++ = (uintB)digit; digit = digit >> 8; count--; }); ok: ; } #endif if (count > 0) { begin_system_call(); memset(bufferptr,(uintB)sign,count); end_system_call(); } } } return false; } --__--__-- Message: 3 From: Bruno Haible <ha...@us...> To: cli...@li... Subject: clisp/src/po Makefile.devel,1.37,1.38 Date: Sat, 29 Jan 2005 14:55:09 +0000 Reply-To: cli...@li... Update of /cvsroot/clisp/clisp/src/po In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24689/src/po Modified Files: Makefile.devel Log Message: New primitives for serializing and deserializing integers. Index: Makefile.devel =================================================================== RCS file: /cvsroot/clisp/clisp/src/po/Makefile.devel,v retrieving revision 1.37 retrieving revision 1.38 diff -u -d -r1.37 -r1.38 --- Makefile.devel 20 Dec 2004 14:15:25 -0000 1.37 +++ Makefile.devel 29 Jan 2005 14:55:06 -0000 1.38 @@ -37,8 +37,8 @@ misc time predtype symbol \ lisparit aridecl arilev0 arilev1 arilev1c arilev1e arilev1i intelem \ intlog intplus intcomp intbyte intmal intdiv intgcd int2adic intsqrt \ - intprint intread rational sfloat ffloat dfloat lfloat flo_konv flo_rest \ - realelem realrand realtran compelem comptran \ + intprint intread intserial rational sfloat ffloat dfloat lfloat flo_konv \ + flo_rest realelem realrand realtran compelem comptran \ affi \ foreign \ unixaux win32aux \ --__--__-- Message: 4 From: Bruno Haible <ha...@us...> To: cli...@li... Subject: clisp/src lispbibl.d,1.610,1.611 genclisph.d,1.168,1.169 intelem.d,1.29,1.30 socket.d,1.89,1.90 ChangeLog,1.4171,1.4172 Date: Sat, 29 Jan 2005 14:57:13 +0000 Reply-To: cli...@li... Update of /cvsroot/clisp/clisp/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25162/src Modified Files: lispbibl.d genclisph.d intelem.d socket.d ChangeLog Log Message: Remove ill-designed function udigits_to_I. Index: socket.d =================================================================== RCS file: /cvsroot/clisp/clisp/src/socket.d,v retrieving revision 1.89 retrieving revision 1.90 diff -u -d -r1.89 -r1.90 --- socket.d 25 Jan 2005 14:35:06 -0000 1.89 +++ socket.d 29 Jan 2005 14:57:10 -0000 1.90 @@ -337,7 +337,7 @@ local int string_to_addr1 (void* addr, int addrlen, int family, void* ret) { *(object*)ret = (addrlen - ? udigits_to_I(addr,addrlen) + ? LEbytes_to_UI(addrlen,(const uintB*)addr) : asciz_to_string((char*)addr,O(misc_encoding))); (void)family; /* ignore */ return 0; Index: lispbibl.d =================================================================== RCS file: /cvsroot/clisp/clisp/src/lispbibl.d,v retrieving revision 1.610 retrieving revision 1.611 diff -u -d -r1.610 -r1.611 --- lispbibl.d 29 Jan 2005 14:55:07 -0000 1.610 +++ lispbibl.d 29 Jan 2005 14:57:10 -0000 1.611 @@ -14442,7 +14442,6 @@ there must be room for 1 digit below of MSDptr. can trigger GC */ extern maygc object UDS_to_I (uintD* MSDptr, uintC len); -extern maygc object udigits_to_I (void* digits, uintC len); /* is used by modules */ /* Digit Sequence to Integer Index: intelem.d =================================================================== RCS file: /cvsroot/clisp/clisp/src/intelem.d,v retrieving revision 1.29 retrieving revision 1.30 diff -u -d -r1.29 -r1.30 --- intelem.d 25 Jan 2005 09:32:48 -0000 1.29 +++ intelem.d 29 Jan 2005 14:57:10 -0000 1.30 @@ -1357,27 +1357,6 @@ return NDS_to_I(MSDptr,len); } -/* bit sequence --> integer */ -global maygc object udigits_to_I (void* digits, uintC len) { - var uintL bn_size = ceiling(len,sizeof(uintD)); - var uintD total = bn_size * sizeof(uintD); - var void *data = (len == total ? digits : - total<=1024 ? alloca(total) : my_malloc(total)); - if (data != digits) { /* len is not divisible by sizeof(uintD) */ - begin_system_call(); - memset(data,0,total); - memcpy((char*)data + total - len,digits,len); - end_system_call(); - } - var object ret = UDS_to_I(data,bn_size); - if (data != digits && total>1024) { - begin_system_call(); - free(data); - end_system_call(); - } - return ret; -} - /* Digit Sequence to Integer DS_to_I(MSDptr,len) convert DS MSDptr/len/.. into Integer. Index: genclisph.d =================================================================== RCS file: /cvsroot/clisp/clisp/src/genclisph.d,v retrieving revision 1.168 retrieving revision 1.169 diff -u -d -r1.168 -r1.169 --- genclisph.d 29 Jan 2005 14:55:10 -0000 1.168 +++ genclisph.d 29 Jan 2005 14:57:10 -0000 1.169 @@ -2213,7 +2213,6 @@ printf("#define I_to_slong I_to_sint64\n"); #endif printf("extern object UDS_to_I (uintD* MSDptr, uintC len);\n"); - printf("extern object udigits_to_I (void* digits, uintC len);\n"); printf("extern object DS_to_I (const uintD* MSDptr, uintC len);\n"); #if notused printf("extern object I_1_plus_I (object x);\n"); Index: ChangeLog =================================================================== RCS file: /cvsroot/clisp/clisp/src/ChangeLog,v retrieving revision 1.4171 retrieving revision 1.4172 diff -u -d -r1.4171 -r1.4172 --- ChangeLog 29 Jan 2005 14:55:10 -0000 1.4171 +++ ChangeLog 29 Jan 2005 14:57:10 -0000 1.4172 @@ -1,5 +1,13 @@ 2005-01-28 Bruno Haible <br...@cl...> + * lispbibl.d (udigits_to_I): Remove declaration. + * intelem.d (udigits_to_I): Remove function. + * socket.d (string_to_addr1): Call LEbytes_to_UI instead of + udigits_to_I. + * genclisph.d (main): Don't emit udigits_to_I declaration. + +2005-01-28 Bruno Haible <br...@cl...> + * lispbibl.d (FAKE_8BIT_VECTOR): New macro. (LEbytes_to_UI, LESbvector_to_UI, LEbytes_to_I, LESbvector_to_I, UI_to_LEbytes, I_to_LEbytes): New declarations. --__--__-- _______________________________________________ clisp-cvs mailing list cli...@li... https://lists.sourceforge.net/lists/listinfo/clisp-cvs End of clisp-cvs Digest |