home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / mitsch75.zip / scheme-7_5_17-src.zip / scheme-7.5.17 / src / microcode / confshared.h < prev    next >
C/C++ Source or Header  |  2000-12-05  |  15KB  |  541 lines

  1. /* -*-C-*-
  2.  
  3. $Id: confshared.h,v 11.1 2000/12/05 21:23:43 cph Exp $
  4.  
  5. Copyright (c) 2000 Massachusetts Institute of Technology
  6.  
  7. This program is free software; you can redistribute it and/or modify
  8. it under the terms of the GNU General Public License as published by
  9. the Free Software Foundation; either version 2 of the License, or (at
  10. your option) any later version.
  11.  
  12. This program is distributed in the hope that it will be useful, but
  13. WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  15. General Public License for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with this program; if not, write to the Free Software
  19. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  20. */
  21.  
  22. /* Shared part of "config.h".  */
  23.  
  24. #ifndef SCM_CONFSHARED_H
  25. #define SCM_CONFSHARED_H
  26.  
  27. #include "ansidecl.h"
  28.  
  29. /* To enable the STEPPER.  Incompatible with futures. */
  30. #define COMPILE_STEPPER 
  31.  
  32. /* Some configuration consistency testing */
  33.  
  34. #ifdef COMPILE_STEPPER
  35. #  ifdef COMPILE_FUTURES
  36. #    include "Error: The stepper doesn't work with futures."
  37. #  endif
  38. #  ifdef USE_STACKLETS
  39. #    include "Error: The stepper doesn't work with stacklets."
  40. #  endif
  41. #endif
  42.  
  43. /* For use in the C pre-processor, not in code! */
  44. #define FALSE        0
  45. #define TRUE        1
  46.  
  47. /* These C type definitions are needed by everybody.
  48.    They should not be here, but it is unavoidable. */
  49. typedef char Boolean;
  50. #define true        ((Boolean) TRUE)
  51. #define false        ((Boolean) FALSE)
  52.  
  53. /* This is the Scheme object type.
  54.    The various fields are defined in "object.h". */
  55. typedef unsigned long SCHEME_OBJECT;
  56. #define OBJECT_LENGTH (CHAR_BIT * SIZEOF_UNSIGNED_LONG)
  57.  
  58. /* Operating System / Machine dependencies:
  59.  
  60.    For each implementation, be sure to specify FASL_INTERNAL_FORMAT.
  61.    Make sure that there is an appropriate FASL_<machine name>.
  62.    If there isn't, add one to the list below.
  63.  
  64.    If you do not know the values of the parameters specified below,
  65.    try compiling and running the Wsize program ("make Wsize" if on a
  66.    unix variant).  It may not run, but if it does, it will probably
  67.    compute the correct information.
  68.  
  69.    Note that the C type void is used in the sources.  If your version
  70.    of C does not have this type, you should bypass it.  This can be
  71.    done by inserting the preprocessor command '#define void' in this
  72.    file, under the heading for your kind of machine.
  73.  
  74.    These parameters MUST be specified (and are computed by Wsize):
  75.  
  76.    CHAR_BIT is the size of a character in bits.
  77.  
  78.    FLOATING_ALIGNMENT should be defined ONLY if the system requires
  79.    floating point numbers (double) to be aligned more strictly than
  80.    SCHEME_OBJECTs (unsigned long).  The value must be a mask of the
  81.    low order bits which are required to be zero for the storage
  82.    address.  For example, a value of 0x7 requires octabyte alignment
  83.    on a machine where addresses are specified in bytes.  The alignment
  84.    must be an integral multiple of the length of a long.
  85.  
  86.    Other flags (the safe option is NOT to define them, which will
  87.    sacrifice speed for safety):
  88.  
  89.    HEAP_IN_LOW_MEMORY should be defined if malloc returns the lowest
  90.    available memory and thus all addresses will fit in the datum portion
  91.    of a Scheme object.  The datum portion of a Scheme object is 8 bits
  92.    less than the length of a C long.  */
  93.  
  94. /* Possible values for FASL_INTERNAL_FORMAT.  For the most part this
  95.    means the processor type, so for example there are several aliases
  96.    for 68000 family processors.  This scheme allows sharing of
  97.    compiled code on machines with the same processor type.  Probably
  98.    we will have to create a more powerful method of identifying FASL
  99.    files when we introduce new differences, such as whether or not a
  100.    68881 coprocessor is installed. */
  101.  
  102. #define FASL_UNKNOWN        0
  103. #define FASL_PDP10        1
  104. #define FASL_VAX        2
  105. #define FASL_68020        3
  106. #define FASL_68000          4
  107. #define FASL_HP_9000_500    5
  108. #define FASL_IA32        6
  109. #define FASL_BFLY        7
  110. #define FASL_CYBER        8
  111. #define FASL_CELERITY        9
  112. #define FASL_HP_SPECTRUM    10
  113. #define FASL_UMAX        11
  114. #define FASL_PYR        12
  115. #define FASL_ALLIANT        13
  116. #define FASL_SPARC        14
  117. #define FASL_MIPS        15
  118. #define FASL_APOLLO_68K        16
  119. #define FASL_APOLLO_PRISM    17
  120. #define FASL_ALPHA        18
  121. #define FASL_RS6000        19
  122.  
  123. #ifdef vax
  124.  
  125. /* Amazingly unix and vms agree on all these */
  126.  
  127. #define MACHINE_TYPE        "vax"
  128. #define FASL_INTERNAL_FORMAT    FASL_VAX
  129. #define TYPE_CODE_LENGTH    6
  130. #define HEAP_IN_LOW_MEMORY
  131.  
  132. /* Not on these, however */
  133.  
  134. #ifdef vms
  135.  
  136. #define VMS_VERSION        4
  137. #define VMS_SUBVERSION        5
  138.  
  139. /* If your C runtime library already defines the `tbuffer' datatype,
  140.    then define this symbol. */
  141. /* #define HAVE_TBUFFER */
  142.  
  143. /* Name conflict in VMS with system variable */
  144. #define Free            Free_Register
  145.  
  146. #if (VMS_VERSION < 4)
  147.    /* Pre version 4 VMS has no void type. */
  148. #  define void
  149. #endif
  150.  
  151. /* This eliminates a spurious warning from the C compiler. */
  152. #define main_type
  153.  
  154. /* exit(0) produces horrible message on VMS */
  155. #define NORMAL_EXIT 1
  156.  
  157. #define EXIT_SCHEME_DECLARATIONS static jmp_buf exit_scheme_jmp_buf
  158.  
  159. #define INIT_EXIT_SCHEME()                        \
  160. {                                    \
  161.   int which_way = (setjmp (exit_scheme_jmp_buf));            \
  162.   if (which_way == NORMAL_EXIT)                        \
  163.     return;                                \
  164. }
  165.  
  166. #define EXIT_SCHEME(value)                        \
  167. {                                    \
  168.   if (value != 0)                            \
  169.     exit (value);                            \
  170.   longjmp (exit_scheme_jmp_buf, NORMAL_EXIT);                \
  171. }
  172.  
  173. #else /* not vms */
  174.  
  175. /* Vax Unix C compiler bug */
  176. #define HAVE_DOUBLE_TO_LONG_BUG
  177.  
  178. #endif /* not vms */
  179. #endif /* vax */
  180.  
  181. #if defined(hp9000s800) || defined(__hp9000s800)
  182. #if defined(hp9000s700) || defined(__hp9000s700)
  183. #define MACHINE_TYPE        "hp9000s700"
  184. #else
  185. #define MACHINE_TYPE        "hp9000s800"
  186. #endif
  187. #define FASL_INTERNAL_FORMAT    FASL_HP_SPECTRUM
  188. #define TYPE_CODE_LENGTH    6
  189. #define FLOATING_ALIGNMENT    0x7
  190.  
  191. /* Heap resides in data space, pointed at by space register 5.
  192.    Short pointers must have their high two bits set to 01 so that
  193.    it is interpreted as space register 5, 2nd quadrant.
  194.  
  195.    This is kludged by the definitions below, and is still considered
  196.    HEAP_IN_LOW_MEMORY.  */
  197.  
  198. #define HEAP_IN_LOW_MEMORY
  199.  
  200. /* data segment bits and mask for all bits */
  201.  
  202. #define HPPA_QUAD_BIT    0x40000000
  203. #define HPPA_QUAD_MASK    0xC0000000
  204.  
  205. #define DATUM_TO_ADDRESS(datum)                        \
  206.   ((SCHEME_OBJECT *) (((unsigned long) (datum)) | HPPA_QUAD_BIT))
  207.  
  208. #define ADDRESS_TO_DATUM(address)                    \
  209.   ((SCHEME_OBJECT) (((unsigned long) (address)) & (~(HPPA_QUAD_MASK))))
  210.  
  211. #if (SCHEME_VERSION > 11)
  212.  
  213. /* SHARP_F is a magic value:
  214.    Typecode TC_CONSTANT, high datum bits #b100, low datum bits are the top
  215.    TYPE_CODE_LENGTH bits of HPPA_QUAD_BIT
  216.  
  217.    SHARP_F is stored in gr5 for access by compiled code.  This allows
  218.    us to generate #F and test against #F quickly, and also to use gr5
  219.    for compiled OBJECT->ADDRESS operations.  If we ever go to 5bit
  220.    typecodes we will be able to dispense with this overloading.
  221.  
  222.    See also cmpauxmd/hppa.m4.  */
  223.  
  224. #define SHARP_F         0x22000010
  225. #endif /* (SCHEME_VERSION > 11) */
  226.  
  227. #endif /* hp9000s800 */
  228.  
  229. #if defined(hp9000s300) || defined(__hp9000s300)
  230. #if defined(hp9000s400) || defined(__hp9000s400)
  231. #define MACHINE_TYPE        "hp9000s400"
  232. #else
  233. #define MACHINE_TYPE        "hp9000s300"
  234. #endif
  235. #ifdef MC68010
  236. #define FASL_INTERNAL_FORMAT    FASL_68000
  237. #else
  238. #define FASL_INTERNAL_FORMAT    FASL_68020
  239. #endif
  240. #define HEAP_IN_LOW_MEMORY
  241. #define TYPE_CODE_LENGTH    6
  242.  
  243. #endif /* hp9000s300 */
  244.  
  245. #ifdef hp9000s500
  246. #define MACHINE_TYPE        "hp9000s500"
  247. #define FASL_INTERNAL_FORMAT     FASL_HP_9000_500
  248.  
  249. /* An unfortunate fact of life on this machine:
  250.    the C heap is in high memory thus HEAP_IN_LOW_MEMORY is not
  251.    defined and the whole thing runs slowly.  */
  252.  
  253. /* C Compiler bug when constant folding and anchor pointing */
  254. #define And2(x, y)    ((x) ? (y) : false)
  255. #define And3(x, y, z)    ((x) ? ((y) ? (z) : false) : false)
  256. #define Or2(x, y)    ((x) ? true : (y))
  257. #define Or3(x, y, z)    ((x) ? true : ((y) ? true : (z)))
  258.  
  259. #endif /* hp9000s500 */
  260.  
  261. #ifdef sparc
  262. #  define MACHINE_TYPE        "sun4"
  263. #  define FASL_INTERNAL_FORMAT    FASL_SPARC
  264. #  define FLOATING_ALIGNMENT    0x7
  265. #  define HEAP_IN_LOW_MEMORY
  266. #  define HAVE_DOUBLE_TO_LONG_BUG
  267. #endif
  268.  
  269. #ifdef sun3
  270. #  define MACHINE_TYPE        "sun3"
  271. #  define FASL_INTERNAL_FORMAT    FASL_68020
  272. #  define TYPE_CODE_LENGTH    6
  273. #  define HEAP_IN_LOW_MEMORY
  274. #  define HAVE_DOUBLE_TO_LONG_BUG
  275. #endif
  276.  
  277. #ifdef sun2
  278. #  define MACHINE_TYPE        "sun2"
  279. #  define FASL_INTERNAL_FORMAT    FASL_68000
  280. #  define HEAP_IN_LOW_MEMORY
  281. #  define HAVE_DOUBLE_TO_LONG_BUG
  282. #endif
  283.  
  284. #ifdef NeXT
  285. #  define MACHINE_TYPE        "next"
  286. #  define FASL_INTERNAL_FORMAT    FASL_68020
  287. #  define TYPE_CODE_LENGTH    6
  288. #  define HEAP_IN_LOW_MEMORY
  289. #endif
  290.  
  291. #if defined(_M_IX86) || defined(__i386__) || defined(__i386) || defined(i386)
  292. #  define __IA32__
  293. #endif
  294.  
  295. #ifdef __IA32__
  296.  
  297. #define FASL_INTERNAL_FORMAT    FASL_IA32
  298. #define HEAP_IN_LOW_MEMORY
  299. #define TYPE_CODE_LENGTH    6
  300.  
  301. #ifdef sequent
  302. #  define MACHINE_TYPE        "sequent386"
  303. #endif
  304.  
  305. #ifdef sun
  306. #  define MACHINE_TYPE        "sun386i"
  307. #endif
  308.  
  309. #ifndef MACHINE_TYPE
  310. #  define MACHINE_TYPE        "IA-32"
  311. #endif
  312.  
  313. #ifdef __linux__
  314.    extern void * linux_heap_malloc (unsigned long);
  315. #  define HEAP_MALLOC linux_heap_malloc
  316. #  define HEAP_FREE(address)
  317. #endif
  318.  
  319. #ifdef __FreeBSD__
  320.    extern void * freebsd_heap_malloc (unsigned long);
  321. #  define HEAP_MALLOC freebsd_heap_malloc
  322. #  define HEAP_FREE(address)
  323. #endif
  324.  
  325. #endif /* __IA32__ */
  326.  
  327. #ifdef mips
  328.  
  329. #define MACHINE_TYPE        "mips"
  330. #define FASL_INTERNAL_FORMAT    FASL_MIPS
  331. #define TYPE_CODE_LENGTH    6
  332. #define FLOATING_ALIGNMENT       0x7
  333.  
  334. #if defined(_IRIX6) && defined(HAS_COMPILER_SUPPORT) && !defined(NATIVE_CODE_IS_C)
  335.    extern void * irix_heap_malloc (long);
  336. #  define HEAP_MALLOC irix_heap_malloc
  337. #endif
  338.  
  339. /* Heap resides in data space which begins at 0x10000000. This is
  340.    kludged by the definitions below, and is still considered
  341.    HEAP_IN_LOW_MEMORY.  */
  342.  
  343. #define HEAP_IN_LOW_MEMORY
  344. #define MIPS_DATA_BIT    0x10000000
  345.  
  346. #define DATUM_TO_ADDRESS(datum)                        \
  347.   ((SCHEME_OBJECT *) (((unsigned long) (datum)) | MIPS_DATA_BIT))
  348.  
  349. #define ADDRESS_TO_DATUM(address)                    \
  350.   ((SCHEME_OBJECT) (((unsigned long) (address)) & (~(MIPS_DATA_BIT))))
  351.  
  352. /* MIPS compiled binaries are large! */
  353. #ifdef HAS_COMPILER_SUPPORT
  354.  
  355. #ifndef DEFAULT_SMALL_CONSTANT
  356. #define DEFAULT_SMALL_CONSTANT 700
  357. #endif
  358.  
  359. #ifndef DEFAULT_LARGE_CONSTANT
  360. #define DEFAULT_LARGE_CONSTANT 1500
  361. #endif
  362.  
  363. #endif /* HAS_COMPILER_SUPPORT */
  364.  
  365. #endif /* mips */
  366.  
  367. #ifdef __alpha
  368. #define MACHINE_TYPE           "Alpha"
  369. #define FASL_INTERNAL_FORMAT   FASL_ALPHA
  370. #define TYPE_CODE_LENGTH       8
  371.  
  372. /* The ASCII character set is used. */
  373. #define HEAP_IN_LOW_MEMORY     1
  374.  
  375. /* Flonums have no special alignment constraints. */
  376. #define FLONUM_MANTISSA_BITS   53
  377. #define FLONUM_EXPT_SIZE       10
  378. #define MAX_FLONUM_EXPONENT    1023
  379. /* Floating point representation uses hidden bit. */
  380.  
  381. #if defined(HAS_COMPILER_SUPPORT) && !defined(NATIVE_CODE_IS_C)
  382.    extern void * alpha_heap_malloc (long);
  383. #  define HEAP_MALLOC        alpha_heap_malloc
  384. #endif
  385.  
  386. #endif /* __alpha */
  387.  
  388. #ifdef __OS2__
  389.  
  390. #define PREALLOCATE_HEAP_MEMORY()                    \
  391. {                                    \
  392.   extern void OS2_alloc_heap (void);                    \
  393.   OS2_alloc_heap ();                            \
  394. }
  395.  
  396. extern void * OS2_commit_heap (unsigned long);
  397. #define HEAP_MALLOC OS2_commit_heap
  398. #define HEAP_FREE(address)
  399.  
  400. #define EXIT_SCHEME_DECLARATIONS extern void OS2_exit_scheme (int)
  401. #define EXIT_SCHEME OS2_exit_scheme
  402.  
  403. extern void OS2_stack_reset (void);
  404. #define STACK_RESET OS2_stack_reset
  405.  
  406. extern int OS2_stack_overflowed_p (void);
  407. #define STACK_OVERFLOWED_P OS2_stack_overflowed_p
  408.  
  409. #endif /* __OS2__ */
  410.  
  411. #ifdef __WIN32__
  412.  
  413. extern void EXFUN (win32_stack_reset, (void));
  414. #define STACK_RESET win32_stack_reset
  415.  
  416. #define HEAP_MALLOC(size) (WIN32_ALLOCATE_HEAP ((size), (&scheme_heap_handle)))
  417. #define HEAP_FREE(base)                            \
  418.   WIN32_RELEASE_HEAP (((char *) (base)), scheme_heap_handle)
  419.  
  420. /* We must not define `main' as that causes conflicts when compiling
  421.    this code with the Watcom C compiler.  */
  422. #define main_name scheme_main
  423.  
  424. #endif /* __WIN32__ */
  425.  
  426. /* These (pdp10, nu) haven't worked in a while.
  427.    Should be upgraded or flushed some day.  */
  428.  
  429. #ifdef pdp10
  430. #define MACHINE_TYPE        "pdp10"
  431. #define FASL_INTERNAL_FORMAT    FASL_PDP10
  432. #define HEAP_IN_LOW_MEMORY
  433. #define CHAR_BIT 36        / * Ugh! Supposedly fixed in newer Cs * /
  434. #define UNSIGNED_SHIFT_BUG
  435. #endif
  436.  
  437. #ifdef nu
  438. #define MACHINE_TYPE        "nu"
  439. #define FASL_INTERNAL_FORMAT    FASL_68000
  440. #define HEAP_IN_LOW_MEMORY
  441. #define UNSIGNED_SHIFT_BUG
  442. #endif
  443.  
  444. /* These are pretty old too, but more recent versions have run. */
  445.  
  446. #ifdef butterfly
  447. #define MACHINE_TYPE        "butterfly"
  448. #define FASL_INTERNAL_FORMAT    FASL_BFLY
  449. #define HEAP_IN_LOW_MEMORY
  450. #include <public.h>
  451. #endif
  452.  
  453. #ifdef cyber180
  454. #define MACHINE_TYPE        "cyber180"
  455. #define FASL_INTERNAL_FORMAT    FASL_CYBER
  456. #define HEAP_IN_LOW_MEMORY
  457. #define UNSIGNED_SHIFT_BUG
  458. /* The Cyber180 C compiler manifests a bug in hairy conditional expressions */
  459. #define Conditional_Bug
  460. #endif
  461.  
  462. #ifdef celerity
  463. #define MACHINE_TYPE        "celerity"
  464. #define FASL_INTERNAL_FORMAT    FASL_CELERITY
  465. #define HEAP_IN_LOW_MEMORY
  466. #endif
  467.  
  468. #ifdef umax
  469. #define MACHINE_TYPE        "umax"
  470. #define FASL_INTERNAL_FORMAT    FASL_UMAX
  471. #define HEAP_IN_LOW_MEMORY
  472. #endif
  473.  
  474. #ifdef pyr
  475. #define MACHINE_TYPE        "pyramid"
  476. #define FASL_INTERNAL_FORMAT    FASL_PYR
  477. #define HEAP_IN_LOW_MEMORY
  478. #endif
  479.  
  480. #ifdef alliant
  481. #define MACHINE_TYPE        "alliant"
  482. #define FASL_INTERNAL_FORMAT    FASL_ALLIANT
  483. #define HEAP_IN_LOW_MEMORY
  484. #endif
  485.  
  486. #ifdef apollo
  487. #if _ISP__M68K
  488. #define MACHINE_TYPE          "Apollo 68k"
  489. #define FASL_INTERNAL_FORMAT  FASL_APOLLO_68K
  490. #define TYPE_CODE_LENGTH    6
  491. #else
  492. #define MACHINE_TYPE          "Apollo Prism"
  493. #define FASL_INTERNAL_FORMAT  FASL_APOLLO_PRISM
  494. #endif
  495. #define HEAP_IN_LOW_MEMORY
  496. #endif
  497.  
  498. #ifdef _IBMR2
  499. #define MACHINE_TYPE          "IBM RS6000"
  500. #define FASL_INTERNAL_FORMAT   FASL_RS6000
  501. /* Heap is not in Low Memory. */
  502. #define FLONUM_MANTISSA_BITS   53
  503. #define FLONUM_EXPT_SIZE       10
  504. #define MAX_FLONUM_EXPONENT    1023
  505. #endif
  506.  
  507. #ifdef NATIVE_CODE_IS_C
  508. #  ifndef HAS_COMPILER_SUPPORT
  509. #    define HAS_COMPILER_SUPPORT
  510. #  endif
  511. #  ifndef TYPE_CODE_LENGTH
  512. #    define TYPE_CODE_LENGTH 6
  513. #  endif
  514. #endif
  515.  
  516. /* Make sure that some definition applies.  If this error occurs, and
  517.    the parameters of the configuration are unknown, try the Wsize
  518.    program.  */
  519. #ifndef MACHINE_TYPE
  520. #  include "Error: confshared.h: Unknown configuration."
  521. #endif
  522.  
  523. /* Virtually all machines have 8-bit characters these days, so don't
  524.    explicitly specify this value unless it is different.  */
  525. #ifndef CHAR_BIT
  526. #  define CHAR_BIT 8
  527. #endif
  528.  
  529. #ifndef TYPE_CODE_LENGTH
  530. #  define TYPE_CODE_LENGTH 8
  531. #endif
  532.  
  533. /* The GNU C compiler does not have any of these bugs. */
  534. #ifdef __GNUC__
  535. #  undef HAVE_DOUBLE_TO_LONG_BUG
  536. #  undef UNSIGNED_SHIFT_BUG
  537. #  undef Conditional_Bug
  538. #endif
  539.  
  540. #endif /* SCM_CONFSHARED_H */
  541.