Mercurial > hg > xemacs-beta
comparison src/lisp.h @ 5934:e2fae7783046 cygwin
lots of use of EMACS_INT, a few others, to eliminate all pointer truncation warnings
author | Henry Thompson <ht@markup.co.uk> |
---|---|
date | Sat, 12 Dec 2015 19:08:46 +0000 |
parents | f5dfcf2323bc |
children | d5eb0914ca1f |
comparison
equal
deleted
inserted
replaced
5933:c1e8f3294298 | 5934:e2fae7783046 |
---|---|
465 | 465 |
466 #ifndef SIZEOF_EMACS_INT | 466 #ifndef SIZEOF_EMACS_INT |
467 # define SIZEOF_EMACS_INT SIZEOF_VOID_P | 467 # define SIZEOF_EMACS_INT SIZEOF_VOID_P |
468 #endif | 468 #endif |
469 | 469 |
470 /* HST moved MOST_POSITIVE_FIXNUM_UNSIGNED here */ | |
470 #ifndef EMACS_INT | 471 #ifndef EMACS_INT |
471 # if SIZEOF_EMACS_INT == SIZEOF_LONG | 472 # if SIZEOF_EMACS_INT == SIZEOF_LONG |
472 # define EMACS_INT long | 473 # define EMACS_INT long |
474 #define MOST_POSITIVE_FIXNUM_UNSIGNED ((1UL << (FIXNUM_VALBITS - 1)) -1UL) | |
473 # elif SIZEOF_EMACS_INT == SIZEOF_INT | 475 # elif SIZEOF_EMACS_INT == SIZEOF_INT |
474 # define EMACS_INT int | 476 # define EMACS_INT int |
477 #define MOST_POSITIVE_FIXNUM_UNSIGNED ((1U << (FIXNUM_VALBITS - 1)) -1U) | |
475 # elif SIZEOF_EMACS_INT == SIZEOF_LONG_LONG | 478 # elif SIZEOF_EMACS_INT == SIZEOF_LONG_LONG |
476 # define EMACS_INT long long | 479 # define EMACS_INT long long |
480 #define MOST_POSITIVE_FIXNUM_UNSIGNED ((1ULL << (FIXNUM_VALBITS - 1)) -1ULL) | |
477 # else | 481 # else |
478 # error Unable to determine suitable type for EMACS_INT | 482 # error Unable to determine suitable type for EMACS_INT |
479 # endif | 483 # endif |
480 #endif | 484 #endif |
481 | 485 |
1147 #endif /* __cplusplus */ | 1151 #endif /* __cplusplus */ |
1148 | 1152 |
1149 /* Counts of elements */ | 1153 /* Counts of elements */ |
1150 typedef EMACS_INT Elemcount; | 1154 typedef EMACS_INT Elemcount; |
1151 /* Hash codes */ | 1155 /* Hash codes */ |
1152 typedef unsigned long Hashcode; | 1156 typedef uintptr_t Hashcode; /* HST: protect wrt _WIN64 short longs */ |
1153 /* Booleans */ | 1157 /* Booleans */ |
1154 typedef int Boolint; | 1158 typedef int Boolint; |
1155 | 1159 |
1156 /* ------------------------ basic compiler defines ------------------- */ | 1160 /* ------------------------ basic compiler defines ------------------- */ |
1157 | 1161 |
1383 #define ALLOCA_FUNCALL_OK(size) xemacs_c_alloca (size) | 1387 #define ALLOCA_FUNCALL_OK(size) xemacs_c_alloca (size) |
1384 #else | 1388 #else |
1385 #define ALLOCA_FUNCALL_OK(size) ALLOCA (size) | 1389 #define ALLOCA_FUNCALL_OK(size) ALLOCA (size) |
1386 #endif | 1390 #endif |
1387 | 1391 |
1388 MODULE_API void *xemacs_c_alloca (unsigned int size) ATTRIBUTE_MALLOC; | 1392 MODULE_API void *xemacs_c_alloca (EMACS_UINT size) ATTRIBUTE_MALLOC; |
1389 | 1393 |
1390 MODULE_API int record_unwind_protect_freeing (void *ptr); | 1394 MODULE_API int record_unwind_protect_freeing (void *ptr); |
1391 | 1395 |
1392 DECLARE_INLINE_HEADER ( | 1396 DECLARE_INLINE_HEADER ( |
1393 void * | 1397 void * |
1680 #define GCBITS 2 | 1684 #define GCBITS 2 |
1681 #define FIXNUM_GCBITS 1 | 1685 #define FIXNUM_GCBITS 1 |
1682 | 1686 |
1683 #define FIXNUM_VALBITS (BITS_PER_EMACS_INT - FIXNUM_GCBITS) | 1687 #define FIXNUM_VALBITS (BITS_PER_EMACS_INT - FIXNUM_GCBITS) |
1684 #define VALBITS (BITS_PER_EMACS_INT - GCBITS) | 1688 #define VALBITS (BITS_PER_EMACS_INT - GCBITS) |
1685 #define MOST_POSITIVE_FIXNUM_UNSIGNED ((1UL << (FIXNUM_VALBITS - 1)) -1UL) | |
1686 #define MOST_POSITIVE_FIXNUM ((EMACS_INT) MOST_POSITIVE_FIXNUM_UNSIGNED) | 1689 #define MOST_POSITIVE_FIXNUM ((EMACS_INT) MOST_POSITIVE_FIXNUM_UNSIGNED) |
1687 #define MOST_NEGATIVE_FIXNUM (-(MOST_POSITIVE_FIXNUM) - 1) | 1690 #define MOST_NEGATIVE_FIXNUM (-(MOST_POSITIVE_FIXNUM) - 1) |
1688 /* WARNING: evaluates its arg twice. */ | 1691 /* WARNING: evaluates its arg twice. */ |
1689 #define NUMBER_FITS_IN_A_FIXNUM(num) \ | 1692 #define NUMBER_FITS_IN_A_FIXNUM(num) \ |
1690 ((num) <= MOST_POSITIVE_FIXNUM && (num) >= MOST_NEGATIVE_FIXNUM) | 1693 ((num) <= MOST_POSITIVE_FIXNUM && (num) >= MOST_NEGATIVE_FIXNUM) |
1745 STORE_VOID_IN_LISP (void *ptr) | 1748 STORE_VOID_IN_LISP (void *ptr) |
1746 ) | 1749 ) |
1747 { | 1750 { |
1748 EMACS_UINT p = (EMACS_UINT) ptr; | 1751 EMACS_UINT p = (EMACS_UINT) ptr; |
1749 | 1752 |
1750 type_checking_assert ((p & 1) == 0); | 1753 type_checking_assert ((p & (EMACS_UINT)1) == 0); |
1751 return make_fixnum (p >> 1); | 1754 return make_fixnum (p >> 1); |
1752 } | 1755 } |
1753 | 1756 |
1754 DECLARE_INLINE_HEADER ( | 1757 DECLARE_INLINE_HEADER ( |
1755 void * | 1758 void * |
3104 | 3107 |
3105 /* True of X is a character or an integral value that can be converted into a | 3108 /* True of X is a character or an integral value that can be converted into a |
3106 character. */ | 3109 character. */ |
3107 #define CHAR_OR_CHAR_INTP(x) (CHARP (x) || CHAR_INTP (x)) | 3110 #define CHAR_OR_CHAR_INTP(x) (CHARP (x) || CHAR_INTP (x)) |
3108 | 3111 |
3112 /* HST editted in the (int) to stop many warnings */ | |
3109 DECLARE_INLINE_HEADER ( | 3113 DECLARE_INLINE_HEADER ( |
3110 Ichar | 3114 Ichar |
3111 XCHAR_OR_CHAR_INT (Lisp_Object obj) | 3115 XCHAR_OR_CHAR_INT (Lisp_Object obj) |
3112 ) | 3116 ) |
3113 { | 3117 { |
3114 return CHARP (obj) ? XCHAR (obj) : XFIXNUM (obj); | 3118 return CHARP (obj) ? XCHAR (obj) : (int)XFIXNUM (obj); |
3115 } | 3119 } |
3116 | 3120 |
3117 /* Signal an error if CH is not a valid character or integer Lisp_Object. | 3121 /* Signal an error if CH is not a valid character or integer Lisp_Object. |
3118 If CH is an integer Lisp_Object, convert it to a character Lisp_Object, | 3122 If CH is an integer Lisp_Object, convert it to a character Lisp_Object, |
3119 but merely by repackaging, without performing tests for char validity. | 3123 but merely by repackaging, without performing tests for char validity. |
3841 #define HASH6(a,b,c,d,e,f) (GOOD_HASH * HASH5 (a,b,c,d,e) + (f)) | 3845 #define HASH6(a,b,c,d,e,f) (GOOD_HASH * HASH5 (a,b,c,d,e) + (f)) |
3842 #define HASH7(a,b,c,d,e,f,g) (GOOD_HASH * HASH6 (a,b,c,d,e,f) + (g)) | 3846 #define HASH7(a,b,c,d,e,f,g) (GOOD_HASH * HASH6 (a,b,c,d,e,f) + (g)) |
3843 #define HASH8(a,b,c,d,e,f,g,h) (GOOD_HASH * HASH7 (a,b,c,d,e,f,g) + (h)) | 3847 #define HASH8(a,b,c,d,e,f,g,h) (GOOD_HASH * HASH7 (a,b,c,d,e,f,g) + (h)) |
3844 #define HASH9(a,b,c,d,e,f,g,h,i) (GOOD_HASH * HASH8 (a,b,c,d,e,f,g,h) + (i)) | 3848 #define HASH9(a,b,c,d,e,f,g,h,i) (GOOD_HASH * HASH8 (a,b,c,d,e,f,g,h) + (i)) |
3845 | 3849 |
3846 #define LISP_HASH(obj) ((unsigned long) STORE_LISP_IN_VOID (obj)) | 3850 #define LISP_HASH(obj) ((Hashcode) STORE_LISP_IN_VOID (obj)) |
3847 Hashcode memory_hash (const void *xv, Bytecount size); | 3851 Hashcode memory_hash (const void *xv, Bytecount size); |
3848 Hashcode internal_hash (Lisp_Object obj, int depth, Boolint equalp); | 3852 Hashcode internal_hash (Lisp_Object obj, int depth, Boolint equalp); |
3849 Hashcode internal_array_hash (Lisp_Object *arr, int size, int depth, | 3853 Hashcode internal_array_hash (Lisp_Object *arr, int size, int depth, |
3850 Boolint equalp); | 3854 Boolint equalp); |
3851 | 3855 |