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