Ruby 2.0.0p353(2013-11-22revision43784)

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

Data Structures | Macros | Typedefs | Functions | Variables
util.c File Reference
`#include "ruby/ruby.h"`
`#include "internal.h"`
`#include <ctype.h>`
`#include <stdio.h>`
`#include <errno.h>`
`#include <math.h>`
`#include <float.h>`
`#include "ruby/util.h"`
`#include <sys/types.h>`
`#include <sys/stat.h>`
`#include "stdlib.h"`
`#include "string.h"`
Include dependency graph for util.c:

Go to the source code of this file.

## Data Structures
struct | stack_node
union | U
struct | Bigint

## Macros
#define | S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
#define | mmtype long
#define | mmcount (16 / SIZEOF_LONG)
#define | A ((mmtype*)a)
#define | B ((mmtype*)b)
#define | C ((mmtype*)c)
#define | D ((mmtype*)d)
#define | mmstep (sizeof(mmtype) * mmcount)
#define | mmprepare(base, size)
#define | mmarg mmkind, size, high, low
#define | mmargdecl int mmkind, size_t size, size_t high, size_t low
#define | mmswap(a, b) mmswap_((a),(b),mmarg)
#define | mmrot3(a, b, c) mmrot3_((a),(b),(c),mmarg)
#define | PUSH(ll, rr) do { top->LL = (ll); top->RR = (rr); ++top; } while (0) /* Push L,l,R,r */
#define | POP(ll, rr) do { --top; (ll) = top->LL; (rr) = top->RR; } while (0) /* Pop L,l,R,r */
#define | med3(a, b, c)
#define | PATH_MAX 8192
#define | IEEE_LITTLE_ENDIAN
#define | MALLOC malloc
#define | FREE free
#define | PRIVATE_MEM 2304
#define | PRIVATE_mem ((PRIVATE_MEM+sizeof(double)-1)/sizeof(double))
#define | IEEE_Arith
#define | word0(x) ((x).L[1])
#define | word1(x) ((x).L[0])
#define | dval(x) ((x).d)
#define | Storeinc(a, b, c)
#define | Exp_shift 20
#define | Exp_shift1 20
#define | Exp_msk1 0x100000
#define | Exp_msk11 0x100000
#define | Exp_mask 0x7ff00000
#define | P 53
#define | Bias 1023
#define | Emin (-1022)
#define | Exp_1 0x3ff00000
#define | Exp_11 0x3ff00000
#define | Ebits 11
#define | Frac_mask 0xfffff
#define | Frac_mask1 0xfffff
#define | Ten_pmax 22
#define | Bletch 0x10
#define | Bndry_mask 0xfffff
#define | Bndry_mask1 0xfffff
#define | LSB 1
#define | Sign_bit 0x80000000
#define | Log2P 1
#define | Tiny0 0
#define | Tiny1 1
#define | Quick_max 14
#define | Int_max 14
#define | Avoid_Underflow
#define | Flt_Rounds 1
#define | Rounding Flt_Rounds
#define | rounded_product(a, b) ((a) *= (b))
#define | rounded_quotient(a, b) ((a) /= (b))
#define | Big0 (Frac_mask1 | Exp_msk1*(DBL_MAX_EXP+Bias-1))
#define | Big1 0xffffffff
#define | Pack_32
#define | FFFFFFFF 0xffffffffUL
#define | Llong long long
#define | ULLong unsigned Llong
#define | MULTIPLE_THREADS 1
#define | ACQUIRE_DTOA_LOCK(n) /*unused right now*/
#define | FREE_DTOA_LOCK(n) /*unused right now*/
#define | Kmax 15
#define | Bcopy(x, y)
#define | d0 word0(d)
#define | d1 word1(d)
#define | d0 word0(d)
#define | d1 word1(d)
#define | Scale_Bit 0x10
#define | n_bigtens 5
#define | rv_alloc(i) xmalloc(i)
#define | rv_strdup(s, rve) nrv_alloc((s), (rve), strlen(s)+1)
#define | DBL_MANH_SIZE 20
#define | DBL_MANL_SIZE 32
#define | DBL_ADJ (DBL_MAX_EXP - 2)
#define | SIGFIGS ((DBL_MANT_DIG + 3) / 4 + 1)
#define | dexp_get(u) ((int)(word0(u) >> Exp_shift) & ~Exp_msk1)
#define | dexp_set(u, v) (word0(u) = (((int)(word0(u)) & ~Exp_mask) | ((v) << Exp_shift)))
#define | dmanh_get(u) ((uint32_t)(word0(u) & Frac_mask))
#define | dmanl_get(u) ((uint32_t)word1(u))

