serenity.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <Kernel/API/POSIX/futex.h>
  8. #include <Kernel/API/POSIX/serenity.h>
  9. #include <stdio.h>
  10. #include <time.h>
  11. #include <unistd.h>
  12. __BEGIN_DECLS
  13. int disown(pid_t);
  14. int profiling_enable(pid_t, uint64_t);
  15. int profiling_disable(pid_t);
  16. int profiling_free_buffer(pid_t);
  17. int futex(uint32_t* userspace_address, int futex_op, uint32_t value, const struct timespec* timeout, uint32_t* userspace_address2, uint32_t value3);
  18. static ALWAYS_INLINE int futex_wait(uint32_t* userspace_address, uint32_t value, const struct timespec* abstime, int clockid)
  19. {
  20. int op;
  21. if (abstime) {
  22. // NOTE: FUTEX_WAIT takes a relative timeout, so use FUTEX_WAIT_BITSET instead!
  23. op = FUTEX_WAIT_BITSET;
  24. if (clockid == CLOCK_REALTIME || clockid == CLOCK_REALTIME_COARSE)
  25. op |= FUTEX_CLOCK_REALTIME;
  26. } else {
  27. op = FUTEX_WAIT;
  28. }
  29. return futex(userspace_address, op, value, abstime, NULL, FUTEX_BITSET_MATCH_ANY);
  30. }
  31. static ALWAYS_INLINE int futex_wake(uint32_t* userspace_address, uint32_t count)
  32. {
  33. return futex(userspace_address, FUTEX_WAKE, count, NULL, NULL, 0);
  34. }
  35. int purge(int mode);
  36. int perf_event(int type, uintptr_t arg1, uintptr_t arg2);
  37. int perf_register_string(char const* string, size_t string_length);
  38. int get_stack_bounds(uintptr_t* user_stack_base, size_t* user_stack_size);
  39. int anon_create(size_t size, int options);
  40. int serenity_readlink(const char* path, size_t path_length, char* buffer, size_t buffer_size);
  41. 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);
  42. int setkeymap(const char* name, const uint32_t* map, uint32_t* const shift_map, const uint32_t* alt_map, const uint32_t* altgr_map, const uint32_t* shift_altgr_map);
  43. uint16_t internet_checksum(const void* ptr, size_t count);
  44. int emuctl(uintptr_t command, uintptr_t arg0, uintptr_t arg1);
  45. int serenity_open(char const* path, size_t path_length, int options, ...);
  46. __END_DECLS