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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ff28770b77a2818d91048c24aaf1afa0350b6acf100ecc47ab6c595768a03554
|
4
|
+
data.tar.gz: aad76805ccfb985f33d846a2974d2807f078e2ecb1f1cedb7e8ef95b9cac0f93
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 909eb39b2a985d634dbd1d54e4dd573d8948a574e6161393959d18c620f3f8d14972d26a5b1aefcf0f569ea8c9b70cc4c0d951162c09272110128972757dae17
|
7
|
+
data.tar.gz: 1d41a4adc81fef0d1059d84def02e5aa49d16c829e25b48e05633018f290f11964efad0db94aa3c857799fe06b84af6b8923c23269e7b5cd17639a24c978b63b
|
data/CHANGELOG.md
CHANGED
@@ -0,0 +1,20 @@
|
|
1
|
+
#ifndef RUBY_ADDR2LINE_H
|
2
|
+
#define RUBY_ADDR2LINE_H
|
3
|
+
/**********************************************************************
|
4
|
+
|
5
|
+
addr2line.h -
|
6
|
+
|
7
|
+
$Author$
|
8
|
+
|
9
|
+
Copyright (C) 2010 Shinichiro Hamaji
|
10
|
+
|
11
|
+
**********************************************************************/
|
12
|
+
|
13
|
+
#if (defined(USE_ELF) || defined(HAVE_MACH_O_LOADER_H))
|
14
|
+
|
15
|
+
void
|
16
|
+
rb_dump_backtrace_with_lines(int num_traces, void **traces);
|
17
|
+
|
18
|
+
#endif /* USE_ELF */
|
19
|
+
|
20
|
+
#endif /* RUBY_ADDR2LINE_H */
|
@@ -0,0 +1,121 @@
|
|
1
|
+
#ifndef BUILTIN_H_INCLUDED
|
2
|
+
#define BUILTIN_H_INCLUDED
|
3
|
+
|
4
|
+
// invoke
|
5
|
+
|
6
|
+
struct rb_builtin_function {
|
7
|
+
// for invocation
|
8
|
+
const void * const func_ptr;
|
9
|
+
const int argc;
|
10
|
+
|
11
|
+
// for load
|
12
|
+
const int index;
|
13
|
+
const char * const name;
|
14
|
+
|
15
|
+
// for jit
|
16
|
+
void (*compiler)(FILE *, long, unsigned, bool);
|
17
|
+
};
|
18
|
+
|
19
|
+
#define RB_BUILTIN_FUNCTION(_i, _name, _fname, _arity, _compiler) {\
|
20
|
+
.name = _i < 0 ? NULL : #_name, \
|
21
|
+
.func_ptr = (void *)_fname, \
|
22
|
+
.argc = _arity, \
|
23
|
+
.index = _i, \
|
24
|
+
.compiler = _compiler, \
|
25
|
+
}
|
26
|
+
|
27
|
+
void rb_load_with_builtin_functions(const char *feature_name, const struct rb_builtin_function *table);
|
28
|
+
|
29
|
+
#ifndef rb_execution_context_t
|
30
|
+
typedef struct rb_execution_context_struct rb_execution_context_t;
|
31
|
+
#define rb_execution_context_t rb_execution_context_t
|
32
|
+
#endif
|
33
|
+
|
34
|
+
/* The following code is generated by the following Ruby script:
|
35
|
+
|
36
|
+
typedef = proc {|i, args|
|
37
|
+
"typedef VALUE (*rb_builtin_arity#{i}_function_type)(rb_execution_context_t *ec, VALUE self#{args});"
|
38
|
+
}
|
39
|
+
puts typedef[0, ""]
|
40
|
+
(1..15).each {|i|
|
41
|
+
puts typedef[i, ",\n " + (0...i).map{"VALUE"}.join(", ")]
|
42
|
+
}
|
43
|
+
16.times{|i|
|
44
|
+
puts "static inline void rb_builtin_function_check_arity#{i}(rb_builtin_arity#{i}_function_type f){}"
|
45
|
+
}
|
46
|
+
*/
|
47
|
+
|
48
|
+
typedef VALUE (*rb_builtin_arity0_function_type)(rb_execution_context_t *ec, VALUE self);
|
49
|
+
typedef VALUE (*rb_builtin_arity1_function_type)(rb_execution_context_t *ec, VALUE self,
|
50
|
+
VALUE);
|
51
|
+
typedef VALUE (*rb_builtin_arity2_function_type)(rb_execution_context_t *ec, VALUE self,
|
52
|
+
VALUE, VALUE);
|
53
|
+
typedef VALUE (*rb_builtin_arity3_function_type)(rb_execution_context_t *ec, VALUE self,
|
54
|
+
VALUE, VALUE, VALUE);
|
55
|
+
typedef VALUE (*rb_builtin_arity4_function_type)(rb_execution_context_t *ec, VALUE self,
|
56
|
+
VALUE, VALUE, VALUE, VALUE);
|
57
|
+
typedef VALUE (*rb_builtin_arity5_function_type)(rb_execution_context_t *ec, VALUE self,
|
58
|
+
VALUE, VALUE, VALUE, VALUE, VALUE);
|
59
|
+
typedef VALUE (*rb_builtin_arity6_function_type)(rb_execution_context_t *ec, VALUE self,
|
60
|
+
VALUE, VALUE, VALUE, VALUE, VALUE, VALUE);
|
61
|
+
typedef VALUE (*rb_builtin_arity7_function_type)(rb_execution_context_t *ec, VALUE self,
|
62
|
+
VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE);
|
63
|
+
typedef VALUE (*rb_builtin_arity8_function_type)(rb_execution_context_t *ec, VALUE self,
|
64
|
+
VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE);
|
65
|
+
typedef VALUE (*rb_builtin_arity9_function_type)(rb_execution_context_t *ec, VALUE self,
|
66
|
+
VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE);
|
67
|
+
typedef VALUE (*rb_builtin_arity10_function_type)(rb_execution_context_t *ec, VALUE self,
|
68
|
+
VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE);
|
69
|
+
typedef VALUE (*rb_builtin_arity11_function_type)(rb_execution_context_t *ec, VALUE self,
|
70
|
+
VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE);
|
71
|
+
typedef VALUE (*rb_builtin_arity12_function_type)(rb_execution_context_t *ec, VALUE self,
|
72
|
+
VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE);
|
73
|
+
typedef VALUE (*rb_builtin_arity13_function_type)(rb_execution_context_t *ec, VALUE self,
|
74
|
+
VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE);
|
75
|
+
typedef VALUE (*rb_builtin_arity14_function_type)(rb_execution_context_t *ec, VALUE self,
|
76
|
+
VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE);
|
77
|
+
typedef VALUE (*rb_builtin_arity15_function_type)(rb_execution_context_t *ec, VALUE self,
|
78
|
+
VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE);
|
79
|
+
static inline void rb_builtin_function_check_arity0(rb_builtin_arity0_function_type f){}
|
80
|
+
static inline void rb_builtin_function_check_arity1(rb_builtin_arity1_function_type f){}
|
81
|
+
static inline void rb_builtin_function_check_arity2(rb_builtin_arity2_function_type f){}
|
82
|
+
static inline void rb_builtin_function_check_arity3(rb_builtin_arity3_function_type f){}
|
83
|
+
static inline void rb_builtin_function_check_arity4(rb_builtin_arity4_function_type f){}
|
84
|
+
static inline void rb_builtin_function_check_arity5(rb_builtin_arity5_function_type f){}
|
85
|
+
static inline void rb_builtin_function_check_arity6(rb_builtin_arity6_function_type f){}
|
86
|
+
static inline void rb_builtin_function_check_arity7(rb_builtin_arity7_function_type f){}
|
87
|
+
static inline void rb_builtin_function_check_arity8(rb_builtin_arity8_function_type f){}
|
88
|
+
static inline void rb_builtin_function_check_arity9(rb_builtin_arity9_function_type f){}
|
89
|
+
static inline void rb_builtin_function_check_arity10(rb_builtin_arity10_function_type f){}
|
90
|
+
static inline void rb_builtin_function_check_arity11(rb_builtin_arity11_function_type f){}
|
91
|
+
static inline void rb_builtin_function_check_arity12(rb_builtin_arity12_function_type f){}
|
92
|
+
static inline void rb_builtin_function_check_arity13(rb_builtin_arity13_function_type f){}
|
93
|
+
static inline void rb_builtin_function_check_arity14(rb_builtin_arity14_function_type f){}
|
94
|
+
static inline void rb_builtin_function_check_arity15(rb_builtin_arity15_function_type f){}
|
95
|
+
|
96
|
+
PUREFUNC(VALUE rb_vm_lvar_exposed(rb_execution_context_t *ec, int index));
|
97
|
+
VALUE rb_vm_lvar_exposed(rb_execution_context_t *ec, int index);
|
98
|
+
|
99
|
+
// __builtin_inline!
|
100
|
+
|
101
|
+
PUREFUNC(static inline VALUE rb_vm_lvar(rb_execution_context_t *ec, int index));
|
102
|
+
|
103
|
+
static inline VALUE
|
104
|
+
rb_vm_lvar(rb_execution_context_t *ec, int index)
|
105
|
+
{
|
106
|
+
#if defined(VM_CORE_H_EC_DEFINED) && VM_CORE_H_EC_DEFINED
|
107
|
+
return ec->cfp->ep[index];
|
108
|
+
#else
|
109
|
+
return rb_vm_lvar_exposed(ec, index);
|
110
|
+
#endif
|
111
|
+
}
|
112
|
+
|
113
|
+
// dump/load
|
114
|
+
|
115
|
+
struct builtin_binary {
|
116
|
+
const char *feature; // feature name
|
117
|
+
const unsigned char *bin; // binary by ISeq#to_binary
|
118
|
+
size_t bin_size;
|
119
|
+
};
|
120
|
+
|
121
|
+
#endif // BUILTIN_H_INCLUDED
|
@@ -0,0 +1,40 @@
|
|
1
|
+
/* CC0 (Public domain) - see ccan/licenses/CC0 file for details */
|
2
|
+
#ifndef CCAN_BUILD_ASSERT_H
|
3
|
+
#define CCAN_BUILD_ASSERT_H
|
4
|
+
|
5
|
+
/**
|
6
|
+
* CCAN_BUILD_ASSERT - assert a build-time dependency.
|
7
|
+
* @cond: the compile-time condition which must be true.
|
8
|
+
*
|
9
|
+
* Your compile will fail if the condition isn't true, or can't be evaluated
|
10
|
+
* by the compiler. This can only be used within a function.
|
11
|
+
*
|
12
|
+
* Example:
|
13
|
+
* #include <stddef.h>
|
14
|
+
* ...
|
15
|
+
* static char *foo_to_char(struct foo *foo)
|
16
|
+
* {
|
17
|
+
* // This code needs string to be at start of foo.
|
18
|
+
* CCAN_BUILD_ASSERT(offsetof(struct foo, string) == 0);
|
19
|
+
* return (char *)foo;
|
20
|
+
* }
|
21
|
+
*/
|
22
|
+
#define CCAN_BUILD_ASSERT(cond) \
|
23
|
+
do { (void) sizeof(char [1 - 2*!(cond)]); } while(0)
|
24
|
+
|
25
|
+
/**
|
26
|
+
* CCAN_BUILD_ASSERT_OR_ZERO - assert a build-time dependency, as an expression.
|
27
|
+
* @cond: the compile-time condition which must be true.
|
28
|
+
*
|
29
|
+
* Your compile will fail if the condition isn't true, or can't be evaluated
|
30
|
+
* by the compiler. This can be used in an expression: its value is "0".
|
31
|
+
*
|
32
|
+
* Example:
|
33
|
+
* #define foo_to_char(foo) \
|
34
|
+
* ((char *)(foo) \
|
35
|
+
* + CCAN_BUILD_ASSERT_OR_ZERO(offsetof(struct foo, string) == 0))
|
36
|
+
*/
|
37
|
+
#define CCAN_BUILD_ASSERT_OR_ZERO(cond) \
|
38
|
+
(sizeof(char [1 - 2*!(cond)]) - 1)
|
39
|
+
|
40
|
+
#endif /* CCAN_BUILD_ASSERT_H */
|
@@ -0,0 +1,63 @@
|
|
1
|
+
/* CC0 (Public domain) - see ccan/licenses/CC0 file for details */
|
2
|
+
#ifndef CCAN_CHECK_TYPE_H
|
3
|
+
#define CCAN_CHECK_TYPE_H
|
4
|
+
|
5
|
+
/**
|
6
|
+
* ccan_check_type - issue a warning or build failure if type is not correct.
|
7
|
+
* @expr: the expression whose type we should check (not evaluated).
|
8
|
+
* @type: the exact type we expect the expression to be.
|
9
|
+
*
|
10
|
+
* This macro is usually used within other macros to try to ensure that a macro
|
11
|
+
* argument is of the expected type. No type promotion of the expression is
|
12
|
+
* done: an unsigned int is not the same as an int!
|
13
|
+
*
|
14
|
+
* ccan_check_type() always evaluates to 0.
|
15
|
+
*
|
16
|
+
* If your compiler does not support typeof, then the best we can do is fail
|
17
|
+
* to compile if the sizes of the types are unequal (a less complete check).
|
18
|
+
*
|
19
|
+
* Example:
|
20
|
+
* // They should always pass a 64-bit value to _set_some_value!
|
21
|
+
* #define set_some_value(expr) \
|
22
|
+
* _set_some_value((ccan_check_type((expr), uint64_t), (expr)))
|
23
|
+
*/
|
24
|
+
|
25
|
+
/**
|
26
|
+
* ccan_check_types_match - issue a warning or build failure if types are not same.
|
27
|
+
* @expr1: the first expression (not evaluated).
|
28
|
+
* @expr2: the second expression (not evaluated).
|
29
|
+
*
|
30
|
+
* This macro is usually used within other macros to try to ensure that
|
31
|
+
* arguments are of identical types. No type promotion of the expressions is
|
32
|
+
* done: an unsigned int is not the same as an int!
|
33
|
+
*
|
34
|
+
* ccan_check_types_match() always evaluates to 0.
|
35
|
+
*
|
36
|
+
* If your compiler does not support typeof, then the best we can do is fail
|
37
|
+
* to compile if the sizes of the types are unequal (a less complete check).
|
38
|
+
*
|
39
|
+
* Example:
|
40
|
+
* // Do subtraction to get to enclosing type, but make sure that
|
41
|
+
* // pointer is of correct type for that member.
|
42
|
+
* #define ccan_container_of(mbr_ptr, encl_type, mbr) \
|
43
|
+
* (ccan_check_types_match((mbr_ptr), &((encl_type *)0)->mbr), \
|
44
|
+
* ((encl_type *) \
|
45
|
+
* ((char *)(mbr_ptr) - offsetof(enclosing_type, mbr))))
|
46
|
+
*/
|
47
|
+
#if defined(HAVE_TYPEOF) && HAVE_TYPEOF
|
48
|
+
#define ccan_check_type(expr, type) \
|
49
|
+
((typeof(expr) *)0 != (type *)0)
|
50
|
+
|
51
|
+
#define ccan_check_types_match(expr1, expr2) \
|
52
|
+
((typeof(expr1) *)0 != (typeof(expr2) *)0)
|
53
|
+
#else
|
54
|
+
#include "ccan/build_assert/build_assert.h"
|
55
|
+
/* Without typeof, we can only test the sizes. */
|
56
|
+
#define ccan_check_type(expr, type) \
|
57
|
+
CCAN_BUILD_ASSERT_OR_ZERO(sizeof(expr) == sizeof(type))
|
58
|
+
|
59
|
+
#define ccan_check_types_match(expr1, expr2) \
|
60
|
+
CCAN_BUILD_ASSERT_OR_ZERO(sizeof(expr1) == sizeof(expr2))
|
61
|
+
#endif /* HAVE_TYPEOF */
|
62
|
+
|
63
|
+
#endif /* CCAN_CHECK_TYPE_H */
|
@@ -0,0 +1,142 @@
|
|
1
|
+
/* CC0 (Public domain) - see ccan/licenses/CC0 file for details */
|
2
|
+
#ifndef CCAN_CONTAINER_OF_H
|
3
|
+
#define CCAN_CONTAINER_OF_H
|
4
|
+
#include "ccan/check_type/check_type.h"
|
5
|
+
|
6
|
+
/**
|
7
|
+
* ccan_container_of - get pointer to enclosing structure
|
8
|
+
* @member_ptr: pointer to the structure member
|
9
|
+
* @containing_type: the type this member is within
|
10
|
+
* @member: the name of this member within the structure.
|
11
|
+
*
|
12
|
+
* Given a pointer to a member of a structure, this macro does pointer
|
13
|
+
* subtraction to return the pointer to the enclosing type.
|
14
|
+
*
|
15
|
+
* Example:
|
16
|
+
* struct foo {
|
17
|
+
* int fielda, fieldb;
|
18
|
+
* // ...
|
19
|
+
* };
|
20
|
+
* struct info {
|
21
|
+
* int some_other_field;
|
22
|
+
* struct foo my_foo;
|
23
|
+
* };
|
24
|
+
*
|
25
|
+
* static struct info *foo_to_info(struct foo *foo)
|
26
|
+
* {
|
27
|
+
* return ccan_container_of(foo, struct info, my_foo);
|
28
|
+
* }
|
29
|
+
*/
|
30
|
+
#define ccan_container_of(member_ptr, containing_type, member) \
|
31
|
+
((containing_type *) \
|
32
|
+
((char *)(member_ptr) \
|
33
|
+
- ccan_container_off(containing_type, member)) \
|
34
|
+
+ ccan_check_types_match(*(member_ptr), ((containing_type *)0)->member))
|
35
|
+
|
36
|
+
|
37
|
+
/**
|
38
|
+
* ccan_container_of_or_null - get pointer to enclosing structure, or NULL
|
39
|
+
* @member_ptr: pointer to the structure member
|
40
|
+
* @containing_type: the type this member is within
|
41
|
+
* @member: the name of this member within the structure.
|
42
|
+
*
|
43
|
+
* Given a pointer to a member of a structure, this macro does pointer
|
44
|
+
* subtraction to return the pointer to the enclosing type, unless it
|
45
|
+
* is given NULL, in which case it also returns NULL.
|
46
|
+
*
|
47
|
+
* Example:
|
48
|
+
* struct foo {
|
49
|
+
* int fielda, fieldb;
|
50
|
+
* // ...
|
51
|
+
* };
|
52
|
+
* struct info {
|
53
|
+
* int some_other_field;
|
54
|
+
* struct foo my_foo;
|
55
|
+
* };
|
56
|
+
*
|
57
|
+
* static struct info *foo_to_info_allowing_null(struct foo *foo)
|
58
|
+
* {
|
59
|
+
* return ccan_container_of_or_null(foo, struct info, my_foo);
|
60
|
+
* }
|
61
|
+
*/
|
62
|
+
static inline char *container_of_or_null_(void *member_ptr, size_t offset)
|
63
|
+
{
|
64
|
+
return member_ptr ? (char *)member_ptr - offset : NULL;
|
65
|
+
}
|
66
|
+
#define ccan_container_of_or_null(member_ptr, containing_type, member) \
|
67
|
+
((containing_type *) \
|
68
|
+
ccan_container_of_or_null_(member_ptr, \
|
69
|
+
ccan_container_off(containing_type, member)) \
|
70
|
+
+ ccan_check_types_match(*(member_ptr), ((containing_type *)0)->member))
|
71
|
+
|
72
|
+
/**
|
73
|
+
* ccan_container_off - get offset to enclosing structure
|
74
|
+
* @containing_type: the type this member is within
|
75
|
+
* @member: the name of this member within the structure.
|
76
|
+
*
|
77
|
+
* Given a pointer to a member of a structure, this macro does
|
78
|
+
* typechecking and figures out the offset to the enclosing type.
|
79
|
+
*
|
80
|
+
* Example:
|
81
|
+
* struct foo {
|
82
|
+
* int fielda, fieldb;
|
83
|
+
* // ...
|
84
|
+
* };
|
85
|
+
* struct info {
|
86
|
+
* int some_other_field;
|
87
|
+
* struct foo my_foo;
|
88
|
+
* };
|
89
|
+
*
|
90
|
+
* static struct info *foo_to_info(struct foo *foo)
|
91
|
+
* {
|
92
|
+
* size_t off = ccan_container_off(struct info, my_foo);
|
93
|
+
* return (void *)((char *)foo - off);
|
94
|
+
* }
|
95
|
+
*/
|
96
|
+
#define ccan_container_off(containing_type, member) \
|
97
|
+
offsetof(containing_type, member)
|
98
|
+
|
99
|
+
/**
|
100
|
+
* ccan_container_of_var - get pointer to enclosing structure using a variable
|
101
|
+
* @member_ptr: pointer to the structure member
|
102
|
+
* @container_var: a pointer of same type as this member's container
|
103
|
+
* @member: the name of this member within the structure.
|
104
|
+
*
|
105
|
+
* Given a pointer to a member of a structure, this macro does pointer
|
106
|
+
* subtraction to return the pointer to the enclosing type.
|
107
|
+
*
|
108
|
+
* Example:
|
109
|
+
* static struct info *foo_to_i(struct foo *foo)
|
110
|
+
* {
|
111
|
+
* struct info *i = ccan_container_of_var(foo, i, my_foo);
|
112
|
+
* return i;
|
113
|
+
* }
|
114
|
+
*/
|
115
|
+
#if defined(HAVE_TYPEOF) && HAVE_TYPEOF
|
116
|
+
#define ccan_container_of_var(member_ptr, container_var, member) \
|
117
|
+
ccan_container_of(member_ptr, typeof(*container_var), member)
|
118
|
+
#else
|
119
|
+
#define ccan_container_of_var(member_ptr, container_var, member) \
|
120
|
+
((void *)((char *)(member_ptr) - \
|
121
|
+
ccan_container_off_var(container_var, member)))
|
122
|
+
#endif
|
123
|
+
|
124
|
+
/**
|
125
|
+
* ccan_container_off_var - get offset of a field in enclosing structure
|
126
|
+
* @container_var: a pointer to a container structure
|
127
|
+
* @member: the name of a member within the structure.
|
128
|
+
*
|
129
|
+
* Given (any) pointer to a structure and a its member name, this
|
130
|
+
* macro does pointer subtraction to return offset of member in a
|
131
|
+
* structure memory layout.
|
132
|
+
*
|
133
|
+
*/
|
134
|
+
#if defined(HAVE_TYPEOF) && HAVE_TYPEOF
|
135
|
+
#define ccan_container_off_var(var, member) \
|
136
|
+
ccan_container_off(typeof(*var), member)
|
137
|
+
#else
|
138
|
+
#define ccan_container_off_var(var, member) \
|
139
|
+
((const char *)&(var)->member - (const char *)(var))
|
140
|
+
#endif
|
141
|
+
|
142
|
+
#endif /* CCAN_CONTAINER_OF_H */
|