## Typedefs
typedef int( | cmpfunc_t )(const void *, const void *, void *)
typedef U | double_u
typedef struct Bigint | Bigint

## Functions
unsigned long | ruby_scan_oct (const char *start, size_t len, size_t *retlen)
unsigned long | ruby_scan_hex (const char *start, size_t len, size_t *retlen)
static unsigned long | scan_digits (const char *str, int base, size_t *retlen, int *overflow)
unsigned long | ruby_strtoul (const char *str, char **endptr, int base)
static void | mmswap_ (register char *a, register char *b, mmargdecl)
static void | mmrot3_ (register char *a, register char *b, register char *c, mmargdecl)
void | ruby_qsort (void *base, const size_t nel, const size_t size, cmpfunc_t *cmp, void *d)
char * | ruby_strdup (const char *str)
char * | ruby_getcwd (void)
static Bigint * | Balloc (int k)
static void | Bfree (Bigint *v)
static Bigint * | multadd (Bigint *b, int m, int a)
static Bigint * | s2b (const char *s, int nd0, int nd, ULong y9)
static int | hi0bits (register ULong x)
static int | lo0bits (ULong *y)
static Bigint * | i2b (int i)
static Bigint * | mult (Bigint *a, Bigint *b)
static Bigint * | pow5mult (Bigint *b, int k)
static Bigint * | lshift (Bigint *b, int k)
static int | cmp (Bigint *a, Bigint *b)
static Bigint * | diff (Bigint *a, Bigint *b)
static double | ulp (double x_)
static double | b2d (Bigint *a, int *e)
static Bigint * | d2b (double d_, int *e, int *bits)
static double | ratio (Bigint *a, Bigint *b)
double | ruby_strtod (const char *s00, char **se)
static int | quorem (Bigint *b, Bigint *S)
static char * | nrv_alloc (const char *s, char **rve, size_t n)
char * | ruby_dtoa (double d_, int mode, int ndigits, int *decpt, int *sign, char **rve)
void | ruby_each_words (const char *str, void(*func)(const char *, int, void *), void *arg)
char * | ruby_hdtoa (double d, const char *xdigs, int ndigits, int *decpt, int *sign, char **rve)

## Variables
static double | private_mem [PRIVATE_mem]
static double * | pmem_next = private_mem
static Bigint * | freelist [Kmax+1]
static Bigint * | p5s
static const double | tens []
static const double | bigtens [] = { 1e16, 1e32, 1e64, 1e128, 1e256 }
static const double | tinytens []
static const char | INFSTR [] = "Infinity"
static const char | NANSTR [] = "NaN"
static const char | ZEROSTR [] = "0"

## Macro Definition Documentation

#define A ((mmtype*)a)

Definition at line 192 of file util.c.

Referenced by mmrot3_(), and mmswap_().

#define ACQUIRE_DTOA_LOCK | ( |  | n | ) | /*unused right now*/

Definition at line 987 of file util.c.

Referenced by Balloc(), Bfree(), and pow5mult().

#define Avoid_Underflow

Definition at line 857 of file util.c.

Referenced by ruby_strtod().

#define B ((mmtype*)b)

Definition at line 193 of file util.c.

Referenced by mmrot3_(), and mmswap_().

#define Bcopy | ( |  | x,
|  |  | y
| ) |  |

Value:
memcpy((char *)&(x)->sign, (char *)&(y)->sign, \
(y)->wds*sizeof(Long) + 2*sizeof(int))
memcpy
memcpy(buf+1, str, len)

Definition at line 1053 of file util.c.

Referenced by multadd(), ruby_dtoa(), and ruby_strtod().

#define Bias 1023

Definition at line 838 of file util.c.

Referenced by d2b(), ruby_dtoa(), and ruby_strtod().

#define Big0 (Frac_mask1 | Exp_msk1*(DBL_MAX_EXP+Bias-1))

