Ruby: include/ruby/backward/2/limits.h Source File

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

limits.h
Go to the documentation of this file.
1#ifndef RUBY_BACKWARD2_LIMITS_H /*-*-C++-*-vi:se ft=cpp:*/
2#define RUBY_BACKWARD2_LIMITS_H
26#include "ruby/internal/config.h"
27
28#ifdef HAVE_LIMITS_H
29# include <limits.h>
30#endif
31
32#include "ruby/backward/2/long_long.h"
33
34#ifndef LONG_MAX
35# /* assuming 32bit(2's complement) long */
36# define LONG_MAX 2147483647L
37#endif
38
39#ifndef LONG_MIN
40# define LONG_MIN (-LONG_MAX-1)
41#endif
42
43#ifndef CHAR_BIT
44# define CHAR_BIT 8
45#endif
46
47#ifdef LLONG_MAX
48# /* Take that. */
49#elif defined(LONG_LONG_MAX)
50# define LLONG_MAX LONG_LONG_MAX
51#elif defined(_I64_MAX)
52# define LLONG_MAX _I64_MAX
53#else
54# /* assuming 64bit(2's complement) long long */
55# define LLONG_MAX 9223372036854775807LL
56#endif
57
58#ifdef LLONG_MIN
59# /* Take that. */
60#elif defined(LONG_LONG_MIN)
61# define LLONG_MIN LONG_LONG_MIN
62#elif defined(_I64_MAX)
63# define LLONG_MIN _I64_MIN
64#else
65# define LLONG_MIN (-LLONG_MAX-1)
66#endif
67
68#ifdef SIZE_MAX
69# /* Take that. */
70#elif SIZEOF_SIZE_T == SIZEOF_LONG_LONG
71# define SIZE_MAX ULLONG_MAX
72# define SIZE_MIN ULLONG_MIN
73#elif SIZEOF_SIZE_T == SIZEOF_LONG
74# define SIZE_MAX ULONG_MAX
75# define SIZE_MIN ULONG_MIN
76#elif SIZEOF_SIZE_T == SIZEOF_INT
77# define SIZE_MAX UINT_MAX
78# define SIZE_MIN UINT_MIN
79#else
80# define SIZE_MAX USHRT_MAX
81# define SIZE_MIN USHRT_MIN
82#endif
83
84#ifdef SSIZE_MAX
85# /* Take that. */
86#elif SIZEOF_SIZE_T == SIZEOF_LONG_LONG
87# define SSIZE_MAX LLONG_MAX
88# define SSIZE_MIN LLONG_MIN
89#elif SIZEOF_SIZE_T == SIZEOF_LONG
90# define SSIZE_MAX LONG_MAX
91# define SSIZE_MIN LONG_MIN
92#elif SIZEOF_SIZE_T == SIZEOF_INT
93# define SSIZE_MAX INT_MAX
94# define SSIZE_MIN INT_MIN
95#else
96# define SSIZE_MAX SHRT_MAX
97# define SSIZE_MIN SHRT_MIN
98#endif
99
100#endif /* RUBY_BACKWARD2_LIMITS_H */
long_long.h
Defines old #LONG_LONG.
config.h
Thin wrapper to ruby/config.h.
limits.h
Historical shim for <limits.h>.