2020-01-18 11:38:21 +03:00
|
|
|
/*
|
2021-02-02 21:48:39 +03:00
|
|
|
* Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
|
2020-01-18 11:38:21 +03:00
|
|
|
*
|
2021-04-22 11:24:48 +03:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-01-18 11:38:21 +03:00
|
|
|
*/
|
|
|
|
|
2019-01-29 01:01:47 +03:00
|
|
|
#pragma once
|
|
|
|
|
2021-08-14 18:12:54 +03:00
|
|
|
#include <Kernel/API/POSIX/futex.h>
|
2021-08-14 19:28:05 +03:00
|
|
|
#include <Kernel/API/POSIX/serenity.h>
|
2019-01-29 01:01:47 +03:00
|
|
|
#include <stdio.h>
|
2022-08-15 18:57:43 +03:00
|
|
|
#include <sys/cdefs.h>
|
2021-07-05 14:24:40 +03:00
|
|
|
#include <time.h>
|
2021-02-03 12:19:09 +03:00
|
|
|
#include <unistd.h>
|
2019-01-29 01:01:47 +03:00
|
|
|
|
2019-11-28 22:59:11 +03:00
|
|
|
__BEGIN_DECLS
|
|
|
|
|
2020-08-04 14:51:11 +03:00
|
|
|
int disown(pid_t);
|
|
|
|
|
2021-05-14 09:10:43 +03:00
|
|
|
int profiling_enable(pid_t, uint64_t);
|
2019-12-11 22:36:56 +03:00
|
|
|
int profiling_disable(pid_t);
|
2021-04-19 07:12:06 +03:00
|
|
|
int profiling_free_buffer(pid_t);
|
2019-12-11 22:36:56 +03:00
|
|
|
|
2020-12-22 09:21:58 +03:00
|
|
|
int futex(uint32_t* userspace_address, int futex_op, uint32_t value, const struct timespec* timeout, uint32_t* userspace_address2, uint32_t value3);
|
2019-12-22 23:29:47 +03:00
|
|
|
|
2022-03-01 04:48:32 +03:00
|
|
|
#ifndef ALWAYS_INLINE
|
|
|
|
# define ALWAYS_INLINE inline __attribute__((always_inline))
|
|
|
|
# define ALWAYS_INLINE_SERENITY_H
|
|
|
|
#endif
|
|
|
|
|
2022-07-14 01:25:35 +03:00
|
|
|
static ALWAYS_INLINE int futex_wait(uint32_t* userspace_address, uint32_t value, const struct timespec* abstime, int clockid, int process_shared)
|
2021-07-05 14:24:40 +03:00
|
|
|
{
|
|
|
|
int op;
|
|
|
|
|
|
|
|
if (abstime) {
|
|
|
|
// NOTE: FUTEX_WAIT takes a relative timeout, so use FUTEX_WAIT_BITSET instead!
|
2021-08-17 00:29:25 +03:00
|
|
|
op = FUTEX_WAIT_BITSET;
|
2021-07-05 14:24:40 +03:00
|
|
|
if (clockid == CLOCK_REALTIME || clockid == CLOCK_REALTIME_COARSE)
|
|
|
|
op |= FUTEX_CLOCK_REALTIME;
|
|
|
|
} else {
|
2021-08-17 00:29:25 +03:00
|
|
|
op = FUTEX_WAIT;
|
2021-07-05 14:24:40 +03:00
|
|
|
}
|
2022-07-14 01:25:35 +03:00
|
|
|
return futex(userspace_address, op | (process_shared ? 0 : FUTEX_PRIVATE_FLAG), value, abstime, NULL, FUTEX_BITSET_MATCH_ANY);
|
2021-07-05 14:24:40 +03:00
|
|
|
}
|
|
|
|
|
2022-07-14 01:25:35 +03:00
|
|
|
static ALWAYS_INLINE int futex_wake(uint32_t* userspace_address, uint32_t count, int process_shared)
|
2021-07-05 14:24:40 +03:00
|
|
|
{
|
2022-07-14 01:25:35 +03:00
|
|
|
return futex(userspace_address, FUTEX_WAKE | (process_shared ? 0 : FUTEX_PRIVATE_FLAG), count, NULL, NULL, 0);
|
2021-07-05 14:24:40 +03:00
|
|
|
}
|
|
|
|
|
2022-03-01 04:48:32 +03:00
|
|
|
#ifdef ALWAYS_INLINE_SERENITY_H
|
|
|
|
# undef ALWAYS_INLINE
|
|
|
|
#endif
|
|
|
|
|
2020-01-02 15:37:02 +03:00
|
|
|
int purge(int mode);
|
|
|
|
|
2020-02-02 22:28:29 +03:00
|
|
|
int perf_event(int type, uintptr_t arg1, uintptr_t arg2);
|
2021-08-11 21:41:29 +03:00
|
|
|
int perf_register_string(char const* string, size_t string_length);
|
2020-02-02 22:28:29 +03:00
|
|
|
|
2020-03-16 21:06:33 +03:00
|
|
|
int get_stack_bounds(uintptr_t* user_stack_base, size_t* user_stack_size);
|
|
|
|
|
2021-01-15 13:28:07 +03:00
|
|
|
int anon_create(size_t size, int options);
|
|
|
|
|
2022-04-01 20:58:27 +03:00
|
|
|
int serenity_readlink(char const* path, size_t path_length, char* buffer, size_t buffer_size);
|
2021-02-02 21:48:39 +03:00
|
|
|
|
2021-02-05 14:16:30 +03:00
|
|
|
int getkeymap(char* name_buffer, size_t name_buffer_size, uint32_t* map, uint32_t* shift_map, uint32_t* alt_map, uint32_t* altgr_map, uint32_t* shift_altgr_map);
|
2022-04-01 20:58:27 +03:00
|
|
|
int setkeymap(char const* name, uint32_t const* map, uint32_t* const shift_map, uint32_t const* alt_map, uint32_t const* altgr_map, uint32_t const* shift_altgr_map);
|
2021-02-04 01:15:13 +03:00
|
|
|
|
2022-04-01 20:58:27 +03:00
|
|
|
uint16_t internet_checksum(void const* ptr, size_t count);
|
2021-03-30 21:18:28 +03:00
|
|
|
|
2021-08-08 01:30:17 +03:00
|
|
|
int emuctl(uintptr_t command, uintptr_t arg0, uintptr_t arg1);
|
|
|
|
|
2021-09-11 01:45:28 +03:00
|
|
|
int serenity_open(char const* path, size_t path_length, int options, ...);
|
|
|
|
|
2019-11-28 22:59:11 +03:00
|
|
|
__END_DECLS
|