summaryrefslogtreecommitdiffstats
path: root/src/common/tuklib_common.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-15 09:41:34 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-15 09:41:34 +0000
commit25e43e389c26d56f90f2f20e3cee19c808b2a18c (patch)
treefdadca249ffd70901103b3f06a98aeab695c6193 /src/common/tuklib_common.h
parentAdding debian version 5.6.1+really5.4.5-1. (diff)
downloadxz-utils-25e43e389c26d56f90f2f20e3cee19c808b2a18c.tar.xz
xz-utils-25e43e389c26d56f90f2f20e3cee19c808b2a18c.zip
Merging upstream version 5.6.2.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/common/tuklib_common.h')
-rw-r--r--src/common/tuklib_common.h27
1 files changed, 23 insertions, 4 deletions
diff --git a/src/common/tuklib_common.h b/src/common/tuklib_common.h
index b1f531e..7554dfc 100644
--- a/src/common/tuklib_common.h
+++ b/src/common/tuklib_common.h
@@ -1,3 +1,5 @@
+// SPDX-License-Identifier: 0BSD
+
///////////////////////////////////////////////////////////////////////////////
//
/// \file tuklib_common.h
@@ -5,9 +7,6 @@
//
// Author: Lasse Collin
//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
///////////////////////////////////////////////////////////////////////////////
#ifndef TUKLIB_COMMON_H
@@ -57,8 +56,28 @@
# define TUKLIB_GNUC_REQ(major, minor) 0
#endif
-#if TUKLIB_GNUC_REQ(2, 5)
+// tuklib_attr_noreturn attribute is used to mark functions as non-returning.
+// We cannot use "noreturn" as the macro name because then C23 code that
+// uses [[noreturn]] would break as it would expand to [[ [[noreturn]] ]].
+//
+// tuklib_attr_noreturn must be used at the beginning of function declaration
+// to work in all cases. The [[noreturn]] syntax is the most limiting, it
+// must be even before any GNU C's __attribute__ keywords:
+//
+// tuklib_attr_noreturn
+// __attribute__((nonnull(1)))
+// extern void foo(const char *s);
+//
+// FIXME: Update __STDC_VERSION__ for the final C23 version. 202000 is used
+// by GCC 13 and Clang 15 with -std=c2x.
+#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202000
+# define tuklib_attr_noreturn [[noreturn]]
+#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112
+# define tuklib_attr_noreturn _Noreturn
+#elif TUKLIB_GNUC_REQ(2, 5)
# define tuklib_attr_noreturn __attribute__((__noreturn__))
+#elif defined(_MSC_VER)
+# define tuklib_attr_noreturn __declspec(noreturn)
#else
# define tuklib_attr_noreturn
#endif