Commit e764d0a2 authored by Rusty Russell's avatar Rusty Russell

compiler, ilog: IDEMPOTENT "idempotent does not mean what you think it means"

Actually, I don't even think it means that.  But rename it to something
which is sane.

Thanks to David Gibson for reporting.
parent 2578442d
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
* For functions not called in fast paths (aka. cold functions) * For functions not called in fast paths (aka. cold functions)
* - PRINTF_FMT * - PRINTF_FMT
* For functions which take printf-style parameters. * For functions which take printf-style parameters.
* - IDEMPOTENT * - CONST_FUNCTION
* For functions which return the same value for same parameters. * For functions which return the same value for same parameters.
* - NEEDED * - NEEDED
* For functions and variables which must be emitted even if unused. * For functions and variables which must be emitted even if unused.
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
* For functions and variables which need not be emitted if unused. * For functions and variables which need not be emitted if unused.
* - UNUSED * - UNUSED
* For parameters which are not used. * For parameters which are not used.
* - IS_COMPILE_CONSTANT * - IS_COMPILE_CONSTANT()
* For using different tradeoffs for compiletime vs runtime evaluation. * For using different tradeoffs for compiletime vs runtime evaluation.
* *
* License: Public Domain * License: Public Domain
......
...@@ -61,18 +61,18 @@ ...@@ -61,18 +61,18 @@
#endif #endif
#endif #endif
#ifndef IDEMPOTENT #ifndef CONST_FUNCTION
#if HAVE_ATTRIBUTE_CONST #if HAVE_ATTRIBUTE_CONST
/** /**
* IDEMPOTENT - a function's return depends only on its argument * CONST_FUNCTION - a function's return depends only on its argument
* *
* This allows the compiler to assume that the function will return the exact * This allows the compiler to assume that the function will return the exact
* same value for the exact same arguments. This implies that the function * same value for the exact same arguments. This implies that the function
* must not use global variables, or dereference pointer arguments. * must not use global variables, or dereference pointer arguments.
*/ */
#define IDEMPOTENT __attribute__((const)) #define CONST_FUNCTION __attribute__((const))
#else #else
#define IDEMPOTENT #define CONST_FUNCTION
#endif #endif
#endif #endif
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
* return 1U << ilog32(i-1); * return 1U << ilog32(i-1);
* } * }
*/ */
int ilog32(uint32_t _v) IDEMPOTENT; int ilog32(uint32_t _v) CONST_FUNCTION;
/** /**
* ilog32_nz - Integer binary logarithm of a non-zero 32-bit value. * ilog32_nz - Integer binary logarithm of a non-zero 32-bit value.
...@@ -44,7 +44,7 @@ int ilog32(uint32_t _v) IDEMPOTENT; ...@@ -44,7 +44,7 @@ int ilog32(uint32_t _v) IDEMPOTENT;
* return ilog32_nz(i) - 1; * return ilog32_nz(i) - 1;
* } * }
*/ */
int ilog32_nz(uint32_t _v) IDEMPOTENT; int ilog32_nz(uint32_t _v) CONST_FUNCTION;
/** /**
* ilog64 - Integer binary logarithm of a 64-bit value. * ilog64 - Integer binary logarithm of a 64-bit value.
...@@ -56,7 +56,7 @@ int ilog32_nz(uint32_t _v) IDEMPOTENT; ...@@ -56,7 +56,7 @@ int ilog32_nz(uint32_t _v) IDEMPOTENT;
* See Also: * See Also:
* ilog64_nz(), ilog32() * ilog64_nz(), ilog32()
*/ */
int ilog64(uint64_t _v) IDEMPOTENT; int ilog64(uint64_t _v) CONST_FUNCTION;
/** /**
* ilog64_nz - Integer binary logarithm of a non-zero 64-bit value. * ilog64_nz - Integer binary logarithm of a non-zero 64-bit value.
...@@ -68,7 +68,7 @@ int ilog64(uint64_t _v) IDEMPOTENT; ...@@ -68,7 +68,7 @@ int ilog64(uint64_t _v) IDEMPOTENT;
* See Also: * See Also:
* ilog64(), ilog32_nz() * ilog64(), ilog32_nz()
*/ */
int ilog64_nz(uint64_t _v) IDEMPOTENT; int ilog64_nz(uint64_t _v) CONST_FUNCTION;
/** /**
* STATIC_ILOG_32 - The integer logarithm of an (unsigned, 32-bit) constant. * STATIC_ILOG_32 - The integer logarithm of an (unsigned, 32-bit) constant.
......
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