Include <signal.h> in sysdeps/nptl/allocrtsig.c
[platform/upstream/glibc.git] / assert / assert.h
index 7458e15..ae77793 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991,1992,1994-2001,2003 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2015 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.  */
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
 
 /*
  *     ISO C99 Standard: 7.2 Diagnostics       <assert.h>
 __BEGIN_DECLS
 
 /* This prints an "Assertion failed" message and aborts.  */
-extern void __assert_fail (__const char *__assertion, __const char *__file,
-                          unsigned int __line, __const char *__function)
+extern void __assert_fail (const char *__assertion, const char *__file,
+                          unsigned int __line, const char *__function)
      __THROW __attribute__ ((__noreturn__));
 
 /* Likewise, but prints the error text for ERRNUM.  */
-extern void __assert_perror_fail (int __errnum, __const char *__file,
-                                 unsigned int __line,
-                                 __const char *__function)
+extern void __assert_perror_fail (int __errnum, const char *__file,
+                                 unsigned int __line, const char *__function)
      __THROW __attribute__ ((__noreturn__));
 
 
@@ -84,33 +82,16 @@ extern void __assert (const char *__assertion, const char *__file, int __line)
 
 __END_DECLS
 
-/* For the macro definition we use gcc's __builtin_expect if possible
-   to generate good code for the non-error case.  gcc 3.0 is a good
-   enough estimate for when the feature became available.  */
-# if __GNUC_PREREQ (3, 0)
-#  define assert(expr) \
-  (__ASSERT_VOID_CAST (__builtin_expect (!!(expr), 1) ? 0 :                  \
-                      (__assert_fail (__STRING(expr), __FILE__, __LINE__,    \
-                                      __ASSERT_FUNCTION), 0)))
-# else
-#  define assert(expr) \
-  (__ASSERT_VOID_CAST ((expr) ? 0 :                                          \
-                      (__assert_fail (__STRING(expr), __FILE__, __LINE__,    \
-                                      __ASSERT_FUNCTION), 0)))
-# endif
+# define assert(expr)                                                  \
+  ((expr)                                                              \
+   ? __ASSERT_VOID_CAST (0)                                            \
+   : __assert_fail (__STRING(expr), __FILE__, __LINE__, __ASSERT_FUNCTION))
 
 # ifdef        __USE_GNU
-#  if __GNUC_PREREQ (3, 0)
-#   define assert_perror(errnum) \
-  (__ASSERT_VOID_CAST (__builtin_expect (!(errnum), 1) ? 0 :                 \
-                      (__assert_perror_fail ((errnum), __FILE__, __LINE__,   \
-                                             __ASSERT_FUNCTION), 0)))
-#  else
-#   define assert_perror(errnum) \
-  (__ASSERT_VOID_CAST (!(errnum) ? 0 :                                       \
-                      (__assert_perror_fail ((errnum), __FILE__, __LINE__,   \
-                                             __ASSERT_FUNCTION), 0)))
-#  endif
+#  define assert_perror(errnum)                                                \
+  (!(errnum)                                                           \
+   ? __ASSERT_VOID_CAST (0)                                            \
+   : __assert_perror_fail ((errnum), __FILE__, __LINE__, __ASSERT_FUNCTION))
 # endif
 
 /* Version 2.4 and later of GCC define a magical variable `__PRETTY_FUNCTION__'
@@ -124,8 +105,15 @@ __END_DECLS
 #  if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
 #   define __ASSERT_FUNCTION   __func__
 #  else
-#   define __ASSERT_FUNCTION   ((__const char *) 0)
+#   define __ASSERT_FUNCTION   ((const char *) 0)
 #  endif
 # endif
 
 #endif /* NDEBUG.  */
+
+
+#if defined __USE_ISOC11 && !defined __cplusplus
+/* Static assertion.  Requires support in the compiler.  */
+# undef static_assert
+# define static_assert _Static_assert
+#endif