mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-21 12:40:02 +00:00
ICU-1075 udata.c restructuring, fix broken UNIX build.
Windows project file, disable language extensions for udata.c X-SVN-Rev: 5721
This commit is contained in:
parent
d47f600940
commit
a9f6f41f42
5 changed files with 36 additions and 36 deletions
|
@ -77,7 +77,7 @@ uchar.o ucmp8.o ucmp16.o ucmp32.o ucmpe32.o uvector.o uhash.o uhash_us.o \
|
|||
unames.o unicode.o unistr.o ustring.o cstring.o utf_impl.o \
|
||||
scsu.o ucnv.o ucnv_bld.o ucnv_cb.o ucnv_cnv.o ucnv_err.o ucnv_io.o convert.o \
|
||||
ucnvlat1.o ucnvmbcs.o ucnv_utf.o ucnv2022.o ucnvhz.o ucnv_lmb.o ucnvscsu.o \
|
||||
uscript.o ucnvisci.o ucln_cmn.o ustrfmt.o
|
||||
uscript.o ucnvisci.o ucln_cmn.o ustrfmt.o ucmndata.o udatamem.o umapfile.o
|
||||
|
||||
STATIC_OBJECTS = $(OBJECTS:.o=.$(STATIC_O))
|
||||
|
||||
|
|
|
@ -258,7 +258,7 @@ SOURCE=.\ucnvscsu.c
|
|||
# Begin Source File
|
||||
|
||||
SOURCE=.\udata.c
|
||||
# ADD CPP /Ze
|
||||
# ADD CPP /Za
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
|
|
|
@ -19,22 +19,27 @@
|
|||
#ifndef __UDATAMEM_H__
|
||||
#define __UDATAMEM_H__
|
||||
|
||||
#include "unicode/udata.h"
|
||||
#include "ucmndata.h"
|
||||
|
||||
typedef struct UDataMemory {
|
||||
void *map; /* Handle, or whatever. OS dependent. */
|
||||
/* Only set if a close operation should unmap the */
|
||||
/* associated data. */
|
||||
const void *mapAddr; /* For mapped or allocated memory, the start addr. */
|
||||
/* Needed to allow unmapping. */
|
||||
|
||||
|
||||
struct UDataMemory {
|
||||
commonDataFuncs *vFuncs; /* Function Pointers for accessing TOC */
|
||||
const void *toc; /* For common memory, to find pieces within. */
|
||||
const DataHeader *pHeader; /* Header. For common data, header is at top of file */
|
||||
UBool heapAllocated; /* True if this UDataMemObject is on the heap */
|
||||
/* and thus needs to be deleted when closed. */
|
||||
} UDataMemory;
|
||||
|
||||
const DataHeader *pHeader; /* Header of the memory being described by this */
|
||||
/* UDataMemory object. */
|
||||
const void *toc; /* For common memory, table of contents for */
|
||||
/* the pieces within. */
|
||||
UBool heapAllocated; /* True if this UDataMemory Object is on the */
|
||||
/* heap and thus needs to be deleted when closed. */
|
||||
|
||||
void *mapAddr; /* For mapped or allocated memory, the start addr. */
|
||||
/* Only non-null if a close operation should unmap */
|
||||
/* the associated data. */
|
||||
void *map; /* Handle, or other data, OS dependent. */
|
||||
/* Only non-null if a close operation should unmap */
|
||||
/* the associated data, and additional info */
|
||||
/* beyond the mapAddr is needed to do that. */
|
||||
};
|
||||
|
||||
UDataMemory *UDataMemory_createNewInstance(UErrorCode *pErr);
|
||||
void UDatamemory_assign (UDataMemory *dest, UDataMemory *source);
|
||||
|
@ -45,3 +50,4 @@ void UDataMemory_setData (UDataMemory *This, const void *dataAddr);
|
|||
|
||||
const DataHeader *normalizeDataPointer(const void *p);
|
||||
#endif
|
||||
|
||||
|
|
|
@ -137,13 +137,15 @@
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#elif MAP_IMPLEMENTATION==MAP_POSIX
|
||||
static UBool
|
||||
UBool
|
||||
uprv_mapFile(UDataMemory *pData, const char *path) {
|
||||
int fd;
|
||||
int length;
|
||||
struct stat mystat;
|
||||
const void *data;
|
||||
void *data;
|
||||
|
||||
UDataMemory_init(pData); /* Clear the output struct. */
|
||||
|
||||
|
@ -167,32 +169,22 @@
|
|||
#endif
|
||||
close(fd); /* no longer needed */
|
||||
if(data==MAP_FAILED) {
|
||||
|
||||
# ifdef UDATA_DEBUG
|
||||
perror("mmap");
|
||||
# endif
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
# ifdef UDATA_DEBUG
|
||||
fprintf(stderr, "mmap of %s [%d bytes] succeeded, -> 0x%X\n", path, length, data);
|
||||
fflush(stderr);
|
||||
# endif
|
||||
|
||||
pData->map=length;
|
||||
pData->map = (char *)data + length;
|
||||
pData->pHeader=(const DataHeader *)data;
|
||||
pData->mapAddr = data;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
|
||||
void
|
||||
uprv_unmapFile(UDataMemory *pData) {
|
||||
if(pData!=NULL && pData->map>0) {
|
||||
if(munmap((void *)pData->mapAddr, pData->map)==-1) {
|
||||
# ifdef UDATA_DEBUG
|
||||
perror("munmap");
|
||||
# endif
|
||||
if(pData!=NULL && pData->map!=NULL) {
|
||||
size_t dataLen = (char *)pData->map - (char *)pData->mapAddr;
|
||||
if(munmap(pData->mapAddr, dataLen)==-1) {
|
||||
}
|
||||
pData->pHeader=NULL;
|
||||
pData->map=0;
|
||||
|
@ -200,6 +192,8 @@
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#elif MAP_IMPLEMENTATION==MAP_FILE_STREAM
|
||||
static UBool
|
||||
uprv_mapFile(UDataMemory *pData, const char *path) {
|
||||
|
@ -221,7 +215,7 @@
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
/* allocate the data structure */
|
||||
/* allocate the memory to hold the file data */
|
||||
p=uprv_malloc(fileLength);
|
||||
if(p==NULL) {
|
||||
T_FileStream_close(file);
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#ifndef __UMAPFILE_H__
|
||||
#define __UMAPFILE_H__
|
||||
|
||||
typedef struct UDataMemory UDataMemory;
|
||||
#include "unicode/udata.h"
|
||||
|
||||
UBool uprv_mapFile(UDataMemory *pdm, const char *path);
|
||||
void uprv_unmapFile(UDataMemory *pData);
|
||||
|
|
Loading…
Add table
Reference in a new issue