[6916] Fixed typos in spell checking code.
[getmangos.git] / dep / ACE_wrappers / ace / OS_NS_macros.h
bloba949ce2472cf4134a13b8756f088e81585921d75
1 // -*- C++ -*-
3 //=============================================================================
4 /**
5 * @file OS_NS_macros.h
7 * $Id: OS_NS_macros.h 80826 2008-03-04 14:51:23Z wotte $
9 * @author Douglas C. Schmidt <schmidt@cs.wustl.edu>
10 * @author Jesper S. M|ller<stophph@diku.dk>
11 * @author and a cast of thousands...
13 * Originally in OS.h.
15 //=============================================================================
17 #ifndef ACE_OS_NS_MACROS_H
18 # define ACE_OS_NS_MACROS_H
20 # include /**/ "ace/pre.h"
22 # include "ace/config-all.h"
24 # if !defined (ACE_LACKS_PRAGMA_ONCE)
25 # pragma once
26 # endif /* ACE_LACKS_PRAGMA_ONCE */
28 #if defined (ACE_WIN32)
29 # define ACE_SOCKCALL_RETURN(OP,TYPE,FAILVALUE) \
30 do { TYPE ace_result_ = (TYPE) OP; \
31 if (ace_result_ == FAILVALUE) { int ___ = ::WSAGetLastError (); errno = ___; return (TYPE) FAILVALUE; } else return ace_result_; \
32 } while (0)
33 # define ACE_SOCKCALL(OP,TYPE,FAILVALUE,RESULT) \
34 do { RESULT = (TYPE) OP; \
35 if (RESULT == FAILVALUE) { int ___ = ::WSAGetLastError (); errno = ___; RESULT = FAILVALUE; } \
36 } while (0)
37 #else
38 # define ACE_SOCKCALL_RETURN(OP,TYPE,FAILVALUE) ACE_OSCALL_RETURN(OP,TYPE,FAILVALUE)
39 # define ACE_SOCKCALL(OP,TYPE,FAILVALUE,RESULT) ACE_OSCALL(OP,TYPE,FAILVALUE,RESULT)
40 #endif /* ACE_WIN32 */
42 #if !defined (ACE_WIN32)
44 // Adapt the weird threading and synchronization routines (which
45 // return errno rather than -1) so that they return -1 and set errno.
46 // This is more consistent with the rest of ACE_OS and enables us to
47 // use the ACE_OSCALL* macros.
48 # if defined (ACE_VXWORKS)
49 # define ACE_ADAPT_RETVAL(OP,RESULT) ((RESULT = (OP)) != OK ? (errno = RESULT, -1) : 0)
50 # else
51 # define ACE_ADAPT_RETVAL(OP,RESULT) ((RESULT = (OP)) != 0 ? (errno = RESULT, -1) : 0)
52 # endif /* ACE_VXWORKS */
54 #else /* ACE_WIN32 */
56 // Adapt the Win32 System Calls (which return BOOLEAN values of TRUE
57 // and FALSE) into int values expected by the ACE_OSCALL macros.
58 # define ACE_ADAPT_RETVAL(OP,RESULT) ((RESULT = (OP)) == FALSE ? -1 : 0)
60 // Perform a mapping of Win32 error numbers into POSIX errnos.
61 # define ACE_FAIL_RETURN(RESULT) do { \
62 switch (ACE_OS::set_errno_to_last_error ()) { \
63 case ERROR_NOT_ENOUGH_MEMORY: errno = ENOMEM; break; \
64 case ERROR_FILE_EXISTS: errno = EEXIST; break; \
65 case ERROR_SHARING_VIOLATION: errno = EACCES; break; \
66 case ERROR_PATH_NOT_FOUND: errno = ENOENT; break; \
67 } \
68 return RESULT; } while (0)
70 #endif /* !ACE_WIN32 */
72 // Helper functions to split large intergers into smaller high-order
73 // and low-order parts, and reconstitute them again. These are
74 // required primarily for supporting _FILE_OFFSET_BITS==64 on windows.
76 #if defined(ACE_WIN32)
77 # if defined(_FILE_OFFSET_BITS) && (_FILE_OFFSET_BITS==64)
78 # include "ace/Basic_Types.h"
80 # define ACE_LOW_PART(X) static_cast<DWORD>(X)
82 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
83 LONG
84 inline ACE_High_Part (ACE_OFF_T value)
86 LARGE_INTEGER new_value;
87 new_value.QuadPart = value;
88 return new_value.HighPart;
90 # define ACE_HIGH_PART(X) ACE_High_Part(X)
92 LONGLONG
93 inline ACE_Combine_Parts (LONG high, DWORD low)
95 LARGE_INTEGER value;
96 value.LowPart = low; // DWORD
97 value.HighPart = high; // LONG
98 return value.QuadPart;
100 ACE_END_VERSIONED_NAMESPACE_DECL
102 # define ACE_COMBINE_PARTS(X,Y) ACE_Combine_Parts(X,Y)
103 # else /* _FILE_OFFSET_BITS==64 */
104 # define ACE_LOW_PART(X) X
105 # define ACE_HIGH_PART(X) 0
106 # define ACE_COMBINE_PARTS(X,Y) X
107 # endif /* _FILE_OFFSET_BITS==64 */
108 #endif /* ACE_WIN32 */
112 # include /**/ "ace/post.h"
114 #endif /* ACE_OS_NS_MACROS_H */