summaryrefslogtreecommitdiff
path: root/src/visibility.h
blob: 1de6c62d07bfb1ca0001fcd78a5f6aeaa5090995 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
/* visibility.h - Set visibility attribute
 * Copyright (C) 2014  g10 Code GmbH
 *
 * This file is part of libgpg-error.
 *
 * libgpg-error is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public License
 * as published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * libgpg-error is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this program; if not, see <https://www.gnu.org/licenses/>.
 */

#ifndef _GPGRT_VISIBILITY_H
#define _GPGRT_VISIBILITY_H

/* Include the main header here so that public symbols are mapped to
   the internal underscored ones.  */
#ifdef _GPGRT_INCL_BY_VISIBILITY_C
# include "gpgrt-int.h"
#endif


/* Our use of the ELF visibility feature works by passing
   -fvisibiliy=hidden on the command line and by explicitly marking
   all exported functions as visible.

   NOTE: When adding new functions, please make sure to add them to
         gpg-error.vers and gpg-error.def.in as well.  */

#ifdef _GPGRT_INCL_BY_VISIBILITY_C

# ifdef GPGRT_USE_VISIBILITY
#  define MARK_VISIBLE(name) \
     extern __typeof__ (name) name __attribute__ ((visibility("default")));
# else
#  define MARK_VISIBLE(name) /* */
# endif

MARK_VISIBLE (gpg_strerror)
MARK_VISIBLE (gpg_strerror_r)
MARK_VISIBLE (gpg_strsource)
MARK_VISIBLE (gpg_err_code_from_errno)
MARK_VISIBLE (gpg_err_code_to_errno)
MARK_VISIBLE (gpg_err_code_from_syserror)
MARK_VISIBLE (gpg_err_set_errno)

MARK_VISIBLE (gpg_err_init)
MARK_VISIBLE (gpg_err_deinit)
MARK_VISIBLE (gpg_error_check_version)
MARK_VISIBLE (gpgrt_check_version)

MARK_VISIBLE (gpgrt_lock_init)
MARK_VISIBLE (gpgrt_lock_lock)
MARK_VISIBLE (gpgrt_lock_unlock)
MARK_VISIBLE (gpgrt_lock_destroy)
MARK_VISIBLE (gpgrt_yield)
MARK_VISIBLE (gpgrt_lock_trylock)

