event: fix divide by 0 in send_event()
[akaros.git] / tests / misc-compat.h
index a0f3f4d..08f472f 100644 (file)
@@ -1,9 +1,8 @@
-#ifndef MISC_COMPAT_H
-#define MISC_COMPAT_H
+#pragma once
 
 #ifdef __ros__
 
-#include <timing.h>
+#include <parlib/timing.h>
 
 #define pthread_id() (pthread_self()->id)
 
 #endif
 
 #include <sys/param.h> /* MIN/MAX */
+#include <unistd.h>
 
 /* not quite, since akaros udelay is a busy wait */
 #define udelay(usec) usleep(usec)
 #define ndelay(nsec)                                                           \
 {                                                                              \
-       struct timespec ts = {0, 0};                                               \
-       ts.tv_nsec = (nsec);                                                       \
-       nanosleep(&ts, 0);                                                         \
+       struct timespec ts = {0, 0};                                           \
+       ts.tv_nsec = (nsec);                                                   \
+       nanosleep(&ts, 0);                                                     \
 }
 
 /* not quite a normal relax, which also pauses, but this works for all archs */
@@ -53,8 +53,15 @@ static void uth_enable_notifs(void)
 {
 }
 
+static int get_pcoreid(void)
+{
+       return -1;
+}
+
 #define printd(args...) {}
 
+#define COUNT_OF(x) (sizeof((x))/sizeof((x)[0]))
+
 #ifdef __x86_64__
 
 #define mb() ({ asm volatile("mfence" ::: "memory"); })
@@ -67,4 +74,3 @@ static void uth_enable_notifs(void)
 #endif /* __x86_64__ */
 
 #endif /* __ros__ */
-#endif /* MISC_COMPAT_H */