home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 2: Applications / Linux Cubed Series 2 - Applications.iso / editors / emacs / xemacs / xemacs-1.004 / xemacs-1 / xemacs-19.13 / src / lisp-disunion.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-03-25  |  6.0 KB  |  183 lines

  1. /* Fundamental definitions for XEmacs Lisp interpreter -- non-union objects.
  2.    Copyright (C) 1985, 1986, 1987, 1992, 1993 Free Software Foundation, Inc.
  3.  
  4. This file is part of XEmacs.
  5.  
  6. XEmacs is free software; you can redistribute it and/or modify it
  7. under the terms of the GNU General Public License as published by the
  8. Free Software Foundation; either version 2, or (at your option) any
  9. later version.
  10.  
  11. XEmacs is distributed in the hope that it will be useful, but WITHOUT
  12. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13. FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14. for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with XEmacs; see the file COPYING.  If not, write to the Free
  18. Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  19.  
  20. /* Synched up with: FSF 19.28.  Split out from lisp.h. */
  21.  
  22. /* If union type is not wanted, define Lisp_Object as just a number
  23.    and define the macros below to extract fields by shifting */
  24.  
  25. #define Qzero 0
  26.  
  27. /* #define Lisp_Object int */
  28. typedef LISP_WORD_TYPE Lisp_Object;
  29.  
  30. #ifndef VALMASK
  31. # define VALMASK ((1L << (VALBITS)) - 1L)
  32. #endif
  33. #define GCTYPEMASK ((1L << (GCTYPEBITS)) - 1L)
  34.  
  35. /* comment from FSFmacs (perhaps not accurate here):
  36.  
  37.    This is set in the car of a cons and in the plist slot of a symbol
  38.    to indicate it is marked.  Likewise in the plist slot of an interval,
  39.    the chain slot of a marker, the type slot of a float, and the name
  40.    slot of a buffer.
  41.  
  42.    In strings, this bit in the size field indicates that the string
  43.    is a "large" one, one which was separately malloc'd
  44.    rather than being part of a string block.  */
  45.  
  46. #define MARKBIT (1UL << ((VALBITS) + (GCTYPEBITS)))
  47.  
  48.  
  49. /* These macros extract various sorts of values from a Lisp_Object.
  50.  For example, if tem is a Lisp_Object whose type is Lisp_Cons,
  51.  XCONS (tem) is the struct Lisp_Cons * pointing to the memory for that cons. */
  52.  
  53. /* One need to override this if there must be high bits set in data space
  54.    (doing the result of the below & ((1 << (GCTYPE + 1)) - 1) would work
  55.     on all machines, but would penalise machines which don't need it)
  56.  */
  57. #ifndef XTYPE
  58. # define XTYPE(a) ((enum Lisp_Type) ((a) >> VALBITS))
  59. #endif
  60.  
  61. #ifndef XSETTYPE
  62. # define XSETTYPE(a,b) ((a)  =  XUINT (a) | ((LISP_WORD_TYPE)(b) << VALBITS))
  63. #endif
  64.  
  65. #define EQ(x,y) ((x) == (y))
  66.  
  67. #if 0
  68. /* XFASTINT is error-prone and saves a few instructions at best,
  69.    so there's really no point to it.  Just use XINT() or make_number()
  70.    instead. --ben */
  71. /* Use XFASTINT for fast retrieval and storage of integers known
  72.   to be positive.  This takes advantage of the fact that Lisp_Int is 0.  */
  73. #define XFASTINT(a) (a)
  74. #endif /* 0 */
  75.  
  76. /* Extract the value of a Lisp_Object as a signed integer.  */
  77.  
  78. #ifndef XINT   /* Some machines need to do this differently.  */
  79. # define XINT(a) (((a) << (LONGBITS-VALBITS)) >> (LONGBITS-VALBITS))
  80. #endif
  81.  
  82. /* Extract the value as an unsigned integer.  This is a basis
  83.    for extracting it as a pointer to a structure in storage.  */
  84.  
  85. #ifndef XUINT
  86. # define XUINT(a) ((a) & VALMASK)
  87. #endif
  88.  
  89. #ifndef XPNTR
  90. # ifdef HAVE_SHM
  91. /* In this representation, data is found in two widely separated segments.  */
  92. extern int pure_size;
  93. #  define XPNTR(a) \
  94.   (XUINT (a) | (XUINT (a) > pure_size ? DATA_SEG_BITS : PURE_SEG_BITS))
  95. # else /* not HAVE_SHM */
  96. #  ifdef DATA_SEG_BITS
  97. /* This case is used for the rt-pc.
  98.    In the diffs I was given, it checked for ptr = 0
  99.    and did not adjust it in that case.
  100.    But I don't think that zero should ever be found
  101.    in a Lisp object whose data type says it points to something.
  102.  */
  103. #   define XPNTR(a) (XUINT (a) | DATA_SEG_BITS)
  104. #  else
  105. #   define XPNTR(a) XUINT (a)
  106. #  endif
  107. # endif /* not HAVE_SHM */
  108. #endif /* no XPNTR */
  109.  
  110. #ifndef XSETINT
  111. # if 1 /* Back in the dark ages, this def "broke things" */
  112. #  define XSETINT(a,b) do { XSETOBJ ((a), Lisp_Int, (b)); } while (0)
  113. # else /* alternate def to work around some putative bug with the above */
  114. #  define XSETINT(a,b) do { (a) = (((a) & ~VALMASK) | ((b) & VALMASK)); \
  115.               } while (0)
  116. # endif
  117. #endif /* !XSETINT */
  118.  
  119. #ifndef XSETUINT
  120. #define XSETUINT(a, b) XSETINT (a, b)
  121. #endif
  122.  
  123. #ifndef XSETPNTR
  124. #define XSETPNTR(a, b) XSETINT (a, b)
  125. #endif
  126.  
  127. /* XSETOBJ was formerly named XSET.  The name change was made to catch
  128.    C code that attempts to use this macro.  You should always use the
  129.    individual settor macros (XSETCONS, XSETBUFFER, etc.) instead. */
  130.  
  131. #ifndef XSETOBJ
  132. # define XSETOBJ(var,type,ptr)                        \
  133.    do { (var) = (((LISP_WORD_TYPE) (type) << VALBITS)            \
  134.                  + ((LISP_WORD_TYPE) (ptr) & VALMASK));            \
  135.       } while(0)
  136. #endif
  137.  
  138. /* During garbage collection, XGCTYPE must be used for extracting types
  139.  so that the mark bit is ignored.  XMARKBIT accesses the markbit.
  140.  Markbits are used only in particular slots of particular structure types.
  141.  Other markbits are always zero.
  142.  Outside of garbage collection, all mark bits are always zero.  */
  143.  
  144. #ifndef XGCTYPE
  145. # define XGCTYPE(a) ((enum Lisp_Type) (((a) >> VALBITS) & GCTYPEMASK))
  146. #endif
  147.  
  148. #if ((VALBITS) + (GCTYPEBITS)) == ((LONGBITS) - 1L)
  149. /* Make XMARKBIT faster if mark bit is sign bit.  */
  150. # ifndef XMARKBIT
  151. #  define XMARKBIT(a) ((a) < 0L)
  152. # endif
  153. #endif /* markbit is sign bit */
  154.  
  155. #ifndef XMARKBIT
  156. # define XMARKBIT(a) ((a) & (MARKBIT))
  157. #endif
  158.  
  159. #ifndef XSETMARKBIT
  160. #define XSETMARKBIT(a,b) \
  161.   do { ((a) = ((a) & ~(MARKBIT)) | ((b) ? (MARKBIT) : 0)); } while (0)
  162. #endif
  163.  
  164. #ifndef XMARK
  165. # define XMARK(a) do { ((a) |= (MARKBIT)); } while (0)
  166. #endif
  167.  
  168. #ifndef XUNMARK
  169. /* no 'do {} while' because this is used in a mondo macro in lrecord.h */
  170. # define XUNMARK(a) ((a) &= (~(MARKBIT)))
  171. #endif
  172.  
  173. /* Use this for turning a (void *) into a Lisp_Object, as when the
  174.   Lisp_Object is passed into a toolkit callback function */
  175. #define VOID_TO_LISP(larg,varg) \
  176.   do { ((larg) = ((Lisp_Object) (varg))); } while (0)
  177. #define CVOID_TO_LISP VOID_TO_LISP
  178.  
  179. /* Use this for turning a Lisp_Object into a  (void *), as when the
  180.    Lisp_Object is passed into a toolkit callback function */
  181. #define LISP_TO_VOID(larg) ((void *) (larg))
  182. #define LISP_TO_CVOID(varg) ((CONST void *) (larg))
  183.