| 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 | * |
| 13 | * Memory mapped file wrappers for use by the ICU Data Implementation |
| 14 | * |
| 15 | * Porting note: The implementation of these functions is very platform specific. |
| 16 | * Not all platforms can do real memory mapping. Those that can't |
| 17 | * still must implement these functions, getting the data into memory using |
| 18 | * whatever means are available. |
| 19 | * |
| 20 | * These functions are part of the ICU internal implementation, and |
| 21 | * are not inteded to be used directly by applications. |
| 22 | * |
| 23 | *----------------------------------------------------------------------------------*/ |
| 24 | |
| 25 | #ifndef __UMAPFILE_H__ |
| 26 | #define __UMAPFILE_H__ |
| 27 | |
| 28 | #include "unicode/putil.h" |
| 29 | #include "unicode/udata.h" |
| 30 | #include "putilimp.h" |
| 31 | |
| 32 | U_CFUNC UBool uprv_mapFile(UDataMemory *pdm, const char *path, UErrorCode *status); |
| 33 | U_CFUNC void uprv_unmapFile(UDataMemory *pData); |
| 34 | |
| 35 | /* MAP_NONE: no memory mapping, no file access at all */ |
| 36 | #define MAP_NONE 0 |
| 37 | #define MAP_WIN32 1 |
| 38 | #define MAP_POSIX 2 |
| 39 | #define MAP_STDIO 3 |
| 40 | #define MAP_390DLL 4 |
| 41 | |
| 42 | #if UCONFIG_NO_FILE_IO |
| 43 | # define MAP_IMPLEMENTATION MAP_NONE |
| 44 | #elif U_PLATFORM_USES_ONLY_WIN32_API |
| 45 | # define MAP_IMPLEMENTATION MAP_WIN32 |
| 46 | #elif U_HAVE_MMAP || U_PLATFORM == U_PF_OS390 |
| 47 | # if U_PLATFORM == U_PF_OS390 && defined (OS390_STUBDATA) |
| 48 | /* No memory mapping for 390 batch mode. Fake it using dll loading. */ |
| 49 | # define MAP_IMPLEMENTATION MAP_390DLL |
| 50 | # else |
| 51 | # define MAP_IMPLEMENTATION MAP_POSIX |
| 52 | # endif |
| 53 | #else /* unknown platform, no memory map implementation: use stdio.h and uprv_malloc() instead */ |
| 54 | # define MAP_IMPLEMENTATION MAP_STDIO |
| 55 | #endif |
| 56 | |
| 57 | #endif |
| 58 | |