Added explicit errno reporting from error() API.
[akaros.git] / kern / include / err.h
index 09bbcc7..b2c5fd0 100644 (file)
@@ -4,19 +4,16 @@
 #define ROS_KERN_ERR_H
 
 #include <setjmp.h>
-#include <syscall.h>
-
-struct errbuf {
-       struct jmpbuf jmpbuf;
-};
+#include <kthread.h>
 
 #define ERRSTACK(x) struct errbuf *prev_errbuf; struct errbuf errstack[(x)];   \
                     int curindex = 0;
 #define waserror() (errpush(errstack, ARRAY_SIZE(errstack), &curindex,         \
                             &prev_errbuf) ||                                   \
                     setjmp(&(get_cur_errbuf()->jmpbuf)))
-#define error(x,...) do {set_errstr(x, ##__VA_ARGS__);                         \
-                            longjmp(&get_cur_errbuf()->jmpbuf, 1);} while(0)
+#define error(e, x,...) do {set_errstr(x, ##__VA_ARGS__);                              \
+                                                       set_errno(e);                                                           \
+                                                       longjmp(&get_cur_errbuf()->jmpbuf, 1);} while(0)
 #define nexterror() do {errpop(errstack, ARRAY_SIZE(errstack), &curindex,      \
                             prev_errbuf);                                      \
                      longjmp(&(get_cur_errbuf())->jmpbuf, 1);} while (0)