• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: MIT */
2 #ifndef LIBURING_SYSCALL_H
3 #define LIBURING_SYSCALL_H
4 
5 #include <errno.h>
6 #include <signal.h>
7 #include <stdint.h>
8 #include <unistd.h>
9 #include <stdbool.h>
10 #include <sys/mman.h>
11 #include <sys/syscall.h>
12 #include <sys/resource.h>
13 #include <liburing.h>
14 
15 /*
16  * Don't put this below the #include "arch/$arch/syscall.h", that
17  * file may need it.
18  */
19 struct io_uring_params;
20 
ERR_PTR(intptr_t n)21 static inline void *ERR_PTR(intptr_t n)
22 {
23 	return (void *) n;
24 }
25 
PTR_ERR(const void * ptr)26 static inline int PTR_ERR(const void *ptr)
27 {
28 	return (int) (intptr_t) ptr;
29 }
30 
IS_ERR(const void * ptr)31 static inline bool IS_ERR(const void *ptr)
32 {
33 	return uring_unlikely((uintptr_t) ptr >= (uintptr_t) -4095UL);
34 }
35 
36 #if defined(__x86_64__) || defined(__i386__)
37 #include "arch/x86/syscall.h"
38 #elif defined(__aarch64__)
39 #include "arch/aarch64/syscall.h"
40 #elif defined(__riscv) && __riscv_xlen == 64
41 #include "arch/riscv64/syscall.h"
42 #else
43 /*
44  * We don't have native syscall wrappers
45  * for this arch. Must use libc!
46  */
47 #ifdef CONFIG_NOLIBC
48 	#error "This arch doesn't support building liburing without libc"
49 #endif
50 /* libc syscall wrappers. */
51 #include "arch/generic/syscall.h"
52 #endif
53 #endif
54