[rubygems/rubygems] Use a constant empty tar header to avoid extra allocations
[ruby.git] / parser_value.h
blob4fe444e82f0dc29020dce71a1e10b50a2e4152a5
1 #ifndef EXTERNAL_VALUE_H
2 #define EXTERNAL_VALUE_H
4 #include "ruby/config.h"
6 #if defined(__DOXYGEN__)
8 /**
9 * Type that represents a Ruby object. It is an unsigned integer of some kind,
10 * depending on platforms.
12 * ```CXX
13 * VALUE value = rb_eval_string("ARGF.readlines.map.with_index");
14 * ```
16 * @warning ::VALUE is not a pointer.
17 * @warning ::VALUE can be wider than `long`.
19 typedef uintptr_t VALUE;
21 /**
22 * Type that represents a Ruby identifier such as a variable name.
24 * ```CXX
25 * ID method = rb_intern("method");
26 * VALUE result = rb_funcall(obj, method, 0);
27 * ```
29 * @note ::rb_cSymbol is a Ruby-level data type for the same thing.
31 typedef uintptr_t ID;
33 /**
34 * A signed integer type that has the same width with ::VALUE.
36 * @internal
38 * @shyouhei wonders: is it guaranteed that `uintptr_t` and `intptr_t` are the
39 * same width? As far as I read ISO/IEC 9899:2018 section 7.20.1.4 paragraph 1
40 * no such description is given... or defined elsewhere?
42 typedef intptr_t SIGNED_VALUE;
44 /**
45 * Identical to `sizeof(VALUE)`, except it is a macro that can also be used
46 * inside of preprocessor directives such as `#if`. Handy on occasions.
48 #define SIZEOF_VALUE SIZEOF_UINTPTR_T
50 /**
51 * @private
53 * A compile-time constant of type ::VALUE whose value is 0.
55 #define RBIMPL_VALUE_NULL UINTPTR_C(0)
57 /**
58 * @private
60 * A compile-time constant of type ::VALUE whose value is 1.
62 #define RBIMPL_VALUE_ONE UINTPTR_C(1)
64 /**
65 * @private
67 * Maximum possible value that a ::VALUE can take.
69 #define RBIMPL_VALUE_FULL UINTPTR_MAX
71 #elif defined HAVE_UINTPTR_T && 0
72 typedef uintptr_t VALUE;
73 typedef uintptr_t ID;
74 # define SIGNED_VALUE intptr_t
75 # define SIZEOF_VALUE SIZEOF_UINTPTR_T
76 # undef PRI_VALUE_PREFIX
77 # define RBIMPL_VALUE_NULL UINTPTR_C(0)
78 # define RBIMPL_VALUE_ONE UINTPTR_C(1)
79 # define RBIMPL_VALUE_FULL UINTPTR_MAX
81 #elif SIZEOF_LONG == SIZEOF_VOIDP
82 typedef unsigned long VALUE;
83 typedef unsigned long ID;
84 # define SIGNED_VALUE long
85 # define SIZEOF_VALUE SIZEOF_LONG
86 # define PRI_VALUE_PREFIX "l"
87 # define RBIMPL_VALUE_NULL 0UL
88 # define RBIMPL_VALUE_ONE 1UL
89 # define RBIMPL_VALUE_FULL ULONG_MAX
91 #elif SIZEOF_LONG_LONG == SIZEOF_VOIDP
92 typedef unsigned LONG_LONG VALUE;
93 typedef unsigned LONG_LONG ID;
94 # define SIGNED_VALUE LONG_LONG
95 # define LONG_LONG_VALUE 1
96 # define SIZEOF_VALUE SIZEOF_LONG_LONG
97 # define PRI_VALUE_PREFIX PRI_LL_PREFIX
98 # define RBIMPL_VALUE_NULL 0ULL
99 # define RBIMPL_VALUE_ONE 1ULL
100 # define RBIMPL_VALUE_FULL ULLONG_MAX
102 #else
103 # error ---->> ruby requires sizeof(void*) == sizeof(long) or sizeof(LONG_LONG) to be compiled. <<----
104 #endif
106 #endif /* EXTERNAL_VALUE_H */