Definition at line 953 of file util.c.

Referenced by ruby_strtod().

#define Big1 0xffffffff

Definition at line 954 of file util.c.

Referenced by ruby_strtod().

#define Bletch 0x10

Definition at line 846 of file util.c.

Referenced by ruby_dtoa().

#define Bndry_mask 0xfffff

Definition at line 847 of file util.c.

Referenced by ruby_dtoa(), and ruby_strtod().

#define Bndry_mask1 0xfffff

Definition at line 848 of file util.c.

Referenced by ruby_strtod().

#define C ((mmtype*)c)

Definition at line 194 of file util.c.

Referenced by get_event_id(), mmrot3_(), and symbol2event_flag().

#define D ((mmtype*)d)

Definition at line 195 of file util.c.

#define d0 word0(d)

Referenced by b2d(), d2b(), math_acos(), math_acosh(), math_asin(), math_atanh(), math_gamma(), math_lgamma(), math_log(), math_log10(), math_log2(), and math_sqrt().

#define d0 word0(d)

#define d1 word1(d)

Referenced by b2d(), d2b(), and inet_pton().

#define d1 word1(d)

#define DBL_ADJ (DBL_MAX_EXP - 2)

Definition at line 3808 of file util.c.

Referenced by ruby_hdtoa().

#define DBL_MANH_SIZE 20

Definition at line 3806 of file util.c.

Referenced by ruby_hdtoa().

#define DBL_MANL_SIZE 32

Definition at line 3807 of file util.c.

Referenced by ruby_hdtoa().

#define dexp_get | ( |  | u | ) | ((int)(word0(u) >> Exp_shift) & ~Exp_msk1)

Definition at line 3810 of file util.c.

Referenced by ruby_hdtoa().

#define dexp_set | ( |  | u,
|  |  | v
| ) |  | (word0(u) = (((int)(word0(u)) & ~Exp_mask) | ((v) << Exp_shift)))

Definition at line 3811 of file util.c.

Referenced by ruby_hdtoa().

#define dmanh_get | ( |  | u | ) | ((uint32_t)(word0(u) & Frac_mask))

Definition at line 3812 of file util.c.

Referenced by ruby_hdtoa().

#define dmanl_get | ( |  | u | ) | ((uint32_t)word1(u))

Definition at line 3813 of file util.c.

Referenced by ruby_hdtoa().

#define dval | ( |  | x | ) | ((x).d)

Definition at line 810 of file util.c.

Referenced by b2d(), d2b(), ratio(), ruby_dtoa(), ruby_strtod(), and ulp().

#define Ebits 11

Definition at line 842 of file util.c.

Referenced by b2d().

#define Emin (-1022)

Definition at line 839 of file util.c.

Referenced by ruby_strtod().

#define Exp_1 0x3ff00000

Definition at line 840 of file util.c.

Referenced by b2d(), ruby_dtoa(), and ruby_strtod().

#define Exp_11 0x3ff00000

Definition at line 841 of file util.c.

Referenced by ruby_dtoa().

#define Exp_mask 0x7ff00000

Definition at line 836 of file util.c.

Referenced by ruby_dtoa(), ruby_strtod(), and ulp().

#define Exp_msk1 0x100000

Definition at line 834 of file util.c.

Referenced by d2b(), ratio(), ruby_dtoa(), ruby_strtod(), and ulp().

#define Exp_msk11 0x100000

Definition at line 835 of file util.c.

Referenced by d2b().

#define Exp_shift 20

Definition at line 832 of file util.c.

Referenced by d2b(), ruby_dtoa(), ruby_strtod(), and ulp().

#define Exp_shift1 20

Definition at line 833 of file util.c.

Referenced by ruby_dtoa().

#define FFFFFFFF 0xffffffffUL

Definition at line 960 of file util.c.

Referenced by diff(), mult(), multadd(), and quorem().

#define Flt_Rounds 1

Definition at line 867 of file util.c.

Referenced by ruby_dtoa(), and ruby_strtod().

#define Frac_mask 0xfffff

Definition at line 843 of file util.c.

Referenced by d2b(), ruby_dtoa(), and ruby_strtod().

#define Frac_mask1 0xfffff

Definition at line 844 of file util.c.

