Ruby: include/ruby/internal/value.h Source File

Ruby 3.0.5p211 (2022-11-24 revision ba5cf0f7c52d4d35cc6a173c89eda98ceffa2dcf)

value.h
Go to the documentation of this file.
1#ifndef RBIMPL_VALUE_H /*-*-C++-*-vi:se ft=cpp:*/
2#define RBIMPL_VALUE_H
23#include "ruby/internal/static_assert.h"
24#include "ruby/backward/2/long_long.h"
25#include "ruby/backward/2/limits.h"
26
27#if defined HAVE_UINTPTR_T && 0
28typedef uintptr_t VALUE;
29typedef uintptr_t ID;
30# define SIGNED_VALUE intptr_t
31# define SIZEOF_VALUE SIZEOF_UINTPTR_T
32# undef PRI_VALUE_PREFIX
33# define RBIMPL_VALUE_NULL UINTPTR_C(0)
34# define RBIMPL_VALUE_ONE UINTPTR_C(1)
35# define RBIMPL_VALUE_FULL UINTPTR_MAX
36
37#elif SIZEOF_LONG == SIZEOF_VOIDP
38 typedef unsigned long VALUE;
39 typedef unsigned long ID;
40# define SIGNED_VALUE long
41# define SIZEOF_VALUE SIZEOF_LONG
42# define PRI_VALUE_PREFIX "l"
43# define RBIMPL_VALUE_NULL 0UL
44# define RBIMPL_VALUE_ONE 1UL
45# define RBIMPL_VALUE_FULL ULONG_MAX
46
47#elif SIZEOF_LONG_LONG == SIZEOF_VOIDP
48typedef unsigned LONG_LONG VALUE;
49typedef unsigned LONG_LONG ID;
50# define SIGNED_VALUE LONG_LONG
51# define LONG_LONG_VALUE 1
52# define SIZEOF_VALUE SIZEOF_LONG_LONG
53# define PRI_VALUE_PREFIX PRI_LL_PREFIX
54# define RBIMPL_VALUE_NULL 0ULL
55# define RBIMPL_VALUE_ONE 1ULL
56# define RBIMPL_VALUE_FULL ULLONG_MAX
57
58#else
59# error ---->> ruby requires sizeof(void*) == sizeof(long) or sizeof(LONG_LONG) to be compiled. <<----
60#endif
61
62 RBIMPL_STATIC_ASSERT(sizeof_int, SIZEOF_INT == sizeof(int));
63 RBIMPL_STATIC_ASSERT(sizeof_long, SIZEOF_LONG == sizeof(long));
64 RBIMPL_STATIC_ASSERT(sizeof_long_long, SIZEOF_LONG_LONG == sizeof(LONG_LONG));
65 RBIMPL_STATIC_ASSERT(sizeof_voidp, SIZEOF_VOIDP == sizeof(void *));
66#endif /* RBIMPL_VALUE_H */
long_long.h
Defines old #LONG_LONG.
static_assert.h
Defines RBIMPL_STATIC_ASSERT.
RBIMPL_STATIC_ASSERT
#define RBIMPL_STATIC_ASSERT
Wraps (or simulates) static_assert
Definition: static_assert.h:66
limits.h
Historical shim for <limits.h>.
VALUE
unsigned long VALUE
Definition: value.h:38
ID
unsigned long ID
Definition: value.h:39
uintptr_t
unsigned int uintptr_t
Definition: win32.h:106