/byterun/config.h

http://github.com/bmeurer/ocaml · C Header · 183 lines · 87 code · 35 blank · 61 comment · 13 complexity · db084d0069594b51253461a630d51c68 MD5 · raw file

  1. /***********************************************************************/
  2. /* */
  3. /* OCaml */
  4. /* */
  5. /* Xavier Leroy and Damien Doligez, INRIA Rocquencourt */
  6. /* */
  7. /* Copyright 1996 Institut National de Recherche en Informatique et */
  8. /* en Automatique. All rights reserved. This file is distributed */
  9. /* under the terms of the GNU Library General Public License, with */
  10. /* the special exception on linking described in file ../LICENSE. */
  11. /* */
  12. /***********************************************************************/
  13. #ifndef CAML_CONFIG_H
  14. #define CAML_CONFIG_H
  15. /* <include ../config/m.h> */
  16. /* <include ../config/s.h> */
  17. /* <private> */
  18. #include "../config/m.h"
  19. #include "../config/s.h"
  20. /* </private> */
  21. #ifndef CAML_NAME_SPACE
  22. #include "compatibility.h"
  23. #endif
  24. #ifdef HAS_STDINT_H
  25. #include <stdint.h>
  26. #endif
  27. /* Types for 32-bit integers, 64-bit integers, and
  28. native integers (as wide as a pointer type) */
  29. #ifndef ARCH_INT32_TYPE
  30. #if SIZEOF_INT == 4
  31. #define ARCH_INT32_TYPE int
  32. #define ARCH_UINT32_TYPE unsigned int
  33. #define ARCH_INT32_PRINTF_FORMAT ""
  34. #elif SIZEOF_LONG == 4
  35. #define ARCH_INT32_TYPE long
  36. #define ARCH_UINT32_TYPE unsigned long
  37. #define ARCH_INT32_PRINTF_FORMAT "l"
  38. #elif SIZEOF_SHORT == 4
  39. #define ARCH_INT32_TYPE short
  40. #define ARCH_UINT32_TYPE unsigned short
  41. #define ARCH_INT32_PRINTF_FORMAT ""
  42. #else
  43. #error "No 32-bit integer type available"
  44. #endif
  45. #endif
  46. #ifndef ARCH_INT64_TYPE
  47. #if SIZEOF_LONGLONG == 8
  48. #define ARCH_INT64_TYPE long long
  49. #define ARCH_UINT64_TYPE unsigned long long
  50. #define ARCH_INT64_PRINTF_FORMAT "ll"
  51. #elif SIZEOF_LONG == 8
  52. #define ARCH_INT64_TYPE long
  53. #define ARCH_UINT64_TYPE unsigned long
  54. #define ARCH_INT64_PRINTF_FORMAT "l"
  55. #else
  56. #error "No 64-bit integer type available"
  57. #endif
  58. #endif
  59. #ifndef HAS_STDINT_H
  60. /* Not a C99 compiler, typically MSVC. Define the C99 types we use. */
  61. typedef ARCH_INT32_TYPE int32_t;
  62. typedef ARCH_UINT32_TYPE uint32_t;
  63. typedef ARCH_INT64_TYPE int64_t;
  64. typedef ARCH_UINT64_TYPE uint64_t;
  65. #endif
  66. #if SIZEOF_PTR == SIZEOF_LONG
  67. /* Standard models: ILP32 or I32LP64 */
  68. typedef long intnat;
  69. typedef unsigned long uintnat;
  70. #define ARCH_INTNAT_PRINTF_FORMAT "l"
  71. #elif SIZEOF_PTR == SIZEOF_INT
  72. /* Hypothetical IP32L64 model */
  73. typedef int intnat;
  74. typedef unsigned int uintnat;
  75. #define ARCH_INTNAT_PRINTF_FORMAT ""
  76. #elif SIZEOF_PTR == 8
  77. /* Win64 model: IL32P64 */
  78. typedef int64_t intnat;
  79. typedef uint64_t uintnat;
  80. #define ARCH_INTNAT_PRINTF_FORMAT ARCH_INT64_PRINTF_FORMAT
  81. #else
  82. #error "No integer type available to represent pointers"
  83. #endif
  84. /* Endianness of floats */
  85. /* ARCH_FLOAT_ENDIANNESS encodes the byte order of doubles as follows:
  86. the value [0xabcdefgh] means that the least significant byte of the
  87. float is at byte offset [a], the next lsb at [b], ..., and the
  88. most significant byte at [h]. */
  89. #if defined(__arm__) && !defined(__ARM_EABI__)
  90. #define ARCH_FLOAT_ENDIANNESS 0x45670123
  91. #elif defined(ARCH_BIG_ENDIAN)
  92. #define ARCH_FLOAT_ENDIANNESS 0x76543210
  93. #else
  94. #define ARCH_FLOAT_ENDIANNESS 0x01234567
  95. #endif
  96. /* We use threaded code interpretation if the compiler provides labels
  97. as first-class values (GCC 2.x). */
  98. #if defined(__GNUC__) && __GNUC__ >= 2 && !defined(DEBUG) \
  99. && !defined (SHRINKED_GNUC) && !defined(CAML_JIT)
  100. #define THREADED_CODE
  101. #endif
  102. /* Memory model parameters */
  103. /* The size of a page for memory management (in bytes) is [1 << Page_log].
  104. [Page_size] must be a multiple of [sizeof (value)].
  105. [Page_log] must be be >= 8 and <= 20.
  106. Do not change the definition of [Page_size]. */
  107. #define Page_log 12 /* A page is 4 kilobytes. */
  108. #define Page_size (1 << Page_log)
  109. /* Initial size of stack (bytes). */
  110. #define Stack_size (4096 * sizeof(value))
  111. /* Minimum free size of stack (bytes); below that, it is reallocated. */
  112. #define Stack_threshold (256 * sizeof(value))
  113. /* Default maximum size of the stack (words). */
  114. #define Max_stack_def (1024 * 1024)
  115. /* Maximum size of a block allocated in the young generation (words). */
  116. /* Must be > 4 */
  117. #define Max_young_wosize 256
  118. /* Minimum size of the minor zone (words).
  119. This must be at least [Max_young_wosize + 1]. */
  120. #define Minor_heap_min 4096
  121. /* Maximum size of the minor zone (words).
  122. Must be greater than or equal to [Minor_heap_min].
  123. */
  124. #define Minor_heap_max (1 << 28)
  125. /* Default size of the minor zone. (words) */
  126. #define Minor_heap_def 262144
  127. /* Minimum size increment when growing the heap (words).
  128. Must be a multiple of [Page_size / sizeof (value)]. */
  129. #define Heap_chunk_min (15 * Page_size)
  130. /* Default size increment when growing the heap.
  131. If this is <= 1000, it's a percentage of the current heap size.
  132. If it is > 1000, it's a number of words. */
  133. #define Heap_chunk_def 15
  134. /* Default initial size of the major heap (words);
  135. Must be a multiple of [Page_size / sizeof (value)]. */
  136. #define Init_heap_def (31 * Page_size)
  137. /* (about 512 kB for a 32-bit platform, 1 MB for a 64-bit platform.) */
  138. /* Default speed setting for the major GC. The heap will grow until
  139. the dead objects and the free list represent this percentage of the
  140. total size of live objects. */
  141. #define Percent_free_def 80
  142. /* Default setting for the compacter: 500%
  143. (i.e. trigger the compacter when 5/6 of the heap is free or garbage)
  144. This can be set quite high because the overhead is over-estimated
  145. when fragmentation occurs.
  146. */
  147. #define Max_percent_free_def 500
  148. #endif /* CAML_CONFIG_H */