debase-ruby_core_source 0.10.6 → 0.10.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +17 -0
- data/README.md +1 -1
- data/Rakefile +6 -3
- data/debase-ruby_core_source.gemspec +2 -1
- data/lib/debase/ruby_core_source.rb +1 -1
- data/lib/debase/ruby_core_source/ruby-2.7.0-p0/addr2line.h +21 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-p0/builtin.h +78 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-p0/ccan/build_assert/build_assert.h +40 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-p0/ccan/check_type/check_type.h +63 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-p0/ccan/container_of/container_of.h +142 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-p0/ccan/list/list.h +788 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-p0/ccan/str/str.h +16 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-p0/constant.h +50 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-p0/debug_counter.h +390 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-p0/dln.h +51 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-p0/encindex.h +69 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-p0/eval_intern.h +312 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-p0/gc.h +131 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-p0/hrtime.h +168 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-p0/id.h +290 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-p0/id_table.h +34 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-p0/insns.inc +253 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-p0/insns_info.inc +9197 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-p0/internal.h +2697 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-p0/iseq.h +312 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-p0/known_errors.inc +791 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-p0/method.h +229 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-p0/mjit.h +177 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-p0/mjit_compile.inc +7779 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-p0/node.h +476 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-p0/node_name.inc +208 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-p0/opt_sc.inc +109 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-p0/optinsn.inc +128 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-p0/optunifs.inc +43 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-p0/parse.h +210 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-p0/probes_helper.h +42 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-p0/regenc.h +254 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-p0/regint.h +938 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-p0/regparse.h +370 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-p0/revision.h +2 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-p0/ruby_assert.h +15 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-p0/ruby_atomic.h +244 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-p0/siphash.h +48 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-p0/symbol.h +119 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-p0/thread_pthread.h +75 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-p0/thread_win32.h +36 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-p0/timev.h +56 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-p0/transcode_data.h +139 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-p0/transient_heap.h +62 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-p0/variable.h +9 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-p0/version.h +77 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-p0/vm.inc +5466 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-p0/vm_call_iseq_optimized.inc +237 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-p0/vm_core.h +1968 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-p0/vm_debug.h +34 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-p0/vm_exec.h +193 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-p0/vm_insnhelper.h +267 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-p0/vm_opts.h +72 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-p0/vmtc.inc +247 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/addr2line.h +20 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/builtin.h +83 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/ccan/build_assert/build_assert.h +40 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/ccan/check_type/check_type.h +63 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/ccan/container_of/container_of.h +142 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/ccan/list/list.h +788 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/ccan/str/str.h +16 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/constant.h +55 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/debug_counter.h +423 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/dln.h +36 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/encindex.h +70 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/eval_intern.h +312 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/gc.h +140 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/hrtime.h +168 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/id.h +290 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/id_table.h +36 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/insns.inc +249 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/insns_info.inc +8979 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/internal.h +107 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/internal/array.h +114 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/internal/bignum.h +246 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/internal/bits.h +566 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/internal/class.h +168 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/internal/compar.h +50 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/internal/compile.h +32 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/internal/compilers.h +108 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/internal/complex.h +29 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/internal/cont.h +25 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/internal/dir.h +17 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/internal/enc.h +20 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/internal/encoding.h +28 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/internal/enum.h +19 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/internal/enumerator.h +22 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/internal/error.h +131 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/internal/eval.h +33 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/internal/file.h +39 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/internal/fixnum.h +185 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/internal/gc.h +154 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/internal/hash.h +240 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/internal/imemo.h +243 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/internal/inits.h +51 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/internal/io.h +35 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/internal/load.h +19 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/internal/loadpath.h +17 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/internal/math.h +24 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/internal/missing.h +19 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/internal/mjit.h +29 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/internal/numeric.h +252 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/internal/object.h +83 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/internal/parse.h +23 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/internal/proc.h +32 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/internal/process.h +136 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/internal/random.h +17 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/internal/range.h +37 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/internal/rational.h +69 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/internal/re.h +29 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/internal/sanitizers.h +191 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/internal/scheduler.h +35 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/internal/serial.h +24 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/internal/signal.h +22 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/internal/static_assert.h +17 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/internal/string.h +135 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/internal/struct.h +154 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/internal/symbol.h +41 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/internal/thread.h +60 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/internal/time.h +35 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/internal/transcode.h +21 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/internal/util.h +31 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/internal/variable.h +83 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/internal/vm.h +135 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/internal/warnings.h +17 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/iseq.h +304 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/known_errors.inc +791 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/method.h +245 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/mjit.h +197 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/mjit_compile.inc +8082 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/node.h +484 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/node_name.inc +210 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/opt_sc.inc +109 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/optinsn.inc +128 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/optunifs.inc +43 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/parse.h +211 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/probes_helper.h +44 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/ractor.h +271 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/ractor_pub.h +50 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/regenc.h +254 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/regint.h +938 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/regparse.h +370 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/revision.h +2 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/ruby_assert.h +15 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/ruby_atomic.h +236 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/siphash.h +48 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/symbol.h +119 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/thread_pthread.h +106 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/thread_win32.h +66 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/timev.h +57 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/transcode_data.h +138 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/transient_heap.h +61 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/variable.h +21 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/version.h +89 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/vm.inc +5360 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/vm_call_iseq_optimized.inc +244 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/vm_callinfo.h +457 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/vm_core.h +1952 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/vm_debug.h +116 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/vm_exec.h +196 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/vm_insnhelper.h +260 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/vm_opts.h +73 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/vm_sync.h +97 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-preview1/vmtc.inc +243 -0
- data/lib/debase/ruby_core_source/version.rb +1 -1
- metadata +183 -5
@@ -0,0 +1,168 @@
|
|
1
|
+
#ifndef RB_HRTIME_H
|
2
|
+
#define RB_HRTIME_H
|
3
|
+
#include "ruby/ruby.h"
|
4
|
+
#include <time.h>
|
5
|
+
#if defined(HAVE_SYS_TIME_H)
|
6
|
+
# include <sys/time.h>
|
7
|
+
#endif
|
8
|
+
|
9
|
+
/*
|
10
|
+
* Hi-res monotonic clock. It is currently nsec resolution, which has over
|
11
|
+
* 500 years of range (with an unsigned 64-bit integer). Developers
|
12
|
+
* targeting small systems may try 32-bit and low-resolution (milliseconds).
|
13
|
+
*
|
14
|
+
* TBD: Is nsec even necessary? usec resolution seems enough for userspace
|
15
|
+
* and it'll be suitable for use with devices lasting over 500,000 years
|
16
|
+
* (maybe some devices designed for long-term space travel)
|
17
|
+
*
|
18
|
+
* Current API:
|
19
|
+
*
|
20
|
+
* * rb_hrtime_now - current clock value (monotonic if available)
|
21
|
+
* * rb_hrtime_mul - multiply with overflow check
|
22
|
+
* * rb_hrtime_add - add with overflow check
|
23
|
+
* * rb_timeval2hrtime - convert from timeval
|
24
|
+
* * rb_timespec2hrtime - convert from timespec
|
25
|
+
* * rb_msec2hrtime - convert from millisecond
|
26
|
+
* * rb_sec2hrtime - convert from time_t (seconds)
|
27
|
+
* * rb_hrtime2timeval - convert to timeval
|
28
|
+
* * rb_hrtime2timespec - convert to timespec
|
29
|
+
*
|
30
|
+
* Note: no conversion to milliseconds is provided here because different
|
31
|
+
* functions have different limits (e.g. epoll_wait vs w32_wait_events).
|
32
|
+
* So we provide RB_HRTIME_PER_MSEC and similar macros for implementing
|
33
|
+
* this for each use case.
|
34
|
+
*/
|
35
|
+
#define RB_HRTIME_PER_USEC ((rb_hrtime_t)1000)
|
36
|
+
#define RB_HRTIME_PER_MSEC (RB_HRTIME_PER_USEC * (rb_hrtime_t)1000)
|
37
|
+
#define RB_HRTIME_PER_SEC (RB_HRTIME_PER_MSEC * (rb_hrtime_t)1000)
|
38
|
+
#define RB_HRTIME_MAX UINT64_MAX
|
39
|
+
|
40
|
+
/*
|
41
|
+
* Lets try to support time travelers. Lets assume anybody with a time machine
|
42
|
+
* also has access to a modern gcc or clang with 128-bit int support
|
43
|
+
*/
|
44
|
+
#ifdef MY_RUBY_BUILD_MAY_TIME_TRAVEL
|
45
|
+
typedef int128_t rb_hrtime_t;
|
46
|
+
#else
|
47
|
+
typedef uint64_t rb_hrtime_t;
|
48
|
+
#endif
|
49
|
+
|
50
|
+
/* thread.c */
|
51
|
+
/* returns the value of the monotonic clock (if available) */
|
52
|
+
rb_hrtime_t rb_hrtime_now(void);
|
53
|
+
|
54
|
+
/*
|
55
|
+
* multiply @a and @b with overflow check and return the
|
56
|
+
* (clamped to RB_HRTIME_MAX) result.
|
57
|
+
*/
|
58
|
+
static inline rb_hrtime_t
|
59
|
+
rb_hrtime_mul(rb_hrtime_t a, rb_hrtime_t b)
|
60
|
+
{
|
61
|
+
rb_hrtime_t c;
|
62
|
+
|
63
|
+
#ifdef HAVE_BUILTIN___BUILTIN_MUL_OVERFLOW
|
64
|
+
if (__builtin_mul_overflow(a, b, &c))
|
65
|
+
return RB_HRTIME_MAX;
|
66
|
+
#else
|
67
|
+
if (b != 0 && a > RB_HRTIME_MAX / b) /* overflow */
|
68
|
+
return RB_HRTIME_MAX;
|
69
|
+
c = a * b;
|
70
|
+
#endif
|
71
|
+
return c;
|
72
|
+
}
|
73
|
+
|
74
|
+
/*
|
75
|
+
* add @a and @b with overflow check and return the
|
76
|
+
* (clamped to RB_HRTIME_MAX) result.
|
77
|
+
*/
|
78
|
+
static inline rb_hrtime_t
|
79
|
+
rb_hrtime_add(rb_hrtime_t a, rb_hrtime_t b)
|
80
|
+
{
|
81
|
+
rb_hrtime_t c;
|
82
|
+
|
83
|
+
#ifdef HAVE_BUILTIN___BUILTIN_ADD_OVERFLOW
|
84
|
+
if (__builtin_add_overflow(a, b, &c))
|
85
|
+
return RB_HRTIME_MAX;
|
86
|
+
#else
|
87
|
+
c = a + b;
|
88
|
+
if (c < a) /* overflow */
|
89
|
+
return RB_HRTIME_MAX;
|
90
|
+
#endif
|
91
|
+
return c;
|
92
|
+
}
|
93
|
+
|
94
|
+
/*
|
95
|
+
* convert a timeval struct to rb_hrtime_t, clamping at RB_HRTIME_MAX
|
96
|
+
*/
|
97
|
+
static inline rb_hrtime_t
|
98
|
+
rb_timeval2hrtime(const struct timeval *tv)
|
99
|
+
{
|
100
|
+
rb_hrtime_t s = rb_hrtime_mul((rb_hrtime_t)tv->tv_sec, RB_HRTIME_PER_SEC);
|
101
|
+
rb_hrtime_t u = rb_hrtime_mul((rb_hrtime_t)tv->tv_usec, RB_HRTIME_PER_USEC);
|
102
|
+
|
103
|
+
return rb_hrtime_add(s, u);
|
104
|
+
}
|
105
|
+
|
106
|
+
/*
|
107
|
+
* convert a timespec struct to rb_hrtime_t, clamping at RB_HRTIME_MAX
|
108
|
+
*/
|
109
|
+
static inline rb_hrtime_t
|
110
|
+
rb_timespec2hrtime(const struct timespec *ts)
|
111
|
+
{
|
112
|
+
rb_hrtime_t s = rb_hrtime_mul((rb_hrtime_t)ts->tv_sec, RB_HRTIME_PER_SEC);
|
113
|
+
|
114
|
+
return rb_hrtime_add(s, (rb_hrtime_t)ts->tv_nsec);
|
115
|
+
}
|
116
|
+
|
117
|
+
/*
|
118
|
+
* convert a millisecond value to rb_hrtime_t, clamping at RB_HRTIME_MAX
|
119
|
+
*/
|
120
|
+
static inline rb_hrtime_t
|
121
|
+
rb_msec2hrtime(unsigned long msec)
|
122
|
+
{
|
123
|
+
return rb_hrtime_mul((rb_hrtime_t)msec, RB_HRTIME_PER_MSEC);
|
124
|
+
}
|
125
|
+
|
126
|
+
/*
|
127
|
+
* convert a time_t value to rb_hrtime_t, clamping at RB_HRTIME_MAX
|
128
|
+
* Negative values will be clamped at 0.
|
129
|
+
*/
|
130
|
+
static inline rb_hrtime_t
|
131
|
+
rb_sec2hrtime(time_t sec)
|
132
|
+
{
|
133
|
+
if (sec <= 0) return 0;
|
134
|
+
|
135
|
+
return rb_hrtime_mul((rb_hrtime_t)sec, RB_HRTIME_PER_SEC);
|
136
|
+
}
|
137
|
+
|
138
|
+
/*
|
139
|
+
* convert a rb_hrtime_t value to a timespec, suitable for calling
|
140
|
+
* functions like ppoll(2) or kevent(2)
|
141
|
+
*/
|
142
|
+
static inline struct timespec *
|
143
|
+
rb_hrtime2timespec(struct timespec *ts, const rb_hrtime_t *hrt)
|
144
|
+
{
|
145
|
+
if (hrt) {
|
146
|
+
ts->tv_sec = (time_t)(*hrt / RB_HRTIME_PER_SEC);
|
147
|
+
ts->tv_nsec = (int32_t)(*hrt % RB_HRTIME_PER_SEC);
|
148
|
+
return ts;
|
149
|
+
}
|
150
|
+
return 0;
|
151
|
+
}
|
152
|
+
|
153
|
+
/*
|
154
|
+
* convert a rb_hrtime_t value to a timeval, suitable for calling
|
155
|
+
* functions like select(2)
|
156
|
+
*/
|
157
|
+
static inline struct timeval *
|
158
|
+
rb_hrtime2timeval(struct timeval *tv, const rb_hrtime_t *hrt)
|
159
|
+
{
|
160
|
+
if (hrt) {
|
161
|
+
tv->tv_sec = (time_t)(*hrt / RB_HRTIME_PER_SEC);
|
162
|
+
tv->tv_usec = (int32_t)((*hrt % RB_HRTIME_PER_SEC)/RB_HRTIME_PER_USEC);
|
163
|
+
|
164
|
+
return tv;
|
165
|
+
}
|
166
|
+
return 0;
|
167
|
+
}
|
168
|
+
#endif /* RB_HRTIME_H */
|
@@ -0,0 +1,290 @@
|
|
1
|
+
/* DO NOT EDIT THIS FILE DIRECTLY */
|
2
|
+
/**********************************************************************
|
3
|
+
|
4
|
+
id.h -
|
5
|
+
|
6
|
+
$Author$
|
7
|
+
created at: Sun Oct 19 21:12:51 2008
|
8
|
+
|
9
|
+
Copyright (C) 2007 Koichi Sasada
|
10
|
+
|
11
|
+
**********************************************************************/
|
12
|
+
|
13
|
+
#ifndef RUBY_ID_H
|
14
|
+
#define RUBY_ID_H
|
15
|
+
|
16
|
+
enum ruby_id_types {
|
17
|
+
RUBY_ID_STATIC_SYM = 0x01,
|
18
|
+
RUBY_ID_LOCAL = 0x00,
|
19
|
+
RUBY_ID_INSTANCE = (0x01<<1),
|
20
|
+
RUBY_ID_GLOBAL = (0x03<<1),
|
21
|
+
RUBY_ID_ATTRSET = (0x04<<1),
|
22
|
+
RUBY_ID_CONST = (0x05<<1),
|
23
|
+
RUBY_ID_CLASS = (0x06<<1),
|
24
|
+
RUBY_ID_JUNK = (0x07<<1),
|
25
|
+
RUBY_ID_INTERNAL = RUBY_ID_JUNK,
|
26
|
+
RUBY_ID_SCOPE_SHIFT = 4,
|
27
|
+
RUBY_ID_SCOPE_MASK = (~(~0U<<(RUBY_ID_SCOPE_SHIFT-1))<<1)
|
28
|
+
};
|
29
|
+
|
30
|
+
#define ID_STATIC_SYM RUBY_ID_STATIC_SYM
|
31
|
+
#define ID_SCOPE_SHIFT RUBY_ID_SCOPE_SHIFT
|
32
|
+
#define ID_SCOPE_MASK RUBY_ID_SCOPE_MASK
|
33
|
+
#define ID_LOCAL RUBY_ID_LOCAL
|
34
|
+
#define ID_INSTANCE RUBY_ID_INSTANCE
|
35
|
+
#define ID_GLOBAL RUBY_ID_GLOBAL
|
36
|
+
#define ID_ATTRSET RUBY_ID_ATTRSET
|
37
|
+
#define ID_CONST RUBY_ID_CONST
|
38
|
+
#define ID_CLASS RUBY_ID_CLASS
|
39
|
+
#define ID_JUNK RUBY_ID_JUNK
|
40
|
+
#define ID_INTERNAL RUBY_ID_INTERNAL
|
41
|
+
|
42
|
+
#define symIFUNC ID2SYM(idIFUNC)
|
43
|
+
#define symCFUNC ID2SYM(idCFUNC)
|
44
|
+
|
45
|
+
#define RUBY_TOKEN_DOT2 128
|
46
|
+
#define RUBY_TOKEN_DOT3 129
|
47
|
+
#define RUBY_TOKEN_BDOT2 130
|
48
|
+
#define RUBY_TOKEN_BDOT3 131
|
49
|
+
#define RUBY_TOKEN_UPLUS 132
|
50
|
+
#define RUBY_TOKEN_UMINUS 133
|
51
|
+
#define RUBY_TOKEN_POW 134
|
52
|
+
#define RUBY_TOKEN_CMP 135
|
53
|
+
#define RUBY_TOKEN_LSHFT 136
|
54
|
+
#define RUBY_TOKEN_RSHFT 137
|
55
|
+
#define RUBY_TOKEN_LEQ 138
|
56
|
+
#define RUBY_TOKEN_GEQ 139
|
57
|
+
#define RUBY_TOKEN_EQ 140
|
58
|
+
#define RUBY_TOKEN_EQQ 141
|
59
|
+
#define RUBY_TOKEN_NEQ 142
|
60
|
+
#define RUBY_TOKEN_MATCH 143
|
61
|
+
#define RUBY_TOKEN_NMATCH 144
|
62
|
+
#define RUBY_TOKEN_AREF 145
|
63
|
+
#define RUBY_TOKEN_ASET 146
|
64
|
+
#define RUBY_TOKEN_COLON2 147
|
65
|
+
#define RUBY_TOKEN_ANDOP 148
|
66
|
+
#define RUBY_TOKEN_OROP 149
|
67
|
+
#define RUBY_TOKEN_ANDDOT 150
|
68
|
+
#define RUBY_TOKEN(t) RUBY_TOKEN_##t
|
69
|
+
|
70
|
+
#define RUBY_TOKEN2ID_TYPE(tok, type) ((tok<<RUBY_ID_SCOPE_SHIFT)|type|RUBY_ID_STATIC_SYM)
|
71
|
+
#define TOKEN2LOCALID(tok) RUBY_TOKEN2ID_TYPE(tok, RUBY_ID_LOCAL)
|
72
|
+
#define TOKEN2INSTANCEID(tok) RUBY_TOKEN2ID_TYPE(tok, RUBY_ID_INSTANCE)
|
73
|
+
#define TOKEN2GLOBALID(tok) RUBY_TOKEN2ID_TYPE(tok, RUBY_ID_GLOBAL)
|
74
|
+
#define TOKEN2CONSTID(tok) RUBY_TOKEN2ID_TYPE(tok, RUBY_ID_CONST)
|
75
|
+
#define TOKEN2CLASSID(tok) RUBY_TOKEN2ID_TYPE(tok, RUBY_ID_CLASS)
|
76
|
+
#define TOKEN2ATTRSETID(tok) RUBY_TOKEN2ID_TYPE(tok, RUBY_ID_ATTRSET)
|
77
|
+
|
78
|
+
enum ruby_method_ids {
|
79
|
+
idDot2 = RUBY_TOKEN(DOT2),
|
80
|
+
idDot3 = RUBY_TOKEN(DOT3),
|
81
|
+
idUPlus = RUBY_TOKEN(UPLUS),
|
82
|
+
idUMinus = RUBY_TOKEN(UMINUS),
|
83
|
+
idPow = RUBY_TOKEN(POW),
|
84
|
+
idCmp = RUBY_TOKEN(CMP),
|
85
|
+
idPLUS = '+',
|
86
|
+
idMINUS = '-',
|
87
|
+
idMULT = '*',
|
88
|
+
idDIV = '/',
|
89
|
+
idMOD = '%',
|
90
|
+
idLTLT = RUBY_TOKEN(LSHFT),
|
91
|
+
idGTGT = RUBY_TOKEN(RSHFT),
|
92
|
+
idLT = '<',
|
93
|
+
idLE = RUBY_TOKEN(LEQ),
|
94
|
+
idGT = '>',
|
95
|
+
idGE = RUBY_TOKEN(GEQ),
|
96
|
+
idEq = RUBY_TOKEN(EQ),
|
97
|
+
idEqq = RUBY_TOKEN(EQQ),
|
98
|
+
idNeq = RUBY_TOKEN(NEQ),
|
99
|
+
idNot = '!',
|
100
|
+
idAnd = '&',
|
101
|
+
idOr = '|',
|
102
|
+
idBackquote = '`',
|
103
|
+
idEqTilde = RUBY_TOKEN(MATCH),
|
104
|
+
idNeqTilde = RUBY_TOKEN(NMATCH),
|
105
|
+
idAREF = RUBY_TOKEN(AREF),
|
106
|
+
idASET = RUBY_TOKEN(ASET),
|
107
|
+
idCOLON2 = RUBY_TOKEN(COLON2),
|
108
|
+
idANDOP = RUBY_TOKEN(ANDOP),
|
109
|
+
idOROP = RUBY_TOKEN(OROP),
|
110
|
+
idANDDOT = RUBY_TOKEN(ANDDOT),
|
111
|
+
tPRESERVED_ID_BEGIN = 150,
|
112
|
+
idNilP,
|
113
|
+
idNULL,
|
114
|
+
idEmptyP,
|
115
|
+
idEqlP,
|
116
|
+
idRespond_to,
|
117
|
+
idRespond_to_missing,
|
118
|
+
idIFUNC,
|
119
|
+
idCFUNC,
|
120
|
+
id_core_set_method_alias,
|
121
|
+
id_core_set_variable_alias,
|
122
|
+
id_core_undef_method,
|
123
|
+
id_core_define_method,
|
124
|
+
id_core_define_singleton_method,
|
125
|
+
id_core_set_postexe,
|
126
|
+
id_core_hash_merge_ptr,
|
127
|
+
id_core_hash_merge_kwd,
|
128
|
+
id_core_raise,
|
129
|
+
id_debug_created_info,
|
130
|
+
tPRESERVED_ID_END,
|
131
|
+
tTOKEN_LOCAL_BEGIN = tPRESERVED_ID_END-1,
|
132
|
+
tMax,
|
133
|
+
tMin,
|
134
|
+
tFreeze,
|
135
|
+
tInspect,
|
136
|
+
tIntern,
|
137
|
+
tObject_id,
|
138
|
+
tConst_missing,
|
139
|
+
tMethodMissing,
|
140
|
+
tMethod_added,
|
141
|
+
tSingleton_method_added,
|
142
|
+
tMethod_removed,
|
143
|
+
tSingleton_method_removed,
|
144
|
+
tMethod_undefined,
|
145
|
+
tSingleton_method_undefined,
|
146
|
+
tLength,
|
147
|
+
tSize,
|
148
|
+
tGets,
|
149
|
+
tSucc,
|
150
|
+
tEach,
|
151
|
+
tProc,
|
152
|
+
tLambda,
|
153
|
+
tSend,
|
154
|
+
t__send__,
|
155
|
+
t__attached__,
|
156
|
+
tInitialize,
|
157
|
+
tInitialize_copy,
|
158
|
+
tInitialize_clone,
|
159
|
+
tInitialize_dup,
|
160
|
+
tTo_int,
|
161
|
+
tTo_ary,
|
162
|
+
tTo_str,
|
163
|
+
tTo_sym,
|
164
|
+
tTo_hash,
|
165
|
+
tTo_proc,
|
166
|
+
tTo_io,
|
167
|
+
tTo_a,
|
168
|
+
tTo_s,
|
169
|
+
tTo_i,
|
170
|
+
tTo_f,
|
171
|
+
tTo_r,
|
172
|
+
tBt,
|
173
|
+
tBt_locations,
|
174
|
+
tCall,
|
175
|
+
tMesg,
|
176
|
+
tException,
|
177
|
+
tLocals,
|
178
|
+
tNOT,
|
179
|
+
tAND,
|
180
|
+
tOR,
|
181
|
+
tDiv,
|
182
|
+
tDivmod,
|
183
|
+
tFdiv,
|
184
|
+
tQuo,
|
185
|
+
tName,
|
186
|
+
tNil,
|
187
|
+
tUScore,
|
188
|
+
tNUMPARAM_1,
|
189
|
+
tNUMPARAM_2,
|
190
|
+
tNUMPARAM_3,
|
191
|
+
tNUMPARAM_4,
|
192
|
+
tNUMPARAM_5,
|
193
|
+
tNUMPARAM_6,
|
194
|
+
tNUMPARAM_7,
|
195
|
+
tNUMPARAM_8,
|
196
|
+
tNUMPARAM_9,
|
197
|
+
tTOKEN_LOCAL_END,
|
198
|
+
tTOKEN_INSTANCE_BEGIN = tTOKEN_LOCAL_END-1,
|
199
|
+
tTOKEN_INSTANCE_END,
|
200
|
+
tTOKEN_GLOBAL_BEGIN = tTOKEN_INSTANCE_END-1,
|
201
|
+
tLASTLINE,
|
202
|
+
tBACKREF,
|
203
|
+
tERROR_INFO,
|
204
|
+
tTOKEN_GLOBAL_END,
|
205
|
+
tTOKEN_CONST_BEGIN = tTOKEN_GLOBAL_END-1,
|
206
|
+
tTOKEN_CONST_END,
|
207
|
+
tTOKEN_CLASS_BEGIN = tTOKEN_CONST_END-1,
|
208
|
+
tTOKEN_CLASS_END,
|
209
|
+
tTOKEN_ATTRSET_BEGIN = tTOKEN_CLASS_END-1,
|
210
|
+
tTOKEN_ATTRSET_END,
|
211
|
+
tNEXT_ID = tTOKEN_ATTRSET_END,
|
212
|
+
#define DEFINE_LOCALID_FROM_TOKEN(n) id##n = TOKEN2LOCALID(t##n)
|
213
|
+
DEFINE_LOCALID_FROM_TOKEN(Max),
|
214
|
+
DEFINE_LOCALID_FROM_TOKEN(Min),
|
215
|
+
DEFINE_LOCALID_FROM_TOKEN(Freeze),
|
216
|
+
DEFINE_LOCALID_FROM_TOKEN(Inspect),
|
217
|
+
DEFINE_LOCALID_FROM_TOKEN(Intern),
|
218
|
+
DEFINE_LOCALID_FROM_TOKEN(Object_id),
|
219
|
+
DEFINE_LOCALID_FROM_TOKEN(Const_missing),
|
220
|
+
DEFINE_LOCALID_FROM_TOKEN(MethodMissing),
|
221
|
+
DEFINE_LOCALID_FROM_TOKEN(Method_added),
|
222
|
+
DEFINE_LOCALID_FROM_TOKEN(Singleton_method_added),
|
223
|
+
DEFINE_LOCALID_FROM_TOKEN(Method_removed),
|
224
|
+
DEFINE_LOCALID_FROM_TOKEN(Singleton_method_removed),
|
225
|
+
DEFINE_LOCALID_FROM_TOKEN(Method_undefined),
|
226
|
+
DEFINE_LOCALID_FROM_TOKEN(Singleton_method_undefined),
|
227
|
+
DEFINE_LOCALID_FROM_TOKEN(Length),
|
228
|
+
DEFINE_LOCALID_FROM_TOKEN(Size),
|
229
|
+
DEFINE_LOCALID_FROM_TOKEN(Gets),
|
230
|
+
DEFINE_LOCALID_FROM_TOKEN(Succ),
|
231
|
+
DEFINE_LOCALID_FROM_TOKEN(Each),
|
232
|
+
DEFINE_LOCALID_FROM_TOKEN(Proc),
|
233
|
+
DEFINE_LOCALID_FROM_TOKEN(Lambda),
|
234
|
+
DEFINE_LOCALID_FROM_TOKEN(Send),
|
235
|
+
DEFINE_LOCALID_FROM_TOKEN(__send__),
|
236
|
+
DEFINE_LOCALID_FROM_TOKEN(__attached__),
|
237
|
+
DEFINE_LOCALID_FROM_TOKEN(Initialize),
|
238
|
+
DEFINE_LOCALID_FROM_TOKEN(Initialize_copy),
|
239
|
+
DEFINE_LOCALID_FROM_TOKEN(Initialize_clone),
|
240
|
+
DEFINE_LOCALID_FROM_TOKEN(Initialize_dup),
|
241
|
+
DEFINE_LOCALID_FROM_TOKEN(To_int),
|
242
|
+
DEFINE_LOCALID_FROM_TOKEN(To_ary),
|
243
|
+
DEFINE_LOCALID_FROM_TOKEN(To_str),
|
244
|
+
DEFINE_LOCALID_FROM_TOKEN(To_sym),
|
245
|
+
DEFINE_LOCALID_FROM_TOKEN(To_hash),
|
246
|
+
DEFINE_LOCALID_FROM_TOKEN(To_proc),
|
247
|
+
DEFINE_LOCALID_FROM_TOKEN(To_io),
|
248
|
+
DEFINE_LOCALID_FROM_TOKEN(To_a),
|
249
|
+
DEFINE_LOCALID_FROM_TOKEN(To_s),
|
250
|
+
DEFINE_LOCALID_FROM_TOKEN(To_i),
|
251
|
+
DEFINE_LOCALID_FROM_TOKEN(To_f),
|
252
|
+
DEFINE_LOCALID_FROM_TOKEN(To_r),
|
253
|
+
DEFINE_LOCALID_FROM_TOKEN(Bt),
|
254
|
+
DEFINE_LOCALID_FROM_TOKEN(Bt_locations),
|
255
|
+
DEFINE_LOCALID_FROM_TOKEN(Call),
|
256
|
+
DEFINE_LOCALID_FROM_TOKEN(Mesg),
|
257
|
+
DEFINE_LOCALID_FROM_TOKEN(Exception),
|
258
|
+
DEFINE_LOCALID_FROM_TOKEN(Locals),
|
259
|
+
DEFINE_LOCALID_FROM_TOKEN(NOT),
|
260
|
+
DEFINE_LOCALID_FROM_TOKEN(AND),
|
261
|
+
DEFINE_LOCALID_FROM_TOKEN(OR),
|
262
|
+
DEFINE_LOCALID_FROM_TOKEN(Div),
|
263
|
+
DEFINE_LOCALID_FROM_TOKEN(Divmod),
|
264
|
+
DEFINE_LOCALID_FROM_TOKEN(Fdiv),
|
265
|
+
DEFINE_LOCALID_FROM_TOKEN(Quo),
|
266
|
+
DEFINE_LOCALID_FROM_TOKEN(Name),
|
267
|
+
DEFINE_LOCALID_FROM_TOKEN(Nil),
|
268
|
+
DEFINE_LOCALID_FROM_TOKEN(UScore),
|
269
|
+
DEFINE_LOCALID_FROM_TOKEN(NUMPARAM_1),
|
270
|
+
DEFINE_LOCALID_FROM_TOKEN(NUMPARAM_2),
|
271
|
+
DEFINE_LOCALID_FROM_TOKEN(NUMPARAM_3),
|
272
|
+
DEFINE_LOCALID_FROM_TOKEN(NUMPARAM_4),
|
273
|
+
DEFINE_LOCALID_FROM_TOKEN(NUMPARAM_5),
|
274
|
+
DEFINE_LOCALID_FROM_TOKEN(NUMPARAM_6),
|
275
|
+
DEFINE_LOCALID_FROM_TOKEN(NUMPARAM_7),
|
276
|
+
DEFINE_LOCALID_FROM_TOKEN(NUMPARAM_8),
|
277
|
+
DEFINE_LOCALID_FROM_TOKEN(NUMPARAM_9),
|
278
|
+
#define DEFINE_INSTANCEID_FROM_TOKEN(n) id##n = TOKEN2INSTANCEID(t##n)
|
279
|
+
#define DEFINE_GLOBALID_FROM_TOKEN(n) id##n = TOKEN2GLOBALID(t##n)
|
280
|
+
DEFINE_GLOBALID_FROM_TOKEN(LASTLINE),
|
281
|
+
DEFINE_GLOBALID_FROM_TOKEN(BACKREF),
|
282
|
+
DEFINE_GLOBALID_FROM_TOKEN(ERROR_INFO),
|
283
|
+
#define DEFINE_CONSTID_FROM_TOKEN(n) id##n = TOKEN2CONSTID(t##n)
|
284
|
+
#define DEFINE_CLASSID_FROM_TOKEN(n) id##n = TOKEN2CLASSID(t##n)
|
285
|
+
#define DEFINE_ATTRSETID_FROM_TOKEN(n) id##n = TOKEN2ATTRSETID(t##n)
|
286
|
+
tLAST_OP_ID = tPRESERVED_ID_END-1,
|
287
|
+
idLAST_OP_ID = tLAST_OP_ID >> ID_SCOPE_SHIFT
|
288
|
+
};
|
289
|
+
|
290
|
+
#endif /* RUBY_ID_H */
|