]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - libctf/ctf-impl.h
libctf: error handling
[thirdparty/binutils-gdb.git] / libctf / ctf-impl.h
CommitLineData
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
36extern "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
61typedef 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
70extern void ctf_list_append (ctf_list_t *, void *);
71extern void ctf_list_prepend (ctf_list_t *, void *);
72extern void ctf_list_delete (ctf_list_t *, void *);
73
74extern const char *ctf_strraw (ctf_file_t *, uint32_t);
75extern const char *ctf_strptr (ctf_file_t *, uint32_t);
76
77extern void *ctf_set_open_errno (int *, int);
78extern long ctf_set_errno (ctf_file_t *, int);
79
60da9d95
NA
80_libctf_malloc_
81extern void *ctf_data_alloc (size_t);
82extern void ctf_data_free (void *, size_t);
83extern void ctf_data_protect (void *, size_t);
84
85_libctf_malloc_
86extern void *ctf_mmap (size_t length, size_t offset, int fd);
87extern void ctf_munmap (void *, size_t);
88extern ssize_t ctf_pread (int fd, void *buf, ssize_t count, off_t offset);
89
90_libctf_malloc_
91extern void *ctf_alloc (size_t);
92extern void ctf_free (void *);
93
94585e7f
NA
94_libctf_malloc_
95extern char *ctf_strdup (const char *);
96extern char *ctf_str_append (char *, const char *);
97extern const char *ctf_strerror (int);
98
60da9d95
NA
99_libctf_printflike_ (1, 2)
100extern void ctf_dprintf (const char *, ...);
101extern void libctf_init_debug (void);
102
94585e7f
NA
103extern Elf64_Sym *ctf_sym_to_elf64 (const Elf32_Sym *src, Elf64_Sym *dst);
104
60da9d95
NA
105extern int _libctf_debug; /* debugging messages enabled */
106
107#ifdef __cplusplus
108}
109#endif
110
111#endif /* _CTF_IMPL_H */