rubycc 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CHANGELOG.md +56 -0
- data/LICENSE.txt +21 -0
- data/NOTICE +52 -0
- data/README.md +208 -0
- data/data/README.md +117 -0
- data/data/r10_corpus_scan.json +4082 -0
- data/data/r10_manual_classification.json +5342 -0
- data/data/r10_verification_m4a.json +1531 -0
- data/data/r10_verification_m4b.json +1818 -0
- data/data/r10_verification_m4c.json +1489 -0
- data/data/r10_verification_m4d.json +318 -0
- data/data/r10_verification_rbs.json +192 -0
- data/data/verified_gems.json +397 -0
- data/exe/rmake +16 -0
- data/exe/rubycc +9 -0
- data/exe/rubycc-ar +114 -0
- data/exe/rubycc-doctor +14 -0
- data/exe/rubycc-pkgconf +8 -0
- data/include/float.h +87 -0
- data/include/iso646.h +18 -0
- data/include/libc/alloca.h +18 -0
- data/include/libc/arpa/inet.h +61 -0
- data/include/libc/assert.h +43 -0
- data/include/libc/dirent.h +72 -0
- data/include/libc/dlfcn.h +58 -0
- data/include/libc/features.h +205 -0
- data/include/libc/glibc/aarch64/ctype.h +108 -0
- data/include/libc/glibc/aarch64/endian.h +54 -0
- data/include/libc/glibc/aarch64/errno.h +154 -0
- data/include/libc/glibc/aarch64/fcntl.h +144 -0
- data/include/libc/glibc/aarch64/inttypes.h +182 -0
- data/include/libc/glibc/aarch64/limits.h +63 -0
- data/include/libc/glibc/aarch64/pthread.h +131 -0
- data/include/libc/glibc/aarch64/setjmp.h +84 -0
- data/include/libc/glibc/aarch64/stdint.h +174 -0
- data/include/libc/glibc/aarch64/sys/epoll.h +88 -0
- data/include/libc/glibc/aarch64/sys/fcntl.h +19 -0
- data/include/libc/glibc/aarch64/sys/select.h +75 -0
- data/include/libc/glibc/aarch64/sys/stat.h +136 -0
- data/include/libc/glibc/aarch64/sys/syscall.h +167 -0
- data/include/libc/glibc/aarch64/sys/time.h +74 -0
- data/include/libc/glibc/aarch64/sys/types.h +127 -0
- data/include/libc/glibc/aarch64/time.h +113 -0
- data/include/libc/glibc/x86_64/ctype.h +108 -0
- data/include/libc/glibc/x86_64/endian.h +54 -0
- data/include/libc/glibc/x86_64/errno.h +154 -0
- data/include/libc/glibc/x86_64/fcntl.h +134 -0
- data/include/libc/glibc/x86_64/inttypes.h +182 -0
- data/include/libc/glibc/x86_64/limits.h +61 -0
- data/include/libc/glibc/x86_64/pthread.h +111 -0
- data/include/libc/glibc/x86_64/setjmp.h +82 -0
- data/include/libc/glibc/x86_64/stdint.h +163 -0
- data/include/libc/glibc/x86_64/sys/epoll.h +91 -0
- data/include/libc/glibc/x86_64/sys/fcntl.h +19 -0
- data/include/libc/glibc/x86_64/sys/select.h +75 -0
- data/include/libc/glibc/x86_64/sys/stat.h +130 -0
- data/include/libc/glibc/x86_64/sys/syscall.h +188 -0
- data/include/libc/glibc/x86_64/sys/time.h +74 -0
- data/include/libc/glibc/x86_64/sys/types.h +123 -0
- data/include/libc/glibc/x86_64/time.h +113 -0
- data/include/libc/grp.h +50 -0
- data/include/libc/langinfo.h +126 -0
- data/include/libc/link.h +18 -0
- data/include/libc/locale.h +83 -0
- data/include/libc/math.h +191 -0
- data/include/libc/netinet/in.h +126 -0
- data/include/libc/netinet/tcp.h +44 -0
- data/include/libc/poll.h +46 -0
- data/include/libc/pwd.h +58 -0
- data/include/libc/regex.h +53 -0
- data/include/libc/sched.h +35 -0
- data/include/libc/signal.h +204 -0
- data/include/libc/stdio.h +157 -0
- data/include/libc/stdlib.h +92 -0
- data/include/libc/string.h +74 -0
- data/include/libc/strings.h +25 -0
- data/include/libc/sys/cdefs.h +126 -0
- data/include/libc/sys/inotify.h +111 -0
- data/include/libc/sys/ioctl.h +36 -0
- data/include/libc/sys/mman.h +65 -0
- data/include/libc/sys/param.h +41 -0
- data/include/libc/sys/resource.h +109 -0
- data/include/libc/sys/socket.h +167 -0
- data/include/libc/sys/statfs.h +82 -0
- data/include/libc/sys/timerfd.h +55 -0
- data/include/libc/sys/uio.h +40 -0
- data/include/libc/sys/un.h +25 -0
- data/include/libc/sys/utsname.h +35 -0
- data/include/libc/sys/wait.h +135 -0
- data/include/libc/termios.h +179 -0
- data/include/libc/unistd.h +194 -0
- data/include/stdalign.h +16 -0
- data/include/stdarg.h +31 -0
- data/include/stdatomic.h +158 -0
- data/include/stdbool.h +15 -0
- data/include/stdckdint.h +28 -0
- data/include/stddef.h +60 -0
- data/include/stdnoreturn.h +18 -0
- data/include/x86intrin.h +16 -0
- data/lib/rubycc/backend/aarch64.rb +1724 -0
- data/lib/rubycc/backend/x86_64.rb +1369 -0
- data/lib/rubycc/compile_error.rb +36 -0
- data/lib/rubycc/compiler.rb +305 -0
- data/lib/rubycc/doctor/builder.rb +151 -0
- data/lib/rubycc/doctor/cli.rb +190 -0
- data/lib/rubycc/doctor/fetcher.rb +84 -0
- data/lib/rubycc/doctor/gemfile.rb +115 -0
- data/lib/rubycc/doctor/verified_gems.rb +114 -0
- data/lib/rubycc/doctor.rb +16 -0
- data/lib/rubycc/driver.rb +463 -0
- data/lib/rubycc/front/ast.rb +528 -0
- data/lib/rubycc/front/constant_evaluator.rb +631 -0
- data/lib/rubycc/front/initializer_resolver.rb +592 -0
- data/lib/rubycc/front/lexeme_reader.rb +460 -0
- data/lib/rubycc/front/lexer.rb +232 -0
- data/lib/rubycc/front/parser.rb +4122 -0
- data/lib/rubycc/front/token.rb +49 -0
- data/lib/rubycc/ir/call_convention.rb +486 -0
- data/lib/rubycc/ir/generator.rb +6036 -0
- data/lib/rubycc/ir/ir.rb +417 -0
- data/lib/rubycc/link/compat_runtime.rb +89 -0
- data/lib/rubycc/link/errors.rb +13 -0
- data/lib/rubycc/link/executable_linker.rb +405 -0
- data/lib/rubycc/link/library_resolver.rb +437 -0
- data/lib/rubycc/link/partial_linker.rb +546 -0
- data/lib/rubycc/link/shared_linker.rb +1732 -0
- data/lib/rubycc/mkmf_shim.rb +83 -0
- data/lib/rubycc/objfile/ar_archive.rb +437 -0
- data/lib/rubycc/objfile/elf_reader.rb +646 -0
- data/lib/rubycc/objfile/elf_writer.rb +891 -0
- data/lib/rubycc/objfile/relocatable_writer.rb +376 -0
- data/lib/rubycc/pkgconf/cli.rb +139 -0
- data/lib/rubycc/pkgconf/errors.rb +39 -0
- data/lib/rubycc/pkgconf/model.rb +28 -0
- data/lib/rubycc/pkgconf/parser.rb +109 -0
- data/lib/rubycc/pkgconf/pkgconf.rb +15 -0
- data/lib/rubycc/pkgconf/resolver.rb +70 -0
- data/lib/rubycc/pkgconf/search_path.rb +38 -0
- data/lib/rubycc/pkgconf/system_path_filter.rb +131 -0
- data/lib/rubycc/preprocess/constant_expression.rb +219 -0
- data/lib/rubycc/preprocess/glibc_version.rb +124 -0
- data/lib/rubycc/preprocess/pp_token.rb +62 -0
- data/lib/rubycc/preprocess/preprocessor.rb +2020 -0
- data/lib/rubycc/preprocess/scanner.rb +290 -0
- data/lib/rubycc/preprocess/token_converter.rb +157 -0
- data/lib/rubycc/rmake/cli.rb +143 -0
- data/lib/rubycc/rmake/errors.rb +71 -0
- data/lib/rubycc/rmake/executor.rb +818 -0
- data/lib/rubycc/rmake/expander.rb +251 -0
- data/lib/rubycc/rmake/makefile.rb +352 -0
- data/lib/rubycc/rmake/model.rb +137 -0
- data/lib/rubycc/rmake/parser.rb +226 -0
- data/lib/rubycc/rmake/rmake.rb +15 -0
- data/lib/rubycc/type.rb +1236 -0
- data/lib/rubycc/version.rb +5 -0
- data/lib/rubycc.rb +36 -0
- data/lib/rubygems_plugin.rb +102 -0
- metadata +219 -0
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/* rubycc bundled <ctype.h>: character classification (ISO C 7.4). glibc does
|
|
2
|
+
not return a bare 0/1 from isalpha() and kin -- it returns the masked bits of
|
|
3
|
+
a per-locale classification table reached through __ctype_b_loc(), so the
|
|
4
|
+
result values are part of its ABI. This header reproduces that mechanism clean
|
|
5
|
+
room from the published _ISbit formula and accessor signatures (not copied
|
|
6
|
+
from glibc, not derived from musl, whose ctype returns 0/1); the accessor
|
|
7
|
+
functions themselves are resolved from the host libc at link time. The whole
|
|
8
|
+
mechanism is glibc's, so under __RUBYCC_LIBC_MUSL__ (see the preprocessor's
|
|
9
|
+
LIBCS) the classification macros are switched off and the plain function
|
|
10
|
+
calls stand instead -- see the note above them. Placed in the glibc layer
|
|
11
|
+
because that is where the arch-switched headers live; the values themselves
|
|
12
|
+
are arch independent. */
|
|
13
|
+
|
|
14
|
+
#ifndef _RUBYCC_CTYPE_H
|
|
15
|
+
#define _RUBYCC_CTYPE_H
|
|
16
|
+
|
|
17
|
+
/* The classification bit for each property, as glibc lays them out in the table
|
|
18
|
+
entry: properties 0-7 occupy the high byte, 8-11 the low byte. */
|
|
19
|
+
#ifndef _ISbit
|
|
20
|
+
# define _ISbit(bit) ((bit) < 8 ? ((1 << (bit)) << 8) : ((1 << (bit)) >> 8))
|
|
21
|
+
#endif
|
|
22
|
+
|
|
23
|
+
enum {
|
|
24
|
+
_ISupper = _ISbit(0),
|
|
25
|
+
_ISlower = _ISbit(1),
|
|
26
|
+
_ISalpha = _ISbit(2),
|
|
27
|
+
_ISdigit = _ISbit(3),
|
|
28
|
+
_ISxdigit = _ISbit(4),
|
|
29
|
+
_ISspace = _ISbit(5),
|
|
30
|
+
_ISprint = _ISbit(6),
|
|
31
|
+
_ISgraph = _ISbit(7),
|
|
32
|
+
_ISblank = _ISbit(8),
|
|
33
|
+
_IScntrl = _ISbit(9),
|
|
34
|
+
_ISpunct = _ISbit(10),
|
|
35
|
+
_ISalnum = _ISbit(11)
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
extern const unsigned short int **__ctype_b_loc(void);
|
|
39
|
+
extern const int **__ctype_tolower_loc(void);
|
|
40
|
+
extern const int **__ctype_toupper_loc(void);
|
|
41
|
+
|
|
42
|
+
/* The out-of-line entry points (declared so code taking their address still
|
|
43
|
+
links); the macros below inline the common case. */
|
|
44
|
+
extern int isalnum(int __c);
|
|
45
|
+
extern int isalpha(int __c);
|
|
46
|
+
extern int iscntrl(int __c);
|
|
47
|
+
extern int isdigit(int __c);
|
|
48
|
+
extern int islower(int __c);
|
|
49
|
+
extern int isgraph(int __c);
|
|
50
|
+
extern int isprint(int __c);
|
|
51
|
+
extern int ispunct(int __c);
|
|
52
|
+
extern int isspace(int __c);
|
|
53
|
+
extern int isupper(int __c);
|
|
54
|
+
extern int isxdigit(int __c);
|
|
55
|
+
extern int isblank(int __c);
|
|
56
|
+
extern int tolower(int __c);
|
|
57
|
+
extern int toupper(int __c);
|
|
58
|
+
extern int isascii(int __c);
|
|
59
|
+
extern int toascii(int __c);
|
|
60
|
+
|
|
61
|
+
/* The classification macros are glibc's mechanism and glibc's result values,
|
|
62
|
+
so on musl they must not be used at all: the two libraries differ in the
|
|
63
|
+
*shape* of the answer, not merely in a constant. glibc's isalpha('a') is the
|
|
64
|
+
masked table entry (measured 1024, and 2048/8192/... for the other
|
|
65
|
+
properties) while musl's is a bare 1; and musl has no __ctype_b_loc() /
|
|
66
|
+
__ctype_tolower_loc() / __ctype_toupper_loc() to reach a table through in the
|
|
67
|
+
first place, so a table-lookup macro would not even link there. Both
|
|
68
|
+
behaviours measured with the ABI harness, glibc's on this host and musl's on
|
|
69
|
+
the CI musl run (docs/STEPS.md Step 193). Under musl the macros are therefore
|
|
70
|
+
left undefined and every classifier resolves to the out-of-line function
|
|
71
|
+
declared above, which is what returns musl's 0/1. The accessor prototypes and
|
|
72
|
+
the _IS* enumerators stay declared on both: a prototype that is never called
|
|
73
|
+
emits nothing, and code that does call one is asking for glibc's own
|
|
74
|
+
interface by name. */
|
|
75
|
+
#if !defined(__RUBYCC_LIBC_MUSL__)
|
|
76
|
+
|
|
77
|
+
#define __isctype(c, type) ((*__ctype_b_loc())[(int)(c)] & (unsigned short int)(type))
|
|
78
|
+
|
|
79
|
+
#define isalnum(c) __isctype((c), _ISalnum)
|
|
80
|
+
#define isalpha(c) __isctype((c), _ISalpha)
|
|
81
|
+
#define iscntrl(c) __isctype((c), _IScntrl)
|
|
82
|
+
#define isdigit(c) __isctype((c), _ISdigit)
|
|
83
|
+
#define islower(c) __isctype((c), _ISlower)
|
|
84
|
+
#define isgraph(c) __isctype((c), _ISgraph)
|
|
85
|
+
#define isprint(c) __isctype((c), _ISprint)
|
|
86
|
+
#define ispunct(c) __isctype((c), _ISpunct)
|
|
87
|
+
#define isspace(c) __isctype((c), _ISspace)
|
|
88
|
+
#define isupper(c) __isctype((c), _ISupper)
|
|
89
|
+
#define isxdigit(c) __isctype((c), _ISxdigit)
|
|
90
|
+
#define isblank(c) __isctype((c), _ISblank)
|
|
91
|
+
|
|
92
|
+
#define tolower(c) ((int) (*__ctype_tolower_loc())[(int)(c)])
|
|
93
|
+
#define toupper(c) ((int) (*__ctype_toupper_loc())[(int)(c)])
|
|
94
|
+
|
|
95
|
+
#endif /* !__RUBYCC_LIBC_MUSL__ */
|
|
96
|
+
|
|
97
|
+
/* isascii/toascii: glibc declares these under __USE_MISC || __USE_XOPEN and
|
|
98
|
+
defines them as pure bit tests (no locale classification table), so the
|
|
99
|
+
inline value matches glibc's out-of-line result exactly -- no ABI subtlety
|
|
100
|
+
like the isalpha() family above. Real sources (e.g. redcarpet's html.c) call
|
|
101
|
+
isascii() with only <ctype.h> included. They stay macros under either C
|
|
102
|
+
library: the probed values (isascii of 'a'/200/0/127, toascii of 0x1FF/'A')
|
|
103
|
+
measured identical on glibc and musl (docs/STEPS.md Step 193), which is why
|
|
104
|
+
they sit outside the branch above. */
|
|
105
|
+
#define isascii(c) (((c) & ~0x7f) == 0)
|
|
106
|
+
#define toascii(c) ((c) & 0x7f)
|
|
107
|
+
|
|
108
|
+
#endif /* _RUBYCC_CTYPE_H */
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/* rubycc bundled <endian.h>: byte-order identity macros and the host<->big/
|
|
2
|
+
little conversions (glibc/BSD extension). Derived from musl's <endian.h>
|
|
3
|
+
shape; the byte order and the glibc spellings (__BYTE_ORDER, bswap via the
|
|
4
|
+
compiler builtins) are pinned to the little-endian x86-64 ABI. ABI switch
|
|
5
|
+
layer: the byte order is arch specific. */
|
|
6
|
+
|
|
7
|
+
#ifndef _RUBYCC_ENDIAN_H
|
|
8
|
+
#define _RUBYCC_ENDIAN_H
|
|
9
|
+
|
|
10
|
+
#define __LITTLE_ENDIAN 1234
|
|
11
|
+
#define __BIG_ENDIAN 4321
|
|
12
|
+
#define __PDP_ENDIAN 3412
|
|
13
|
+
#define __BYTE_ORDER __LITTLE_ENDIAN
|
|
14
|
+
#define __FLOAT_WORD_ORDER __BYTE_ORDER
|
|
15
|
+
|
|
16
|
+
/* BSD-style spellings (glibc exposes both under _DEFAULT_SOURCE). */
|
|
17
|
+
#define LITTLE_ENDIAN __LITTLE_ENDIAN
|
|
18
|
+
#define BIG_ENDIAN __BIG_ENDIAN
|
|
19
|
+
#define PDP_ENDIAN __PDP_ENDIAN
|
|
20
|
+
#define BYTE_ORDER __BYTE_ORDER
|
|
21
|
+
|
|
22
|
+
/* Byte reversals as static inline helpers (arithmetic, so no compiler byte-swap
|
|
23
|
+
builtin is required and each argument is evaluated once). */
|
|
24
|
+
static inline unsigned short __rubycc_bswap16(unsigned short __x) {
|
|
25
|
+
return (unsigned short) ((__x << 8) | (__x >> 8));
|
|
26
|
+
}
|
|
27
|
+
static inline unsigned int __rubycc_bswap32(unsigned int __x) {
|
|
28
|
+
return ((__x & 0x000000ffU) << 24) | ((__x & 0x0000ff00U) << 8)
|
|
29
|
+
| ((__x & 0x00ff0000U) >> 8) | ((__x & 0xff000000U) >> 24);
|
|
30
|
+
}
|
|
31
|
+
static inline unsigned long __rubycc_bswap64(unsigned long __x) {
|
|
32
|
+
return ((__x & 0x00000000000000ffUL) << 56) | ((__x & 0x000000000000ff00UL) << 40)
|
|
33
|
+
| ((__x & 0x0000000000ff0000UL) << 24) | ((__x & 0x00000000ff000000UL) << 8)
|
|
34
|
+
| ((__x & 0x000000ff00000000UL) >> 8) | ((__x & 0x0000ff0000000000UL) >> 24)
|
|
35
|
+
| ((__x & 0x00ff000000000000UL) >> 40) | ((__x & 0xff00000000000000UL) >> 56);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/* Host is little-endian: the "le" forms are identities, the "be" forms swap. */
|
|
39
|
+
#define htobe16(x) __rubycc_bswap16(x)
|
|
40
|
+
#define htole16(x) ((unsigned short)(x))
|
|
41
|
+
#define be16toh(x) __rubycc_bswap16(x)
|
|
42
|
+
#define le16toh(x) ((unsigned short)(x))
|
|
43
|
+
|
|
44
|
+
#define htobe32(x) __rubycc_bswap32(x)
|
|
45
|
+
#define htole32(x) ((unsigned int)(x))
|
|
46
|
+
#define be32toh(x) __rubycc_bswap32(x)
|
|
47
|
+
#define le32toh(x) ((unsigned int)(x))
|
|
48
|
+
|
|
49
|
+
#define htobe64(x) __rubycc_bswap64(x)
|
|
50
|
+
#define htole64(x) ((unsigned long)(x))
|
|
51
|
+
#define be64toh(x) __rubycc_bswap64(x)
|
|
52
|
+
#define le64toh(x) ((unsigned long)(x))
|
|
53
|
+
|
|
54
|
+
#endif /* _RUBYCC_ENDIAN_H */
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/* rubycc bundled <errno.h>: the error-number macros and the errno lvalue
|
|
2
|
+
(POSIX). Provenance: clean room against the Linux/asm-generic UAPI, not
|
|
3
|
+
derived from musl. The error numbers are the kernel ABI, reproduced here as
|
|
4
|
+
measured integer constants (an ABI fact, not copied text -- see
|
|
5
|
+
docs/HEADER-LICENSING.md); glibc reaches them via __errno_location, which
|
|
6
|
+
resolves from the host libc at link time. Placed in the glibc/x86-64 layer
|
|
7
|
+
because the numeric values are kernel-ABI specific. */
|
|
8
|
+
|
|
9
|
+
#ifndef _RUBYCC_ERRNO_H
|
|
10
|
+
#define _RUBYCC_ERRNO_H
|
|
11
|
+
|
|
12
|
+
extern int *__errno_location(void);
|
|
13
|
+
#define errno (*__errno_location())
|
|
14
|
+
|
|
15
|
+
#define EPERM 1
|
|
16
|
+
#define ENOENT 2
|
|
17
|
+
#define ESRCH 3
|
|
18
|
+
#define EINTR 4
|
|
19
|
+
#define EIO 5
|
|
20
|
+
#define ENXIO 6
|
|
21
|
+
#define E2BIG 7
|
|
22
|
+
#define ENOEXEC 8
|
|
23
|
+
#define EBADF 9
|
|
24
|
+
#define ECHILD 10
|
|
25
|
+
#define EAGAIN 11
|
|
26
|
+
#define ENOMEM 12
|
|
27
|
+
#define EACCES 13
|
|
28
|
+
#define EFAULT 14
|
|
29
|
+
#define ENOTBLK 15
|
|
30
|
+
#define EBUSY 16
|
|
31
|
+
#define EEXIST 17
|
|
32
|
+
#define EXDEV 18
|
|
33
|
+
#define ENODEV 19
|
|
34
|
+
#define ENOTDIR 20
|
|
35
|
+
#define EISDIR 21
|
|
36
|
+
#define EINVAL 22
|
|
37
|
+
#define ENFILE 23
|
|
38
|
+
#define EMFILE 24
|
|
39
|
+
#define ENOTTY 25
|
|
40
|
+
#define ETXTBSY 26
|
|
41
|
+
#define EFBIG 27
|
|
42
|
+
#define ENOSPC 28
|
|
43
|
+
#define ESPIPE 29
|
|
44
|
+
#define EROFS 30
|
|
45
|
+
#define EMLINK 31
|
|
46
|
+
#define EPIPE 32
|
|
47
|
+
#define EDOM 33
|
|
48
|
+
#define ERANGE 34
|
|
49
|
+
#define EDEADLK 35
|
|
50
|
+
#define ENAMETOOLONG 36
|
|
51
|
+
#define ENOLCK 37
|
|
52
|
+
#define ENOSYS 38
|
|
53
|
+
#define ENOTEMPTY 39
|
|
54
|
+
#define ELOOP 40
|
|
55
|
+
#define ENOMSG 42
|
|
56
|
+
#define EIDRM 43
|
|
57
|
+
#define ECHRNG 44
|
|
58
|
+
#define EL2NSYNC 45
|
|
59
|
+
#define EL3HLT 46
|
|
60
|
+
#define EL3RST 47
|
|
61
|
+
#define ELNRNG 48
|
|
62
|
+
#define EUNATCH 49
|
|
63
|
+
#define ENOCSI 50
|
|
64
|
+
#define EL2HLT 51
|
|
65
|
+
#define EBADE 52
|
|
66
|
+
#define EBADR 53
|
|
67
|
+
#define EXFULL 54
|
|
68
|
+
#define ENOANO 55
|
|
69
|
+
#define EBADRQC 56
|
|
70
|
+
#define EBADSLT 57
|
|
71
|
+
#define EBFONT 59
|
|
72
|
+
#define ENOSTR 60
|
|
73
|
+
#define ENODATA 61
|
|
74
|
+
#define ETIME 62
|
|
75
|
+
#define ENOSR 63
|
|
76
|
+
#define ENONET 64
|
|
77
|
+
#define ENOPKG 65
|
|
78
|
+
#define EREMOTE 66
|
|
79
|
+
#define ENOLINK 67
|
|
80
|
+
#define EADV 68
|
|
81
|
+
#define ESRMNT 69
|
|
82
|
+
#define ECOMM 70
|
|
83
|
+
#define EPROTO 71
|
|
84
|
+
#define EMULTIHOP 72
|
|
85
|
+
#define EDOTDOT 73
|
|
86
|
+
#define EBADMSG 74
|
|
87
|
+
#define EOVERFLOW 75
|
|
88
|
+
#define ENOTUNIQ 76
|
|
89
|
+
#define EBADFD 77
|
|
90
|
+
#define EREMCHG 78
|
|
91
|
+
#define ELIBACC 79
|
|
92
|
+
#define ELIBBAD 80
|
|
93
|
+
#define ELIBSCN 81
|
|
94
|
+
#define ELIBMAX 82
|
|
95
|
+
#define ELIBEXEC 83
|
|
96
|
+
#define EILSEQ 84
|
|
97
|
+
#define ERESTART 85
|
|
98
|
+
#define ESTRPIPE 86
|
|
99
|
+
#define EUSERS 87
|
|
100
|
+
#define ENOTSOCK 88
|
|
101
|
+
#define EDESTADDRREQ 89
|
|
102
|
+
#define EMSGSIZE 90
|
|
103
|
+
#define EPROTOTYPE 91
|
|
104
|
+
#define ENOPROTOOPT 92
|
|
105
|
+
#define EPROTONOSUPPORT 93
|
|
106
|
+
#define ESOCKTNOSUPPORT 94
|
|
107
|
+
#define EOPNOTSUPP 95
|
|
108
|
+
#define EPFNOSUPPORT 96
|
|
109
|
+
#define EAFNOSUPPORT 97
|
|
110
|
+
#define EADDRINUSE 98
|
|
111
|
+
#define EADDRNOTAVAIL 99
|
|
112
|
+
#define ENETDOWN 100
|
|
113
|
+
#define ENETUNREACH 101
|
|
114
|
+
#define ENETRESET 102
|
|
115
|
+
#define ECONNABORTED 103
|
|
116
|
+
#define ECONNRESET 104
|
|
117
|
+
#define ENOBUFS 105
|
|
118
|
+
#define EISCONN 106
|
|
119
|
+
#define ENOTCONN 107
|
|
120
|
+
#define ESHUTDOWN 108
|
|
121
|
+
#define ETOOMANYREFS 109
|
|
122
|
+
#define ETIMEDOUT 110
|
|
123
|
+
#define ECONNREFUSED 111
|
|
124
|
+
#define EHOSTDOWN 112
|
|
125
|
+
#define EHOSTUNREACH 113
|
|
126
|
+
#define EALREADY 114
|
|
127
|
+
#define EINPROGRESS 115
|
|
128
|
+
#define ESTALE 116
|
|
129
|
+
#define EUCLEAN 117
|
|
130
|
+
#define ENOTNAM 118
|
|
131
|
+
#define ENAVAIL 119
|
|
132
|
+
#define EISNAM 120
|
|
133
|
+
#define EREMOTEIO 121
|
|
134
|
+
#define EDQUOT 122
|
|
135
|
+
#define ENOMEDIUM 123
|
|
136
|
+
#define EMEDIUMTYPE 124
|
|
137
|
+
#define ECANCELED 125
|
|
138
|
+
#define ENOKEY 126
|
|
139
|
+
#define EKEYEXPIRED 127
|
|
140
|
+
#define EKEYREVOKED 128
|
|
141
|
+
#define EKEYREJECTED 129
|
|
142
|
+
#define EOWNERDEAD 130
|
|
143
|
+
#define ENOTRECOVERABLE 131
|
|
144
|
+
#define ERFKILL 132
|
|
145
|
+
#define EHWPOISON 133
|
|
146
|
+
|
|
147
|
+
/* Common aliases. */
|
|
148
|
+
#define EWOULDBLOCK EAGAIN
|
|
149
|
+
#define EDEADLOCK EDEADLK
|
|
150
|
+
|
|
151
|
+
extern char *program_invocation_name;
|
|
152
|
+
extern char *program_invocation_short_name;
|
|
153
|
+
|
|
154
|
+
#endif /* _RUBYCC_ERRNO_H */
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/* rubycc bundled <fcntl.h>: the open/fcntl flag macros, the fcntl commands,
|
|
2
|
+
the *at family constants, and struct flock (POSIX). Provenance: clean room
|
|
3
|
+
against the Linux kernel UAPI (asm-generic/fcntl.h plus the arch-specific
|
|
4
|
+
uapi/asm/fcntl.h), not derived from musl. The O_*, F_* and AT_* values and
|
|
5
|
+
the struct flock layout are ABI facts reproduced as measured integers, not
|
|
6
|
+
copied text (see docs/HEADER-LICENSING.md) -- the same treatment as
|
|
7
|
+
errno.h and sys/stat.h. open/openat/creat/fcntl are POSIX declarations.
|
|
8
|
+
Placed in the glibc/x86-64 layer because O_DIRECT, O_DIRECTORY and
|
|
9
|
+
O_NOFOLLOW swap bit assignments against aarch64's uapi/asm/fcntl.h.
|
|
10
|
+
Two macros -- O_ACCMODE and O_LARGEFILE -- additionally differ between the
|
|
11
|
+
two C libraries; both measured values are carried below, selected by
|
|
12
|
+
__RUBYCC_LIBC_MUSL__ (see the preprocessor's LIBCS). */
|
|
13
|
+
|
|
14
|
+
#ifndef _RUBYCC_FCNTL_H
|
|
15
|
+
#define _RUBYCC_FCNTL_H
|
|
16
|
+
|
|
17
|
+
#ifndef _RUBYCC_MODE_T
|
|
18
|
+
#define _RUBYCC_MODE_T
|
|
19
|
+
typedef unsigned int mode_t;
|
|
20
|
+
#endif
|
|
21
|
+
#ifndef _RUBYCC_OFF_T
|
|
22
|
+
#define _RUBYCC_OFF_T
|
|
23
|
+
typedef long off_t;
|
|
24
|
+
#endif
|
|
25
|
+
#ifndef _RUBYCC_PID_T
|
|
26
|
+
#define _RUBYCC_PID_T
|
|
27
|
+
typedef int pid_t;
|
|
28
|
+
#endif
|
|
29
|
+
|
|
30
|
+
/* Access modes (octal). */
|
|
31
|
+
#define O_RDONLY 0
|
|
32
|
+
#define O_WRONLY 01
|
|
33
|
+
#define O_RDWR 02
|
|
34
|
+
/* O_ACCMODE is one of the two flag macros the two libcs disagree on: musl's
|
|
35
|
+
access-mode mask spans the O_PATH bit as well (measured 2097155, i.e.
|
|
36
|
+
010000003), glibc's is the low two bits only (measured 3, i.e. 03). Both
|
|
37
|
+
figures are measurements of the ABI harness, glibc's on this host and musl's
|
|
38
|
+
on the CI musl run (docs/STEPS.md Step 193), not values read off either
|
|
39
|
+
library's headers. */
|
|
40
|
+
#if defined(__RUBYCC_LIBC_MUSL__)
|
|
41
|
+
#define O_ACCMODE 010000003
|
|
42
|
+
#else
|
|
43
|
+
#define O_ACCMODE 03
|
|
44
|
+
#endif
|
|
45
|
+
|
|
46
|
+
/* Creation and status flags (octal, kernel ABI). */
|
|
47
|
+
#define O_CREAT 0100
|
|
48
|
+
#define O_EXCL 0200
|
|
49
|
+
#define O_NOCTTY 0400
|
|
50
|
+
#define O_TRUNC 01000
|
|
51
|
+
#define O_APPEND 02000
|
|
52
|
+
#define O_NONBLOCK 04000
|
|
53
|
+
#define O_NDELAY O_NONBLOCK
|
|
54
|
+
#define O_DSYNC 010000
|
|
55
|
+
#define O_ASYNC 020000
|
|
56
|
+
#define O_SYNC 04010000
|
|
57
|
+
#define O_RSYNC O_SYNC
|
|
58
|
+
#define O_CLOEXEC 02000000
|
|
59
|
+
/* O_LARGEFILE is the other flag macro the two libcs disagree on: musl hands
|
|
60
|
+
out the kernel's own large-file bit (measured 32768, i.e. 0100000) while
|
|
61
|
+
glibc, whose LP64 off_t is already 64-bit, leaves it empty (measured 0).
|
|
62
|
+
Both measured with the ABI harness, glibc's here and musl's on the CI musl
|
|
63
|
+
run (docs/STEPS.md Step 193). */
|
|
64
|
+
#if defined(__RUBYCC_LIBC_MUSL__)
|
|
65
|
+
#define O_LARGEFILE 0100000
|
|
66
|
+
#else
|
|
67
|
+
#define O_LARGEFILE 0
|
|
68
|
+
#endif
|
|
69
|
+
#define O_NOATIME 01000000
|
|
70
|
+
#define O_PATH 010000000
|
|
71
|
+
|
|
72
|
+
/* Arch-specific bits (kernel uapi/asm/fcntl.h): O_DIRECT/O_DIRECTORY/
|
|
73
|
+
O_NOFOLLOW swap values between x86-64 and aarch64. */
|
|
74
|
+
#define O_DIRECT 040000
|
|
75
|
+
#define O_DIRECTORY 0200000
|
|
76
|
+
#define O_NOFOLLOW 0400000
|
|
77
|
+
|
|
78
|
+
#define __O_TMPFILE 020000000
|
|
79
|
+
#define O_TMPFILE (__O_TMPFILE | O_DIRECTORY)
|
|
80
|
+
|
|
81
|
+
/* fcntl commands. */
|
|
82
|
+
#define F_DUPFD 0
|
|
83
|
+
#define F_GETFD 1
|
|
84
|
+
#define F_SETFD 2
|
|
85
|
+
#define F_GETFL 3
|
|
86
|
+
#define F_SETFL 4
|
|
87
|
+
#define F_GETLK 5
|
|
88
|
+
#define F_SETLK 6
|
|
89
|
+
#define F_SETLKW 7
|
|
90
|
+
#define F_SETOWN 8
|
|
91
|
+
#define F_GETOWN 9
|
|
92
|
+
#define F_DUPFD_CLOEXEC 1030
|
|
93
|
+
/* Linux pipe-buffer sizing (Fcntl exposes both). Measured on this target
|
|
94
|
+
rather than derived: 1024 + 7 and 1024 + 8 off the Linux-specific base,
|
|
95
|
+
the same pair on x86-64 and aarch64. */
|
|
96
|
+
#define F_SETPIPE_SZ 1031
|
|
97
|
+
#define F_GETPIPE_SZ 1032
|
|
98
|
+
|
|
99
|
+
/* FD_CLOEXEC: the sole close-on-exec bit for F_GETFD/F_SETFD. */
|
|
100
|
+
#define FD_CLOEXEC 1
|
|
101
|
+
|
|
102
|
+
/* struct flock l_type / l_whence values. */
|
|
103
|
+
#define F_RDLCK 0
|
|
104
|
+
#define F_WRLCK 1
|
|
105
|
+
#define F_UNLCK 2
|
|
106
|
+
|
|
107
|
+
/* *at family flags. */
|
|
108
|
+
#define AT_FDCWD (-100)
|
|
109
|
+
#define AT_SYMLINK_NOFOLLOW 0x100
|
|
110
|
+
#define AT_REMOVEDIR 0x200
|
|
111
|
+
#define AT_SYMLINK_FOLLOW 0x400
|
|
112
|
+
#define AT_EACCESS 0x200
|
|
113
|
+
|
|
114
|
+
#ifndef SEEK_SET
|
|
115
|
+
#define SEEK_SET 0
|
|
116
|
+
#define SEEK_CUR 1
|
|
117
|
+
#define SEEK_END 2
|
|
118
|
+
#endif
|
|
119
|
+
|
|
120
|
+
/* struct flock: 32 bytes, 8-byte aligned (LP64, measured). */
|
|
121
|
+
struct flock {
|
|
122
|
+
short l_type;
|
|
123
|
+
short l_whence;
|
|
124
|
+
off_t l_start;
|
|
125
|
+
off_t l_len;
|
|
126
|
+
pid_t l_pid;
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
int open(const char *__file, int __oflag, ...);
|
|
130
|
+
int openat(int __fd, const char *__file, int __oflag, ...);
|
|
131
|
+
int creat(const char *__file, mode_t __mode);
|
|
132
|
+
int fcntl(int __fd, int __cmd, ...);
|
|
133
|
+
|
|
134
|
+
#endif /* _RUBYCC_FCNTL_H */
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
/* rubycc bundled <inttypes.h>: the <stdint.h> types plus the printf/scanf
|
|
2
|
+
format-specifier macros (ISO C 7.8) and the greatest-width integer calls.
|
|
3
|
+
Derived from musl's <inttypes.h> shape; the PRI and SCN length modifiers are
|
|
4
|
+
pinned to the glibc x86-64 LP64 ABI (the 64-bit, MAX, PTR and fast16+ forms
|
|
5
|
+
use "l", measured). ABI switch layer: the format widths track the type
|
|
6
|
+
widths, which are arch specific. */
|
|
7
|
+
|
|
8
|
+
#ifndef _RUBYCC_INTTYPES_H
|
|
9
|
+
#define _RUBYCC_INTTYPES_H
|
|
10
|
+
|
|
11
|
+
#include <stdint.h>
|
|
12
|
+
|
|
13
|
+
#ifndef _RUBYCC_WCHAR_T
|
|
14
|
+
#define _RUBYCC_WCHAR_T
|
|
15
|
+
typedef int wchar_t;
|
|
16
|
+
#endif
|
|
17
|
+
|
|
18
|
+
typedef struct { intmax_t quot; intmax_t rem; } imaxdiv_t;
|
|
19
|
+
|
|
20
|
+
#define PRId8 "d"
|
|
21
|
+
#define PRId16 "d"
|
|
22
|
+
#define PRId32 "d"
|
|
23
|
+
#define PRId64 "ld"
|
|
24
|
+
#define PRIdLEAST8 "d"
|
|
25
|
+
#define PRIdLEAST16 "d"
|
|
26
|
+
#define PRIdLEAST32 "d"
|
|
27
|
+
#define PRIdLEAST64 "ld"
|
|
28
|
+
#define PRIdFAST8 "d"
|
|
29
|
+
#define PRIdFAST16 "ld"
|
|
30
|
+
#define PRIdFAST32 "ld"
|
|
31
|
+
#define PRIdFAST64 "ld"
|
|
32
|
+
#define PRIdMAX "ld"
|
|
33
|
+
#define PRIdPTR "ld"
|
|
34
|
+
#define PRIi8 "i"
|
|
35
|
+
#define PRIi16 "i"
|
|
36
|
+
#define PRIi32 "i"
|
|
37
|
+
#define PRIi64 "li"
|
|
38
|
+
#define PRIiLEAST8 "i"
|
|
39
|
+
#define PRIiLEAST16 "i"
|
|
40
|
+
#define PRIiLEAST32 "i"
|
|
41
|
+
#define PRIiLEAST64 "li"
|
|
42
|
+
#define PRIiFAST8 "i"
|
|
43
|
+
#define PRIiFAST16 "li"
|
|
44
|
+
#define PRIiFAST32 "li"
|
|
45
|
+
#define PRIiFAST64 "li"
|
|
46
|
+
#define PRIiMAX "li"
|
|
47
|
+
#define PRIiPTR "li"
|
|
48
|
+
#define PRIo8 "o"
|
|
49
|
+
#define PRIo16 "o"
|
|
50
|
+
#define PRIo32 "o"
|
|
51
|
+
#define PRIo64 "lo"
|
|
52
|
+
#define PRIoLEAST8 "o"
|
|
53
|
+
#define PRIoLEAST16 "o"
|
|
54
|
+
#define PRIoLEAST32 "o"
|
|
55
|
+
#define PRIoLEAST64 "lo"
|
|
56
|
+
#define PRIoFAST8 "o"
|
|
57
|
+
#define PRIoFAST16 "lo"
|
|
58
|
+
#define PRIoFAST32 "lo"
|
|
59
|
+
#define PRIoFAST64 "lo"
|
|
60
|
+
#define PRIoMAX "lo"
|
|
61
|
+
#define PRIoPTR "lo"
|
|
62
|
+
#define PRIu8 "u"
|
|
63
|
+
#define PRIu16 "u"
|
|
64
|
+
#define PRIu32 "u"
|
|
65
|
+
#define PRIu64 "lu"
|
|
66
|
+
#define PRIuLEAST8 "u"
|
|
67
|
+
#define PRIuLEAST16 "u"
|
|
68
|
+
#define PRIuLEAST32 "u"
|
|
69
|
+
#define PRIuLEAST64 "lu"
|
|
70
|
+
#define PRIuFAST8 "u"
|
|
71
|
+
#define PRIuFAST16 "lu"
|
|
72
|
+
#define PRIuFAST32 "lu"
|
|
73
|
+
#define PRIuFAST64 "lu"
|
|
74
|
+
#define PRIuMAX "lu"
|
|
75
|
+
#define PRIuPTR "lu"
|
|
76
|
+
#define PRIx8 "x"
|
|
77
|
+
#define PRIx16 "x"
|
|
78
|
+
#define PRIx32 "x"
|
|
79
|
+
#define PRIx64 "lx"
|
|
80
|
+
#define PRIxLEAST8 "x"
|
|
81
|
+
#define PRIxLEAST16 "x"
|
|
82
|
+
#define PRIxLEAST32 "x"
|
|
83
|
+
#define PRIxLEAST64 "lx"
|
|
84
|
+
#define PRIxFAST8 "x"
|
|
85
|
+
#define PRIxFAST16 "lx"
|
|
86
|
+
#define PRIxFAST32 "lx"
|
|
87
|
+
#define PRIxFAST64 "lx"
|
|
88
|
+
#define PRIxMAX "lx"
|
|
89
|
+
#define PRIxPTR "lx"
|
|
90
|
+
#define PRIX8 "X"
|
|
91
|
+
#define PRIX16 "X"
|
|
92
|
+
#define PRIX32 "X"
|
|
93
|
+
#define PRIX64 "lX"
|
|
94
|
+
#define PRIXLEAST8 "X"
|
|
95
|
+
#define PRIXLEAST16 "X"
|
|
96
|
+
#define PRIXLEAST32 "X"
|
|
97
|
+
#define PRIXLEAST64 "lX"
|
|
98
|
+
#define PRIXFAST8 "X"
|
|
99
|
+
#define PRIXFAST16 "lX"
|
|
100
|
+
#define PRIXFAST32 "lX"
|
|
101
|
+
#define PRIXFAST64 "lX"
|
|
102
|
+
#define PRIXMAX "lX"
|
|
103
|
+
#define PRIXPTR "lX"
|
|
104
|
+
#define SCNd8 "hhd"
|
|
105
|
+
#define SCNd16 "hd"
|
|
106
|
+
#define SCNd32 "d"
|
|
107
|
+
#define SCNd64 "ld"
|
|
108
|
+
#define SCNdLEAST8 "hhd"
|
|
109
|
+
#define SCNdLEAST16 "hd"
|
|
110
|
+
#define SCNdLEAST32 "d"
|
|
111
|
+
#define SCNdLEAST64 "ld"
|
|
112
|
+
#define SCNdFAST8 "hhd"
|
|
113
|
+
#define SCNdFAST16 "ld"
|
|
114
|
+
#define SCNdFAST32 "ld"
|
|
115
|
+
#define SCNdFAST64 "ld"
|
|
116
|
+
#define SCNdMAX "ld"
|
|
117
|
+
#define SCNdPTR "ld"
|
|
118
|
+
#define SCNi8 "hhi"
|
|
119
|
+
#define SCNi16 "hi"
|
|
120
|
+
#define SCNi32 "i"
|
|
121
|
+
#define SCNi64 "li"
|
|
122
|
+
#define SCNiLEAST8 "hhi"
|
|
123
|
+
#define SCNiLEAST16 "hi"
|
|
124
|
+
#define SCNiLEAST32 "i"
|
|
125
|
+
#define SCNiLEAST64 "li"
|
|
126
|
+
#define SCNiFAST8 "hhi"
|
|
127
|
+
#define SCNiFAST16 "li"
|
|
128
|
+
#define SCNiFAST32 "li"
|
|
129
|
+
#define SCNiFAST64 "li"
|
|
130
|
+
#define SCNiMAX "li"
|
|
131
|
+
#define SCNiPTR "li"
|
|
132
|
+
#define SCNo8 "hho"
|
|
133
|
+
#define SCNo16 "ho"
|
|
134
|
+
#define SCNo32 "o"
|
|
135
|
+
#define SCNo64 "lo"
|
|
136
|
+
#define SCNoLEAST8 "hho"
|
|
137
|
+
#define SCNoLEAST16 "ho"
|
|
138
|
+
#define SCNoLEAST32 "o"
|
|
139
|
+
#define SCNoLEAST64 "lo"
|
|
140
|
+
#define SCNoFAST8 "hho"
|
|
141
|
+
#define SCNoFAST16 "lo"
|
|
142
|
+
#define SCNoFAST32 "lo"
|
|
143
|
+
#define SCNoFAST64 "lo"
|
|
144
|
+
#define SCNoMAX "lo"
|
|
145
|
+
#define SCNoPTR "lo"
|
|
146
|
+
#define SCNu8 "hhu"
|
|
147
|
+
#define SCNu16 "hu"
|
|
148
|
+
#define SCNu32 "u"
|
|
149
|
+
#define SCNu64 "lu"
|
|
150
|
+
#define SCNuLEAST8 "hhu"
|
|
151
|
+
#define SCNuLEAST16 "hu"
|
|
152
|
+
#define SCNuLEAST32 "u"
|
|
153
|
+
#define SCNuLEAST64 "lu"
|
|
154
|
+
#define SCNuFAST8 "hhu"
|
|
155
|
+
#define SCNuFAST16 "lu"
|
|
156
|
+
#define SCNuFAST32 "lu"
|
|
157
|
+
#define SCNuFAST64 "lu"
|
|
158
|
+
#define SCNuMAX "lu"
|
|
159
|
+
#define SCNuPTR "lu"
|
|
160
|
+
#define SCNx8 "hhx"
|
|
161
|
+
#define SCNx16 "hx"
|
|
162
|
+
#define SCNx32 "x"
|
|
163
|
+
#define SCNx64 "lx"
|
|
164
|
+
#define SCNxLEAST8 "hhx"
|
|
165
|
+
#define SCNxLEAST16 "hx"
|
|
166
|
+
#define SCNxLEAST32 "x"
|
|
167
|
+
#define SCNxLEAST64 "lx"
|
|
168
|
+
#define SCNxFAST8 "hhx"
|
|
169
|
+
#define SCNxFAST16 "lx"
|
|
170
|
+
#define SCNxFAST32 "lx"
|
|
171
|
+
#define SCNxFAST64 "lx"
|
|
172
|
+
#define SCNxMAX "lx"
|
|
173
|
+
#define SCNxPTR "lx"
|
|
174
|
+
|
|
175
|
+
intmax_t imaxabs(intmax_t __n);
|
|
176
|
+
imaxdiv_t imaxdiv(intmax_t __numer, intmax_t __denom);
|
|
177
|
+
intmax_t strtoimax(const char *__restrict __nptr, char **__restrict __endptr, int __base);
|
|
178
|
+
uintmax_t strtoumax(const char *__restrict __nptr, char **__restrict __endptr, int __base);
|
|
179
|
+
intmax_t wcstoimax(const wchar_t *__restrict __nptr, wchar_t **__restrict __endptr, int __base);
|
|
180
|
+
uintmax_t wcstoumax(const wchar_t *__restrict __nptr, wchar_t **__restrict __endptr, int __base);
|
|
181
|
+
|
|
182
|
+
#endif /* _RUBYCC_INTTYPES_H */
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/* rubycc bundled <limits.h>: the arithmetic-type ranges (ISO C 5.2.4.2.1).
|
|
2
|
+
Derived from the ISO-mandated values with the `long`/`char` widths pinned to
|
|
3
|
+
the x86-64 LP64 ABI (`long` is 64-bit); the arithmetic ranges are the same
|
|
4
|
+
under either C library, and only MB_LEN_MAX differs between them (carried
|
|
5
|
+
below under __RUBYCC_LIBC_MUSL__, see the preprocessor's LIBCS). ABI switch
|
|
6
|
+
layer: LONG_MAX is arch specific, and so is the signedness of plain char --
|
|
7
|
+
that one is taken from the compiler's own __CHAR_UNSIGNED__ rather than from
|
|
8
|
+
this directory. */
|
|
9
|
+
|
|
10
|
+
#ifndef _RUBYCC_LIMITS_H
|
|
11
|
+
#define _RUBYCC_LIMITS_H
|
|
12
|
+
|
|
13
|
+
#define CHAR_BIT 8
|
|
14
|
+
/* MB_LEN_MAX is the one value in this header the two C libraries disagree on:
|
|
15
|
+
musl reports 4 (its widest multibyte character, UTF-8's four bytes) and glibc
|
|
16
|
+
16. Both measured with the ABI harness, glibc's on this host and musl's on
|
|
17
|
+
the CI musl run (docs/STEPS.md Step 193). */
|
|
18
|
+
#if defined(__RUBYCC_LIBC_MUSL__)
|
|
19
|
+
#define MB_LEN_MAX 4
|
|
20
|
+
#else
|
|
21
|
+
#define MB_LEN_MAX 16
|
|
22
|
+
#endif
|
|
23
|
+
|
|
24
|
+
#define SCHAR_MIN (-128)
|
|
25
|
+
#define SCHAR_MAX 127
|
|
26
|
+
#define UCHAR_MAX 255
|
|
27
|
+
|
|
28
|
+
/* Plain char's signedness is implementation-defined and pinned per ABI: signed
|
|
29
|
+
on the x86-64 SysV ABI, unsigned on AAPCS64. rubycc predefines
|
|
30
|
+
__CHAR_UNSIGNED__ on a target of the latter kind (as gcc does), so the range
|
|
31
|
+
follows the compilation target rather than this header's directory. */
|
|
32
|
+
#ifdef __CHAR_UNSIGNED__
|
|
33
|
+
#define CHAR_MIN 0
|
|
34
|
+
#define CHAR_MAX UCHAR_MAX
|
|
35
|
+
#else
|
|
36
|
+
#define CHAR_MIN SCHAR_MIN
|
|
37
|
+
#define CHAR_MAX SCHAR_MAX
|
|
38
|
+
#endif
|
|
39
|
+
|
|
40
|
+
#define SHRT_MIN (-32768)
|
|
41
|
+
#define SHRT_MAX 32767
|
|
42
|
+
#define USHRT_MAX 65535
|
|
43
|
+
|
|
44
|
+
#define INT_MIN (-INT_MAX-1)
|
|
45
|
+
#define INT_MAX 2147483647
|
|
46
|
+
#define UINT_MAX 4294967295U
|
|
47
|
+
|
|
48
|
+
#define LONG_MIN (-LONG_MAX-1L)
|
|
49
|
+
#define LONG_MAX 9223372036854775807L
|
|
50
|
+
#define ULONG_MAX 18446744073709551615UL
|
|
51
|
+
|
|
52
|
+
#define LLONG_MIN (-LLONG_MAX-1LL)
|
|
53
|
+
#define LLONG_MAX 9223372036854775807LL
|
|
54
|
+
#define ULLONG_MAX 18446744073709551615ULL
|
|
55
|
+
|
|
56
|
+
/* GNU spellings some code still uses. */
|
|
57
|
+
#define LONG_LONG_MIN LLONG_MIN
|
|
58
|
+
#define LONG_LONG_MAX LLONG_MAX
|
|
59
|
+
#define ULONG_LONG_MAX ULLONG_MAX
|
|
60
|
+
|
|
61
|
+
#endif /* _RUBYCC_LIMITS_H */
|