common.h
Go to the documentation of this file.
00001 #include <stdio.h>
00002 #include <stdlib.h>
00003 #include <stdint.h>
00004 #include <string.h>
00005 
00006 #ifndef offsetof
00007 #define offsetof(type, slot) ((long) ((char *) &(((type *) 0)->slot)))
00008 #endif
00009 #define sizeofslot(type, slot) (sizeof(((type *) 0)->slot))
00010 #define stringify(x) #x
00011 #define indirect_stringify(x) stringify(x)
00012 
00013 #define TYPE_SIGNED_P(type) (((type)-1)<0LL)
00014 #define _64_BIT_VALUE_FITS_SIGNED_P(value) ( (value) <= 0x7FFFFFFFFFFFFFFFLL )
00015 
00016 void type_name(FILE *output, int signed_p, int size) {
00017   if (signed_p) {
00018     switch (size) {
00019     case 1: fprintf(output, ":int8"); break;
00020     case 2: fprintf(output, ":int16"); break;
00021     case 4: fprintf(output, ":int32"); break;
00022     case 8: fprintf(output, ":int64"); break;
00023     default: goto error;
00024     }
00025   } else {
00026     switch(size) {
00027     case 1: fprintf(output, ":uint8"); break;
00028     case 2: fprintf(output, ":uint16"); break;
00029     case 4: fprintf(output, ":uint32"); break;
00030     case 8: fprintf(output, ":uint64"); break;
00031     default: goto error;
00032     }
00033   }
00034 
00035   return;
00036 
00037 error:
00038   fprintf(output, "(cl:error \"No type of size ~D.\" %i)\n", size);
00039 }
00040 
00041 char* print_double_for_lisp(double n)
00042 {
00043     static char buf[256];
00044     memset(buf, 0, 256);
00045     snprintf(buf, 255, "(let ((*read-default-float-format* 'double-float)) (coerce (read-from-string \"%.20E\") 'double-float))", n);
00046     return buf;
00047 }


cffi
Author(s): James Bielman
autogenerated on Thu Feb 11 2016 22:45:14