Module Name: src
Committed By: joerg
Date: Mon Jul 20 17:46:04 UTC 2009
Modified Files:
src/sys/sys: cdefs.h
Log Message:
Add __constfunc and explain how it differs from __pure.
To generate a diff of this commit:
cvs rdiff -u -r1.75 -r1.76 src/sys/sys/cdefs.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/sys/cdefs.h
diff -u src/sys/sys/cdefs.h:1.75 src/sys/sys/cdefs.h:1.76
--- src/sys/sys/cdefs.h:1.75 Tue May 12 13:41:44 2009
+++ src/sys/sys/cdefs.h Mon Jul 20 17:46:04 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: cdefs.h,v 1.75 2009/05/12 13:41:44 reinoud Exp $ */
+/* $NetBSD: cdefs.h,v 1.76 2009/07/20 17:46:04 joerg Exp $ */
/*
* Copyright (c) 1991, 1993
@@ -170,6 +170,19 @@
* GCC2 uses a new, peculiar __attribute__((attrs)) style. All of
* these work for GNU C++ (modulo a slight glitch in the C++ grammar
* in the distribution version of 2.5.5).
+ *
+ * GCC defines a pure function as depending only on its arguments and
+ * global variables. Typical examples are strlen and sqrt.
+ *
+ * GCC defines a const function as depending only on its arguments.
+ * Therefore calling a const function again with identical arguments
+ * will always produce the same result.
+ *
+ * Rounding modes for floating point operations are considered global
+ * variables and prevent sqrt from being a const function.
+ *
+ * Calls to const functions can be optimised away and moved around
+ * without limitations.
*/
#if !__GNUC_PREREQ__(2, 0)
#define __attribute__(x)
@@ -191,6 +204,12 @@
#define __pure
#endif
+#if __GNUC_PREREQ__(2, 5)
+#define __constfunc __attribute__((__const__))
+#else
+#define __constfunc
+#endif
+
#if __GNUC_PREREQ__(3, 0)
#define __noinline __attribute__((__noinline__))
#else