diff options
author | wrowe <wrowe@13f79535-47bb-0310-9956-ffa450edef68> | 2002-06-04 04:41:53 +0000 |
---|---|---|
committer | wrowe <wrowe@13f79535-47bb-0310-9956-ffa450edef68> | 2002-06-04 04:41:53 +0000 |
commit | b0382eb9ed1630c2dbe931c468bdfe22e99898d7 (patch) | |
tree | 7b1ab17619932cd2e026b6685544439bbbaa911b /shmem/win32 | |
parent | b63e8de2a307721eeb71e027a8d2c553bea8b545 (diff) | |
download | libapr-b0382eb9ed1630c2dbe931c468bdfe22e99898d7.tar.gz |
More WinCE Porting
Antique patches that need to get out of my tree, into CVS.
Submitted by: Mladen Turk <mturk@mappingsoft.com>
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@63464 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'shmem/win32')
-rw-r--r-- | shmem/win32/shm.c | 35 |
1 files changed, 31 insertions, 4 deletions
diff --git a/shmem/win32/shm.c b/shmem/win32/shm.c index ec0befa79..48f45a5fd 100644 --- a/shmem/win32/shm.c +++ b/shmem/win32/shm.c @@ -118,12 +118,16 @@ APR_DECLARE(apr_status_t) apr_shm_create(apr_shm_t **m, if (!file) { /* Do Anonymous, which will be an inherited handle */ +#ifndef _WIN32_WCE hFile = INVALID_HANDLE_VALUE; sec.nLength = sizeof(SECURITY_ATTRIBUTES); sec.lpSecurityDescriptor = NULL; sec.bInheritHandle = TRUE; - mapkey = NULL; psec = &sec; +#else + psec = NULL; +#endif + mapkey = NULL; } else { /* Do file backed, which is not an inherited handle @@ -218,7 +222,15 @@ APR_DECLARE(apr_status_t) apr_shm_attach(apr_shm_t **m, #if APR_HAS_UNICODE_FS IF_WIN_OS_IS_UNICODE { +#ifndef _WIN32_WCE hMap = OpenFileMappingW(FILE_MAP_READ | FILE_MAP_WRITE, FALSE, mapkey); +#else + /* The WCE 3.0 lacks OpenFileMapping. So we emulate one with + * opening the existing shmem and reading its size from the header + */ + hMap = CreateFileMappingW(INVALID_HANDLE_VALUE, NULL, + PAGE_READWRITE, 0, sizeof(apr_shm_t), mapkey); +#endif } #endif #if APR_HAS_ANSI_FS @@ -240,13 +252,28 @@ APR_DECLARE(apr_status_t) apr_shm_attach(apr_shm_t **m, *m = (apr_shm_t *) apr_palloc(pool, sizeof(apr_shm_t)); (*m)->pool = pool; - (*m)->hMap = hMap; (*m)->memblk = base; - (*m)->usrmem = (char*)base + sizeof(memblock_t); /* Real (*m)->mem->size could be recovered with VirtualQuery */ (*m)->size = (*m)->memblk->size; - (*m)->length = (*m)->memblk->length; +#if _WIN32_WCE + /* Reopen with real size */ + UnmapViewOfFile(base); + CloseHandle(hMap); + hMap = CreateFileMappingW(INVALID_HANDLE_VALUE, NULL, + PAGE_READWRITE, 0, (*m)->size, mapkey); + if (!hMap) { + return apr_get_os_error(); + } + base = MapViewOfFile(hMap, FILE_MAP_READ | FILE_MAP_WRITE, 0, 0, 0); + if (!base) { + CloseHandle(hMap); + return apr_get_os_error(); + } +#endif + (*m)->hMap = hMap; + (*m)->length = (*m)->memblk->length; + (*m)->usrmem = (char*)base + sizeof(memblock_t); apr_pool_cleanup_register((*m)->pool, *m, shm_cleanup, apr_pool_cleanup_null); return APR_SUCCESS; |