mman.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
  3. * All rights reserved.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions are met:
  7. *
  8. * 1. Redistributions of source code must retain the above copyright notice, this
  9. * list of conditions and the following disclaimer.
  10. *
  11. * 2. Redistributions in binary form must reproduce the above copyright notice,
  12. * this list of conditions and the following disclaimer in the documentation
  13. * and/or other materials provided with the distribution.
  14. *
  15. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  16. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  17. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  18. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  19. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  20. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  21. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  22. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  23. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  24. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  25. */
  26. #pragma once
  27. #include <sys/cdefs.h>
  28. #include <sys/types.h>
  29. #define MAP_FILE 0x00
  30. #define MAP_SHARED 0x01
  31. #define MAP_PRIVATE 0x02
  32. #define MAP_FIXED 0x10
  33. #define MAP_ANONYMOUS 0x20
  34. #define MAP_ANON MAP_ANONYMOUS
  35. #define MAP_STACK 0x40
  36. #define MAP_NORESERVE 0x80
  37. #define PROT_READ 0x1
  38. #define PROT_WRITE 0x2
  39. #define PROT_EXEC 0x4
  40. #define PROT_NONE 0x0
  41. #define MAP_FAILED ((void*)-1)
  42. #define MADV_SET_VOLATILE 0x100
  43. #define MADV_SET_NONVOLATILE 0x200
  44. #define MADV_GET_VOLATILE 0x400
  45. #define MAP_INHERIT_ZERO 1
  46. __BEGIN_DECLS
  47. void* mmap(void* addr, size_t, int prot, int flags, int fd, off_t);
  48. void* mmap_with_name(void* addr, size_t, int prot, int flags, int fd, off_t, const char* name);
  49. void* serenity_mmap(void* addr, size_t, int prot, int flags, int fd, off_t, size_t alignment, const char* name);
  50. void* mremap(void* old_address, size_t old_size, size_t new_size, int flags);
  51. int munmap(void*, size_t);
  52. int mprotect(void*, size_t, int prot);
  53. int set_mmap_name(void*, size_t, const char*);
  54. int madvise(void*, size_t, int advice);
  55. int minherit(void*, size_t, int inherit);
  56. void* allocate_tls(size_t);
  57. __END_DECLS