Ruby 3.0.5p211 (2022-11-24 revision ba5cf0f7c52d4d35cc6a173c89eda98ceffa2dcf)
missing.h
Go to the documentation of this file.
1#ifndef RUBY_MISSING_H /*-*-C++-*-vi:se ft=cpp:*/
2#define RUBY_MISSING_H 1
14
15#ifdef STDC_HEADERS
16# include <stddef.h>
17#endif
18
19#if defined(__cplusplus)
20# include <cmath>
21#else
22# include <math.h> /* for INFINITY and NAN */
23#endif
24
25#ifdef RUBY_ALTERNATIVE_MALLOC_HEADER
26# include RUBY_ALTERNATIVE_MALLOC_HEADER
27#endif
28
29#if defined(HAVE_TIME_H)
30# include <time.h>
31#endif
32
33#if defined(HAVE_SYS_TIME_H)
34# include <sys/time.h>
35#endif
36
37#ifdef HAVE_IEEEFP_H
38# include <ieeefp.h>
39#endif
40
42
43#ifndef M_PI
44# define M_PI 3.14159265358979323846
45#endif
46#ifndef M_PI_2
47# define M_PI_2 (M_PI/2)
48#endif
49
50#if !defined(HAVE_STRUCT_TIMEVAL)
51struct timeval {
52 time_t tv_sec; /* seconds */
53 long tv_usec; /* microseconds */
54};
55#endif /* HAVE_STRUCT_TIMEVAL */
56
57#if !defined(HAVE_STRUCT_TIMESPEC)
58/* :BEWARE: @shyouhei warns that IT IS A WRONG IDEA to define our own version
59 * of struct timespec here. `clock_gettime` is a system call, and your kernel
60 * could expect something other than just `long` (results stack smashing if
61 * that happens). See also https://ewontfix.com/19/ */
62struct timespec {
63 time_t tv_sec; /* seconds */
64 long tv_nsec; /* nanoseconds */
65};
66#endif
67
68#if !defined(HAVE_STRUCT_TIMEZONE)
69struct timezone {
72};
73#endif
74
76
77#ifndef HAVE_ACOSH
78RUBY_EXTERN double acosh(double);
79RUBY_EXTERN double asinh(double);
80RUBY_EXTERN double atanh(double);
81#endif
82
83#ifndef HAVE_CRYPT
84RUBY_EXTERN char *crypt(const char *, const char *);
85#endif
86
87#ifndef HAVE_DUP2
88RUBY_EXTERN int dup2(int, int);
89#endif
90
91#ifndef HAVE_EACCESS
92RUBY_EXTERN int eaccess(const char*, int);
93#endif
94
95#ifndef HAVE_ROUND
96RUBY_EXTERN double round(double); /* numeric.c */
97#endif
98
99#ifndef HAVE_FINITE
100RUBY_EXTERN int finite(double);
101#endif
102
103#ifndef HAVE_FLOCK
104RUBY_EXTERN int flock(int, int);
105#endif
106
107/*
108#ifndef HAVE_FREXP
109RUBY_EXTERN double frexp(double, int *);
110#endif
111*/
112
113#ifndef HAVE_HYPOT
114RUBY_EXTERN double hypot(double, double);
115#endif
116
117#ifndef HAVE_ERF
118RUBY_EXTERN double erf(double);
119RUBY_EXTERN double erfc(double);
120#endif
121
122#ifndef HAVE_TGAMMA
123RUBY_EXTERN double tgamma(double);
124#endif
125
126#ifndef HAVE_LGAMMA_R
127RUBY_EXTERN double lgamma_r(double, int *);
128#endif
129
130#ifndef HAVE_CBRT
131RUBY_EXTERN double cbrt(double);
132#endif
133
134#if !defined(INFINITY) || !defined(NAN)
136 unsigned char bytesequence[4];
138};
139#endif
140
141#ifndef INFINITY
144# define INFINITY (rb_infinity.float_value)
145# define USE_RB_INFINITY 1
146#endif
147
148#ifndef NAN
151# define NAN (rb_nan.float_value)
152# define USE_RB_NAN 1
153#endif
154
155#ifndef HUGE_VAL
156# define HUGE_VAL ((double)INFINITY)
157#endif
158
159#if defined(isinf)
160# /* Take that. */
161#elif defined(HAVE_ISINF)
162# /* Take that. */
163#elif defined(HAVE_FINITE) && defined(HAVE_ISNAN)
164# define isinf(x) (!finite(x) && !isnan(x))
165#elif defined(__cplusplus) && __cplusplus >= 201103L
166# // <cmath> must include constexpr bool isinf(double);
167#else
168RUBY_EXTERN int isinf(double);
169#endif
170
171#if defined(isnan)
172# /* Take that. */
173#elif defined(HAVE_ISNAN)
174# /* Take that. */
175#elif defined(__cplusplus) && __cplusplus >= 201103L
176# // <cmath> must include constexpr bool isnan(double);
177#else
178RUBY_EXTERN int isnan(double);
179#endif
180
181#if defined(isfinite)
182# /* Take that. */
183#elif defined(HAVE_ISFINITE)
184# /* Take that. */
185#else
186# define HAVE_ISFINITE 1
187# define isfinite(x) finite(x)
188#endif
189
190#ifndef HAVE_NAN
191RUBY_EXTERN double nan(const char *);
192#endif
193
194#ifndef HAVE_NEXTAFTER
195RUBY_EXTERN double nextafter(double x, double y);
196#endif
197
198/*
199#ifndef HAVE_MEMCMP
200RUBY_EXTERN int memcmp(const void *, const void *, size_t);
201#endif
202*/
203
204#ifndef HAVE_MEMMOVE
205RUBY_EXTERN void *memmove(void *, const void *, size_t);
206#endif
207
208/*
209#ifndef HAVE_MODF
210RUBY_EXTERN double modf(double, double *);
211#endif
212*/
213
214#ifndef HAVE_STRCHR
215RUBY_EXTERN char *strchr(const char *, int);
216RUBY_EXTERN char *strrchr(const char *, int);
217#endif
218
219#ifndef HAVE_STRERROR
220RUBY_EXTERN char *strerror(int);
221#endif
222
223#ifndef HAVE_STRSTR
224RUBY_EXTERN char *strstr(const char *, const char *);
225#endif
226
227#ifndef HAVE_STRLCPY
228RUBY_EXTERN size_t strlcpy(char *, const char*, size_t);
229#endif
230
231#ifndef HAVE_STRLCAT
232RUBY_EXTERN size_t strlcat(char *, const char*, size_t);
233#endif
234
235#ifndef HAVE_SIGNBIT
236RUBY_EXTERN int signbit(double x);
237#endif
238
239#ifndef HAVE_FFS
240RUBY_EXTERN int ffs(int);
241#endif
242
243#ifdef BROKEN_CLOSE
244# include <sys/types.h>
245# include <sys/socket.h>
246RUBY_EXTERN int ruby_getpeername(int, struct sockaddr *, socklen_t *);
247RUBY_EXTERN int ruby_getsockname(int, struct sockaddr *, socklen_t *);
248RUBY_EXTERN int ruby_shutdown(int, int);
249RUBY_EXTERN int ruby_close(int);
250#endif
251
252#ifndef HAVE_SETPROCTITLE
253RUBY_EXTERN void setproctitle(const char *fmt, ...);
254#endif
255
256#ifdef HAVE_EXPLICIT_BZERO
257# /* Take that. */
258#elif defined(SecureZeroMemory)
259# define explicit_bzero(b, len) SecureZeroMemory(b, len)
260#else
261RUBY_EXTERN void explicit_bzero(void *b, size_t len);
262#endif
263
265
266#endif /* RUBY_MISSING_H */
int ruby_getpeername(int s, struct sockaddr *name, socklen_t *namelen)
Definition: close.c:10
int ruby_close(int s)
Definition: close.c:60
int ruby_getsockname(int s, struct sockaddr *name, socklen_t *namelen)
Definition: close.c:27
int ruby_shutdown(int s, int how)
Definition: close.c:44
Tewaking visibility of C variables/functions.
#define RUBY_EXTERN
Definition: dllexport.h:36
#define RBIMPL_SYMBOL_EXPORT_END()
Counterpart of RBIMPL_SYMBOL_EXPORT_BEGIN.
Definition: dllexport.h:86
#define RBIMPL_SYMBOL_EXPORT_BEGIN()
Shortcut macro equivalent to RUBY_SYMBOL_EXPORT_BEGIN extern "C" {.
Definition: dllexport.h:77
uint8_t len
Definition: escape.c:17
int socklen_t
Definition: getaddrinfo.c:83
Thin wrapper to ruby/config.h.
double round(double)
Definition: numeric.c:92
int eaccess(const char *, int)
Definition: file.c:1529
const union bytesequence4_or_float rb_infinity
Definition: numeric.c:78
int dup2(int, int)
Definition: dup2.c:27
double hypot(double, double)
Definition: hypot.c:6
char * strstr(const char *, const char *)
Definition: strstr.c:8
char * strerror(int)
Definition: strerror.c:11
double erfc(double)
Definition: erf.c:81
int ffs(int)
Definition: ffs.c:6
char * strrchr(const char *, int)
Definition: strchr.c:20
size_t strlcat(char *, const char *, size_t)
Definition: strlcat.c:31
size_t strlcpy(char *, const char *, size_t)
Definition: strlcpy.c:29
double tgamma(double)
Definition: tgamma.c:66
int signbit(double x)
Definition: signbit.c:5
double nan(const char *)
Definition: nan.c:7
void * memmove(void *, const void *, size_t)
Definition: memmove.c:7
double atanh(double)
Definition: acosh.c:75
double acosh(double)
Definition: acosh.c:36
char * strchr(const char *, int)
Definition: strchr.c:8
char * crypt(const char *, const char *)
double lgamma_r(double, int *)
Definition: lgamma_r.c:63
int finite(double)
Definition: finite.c:6
const union bytesequence4_or_float rb_nan
Definition: numeric.c:85
double nextafter(double x, double y)
Definition: nextafter.c:9
void explicit_bzero(void *b, size_t len)
void setproctitle(const char *fmt,...)
Definition: setproctitle.c:139
double asinh(double)
Definition: acosh.c:52
double cbrt(double)
Definition: cbrt.c:4
int flock(int, int)
Definition: flock.c:125
double erf(double)
Definition: erf.c:71
int isinf(double n)
Definition: isinf.c:56
Internal header for Math.
long tv_nsec
Definition: missing.h:64
time_t tv_sec
Definition: missing.h:63
long tv_usec
Definition: missing.h:53
time_t tv_sec
Definition: missing.h:52
int tz_minuteswest
Definition: missing.h:70
int tz_dsttime
Definition: missing.h:71
unsigned char bytesequence[4]
Definition: missing.h:136
#define isnan(x)
Definition: win32.h:346