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,188 @@
1
+ /* rubycc bundled <sys/syscall.h> (x86-64): the system-call numbers, as the
2
+ SYS_ names callers pass to syscall(2). Provenance: clean room against the
3
+ Linux kernel's x86-64 system-call table, not derived from musl or glibc
4
+ source. Every number below was printed from the glibc oracle (an ABI fact,
5
+ not copied text -- see docs/HEADER-LICENSING.md sec. 4).
6
+
7
+ Arch layer, necessarily. glibc's <sys/syscall.h> is a thin shim that pulls
8
+ in <asm/unistd.h> and then defines each SYS_ name as an alias of the
9
+ corresponding __NR_ name, and __NR_ numbering is per-architecture: x86-64
10
+ carries its own historical table while aarch64 uses the modern
11
+ asm-generic one. Measured side by side, the two disagree on essentially
12
+ every entry -- SYS_read is 0 here and 63 there, SYS_write 1 vs 64,
13
+ SYS_openat 257 vs 56, SYS_epoll_ctl 233 vs 21 -- so there is no common
14
+ layer to be had and this header has an aarch64 sibling. The only
15
+ agreements found were the io_uring trio (425/426/427), which entered the
16
+ kernel late enough to be allocated from the shared modern range. The
17
+ __NR_/SYS_ two-level spelling is reproduced rather than collapsed because
18
+ callers do write __NR_ names directly, and because it is what makes the
19
+ `#if SYS_foo` feature tests third-party code performs behave as they do
20
+ against the real header.
21
+
22
+ Scope: this is deliberately NOT the whole table. glibc's copy is generated
23
+ from the kernel headers and runs to several hundred entries; reproducing
24
+ all of them by measurement would add a large surface with no consumer and
25
+ would need re-measuring on every kernel release. The set below is (a)
26
+ everything nio4r, the gem that put this header on the list, can reach --
27
+ libev routes clock_gettime, the eventfd/signalfd/inotify/epoll creation
28
+ calls, and its linuxaio and io_uring backends through raw syscall numbers
29
+ -- and (b) a representative core of process, memory, file and socket
30
+ calls, chosen so the numbering itself is verifiable across a wide span of
31
+ the table rather than at one end of it.
32
+
33
+ One consequence of the scope rule used here is worth stating: only names
34
+ that exist on BOTH targets are defined, so the two arch copies differ in
35
+ their numbers and in nothing else. That excludes the legacy x86-64-only
36
+ entry points (open, poll, select, pipe, dup2, access, unlink, rename,
37
+ creat, fork, and their kin), for which the asm-generic table aarch64 uses
38
+ has no entry at all -- their callers are expected to use the *at / *2 /
39
+ p* replacements that are listed below. No corpus census hit reaches any of
40
+ them through syscall(2).
41
+
42
+ Note that this header intentionally does not declare syscall() itself;
43
+ measured, neither does glibc's -- the prototype lives in <unistd.h>. */
44
+
45
+ #ifndef _RUBYCC_SYS_SYSCALL_H
46
+ #define _RUBYCC_SYS_SYSCALL_H
47
+
48
+ /* Basic file I/O. */
49
+ #define __NR_read 0
50
+ #define __NR_write 1
51
+ #define __NR_close 3
52
+ #define __NR_lseek 8
53
+ #define __NR_openat 257
54
+ #define __NR_readlinkat 267
55
+ #define __NR_faccessat 269
56
+ #define __NR_ioctl 16
57
+ #define __NR_fcntl 72
58
+ #define __NR_pipe2 293
59
+ #define __NR_dup3 292
60
+
61
+ /* Filesystem statistics (the calls behind <sys/statfs.h>). */
62
+ #define __NR_statfs 137
63
+ #define __NR_fstatfs 138
64
+
65
+ /* Memory. */
66
+ #define __NR_mmap 9
67
+ #define __NR_mprotect 10
68
+ #define __NR_munmap 11
69
+
70
+ /* Processes, threads and signals. */
71
+ #define __NR_clone 56
72
+ #define __NR_exit 60
73
+ #define __NR_exit_group 231
74
+ #define __NR_getpid 39
75
+ #define __NR_gettid 186
76
+ #define __NR_kill 62
77
+ #define __NR_tgkill 234
78
+ #define __NR_rt_sigaction 13
79
+ #define __NR_rt_sigprocmask 14
80
+ #define __NR_futex 202
81
+ #define __NR_sched_yield 24
82
+ #define __NR_getcpu 309
83
+ #define __NR_membarrier 324
84
+ #define __NR_getrandom 318
85
+
86
+ /* Time. */
87
+ #define __NR_nanosleep 35
88
+ #define __NR_clock_gettime 228
89
+ #define __NR_clock_nanosleep 230
90
+
91
+ /* Event notification: the file-descriptor-based interfaces libev drives
92
+ through raw syscalls when the libc wrappers are not available. */
93
+ #define __NR_epoll_create1 291
94
+ #define __NR_epoll_ctl 233
95
+ #define __NR_epoll_pwait 281
96
+ #define __NR_ppoll 271
97
+ #define __NR_pselect6 270
98
+ #define __NR_eventfd2 290
99
+ #define __NR_signalfd4 289
100
+ #define __NR_inotify_init1 294
101
+ #define __NR_inotify_add_watch 254
102
+ #define __NR_inotify_rm_watch 255
103
+ #define __NR_timerfd_create 283
104
+ #define __NR_timerfd_settime 286
105
+ #define __NR_timerfd_gettime 287
106
+
107
+ /* Asynchronous I/O: the legacy linux-aio calls and io_uring. These have no
108
+ libc wrappers at all, which is why libev issues them by number. */
109
+ #define __NR_io_setup 206
110
+ #define __NR_io_destroy 207
111
+ #define __NR_io_getevents 208
112
+ #define __NR_io_submit 209
113
+ #define __NR_io_cancel 210
114
+ #define __NR_io_uring_setup 425
115
+ #define __NR_io_uring_enter 426
116
+ #define __NR_io_uring_register 427
117
+
118
+ /* Sockets. */
119
+ #define __NR_socket 41
120
+ #define __NR_setsockopt 54
121
+
122
+ /* The SYS_ spellings: aliases of the __NR_ names above, which is the
123
+ relationship measured against the real header. */
124
+ #define SYS_read __NR_read
125
+ #define SYS_write __NR_write
126
+ #define SYS_close __NR_close
127
+ #define SYS_lseek __NR_lseek
128
+ #define SYS_openat __NR_openat
129
+ #define SYS_readlinkat __NR_readlinkat
130
+ #define SYS_faccessat __NR_faccessat
131
+ #define SYS_ioctl __NR_ioctl
132
+ #define SYS_fcntl __NR_fcntl
133
+ #define SYS_pipe2 __NR_pipe2
134
+ #define SYS_dup3 __NR_dup3
135
+
136
+ #define SYS_statfs __NR_statfs
137
+ #define SYS_fstatfs __NR_fstatfs
138
+
139
+ #define SYS_mmap __NR_mmap
140
+ #define SYS_mprotect __NR_mprotect
141
+ #define SYS_munmap __NR_munmap
142
+
143
+ #define SYS_clone __NR_clone
144
+ #define SYS_exit __NR_exit
145
+ #define SYS_exit_group __NR_exit_group
146
+ #define SYS_getpid __NR_getpid
147
+ #define SYS_gettid __NR_gettid
148
+ #define SYS_kill __NR_kill
149
+ #define SYS_tgkill __NR_tgkill
150
+ #define SYS_rt_sigaction __NR_rt_sigaction
151
+ #define SYS_rt_sigprocmask __NR_rt_sigprocmask
152
+ #define SYS_futex __NR_futex
153
+ #define SYS_sched_yield __NR_sched_yield
154
+ #define SYS_getcpu __NR_getcpu
155
+ #define SYS_membarrier __NR_membarrier
156
+ #define SYS_getrandom __NR_getrandom
157
+
158
+ #define SYS_nanosleep __NR_nanosleep
159
+ #define SYS_clock_gettime __NR_clock_gettime
160
+ #define SYS_clock_nanosleep __NR_clock_nanosleep
161
+
162
+ #define SYS_epoll_create1 __NR_epoll_create1
163
+ #define SYS_epoll_ctl __NR_epoll_ctl
164
+ #define SYS_epoll_pwait __NR_epoll_pwait
165
+ #define SYS_ppoll __NR_ppoll
166
+ #define SYS_pselect6 __NR_pselect6
167
+ #define SYS_eventfd2 __NR_eventfd2
168
+ #define SYS_signalfd4 __NR_signalfd4
169
+ #define SYS_inotify_init1 __NR_inotify_init1
170
+ #define SYS_inotify_add_watch __NR_inotify_add_watch
171
+ #define SYS_inotify_rm_watch __NR_inotify_rm_watch
172
+ #define SYS_timerfd_create __NR_timerfd_create
173
+ #define SYS_timerfd_settime __NR_timerfd_settime
174
+ #define SYS_timerfd_gettime __NR_timerfd_gettime
175
+
176
+ #define SYS_io_setup __NR_io_setup
177
+ #define SYS_io_destroy __NR_io_destroy
178
+ #define SYS_io_getevents __NR_io_getevents
179
+ #define SYS_io_submit __NR_io_submit
180
+ #define SYS_io_cancel __NR_io_cancel
181
+ #define SYS_io_uring_setup __NR_io_uring_setup
182
+ #define SYS_io_uring_enter __NR_io_uring_enter
183
+ #define SYS_io_uring_register __NR_io_uring_register
184
+
185
+ #define SYS_socket __NR_socket
186
+ #define SYS_setsockopt __NR_setsockopt
187
+
188
+ #endif /* _RUBYCC_SYS_SYSCALL_H */
@@ -0,0 +1,74 @@
1
+ /* rubycc bundled <sys/time.h>: struct timeval and the BSD time calls (POSIX).
2
+ Derived from musl's <sys/time.h> shape; struct timeval's members are pinned to
3
+ the glibc x86-64 ABI (time_t and suseconds_t are both `long`, giving a 16-byte
4
+ layout, measured). The struct guard reuses glibc's __timeval_defined. ABI
5
+ switch layer: the member widths are arch specific. */
6
+
7
+ #ifndef _RUBYCC_SYS_TIME_H
8
+ #define _RUBYCC_SYS_TIME_H
9
+
10
+ #ifndef _RUBYCC_TIME_T
11
+ #define _RUBYCC_TIME_T
12
+ typedef long time_t;
13
+ #endif
14
+ #ifndef _RUBYCC_SUSECONDS_T
15
+ #define _RUBYCC_SUSECONDS_T
16
+ typedef long suseconds_t;
17
+ #endif
18
+
19
+ #ifndef __timeval_defined
20
+ #define __timeval_defined 1
21
+ struct timeval {
22
+ time_t tv_sec;
23
+ suseconds_t tv_usec;
24
+ };
25
+ #endif
26
+
27
+ struct timezone {
28
+ int tz_minuteswest;
29
+ int tz_dsttime;
30
+ };
31
+
32
+ struct itimerval {
33
+ struct timeval it_interval;
34
+ struct timeval it_value;
35
+ };
36
+
37
+ #define ITIMER_REAL 0
38
+ #define ITIMER_VIRTUAL 1
39
+ #define ITIMER_PROF 2
40
+
41
+ int gettimeofday(struct timeval *__restrict __tv, void *__restrict __tz);
42
+ int settimeofday(const struct timeval *__tv, const struct timezone *__tz);
43
+ int getitimer(int __which, struct itimerval *__value);
44
+ int setitimer(int __which, const struct itimerval *__restrict __new,
45
+ struct itimerval *__restrict __old);
46
+ int utimes(const char *__file, const struct timeval __tvp[2]);
47
+
48
+ /* Convenience timeval arithmetic macros (glibc/BSD, under _DEFAULT_SOURCE). */
49
+ #define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec)
50
+ #define timerclear(tvp) ((tvp)->tv_sec = (tvp)->tv_usec = 0)
51
+ #define timercmp(a, b, CMP) \
52
+ (((a)->tv_sec == (b)->tv_sec) ? \
53
+ ((a)->tv_usec CMP (b)->tv_usec) : \
54
+ ((a)->tv_sec CMP (b)->tv_sec))
55
+ #define timeradd(a, b, result) \
56
+ do { \
57
+ (result)->tv_sec = (a)->tv_sec + (b)->tv_sec; \
58
+ (result)->tv_usec = (a)->tv_usec + (b)->tv_usec; \
59
+ if ((result)->tv_usec >= 1000000) { \
60
+ ++(result)->tv_sec; \
61
+ (result)->tv_usec -= 1000000; \
62
+ } \
63
+ } while (0)
64
+ #define timersub(a, b, result) \
65
+ do { \
66
+ (result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \
67
+ (result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \
68
+ if ((result)->tv_usec < 0) { \
69
+ --(result)->tv_sec; \
70
+ (result)->tv_usec += 1000000; \
71
+ } \
72
+ } while (0)
73
+
74
+ #endif /* _RUBYCC_SYS_TIME_H */
@@ -0,0 +1,123 @@
1
+ /* rubycc bundled <sys/types.h>: the width-critical POSIX typedefs. Derived from
2
+ musl's <sys/types.h> shape; every width and signedness is pinned to the glibc
3
+ x86-64 LP64 ABI (measured): off_t/time_t/ssize_t are `long`, pid_t is `int`,
4
+ dev_t/ino_t/nlink_t are `unsigned long`. Each typedef is guarded by a shared
5
+ _RUBYCC_* tag so the other bundled headers that also spell these types agree
6
+ rather than redefine. ABI switch layer: the widths are arch specific. */
7
+
8
+ #ifndef _RUBYCC_SYS_TYPES_H
9
+ #define _RUBYCC_SYS_TYPES_H
10
+
11
+ #ifndef _RUBYCC_SIZE_T
12
+ #define _RUBYCC_SIZE_T
13
+ typedef unsigned long size_t;
14
+ #endif
15
+ #ifndef _RUBYCC_SSIZE_T
16
+ #define _RUBYCC_SSIZE_T
17
+ typedef long ssize_t;
18
+ #endif
19
+ #ifndef _RUBYCC_OFF_T
20
+ #define _RUBYCC_OFF_T
21
+ typedef long off_t;
22
+ #endif
23
+ typedef long off64_t;
24
+ typedef long loff_t;
25
+ #ifndef _RUBYCC_PID_T
26
+ #define _RUBYCC_PID_T
27
+ typedef int pid_t;
28
+ #endif
29
+ #ifndef _RUBYCC_UID_T
30
+ #define _RUBYCC_UID_T
31
+ typedef unsigned int uid_t;
32
+ #endif
33
+ #ifndef _RUBYCC_GID_T
34
+ #define _RUBYCC_GID_T
35
+ typedef unsigned int gid_t;
36
+ #endif
37
+ #ifndef _RUBYCC_MODE_T
38
+ #define _RUBYCC_MODE_T
39
+ typedef unsigned int mode_t;
40
+ #endif
41
+ #ifndef _RUBYCC_INO_T
42
+ #define _RUBYCC_INO_T
43
+ typedef unsigned long ino_t;
44
+ #endif
45
+ typedef unsigned long ino64_t;
46
+ #ifndef _RUBYCC_DEV_T
47
+ #define _RUBYCC_DEV_T
48
+ typedef unsigned long dev_t;
49
+ #endif
50
+ #ifndef _RUBYCC_NLINK_T
51
+ #define _RUBYCC_NLINK_T
52
+ typedef unsigned long nlink_t;
53
+ #endif
54
+ #ifndef _RUBYCC_BLKSIZE_T
55
+ #define _RUBYCC_BLKSIZE_T
56
+ typedef long blksize_t;
57
+ #endif
58
+ #ifndef _RUBYCC_BLKCNT_T
59
+ #define _RUBYCC_BLKCNT_T
60
+ typedef long blkcnt_t;
61
+ #endif
62
+ typedef long blkcnt64_t;
63
+ #ifndef _RUBYCC_FSBLKCNT_T
64
+ #define _RUBYCC_FSBLKCNT_T
65
+ typedef unsigned long fsblkcnt_t;
66
+ #endif
67
+ typedef unsigned long fsblkcnt64_t;
68
+ #ifndef _RUBYCC_FSFILCNT_T
69
+ #define _RUBYCC_FSFILCNT_T
70
+ typedef unsigned long fsfilcnt_t;
71
+ #endif
72
+ typedef unsigned long fsfilcnt64_t;
73
+ #ifndef _RUBYCC_TIME_T
74
+ #define _RUBYCC_TIME_T
75
+ typedef long time_t;
76
+ #endif
77
+ #ifndef _RUBYCC_CLOCK_T
78
+ #define _RUBYCC_CLOCK_T
79
+ typedef long clock_t;
80
+ #endif
81
+ #ifndef _RUBYCC_CLOCKID_T
82
+ #define _RUBYCC_CLOCKID_T
83
+ typedef int clockid_t;
84
+ #endif
85
+ #ifndef _RUBYCC_TIMER_T
86
+ #define _RUBYCC_TIMER_T
87
+ typedef void *timer_t;
88
+ #endif
89
+ #ifndef _RUBYCC_SUSECONDS_T
90
+ #define _RUBYCC_SUSECONDS_T
91
+ typedef long suseconds_t;
92
+ #endif
93
+ #ifndef _RUBYCC_USECONDS_T
94
+ #define _RUBYCC_USECONDS_T
95
+ typedef unsigned int useconds_t;
96
+ #endif
97
+ #ifndef _RUBYCC_ID_T
98
+ #define _RUBYCC_ID_T
99
+ typedef unsigned int id_t;
100
+ #endif
101
+ #ifndef _RUBYCC_KEY_T
102
+ #define _RUBYCC_KEY_T
103
+ typedef int key_t;
104
+ #endif
105
+
106
+ typedef long register_t;
107
+ typedef int daddr_t;
108
+ typedef char *caddr_t;
109
+
110
+ /* BSD short-hand integer names (glibc exposes them under _DEFAULT_SOURCE). */
111
+ typedef unsigned char u_char;
112
+ typedef unsigned short u_short;
113
+ typedef unsigned int u_int;
114
+ typedef unsigned long u_long;
115
+ typedef unsigned char ushort;
116
+ typedef unsigned int uint;
117
+ typedef unsigned long ulong;
118
+ typedef unsigned char u_int8_t;
119
+ typedef unsigned short u_int16_t;
120
+ typedef unsigned int u_int32_t;
121
+ typedef unsigned long u_int64_t;
122
+
123
+ #endif /* _RUBYCC_SYS_TYPES_H */
@@ -0,0 +1,113 @@
1
+ /* rubycc bundled <time.h>: the calendar/clock types and declarations (ISO C
2
+ 7.27, POSIX). Derived from musl's <time.h> shape; time_t is pinned to `long`
3
+ and `struct tm` carries glibc's tm_gmtoff/tm_zone extension so its 56-byte
4
+ layout matches the reference ABI (measured). The struct guards reuse glibc's
5
+ (__struct_tm_defined, _STRUCT_TIMESPEC) so a host header coexisting on the
6
+ path does not redefine. ABI switch layer: time_t width and struct tm layout
7
+ are arch specific. */
8
+
9
+ #ifndef _RUBYCC_TIME_H
10
+ #define _RUBYCC_TIME_H
11
+
12
+ #ifndef NULL
13
+ #define NULL ((void*)0)
14
+ #endif
15
+
16
+ #ifndef _RUBYCC_SIZE_T
17
+ #define _RUBYCC_SIZE_T
18
+ typedef unsigned long size_t;
19
+ #endif
20
+ #ifndef _RUBYCC_TIME_T
21
+ #define _RUBYCC_TIME_T
22
+ typedef long time_t;
23
+ #endif
24
+ #ifndef _RUBYCC_CLOCK_T
25
+ #define _RUBYCC_CLOCK_T
26
+ typedef long clock_t;
27
+ #endif
28
+ #ifndef _RUBYCC_CLOCKID_T
29
+ #define _RUBYCC_CLOCKID_T
30
+ typedef int clockid_t;
31
+ #endif
32
+ #ifndef _RUBYCC_TIMER_T
33
+ #define _RUBYCC_TIMER_T
34
+ typedef void *timer_t;
35
+ #endif
36
+ #ifndef _RUBYCC_PID_T
37
+ #define _RUBYCC_PID_T
38
+ typedef int pid_t;
39
+ #endif
40
+
41
+ #define CLOCKS_PER_SEC ((clock_t) 1000000)
42
+ #define TIME_UTC 1
43
+
44
+ /* POSIX clock ids. */
45
+ #define CLOCK_REALTIME 0
46
+ #define CLOCK_MONOTONIC 1
47
+ #define CLOCK_PROCESS_CPUTIME_ID 2
48
+ #define CLOCK_THREAD_CPUTIME_ID 3
49
+ #define CLOCK_MONOTONIC_RAW 4
50
+ #define CLOCK_REALTIME_COARSE 5
51
+ #define CLOCK_MONOTONIC_COARSE 6
52
+ #define CLOCK_BOOTTIME 7
53
+ #define TIMER_ABSTIME 1
54
+
55
+ #ifndef _STRUCT_TIMESPEC
56
+ #define _STRUCT_TIMESPEC 1
57
+ struct timespec {
58
+ time_t tv_sec;
59
+ long tv_nsec;
60
+ };
61
+ #endif
62
+
63
+ #ifndef __struct_tm_defined
64
+ #define __struct_tm_defined 1
65
+ struct tm {
66
+ int tm_sec;
67
+ int tm_min;
68
+ int tm_hour;
69
+ int tm_mday;
70
+ int tm_mon;
71
+ int tm_year;
72
+ int tm_wday;
73
+ int tm_yday;
74
+ int tm_isdst;
75
+ long tm_gmtoff;
76
+ const char *tm_zone;
77
+ };
78
+ #endif
79
+
80
+ struct itimerspec {
81
+ struct timespec it_interval;
82
+ struct timespec it_value;
83
+ };
84
+
85
+ clock_t clock(void);
86
+ time_t time(time_t *__timer);
87
+ double difftime(time_t __time1, time_t __time0);
88
+ time_t mktime(struct tm *__tp);
89
+ size_t strftime(char *__restrict __s, size_t __maxsize,
90
+ const char *__restrict __format, const struct tm *__restrict __tp);
91
+ struct tm *gmtime(const time_t *__timer);
92
+ struct tm *localtime(const time_t *__timer);
93
+ struct tm *gmtime_r(const time_t *__restrict __timer, struct tm *__restrict __tp);
94
+ struct tm *localtime_r(const time_t *__restrict __timer, struct tm *__restrict __tp);
95
+ char *asctime(const struct tm *__tp);
96
+ char *ctime(const time_t *__timer);
97
+ char *asctime_r(const struct tm *__restrict __tp, char *__restrict __buf);
98
+ char *ctime_r(const time_t *__restrict __timer, char *__restrict __buf);
99
+ char *strptime(const char *__restrict __s, const char *__restrict __fmt, struct tm *__tp);
100
+
101
+ int nanosleep(const struct timespec *__requested_time, struct timespec *__remaining);
102
+ int clock_gettime(clockid_t __clock_id, struct timespec *__tp);
103
+ int clock_settime(clockid_t __clock_id, const struct timespec *__tp);
104
+ int clock_getres(clockid_t __clock_id, struct timespec *__res);
105
+ time_t timegm(struct tm *__tp);
106
+ time_t timelocal(struct tm *__tp);
107
+
108
+ extern char *tzname[2];
109
+ extern long timezone;
110
+ extern int daylight;
111
+ void tzset(void);
112
+
113
+ #endif /* _RUBYCC_TIME_H */
@@ -0,0 +1,50 @@
1
+ /* rubycc bundled <grp.h>: the group database access interface (POSIX.1 9.2.1).
2
+ Provenance: clean room against the POSIX public interface -- struct group's
3
+ member names, types and order are POSIX's own public contract, not glibc
4
+ implementation detail. Every member is used directly by callers, so it
5
+ cannot be an opaque byte blob; its size and every member's offset were
6
+ measured against the glibc oracle on both x86-64 and aarch64 (see
7
+ test/test_header_abi.rb's GRP case) and the two agreed exactly (an
8
+ all-pointer/gid_t struct has no arch-dependent field widths on either LP64
9
+ target), so this header lives in the common layer. gid_t reuses the shared
10
+ _RUBYCC_GID_T guard sys/types.h and unistd.h also carry. getgrnam/getgrgid/
11
+ getgrent/setgrent/endgrent/getgrnam_r/getgrgid_r are POSIX declarations
12
+ whose bodies resolve from the host libc at link time (the _r variants
13
+ answer through NSS, a host runtime fact, not something rubycc computes).
14
+ Not included: fgetgrent/putgrent (glibc/BSD extensions no corpus sample
15
+ census hit needs), left out to keep the surface to what etc's use of
16
+ getgrnam/getgrgid actually requires (Step 123, M5 H2). */
17
+
18
+ #ifndef _RUBYCC_GRP_H
19
+ #define _RUBYCC_GRP_H
20
+
21
+ #ifndef _RUBYCC_SIZE_T
22
+ #define _RUBYCC_SIZE_T
23
+ typedef unsigned long size_t;
24
+ #endif
25
+ #ifndef _RUBYCC_GID_T
26
+ #define _RUBYCC_GID_T
27
+ typedef unsigned int gid_t;
28
+ #endif
29
+
30
+ /* A record in the group database. Member names, types and order are the
31
+ POSIX.1 public contract; every offset below was measured against the glibc
32
+ oracle on both x86-64 and aarch64 and the two agreed byte for byte. */
33
+ struct group {
34
+ char *gr_name; /* Group name. */
35
+ char *gr_passwd; /* Password. */
36
+ gid_t gr_gid; /* Group ID. */
37
+ char **gr_mem; /* Member list (NULL-terminated). */
38
+ };
39
+
40
+ struct group *getgrnam(const char *__name);
41
+ struct group *getgrgid(gid_t __gid);
42
+ struct group *getgrent(void);
43
+ void setgrent(void);
44
+ void endgrent(void);
45
+ int getgrnam_r(const char *__restrict __name, struct group *__restrict __resultbuf,
46
+ char *__restrict __buffer, size_t __buflen, struct group **__restrict __result);
47
+ int getgrgid_r(gid_t __gid, struct group *__restrict __resultbuf,
48
+ char *__restrict __buffer, size_t __buflen, struct group **__restrict __result);
49
+
50
+ #endif /* _RUBYCC_GRP_H */
@@ -0,0 +1,126 @@
1
+ /* rubycc bundled <langinfo.h>: locale-dependent string lookup (POSIX.1).
2
+ Provenance: clean room against the POSIX public interface and the glibc
3
+ runtime ABI, not derived from musl or glibc source. nl_langinfo is answered
4
+ by the host libc, so the nl_item numbers must match the host's own
5
+ enumeration exactly -- the same reasoning <locale.h>'s LC_* values and
6
+ <unistd.h>'s _SC_* values rest on -- and every value below was therefore
7
+ printed from the glibc oracle rather than guessed.
8
+
9
+ The numbering is not a flat sequence: an nl_item packs the locale category
10
+ in the upper 16 bits and an index within that category in the lower 16, so
11
+ e.g. D_T_FMT measures 0x20028 = category 2 (LC_TIME) index 40. That
12
+ composition was itself measured, not assumed: a probe compared rubycc's
13
+ own _NL_ITEM/_NL_ITEM_CATEGORY/_NL_ITEM_INDEX formulas against the glibc
14
+ oracle's over every (category, index) pair in range and found them equal,
15
+ and the category numbers the items carry match the LC_* values the bundled
16
+ <locale.h> already reproduces. The constants below are still written out as
17
+ their measured composed values so this header does not depend on
18
+ <locale.h> being included.
19
+
20
+ Common layer: every nl_item value measured identical on x86-64 and on
21
+ aarch64 (cross gcc + qemu), and nl_item is `int` (4 bytes) on both, so the
22
+ header is arch-neutral.
23
+
24
+ Not included: nl_langinfo_l (its locale_t parameter is part of the glibc
25
+ locale extension set the bundled <locale.h> deliberately leaves out), and
26
+ glibc's _NL_* internal item names beyond the three composition helpers.
27
+ nkf, the gem that put this header on the list, reaches nl_langinfo with the
28
+ POSIX item set. */
29
+
30
+ #ifndef _RUBYCC_LANGINFO_H
31
+ #define _RUBYCC_LANGINFO_H
32
+
33
+ /* The item selector. Measured: 4 bytes, 4-byte aligned, signed. glibc reaches
34
+ for this typedef through <nl_types.h>; rubycc has no such header, so it is
35
+ given here under its own guard. */
36
+ #ifndef _RUBYCC_NL_ITEM
37
+ #define _RUBYCC_NL_ITEM
38
+ typedef int nl_item;
39
+ #endif
40
+
41
+ /* The category/index composition, re-derived from the measured values (see
42
+ the note above): category in bits 16.., index in bits 0..15. */
43
+ #define _NL_ITEM(category, index) (((category) << 16) | (index))
44
+ #define _NL_ITEM_CATEGORY(item) ((item) >> 16)
45
+ #define _NL_ITEM_INDEX(item) ((item) & 0xffff)
46
+
47
+ /* LC_CTYPE items (category 0). */
48
+ #define CODESET 14
49
+
50
+ /* LC_NUMERIC items (category 1). DECIMAL_POINT / THOUSANDS_SEP are glibc's
51
+ alternate spellings of the same two items. */
52
+ #define RADIXCHAR 0x10000
53
+ #define THOUSEP 0x10001
54
+ #define DECIMAL_POINT 0x10000
55
+ #define THOUSANDS_SEP 0x10001
56
+
57
+ /* LC_TIME items (category 2), in the order glibc numbers them: the seven
58
+ abbreviated day names, the seven full day names, the twelve abbreviated
59
+ month names, the twelve full month names, then the format strings. */
60
+ #define ABDAY_1 0x20000
61
+ #define ABDAY_2 0x20001
62
+ #define ABDAY_3 0x20002
63
+ #define ABDAY_4 0x20003
64
+ #define ABDAY_5 0x20004
65
+ #define ABDAY_6 0x20005
66
+ #define ABDAY_7 0x20006
67
+
68
+ #define DAY_1 0x20007
69
+ #define DAY_2 0x20008
70
+ #define DAY_3 0x20009
71
+ #define DAY_4 0x2000a
72
+ #define DAY_5 0x2000b
73
+ #define DAY_6 0x2000c
74
+ #define DAY_7 0x2000d
75
+
76
+ #define ABMON_1 0x2000e
77
+ #define ABMON_2 0x2000f
78
+ #define ABMON_3 0x20010
79
+ #define ABMON_4 0x20011
80
+ #define ABMON_5 0x20012
81
+ #define ABMON_6 0x20013
82
+ #define ABMON_7 0x20014
83
+ #define ABMON_8 0x20015
84
+ #define ABMON_9 0x20016
85
+ #define ABMON_10 0x20017
86
+ #define ABMON_11 0x20018
87
+ #define ABMON_12 0x20019
88
+
89
+ #define MON_1 0x2001a
90
+ #define MON_2 0x2001b
91
+ #define MON_3 0x2001c
92
+ #define MON_4 0x2001d
93
+ #define MON_5 0x2001e
94
+ #define MON_6 0x2001f
95
+ #define MON_7 0x20020
96
+ #define MON_8 0x20021
97
+ #define MON_9 0x20022
98
+ #define MON_10 0x20023
99
+ #define MON_11 0x20024
100
+ #define MON_12 0x20025
101
+
102
+ #define AM_STR 0x20026
103
+ #define PM_STR 0x20027
104
+ #define D_T_FMT 0x20028
105
+ #define D_FMT 0x20029
106
+ #define T_FMT 0x2002a
107
+ #define T_FMT_AMPM 0x2002b
108
+ #define ERA 0x2002c
109
+ #define ERA_D_FMT 0x2002e
110
+ #define ALT_DIGITS 0x2002f
111
+ #define ERA_D_T_FMT 0x20030
112
+ #define ERA_T_FMT 0x20031
113
+
114
+ /* LC_MONETARY item (category 4). */
115
+ #define CRNCYSTR 0x4000f
116
+
117
+ /* LC_MESSAGES items (category 5). YESSTR / NOSTR are glibc legacy items kept
118
+ for callers that still ask for them. */
119
+ #define YESEXPR 0x50000
120
+ #define NOEXPR 0x50001
121
+ #define YESSTR 0x50002
122
+ #define NOSTR 0x50003
123
+
124
+ char *nl_langinfo(nl_item __item);
125
+
126
+ #endif /* _RUBYCC_LANGINFO_H */
@@ -0,0 +1,18 @@
1
+ /* Clean-room ABI subset: rubycc bundled <link.h> exposes the leading fields of
2
+ glibc's link_map ABI used by
3
+ dlinfo(RTLD_DI_LINKMAP). The dynamic-loader extension only exposes the
4
+ object's load bias and name to this C subset; the remaining loader-private
5
+ fields are deliberately not presented as a false public surface. */
6
+
7
+ #ifndef _RUBYCC_LINK_H
8
+ #define _RUBYCC_LINK_H
9
+
10
+ struct link_map {
11
+ unsigned long l_addr;
12
+ char *l_name;
13
+ void *l_ld;
14
+ struct link_map *l_next;
15
+ struct link_map *l_prev;
16
+ };
17
+
18
+ #endif /* _RUBYCC_LINK_H */