Commit 48c18243 authored by Cody P Schafer's avatar Cody P Schafer Committed by Rusty Russell

compiler: Add PURE_FUNCTION

CC: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: default avatarCody P Schafer <dev@codyps.com>
Signed-off-by: default avatarRusty Russell <rusty@rustcorp.com.au>
parent 7bcba766
......@@ -75,6 +75,20 @@
#else
#define CONST_FUNCTION
#endif
#ifndef PURE_FUNCTION
#if HAVE_ATTRIBUTE_PURE
/**
* PURE_FUNCTION - a function is pure
*
* A pure function is one that has no side effects other than it's return value
* and uses no inputs other than it's arguments and global variables.
*/
#define PURE_FUNCTION __attribute__((__pure__))
#else
#define PURE_FUNCTION
#endif
#endif
#endif
#if HAVE_ATTRIBUTE_UNUSED
......
......@@ -79,6 +79,8 @@ static struct test tests[] = {
"static int __attribute__((cold)) func(int x) { return x; }" },
{ "HAVE_ATTRIBUTE_CONST", DEFINES_FUNC, NULL, NULL,
"static int __attribute__((const)) func(int x) { return x; }" },
{ "HAVE_ATTRIBUTE_PURE", DEFINES_FUNC, NULL, NULL,
"static int __attribute__((pure)) func(int x) { return x; }" },
{ "HAVE_ATTRIBUTE_MAY_ALIAS", OUTSIDE_MAIN, NULL, NULL,
"typedef short __attribute__((__may_alias__)) short_a;" },
{ "HAVE_ATTRIBUTE_NORETURN", DEFINES_FUNC, NULL, NULL,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment