blob: fade1eb11ca6a57b72f1c5cee5d33b3e3c930f91 (
plain)
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
|
#pragma once
#include "errno.h"
#include "stddef.h"
#include "sys/types.h"
#include "weenix/syscall.h"
#define TRAP_INTR_STRING QUOTE(INTR_SYSCALL)
/* ssize_t will be 32 bits or 64 bits wide as appropriate.
args are passed via %(r/e)ax and %(r/e)dx, so they need
to be the size of a register. */
static inline ssize_t trap(ssize_t num, ssize_t arg)
{
ssize_t ret;
__asm__ volatile("int $" TRAP_INTR_STRING
: "=a"(ret)
: "a"(num), "d"(arg));
/* Copy in errno */
__asm__ volatile("int $" TRAP_INTR_STRING
: "=a"(errno)
: "a"(SYS_errno));
return ret;
}
|