diff options
author | luther <luther@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2000-07-25 22:05:39 +0000 |
---|---|---|
committer | luther <luther@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2000-07-25 22:05:39 +0000 |
commit | 81739dad6b1b41f865e0956bc12bfbc7044944f9 (patch) | |
tree | 8449f282a2b061c443056bef34b7c7bf4428014a | |
parent | 39721e4dab54cf15591ad0ce49682e41577081f9 (diff) | |
download | ATCD-81739dad6b1b41f865e0956bc12bfbc7044944f9.tar.gz |
Tue Jul 25 17:00:13 2000 Luther J Baker <luther@cs.wustl.edu>
29 files changed, 932 insertions, 607 deletions
diff --git a/PACE/ChangeLog b/PACE/ChangeLog index a131f17f1de..fd572817a76 100644 --- a/PACE/ChangeLog +++ b/PACE/ChangeLog @@ -1,3 +1,37 @@ +Tue Jul 25 17:00:13 2000 Luther J Baker <luther@cs.wustl.edu> + + * pace/win32/dirent.h: + * pace/win32/dirent.inl: + * pace/win32/dirent.c: + * pace/win32/fcntl.h: + * pace/win32/fcntl.inl: + * pace/win32/fcntl.c: + * pace/win32/mman.h: + * pace/win32/mman.inl: + * pace/win32/mman.c: + * pace/win32/semaphore.h: + * pace/win32/semaphore.inl: + * pace/win32/semaphore.c: + * pace/win32/signal.h: + * pace/win32/signal.inl: + * pace/win32/signal.c: + * pace/win32/stat.h: + * pace/win32/stat.inl: + * pace/win32/stat.c: + * pace/win32/unistd.h: + * pace/win32/unistd.inl: + * pace/win32/unistd.c: + * pace/win32/utime.h: + * pace/win32/utime.inl: + * pace/win32/utime.c: + * pace/win32/utsname.h: + * pace/win32/utsname.inl: + * pace/win32/utsname.c: + + Placed emulation prototype in the .h file. + Removed emulation code from the .inl file. + Moved emulation code to the .c file. + Mon Jul 24 15:57:24 2000 John Heitmann <jwh1@cs.wustl.edu> * pace/posix/string.inl diff --git a/PACE/pace/win32/dirent.c b/PACE/pace/win32/dirent.c index 1c7317dd753..b67213012f0 100644 --- a/PACE/pace/win32/dirent.c +++ b/PACE/pace/win32/dirent.c @@ -18,3 +18,83 @@ #if !defined (PACE_HAS_INLINE) # include "pace/win32/dirent.inl" #endif /* ! PACE_HAS_INLINE */ + +#if (PACE_HAS_POSIX_FS_UOF) +int +closedir (PACE_DIR * dirp) +{ + if (dirp->current_handle_ != (void*)0) + { + FindClose (dirp->current_handle_); + } + dirp->current_handle_ = (void*)0; + dirp->started_reading_ = 0; + return 1; +} +#endif /* PACE_HAS_POSIX_FS_UOF */ + +#if (PACE_HAS_POSIX_FS_UOF) +PACE_DIR * +opendir (const char * dirname) +{ + PACE_DIR * dirp = (PACE_DIR*) pace_malloc (sizeof (PACE_DIR)); + const pace_size_t dir_size = pace_strlen (dirname) + 1; + dirp->directory_name_ = (char*) pace_malloc (dir_size); + pace_strcpy (dirp->directory_name_, dirname); + dirp->current_handle_ = PACE_INVALID_HANDLE; + dirp->started_reading_ = 0; + return dirp; +} +#endif /* PACE_HAS_POSIX_FS_UOF */ + +#if (PACE_HAS_POSIX_FS_UOF) +pace_dirent * +readdir (PACE_DIR * dirp) +{ + if (dirp->started_reading_) + { + dirp->current_handle_ = FindFirstFile (dirp->directory_name_, + &(dirp->fdata_)); + if (dirp->current_handle_ != PACE_INVALID_HANDLE) + { + FindClose (dirp->current_handle_); + dirp->current_handle_ = PACE_INVALID_HANDLE; + } + else /* Skip "." and ".." */ + { + int retval = 1; + while (*(dirp->fdata_.cFileName) == '.' + && retval + && dirp->fdata_.dwFileAttributes == FILE_ATTRIBUTE_DIRECTORY) + { + retval = FindNextFile (dirp->current_handle_, + &(dirp->fdata_)); + } + if (retval == 0) + { + dirp->current_handle_ = PACE_INVALID_HANDLE; + } + } + dirp->started_reading_ = 1; + } + else + { + int retval = FindNextFile (dirp->current_handle_, + &(dirp->fdata_)); + if (retval == 0) + { + dirp->current_handle_ = PACE_INVALID_HANDLE; + } + } + + if (dirp->current_handle_ != PACE_INVALID_HANDLE) + { + dirp->dirent_.d_name = dirp->fdata_.cFileName; + return &(dirp->dirent_); + } + else + { + return (pace_dirent*)0; + } +} +#endif /* PACE_HAS_POSIX_FS_UOF */ diff --git a/PACE/pace/win32/dirent.h b/PACE/pace/win32/dirent.h index 5d4b10935fd..81751543fca 100644 --- a/PACE/pace/win32/dirent.h +++ b/PACE/pace/win32/dirent.h @@ -55,6 +55,18 @@ extern "C" { #endif /* PACE_DIR_T */ +#if (PACE_HAS_POSIX_FS_UOF) + int closedir (PACE_DIR * dirp); +#endif /* PACE_HAS_POSIX_FS_UOF */ + +#if (PACE_HAS_POSIX_FS_UOF) + PACE_DIR * opendir (const char * dirname); +#endif /* PACE_HAS_POSIX_FS_UOF */ + +#if (PACE_HAS_POSIX_FS_UOF) + pace_dirent * readdir (PACE_DIR * dirp); +#endif /* PACE_HAS_POSIX_FS_UOF */ + #if defined (PACE_HAS_CPLUSPLUS) } #endif /* PACE_HAS_CPLUSPLUS */ diff --git a/PACE/pace/win32/dirent.inl b/PACE/pace/win32/dirent.inl index 9004eeaab47..edf5071c55d 100644 --- a/PACE/pace/win32/dirent.inl +++ b/PACE/pace/win32/dirent.inl @@ -21,13 +21,7 @@ PACE_INLINE int pace_closedir (PACE_DIR * dirp) { - if (dirp->current_handle_ != (void*)0) - { - FindClose (dirp->current_handle_); - } - dirp->current_handle_ = (void*)0; - dirp->started_reading_ = 0; - return 1; + return closedir (dirp); } #endif /* PACE_HAS_POSIX_FS_UOF */ @@ -36,13 +30,7 @@ PACE_INLINE PACE_DIR * pace_opendir (const char * dirname) { - PACE_DIR * dirp = (PACE_DIR*) pace_malloc (sizeof (PACE_DIR)); - const pace_size_t dir_size = pace_strlen (dirname) + 1; - dirp->directory_name_ = (char*) pace_malloc (dir_size); - pace_strcpy (dirp->directory_name_, dirname); - dirp->current_handle_ = PACE_INVALID_HANDLE; - dirp->started_reading_ = 0; - return dirp; + return opendir (dirname); } #endif /* PACE_HAS_POSIX_FS_UOF */ @@ -51,51 +39,7 @@ PACE_INLINE pace_dirent * pace_readdir (PACE_DIR * dirp) { - if (dirp->started_reading_) - { - dirp->current_handle_ = FindFirstFile (dirp->directory_name_, - &(dirp->fdata_)); - if (dirp->current_handle_ != PACE_INVALID_HANDLE) - { - FindClose (dirp->current_handle_); - dirp->current_handle_ = PACE_INVALID_HANDLE; - } - else /* Skip "." and ".." */ - { - int retval = 1; - while (*(dirp->fdata_.cFileName) == '.' - && retval - && dirp->fdata_.dwFileAttributes == FILE_ATTRIBUTE_DIRECTORY) - { - retval = FindNextFile (dirp->current_handle_, - &(dirp->fdata_)); - } - if (retval == 0) - { - dirp->current_handle_ = PACE_INVALID_HANDLE; - } - } - dirp->started_reading_ = 1; - } - else - { - int retval = FindNextFile (dirp->current_handle_, - &(dirp->fdata_)); - if (retval == 0) - { - dirp->current_handle_ = PACE_INVALID_HANDLE; - } - } - - if (dirp->current_handle_ != PACE_INVALID_HANDLE) - { - dirp->dirent_.d_name = dirp->fdata_.cFileName; - return &(dirp->dirent_); - } - else - { - return (pace_dirent*)0; - } + return readdir (dirp); } #endif /* PACE_HAS_POSIX_FS_UOF */ diff --git a/PACE/pace/win32/fcntl.c b/PACE/pace/win32/fcntl.c index 17b00cbcabc..d7a91d4ffe4 100644 --- a/PACE/pace/win32/fcntl.c +++ b/PACE/pace/win32/fcntl.c @@ -18,3 +18,146 @@ #if !defined (PACE_HAS_INLINE) # include "pace/win32/fcntl.inl" #endif /* ! PACE_HAS_INLINE */ + +#if (PACE_HAS_POSIX_FS_UOF) +#include <windows.h> +#include <wtypes.h> +int creat (const char * path, pace_mode_t mode) +{ + /* Emulation is still buggy! DO NOT YET USE! */ + + DWORD access = GENERIC_READ, + creation = OPEN_EXISTING, + flags = 0, + shared_mode = FILE_SHARE_READ | FILE_SHARE_WRITE; + + HANDLE h = (void*)0; + + if (PACE_BIT_ENABLED (mode, O_WRONLY)) + { + access = GENERIC_WRITE; + } + else if (PACE_BIT_ENABLED (mode, O_RDWR)) + { + access = GENERIC_READ | GENERIC_WRITE; + } + + if ((mode & (_O_CREAT | _O_EXCL)) == (_O_CREAT | _O_EXCL)) + { + creation = CREATE_NEW; + } + else if ((mode & (_O_CREAT | _O_TRUNC)) == (_O_CREAT | _O_TRUNC)) + { + creation = CREATE_ALWAYS; + } + else if (PACE_BIT_ENABLED (mode, _O_CREAT)) + { + creation = OPEN_ALWAYS; + } + else if (PACE_BIT_ENABLED (mode, _O_TRUNC)) + { + creation = TRUNCATE_EXISTING; + } + + if (PACE_BIT_ENABLED (mode, _O_TEMPORARY)) + { + flags |= FILE_FLAG_DELETE_ON_CLOSE | FILE_ATTRIBUTE_TEMPORARY; + } + + if (PACE_BIT_ENABLED (mode, FILE_FLAG_WRITE_THROUGH)) + { + flags |= FILE_FLAG_WRITE_THROUGH; + } + if (PACE_BIT_ENABLED (mode, FILE_FLAG_OVERLAPPED)) + { + flags |= FILE_FLAG_OVERLAPPED; + } + if (PACE_BIT_ENABLED (mode, FILE_FLAG_NO_BUFFERING)) + { + flags |= FILE_FLAG_NO_BUFFERING; + } + if (PACE_BIT_ENABLED (mode, FILE_FLAG_RANDOM_ACCESS)) + { + flags |= FILE_FLAG_RANDOM_ACCESS; + } + if (PACE_BIT_ENABLED (mode, FILE_FLAG_SEQUENTIAL_SCAN)) + { + flags |= FILE_FLAG_SEQUENTIAL_SCAN; + } + if (PACE_BIT_ENABLED (mode, FILE_FLAG_DELETE_ON_CLOSE)) + { + flags |= FILE_FLAG_DELETE_ON_CLOSE; + } + if (PACE_BIT_ENABLED (mode, FILE_FLAG_BACKUP_SEMANTICS)) + { + flags |= FILE_FLAG_BACKUP_SEMANTICS; + } + if (PACE_BIT_ENABLED (mode, FILE_FLAG_POSIX_SEMANTICS)) + { + flags |= FILE_FLAG_POSIX_SEMANTICS; + } + +#if 0 ////////////////////////////////////////////////////////////////////// + + /* Threads and version info that isn't implemented yet in PACE. + ACE_MT (ACE_thread_mutex_t *ace_os_monitor_lock = 0;) + */ + if (PACE_BIT_ENABLED (mode, _O_APPEND)) + { + ACE_MT + ( + ace_os_monitor_lock = (ACE_thread_mutex_t *) + ACE_OS_Object_Manager::preallocated_object[ + ACE_OS_Object_Manager::ACE_OS_MONITOR_LOCK]; + ACE_OS::thread_mutex_lock (ace_os_monitor_lock); + ) + } + +#if !defined (ACE_HAS_WINCE) /* CE doesn't have FILE_SHARE_DELETE */ + if (ACE_OS::get_win32_versioninfo().dwPlatformId == + VER_PLATFORM_WIN32_NT) + shared_mode |= FILE_SHARE_DELETE; +#endif /* ACE_HAS_WINCE */ + +//////////////////////////////////////////////////////////// +#endif /* 0 */ + + h = CreateFile (path, + access, + shared_mode, + 0, + creation, + flags, + 0); + + if (PACE_BIT_ENABLED (mode, _O_APPEND)) + { + if (h != PACE_INVALID_HANDLE) + { + SetFilePointer (h, 0, 0, FILE_END); + } + /* Threads and version info that isn't implemented yet in PACE. + ACE_MT (ACE_thread_mutex_t *ace_os_monitor_lock = 0;) + ACE_MT (ACE_OS::thread_mutex_unlock (ace_os_monitor_lock);) + */ + } + + if (h == PACE_INVALID_HANDLE) + { + /* Where is this in ACE? + ACE_FAIL_RETURN (h); + */ + return -1; + } + else + { + /* return h; + + POSIX returns lowest unused file descriptor but windows + doesn't handle files in the same manner. + We return -1 for failure and 1 for success. + */ + return 1; + } +} +#endif /* PACE_HAS_POSIX_FS_UOF */ diff --git a/PACE/pace/win32/fcntl.h b/PACE/pace/win32/fcntl.h index 584e48d1282..eda6cd3266d 100644 --- a/PACE/pace/win32/fcntl.h +++ b/PACE/pace/win32/fcntl.h @@ -56,6 +56,10 @@ extern "C" { typedef struct flock pace_flock; #endif /* PACE_FLOCK */ +#if (PACE_HAS_POSIX_FS_UOF) + int creat (const char * path, pace_mode_t mode); +#endif /* PACE_HAS_POSIX_FS_UOF */ + #if defined (PACE_HAS_CPLUSPLUS) } #endif /* PACE_HAS_CPLUSPLUS */ diff --git a/PACE/pace/win32/fcntl.inl b/PACE/pace/win32/fcntl.inl index e751070d001..4ca9257ec8d 100644 --- a/PACE/pace/win32/fcntl.inl +++ b/PACE/pace/win32/fcntl.inl @@ -13,153 +13,13 @@ * * ============================================================================= */ -#include <windows.h> -#include <wtypes.h> - #if (PACE_HAS_POSIX_FS_UOF) PACE_INLINE int pace_creat (const char * path, pace_mode_t mode) { + /* Emulation is still buggy! creat (path, mode); */ PACE_ERRNO_NO_SUPPORT_RETURN (-1); - -#if 0 /* Emulation is still buggy! */ - - DWORD access = GENERIC_READ, - creation = OPEN_EXISTING, - flags = 0, - shared_mode = FILE_SHARE_READ | FILE_SHARE_WRITE; - - HANDLE h = (void*)0; - - if (PACE_BIT_ENABLED (mode, O_WRONLY)) - { - access = GENERIC_WRITE; - } - else if (PACE_BIT_ENABLED (mode, O_RDWR)) - { - access = GENERIC_READ | GENERIC_WRITE; - } - - if ((mode & (_O_CREAT | _O_EXCL)) == (_O_CREAT | _O_EXCL)) - { - creation = CREATE_NEW; - } - else if ((mode & (_O_CREAT | _O_TRUNC)) == (_O_CREAT | _O_TRUNC)) - { - creation = CREATE_ALWAYS; - } - else if (PACE_BIT_ENABLED (mode, _O_CREAT)) - { - creation = OPEN_ALWAYS; - } - else if (PACE_BIT_ENABLED (mode, _O_TRUNC)) - { - creation = TRUNCATE_EXISTING; - } - - if (PACE_BIT_ENABLED (mode, _O_TEMPORARY)) - { - flags |= FILE_FLAG_DELETE_ON_CLOSE | FILE_ATTRIBUTE_TEMPORARY; - } - - if (PACE_BIT_ENABLED (mode, FILE_FLAG_WRITE_THROUGH)) - { - flags |= FILE_FLAG_WRITE_THROUGH; - } - if (PACE_BIT_ENABLED (mode, FILE_FLAG_OVERLAPPED)) - { - flags |= FILE_FLAG_OVERLAPPED; - } - if (PACE_BIT_ENABLED (mode, FILE_FLAG_NO_BUFFERING)) - { - flags |= FILE_FLAG_NO_BUFFERING; - } - if (PACE_BIT_ENABLED (mode, FILE_FLAG_RANDOM_ACCESS)) - { - flags |= FILE_FLAG_RANDOM_ACCESS; - } - if (PACE_BIT_ENABLED (mode, FILE_FLAG_SEQUENTIAL_SCAN)) - { - flags |= FILE_FLAG_SEQUENTIAL_SCAN; - } - if (PACE_BIT_ENABLED (mode, FILE_FLAG_DELETE_ON_CLOSE)) - { - flags |= FILE_FLAG_DELETE_ON_CLOSE; - } - if (PACE_BIT_ENABLED (mode, FILE_FLAG_BACKUP_SEMANTICS)) - { - flags |= FILE_FLAG_BACKUP_SEMANTICS; - } - if (PACE_BIT_ENABLED (mode, FILE_FLAG_POSIX_SEMANTICS)) - { - flags |= FILE_FLAG_POSIX_SEMANTICS; - } - -#if 0 ////////////////////////////////////////////////////////////////////// - - /* Threads and version info that isn't implemented yet in PACE. - ACE_MT (ACE_thread_mutex_t *ace_os_monitor_lock = 0;) - */ - if (PACE_BIT_ENABLED (mode, _O_APPEND)) - { - ACE_MT - ( - ace_os_monitor_lock = (ACE_thread_mutex_t *) - ACE_OS_Object_Manager::preallocated_object[ - ACE_OS_Object_Manager::ACE_OS_MONITOR_LOCK]; - ACE_OS::thread_mutex_lock (ace_os_monitor_lock); - ) - } - -#if !defined (ACE_HAS_WINCE) /* CE doesn't have FILE_SHARE_DELETE */ - if (ACE_OS::get_win32_versioninfo().dwPlatformId == - VER_PLATFORM_WIN32_NT) - shared_mode |= FILE_SHARE_DELETE; -#endif /* ACE_HAS_WINCE */ - -//////////////////////////////////////////////////////////// -#endif /* 0 */ - - h = CreateFile (path, - access, - shared_mode, - 0, - creation, - flags, - 0); - - if (PACE_BIT_ENABLED (mode, _O_APPEND)) - { - if (h != PACE_INVALID_HANDLE) - { - SetFilePointer (h, 0, 0, FILE_END); - } - /* Threads and version info that isn't implemented yet in PACE. - ACE_MT (ACE_thread_mutex_t *ace_os_monitor_lock = 0;) - ACE_MT (ACE_OS::thread_mutex_unlock (ace_os_monitor_lock);) - */ - } - - if (h == PACE_INVALID_HANDLE) - { - /* Where is this in ACE? - ACE_FAIL_RETURN (h); - */ - return -1; - } - else - { - /* return h; - - POSIX returns lowest unused file descriptor but windows - doesn't handle files in the same manner. - We return -1 for failure and 1 for success. - */ - return 1; - } - -#endif /* Emulation! */ - } #endif /* PACE_HAS_POSIX_FS_UOF */ + diff --git a/PACE/pace/win32/mman.c b/PACE/pace/win32/mman.c index 495fbcf2016..ba6ac654ba7 100644 --- a/PACE/pace/win32/mman.c +++ b/PACE/pace/win32/mman.c @@ -18,3 +18,111 @@ #if !defined (PACE_HAS_INLINE) # include "pace/win32/mman.inl" #endif /* ! PACE_HAS_INLINE */ + +#include <windows.h> +#include <io.h> +#include <stdio.h> + +#if (PACE_HAS_POSIX_NONUOF_FUNCS) +void * +mmap (void * addr, size_t len, int prot, int flags, + PACE_HANDLE fildes, pace_off_t off) +{ + void * addr_mapping = (void*)0; + int nt_flags = 0; + PACE_HANDLE local_handle = PACE_INVALID_HANDLE; + PACE_HANDLE * file_mapping = CreateFileMapping (fildes, + 0, + prot, + 0, + 0, + 0); + if (*file_mapping == 0) + { + PACE_FAIL_RETURN (MAP_FAILED); + } + + if (PACE_BIT_ENABLED (flags, MAP_PRIVATE)) + { + prot = PAGE_WRITECOPY; + nt_flags = FILE_MAP_COPY; + } + else if (PACE_BIT_ENABLED (flags, MAP_SHARED)) + { + if (PACE_BIT_ENABLED (prot, PAGE_READONLY)) + nt_flags = FILE_MAP_READ; + if (PACE_BIT_ENABLED (prot, PAGE_READWRITE)) + nt_flags = FILE_MAP_WRITE; + } + +# if !defined (PACE_HAS_WINCE) + addr_mapping = MapViewOfFileEx (*file_mapping, + nt_flags, + 0, + off, + len, + addr); +# else + /* WinCE doesn't allow specifying <addr>. */ + PACE_UNUSED_ARG (addr); + addr_mapping = MapViewOfFile (*file_mapping, + nt_flags, + 0, + off, + len); +# endif /* ! ACE_HAS_WINCE */ + + /* Only close this down if we used the temporary. */ + if (file_mapping == &local_handle) + { + CloseHandle (*file_mapping); + } + + if (addr_mapping == 0) + { + PACE_FAIL_RETURN (MAP_FAILED); + } + + else if (PACE_BIT_ENABLED (flags, MAP_FIXED) + && addr_mapping != addr) + { + errno = EINVAL; + return MAP_FAILED; + } + else + { + return addr_mapping; + } +} +#endif /* PACE_HAS_POSIX_NONUOF_FUNCS */ + +#if (PACE_HAS_POSIX_NONUOF_FUNCS) +int +mprotect (void * addr, size_t len, int prot) +{ + DWORD dummy; /* Sigh! */ + return VirtualProtect(addr, len, prot, &dummy) ? 0 : -1; +} +#endif /* PACE_HAS_POSIX_NONUOF_FUNCS */ + +#if (PACE_HAS_POSIX_NONUOF_FUNCS) +int +msync (void * addr, size_t len, int flags) +{ + PACE_UNUSED_ARG (flags); + PACE_WIN32CALL_RETURN + (PACE_ADAPT_RETVAL + (FlushViewOfFile (addr, len), pace_result_), int, -1); +} +#endif /* PACE_HAS_POSIX_NONUOF_FUNCS */ + +#if (PACE_HAS_POSIX_NONUOF_FUNCS) +int +munmap (void * addr, size_t len) +{ + PACE_UNUSED_ARG (len); + PACE_WIN32CALL_RETURN + (PACE_ADAPT_RETVAL + (UnmapViewOfFile (addr), pace_result_), int, -1); +} +#endif /* PACE_HAS_POSIX_NONUOF_FUNCS */ diff --git a/PACE/pace/win32/mman.h b/PACE/pace/win32/mman.h index 5f68998e5a7..2a5621823d7 100644 --- a/PACE/pace/win32/mman.h +++ b/PACE/pace/win32/mman.h @@ -41,6 +41,23 @@ extern "C" { # define PACE_PROT_READ PROT_READ # define PACE_PROT_WRITE PROT_WRITE +#if (PACE_HAS_POSIX_NONUOF_FUNCS) + void * mmap (void * addr, size_t len, int prot, int flags, + PACE_HANDLE fildes, pace_off_t off); +#endif /* PACE_HAS_POSIX_NONUOF_FUNCS */ + +#if (PACE_HAS_POSIX_NONUOF_FUNCS) + int mprotect (void * addr, size_t len, int prot); +#endif /* PACE_HAS_POSIX_NONUOF_FUNCS */ + +#if (PACE_HAS_POSIX_NONUOF_FUNCS) + int msync (void * addr, size_t len, int flags); +#endif /* PACE_HAS_POSIX_NONUOF_FUNCS */ + +#if (PACE_HAS_POSIX_NONUOF_FUNCS) + int munmap (void * addr, size_t len); +#endif /* PACE_HAS_POSIX_NONUOF_FUNCS */ + #if defined (PACE_HAS_CPLUSPLUS) } #endif /* PACE_HAS_CPLUSPLUS */ diff --git a/PACE/pace/win32/mman.inl b/PACE/pace/win32/mman.inl index cd9b9f85bac..1b0abb8ee1b 100644 --- a/PACE/pace/win32/mman.inl +++ b/PACE/pace/win32/mman.inl @@ -13,9 +13,7 @@ * * ============================================================================= */ -#include <windows.h> #include <io.h> -#include <stdio.h> #if (PACE_HAS_POSIX_NONUOF_FUNCS) PACE_INLINE @@ -48,71 +46,7 @@ pace_mmap (void * addr, PACE_HANDLE fildes, pace_off_t off) { - void * addr_mapping = (void*)0; - int nt_flags = 0; - PACE_HANDLE local_handle = PACE_INVALID_HANDLE; - PACE_HANDLE * file_mapping = CreateFileMapping (fildes, - 0, - prot, - 0, - 0, - 0); - if (*file_mapping == 0) - { - PACE_FAIL_RETURN (MAP_FAILED); - } - - if (PACE_BIT_ENABLED (flags, MAP_PRIVATE)) - { - prot = PAGE_WRITECOPY; - nt_flags = FILE_MAP_COPY; - } - else if (PACE_BIT_ENABLED (flags, MAP_SHARED)) - { - if (PACE_BIT_ENABLED (prot, PAGE_READONLY)) - nt_flags = FILE_MAP_READ; - if (PACE_BIT_ENABLED (prot, PAGE_READWRITE)) - nt_flags = FILE_MAP_WRITE; - } - -# if !defined (PACE_HAS_WINCE) - addr_mapping = MapViewOfFileEx (*file_mapping, - nt_flags, - 0, - off, - len, - addr); -# else - /* WinCE doesn't allow specifying <addr>. */ - PACE_UNUSED_ARG (addr); - addr_mapping = MapViewOfFile (*file_mapping, - nt_flags, - 0, - off, - len); -# endif /* ! ACE_HAS_WINCE */ - - /* Only close this down if we used the temporary. */ - if (file_mapping == &local_handle) - { - CloseHandle (*file_mapping); - } - - if (addr_mapping == 0) - { - PACE_FAIL_RETURN (MAP_FAILED); - } - - else if (PACE_BIT_ENABLED (flags, MAP_FIXED) - && addr_mapping != addr) - { - errno = EINVAL; - return MAP_FAILED; - } - else - { - return addr_mapping; - } + return mmap (addr, len, prot, flags, fildes, off); } #endif /* PACE_HAS_POSIX_NONUOF_FUNCS */ @@ -130,12 +64,9 @@ pace_munlock (const void * addr, size_t len) #if (PACE_HAS_POSIX_NONUOF_FUNCS) PACE_INLINE int -pace_mprotect (void * addr, - size_t len, - int prot) +pace_mprotect (void * addr, size_t len, int prot) { - DWORD dummy; /* Sigh! */ - return VirtualProtect(addr, len, prot, &dummy) ? 0 : -1; + return mprotect (addr, len, prot); } #endif /* PACE_HAS_POSIX_NONUOF_FUNCS */ @@ -146,10 +77,7 @@ pace_msync (void * addr, size_t len, int flags) { - PACE_UNUSED_ARG (flags); - PACE_WIN32CALL_RETURN - (PACE_ADAPT_RETVAL - (FlushViewOfFile (addr, len), pace_result_), int, -1); + return msync (addr, len, flags); } #endif /* PACE_HAS_POSIX_NONUOF_FUNCS */ @@ -167,19 +95,14 @@ PACE_INLINE int pace_munmap (void * addr, size_t len) { - PACE_UNUSED_ARG (len); - PACE_WIN32CALL_RETURN - (PACE_ADAPT_RETVAL - (UnmapViewOfFile (addr), pace_result_), int, -1); + return munmap (addr, len); } #endif /* PACE_HAS_POSIX_NONUOF_FUNCS */ #if (PACE_HAS_POSIX_NONUOF_FUNCS) PACE_INLINE PACE_HANDLE -pace_shm_open (const char * name, - int oflag, - pace_mode_t mode) +pace_shm_open (const char * name, int oflag, pace_mode_t mode) { /* Would be similar to ACE_OS::open which (currently uses threads and Object Manager). diff --git a/PACE/pace/win32/semaphore.c b/PACE/pace/win32/semaphore.c index a2bab745738..401ebddc5a5 100644 --- a/PACE/pace/win32/semaphore.c +++ b/PACE/pace/win32/semaphore.c @@ -18,3 +18,103 @@ #if !defined (PACE_HAS_INLINE) # include "pace/win32/semaphore.inl" #endif /* ! PACE_HAS_INLINE */ + +#if (PACE_HAS_POSIX_NONUOF_FUNCS) +# include <stdio.h> +#endif /* PACE_HAS_POSIX_NONUOF_FUNCS */ + +#if (PACE_HAS_POSIX_NONUOF_FUNCS) +int +sem_close (pace_sem_t * sem) +{ + PACE_WIN32CALL_RETURN + (PACE_ADAPT_RETVAL + (CloseHandle (sem), pace_result_), int, -1); +} +#endif /* PACE_HAS_POSIX_NONUOF_FUNCS */ + +#if (PACE_HAS_POSIX_NONUOF_FUNCS) +int +sem_destroy (pace_sem_t * sem) +{ + PACE_WIN32CALL_RETURN + (PACE_ADAPT_RETVAL + (CloseHandle (sem), pace_result_), int, -1); +} +#endif /* PACE_HAS_POSIX_NONUOF_FUNCS */ + +#if (PACE_HAS_POSIX_NONUOF_FUNCS) +int +sem_init (pace_sem_t * sem, int pshared, unsigned int value) +{ + /* Create the semaphore with its value initialized to <count> and + its maximum value initialized to <max>. + + How do we want to call CreateSemaphore? What about the char *? + */ + *sem = CreateSemaphore (0, value, 2147483647, "noname"); + + if (*sem == 0) + { + PACE_FAIL_RETURN (-1); + } + /* NOTREACHED */ + else + { + return 0; + } +} +#endif /* PACE_HAS_POSIX_NONUOF_FUNCS */ + +#if (PACE_HAS_POSIX_NONUOF_FUNCS) +int +sem_post (pace_sem_t * sem) +{ + PACE_WIN32CALL_RETURN + (PACE_ADAPT_RETVAL + (ReleaseSemaphore (*sem, 1, 0), pace_result_), int, -1); +} +#endif /* PACE_HAS_POSIX_NONUOF_FUNCS */ + +#if (PACE_HAS_POSIX_NONUOF_FUNCS) +int +sem_trywait (pace_sem_t * sem) +{ + int result = WaitForSingleObject (*sem, 0); + + if (result == WAIT_OBJECT_0) + { + return 0; + } + else + { + if (result == WAIT_TIMEOUT) + { + errno = EBUSY; + } + else + { + errno = GetLastError (); + } + /* This is a hack, we need to find an appropriate mapping... */ + return -1; + } +} +#endif /* PACE_HAS_POSIX_NONUOF_FUNCS */ + +#if (PACE_HAS_POSIX_NONUOF_FUNCS) +int +sem_wait (pace_sem_t * sem) +{ + switch (WaitForSingleObject (*sem, INFINITE)) + { + case WAIT_OBJECT_0: + return 0; + default: + /* This is a hack, we need to find an appropriate mapping... */ + errno = GetLastError (); + return -1; + } +} +#endif /* PACE_HAS_POSIX_NONUOF_FUNCS */ + diff --git a/PACE/pace/win32/semaphore.h b/PACE/pace/win32/semaphore.h index e3c3b75780c..c600bf7e068 100644 --- a/PACE/pace/win32/semaphore.h +++ b/PACE/pace/win32/semaphore.h @@ -30,6 +30,30 @@ extern "C" { typedef HANDLE pace_sem_t; #endif /* PACE_SEM_T */ +#if (PACE_HAS_POSIX_NONUOF_FUNCS) + int sem_close (pace_sem_t * sem); +#endif /* PACE_HAS_POSIX_NONUOF_FUNCS */ + +#if (PACE_HAS_POSIX_NONUOF_FUNCS) + int sem_destroy (pace_sem_t * sem); +#endif /* PACE_HAS_POSIX_NONUOF_FUNCS */ + +#if (PACE_HAS_POSIX_NONUOF_FUNCS) + int sem_init (pace_sem_t * sem, int pshared, unsigned int value); +#endif /* PACE_HAS_POSIX_NONUOF_FUNCS */ + +#if (PACE_HAS_POSIX_NONUOF_FUNCS) + int sem_post (pace_sem_t * sem); +#endif /* PACE_HAS_POSIX_NONUOF_FUNCS */ + +#if (PACE_HAS_POSIX_NONUOF_FUNCS) + int sem_trywait (pace_sem_t * sem); +#endif /* PACE_HAS_POSIX_NONUOF_FUNCS */ + +#if (PACE_HAS_POSIX_NONUOF_FUNCS) + int sem_wait (pace_sem_t * sem); +#endif /* PACE_HAS_POSIX_NONUOF_FUNCS */ + #if defined (PACE_HAS_CPLUSPLUS) } #endif /* PACE_HAS_CPLUSPLUS */ diff --git a/PACE/pace/win32/semaphore.inl b/PACE/pace/win32/semaphore.inl index a70aaf092d7..cdef7d7fe8a 100644 --- a/PACE/pace/win32/semaphore.inl +++ b/PACE/pace/win32/semaphore.inl @@ -14,16 +14,13 @@ * ============================================================================= */ #include <io.h> -#include <stdio.h> #if (PACE_HAS_POSIX_NONUOF_FUNCS) PACE_INLINE int pace_sem_close (pace_sem_t * sem) { - PACE_WIN32CALL_RETURN - (PACE_ADAPT_RETVAL - (CloseHandle (sem), pace_result_), int, -1); + return sem_close (sem); } #endif /* PACE_HAS_POSIX_NONUOF_FUNCS */ @@ -32,9 +29,7 @@ PACE_INLINE int pace_sem_destroy (pace_sem_t * sem) { - PACE_WIN32CALL_RETURN - (PACE_ADAPT_RETVAL - (CloseHandle (sem), pace_result_), int, -1); + return sem_destroy (sem); } #endif /* PACE_HAS_POSIX_NONUOF_FUNCS */ @@ -56,22 +51,7 @@ pace_sem_init (pace_sem_t * sem, int pshared, unsigned int value) { - /* Create the semaphore with its value initialized to <count> and - its maximum value initialized to <max>. - - How do we want to call CreateSemaphore? What about the char *? - */ - *sem = CreateSemaphore (0, value, 2147483647, "noname"); - - if (*sem == 0) - { - PACE_FAIL_RETURN (-1); - } - /* NOTREACHED */ - else - { - return 0; - } + return sem_init (sem, pshared, value); } #endif /* PACE_HAS_POSIX_NONUOF_FUNCS */ @@ -80,9 +60,7 @@ PACE_INLINE int pace_sem_post (pace_sem_t * sem) { - PACE_WIN32CALL_RETURN - (PACE_ADAPT_RETVAL - (ReleaseSemaphore (*sem, 1, 0), pace_result_), int, -1); + return sem_post (sem); } #endif /* PACE_HAS_POSIX_NONUOF_FUNCS */ @@ -91,25 +69,7 @@ PACE_INLINE int pace_sem_trywait (pace_sem_t * sem) { - int result = WaitForSingleObject (*sem, 0); - - if (result == WAIT_OBJECT_0) - { - return 0; - } - else - { - if (result == WAIT_TIMEOUT) - { - errno = EBUSY; - } - else - { - errno = GetLastError (); - } - /* This is a hack, we need to find an appropriate mapping... */ - return -1; - } + return sem_trywait (sem); } #endif /* PACE_HAS_POSIX_NONUOF_FUNCS */ @@ -127,15 +87,7 @@ PACE_INLINE int pace_sem_wait (pace_sem_t * sem) { - switch (WaitForSingleObject (*sem, INFINITE)) - { - case WAIT_OBJECT_0: - return 0; - default: - /* This is a hack, we need to find an appropriate mapping... */ - errno = GetLastError (); - return -1; - } + return sem_wait (sem); } #endif /* PACE_HAS_POSIX_NONUOF_FUNCS */ diff --git a/PACE/pace/win32/signal.c b/PACE/pace/win32/signal.c index 4c2e3f238a4..f0d1685971a 100644 --- a/PACE/pace/win32/signal.c +++ b/PACE/pace/win32/signal.c @@ -18,3 +18,28 @@ #if !defined (PACE_HAS_INLINE) # include "pace/win32/signal.inl" #endif /* ! PACE_HAS_INLINE */ + +#if (PACE_HAS_POSIX_SIG_UOF) +int +sigaction (int sig, const pace_sigaction_s * act, + pace_sigaction_s * oact) +{ + pace_sigaction_s sa; + + if (oact == 0) + { + oact = &sa; + } + + if (act == 0) + { + oact->sa_handler = signal (sig, SIG_IGN); + signal (sig, oact->sa_handler); + } + else + { + oact->sa_handler = signal (sig, act->sa_handler); + } + return (oact->sa_handler == SIG_ERR ? -1 : 0); +} +#endif /* PACE_HAS_POSIX_SIG_UOF */ diff --git a/PACE/pace/win32/signal.h b/PACE/pace/win32/signal.h index a3b04bd96f0..b0ca85eeaf6 100644 --- a/PACE/pace/win32/signal.h +++ b/PACE/pace/win32/signal.h @@ -61,8 +61,18 @@ extern "C" { } pace_siginfo_t; # endif /* PACE_SIGINFO_T */ +#ifndef PACE_SIGEVENT typedef struct sigevent pace_sigevent; +#endif /* PACE_SIGEVENT */ + +#ifndef PACE_SIGVAL typedef union sigval pace_sigval; +#endif /* PACE_SIGVAL */ + +#if (PACE_HAS_POSIX_SIG_UOF) + int sigaction (int sig, const pace_sigaction_s * act, + pace_sigaction_s * oact); +#endif /* PACE_HAS_POSIX_SIG_UOF */ #if defined (PACE_HAS_CPLUSPLUS) } diff --git a/PACE/pace/win32/signal.inl b/PACE/pace/win32/signal.inl index 8f62ff1a018..45e842733e4 100644 --- a/PACE/pace/win32/signal.inl +++ b/PACE/pace/win32/signal.inl @@ -40,23 +40,7 @@ int pace_sigaction (int sig, const pace_sigaction_s * act, pace_sigaction_s * oact) { - pace_sigaction_s sa; - - if (oact == 0) - { - oact = &sa; - } - - if (act == 0) - { - oact->sa_handler = signal (sig, SIG_IGN); - signal (sig, oact->sa_handler); - } - else - { - oact->sa_handler = signal (sig, act->sa_handler); - } - return (oact->sa_handler == SIG_ERR ? -1 : 0); + return sigaction (sig, act, oact); } #endif /* PACE_HAS_POSIX_SIG_UOF */ diff --git a/PACE/pace/win32/stat.c b/PACE/pace/win32/stat.c index 6043a480a51..7d19234162e 100644 --- a/PACE/pace/win32/stat.c +++ b/PACE/pace/win32/stat.c @@ -18,3 +18,23 @@ #if !defined (PACE_HAS_INLINE) # include "pace/win32/stat.inl" #endif /* ! PACE_HAS_INLINE */ + +#include <windows.h> +#include <direct.h> + +#if (PACE_HAS_POSIX_FS_UOF) +int +win32_mkdir (const char * path, pace_mode_t mode) +{ + PACE_UNUSED_ARG (mode); +# if defined (__IBMCPP__) && (__IBMCPP__ >= 400) + PACE_OSCALL_RETURN (_mkdir ((char *) path), int, -1); +# elif defined (PACE_WINCE) + PACE_WIN32CALL_RETURN + (PACE_ADAPT_RETVAL + (CreateDirectory (path, NULL), pace_result_), int, -1); +# else + PACE_OSCALL_RETURN (_mkdir (path), int, -1); +# endif /* PACE_WIN32 */ +} +#endif /* PACE_HAS_POSIX_FS_UOF */ diff --git a/PACE/pace/win32/stat.h b/PACE/pace/win32/stat.h index 3f6727869ce..570f1110ab6 100644 --- a/PACE/pace/win32/stat.h +++ b/PACE/pace/win32/stat.h @@ -54,6 +54,10 @@ extern "C" { typedef struct _stat pace_stat_s; #endif /* PACE_STAT */ +#if (PACE_HAS_POSIX_FS_UOF) + int win32_mkdir (const char * path, pace_mode_t mode); +#endif /* PACE_HAS_POSIX_FS_UOF */ + #if defined (PACE_HAS_CPLUSPLUS) } #endif /* PACE_HAS_CPLUSPLUS */ diff --git a/PACE/pace/win32/stat.inl b/PACE/pace/win32/stat.inl index 6fde7d5e830..c6181afdcfc 100644 --- a/PACE/pace/win32/stat.inl +++ b/PACE/pace/win32/stat.inl @@ -13,9 +13,6 @@ * * ============================================================================= */ -#include <windows.h> -#include <direct.h> - #if (PACE_HAS_POSIX_FA_UOF) PACE_INLINE int @@ -52,16 +49,7 @@ PACE_INLINE int pace_mkdir (const char * path, pace_mode_t mode) { - PACE_UNUSED_ARG (mode); -# if defined (__IBMCPP__) && (__IBMCPP__ >= 400) - PACE_OSCALL_RETURN (_mkdir ((char *) path), int, -1); -# elif defined (PACE_WINCE) - PACE_WIN32CALL_RETURN - (PACE_ADAPT_RETVAL - (CreateDirectory (path, NULL), pace_result_), int, -1); -# else - PACE_OSCALL_RETURN (_mkdir (path), int, -1); -# endif /* PACE_WIN32 */ + return win32_mkdir (path, mode); } #endif /* PACE_HAS_POSIX_FS_UOF */ diff --git a/PACE/pace/win32/stdio.inl b/PACE/pace/win32/stdio.inl index a0d730c7fdd..fca3384d839 100644 --- a/PACE/pace/win32/stdio.inl +++ b/PACE/pace/win32/stdio.inl @@ -115,9 +115,7 @@ pace_fgets (char * s, int n, FILE * stream) { - return fgets (s, - n, - stream); + return fgets (s, n, stream); } #endif /* PACE_HAS_POSIX_DI_UOF */ @@ -200,7 +198,7 @@ pace_fseek (FILE * stream, #if (PACE_HAS_POSIX_NONUOF_FUNCS) PACE_INLINE int -pace_fsetpos(PACE_FILE *stream, const pace_fpos_t *pos) +pace_fsetpos(PACE_FILE * stream, const pace_fpos_t * pos) { return fsetpos (stream, pos); } diff --git a/PACE/pace/win32/unistd.c b/PACE/pace/win32/unistd.c index a50a6f53dbb..9c11f0159ce 100644 --- a/PACE/pace/win32/unistd.c +++ b/PACE/pace/win32/unistd.c @@ -18,3 +18,112 @@ #if !defined (PACE_HAS_INLINE) # include "pace/win32/unistd.inl" #endif /* ! PACE_HAS_INLINE */ + +#if (PACE_HAS_POSIX_DI_UOF) +int +win32_close (PACE_HANDLE fildes) +{ + PACE_WIN32CALL_RETURN + (PACE_ADAPT_RETVAL + (CloseHandle (fildes), pace_result_), int, -1); +} +#endif /* PACE_HAS_POSIX_DI_UOF */ + +#if (PACE_HAS_POSIX_FM_UOF) +PACE_HANDLE +win32_dup (PACE_HANDLE fildes) +{ + PACE_HANDLE new_fd; + if (DuplicateHandle(GetCurrentProcess (), + fildes, + GetCurrentProcess(), + &new_fd, + 0, + TRUE, + DUPLICATE_SAME_ACCESS)) + { + return new_fd; + } + else + { + PACE_FAIL_RETURN (PACE_INVALID_HANDLE); + } +} +#endif /* PACE_HAS_POSIX_FM_UOF */ + +#if (PACE_HAS_POSIX_NONUOF_FUNCS) +int +win32_ftruncate (PACE_HANDLE fildes, pace_off_t length) +{ + if (SetFilePointer (fildes, length, NULL, FILE_BEGIN) != (unsigned) -1) + { + PACE_WIN32CALL_RETURN + (PACE_ADAPT_RETVAL + (SetEndOfFile (fildes), pace_result_), int, -1); + } + else + { + PACE_FAIL_RETURN (-1); + } +} +#endif /* PACE_HAS_POSIX_NONUOF_FUNCS */ + +#if (PACE_HAS_POSIX_FM_UOF) +pace_off_t +win32_lseek (PACE_HANDLE fildes, pace_off_t offset, int whence) +{ +# if SEEK_SET != FILE_BEGIN \ + || SEEK_CUR != FILE_CURRENT \ + || SEEK_END != FILE_END + + /* #error Windows NT is evil AND rude! */ + switch (whence) { + + case SEEK_SET: { + whence = FILE_BEGIN; + break; + } + case SEEK_CUR: { + whence = FILE_CURRENT; + break; + } + case SEEK_END: { + whence = FILE_END; + break; + } + default: { + errno = EINVAL; + return (off_t)-1; // rather safe than sorry + } + } + PACE_OSCALL_RETURN (lseek (handle, offset, whence), off_t, -1); +# endif /* SEEK_SET != FILE_BEGIN || SEEK_CUR != FILE_CURRENT || SEEK_END != FILE_END */ + DWORD result = SetFilePointer (fildes, offset, NULL, whence); + if (result == PACE_SYSCALL_FAILED) + { + off_t retval = -1; + PACE_FAIL_RETURN (retval); + } + else + { + return result; + } +} +#endif /* PACE_HAS_POSIX_FM_UOF */ + +#if (PACE_HAS_POSIX_DI_UOF) +ssize_t +win32_write (PACE_HANDLE fildes, const void * buf, size_t nbyte) +{ + DWORD bytes_written; /* This is set to 0 byte WriteFile. */ + + if (WriteFile (fildes, buf, nbyte, &bytes_written, 0)) + { + return (ssize_t) bytes_written; + } + else + { + PACE_FAIL_RETURN (-1); + } +} +#endif /* PACE_HAS_POSIX_DI_UOF */ diff --git a/PACE/pace/win32/unistd.h b/PACE/pace/win32/unistd.h index 1fc56e06a6a..9a12306aed6 100644 --- a/PACE/pace/win32/unistd.h +++ b/PACE/pace/win32/unistd.h @@ -46,8 +46,36 @@ typedef size_t pace_size_t; typedef ssize_t pace_ssize_t; #endif /* PACE_SSIZE_T */ +#if (PACE_HAS_POSIX_DI_UOF) + int win32_close (PACE_HANDLE fildes); +#endif /* PACE_HAS_POSIX_DI_UOF */ + +#if (PACE_HAS_POSIX_FM_UOF) + PACE_HANDLE win32_dup (PACE_HANDLE fildes); +#endif /* PACE_HAS_POSIX_FM_UOF */ + +#if (PACE_HAS_POSIX_NONUOF_FUNCS) + int win32_ftruncate (PACE_HANDLE fildes, pace_off_t length); +#endif /* PACE_HAS_POSIX_NONUOF_FUNCS */ + +#if (PACE_HAS_POSIX_FM_UOF) + pace_off_t win32_lseek (PACE_HANDLE fildes, + pace_off_t offset, + int whence); +#endif /* PACE_HAS_POSIX_FM_UOF */ + +#if (PACE_HAS_POSIX_DI_UOF) + ssize_t win32_write (PACE_HANDLE fildes, + const void * buf, + size_t nbyte); +#endif /* PACE_HAS_POSIX_DI_UOF */ + #if defined (PACE_HAS_CPLUSPLUS) } #endif /* PACE_HAS_CPLUSPLUS */ #endif /* PACE_UNISTD_H_WIN32 */ + + + + diff --git a/PACE/pace/win32/unistd.inl b/PACE/pace/win32/unistd.inl index 3671be890dd..c830e64c6cc 100644 --- a/PACE/pace/win32/unistd.inl +++ b/PACE/pace/win32/unistd.inl @@ -15,6 +15,7 @@ #include <stdarg.h> #include <io.h> +#include <stdio.h> #include <direct.h> #include <process.h> @@ -73,9 +74,7 @@ PACE_INLINE int pace_close (PACE_HANDLE fildes) { - PACE_WIN32CALL_RETURN - (PACE_ADAPT_RETVAL - (CloseHandle (fildes), pace_result_), int, -1); + return win32_close (fildes); } #endif /* PACE_HAS_POSIX_DI_UOF */ @@ -84,21 +83,7 @@ PACE_INLINE PACE_HANDLE pace_dup (PACE_HANDLE fildes) { - PACE_HANDLE new_fd; - if (DuplicateHandle(GetCurrentProcess (), - fildes, - GetCurrentProcess(), - &new_fd, - 0, - TRUE, - DUPLICATE_SAME_ACCESS)) - { - return new_fd; - } - else - { - PACE_FAIL_RETURN (PACE_INVALID_HANDLE); - } + return win32_dup (fildes); } #endif /* PACE_HAS_POSIX_FM_UOF */ @@ -194,16 +179,7 @@ PACE_INLINE int pace_ftruncate (PACE_HANDLE fildes, pace_off_t length) { - if (SetFilePointer (fildes, length, NULL, FILE_BEGIN) != (unsigned) -1) - { - PACE_WIN32CALL_RETURN - (PACE_ADAPT_RETVAL - (SetEndOfFile (fildes), pace_result_), int, -1); - } - else - { - PACE_FAIL_RETURN (-1); - } + return win32_ftruncate (fildes, length); } #endif /* PACE_HAS_POSIX_NONUOF_FUNCS */ @@ -338,42 +314,7 @@ PACE_INLINE pace_off_t pace_lseek (PACE_HANDLE fildes, pace_off_t offset, int whence) { -# if SEEK_SET != FILE_BEGIN \ - || SEEK_CUR != FILE_CURRENT \ - || SEEK_END != FILE_END - - /* #error Windows NT is evil AND rude! */ - switch (whence) { - - case SEEK_SET: { - whence = FILE_BEGIN; - break; - } - case SEEK_CUR: { - whence = FILE_CURRENT; - break; - } - case SEEK_END: { - whence = FILE_END; - break; - } - default: { - errno = EINVAL; - return (off_t)-1; // rather safe than sorry - } - } - PACE_OSCALL_RETURN (lseek (handle, offset, whence), off_t, -1); -# endif /* SEEK_SET != FILE_BEGIN || SEEK_CUR != FILE_CURRENT || SEEK_END != FILE_END */ - DWORD result = SetFilePointer (fildes, offset, NULL, whence); - if (result == PACE_SYSCALL_FAILED) - { - off_t retval = -1; - PACE_FAIL_RETURN (retval); - } - else - { - return result; - } + return win32_lseek (fildes, offset, whence); } #endif /* PACE_HAS_POSIX_FM_UOF */ @@ -540,7 +481,7 @@ PACE_INLINE int pace_unlink (const char * path) { - return unlink (path); + return _unlink (path); } #endif /* PACE_HAS_POSIX_FS_UOF */ @@ -549,15 +490,6 @@ PACE_INLINE ssize_t pace_write (PACE_HANDLE fildes, const void * buf, size_t nbyte) { - DWORD bytes_written; /* This is set to 0 byte WriteFile. */ - - if (WriteFile (fildes, buf, nbyte, &bytes_written, 0)) - { - return (ssize_t) bytes_written; - } - else - { - PACE_FAIL_RETURN (-1); - } + return win32_write (fildes, buf, nbyte); } #endif /* PACE_HAS_POSIX_DI_UOF */ diff --git a/PACE/pace/win32/utime.c b/PACE/pace/win32/utime.c index 3258432d3bc..1ee2542885b 100644 --- a/PACE/pace/win32/utime.c +++ b/PACE/pace/win32/utime.c @@ -18,3 +18,20 @@ #if !defined (PACE_HAS_INLINE) # include "pace/win32/utime.inl" #endif /* ! PACE_HAS_INLINE */ + +#if (PACE_HAS_POSIX_FS_UOF) +int +win32_utime (const char * path, const pace_utimbuf * times) +{ + PACE_ERRNO_NO_SUPPORT_RETURN (-1); + + /* Not yet working + char * path2 = (char*) malloc (sizeof (path)); + pace_strcpy (path2, path); + + pace_utimbuf * times2 = (pace_utimbuf*) malloc (sizeof (pace_utimbuf); + memcpy (times2, times, sizeof times); + return _utime (path2, times2); + */ +} +#endif /* PACE_HAS_POSIX_FS_UOF */ diff --git a/PACE/pace/win32/utime.h b/PACE/pace/win32/utime.h index 9a471c9b69b..cfd7e5014ce 100644 --- a/PACE/pace/win32/utime.h +++ b/PACE/pace/win32/utime.h @@ -28,6 +28,10 @@ extern "C" { typedef struct _utimbuf pace_utimbuf; #endif /* PACE_UTIMBUF */ +#if (PACE_HAS_POSIX_FS_UOF) + int win32_utime (const char * path, const pace_utimbuf * times); +#endif /* PACE_HAS_POSIX_FS_UOF */ + #if defined (PACE_HAS_CPLUSPLUS) } #endif /* PACE_HAS_CPLUSPLUS */ diff --git a/PACE/pace/win32/utime.inl b/PACE/pace/win32/utime.inl index 9c4547742bd..1154ebd29c4 100644 --- a/PACE/pace/win32/utime.inl +++ b/PACE/pace/win32/utime.inl @@ -21,14 +21,7 @@ int pace_utime (const char * path, const pace_utimbuf * times) { - /* Not yet working - char * path2 = (char*) malloc (sizeof (path)); - pace_strcpy (path2, path); - - pace_utimbuf * times2 = (pace_utimbuf*) malloc (sizeof (pace_utimbuf); - memcpy (times2, times, sizeof times); - return _utime (path2, times2); - */ + /* Emulation not yet finished! Not yet working! */ /* Not quite the perfect answer... win32 doesn't take const args. */ return _utime ((char*)path, (struct _utimbuf*)times); diff --git a/PACE/pace/win32/utsname.c b/PACE/pace/win32/utsname.c index 0d842690a91..208b3f2f142 100644 --- a/PACE/pace/win32/utsname.c +++ b/PACE/pace/win32/utsname.c @@ -18,3 +18,163 @@ #if !defined (PACE_HAS_INLINE) # include "pace/win32/utsname.inl" #endif /* ! PACE_HAS_INLINE */ + +#if (PACE_HAS_POSIX_SP_UOF) +int +uname (pace_utsname * name) +{ + PACE_ERRNO_NO_SUPPORT_RETURN (-1); + +#if 0 /* Emulation: Not bug free! :-/ */ + + size_t maxnamelen = sizeof name->nodename; + pace_strcpy (name->sysname, "Win32"); + + OSVERSIONINFO vinfo; + vinfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); + ::GetVersionEx (&vinfo); + + SYSTEM_INFO sinfo; + GetSystemInfo(&sinfo); + pace_strcpy (name->sysname, "Win32"); + + if (vinfo.dwPlatformId == VER_PLATFORM_WIN32_NT) + { + /* Get information from the two structures */ + pace_sprintf (name->release, "Windows NT %d.%d", + vinfo.dwMajorVersion, + vinfo.dwMinorVersion); + pace_sprintf (name->version, + "Build %d %s", + vinfo.dwBuildNumber, + vinfo.szCSDVersion); + + /* We have to make sure that the size of (processor + subtype) is + not greater than the size of name->machine. So we give half + the space to the processor and half the space to subtype. The + -1 is necessary for because of the space between processor and + subtype in the machine name. + */ + const int bufsize = ((sizeof (name->machine) / sizeof (ACE_TCHAR)) / 2) - 1; + char processor[bufsize] = "Unknown"; + char subtype[bufsize] = "Unknown"; + + WORD arch = sinfo.wProcessorArchitecture; + + switch (arch) + { + + case PROCESSOR_ARCHITECTURE_INTEL: { + + pace_strcpy (processor, "Intel"); + if (sinfo.wProcessorLevel == 3) + { + pace_strcpy (subtype, "80386"); + } + else if (sinfo.wProcessorLevel == 4) + { + pace_strcpy (subtype, "80486"); + } + else if (sinfo.wProcessorLevel == 5) + { + pace_strcpy (subtype, "Pentium"); + } + else if (sinfo.wProcessorLevel == 6) + { + pace_strcpy (subtype, "Pentium Pro"); + } + else if (sinfo.wProcessorLevel == 7) /* guessing here */ + { + pace_strcpy (subtype, "Pentium II"); + } + break; + } + + case PROCESSOR_ARCHITECTURE_MIPS: { + pace_strcpy (processor, "MIPS"); + pace_strcpy (subtype, "R4000"); + break; + } + + case PROCESSOR_ARCHITECTURE_ALPHA: { + pace_strcpy (processor, "Alpha"); + pace_sprintf (subtype, "%d", sinfo.wProcessorLevel); + break; + } + + case PROCESSOR_ARCHITECTURE_PPC: { + pace_strcpy (processor, "PPC"); + if (sinfo.wProcessorLevel == 1) + { + pace_strcpy (subtype, "601"); + } + else if (sinfo.wProcessorLevel == 3) + { + pace_strcpy (subtype, "603"); + } + else if (sinfo.wProcessorLevel == 4) + { + pace_strcpy (subtype, "604"); + } + else if (sinfo.wProcessorLevel == 6) + { + pace_strcpy (subtype, "603+"); + } + else if (sinfo.wProcessorLevel == 9) + { + pace_strcpy (subtype, "804+"); + } + else if (sinfo.wProcessorLevel == 20) + { + pace_strcpy (subtype, "620"); + } + break; + } + + case PROCESSOR_ARCHITECTURE_UNKNOWN: { + + default: + { + /* @@ We could provide WinCE specific info here. But let's + defer that to some later point. + */ + pace_strcpy (processor, "Unknown"); + break; + } + } + } + pace_sprintf(name->machine, "%s %s", processor, subtype); + } + else if (vinfo.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) + { + // Get Windows 95 Information + pace_strcpy (name->release, "Windows 95"); + pace_sprintf (name->version, "%d", LOWORD (vinfo.dwBuildNumber)); + if (sinfo.dwProcessorType == PROCESSOR_INTEL_386) + { + pace_strcpy (name->machine, "Intel 80386"); + } + else if (sinfo.dwProcessorType == PROCESSOR_INTEL_486) + { + pace_strcpy (name->machine, "Intel 80486"); + } + else if (sinfo.dwProcessorType == PROCESSOR_INTEL_PENTIUM) + { + pace_strcpy (name->machine, "Intel Pentium"); + } + } + else + { + /* We don't know what this is! */ + pace_strcpy (name->release, "???"); + pace_strcpy (name->version, "???"); + pace_strcpy (name->machine, "???"); + } + + /* ick */ + return ACE_OS::hostname (name->nodename, maxnamelen); + +#endif /* emulation */ + +} +#endif /* PACE_HAS_POSIX_SP_UOF */ diff --git a/PACE/pace/win32/utsname.h b/PACE/pace/win32/utsname.h index 178c3f20648..d7115856b92 100644 --- a/PACE/pace/win32/utsname.h +++ b/PACE/pace/win32/utsname.h @@ -32,6 +32,10 @@ extern "C" { } pace_utsname; # endif /* PACE_UTSNAME */ +#if (PACE_HAS_POSIX_SP_UOF) + int uname (pace_utsname * name); +#endif /* PACE_HAS_POSIX_SP_UOF */ + #if defined (PACE_HAS_CPLUSPLUS) } #endif /* PACE_HAS_CPLUSPLUS */ diff --git a/PACE/pace/win32/utsname.inl b/PACE/pace/win32/utsname.inl index f08eb755270..e906fc1e131 100644 --- a/PACE/pace/win32/utsname.inl +++ b/PACE/pace/win32/utsname.inl @@ -21,157 +21,5 @@ int pace_uname (pace_utsname * name) { PACE_ERRNO_NO_SUPPORT_RETURN (-1); - -#if 0 /* Emulation: Not bug free! :-/ */ - - size_t maxnamelen = sizeof name->nodename; - pace_strcpy (name->sysname, "Win32"); - - OSVERSIONINFO vinfo; - vinfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); - ::GetVersionEx (&vinfo); - - SYSTEM_INFO sinfo; - GetSystemInfo(&sinfo); - pace_strcpy (name->sysname, "Win32"); - - if (vinfo.dwPlatformId == VER_PLATFORM_WIN32_NT) - { - /* Get information from the two structures */ - pace_sprintf (name->release, "Windows NT %d.%d", - vinfo.dwMajorVersion, - vinfo.dwMinorVersion); - pace_sprintf (name->version, - "Build %d %s", - vinfo.dwBuildNumber, - vinfo.szCSDVersion); - - /* We have to make sure that the size of (processor + subtype) is - not greater than the size of name->machine. So we give half - the space to the processor and half the space to subtype. The - -1 is necessary for because of the space between processor and - subtype in the machine name. - */ - const int bufsize = ((sizeof (name->machine) / sizeof (ACE_TCHAR)) / 2) - 1; - char processor[bufsize] = "Unknown"; - char subtype[bufsize] = "Unknown"; - - WORD arch = sinfo.wProcessorArchitecture; - - switch (arch) - { - - case PROCESSOR_ARCHITECTURE_INTEL: { - - pace_strcpy (processor, "Intel"); - if (sinfo.wProcessorLevel == 3) - { - pace_strcpy (subtype, "80386"); - } - else if (sinfo.wProcessorLevel == 4) - { - pace_strcpy (subtype, "80486"); - } - else if (sinfo.wProcessorLevel == 5) - { - pace_strcpy (subtype, "Pentium"); - } - else if (sinfo.wProcessorLevel == 6) - { - pace_strcpy (subtype, "Pentium Pro"); - } - else if (sinfo.wProcessorLevel == 7) /* guessing here */ - { - pace_strcpy (subtype, "Pentium II"); - } - break; - } - - case PROCESSOR_ARCHITECTURE_MIPS: { - pace_strcpy (processor, "MIPS"); - pace_strcpy (subtype, "R4000"); - break; - } - - case PROCESSOR_ARCHITECTURE_ALPHA: { - pace_strcpy (processor, "Alpha"); - pace_sprintf (subtype, "%d", sinfo.wProcessorLevel); - break; - } - - case PROCESSOR_ARCHITECTURE_PPC: { - pace_strcpy (processor, "PPC"); - if (sinfo.wProcessorLevel == 1) - { - pace_strcpy (subtype, "601"); - } - else if (sinfo.wProcessorLevel == 3) - { - pace_strcpy (subtype, "603"); - } - else if (sinfo.wProcessorLevel == 4) - { - pace_strcpy (subtype, "604"); - } - else if (sinfo.wProcessorLevel == 6) - { - pace_strcpy (subtype, "603+"); - } - else if (sinfo.wProcessorLevel == 9) - { - pace_strcpy (subtype, "804+"); - } - else if (sinfo.wProcessorLevel == 20) - { - pace_strcpy (subtype, "620"); - } - break; - } - - case PROCESSOR_ARCHITECTURE_UNKNOWN: { - - default: - { - /* @@ We could provide WinCE specific info here. But let's - defer that to some later point. - */ - pace_strcpy (processor, "Unknown"); - break; - } - } - } - pace_sprintf(name->machine, "%s %s", processor, subtype); - } - else if (vinfo.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) - { - // Get Windows 95 Information - pace_strcpy (name->release, "Windows 95"); - pace_sprintf (name->version, "%d", LOWORD (vinfo.dwBuildNumber)); - if (sinfo.dwProcessorType == PROCESSOR_INTEL_386) - { - pace_strcpy (name->machine, "Intel 80386"); - } - else if (sinfo.dwProcessorType == PROCESSOR_INTEL_486) - { - pace_strcpy (name->machine, "Intel 80486"); - } - else if (sinfo.dwProcessorType == PROCESSOR_INTEL_PENTIUM) - { - pace_strcpy (name->machine, "Intel Pentium"); - } - } - else - { - /* We don't know what this is! */ - pace_strcpy (name->release, "???"); - pace_strcpy (name->version, "???"); - pace_strcpy (name->machine, "???"); - } - - /* ick */ - return ACE_OS::hostname (name->nodename, maxnamelen); - -#endif 0 /* Emulated! */ - } #endif /* PACE_HAS_POSIX_SP_UOF */ |