aboutsummaryrefslogtreecommitdiff
path: root/externals/ace/OS_Errno.h
diff options
context:
space:
mode:
authorXanadu <none@none>2010-07-20 02:49:28 +0200
committerXanadu <none@none>2010-07-20 02:49:28 +0200
commit79622802f397258ee0f34327ba3ae6977ca3e7ff (patch)
tree1868946c234ab9ee256a6b7766a15713eae94235 /externals/ace/OS_Errno.h
parent7dd2dc91816ab8b3bc3b99a1b1c99c7ea314d5a8 (diff)
parentf906976837502fa5aa81b982b901d1509f5aa0c4 (diff)
Merge. Revision history for source files should be all back now.
--HG-- branch : trunk rename : sql/CMakeLists.txt => sql/tools/CMakeLists.txt rename : src/server/game/Pools/PoolHandler.cpp => src/server/game/Pools/PoolMgr.cpp rename : src/server/game/Pools/PoolHandler.h => src/server/game/Pools/PoolMgr.h rename : src/server/game/PrecompiledHeaders/NixCorePCH.cpp => src/server/game/PrecompiledHeaders/gamePCH.cpp rename : src/server/game/PrecompiledHeaders/NixCorePCH.h => src/server/game/PrecompiledHeaders/gamePCH.h
Diffstat (limited to 'externals/ace/OS_Errno.h')
-rw-r--r--externals/ace/OS_Errno.h100
1 files changed, 100 insertions, 0 deletions
diff --git a/externals/ace/OS_Errno.h b/externals/ace/OS_Errno.h
new file mode 100644
index 00000000000..bda24ad0a90
--- /dev/null
+++ b/externals/ace/OS_Errno.h
@@ -0,0 +1,100 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file OS_Errno.h
+ *
+ * $Id: OS_Errno.h 83891 2008-11-28 11:01:50Z johnnyw $
+ *
+ * @author (Originally in OS.h)Doug Schmidt <schmidt@cs.wustl.edu>
+ */
+//=============================================================================
+
+#ifndef ACE_OS_ERRNO_H
+#define ACE_OS_ERRNO_H
+#include /**/ "ace/pre.h"
+
+#include /**/ "ace/ACE_export.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ace/OS_NS_errno.h"
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+/**
+ * @class ACE_Errno_Guard
+ *
+ * @brief Provides a wrapper to improve performance when thread-specific
+ * errno must be saved and restored in a block of code.
+ *
+ * The typical use-case for this is the following:
+ * int error = errno;
+ * call_some_function_that_might_change_errno ();
+ * errno = error;
+ * This can be replaced with
+ * {
+ * ACE_Errno_Guard guard (errno);
+ * call_some_function_that_might_change_errno ();
+ * }
+ * This implementation is more elegant and more efficient since it
+ * avoids an unnecessary second access to thread-specific storage
+ * by caching a pointer to the value of errno in TSS.
+ */
+class ACE_Export ACE_Errno_Guard
+{
+public:
+ /// Stash the value of @a error into @c error_ and initialize the
+ /// @c errno_ptr_ to the address of @a errno_ref.
+ ACE_Errno_Guard (ACE_ERRNO_TYPE &errno_ref,
+ int error);
+
+ /// Initialize the @c errno_ptr_ to the address of @a errno_ref.
+ ACE_Errno_Guard (ACE_ERRNO_TYPE &errno_ref);
+
+ /// Reset the value of @c errno to <error>.
+ ~ACE_Errno_Guard (void);
+
+#if defined (ACE_HAS_WINCE_BROKEN_ERRNO)
+ /// Assign @a errno_ref to <error_>.
+ int operator= (const ACE_ERRNO_TYPE &errno_ref);
+#endif /* ACE_HAS_WINCE_BROKEN_ERRNO */
+
+ /// Assign <error> to <error_>.
+ int operator= (int error);
+
+ /// Compare <error> with <error_> for equality.
+ bool operator== (int error);
+
+ /// Compare <error> with <error_> for inequality.
+ bool operator!= (int error);
+
+private:
+ // Prevent copying
+ ACE_Errno_Guard (const ACE_Errno_Guard &);
+ ACE_Errno_Guard &operator= (const ACE_Errno_Guard &);
+
+#if defined (ACE_MT_SAFE)
+ ACE_ERRNO_TYPE *errno_ptr_;
+#endif /* ACE_MT_SAFE */
+ int error_;
+};
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+// Inlining this class on debug builds with gcc on Solaris can cause
+// deadlocks during static initialization. On non debug builds it
+// causes compilation errors.
+#if defined (ACE_HAS_INLINED_OSCALLS) && \
+ (!defined (__GNUG__) || !defined (__sun__))
+# if defined (ACE_INLINE)
+# undef ACE_INLINE
+# endif /* ACE_INLINE */
+# define ACE_INLINE inline
+# include "ace/OS_Errno.inl"
+#endif /* ACE_HAS_INLINED_OSCALLS */
+
+#include /**/ "ace/post.h"
+#endif /* ACE_OS_ERRNO_H */