Mercurial > hg > xemacs-beta
comparison src/alloc.c @ 369:1d62742628b6 r21-1-14
Import from CVS: tag r21-1-14
| author | cvs |
|---|---|
| date | Mon, 13 Aug 2007 11:01:51 +0200 |
| parents | 7347b34c275b |
| children | cc15677e0335 |
comparison
equal
deleted
inserted
replaced
| 368:397a7324211a | 369:1d62742628b6 |
|---|---|
| 1020 | 1020 |
| 1021 Even if Emacs is run on some weirdo system that allows and allocates | 1021 Even if Emacs is run on some weirdo system that allows and allocates |
| 1022 byte-aligned pointers, this pointer is at the very top of the address | 1022 byte-aligned pointers, this pointer is at the very top of the address |
| 1023 space and so it's almost inconceivable that it could ever be valid. */ | 1023 space and so it's almost inconceivable that it could ever be valid. */ |
| 1024 | 1024 |
| 1025 #if INTBITS == 32 | 1025 #if SIZEOF_LONG == 4 |
| 1026 # define INVALID_POINTER_VALUE 0xFFFFFFFF | 1026 # define INVALID_POINTER_VALUE 0xFFFFFFFFUL |
| 1027 #elif INTBITS == 48 | 1027 #elif SIZEOF_LONG == 8 |
| 1028 # define INVALID_POINTER_VALUE 0xFFFFFFFFFFFF | 1028 # define INVALID_POINTER_VALUE 0xFFFFFFFFFFFFFFFFUL |
| 1029 #elif INTBITS == 64 | |
| 1030 # define INVALID_POINTER_VALUE 0xFFFFFFFFFFFFFFFF | |
| 1031 #else | 1029 #else |
| 1032 You have some weird system and need to supply a reasonable value here. | 1030 You have some weird system and need to supply a reasonable value here. |
| 1033 #endif | 1031 #endif |
| 1034 | 1032 |
| 1033 /* The construct (* (void **) (ptr)) would cause aliasing problems | |
| 1034 with modern optimizing compilers like `gcc -O3 -fstrict-aliasing'. | |
| 1035 But `char *' can legally alias any pointer. Hence this union trick... | |
| 1036 | |
| 1037 It turned out that the union trick was not good enough for xlC -O3; | |
| 1038 and it is questionable whether it really complies with the C standard. | |
| 1039 so we use memset instead, which should be safe from optimizations. */ | |
| 1040 typedef union { char c; void *p; } *aliasing_voidpp; | |
| 1041 #define ALIASING_VOIDPP_DEREFERENCE(ptr) \ | |
| 1042 (((aliasing_voidpp) (ptr))->p) | |
| 1035 #define FREE_STRUCT_P(ptr) \ | 1043 #define FREE_STRUCT_P(ptr) \ |
| 1036 (* (void **) ptr == (void *) INVALID_POINTER_VALUE) | 1044 (ALIASING_VOIDPP_DEREFERENCE (ptr) == (void *) INVALID_POINTER_VALUE) |
| 1037 #define MARK_STRUCT_AS_FREE(ptr) \ | 1045 #define MARK_STRUCT_AS_FREE(ptr) memset (ptr, 0xff, sizeof (void *)) |
| 1038 (* (void **) ptr = (void *) INVALID_POINTER_VALUE) | 1046 #define MARK_STRUCT_AS_NOT_FREE(ptr) memset (ptr, 0x00, sizeof (void *)) |
| 1039 #define MARK_STRUCT_AS_NOT_FREE(ptr) \ | |
| 1040 (* (void **) ptr = 0) | |
| 1041 | 1047 |
| 1042 #ifdef ERROR_CHECK_GC | 1048 #ifdef ERROR_CHECK_GC |
| 1043 | 1049 |
| 1044 #define PUT_FIXED_TYPE_ON_FREE_LIST(type, structtype, ptr) \ | 1050 #define PUT_FIXED_TYPE_ON_FREE_LIST(type, structtype, ptr) \ |
| 1045 do { if (type##_free_list_tail) \ | 1051 do { if (type##_free_list_tail) \ |