Referenced by ruby_dtoa().

#define FREE free

Definition at line 721 of file util.c.

Referenced by Bfree().

#define FREE_DTOA_LOCK | ( |  | n | ) | /*unused right now*/

Definition at line 988 of file util.c.

Referenced by Balloc(), Bfree(), and pow5mult().

#define IEEE_Arith

Definition at line 738 of file util.c.

Referenced by ruby_strtod().

#define IEEE_LITTLE_ENDIAN

Definition at line 672 of file util.c.

#define Int_max 14

Definition at line 855 of file util.c.

Referenced by ruby_dtoa().

#define Kmax 15

Definition at line 991 of file util.c.

Referenced by Balloc(), and Bfree().

#define Llong long long

Definition at line 974 of file util.c.

#define Log2P 1

Definition at line 851 of file util.c.

Referenced by ruby_dtoa(), and ruby_strtod().

#define LSB 1

Definition at line 849 of file util.c.

Referenced by ruby_strtod().

#define MALLOC malloc

Definition at line 716 of file util.c.

Referenced by Balloc().

#define med3 | ( |  | a,
|  |  | b,
|  |  | c
| ) |  |

Value:
((*cmp)((a),(b),d)<0 ? \
((*cmp)((b),(c),d)<0 ? (b) : ((*cmp)((a),(c),d)<0 ? (c) : (a))) : \
((*cmp)((b),(c),d)>0 ? (b) : ((*cmp)((a),(c),d)<0 ? (a) : (c))))
a
Real * a
Definition: bigdecimal.c:1182
d
d
Definition: strlcat.c:58
cmp
static int cmp(Bigint *a, Bigint *b)
Definition: util.c:1434
b
Real * b
Definition: bigdecimal.c:1182
c
VpDivd * c
Definition: bigdecimal.c:1205

Definition at line 299 of file util.c.

Referenced by ruby_qsort().

#define mmarg mmkind, size, high, low

Definition at line 207 of file util.c.

#define mmargdecl int mmkind, size_t size, size_t high, size_t low

Definition at line 208 of file util.c.

#define mmcount (16 / SIZEOF_LONG)

Definition at line 191 of file util.c.

#define mmprepare | ( |  | base,
|  |  | size
| ) |  |

Value:
do {\
if (((VALUE)(base) % sizeof(mmtype)) == 0 && ((size) % sizeof(mmtype)) == 0) \
if ((size) >= mmstep) mmkind = 1;\
else mmkind = 0;\
else mmkind = -1;\
high = ((size) / mmstep) * mmstep;\
low = ((size) % mmstep);\
} while (0)\
mmstep
#define mmstep
Definition: util.c:197
while
while(a->frac[0]/shift==0)
Definition: bigdecimal.c:5117
else
else
Definition: bigdecimal.c:1192
mmtype
#define mmtype
Definition: util.c:190
size
int size
Definition: encoding.c:52
if
if(RB_TYPE_P(r, T_FLOAT))
Definition: bigdecimal.c:1186
VALUE
unsigned long VALUE
Definition: ripper.y:104

Definition at line 198 of file util.c.

Referenced by ruby_qsort().

#define mmrot3 | ( |  | a,
|  |  | b,
|  |  | c
| ) |  | mmrot3_((a),(b),(c),mmarg)

Definition at line 284 of file util.c.

Referenced by ruby_qsort().

#define mmstep (sizeof(mmtype) * mmcount)

Definition at line 197 of file util.c.

Referenced by mmrot3_(), and mmswap_().

#define mmswap | ( |  | a,
|  |  | b
| ) |  | mmswap_((a),(b),mmarg)

Definition at line 246 of file util.c.

Referenced by ruby_qsort().

#define mmtype long

Definition at line 190 of file util.c.

Referenced by mmrot3_(), and mmswap_().

#define MULTIPLE_THREADS 1

Definition at line 981 of file util.c.

#define n_bigtens 5

Definition at line 1848 of file util.c.

Referenced by ruby_dtoa(), and ruby_strtod().

#define P 53

Definition at line 837 of file util.c.

Referenced by d2b(), ruby_dtoa(), ruby_strtod(), and ulp().

#define Pack_32

Definition at line 957 of file util.c.

