summaryrefslogtreecommitdiffstats
path: root/src/corelib/global
diff options
context:
space:
mode:
authorGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2014-03-01 14:12:33 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-03-03 23:02:24 +0100
commitd85983ece7223d733ab87b0b9a8cca3aa246a406 (patch)
treee63c9ed8232c20542821ab2c4bc9280fef333432 /src/corelib/global
parentb72880d213b6ec94dcd9e388a6e648cc9b636194 (diff)
Introduce Q_DECL_CONST_FUNCTION and Q_DECL_PURE_FUNCTION
That expand to __attribute__((const)) and ((pure)). A "const" function is a function allowed to examine only its arguments, without modifying them. A "pure" function is also allowed to read memory. Currently working only on GCC/ICC/Clang, MSVC lacks these. Change-Id: Ie60a0847b193fb88e116f61611dc571296a3df1c Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Diffstat (limited to 'src/corelib/global')
-rw-r--r--src/corelib/global/qcompilerdetection.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h
index 1eb442aa5f..a9f143502e 100644
--- a/src/corelib/global/qcompilerdetection.h
+++ b/src/corelib/global/qcompilerdetection.h
@@ -200,6 +200,8 @@
# define Q_UNLIKELY(expr) __builtin_expect(!!(expr), false)
# define Q_NORETURN __attribute__((__noreturn__))
# define Q_REQUIRED_RESULT __attribute__ ((__warn_unused_result__))
+# define Q_DECL_PURE_FUNCTION __attribute__((pure))
+# define Q_DECL_CONST_FUNCTION __attribute__((const))
# if !defined(QT_MOC_CPP)
# define Q_PACKED __attribute__ ((__packed__))
# ifndef __ARM_EABI__
@@ -975,6 +977,12 @@
#ifndef Q_DECL_NS_RETURNS_AUTORELEASED
# define Q_DECL_NS_RETURNS_AUTORELEASED
#endif
+#ifndef Q_DECL_PURE_FUNCTION
+# define Q_DECL_PURE_FUNCTION
+#endif
+#ifndef Q_DECL_CONST_FUNCTION
+# define Q_DECL_CONST_FUNCTION Q_DECL_PURE_FUNCTION
+#endif
/*
Workaround for static const members on MSVC++.