Changes to attempt to silence bcc64x
[ACE_TAO.git] / ACE / ace / OS_NS_macros.h
blobac1c5e2f941c5f19c67c55851110cbd438f41039
1 // -*- C++ -*-
3 //=============================================================================
4 /**
5 * @file OS_NS_macros.h
7 * @author Douglas C. Schmidt <d.schmidt@vanderbilt.edu>
8 * @author Jesper S. M|ller<stophph@diku.dk>
9 * @author and a cast of thousands...
11 //=============================================================================
13 #ifndef ACE_OS_NS_MACROS_H
14 # define ACE_OS_NS_MACROS_H
16 # include /**/ "ace/pre.h"
18 # include "ace/config-all.h"
20 # if !defined (ACE_LACKS_PRAGMA_ONCE)
21 # pragma once
22 # endif /* ACE_LACKS_PRAGMA_ONCE */
24 #if defined (ACE_WIN32)
25 # define ACE_SOCKCALL_RETURN(OP,TYPE,FAILVALUE) \
26 do { TYPE ace_result_ = (TYPE) OP; \
27 if (ace_result_ == FAILVALUE) { int ___ = ::WSAGetLastError (); errno = ___; return (TYPE) FAILVALUE; } else return ace_result_; \
28 } while (0)
29 # define ACE_SOCKCALL(OP,TYPE,FAILVALUE,RESULT) \
30 do { RESULT = (TYPE) OP; \
31 if (RESULT == FAILVALUE) { int ___ = ::WSAGetLastError (); errno = ___; RESULT = FAILVALUE; } \
32 } while (0)
33 #else
34 # define ACE_SOCKCALL_RETURN(OP,TYPE,FAILVALUE) ACE_OSCALL_RETURN(OP,TYPE)
35 # define ACE_SOCKCALL(OP,TYPE,FAILVALUE,RESULT) ACE_OSCALL(OP,TYPE,RESULT)
36 #endif /* ACE_WIN32 */
38 #if !defined (ACE_WIN32)
40 // Adapt the weird threading and synchronization routines (which
41 // return errno rather than -1) so that they return -1 and set errno.
42 // This is more consistent with the rest of ACE_OS and enables us to
43 // use the ACE_OSCALL* macros.
44 # if defined (ACE_VXWORKS)
45 # define ACE_ADAPT_RETVAL(OP,RESULT) ((RESULT = (OP)) != OK ? (errno = RESULT, -1) : 0)
46 # else
47 # define ACE_ADAPT_RETVAL(OP,RESULT) ((RESULT = (OP)) != 0 ? (errno = RESULT, -1) : 0)
48 # endif /* ACE_VXWORKS */
50 #else /* ACE_WIN32 */
52 // Adapt the Win32 System Calls (which return BOOLEAN values of TRUE
53 // and FALSE) into int values expected by the ACE_OSCALL macros.
54 # define ACE_ADAPT_RETVAL(OP,RESULT) ((RESULT = (OP)) == FALSE ? -1 : 0)
56 // Perform a mapping of Win32 error numbers into POSIX errnos.
57 # define ACE_FAIL_RETURN(RESULT) do { \
58 switch (ACE_OS::set_errno_to_last_error ()) { \
59 case ERROR_NOT_ENOUGH_MEMORY: errno = ENOMEM; break; \
60 case ERROR_FILE_EXISTS: errno = EEXIST; break; \
61 case ERROR_SHARING_VIOLATION: errno = EACCES; break; \
62 case ERROR_PATH_NOT_FOUND: errno = ENOENT; break; \
63 } \
64 return RESULT; } while (0)
66 #endif /* !ACE_WIN32 */
68 // Helper functions to split large integers into smaller high-order
69 // and low-order parts, and reconstitute them again. These are
70 // required primarily for supporting _FILE_OFFSET_BITS==64 on windows.
71 #if defined(ACE_WIN32)
72 # if defined(_FILE_OFFSET_BITS) && (_FILE_OFFSET_BITS==64)
73 # include "ace/Basic_Types.h"
75 # define ACE_LOW_PART(X) static_cast<DWORD>(X)
77 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
78 LONG
79 inline ACE_High_Part (LONGLONG value)
81 LARGE_INTEGER new_value;
82 new_value.QuadPart = value;
83 return new_value.HighPart;
85 # define ACE_HIGH_PART(X) ACE_High_Part(X)
87 LONGLONG
88 inline ACE_Combine_Parts (LONG high, DWORD low)
90 LARGE_INTEGER value;
91 value.LowPart = low; // DWORD
92 value.HighPart = high; // LONG
93 return value.QuadPart;
95 ACE_END_VERSIONED_NAMESPACE_DECL
97 # define ACE_COMBINE_PARTS(X,Y) ACE_Combine_Parts(X,Y)
98 # else /* _FILE_OFFSET_BITS==64 */
99 # define ACE_LOW_PART(X) X
100 # define ACE_HIGH_PART(X) 0
101 # define ACE_COMBINE_PARTS(X,Y) X
102 # endif /* _FILE_OFFSET_BITS==64 */
103 #endif /* ACE_WIN32 */
105 // 64-bit quad-word definitions.
106 #if defined (ACE_WIN32)
107 # if defined (_FILE_OFFSET_BITS) && (_FILE_OFFSET_BITS == 64)
108 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
109 typedef unsigned __int64 ACE_QWORD;
110 inline ACE_QWORD ACE_Make_QWORD (DWORD lo, DWORD hi) { return ACE_QWORD (lo) | (ACE_QWORD (hi) << 32); }
111 inline DWORD ACE_Low_DWORD (ACE_QWORD q) { return (DWORD) q; }
112 inline DWORD ACE_High_DWORD (ACE_QWORD q) { return (DWORD) (q >> 32); }
113 ACE_END_VERSIONED_NAMESPACE_DECL
114 # endif /* _FILE_OFFSET_BITS==64 */
115 #endif /* ACE_WIN32 */
117 # include /**/ "ace/post.h"
119 #endif /* ACE_OS_NS_MACROS_H */