OS_NS_macros.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  *  @file   OS_NS_macros.h
00006  *
00007  *  $Id: OS_NS_macros.h 80826 2008-03-04 14:51:23Z wotte $
00008  *
00009  *  @author Douglas C. Schmidt <schmidt@cs.wustl.edu>
00010  *  @author Jesper S. M|ller<stophph@diku.dk>
00011  *  @author and a cast of thousands...
00012  *
00013  *  Originally in OS.h.
00014  */
00015 //=============================================================================
00016 
00017 #ifndef ACE_OS_NS_MACROS_H
00018 # define ACE_OS_NS_MACROS_H
00019 
00020 # include /**/ "ace/pre.h"
00021 
00022 # include "ace/config-all.h"
00023 
00024 # if !defined (ACE_LACKS_PRAGMA_ONCE)
00025 #  pragma once
00026 # endif /* ACE_LACKS_PRAGMA_ONCE */
00027 
00028 #if defined (ACE_WIN32)
00029 # define ACE_SOCKCALL_RETURN(OP,TYPE,FAILVALUE) \
00030   do { TYPE ace_result_ = (TYPE) OP; \
00031       if (ace_result_ == FAILVALUE) { int ___ = ::WSAGetLastError (); errno = ___; return (TYPE) FAILVALUE; } else return ace_result_; \
00032   } while (0)
00033 # define ACE_SOCKCALL(OP,TYPE,FAILVALUE,RESULT) \
00034   do { RESULT = (TYPE) OP; \
00035       if (RESULT == FAILVALUE) { int ___ = ::WSAGetLastError (); errno = ___; RESULT = FAILVALUE; } \
00036   } while (0)
00037 #else
00038 # define ACE_SOCKCALL_RETURN(OP,TYPE,FAILVALUE) ACE_OSCALL_RETURN(OP,TYPE,FAILVALUE)
00039 # define ACE_SOCKCALL(OP,TYPE,FAILVALUE,RESULT) ACE_OSCALL(OP,TYPE,FAILVALUE,RESULT)
00040 #endif /* ACE_WIN32 */
00041 
00042 #if !defined (ACE_WIN32)
00043 
00044 // Adapt the weird threading and synchronization routines (which
00045 // return errno rather than -1) so that they return -1 and set errno.
00046 // This is more consistent with the rest of ACE_OS and enables us to
00047 // use the ACE_OSCALL* macros.
00048 # if defined (ACE_VXWORKS)
00049 #   define ACE_ADAPT_RETVAL(OP,RESULT) ((RESULT = (OP)) != OK ? (errno = RESULT, -1) : 0)
00050 # else
00051 #   define ACE_ADAPT_RETVAL(OP,RESULT) ((RESULT = (OP)) != 0 ? (errno = RESULT, -1) : 0)
00052 # endif /* ACE_VXWORKS */
00053 
00054 #else /* ACE_WIN32 */
00055 
00056 // Adapt the Win32 System Calls (which return BOOLEAN values of TRUE
00057 // and FALSE) into int values expected by the ACE_OSCALL macros.
00058 # define ACE_ADAPT_RETVAL(OP,RESULT) ((RESULT = (OP)) == FALSE ? -1 : 0)
00059 
00060 // Perform a mapping of Win32 error numbers into POSIX errnos.
00061 # define ACE_FAIL_RETURN(RESULT) do { \
00062   switch (ACE_OS::set_errno_to_last_error ()) { \
00063   case ERROR_NOT_ENOUGH_MEMORY: errno = ENOMEM; break; \
00064   case ERROR_FILE_EXISTS:       errno = EEXIST; break; \
00065   case ERROR_SHARING_VIOLATION: errno = EACCES; break; \
00066   case ERROR_PATH_NOT_FOUND:    errno = ENOENT; break; \
00067   } \
00068   return RESULT; } while (0)
00069 
00070 #endif /* !ACE_WIN32 */
00071 
00072 // Helper functions to split large intergers into smaller high-order
00073 // and low-order parts, and reconstitute them again.  These are
00074 // required primarily for supporting _FILE_OFFSET_BITS==64 on windows.
00075 
00076 #if defined(ACE_WIN32)
00077 #  if defined(_FILE_OFFSET_BITS) && (_FILE_OFFSET_BITS==64)
00078 #    include "ace/Basic_Types.h"
00079 
00080 #    define ACE_LOW_PART(X) static_cast<DWORD>(X)
00081 
00082 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00083 LONG
00084 inline ACE_High_Part (ACE_OFF_T value)
00085 {
00086   LARGE_INTEGER new_value;
00087   new_value.QuadPart = value;
00088   return new_value.HighPart;
00089 }
00090 #    define ACE_HIGH_PART(X) ACE_High_Part(X)
00091 
00092 LONGLONG
00093 inline ACE_Combine_Parts (LONG high, DWORD low)
00094 {
00095   LARGE_INTEGER value;
00096   value.LowPart = low;    // DWORD
00097   value.HighPart = high;  // LONG
00098   return value.QuadPart;
00099 }
00100 ACE_END_VERSIONED_NAMESPACE_DECL
00101 
00102 #    define ACE_COMBINE_PARTS(X,Y) ACE_Combine_Parts(X,Y)
00103 #  else  /* _FILE_OFFSET_BITS==64 */
00104 #    define ACE_LOW_PART(X) X
00105 #    define ACE_HIGH_PART(X) 0
00106 #    define ACE_COMBINE_PARTS(X,Y) X
00107 #  endif /* _FILE_OFFSET_BITS==64 */
00108 #endif /* ACE_WIN32 */
00109 
00110 
00111 
00112 # include /**/ "ace/post.h"
00113 
00114 #endif /* ACE_OS_NS_MACROS_H */

Generated on Tue Feb 2 17:18:41 2010 for ACE by  doxygen 1.4.7