diff options
Diffstat (limited to 'src/lisp.h')
| -rw-r--r-- | src/lisp.h | 45 |
1 files changed, 28 insertions, 17 deletions
diff --git a/src/lisp.h b/src/lisp.h index 823e0ec5205..fd9ac6ef0e2 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -41,25 +41,36 @@ extern void check_cons_list (void); | |||
| 41 | Build with CFLAGS='-DWIDE_EMACS_INT' to try them out. */ | 41 | Build with CFLAGS='-DWIDE_EMACS_INT' to try them out. */ |
| 42 | /* #undef WIDE_EMACS_INT */ | 42 | /* #undef WIDE_EMACS_INT */ |
| 43 | 43 | ||
| 44 | /* These are default choices for the types to use. */ | 44 | /* EMACS_INT - signed integer wide enough to hold an Emacs value |
| 45 | EMACS_INT_MAX - maximum value of EMACS_INT; can be used in #if | ||
| 46 | pI - printf length modifier for EMACS_INT | ||
| 47 | EMACS_UINT - unsigned variant of EMACS_INT */ | ||
| 45 | #ifndef EMACS_INT | 48 | #ifndef EMACS_INT |
| 46 | # if BITS_PER_LONG < BITS_PER_LONG_LONG && defined WIDE_EMACS_INT | 49 | # if LONG_MAX < LLONG_MAX && defined WIDE_EMACS_INT |
| 47 | # define EMACS_INT long long | 50 | # define EMACS_INT long long |
| 48 | # define BITS_PER_EMACS_INT BITS_PER_LONG_LONG | 51 | # define EMACS_INT_MAX LLONG_MAX |
| 49 | # define pI "ll" | 52 | # define pI "ll" |
| 50 | # elif BITS_PER_INT < BITS_PER_LONG | 53 | # elif INT_MAX < LONG_MAX |
| 51 | # define EMACS_INT long | 54 | # define EMACS_INT long |
| 52 | # define BITS_PER_EMACS_INT BITS_PER_LONG | 55 | # define EMACS_INT_MAX LONG_MAX |
| 53 | # define pI "l" | 56 | # define pI "l" |
| 54 | # else | 57 | # else |
| 55 | # define EMACS_INT int | 58 | # define EMACS_INT int |
| 56 | # define BITS_PER_EMACS_INT BITS_PER_INT | 59 | # define EMACS_INT_MAX INT_MAX |
| 57 | # define pI "" | 60 | # define pI "" |
| 58 | # endif | 61 | # endif |
| 59 | #endif | 62 | #endif |
| 60 | #ifndef EMACS_UINT | 63 | #define EMACS_UINT unsigned EMACS_INT |
| 61 | # define EMACS_UINT unsigned EMACS_INT | 64 | |
| 62 | #endif | 65 | /* Number of bits in some machine integer types. */ |
| 66 | enum | ||
| 67 | { | ||
| 68 | BITS_PER_CHAR = CHAR_BIT, | ||
| 69 | BITS_PER_SHORT = CHAR_BIT * sizeof (short), | ||
| 70 | BITS_PER_INT = CHAR_BIT * sizeof (int), | ||
| 71 | BITS_PER_LONG = CHAR_BIT * sizeof (long int), | ||
| 72 | BITS_PER_EMACS_INT = CHAR_BIT * sizeof (EMACS_INT) | ||
| 73 | }; | ||
| 63 | 74 | ||
| 64 | /* printmax_t and uprintmax_t are types for printing large integers. | 75 | /* printmax_t and uprintmax_t are types for printing large integers. |
| 65 | These are the widest integers that are supported for printing. | 76 | These are the widest integers that are supported for printing. |
| @@ -164,13 +175,13 @@ extern int suppress_checking EXTERNALLY_VISIBLE; | |||
| 164 | variable VAR of type TYPE with the added requirement that it be | 175 | variable VAR of type TYPE with the added requirement that it be |
| 165 | TYPEBITS-aligned. */ | 176 | TYPEBITS-aligned. */ |
| 166 | 177 | ||
| 167 | #ifndef GCTYPEBITS | ||
| 168 | #define GCTYPEBITS 3 | 178 | #define GCTYPEBITS 3 |
| 169 | #endif | ||
| 170 | |||
| 171 | #ifndef VALBITS | ||
| 172 | #define VALBITS (BITS_PER_EMACS_INT - GCTYPEBITS) | 179 | #define VALBITS (BITS_PER_EMACS_INT - GCTYPEBITS) |
| 173 | #endif | 180 | |
| 181 | /* The maximum value that can be stored in a EMACS_INT, assuming all | ||
| 182 | bits other than the type bits contribute to a nonnegative signed value. | ||
| 183 | This can be used in #if, e.g., '#if VAL_MAX < UINTPTR_MAX' below. */ | ||
| 184 | #define VAL_MAX (EMACS_INT_MAX >> (GCTYPEBITS - 1)) | ||
| 174 | 185 | ||
| 175 | #ifndef NO_DECL_ALIGN | 186 | #ifndef NO_DECL_ALIGN |
| 176 | # ifndef DECL_ALIGN | 187 | # ifndef DECL_ALIGN |
| @@ -195,12 +206,12 @@ extern int suppress_checking EXTERNALLY_VISIBLE; | |||
| 195 | || defined DARWIN_OS || defined __sun) | 206 | || defined DARWIN_OS || defined __sun) |
| 196 | /* We also need to be able to specify mult-of-8 alignment on static vars. */ | 207 | /* We also need to be able to specify mult-of-8 alignment on static vars. */ |
| 197 | # if defined DECL_ALIGN | 208 | # if defined DECL_ALIGN |
| 198 | /* On hosts where VALBITS is greater than the pointer width in bits, | 209 | /* On hosts where pointers-as-ints do not exceed VAL_MAX, |
| 199 | USE_LSB_TAG is: | 210 | USE_LSB_TAG is: |
| 200 | a. unnecessary, because the top bits of an EMACS_INT are unused, and | 211 | a. unnecessary, because the top bits of an EMACS_INT are unused, and |
| 201 | b. slower, because it typically requires extra masking. | 212 | b. slower, because it typically requires extra masking. |
| 202 | So, define USE_LSB_TAG only on hosts where it might be useful. */ | 213 | So, define USE_LSB_TAG only on hosts where it might be useful. */ |
| 203 | # if UINTPTR_MAX >> VALBITS != 0 | 214 | # if VAL_MAX < UINTPTR_MAX |
| 204 | # define USE_LSB_TAG | 215 | # define USE_LSB_TAG |
| 205 | # endif | 216 | # endif |
| 206 | # endif | 217 | # endif |
| @@ -483,7 +494,7 @@ enum pvec_type | |||
| 483 | 494 | ||
| 484 | #else /* not USE_LSB_TAG */ | 495 | #else /* not USE_LSB_TAG */ |
| 485 | 496 | ||
| 486 | #define VALMASK ((((EMACS_INT) 1) << VALBITS) - 1) | 497 | #define VALMASK VAL_MAX |
| 487 | 498 | ||
| 488 | /* One need to override this if there must be high bits set in data space | 499 | /* One need to override this if there must be high bits set in data space |
| 489 | (doing the result of the below & ((1 << (GCTYPE + 1)) - 1) would work | 500 | (doing the result of the below & ((1 << (GCTYPE + 1)) - 1) would work |