#define PATH_MAX 8192

Referenced by ruby_getcwd().

#define POP | ( |  | ll,
|  |  | rr
| ) |  | do { --top; (ll) = top->LL; (rr) = top->RR; } while (0) /* Pop L,l,R,r */

Definition at line 297 of file util.c.

Referenced by ruby_qsort().

#define PRIVATE_MEM 2304

Definition at line 726 of file util.c.

#define PRIVATE_mem ((PRIVATE_MEM+sizeof(double)-1)/sizeof(double))

Definition at line 728 of file util.c.

Referenced by Balloc().

#define PUSH | ( |  | ll,
|  |  | rr
| ) |  | do { top->LL = (ll); top->RR = (rr); ++top; } while (0) /* Push L,l,R,r */

Definition at line 296 of file util.c.

Referenced by ruby_qsort().

#define Quick_max 14

Definition at line 854 of file util.c.

Referenced by ruby_dtoa().

#define rounded_product | ( |  | a,
|  |  | b
| ) |  | ((a) *= (b))

Definition at line 949 of file util.c.

Referenced by ruby_strtod().

#define rounded_quotient | ( |  | a,
|  |  | b
| ) |  | ((a) /= (b))

Definition at line 950 of file util.c.

Referenced by ruby_strtod().

#define Rounding Flt_Rounds

Definition at line 876 of file util.c.

Referenced by ruby_dtoa(), and ruby_strtod().

#define rv_alloc | ( |  | i | ) | xmalloc(i)

Definition at line 3021 of file util.c.

Referenced by nrv_alloc(), ruby_dtoa(), and ruby_hdtoa().

#define rv_strdup | ( |  | s,
|  |  | rve
| ) |  | nrv_alloc((s), (rve), strlen(s)+1)

Definition at line 3036 of file util.c.

Referenced by ruby_dtoa(), and ruby_hdtoa().

#define S_ISDIR | ( |  | m | ) | (((m) & S_IFMT) == S_IFDIR)

Definition at line 184 of file util.c.

#define Scale_Bit 0x10

Definition at line 1847 of file util.c.

Referenced by ruby_strtod().

#define SIGFIGS ((DBL_MANT_DIG + 3) / 4 + 1)

Definition at line 3809 of file util.c.

Referenced by ruby_hdtoa().

#define Sign_bit 0x80000000

Definition at line 850 of file util.c.

Referenced by ruby_dtoa(), and ruby_hdtoa().

#define Storeinc | ( |  | a,
|  |  | b,
|  |  | c
| ) |  |

Value:
(((unsigned short *)(a))[1] = (unsigned short)(b), \
((unsigned short *)(a))[0] = (unsigned short)(c), (a)++)
a
Real * a
Definition: bigdecimal.c:1182
b
Real * b
Definition: bigdecimal.c:1182
c
VpDivd * c
Definition: bigdecimal.c:1205

Definition at line 818 of file util.c.

Referenced by diff(), mult(), and quorem().

#define Ten_pmax 22

Definition at line 845 of file util.c.

Referenced by ruby_dtoa(), and ruby_strtod().

#define Tiny0 0

Definition at line 852 of file util.c.

Referenced by ruby_strtod().

#define Tiny1 1

Definition at line 853 of file util.c.

Referenced by ruby_strtod().

#define ULLong unsigned Llong

Definition at line 977 of file util.c.

Referenced by diff(), mult(), multadd(), and quorem().

#define word0 | ( |  | x | ) | ((x).L[1])

Definition at line 804 of file util.c.

Referenced by b2d(), d2b(), ratio(), ruby_dtoa(), ruby_hdtoa(), ruby_strtod(), and ulp().

#define word1 | ( |  | x | ) | ((x).L[0])

Definition at line 805 of file util.c.

Referenced by b2d(), d2b(), ruby_dtoa(), ruby_strtod(), and ulp().

## Typedef Documentation

typedef struct Bigint Bigint

Definition at line 999 of file util.c.

typedef int( cmpfunc_t)(const void *, const void *, void *)

Definition at line 303 of file util.c.

typedef U double_u

Definition at line 802 of file util.c.

## Function Documentation

static double b2d | ( | Bigint * | a,
|  | int * | e
| ) |  |
| static

