comparison src/lisp.h @ 53088:63a8b584e971

(VALMASK): Only define for non-union type. (MARKBIT): Remove. (ARRAY_MARK_FLAG): Use previous value of MARKBIT. (XTYPE): Define unconditionally. (XSETTYPE): Remove one more remnant. (EQ): Define differently for the union and non-union cases. (INTMASK): New bit mask. (struct Lisp_Marker): Move down to prepare for upcoming patch. (GC_EQ): Delegate to EQ.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Mon, 17 Nov 2003 23:29:30 +0000
parents 06fd6a34f764
children 094f6b57ed09
comparison
equal deleted inserted replaced
53087:858cdfcb7635 53088:63a8b584e971
248 #ifdef NO_UNION_TYPE 248 #ifdef NO_UNION_TYPE
249 #define Lisp_Object EMACS_INT 249 #define Lisp_Object EMACS_INT
250 #define LISP_MAKE_RVALUE(o) (0+(o)) 250 #define LISP_MAKE_RVALUE(o) (0+(o))
251 #endif /* NO_UNION_TYPE */ 251 #endif /* NO_UNION_TYPE */
252 252
253 #ifndef VALMASK
254 #define VALMASK ((((EMACS_INT) 1)<<VALBITS) - 1)
255 #endif
256
257 /* Two flags that are set during GC. On some machines, these flags 253 /* Two flags that are set during GC. On some machines, these flags
258 are defined differently by the m- file. */ 254 are defined differently by the m- file. */
259 255
260 /* This is set in the car of a cons to indicate it is marked.
261 Likewise in the type slot of a float and in the size slot of strings. */
262
263 #ifndef MARKBIT
264 #define MARKBIT ((EMACS_INT) ((EMACS_UINT) 1 << (VALBITS + GCTYPEBITS - 1)))
265 #endif /*MARKBIT */
266
267 /* In the size word of a vector, this bit means the vector has been marked. */ 256 /* In the size word of a vector, this bit means the vector has been marked. */
268 257
269 #ifndef ARRAY_MARK_FLAG 258 #ifndef ARRAY_MARK_FLAG
270 #define ARRAY_MARK_FLAG ((MARKBIT >> 1) & ~MARKBIT) 259 #define ARRAY_MARK_FLAG ((EMACS_INT) ((EMACS_UINT) 1 << (VALBITS + GCTYPEBITS - 1)))
271 #endif /* no ARRAY_MARK_FLAG */ 260 #endif /* no ARRAY_MARK_FLAG */
272 261
273 /* In the size word of a struct Lisp_Vector, this bit means it's really 262 /* In the size word of a struct Lisp_Vector, this bit means it's really
274 some other vector-like object. */ 263 some other vector-like object. */
275 #ifndef PSEUDOVECTOR_FLAG 264 #ifndef PSEUDOVECTOR_FLAG
308 For example, if tem is a Lisp_Object whose type is Lisp_Cons, 297 For example, if tem is a Lisp_Object whose type is Lisp_Cons,
309 XCONS (tem) is the struct Lisp_Cons * pointing to the memory for that cons. */ 298 XCONS (tem) is the struct Lisp_Cons * pointing to the memory for that cons. */
310 299
311 #ifdef NO_UNION_TYPE 300 #ifdef NO_UNION_TYPE
312 301
302 #define VALMASK ((((EMACS_INT) 1) << VALBITS) - 1)
303
313 /* One need to override this if there must be high bits set in data space 304 /* One need to override this if there must be high bits set in data space
314 (doing the result of the below & ((1 << (GCTYPE + 1)) - 1) would work 305 (doing the result of the below & ((1 << (GCTYPE + 1)) - 1) would work
315 on all machines, but would penalize machines which don't need it) 306 on all machines, but would penalize machines which don't need it)
316 */ 307 */
317 #ifndef XTYPE
318 #define XTYPE(a) ((enum Lisp_Type) (((EMACS_UINT) (a)) >> VALBITS)) 308 #define XTYPE(a) ((enum Lisp_Type) (((EMACS_UINT) (a)) >> VALBITS))
319 #endif
320 309
321 /* For integers known to be positive, XFASTINT provides fast retrieval 310 /* For integers known to be positive, XFASTINT provides fast retrieval
322 and XSETFASTINT provides fast storage. This takes advantage of the 311 and XSETFASTINT provides fast storage. This takes advantage of the
323 fact that Lisp_Int is 0. 312 fact that Lisp_Int is 0. */
324 Beware: XFASTINT applied to a non-positive integer or to something
325 else than an integer should return something that preserves all the
326 info that was in the Lisp_Object, because it is used in EQ. */
327 #define XFASTINT(a) ((a) + 0) 313 #define XFASTINT(a) ((a) + 0)
328 #define XSETFASTINT(a, b) ((a) = (b)) 314 #define XSETFASTINT(a, b) ((a) = (b))
329 315
330 /* Extract the value of a Lisp_Object as a signed integer. */ 316 /* Extract the value of a Lisp_Object as a signed integer. */
331 317
349 /* Convert a C integer into a Lisp_Object integer. */ 335 /* Convert a C integer into a Lisp_Object integer. */
350 336
351 #define make_number(N) \ 337 #define make_number(N) \
352 ((((EMACS_INT) (N)) & VALMASK) | ((EMACS_INT) Lisp_Int) << VALBITS) 338 ((((EMACS_INT) (N)) & VALMASK) | ((EMACS_INT) Lisp_Int) << VALBITS)
353 339
354 #endif /* NO_UNION_TYPE */ 340 #define EQ(x, y) ((x) == (y))
355 341
356 #ifndef NO_UNION_TYPE 342 #else /* not NO_UNION_TYPE */
357 343
358 #define XTYPE(a) ((enum Lisp_Type) (a).u.type) 344 #define XTYPE(a) ((enum Lisp_Type) (a).u.type)
359 #define XSETTYPE(a, b) ((a).u.type = (char) (b))
360 345
361 /* For integers known to be positive, XFASTINT provides fast retrieval 346 /* For integers known to be positive, XFASTINT provides fast retrieval
362 and XSETFASTINT provides fast storage. This takes advantage of the 347 and XSETFASTINT provides fast storage. This takes advantage of the
363 fact that Lisp_Int is 0. */ 348 fact that Lisp_Int is 0. */
364 #define XFASTINT(a) ((a).i + 0) 349 #define XFASTINT(a) ((a).i + 0)
382 (__extension__ ({ Lisp_Object _l; _l.s.val = (N); _l.s.type = Lisp_Int; _l; })) 367 (__extension__ ({ Lisp_Object _l; _l.s.val = (N); _l.s.type = Lisp_Int; _l; }))
383 #else 368 #else
384 extern Lisp_Object make_number (); 369 extern Lisp_Object make_number ();
385 #endif 370 #endif
386 371
372 #define EQ(x, y) ((x).s.val == (y).s.val)
373
387 #endif /* NO_UNION_TYPE */ 374 #endif /* NO_UNION_TYPE */
388 375
389 /* During garbage collection, XGCTYPE must be used for extracting types 376 /* During garbage collection, XGCTYPE must be used for extracting types
390 so that the mark bit is ignored. XMARKBIT accesses the markbit. 377 so that the mark bit is ignored. XMARKBIT accesses the markbit.
391 Markbits are used only in particular slots of particular structure types. 378 Markbits are used only in particular slots of particular structure types.
392 Other markbits are always zero. 379 Other markbits are always zero.
393 Outside of garbage collection, all mark bits are always zero. */ 380 Outside of garbage collection, all mark bits are always zero. */
394 381
395 #ifndef XGCTYPE 382 #ifndef XGCTYPE
396 /* The distinction does not exist now that the MARKBIT has been eliminated. */ 383 /* The distinction does not exist now that the MARKBIT has been eliminated. */
397 #define XGCTYPE(a) XTYPE(a) 384 #define XGCTYPE(a) XTYPE (a)
398 #endif 385 #endif
399 386
400 #ifndef XPNTR 387 #ifndef XPNTR
401 #ifdef HAVE_SHM 388 #ifdef HAVE_SHM
402 /* In this representation, data is found in two widely separated segments. */ 389 /* In this representation, data is found in two widely separated segments. */
420 /* Largest and smallest representable fixnum values. These are the C 407 /* Largest and smallest representable fixnum values. These are the C
421 values. */ 408 values. */
422 409
423 #define MOST_NEGATIVE_FIXNUM - ((EMACS_INT) 1 << (VALBITS - 1)) 410 #define MOST_NEGATIVE_FIXNUM - ((EMACS_INT) 1 << (VALBITS - 1))
424 #define MOST_POSITIVE_FIXNUM (((EMACS_INT) 1 << (VALBITS - 1)) - 1) 411 #define MOST_POSITIVE_FIXNUM (((EMACS_INT) 1 << (VALBITS - 1)) - 1)
412 /* Mask indicating the significant bits of a Lisp_Int.
413 I.e. (x & INTMASK) == XUINT (make_number (x)). */
414 #define INTMASK ((((EMACS_INT) 1) << VALBITS) - 1)
425 415
426 /* Value is non-zero if C integer I doesn't fit into a Lisp fixnum. */ 416 /* Value is non-zero if C integer I doesn't fit into a Lisp fixnum. */
427 417
428 #define FIXNUM_OVERFLOW_P(i) \ 418 #define FIXNUM_OVERFLOW_P(i) \
429 ((EMACS_INT)(i) > MOST_POSITIVE_FIXNUM \ 419 ((EMACS_INT)(i) > MOST_POSITIVE_FIXNUM \
987 #define DEFAULT_REHASH_SIZE 1.5 977 #define DEFAULT_REHASH_SIZE 1.5
988 978
989 979
990 /* These structures are used for various misc types. */ 980 /* These structures are used for various misc types. */
991 981
992 /* A miscellaneous object, when it's on the free list. */
993 struct Lisp_Free
994 {
995 int type : 16; /* = Lisp_Misc_Free */
996 unsigned gcmarkbit : 1;
997 int spacer : 15;
998 union Lisp_Misc *chain;
999 };
1000
1001 struct Lisp_Marker 982 struct Lisp_Marker
1002 { 983 {
1003 int type : 16; /* = Lisp_Misc_Marker */ 984 int type : 16; /* = Lisp_Misc_Marker */
1004 unsigned gcmarkbit : 1; 985 unsigned gcmarkbit : 1;
1005 int spacer : 14; 986 int spacer : 14;
1159 int spacer : 15; 1140 int spacer : 15;
1160 void *pointer; 1141 void *pointer;
1161 int integer; 1142 int integer;
1162 }; 1143 };
1163 1144
1145
1146 /* A miscellaneous object, when it's on the free list. */
1147 struct Lisp_Free
1148 {
1149 int type : 16; /* = Lisp_Misc_Free */
1150 unsigned gcmarkbit : 1;
1151 int spacer : 15;
1152 union Lisp_Misc *chain;
1153 };
1164 1154
1165 /* To get the type field of a union Lisp_Misc, use XMISCTYPE. 1155 /* To get the type field of a union Lisp_Misc, use XMISCTYPE.
1166 It uses one of these struct subtypes to get the type field. */ 1156 It uses one of these struct subtypes to get the type field. */
1167 1157
1168 union Lisp_Misc 1158 union Lisp_Misc
1319 #define GC_NUMBERP(x) (GC_INTEGERP (x) || GC_FLOATP (x)) 1309 #define GC_NUMBERP(x) (GC_INTEGERP (x) || GC_FLOATP (x))
1320 #define NATNUMP(x) (INTEGERP (x) && XINT (x) >= 0) 1310 #define NATNUMP(x) (INTEGERP (x) && XINT (x) >= 0)
1321 #define GC_NATNUMP(x) (GC_INTEGERP (x) && XINT (x) >= 0) 1311 #define GC_NATNUMP(x) (GC_INTEGERP (x) && XINT (x) >= 0)
1322 1312
1323 #define INTEGERP(x) (XTYPE ((x)) == Lisp_Int) 1313 #define INTEGERP(x) (XTYPE ((x)) == Lisp_Int)
1324 #define GC_INTEGERP(x) (XGCTYPE ((x)) == Lisp_Int) 1314 #define GC_INTEGERP(x) INTEGERP (x)
1325 #define SYMBOLP(x) (XTYPE ((x)) == Lisp_Symbol) 1315 #define SYMBOLP(x) (XTYPE ((x)) == Lisp_Symbol)
1326 #define GC_SYMBOLP(x) (XGCTYPE ((x)) == Lisp_Symbol) 1316 #define GC_SYMBOLP(x) (XGCTYPE ((x)) == Lisp_Symbol)
1327 #define MISCP(x) (XTYPE ((x)) == Lisp_Misc) 1317 #define MISCP(x) (XTYPE ((x)) == Lisp_Misc)
1328 #define GC_MISCP(x) (XGCTYPE ((x)) == Lisp_Misc) 1318 #define GC_MISCP(x) (XGCTYPE ((x)) == Lisp_Misc)
1329 #define VECTORLIKEP(x) (XTYPE ((x)) == Lisp_Vectorlike) 1319 #define VECTORLIKEP(x) (XTYPE ((x)) == Lisp_Vectorlike)
1390 #define FRAMEP(x) PSEUDOVECTORP (x, PVEC_FRAME) 1380 #define FRAMEP(x) PSEUDOVECTORP (x, PVEC_FRAME)
1391 #define GC_FRAMEP(x) GC_PSEUDOVECTORP (x, PVEC_FRAME) 1381 #define GC_FRAMEP(x) GC_PSEUDOVECTORP (x, PVEC_FRAME)
1392 1382
1393 #define SUB_CHAR_TABLE_P(x) (CHAR_TABLE_P (x) && NILP (XCHAR_TABLE (x)->top)) 1383 #define SUB_CHAR_TABLE_P(x) (CHAR_TABLE_P (x) && NILP (XCHAR_TABLE (x)->top))
1394 1384
1395 #define EQ(x, y) (XFASTINT (x) == XFASTINT (y)) 1385 #define GC_EQ(x, y) EQ (x, y)
1396 #define GC_EQ(x, y) (XGCTYPE (x) == XGCTYPE (y) && XPNTR (x) == XPNTR (y))
1397 1386
1398 #define CHECK_LIST(x) \ 1387 #define CHECK_LIST(x) \
1399 do { if (!CONSP ((x)) && !NILP (x)) x = wrong_type_argument (Qlistp, (x)); } while (0) 1388 do { if (!CONSP ((x)) && !NILP (x)) x = wrong_type_argument (Qlistp, (x)); } while (0)
1400 1389
1401 #define CHECK_STRING(x) \ 1390 #define CHECK_STRING(x) \