18dffb485Schristos /* Inline functions. 2*12989c96Schristos Copyright (C) 2020-2024 Free Software Foundation, Inc. 38dffb485Schristos 48dffb485Schristos This file is part of libctf. 58dffb485Schristos 68dffb485Schristos libctf is free software; you can redistribute it and/or modify it under 78dffb485Schristos the terms of the GNU General Public License as published by the Free 88dffb485Schristos Software Foundation; either version 3, or (at your option) any later 98dffb485Schristos version. 108dffb485Schristos 118dffb485Schristos This program is distributed in the hope that it will be useful, but 128dffb485Schristos WITHOUT ANY WARRANTY; without even the implied warranty of 138dffb485Schristos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 148dffb485Schristos See the GNU General Public License for more details. 158dffb485Schristos 168dffb485Schristos You should have received a copy of the GNU General Public License 178dffb485Schristos along with this program; see the file COPYING. If not see 188dffb485Schristos <http://www.gnu.org/licenses/>. */ 198dffb485Schristos 208dffb485Schristos #ifndef _CTF_INLINES_H 218dffb485Schristos #define _CTF_INLINES_H 228dffb485Schristos 238dffb485Schristos #ifdef __cplusplus 248dffb485Schristos extern "C" 258dffb485Schristos { 268dffb485Schristos #endif 278dffb485Schristos 288dffb485Schristos #include "config.h" 298dffb485Schristos 308dffb485Schristos #ifndef _libctf_malloc_ 318dffb485Schristos #error "ctf-inlines.h" should not be included directly: include "ctf-impl.h". 328dffb485Schristos #endif 338dffb485Schristos 348dffb485Schristos static inline ssize_t 354b169a6bSchristos ctf_get_ctt_size (const ctf_dict_t *fp, 368dffb485Schristos const ctf_type_t *tp, 378dffb485Schristos ssize_t *sizep, 388dffb485Schristos ssize_t *incrementp) 398dffb485Schristos { 404b169a6bSchristos return (fp->ctf_dictops->ctfo_get_ctt_size (fp, tp, sizep, incrementp)); 418dffb485Schristos } 428dffb485Schristos 438dffb485Schristos static inline int 448dffb485Schristos ctf_forwardable_kind (int kind) 458dffb485Schristos { 468dffb485Schristos return (kind == CTF_K_STRUCT || kind == CTF_K_UNION || kind == CTF_K_ENUM); 478dffb485Schristos } 488dffb485Schristos 498dffb485Schristos static inline int 508dffb485Schristos ctf_dynhash_cnext_sorted (ctf_dynhash_t *h, ctf_next_t **i, const void **key, 518dffb485Schristos const void **value, ctf_hash_sort_f sort_fun, 528dffb485Schristos void *sort_arg) 538dffb485Schristos { 548dffb485Schristos return ctf_dynhash_next_sorted (h, i, (void **) key, (void **) value, 558dffb485Schristos sort_fun, sort_arg); 568dffb485Schristos } 578dffb485Schristos 588dffb485Schristos static inline int 598dffb485Schristos ctf_dynhash_cnext (ctf_dynhash_t *h, ctf_next_t **it, 608dffb485Schristos const void **key, const void **value) 618dffb485Schristos { 628dffb485Schristos return ctf_dynhash_next (h, it, (void **) key, (void **) value); 638dffb485Schristos } 648dffb485Schristos 658dffb485Schristos static inline int 668dffb485Schristos ctf_dynhash_cinsert (ctf_dynhash_t *h, const void *k, const void *v) 678dffb485Schristos { 688dffb485Schristos return ctf_dynhash_insert (h, (void *) k, (void *) v); 698dffb485Schristos } 708dffb485Schristos 718dffb485Schristos static inline int 728dffb485Schristos ctf_dynset_cnext (ctf_dynset_t *h, ctf_next_t **it, const void **key) 738dffb485Schristos { 748dffb485Schristos return ctf_dynset_next (h, it, (void **) key); 758dffb485Schristos } 768dffb485Schristos 778dffb485Schristos static inline int 788dffb485Schristos ctf_dynset_cinsert (ctf_dynset_t *h, const void *k) 798dffb485Schristos { 808dffb485Schristos return ctf_dynset_insert (h, (void *) k); 818dffb485Schristos } 828dffb485Schristos 838dffb485Schristos static inline int 844b169a6bSchristos ctf_assert_internal (ctf_dict_t *fp, const char *file, size_t line, 858dffb485Schristos const char *exprstr, int expr) 868dffb485Schristos { 878dffb485Schristos if (_libctf_unlikely_ (!expr)) 888dffb485Schristos ctf_assert_fail_internal (fp, file, line, exprstr); 898dffb485Schristos 908dffb485Schristos return expr; 918dffb485Schristos } 928dffb485Schristos 93*12989c96Schristos static inline int 94*12989c96Schristos ctf_set_errno (ctf_dict_t *fp, int err) 95*12989c96Schristos { 96*12989c96Schristos fp->ctf_errno = err; 97*12989c96Schristos /* Don't rely on CTF_ERR here as it will not properly sign extend on 64-bit 98*12989c96Schristos Windows ABI. */ 99*12989c96Schristos return -1; 100*12989c96Schristos } 101*12989c96Schristos 102*12989c96Schristos static inline ctf_id_t 103*12989c96Schristos ctf_set_typed_errno (ctf_dict_t *fp, int err) 104*12989c96Schristos { 105*12989c96Schristos fp->ctf_errno = err; 106*12989c96Schristos return CTF_ERR; 107*12989c96Schristos } 108*12989c96Schristos 109*12989c96Schristos 1108dffb485Schristos #ifdef __cplusplus 1118dffb485Schristos } 1128dffb485Schristos #endif 1138dffb485Schristos 1148dffb485Schristos #endif /* _CTF_INLINES_H */ 115