Ruby 2.7.6p219 (2022-04-12 revision c9c2245c0a25176072e02db9254f0e0c84c805cd)
util.h
Go to the documentation of this file.
1/**********************************************************************
2
3 util.h -
4
5 $Author$
6 created at: Thu Mar 9 11:55:53 JST 1995
7
8 Copyright (C) 1993-2007 Yukihiro Matsumoto
9
10**********************************************************************/
11
12#ifndef RUBY_UTIL_H
13#define RUBY_UTIL_H 1
14
15#if defined(__cplusplus)
16extern "C" {
17#if 0
18} /* satisfy cc-mode */
19#endif
20#endif
21
22#include "ruby/defines.h"
23#ifdef RUBY_EXTCONF_H
24#include RUBY_EXTCONF_H
25#endif
26
27#ifndef _
28#ifdef __cplusplus
29# ifndef HAVE_PROTOTYPES
30# define HAVE_PROTOTYPES 1
31# endif
32# ifndef HAVE_STDARG_PROTOTYPES
33# define HAVE_STDARG_PROTOTYPES 1
34# endif
35#endif
36#ifdef HAVE_PROTOTYPES
37# define _(args) args
38#else
39# define _(args) ()
40#endif
41#ifdef HAVE_STDARG_PROTOTYPES
42# define __(args) args
43#else
44# define __(args) ()
45#endif
46#endif
47
49
50#define DECIMAL_SIZE_OF_BITS(n) (((n) * 3010 + 9998) / 9999)
51/* an approximation of ceil(n * log10(2)), up to 65536 at least */
52
53#define scan_oct(s,l,e) ((int)ruby_scan_oct((s),(l),(e)))
54unsigned long ruby_scan_oct(const char *, size_t, size_t *);
55#define scan_hex(s,l,e) ((int)ruby_scan_hex((s),(l),(e)))
56unsigned long ruby_scan_hex(const char *, size_t, size_t *);
57
58#ifdef HAVE_GNU_QSORT_R
59# define ruby_qsort qsort_r
60#else
61void ruby_qsort(void *, const size_t, const size_t,
62 int (*)(const void *, const void *, void *), void *);
63#endif
64
65void ruby_setenv(const char *, const char *);
66void ruby_unsetenv(const char *);
67
68char *ruby_strdup(const char *);
69#undef strdup
70#define strdup(s) ruby_strdup(s)
71
72char *ruby_getcwd(void);
73
74double ruby_strtod(const char *, char **);
75#undef strtod
76#define strtod(s,e) ruby_strtod((s),(e))
77
78void ruby_each_words(const char *, void (*)(const char*, int, void*), void *);
79
81
82#if defined(__cplusplus)
83#if 0
84{ /* satisfy cc-mode */
85#endif
86} /* extern "C" { */
87#endif
88
89#endif /* RUBY_UTIL_H */
#define RUBY_SYMBOL_EXPORT_BEGIN
#define RUBY_SYMBOL_EXPORT_END
unsigned long ruby_scan_oct(const char *, size_t, size_t *)
Definition: util.c:34
char * ruby_strdup(const char *)
Definition: util.c:527
unsigned long ruby_scan_hex(const char *, size_t, size_t *)
Definition: util.c:52
void ruby_setenv(const char *, const char *)
Definition: hash.c:4998
double ruby_strtod(const char *, char **)
void ruby_unsetenv(const char *)
Definition: hash.c:5137
void ruby_qsort(void *, const size_t, const size_t, int(*)(const void *, const void *, void *), void *)
char * ruby_getcwd(void)
Definition: util.c:539
void ruby_each_words(const char *, void(*)(const char *, int, void *), void *)
Definition: util.c:585