Definition at line 1587 of file util.c.

References d, d0, d1, dval, Ebits, Exp_1, hi0bits(), Bigint::k, Bigint::wds, word0, word1, and Bigint::x.

Referenced by ratio().

static Bigint* Balloc | ( | int | k | ) |
| static

Definition at line 1004 of file util.c.

References ACQUIRE_DTOA_LOCK, FREE_DTOA_LOCK, Bigint::k, Kmax, len, MALLOC, Bigint::maxwds, Bigint::next, pmem_next, PRIVATE_mem, private_mem, Bigint::sign, Bigint::wds, and Bigint::x.

Referenced by d2b(), diff(), i2b(), lshift(), mult(), multadd(), ruby_dtoa(), ruby_strtod(), and s2b().

static void Bfree | ( | Bigint * | v | ) |
| static

Definition at line 1039 of file util.c.

References ACQUIRE_DTOA_LOCK, FREE, FREE_DTOA_LOCK, Bigint::k, Kmax, Bigint::next, and v.

Referenced by lshift(), multadd(), pow5mult(), ruby_dtoa(), and ruby_strtod().

static int cmp | ( | Bigint * | a,
|  | Bigint * | b
| ) |  |
| static

Definition at line 1434 of file util.c.

References i, Bigint::wds, and Bigint::x.

Referenced by diff(), quorem(), ruby_dtoa(), and ruby_strtod().

static Bigint* d2b | ( | double | d_,
|  | int * | e,
|  | int * | bits
| ) |  |
| static

Definition at line 1652 of file util.c.

References b, Balloc(), Bias, d, d0, d1, dval, Exp_msk1, Exp_msk11, Exp_shift, Frac_mask, hi0bits(), i, int, Bigint::k, lo0bits(), P, Bigint::wds, word0, word1, and Bigint::x.

Referenced by ruby_dtoa(), and ruby_strtod().

static Bigint* diff | ( | Bigint * | a,
|  | Bigint * | b
| ) |  |
| static

Definition at line 1463 of file util.c.

References a, b, Balloc(), c, cmp(), FFFFFFFF, i, Bigint::k, Bigint::sign, Storeinc, ULLong, Bigint::wds, and Bigint::x.

Referenced by num_interval_step_size(), num_step(), pair_byte_cmp(), rb_dlptr_cmp(), rb_fiddle_ptr_cmp(), ruby_dtoa(), and ruby_strtod().

static int hi0bits | ( | register ULong | x | ) |
| static

Definition at line 1142 of file util.c.

References Bigint::k.

Referenced by b2d(), d2b(), and ruby_dtoa().

static Bigint* i2b | ( | int | i | ) |
| static

Definition at line 1214 of file util.c.

References b, Balloc(), i, Bigint::wds, and Bigint::x.

Referenced by pow5mult(), ruby_dtoa(), and ruby_strtod().

static int lo0bits | ( | ULong * | y | ) |
| static

Definition at line 1171 of file util.c.

References Bigint::k, and Bigint::x.

Referenced by d2b().

static Bigint* lshift | ( | Bigint * | b,
|  | int | k
| ) |  |
| static

Definition at line 1380 of file util.c.

References Balloc(), Bfree(), i, Bigint::k, Bigint::maxwds, n, Bigint::wds, and Bigint::x.

Referenced by ruby_dtoa(), and ruby_strtod().

static void mmrot3_ | ( | register char * | a,
|  | register char * | b,
|  | register char * | c,
|  | mmargdecl |
| ) |  |
| static

Definition at line 249 of file util.c.

References A, a, B, b, C, c, mmstep, mmtype, s, size, and t.

static void mmswap_ | ( | register char * | a,
|  | register char * | b,
|  | mmargdecl |
| ) |  |
| static

Definition at line 210 of file util.c.

References A, a, B, b, mmstep, mmtype, s, size, and t.

static Bigint* mult | ( | Bigint * | a,
|  | Bigint * | b
| ) |  |
| static

Definition at line 1225 of file util.c.

References a, b, Balloc(), c, FFFFFFFF, Bigint::k, Bigint::maxwds, Storeinc, ULLong, Bigint::wds, and Bigint::x.

Referenced by iseq_specialized_instruction(), pow5mult(), ruby_dtoa(), and ruby_strtod().

