xref: /openbsd-src/lib/libssl/hidden/ssl_namespace.h (revision a8d65a3f56d3a0ce3a4896b81833569012f87a21)
1 /*	$OpenBSD: ssl_namespace.h,v 1.3 2024/07/12 05:26:34 miod Exp $	*/
2 /*
3  * Copyright (c) 2016 Philip Guenther <guenther@openbsd.org>
4  *
5  * Permission to use, copy, modify, and distribute this software for any
6  * purpose with or without fee is hereby granted, provided that the above
7  * copyright notice and this permission notice appear in all copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16  */
17 
18 #ifndef _LIBSSL_SSL_NAMESPACE_H_
19 #define _LIBSSL_SSL_NAMESPACE_H_
20 
21 /*
22  * If marked as 'used', then internal calls use the name with prefix "_lssl_"
23  * and we alias that to the normal name.
24  */
25 
26 #ifdef LIBRESSL_NAMESPACE
27 #define LSSL_UNUSED(x)		typeof(x) x __attribute__((deprecated))
28 #define LSSL_USED(x)		__attribute__((visibility("hidden")))	\
29 				typeof(x) x asm("_lssl_"#x)
30 #if defined(__hppa__)
31 #define LSSL_ALIAS(x)		asm("! .global "#x" ! .set "#x", _lssl_"#x)
32 #else
33 #define LSSL_ALIAS(x)		asm(".global "#x"; "#x" = _lssl_"#x)
34 #endif
35 #else
36 #define LSSL_UNUSED(x)
37 #define LSSL_USED(x)
38 #define LSSL_ALIAS(x)		asm("")
39 #endif
40 
41 #endif	/* _LIBSSL_SSL_NAMESPACE_H_ */
42