/* SPDX-License-Identifier: LGPL-2.1 OR MIT */
/*
* Syscall definitions for NOLIBC (those in man(2))
* Copyright (C) 2017-2021 Willy Tarreau <w@1wt.eu>
*/
#ifndef _NOLIBC_SYS_H
#define _NOLIBC_SYS_H
#include <stdarg.h>
#include "std.h"
/* system includes */
#include <asm/unistd.h>
#include <asm/signal.h> /* for SIGCHLD */
#include <asm/ioctls.h>
#include <asm/mman.h>
#include <linux/fs.h>
#include <linux/loop.h>
#include <linux/time.h>
#include <linux/auxvec.h>
#include <linux/fcntl.h> /* for O_* and AT_* */
#include <linux/stat.h> /* for statx() */
#include <linux/reboot.h> /* for LINUX_REBOOT_* */
#include <linux/prctl.h>
#include "arch.h"
#include "errno.h"
#include "types.h"
/* Syscall return helper, set errno as -ret when ret < 0 */
static __inline__ __attribute__((unused, always_inline))
long __sysret(long ret)
{
if (ret < 0) {
SET_ERRNO(-ret);
ret = -1;
}
return ret;
}
/* Functions in this file only describe syscalls. They're declared static so
* that the compiler usually decides to inline them while still being allowed
* to pass a pointer to one of their instances. Each syscall exists in two
* versions:
* - the "internal" ones, which matches the raw syscall interface at the
* kernel level, which may sometimes slightly differ from the documented
* libc-level ones. For example most of them return either a valid value
* or -errno. All of these are prefixed with "sys_". They may be called
* by non-portable applications if desired.
*
* - the "exported" ones, whose interface must closely match the one
* documented in man(2), that applications are supposed to expect. These
* ones rely on the internal ones, and set errno.
*
* Each syscall will be defined with the two functions, sorted in alphabetical
* order applied to the exported names.
*
* In case of doubt about the relevance of a function here, only those which
* set errno should be defined here. Wrappers like those appearing in man(3)
* should not be placed here.
*/
/*
* int brk(void *addr);
* void *sbrk(intptr_t inc)
*/
static __attribute__((unused))