static Bigint* multadd | ( | Bigint * | b,
|  | int | m,
|  | int | a
| ) |  |
| static

Definition at line 1057 of file util.c.

References a, b, Balloc(), Bcopy, Bfree(), FFFFFFFF, i, Bigint::k, Bigint::maxwds, ULLong, Bigint::wds, and Bigint::x.

Referenced by pow5mult(), ruby_dtoa(), and s2b().

static char* nrv_alloc | ( | const char * | s,
|  | char ** | rve,
|  | size_t | n
| ) |  |
| static

Definition at line 3025 of file util.c.

References rv_alloc, and t.

static Bigint* pow5mult | ( | Bigint * | b,
|  | int | k
| ) |  |
| static

Definition at line 1328 of file util.c.

References ACQUIRE_DTOA_LOCK, b, Bfree(), FREE_DTOA_LOCK, i, i2b(), mult(), multadd(), and Bigint::next.

Referenced by ruby_dtoa(), and ruby_strtod().

static int quorem | ( | Bigint * | b,
|  | Bigint * | S
| ) |  |
| static

Definition at line 2900 of file util.c.

References cmp(), FFFFFFFF, n, q, Storeinc, ULLong, Bigint::wds, and Bigint::x.

Referenced by ruby_dtoa().

static double ratio | ( | Bigint * | a,
|  | Bigint * | b
| ) |  |
| static

Definition at line 1789 of file util.c.

References b2d(), dval, Exp_msk1, Bigint::k, Bigint::wds, and word0.

Referenced by ruby_strtod().

char* ruby_dtoa | ( | double | d_,
|  | int | mode,
|  | int | ndigits,
|  | int * | decpt,
|  | int * | sign,
|  | char ** | rve
| ) |  |

Definition at line 3091 of file util.c.

References b, Balloc(), Bcopy, Bfree(), Bias, bigtens, Bletch, Bndry_mask, cmp(), d, d2b(), diff(), dval, Exp_1, Exp_11, Exp_mask, Exp_msk1, Exp_shift, Exp_shift1, Flt_Rounds, Frac_mask, Frac_mask1, hi0bits(), i, i2b(), int, Int_max, Bigint::k, Log2P, lshift(), mult(), multadd(), n_bigtens, no_digits, P, pow5mult(), Quick_max, quorem(), ret, Rounding, rv_alloc, rv_strdup, s, S, Bigint::sign, Sign_bit, Ten_pmax, tens, Bigint::wds, word0, word1, and Bigint::x.

Referenced by flo_to_s(), and w_float().

void ruby_each_words | ( | const char * | str,
|  | void(*)(const char *, int, void *) | func,
|  | void * | arg
| ) |  |

Definition at line 3764 of file util.c.

References arg, end, int, ISSPACE, len, and str.

Referenced by proc_options(), and ruby_set_debug_option().

char* ruby_getcwd | ( | void |  | ) |

Definition at line 475 of file util.c.

References buf, errno, PATH_MAX, rb_sys_fail(), size, xfree, xmalloc, and xrealloc.

char* ruby_hdtoa | ( | double | d,
|  | const char * | xdigs,
|  | int | ndigits,
|  | int * | decpt,
|  | int * | sign,
|  | char ** | rve
| ) |  |

Definition at line 3841 of file util.c.

References bufsize, d, U::d, DBL_ADJ, DBL_MANH_SIZE, DBL_MANL_SIZE, DBL_MANT_DIG, DBL_MAX_EXP, dexp_get, dexp_set, dmanh_get, dmanl_get, isinf(), isnan, NULL, rv_alloc, rv_strdup, s, SIGFIGS, Sign_bit, and word0.

void ruby_qsort | ( | void * | base,
|  | const size_t | nel,
|  | const size_t | size,
|  | cmpfunc_t * | cmp,
|  | void * | d
| ) |  |

Definition at line 305 of file util.c.

References fail, m, med3, mmprepare, mmrot3, mmswap, n, p, POP, PUSH, R, r, size, t, and top.

unsigned long ruby_scan_hex | ( | const char * | start,
|  | size_t | len,
|  | size_t * | retlen
| ) |  |

Definition at line 42 of file util.c.

References int, retval, s, strchr(), and tmp.

