OS_NS_errno.inl

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // OS_NS_errno.inl,v 1.6 2005/10/28 16:14:54 ossama Exp
00004 
00005 #include "ace/config-all.h"    /* Need ACE_TRACE */
00006 
00007 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00008 
00009 ACE_INLINE int
00010 ACE_OS::last_error (void)
00011 {
00012   // ACE_OS_TRACE ("ACE_OS::last_error");
00013 
00014 #if defined (ACE_WIN32)
00015   // ACE_OS::last_error() prefers errnor since started out as a way to
00016   // avoid directly accessing errno in ACE code - particularly the ACE
00017   // C++ socket wrapper facades.  On Windows, some things that would
00018   // use errno on UNIX require ::GetLastError(), so this method tries
00019   // to shield the rest of ACE from having to know about this.
00020   int lerror = ::GetLastError ();
00021   int lerrno = errno;
00022   return lerrno == 0 ? lerror : lerrno;
00023 #else
00024   return errno;
00025 #endif /* ACE_WIN32 */
00026 }
00027 
00028 ACE_INLINE void
00029 ACE_OS::last_error (int error)
00030 {
00031   ACE_OS_TRACE ("ACE_OS::last_error");
00032 #if defined (ACE_WIN32)
00033   ::SetLastError (error);
00034 #endif /* ACE_WIN32 */
00035   errno = error;
00036 }
00037 
00038 ACE_INLINE int
00039 ACE_OS::set_errno_to_last_error (void)
00040 {
00041 # if defined (ACE_WIN32)
00042 // Borland C++ Builder 4 has a bug in the RTL that resets the
00043 // <GetLastError> value to zero when errno is accessed.  Thus, we have
00044 // to use this to set errno to GetLastError.  It's bad, but only for
00045 // WIN32.
00046 #   if defined(__BORLANDC__) && (__BORLANDC__ == 0x540) || defined (__IBMCPP__) && (__IBMCPP__ >= 400)
00047   int last_error = ::GetLastError ();
00048   return errno = last_error;
00049 #   else /* defined(__BORLANDC__) && (__BORLANDC__ == 0x540) */
00050   return errno = ::GetLastError ();
00051 #   endif /* defined(__BORLANDC__) && (__BORLANDC__ == 0x540) */
00052 #else
00053   return errno;
00054 # endif /* defined(ACE_WIN32) */
00055 }
00056 
00057 ACE_INLINE int
00058 ACE_OS::set_errno_to_wsa_last_error (void)
00059 {
00060 # if defined (ACE_WIN32)
00061 // Borland C++ Builder 4 has a bug in the RTL that resets the
00062 // <GetLastError> value to zero when errno is accessed.  Thus, we have
00063 // to use this to set errno to GetLastError.  It's bad, but only for
00064 // WIN32
00065 #   if defined(__BORLANDC__) && (__BORLANDC__ == 0x540) || defined (__IBMCPP__) && (__IBMCPP__ >= 400)
00066   int last_error = ::WSAGetLastError ();
00067   return errno = last_error;
00068 #   else /* defined(__BORLANDC__) && (__BORLANDC__ == 0x540) */
00069   return errno = ::WSAGetLastError ();
00070 #   endif /* defined(__BORLANDC__) && (__BORLANDC__ == 0x540) */
00071 #else
00072   return errno;
00073 # endif /* defined(ACE_WIN32) */
00074 }
00075 
00076 #if defined (ACE_HAS_WINCE_BROKEN_ERRNO)
00077 
00078 ACE_INLINE ACE_CE_Errno *
00079 ACE_CE_Errno::instance ()
00080 {
00081   // This should be inlined.
00082   return ACE_CE_Errno::instance_;
00083 }
00084 
00085 ACE_INLINE
00086 ACE_CE_Errno::operator int (void) const
00087 {
00088   return (int) TlsGetValue (ACE_CE_Errno::errno_key_);
00089 }
00090 
00091 ACE_INLINE int
00092 ACE_CE_Errno::operator= (int x)
00093 {
00094   // error checking?
00095   TlsSetValue (ACE_CE_Errno::errno_key_, (void *) x);
00096   return x;
00097 }
00098 
00099 #endif /* ACE_HAS_WINCE_BROKEN_ERRNO */
00100 
00101 ACE_END_VERSIONED_NAMESPACE_DECL

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