MARK_VISIBLE (gpgrt_fopen)
MARK_VISIBLE (gpgrt_mopen)
MARK_VISIBLE (gpgrt_fopenmem)
MARK_VISIBLE (gpgrt_fopenmem_init)
MARK_VISIBLE (gpgrt_fdopen)
MARK_VISIBLE (gpgrt_fdopen_nc)
MARK_VISIBLE (gpgrt_sysopen)
MARK_VISIBLE (gpgrt_sysopen_nc)
MARK_VISIBLE (gpgrt_fpopen)
MARK_VISIBLE (gpgrt_fpopen_nc)
MARK_VISIBLE (gpgrt_freopen)
MARK_VISIBLE (gpgrt_fopencookie)
MARK_VISIBLE (gpgrt_fclose)
MARK_VISIBLE (gpgrt_fclose_snatch)
MARK_VISIBLE (gpgrt_onclose)
MARK_VISIBLE (gpgrt_fileno)
MARK_VISIBLE (gpgrt_fileno_unlocked)
MARK_VISIBLE (gpgrt_syshd)
MARK_VISIBLE (gpgrt_syshd_unlocked)
MARK_VISIBLE (_gpgrt_set_std_fd)
MARK_VISIBLE (_gpgrt_get_std_stream)
MARK_VISIBLE (gpgrt_flockfile)
MARK_VISIBLE (gpgrt_ftrylockfile)
MARK_VISIBLE (gpgrt_funlockfile)
MARK_VISIBLE (_gpgrt_pending)
MARK_VISIBLE (_gpgrt_pending_unlocked)
MARK_VISIBLE (gpgrt_feof)
MARK_VISIBLE (gpgrt_feof_unlocked)
MARK_VISIBLE (gpgrt_ferror)
MARK_VISIBLE (gpgrt_ferror_unlocked)
MARK_VISIBLE (gpgrt_clearerr)
MARK_VISIBLE (gpgrt_clearerr_unlocked)
MARK_VISIBLE (gpgrt_fflush)
MARK_VISIBLE (gpgrt_fseek)
MARK_VISIBLE (gpgrt_fseeko)
MARK_VISIBLE (gpgrt_ftell)
MARK_VISIBLE (gpgrt_ftello)
MARK_VISIBLE (gpgrt_rewind)
MARK_VISIBLE (gpgrt_fgetc)
MARK_VISIBLE (_gpgrt_getc_underflow)
MARK_VISIBLE (gpgrt_fputc)
MARK_VISIBLE (_gpgrt_putc_overflow)
MARK_VISIBLE (gpgrt_ungetc)
MARK_VISIBLE (gpgrt_read)
MARK_VISIBLE (gpgrt_write)
MARK_VISIBLE (gpgrt_write_sanitized)
MARK_VISIBLE (gpgrt_write_hexstring)
MARK_VISIBLE (gpgrt_fread)
MARK_VISIBLE (gpgrt_fwrite)
MARK_VISIBLE (gpgrt_fgets)
MARK_VISIBLE (gpgrt_fputs)
MARK_VISIBLE (gpgrt_fputs_unlocked)
MARK_VISIBLE (gpgrt_getline)
MARK_VISIBLE (gpgrt_read_line)
MARK_VISIBLE (gpgrt_free)
MARK_VISIBLE (gpgrt_fprintf)
MARK_VISIBLE (gpgrt_fprintf_unlocked)
MARK_VISIBLE (gpgrt_printf)
MARK_VISIBLE (gpgrt_printf_unlocked)
MARK_VISIBLE (gpgrt_vfprintf)
MARK_VISIBLE (gpgrt_vfprintf_unlocked)
MARK_VISIBLE (gpgrt_setvbuf)
MARK_VISIBLE (gpgrt_setbuf)
MARK_VISIBLE (gpgrt_set_binary)
MARK_VISIBLE (gpgrt_set_nonblock)
MARK_VISIBLE (gpgrt_get_nonblock)
MARK_VISIBLE (gpgrt_poll)
MARK_VISIBLE (gpgrt_tmpfile)
MARK_VISIBLE (gpgrt_opaque_set)
MARK_VISIBLE (gpgrt_opaque_get)
MARK_VISIBLE (gpgrt_fname_set)
MARK_VISIBLE (gpgrt_fname_get)
MARK_VISIBLE (gpgrt_asprintf)
MARK_VISIBLE (gpgrt_vasprintf)
MARK_VISIBLE (gpgrt_bsprintf)
MARK_VISIBLE (gpgrt_vbsprintf)
MARK_VISIBLE (gpgrt_snprintf)
MARK_VISIBLE (gpgrt_vsnprintf)
MARK_VISIBLE (gpgrt_set_syscall_clamp)
MARK_VISIBLE (gpgrt_set_alloc_func)

#undef MARK_VISIBLE

#else /*!_GPGRT_INCL_BY_VISIBILITY_C*/

/* To avoid accidental use of the public functions inside Libgpg-error,
   we redefine them to catch such errors.  */

#define gpg_strerror                _gpgrt_USE_UNDERSCORED_FUNCTION
#define gpg_strerror_r              _gpgrt_USE_UNDERSCORED_FUNCTION
#define gpg_strsource               _gpgrt_USE_UNDERSCORED_FUNCTION
#define gpg_err_code_from_errno     _gpgrt_USE_UNDERSCORED_FUNCTION
#define gpg_err_code_to_errno       _gpgrt_USE_UNDERSCORED_FUNCTION
#define gpg_err_code_from_syserror  _gpgrt_USE_UNDERSCORED_FUNCTION
#define gpg_err_set_errno           _gpgrt_USE_UNDERSCORED_FUNCTION

#define gpg_err_init                _gpgrt_USE_UNDERSCORED_FUNCTION
#define gpg_err_deinit              _gpgrt_USE_UNDERSCORED_FUNCTION
#define gpg_error_check_version     _gpgrt_USE_UNDERSCORED_FUNCTION
#define gpgrt_check_version         _gpgrt_USE_OTHER_FUNCTION

