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
feat: signal support (tested!)
[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 e39c6119a96c5ba1dd868ed65eb6b20d3fd45980..48a19045dbb5b801d5e901856b9c391f8ed4ec81 100644
(file)
--- a/
lunaix-os/includes/lunaix/spike.h
+++ b/
lunaix-os/includes/lunaix/spike.h
@@
-4,37
+4,52
@@
// Some helper functions. As helpful as Spike the Dragon! :)
// 除法向上取整
// Some helper functions. As helpful as Spike the Dragon! :)
// 除法向上取整
-#define CEIL(v, k)
(((v) + (1 << (k)) - 1) >> (k))
+#define CEIL(v, k) (((v) + (1 << (k)) - 1) >> (k))
// 除法向下取整
// 除法向下取整
-#define FLOOR(v, k)
((v) >> (k))
+#define FLOOR(v, k) ((v) >> (k))
// 获取v最近的最大k倍数
// 获取v最近的最大k倍数
-#define ROUNDUP(v, k)
(((v) + (k) - 1) & ~((k) -
1))
+#define ROUNDUP(v, k)
(((v) + (k)-1) & ~((k)-
1))
// 获取v最近的最小k倍数
// 获取v最近的最小k倍数
-#define ROUNDDOWN(v, k)
((v) & ~((k) -
1))
+#define ROUNDDOWN(v, k)
((v) & ~((k)-
1))
-inline static void spin() {
- while(1);
+#define __USER__ __attribute__((section(".usrtext")))
+
+inline static void
+spin()
+{
+ while (1)
+ ;
}
#ifdef __LUNAIXOS_DEBUG__
}
#ifdef __LUNAIXOS_DEBUG__
-#define assert(cond) \
- if (!(cond)) { \
- __assert_fail(#cond, __FILE__, __LINE__); \
+#define assert(cond)
\
+ if (!(cond)) {
\
+ __assert_fail(#cond, __FILE__, __LINE__);
\
}
}
-#define assert_msg(cond, msg) \
- if (!(cond)) { \
- __assert_fail(msg, __FILE__, __LINE__); \
+#define assert_msg(cond, msg)
\
+ if (!(cond)) {
\
+ __assert_fail(msg, __FILE__, __LINE__);
\
}
}
-void __assert_fail(const char* expr, const char* file, unsigned int line) __attribute__((noinline, noreturn));
+void
+__assert_fail(const char* expr, const char* file, unsigned int line)
+ __attribute__((noinline, noreturn));
#else
#else
-#define assert(cond)
//
assert nothing
-#define assert_msg(cond, msg)
//
assert nothing
+#define assert(cond)
(void)(cond); //
assert nothing
+#define assert_msg(cond, msg)
(void)(cond); //
assert nothing
#endif
#endif
+void
+panick(const char* msg);
+#define wait_until(cond) \
+ while (!(cond)) \
+ ;
+#define loop_until(cond) \
+ while (!(cond)) \
+ ;
#endif /* __LUNAIX_SPIKE_H */
#endif /* __LUNAIX_SPIKE_H */