Referenced by unescape_unicode_bmp(), and unescape_unicode_list().

unsigned long ruby_scan_oct | ( | const char * | start,
|  | size_t | len,
|  | size_t * | retlen
| ) |  |

Definition at line 28 of file util.c.

References int, retval, and s.

Referenced by parser_tokadd_escape(), and unescape_nonascii().

char* ruby_strdup | ( | const char * | str | ) |

Definition at line 454 of file util.c.

References len, memcpy(), strlen(), tmp, and xmalloc.

Referenced by argf_initialize_copy(), compat_init_setproctitle(), features_index_add_single(), load_lock(), register_init_ext(), ruby_setenv(), and yycompile().

double ruby_strtod | ( | const char * | s00,
|  | char ** | se
| ) |  |

Definition at line 1942 of file util.c.

References Avoid_Underflow, Balloc(), Bcopy, Bfree(), Bias, Big0, Big1, bigtens, Bndry_mask, Bndry_mask1, c, cmp(), d2b(), DBL_DIG, DBL_MAX_10_EXP, DBL_MAX_EXP, diff(), dval, e, Emin, errno, Exp_1, Exp_mask, Exp_msk1, Exp_shift, FLT_RADIX, Flt_Rounds, Frac_mask, i, i2b(), IEEE_Arith, int, ISDIGIT, Bigint::k, Log2P, LSB, lshift(), match(), mult(), n_bigtens, nf, NULL, P, pow5mult(), ratio(), ret, rounded_product, rounded_quotient, Rounding, s, s2b(), Scale_Bit, Bigint::sign, strchr(), Ten_pmax, tens, Tiny0, Tiny1, tinytens, ulp(), Bigint::wds, word0, word1, and Bigint::x.

unsigned long ruby_strtoul | ( | const char * | str,
|  | char ** | endptr,
|  | int | base
| ) |  |

Definition at line 106 of file util.c.

References b, c, errno, ISSPACE, len, ret, scan_digits(), and str.

static Bigint* s2b | ( | const char * | s,
|  | int | nd0,
|  | int | nd,
|  | ULong | y9
| ) |  |
| static

Definition at line 1108 of file util.c.

References b, Balloc(), i, Bigint::k, multadd(), Bigint::wds, and Bigint::x.

Referenced by ruby_strtod().

static unsigned long scan_digits | ( | const char * | str,
|  | int | base,
|  | size_t * | retlen,
|  | int * | overflow
| ) |  |
| static

Definition at line 59 of file util.c.

References c, d, ret, str, and table.

Referenced by ruby_strtoul().

static double ulp | ( | double | x_ | ) |
| static

Definition at line 1549 of file util.c.

References a, dval, Exp_mask, Exp_msk1, Exp_shift, P, word0, word1, and Bigint::x.

Referenced by ruby_strtod().

## Variable Documentation

const double bigtens[] = { 1e16, 1e32, 1e64, 1e128, 1e256 }
| static

Definition at line 1836 of file util.c.

Referenced by ruby_dtoa(), and ruby_strtod().

Bigint* freelist[Kmax+1]
| static

Definition at line 1001 of file util.c.

const char INFSTR[] = "Infinity"
| static

Definition at line 3052 of file util.c.

const char NANSTR[] = "NaN"
| static

Definition at line 3053 of file util.c.

Bigint* p5s
| static

Definition at line 1325 of file util.c.

double * pmem_next = private_mem
| static

Definition at line 729 of file util.c.

Referenced by Balloc().

double private_mem[PRIVATE_mem]
| static

Definition at line 729 of file util.c.

Referenced by Balloc().

const double tens[]
| static

Initial value:
= {
1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9,
1e10, 1e11, 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19,
1e20, 1e21, 1e22
}

Definition at line 1825 of file util.c.

Referenced by ruby_dtoa(), and ruby_strtod().

const double tinytens[]
| static

Initial value:
= { 1e-16, 1e-32, 1e-64, 1e-128,
9007199254740992.*9007199254740992.e-256
}
e
BDIGIT e
Definition: bigdecimal.c:5085

Definition at line 1837 of file util.c.

Referenced by ruby_strtod().

const char ZEROSTR[] = "0"
| static

Definition at line 3054 of file util.c.