]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - libctf/ctf-impl.h
libctf: lowest-level memory allocation and debug-dumping wrappers
[thirdparty/binutils-gdb.git] / libctf / ctf-impl.h
1 /* Implementation header.
2 Copyright (C) 2019 Free Software Foundation, Inc.
3
4 This file is part of libctf.
5
6 libctf is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 3, or (at your option) any later
9 version.
10
11 This program is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14 See the GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; see the file COPYING. If not see
18 <http://www.gnu.org/licenses/>. */
19
20 #ifndef _CTF_IMPL_H
21 #define _CTF_IMPL_H
22
23 #include "config.h"
24 #include <sys/errno.h>
25 #include <ctf-api.h>
26 #include <sys/types.h>
27
28 #ifdef __cplusplus
29 extern "C"
30 {
31 #endif
32
33 /* Compiler attributes. */
34
35 #if defined (__GNUC__)
36
37 /* GCC. We assume that all compilers claiming to be GCC support sufficiently
38 many GCC attributes that the code below works. If some non-GCC compilers
39 masquerading as GCC in fact do not implement these attributes, version checks
40 may be required. */
41
42 /* We use the _libctf_*_ pattern to avoid clashes with any future attribute
43 macros glibc may introduce, which have names of the pattern
44 __attribute_blah__. */
45
46 #define _libctf_printflike_(string_index,first_to_check) \
47 __attribute__ ((__format__ (__printf__, (string_index), (first_to_check))))
48 #define _libctf_unlikely_(x) __builtin_expect ((x), 0)
49 #define _libctf_unused_ __attribute__ ((__unused__))
50 #define _libctf_malloc_ __attribute__((__malloc__))
51
52 #endif
53
54 _libctf_malloc_
55 extern void *ctf_data_alloc (size_t);
56 extern void ctf_data_free (void *, size_t);
57 extern void ctf_data_protect (void *, size_t);
58
59 _libctf_malloc_
60 extern void *ctf_mmap (size_t length, size_t offset, int fd);
61 extern void ctf_munmap (void *, size_t);
62 extern ssize_t ctf_pread (int fd, void *buf, ssize_t count, off_t offset);
63
64 _libctf_malloc_
65 extern void *ctf_alloc (size_t);
66 extern void ctf_free (void *);
67
68 _libctf_printflike_ (1, 2)
69 extern void ctf_dprintf (const char *, ...);
70 extern void libctf_init_debug (void);
71
72 extern int _libctf_debug; /* debugging messages enabled */
73
74 #ifdef __cplusplus
75 }
76 #endif
77
78 #endif /* _CTF_IMPL_H */