1/*
2 * Copyright 2017, Data61
3 * Commonwealth Scientific and Industrial Research Organisation (CSIRO)
4 * ABN 41 687 119 230.
5 *
6 * This software may be distributed and modified according to the terms of
7 * the BSD 2-Clause license. Note that NO WARRANTY is provided.
8 * See "LICENSE_BSD2.txt" for details.
9 *
10 * @TAG(DATA61_BSD)
11 */
12
13#pragma once
14
15#include <autoconf.h>
16#include <sel4muslcsys/gen_config.h>
17#include <stdarg.h>
18#include <stdbool.h>
19#include <bits/syscall.h>
20#include <utils/attribute.h>
21
22#define MUSLCSYS_WITH_VSYSCALL_PRIORITY (CONSTRUCTOR_MIN_PRIORITY + 10)
23
24typedef long (*muslcsys_syscall_t)(va_list);
25
26/* Installs a new handler for the given syscall. Any previous handler is returned
27 * and can be used to provide layers of syscall handling */
28muslcsys_syscall_t muslcsys_install_syscall(int syscall, muslcsys_syscall_t new_syscall);
29
30/* Some syscalls happen in the C library prior the init constructors being called,
31 * and hence prior to syscall handlers being able to be installed. For such cases
32 * we simply record such occurances and provide functions here for retrieving the
33 * arguments allow a process to do anything necessary once they get to `main`.
34 * These functions return true/false if the syscall was called on boot, and take
35 * pointers for returning the arguments. Pointers must be non NULL
36 */
37bool muslcsys_get_boot_set_tid_address(int **arg) NONNULL(1);
38#if defined(__NR_set_thread_area) || defined(__ARM_NR_set_tls)
39bool muslcsys_get_boot_set_thread_area(void **arg) NONNULL(1);
40#endif
41