ctf-inlines.h 2.4 KB

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