1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 /* Copyright (c) 1988 AT&T */ 23 /* All Rights Reserved */ 24 25 /* 26 * Copyright 2016 Joyent, Inc. 27 * Copyright 2025 Oxide Computer Company 28 * 29 * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 30 * Use is subject to license terms. 31 */ 32 33 #ifndef _ISO_ASSERT_ISO_H 34 #define _ISO_ASSERT_ISO_H 35 36 /* 37 * This file contains all of the portions of the assert.h implementation that we 38 * wish to be re-entrant safe. This is not in <assert.h> as a number of 39 * third-party applications have tried to use their own wrappers that use a 40 * header guard, which lead to us losing the definitions that we need to have. 41 * While those applications are potentially using the implementation namespace 42 * incorrectly, separating out the two logical uses is helpful nonetheless and 43 * hopefully makes it clearer what is what. 44 * 45 * This header should not be included directly by applications! 46 */ 47 48 #include <sys/feature_tests.h> 49 50 #ifdef __cplusplus 51 extern "C" { 52 #endif 53 54 /* 55 * This does not use _STDC_C99 as it must match the definition of assert in 56 * <assert.h>. Many C++ compilers on illumos have defined either a 57 * __STDC_VERSION__ or the internal definitions such as _STDC_C99 so mixing 58 * these can result in either missing the macro or the function prototype. 59 */ 60 #if (__cplusplus - 0 >= 201103L) || (__STDC_VERSION__ - 0 >= 199901L) 61 extern _NORETURN_KYWD void __assert_c99(const char *, const char *, int, 62 const char *) __NORETURN; 63 #else 64 extern _NORETURN_KYWD void __assert(const char *, const char *, int) __NORETURN; 65 #endif /* __cplusplus - 0 >= 201103L || (__STDC_VERSION__ - 0 >= 199901L) */ 66 67 /* 68 * In C11 the static_assert macro is always defined, unlike the assert macro. 69 * Starting in C23, static_assert is a keyword, so this is no longer required. 70 */ 71 #if defined(_STDC_C11) && !defined(__cplusplus) && !defined(_STDC_C23) 72 #define static_assert _Static_assert 73 #endif /* _STDC_C11 && !defined(__cplusplus) && !_STDC_C23 */ 74 75 #ifdef __cplusplus 76 } 77 #endif 78 79 #endif /* _ISO_ASSERT_ISO_H */ 80