mmap.h 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /* Copyright (c) 2003-2004, Roger Dingledine
  2. * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
  3. * Copyright (c) 2007-2018, The Tor Project, Inc. */
  4. /* See LICENSE for licensing information */
  5. /**
  6. * \file mmap.h
  7. *
  8. * \brief Header for mmap.c
  9. **/
  10. #ifndef TOR_MMAP_H
  11. #define TOR_MMAP_H
  12. #include "lib/cc/compat_compiler.h"
  13. #include <stddef.h>
  14. #ifdef _WIN32
  15. #include <windef.h>
  16. #endif
  17. /** Represents an mmaped file. Allocated via tor_mmap_file; freed with
  18. * tor_munmap_file. */
  19. typedef struct tor_mmap_t {
  20. const char *data; /**< Mapping of the file's contents. */
  21. size_t size; /**< Size of the file. */
  22. /* None of the fields below should be accessed from outside compat.c */
  23. #ifdef HAVE_MMAP
  24. size_t mapping_size; /**< Size of the actual mapping. (This is this file
  25. * size, rounded up to the nearest page.) */
  26. #elif defined _WIN32
  27. HANDLE mmap_handle;
  28. #endif /* defined(HAVE_MMAP) || ... */
  29. } tor_mmap_t;
  30. tor_mmap_t *tor_mmap_file(const char *filename);
  31. int tor_munmap_file(tor_mmap_t *handle);
  32. #endif