Ruby: include/ruby/util.h Source File

Ruby 3.0.5p211 (2022-11-24 revision ba5cf0f7c52d4d35cc6a173c89eda98ceffa2dcf)

util.h
Go to the documentation of this file.
1#ifndef RUBY_UTIL_H /*-*-C++-*-vi:se ft=cpp:*/
2#define RUBY_UTIL_H 1
13#include "ruby/internal/config.h"
14#include "ruby/internal/dllexport.h"
15#include "ruby/defines.h"
16
17 RBIMPL_SYMBOL_EXPORT_BEGIN()
18
19#define DECIMAL_SIZE_OF_BITS(n) (((n) * 3010 + 9998) / 9999)
20/* an approximation of ceil(n * log10(2)), up to 65536 at least */
21
22#define scan_oct(s,l,e) ((int)ruby_scan_oct((s),(l),(e)))
23unsigned long ruby_scan_oct(const char *, size_t, size_t *);
24#define scan_hex(s,l,e) ((int)ruby_scan_hex((s),(l),(e)))
25unsigned long ruby_scan_hex(const char *, size_t, size_t *);
26
27#ifdef HAVE_GNU_QSORT_R
28# define ruby_qsort qsort_r
29#else
30 void ruby_qsort(void *, const size_t, const size_t,
31 int (*)(const void *, const void *, void *), void *);
32#endif
33
34void ruby_setenv(const char *, const char *);
35void ruby_unsetenv(const char *);
36
37char *ruby_strdup(const char *);
38#undef strdup
39#define strdup(s) ruby_strdup(s)
40
41char *ruby_getcwd(void);
42
43 double ruby_strtod(const char *, char **);
44#undef strtod
45#define strtod(s,e) ruby_strtod((s),(e))
46
47void ruby_each_words(const char *, void (*)(const char*, int, void*), void *);
48
49 RBIMPL_SYMBOL_EXPORT_END()
50
51#endif /* RUBY_UTIL_H */
defines.h
dllexport.h
Tewaking visibility of C variables/functions.
RBIMPL_SYMBOL_EXPORT_END
#define RBIMPL_SYMBOL_EXPORT_END()
Counterpart of RBIMPL_SYMBOL_EXPORT_BEGIN.
Definition: dllexport.h:86
RBIMPL_SYMBOL_EXPORT_BEGIN
#define RBIMPL_SYMBOL_EXPORT_BEGIN()
Shortcut macro equivalent to RUBY_SYMBOL_EXPORT_BEGIN extern "C" {.
Definition: dllexport.h:77
config.h
Thin wrapper to ruby/config.h.
ruby_scan_oct
unsigned long ruby_scan_oct(const char *, size_t, size_t *)
Definition: util.c:38
ruby_strdup
char * ruby_strdup(const char *)
Definition: util.c:531
ruby_scan_hex
unsigned long ruby_scan_hex(const char *, size_t, size_t *)
Definition: util.c:56
ruby_setenv
void ruby_setenv(const char *, const char *)
Definition: hash.c:5145
ruby_strtod
double ruby_strtod(const char *, char **)
ruby_unsetenv
void ruby_unsetenv(const char *)
Definition: hash.c:5284
ruby_qsort
void ruby_qsort(void *, const size_t, const size_t, int(*)(const void *, const void *, void *), void *)
ruby_getcwd
char * ruby_getcwd(void)
Definition: util.c:543
ruby_each_words
void ruby_each_words(const char *, void(*)(const char *, int, void *), void *)
Definition: util.c:589