summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorluther <luther@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2000-07-15 03:08:44 +0000
committerluther <luther@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2000-07-15 03:08:44 +0000
commit43f4c9c8fdcc9e1e968566c0e26ebaf511d861f8 (patch)
treef168af89832d059b0344cc10264fcbba37e7430f
parentf466ed7c5e171ee417f0a24bdd509653ae088706 (diff)
downloadATCD-43f4c9c8fdcc9e1e968566c0e26ebaf511d861f8.tar.gz
Fri Jul 14 22:00:34 2000 Luther J Baker <luther@cs.wustl.edu>
-rw-r--r--PACE/ChangeLog16
-rw-r--r--PACE/pace/fcntl.h4
-rw-r--r--PACE/pace/win32/fcntl.inl145
3 files changed, 164 insertions, 1 deletions
diff --git a/PACE/ChangeLog b/PACE/ChangeLog
index fc4febcfaf0..4bfa70d9720 100644
--- a/PACE/ChangeLog
+++ b/PACE/ChangeLog
@@ -1,3 +1,19 @@
+Fri Jul 14 22:00:34 2000 Luther J Baker <luther@cs.wustl.edu>
+
+ * pace/win32/fcntl.inl (creat):
+
+ WIN32 doesn't support integers as file handles. Note here,
+ we return -1 for failure and we cast a HANDLE to an int
+ for success.
+
+ Also, emulated support for POSIX creat. The ACE_OS version
+ extensively uses thread protection. This is commented out and
+ may be added in later, when threads are implemented in PACE.
+
+ * pace/fcntl.h (creat):
+
+ Comments regarding return values == (int)*HANDLE for WIN32.
+
Fri Jul 14 21:20:59 2000 Luther J Baker <luther@cs.wustl.edu>
* pace/win32/types.h:
diff --git a/PACE/pace/fcntl.h b/PACE/pace/fcntl.h
index 7b9de15cc29..3fcd2ea618a 100644
--- a/PACE/pace/fcntl.h
+++ b/PACE/pace/fcntl.h
@@ -37,6 +37,10 @@ extern "C" {
*/
#if (PACE_HAS_POSIX_FS_UOF)
PACE_INLINE int pace_creat (const char * path, pace_mode_t mode);
+ /* WIN32 doesn't correctly return a file desciptor. WIN32 doesn't use
+ integers to represent file handles. Instead, we return (int)*HANDLE
+ for success and -1 for failure.
+ */
#endif /* PACE_HAS_POSIX_FS_UOF */
/**
diff --git a/PACE/pace/win32/fcntl.inl b/PACE/pace/win32/fcntl.inl
index fd9e49cd76f..fb22393d337 100644
--- a/PACE/pace/win32/fcntl.inl
+++ b/PACE/pace/win32/fcntl.inl
@@ -13,11 +13,154 @@
*
* ============================================================================= */
+#include <windows.h>
+#include <wtypes.h>
+
+#if (PACE_HAS_POSIX_FS_UOF)
+PACE_INLINE
+int
+pace_win32_emulation_creat (const char * path, pace_mode_t mode)
+{
+ 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_WIN32_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_WIN32_INVALID_HANDLE)
+ {
+ /* Where is this in ACE?
+ ACE_FAIL_RETURN (h);
+ */
+ return -1;
+ }
+ else
+ {
+ /* POSIX needs an integer
+ return h;
+ Should return lowest unused file descriptor but windows
+ doesn't do that. So we simply return 1;
+ */
+ return (int)*h;
+ }
+}
+#endif /* PACE_HAS_POSIX_FS_UOF */
+
#if (PACE_HAS_POSIX_FS_UOF)
PACE_INLINE
int
pace_creat (const char * path, pace_mode_t mode)
{
- return creat (path, mode);
+ return pace_win32_emulation_creat (path, mode);
}
#endif /* PACE_HAS_POSIX_FS_UOF */