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.
Files changed (159) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +56 -0
  3. data/LICENSE.txt +21 -0
  4. data/NOTICE +52 -0
  5. data/README.md +208 -0
  6. data/data/README.md +117 -0
  7. data/data/r10_corpus_scan.json +4082 -0
  8. data/data/r10_manual_classification.json +5342 -0
  9. data/data/r10_verification_m4a.json +1531 -0
  10. data/data/r10_verification_m4b.json +1818 -0
  11. data/data/r10_verification_m4c.json +1489 -0
  12. data/data/r10_verification_m4d.json +318 -0
  13. data/data/r10_verification_rbs.json +192 -0
  14. data/data/verified_gems.json +397 -0
  15. data/exe/rmake +16 -0
  16. data/exe/rubycc +9 -0
  17. data/exe/rubycc-ar +114 -0
  18. data/exe/rubycc-doctor +14 -0
  19. data/exe/rubycc-pkgconf +8 -0
  20. data/include/float.h +87 -0
  21. data/include/iso646.h +18 -0
  22. data/include/libc/alloca.h +18 -0
  23. data/include/libc/arpa/inet.h +61 -0
  24. data/include/libc/assert.h +43 -0
  25. data/include/libc/dirent.h +72 -0
  26. data/include/libc/dlfcn.h +58 -0
  27. data/include/libc/features.h +205 -0
  28. data/include/libc/glibc/aarch64/ctype.h +108 -0
  29. data/include/libc/glibc/aarch64/endian.h +54 -0
  30. data/include/libc/glibc/aarch64/errno.h +154 -0
  31. data/include/libc/glibc/aarch64/fcntl.h +144 -0
  32. data/include/libc/glibc/aarch64/inttypes.h +182 -0
  33. data/include/libc/glibc/aarch64/limits.h +63 -0
  34. data/include/libc/glibc/aarch64/pthread.h +131 -0
  35. data/include/libc/glibc/aarch64/setjmp.h +84 -0
  36. data/include/libc/glibc/aarch64/stdint.h +174 -0
  37. data/include/libc/glibc/aarch64/sys/epoll.h +88 -0
  38. data/include/libc/glibc/aarch64/sys/fcntl.h +19 -0
  39. data/include/libc/glibc/aarch64/sys/select.h +75 -0
  40. data/include/libc/glibc/aarch64/sys/stat.h +136 -0
  41. data/include/libc/glibc/aarch64/sys/syscall.h +167 -0
  42. data/include/libc/glibc/aarch64/sys/time.h +74 -0
  43. data/include/libc/glibc/aarch64/sys/types.h +127 -0
  44. data/include/libc/glibc/aarch64/time.h +113 -0
  45. data/include/libc/glibc/x86_64/ctype.h +108 -0
  46. data/include/libc/glibc/x86_64/endian.h +54 -0
  47. data/include/libc/glibc/x86_64/errno.h +154 -0
  48. data/include/libc/glibc/x86_64/fcntl.h +134 -0
  49. data/include/libc/glibc/x86_64/inttypes.h +182 -0
  50. data/include/libc/glibc/x86_64/limits.h +61 -0
  51. data/include/libc/glibc/x86_64/pthread.h +111 -0
  52. data/include/libc/glibc/x86_64/setjmp.h +82 -0
  53. data/include/libc/glibc/x86_64/stdint.h +163 -0
  54. data/include/libc/glibc/x86_64/sys/epoll.h +91 -0
  55. data/include/libc/glibc/x86_64/sys/fcntl.h +19 -0
  56. data/include/libc/glibc/x86_64/sys/select.h +75 -0
  57. data/include/libc/glibc/x86_64/sys/stat.h +130 -0
  58. data/include/libc/glibc/x86_64/sys/syscall.h +188 -0
  59. data/include/libc/glibc/x86_64/sys/time.h +74 -0
  60. data/include/libc/glibc/x86_64/sys/types.h +123 -0
  61. data/include/libc/glibc/x86_64/time.h +113 -0
  62. data/include/libc/grp.h +50 -0
  63. data/include/libc/langinfo.h +126 -0
  64. data/include/libc/link.h +18 -0
  65. data/include/libc/locale.h +83 -0
  66. data/include/libc/math.h +191 -0
  67. data/include/libc/netinet/in.h +126 -0
  68. data/include/libc/netinet/tcp.h +44 -0
  69. data/include/libc/poll.h +46 -0
  70. data/include/libc/pwd.h +58 -0
  71. data/include/libc/regex.h +53 -0
  72. data/include/libc/sched.h +35 -0
  73. data/include/libc/signal.h +204 -0
  74. data/include/libc/stdio.h +157 -0
  75. data/include/libc/stdlib.h +92 -0
  76. data/include/libc/string.h +74 -0
  77. data/include/libc/strings.h +25 -0
  78. data/include/libc/sys/cdefs.h +126 -0
  79. data/include/libc/sys/inotify.h +111 -0
  80. data/include/libc/sys/ioctl.h +36 -0
  81. data/include/libc/sys/mman.h +65 -0
  82. data/include/libc/sys/param.h +41 -0
  83. data/include/libc/sys/resource.h +109 -0
  84. data/include/libc/sys/socket.h +167 -0
  85. data/include/libc/sys/statfs.h +82 -0
  86. data/include/libc/sys/timerfd.h +55 -0
  87. data/include/libc/sys/uio.h +40 -0
  88. data/include/libc/sys/un.h +25 -0
  89. data/include/libc/sys/utsname.h +35 -0
  90. data/include/libc/sys/wait.h +135 -0
  91. data/include/libc/termios.h +179 -0
  92. data/include/libc/unistd.h +194 -0
  93. data/include/stdalign.h +16 -0
  94. data/include/stdarg.h +31 -0
  95. data/include/stdatomic.h +158 -0
  96. data/include/stdbool.h +15 -0
  97. data/include/stdckdint.h +28 -0
  98. data/include/stddef.h +60 -0
  99. data/include/stdnoreturn.h +18 -0
  100. data/include/x86intrin.h +16 -0
  101. data/lib/rubycc/backend/aarch64.rb +1724 -0
  102. data/lib/rubycc/backend/x86_64.rb +1369 -0
  103. data/lib/rubycc/compile_error.rb +36 -0
  104. data/lib/rubycc/compiler.rb +305 -0
  105. data/lib/rubycc/doctor/builder.rb +151 -0
  106. data/lib/rubycc/doctor/cli.rb +190 -0
  107. data/lib/rubycc/doctor/fetcher.rb +84 -0
  108. data/lib/rubycc/doctor/gemfile.rb +115 -0
  109. data/lib/rubycc/doctor/verified_gems.rb +114 -0
  110. data/lib/rubycc/doctor.rb +16 -0
  111. data/lib/rubycc/driver.rb +463 -0
  112. data/lib/rubycc/front/ast.rb +528 -0
  113. data/lib/rubycc/front/constant_evaluator.rb +631 -0
  114. data/lib/rubycc/front/initializer_resolver.rb +592 -0
  115. data/lib/rubycc/front/lexeme_reader.rb +460 -0
  116. data/lib/rubycc/front/lexer.rb +232 -0
  117. data/lib/rubycc/front/parser.rb +4122 -0
  118. data/lib/rubycc/front/token.rb +49 -0
  119. data/lib/rubycc/ir/call_convention.rb +486 -0
  120. data/lib/rubycc/ir/generator.rb +6036 -0
  121. data/lib/rubycc/ir/ir.rb +417 -0
  122. data/lib/rubycc/link/compat_runtime.rb +89 -0
  123. data/lib/rubycc/link/errors.rb +13 -0
  124. data/lib/rubycc/link/executable_linker.rb +405 -0
  125. data/lib/rubycc/link/library_resolver.rb +437 -0
  126. data/lib/rubycc/link/partial_linker.rb +546 -0
  127. data/lib/rubycc/link/shared_linker.rb +1732 -0
  128. data/lib/rubycc/mkmf_shim.rb +83 -0
  129. data/lib/rubycc/objfile/ar_archive.rb +437 -0
  130. data/lib/rubycc/objfile/elf_reader.rb +646 -0
  131. data/lib/rubycc/objfile/elf_writer.rb +891 -0
  132. data/lib/rubycc/objfile/relocatable_writer.rb +376 -0
  133. data/lib/rubycc/pkgconf/cli.rb +139 -0
  134. data/lib/rubycc/pkgconf/errors.rb +39 -0
  135. data/lib/rubycc/pkgconf/model.rb +28 -0
  136. data/lib/rubycc/pkgconf/parser.rb +109 -0
  137. data/lib/rubycc/pkgconf/pkgconf.rb +15 -0
  138. data/lib/rubycc/pkgconf/resolver.rb +70 -0
  139. data/lib/rubycc/pkgconf/search_path.rb +38 -0
  140. data/lib/rubycc/pkgconf/system_path_filter.rb +131 -0
  141. data/lib/rubycc/preprocess/constant_expression.rb +219 -0
  142. data/lib/rubycc/preprocess/glibc_version.rb +124 -0
  143. data/lib/rubycc/preprocess/pp_token.rb +62 -0
  144. data/lib/rubycc/preprocess/preprocessor.rb +2020 -0
  145. data/lib/rubycc/preprocess/scanner.rb +290 -0
  146. data/lib/rubycc/preprocess/token_converter.rb +157 -0
  147. data/lib/rubycc/rmake/cli.rb +143 -0
  148. data/lib/rubycc/rmake/errors.rb +71 -0
  149. data/lib/rubycc/rmake/executor.rb +818 -0
  150. data/lib/rubycc/rmake/expander.rb +251 -0
  151. data/lib/rubycc/rmake/makefile.rb +352 -0
  152. data/lib/rubycc/rmake/model.rb +137 -0
  153. data/lib/rubycc/rmake/parser.rb +226 -0
  154. data/lib/rubycc/rmake/rmake.rb +15 -0
  155. data/lib/rubycc/type.rb +1236 -0
  156. data/lib/rubycc/version.rb +5 -0
  157. data/lib/rubycc.rb +36 -0
  158. data/lib/rubygems_plugin.rb +102 -0
  159. metadata +219 -0
