xref: /netbsd-src/external/gpl3/gdb.old/dist/libctf/ctf-inlines.h (revision 6881a4007f077b54e5f51159c52b9b25f57deb0d)
17d62b00eSchristos /* Inline functions.
2*6881a400Schristos    Copyright (C) 2020-2022 Free Software Foundation, Inc.
37d62b00eSchristos 
47d62b00eSchristos    This file is part of libctf.
57d62b00eSchristos 
67d62b00eSchristos    libctf is free software; you can redistribute it and/or modify it under
77d62b00eSchristos    the terms of the GNU General Public License as published by the Free
87d62b00eSchristos    Software Foundation; either version 3, or (at your option) any later
97d62b00eSchristos    version.
107d62b00eSchristos 
117d62b00eSchristos    This program is distributed in the hope that it will be useful, but
127d62b00eSchristos    WITHOUT ANY WARRANTY; without even the implied warranty of
137d62b00eSchristos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
147d62b00eSchristos    See the GNU General Public License for more details.
157d62b00eSchristos 
167d62b00eSchristos    You should have received a copy of the GNU General Public License
177d62b00eSchristos    along with this program; see the file COPYING.  If not see
187d62b00eSchristos    <http://www.gnu.org/licenses/>.  */
197d62b00eSchristos 
207d62b00eSchristos #ifndef	_CTF_INLINES_H
217d62b00eSchristos #define	_CTF_INLINES_H
227d62b00eSchristos 
237d62b00eSchristos #ifdef	__cplusplus
247d62b00eSchristos extern "C"
257d62b00eSchristos {
267d62b00eSchristos #endif
277d62b00eSchristos 
287d62b00eSchristos #include "config.h"
297d62b00eSchristos 
307d62b00eSchristos #ifndef _libctf_malloc_
317d62b00eSchristos #error "ctf-inlines.h" should not be included directly: include "ctf-impl.h".
327d62b00eSchristos #endif
337d62b00eSchristos 
347d62b00eSchristos static inline ssize_t
35*6881a400Schristos ctf_get_ctt_size (const ctf_dict_t *fp,
367d62b00eSchristos 		  const ctf_type_t *tp,
377d62b00eSchristos 		  ssize_t *sizep,
387d62b00eSchristos 		  ssize_t *incrementp)
397d62b00eSchristos {
40*6881a400Schristos   return (fp->ctf_dictops->ctfo_get_ctt_size (fp, tp, sizep, incrementp));
417d62b00eSchristos }
427d62b00eSchristos 
437d62b00eSchristos static inline int
447d62b00eSchristos ctf_forwardable_kind (int kind)
457d62b00eSchristos {
467d62b00eSchristos   return (kind == CTF_K_STRUCT || kind == CTF_K_UNION || kind == CTF_K_ENUM);
477d62b00eSchristos }
487d62b00eSchristos 
497d62b00eSchristos static inline int
507d62b00eSchristos ctf_dynhash_cnext_sorted (ctf_dynhash_t *h, ctf_next_t **i, const void **key,
517d62b00eSchristos 			  const void **value, ctf_hash_sort_f sort_fun,
527d62b00eSchristos 			  void *sort_arg)
537d62b00eSchristos {
547d62b00eSchristos   return ctf_dynhash_next_sorted (h, i, (void **) key, (void **) value,
557d62b00eSchristos 				  sort_fun, sort_arg);
567d62b00eSchristos }
577d62b00eSchristos 
587d62b00eSchristos static inline int
597d62b00eSchristos ctf_dynhash_cnext (ctf_dynhash_t *h, ctf_next_t **it,
607d62b00eSchristos 		  const void **key, const void **value)
617d62b00eSchristos {
627d62b00eSchristos   return ctf_dynhash_next (h, it, (void **) key, (void **) value);
637d62b00eSchristos }
647d62b00eSchristos 
657d62b00eSchristos static inline int
667d62b00eSchristos ctf_dynhash_cinsert (ctf_dynhash_t *h, const void *k, const void *v)
677d62b00eSchristos {
687d62b00eSchristos   return ctf_dynhash_insert (h, (void *) k, (void *) v);
697d62b00eSchristos }
707d62b00eSchristos 
717d62b00eSchristos static inline int
727d62b00eSchristos ctf_dynset_cnext (ctf_dynset_t *h, ctf_next_t **it, const void **key)
737d62b00eSchristos {
747d62b00eSchristos   return ctf_dynset_next (h, it, (void **) key);
757d62b00eSchristos }
767d62b00eSchristos 
777d62b00eSchristos static inline int
787d62b00eSchristos ctf_dynset_cinsert (ctf_dynset_t *h, const void *k)
797d62b00eSchristos {
807d62b00eSchristos   return ctf_dynset_insert (h, (void *) k);
817d62b00eSchristos }
827d62b00eSchristos 
837d62b00eSchristos static inline int
84*6881a400Schristos ctf_assert_internal (ctf_dict_t *fp, const char *file, size_t line,
857d62b00eSchristos 		     const char *exprstr, int expr)
867d62b00eSchristos {
877d62b00eSchristos   if (_libctf_unlikely_ (!expr))
887d62b00eSchristos     ctf_assert_fail_internal (fp, file, line, exprstr);
897d62b00eSchristos 
907d62b00eSchristos   return expr;
917d62b00eSchristos }
927d62b00eSchristos 
937d62b00eSchristos #ifdef	__cplusplus
947d62b00eSchristos }
957d62b00eSchristos #endif
967d62b00eSchristos 
977d62b00eSchristos #endif /* _CTF_INLINES_H */
98