OS_NS_macros.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  *  @file   OS_NS_macros.h
00006  *
00007  *  OS_NS_macros.h,v 1.9 2006/05/30 10:57:22 jwillemsen Exp
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 # include /**/ "ace/post.h"
00073 
00074 #endif /* ACE_OS_NS_MACROS_H */

Generated on Thu Nov 9 09:41:57 2006 for ACE by doxygen 1.3.6