@@ -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/aarch64 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,144 @@
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/aarch64 layer because O_DIRECT, O_DIRECTORY and
9
+ O_NOFOLLOW swap bit assignments here versus x86-64'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). This is also the layer
13
+ that exists precisely because values move between machines -- the O_DIRECT
14
+ group below is the standing proof, and O_LARGEFILE is a second one: musl's
15
+ figure here (131072, i.e. 0400000) is not musl's x86-64 figure (32768,
16
+ i.e. 0100000). Had this file copied the x86-64 companion's musl value
17
+ instead of measuring its own, it would have been wrong. */
18
+
19
+ #ifndef _RUBYCC_FCNTL_H
20
+ #define _RUBYCC_FCNTL_H
21
+
22
+ #ifndef _RUBYCC_MODE_T
23
+ #define _RUBYCC_MODE_T
24
+ typedef unsigned int mode_t;
25
+ #endif
26
+ #ifndef _RUBYCC_OFF_T
27
+ #define _RUBYCC_OFF_T
28
+ typedef long off_t;
29
+ #endif
30
+ #ifndef _RUBYCC_PID_T
31
+ #define _RUBYCC_PID_T
32
+ typedef int pid_t;
33
+ #endif
34
+
35
+ /* Access modes (octal). */
36
+ #define O_RDONLY 0
37
+ #define O_WRONLY 01
38
+ #define O_RDWR 02
39
+ /* O_ACCMODE is one of the two flag macros the two libcs disagree on: musl's
40
+ access-mode mask spans the O_PATH bit as well (measured 2097155, i.e.
41
+ 010000003), glibc's is the low two bits only (measured 3, i.e. 03) -- the
42
+ same pair the x86-64 companion carries, and measured identically here
43
+ (docs/STEPS.md Step 202), not merely assumed to match it (R8). Both
44
+ figures are measurements of the ABI harness, glibc's on this host and
45
+ musl's on the CI aarch64 musl run. */
46
+ #if defined(__RUBYCC_LIBC_MUSL__)
47
+ #define O_ACCMODE 010000003
48
+ #else
49
+ #define O_ACCMODE 03
50
+ #endif
51
+
52
+ /* Creation and status flags (octal, kernel ABI). */
53
+ #define O_CREAT 0100
54
+ #define O_EXCL 0200
55
+ #define O_NOCTTY 0400
56
+ #define O_TRUNC 01000
57
+ #define O_APPEND 02000
58
+ #define O_NONBLOCK 04000
59
+ #define O_NDELAY O_NONBLOCK
60
+ #define O_DSYNC 010000
61
+ #define O_ASYNC 020000
62
+ #define O_SYNC 04010000
63
+ #define O_RSYNC O_SYNC
64
+ #define O_CLOEXEC 02000000
65
+ /* O_LARGEFILE is the other flag macro the two libcs disagree on: musl hands
66
+ out the kernel's own large-file bit (measured 131072, i.e. 0400000) while
67
+ glibc, whose LP64 off_t is already 64-bit, leaves it empty (measured 0).
68
+ Unlike O_ACCMODE above, this is NOT the x86-64 companion's musl figure
69
+ (32768, i.e. 0100000): the large-file bit's position is arch specific, the
70
+ same way O_DIRECT/O_DIRECTORY/O_NOFOLLOW are, so copying x86-64's value here
71
+ would have been wrong rather than merely unmeasured (R8). Both measured
72
+ with the ABI harness, glibc's here and musl's on the CI aarch64 musl run
73
+ (docs/STEPS.md Step 202). */
74
+ #if defined(__RUBYCC_LIBC_MUSL__)
75
+ #define O_LARGEFILE 0400000
76
+ #else
77
+ #define O_LARGEFILE 0
78
+ #endif
79
+ #define O_NOATIME 01000000
80
+ #define O_PATH 010000000
81
+
82
+ /* Arch-specific bits (kernel uapi/asm/fcntl.h): O_DIRECT/O_DIRECTORY/
83
+ O_NOFOLLOW swap values here versus x86-64. */
84
+ #define O_DIRECT 0200000
85
+ #define O_DIRECTORY 040000
86
+ #define O_NOFOLLOW 0100000
87
+
88
+ #define __O_TMPFILE 020000000
89
+ #define O_TMPFILE (__O_TMPFILE | O_DIRECTORY)
90
+
91
+ /* fcntl commands. */
92
+ #define F_DUPFD 0
93
+ #define F_GETFD 1
94
+ #define F_SETFD 2
95
+ #define F_GETFL 3
96
+ #define F_SETFL 4
97
+ #define F_GETLK 5
98
+ #define F_SETLK 6
99
+ #define F_SETLKW 7
100
+ #define F_SETOWN 8
101
+ #define F_GETOWN 9
102
+ #define F_DUPFD_CLOEXEC 1030
103
+ /* Linux pipe-buffer sizing (Fcntl exposes both). Measured on this target
104
+ rather than derived: 1024 + 7 and 1024 + 8 off the Linux-specific base,
105
+ the same pair on x86-64 and aarch64. */
106
+ #define F_SETPIPE_SZ 1031
107
+ #define F_GETPIPE_SZ 1032
108
+
109
+ /* FD_CLOEXEC: the sole close-on-exec bit for F_GETFD/F_SETFD. */
110
+ #define FD_CLOEXEC 1
111
+
112
+ /* struct flock l_type / l_whence values. */
113
+ #define F_RDLCK 0
114
+ #define F_WRLCK 1
115
+ #define F_UNLCK 2
116
+
117
+ /* *at family flags. */
118
+ #define AT_FDCWD (-100)
119
+ #define AT_SYMLINK_NOFOLLOW 0x100
120
+ #define AT_REMOVEDIR 0x200
121
+ #define AT_SYMLINK_FOLLOW 0x400
122
+ #define AT_EACCESS 0x200
123
+
124
+ #ifndef SEEK_SET
125
+ #define SEEK_SET 0
126
+ #define SEEK_CUR 1
127
+ #define SEEK_END 2
128
+ #endif
129
+
130
+ /* struct flock: 32 bytes, 8-byte aligned (LP64, measured). */
131
+ struct flock {
132
+ short l_type;
133
+ short l_whence;
134
+ off_t l_start;
135
+ off_t l_len;
136
+ pid_t l_pid;
137
+ };
138
+
139
+ int open(const char *__file, int __oflag, ...);
140
+ int openat(int __fd, const char *__file, int __oflag, ...);
141
+ int creat(const char *__file, mode_t __mode);
142
+ int fcntl(int __fd, int __cmd, ...);
143
+
144
+ #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,63 @@
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 glibc x86-64 LP64 ABI (`long` is 64-bit); the arithmetic ranges are the
4
+ same under either C library, and only MB_LEN_MAX differs between them
5
+ (carried below under __RUBYCC_LIBC_MUSL__, see the preprocessor's LIBCS).
6
+ ABI switch layer: LONG_MAX is arch specific, and so is the signedness of
7
+ plain char -- that one is taken from the compiler's own __CHAR_UNSIGNED__
8
+ rather than from 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
16
+ glibc 16, the same pair the x86-64 companion carries -- but not copied from
17
+ it (a value's identity across two machines is a coincidence, not a rule
18
+ this layer may assume, R8): measured directly on the CI aarch64 musl run
19
+ (docs/STEPS.md Step 202), with glibc's on this host. */
20
+ #if defined(__RUBYCC_LIBC_MUSL__)
21
+ #define MB_LEN_MAX 4
22
+ #else
23
+ #define MB_LEN_MAX 16
24
+ #endif
25
+
26
+ #define SCHAR_MIN (-128)
27
+ #define SCHAR_MAX 127
28
+ #define UCHAR_MAX 255
29
+
30
+ /* Plain char's signedness is implementation-defined and pinned per ABI: signed
31
+ on the x86-64 SysV ABI, unsigned on AAPCS64. rubycc predefines
32
+ __CHAR_UNSIGNED__ on a target of the latter kind (as gcc does), so the range
33
+ follows the compilation target rather than this header's directory. */
34
+ #ifdef __CHAR_UNSIGNED__
35
+ #define CHAR_MIN 0
36
+ #define CHAR_MAX UCHAR_MAX
37
+ #else
38
+ #define CHAR_MIN SCHAR_MIN
39
+ #define CHAR_MAX SCHAR_MAX
40
+ #endif
41
+
42
+ #define SHRT_MIN (-32768)
43
+ #define SHRT_MAX 32767
44
+ #define USHRT_MAX 65535
45
+
46
+ #define INT_MIN (-INT_MAX-1)
47
+ #define INT_MAX 2147483647
48
+ #define UINT_MAX 4294967295U
49
+
50
+ #define LONG_MIN (-LONG_MAX-1L)
51
+ #define LONG_MAX 9223372036854775807L
52
+ #define ULONG_MAX 18446744073709551615UL
53
+
54
+ #define LLONG_MIN (-LLONG_MAX-1LL)
55
+ #define LLONG_MAX 9223372036854775807LL
56
+ #define ULLONG_MAX 18446744073709551615ULL
57
+
58
+ /* GNU spellings some code still uses. */
59
+ #define LONG_LONG_MIN LLONG_MIN
60
+ #define LONG_LONG_MAX LLONG_MAX
61
+ #define ULONG_LONG_MAX ULLONG_MAX
62
+
63
+ #endif /* _RUBYCC_LIMITS_H */