debase-ruby_core_source 0.10.10 → 0.10.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +6 -3
- data/debase-ruby_core_source.gemspec +4 -4
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/addr2line.h +20 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/builtin.h +83 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/ccan/build_assert/build_assert.h +40 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/ccan/check_type/check_type.h +63 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/ccan/container_of/container_of.h +142 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/ccan/list/list.h +788 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/ccan/str/str.h +16 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/constant.h +55 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/debug_counter.h +457 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/dln.h +36 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/encindex.h +70 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/eval_intern.h +323 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/gc.h +140 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/hrtime.h +168 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/id.h +290 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/id_table.h +36 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/insns.inc +249 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/insns_info.inc +8983 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/array.h +119 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/bignum.h +246 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/bits.h +566 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/class.h +174 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/compar.h +50 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/compile.h +32 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/compilers.h +108 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/complex.h +29 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/cont.h +25 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/dir.h +17 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/enc.h +20 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/encoding.h +28 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/enum.h +19 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/enumerator.h +22 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/error.h +124 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/eval.h +33 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/file.h +39 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/fixnum.h +185 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/gc.h +161 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/hash.h +241 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/imemo.h +243 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/inits.h +51 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/io.h +35 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/load.h +19 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/loadpath.h +17 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/math.h +24 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/missing.h +19 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/numeric.h +255 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/object.h +83 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/parse.h +23 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/proc.h +33 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/process.h +136 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/random.h +17 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/range.h +41 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/rational.h +71 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/re.h +29 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/sanitizers.h +191 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/scheduler.h +44 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/serial.h +24 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/signal.h +22 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/static_assert.h +17 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/string.h +140 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/struct.h +154 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/symbol.h +41 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/thread.h +54 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/time.h +35 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/transcode.h +21 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/util.h +31 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/variable.h +84 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/vm.h +136 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/warnings.h +17 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal.h +107 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/iseq.h +305 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/known_errors.inc +791 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/method.h +245 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/mjit.h +220 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/mjit_compile.inc +8240 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/node.h +484 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/node_name.inc +210 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/opt_sc.inc +109 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/optinsn.inc +128 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/optunifs.inc +43 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/parse.h +211 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/probes_helper.h +44 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/ractor_core.h +343 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/regenc.h +254 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/regint.h +938 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/regparse.h +370 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/revision.h +2 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/ruby_assert.h +15 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/ruby_atomic.h +23 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/siphash.h +48 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/symbol.h +119 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/thread_pthread.h +115 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/thread_win32.h +61 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/timev.h +57 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/transcode_data.h +138 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/transient_heap.h +65 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/variable.h +22 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/version.h +89 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/vm.inc +5355 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/vm_call_iseq_optimized.inc +244 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/vm_callinfo.h +456 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/vm_core.h +2023 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/vm_debug.h +116 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/vm_exec.h +196 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/vm_insnhelper.h +257 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/vm_opts.h +73 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/vm_sync.h +136 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/vmtc.inc +243 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/addr2line.h +20 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/builtin.h +84 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/ccan/build_assert/build_assert.h +40 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/ccan/check_type/check_type.h +63 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/ccan/container_of/container_of.h +142 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/ccan/list/list.h +788 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/ccan/str/str.h +16 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/constant.h +55 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/darray.h +198 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/debug_counter.h +469 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/dln.h +31 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/encindex.h +70 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/eval_intern.h +335 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/gc.h +141 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/hrtime.h +168 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/id.h +293 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/id_table.h +36 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/insns.inc +249 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/insns_info.inc +9063 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/internal/array.h +113 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/internal/bignum.h +246 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/internal/bits.h +565 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/internal/class.h +196 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/internal/compar.h +49 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/internal/compile.h +35 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/internal/compilers.h +107 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/internal/complex.h +29 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/internal/cont.h +24 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/internal/dir.h +16 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/internal/enc.h +19 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/internal/encoding.h +30 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/internal/enum.h +18 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/internal/enumerator.h +21 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/internal/error.h +191 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/internal/eval.h +32 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/internal/file.h +38 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/internal/fixnum.h +184 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/internal/gc.h +186 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/internal/hash.h +243 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/internal/imemo.h +243 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/internal/inits.h +50 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/internal/io.h +38 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/internal/load.h +18 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/internal/loadpath.h +16 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/internal/math.h +23 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/internal/missing.h +18 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/internal/numeric.h +271 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/internal/object.h +83 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/internal/parse.h +23 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/internal/proc.h +32 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/internal/process.h +137 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/internal/random.h +16 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/internal/range.h +40 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/internal/rational.h +72 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/internal/re.h +30 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/internal/sanitizers.h +190 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/internal/serial.h +23 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/internal/signal.h +21 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/internal/static_assert.h +16 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/internal/string.h +141 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/internal/struct.h +153 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/internal/symbol.h +41 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/internal/thread.h +53 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/internal/time.h +34 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/internal/transcode.h +20 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/internal/util.h +27 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/internal/variable.h +83 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/internal/vm.h +133 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/internal/warnings.h +16 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/internal.h +109 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/iseq.h +322 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/known_errors.inc +791 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/method.h +253 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/mjit.h +231 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/mjit_compile.inc +8322 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/node.h +510 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/node_name.inc +208 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/opt_sc.inc +109 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/optinsn.inc +128 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/optunifs.inc +43 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/parse.h +214 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/probes_helper.h +44 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/ractor_core.h +346 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/regenc.h +254 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/regint.h +942 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/regparse.h +370 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/revision.h +2 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/ruby_assert.h +14 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/ruby_atomic.h +23 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/siphash.h +48 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/symbol.h +119 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/thread_pthread.h +115 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/thread_win32.h +61 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/timev.h +57 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/transcode_data.h +138 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/transient_heap.h +65 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/variable.h +21 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/version.h +88 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/vm.inc +5470 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/vm_call_iseq_optimized.inc +244 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/vm_callinfo.h +487 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/vm_core.h +2107 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/vm_debug.h +124 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/vm_exec.h +197 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/vm_insnhelper.h +265 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/vm_opts.h +73 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/vm_sync.h +137 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/vmtc.inc +243 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/yjit.h +73 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/yjit_asm.h +408 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/yjit_codegen.h +23 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/yjit_core.h +307 -0
- data/lib/debase/ruby_core_source/ruby-3.1.0-p0/yjit_iface.h +38 -0
- data/lib/debase/ruby_core_source/version.rb +1 -1
- metadata +235 -14
@@ -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
|
+
* 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 container_of(foo, struct info, my_foo);
|
28
|
+
* }
|
29
|
+
*/
|
30
|
+
#define container_of(member_ptr, containing_type, member) \
|
31
|
+
((containing_type *) \
|
32
|
+
((char *)(member_ptr) \
|
33
|
+
- container_off(containing_type, member)) \
|
34
|
+
+ check_types_match(*(member_ptr), ((containing_type *)0)->member))
|
35
|
+
|
36
|
+
|
37
|
+
/**
|
38
|
+
* 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 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 container_of_or_null(member_ptr, containing_type, member) \
|
67
|
+
((containing_type *) \
|
68
|
+
container_of_or_null_(member_ptr, \
|
69
|
+
container_off(containing_type, member)) \
|
70
|
+
+ check_types_match(*(member_ptr), ((containing_type *)0)->member))
|
71
|
+
|
72
|
+
/**
|
73
|
+
* 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 = container_off(struct info, my_foo);
|
93
|
+
* return (void *)((char *)foo - off);
|
94
|
+
* }
|
95
|
+
*/
|
96
|
+
#define container_off(containing_type, member) \
|
97
|
+
offsetof(containing_type, member)
|
98
|
+
|
99
|
+
/**
|
100
|
+
* 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 = container_of_var(foo, i, my_foo);
|
112
|
+
* return i;
|
113
|
+
* }
|
114
|
+
*/
|
115
|
+
#if HAVE_TYPEOF
|
116
|
+
#define container_of_var(member_ptr, container_var, member) \
|
117
|
+
container_of(member_ptr, typeof(*container_var), member)
|
118
|
+
#else
|
119
|
+
#define container_of_var(member_ptr, container_var, member) \
|
120
|
+
((void *)((char *)(member_ptr) - \
|
121
|
+
container_off_var(container_var, member)))
|
122
|
+
#endif
|
123
|
+
|
124
|
+
/**
|
125
|
+
* 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 HAVE_TYPEOF
|
135
|
+
#define container_off_var(var, member) \
|
136
|
+
container_off(typeof(*var), member)
|
137
|
+
#else
|
138
|
+
#define container_off_var(var, member) \
|
139
|
+
((const char *)&(var)->member - (const char *)(var))
|
140
|
+
#endif
|
141
|
+
|
142
|
+
#endif /* CCAN_CONTAINER_OF_H */
|