umapfile.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // © 2016 and later: Unicode, Inc. and others.
  2. // License & terms of use: http://www.unicode.org/copyright.html
  3. /*
  4. ******************************************************************************
  5. *
  6. * Copyright (C) 1999-2011, International Business Machines
  7. * Corporation and others. All Rights Reserved.
  8. *
  9. ******************************************************************************/
  10. /*----------------------------------------------------------------------------------
  11. *
  12. * Memory mapped file wrappers for use by the ICU Data Implementation
  13. *
  14. * Porting note: The implementation of these functions is very platform specific.
  15. * Not all platforms can do real memory mapping. Those that can't
  16. * still must implement these functions, getting the data into memory using
  17. * whatever means are available.
  18. *
  19. * These functions are part of the ICU internal implementation, and
  20. * are not intended to be used directly by applications.
  21. *
  22. *----------------------------------------------------------------------------------*/
  23. #ifndef __UMAPFILE_H__
  24. #define __UMAPFILE_H__
  25. #include "unicode/putil.h"
  26. #include "unicode/udata.h"
  27. #include "putilimp.h"
  28. U_CAPI UBool U_EXPORT2 uprv_mapFile(UDataMemory *pdm, const char *path, UErrorCode *status);
  29. U_CFUNC void uprv_unmapFile(UDataMemory *pData);
  30. /* MAP_NONE: no memory mapping, no file access at all */
  31. #define MAP_NONE 0
  32. #define MAP_WIN32 1
  33. #define MAP_POSIX 2
  34. #define MAP_STDIO 3
  35. #define MAP_390DLL 4
  36. #if UCONFIG_NO_FILE_IO
  37. # define MAP_IMPLEMENTATION MAP_NONE
  38. #elif U_PLATFORM_USES_ONLY_WIN32_API
  39. # define MAP_IMPLEMENTATION MAP_WIN32
  40. #elif U_HAVE_MMAP || U_PLATFORM == U_PF_OS390
  41. # if U_PLATFORM == U_PF_OS390 && defined (OS390_STUBDATA)
  42. /* No memory mapping for 390 batch mode. Fake it using dll loading. */
  43. # define MAP_IMPLEMENTATION MAP_390DLL
  44. # else
  45. # define MAP_IMPLEMENTATION MAP_POSIX
  46. # endif
  47. #else /* unknown platform, no memory map implementation: use stdio.h and uprv_malloc() instead */
  48. # define MAP_IMPLEMENTATION MAP_STDIO
  49. #endif
  50. #endif