1 /* Implementation header.
2 Copyright (C) 2019 Free Software Foundation, Inc.
4 This file is part of libctf.
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
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.
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/>. */
24 #include <sys/errno.h>
26 #include <sys/types.h>
33 /* Compiler attributes. */
35 #if defined (__GNUC__)
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
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__. */
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__))
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);
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);
65 extern void *ctf_alloc (size_t);
66 extern void ctf_free (void *);
68 _libctf_printflike_ (1, 2)
69 extern void ctf_dprintf (const char *, ...);
70 extern void libctf_init_debug (void);
72 extern int _libctf_debug; /* debugging messages enabled */
78 #endif /* _CTF_IMPL_H */