Ruby
2.5.0dev(2017-10-22revision60238)
|
#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"
Go to the source code of this file.
Data Structures | |
struct | stack_node |
union | U |
struct | Bigint |
Macros | |
#define | hexdigit ruby_hexdigits |
#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 xmalloc |
#define | FREE xfree |
#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) |
unsigned long | ruby_scan_digits (const char *str, ssize_t len, int base, size_t *retlen, int *overflow) |
unsigned long | ruby_strtoul (const char *str, char **endptr, int base) |
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) |
double | ruby_strtod (const char *s00, char **se) |
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 | |
const char | ruby_hexdigits [] = "0123456789abcdef0123456789ABCDEF" |
const signed char | ruby_digit36_to_number_table [] |
#define Bcopy | ( | x, | |
y | |||
) |
#define Big0 (Frac_mask1 | Exp_msk1*(DBL_MAX_EXP+Bias-1)) |
#define d0 word0(d) |
#define d0 word0(d) |
#define d1 word1(d) |
#define d1 word1(d) |
#define DBL_ADJ (DBL_MAX_EXP - 2) |
Definition at line 3866 of file util.c.
Referenced by ruby_hdtoa().
#define DBL_MANH_SIZE 20 |
Definition at line 3864 of file util.c.
Referenced by ruby_hdtoa().
#define DBL_MANL_SIZE 32 |
Definition at line 3865 of file util.c.
Referenced by ruby_hdtoa().
Definition at line 3868 of file util.c.
Referenced by ruby_hdtoa().
Definition at line 3869 of file util.c.
Referenced by ruby_hdtoa().
Definition at line 3870 of file util.c.
Referenced by ruby_hdtoa().
Definition at line 3871 of file util.c.
Referenced by ruby_hdtoa().
#define dval | ( | x | ) | ((x).d) |
Definition at line 862 of file util.c.
Referenced by ruby_dtoa(), and ruby_strtod().
#define Exp_mask 0x7ff00000 |
Definition at line 888 of file util.c.
Referenced by ruby_dtoa().
#define Flt_Rounds 1 |
Definition at line 919 of file util.c.
Referenced by ruby_dtoa().
#define hexdigit ruby_hexdigits |
Definition at line 31 of file util.c.
Referenced by ruby_scan_hex(), and ruby_strtod().
#define med3 | ( | a, | |
b, | |||
c | |||
) |
#define mmargdecl int mmkind, size_t size, size_t high, size_t low |
#define mmprepare | ( | base, | |
size | |||
) |
#define PATH_MAX 8192 |
Referenced by rb_w32_special_folder(), and ruby_getcwd().
#define PRIVATE_mem ((PRIVATE_MEM+sizeof(double)-1)/sizeof(double)) |
#define Rounding Flt_Rounds |
#define rv_alloc | ( | i | ) | xmalloc(i) |
Definition at line 3074 of file util.c.
Referenced by ruby_hdtoa().
#define rv_strdup | ( | s, | |
rve | |||
) | nrv_alloc((s), (rve), strlen(s)+1) |
Definition at line 3089 of file util.c.
Referenced by ruby_dtoa(), and ruby_hdtoa().
#define SIGFIGS ((DBL_MANT_DIG + 3) / 4 + 1) |
Definition at line 3867 of file util.c.
Referenced by ruby_hdtoa().
#define Sign_bit 0x80000000 |
Definition at line 902 of file util.c.
Referenced by ruby_dtoa(), and ruby_hdtoa().
#define Storeinc | ( | a, | |
b, | |||
c | |||
) |
#define word0 | ( | x | ) | ((x).L[1]) |
Definition at line 856 of file util.c.
Referenced by ruby_dtoa(), and ruby_hdtoa().
#define word1 | ( | x | ) | ((x).L[0]) |
Definition at line 857 of file util.c.
Referenced by ruby_dtoa().
char* ruby_dtoa | ( | double | d_, |
int | mode, | ||
int | ndigits, | ||
int * | decpt, | ||
int * | sign, | ||
char ** | rve | ||
) |
Definition at line 3822 of file util.c.
Referenced by ruby_set_debug_option().
char* ruby_getcwd | ( | void | ) |
Definition at line 508 of file util.c.
References buf, DATA_PTR, Data_Wrap_Struct, errno, free(), NULL, PATH_MAX, RB_GC_GUARD, rb_sys_fail(), rb_syserr_fail(), RUBY_DEFAULT_FREE, ruby_strdup(), size, xfree(), xmalloc, and xrealloc.
char* ruby_hdtoa | ( | double | d, |
const char * | xdigs, | ||
int | ndigits, | ||
int * | decpt, | ||
int * | sign, | ||
char ** | rve | ||
) |
Definition at line 3899 of file util.c.
References 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, SIGFIGS, Sign_bit, and word0.
unsigned long ruby_scan_digits | ( | const char * | str, |
ssize_t | len, | ||
int | base, | ||
size_t * | retlen, | ||
int * | overflow | ||
) |
Definition at line 84 of file util.c.
References ruby_digit36_to_number_table.
Referenced by ruby_strtoul().
unsigned long ruby_scan_hex | ( | const char * | start, |
size_t | len, | ||
size_t * | retlen | ||
) |
unsigned long ruby_scan_oct | ( | const char * | start, |
size_t | len, | ||
size_t * | retlen | ||
) |
char* ruby_strdup | ( | const char * | str | ) |
Definition at line 496 of file util.c.
References len, strlen(), and xmalloc.
Referenced by compat_init_setproctitle(), and ruby_getcwd().
double ruby_strtod | ( | const char * | s00, |
char ** | se | ||
) |
unsigned long ruby_strtoul | ( | const char * | str, |
char ** | endptr, | ||
int | base | ||
) |
const signed char ruby_digit36_to_number_table[] |
Definition at line 63 of file util.c.
Referenced by ruby_scan_digits().