forked from rsenn/qjs-modules
-
Notifications
You must be signed in to change notification settings - Fork 0
/
quickjs-syscallerror.h
42 lines (35 loc) · 1.18 KB
/
quickjs-syscallerror.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include "defines.h"
#ifndef QUICKJS_SYSCALLERROR_H
#define QUICKJS_SYSCALLERROR_H
#include "utils.h"
/**
* \defgroup quickjs-syscallerror quickjs-syscallerror: System-call error object
* @{
*/
typedef struct {
char* syscall;
int number;
char* stack;
} SyscallError;
#define js_syscall(name, retval) js_syscall_return(name, retval, JS_NewInt32(ctx, result))
#define js_syscall_return(name, retval, successval) \
do { \
int prev_errno = errno, result = retval; \
if(result == -1) { \
ret = js_syscallerror_new(ctx, name, errno); \
errno = prev_errno; \
} else { \
ret = successval; \
} \
} while(0)
VISIBLE SyscallError* js_syscallerror_data(JSValue);
VISIBLE SyscallError* js_syscallerror_data2(JSContext*, JSValue);
VISIBLE SyscallError* syscallerror_new(JSContext*, const char* syscall, int number);
VISIBLE JSValue js_syscallerror_wrap(JSContext*, SyscallError* err);
VISIBLE JSValue js_syscallerror_new(JSContext*, const char* syscall, int number);
VISIBLE JSValue js_syscallerror_throw(JSContext*, const char* syscall);
VISIBLE int js_syscallerror_init(JSContext* ctx, JSModuleDef* m);
/**
* @}
*/
#endif /* defined(QUICKJS_SYSCALLERROR_H) */