git://scm.lunaixsky.com
/
lunaix-os.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
sweep through entire page table to free up intermediate tables
[lunaix-os.git]
/
lunaix-os
/
includes
/
lunaix
/
spike.h
diff --git
a/lunaix-os/includes/lunaix/spike.h
b/lunaix-os/includes/lunaix/spike.h
index da901fc39e76f59f6a3995dd86fddf759ca890ba..b2a335b00d50cf57906f6314a035985060540684 100644
(file)
--- a/
lunaix-os/includes/lunaix/spike.h
+++ b/
lunaix-os/includes/lunaix/spike.h
@@
-30,7
+30,7
@@
* https://elixir.bootlin.com/linux/v4.4/source/include/linux/log2.h#L85
*
*/
* https://elixir.bootlin.com/linux/v4.4/source/include/linux/log2.h#L85
*
*/
-#define
ILOG
2(x) \
+#define
ilog
2(x) \
(__builtin_constant_p(x) ? ((x) == 0 ? 0 \
: ((x) & (1ul << 31)) ? 31 \
: ((x) & (1ul << 30)) ? 30 \
(__builtin_constant_p(x) ? ((x) == 0 ? 0 \
: ((x) & (1ul << 31)) ? 31 \
: ((x) & (1ul << 30)) ? 30 \
@@
-64,30
+64,47
@@
: ((x) & (1ul << 2)) ? 2 \
: ((x) & (1ul << 1)) ? 1 \
: 0) \
: ((x) & (1ul << 2)) ? 2 \
: ((x) & (1ul << 1)) ? 1 \
: 0) \
- : (
31
- clz(x)))
+ : (
msbiti
- clz(x)))
-#ifndef __LUNAIXOS_NASSERT__
+#define llog2(x) (msbitl - clzl(x))
+
+#ifndef CONFIG_NO_ASSERT
#define assert(cond) \
do { \
#define assert(cond) \
do { \
- if (unlikely(!(cond))) {
\
+ if (unlikely(!(cond))) { \
__assert_fail(#cond, __FILE__, __LINE__); \
} \
} while(0)
__assert_fail(#cond, __FILE__, __LINE__); \
} \
} while(0)
+#define assert_p(cond, prefix) \
+ do { \
+ if (unlikely(!(cond))) { \
+ __assert_fail(prefix ": " #cond, __FILE__, __LINE__); \
+ } \
+ } while(0)
+
#define assert_msg(cond, msg) \
do { \
#define assert_msg(cond, msg) \
do { \
- if (unlikely(!(cond))) {
\
+ if (unlikely(!(cond))) { \
__assert_fail(msg, __FILE__, __LINE__); \
} \
} while(0)
__assert_fail(msg, __FILE__, __LINE__); \
} \
} while(0)
+#define assert_msg_p(cond, prefix, msg) \
+ do { \
+ if (unlikely(!(cond))) { \
+ __assert_fail(prefix ":" msg, __FILE__, __LINE__); \
+ } \
+ } while(0)
+
#define must_success(statement) \
do { \
int err = (statement); \
#define must_success(statement) \
do { \
int err = (statement); \
- if (err)
panickf(#statement "failed with errcode=%d", err);
\
+ if (err)
fail(#statement " failed");
\
} while(0)
#define fail(msg) __assert_fail(msg, __FILE__, __LINE__);
} while(0)
#define fail(msg) __assert_fail(msg, __FILE__, __LINE__);
+#define fail_p(msg, prefix) fail(prefix msg);
void
__assert_fail(const char* expr, const char* file, unsigned int line)
void
__assert_fail(const char* expr, const char* file, unsigned int line)
@@
-96,13
+113,7
@@
__assert_fail(const char* expr, const char* file, unsigned int line)
#define assert(cond) (void)(cond); // assert nothing
#define assert_msg(cond, msg) (void)(cond); // assert nothing
#define assert(cond) (void)(cond); // assert nothing
#define assert_msg(cond, msg) (void)(cond); // assert nothing
-#endif // __LUNAIXOS_NASSERT__
-
-void noret
-panick(const char* msg);
-
-void noret
-panickf(const char* fmt, ...);
+#endif // CONFIG_NO_ASSERT
#define wait_until(cond) \
while (!(cond)) \
#define wait_until(cond) \
while (!(cond)) \