1*c42dbd0eSchristos /* Inline functions.
2*c42dbd0eSchristos Copyright (C) 2020-2022 Free Software Foundation, Inc.
3*c42dbd0eSchristos
4*c42dbd0eSchristos This file is part of libctf.
5*c42dbd0eSchristos
6*c42dbd0eSchristos libctf is free software; you can redistribute it and/or modify it under
7*c42dbd0eSchristos the terms of the GNU General Public License as published by the Free
8*c42dbd0eSchristos Software Foundation; either version 3, or (at your option) any later
9*c42dbd0eSchristos version.
10*c42dbd0eSchristos
11*c42dbd0eSchristos This program is distributed in the hope that it will be useful, but
12*c42dbd0eSchristos WITHOUT ANY WARRANTY; without even the implied warranty of
13*c42dbd0eSchristos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14*c42dbd0eSchristos See the GNU General Public License for more details.
15*c42dbd0eSchristos
16*c42dbd0eSchristos You should have received a copy of the GNU General Public License
17*c42dbd0eSchristos along with this program; see the file COPYING. If not see
18*c42dbd0eSchristos <http://www.gnu.org/licenses/>. */
19*c42dbd0eSchristos
20*c42dbd0eSchristos #ifndef _CTF_INLINES_H
21*c42dbd0eSchristos #define _CTF_INLINES_H
22*c42dbd0eSchristos
23*c42dbd0eSchristos #ifdef __cplusplus
24*c42dbd0eSchristos extern "C"
25*c42dbd0eSchristos {
26*c42dbd0eSchristos #endif
27*c42dbd0eSchristos
28*c42dbd0eSchristos #include "config.h"
29*c42dbd0eSchristos
30*c42dbd0eSchristos #ifndef _libctf_malloc_
31*c42dbd0eSchristos #error "ctf-inlines.h" should not be included directly: include "ctf-impl.h".
32*c42dbd0eSchristos #endif
33*c42dbd0eSchristos
34*c42dbd0eSchristos static inline ssize_t
ctf_get_ctt_size(const ctf_dict_t * fp,const ctf_type_t * tp,ssize_t * sizep,ssize_t * incrementp)35*c42dbd0eSchristos ctf_get_ctt_size (const ctf_dict_t *fp,
36*c42dbd0eSchristos const ctf_type_t *tp,
37*c42dbd0eSchristos ssize_t *sizep,
38*c42dbd0eSchristos ssize_t *incrementp)
39*c42dbd0eSchristos {
40*c42dbd0eSchristos return (fp->ctf_dictops->ctfo_get_ctt_size (fp, tp, sizep, incrementp));
41*c42dbd0eSchristos }
42*c42dbd0eSchristos
43*c42dbd0eSchristos static inline int
ctf_forwardable_kind(int kind)44*c42dbd0eSchristos ctf_forwardable_kind (int kind)
45*c42dbd0eSchristos {
46*c42dbd0eSchristos return (kind == CTF_K_STRUCT || kind == CTF_K_UNION || kind == CTF_K_ENUM);
47*c42dbd0eSchristos }
48*c42dbd0eSchristos
49*c42dbd0eSchristos static inline int
ctf_dynhash_cnext_sorted(ctf_dynhash_t * h,ctf_next_t ** i,const void ** key,const void ** value,ctf_hash_sort_f sort_fun,void * sort_arg)50*c42dbd0eSchristos ctf_dynhash_cnext_sorted (ctf_dynhash_t *h, ctf_next_t **i, const void **key,
51*c42dbd0eSchristos const void **value, ctf_hash_sort_f sort_fun,
52*c42dbd0eSchristos void *sort_arg)
53*c42dbd0eSchristos {
54*c42dbd0eSchristos return ctf_dynhash_next_sorted (h, i, (void **) key, (void **) value,
55*c42dbd0eSchristos sort_fun, sort_arg);
56*c42dbd0eSchristos }
57*c42dbd0eSchristos
58*c42dbd0eSchristos static inline int
ctf_dynhash_cnext(ctf_dynhash_t * h,ctf_next_t ** it,const void ** key,const void ** value)59*c42dbd0eSchristos ctf_dynhash_cnext (ctf_dynhash_t *h, ctf_next_t **it,
60*c42dbd0eSchristos const void **key, const void **value)
61*c42dbd0eSchristos {
62*c42dbd0eSchristos return ctf_dynhash_next (h, it, (void **) key, (void **) value);
63*c42dbd0eSchristos }
64*c42dbd0eSchristos
65*c42dbd0eSchristos static inline int
ctf_dynhash_cinsert(ctf_dynhash_t * h,const void * k,const void * v)66*c42dbd0eSchristos ctf_dynhash_cinsert (ctf_dynhash_t *h, const void *k, const void *v)
67*c42dbd0eSchristos {
68*c42dbd0eSchristos return ctf_dynhash_insert (h, (void *) k, (void *) v);
69*c42dbd0eSchristos }
70*c42dbd0eSchristos
71*c42dbd0eSchristos static inline int
ctf_dynset_cnext(ctf_dynset_t * h,ctf_next_t ** it,const void ** key)72*c42dbd0eSchristos ctf_dynset_cnext (ctf_dynset_t *h, ctf_next_t **it, const void **key)
73*c42dbd0eSchristos {
74*c42dbd0eSchristos return ctf_dynset_next (h, it, (void **) key);
75*c42dbd0eSchristos }
76*c42dbd0eSchristos
77*c42dbd0eSchristos static inline int
ctf_dynset_cinsert(ctf_dynset_t * h,const void * k)78*c42dbd0eSchristos ctf_dynset_cinsert (ctf_dynset_t *h, const void *k)
79*c42dbd0eSchristos {
80*c42dbd0eSchristos return ctf_dynset_insert (h, (void *) k);
81*c42dbd0eSchristos }
82*c42dbd0eSchristos
83*c42dbd0eSchristos static inline int
ctf_assert_internal(ctf_dict_t * fp,const char * file,size_t line,const char * exprstr,int expr)84*c42dbd0eSchristos ctf_assert_internal (ctf_dict_t *fp, const char *file, size_t line,
85*c42dbd0eSchristos const char *exprstr, int expr)
86*c42dbd0eSchristos {
87*c42dbd0eSchristos if (_libctf_unlikely_ (!expr))
88*c42dbd0eSchristos ctf_assert_fail_internal (fp, file, line, exprstr);
89*c42dbd0eSchristos
90*c42dbd0eSchristos return expr;
91*c42dbd0eSchristos }
92*c42dbd0eSchristos
93*c42dbd0eSchristos #ifdef __cplusplus
94*c42dbd0eSchristos }
95*c42dbd0eSchristos #endif
96*c42dbd0eSchristos
97*c42dbd0eSchristos #endif /* _CTF_INLINES_H */
98