debase-ruby_core_source 0.10.17 → 0.10.18
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/addr2line.h +20 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/builtin.h +121 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/ccan/build_assert/build_assert.h +40 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/ccan/check_type/check_type.h +63 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/ccan/container_of/container_of.h +142 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/ccan/list/list.h +789 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/ccan/str/str.h +17 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/constant.h +55 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/darray.h +179 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/debug_counter.h +468 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/dln.h +31 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/encindex.h +70 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/eval_intern.h +339 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/gc.h +147 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/hrtime.h +227 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/id.h +295 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/id_table.h +36 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/insns.inc +249 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/insns_info.inc +9061 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/array.h +163 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/bignum.h +246 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/bits.h +565 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/class.h +181 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/cmdlineopt.h +61 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/compar.h +49 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/compile.h +35 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/compilers.h +107 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/complex.h +29 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/cont.h +29 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/dir.h +16 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/enc.h +19 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/encoding.h +29 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/enum.h +18 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/enumerator.h +21 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/error.h +191 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/eval.h +32 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/file.h +38 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/fixnum.h +184 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/gc.h +191 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/hash.h +243 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/imemo.h +242 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/inits.h +50 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/io.h +38 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/load.h +18 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/loadpath.h +16 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/math.h +23 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/missing.h +18 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/numeric.h +275 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/object.h +61 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/parse.h +24 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/proc.h +32 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/process.h +137 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/ractor.h +6 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/random.h +16 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/range.h +40 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/rational.h +72 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/re.h +30 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/sanitizers.h +190 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/serial.h +23 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/signal.h +21 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/static_assert.h +16 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/string.h +147 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/struct.h +153 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/symbol.h +42 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/thread.h +55 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/time.h +34 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/transcode.h +20 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/util.h +27 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/variable.h +88 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/vm.h +134 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/warnings.h +16 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal.h +113 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/iseq.h +329 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/known_errors.inc +791 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/method.h +254 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/mjit.h +132 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/mjit_compile_attr.inc +430 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/mjit_compiler.h +58 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/mjit_unit.h +29 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/node.h +511 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/node_name.inc +210 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/opt_sc.inc +109 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/optinsn.inc +128 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/optunifs.inc +43 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/parse.h +215 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/probes_helper.h +44 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/ractor_core.h +343 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/regenc.h +254 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/regint.h +984 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/regparse.h +370 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/revision.h +5 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/ruby_assert.h +14 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/ruby_atomic.h +23 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/shape.h +194 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/siphash.h +48 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/symbol.h +119 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/thread_none.h +20 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/thread_pthread.h +132 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/thread_win32.h +63 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/timev.h +57 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/transcode_data.h +138 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/transient_heap.h +65 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/variable.h +29 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/version.h +65 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/vm.inc +5476 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/vm_call_iseq_optimized.inc +244 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/vm_callinfo.h +550 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/vm_core.h +2137 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/vm_debug.h +122 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/vm_exec.h +197 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/vm_insnhelper.h +266 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/vm_opts.h +73 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/vm_sync.h +137 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/vmtc.inc +243 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/yjit.h +72 -0
- data/lib/debase/ruby_core_source/version.rb +1 -1
- metadata +118 -3
@@ -0,0 +1,17 @@
|
|
1
|
+
/* CC0 (Public domain) - see ccan/licenses/CC0 file for details */
|
2
|
+
#ifndef CCAN_STR_H
|
3
|
+
#define CCAN_STR_H
|
4
|
+
/**
|
5
|
+
* ccan_stringify - Turn expression into a string literal
|
6
|
+
* @expr: any C expression
|
7
|
+
*
|
8
|
+
* Example:
|
9
|
+
* #define PRINT_COND_IF_FALSE(cond) \
|
10
|
+
* ((cond) || printf("%s is false!", ccan_stringify(cond)))
|
11
|
+
*/
|
12
|
+
#define stringify(expr) ccan_stringify_1(expr)
|
13
|
+
#define ccan_stringify(expr) ccan_stringify_1(expr)
|
14
|
+
/* Double-indirection required to stringify expansions */
|
15
|
+
#define ccan_stringify_1(expr) #expr
|
16
|
+
|
17
|
+
#endif /* CCAN_STR_H */
|
@@ -0,0 +1,55 @@
|
|
1
|
+
#ifndef CONSTANT_H
|
2
|
+
#define CONSTANT_H
|
3
|
+
/**********************************************************************
|
4
|
+
|
5
|
+
constant.h -
|
6
|
+
|
7
|
+
$Author$
|
8
|
+
created at: Sun Nov 15 00:09:33 2009
|
9
|
+
|
10
|
+
Copyright (C) 2009 Yusuke Endoh
|
11
|
+
|
12
|
+
**********************************************************************/
|
13
|
+
#include "ruby/ruby.h"
|
14
|
+
#include "id_table.h"
|
15
|
+
|
16
|
+
typedef enum {
|
17
|
+
CONST_DEPRECATED = 0x100,
|
18
|
+
|
19
|
+
CONST_VISIBILITY_MASK = 0xff,
|
20
|
+
CONST_PUBLIC = 0x00,
|
21
|
+
CONST_PRIVATE,
|
22
|
+
CONST_VISIBILITY_MAX
|
23
|
+
} rb_const_flag_t;
|
24
|
+
|
25
|
+
#define RB_CONST_PRIVATE_P(ce) \
|
26
|
+
(((ce)->flag & CONST_VISIBILITY_MASK) == CONST_PRIVATE)
|
27
|
+
#define RB_CONST_PUBLIC_P(ce) \
|
28
|
+
(((ce)->flag & CONST_VISIBILITY_MASK) == CONST_PUBLIC)
|
29
|
+
|
30
|
+
#define RB_CONST_DEPRECATED_P(ce) \
|
31
|
+
((ce)->flag & CONST_DEPRECATED)
|
32
|
+
|
33
|
+
typedef struct rb_const_entry_struct {
|
34
|
+
rb_const_flag_t flag;
|
35
|
+
int line;
|
36
|
+
VALUE value; /* should be mark */
|
37
|
+
VALUE file; /* should be mark */
|
38
|
+
} rb_const_entry_t;
|
39
|
+
|
40
|
+
VALUE rb_mod_private_constant(int argc, const VALUE *argv, VALUE obj);
|
41
|
+
VALUE rb_mod_public_constant(int argc, const VALUE *argv, VALUE obj);
|
42
|
+
VALUE rb_mod_deprecate_constant(int argc, const VALUE *argv, VALUE obj);
|
43
|
+
void rb_free_const_table(struct rb_id_table *tbl);
|
44
|
+
VALUE rb_const_source_location(VALUE, ID);
|
45
|
+
|
46
|
+
MJIT_SYMBOL_EXPORT_BEGIN
|
47
|
+
int rb_autoloading_value(VALUE mod, ID id, VALUE *value, rb_const_flag_t *flag);
|
48
|
+
rb_const_entry_t *rb_const_lookup(VALUE klass, ID id);
|
49
|
+
VALUE rb_public_const_get_at(VALUE klass, ID id);
|
50
|
+
VALUE rb_public_const_get_from(VALUE klass, ID id);
|
51
|
+
int rb_public_const_defined_from(VALUE klass, ID id);
|
52
|
+
VALUE rb_const_source_location_at(VALUE, ID);
|
53
|
+
MJIT_SYMBOL_EXPORT_END
|
54
|
+
|
55
|
+
#endif /* CONSTANT_H */
|
@@ -0,0 +1,179 @@
|
|
1
|
+
#ifndef RUBY_DARRAY_H
|
2
|
+
#define RUBY_DARRAY_H
|
3
|
+
|
4
|
+
#include <stdint.h>
|
5
|
+
#include <stddef.h>
|
6
|
+
#include <stdlib.h>
|
7
|
+
|
8
|
+
// Type for a dynamic array. Use to declare a dynamic array.
|
9
|
+
// It is a pointer so it fits in st_table nicely. Designed
|
10
|
+
// to be fairly type-safe.
|
11
|
+
//
|
12
|
+
// NULL is a valid empty dynamic array.
|
13
|
+
//
|
14
|
+
// Example:
|
15
|
+
// rb_darray(char) char_array = NULL;
|
16
|
+
// rb_darray_append(&char_array, 'e');
|
17
|
+
// printf("pushed %c\n", *rb_darray_ref(char_array, 0));
|
18
|
+
// rb_darray_free(char_array);
|
19
|
+
//
|
20
|
+
#define rb_darray(T) struct { rb_darray_meta_t meta; T data[]; } *
|
21
|
+
|
22
|
+
// Copy an element out of the array. Warning: not bounds checked.
|
23
|
+
//
|
24
|
+
// T rb_darray_get(rb_darray(T) ary, size_t idx);
|
25
|
+
//
|
26
|
+
#define rb_darray_get(ary, idx) ((ary)->data[(idx)])
|
27
|
+
|
28
|
+
// Assign to an element. Warning: not bounds checked.
|
29
|
+
//
|
30
|
+
// void rb_darray_set(rb_darray(T) ary, size_t idx, T element);
|
31
|
+
//
|
32
|
+
#define rb_darray_set(ary, idx, element) ((ary)->data[(idx)] = (element))
|
33
|
+
|
34
|
+
// Get a pointer to an element. Warning: not bounds checked.
|
35
|
+
//
|
36
|
+
// T *rb_darray_ref(rb_darray(T) ary, size_t idx);
|
37
|
+
//
|
38
|
+
#define rb_darray_ref(ary, idx) (&((ary)->data[(idx)]))
|
39
|
+
|
40
|
+
// Copy a new element into the array. ptr_to_ary is evaluated multiple times.
|
41
|
+
//
|
42
|
+
// void rb_darray_append(rb_darray(T) *ptr_to_ary, T element);
|
43
|
+
//
|
44
|
+
#define rb_darray_append(ptr_to_ary, element) do { \
|
45
|
+
rb_darray_ensure_space((ptr_to_ary), sizeof(**(ptr_to_ary)), \
|
46
|
+
sizeof((*(ptr_to_ary))->data[0])); \
|
47
|
+
rb_darray_set(*(ptr_to_ary), \
|
48
|
+
(*(ptr_to_ary))->meta.size, \
|
49
|
+
(element)); \
|
50
|
+
(*(ptr_to_ary))->meta.size++; \
|
51
|
+
} while (0)
|
52
|
+
|
53
|
+
|
54
|
+
// Last element of the array
|
55
|
+
//
|
56
|
+
#define rb_darray_back(ary) ((ary)->data[(ary)->meta.size - 1])
|
57
|
+
|
58
|
+
// Remove the last element of the array.
|
59
|
+
//
|
60
|
+
#define rb_darray_pop_back(ary) ((ary)->meta.size--)
|
61
|
+
|
62
|
+
// Remove element at idx and replace it by the last element
|
63
|
+
#define rb_darray_remove_unordered(ary, idx) do { \
|
64
|
+
rb_darray_set(ary, idx, rb_darray_back(ary)); \
|
65
|
+
rb_darray_pop_back(ary); \
|
66
|
+
} while (0);
|
67
|
+
|
68
|
+
// Iterate over items of the array in a for loop
|
69
|
+
//
|
70
|
+
#define rb_darray_foreach(ary, idx_name, elem_ptr_var) \
|
71
|
+
for (size_t idx_name = 0; idx_name < rb_darray_size(ary) && ((elem_ptr_var) = rb_darray_ref(ary, idx_name)); ++idx_name)
|
72
|
+
|
73
|
+
// Iterate over valid indicies in the array in a for loop
|
74
|
+
//
|
75
|
+
#define rb_darray_for(ary, idx_name) \
|
76
|
+
for (size_t idx_name = 0; idx_name < rb_darray_size(ary); ++idx_name)
|
77
|
+
|
78
|
+
// Make a dynamic array of a certain size. All bytes backing the elements are set to zero.
|
79
|
+
//
|
80
|
+
// Note that NULL is a valid empty dynamic array.
|
81
|
+
//
|
82
|
+
// void rb_darray_make(rb_darray(T) *ptr_to_ary, size_t size);
|
83
|
+
//
|
84
|
+
#define rb_darray_make(ptr_to_ary, size) \
|
85
|
+
rb_darray_make_impl((ptr_to_ary), size, sizeof(**(ptr_to_ary)), \
|
86
|
+
sizeof((*(ptr_to_ary))->data[0]))
|
87
|
+
|
88
|
+
#define rb_darray_data_ptr(ary) ((ary)->data)
|
89
|
+
|
90
|
+
// Set the size of the array to zero without freeing the backing memory.
|
91
|
+
// Allows reusing the same array.
|
92
|
+
//
|
93
|
+
#define rb_darray_clear(ary) (ary->meta.size = 0)
|
94
|
+
|
95
|
+
typedef struct rb_darray_meta {
|
96
|
+
size_t size;
|
97
|
+
size_t capa;
|
98
|
+
} rb_darray_meta_t;
|
99
|
+
|
100
|
+
// Get the size of the dynamic array.
|
101
|
+
//
|
102
|
+
static inline size_t
|
103
|
+
rb_darray_size(const void *ary)
|
104
|
+
{
|
105
|
+
const rb_darray_meta_t *meta = ary;
|
106
|
+
return meta ? meta->size : 0;
|
107
|
+
}
|
108
|
+
|
109
|
+
// Get the capacity of the dynamic array.
|
110
|
+
//
|
111
|
+
static inline size_t
|
112
|
+
rb_darray_capa(const void *ary)
|
113
|
+
{
|
114
|
+
const rb_darray_meta_t *meta = ary;
|
115
|
+
return meta ? meta->capa : 0;
|
116
|
+
}
|
117
|
+
|
118
|
+
// Free the dynamic array.
|
119
|
+
//
|
120
|
+
static inline void
|
121
|
+
rb_darray_free(void *ary)
|
122
|
+
{
|
123
|
+
rb_darray_meta_t *meta = ary;
|
124
|
+
ruby_sized_xfree(ary, meta->capa);
|
125
|
+
}
|
126
|
+
|
127
|
+
// Internal function
|
128
|
+
// Ensure there is space for one more element.
|
129
|
+
// Note: header_size can be bigger than sizeof(rb_darray_meta_t) when T is __int128_t, for example.
|
130
|
+
static inline void
|
131
|
+
rb_darray_ensure_space(void *ptr_to_ary, size_t header_size, size_t element_size)
|
132
|
+
{
|
133
|
+
rb_darray_meta_t **ptr_to_ptr_to_meta = ptr_to_ary;
|
134
|
+
rb_darray_meta_t *meta = *ptr_to_ptr_to_meta;
|
135
|
+
size_t current_capa = rb_darray_capa(meta);
|
136
|
+
if (rb_darray_size(meta) < current_capa) return;
|
137
|
+
|
138
|
+
// Double the capacity
|
139
|
+
size_t new_capa = current_capa == 0 ? 1 : current_capa * 2;
|
140
|
+
|
141
|
+
rb_darray_meta_t *doubled_ary = rb_xrealloc_mul_add(meta, new_capa, element_size, header_size);
|
142
|
+
// rb_xrealloc functions guarantee that NULL is not returned
|
143
|
+
assert(doubled_ary != NULL);
|
144
|
+
|
145
|
+
if (meta == NULL) {
|
146
|
+
// First allocation. Initialize size. On subsequence allocations
|
147
|
+
// realloc takes care of carrying over the size.
|
148
|
+
doubled_ary->size = 0;
|
149
|
+
}
|
150
|
+
|
151
|
+
doubled_ary->capa = new_capa;
|
152
|
+
|
153
|
+
// We don't have access to the type of the dynamic array in function context.
|
154
|
+
// Write out result with memcpy to avoid strict aliasing issue.
|
155
|
+
memcpy(ptr_to_ary, &doubled_ary, sizeof(doubled_ary));
|
156
|
+
}
|
157
|
+
|
158
|
+
static inline void
|
159
|
+
rb_darray_make_impl(void *ptr_to_ary, size_t array_size, size_t header_size, size_t element_size)
|
160
|
+
{
|
161
|
+
rb_darray_meta_t **ptr_to_ptr_to_meta = ptr_to_ary;
|
162
|
+
if (array_size == 0) {
|
163
|
+
*ptr_to_ptr_to_meta = NULL;
|
164
|
+
return;
|
165
|
+
}
|
166
|
+
|
167
|
+
rb_darray_meta_t *meta = rb_xcalloc_mul_add(array_size, element_size, header_size);
|
168
|
+
// rb_xcalloc functions guarantee that NULL is not returned
|
169
|
+
assert(meta != NULL);
|
170
|
+
|
171
|
+
meta->size = array_size;
|
172
|
+
meta->capa = array_size;
|
173
|
+
|
174
|
+
// We don't have access to the type of the dynamic array in function context.
|
175
|
+
// Write out result with memcpy to avoid strict aliasing issue.
|
176
|
+
memcpy(ptr_to_ary, &meta, sizeof(meta));
|
177
|
+
}
|
178
|
+
|
179
|
+
#endif /* RUBY_DARRAY_H */
|