summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOssama Othman <ossama-othman@users.noreply.github.com>2006-10-26 23:07:24 +0000
committerOssama Othman <ossama-othman@users.noreply.github.com>2006-10-26 23:07:24 +0000
commitec9496bea543bd5ebb9214880c056b95446b6b13 (patch)
treef13a58e9814886bf7627a4f566caa7425bd61a25
parentd4ce64ef75457044ad7a9334f787d24fbb4c0a23 (diff)
downloadATCD-ec9496bea543bd5ebb9214880c056b95446b6b13.tar.gz
ChangeLogTag:Thu Oct 27 01:59:19 UTC 2006 Ossama Othman <ossama_othman at symantec dot com>
-rw-r--r--ACE/ChangeLog52
-rw-r--r--ACE/ace/ACE.cpp4
-rw-r--r--ACE/ace/ACE.h4
-rw-r--r--ACE/ace/FILE.cpp8
-rw-r--r--ACE/ace/File_Lock.h18
-rw-r--r--ACE/ace/File_Lock.inl18
-rw-r--r--ACE/ace/Filecache.cpp9
-rw-r--r--ACE/ace/Filecache.h10
-rw-r--r--ACE/ace/Local_Memory_Pool.cpp2
-rw-r--r--ACE/ace/MEM_Acceptor.h2
-rw-r--r--ACE/ace/MEM_Acceptor.inl2
-rw-r--r--ACE/ace/MEM_IO.cpp8
-rw-r--r--ACE/ace/MEM_IO.h2
-rw-r--r--ACE/ace/MEM_IO.inl2
-rw-r--r--ACE/ace/MMAP_Memory_Pool.cpp88
-rw-r--r--ACE/ace/MMAP_Memory_Pool.h30
-rw-r--r--ACE/ace/Mem_Map.cpp44
-rw-r--r--ACE/ace/Mem_Map.h43
-rw-r--r--ACE/ace/Mem_Map.inl43
-rw-r--r--ACE/ace/OS_NS_macros.h40
-rw-r--r--ACE/ace/OS_NS_stdio.cpp52
-rw-r--r--ACE/ace/OS_NS_stdio.h33
-rw-r--r--ACE/ace/OS_NS_stdio.inl211
-rw-r--r--ACE/ace/OS_NS_sys_mman.h2
-rw-r--r--ACE/ace/OS_NS_sys_mman.inl13
-rw-r--r--ACE/ace/OS_NS_sys_stat.h4
-rw-r--r--ACE/ace/OS_NS_sys_stat.inl24
-rw-r--r--ACE/ace/OS_NS_unistd.cpp76
-rw-r--r--ACE/ace/OS_NS_unistd.h14
-rw-r--r--ACE/ace/OS_NS_unistd.inl75
-rw-r--r--ACE/ace/Pagefile_Memory_Pool.inl2
-rw-r--r--ACE/ace/Shared_Memory_MM.cpp4
-rw-r--r--ACE/ace/Shared_Memory_MM.h8
-rw-r--r--ACE/ace/Shared_Memory_MM.inl4
-rw-r--r--ACE/ace/Shared_Memory_Pool.cpp28
-rw-r--r--ACE/ace/Shared_Memory_Pool.h21
-rw-r--r--ACE/ace/os_include/os_unistd.h12
-rw-r--r--ACE/ace/os_include/sys/os_stat.h2
-rw-r--r--ACE/ace/os_include/sys/os_types.h6
-rw-r--r--ACE/examples/IPC_SAP/FILE_SAP/client.cpp2
-rw-r--r--ACE/examples/Web_Crawler/Iterators.cpp2
-rw-r--r--ACE/examples/Web_Crawler/Mem_Map_Stream.cpp8
-rw-r--r--ACE/examples/Web_Crawler/Mem_Map_Stream.h2
43 files changed, 662 insertions, 372 deletions
diff --git a/ACE/ChangeLog b/ACE/ChangeLog
index addf4c11b4e..5015f25535e 100644
--- a/ACE/ChangeLog
+++ b/ACE/ChangeLog
@@ -1,3 +1,55 @@
+Thu Oct 26 15:58:09 Pacific Daylight Time 2006 <ossama_othman at symantec dot com>
+
+ From Russell Mora <russell_mora at symantec dot com>
+ * ace/ACE.cpp:
+ * ace/ACE.h:
+ * ace/FILE.cpp:
+ * ace/File_Lock.h:
+ * ace/File_Lock.inl:
+ * ace/Filecache.cpp:
+ * ace/Filecache.h:
+ * ace/Local_Memory_Pool.cpp:
+ * ace/MEM_Acceptor.h:
+ * ace/MEM_Acceptor.inl:
+ * ace/MEM_IO.cpp:
+ * ace/MEM_IO.inl:
+ * ace/MEM_IO.h:
+ * ace/MMAP_Memory_Pool.cpp:
+ * ace/MMAP_Memory_Pool.h:
+ * ace/Mem_Map.cpp:
+ * ace/Mem_Map.h:
+ * ace/Mem_Map.inl:
+ * ace/OS_NS_macros.h:
+ * ace/OS_NS_stdio.cpp:
+ * ace/OS_NS_stdio.inl:
+ * ace/OS_NS_stdio.h:
+ * ace/OS_NS_sys_mman.h:
+ * ace/OS_NS_sys_mman.inl:
+ * ace/OS_NS_sys_stat.h:
+ * ace/OS_NS_sys_stat.inl:
+ * ace/OS_NS_unistd.cpp:
+ * ace/OS_NS_unistd.inl:
+ * ace/OS_NS_unistd.h:
+ * ace/Pagefile_Memory_Pool.inl:
+ * ace/Shared_Memory_MM.cpp:
+ * ace/Shared_Memory_MM.h:
+ * ace/Shared_Memory_MM.inl:
+ * ace/Shared_Memory_Pool.cpp:
+ * ace/Shared_Memory_Pool.h:
+ * ace/os_include/sys/os_types.h:
+ * ace/os_include/sys/os_stat.h:
+ * ace/os_include/os_unistd.h:
+ * examples/Web_Crawler/Iterators.cpp:
+ * examples/Web_Crawler/Mem_Map_Stream.cpp:
+ * examples/Web_Crawler/Mem_Map_Stream.h:
+ * examples/IPC_SAP/FILE_SAP/client.cpp:
+
+ Added support for 64-bit file offsets on 32-bit platforms on
+ platforms that support the _FILE_OFFSET_BITS preprocessor
+ symbol, as well as Windows. Enable by defining the
+ _FILE_OFFSET_BITS=64 preprocessor symbol (ACE provides the
+ necessary support on Windows when it is defined).
+
Thu Oct 26 24:44:55 UTC 2006 Ossama Othman <ossama_othman at symantec dot com>
* ace/Truncate.h (Truncator):
diff --git a/ACE/ace/ACE.cpp b/ACE/ace/ACE.cpp
index 771cac93886..bfc8a867d6c 100644
--- a/ACE/ace/ACE.cpp
+++ b/ACE/ace/ACE.cpp
@@ -2552,7 +2552,7 @@ ACE::timestamp (ACE_TCHAR date_and_time[],
// This function rounds the request to a multiple of the page size.
size_t
-ACE::round_to_pagesize (off_t len)
+ACE::round_to_pagesize (size_t len)
{
ACE_TRACE ("ACE::round_to_pagesize");
@@ -2563,7 +2563,7 @@ ACE::round_to_pagesize (off_t len)
}
size_t
-ACE::round_to_allocation_granularity (off_t len)
+ACE::round_to_allocation_granularity (size_t len)
{
ACE_TRACE ("ACE::round_to_allocation_granularity");
diff --git a/ACE/ace/ACE.h b/ACE/ace/ACE.h
index 0c2abd32ff3..fe48ac4803b 100644
--- a/ACE/ace/ACE.h
+++ b/ACE/ace/ACE.h
@@ -519,10 +519,10 @@ namespace ACE
// = Miscellaneous functions.
/// Rounds the request to a multiple of the page size.
- extern ACE_Export size_t round_to_pagesize (off_t len);
+ extern ACE_Export size_t round_to_pagesize (size_t len);
/// Rounds the request to a multiple of the allocation granularity.
- extern ACE_Export size_t round_to_allocation_granularity (off_t len);
+ extern ACE_Export size_t round_to_allocation_granularity (size_t len);
// @@ UNICODE what about buffer?
/// Format buffer into printable format. This is useful for
diff --git a/ACE/ace/FILE.cpp b/ACE/ace/FILE.cpp
index 57aa52b839f..91ed5511e08 100644
--- a/ACE/ace/FILE.cpp
+++ b/ACE/ace/FILE.cpp
@@ -79,21 +79,21 @@ ACE_FILE::get_info (ACE_FILE_Info &finfo)
}
int
-ACE_FILE::truncate (off_t length)
+ACE_FILE::truncate (ACE_OFF_T length)
{
ACE_TRACE ("ACE_FILE::truncate");
return ACE_OS::ftruncate (this->get_handle(), length);
}
-off_t
-ACE_FILE::seek (off_t offset, int startpos)
+ACE_OFF_T
+ACE_FILE::seek (ACE_OFF_T offset, int startpos)
{
return ACE_OS::lseek (this->get_handle (),
offset,
startpos);
}
-off_t
+ACE_OFF_T
ACE_FILE::tell (void)
{
ACE_TRACE ("ACE_FILE::tell");
diff --git a/ACE/ace/File_Lock.h b/ACE/ace/File_Lock.h
index b45d3347b00..4a6beab51f1 100644
--- a/ACE/ace/File_Lock.h
+++ b/ACE/ace/File_Lock.h
@@ -72,7 +72,7 @@ public:
* wrappers we include the <acquire> method. This is implemented as
* a write-lock to be on the safe-side...
*/
- int acquire (short whence = 0, off_t start = 0, off_t len = 1);
+ int acquire (short whence = 0, ACE_OFF_T start = 0, ACE_OFF_T len = 1);
/**
* Note, for interface uniformity with other synchronization
@@ -81,21 +81,21 @@ public:
* If we "failed" because someone else already had the lock, <errno>
* is set to <EBUSY>.
*/
- int tryacquire (short whence = 0, off_t start = 0, off_t len = 1);
+ int tryacquire (short whence = 0, ACE_OFF_T start = 0, ACE_OFF_T len = 1);
/// Unlock a readers/writer lock.
- int release (short whence = 0, off_t start = 0, off_t len = 1);
+ int release (short whence = 0, ACE_OFF_T start = 0, ACE_OFF_T len = 1);
/// Acquire a write lock, but block if any readers or a
/// writer hold the lock.
- int acquire_write (short whence = 0, off_t start = 0, off_t len = 1);
+ int acquire_write (short whence = 0, ACE_OFF_T start = 0, ACE_OFF_T len = 1);
/**
* Conditionally acquire a write lock (i.e., won't block). Returns
* -1 on failure. If we "failed" because someone else already had
* the lock, <errno> is set to <EBUSY>.
*/
- int tryacquire_write (short whence = 0, off_t start = 0, off_t len = 1);
+ int tryacquire_write (short whence = 0, ACE_OFF_T start = 0, ACE_OFF_T len = 1);
/**
* Conditionally upgrade to a write lock (i.e., won't block). Returns
@@ -103,22 +103,22 @@ public:
* the lock, <errno> is set to <EBUSY>.
*/
int tryacquire_write_upgrade (short whence = 0,
- off_t start = 0,
- off_t len = 1);
+ ACE_OFF_T start = 0,
+ ACE_OFF_T len = 1);
/**
* Acquire a read lock, but block if a writer hold the lock.
* Returns -1 on failure. If we "failed" because someone else
* already had the lock, <errno> is set to <EBUSY>.
*/
- int acquire_read (short whence = 0, off_t start = 0, off_t len = 1);
+ int acquire_read (short whence = 0, ACE_OFF_T start = 0, ACE_OFF_T len = 1);
/**
* Conditionally acquire a read lock (i.e., won't block). Returns
* -1 on failure. If we "failed" because someone else already had
* the lock, <errno> is set to <EBUSY>.
*/
- int tryacquire_read (short whence = 0, off_t start = 0, off_t len = 1);
+ int tryacquire_read (short whence = 0, ACE_OFF_T start = 0, ACE_OFF_T len = 1);
/// Get underlying ACE_HANDLE for the file.
ACE_HANDLE get_handle (void) const;
diff --git a/ACE/ace/File_Lock.inl b/ACE/ace/File_Lock.inl
index be9c149b8d8..bef9de9d063 100644
--- a/ACE/ace/File_Lock.inl
+++ b/ACE/ace/File_Lock.inl
@@ -5,56 +5,58 @@
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_INLINE int
-ACE_File_Lock::acquire_read (short whence, off_t start, off_t len)
+ACE_File_Lock::acquire_read (short whence, ACE_OFF_T start, ACE_OFF_T len)
{
// ACE_TRACE ("ACE_File_Lock::acquire_read");
return ACE_OS::flock_rdlock (&this->lock_, whence, start, len);
}
ACE_INLINE int
-ACE_File_Lock::tryacquire_read (short whence, off_t start, off_t len)
+ACE_File_Lock::tryacquire_read (short whence, ACE_OFF_T start, ACE_OFF_T len)
{
// ACE_TRACE ("ACE_File_Lock::tryacquire_read");
return ACE_OS::flock_tryrdlock (&this->lock_, whence, start, len);
}
ACE_INLINE int
-ACE_File_Lock::tryacquire_write (short whence, off_t start, off_t len)
+ACE_File_Lock::tryacquire_write (short whence, ACE_OFF_T start, ACE_OFF_T len)
{
// ACE_TRACE ("ACE_File_Lock::tryacquire_write");
return ACE_OS::flock_trywrlock (&this->lock_, whence, start, len);
}
ACE_INLINE int
-ACE_File_Lock::tryacquire_write_upgrade (short whence, off_t start, off_t len)
+ACE_File_Lock::tryacquire_write_upgrade (short whence,
+ ACE_OFF_T start,
+ ACE_OFF_T len)
{
// ACE_TRACE ("ACE_File_Lock::tryacquire_write_upgrade");
return ACE_OS::flock_trywrlock (&this->lock_, whence, start, len);
}
ACE_INLINE int
-ACE_File_Lock::tryacquire (short whence, off_t start, off_t len)
+ACE_File_Lock::tryacquire (short whence, ACE_OFF_T start, ACE_OFF_T len)
{
// ACE_TRACE ("ACE_File_Lock::tryacquire");
return this->tryacquire_write (whence, start, len);
}
ACE_INLINE int
-ACE_File_Lock::acquire_write (short whence, off_t start, off_t len)
+ACE_File_Lock::acquire_write (short whence, ACE_OFF_T start, ACE_OFF_T len)
{
// ACE_TRACE ("ACE_File_Lock::acquire_write");
return ACE_OS::flock_wrlock (&this->lock_, whence, start, len);
}
ACE_INLINE int
-ACE_File_Lock::acquire (short whence, off_t start, off_t len)
+ACE_File_Lock::acquire (short whence, ACE_OFF_T start, ACE_OFF_T len)
{
// ACE_TRACE ("ACE_File_Lock::acquire");
return this->acquire_write (whence, start, len);
}
ACE_INLINE int
-ACE_File_Lock::release (short whence, off_t start, off_t len)
+ACE_File_Lock::release (short whence, ACE_OFF_T start, ACE_OFF_T len)
{
// ACE_TRACE ("ACE_File_Lock::release");
return ACE_OS::flock_unlock (&this->lock_, whence, start, len);
diff --git a/ACE/ace/Filecache.cpp b/ACE/ace/Filecache.cpp
index 57239e7391d..1057328762a 100644
--- a/ACE/ace/Filecache.cpp
+++ b/ACE/ace/Filecache.cpp
@@ -9,6 +9,7 @@
#include "ace/OS_NS_time.h"
#include "ace/OS_NS_unistd.h"
#include "ace/OS_NS_fcntl.h"
+#include "ace/Truncate.h"
ACE_RCSID (ace,
Filecache,
@@ -130,7 +131,7 @@ ACE_Filecache_Handle::error (void) const
return this->file_->error ();
}
-ACE_LOFF_T
+ACE_OFF_T
ACE_Filecache_Handle::size (void) const
{
if (this->file_ == 0)
@@ -523,7 +524,7 @@ ACE_Filecache_Object::ACE_Filecache_Object (const ACE_TCHAR *filename,
return;
}
- this->size_ = this->stat_.st_size;
+ this->size_ = ACE_Utils::Truncate<ACE_OFF_T> (this->stat_.st_size);
this->tempname_ = this->filename_;
// Can we open the file?
@@ -555,7 +556,7 @@ ACE_Filecache_Object::ACE_Filecache_Object (const ACE_TCHAR *filename,
}
ACE_Filecache_Object::ACE_Filecache_Object (const ACE_TCHAR *filename,
- off_t size,
+ ACE_OFF_T size,
ACE_SYNCH_RW_MUTEX &lock,
LPSECURITY_ATTRIBUTES sa)
: stale_ (0),
@@ -706,7 +707,7 @@ ACE_Filecache_Object::filename (void) const
return this->filename_;
}
-ACE_LOFF_T
+ACE_OFF_T
ACE_Filecache_Object::size (void) const
{
// The existence of the object means a read lock is being held.
diff --git a/ACE/ace/Filecache.h b/ACE/ace/Filecache.h
index d0cfd0556cc..24c220b4f24 100644
--- a/ACE/ace/Filecache.h
+++ b/ACE/ace/Filecache.h
@@ -117,7 +117,7 @@ public:
int error (void) const;
/// The size of the file.
- ACE_LOFF_T size (void) const;
+ ACE_OFF_T size (void) const;
protected:
/// Default do nothing constructor. Prevent it from being called.
@@ -215,7 +215,7 @@ protected:
ACE_Filecache (void);
private:
- int size_;
+ ACE_OFF_T size_;
/// The hash table
ACE_Filecache_Hash hash_;
@@ -249,7 +249,7 @@ public:
/// Creates a file for writing.
ACE_Filecache_Object (const ACE_TCHAR *filename,
- off_t size,
+ ACE_OFF_T size,
ACE_SYNCH_RW_MUTEX &lock,
LPSECURITY_ATTRIBUTES sa = 0);
@@ -277,7 +277,7 @@ public:
void *address (void) const;
/// size_ accessor.
- ACE_LOFF_T size (void) const;
+ ACE_OFF_T size (void) const;
/// True if file on disk is newer than cached file.
int update (void) const;
@@ -327,7 +327,7 @@ private:
/// Used to compare against the real file to test if an update is needed.
ACE_stat stat_;
- ACE_LOFF_T size_;
+ ACE_OFF_T size_;
/// Status indicators.
int action_;
diff --git a/ACE/ace/Local_Memory_Pool.cpp b/ACE/ace/Local_Memory_Pool.cpp
index 96a647ed6fd..10692afde86 100644
--- a/ACE/ace/Local_Memory_Pool.cpp
+++ b/ACE/ace/Local_Memory_Pool.cpp
@@ -138,7 +138,7 @@ size_t
ACE_Local_Memory_Pool::round_up (size_t nbytes)
{
ACE_TRACE ("ACE_Local_Memory_Pool::round_up");
- return ACE::round_to_pagesize (static_cast<off_t> (nbytes));
+ return ACE::round_to_pagesize (nbytes);
}
ACE_END_VERSIONED_NAMESPACE_DECL
diff --git a/ACE/ace/MEM_Acceptor.h b/ACE/ace/MEM_Acceptor.h
index 87b90f2da92..4a57b7528ff 100644
--- a/ACE/ace/MEM_Acceptor.h
+++ b/ACE/ace/MEM_Acceptor.h
@@ -108,7 +108,7 @@ public:
* Change the initial MMAP buffer size (in bytes) of the MEM_Stream
* this MEM_Acceptor creates.
*/
- void init_buffer_size (off_t bytes);
+ void init_buffer_size (ACE_OFF_T bytes);
/// Get the preferred signaling strategy.
ACE_MEM_IO::Signal_Strategy preferred_strategy (void) const;
diff --git a/ACE/ace/MEM_Acceptor.inl b/ACE/ace/MEM_Acceptor.inl
index 388e1541cdf..c06cdaaee4a 100644
--- a/ACE/ace/MEM_Acceptor.inl
+++ b/ACE/ace/MEM_Acceptor.inl
@@ -86,7 +86,7 @@ ACE_MEM_Acceptor::preferred_strategy (ACE_MEM_IO::Signal_Strategy strategy)
}
ACE_INLINE void
-ACE_MEM_Acceptor::init_buffer_size (off_t bytes)
+ACE_MEM_Acceptor::init_buffer_size (ACE_OFF_T bytes)
{
this->malloc_options_.minimum_bytes_ = bytes;
}
diff --git a/ACE/ace/MEM_IO.cpp b/ACE/ace/MEM_IO.cpp
index 7a9616f5220..96001b954c0 100644
--- a/ACE/ace/MEM_IO.cpp
+++ b/ACE/ace/MEM_IO.cpp
@@ -41,10 +41,10 @@ ACE_Reactive_MEM_IO::recv_buf (ACE_MEM_SAP_Node *&buf,
if (this->shm_malloc_ == 0 || this->handle_ == ACE_INVALID_HANDLE)
return -1;
- off_t new_offset = 0;
+ ACE_OFF_T new_offset = 0;
ssize_t retv = ACE::recv (this->handle_,
(char *) &new_offset,
- sizeof (off_t),
+ sizeof (ACE_OFF_T),
flags,
timeout);
@@ -54,7 +54,7 @@ ACE_Reactive_MEM_IO::recv_buf (ACE_MEM_SAP_Node *&buf,
buf = 0;
return 0;
}
- else if (retv != sizeof (off_t))
+ else if (retv != sizeof (ACE_OFF_T))
{
// Nothing available or we are really screwed.
buf = 0;
@@ -74,7 +74,7 @@ ACE_Reactive_MEM_IO::send_buf (ACE_MEM_SAP_Node *buf,
if (this->shm_malloc_ == 0 || this->handle_ == ACE_INVALID_HANDLE)
return -1;
- off_t offset = reinterpret_cast<char *> (buf) -
+ ACE_OFF_T offset = reinterpret_cast<char *> (buf) -
static_cast<char *> (this->shm_malloc_->base_addr ()); // the offset.
// Send the offset value over the socket.
if (ACE::send (this->handle_,
diff --git a/ACE/ace/MEM_IO.h b/ACE/ace/MEM_IO.h
index 2b1ae570261..f294de2a94d 100644
--- a/ACE/ace/MEM_IO.h
+++ b/ACE/ace/MEM_IO.h
@@ -71,7 +71,7 @@ public:
* Return the size of valid information containing in the <buf>,
* -1 if <shm_malloc_> is not initialized.
*/
- ssize_t get_buf_len (const off_t off, ACE_MEM_SAP_Node *&buf);
+ ssize_t get_buf_len (const ACE_OFF_T off, ACE_MEM_SAP_Node *&buf);
};
#if defined (ACE_WIN32) || !defined (_ACE_USE_SV_SEM)
diff --git a/ACE/ace/MEM_IO.inl b/ACE/ace/MEM_IO.inl
index 07f13764e94..505c90c628c 100644
--- a/ACE/ace/MEM_IO.inl
+++ b/ACE/ace/MEM_IO.inl
@@ -48,7 +48,7 @@ ACE_MT_MEM_IO::Simple_Queue::init (MQ_Struct *mq,
#endif /* ACE_WIN32 || !_ACE_USE_SV_SEM */
ACE_INLINE ssize_t
-ACE_Reactive_MEM_IO::get_buf_len (const off_t off, ACE_MEM_SAP_Node *&buf)
+ACE_Reactive_MEM_IO::get_buf_len (const ACE_OFF_T off, ACE_MEM_SAP_Node *&buf)
{
#if !defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS)
ACE_TRACE ("ACE_Reactive_MEM_IO::get_buf_len");
diff --git a/ACE/ace/MMAP_Memory_Pool.cpp b/ACE/ace/MMAP_Memory_Pool.cpp
index a33097e7403..2be726393e4 100644
--- a/ACE/ace/MMAP_Memory_Pool.cpp
+++ b/ACE/ace/MMAP_Memory_Pool.cpp
@@ -7,6 +7,7 @@
#include "ace/OS_NS_string.h"
#include "ace/OS_NS_sys_stat.h"
#include "ace/Log_Msg.h"
+#include "ace/Truncate.h"
#if (ACE_HAS_POSITION_INDEPENDENT_POINTERS == 1)
#include "ace/Based_Pointer_T.h"
@@ -50,12 +51,20 @@ ACE_MMAP_Memory_Pool::release (int destroy)
}
int
-ACE_MMAP_Memory_Pool::sync (ssize_t len, int flags)
+ACE_MMAP_Memory_Pool::sync (size_t len, int flags)
{
ACE_TRACE ("ACE_MMAP_Memory_Pool::sync");
- if (len < 0)
- len = ACE_OS::lseek (this->mmap_.handle (), 0, SEEK_END);
+ return this->mmap_.sync (len, flags);
+}
+
+int
+ACE_MMAP_Memory_Pool::sync (int flags)
+{
+ ACE_TRACE ("ACE_MMAP_Memory_Pool::sync");
+
+ size_t const len = ACE_Utils::Truncate<size_t> (
+ ACE_OS::lseek (this->mmap_.handle (), 0, SEEK_END));
return this->mmap_.sync (len, flags);
}
@@ -71,20 +80,29 @@ ACE_MMAP_Memory_Pool::sync (void *addr, size_t len, int flags)
}
// Change the protection of the pages of the mapped region to <prot>
-// starting at <this->base_addr_> up to <len> bytes. If <len> == -1
-// then change protection of all pages in the mapped region.
+// starting at <this->base_addr_> up to <len> bytes.
+// Change protection of all pages in the mapped region.
int
-ACE_MMAP_Memory_Pool::protect (ssize_t len, int prot)
+ACE_MMAP_Memory_Pool::protect (size_t len, int prot)
{
ACE_TRACE ("ACE_MMAP_Memory_Pool::protect");
- if (len < 0)
- len = ACE_OS::lseek (this->mmap_.handle (), 0, SEEK_END);
+ return this->mmap_.protect (len, prot);
+}
+
+int
+ACE_MMAP_Memory_Pool::protect (int prot)
+{
+ ACE_TRACE ("ACE_MMAP_Memory_Pool::protect");
+
+ size_t const len = ACE_Utils::Truncate<size_t> (
+ ACE_OS::lseek (this->mmap_.handle (), 0, SEEK_END));
return this->mmap_.protect (len, prot);
}
+
// Change the protection of the pages of the mapped region to <prot>
// starting at <addr> up to <len> bytes.
@@ -188,7 +206,7 @@ ACE_MMAP_Memory_Pool::~ACE_MMAP_Memory_Pool (void)
// memory.
int
ACE_MMAP_Memory_Pool::commit_backing_store_name (size_t rounded_bytes,
- ACE_LOFF_T &map_size)
+ size_t & map_size)
{
ACE_TRACE ("ACE_MMAP_Memory_Pool::commit_backing_store_name");
@@ -210,11 +228,13 @@ ACE_MMAP_Memory_Pool::commit_backing_store_name (size_t rounded_bytes,
cur_block < rounded_bytes;
cur_block += seek_len)
{
- map_size = ACE_OS::lseek (this->mmap_.handle (),
- static_cast<off_t> (seek_len - 1),
- SEEK_END);
+ map_size =
+ ACE_Utils::Truncate<size_t> (
+ ACE_OS::lseek (this->mmap_.handle (),
+ static_cast<ACE_OFF_T> (seek_len - 1),
+ SEEK_END));
- if (map_size == -1
+ if (map_size == static_cast<size_t> (-1)
|| ACE_OS::write (this->mmap_.handle (),
"",
1) == -1)
@@ -237,7 +257,7 @@ ACE_MMAP_Memory_Pool::commit_backing_store_name (size_t rounded_bytes,
// Memory map the file up to <map_size> bytes.
int
-ACE_MMAP_Memory_Pool::map_file (ACE_LOFF_T map_size)
+ACE_MMAP_Memory_Pool::map_file (size_t map_size)
{
ACE_TRACE ("ACE_MMAP_Memory_Pool::map_file");
#if (ACE_HAS_POSITION_INDEPENDENT_POINTERS == 1)
@@ -303,7 +323,7 @@ ACE_MMAP_Memory_Pool::acquire (size_t nbytes,
// ACE_DEBUG ((LM_DEBUG, "(%P|%t) acquiring more chunks, nbytes =
// %d, rounded_bytes = %d\n", nbytes, rounded_bytes));
- ACE_LOFF_T map_size;
+ size_t map_size;
if (this->commit_backing_store_name (rounded_bytes,
map_size) == -1)
@@ -345,7 +365,7 @@ ACE_MMAP_Memory_Pool::init_acquire (size_t nbytes,
errno = 0;
// Reopen file *without* using O_EXCL...
if (this->mmap_.map (this->backing_store_name_,
- -1,
+ static_cast<size_t> (-1),
O_RDWR,
this->file_mode_,
PROT_RDWR,
@@ -397,7 +417,8 @@ ACE_MMAP_Memory_Pool::remap (void *addr)
{
ACE_TRACE ("ACE_MMAP_Memory_Pool::remap");
// ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("Remapping with fault address at: %X\n"), addr));
- off_t const current_map_size = ACE_OS::filesize (this->mmap_.handle ());
+ size_t const current_map_size =
+ ACE_Utils::Truncate<size_t> (ACE_OS::filesize (this->mmap_.handle ()));
// ACE_OS::lseek (this->mmap_.handle (), 0, SEEK_END);
if (!(addr < (void *) ((char *) this->mmap_.addr () + current_map_size)
@@ -408,15 +429,16 @@ ACE_MMAP_Memory_Pool::remap (void *addr)
return this->map_file (current_map_size);
}
-ACE_MMAP_Memory_Pool_Options::ACE_MMAP_Memory_Pool_Options (const void *base_addr,
- int use_fixed_addr,
- int write_each_page,
- ACE_LOFF_T minimum_bytes,
- u_int flags,
- int guess_on_fault,
- LPSECURITY_ATTRIBUTES sa,
- mode_t file_mode,
- bool unique)
+ACE_MMAP_Memory_Pool_Options::ACE_MMAP_Memory_Pool_Options (
+ const void *base_addr,
+ int use_fixed_addr,
+ int write_each_page,
+ size_t minimum_bytes,
+ u_int flags,
+ int guess_on_fault,
+ LPSECURITY_ATTRIBUTES sa,
+ mode_t file_mode,
+ bool unique)
: base_addr_ (base_addr),
use_fixed_addr_ (use_fixed_addr),
write_each_page_ (write_each_page),
@@ -478,7 +500,8 @@ ACE_MMAP_Memory_Pool::handle_signal (int signum, siginfo_t *siginfo, ucontext_t
if (guess_on_fault_)
{
// Check if the current mapping is up to date.
- ACE_LOFF_T const current_map_size = ACE_OS::filesize (this->mmap_.handle ());
+ size_t const current_map_size =
+ ACE_Utils::Truncate<size_t> (ACE_OS::filesize (this->mmap_.handle ()));
if (static_cast<size_t> (current_map_size) == this->mmap_.size ())
{
@@ -508,7 +531,7 @@ size_t
ACE_MMAP_Memory_Pool::round_up (size_t nbytes)
{
ACE_TRACE ("ACE_MMAP_Memory_Pool::round_up");
- return ACE::round_to_pagesize (static_cast<off_t> (nbytes));
+ return ACE::round_to_pagesize (nbytes);
}
ACE_ALLOC_HOOK_DEFINE(ACE_Lite_MMAP_Memory_Pool)
@@ -525,7 +548,14 @@ ACE_Lite_MMAP_Memory_Pool::~ACE_Lite_MMAP_Memory_Pool (void)
}
int
-ACE_Lite_MMAP_Memory_Pool::sync (ssize_t, int)
+ACE_Lite_MMAP_Memory_Pool::sync (size_t, int)
+{
+ ACE_TRACE ("ACE_Lite_MMAP_Memory_Pool::sync");
+ return 0;
+}
+
+int
+ACE_Lite_MMAP_Memory_Pool::sync (int)
{
ACE_TRACE ("ACE_Lite_MMAP_Memory_Pool::sync");
return 0;
diff --git a/ACE/ace/MMAP_Memory_Pool.h b/ACE/ace/MMAP_Memory_Pool.h
index 0b8dffcc83c..5b9cc3f3186 100644
--- a/ACE/ace/MMAP_Memory_Pool.h
+++ b/ACE/ace/MMAP_Memory_Pool.h
@@ -67,7 +67,7 @@ public:
ACE_MMAP_Memory_Pool_Options (const void *base_addr = ACE_DEFAULT_BASE_ADDR,
int use_fixed_addr = ALWAYS_FIXED,
int write_each_page = 1,
- ACE_LOFF_T minimum_bytes = 0,
+ size_t minimum_bytes = 0,
u_int flags = 0,
int guess_on_fault = 1,
LPSECURITY_ATTRIBUTES sa = 0,
@@ -96,7 +96,7 @@ public:
int write_each_page_;
/// What the minimim bytes of the initial segment should be.
- ACE_LOFF_T minimum_bytes_;
+ size_t minimum_bytes_;
/// Any special flags that need to be used for @c mmap.
u_int flags_;
@@ -162,8 +162,13 @@ public:
/// Sync the memory region to the backing store starting at
/// @c this->base_addr_.
- virtual int sync (ssize_t len = -1, int flags = MS_SYNC);
+ virtual int sync (size_t len, int flags = MS_SYNC);
+ /// Sync the memory region to the backing store starting at
+ /// @c this->base_addr_. Will sync as much as the backing file
+ /// allows.
+ virtual int sync (int flags = MS_SYNC);
+
/// Sync the memory region to the backing store starting at @a addr.
virtual int sync (void *addr, size_t len, int flags = MS_SYNC);
@@ -172,7 +177,13 @@ public:
* starting at <this->base_addr_> up to <len> bytes. If <len> == -1
* then change protection of all pages in the mapped region.
*/
- virtual int protect (ssize_t len = -1, int prot = PROT_RDWR);
+ virtual int protect (size_t len, int prot = PROT_RDWR);
+
+ /**
+ * Change the protection of all the pages of the mapped region to <prot>
+ * starting at <this->base_addr_>.
+ */
+ virtual int protect (int prot = PROT_RDWR);
/// Change the protection of the pages of the mapped region to @a prot
/// starting at @a addr up to @a len bytes.
@@ -222,10 +233,10 @@ protected:
/// Compute the new @a map_size of the backing store and commit the
/// memory.
virtual int commit_backing_store_name (size_t rounded_bytes,
- ACE_LOFF_T &map_size);
+ size_t & map_size);
/// Memory map the file up to @a map_size bytes.
- virtual int map_file (ACE_LOFF_T map_size);
+ virtual int map_file (size_t map_size);
/// Handle SIGSEGV and SIGBUS signals to remap shared memory
/// properly.
@@ -255,7 +266,7 @@ protected:
int write_each_page_;
/// What the minimum bytes of the initial segment should be.
- ACE_LOFF_T minimum_bytes_;
+ size_t minimum_bytes_;
/// Name of the backing store where the shared memory pool is kept.
ACE_TCHAR backing_store_name_[MAXPATHLEN + 1];
@@ -297,7 +308,10 @@ public:
virtual ~ACE_Lite_MMAP_Memory_Pool (void);
/// Overwrite the default sync behavior with no-op
- virtual int sync (ssize_t len = -1, int flags = MS_SYNC);
+ virtual int sync (size_t len, int flags = MS_SYNC);
+
+ /// Overwrite the default sync behavior with no-op
+ virtual int sync (int flags = MS_SYNC);
/// Overwrite the default sync behavior with no-op
virtual int sync (void *addr, size_t len, int flags = MS_SYNC);
diff --git a/ACE/ace/Mem_Map.cpp b/ACE/ace/Mem_Map.cpp
index f22f7279bf5..d2bc4102ce6 100644
--- a/ACE/ace/Mem_Map.cpp
+++ b/ACE/ace/Mem_Map.cpp
@@ -11,6 +11,7 @@
#include "ace/OS_NS_fcntl.h"
#include "ace/OS_NS_string.h"
#include "ace/Log_Msg.h"
+#include "ace/Truncate.h"
#if defined (ACE_WIN32) \
&& (!defined(ACE_HAS_WINNT4) || (ACE_HAS_WINNT4 == 0))
@@ -95,11 +96,11 @@ ACE_Mem_Map::~ACE_Mem_Map (void)
int
ACE_Mem_Map::map_it (ACE_HANDLE handle,
- ssize_t length_request,
+ size_t length_request,
int prot,
int share,
void *addr,
- off_t offset,
+ ACE_OFF_T offset,
LPSECURITY_ATTRIBUTES sa)
{
ACE_TRACE ("ACE_Mem_Map::map_it");
@@ -115,25 +116,31 @@ ACE_Mem_Map::map_it (ACE_HANDLE handle,
this->base_addr_ = addr;
this->handle_ = handle;
- ACE_LOFF_T const result = ACE_OS::filesize (this->handle_);
+ ACE_OFF_T const result = ACE_OS::filesize (this->handle_);
// At this point we know <result> is not negative...
- size_t const current_file_length = static_cast<size_t> (result);
+ ACE_OFF_T const current_file_length = result;
// Flag to indicate if we need to extend the back store
bool extend_backing_store = false;
// File length requested by user
- size_t requested_file_length = 0;
+ ACE_OFF_T requested_file_length = 0;
// Check <length_request>
- if (length_request == -1)
- // Set length to file_request.
- this->length_ = current_file_length - offset;
+ if (length_request == static_cast<size_t> (-1))
+ // Set length to file_request or size_t max.
+ this->length_ = ACE_Utils::Truncate<size_t> (current_file_length - offset);
else
- {
+ {
+ // Make sure that we have not been asked to do the impossible.
+ if (static_cast<ACE_UINT64> (length_request)
+ + static_cast<ACE_UINT64> (offset)
+ > static_cast<ACE_UINT64> (ACE_Numeric_Limits<ACE_OFF_T>::max ()))
+ return -1;
+
// File length implicitly requested by user
- requested_file_length = length_request + offset;
+ requested_file_length = static_cast<ACE_OFF_T> (length_request) + offset;
// Check to see if we need to extend the backing store
if (requested_file_length > current_file_length)
@@ -156,11 +163,10 @@ ACE_Mem_Map::map_it (ACE_HANDLE handle,
if (extend_backing_store)
{
// Remember than write increases the size by one.
- off_t null_byte_position;
+ ACE_OFF_T null_byte_position;
if (requested_file_length > 0)
// This will make the file size <requested_file_length>
- null_byte_position =
- static_cast<off_t> (requested_file_length - 1);
+ null_byte_position = requested_file_length - 1;
else
// This will make the file size 1
null_byte_position = 0;
@@ -240,13 +246,13 @@ ACE_Mem_Map::open (const ACE_TCHAR *file_name,
int
ACE_Mem_Map::map (const ACE_TCHAR *file_name,
- ssize_t len,
+ size_t len,
int flags,
int mode,
int prot,
int share,
void *addr,
- off_t offset,
+ ACE_OFF_T offset,
LPSECURITY_ATTRIBUTES sa)
{
ACE_TRACE ("ACE_Mem_Map::map");
@@ -281,13 +287,13 @@ ACE_Mem_Map::ACE_Mem_Map (void)
// Map a file specified by FILE_NAME.
ACE_Mem_Map::ACE_Mem_Map (const ACE_TCHAR *file_name,
- ssize_t len,
+ size_t len,
int flags,
int mode,
int prot,
int share,
void *addr,
- off_t offset,
+ ACE_OFF_T offset,
LPSECURITY_ATTRIBUTES sa)
: base_addr_ (MAP_FAILED),
length_ (0),
@@ -314,11 +320,11 @@ ACE_Mem_Map::ACE_Mem_Map (const ACE_TCHAR *file_name,
// lookup the length of the file if it is not given.
ACE_Mem_Map::ACE_Mem_Map (ACE_HANDLE handle,
- ssize_t len,
+ size_t len,
int prot,
int share,
void *addr,
- off_t offset,
+ ACE_OFF_T offset,
LPSECURITY_ATTRIBUTES sa)
: base_addr_ (MAP_FAILED),
length_ (0),
diff --git a/ACE/ace/Mem_Map.h b/ACE/ace/Mem_Map.h
index e817a1dde5e..847568fb53e 100644
--- a/ACE/ace/Mem_Map.h
+++ b/ACE/ace/Mem_Map.h
@@ -48,51 +48,51 @@ public:
/// Map a file from an open file descriptor @a handle. This function
/// will lookup the length of the file if it is not given.
ACE_Mem_Map (ACE_HANDLE handle,
- ssize_t length = -1,
+ size_t length = static_cast<size_t> (-1),
int prot = PROT_RDWR,
int share = ACE_MAP_PRIVATE,
void *addr = 0,
- off_t offset = 0,
+ ACE_OFF_T offset = 0,
LPSECURITY_ATTRIBUTES sa = 0);
/// Map a file specified by @a file_name.
ACE_Mem_Map (const ACE_TCHAR *filename,
- ssize_t length = -1,
+ size_t length = static_cast<size_t> (-1),
int flags = O_RDWR | O_CREAT,
int mode = ACE_DEFAULT_FILE_PERMS,
int prot = PROT_RDWR,
int share = ACE_MAP_PRIVATE,
void *addr = 0,
- off_t offset = 0,
+ ACE_OFF_T offset = 0,
LPSECURITY_ATTRIBUTES sa = 0);
/// Map a file from an open file descriptor @a handle. This function
/// will lookup the length of the file if it is not given.
int map (ACE_HANDLE handle,
- ssize_t length = -1,
+ size_t length = static_cast<size_t> (-1),
int prot = PROT_RDWR,
int share = ACE_MAP_PRIVATE,
void *addr = 0,
- off_t offset = 0,
+ ACE_OFF_T offset = 0,
LPSECURITY_ATTRIBUTES sa = 0);
/// Remap the file associated with <handle_>.
- int map (ssize_t length = -1,
+ int map (size_t length = static_cast<size_t> (-1),
int prot = PROT_RDWR,
int share = ACE_MAP_PRIVATE,
void *addr = 0,
- off_t offset = 0,
+ ACE_OFF_T offset = 0,
LPSECURITY_ATTRIBUTES sa = 0);
/// Map a file specified by <filename>.
int map (const ACE_TCHAR *filename,
- ssize_t length = -1,
+ size_t length = static_cast<size_t> (-1),
int flags = O_RDWR | O_CREAT,
int mode = ACE_DEFAULT_FILE_PERMS,
int prot = PROT_RDWR,
int share = ACE_MAP_PRIVATE,
void *addr = 0,
- off_t offset = 0,
+ ACE_OFF_T offset = 0,
LPSECURITY_ATTRIBUTES sa = 0);
/// Destructor.
@@ -139,7 +139,13 @@ public:
* starting at <base_addr_>. If <len> == -1 then sync the whole
* region.
*/
- int sync (ssize_t len = -1, int flags = MS_SYNC);
+ int sync (size_t len, int flags = MS_SYNC);
+
+ /**
+ * Sync the whole memory region to the backing store
+ * starting at <base_addr_>.
+ */
+ int sync (int flags = MS_SYNC);
/// Sync <len> bytes of the memory region to the backing store
/// starting at <addr_>.
@@ -147,10 +153,15 @@ public:
/**
* Change the protection of the pages of the mapped region to <prot>
- * starting at <base_addr_> up to <len> bytes. If <len> == -1 then
- * change protection of all pages in the mapped region.
+ * starting at <base_addr_> up to <len> bytes.
+ */
+ int protect (size_t len, int prot = PROT_RDWR);
+
+ /**
+ * Change the protection of all the pages of the mapped region to <prot>
+ * starting at <base_addr_>.
*/
- int protect (ssize_t len = -1, int prot = PROT_RDWR);
+ int protect (int prot = PROT_RDWR);
/// Change the protection of the pages of the mapped region to <prot>
/// starting at <addr> up to <len> bytes.
@@ -179,11 +190,11 @@ private:
/// This method does the dirty work of actually calling ::mmap to map
/// the file into memory.
int map_it (ACE_HANDLE handle,
- ssize_t len = -1,
+ size_t len = static_cast<size_t> (-1),
int prot = PROT_RDWR,
int share = MAP_SHARED,
void *addr = 0,
- off_t offset = 0,
+ ACE_OFF_T offset = 0,
LPSECURITY_ATTRIBUTES sa = 0);
// = Disallow copying and assignment.
diff --git a/ACE/ace/Mem_Map.inl b/ACE/ace/Mem_Map.inl
index b1889f8baf2..78a99646a88 100644
--- a/ACE/ace/Mem_Map.inl
+++ b/ACE/ace/Mem_Map.inl
@@ -25,11 +25,11 @@ ACE_Mem_Map::filename (void) const
ACE_INLINE int
ACE_Mem_Map::map (ACE_HANDLE handle,
- ssize_t length,
+ size_t length,
int prot,
int share,
void *addr,
- off_t offset,
+ ACE_OFF_T offset,
LPSECURITY_ATTRIBUTES sa)
{
ACE_TRACE ("ACE_Mem_Map::map");
@@ -39,11 +39,11 @@ ACE_Mem_Map::map (ACE_HANDLE handle,
// Remap the file associated with <this->handle_>.
ACE_INLINE int
-ACE_Mem_Map::map (ssize_t length,
+ACE_Mem_Map::map (size_t length,
int prot,
int share,
void *addr,
- off_t offset,
+ ACE_OFF_T offset,
LPSECURITY_ATTRIBUTES sa)
{
ACE_TRACE ("ACE_Mem_Map::map");
@@ -144,15 +144,24 @@ ACE_Mem_Map::unmap (void *addr, ssize_t len)
}
// Sync <len> bytes of the memory region to the backing store starting
-// at <this->base_addr_>. If <len> == -1 then sync the whole mapped
-// region.
+// at <this->base_addr_>.
ACE_INLINE int
-ACE_Mem_Map::sync (ssize_t len, int flags)
+ACE_Mem_Map::sync (size_t len, int flags)
{
ACE_TRACE ("ACE_Mem_Map::sync");
return ACE_OS::msync (this->base_addr_,
- len < 0 ? this->length_ : len,
+ len,
+ flags);
+}
+
+// Sync the whole mapped region.
+ACE_INLINE int
+ACE_Mem_Map::sync (int flags)
+{
+ ACE_TRACE ("ACE_Mem_Map::sync");
+ return ACE_OS::msync (this->base_addr_,
+ this->length_,
flags);
}
@@ -167,18 +176,26 @@ ACE_Mem_Map::sync (void *addr, size_t len, int flags)
}
// Change the protection of the pages of the mapped region to <prot>
-// starting at <this->base_addr_> up to <len> bytes. If <len> == -1
-// then change protection of all pages in the mapped region.
+// starting at <this->base_addr_> up to <len> bytes.
ACE_INLINE int
-ACE_Mem_Map::protect (ssize_t len, int prot)
+ACE_Mem_Map::protect (size_t len, int prot)
{
ACE_TRACE ("ACE_Mem_Map::protect");
- if (len < 0)
- len = this->length_;
return ACE_OS::mprotect (this->base_addr_, len, prot);
}
+
+// Change the protection of all the pages of the mapped region to <prot>
+// starting at <this->base_addr_>.
+
+ACE_INLINE int
+ACE_Mem_Map::protect (int prot)
+{
+ ACE_TRACE ("ACE_Mem_Map::protect");
+ return ACE_OS::mprotect (this->base_addr_, this->length_, prot);
+}
+
// Change the protection of the pages of the mapped region to <prot>
// starting at <addr> up to <len> bytes.
diff --git a/ACE/ace/OS_NS_macros.h b/ACE/ace/OS_NS_macros.h
index 02a4aa334bd..8f47d150679 100644
--- a/ACE/ace/OS_NS_macros.h
+++ b/ACE/ace/OS_NS_macros.h
@@ -69,6 +69,46 @@
#endif /* !ACE_WIN32 */
+// Helper functions to split large intergers into smaller high-order
+// and low-order parts, and reconstitute them again. These are
+// required primarily for supporting _FILE_OFFSET_BITS==64 on windows.
+
+#if defined(ACE_WIN32)
+# if defined(_FILE_OFFSET_BITS) && (_FILE_OFFSET_BITS==64)
+# include "ace/Basic_Types.h"
+
+# define ACE_LOW_PART(X) static_cast<DWORD>(X)
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+LONG
+inline ACE_High_Part (ACE_OFF_T value)
+{
+ LARGE_INTEGER new_value;
+ new_value.QuadPart = value;
+ return new_value.HighPart;
+}
+# define ACE_HIGH_PART(X) ACE_High_Part(X)
+
+LONGLONG
+inline ACE_Combine_Parts (LONG high, DWORD low)
+{
+ LARGE_INTEGER value;
+ value.LowPart = low; // DWORD
+ value.HighPart = high; // LONG
+ return value.QuadPart;
+}
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+# define ACE_COMBINE_PARTS(X,Y) ACE_Combine_Parts(X,Y)
+# else /* _FILE_OFFSET_BITS==64 */
+# define ACE_LOW_PART(X) X
+# define ACE_HIGH_PART(X) 0
+# define ACE_COMBINE_PARTS(X,Y) X
+# endif /* _FILE_OFFSET_BITS==64 */
+#endif /* ACE_WIN32 */
+
+
+
# include /**/ "ace/post.h"
#endif /* ACE_OS_NS_MACROS_H */
diff --git a/ACE/ace/OS_NS_stdio.cpp b/ACE/ace/OS_NS_stdio.cpp
index df92196644b..c428ab2f762 100644
--- a/ACE/ace/OS_NS_stdio.cpp
+++ b/ACE/ace/OS_NS_stdio.cpp
@@ -112,6 +112,54 @@ void ACE_OS::checkUnicodeFormat (FILE* fp)
#endif // ACE_USES_WCHAR
#if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)
+namespace
+{
+ /// Translate fopen's mode char to open's mode. This helper function
+ /// is here to avoid maintaining several pieces of identical code.
+ void
+ fopen_mode_to_open_mode_converter (ACE_TCHAR x, int & hmode)
+ {
+ switch (x)
+ {
+ case ACE_LIB_TEXT ('r'):
+ if (ACE_BIT_DISABLED (hmode, _O_RDWR))
+ {
+ ACE_CLR_BITS (hmode, _O_WRONLY);
+ ACE_SET_BITS (hmode, _O_RDONLY);
+ }
+ break;
+ case ACE_LIB_TEXT ('w'):
+ if (ACE_BIT_DISABLED (hmode, _O_RDWR))
+ {
+ ACE_CLR_BITS (hmode, _O_RDONLY);
+ ACE_SET_BITS (hmode, _O_WRONLY);
+ }
+ ACE_SET_BITS (hmode, _O_CREAT | _O_TRUNC);
+ break;
+ case ACE_LIB_TEXT ('a'):
+ if (ACE_BIT_DISABLED (hmode, _O_RDWR))
+ {
+ ACE_CLR_BITS (hmode, _O_RDONLY);
+ ACE_SET_BITS (hmode, _O_WRONLY);
+ }
+ ACE_SET_BITS (hmode, _O_CREAT | _O_APPEND);
+ break;
+ case ACE_LIB_TEXT ('+'):
+ ACE_CLR_BITS (hmode, _O_RDONLY | _O_WRONLY);
+ ACE_SET_BITS (hmode, _O_RDWR);
+ break;
+ case ACE_LIB_TEXT ('t'):
+ ACE_CLR_BITS (hmode, _O_BINARY);
+ ACE_SET_BITS (hmode, _O_TEXT);
+ break;
+ case ACE_LIB_TEXT ('b'):
+ ACE_CLR_BITS (hmode, _O_TEXT);
+ ACE_SET_BITS (hmode, _O_BINARY);
+ break;
+ }
+ }
+} // Close anonymous namespace
+
FILE *
ACE_OS::fopen (const char *filename,
const ACE_TCHAR *mode)
@@ -127,7 +175,7 @@ ACE_OS::fopen (const char *filename,
mode = empty_mode;
for (ACE_TCHAR const* mode_ptr = mode; *mode_ptr != 0; ++mode_ptr)
- ACE_OS::fopen_mode_to_open_mode_converter (*mode_ptr, hmode);
+ fopen_mode_to_open_mode_converter (*mode_ptr, hmode);
ACE_HANDLE const handle = ACE_OS::open (filename, hmode);
if (handle != ACE_INVALID_HANDLE)
@@ -171,7 +219,7 @@ ACE_OS::fopen (const wchar_t *filename,
int hmode = _O_TEXT;
for (const ACE_TCHAR *mode_ptr = mode; *mode_ptr != 0; mode_ptr++)
- ACE_OS::fopen_mode_to_open_mode_converter (*mode_ptr, hmode);
+ fopen_mode_to_open_mode_converter (*mode_ptr, hmode);
ACE_HANDLE handle = ACE_OS::open (filename, hmode);
if (handle != ACE_INVALID_HANDLE)
diff --git a/ACE/ace/OS_NS_stdio.h b/ACE/ace/OS_NS_stdio.h
index 86366e0948f..bc3e5569fcf 100644
--- a/ACE/ace/OS_NS_stdio.h
+++ b/ACE/ace/OS_NS_stdio.h
@@ -86,8 +86,8 @@ struct flock
{
short l_type;
short l_whence;
- off_t l_start;
- off_t l_len; /* len == 0 means until end of file */
+ ACE_OFF_T l_start;
+ ACE_OFF_T l_len; /* len == 0 means until end of file */
long l_sysid;
pid_t l_pid;
long l_pad[4]; /* reserve area */
@@ -187,8 +187,8 @@ namespace ACE_OS {
ACE_NAMESPACE_INLINE_FUNCTION
void flock_adjust_params (ace_flock_t *lock,
short whence,
- off_t &start,
- off_t &len);
+ ACE_OFF_T &start,
+ ACE_OFF_T &len);
# endif /* ACE_WIN32 */
ACE_NAMESPACE_INLINE_FUNCTION
@@ -204,32 +204,32 @@ namespace ACE_OS {
ACE_NAMESPACE_INLINE_FUNCTION
int flock_rdlock (ace_flock_t *lock,
short whence = 0,
- off_t start = 0,
- off_t len = 0);
+ ACE_OFF_T start = 0,
+ ACE_OFF_T len = 0);
ACE_NAMESPACE_INLINE_FUNCTION
int flock_tryrdlock (ace_flock_t *lock,
short whence = 0,
- off_t start = 0,
- off_t len = 0);
+ ACE_OFF_T start = 0,
+ ACE_OFF_T len = 0);
ACE_NAMESPACE_INLINE_FUNCTION
int flock_trywrlock (ace_flock_t *lock,
short whence = 0,
- off_t start = 0,
- off_t len = 0);
+ ACE_OFF_T start = 0,
+ ACE_OFF_T len = 0);
ACE_NAMESPACE_INLINE_FUNCTION
int flock_unlock (ace_flock_t *lock,
short whence = 0,
- off_t start = 0,
- off_t len = 0);
+ ACE_OFF_T start = 0,
+ ACE_OFF_T len = 0);
ACE_NAMESPACE_INLINE_FUNCTION
int flock_wrlock (ace_flock_t *lock,
short whence = 0,
- off_t start = 0,
- off_t len = 0);
+ ACE_OFF_T start = 0,
+ ACE_OFF_T len = 0);
//@}
@@ -276,11 +276,6 @@ namespace ACE_OS {
ACE_NAMESPACE_INLINE_FUNCTION
void set_win32_resource_module (HINSTANCE);
- /// Translate fopen's mode char to open's mode. This helper function
- /// is here to avoid maintaining several pieces of identical code.
- ACE_NAMESPACE_INLINE_FUNCTION
- void fopen_mode_to_open_mode_converter (ACE_TCHAR x, int &hmode);
-
extern ACE_Export ACE_TEXT_OSVERSIONINFO win32_versioninfo_;
extern ACE_Export HINSTANCE win32_resource_module_;
diff --git a/ACE/ace/OS_NS_stdio.inl b/ACE/ace/OS_NS_stdio.inl
index 3a4beb62f65..a2dcf06997e 100644
--- a/ACE/ace/OS_NS_stdio.inl
+++ b/ACE/ace/OS_NS_stdio.inl
@@ -9,6 +9,7 @@
#include "ace/OS_NS_string.h"
#include "ace/OS_NS_pwd.h"
#include "ace/OS_NS_macros.h"
+#include "ace/OS_NS_sys_stat.h"
#include "ace/OS_Memory.h"
#if defined (ACE_HAS_CHARPTR_SPRINTF)
@@ -25,24 +26,57 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_INLINE void
ACE_OS::flock_adjust_params (ACE_OS::ace_flock_t *lock,
short whence,
- off_t &start,
- off_t &len)
+ ACE_OFF_T &start,
+ ACE_OFF_T &len)
{
switch (whence)
{
case SEEK_SET:
break;
case SEEK_CUR:
- start += SetFilePointer (lock->handle_, 0, 0, FILE_CURRENT);
+ {
+# if defined (_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64
+ LARGE_INTEGER distance, offset;
+ distance.QuadPart = 0;
+ if (!::SetFilePointerEx (lock->handle_,
+ distance,
+ &offset,
+ FILE_CURRENT))
+ {
+ ACE_OS::set_errno_to_last_error ();
+ return;
+ }
+ start += offset.QuadPart;
+# else
+ ACE_OFF_T const offset =
+ ::SetFilePointer (lock->handle_, 0, 0, FILE_CURRENT);
+ if (offset == INVALID_SET_FILE_POINTER)
+ {
+ ACE_OS::set_errno_to_last_error ();
+ return;
+ }
+ start += offset;
+# endif /* _FILE_OFFSET_BITS == 64 */
+ }
break;
case SEEK_END:
- start += ::GetFileSize (lock->handle_, 0);
+ {
+ ACE_OFF_T const size = ACE_OS::filesize (lock->handle_);
+ if (size == -1)
+ return;
+
+ start += size;
+ }
break;
}
- lock->overlapped_.Offset = start;
+ lock->overlapped_.Offset = ACE_LOW_PART (start);
+ lock->overlapped_.OffsetHigh = ACE_HIGH_PART (start);
if (len == 0)
- len = ::GetFileSize (lock->handle_,
- 0) - start;
+ {
+ ACE_OFF_T const tlen = ACE_OS::filesize (lock->handle_);
+ if (tlen != -1)
+ len = tlen - start;
+ }
}
#endif /* ACE_WIN32 */
@@ -80,18 +114,21 @@ ACE_OS::flock_init (ACE_OS::ace_flock_t *lock,
ACE_INLINE int
ACE_OS::flock_unlock (ACE_OS::ace_flock_t *lock,
short whence,
- off_t start,
- off_t len)
+ ACE_OFF_T start,
+ ACE_OFF_T len)
{
ACE_OS_TRACE ("ACE_OS::flock_unlock");
#if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)
ACE_OS::flock_adjust_params (lock, whence, start, len);
- ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::UnlockFile (lock->handle_,
- lock->overlapped_.Offset,
- 0,
- len,
- 0),
- ace_result_), int, -1);
+ DWORD low_len = ACE_LOW_PART (len);
+ DWORD high_len = ACE_HIGH_PART (len);
+ ACE_WIN32CALL_RETURN (
+ ACE_ADAPT_RETVAL (::UnlockFile (lock->handle_,
+ lock->overlapped_.Offset,
+ lock->overlapped_.OffsetHigh,
+ low_len,
+ high_len),
+ ace_result_), int, -1);
#elif defined (ACE_LACKS_FILELOCKS)
ACE_UNUSED_ARG (lock);
ACE_UNUSED_ARG (whence);
@@ -137,27 +174,30 @@ ACE_OS::flock_destroy (ACE_OS::ace_flock_t *lock,
ACE_INLINE int
ACE_OS::flock_rdlock (ACE_OS::ace_flock_t *lock,
short whence,
- off_t start,
- off_t len)
+ ACE_OFF_T start,
+ ACE_OFF_T len)
{
ACE_OS_TRACE ("ACE_OS::flock_rdlock");
#if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)
ACE_OS::flock_adjust_params (lock, whence, start, len);
+ DWORD low_len = ACE_LOW_PART (len);
+ DWORD high_len = ACE_HIGH_PART (len);
# if defined (ACE_HAS_WINNT4) && (ACE_HAS_WINNT4 != 0)
ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::LockFileEx (lock->handle_,
0,
0,
- len,
- 0,
+ low_len,
+ high_len,
&lock->overlapped_),
ace_result_), int, -1);
# else /* ACE_HAS_WINNT4 && (ACE_HAS_WINNT4 != 0) */
- ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::LockFile (lock->handle_,
- lock->overlapped_.Offset,
- 0,
- len,
- 0),
- ace_result_), int, -1);
+ ACE_WIN32CALL_RETURN (
+ ACE_ADAPT_RETVAL (::LockFile (lock->handle_,
+ lock->overlapped_.Offset,
+ lock->overlapped_.OffsetHigh,
+ low_len,
+ high_len),
+ ace_result_), int, -1);
# endif /* ACE_HAS_WINNT4 && (ACE_HAS_WINNT4 != 0) */
#elif defined (ACE_LACKS_FILELOCKS)
ACE_UNUSED_ARG (lock);
@@ -180,20 +220,23 @@ ACE_OS::flock_rdlock (ACE_OS::ace_flock_t *lock,
ACE_INLINE int
ACE_OS::flock_tryrdlock (ACE_OS::ace_flock_t *lock,
short whence,
- off_t start,
- off_t len)
+ ACE_OFF_T start,
+ ACE_OFF_T len)
{
ACE_OS_TRACE ("ACE_OS::ace_flock_tryrdlock");
#if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)
# if defined (ACE_HAS_WINNT4) && (ACE_HAS_WINNT4 != 0)
ACE_OS::flock_adjust_params (lock, whence, start, len);
- ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::LockFileEx (lock->handle_,
- LOCKFILE_FAIL_IMMEDIATELY,
- 0,
- len,
- 0,
- &lock->overlapped_),
- ace_result_), int, -1);
+ DWORD low_len = ACE_LOW_PART (len);
+ DWORD high_len = ACE_HIGH_PART (len);
+ ACE_WIN32CALL_RETURN (
+ ACE_ADAPT_RETVAL (::LockFileEx (lock->handle_,
+ LOCKFILE_FAIL_IMMEDIATELY,
+ 0,
+ low_len,
+ high_len,
+ &lock->overlapped_),
+ ace_result_), int, -1);
# else /* ACE_HAS_WINNT4 && (ACE_HAS_WINNT4 != 0) */
ACE_UNUSED_ARG (lock);
ACE_UNUSED_ARG (whence);
@@ -229,20 +272,23 @@ ACE_OS::flock_tryrdlock (ACE_OS::ace_flock_t *lock,
ACE_INLINE int
ACE_OS::flock_trywrlock (ACE_OS::ace_flock_t *lock,
short whence,
- off_t start,
- off_t len)
+ ACE_OFF_T start,
+ ACE_OFF_T len)
{
ACE_OS_TRACE ("ACE_OS::ace_flock_trywrlock");
#if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)
# if defined (ACE_HAS_WINNT4) && (ACE_HAS_WINNT4 != 0)
ACE_OS::flock_adjust_params (lock, whence, start, len);
- ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::LockFileEx (lock->handle_,
- LOCKFILE_FAIL_IMMEDIATELY | LOCKFILE_EXCLUSIVE_LOCK,
- 0,
- len,
- 0,
- &lock->overlapped_),
- ace_result_), int, -1);
+ DWORD low_len = ACE_LOW_PART (len);
+ DWORD high_len = ACE_HIGH_PART (len);
+ ACE_WIN32CALL_RETURN (
+ ACE_ADAPT_RETVAL (::LockFileEx (lock->handle_,
+ LOCKFILE_FAIL_IMMEDIATELY | LOCKFILE_EXCLUSIVE_LOCK,
+ 0,
+ low_len,
+ high_len,
+ &lock->overlapped_),
+ ace_result_), int, -1);
# else /* ACE_HAS_WINNT4 && (ACE_HAS_WINNT4 != 0) */
ACE_UNUSED_ARG (lock);
ACE_UNUSED_ARG (whence);
@@ -279,27 +325,31 @@ ACE_OS::flock_trywrlock (ACE_OS::ace_flock_t *lock,
ACE_INLINE int
ACE_OS::flock_wrlock (ACE_OS::ace_flock_t *lock,
short whence,
- off_t start,
- off_t len)
+ ACE_OFF_T start,
+ ACE_OFF_T len)
{
ACE_OS_TRACE ("ACE_OS::flock_wrlock");
#if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)
ACE_OS::flock_adjust_params (lock, whence, start, len);
+ DWORD low_len = ACE_LOW_PART (len);
+ DWORD high_len = ACE_HIGH_PART (len);
# if defined (ACE_HAS_WINNT4) && (ACE_HAS_WINNT4 != 0)
- ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::LockFileEx (lock->handle_,
- LOCKFILE_EXCLUSIVE_LOCK,
- 0,
- len,
- 0,
- &lock->overlapped_),
- ace_result_), int, -1);
+ ACE_WIN32CALL_RETURN (
+ ACE_ADAPT_RETVAL (::LockFileEx (lock->handle_,
+ LOCKFILE_EXCLUSIVE_LOCK,
+ 0,
+ low_len,
+ high_len,
+ &lock->overlapped_),
+ ace_result_), int, -1);
# else /* ACE_HAS_WINNT4 && (ACE_HAS_WINNT4 != 0) */
- ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::LockFile (lock->handle_,
- lock->overlapped_.Offset,
- 0,
- len,
- 0),
- ace_result_), int, -1);
+ ACE_WIN32CALL_RETURN (
+ ACE_ADAPT_RETVAL (::LockFile (lock->handle_,
+ lock->overlapped_.Offset,
+ lock->overlapped_.OffsetHigh,
+ low_len,
+ high_len),
+ ace_result_), int, -1);
# endif /* ACE_HAS_WINNT4 && (ACE_HAS_WINNT4 != 0) */
#elif defined (ACE_LACKS_FILELOCKS)
ACE_UNUSED_ARG (lock);
@@ -319,51 +369,6 @@ ACE_OS::flock_wrlock (ACE_OS::ace_flock_t *lock,
#endif /* ACE_WIN32 */
}
-#if defined (ACE_WIN32)
-ACE_INLINE void
-ACE_OS::fopen_mode_to_open_mode_converter (ACE_TCHAR x, int &hmode)
-{
- switch (x)
- {
- case ACE_LIB_TEXT ('r'):
- if (ACE_BIT_DISABLED (hmode, _O_RDWR))
- {
- ACE_CLR_BITS (hmode, _O_WRONLY);
- ACE_SET_BITS (hmode, _O_RDONLY);
- }
- break;
- case ACE_LIB_TEXT ('w'):
- if (ACE_BIT_DISABLED (hmode, _O_RDWR))
- {
- ACE_CLR_BITS (hmode, _O_RDONLY);
- ACE_SET_BITS (hmode, _O_WRONLY);
- }
- ACE_SET_BITS (hmode, _O_CREAT | _O_TRUNC);
- break;
- case ACE_LIB_TEXT ('a'):
- if (ACE_BIT_DISABLED (hmode, _O_RDWR))
- {
- ACE_CLR_BITS (hmode, _O_RDONLY);
- ACE_SET_BITS (hmode, _O_WRONLY);
- }
- ACE_SET_BITS (hmode, _O_CREAT | _O_APPEND);
- break;
- case ACE_LIB_TEXT ('+'):
- ACE_CLR_BITS (hmode, _O_RDONLY | _O_WRONLY);
- ACE_SET_BITS (hmode, _O_RDWR);
- break;
- case ACE_LIB_TEXT ('t'):
- ACE_CLR_BITS (hmode, _O_BINARY);
- ACE_SET_BITS (hmode, _O_TEXT);
- break;
- case ACE_LIB_TEXT ('b'):
- ACE_CLR_BITS (hmode, _O_TEXT);
- ACE_SET_BITS (hmode, _O_BINARY);
- break;
- }
-}
-#endif /* ACE_WIN32 */
-
#if !defined (ACE_LACKS_CLEARERR)
ACE_INLINE void
ACE_OS::clearerr (FILE* fp)
diff --git a/ACE/ace/OS_NS_sys_mman.h b/ACE/ace/OS_NS_sys_mman.h
index 0a6f57a5038..ba2d4661eb3 100644
--- a/ACE/ace/OS_NS_sys_mman.h
+++ b/ACE/ace/OS_NS_sys_mman.h
@@ -52,7 +52,7 @@ namespace ACE_OS
int prot,
int flags,
ACE_HANDLE handle,
- off_t off = 0,
+ ACE_OFF_T off = 0,
ACE_HANDLE *file_mapping = 0,
LPSECURITY_ATTRIBUTES sa = 0,
const ACE_TCHAR *file_mapping_name = 0);
diff --git a/ACE/ace/OS_NS_sys_mman.inl b/ACE/ace/OS_NS_sys_mman.inl
index 3f1a69de2bb..422d07e9c35 100644
--- a/ACE/ace/OS_NS_sys_mman.inl
+++ b/ACE/ace/OS_NS_sys_mman.inl
@@ -37,7 +37,7 @@ ACE_OS::mmap (void *addr,
int prot,
int flags,
ACE_HANDLE file_handle,
- off_t off,
+ ACE_OFF_T off,
ACE_HANDLE *file_mapping,
LPSECURITY_ATTRIBUTES sa,
const ACE_TCHAR *file_mapping_name)
@@ -135,18 +135,21 @@ ACE_OS::mmap (void *addr,
nt_flags |= ACE_OS_EXTRA_MMAP_FLAGS;
# endif /* ACE_OS_EXTRA_MMAP_FLAGS */
+ DWORD low_off = ACE_LOW_PART (off);
+ DWORD high_off = ACE_HIGH_PART (off);
+
# if !defined (ACE_HAS_WINCE)
void *addr_mapping = ::MapViewOfFileEx (*file_mapping,
nt_flags,
- 0,
- off,
+ high_off,
+ low_off,
len,
addr);
# else
void *addr_mapping = ::MapViewOfFile (*file_mapping,
nt_flags,
- 0,
- off,
+ high_off,
+ low_off,
len);
# endif /* ! ACE_HAS_WINCE */
diff --git a/ACE/ace/OS_NS_sys_stat.h b/ACE/ace/OS_NS_sys_stat.h
index 6e4ea6d209e..9cb017263aa 100644
--- a/ACE/ace/OS_NS_sys_stat.h
+++ b/ACE/ace/OS_NS_sys_stat.h
@@ -61,10 +61,10 @@ namespace ACE_OS
// non-standard
ACE_NAMESPACE_INLINE_FUNCTION
- ACE_LOFF_T filesize (ACE_HANDLE handle);
+ ACE_OFF_T filesize (ACE_HANDLE handle);
ACE_NAMESPACE_INLINE_FUNCTION
- ACE_LOFF_T filesize (const ACE_TCHAR *handle);
+ ACE_OFF_T filesize (const ACE_TCHAR *handle);
//@}
ACE_NAMESPACE_INLINE_FUNCTION
diff --git a/ACE/ace/OS_NS_sys_stat.inl b/ACE/ace/OS_NS_sys_stat.inl
index 88085ddb84e..63cab76ce22 100644
--- a/ACE/ace/OS_NS_sys_stat.inl
+++ b/ACE/ace/OS_NS_sys_stat.inl
@@ -95,23 +95,39 @@ namespace ACE_OS
// This function returns the number of bytes in the file referenced by
// FD.
- ACE_INLINE ACE_LOFF_T
+ ACE_INLINE ACE_OFF_T
filesize (ACE_HANDLE handle)
{
ACE_OS_TRACE ("ACE_OS::filesize");
+#if defined (ACE_WIN32)
+# if defined (_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64
+ LARGE_INTEGER size;
+ return
+ (::GetFileSizeEx (handle, &size)
+ ? size.QuadPart
+ : (ACE_OS::set_errno_to_last_error (), -1));
+# else
+ ACE_OFF_T const size = ::GetFileSize (handle, 0);
+ return
+ (size != INVALID_FILE_SIZE
+ ? size
+ : (ACE_OS::set_errno_to_last_error (), -1));
+# endif /* _FILE_OFFSET_BITS == 64 */
+#else /* !ACE_WIN32 */
ACE_stat sb;
return ACE_OS::fstat (handle, &sb) == -1 ? -1 : sb.st_size;
+#endif
}
- ACE_INLINE ACE_LOFF_T
+ ACE_INLINE ACE_OFF_T
filesize (const ACE_TCHAR *filename)
{
ACE_OS_TRACE ("ACE_OS::filesize");
- ACE_HANDLE h = ACE_OS::open (filename, O_RDONLY);
+ ACE_HANDLE const h = ACE_OS::open (filename, O_RDONLY);
if (h != ACE_INVALID_HANDLE)
{
- ACE_LOFF_T size = ACE_OS::filesize (h);
+ ACE_OFF_T size = ACE_OS::filesize (h);
ACE_OS::close (h);
return size;
}
diff --git a/ACE/ace/OS_NS_unistd.cpp b/ACE/ace/OS_NS_unistd.cpp
index ac1c21e8993..4fd4401c3d9 100644
--- a/ACE/ace/OS_NS_unistd.cpp
+++ b/ACE/ace/OS_NS_unistd.cpp
@@ -374,7 +374,7 @@ ssize_t
ACE_OS::pread (ACE_HANDLE handle,
void *buf,
size_t nbytes,
- off_t offset)
+ ACE_OFF_T offset)
{
# if defined (ACE_HAS_P_READ_WRITE)
# if defined (ACE_WIN32)
@@ -382,20 +382,25 @@ ACE_OS::pread (ACE_HANDLE handle,
ACE_OS_GUARD
// Remember the original file pointer position
- DWORD original_position = ::SetFilePointer (handle,
- 0,
- 0,
- FILE_CURRENT);
-
- if (original_position == 0xFFFFFFFF)
+ LONG original_high_position = 0;
+ DWORD original_low_position = ::SetFilePointer (handle,
+ 0,
+ &original_high_position,
+ FILE_CURRENT);
+
+ if (original_low_position == INVALID_SET_FILE_POINTER
+ && GetLastError() != NO_ERROR)
return -1;
// Go to the correct position
+ LONG low_offset = ACE_LOW_PART (offset);
+ LONG high_offset = ACE_HIGH_PART (offset);
DWORD altered_position = ::SetFilePointer (handle,
- offset,
- 0,
+ low_offset,
+ &high_offset,
FILE_BEGIN);
- if (altered_position == 0xFFFFFFFF)
+ if (altered_position == INVALID_SET_FILE_POINTER
+ && GetLastError() != NO_ERROR)
return -1;
DWORD bytes_read;
@@ -405,8 +410,8 @@ ACE_OS::pread (ACE_HANDLE handle,
OVERLAPPED overlapped;
overlapped.Internal = 0;
overlapped.InternalHigh = 0;
- overlapped.Offset = offset;
- overlapped.OffsetHigh = 0;
+ overlapped.Offset = low_offset;
+ overlapped.OffsetHigh = high_offset;
overlapped.hEvent = 0;
BOOL result = ::ReadFile (handle,
@@ -445,9 +450,10 @@ ACE_OS::pread (ACE_HANDLE handle,
// Reset the original file pointer position
if (::SetFilePointer (handle,
- original_position,
- 0,
- FILE_BEGIN) == 0xFFFFFFFF)
+ original_low_position,
+ &original_high_position,
+ FILE_BEGIN) == INVALID_SET_FILE_POINTER
+ && GetLastError() != NO_ERROR)
return -1;
return (ssize_t) bytes_read;
@@ -463,17 +469,17 @@ ACE_OS::pread (ACE_HANDLE handle,
ACE_OS_GUARD
// Remember the original file pointer position
- off_t original_position = ACE_OS::lseek (handle,
- 0,
- SEEK_CUR);
+ ACE_OFF_T original_position = ACE_OS::lseek (handle,
+ 0,
+ SEEK_CUR);
if (original_position == -1)
return -1;
// Go to the correct position
- off_t altered_position = ACE_OS::lseek (handle,
- offset,
- SEEK_SET);
+ ACE_OFF_T altered_position = ACE_OS::lseek (handle,
+ offset,
+ SEEK_SET);
if (altered_position == -1)
return -1;
@@ -499,7 +505,7 @@ ssize_t
ACE_OS::pwrite (ACE_HANDLE handle,
const void *buf,
size_t nbytes,
- ACE_LOFF_T offset)
+ ACE_OFF_T offset)
{
# if defined (ACE_HAS_P_READ_WRITE)
# if defined (ACE_WIN32)
@@ -513,8 +519,8 @@ ACE_OS::pwrite (ACE_HANDLE handle,
0,
&orig_position.HighPart,
FILE_CURRENT);
- if (orig_position.LowPart == INVALID_SET_FILE_POINTER &&
- GetLastError () != NO_ERROR)
+ if (orig_position.LowPart == INVALID_SET_FILE_POINTER
+ && GetLastError () != NO_ERROR)
return -1;
DWORD bytes_written;
@@ -552,8 +558,11 @@ ACE_OS::pwrite (ACE_HANDLE handle,
# else /* ACE_HAS_WINNT4 && (ACE_HAS_WINNT4 != 0) */
// Go to the correct position
- if (0 != ::SetFilePointerEx (handle, loffset, 0, FILE_BEGIN))
- return -1;
+ if (! ::SetFilePointerEx (handle, loffset, 0, FILE_BEGIN))
+ {
+ ACE_OS::set_errno_to_last_error ();
+ return -1;
+ }
BOOL result = ::WriteFile (handle,
buf,
@@ -569,7 +578,8 @@ ACE_OS::pwrite (ACE_HANDLE handle,
if (::SetFilePointer (handle,
orig_position.LowPart,
&orig_position.HighPart,
- FILE_BEGIN) == INVALID_SET_FILE_POINTER)
+ FILE_BEGIN) == INVALID_SET_FILE_POINTER
+ && GetLastError () != NO_ERROR)
return -1;
return (ssize_t) bytes_written;
@@ -583,16 +593,16 @@ ACE_OS::pwrite (ACE_HANDLE handle,
ACE_OS_GUARD
// Remember the original file pointer position
- off_t original_position = ACE_OS::lseek (handle,
- 0,
- SEEK_CUR);
+ ACE_OFF_T original_position = ACE_OS::lseek (handle,
+ 0,
+ SEEK_CUR);
if (original_position == -1)
return -1;
// Go to the correct position
- off_t altered_position = ACE_OS::lseek (handle,
- offset,
- SEEK_SET);
+ ACE_OFF_T altered_position = ACE_OS::lseek (handle,
+ offset,
+ SEEK_SET);
if (altered_position == -1)
return -1;
diff --git a/ACE/ace/OS_NS_unistd.h b/ACE/ace/OS_NS_unistd.h
index 1af07d98924..3f51db36c3f 100644
--- a/ACE/ace/OS_NS_unistd.h
+++ b/ACE/ace/OS_NS_unistd.h
@@ -139,7 +139,7 @@ namespace ACE_OS
ACE_NAMESPACE_INLINE_FUNCTION
int ftruncate (ACE_HANDLE,
- ACE_LOFF_T);
+ ACE_OFF_T);
ACE_NAMESPACE_INLINE_FUNCTION
char *getcwd (char *, size_t);
@@ -198,9 +198,9 @@ namespace ACE_OS
#endif /* ACE_WIN32 */
ACE_NAMESPACE_INLINE_FUNCTION
- off_t lseek (ACE_HANDLE handle,
- off_t offset,
- int whence);
+ ACE_OFF_T lseek (ACE_HANDLE handle,
+ ACE_OFF_T offset,
+ int whence);
#if defined (ACE_HAS_LLSEEK) || defined (ACE_HAS_LSEEK64)
ACE_NAMESPACE_INLINE_FUNCTION
@@ -224,13 +224,13 @@ namespace ACE_OS
ssize_t pread (ACE_HANDLE handle,
void *buf,
size_t nbyte,
- off_t offset);
+ ACE_OFF_T offset);
extern ACE_Export
ssize_t pwrite (ACE_HANDLE handle,
const void *buf,
size_t nbyte,
- ACE_LOFF_T offset);
+ ACE_OFF_T offset);
ACE_NAMESPACE_INLINE_FUNCTION
ssize_t read (ACE_HANDLE handle,
@@ -315,7 +315,7 @@ namespace ACE_OS
long count);
ACE_NAMESPACE_INLINE_FUNCTION
- int truncate (const ACE_TCHAR *filename, ACE_LOFF_T length);
+ int truncate (const ACE_TCHAR *filename, ACE_OFF_T length);
ACE_NAMESPACE_INLINE_FUNCTION
useconds_t ualarm (useconds_t usecs,
diff --git a/ACE/ace/OS_NS_unistd.inl b/ACE/ace/OS_NS_unistd.inl
index c1cd0fba4ac..35aedac07ec 100644
--- a/ACE/ace/OS_NS_unistd.inl
+++ b/ACE/ace/OS_NS_unistd.inl
@@ -351,7 +351,7 @@ ACE_OS::fsync (ACE_HANDLE handle)
}
ACE_INLINE int
-ACE_OS::ftruncate (ACE_HANDLE handle, ACE_LOFF_T offset)
+ACE_OS::ftruncate (ACE_HANDLE handle, ACE_OFF_T offset)
{
ACE_OS_TRACE ("ACE_OS::ftruncate");
#if defined (ACE_WIN32)
@@ -360,7 +360,10 @@ ACE_OS::ftruncate (ACE_HANDLE handle, ACE_LOFF_T offset)
loff.QuadPart = offset;
if (::SetFilePointerEx (handle, loff, 0, FILE_BEGIN))
# else
- if (::SetFilePointer (handle, offset, 0, FILE_BEGIN) != (unsigned) -1)
+ if (::SetFilePointer (handle,
+ offset,
+ 0,
+ FILE_BEGIN) != INVALID_SET_FILE_POINTER)
# endif
ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::SetEndOfFile (handle), ace_result_), int, -1);
else
@@ -605,8 +608,8 @@ ACE_OS::isatty (ACE_HANDLE handle)
#endif /* ACE_WIN32 */
-ACE_INLINE off_t
-ACE_OS::lseek (ACE_HANDLE handle, off_t offset, int whence)
+ACE_INLINE ACE_OFF_T
+ACE_OS::lseek (ACE_HANDLE handle, ACE_OFF_T offset, int whence)
{
ACE_OS_TRACE ("ACE_OS::lseek");
#if defined (ACE_WIN32)
@@ -625,16 +628,19 @@ ACE_OS::lseek (ACE_HANDLE handle, off_t offset, int whence)
break;
default:
errno = EINVAL;
- return static_cast<off_t> (-1); // rather safe than sorry
+ return static_cast<ACE_OFF_T> (-1); // rather safe than sorry
}
# endif /* SEEK_SET != FILE_BEGIN || SEEK_CUR != FILE_CURRENT || SEEK_END != FILE_END */
- DWORD result = ::SetFilePointer (handle, offset, 0, whence);
- if (result == ACE_SYSCALL_FAILED)
- ACE_FAIL_RETURN (static_cast<off_t> (-1));
+ LONG low_offset = ACE_LOW_PART(offset);
+ LONG high_offset = ACE_HIGH_PART(offset);
+ DWORD const result =
+ ::SetFilePointer (handle, low_offset, &high_offset, whence);
+ if (result == INVALID_SET_FILE_POINTER && GetLastError() != NO_ERROR)
+ ACE_FAIL_RETURN (static_cast<ACE_OFF_T> (-1));
else
return result;
#else
- ACE_OSCALL_RETURN (::lseek (handle, offset, whence), off_t, -1);
+ ACE_OSCALL_RETURN (::lseek (handle, offset, whence), ACE_OFF_T, -1);
#endif /* ACE_WIN32 */
}
@@ -652,16 +658,33 @@ ACE_OS::llseek (ACE_HANDLE handle, ACE_LOFF_T offset, int whence)
#elif defined (ACE_HAS_LSEEK64)
ACE_OSCALL_RETURN (::lseek64 (handle, offset, whence), ACE_LOFF_T, -1);
#elif defined (ACE_HAS_LLSEEK)
- # if defined (ACE_WIN32)
- LARGE_INTEGER li;
- li.QuadPart = offset;
- li.LowPart = ::SetFilePointer (handle, li.LowPart, &li.HighPart, whence);
- if (li.LowPart == 0xFFFFFFFF && GetLastError() != NO_ERROR)
- li.QuadPart = -1;
- return li.QuadPart;
- # else
+# if defined (ACE_WIN32)
+# ifndef ACE_LACKS_SETFILEPOINTEREX
+ LARGE_INTEGER distance, new_file_pointer;
+
+ distance.QuadPart = offset;
+
+ return
+ (::SetFilePointerEx (handle, distance, &new_file_pointer, whence)
+ ? new_file_pointer.QuadPart
+ : static_cast<ACE_LOFF_T> (-1));
+# else
+ LONG low_offset = ACE_LOW_PART(offset);
+ LONG high_offset = ACE_HIGH_PART(offset);
+
+ ACE_OFF_T const result = ::SetFilePointer (handle,
+ low_offset,
+ &high_offset,
+ whence);
+
+ return
+ ((result != INVALID_SET_FILE_POINTER || GetLastError () == NO_ERROR)
+ ? result
+ : static_cast<ACE_LOFF_T> (-1));
+# endif /* ACE_LACKS_SETFILEPOINTEREX */
+# else
ACE_OSCALL_RETURN (::llseek (handle, offset, whence), ACE_LOFF_T, -1);
- # endif /* WIN32 */
+# endif /* WIN32 */
#endif
}
#endif /* ACE_HAS_LLSEEK || ACE_HAS_LSEEK64 */
@@ -975,7 +998,7 @@ ACE_OS::sysinfo (int cmd, char *buf, long count)
ACE_INLINE int
ACE_OS::truncate (const ACE_TCHAR *filename,
- ACE_LOFF_T offset)
+ ACE_OFF_T offset)
{
ACE_OS_TRACE ("ACE_OS::truncate");
#if defined (ACE_WIN32)
@@ -983,10 +1006,17 @@ ACE_OS::truncate (const ACE_TCHAR *filename,
O_WRONLY,
ACE_DEFAULT_FILE_PERMS);
+# if !defined (ACE_LACKS_SETFILEPOINTEREX)
LARGE_INTEGER loffset;
loffset.QuadPart = offset;
+#else
+ LONG low_offset = ACE_LOW_PART(offset);
+ LONG high_offset = ACE_HIGH_PART(offset);
+#endif
+
if (handle == ACE_INVALID_HANDLE)
ACE_FAIL_RETURN (-1);
+
# if !defined (ACE_LACKS_SETFILEPOINTEREX)
else if (::SetFilePointerEx (handle,
loffset,
@@ -994,9 +1024,10 @@ ACE_OS::truncate (const ACE_TCHAR *filename,
FILE_BEGIN))
# else
else if (::SetFilePointer (handle,
- offset,
- 0,
- FILE_BEGIN) != (unsigned) -1)
+ low_offset,
+ &high_offset,
+ FILE_BEGIN) != INVALID_SET_FILE_POINTER
+ || GetLastError () == NO_ERROR)
# endif
{
BOOL result = ::SetEndOfFile (handle);
diff --git a/ACE/ace/Pagefile_Memory_Pool.inl b/ACE/ace/Pagefile_Memory_Pool.inl
index cf54da23f29..dd8eeb61220 100644
--- a/ACE/ace/Pagefile_Memory_Pool.inl
+++ b/ACE/ace/Pagefile_Memory_Pool.inl
@@ -16,7 +16,7 @@ ACE_Pagefile_Memory_Pool::round_to_chunk_size (size_t nbytes)
ACE_INLINE size_t
ACE_Pagefile_Memory_Pool::round_to_page_size (size_t nbytes)
{
- return ACE::round_to_pagesize (static_cast<off_t> (nbytes));
+ return ACE::round_to_pagesize (nbytes);
}
ACE_INLINE int
diff --git a/ACE/ace/Shared_Memory_MM.cpp b/ACE/ace/Shared_Memory_MM.cpp
index 945cb345b20..0662e7525bd 100644
--- a/ACE/ace/Shared_Memory_MM.cpp
+++ b/ACE/ace/Shared_Memory_MM.cpp
@@ -30,7 +30,7 @@ ACE_Shared_Memory_MM::ACE_Shared_Memory_MM (ACE_HANDLE handle,
int prot,
int share,
char *addr,
- off_t pos)
+ ACE_OFF_T pos)
: shared_memory_ (handle, length, prot, share, addr, pos)
{
ACE_TRACE ("ACE_Shared_Memory_MM::ACE_Shared_Memory_MM");
@@ -43,7 +43,7 @@ ACE_Shared_Memory_MM::ACE_Shared_Memory_MM (const ACE_TCHAR *file_name,
int prot,
int share,
char *addr,
- off_t pos)
+ ACE_OFF_T pos)
: shared_memory_ (file_name, len, flags, mode,
prot, share, addr, pos)
{
diff --git a/ACE/ace/Shared_Memory_MM.h b/ACE/ace/Shared_Memory_MM.h
index 5a8bd83eed1..ff0d066120d 100644
--- a/ACE/ace/Shared_Memory_MM.h
+++ b/ACE/ace/Shared_Memory_MM.h
@@ -47,7 +47,7 @@ public:
int prot = PROT_RDWR,
int share = ACE_MAP_PRIVATE,
char *addr = 0,
- off_t pos = 0);
+ ACE_OFF_T pos = 0);
/// Constructor.
ACE_Shared_Memory_MM (const ACE_TCHAR *file_name,
@@ -56,7 +56,7 @@ public:
int mode = ACE_DEFAULT_FILE_PERMS,
int prot = PROT_RDWR,
int share = ACE_MAP_SHARED,
- char *addr = 0, off_t pos = 0);
+ char *addr = 0, ACE_OFF_T pos = 0);
/// Open method.
int open (ACE_HANDLE handle,
@@ -64,7 +64,7 @@ public:
int prot = PROT_RDWR,
int share = ACE_MAP_PRIVATE,
char *addr = 0,
- off_t pos = 0);
+ ACE_OFF_T pos = 0);
/// Open method.
int open (const ACE_TCHAR *file_name,
@@ -74,7 +74,7 @@ public:
int prot = PROT_RDWR,
int share = ACE_MAP_SHARED,
char *addr = 0,
- off_t pos = 0);
+ ACE_OFF_T pos = 0);
/// Return the name of file that is mapped (if any).
const ACE_TCHAR *filename (void) const;
diff --git a/ACE/ace/Shared_Memory_MM.inl b/ACE/ace/Shared_Memory_MM.inl
index 96d865b667b..6d1e653cc17 100644
--- a/ACE/ace/Shared_Memory_MM.inl
+++ b/ACE/ace/Shared_Memory_MM.inl
@@ -18,7 +18,7 @@ ACE_Shared_Memory_MM::open (ACE_HANDLE handle,
int prot,
int share,
char *addr,
- off_t pos)
+ ACE_OFF_T pos)
{
ACE_TRACE ("ACE_Shared_Memory_MM::open");
return shared_memory_.map (handle, length, prot, share, addr, pos);
@@ -32,7 +32,7 @@ ACE_Shared_Memory_MM::open (const ACE_TCHAR *file_name,
int prot,
int share,
char *addr,
- off_t pos)
+ ACE_OFF_T pos)
{
ACE_TRACE ("ACE_Shared_Memory_MM::open");
return shared_memory_.map (file_name, len, flags, mode,
diff --git a/ACE/ace/Shared_Memory_Pool.cpp b/ACE/ace/Shared_Memory_Pool.cpp
index c61334485b7..007f1c73ab5 100644
--- a/ACE/ace/Shared_Memory_Pool.cpp
+++ b/ACE/ace/Shared_Memory_Pool.cpp
@@ -13,11 +13,12 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_ALLOC_HOOK_DEFINE(ACE_Shared_Memory_Pool)
-ACE_Shared_Memory_Pool_Options::ACE_Shared_Memory_Pool_Options (const char *base_addr,
- size_t max_segments,
- size_t file_perms,
- off_t minimum_bytes,
- size_t segment_size)
+ACE_Shared_Memory_Pool_Options::ACE_Shared_Memory_Pool_Options (
+ const char *base_addr,
+ size_t max_segments,
+ size_t file_perms,
+ ACE_OFF_T minimum_bytes,
+ size_t segment_size)
: base_addr_ (base_addr),
max_segments_ (max_segments),
minimum_bytes_ (minimum_bytes),
@@ -36,7 +37,7 @@ ACE_Shared_Memory_Pool::dump (void) const
}
int
-ACE_Shared_Memory_Pool::in_use (off_t &offset,
+ACE_Shared_Memory_Pool::in_use (ACE_OFF_T &offset,
size_t &counter)
{
offset = 0;
@@ -61,7 +62,7 @@ ACE_Shared_Memory_Pool::in_use (off_t &offset,
int
ACE_Shared_Memory_Pool::find_seg (const void* const searchPtr,
- off_t &offset,
+ ACE_OFF_T &offset,
size_t &counter)
{
offset = 0;
@@ -97,7 +98,7 @@ ACE_Shared_Memory_Pool::find_seg (const void* const searchPtr,
int
ACE_Shared_Memory_Pool::commit_backing_store_name (size_t rounded_bytes,
- off_t &offset)
+ ACE_OFF_T &offset)
{
ACE_TRACE ("ACE_Shared_Memory_Pool::commit_backing_store_name");
@@ -155,7 +156,7 @@ ACE_Shared_Memory_Pool::handle_signal (int , siginfo_t *siginfo, ucontext_t *)
// it does not define SEGV_MAPERR.
#if defined (ACE_HAS_SIGINFO_T) && !defined (ACE_LACKS_SI_ADDR) && \
(defined (SEGV_MAPERR) || defined (SEGV_MEMERR))
- off_t offset;
+ ACE_OFF_T offset;
// Make sure that the pointer causing the problem is within the
// range of the backing store.
@@ -224,8 +225,9 @@ ACE_Shared_Memory_Pool::handle_signal (int , siginfo_t *siginfo, ucontext_t *)
return 0;
}
-ACE_Shared_Memory_Pool::ACE_Shared_Memory_Pool (const ACE_TCHAR *backing_store_name,
- const OPTIONS *options)
+ACE_Shared_Memory_Pool::ACE_Shared_Memory_Pool (
+ const ACE_TCHAR *backing_store_name,
+ const OPTIONS *options)
: base_addr_ (0),
file_perms_ (ACE_DEFAULT_FILE_PERMS),
max_segments_ (ACE_DEFAULT_MAX_SEGMENTS),
@@ -293,7 +295,7 @@ ACE_Shared_Memory_Pool::acquire (size_t nbytes,
// ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("(%P|%t) acquiring more chunks, nbytes = %d, rounded_bytes = %d\n"), nbytes, rounded_bytes));
- off_t offset;
+ ACE_OFF_T offset;
if (this->commit_backing_store_name (rounded_bytes, offset) == -1)
return 0;
@@ -311,7 +313,7 @@ ACE_Shared_Memory_Pool::init_acquire (size_t nbytes,
{
ACE_TRACE ("ACE_Shared_Memory_Pool::init_acquire");
- off_t shm_table_offset = ACE::round_to_pagesize (sizeof (SHM_TABLE));
+ ACE_OFF_T shm_table_offset = ACE::round_to_pagesize (sizeof (SHM_TABLE));
rounded_bytes = this->round_up (nbytes > (size_t) this->minimum_bytes_
? nbytes
: (size_t) this->minimum_bytes_);
diff --git a/ACE/ace/Shared_Memory_Pool.h b/ACE/ace/Shared_Memory_Pool.h
index 2803d3c0d6b..a54ef63da58 100644
--- a/ACE/ace/Shared_Memory_Pool.h
+++ b/ACE/ace/Shared_Memory_Pool.h
@@ -43,11 +43,12 @@ class ACE_Export ACE_Shared_Memory_Pool_Options
{
public:
/// Initialization method.
- ACE_Shared_Memory_Pool_Options (const char *base_addr = ACE_DEFAULT_BASE_ADDR,
- size_t max_segments = ACE_DEFAULT_MAX_SEGMENTS,
- size_t file_perms = ACE_DEFAULT_FILE_PERMS,
- off_t minimum_bytes = 0,
- size_t segment_size = ACE_DEFAULT_SEGMENT_SIZE);
+ ACE_Shared_Memory_Pool_Options (
+ const char *base_addr = ACE_DEFAULT_BASE_ADDR,
+ size_t max_segments = ACE_DEFAULT_MAX_SEGMENTS,
+ size_t file_perms = ACE_DEFAULT_FILE_PERMS,
+ ACE_OFF_T minimum_bytes = 0,
+ size_t segment_size = ACE_DEFAULT_SEGMENT_SIZE);
/// Base address of the memory-mapped backing store.
const char *base_addr_;
@@ -56,7 +57,7 @@ public:
size_t max_segments_;
/// What the minimum bytes of the initial segment should be.
- off_t minimum_bytes_;
+ ACE_OFF_T minimum_bytes_;
/// File permissions to use when creating/opening a segment.
size_t file_perms_;
@@ -145,7 +146,7 @@ protected:
* the backing store.
*/
virtual int commit_backing_store_name (size_t rounded_bytes,
- off_t &offset);
+ ACE_OFF_T &offset);
/// Keeps track of all the segments being used.
struct SHM_TABLE
@@ -175,7 +176,7 @@ protected:
size_t max_segments_;
/// What the minimim bytes of the initial segment should be.
- off_t minimum_bytes_;
+ ACE_OFF_T minimum_bytes_;
/// Shared memory segment size.
size_t segment_size_;
@@ -185,11 +186,11 @@ protected:
/// Find the segment that contains the @a searchPtr
virtual int find_seg (const void *const searchPtr,
- off_t &offset,
+ ACE_OFF_T &offset,
size_t &counter);
/// Determine how much memory is currently in use.
- virtual int in_use (off_t &offset,
+ virtual int in_use (ACE_OFF_T &offset,
size_t &counter);
/// Handles SIGSEGV.
diff --git a/ACE/ace/os_include/os_unistd.h b/ACE/ace/os_include/os_unistd.h
index 687557bfe26..828c45b5cd4 100644
--- a/ACE/ace/os_include/os_unistd.h
+++ b/ACE/ace/os_include/os_unistd.h
@@ -100,14 +100,14 @@ extern "C"
// It seems that _XOPEN_SOURCE == 500 means that the prototypes are
// already defined in the system headers.
ssize_t pread (int fd,
- void *buf,
- size_t nbytes,
- off_t offset);
+ void *buf,
+ size_t nbytes,
+ ACE_OFF_T offset);
ssize_t pwrite (int fd,
- const void *buf,
- size_t n,
- off_t offset);
+ const void *buf,
+ size_t n,
+ ACE_OFF_T offset);
#endif /* ACE_LACKS_PREAD_PROTOTYPE && (_XOPEN_SOURCE - 0) < 500 */
#if defined (ACE_LACKS_GETPGID_PROTOTYPE) && \
diff --git a/ACE/ace/os_include/sys/os_stat.h b/ACE/ace/os_include/sys/os_stat.h
index 0c4a703f5f2..a7c69dc36d4 100644
--- a/ACE/ace/os_include/sys/os_stat.h
+++ b/ACE/ace/os_include/sys/os_stat.h
@@ -111,7 +111,7 @@ extern "C"
ACE_Time_Value st_ctime;
/// file size, in bytes
- off_t st_size;
+ ACE_OFF_T st_size;
// Following members do not have direct conversion in Window platforms.
//u_long st_blksize; // optimal blocksize for I/O
diff --git a/ACE/ace/os_include/sys/os_types.h b/ACE/ace/os_include/sys/os_types.h
index 737f53322ca..dbf1cfa412f 100644
--- a/ACE/ace/os_include/sys/os_types.h
+++ b/ACE/ace/os_include/sys/os_types.h
@@ -72,6 +72,12 @@ typedef double ACE_timer_t;
typedef unsigned int dev_t;
#endif /* ACE_HAS_WINCE */
+#if defined(ACE_WIN32) && defined(_FILE_OFFSET_BITS) && (_FILE_OFFSET_BITS==64)
+ typedef __int64 ACE_OFF_T;
+#else
+ typedef off_t ACE_OFF_T;
+#endif
+
#if defined (ACE_SIZEOF_LONG) && ACE_SIZEOF_LONG == 8
typedef off_t ACE_LOFF_T;
#elif defined (ACE_HAS_RTEMS) || defined (__FreeBSD__) || defined (__NetBSD__) || defined (__OpenBSD__) || defined (__APPLE__) || \
diff --git a/ACE/examples/IPC_SAP/FILE_SAP/client.cpp b/ACE/examples/IPC_SAP/FILE_SAP/client.cpp
index f26302f3b57..7c2402f0b3e 100644
--- a/ACE/examples/IPC_SAP/FILE_SAP/client.cpp
+++ b/ACE/examples/IPC_SAP/FILE_SAP/client.cpp
@@ -55,7 +55,7 @@ ACE_TMAIN (int argc, ACE_TCHAR *argv[])
static_cast<u_long > (fileinfo.nlink_),
(u_long) fileinfo.size_);
- off_t fpos = cli_file.tell ();
+ ACE_OFF_T fpos = cli_file.tell ();
if (fpos == -1)
ACE_ERROR_RETURN ((LM_ERROR,
diff --git a/ACE/examples/Web_Crawler/Iterators.cpp b/ACE/examples/Web_Crawler/Iterators.cpp
index 98b4f999622..232042cb835 100644
--- a/ACE/examples/Web_Crawler/Iterators.cpp
+++ b/ACE/examples/Web_Crawler/Iterators.cpp
@@ -46,7 +46,7 @@ HTML_Body_Iterator::next (ACE_CString &url)
if ( href_index > 0)
{
// Get back to buffer start location.
- this->url_.stream ().seek (-1 * static_cast<off_t> (len),
+ this->url_.stream ().seek (-1 * static_cast<ACE_OFF_T> (len),
SEEK_CUR);
int start_index = buffer.find ('\"',
diff --git a/ACE/examples/Web_Crawler/Mem_Map_Stream.cpp b/ACE/examples/Web_Crawler/Mem_Map_Stream.cpp
index dda1d465a71..26422e07dd3 100644
--- a/ACE/examples/Web_Crawler/Mem_Map_Stream.cpp
+++ b/ACE/examples/Web_Crawler/Mem_Map_Stream.cpp
@@ -70,7 +70,7 @@ Mem_Map_Stream::recv (size_t &len)
const char *s = this->recv_pos_;
- off_t olen = static_cast <off_t> (len);
+ ACE_OFF_T olen = static_cast <ACE_OFF_T> (len);
this->seek (olen, SEEK_CUR);
len = this->get_pos_ - s;
return s;
@@ -94,8 +94,8 @@ Mem_Map_Stream::peek_str (size_t offset,
return &this->get_pos_[offset];
}
-off_t
-Mem_Map_Stream::seek (off_t offset, int whence)
+ACE_OFF_T
+Mem_Map_Stream::seek (ACE_OFF_T offset, int whence)
{
switch (whence)
{
@@ -120,7 +120,7 @@ Mem_Map_Stream::seek (off_t offset, int whence)
// Make sure that the backing store will cover this.
while (this->get_pos_ > this->end_of_mapping_plus1_)
if (this->grow_file_and_remap () == -1)
- return (off_t) -1;
+ return (ACE_OFF_T) -1;
this->recv_pos_ = this->get_pos_;
return this->recv_pos_ - reinterpret_cast<char *> (this->mem_map_.addr ());
diff --git a/ACE/examples/Web_Crawler/Mem_Map_Stream.h b/ACE/examples/Web_Crawler/Mem_Map_Stream.h
index 3595f04ab77..b7aa58c85f0 100644
--- a/ACE/examples/Web_Crawler/Mem_Map_Stream.h
+++ b/ACE/examples/Web_Crawler/Mem_Map_Stream.h
@@ -124,7 +124,7 @@ public:
// store if necessary. Returns 0 if <offset> or <offset + size> is
// past the end of the stream.
- virtual off_t seek (off_t offset, int whence = SEEK_CUR);
+ virtual ACE_OFF_T seek (ACE_OFF_T offset, int whence = SEEK_CUR);
// Sets the <get> and <recv> positions as follows:
// o If <whence> is <SEEK_SET>, the positions are set to <offset>
// bytes from the start of the stream.