Ruby 3.5.0dev (2025-02-20 revision 34098b669c0cbc024cd08e686891f1dfe0a10aaf)
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)
63struct 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/ */
74struct timespec {
75 time_t tv_sec; /* seconds */
76 long tv_nsec; /* nanoseconds */
77};
78#endif
79
80#if !defined(HAVE_STRUCT_TIMEZONE)
81struct timezone {
82 int tz_minuteswest;
83 int tz_dsttime;
84};
85#endif
86
88
89#ifndef HAVE_ACOSH
90RUBY_EXTERN double acosh(double);
91RUBY_EXTERN double asinh(double);
92RUBY_EXTERN double atanh(double);
93#endif
94
95#ifndef HAVE_CRYPT
96RUBY_EXTERN char *crypt(const char *, const char *);
97#endif
98
99#ifndef HAVE_EACCESS
100RUBY_EXTERN int eaccess(const char*, int);
101#endif
102
103#ifndef HAVE_ROUND
104RUBY_EXTERN double round(double); /* numeric.c */
105#endif
106
107#ifndef HAVE_FLOCK
108RUBY_EXTERN int flock(int, int);
109#endif
110
111/*
112#ifndef HAVE_FREXP
113RUBY_EXTERN double frexp(double, int *);
114#endif
115*/
116
117#ifndef HAVE_HYPOT
118RUBY_EXTERN double hypot(double, double);
119#endif
120
121#ifndef HAVE_ERF
122RUBY_EXTERN double erf(double);
123RUBY_EXTERN double erfc(double);
124#endif
125
126#ifndef HAVE_TGAMMA
127RUBY_EXTERN double tgamma(double);
128#endif
129
130#ifndef HAVE_LGAMMA_R
131RUBY_EXTERN double lgamma_r(double, int *);
132#endif
133
134#ifndef HAVE_CBRT
135RUBY_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
147RUBY_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
154RUBY_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
169RUBY_EXTERN double nan(const char *);
170#endif
171
172#ifndef HAVE_NEXTAFTER
173RUBY_EXTERN double nextafter(double x, double y);
174#endif
175
176/*
177#ifndef HAVE_MEMCMP
178RUBY_EXTERN int memcmp(const void *, const void *, size_t);
179#endif
180*/
181
182#ifndef HAVE_MEMMOVE
183RUBY_EXTERN void *memmove(void *, const void *, size_t);
184#endif
185
186/*
187#ifndef HAVE_MODF
188RUBY_EXTERN double modf(double, double *);
189#endif
190*/
191
192#ifndef HAVE_STRCHR
193RUBY_EXTERN char *strchr(const char *, int);
194RUBY_EXTERN char *strrchr(const char *, int);
195#endif
196
197#ifndef HAVE_STRERROR
198RUBY_EXTERN char *strerror(int);
199#endif
200
201#ifndef HAVE_STRSTR
202RUBY_EXTERN char *strstr(const char *, const char *);
203#endif
204
205#ifndef HAVE_STRLCPY
206RUBY_EXTERN size_t strlcpy(char *, const char*, size_t);
207#endif
208
209#ifndef HAVE_STRLCAT
210RUBY_EXTERN size_t strlcat(char *, const char*, size_t);
211#endif
212
213#ifndef HAVE_FFS
214RUBY_EXTERN int ffs(int);
215#endif
216
217#ifdef BROKEN_CLOSE
218# include <sys/types.h>
219# include <sys/socket.h>
220RUBY_EXTERN int ruby_getpeername(int, struct sockaddr *, socklen_t *);
221RUBY_EXTERN int ruby_getsockname(int, struct sockaddr *, socklen_t *);
222RUBY_EXTERN int ruby_shutdown(int, int);
223RUBY_EXTERN int ruby_close(int);
224#endif
225
226#ifndef HAVE_SETPROCTITLE
227RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 1, 2)
228RUBY_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
236RUBY_EXTERN void explicit_bzero(void *b, size_t len);
237#endif
238
239#ifndef HAVE_TZSET
240RUBY_EXTERN void tzset(void);
241#endif
242
243#ifndef HAVE_POSIX_MADVISE
244RUBY_EXTERN int posix_madvise(void *, size_t, int);
245#endif
246
247#ifndef HAVE_GETEUID
248RUBY_EXTERN rb_uid_t geteuid(void);
249#endif
250
251#ifndef HAVE_GETUID
252RUBY_EXTERN rb_uid_t getuid(void);
253#endif
254
255#ifndef HAVE_GETEGID
256RUBY_EXTERN rb_gid_t getegid(void);
257#endif
258
259#ifndef HAVE_GETGID
260RUBY_EXTERN rb_gid_t getgid(void);
261#endif
262
263#ifndef HAVE_GETLOGIN
264RUBY_EXTERN char *getlogin(void);
265#endif
266
267#ifndef HAVE_GETPPID
268RUBY_EXTERN rb_pid_t getppid(void);
269#endif
270
271#ifndef HAVE_UMASK
272RUBY_EXTERN rb_mode_t umask(rb_mode_t);
273#endif
274
275#ifndef HAVE_CHMOD
276RUBY_EXTERN int chmod(const char *, rb_mode_t);
277#endif
278
279#ifndef HAVE_CHOWN
280RUBY_EXTERN int chown(const char *, rb_uid_t, rb_gid_t);
281#endif
282
283#ifndef HAVE_PCLOSE
284RUBY_EXTERN int pclose(FILE *);
285#endif
286
287#ifndef HAVE_POPEN
288RUBY_EXTERN FILE *popen(const char *, const char *);
289#endif
290
291#ifndef HAVE_PIPE
292RUBY_EXTERN int pipe(int [2]);
293#endif
294
295#ifndef HAVE_DUP
296RUBY_EXTERN int dup(int);
297#endif
298
299#ifndef HAVE_DUP2
300RUBY_EXTERN int dup2(int, int);
301#endif
302
303#ifndef HAVE_KILL
304RUBY_EXTERN int kill(rb_pid_t, int);
305#endif
306
307#ifndef HAVE_EXECL
308RUBY_EXTERN int execl(const char *, const char *, ...);
309#endif
310
311#ifndef HAVE_EXECLE
312RUBY_EXTERN int execle(const char *, const char *, ...);
313#endif
314
315#ifndef HAVE_EXECV
316RUBY_EXTERN int execv(const char *, char *const []);
317#endif
318
319#ifndef HAVE_EXECVE
320RUBY_EXTERN int execve(const char *, char *const [], char *const []);
321#endif
322
323#ifndef HAVE_SHUTDOWN
324RUBY_EXTERN int shutdown(int, int);
325#endif
326
327#ifndef HAVE_SYSTEM
328RUBY_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
337RUBY_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:29
int len
Length of the buffer.
Definition io.h:8