1 /* $OpenBSD: crypto_namespace.h,v 1.4 2024/07/11 21:31:52 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 _LIBCRYPTO_CRYPTO_NAMESPACE_H_ 19 #define _LIBCRYPTO_CRYPTO_NAMESPACE_H_ 20 21 /* 22 * If marked as 'used', then internal calls use the name with prefix "_lcry_" 23 * and we alias that to the normal name *and* the name with prefix "_libre_"; 24 * external calls use the latter name. 25 */ 26 27 #ifdef LIBRESSL_NAMESPACE 28 #ifdef LIBRESSL_CRYPTO_NAMESPACE 29 # define LCRYPTO_UNUSED(x) __attribute__((deprecated)) \ 30 __attribute__((visibility("hidden"))) \ 31 typeof(x) x asm("_lcry_"#x) 32 # define LCRYPTO_USED(x) __attribute__((visibility("hidden"))) \ 33 typeof(x) x asm("_lcry_"#x) 34 # if defined(__hppa__) 35 # define LCRYPTO_ALIAS1(pre,x) asm("! .global "#pre#x" ! .set "#pre#x", _lcry_"#x) 36 #else 37 # define LCRYPTO_ALIAS1(pre,x) asm(".global "#pre#x"; "#pre#x" = _lcry_"#x) 38 #endif 39 # define LCRYPTO_ALIAS(x) LCRYPTO_ALIAS1(,x); LCRYPTO_ALIAS1(_libre_,x) 40 #else 41 # define LCRYPTO_UNUSED(x) typeof(x) x __attribute__((deprecated)) 42 # define LCRYPTO_USED(x) typeof(x) x asm("_libre_"#x) 43 #endif 44 #else 45 # define LCRYPTO_UNUSED(x) 46 # define LCRYPTO_USED(x) 47 # define LCRYPTO_ALIAS1(pre,x) 48 # define LCRYPTO_ALIAS(x) asm("") 49 #endif 50 51 #endif /* _LIBCRYPTO_CRYPTO_NAMESPACE_H_ */ 52