diff --git a/third_party/icu/source/common/umapfile.cpp b/third_party/icu/source/common/umapfile.cpp index cb8256d6d90ba..bb1d68de53c1d 100644 --- a/third_party/icu/source/common/umapfile.cpp +++ b/third_party/icu/source/common/umapfile.cpp @@ -26,10 +26,6 @@ #include "udatamem.h" #include "umapfile.h" -#if MAP_IMPLEMENTATION==MAP_STARBOARD -#include "starboard/extension/memory_mapped_file.h" -#endif - /* memory-mapping base definitions ------------------------------------------ */ #if MAP_IMPLEMENTATION==MAP_WIN32 @@ -99,14 +95,6 @@ typedef HANDLE MemoryMap; typedef void *MemoryMap; # define IS_MAP(map) ((map)!=nullptr) -#elif MAP_IMPLEMENTATION==MAP_STARBOARD -# include "starboard/file.h" -# include "cmemory.h" -# include - - typedef void *MemoryMap; - -# define IS_MAP(map) ((map)!=NULL) #endif /*----------------------------------------------------------------------------* @@ -352,93 +340,6 @@ typedef HANDLE MemoryMap; } } -#elif MAP_IMPLEMENTATION==MAP_STARBOARD - U_CFUNC UBool - uprv_mapFile(UDataMemory *pData, const char *path, UErrorCode *status) { - if (U_FAILURE(*status)) { - return FALSE; - } - - UDataMemory_init(pData); /* Clear the output struct. */ - - /* open the input file */ - SbFile file = SbFileOpen(path, kSbFileOpenOnly | kSbFileRead, NULL, NULL); - if (!SbFileIsValid(file)) { - return FALSE; - } - - /* get the file length */ - SbFileInfo info; - if (!SbFileGetInfo(file, &info)) { - SbFileClose(file); - return FALSE; - } - - int32_t fileLength = info.size; - if (fileLength <= 20) { - SbFileClose(file); - return FALSE; - } - - pData->heapAllocated = false; - - const auto* memory_mapped_file_extension = - reinterpret_cast( - SbSystemGetExtension(kCobaltExtensionMemoryMappedFileName)); - - if(memory_mapped_file_extension && - strcmp(memory_mapped_file_extension->name, - kCobaltExtensionMemoryMappedFileName) == 0 && - memory_mapped_file_extension->version >= 1) { - void *p = memory_mapped_file_extension->MemoryMapFile( - NULL, path, kSbMemoryMapProtectRead, 0,fileLength); - if(p) { - pData->map=p; - pData->pHeader=(const DataHeader *)p; - pData->mapAddr=p; - SbFileClose(file); - return TRUE; - } - // If mmap extension didn't work, fall back to allocating - } - - /* allocate the memory to hold the file data */ - void *p = uprv_malloc(fileLength); - if (!p) { - SbFileClose(file); - return FALSE; - } - - /* read the file */ - if (fileLength != SbFileReadAll(file, static_cast(p), fileLength)) { - uprv_free(p); - SbFileClose(file); - return FALSE; - } - - SbFileClose(file); - pData->map=p; - pData->pHeader=(const DataHeader *)p; - pData->mapAddr=p; - pData->heapAllocated = true; - return TRUE; - } - - U_CFUNC void - uprv_unmapFile(UDataMemory *pData) { - if(pData!=NULL && pData->map!=NULL) { - if(pData->heapAllocated) { - uprv_free(pData->map); - } else { - size_t dataLen = (char *)pData->map - (char *)pData->mapAddr; - munmap(pData->mapAddr, dataLen); - } - pData->map = NULL; - pData->mapAddr = NULL; - pData->pHeader = NULL; - } - } - #elif MAP_IMPLEMENTATION==MAP_390DLL /* 390 specific Library Loading. * This is the only platform left that dynamically loads an ICU Data Library. diff --git a/third_party/icu/source/common/umapfile.h b/third_party/icu/source/common/umapfile.h index c7cf2af8cf2bc..779ca0f1ff203 100644 --- a/third_party/icu/source/common/umapfile.h +++ b/third_party/icu/source/common/umapfile.h @@ -38,12 +38,16 @@ U_CFUNC void uprv_unmapFile(UDataMemory *pData); #define MAP_POSIX 2 #define MAP_STDIO 3 #define MAP_390DLL 4 -#define MAP_STARBOARD 5 #if UCONFIG_NO_FILE_IO # define MAP_IMPLEMENTATION MAP_NONE #elif (U_PLATFORM == U_STARBOARD) -# define MAP_IMPLEMENTATION MAP_STARBOARD + /* + * Starboard of course can provide file access, and real memory mapping on + * some platforms, but it's not needed here since ICU data is linked into + * the binary. + */ +# define MAP_IMPLEMENTATION MAP_NONE #elif U_PLATFORM_USES_ONLY_WIN32_API # define MAP_IMPLEMENTATION MAP_WIN32 #elif U_HAVE_MMAP || U_PLATFORM == U_PF_OS390