Changeset 32778 in project


Ignore:
Timestamp:
09/09/15 11:44:20 (4 years ago)
Author:
felix winkelmann
Message:

s11n 0.9.7: applied argvector-patch by sjamaan

Location:
release/4/s11n
Files:
2 edited
1 copied

Legend:

Unmodified
Added
Removed
  • release/4/s11n/tags/0.9.7/s11n-c.c

    r30055 r32778  
    11/* s11n-c.c */
    22
     3/* argvector chicken starts with version 8 */
     4#if C_BINARY_VERSION >= 8
     5# define ARGVECTOR_CHICKEN
     6#endif
    37
    4 static void fixnum_to_bytes(C_word c, C_word self, C_word k, C_word x)
     8/* Messy macros to easily support pre- and post-argvector CHICKENs */
     9#ifdef ARGVECTOR_CHICKEN
     10# define CPS_PROC1(name, c, s, k, a1) name(C_word c, C_word *__av)
     11# define CPS_BODY1(c, s, k, a1) C_word s = __av[0]; C_word k = __av[1]; C_word a1 = c >= 1 ? __av[2] : 0;
     12#else
     13# define CPS_PROC1(name, c, s, k, a1) name(C_word c, C_word s, C_word k, C_word a1)
     14# define CPS_BODY1(c, s, k, a1) /* Nothing */
     15#endif
     16
     17static void CPS_PROC1(fixnum_to_bytes, c, self, k, x)
    518{
     19  CPS_BODY1(c, self, k, x);
    620  C_word *a = C_alloc(C_SIZEOF_STRING(sizeof(C_word)));
    721  C_kontinue(k, C_string(&a, sizeof(C_word), (C_char *)&x));
    822}
    923
    10 static void word_to_bytes(C_word c, C_word self, C_word k, C_word x)
     24static void CPS_PROC1(word_to_bytes, c, self, k, x)
    1125{
     26  CPS_BODY1(c, self, k, x);
    1227  C_word *a = C_alloc(C_SIZEOF_STRING(sizeof(unsigned long)));
    1328  unsigned long n = C_num_to_unsigned_long(x);
     
    1530}
    1631
    17 static void header_to_bytes(C_word c, C_word self, C_word k, C_word x)
     32static void CPS_PROC1(header_to_bytes, c, self, k, x)
    1833{
     34  CPS_BODY1(c, self, k, x);
    1935  C_word *a = C_alloc(C_SIZEOF_STRING(sizeof(C_header)));
    2036  C_kontinue(k, C_string(&a, sizeof(C_header), (C_char *)x));
    2137}
    2238
    23 static void bytes_to_block(C_word c, C_word self, C_word k, C_word str)
     39static void CPS_PROC1(bytes_to_block, c, self, k, str)
    2440{
     41  CPS_BODY1(c, self, k, str);
    2542  C_header h = *((C_header *)C_data_pointer(str)); 
    2643  int size = h & C_HEADER_SIZE_MASK;
     44#ifdef ARGVECTOR_CHICKEN
     45  C_word av[6];
    2746
     47  av[ 0 ] = C_SCHEME_UNDEFINED;
     48  av[ 1 ] = k;
     49  av[ 2 ] = C_fix(size);
     50  av[ 3 ] = C_mk_bool((h & C_BYTEBLOCK_BIT) != 0);
     51  av[ 4 ] = C_SCHEME_FALSE;
     52  av[ 5 ] = C_mk_bool((h & C_8ALIGN_BIT) != 0);
     53  C_allocate_vector(6, av);
     54#else
    2855  C_allocate_vector(6, C_SCHEME_UNDEFINED, k, C_fix(size), C_mk_bool((h & C_BYTEBLOCK_BIT) != 0),
    2956                       C_SCHEME_FALSE, C_mk_bool((h & C_8ALIGN_BIT) != 0));
     57#endif
    3058}
    3159
  • release/4/s11n/trunk/s11n-c.c

    r30055 r32778  
    11/* s11n-c.c */
    22
     3/* argvector chicken starts with version 8 */
     4#if C_BINARY_VERSION >= 8
     5# define ARGVECTOR_CHICKEN
     6#endif
    37
    4 static void fixnum_to_bytes(C_word c, C_word self, C_word k, C_word x)
     8/* Messy macros to easily support pre- and post-argvector CHICKENs */
     9#ifdef ARGVECTOR_CHICKEN
     10# define CPS_PROC1(name, c, s, k, a1) name(C_word c, C_word *__av)
     11# define CPS_BODY1(c, s, k, a1) C_word s = __av[0]; C_word k = __av[1]; C_word a1 = c >= 1 ? __av[2] : 0;
     12#else
     13# define CPS_PROC1(name, c, s, k, a1) name(C_word c, C_word s, C_word k, C_word a1)
     14# define CPS_BODY1(c, s, k, a1) /* Nothing */
     15#endif
     16
     17static void CPS_PROC1(fixnum_to_bytes, c, self, k, x)
    518{
     19  CPS_BODY1(c, self, k, x);
    620  C_word *a = C_alloc(C_SIZEOF_STRING(sizeof(C_word)));
    721  C_kontinue(k, C_string(&a, sizeof(C_word), (C_char *)&x));
    822}
    923
    10 static void word_to_bytes(C_word c, C_word self, C_word k, C_word x)
     24static void CPS_PROC1(word_to_bytes, c, self, k, x)
    1125{
     26  CPS_BODY1(c, self, k, x);
    1227  C_word *a = C_alloc(C_SIZEOF_STRING(sizeof(unsigned long)));
    1328  unsigned long n = C_num_to_unsigned_long(x);
     
    1530}
    1631
    17 static void header_to_bytes(C_word c, C_word self, C_word k, C_word x)
     32static void CPS_PROC1(header_to_bytes, c, self, k, x)
    1833{
     34  CPS_BODY1(c, self, k, x);
    1935  C_word *a = C_alloc(C_SIZEOF_STRING(sizeof(C_header)));
    2036  C_kontinue(k, C_string(&a, sizeof(C_header), (C_char *)x));
    2137}
    2238
    23 static void bytes_to_block(C_word c, C_word self, C_word k, C_word str)
     39static void CPS_PROC1(bytes_to_block, c, self, k, str)
    2440{
     41  CPS_BODY1(c, self, k, str);
    2542  C_header h = *((C_header *)C_data_pointer(str)); 
    2643  int size = h & C_HEADER_SIZE_MASK;
     44#ifdef ARGVECTOR_CHICKEN
     45  C_word av[6];
    2746
     47  av[ 0 ] = C_SCHEME_UNDEFINED;
     48  av[ 1 ] = k;
     49  av[ 2 ] = C_fix(size);
     50  av[ 3 ] = C_mk_bool((h & C_BYTEBLOCK_BIT) != 0);
     51  av[ 4 ] = C_SCHEME_FALSE;
     52  av[ 5 ] = C_mk_bool((h & C_8ALIGN_BIT) != 0);
     53  C_allocate_vector(6, av);
     54#else
    2855  C_allocate_vector(6, C_SCHEME_UNDEFINED, k, C_fix(size), C_mk_bool((h & C_BYTEBLOCK_BIT) != 0),
    2956                       C_SCHEME_FALSE, C_mk_bool((h & C_8ALIGN_BIT) != 0));
     57#endif
    3058}
    3159
Note: See TracChangeset for help on using the changeset viewer.