Ruby  3.4.0dev (2024-11-22 revision 0989400a925cd201defdca9eb28eb87200b30785)
missing.h
1 #ifndef RUBY_MISSING_H /*-*-C++-*-vi:se ft=cpp:*/
2 #define RUBY_MISSING_H 1
12 #include "ruby/internal/config.h"
13 
14 #ifdef STDC_HEADERS
15 # include <stddef.h>
16 #endif
17 
18 #if defined(__cplusplus)
19 # include <cmath>
20 #else
21 # include <math.h> /* for INFINITY and NAN */
22 #endif
23 
24 #ifdef RUBY_ALTERNATIVE_MALLOC_HEADER
25 # include RUBY_ALTERNATIVE_MALLOC_HEADER
26 #endif
27 
28 #if defined(HAVE_TIME_H)
29 # include <time.h>
30 #endif
31 
32 #if defined(HAVE_SYS_TIME_H)
33 # include <sys/time.h>
34 #endif
35 
36 #ifdef HAVE_SYS_STAT_H
37 # include <sys/stat.h>
38 #endif
39 
40 #ifdef HAVE_UNISTD_H
41 # include <unistd.h>
42 #endif
43 
44 #ifdef HAVE_STDIO_H
45 # include <stdio.h>
46 #endif
47 
48 #ifdef HAVE_IEEEFP_H
49 # include <ieeefp.h>
50 #endif
51 
54 
55 #ifndef M_PI
56 # define M_PI 3.14159265358979323846
57 #endif
58 #ifndef M_PI_2
59 # define M_PI_2 (M_PI/2)
60 #endif
61 
62 #if !defined(HAVE_STRUCT_TIMEVAL)
63 struct timeval {
64  time_t tv_sec; /* seconds */
65  long tv_usec; /* microseconds */
66 };
67 #endif /* HAVE_STRUCT_TIMEVAL */
68 
69 #if !defined(HAVE_STRUCT_TIMESPEC)
70 /* :BEWARE: @shyouhei warns that IT IS A WRONG IDEA to define our own version
71  * of struct timespec here. `clock_gettime` is a system call, and your kernel
72  * could expect something other than just `long` (results stack smashing if
73  * that happens). See also https://ewontfix.com/19/ */
74 struct timespec {
75  time_t tv_sec; /* seconds */
76  long tv_nsec; /* nanoseconds */
77 };
78 #endif
79 
80 #if !defined(HAVE_STRUCT_TIMEZONE)
81 struct timezone {
82  int tz_minuteswest;
83  int tz_dsttime;
84 };
85 #endif
86 
88 
89 #ifndef HAVE_ACOSH
90 RUBY_EXTERN double acosh(double);
91 RUBY_EXTERN double asinh(double);
92 RUBY_EXTERN double atanh(double);
93 #endif
94 
95 #ifndef HAVE_CRYPT
96 RUBY_EXTERN char *crypt(const char *, const char *);
97 #endif
98 
99 #ifndef HAVE_EACCESS
100 RUBY_EXTERN int eaccess(const char*, int);
101 #endif
102 
103 #ifndef HAVE_ROUND
104 RUBY_EXTERN double round(double); /* numeric.c */
105 #endif
106 
107 #ifndef HAVE_FLOCK
108 RUBY_EXTERN int flock(int, int);
109 #endif
110 
111 /*
112 #ifndef HAVE_FREXP
113 RUBY_EXTERN double frexp(double, int *);
114 #endif
115 */
116 
117 #ifndef HAVE_HYPOT
118 RUBY_EXTERN double hypot(double, double);
119 #endif
120 
121 #ifndef HAVE_ERF
122 RUBY_EXTERN double erf(double);
123 RUBY_EXTERN double erfc(double);
124 #endif
125 
126 #ifndef HAVE_TGAMMA
127 RUBY_EXTERN double tgamma(double);
128 #endif
129 
130 #ifndef HAVE_LGAMMA_R
131 RUBY_EXTERN double lgamma_r(double, int *);
132 #endif
133 
134 #ifndef HAVE_CBRT
135 RUBY_EXTERN double cbrt(double);
136 #endif
137 
138 #if !defined(INFINITY) || !defined(NAN)
140  unsigned char bytesequence[4];
141  float float_value;
142 };
143 #endif
144 
145 #ifndef INFINITY
147 RUBY_EXTERN const union bytesequence4_or_float rb_infinity;
148 # define INFINITY (rb_infinity.float_value)
149 # define USE_RB_INFINITY 1
150 #endif
151 
152 #ifndef NAN
154 RUBY_EXTERN const union bytesequence4_or_float rb_nan;
155 # define NAN (rb_nan.float_value)
156 # define USE_RB_NAN 1
157 #endif
158 
159 #ifndef HUGE_VAL
160 # define HUGE_VAL ((double)INFINITY)
161 #endif
162 
163 #ifndef HAVE_FINITE
164 # define HAVE_FINITE 1
165 # define finite(x) isfinite(x)
166 #endif
167 
168 #ifndef HAVE_NAN
169 RUBY_EXTERN double nan(const char *);
170 #endif
171 
172 #ifndef HAVE_NEXTAFTER
173 RUBY_EXTERN double nextafter(double x, double y);
174 #endif
175 
176 /*
177 #ifndef HAVE_MEMCMP
178 RUBY_EXTERN int memcmp(const void *, const void *, size_t);
179 #endif
180 */
181 
182 #ifndef HAVE_MEMMOVE
183 RUBY_EXTERN void *memmove(void *, const void *, size_t);
184 #endif
185 
186 /*
187 #ifndef HAVE_MODF
188 RUBY_EXTERN double modf(double, double *);
189 #endif
190 */
191 
192 #ifndef HAVE_STRCHR
193 RUBY_EXTERN char *strchr(const char *, int);
194 RUBY_EXTERN char *strrchr(const char *, int);
195 #endif
196 
197 #ifndef HAVE_STRERROR
198 RUBY_EXTERN char *strerror(int);
199 #endif
200 
201 #ifndef HAVE_STRSTR
202 RUBY_EXTERN char *strstr(const char *, const char *);
203 #endif
204 
205 #ifndef HAVE_STRLCPY
206 RUBY_EXTERN size_t strlcpy(char *, const char*, size_t);
207 #endif
208 
209 #ifndef HAVE_STRLCAT
210 RUBY_EXTERN size_t strlcat(char *, const char*, size_t);
211 #endif
212 
213 #ifndef HAVE_FFS
214 RUBY_EXTERN int ffs(int);
215 #endif
216 
217 #ifdef BROKEN_CLOSE
218 # include <sys/types.h>
219 # include <sys/socket.h>
220 RUBY_EXTERN int ruby_getpeername(int, struct sockaddr *, socklen_t *);
221 RUBY_EXTERN int ruby_getsockname(int, struct sockaddr *, socklen_t *);
222 RUBY_EXTERN int ruby_shutdown(int, int);
223 RUBY_EXTERN int ruby_close(int);
224 #endif
225 
226 #ifndef HAVE_SETPROCTITLE
227 RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 1, 2)
228 RUBY_EXTERN void setproctitle(const char *fmt, ...);
229 #endif
230 
231 #ifdef HAVE_EXPLICIT_BZERO
232 # /* Take that. */
233 #elif defined(SecureZeroMemory)
234 # define explicit_bzero(b, len) SecureZeroMemory(b, len)
235 #else
236 RUBY_EXTERN void explicit_bzero(void *b, size_t len);
237 #endif
238 
239 #ifndef HAVE_TZSET
240 RUBY_EXTERN void tzset(void);
241 #endif
242 
243 #ifndef HAVE_POSIX_MADVISE
244 RUBY_EXTERN int posix_madvise(void *, size_t, int);
245 #endif
246 
247 #ifndef HAVE_GETEUID
248 RUBY_EXTERN rb_uid_t geteuid(void);
249 #endif
250 
251 #ifndef HAVE_GETUID
252 RUBY_EXTERN rb_uid_t getuid(void);
253 #endif
254 
255 #ifndef HAVE_GETEGID
256 RUBY_EXTERN rb_gid_t getegid(void);
257 #endif
258 
259 #ifndef HAVE_GETGID
260 RUBY_EXTERN rb_gid_t getgid(void);
261 #endif
262 
263 #ifndef HAVE_GETLOGIN
264 RUBY_EXTERN char *getlogin(void);
265 #endif
266 
267 #ifndef HAVE_GETPPID
268 RUBY_EXTERN rb_pid_t getppid(void);
269 #endif
270 
271 #ifndef HAVE_UMASK
272 RUBY_EXTERN rb_mode_t umask(rb_mode_t);
273 #endif
274 
275 #ifndef HAVE_CHMOD
276 RUBY_EXTERN int chmod(const char *, rb_mode_t);
277 #endif
278 
279 #ifndef HAVE_CHOWN
280 RUBY_EXTERN int chown(const char *, rb_uid_t, rb_gid_t);
281 #endif
282 
283 #ifndef HAVE_PCLOSE
284 RUBY_EXTERN int pclose(FILE *);
285 #endif
286 
287 #ifndef HAVE_POPEN
288 RUBY_EXTERN FILE *popen(const char *, const char *);
289 #endif
290 
291 #ifndef HAVE_PIPE
292 RUBY_EXTERN int pipe(int [2]);
293 #endif
294 
295 #ifndef HAVE_DUP
296 RUBY_EXTERN int dup(int);
297 #endif
298 
299 #ifndef HAVE_DUP2
300 RUBY_EXTERN int dup2(int, int);
301 #endif
302 
303 #ifndef HAVE_KILL
304 RUBY_EXTERN int kill(rb_pid_t, int);
305 #endif
306 
307 #ifndef HAVE_EXECL
308 RUBY_EXTERN int execl(const char *, const char *, ...);
309 #endif
310 
311 #ifndef HAVE_EXECLE
312 RUBY_EXTERN int execle(const char *, const char *, ...);
313 #endif
314 
315 #ifndef HAVE_EXECV
316 RUBY_EXTERN int execv(const char *, char *const []);
317 #endif
318 
319 #ifndef HAVE_EXECVE
320 RUBY_EXTERN int execve(const char *, char *const [], char *const []);
321 #endif
322 
323 #ifndef HAVE_SHUTDOWN
324 RUBY_EXTERN int shutdown(int, int);
325 #endif
326 
327 #ifndef HAVE_SYSTEM
328 RUBY_EXTERN int system(const char *);
329 #endif
330 
331 #ifndef WNOHANG
332 # define WNOHANG 0
333 #endif
334 
335 #ifndef HAVE_WAITPID
336 # define HAVE_WAITPID 1
337 RUBY_EXTERN rb_pid_t waitpid(rb_pid_t, int *, int);
338 #endif
339 
341 
342 #endif /* RUBY_MISSING_H */
Tweaking visibility of C variables/functions.
#define RUBY_EXTERN
Declaration of externally visible global variables.
Definition: dllexport.h:45
#define RBIMPL_SYMBOL_EXPORT_END()
Counterpart of RBIMPL_SYMBOL_EXPORT_BEGIN.
Definition: dllexport.h:74
#define RBIMPL_SYMBOL_EXPORT_BEGIN()
Shortcut macro equivalent to RUBY_SYMBOL_EXPORT_BEGIN extern "C" {.
Definition: dllexport.h:65
Defines RBIMPL_ATTR_FORMAT.
#define RBIMPL_ATTR_FORMAT(x, y, z)
Wraps (or simulates) __attribute__((format))
Definition: format.h:27
int len
Length of the buffer.
Definition: io.h:8