#define gpgrt_lock_init             _gpgrt_USE_UNDERSCORED_FUNCTION
#define gpgrt_lock_lock             _gpgrt_USE_UNDERSCORED_FUNCTION
#define gpgrt_lock_unlock           _gpgrt_USE_UNDERSCORED_FUNCTION
#define gpgrt_lock_destroy          _gpgrt_USE_UNDERSCORED_FUNCTION
#define gpgrt_yield                 _gpgrt_USE_UNDERSCORED_FUNCTION
#define gpgrt_lock_trylock          _gpgrt_USE_UNDERSCORED_FUNCTION

#define gpgrt_fopen                 _gpgrt_USE_UNDERSCORED_FUNCTION
#define gpgrt_mopen                 _gpgrt_USE_UNDERSCORED_FUNCTION
#define gpgrt_fopenmem              _gpgrt_USE_UNDERSCORED_FUNCTION
#define gpgrt_fopenmem_init         _gpgrt_USE_UNDERSCORED_FUNCTION
#define gpgrt_fdopen                _gpgrt_USE_UNDERSCORED_FUNCTION
#define gpgrt_fdopen_nc             _gpgrt_USE_UNDERSCORED_FUNCTION
#define gpgrt_sysopen               _gpgrt_USE_UNDERSCORED_FUNCTION
#define gpgrt_sysopen_nc            _gpgrt_USE_UNDERSCORED_FUNCTION
#define gpgrt_fpopen                _gpgrt_USE_UNDERSCORED_FUNCTION
#define gpgrt_fpopen_nc             _gpgrt_USE_UNDERSCORED_FUNCTION
#define gpgrt_freopen               _gpgrt_USE_UNDERSCORED_FUNCTION
#define gpgrt_fopencookie           _gpgrt_USE_UNDERSCORED_FUNCTION
#define gpgrt_fclose                _gpgrt_USE_UNDERSCORED_FUNCTION
#define gpgrt_fclose_snatch         _gpgrt_USE_UNDERSCORED_FUNCTION
#define gpgrt_onclose               _gpgrt_USE_UNDERSCORED_FUNCTION
#define gpgrt_fileno                _gpgrt_USE_UNDERSCORED_FUNCTION
#define gpgrt_fileno_unlocked       _gpgrt_USE_UNDERSCORED_FUNCTION
#define gpgrt_syshd                 _gpgrt_USE_UNDERSCORED_FUNCTION
#define gpgrt_syshd_unlocked        _gpgrt_USE_UNDERSCORED_FUNCTION
#define _gpgrt_set_std_fd           _gpgrt_USE_UNDERSCORED_FUNCTION
#define _gpgrt_get_std_stream       _gpgrt_USE_UNDERSCORED_FUNCTION
#define gpgrt_flockfile             _gpgrt_USE_UNDERSCORED_FUNCTION
#define gpgrt_ftrylockfile          _gpgrt_USE_UNDERSCORED_FUNCTION
#define gpgrt_funlockfile           _gpgrt_USE_UNDERSCORED_FUNCTION
#define _gpgrt_pending              _gpgrt_USE_UNDERSCORED_FUNCTION
#define _gpgrt_pending_unlocked     _gpgrt_USE_UNDERSCORED_FUNCTION
#define gpgrt_feof                  _gpgrt_USE_UNDERSCORED_FUNCTION
#define gpgrt_feof_unlocked         _gpgrt_USE_UNDERSCORED_FUNCTION
#define gpgrt_ferror                _gpgrt_USE_UNDERSCORED_FUNCTION
#define gpgrt_ferror_unlocked       _gpgrt_USE_UNDERSCORED_FUNCTION
#define gpgrt_clearerr              _gpgrt_USE_UNDERSCORED_FUNCTION
#define gpgrt_clearerr_unlocked     _gpgrt_USE_UNDERSCORED_FUNCTION
#define gpgrt_fflush                _gpgrt_USE_UNDERSCORED_FUNCTION
#define gpgrt_fseek                 _gpgrt_USE_UNDERSCORED_FUNCTION
#define gpgrt_fseeko                _gpgrt_USE_UNDERSCORED_FUNCTION
#define gpgrt_ftell                 _gpgrt_USE_UNDERSCORED_FUNCTION
#define gpgrt_ftello                _gpgrt_USE_UNDERSCORED_FUNCTION
#define gpgrt_rewind                _gpgrt_USE_UNDERSCORED_FUNCTION
#define gpgrt_fgetc                 _gpgrt_USE_UNDERSCORED_FUNCTION
#define _gpgrt_getc_underflow       _gpgrt_USE_DBLUNDERSCO_FUNCTION
#define gpgrt_fputc                 _gpgrt_USE_UNDERSCORED_FUNCTION
#define _gpgrt_putc_overflow        _gpgrt_USE_DBLUNDERSCO_FUNCTION
#define gpgrt_ungetc                _gpgrt_USE_UNDERSCORED_FUNCTION
#define gpgrt_read                  _gpgrt_USE_UNDERSCORED_FUNCTION
#define gpgrt_write                 _gpgrt_USE_UNDERSCORED_FUNCTION
#define gpgrt_write_sanitized       _gpgrt_USE_UNDERSCORED_FUNCTION
#define gpgrt_write_hexstring       _gpgrt_USE_UNDERSCORED_FUNCTION
#define gpgrt_fread                 _gpgrt_USE_UNDERSCORED_FUNCTION
#define gpgrt_fwrite                _gpgrt_USE_UNDERSCORED_FUNCTION
#define gpgrt_fgets                 _gpgrt_USE_UNDERSCORED_FUNCTION
#define gpgrt_fputs                 _gpgrt_USE_UNDERSCORED_FUNCTION
#define gpgrt_fputs_unlocked        _gpgrt_USE_UNDERSCORED_FUNCTION
#define gpgrt_getline               _gpgrt_USE_UNDERSCORED_FUNCTION
#define gpgrt_read_line             _gpgrt_USE_UNDERSCORED_FUNCTION
#define gpgrt_free                  _gpgrt_USE_UNDERSCORED_FUNCTION
#define gpgrt_fprintf               _gpgrt_USE_UNDERSCORED_FUNCTION
#define gpgrt_fprintf_unlocked      _gpgrt_USE_UNDERSCORED_FUNCTION
#define gpgrt_printf                _gpgrt_USE_UNDERSCORED_FUNCTION
#define gpgrt_printf_unlocked       _gpgrt_USE_UNDERSCORED_FUNCTION
#define gpgrt_vfprintf              _gpgrt_USE_UNDERSCORED_FUNCTION
#define gpgrt_vfprintf_unlocked     _gpgrt_USE_UNDERSCORED_FUNCTION
#define gpgrt_setvbuf               _gpgrt_USE_UNDERSCORED_FUNCTION
#define gpgrt_setbuf                _gpgrt_USE_UNDERSCORED_FUNCTION
#define gpgrt_set_binary            _gpgrt_USE_UNDERSCORED_FUNCTION
#define gpgrt_set_nonblock          _gpgrt_USE_UNDERSCORED_FUNCTION
#define gpgrt_get_nonblock          _gpgrt_USE_UNDERSCORED_FUNCTION
#define gpgrt_poll                  _gpgrt_USE_UNDERSCORED_FUNCTION
#define gpgrt_tmpfile               _gpgrt_USE_UNDERSCORED_FUNCTION
#define gpgrt_opaque_set            _gpgrt_USE_UNDERSCORED_FUNCTION
#define gpgrt_opaque_get            _gpgrt_USE_UNDERSCORED_FUNCTION
#define gpgrt_fname_set             _gpgrt_USE_UNDERSCORED_FUNCTION
#define gpgrt_fname_get             _gpgrt_USE_UNDERSCORED_FUNCTION
#define gpgrt_asprintf              _gpgrt_USE_UNDERSCORED_FUNCTION
#define gpgrt_vasprintf             _gpgrt_USE_UNDERSCORED_FUNCTION
#define gpgrt_bsprintf              _gpgrt_USE_UNDERSCORED_FUNCTION
#define gpgrt_vbsprintf             _gpgrt_USE_UNDERSCORED_FUNCTION
#define gpgrt_snprintf              _gpgrt_USE_UNDERSCORED_FUNCTION
#define gpgrt_vsnprintf             _gpgrt_USE_UNDERSCORED_FUNCTION

#define gpgrt_set_syscall_clamp     _gpgrt_USE_UNDERSCORED_FUNCTION
#define gpgrt_set_alloc_func        _gpgrt_USE_UNDERSCORED_FUNCTION


#endif /*!_GPGRT_INCL_BY_VISIBILITY_C*/

#endif /*_GPGRT_VISIBILITY_H*/