Changes to attempt to silence bcc64x
[ACE_TAO.git] / ACE / tests / TSS_Test_Errno.h
blobde556a585fca1f74ebecb55c4460fdc46bfa4edd
1 /* -*- C++ -*- */
3 //=============================================================================
4 /**
5 * @file TSS_Test_Errno.h
7 * This file contains the definition of Errno.
9 * @author Douglas C. Schmidt <d.schmidt@vanderbilt.edu>
11 //=============================================================================
14 #include "ace/Guard_T.h"
15 #include "ace/Thread_Mutex.h"
17 /**
18 * @class Errno
20 * @brief Define a simple Errno abstraction
22 * It is only used by TSS_Test.cpp.
24 class Errno
26 public:
27 Errno()
29 ACE_MT (ACE_GUARD (ACE_Thread_Mutex, ace_Mon, *Errno::lock_));
30 created_ += 1;
32 ~Errno()
34 ACE_MT (ACE_GUARD (ACE_Thread_Mutex, ace_Mon, *Errno::lock_));
35 deleted_ += 1;
38 int error () { return this->errno_; }
39 void error (int i) { this->errno_ = i; }
41 int line () { return this->lineno_; }
42 void line (int l) { this->lineno_ = l; }
44 // Errno::flags_ is a static variable, so we've got to protect it
45 // with a mutex since it isn't kept in thread-specific storage.
46 int flags ()
48 ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_Mon, *Errno::lock_, -1));
50 return Errno::flags_;
52 int flags (int f)
54 ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, *Errno::lock_, -1));
56 Errno::flags_ = f;
57 return 0;
60 static int created ()
62 return created_;
65 static int deleted ()
67 return deleted_;
70 #if defined (ACE_HAS_THREADS)
71 static
72 ACE_Thread_Mutex *
73 allocate_lock ()
75 ACE_NEW_RETURN (Errno::lock_, ACE_Thread_Mutex, 0);
76 return Errno::lock_;
79 static
80 void
81 deallocate_lock () { delete lock_; lock_ = 0; }
82 #endif /* ACE_HAS_THREADS */
84 private:
85 // = errno_ and lineno_ will be thread-specific data so they don't
86 // need a lock.
87 int errno_;
88 int lineno_;
90 static int flags_;
91 static int created_;
92 static int deleted_;
93 #if defined (ACE_HAS_THREADS)
94 // flags_ needs a lock.
95 static ACE_Thread_Mutex *lock_;
96 #endif /* ACE_HAS_THREADS */