]>
Commit | Line | Data |
---|---|---|
60da9d95 NA |
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> | |
94585e7f NA |
27 | #include <stdlib.h> |
28 | #include <stdarg.h> | |
29 | #include <stdio.h> | |
30 | #include <stdint.h> | |
31 | #include <limits.h> | |
32 | #include <ctype.h> | |
33 | #include <elf.h> | |
60da9d95 NA |
34 | |
35 | #ifdef __cplusplus | |
36 | extern "C" | |
37 | { | |
38 | #endif | |
39 | ||
40 | /* Compiler attributes. */ | |
41 | ||
42 | #if defined (__GNUC__) | |
43 | ||
44 | /* GCC. We assume that all compilers claiming to be GCC support sufficiently | |
45 | many GCC attributes that the code below works. If some non-GCC compilers | |
46 | masquerading as GCC in fact do not implement these attributes, version checks | |
47 | may be required. */ | |
48 | ||
49 | /* We use the _libctf_*_ pattern to avoid clashes with any future attribute | |
50 | macros glibc may introduce, which have names of the pattern | |
51 | __attribute_blah__. */ | |
52 | ||
53 | #define _libctf_printflike_(string_index,first_to_check) \ | |
54 | __attribute__ ((__format__ (__printf__, (string_index), (first_to_check)))) | |
55 | #define _libctf_unlikely_(x) __builtin_expect ((x), 0) | |
56 | #define _libctf_unused_ __attribute__ ((__unused__)) | |
57 | #define _libctf_malloc_ __attribute__((__malloc__)) | |
58 | ||
59 | #endif | |
60 | ||
94585e7f NA |
61 | typedef struct ctf_list |
62 | { | |
63 | struct ctf_list *l_prev; /* Previous pointer or tail pointer. */ | |
64 | struct ctf_list *l_next; /* Next pointer or head pointer. */ | |
65 | } ctf_list_t; | |
66 | ||
67 | #define ctf_list_prev(elem) ((void *)(((ctf_list_t *)(elem))->l_prev)) | |
68 | #define ctf_list_next(elem) ((void *)(((ctf_list_t *)(elem))->l_next)) | |
69 | ||
70 | extern void ctf_list_append (ctf_list_t *, void *); | |
71 | extern void ctf_list_prepend (ctf_list_t *, void *); | |
72 | extern void ctf_list_delete (ctf_list_t *, void *); | |
73 | ||
74 | extern const char *ctf_strraw (ctf_file_t *, uint32_t); | |
75 | extern const char *ctf_strptr (ctf_file_t *, uint32_t); | |
76 | ||
77 | extern void *ctf_set_open_errno (int *, int); | |
78 | extern long ctf_set_errno (ctf_file_t *, int); | |
79 | ||
60da9d95 NA |
80 | _libctf_malloc_ |
81 | extern void *ctf_data_alloc (size_t); | |
82 | extern void ctf_data_free (void *, size_t); | |
83 | extern void ctf_data_protect (void *, size_t); | |
84 | ||
85 | _libctf_malloc_ | |
86 | extern void *ctf_mmap (size_t length, size_t offset, int fd); | |
87 | extern void ctf_munmap (void *, size_t); | |
88 | extern ssize_t ctf_pread (int fd, void *buf, ssize_t count, off_t offset); | |
89 | ||
90 | _libctf_malloc_ | |
91 | extern void *ctf_alloc (size_t); | |
92 | extern void ctf_free (void *); | |
93 | ||
94585e7f NA |
94 | _libctf_malloc_ |
95 | extern char *ctf_strdup (const char *); | |
96 | extern char *ctf_str_append (char *, const char *); | |
97 | extern const char *ctf_strerror (int); | |
98 | ||
60da9d95 NA |
99 | _libctf_printflike_ (1, 2) |
100 | extern void ctf_dprintf (const char *, ...); | |
101 | extern void libctf_init_debug (void); | |
102 | ||
94585e7f NA |
103 | extern Elf64_Sym *ctf_sym_to_elf64 (const Elf32_Sym *src, Elf64_Sym *dst); |
104 | ||
60da9d95 NA |
105 | extern int _libctf_debug; /* debugging messages enabled */ |
106 | ||
107 | #ifdef __cplusplus | |
108 | } | |
109 | #endif | |
110 | ||
111 | #endif /* _CTF_IMPL_H */ |