mmap.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*
  2. This file is part of ethash.
  3. ethash is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation, either version 3 of the License, or
  6. (at your option) any later version.
  7. ethash is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with ethash. If not, see <http://www.gnu.org/licenses/>.
  13. */
  14. /** @file mmap.h
  15. * @author Lefteris Karapetsas <lefteris@ethdev.com>
  16. * @date 2015
  17. */
  18. #pragma once
  19. #if defined(__MINGW32__) || defined(_WIN32)
  20. #include <sys/types.h>
  21. #define PROT_READ 0x1
  22. #define PROT_WRITE 0x2
  23. /* This flag is only available in WinXP+ */
  24. #ifdef FILE_MAP_EXECUTE
  25. #define PROT_EXEC 0x4
  26. #else
  27. #define PROT_EXEC 0x0
  28. #define FILE_MAP_EXECUTE 0
  29. #endif
  30. #define MAP_SHARED 0x01
  31. #define MAP_PRIVATE 0x02
  32. #define MAP_ANONYMOUS 0x20
  33. #define MAP_ANON MAP_ANONYMOUS
  34. #define MAP_FAILED ((void *) -1)
  35. void* mmap(void* start, size_t length, int prot, int flags, int fd, off_t offset);
  36. void munmap(void* addr, size_t length);
  37. #else // posix, yay! ^_^
  38. #include <sys/mman.h>
  39. #endif