summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Guenthe <guenther@cvs.openbsd.org>2010-10-01 04:51:50 +0000
committerPhilip Guenthe <guenther@cvs.openbsd.org>2010-10-01 04:51:50 +0000
commit46c7e95a9c07869d323b1b9b8b5c36c101e03478 (patch)
treefbe9b382aec16c0645a2f6b8f2fa11c3b8db418d
parentc4683a096214da0370b62d7cf9371893d735dad6 (diff)
Add __only_inline, for use in headers like <ctype.h> for defining copies
of functions that can only by used by the compiler for inlining. Also, document __returns_twice, a particularly black piece of magic. ok deraadt@, kettenis@, millert@
-rw-r--r--sys/sys/cdefs.h25
1 files changed, 24 insertions, 1 deletions
diff --git a/sys/sys/cdefs.h b/sys/sys/cdefs.h
index 1c672893947..6325402b619 100644
--- a/sys/sys/cdefs.h
+++ b/sys/sys/cdefs.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cdefs.h,v 1.30 2010/07/01 03:22:12 jsg Exp $ */
+/* $OpenBSD: cdefs.h,v 1.31 2010/10/01 04:51:49 guenther Exp $ */
/* $NetBSD: cdefs.h,v 1.16 1996/04/03 20:46:39 christos Exp $ */
/*
@@ -141,6 +141,12 @@
#define __used __unused /* suppress -Wunused warnings */
#endif
+/*
+ * __returns_twice makes the compiler not assume the function
+ * only returns once. This affects registerisation of variables:
+ * even local variables need to be in memory across such a call.
+ * Example: setjmp()
+ */
#if __GNUC_PREREQ__(4, 1)
#define __returns_twice __attribute__((returns_twice))
#else
@@ -148,6 +154,23 @@
#endif
/*
+ * __only_inline makes the compiler only use this function definition
+ * for inlining; references that can't be inlined will be left as
+ * external references instead of generating a local copy. The
+ * matching library should include a simple extern definition for
+ * the function to handle those references. c.f. ctype.h
+ */
+#ifdef __GNUC__
+# if __GNUC_PREREQ__(4, 2)
+#define __only_inline extern __inline __attribute__((__gnu_inline__))
+# else
+#define __only_inline extern __inline
+# endif
+#else
+#define __only_inline static __inline
+#endif
+
+/*
* GNU C version 2.96 adds explicit branch prediction so that
* the CPU back-end can hint the processor and also so that
* code blocks can be reordered such that the predicted path