Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

OS.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  *  @file   OS.h
00006  *
00007  *  $Id: OS.h,v 1.1.1.4.2.2 2003/05/19 16:25:44 chad 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 //=============================================================================
00014 
00015 #ifndef ACE_OS_H
00016 #define ACE_OS_H
00017 
00018 #include "ace/pre.h"
00019 
00020 #include "ace/config-all.h"
00021 
00022 #if defined (ACE_HAS_VIRTUAL_TIME)
00023 #include /**/ <sys/times.h>
00024 #endif /*ACE_HAS_VIRTUAL_TIME*/
00025 
00026 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00027 # pragma once
00028 #endif /* ACE_LACKS_PRAGMA_ONCE */
00029 
00030 // Include the split up ACE_OS classes
00031 #include "ace/OS_Dirent.h"
00032 #include "ace/OS_String.h"
00033 #include "ace/OS_Memory.h"
00034 #include "ace/OS_TLI.h"
00035 #include "ace/OS_Errno.h"
00036 
00037 #include "ace/Time_Value.h"
00038 
00039 class ACE_Timeout_Manager;
00040 
00041 #if !defined (_SC_AIO_MAX)
00042 #define _SC_AIO_MAX 1
00043 #endif /* _SC_AIO_MAX */
00044 
00045 // Do not change these values wantonly since GPERF depends on them..
00046 #define ACE_ASCII_SIZE 128
00047 #define ACE_EBCDIC_SIZE 256
00048 
00049 #if 'a' < 'A'
00050 #define ACE_HAS_EBCDIC
00051 #define ACE_STANDARD_CHARACTER_SET_SIZE 256
00052 #else
00053 #define ACE_HAS_ASCII
00054 #define ACE_STANDARD_CHARACTER_SET_SIZE 128
00055 #endif /* 'a' < 'A' */
00056 
00057 # if defined (ACE_PSOS_TM)
00058 typedef long long longlong_t;
00059 typedef long      id_t;
00060 # endif /* ACE_PSOS_TM */
00061 
00062 // Deal with MSVC++ insanity for CORBA...
00063 # if defined (ACE_HAS_BROKEN_NAMESPACES)
00064 #   define ACE_CORBA_1(NAME) CORBA_##NAME
00065 #   define ACE_CORBA_2(TYPE, NAME) CORBA_##TYPE##_##NAME
00066 #   define ACE_CORBA_3(TYPE, NAME) CORBA_##TYPE::NAME
00067 #   define ACE_NESTED_CLASS(TYPE, NAME) NAME
00068 # else  /* ! ACE_HAS_BROKEN_NAMESPACES */
00069 #   define ACE_CORBA_1(NAME) CORBA::NAME
00070 #   define ACE_CORBA_2(TYPE, NAME) CORBA::TYPE::NAME
00071 #   define ACE_CORBA_3(TYPE, NAME) CORBA::TYPE::NAME
00072 #   define ACE_NESTED_CLASS(TYPE, NAME) TYPE::NAME
00073 # endif /* ! ACE_HAS_BROKEN_NAMESPACES */
00074 
00075 // Here are all ACE-specific default constants, needed throughout ACE
00076 // and its applications.  The values can be over written by user
00077 // specific values in config.h files.
00078 #include "ace/Default_Constants.h"
00079 
00080 # if defined (ACE_HAS_4_4BSD_SENDMSG_RECVMSG)
00081     // Control message size to pass a file descriptor.
00082 #   define ACE_BSD_CONTROL_MSG_LEN sizeof (struct cmsghdr) + sizeof (ACE_HANDLE)
00083 #   if defined (ACE_LACKS_CMSG_DATA_MACRO)
00084 #     if defined (ACE_LACKS_CMSG_DATA_MEMBER)
00085 #       define CMSG_DATA(cmsg) ((unsigned char *) ((struct cmsghdr *) (cmsg) + 1))
00086 #     else
00087 #       define CMSG_DATA(cmsg) ((cmsg)->cmsg_data)
00088 #     endif /* ACE_LACKS_CMSG_DATA_MEMBER */
00089 #   endif /* ACE_LACKS_CMSG_DATA_MACRO */
00090 # endif /* ACE_HAS_4_4BSD_SENDMSG_RECVMSG */
00091 
00092 
00093 // Default size of the ACE Reactor.
00094 # if defined (FD_SETSIZE)
00095 int const ACE_FD_SETSIZE = FD_SETSIZE;
00096 # else
00097 #   define ACE_FD_SETSIZE FD_SETSIZE
00098 # endif /* ACE_FD_SETSIZE */
00099 
00100 # if !defined (ACE_DEFAULT_SELECT_REACTOR_SIZE)
00101 #   define ACE_DEFAULT_SELECT_REACTOR_SIZE ACE_FD_SETSIZE
00102 # endif /* ACE_DEFAULT_SELECT_REACTOR_SIZE */
00103 
00104 
00105 // Here are all ACE-specific global declarations needed throughout
00106 // ACE.
00107 #include "ace/Global_Macros.h"
00108 
00109 #if !defined (ACE_WIN32)
00110 #define ACE_MAX_USERID L_cuserid
00111 #endif /*!ACE_WIN32*/
00112 
00113 // include the ACE min()/max() functions.
00114 # include "ace/Min_Max.h"
00115 
00116 
00117 // These hooks enable ACE to have all dynamic memory management
00118 // automatically handled on a per-object basis.
00119 
00120 # if defined (ACE_LACKS_KEY_T)
00121 #   if defined (ACE_WIN32)
00122    // Win32 doesn't use numeric values to name its semaphores, it uses
00123    // strings!
00124 typedef char *key_t;
00125 #   else
00126 typedef int key_t;
00127 #   endif /* ACE_WIN32 */
00128 # endif /* ACE_LACKS_KEY_T */
00129 
00130 ///////////////////////////////////////////
00131 //                                       //
00132 // NOTE: Please do not add any #includes //
00133 //       before this point.  On VxWorks, //
00134 //       vxWorks.h must be #included     //
00135 //       first!                          //
00136 //                                       //
00137 ///////////////////////////////////////////
00138 
00139 # if defined (ACE_PSOS)
00140 
00141 #   if defined (ACE_LACKS_ASSERT_MACRO)
00142 #     define assert(expr)
00143 #   endif
00144 
00145 #   if defined (ACE_PSOSIM)
00146 
00147 #     include /**/ "ace/sys_conf.h" /* system configuration file */
00148 #     include /**/ <psos.h>         /* pSOS+ system calls                */
00149 #     include /**/ <pna.h>          /* pNA+ TCP/IP Network Manager calls */
00150 
00151     /* In the *simulator* environment, use unsigned int for size_t */
00152 #     define size_t  unsigned int
00153 
00154 
00155     /*   include <rpc.h>       pRPC+ Remote Procedure Call Library calls   */
00156     /*                         are not supported by pSOSim                 */
00157     /*                                                                     */
00158     /*   include <phile.h>     pHILE+ file system calls are not supported  */
00159     /*                         by pSOSim *so*, for the time being, we make */
00160     /*                         use of UNIX file system headers and then    */
00161     /*                         when we have time, we wrap UNIX file system */
00162     /*                         calls w/ pHILE+ wrappers, and modify ACE to */
00163     /*                         use the wrappers under pSOSim               */
00164 
00165     /* put includes for necessary UNIX file system calls here */
00166 #     include /**/ <sys/stat.h>
00167 #     include /**/ <sys/ioctl.h>
00168 #     include /**/ <sys/sockio.h>
00169 #     include /**/ <netinet/tcp.h>
00170 
00171 #     define TCP_
00172 #     if ! defined (BUFSIZ)
00173 #       define BUFSIZ 1024
00174 #     endif  /* ! defined (BUFSIZ) */
00175 
00176 
00177 #   else
00178 
00179 #     if defined (ACE_PSOS_CANT_USE_SYS_TYPES)
00180       // these are missing from the pSOS types.h file, and the compiler
00181       // supplied types.h file collides with the pSOS version.
00182 #       if !defined (ACE_SHOULD_NOT_DEFINE_SYS_TYPES)
00183       typedef unsigned char     u_char;
00184       typedef unsigned short    u_short;
00185 #       endif /* ACE_SHOULD_NOT_DEFINE_SYS_TYPES */
00186       typedef unsigned int      u_int;
00187 #       if !defined (ACE_SHOULD_NOT_DEFINE_SYS_TYPES)
00188       typedef unsigned long     u_long;
00189 #       endif /* ACE_SHOULD_NOT_DEFINE_SYS_TYPES */
00190 
00191       // These are defined in types.h included by (among others) pna.h
00192 #       if 0
00193       typedef unsigned char     uchar_t;
00194       typedef unsigned short    ushort_t;
00195       typedef unsigned int      uint_t;
00196       typedef unsigned long     ulong_t;
00197 #       endif /* 0 */
00198       typedef char *            caddr_t;
00199 
00200 #       if defined (ACE_PSOS_DIAB_PPC)
00201       // pid_t is defined in sys/types.h
00202 #         if 0
00203       typedef unsigned long pid_t;
00204 #         endif /* 0 */
00205 #     define ACE_INVALID_PID ((pid_t) ~0)
00206 #       else /* !defined (ACE_PSOS_DIAB_PPC) */
00207       typedef long pid_t;
00208 #     define ACE_INVALID_PID ((pid_t) -1)
00209 #       endif /* defined (ACE_PSOS_DIAB_PPC) */
00210 
00211 //      typedef unsigned char wchar_t;
00212 #     endif /* ACE_PSOS_CANT_USE_SYS_TYPES */
00213 
00214 #     include /**/ "ace/sys_conf.h" /* system configuration file */
00215 #     include /**/ <configs.h>   /* includes all pSOS headers */
00216 //    #include /**/ <psos.h>    /* pSOS system calls */
00217 #     include /**/ <pna.h>      /* pNA+ TCP/IP Network Manager calls */
00218 #     include /**/ <phile.h>     /* pHILE+ file system calls */
00219 //    #include /**/ <prepccfg.h>     /* pREPC+ file system calls */
00220 #     if defined (ACE_PSOS_DIAB_MIPS)
00221 #       if defined (ACE_PSOS_USES_DIAB_SYS_CALLS)
00222 #         include /**/ <unistd.h>    /* Diab Data supplied file system calls */
00223 #       else
00224 #         include /**/ <prepc.h>
00225 #       endif /* ACE_PSOS_USES_DIAB_SYS_CALLS */
00226 #       include /**/ <sys/wait.h>    /* Diab Data supplied header file */
00227 #     endif /* ACE_PSOS_DIAB_MIPS */
00228 
00229 // This collides with phile.h
00230 //    #include /**/ <sys/stat.h>    /* Diab Data supplied header file */
00231 
00232 // Some versions have missing preprocessor definitions
00233 #     if !defined (AF_UNIX)
00234 #       define AF_UNIX 0x1
00235 #     endif /* AF_UNIX */
00236 #     define PF_UNIX AF_UNIX
00237 #     define PF_INET AF_INET
00238 #     if !defined (AF_MAX)
00239 #       define AF_MAX AF_INET
00240 #     endif /* AF_MAX */
00241 #     if !defined (IFF_LOOPBACK)
00242 #       define IFF_LOOPBACK IFF_EXTLOOPBACK
00243 #     endif /* IFF_LOOPBACK */
00244 
00245   typedef long fd_mask;
00246 #     define IPPORT_RESERVED       1024
00247 #     define IPPORT_USERRESERVED   5000
00248 
00249 #     if !defined (howmany)
00250 #       define howmany(x, y) (((x)+((y)-1))/(y))
00251 #     endif /* howmany */
00252 
00253   extern "C"
00254   {
00255     typedef void (* ACE_SignalHandler) (void);
00256     typedef void (* ACE_SignalHandlerV) (void);
00257   }
00258 
00259 #     if !defined(SIG_DFL)
00260 #       define SIG_DFL (ACE_SignalHandler) 0
00261 #     endif  /* philabs */
00262 
00263 #   endif /* defined (ACE_PSOSIM) */
00264 
00265 // Some versions of pSOS do not define error numbers, but newer
00266 // versions do. So, include errno.h and then see which ones are not
00267 // yet defined.
00268 #   include /**/ <errno.h>
00269 
00270 #   if !defined (EPERM)
00271 #     define EPERM        1        /* Not super-user                        */
00272 #   endif /* EPERM */
00273 #   if !defined (ENOENT)
00274 #     define ENOENT       2        /* No such file or directory             */
00275 #   endif /* ENOENT */
00276 #   if !defined (ESRCH)
00277 #     define ESRCH        3        /* No such process                       */
00278 #   endif /* ESRCH */
00279 #   if ! defined (EINTR)
00280 #     define EINTR        4        /* interrupted system call               */
00281 #   endif /* EINTR */
00282 #   if !defined (EBADF)
00283 #     define EBADF        9        /* Bad file number                       */
00284 #   endif /* EBADF */
00285 #   if !defined (EAGAIN)
00286 #     define EAGAIN       11       /* Resource temporarily unavailable      */
00287 #   endif /* EAGAIN */
00288 #   if !defined (EWOULDBLOCK)
00289 #     define EWOULDBLOCK  EAGAIN   /* Blocking resource request would block */
00290 #   endif /* EWOULDBLOCK */
00291 #   if !defined (ENOMEM)
00292 #     define ENOMEM       12       /* Not enough core                       */
00293 #   endif /* ENOMEM */
00294 #   if !defined (EACCES)
00295 #     define EACCES      13       /* Permission denied                     */
00296 #   endif /* EACCES */
00297 #   if !defined (EFAULT)
00298 #     define EFAULT       14       /* Bad access                            */
00299 #   endif /* EFAULT */
00300 #   if !defined (EEXIST)
00301 #     define EEXIST       17       /* File exists                           */
00302 #   endif /* EEXIST */
00303 #   if !defined (ENOSPC)
00304 #     define ENOSPC       28       /* No space left on device               */
00305 #   endif /* ENOSPC */
00306 #   if !defined (EPIPE)
00307 #     define EPIPE        32       /* Broken pipe                           */
00308 #   endif /* EPIPE */
00309 #   if !defined (ETIME)
00310 #     define ETIME        62       /* timer expired                         */
00311 #   endif /* ETIME */
00312 #   if !defined (ENAMETOOLONG)
00313 #     define ENAMETOOLONG 78       /* path name is too long                 */
00314 #   endif /* ENAMETOOLONG */
00315 #   if !defined (ENOSYS)
00316 #     define ENOSYS       89       /* Unsupported file system operation     */
00317 #   endif /* ENOSYS */
00318 #   if !defined (EADDRINUSE)
00319 #     define EADDRINUSE   125      /* Address already in use                */
00320 #   endif /* EADDRINUSE */
00321 #   if !defined (ENETUNREACH)
00322 #     define ENETUNREACH  128      /* Network is unreachable                */
00323 #   endif /* ENETUNREACH */
00324 #   if !defined (EISCONN)
00325 #     define EISCONN      133      /* Socket is already connected           */
00326 #   endif /* EISCONN */
00327 #   if !defined (ESHUTDOWN)
00328 #     define ESHUTDOWN    143      /* Can't send after socket shutdown      */
00329 #   endif /* ESHUTDOWN */
00330 #   if !defined (ECONNREFUSED)
00331 #     define ECONNREFUSED 146      /* Connection refused                    */
00332 #   endif /* ECONNREFUSED */
00333 #   if !defined (EINPROGRESS)
00334 #     define EINPROGRESS  150      /* operation now in progress             */
00335 #   endif /* EINPROGRESS */
00336 #   if !defined (ERRMAX)
00337 #     define ERRMAX       151      /* Last error number                     */
00338 #   endif /* ERRMAX */
00339 
00340 #   if ! defined (NSIG)
00341 #     define NSIG 32
00342 #   endif /* NSIG */
00343 
00344 #   if ! defined (TCP_NODELAY)
00345 #     define TCP_NODELAY  1
00346 #   endif /* TCP_NODELAY */
00347 
00348 // For general purpose portability
00349 
00350 #   define ACE_BITS_PER_ULONG (8 * sizeof (u_long))
00351 
00352 typedef u_long ACE_idtype_t;
00353 typedef u_long ACE_id_t;
00354 #   define ACE_SELF (0)
00355 typedef u_long ACE_pri_t;
00356 
00357 // pHILE+ calls the DIR struct XDIR instead
00358 #    if !defined (ACE_PSOS_DIAB_PPC)
00359 typedef XDIR ACE_DIR;
00360 #    endif /* !defined (ACE_PSOS_DIAB_PPC) */
00361 
00362 // Use pSOS semaphores, wrapped . . .
00363 typedef struct
00364 {
00365   /// Semaphore handle.  This is allocated by pSOS.
00366   u_long sema_;
00367 
00368   /// Name of the semaphore: really a 32 bit number to pSOS
00369   char name_[4];
00370 } ACE_sema_t;
00371 
00372 // Used for dynamic linking.
00373 #   if !defined (ACE_DEFAULT_SVC_CONF)
00374 #     if (ACE_USES_CLASSIC_SVC_CONF == 1)
00375 #       define ACE_DEFAULT_SVC_CONF "./svc.conf"
00376 #     else
00377 #       define ACE_DEFAULT_SVC_CONF "./svc.conf.xml"
00378 #     endif /* ACE_USES_CLASSIC_SVC_CONF ==1 */
00379 #   endif /* ACE_DEFAULT_SVC_CONF */
00380 
00381 #   if !defined (ACE_DEFAULT_SEM_KEY)
00382 #     define ACE_DEFAULT_SEM_KEY 1234
00383 #   endif /* ACE_DEFAULT_SEM_KEY */
00384 
00385 #   define ACE_STDIN 0
00386 #   define ACE_STDOUT 1
00387 #   define ACE_STDERR 2
00388 
00389 #   define ACE_DIRECTORY_SEPARATOR_STR_A "/"
00390 #   define ACE_DIRECTORY_SEPARATOR_CHAR_A '/'
00391 #   define ACE_PLATFORM_A "pSOS"
00392 #   define ACE_PLATFORM_EXE_SUFFIX_A ""
00393 
00394 #   define ACE_DLL_SUFFIX ACE_LIB_TEXT (".so")
00395 #   define ACE_DLL_PREFIX ACE_LIB_TEXT ("lib")
00396 #   define ACE_LD_SEARCH_PATH ACE_LIB_TEXT ("LD_LIBRARY_PATH")
00397 #   define ACE_LD_SEARCH_PATH_SEPARATOR_STR ACE_LIB_TEXT (":")
00398 #   define ACE_LOGGER_KEY ACE_LIB_TEXT ("/tmp/server_daemon")
00399 
00400 #   define ACE_MAX_DEFAULT_PORT 65535
00401 
00402 #   if ! defined(MAXPATHLEN)
00403 #     define MAXPATHLEN  1024
00404 #   endif /* MAXPATHLEN */
00405 
00406 #   if ! defined(MAXNAMLEN)
00407 #     define MAXNAMLEN   255
00408 #   endif /* MAXNAMLEN */
00409 
00410 #   if defined (ACE_LACKS_MMAP)
00411 #     define PROT_READ 0
00412 #     define PROT_WRITE 0
00413 #     define PROT_EXEC 0
00414 #     define PROT_NONE 0
00415 #     define PROT_RDWR 0
00416 #     define MAP_PRIVATE 0
00417 #     define MAP_SHARED 0
00418 #     define MAP_FIXED 0
00419 #   endif /* ACE_LACKS_MMAP */
00420 
00421 typedef int ACE_exitcode;
00422 
00423 typedef ACE_HANDLE ACE_SHLIB_HANDLE;
00424 #   define ACE_SHLIB_INVALID_HANDLE ACE_INVALID_HANDLE
00425 #   define ACE_DEFAULT_SHLIB_MODE 0
00426 
00427 #   define ACE_INVALID_SEM_KEY -1
00428 
00429 struct  hostent {
00430   char    *h_name;        /* official name of host */
00431   char    **h_aliases;    /* alias list */
00432   int     h_addrtype;     /* host address type */
00433   int     h_length;       /* address length */
00434   char    **h_addr_list;  /* (first, only) address from name server */
00435 #   define h_addr h_addr_list[0]   /* the first address */
00436 };
00437 
00438 struct  servent {
00439   char     *s_name;    /* official service name */
00440   char    **s_aliases; /* alias list */
00441   int       s_port;    /* port # */
00442   char     *s_proto;   /* protocol to use */
00443 };
00444 
00445 #   define ACE_SEH_TRY if (1)
00446 #   define ACE_SEH_EXCEPT(X) while (0)
00447 #   define ACE_SEH_FINALLY if (1)
00448 
00449 #   if !defined (LPSECURITY_ATTRIBUTES)
00450 #     define LPSECURITY_ATTRIBUTES int
00451 #   endif /* !defined LPSECURITY_ATTRIBUTES */
00452 #   if !defined (GENERIC_READ)
00453 #     define GENERIC_READ 0
00454 #   endif /* !defined GENERIC_READ */
00455 #   if !defined (FILE_SHARE_READ)
00456 #     define FILE_SHARE_READ 0
00457 #   endif /* !defined FILE_SHARE_READ */
00458 #   if !defined (OPEN_EXISTING)
00459 #     define OPEN_EXISTING 0
00460 #   endif /* !defined OPEN_EXISTING */
00461 #   if !defined (FILE_ATTRIBUTE_NORMAL)
00462 #     define FILE_ATTRIBUTE_NORMAL 0
00463 #   endif /* !defined FILE_ATTRIBUTE_NORMAL */
00464 #   if !defined (MAXIMUM_WAIT_OBJECTS)
00465 #     define MAXIMUM_WAIT_OBJECTS 0
00466 #   endif /* !defined MAXIMUM_WAIT_OBJECTS */
00467 #   if !defined (FILE_FLAG_OVERLAPPED)
00468 #     define FILE_FLAG_OVERLAPPED 0
00469 #   endif /* !defined FILE_FLAG_OVERLAPPED */
00470 #   if !defined (FILE_FLAG_SEQUENTIAL_SCAN)
00471 #     define FILE_FLAG_SEQUENTIAL_SCAN 0
00472 #   endif /* !defined FILE_FLAG_SEQUENTIAL_SCAN */
00473 #   if !defined(FILE_FLAG_WRITE_THROUGH)
00474 #     define FILE_FLAG_WRITE_THROUGH 0
00475 #   endif /* !defined FILE_FLAG_WRITE_THROUGH */
00476 #   if !defined(PIPE_WAIT)
00477 #     define PIPE_WAIT 0
00478 #   endif /* !defined PIPE_WAIT */
00479 #   if !defined(PIPE_NOWAIT)
00480 #     define PIPE_NOWAIT 0
00481 #   endif /* !defined PIPE_WAIT */
00482 #   if !defined(PIPE_READMODE_BYTE)
00483 #     define PIPE_READMODE_BYTE 0
00484 #   endif /* !defined PIPE_READMODE_BYTE */
00485 #   if !defined(PIPE_READMODE_MESSAGE)
00486 #     define PIPE_READMODE_MESSAGE 0
00487 #   endif /* !defined PIPE_READMODE_MESSAGE */
00488 #   if !defined(PIPE_TYPE_BYTE)
00489 #     define PIPE_TYPE_BYTE 0
00490 #   endif /* !defined PIPE_TYPE_BYTE */
00491 #   if !defined(PIPE_TYPE_MESSAGE)
00492 #     define PIPE_TYPE_MESSAGE 0
00493 #   endif /* !defined PIPE_TYPE_MESSAGE */
00494 
00495 struct ACE_OVERLAPPED
00496 {
00497   u_long Internal;
00498   u_long InternalHigh;
00499   u_long Offset;
00500   u_long OffsetHigh;
00501   ACE_HANDLE hEvent;
00502 };
00503 
00504 #   if !defined (USER_INCLUDE_SYS_TIME_TM)
00505 #     if defined (ACE_PSOS_DIAB_PPC)
00506 typedef struct timespec timespec_t;
00507 #     else /* ! defined (ACE_PSOS_DIAB_PPC) */
00508 typedef struct timespec
00509 {
00510   time_t tv_sec; // Seconds
00511   long tv_nsec; // Nanoseconds
00512 } timespec_t;
00513 #     endif /* defined (ACE_PSOS_DIAB_PPC) */
00514 #   endif /*  !defined (USER_INCLUDE_SYS_TIME_TM) */
00515 
00516 #if defined (ACE_PSOS_HAS_TIME)
00517 
00518 // Use pSOS time, wrapped . . .
00519 class ACE_OS_Export ACE_PSOS_Time_t
00520 {
00521 public:
00522     /// default ctor: date, time, and ticks all zeroed.
00523   ACE_PSOS_Time_t (void);
00524 
00525     /// ctor from a timespec_t
00526   ACE_PSOS_Time_t (const timespec_t& t);
00527 
00528     /// type cast operator (to a timespec_t)
00529   operator timespec_t ();
00530 
00531     /// static member function to get current system time
00532   static u_long get_system_time (ACE_PSOS_Time_t& t);
00533 
00534     /// static member function to set current system time
00535   static u_long set_system_time (const ACE_PSOS_Time_t& t);
00536 
00537 #   if defined (ACE_PSOSIM)
00538     /// static member function to initialize system time, using UNIX calls
00539   static u_long init_simulator_time (void);
00540 #   endif /* ACE_PSOSIM */
00541 
00542     /// max number of ticks supported in a single system call
00543   static const u_long max_ticks;
00544 private:
00545   // = Constants for prying info out of the pSOS time encoding.
00546   static const u_long year_mask;
00547   static const u_long month_mask;
00548   static const u_long day_mask;
00549   static const u_long hour_mask;
00550   static const u_long minute_mask;
00551   static const u_long second_mask;
00552   static const int year_shift;
00553   static const int month_shift;
00554   static const int hour_shift;
00555   static const int minute_shift;
00556   static const int year_origin;
00557   static const int month_origin;
00558 
00559   // error codes
00560   static const u_long err_notime;   // system time not set
00561   static const u_long err_illdate;  // date out of range
00562   static const u_long err_illtime;  // time out of range
00563   static const u_long err_illticks; // ticks out of range
00564 
00565   /// date : year in bits 31-16, month in bits 15-8, day in bits 7-0
00566    u_long date_;
00567 
00568   /// time : hour in bits 31-16, minutes in bits 15-8, seconds in bits 7-0
00569   u_long time_;
00570 
00571   /// ticks: number of system clock ticks (KC_TICKS2SEC-1 max)
00572   u_long ticks_;
00573 } ;
00574 #endif /* ACE_PSOS_HAS_TIME */
00575 
00576 # endif /* defined (ACE_PSOS) */
00577 
00578 # if defined (ACE_HAS_CHARPTR_SPRINTF)
00579 #   define ACE_SPRINTF_ADAPTER(X) ::strlen (X)
00580 # else
00581 #   define ACE_SPRINTF_ADAPTER(X) X
00582 # endif /* ACE_HAS_CHARPTR_SPRINTF */
00583 
00584 // Default address for shared memory mapped files and SYSV shared memory
00585 // (defaults to 64 M).
00586 # if !defined (ACE_DEFAULT_BASE_ADDR)
00587 #   define ACE_DEFAULT_BASE_ADDR ((char *) (64 * 1024 * 1024))
00588 # endif /* ACE_DEFAULT_BASE_ADDR */
00589 
00590 // This fudge factor can be overriden for timers that need it, such as on
00591 // Solaris, by defining the ACE_TIMER_SKEW symbol in the appropriate config
00592 // header.
00593 #if !defined (ACE_TIMER_SKEW)
00594 #  define ACE_TIMER_SKEW 0
00595 #endif /* ACE_TIMER_SKEW */
00596 
00597 // This needs to go here *first* to avoid problems with AIX.
00598 # if defined (ACE_HAS_PTHREADS)
00599 extern "C" {
00600 #   define ACE_DONT_INCLUDE_ACE_SIGNAL_H
00601 #     include /**/ <signal.h>
00602 #   undef ACE_DONT_INCLUDE_ACE_SIGNAL_H
00603 #   include /**/ <pthread.h>
00604 #   if defined (DIGITAL_UNIX)
00605 #     define pthread_self __pthread_self
00606 extern "C" pthread_t pthread_self (void);
00607 #   endif /* DIGITAL_UNIX */
00608 }
00609 #   if defined (HPUX_10)
00610 //    HP-UX 10 needs to see cma_sigwait, and since _CMA_NOWRAPPERS_ is defined,
00611 //    this header does not get included from pthreads.h.
00612 #     include /**/ <dce/cma_sigwait.h>
00613 #   endif /* HPUX_10 */
00614 # endif /* ACE_HAS_PTHREADS */
00615 
00616 // There are a lot of threads-related macro definitions in the config files.
00617 // They came in at different times and from different places and platform
00618 // requirements as threads evolved.  They are probably not all needed - some
00619 // overlap or are otherwise confused.  This is an attempt to start
00620 // straightening them out.
00621 # if defined (ACE_HAS_PTHREADS_STD)    /* POSIX.1c threads (pthreads) */
00622   // ... and 2-parameter asctime_r and ctime_r
00623 #   if !defined (ACE_HAS_2_PARAM_ASCTIME_R_AND_CTIME_R) && \
00624        !defined (ACE_HAS_STHREADS)
00625 #     define ACE_HAS_2_PARAM_ASCTIME_R_AND_CTIME_R
00626 #   endif
00627 # endif /* ACE_HAS_PTHREADS_STD */
00628 
00629 // By default we perform no tracing on the OS layer, otherwise the
00630 // coupling between the OS layer and Log_Msg is too tight.  But the
00631 // application can override the default if they wish to.
00632 # if !defined(ACE_OS_TRACE)
00633 #  define ACE_OS_TRACE(X)
00634 # endif /* ACE_OS_TRACE */
00635 
00636 # if defined (ACE_USES_STD_NAMESPACE_FOR_STDC_LIB) && \
00637              (ACE_USES_STD_NAMESPACE_FOR_STDC_LIB != 0)
00638 using std::time_t;
00639 using std::tm;
00640 # if defined (ACE_WIN32)
00641 using std::_timezone;
00642 # else
00643 using std::timezone;
00644 # endif
00645 using std::difftime;
00646 # endif /* ACE_USES_STD_NAMESPACE_FOR_STDC_LIB */
00647 
00648 # if !defined (ACE_HAS_CLOCK_GETTIME) && !(defined (_CLOCKID_T_) || defined (_CLOCKID_T))
00649 typedef int clockid_t;
00650 #   if !defined (CLOCK_REALTIME)
00651 #     define CLOCK_REALTIME 0
00652 #   endif /* CLOCK_REALTIME */
00653 # endif /* ! ACE_HAS_CLOCK_GETTIME && ! _CLOCKID_T_ */
00654 
00655 #if !defined (E2BIG)
00656 #  define E2BIG 7
00657 #endif /* E2BIG */
00658 
00659 /**
00660  * @class ACE_Countdown_Time
00661  *
00662  * @brief Keeps track of the amount of elapsed time.
00663  *
00664  * This class has a side-effect on the <max_wait_time> -- every
00665  * time the <stop> method is called the <max_wait_time> is
00666  * updated.
00667  */
00668 class ACE_OS_Export ACE_Countdown_Time
00669 {
00670 public:
00671   // = Initialization and termination methods.
00672   /// Cache the <max_wait_time> and call <start>.
00673   ACE_Countdown_Time (ACE_Time_Value *max_wait_time);
00674 
00675   /// Call <stop>.
00676   ~ACE_Countdown_Time (void);
00677 
00678   /// Cache the current time and enter a start state.
00679   int start (void);
00680 
00681   /// Subtract the elapsed time from max_wait_time_ and enter a stopped
00682   /// state.
00683   int stop (void);
00684 
00685   /// Calls stop and then start.  max_wait_time_ is modified by the
00686   /// call to stop.
00687   int update (void);
00688 
00689   /// Returns 1 if we've already been stopped, else 0.
00690   int stopped (void) const;
00691 
00692 private:
00693   /// Maximum time we were willing to wait.
00694   ACE_Time_Value *max_wait_time_;
00695 
00696   /// Beginning of the start time.
00697   ACE_Time_Value start_time_;
00698 
00699   /// Keeps track of whether we've already been stopped.
00700   int stopped_;
00701 };
00702 
00703 # if defined (ACE_HAS_USING_KEYWORD)
00704 #   define ACE_USING using
00705 # else
00706 #   define ACE_USING
00707 # endif /* ACE_HAS_USING_KEYWORD */
00708 
00709 # if defined (ACE_HAS_TYPENAME_KEYWORD)
00710 #   define ACE_TYPENAME typename
00711 # else
00712 #   define ACE_TYPENAME
00713 # endif /* ACE_HAS_TYPENAME_KEYWORD */
00714 
00715 # if defined (ACE_HAS_STD_TEMPLATE_SPECIALIZATION)
00716 #   define ACE_TEMPLATE_SPECIALIZATION template<>
00717 # else
00718 #   define ACE_TEMPLATE_SPECIALIZATION
00719 # endif /* ACE_HAS_STD_TEMPLATE_SPECIALIZATION */
00720 
00721 # if defined (ACE_HAS_STD_TEMPLATE_METHOD_SPECIALIZATION)
00722 #   define ACE_TEMPLATE_METHOD_SPECIALIZATION template<>
00723 # else
00724 #   define ACE_TEMPLATE_METHOD_SPECIALIZATION
00725 # endif /* ACE_HAS_STD_TEMPLATE_SPECIALIZATION */
00726 
00727 // The following is necessary since many C++ compilers don't support
00728 // typedef'd types inside of classes used as formal template
00729 // arguments... ;-(.  Luckily, using the C++ preprocessor I can hide
00730 // most of this nastiness!
00731 
00732 # if defined (ACE_HAS_TEMPLATE_TYPEDEFS)
00733 
00734 // Handle ACE_Message_Queue.
00735 #   define ACE_SYNCH_DECL class _ACE_SYNCH
00736 #   define ACE_SYNCH_USE _ACE_SYNCH
00737 #   define ACE_SYNCH_MUTEX_T ACE_TYPENAME _ACE_SYNCH::MUTEX
00738 #   define ACE_SYNCH_CONDITION_T ACE_TYPENAME _ACE_SYNCH::CONDITION
00739 #   define ACE_SYNCH_SEMAPHORE_T ACE_TYPENAME _ACE_SYNCH::SEMAPHORE
00740 
00741 // Handle ACE_Malloc*
00742 #   define ACE_MEM_POOL_1 class _ACE_MEM_POOL
00743 #   define ACE_MEM_POOL_2 _ACE_MEM_POOL
00744 #   define ACE_MEM_POOL _ACE_MEM_POOL
00745 #   define ACE_MEM_POOL_OPTIONS ACE_TYPENAME _ACE_MEM_POOL::OPTIONS
00746 
00747 // Handle ACE_Svc_Handler
00748 #   define ACE_PEER_STREAM_1 class _ACE_PEER_STREAM
00749 #   define ACE_PEER_STREAM_2 _ACE_PEER_STREAM
00750 #   define ACE_PEER_STREAM _ACE_PEER_STREAM
00751 #   define ACE_PEER_STREAM_ADDR ACE_TYPENAME _ACE_PEER_STREAM::PEER_ADDR
00752 
00753 // Handle ACE_Acceptor
00754 #   define ACE_PEER_ACCEPTOR_1 class _ACE_PEER_ACCEPTOR
00755 #   define ACE_PEER_ACCEPTOR_2 _ACE_PEER_ACCEPTOR
00756 #   define ACE_PEER_ACCEPTOR _ACE_PEER_ACCEPTOR
00757 #   define ACE_PEER_ACCEPTOR_ADDR ACE_TYPENAME _ACE_PEER_ACCEPTOR::PEER_ADDR
00758 
00759 // Handle ACE_Connector
00760 #   define ACE_PEER_CONNECTOR_1 class _ACE_PEER_CONNECTOR
00761 #   define ACE_PEER_CONNECTOR_2 _ACE_PEER_CONNECTOR
00762 #   define ACE_PEER_CONNECTOR _ACE_PEER_CONNECTOR
00763 #   define ACE_PEER_CONNECTOR_ADDR ACE_TYPENAME _ACE_PEER_CONNECTOR::PEER_ADDR
00764 #   if !defined(ACE_HAS_TYPENAME_KEYWORD)
00765 #     define ACE_PEER_CONNECTOR_ADDR_ANY ACE_PEER_CONNECTOR_ADDR::sap_any
00766 #   else
00767     //
00768     // If the compiler supports 'typename' we cannot use
00769     //
00770     // PEER_CONNECTOR::PEER_ADDR::sap_any
00771     //
00772     // because PEER_CONNECTOR::PEER_ADDR is not considered a type. But:
00773     //
00774     // typename PEER_CONNECTOR::PEER_ADDR::sap_any
00775     //
00776     // will not work either, because now we are declaring sap_any a
00777     // type, further:
00778     //
00779     // (typename PEER_CONNECTOR::PEER_ADDR)::sap_any
00780     //
00781     // is considered a casting expression. All I can think of is using a
00782     // typedef, I tried PEER_ADDR but that was a source of trouble on
00783     // some platforms. I will try:
00784     //
00785 #     define ACE_PEER_CONNECTOR_ADDR_ANY ACE_PEER_ADDR_TYPEDEF::sap_any
00786 #   endif /* ACE_HAS_TYPENAME_KEYWORD */
00787 
00788 // Handle ACE_SOCK_*
00789 #   define ACE_SOCK_ACCEPTOR ACE_SOCK_Acceptor
00790 #   define ACE_SOCK_CONNECTOR ACE_SOCK_Connector
00791 #   define ACE_SOCK_STREAM ACE_SOCK_Stream
00792 
00793 // Handle ACE_MEM_*
00794 #   define ACE_MEM_ACCEPTOR ACE_MEM_Acceptor
00795 #   define ACE_MEM_CONNECTOR ACE_MEM_Connector
00796 #   define ACE_MEM_STREAM ACE_MEM_Stream
00797 
00798 // Handle ACE_LSOCK_*
00799 #   define ACE_LSOCK_ACCEPTOR ACE_LSOCK_Acceptor
00800 #   define ACE_LSOCK_CONNECTOR ACE_LSOCK_Connector
00801 #   define ACE_LSOCK_STREAM ACE_LSOCK_Stream
00802 
00803 // Handle ACE_TLI_*
00804 #   define ACE_TLI_ACCEPTOR ACE_TLI_Acceptor
00805 #   define ACE_TLI_CONNECTOR ACE_TLI_Connector
00806 #   define ACE_TLI_STREAM ACE_TLI_Stream
00807 
00808 // Handle ACE_SPIPE_*
00809 #   define ACE_SPIPE_ACCEPTOR ACE_SPIPE_Acceptor
00810 #   define ACE_SPIPE_CONNECTOR ACE_SPIPE_Connector
00811 #   define ACE_SPIPE_STREAM ACE_SPIPE_Stream
00812 
00813 // Handle ACE_UPIPE_*
00814 #   define ACE_UPIPE_ACCEPTOR ACE_UPIPE_Acceptor
00815 #   define ACE_UPIPE_CONNECTOR ACE_UPIPE_Connector
00816 #   define ACE_UPIPE_STREAM ACE_UPIPE_Stream
00817 
00818 // Handle ACE_FILE_*
00819 #   define ACE_FILE_CONNECTOR ACE_FILE_Connector
00820 #   define ACE_FILE_STREAM ACE_FILE_IO
00821 
00822 // Handle ACE_*_Memory_Pool.
00823 #   define ACE_MMAP_MEMORY_POOL ACE_MMAP_Memory_Pool
00824 #   define ACE_LITE_MMAP_MEMORY_POOL ACE_Lite_MMAP_Memory_Pool
00825 #   define ACE_SBRK_MEMORY_POOL ACE_Sbrk_Memory_Pool
00826 #   define ACE_SHARED_MEMORY_POOL ACE_Shared_Memory_Pool
00827 #   define ACE_LOCAL_MEMORY_POOL ACE_Local_Memory_Pool
00828 #   define ACE_PAGEFILE_MEMORY_POOL ACE_Pagefile_Memory_Pool
00829 
00830 # else /* TEMPLATES are broken in some form or another (i.e., most C++ compilers) */
00831 
00832 // Handle ACE_Message_Queue.
00833 #   if defined (ACE_HAS_OPTIMIZED_MESSAGE_QUEUE)
00834 #     define ACE_SYNCH_DECL class _ACE_SYNCH_MUTEX_T, class _ACE_SYNCH_CONDITION_T, class _ACE_SYNCH_SEMAPHORE_T
00835 #     define ACE_SYNCH_USE _ACE_SYNCH_MUTEX_T, _ACE_SYNCH_CONDITION_T, _ACE_SYNCH_SEMAPHORE_T
00836 #   else
00837 #     define ACE_SYNCH_DECL class _ACE_SYNCH_MUTEX_T, class _ACE_SYNCH_CONDITION_T
00838 #     define ACE_SYNCH_USE _ACE_SYNCH_MUTEX_T, _ACE_SYNCH_CONDITION_T
00839 #   endif /* ACE_HAS_OPTIMIZED_MESSAGE_QUEUE */
00840 #   define ACE_SYNCH_MUTEX_T _ACE_SYNCH_MUTEX_T
00841 #   define ACE_SYNCH_CONDITION_T _ACE_SYNCH_CONDITION_T
00842 #   define ACE_SYNCH_SEMAPHORE_T _ACE_SYNCH_SEMAPHORE_T
00843 
00844 // Handle ACE_Malloc*
00845 #   define ACE_MEM_POOL_1 class _ACE_MEM_POOL, class _ACE_MEM_POOL_OPTIONS
00846 #   define ACE_MEM_POOL_2 _ACE_MEM_POOL, _ACE_MEM_POOL_OPTIONS
00847 #   define ACE_MEM_POOL _ACE_MEM_POOL
00848 #   define ACE_MEM_POOL_OPTIONS _ACE_MEM_POOL_OPTIONS
00849 
00850 // Handle ACE_Svc_Handler
00851 #   define ACE_PEER_STREAM_1 class _ACE_PEER_STREAM, class _ACE_PEER_ADDR
00852 #   define ACE_PEER_STREAM_2 _ACE_PEER_STREAM, _ACE_PEER_ADDR
00853 #   define ACE_PEER_STREAM _ACE_PEER_STREAM
00854 #   define ACE_PEER_STREAM_ADDR _ACE_PEER_ADDR
00855 
00856 // Handle ACE_Acceptor
00857 #   define ACE_PEER_ACCEPTOR_1 class _ACE_PEER_ACCEPTOR, class _ACE_PEER_ADDR
00858 #   define ACE_PEER_ACCEPTOR_2 _ACE_PEER_ACCEPTOR, _ACE_PEER_ADDR
00859 #   define ACE_PEER_ACCEPTOR _ACE_PEER_ACCEPTOR
00860 #   define ACE_PEER_ACCEPTOR_ADDR _ACE_PEER_ADDR
00861 
00862 // Handle ACE_Connector
00863 #   define ACE_PEER_CONNECTOR_1 class _ACE_PEER_CONNECTOR, class _ACE_PEER_ADDR
00864 #   define ACE_PEER_CONNECTOR_2 _ACE_PEER_CONNECTOR, _ACE_PEER_ADDR
00865 #   define ACE_PEER_CONNECTOR _ACE_PEER_CONNECTOR
00866 #   define ACE_PEER_CONNECTOR_ADDR _ACE_PEER_ADDR
00867 #   define ACE_PEER_CONNECTOR_ADDR_ANY ACE_PEER_CONNECTOR_ADDR::sap_any
00868 
00869 // Handle ACE_SOCK_*
00870 #   define ACE_SOCK_ACCEPTOR ACE_SOCK_Acceptor, ACE_INET_Addr
00871 #   define ACE_SOCK_CONNECTOR ACE_SOCK_Connector, ACE_INET_Addr
00872 #   define ACE_SOCK_STREAM ACE_SOCK_Stream, ACE_INET_Addr
00873 
00874 // Handle ACE_MEM_*
00875 #   define ACE_MEM_ACCEPTOR ACE_MEM_Acceptor, ACE_MEM_Addr
00876 #   define ACE_MEM_CONNECTOR ACE_MEM_Connector, ACE_INET_Addr
00877 #   define ACE_MEM_STREAM ACE_MEM_Stream, ACE_INET_Addr
00878 
00879 // Handle ACE_LSOCK_*
00880 #   define ACE_LSOCK_ACCEPTOR ACE_LSOCK_Acceptor, ACE_UNIX_Addr
00881 #   define ACE_LSOCK_CONNECTOR ACE_LSOCK_Connector, ACE_UNIX_Addr
00882 #   define ACE_LSOCK_STREAM ACE_LSOCK_Stream, ACE_UNIX_Addr
00883 
00884 // Handle ACE_TLI_*
00885 #   define ACE_TLI_ACCEPTOR ACE_TLI_Acceptor, ACE_INET_Addr
00886 #   define ACE_TLI_CONNECTOR ACE_TLI_Connector, ACE_INET_Addr
00887 #   define ACE_TLI_STREAM ACE_TLI_Stream, ACE_INET_Addr
00888 
00889 // Handle ACE_SPIPE_*
00890 #   define ACE_SPIPE_ACCEPTOR ACE_SPIPE_Acceptor, ACE_SPIPE_Addr
00891 #   define ACE_SPIPE_CONNECTOR ACE_SPIPE_Connector, ACE_SPIPE_Addr
00892 #   define ACE_SPIPE_STREAM ACE_SPIPE_Stream, ACE_SPIPE_Addr
00893 
00894 // Handle ACE_UPIPE_*
00895 #   define ACE_UPIPE_ACCEPTOR ACE_UPIPE_Acceptor, ACE_SPIPE_Addr
00896 #   define ACE_UPIPE_CONNECTOR ACE_UPIPE_Connector, ACE_SPIPE_Addr
00897 #   define ACE_UPIPE_STREAM ACE_UPIPE_Stream, ACE_SPIPE_Addr
00898 
00899 // Handle ACE_FILE_*
00900 #   define ACE_FILE_CONNECTOR ACE_FILE_Connector, ACE_FILE_Addr
00901 #   define ACE_FILE_STREAM ACE_FILE_IO, ACE_FILE_Addr
00902 
00903 // Handle ACE_*_Memory_Pool.
00904 #   define ACE_MMAP_MEMORY_POOL ACE_MMAP_Memory_Pool, ACE_MMAP_Memory_Pool_Options
00905 #   define ACE_LITE_MMAP_MEMORY_POOL ACE_Lite_MMAP_Memory_Pool, ACE_MMAP_Memory_Pool_Options
00906 #   define ACE_SBRK_MEMORY_POOL ACE_Sbrk_Memory_Pool, ACE_Sbrk_Memory_Pool_Options
00907 #   define ACE_SHARED_MEMORY_POOL ACE_Shared_Memory_Pool, ACE_Shared_Memory_Pool_Options
00908 #   define ACE_LOCAL_MEMORY_POOL ACE_Local_Memory_Pool, ACE_Local_Memory_Pool_Options
00909 #   define ACE_PAGEFILE_MEMORY_POOL ACE_Pagefile_Memory_Pool, ACE_Pagefile_Memory_Pool_Options
00910 # endif /* ACE_HAS_TEMPLATE_TYPEDEFS */
00911 
00912 // These two are only for backward compatibility. You should avoid
00913 // using them if not necessary.
00914 # define ACE_SYNCH_1 ACE_SYNCH_DECL
00915 # define ACE_SYNCH_2 ACE_SYNCH_USE
00916 
00917 // For Win32 compatibility...
00918 # if !defined (ACE_WSOCK_VERSION)
00919 #   define ACE_WSOCK_VERSION 0, 0
00920 # endif /* ACE_WSOCK_VERSION */
00921 
00922 # if defined (ACE_HAS_BROKEN_CTIME)
00923 #   undef ctime
00924 # endif /* ACE_HAS_BROKEN_CTIME */
00925 
00926 /// Service Objects, i.e., objects dynamically loaded via the service
00927 /// configurator, must provide a destructor function with the
00928 /// following prototype to perform object cleanup.
00929 typedef void (*ACE_Service_Object_Exterminator)(void *);
00930 
00931 /** @name Service Configurator macros
00932  *
00933  * The following macros are used to define helper objects used in
00934  * ACE's Service Configurator.  This is an implementation of the
00935  * Service Configurator pattern:
00936  *
00937  * http://www.cs.wustl.edu/~schmidt/PDF/SvcConf.pdf
00938  *
00939  * The intent of this pattern is to allow developers to dynamically
00940  * load and configure services into a system.  With a little help from
00941  * this macros statically linked services can also be dynamically
00942  * configured.
00943  *
00944  * More details about this component are available in the documentation
00945  * of the ACE_Service_Configurator class and also
00946  * ACE_Dynamic_Service.
00947  *
00948  * Notice that in all the macros the SERVICE_CLASS parameter must be
00949  * the name of a class derived from ACE_Service_Object.
00950  */
00951 //@{
00952 /// Declare a the data structure required to register a statically
00953 /// linked service into the service configurator.
00954 /**
00955  * The macro should be used in the header file where the service is
00956  * declared, its only argument is usually the name of the class that
00957  * implements the service.
00958  *
00959  * @param SERVICE_CLASS The name of the class implementing the
00960  *   service.
00961  */
00962 # define ACE_STATIC_SVC_DECLARE(SERVICE_CLASS) \
00963 extern ACE_Static_Svc_Descriptor ace_svc_desc_##SERVICE_CLASS ;
00964 
00965 /// As ACE_STATIC_SVC_DECLARE, but using an export macro for NT
00966 /// compilers.
00967 /**
00968  * NT compilers require the use of explicit directives to export and
00969  * import symbols from a DLL.  If you need to define a service in a
00970  * dynamic library you should use this version instead.
00971  * Normally ACE uses a macro to inject the correct export/import
00972  * directives on NT.  Naturally it also the macro expands to a blank
00973  * on platforms that do not require such directives.
00974  * The first argument (EXPORT_NAME) is the prefix for this export
00975  * macro, the full name is formed by appending _Export.
00976  * ACE provides tools to generate header files that define the macro
00977  * correctly on all platforms, please see
00978  * $ACE_ROOT/bin/generate_export_file.pl
00979  *
00980  * @param EXPORT_NAME The export macro name prefix.
00981  * @param SERVICE_CLASS The name of the class implementing the service.
00982  */
00983 #define ACE_STATIC_SVC_DECLARE_EXPORT(EXPORT_NAME,SERVICE_CLASS) \
00984 extern EXPORT_NAME##_Export ACE_Static_Svc_Descriptor ace_svc_desc_##SERVICE_CLASS;
00985 
00986 /// Define the data structure used to register a statically linked
00987 /// service into the Service Configurator.
00988 /**
00989  * The service configurator requires several arguments to build and
00990  * control an statically linked service, including its name, the
00991  * factory function used to construct the service, and some flags.
00992  * All those parameters are configured in a single structure, an
00993  * instance of this structure is statically initialized using the
00994  * following macro.
00995  *
00996  * @param SERVICE_CLASS The name of the class that implements the
00997  *    service, must be derived (directly or indirectly) from
00998  *    ACE_Service_Object.
00999  * @param NAME The name for this service, this name is used by the
01000  *    service configurator to match configuration options provided in
01001  *    the svc.conf file.
01002  * @param TYPE The type of object.  Objects can be streams or service
01003  *    objects.  Please read the ACE_Service_Configurator and ASX
01004  *    documentation for more details.
01005  * @param FN The name of the factory function, usually the
01006  *    ACE_SVC_NAME macro can be used to generate the name.  The
01007  *    factory function is often defined using ACE_FACTORY_DECLARE and
01008  *    ACE_FACTORY_DEFINE.
01009  * @param FLAGS Flags to control the ownership and lifecycle of the
01010  *    object. Please read the ACE_Service_Configurator documentation
01011  *    for more details.
01012  * @param ACTIVE If not zero then a thread will be dedicate to the
01013  *    service. Please read the ACE_Service_Configurator documentation
01014  *    for more details.
01015  */
01016 #define ACE_STATIC_SVC_DEFINE(SERVICE_CLASS, NAME, TYPE, FN, FLAGS, ACTIVE) \
01017 ACE_Static_Svc_Descriptor ace_svc_desc_##SERVICE_CLASS = { NAME, TYPE, FN, FLAGS, ACTIVE };
01018 
01019 /// Automatically register a service with the service configurator
01020 /**
01021  * In some applications the services must be automatically registered
01022  * with the service configurator, before main() starts.
01023  * The ACE_STATIC_SVC_REQUIRE macro defines a class whose constructor
01024  * register the service, it also defines a static instance of that
01025  * class to ensure that the service is registered before main.
01026  *
01027  * On platforms that lack adequate support for static C++ objects the
01028  * macro ACE_STATIC_SVC_REGISTER can be used to explicitly register
01029  * the service.
01030  *
01031  * @todo One class per-Service_Object seems wasteful.  It should be
01032  *   possible to define a single class and re-use it for all the
01033  *   service objects, just by passing the Service_Descriptor as an
01034  *   argument to the constructor.
01035  */
01036 #if defined(ACE_LACKS_STATIC_CONSTRUCTORS)
01037 # define ACE_STATIC_SVC_REQUIRE(SERVICE_CLASS)\
01038 class ACE_Static_Svc_##SERVICE_CLASS {\
01039 public:\
01040   ACE_Static_Svc_##SERVICE_CLASS() { \
01041     ACE_Service_Config::static_svcs ()->insert (\
01042          &ace_svc_desc_##SERVICE_CLASS); \
01043   } \
01044 };
01045 #define ACE_STATIC_SVC_REGISTER(SERVICE_CLASS)\
01046 ACE_Static_Svc_##SERVICE_CLASS ace_static_svc_##SERVICE_CLASS
01047 
01048 #else /* !ACE_LACKS_STATIC_CONSTRUCTORS */
01049 
01050 # define ACE_STATIC_SVC_REQUIRE(SERVICE_CLASS)\
01051 class ACE_Static_Svc_##SERVICE_CLASS {\
01052 public:\
01053   ACE_Static_Svc_##SERVICE_CLASS() { \
01054     ACE_Service_Config::static_svcs ()->insert (\
01055          &ace_svc_desc_##SERVICE_CLASS); \
01056     } \
01057 };\
01058 static ACE_Static_Svc_##SERVICE_CLASS ace_static_svc_##SERVICE_CLASS;
01059 #define ACE_STATIC_SVC_REGISTER(SERVICE_CLASS) do {} while (0)
01060 
01061 #endif /* !ACE_LACKS_STATIC_CONSTRUCTORS */
01062 
01063 /// Declare the factory method used to create dynamically loadable
01064 /// services.
01065 /**
01066  * Once the service implementation is dynamically loaded the Service
01067  * Configurator uses a factory method to create the object.
01068  * This macro declares such a factory function with the proper
01069  * interface and export macros.
01070  * Normally used in the header file that declares the service
01071  * implementation.
01072  *
01073  * @param CLS must match the prefix of the export macro used for this
01074  *        service.
01075  * @param SERVICE_CLASS must match the name of the class that
01076  *        implements the service.
01077  *
01078  */
01079 #define ACE_FACTORY_DECLARE(CLS,SERVICE_CLASS) \
01080 extern "C" CLS##_Export ACE_Service_Object *\
01081 _make_##SERVICE_CLASS (ACE_Service_Object_Exterminator *);
01082 
01083 /// Define the factory method (and destructor) for a dynamically
01084 /// loadable service.
01085 /**
01086  * Use with arguments matching ACE_FACTORY_DECLARE.
01087  * Normally used in the .cpp file that defines the service
01088  * implementation.
01089  *
01090  * This macro defines both the factory method and the function used to
01091  * cleanup the service object.
01092  *
01093  * If this macro is used to define a factory function that need not be
01094  * exported (for example, in a static service situation), CLS can be
01095  * specified as ACE_Local_Service.
01096  */
01097 # define ACE_Local_Service_Export
01098 
01099 # define ACE_FACTORY_DEFINE(CLS,SERVICE_CLASS) \
01100 void _gobble_##SERVICE_CLASS (void *p) { \
01101   ACE_Service_Object *_p = ACE_static_cast (ACE_Service_Object *, p); \
01102   ACE_ASSERT (_p != 0); \
01103   delete _p; } \
01104 extern "C" CLS##_Export ACE_Service_Object *\
01105 _make_##SERVICE_CLASS (ACE_Service_Object_Exterminator *gobbler) \
01106 { \
01107   ACE_TRACE (#SERVICE_CLASS); \
01108   if (gobbler != 0) \
01109     *gobbler = (ACE_Service_Object_Exterminator) _gobble_##SERVICE_CLASS; \
01110   return new SERVICE_CLASS; \
01111 }
01112 
01113 /// The canonical name for a service factory method
01114 #define ACE_SVC_NAME(SERVICE_CLASS) _make_##SERVICE_CLASS
01115 
01116 /// The canonical way to invoke (i.e. construct) a service factory
01117 /// method.
01118 #define ACE_SVC_INVOKE(SERVICE_CLASS) _make_##SERVICE_CLASS (0)
01119 
01120 //@}
01121 
01122 /** @name Helper macros for services defined in the netsvcs library.
01123  *
01124  * The ACE services defined in netsvcs use this helper macros for
01125  * simplicity.
01126  *
01127  */
01128 //@{
01129 # define ACE_SVC_FACTORY_DECLARE(X) ACE_FACTORY_DECLARE (ACE_Svc, X)
01130 # define ACE_SVC_FACTORY_DEFINE(X) ACE_FACTORY_DEFINE (ACE_Svc, X)
01131 //@}
01132 
01133 # if defined (ACE_HAS_THREADS) && (defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) || defined (ACE_HAS_TSS_EMULATION))
01134 #   define ACE_TSS_TYPE(T) ACE_TSS< T >
01135 #   if defined (ACE_HAS_BROKEN_CONVERSIONS)
01136 #     define ACE_TSS_GET(I, T) (*(I))
01137 #   else
01138 #     define ACE_TSS_GET(I, T) ((I)->operator T * ())
01139 #   endif /* ACE_HAS_BROKEN_CONVERSIONS */
01140 # else
01141 #   define ACE_TSS_TYPE(T) T
01142 #   define ACE_TSS_GET(I, T) (I)
01143 # endif /* ACE_HAS_THREADS && (ACE_HAS_THREAD_SPECIFIC_STORAGE || ACE_HAS_TSS_EMULATIOND) */
01144 
01145 # if defined (ACE_LACKS_MODE_MASKS)
01146 // MODE MASKS
01147 
01148 // the following macros are for POSIX conformance.
01149 
01150 #   if !defined (ACE_HAS_USER_MODE_MASKS)
01151 #     define S_IRWXU 00700         /* read, write, execute: owner. */
01152 #     define S_IRUSR 00400         /* read permission: owner. */
01153 #     define S_IWUSR 00200         /* write permission: owner. */
01154 #     define S_IXUSR 00100         /* execute permission: owner. */
01155 #   endif /* ACE_HAS_USER_MODE_MASKS */
01156 #   define S_IRWXG 00070           /* read, write, execute: group. */
01157 #   define S_IRGRP 00040           /* read permission: group. */
01158 #   define S_IWGRP 00020           /* write permission: group. */
01159 #   define S_IXGRP 00010           /* execute permission: group. */
01160 #   define S_IRWXO 00007           /* read, write, execute: other. */
01161 #   define S_IROTH 00004           /* read permission: other. */
01162 #   define S_IWOTH 00002           /* write permission: other. */
01163 #   define S_IXOTH 00001           /* execute permission: other. */
01164 
01165 // eVC doesn't define these bits, but MSVC does. The bit settings are copied
01166 // from the MSVC defs.
01167 #   if defined (ACE_HAS_WINCE)
01168 #     define S_IFDIR 0040000
01169 #     define S_IFREG 0100000
01170 #   endif /* ACE_HAS_WINCE */
01171 # endif /* ACE_LACKS_MODE_MASKS */
01172 
01173 # if defined (ACE_LACKS_SEMBUF_T)
01174 struct sembuf
01175 {
01176   /// semaphore #
01177   unsigned short sem_num;
01178 
01179   /// semaphore operation
01180   short sem_op;
01181 
01182   /// operation flags
01183   short sem_flg;
01184 };
01185 # endif /* ACE_LACKS_SEMBUF_T */
01186 
01187 # if defined (ACE_LACKS_MSGBUF_T)
01188 struct msgbuf {};
01189 # endif /* ACE_LACKS_MSGBUF_T */
01190 
01191 # if defined (ACE_LACKS_STRRECVFD)
01192 struct strrecvfd {};
01193 # endif /* ACE_LACKS_STRRECVFD */
01194 
01195 # if defined (ACE_HAS_PROC_FS)
01196 #   include /**/ <sys/procfs.h>
01197 # endif /* ACE_HAS_PROC_FS */
01198 
01199 # if defined(__rtems__)
01200 struct iovec {
01201   /// Base address.
01202   char *iov_base;
01203   /// Length.
01204   size_t iov_len;
01205 };
01206 # endif
01207 
01208 # if defined (ACE_HAS_BROKEN_WRITEV)
01209 typedef struct iovec ACE_WRITEV_TYPE;
01210 # else
01211 typedef const struct iovec ACE_WRITEV_TYPE;
01212 # endif /* ACE_HAS_BROKEN_WRITEV */
01213 
01214 # if defined (ACE_HAS_BROKEN_READV)
01215 typedef const struct iovec ACE_READV_TYPE;
01216 # else
01217 typedef struct iovec ACE_READV_TYPE;
01218 # endif /* ACE_HAS_BROKEN_READV */
01219 
01220 # if defined (ACE_HAS_BROKEN_SETRLIMIT)
01221 typedef struct rlimit ACE_SETRLIMIT_TYPE;
01222 # else
01223 typedef const struct rlimit ACE_SETRLIMIT_TYPE;
01224 # endif /* ACE_HAS_BROKEN_SETRLIMIT */
01225 
01226 # if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0)
01227 #   define ACE_MT(X) X
01228 #   if !defined (_REENTRANT)
01229 #     define _REENTRANT
01230 #   endif /* _REENTRANT */
01231 # else
01232 #   define ACE_MT(X)
01233 # endif /* ACE_MT_SAFE */
01234 
01235 # if !defined (ACE_DEFAULT_THREAD_PRIORITY)
01236 #   define ACE_DEFAULT_THREAD_PRIORITY (-0x7fffffffL - 1L)
01237 # endif /* ACE_DEFAULT_THREAD_PRIORITY */
01238 
01239 # if defined (ACE_HAS_POSIX_SEM)
01240 #   include /**/ <semaphore.h>
01241 #   if !defined (SEM_FAILED) && !defined (ACE_LACKS_NAMED_POSIX_SEM)
01242 #     define SEM_FAILED ((sem_t *) -1)
01243 #   endif  /* !SEM_FAILED */
01244 
01245 typedef struct
01246 {
01247   /// Pointer to semaphore handle.  This is allocated by ACE if we are
01248   /// working with an unnamed POSIX semaphore or by the OS if we are
01249   /// working with a named POSIX semaphore.
01250   sem_t *sema_;
01251 
01252   /// Name of the semaphore (if this is non-NULL then this is a named
01253   /// POSIX semaphore, else its an unnamed POSIX semaphore).
01254   char *name_;
01255 
01256 #   if defined (ACE_LACKS_NAMED_POSIX_SEM)
01257   /// this->sema_ doesn't always get created dynamically if a platform
01258   /// doesn't support named posix semaphores.  We use this flag to
01259   /// remember if we need to delete <sema_> or not.
01260   int new_sema_;
01261 #   endif /* ACE_LACKS_NAMED_POSIX_SEM */
01262 } ACE_sema_t;
01263 # endif /* ACE_HAS_POSIX_SEM */
01264 
01265 struct cancel_state
01266 {
01267   /// e.g., PTHREAD_CANCEL_ENABLE, PTHREAD_CANCEL_DISABLE,
01268   /// PTHREAD_CANCELED.
01269   int cancelstate;
01270 
01271   /// e.g., PTHREAD_CANCEL_DEFERRED and PTHREAD_CANCEL_ASYNCHRONOUS.
01272   int canceltype;
01273 };
01274 
01275 # if defined (ACE_HAS_WINCE)
01276 #   include /**/ <types.h>
01277 
01278 #   if (_WIN32_WCE < 400)
01279 typedef unsigned long  ptrdiff_t;    // evc3, PocketPC don't defined ptrdiff_t
01280 #   else
01281 #     include /**/ <stddef.h>        // WinCE .NET puts it in stddef.h
01282 #   endif
01283 
01284 //typedef DWORD  nlink_t;
01285 
01286 // CE's add-on for c-style fstat/stat functionalities.  This struct is
01287 // by no mean complete compared to what you usually find in UNIX
01288 // platforms.  Only members that have direct conversion using Win32's
01289 // BY_HANDLE_FILE_INFORMATION are defined so that users can discover
01290 // non-supported members at compile time.  Time values are of type
01291 // ACE_Time_Value for easy comparison.
01292 
01293 // Since CE does not have _stat by default as NT/2000 does, the 'stat'
01294 // struct defined here will be used.  Also note that CE file system
01295 // struct is only for the CE 3.0 or later.
01296 // Refer to the WCHAR.H from Visual C++ and WIBASE.H from eVC 3.0.
01297 
01298 typedef unsigned int dev_t;
01299 
01300 struct stat
01301 {
01302     /// always 0 on Windows platforms
01303     dev_t st_dev;
01304 
01305     /// always 0 on Windows platforms
01306     dev_t st_rdev;
01307 
01308     /// file attribute
01309     unsigned short st_mode;
01310 
01311     /// number of hard links
01312     short st_nlink;
01313 
01314     /// time of last access
01315     ACE_Time_Value st_atime;
01316 
01317     /// time of last data modification
01318     ACE_Time_Value st_mtime;
01319 
01320     /// time of creation
01321     ACE_Time_Value st_ctime;
01322 
01323     /// file size, in bytes
01324     off_t st_size;
01325 
01326     // Following members do not have direct conversion in Window platforms.
01327 //    u_long st_blksize;        // optimal blocksize for I/O
01328 //    u_long st_flags;          // user defined flags for file
01329 };
01330 
01331 # else /* ! ACE_HAS_WINCE */
01332 #   if defined (ACE_LACKS_SYS_TYPES_H) \
01333        || (defined (__GLIBC__) && !defined (_BSD_SOURCE))
01334 #     if ! defined (ACE_PSOS)
01335   typedef unsigned char u_char;
01336   typedef unsigned short u_short;
01337   typedef unsigned int u_int;
01338   typedef unsigned long u_long;
01339 
01340   typedef unsigned char uchar_t;
01341   typedef unsigned short ushort_t;
01342   typedef unsigned int  uint_t;
01343   typedef unsigned long ulong_t;
01344 #     endif /* ! defined (ACE_PSOS) */
01345 #   else
01346 #     include /**/ <sys/types.h>
01347 #   endif  /* ACE_LACKS_SYS_TYPES_H */
01348 
01349 #   if ! defined (ACE_PSOS)
01350 #     include /**/ <sys/stat.h>
01351 #   endif
01352 # endif /* ACE_HAS_WINCE */
01353 
01354 
01355 #if defined (ACE_HAS_NO_THROW_SPEC)
01356 #   define ACE_THROW_SPEC(X)
01357 #else
01358 # if defined (ACE_HAS_EXCEPTIONS)
01359 #   define ACE_THROW_SPEC(X) throw X
01360 #   if defined (ACE_WIN32) && defined(_MSC_VER) && !defined (ghs)
01361 // @@ MSVC "supports" the keyword but doesn't implement it (Huh?).
01362 //    Therefore, we simply supress the warning for now.
01363 #     pragma warning( disable : 4290 )
01364 #   endif /* ACE_WIN32 */
01365 # else  /* ! ACE_HAS_EXCEPTIONS */
01366 #   define ACE_THROW_SPEC(X)
01367 # endif /* ! ACE_HAS_EXCEPTIONS */
01368 #endif /*ACE_HAS_NO_THROW_SPEC*/
01369 
01370 #if !defined (ACE_LACKS_UNISTD_H)
01371 #  include /**/ <unistd.h>
01372 #endif /* ACE_LACKS_UNISTD_H */
01373 
01374 #if defined (ACE_HAS_PRIOCNTL)
01375   // Need to #include thread.h before #defining THR_BOUND, etc.,
01376   // when building without threads on SunOS 5.x.
01377 #  if defined (sun)
01378 #    include /**/ <thread.h>
01379 #  endif /* sun */
01380 
01381   // Need to #include these before #defining USYNC_PROCESS on SunOS 5.x.
01382 # include /**/ <sys/rtpriocntl.h>
01383 # include /**/ <sys/tspriocntl.h>
01384 #endif /* ACE_HAS_PRIOCNTL */
01385 
01386 # if defined (ACE_HAS_THREADS)
01387 
01388 #   if defined (ACE_HAS_STHREADS)
01389 #     include /**/ <synch.h>
01390 #     include /**/ <thread.h>
01391 #     define ACE_SCOPE_PROCESS P_PID
01392 #     define ACE_SCOPE_LWP P_LWPID
01393 #     define ACE_SCOPE_THREAD (ACE_SCOPE_LWP + 1)
01394 #   else
01395 #     define ACE_SCOPE_PROCESS 0
01396 #     define ACE_SCOPE_LWP 1
01397 #     define ACE_SCOPE_THREAD 2
01398 #   endif /* ACE_HAS_STHREADS */
01399 
01400 #   if !defined (ACE_HAS_PTHREADS)
01401 #     define ACE_SCHED_OTHER 0
01402 #     define ACE_SCHED_FIFO 1
01403 #     define ACE_SCHED_RR 2
01404 #   endif /* ! ACE_HAS_PTHREADS */
01405 
01406 #   if defined (ACE_HAS_PTHREADS)
01407 #     define ACE_SCHED_OTHER SCHED_OTHER
01408 #     define ACE_SCHED_FIFO SCHED_FIFO
01409 #     define ACE_SCHED_RR SCHED_RR
01410 
01411 // Definitions for mapping POSIX pthreads draft 6 into 1003.1c names
01412 
01413 #     if defined (ACE_HAS_PTHREADS_DRAFT6)
01414 #       define PTHREAD_SCOPE_PROCESS           PTHREAD_SCOPE_LOCAL
01415 #       define PTHREAD_SCOPE_SYSTEM            PTHREAD_SCOPE_GLOBAL
01416 #       define PTHREAD_CREATE_UNDETACHED       0
01417 #       define PTHREAD_CREATE_DETACHED         1
01418 #       define PTHREAD_CREATE_JOINABLE         0
01419 #       define PTHREAD_EXPLICIT_SCHED          0
01420 #       define PTHREAD_MIN_PRIORITY            0
01421 #       define PTHREAD_MAX_PRIORITY            126
01422 #     endif /* ACE_HAS_PTHREADS_DRAFT6 */
01423 
01424 // Definitions for THREAD- and PROCESS-LEVEL priorities...some
01425 // implementations define these while others don't.  In order to
01426 // further complicate matters, we don't redefine the default (*_DEF)
01427 // values if they've already been defined, which allows individual
01428 // programs to have their own ACE-wide "default".
01429 
01430 // PROCESS-level values
01431 #     if defined (_POSIX_PRIORITY_SCHEDULING) && \
01432          !defined(_UNICOS) && !defined(UNIXWARE_7_1)
01433 #       define ACE_PROC_PRI_FIFO_MIN  (sched_get_priority_min(SCHED_FIFO))
01434 #       define ACE_PROC_PRI_RR_MIN    (sched_get_priority_min(SCHED_RR))
01435 #       if defined (HPUX)
01436           // HP-UX's other is the SCHED_HPUX class, which uses historical
01437           // values that have reverse semantics from POSIX (low value is
01438           // more important priority). To use these in pthreads calls,
01439           // the values need to be converted. The other scheduling classes
01440           // don't need this special treatment.
01441 #         define ACE_PROC_PRI_OTHER_MIN \
01442                       (sched_get_priority_min(SCHED_OTHER))
01443 #       else
01444 #         define ACE_PROC_PRI_OTHER_MIN (sched_get_priority_min(SCHED_OTHER))
01445 #       endif /* HPUX */
01446 #     else /* UNICOS is missing a sched_get_priority_min() implementation,
01447               SCO too */
01448 #       define ACE_PROC_PRI_FIFO_MIN  0
01449 #       define ACE_PROC_PRI_RR_MIN    0
01450 #       define ACE_PROC_PRI_OTHER_MIN 0
01451 #     endif
01452 
01453 #     if defined (_POSIX_PRIORITY_SCHEDULING) && !defined(UNIXWARE_7_1)
01454 #       define ACE_PROC_PRI_FIFO_MAX  (sched_get_priority_max(SCHED_FIFO))
01455 #       define ACE_PROC_PRI_RR_MAX    (sched_get_priority_max(SCHED_RR))
01456 #       if defined (HPUX)
01457 #         define ACE_PROC_PRI_OTHER_MAX \
01458                       (sched_get_priority_max(SCHED_OTHER))
01459 #       else
01460 #         define ACE_PROC_PRI_OTHER_MAX (sched_get_priority_max(SCHED_OTHER))
01461 #       endif /* HPUX */
01462 #     else /* SCO missing sched_get_priority_max() implementation */
01463 #       define ACE_PROC_PRI_FIFO_MAX  59
01464 #       define ACE_PROC_PRI_RR_MAX    59
01465 #       define ACE_PROC_PRI_OTHER_MAX 59
01466 #     endif
01467 
01468 #     if !defined(ACE_PROC_PRI_FIFO_DEF)
01469 #       define ACE_PROC_PRI_FIFO_DEF (ACE_PROC_PRI_FIFO_MIN + (ACE_PROC_PRI_FIFO_MAX - ACE_PROC_PRI_FIFO_MIN)/2)
01470 #     endif
01471 #     if !defined(ACE_PROC_PRI_RR_DEF)
01472 #       define ACE_PROC_PRI_RR_DEF (ACE_PROC_PRI_RR_MIN + (ACE_PROC_PRI_RR_MAX - ACE_PROC_PRI_RR_MIN)/2)
01473 #     endif
01474 #     if !defined(ACE_PROC_PRI_OTHER_DEF)
01475 #       define ACE_PROC_PRI_OTHER_DEF (ACE_PROC_PRI_OTHER_MIN + (ACE_PROC_PRI_OTHER_MAX - ACE_PROC_PRI_OTHER_MIN)/2)
01476 #     endif
01477 
01478 // THREAD-level values
01479 #     if defined(PRI_FIFO_MIN) && defined(PRI_FIFO_MAX) && defined(PRI_RR_MIN) && defined(PRI_RR_MAX) && defined(PRI_OTHER_MIN) && defined(PRI_OTHER_MAX)
01480 #       if !defined (ACE_THR_PRI_FIFO_MIN)
01481 #         define ACE_THR_PRI_FIFO_MIN  (long) PRI_FIFO_MIN
01482 #       endif /* !ACE_THR_PRI_FIFO_MIN */
01483 #       if !defined (ACE_THR_PRI_FIFO_MAX)
01484 #         define ACE_THR_PRI_FIFO_MAX  (long) PRI_FIFO_MAX
01485 #       endif /* !ACE_THR_PRI_FIFO_MAX */
01486 #       if !defined (ACE_THR_PRI_RR_MIN)
01487 #         define ACE_THR_PRI_RR_MIN    (long) PRI_RR_MIN
01488 #       endif /* !ACE_THR_PRI_RR_MIN */
01489 #       if !defined (ACE_THR_PRI_RR_MAX)
01490 #         define ACE_THR_PRI_RR_MAX    (long) PRI_RR_MAX
01491 #       endif /* !ACE_THR_PRI_RR_MAX */
01492 #       if !defined (ACE_THR_PRI_OTHER_MIN)
01493 #         define ACE_THR_PRI_OTHER_MIN (long) PRI_OTHER_MIN
01494 #       endif /* !ACE_THR_PRI_OTHER_MIN */
01495 #       if !defined (ACE_THR_PRI_OTHER_MAX)
01496 #         define ACE_THR_PRI_OTHER_MAX (long) PRI_OTHER_MAX
01497 #       endif /* !ACE_THR_PRI_OTHER_MAX */
01498 #     elif defined (AIX)
01499         // AIX's priority range is 1 (low) to 127 (high). There aren't
01500         // any preprocessor macros I can find. PRIORITY_MIN is for
01501         // process priorities, as far as I can see, and does not apply
01502         // to thread priority. The 1 to 127 range is from the
01503         // pthread_attr_setschedparam man page (Steve Huston, 18-May-2001).
01504 #       if !defined (ACE_THR_PRI_FIFO_MIN)
01505 #         define ACE_THR_PRI_FIFO_MIN  (long) 1
01506 #       endif /* !ACE_THR_PRI_FIFO_MIN */
01507 #       if !defined (ACE_THR_PRI_FIFO_MAX)
01508 #         define ACE_THR_PRI_FIFO_MAX  (long) 127
01509 #       endif /* !ACE_THR_PRI_FIFO_MAX */
01510 #       if !defined (ACE_THR_PRI_RR_MIN)
01511 #         define ACE_THR_PRI_RR_MIN    (long) 1
01512 #       endif /* !ACE_THR_PRI_RR_MIN */
01513 #       if !defined (ACE_THR_PRI_RR_MAX)
01514 #         define ACE_THR_PRI_RR_MAX    (long) 127
01515 #       endif /* !ACE_THR_PRI_RR_MAX */
01516 #       if !defined (ACE_THR_PRI_OTHER_MIN)
01517 #         define ACE_THR_PRI_OTHER_MIN (long) 1
01518 #       endif /* !ACE_THR_PRI_OTHER_MIN */
01519 #       if !defined (ACE_THR_PRI_OTHER_MAX)
01520 #         define ACE_THR_PRI_OTHER_MAX (long) 127
01521 #       endif /* !ACE_THR_PRI_OTHER_MAX */
01522 #     elif defined (sun)
01523 #       if !defined (ACE_THR_PRI_FIFO_MIN)
01524 #         define ACE_THR_PRI_FIFO_MIN  (long) 0
01525 #       endif /* !ACE_THR_PRI_FIFO_MIN */
01526 #       if !defined (ACE_THR_PRI_FIFO_MAX)
01527 #         define ACE_THR_PRI_FIFO_MAX  (long) 59
01528 #       endif /* !ACE_THR_PRI_FIFO_MAX */
01529 #       if !defined (ACE_THR_PRI_RR_MIN)
01530 #         define ACE_THR_PRI_RR_MIN    (long) 0
01531 #       endif /* !ACE_THR_PRI_RR_MIN */
01532 #       if !defined (ACE_THR_PRI_RR_MAX)
01533 #         define ACE_THR_PRI_RR_MAX    (long) 59
01534 #       endif /* !ACE_THR_PRI_RR_MAX */
01535 #       if !defined (ACE_THR_PRI_OTHER_MIN)
01536 #         define ACE_THR_PRI_OTHER_MIN (long) 0
01537 #       endif /* !ACE_THR_PRI_OTHER_MIN */
01538 #       if !defined (ACE_THR_PRI_OTHER_MAX)
01539 #         define ACE_THR_PRI_OTHER_MAX (long) 127
01540 #       endif /* !ACE_THR_PRI_OTHER_MAX */
01541 #     else
01542 #       if !defined (ACE_THR_PRI_FIFO_MIN)
01543 #         define ACE_THR_PRI_FIFO_MIN  (long) ACE_PROC_PRI_FIFO_MIN
01544 #       endif /* !ACE_THR_PRI_FIFO_MIN */
01545 #       if !defined (ACE_THR_PRI_FIFO_MAX)
01546 #         define ACE_THR_PRI_FIFO_MAX  (long) ACE_PROC_PRI_FIFO_MAX
01547 #       endif /* !ACE_THR_PRI_FIFO_MAX */
01548 #       if !defined (ACE_THR_PRI_RR_MIN)
01549 #         define ACE_THR_PRI_RR_MIN    (long) ACE_PROC_PRI_RR_MIN
01550 #       endif /* !ACE_THR_PRI_RR_MIN */
01551 #       if !defined (ACE_THR_PRI_RR_MAX)
01552 #         define ACE_THR_PRI_RR_MAX    (long) ACE_PROC_PRI_RR_MAX
01553 #       endif /* !ACE_THR_PRI_RR_MAX */
01554 #       if !defined (ACE_THR_PRI_OTHER_MIN)
01555 #         define ACE_THR_PRI_OTHER_MIN (long) ACE_PROC_PRI_OTHER_MIN
01556 #       endif /* !ACE_THR_PRI_OTHER_MIN */
01557 #       if !defined (ACE_THR_PRI_OTHER_MAX)
01558 #         define ACE_THR_PRI_OTHER_MAX (long) ACE_PROC_PRI_OTHER_MAX
01559 #       endif /* !ACE_THR_PRI_OTHER_MAX */
01560 #     endif
01561 #     if !defined(ACE_THR_PRI_FIFO_DEF)
01562 #       define ACE_THR_PRI_FIFO_DEF  ((ACE_THR_PRI_FIFO_MIN + ACE_THR_PRI_FIFO_MAX)/2)
01563 #     endif
01564 #     if !defined(ACE_THR_PRI_RR_DEF)
01565 #       define ACE_THR_PRI_RR_DEF ((ACE_THR_PRI_RR_MIN + ACE_THR_PRI_RR_MAX)/2)
01566 #     endif
01567 #     if !defined(ACE_THR_PRI_OTHER_DEF)
01568 #       define ACE_THR_PRI_OTHER_DEF ((ACE_THR_PRI_OTHER_MIN + ACE_THR_PRI_OTHER_MAX)/2)
01569 #     endif
01570 
01571 // Typedefs to help compatibility with Windows NT and Pthreads.
01572 typedef pthread_t ACE_hthread_t;
01573 typedef pthread_t ACE_thread_t;
01574 
01575 #     if defined (ACE_HAS_TSS_EMULATION)
01576         typedef pthread_key_t ACE_OS_thread_key_t;
01577         typedef u_long ACE_thread_key_t;
01578 #     else  /* ! ACE_HAS_TSS_EMULATION */
01579         typedef pthread_key_t ACE_thread_key_t;
01580 #     endif /* ! ACE_HAS_TSS_EMULATION */
01581 
01582 #     if !defined (ACE_LACKS_COND_T)
01583 typedef pthread_mutex_t ACE_mutex_t;
01584 typedef pthread_cond_t ACE_cond_t;
01585 typedef pthread_condattr_t ACE_condattr_t;
01586 typedef pthread_mutexattr_t ACE_mutexattr_t;
01587 #     endif /* ! ACE_LACKS_COND_T */
01588 typedef pthread_mutex_t ACE_thread_mutex_t;
01589 
01590 #     if !defined (PTHREAD_CANCEL_DISABLE)
01591 #       define PTHREAD_CANCEL_DISABLE      0
01592 #     endif /* PTHREAD_CANCEL_DISABLE */
01593 
01594 #     if !defined (PTHREAD_CANCEL_ENABLE)
01595 #       define PTHREAD_CANCEL_ENABLE       0
01596 #     endif /* PTHREAD_CANCEL_ENABLE */
01597 
01598 #     if !defined (PTHREAD_CANCEL_DEFERRED)
01599 #       define PTHREAD_CANCEL_DEFERRED     0
01600 #     endif /* PTHREAD_CANCEL_DEFERRED */
01601 
01602 #     if !defined (PTHREAD_CANCEL_ASYNCHRONOUS)
01603 #       define PTHREAD_CANCEL_ASYNCHRONOUS 0
01604 #     endif /* PTHREAD_CANCEL_ASYNCHRONOUS */
01605 
01606 #     define THR_CANCEL_DISABLE      PTHREAD_CANCEL_DISABLE
01607 #     define THR_CANCEL_ENABLE       PTHREAD_CANCEL_ENABLE
01608 #     define THR_CANCEL_DEFERRED     PTHREAD_CANCEL_DEFERRED
01609 #     define THR_CANCEL_ASYNCHRONOUS PTHREAD_CANCEL_ASYNCHRONOUS
01610 
01611 #     if !defined (PTHREAD_CREATE_JOINABLE)
01612 #       if defined (PTHREAD_CREATE_UNDETACHED)
01613 #         define PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED
01614 #       else
01615 #         define PTHREAD_CREATE_JOINABLE 0
01616 #       endif /* PTHREAD_CREATE_UNDETACHED */
01617 #     endif /* PTHREAD_CREATE_JOINABLE */
01618 
01619 #     if !defined (PTHREAD_CREATE_DETACHED)
01620 #       define PTHREAD_CREATE_DETACHED 1
01621 #     endif /* PTHREAD_CREATE_DETACHED */
01622 
01623 #     if !defined (PTHREAD_PROCESS_PRIVATE) && !defined (ACE_HAS_PTHREAD_PROCESS_ENUM)
01624 #       if defined (PTHREAD_MUTEXTYPE_FAST)
01625 #         define PTHREAD_PROCESS_PRIVATE PTHREAD_MUTEXTYPE_FAST
01626 #       else
01627 #         define PTHREAD_PROCESS_PRIVATE 0
01628 #       endif /* PTHREAD_MUTEXTYPE_FAST */
01629 #     endif /* PTHREAD_PROCESS_PRIVATE */
01630 
01631 #     if !defined (PTHREAD_PROCESS_SHARED) && !defined (ACE_HAS_PTHREAD_PROCESS_ENUM)
01632 #       if defined (PTHREAD_MUTEXTYPE_FAST)
01633 #         define PTHREAD_PROCESS_SHARED PTHREAD_MUTEXTYPE_FAST
01634 #       else
01635 #         define PTHREAD_PROCESS_SHARED 1
01636 #       endif /* PTHREAD_MUTEXTYPE_FAST */
01637 #     endif /* PTHREAD_PROCESS_SHARED */
01638 
01639 #     if defined (ACE_HAS_PTHREADS_DRAFT4)
01640 #       if defined (PTHREAD_PROCESS_PRIVATE)
01641 #         if !defined (USYNC_THREAD)
01642 #         define USYNC_THREAD    PTHREAD_PROCESS_PRIVATE
01643 #         endif /* ! USYNC_THREAD */
01644 #       else
01645 #         if !defined (USYNC_THREAD)
01646 #         define USYNC_THREAD    MUTEX_NONRECURSIVE_NP
01647 #         endif /* ! USYNC_THREAD */
01648 #       endif /* PTHREAD_PROCESS_PRIVATE */
01649 
01650 #       if defined (PTHREAD_PROCESS_SHARED)
01651 #         if !defined (USYNC_PROCESS)
01652 #         define USYNC_PROCESS   PTHREAD_PROCESS_SHARED
01653 #         endif /* ! USYNC_PROCESS */
01654 #       else
01655 #         if !defined (USYNC_PROCESS)
01656 #         define USYNC_PROCESS   MUTEX_NONRECURSIVE_NP
01657 #         endif /* ! USYNC_PROCESS */
01658 #       endif /* PTHREAD_PROCESS_SHARED */
01659 #     elif !defined (ACE_HAS_STHREADS)
01660 #       if !defined (USYNC_THREAD)
01661 #       define USYNC_THREAD PTHREAD_PROCESS_PRIVATE
01662 #       endif /* ! USYNC_THREAD */
01663 #       if !defined (USYNC_PROCESS)
01664 #       define USYNC_PROCESS PTHREAD_PROCESS_SHARED
01665 #       endif /* ! USYNC_PROCESS */
01666 #     endif /* ACE_HAS_PTHREADS_DRAFT4 */
01667 
01668 /* MM-Graz:  prevent warnings */
01669 #undef THR_BOUND
01670 #undef THR_NEW_LWP
01671 #undef THR_DETACHED
01672 #undef THR_SUSPENDED
01673 #undef THR_DAEMON
01674 
01675 #     define THR_BOUND               0x00000001
01676 #     if defined (CHORUS)
01677 #       define THR_NEW_LWP             0x00000000
01678 #     else
01679 #       define THR_NEW_LWP             0x00000002
01680 #     endif /* CHORUS */
01681 #     define THR_DETACHED            0x00000040
01682 #     define THR_SUSPENDED           0x00000080
01683 #     define THR_DAEMON              0x00000100
01684 #     define THR_JOINABLE            0x00010000
01685 #     define THR_SCHED_FIFO          0x00020000
01686 #     define THR_SCHED_RR            0x00040000
01687 #     define THR_SCHED_DEFAULT       0x00080000
01688 
01689 #     if defined (ACE_HAS_IRIX62_THREADS)
01690 #     define THR_SCOPE_SYSTEM        0x00100000
01691 #     else
01692 #     define THR_SCOPE_SYSTEM        THR_BOUND
01693 #endif /*ACE_HAS_IRIX62_THREADS*/
01694 
01695 #     define THR_SCOPE_PROCESS       0x00200000
01696 #     define THR_INHERIT_SCHED       0x00400000
01697 #     define THR_EXPLICIT_SCHED      0x00800000
01698 #     define THR_SCHED_IO            0x01000000
01699 
01700 #     if !defined (ACE_HAS_STHREADS)
01701 #       if !defined (ACE_HAS_POSIX_SEM)
01702 /**
01703  * @class ACE_sema_t
01704  *
01705  * @brief This is used to implement semaphores for platforms that support
01706  * POSIX pthreads, but do *not* support POSIX semaphores, i.e.,
01707  * it's a different type than the POSIX <sem_t>.
01708  */
01709 class ACE_OS_Export ACE_sema_t
01710 {
01711 friend class ACE_OS;
01712 protected:
01713   /// Serialize access to internal state.
01714   ACE_mutex_t lock_;
01715 
01716   /// Block until there are no waiters.
01717   ACE_cond_t count_nonzero_;
01718 
01719   /// Count of the semaphore.
01720   u_long count_;
01721 
01722   /// Number of threads that have called <ACE_OS::sema_wait>.
01723   u_long waiters_;
01724 };
01725 #       endif /* !ACE_HAS_POSIX_SEM */
01726 
01727 #       if defined (ACE_LACKS_PTHREAD_YIELD) && defined (ACE_HAS_THR_YIELD)
01728         // If we are on Solaris we can just reuse the existing
01729         // implementations of these synchronization types.
01730 #         if !defined (ACE_LACKS_RWLOCK_T)
01731 #           include /**/ <synch.h>
01732 typedef rwlock_t ACE_rwlock_t;
01733 #         endif /* !ACE_LACKS_RWLOCK_T */
01734 #         include /**/ <thread.h>
01735 #       endif /* (ACE_LACKS_PTHREAD_YIELD) && defined (ACE_HAS_THR_YIELD) */
01736 
01737 #     else
01738 #       if !defined (ACE_HAS_POSIX_SEM)
01739 typedef sema_t ACE_sema_t;
01740 #       endif /* !ACE_HAS_POSIX_SEM */
01741 #     endif /* !ACE_HAS_STHREADS */
01742 #   elif defined (ACE_HAS_STHREADS)
01743 // Solaris threads, without PTHREADS.
01744 // Typedefs to help compatibility with Windows NT and Pthreads.
01745 typedef thread_t ACE_thread_t;
01746 typedef thread_key_t ACE_thread_key_t;
01747 typedef mutex_t ACE_mutex_t;
01748 #     if !defined (ACE_LACKS_RWLOCK_T)
01749 typedef rwlock_t ACE_rwlock_t;
01750 #     endif /* !ACE_LACKS_RWLOCK_T */
01751 #     if !defined (ACE_HAS_POSIX_SEM)
01752 typedef sema_t ACE_sema_t;
01753 #     endif /* !ACE_HAS_POSIX_SEM */
01754 
01755 typedef cond_t ACE_cond_t;
01756 struct ACE_OS_Export ACE_condattr_t
01757 {
01758   int type;
01759 };
01760 struct ACE_OS_Export ACE_mutexattr_t
01761 {
01762   int type;
01763 };
01764 typedef ACE_thread_t ACE_hthread_t;
01765 typedef ACE_mutex_t ACE_thread_mutex_t;
01766 
01767 #     define THR_CANCEL_DISABLE      0
01768 #     define THR_CANCEL_ENABLE       0
01769 #     define THR_CANCEL_DEFERRED     0
01770 #     define THR_CANCEL_ASYNCHRONOUS 0
01771 #     define THR_JOINABLE            0
01772 #     define THR_SCHED_FIFO          0
01773 #     define THR_SCHED_RR            0
01774 #     define THR_SCHED_DEFAULT       0
01775 
01776 #   elif defined (ACE_PSOS)
01777 
01778 // Some versions of pSOS provide native mutex support.  For others,
01779 // implement ACE_thread_mutex_t and ACE_mutex_t using pSOS semaphores.
01780 // Either way, the types are all u_longs.
01781 typedef u_long ACE_mutex_t;
01782 typedef u_long ACE_thread_mutex_t;
01783 typedef u_long ACE_thread_t;
01784 typedef u_long ACE_hthread_t;
01785 
01786 #if defined (ACE_PSOS_HAS_COND_T)
01787 typedef u_long ACE_cond_t;
01788 typedef u_long ACE_condattr_t;
01789 struct ACE_OS_Export ACE_mutexattr_t
01790 {
01791   int type;
01792 };
01793 #endif /* ACE_PSOS_HAS_COND_T */
01794 
01795 
01796 // TCB registers 0-7 are for application use
01797 #     define PSOS_TASK_REG_TSS 0
01798 #     define PSOS_TASK_REG_MAX 7
01799 
01800 #     define PSOS_TASK_MIN_PRIORITY   1
01801 #     define PSOS_TASK_MAX_PRIORITY 239
01802 
01803 // Key type: the ACE TSS emulation requires the key type be unsigned,
01804 // for efficiency.  Current POSIX and Solaris TSS implementations also
01805 // use unsigned int, so the ACE TSS emulation is compatible with them.
01806 // Native pSOS TSD, where available, uses unsigned long as the key type.
01807 #     if defined (ACE_PSOS_HAS_TSS)
01808 typedef u_long ACE_thread_key_t;
01809 #     else
01810 typedef u_int ACE_thread_key_t;
01811 #     endif /* ACE_PSOS_HAS_TSS */
01812 
01813 #     define THR_CANCEL_DISABLE      0  /* thread can never be cancelled */
01814 #     define THR_CANCEL_ENABLE       0      /* thread can be cancelled */
01815 #     define THR_CANCEL_DEFERRED     0      /* cancellation deferred to cancellation point */
01816 #     define THR_CANCEL_ASYNCHRONOUS 0      /* cancellation occurs immediately */
01817 
01818 #     define THR_BOUND               0
01819 #     define THR_NEW_LWP             0
01820 #     define THR_DETACHED            0
01821 #     define THR_SUSPENDED           0
01822 #     define THR_DAEMON              0
01823 #     define THR_JOINABLE            0
01824 
01825 #     define THR_SCHED_FIFO          0
01826 #     define THR_SCHED_RR            0
01827 #     define THR_SCHED_DEFAULT       0
01828 #     define USYNC_THREAD            T_LOCAL
01829 #     define USYNC_PROCESS           T_GLOBAL
01830 
01831 /* from psos.h */
01832 /* #define T_NOPREEMPT     0x00000001   Not preemptible bit */
01833 /* #define T_PREEMPT       0x00000000   Preemptible */
01834 /* #define T_TSLICE        0x00000002   Time-slicing enabled bit */
01835 /* #define T_NOTSLICE      0x00000000   No Time-slicing */
01836 /* #define T_NOASR         0x00000004   ASRs disabled bit */
01837 /* #define T_ASR           0x00000000   ASRs enabled */
01838 
01839 /* #define SM_GLOBAL       0x00000001  1 = Global */
01840 /* #define SM_LOCAL        0x00000000  0 = Local */
01841 /* #define SM_PRIOR        0x00000002  Queue by priority */
01842 /* #define SM_FIFO         0x00000000  Queue by FIFO order */
01843 
01844 /* #define T_NOFPU         0x00000000   Not using FPU */
01845 /* #define T_FPU           0x00000002   Using FPU bit */
01846 
01847 #   elif defined (VXWORKS)
01848 // For mutex implementation using mutual-exclusion semaphores (which
01849 // can be taken recursively).
01850 #     include /**/ <semLib.h>
01851 
01852 #     include /**/ <envLib.h>
01853 #     include /**/ <hostLib.h>
01854 #     include /**/ <ioLib.h>
01855 #     include /**/ <remLib.h>
01856 #     include /**/ <selectLib.h>
01857 #     include /**/ <sigLib.h>
01858 #     include /**/ <sockLib.h>
01859 #     include /**/ <sysLib.h>
01860 #     include /**/ <taskLib.h>
01861 #     include /**/ <taskHookLib.h>
01862 #     include /**/ <inetLib.h>
01863 extern "C"
01864 struct sockaddr_un {
01865   short sun_family;    // AF_UNIX.
01866   char  sun_path[108]; // path name.
01867 };
01868 
01869 #     define MAXNAMLEN   255
01870 #     define NSIG (_NSIGS + 1)
01871 
01872 // task options:  the other options are either obsolete, internal, or for
01873 // Fortran or Ada support
01874 #     define VX_UNBREAKABLE        0x0002  /* breakpoints ignored */
01875 #     define VX_FP_TASK            0x0008  /* floating point coprocessor */
01876 #     define VX_PRIVATE_ENV        0x0080  /* private environment support */
01877 #     define VX_NO_STACK_FILL      0x0100  /* do not stack fill for
01878                                               checkstack () */
01879 
01880 #     define THR_CANCEL_DISABLE      0
01881 #     define THR_CANCEL_ENABLE       0
01882 #     define THR_CANCEL_DEFERRED     0
01883 #     define THR_CANCEL_ASYNCHRONOUS 0
01884 #     define THR_BOUND               0
01885 #     define THR_NEW_LWP             0
01886 #     define THR_DETACHED            0
01887 #     define THR_SUSPENDED           0
01888 #     define THR_DAEMON              0
01889 #     define THR_JOINABLE            0
01890 #     define THR_SCHED_FIFO          0
01891 #     define THR_SCHED_RR            0
01892 #     define THR_SCHED_DEFAULT       0
01893 #     define THR_INHERIT_SCHED       0
01894 #     define THR_EXPLICIT_SCHED      0
01895 #     define THR_SCHED_IO            0
01896 #     define THR_SCOPE_SYSTEM        0
01897 #     define THR_SCOPE_PROCESS       0
01898 #     define USYNC_THREAD            0
01899 #     define USYNC_PROCESS           1 /* It's all global on VxWorks
01900                                           (without MMU option). */
01901 
01902 #     if !defined (ACE_DEFAULT_SYNCH_TYPE)
01903  // Types include these options: SEM_Q_PRIORITY, SEM_Q_FIFO,
01904  // SEM_DELETE_SAFE, and SEM_INVERSION_SAFE.  SEM_Q_FIFO is
01905  // used as the default because that is VxWorks' default.
01906 #       define ACE_DEFAULT_SYNCH_TYPE SEM_Q_FIFO
01907 #     endif /* ! ACE_DEFAULT_SYNCH_TYPE */
01908 
01909 typedef SEM_ID ACE_mutex_t;
01910 // Implement ACE_thread_mutex_t with ACE_mutex_t because there's just
01911 // one process . . .
01912 typedef ACE_mutex_t ACE_thread_mutex_t;
01913 #     if !defined (ACE_HAS_POSIX_SEM)
01914 // Use VxWorks semaphores, wrapped ...
01915 typedef struct
01916 {
01917   /// Semaphore handle.  This is allocated by VxWorks.
01918   SEM_ID sema_;
01919 
01920   /// Name of the semaphore:  always NULL with VxWorks.
01921   char *name_;
01922 } ACE_sema_t;
01923 #     endif /* !ACE_HAS_POSIX_SEM */
01924 typedef char * ACE_thread_t;
01925 typedef int ACE_hthread_t;
01926 // Key type: the ACE TSS emulation requires the key type be unsigned,
01927 // for efficiency.  (Current POSIX and Solaris TSS implementations also
01928 // use u_int, so the ACE TSS emulation is compatible with them.)
01929 typedef u_int ACE_thread_key_t;
01930 
01931       // Marker for ACE_Thread_Manager to indicate that it allocated
01932       // an ACE_thread_t.  It is placed at the beginning of the ID.
01933 #     define ACE_THR_ID_ALLOCATED '\022'
01934 
01935 #   elif defined (ACE_HAS_WTHREADS)
01936 
01937 typedef CRITICAL_SECTION ACE_thread_mutex_t;
01938 
01939 typedef struct
01940 {
01941   /// Either USYNC_THREAD or USYNC_PROCESS
01942   int type_;
01943   union
01944   {
01945     HANDLE proc_mutex_;
01946     CRITICAL_SECTION thr_mutex_;
01947   };
01948 } ACE_mutex_t;
01949 
01950 // Wrapper for NT Events.
01951 typedef HANDLE ACE_event_t;
01952 
01953 #   if defined (ACE_WIN32)
01954 //@@ ACE_USES_WINCE_SEMA_SIMULATION is used to debug
01955 //   semaphore simulation on WinNT.  It should be
01956 //   changed to ACE_USES_HAS_WINCE at some later point.
01957 #     if !defined (ACE_USES_WINCE_SEMA_SIMULATION)
01958 typedef HANDLE ACE_sema_t;
01959 #     else
01960 /**
01961  * @class ACE_sema_t
01962  *
01963  * @brief Semaphore simulation for Windows CE.
01964  */
01965 class ACE_OS_Export ACE_sema_t
01966 {
01967 public:
01968   /// Serializes access to <count_>.
01969   ACE_thread_mutex_t lock_;
01970 
01971   /// This event is signaled whenever the count becomes non-zero.
01972   ACE_event_t count_nonzero_;
01973 
01974   /// Current count of the semaphore.
01975   u_int count_;
01976 };
01977 
01978 #     endif /* ACE_USES_WINCE_SEMA_SIMULATION */
01979 #   endif /* defined (ACE_WIN32) */
01980 
01981 // These need to be different values, neither of which can be 0...
01982 #     define USYNC_THREAD 1
01983 #     define USYNC_PROCESS 2
01984 
01985 #     define THR_CANCEL_DISABLE      0
01986 #     define THR_CANCEL_ENABLE       0
01987 #     define THR_CANCEL_DEFERRED     0
01988 #     define THR_CANCEL_ASYNCHRONOUS 0
01989 #     define THR_DETACHED            0x02000000 /* ignore in most places */
01990 #     define THR_BOUND               0          /* ignore in most places */
01991 #     define THR_NEW_LWP             0          /* ignore in most places */
01992 #     define THR_DAEMON              0          /* ignore in most places */
01993 #     define THR_JOINABLE            0          /* ignore in most places */
01994 #     define THR_SUSPENDED   CREATE_SUSPENDED
01995 #     define THR_USE_AFX             0x01000000
01996 #     define THR_SCHED_FIFO          0
01997 #     define THR_SCHED_RR            0
01998 #     define THR_SCHED_DEFAULT       0
01999 #     define THR_SCOPE_PROCESS       0
02000 #     define THR_SCOPE_SYSTEM        0
02001 #   endif /* ACE_HAS_PTHREADS / STHREADS / PSOS / VXWORKS / WTHREADS */
02002 
02003 // If we're using PACE then we don't want this class (since PACE
02004 // takes care of it) unless we're on Windows. Win32 mutexes, semaphores,
02005 // and condition variables are not yet supported in PACE.
02006 #   if defined (ACE_LACKS_COND_T)
02007 /**
02008  * @class ACE_cond_t
02009  *
02010  * @brief This structure is used to implement condition variables on
02011  * platforms that lack it natively, such as VxWorks, pSoS, and
02012  * Win32.
02013  *
02014  * At the current time, this stuff only works for threads
02015  * within the same process.
02016  */
02017 class ACE_OS_Export ACE_cond_t
02018 {
02019 public:
02020   friend class ACE_OS;
02021 
02022   /// Returns the number of waiters.
02023   long waiters (void) const;
02024 
02025 protected:
02026   /// Number of waiting threads.
02027   long waiters_;
02028 
02029   /// Serialize access to the waiters count.
02030   ACE_thread_mutex_t waiters_lock_;
02031 
02032   /// Queue up threads waiting for the condition to become signaled.
02033   ACE_sema_t sema_;
02034 
02035 #     if defined (VXWORKS) || defined (ACE_PSOS)
02036   /**
02037    * A semaphore used by the broadcast/signal thread to wait for all
02038    * the waiting thread(s) to wake up and be released from the
02039    * semaphore.
02040    */
02041   ACE_sema_t waiters_done_;
02042 #     elif defined (ACE_WIN32)
02043   /**
02044    * An auto reset event used by the broadcast/signal thread to wait
02045    * for the waiting thread(s) to wake up and get a chance at the
02046    * semaphore.
02047    */
02048   HANDLE waiters_done_;
02049 #     else
02050 #       error "Please implement this feature or check your config.h file!"
02051 #     endif /* VXWORKS || ACE_PSOS */
02052 
02053   /// Keeps track of whether we were broadcasting or just signaling.
02054   size_t was_broadcast_;
02055 };
02056 
02057 struct ACE_OS_Export ACE_condattr_t
02058 {
02059   int type;
02060 };
02061 
02062 struct ACE_OS_Export ACE_mutexattr_t
02063 {
02064   int type;
02065 };
02066 #   endif /* ACE_LACKS_COND_T */
02067 
02068 #   if defined (ACE_LACKS_RWLOCK_T) && !defined (ACE_HAS_PTHREADS_UNIX98_EXT)
02069 
02070 /**
02071  * @class ACE_rwlock_t
02072  *
02073  * @brief This is used to implement readers/writer locks on NT,
02074  *     VxWorks, and POSIX pthreads.
02075  *
02076  *     At the current time, this stuff only works for threads
02077  *     within the same process.
02078  */
02079 struct ACE_OS_Export ACE_rwlock_t
02080 {
02081 protected:
02082   friend class ACE_OS;
02083 
02084   ACE_mutex_t lock_;
02085   // Serialize access to internal state.
02086 
02087   ACE_cond_t waiting_readers_;
02088   // Reader threads waiting to acquire the lock.
02089 
02090   int num_waiting_readers_;
02091   // Number of waiting readers.
02092 
02093   ACE_cond_t waiting_writers_;
02094   // Writer threads waiting to acquire the lock.
02095 
02096   int num_waiting_writers_;
02097   // Number of waiting writers.
02098 
02099   int ref_count_;
02100   // Value is -1 if writer has the lock, else this keeps track of the
02101   // number of readers holding the lock.
02102 
02103   int important_writer_;
02104   // indicate that a reader is trying to upgrade
02105 
02106   ACE_cond_t waiting_important_writer_;
02107   // condition for the upgrading reader
02108 };
02109 #   elif defined (ACE_HAS_PTHREADS_UNIX98_EXT)
02110 typedef pthread_rwlock_t ACE_rwlock_t;
02111 #   elif defined (ACE_HAS_STHREADS)
02112 #     include /**/ <synch.h>
02113 typedef rwlock_t ACE_rwlock_t;
02114 #   endif /* ACE_LACKS_RWLOCK_T */
02115 
02116 // Define some default thread priorities on all threaded platforms, if
02117 // not defined above or in the individual platform config file.
02118 // ACE_THR_PRI_FIFO_DEF should be used by applications for default
02119 // real-time thread priority.  ACE_THR_PRI_OTHER_DEF should be used
02120 // for non-real-time priority.
02121 #   if !defined(ACE_THR_PRI_FIFO_DEF)
02122 #     if defined (ACE_WTHREADS)
02123       // It would be more in spirit to use THREAD_PRIORITY_NORMAL.  But,
02124       // using THREAD_PRIORITY_ABOVE_NORMAL should give preference to the
02125       // threads in this process, even if the process is not in the
02126       // REALTIME_PRIORITY_CLASS.
02127 #       define ACE_THR_PRI_FIFO_DEF THREAD_PRIORITY_ABOVE_NORMAL
02128 #     else  /* ! ACE_WTHREADS */
02129 #       define ACE_THR_PRI_FIFO_DEF 0
02130 #     endif /* ! ACE_WTHREADS */
02131 #   endif /* ! ACE_THR_PRI_FIFO_DEF */
02132 
02133 #   if !defined(ACE_THR_PRI_OTHER_DEF)
02134 #     if defined (ACE_WTHREADS)
02135       // It would be more in spirit to use THREAD_PRIORITY_NORMAL.  But,
02136       // using THREAD_PRIORITY_ABOVE_NORMAL should give preference to the
02137       // threads in this process, even if the process is not in the
02138       // REALTIME_PRIORITY_CLASS.
02139 #       define ACE_THR_PRI_OTHER_DEF THREAD_PRIORITY_NORMAL
02140 #     else  /* ! ACE_WTHREADS */
02141 #       define ACE_THR_PRI_OTHER_DEF 0
02142 #     endif /* ! ACE_WTHREADS */
02143 #   endif /* ! ACE_THR_PRI_OTHER_DEF */
02144 
02145 // Recursive mutex support.
02146 //
02147 // There are two parts to this:
02148 // 1. The mutex type itself. This is based on whether or not the
02149 //    platform supports recursive mutexes natively or they're emulated.
02150 // 2. Support for using the recursive mutex with a condition variable.
02151 //    When a thread waits on a condition variable, it has to relinquish
02152 //    the lock and wait atomically, then reacquire it after the condition
02153 //    variable is signaled. In non-recursive mutexes, the platform
02154 //    handles this automatically. But in recursive mutexes, especially
02155 //    when emulated, the recursion count needs to be maintained across
02156 //    the wait. Since another thread needs to be able to acquire the
02157 //    lock, it needs to appear free, even if the waiting thread had done
02158 //    multiple acquires. Thus, there's another structure to hold this
02159 //    information, and is used with the recursive_mutex_cond_unlock()
02160 //    and recursive_mutex_cond_relock() methods to maintain the expected
02161 //    state when the wait finishes.
02162 #if defined (ACE_HAS_RECURSIVE_MUTEXES)
02163 typedef ACE_thread_mutex_t ACE_recursive_thread_mutex_t;
02164 #  if defined (ACE_WIN32)
02165 // Windows has recursive mutexes, but doesn't have condition variables,
02166 // so there's no built-in support for this. Thus, the condition-related
02167 // unlock/relock is augmented in ACE.
02168 struct ACE_recursive_mutex_state
02169 {
02170   // On Windows the augmented processing is simply unlocking/relocking
02171   // the recursive locks - the condition handles a single lock ok.
02172   LONG relock_count_;
02173 };
02174 #  else
02175 // No need for special handling; just need a type for method signatures.
02176 typedef int ACE_recursive_mutex_state;
02177 #  endif /* ACE_WIN32 */
02178 #else
02179 /**
02180  * @class ACE_recursive_thread_mutex_t
02181  *
02182  * @brief Implement a thin C++ wrapper that allows nested acquisition
02183  * and release of a mutex that occurs in the same thread.
02184  *
02185  * This implementation is based on an algorithm sketched by Dave
02186  * Butenhof <butenhof@zko.dec.com>.  Naturally, I take the
02187  * credit for any mistakes ;-)
02188  */
02189 class ACE_recursive_thread_mutex_t
02190 {
02191 public:
02192   /// Guards the state of the nesting level and thread id.
02193   ACE_thread_mutex_t nesting_mutex_;
02194 
02195   /// This condition variable suspends other waiting threads until the
02196   /// mutex is available.
02197   ACE_cond_t lock_available_;
02198 
02199   /// Current nesting level of the recursion.
02200   int nesting_level_;
02201 
02202   /// Current owner of the lock.
02203   ACE_thread_t owner_id_;
02204 };
02205 
02206 // Since recursive mutex is emulated, the state saving needs to be handled
02207 // in ACE as well. These members save those from ACE_recursive_thread_mutex_t.
02208 struct ACE_recursive_mutex_state
02209 {
02210   int nesting_level_;
02211   ACE_thread_t owner_id_;
02212 };
02213 #endif /* ACE_HAS_RECURSIVE_MUTEXES */
02214 
02215 # else /* !ACE_HAS_THREADS, i.e., the OS/platform doesn't support threading. */
02216 
02217 // Give these things some reasonable value...
02218 #   define ACE_SCOPE_PROCESS 0
02219 #   define ACE_SCOPE_LWP 1
02220 #   define ACE_SCOPE_THREAD 2
02221 #   define ACE_SCHED_OTHER 0
02222 #   define ACE_SCHED_FIFO 1
02223 #   define ACE_SCHED_RR 2
02224 #   if !defined (THR_CANCEL_DISABLE)
02225 #     define THR_CANCEL_DISABLE      0
02226 #   endif /* ! THR_CANCEL_DISABLE */
02227 #   if !defined (THR_CANCEL_ENABLE)
02228 #     define THR_CANCEL_ENABLE       0
02229 #   endif /* ! THR_CANCEL_ENABLE */
02230 #   if !defined (THR_CANCEL_DEFERRED)
02231 #     define THR_CANCEL_DEFERRED     0
02232 #   endif /* ! THR_CANCEL_DEFERRED */
02233 #   if !defined (THR_CANCEL_ASYNCHRONOUS)
02234 #     define THR_CANCEL_ASYNCHRONOUS 0
02235 #   endif /* ! THR_CANCEL_ASYNCHRONOUS */
02236 #   if !defined (THR_JOINABLE)
02237 #     define THR_JOINABLE    0     /* ignore in most places */
02238 #   endif /* ! THR_JOINABLE */
02239 #   if !defined (THR_DETACHED)
02240 #     define THR_DETACHED    0     /* ignore in most places */
02241 #   endif /* ! THR_DETACHED */
02242 #   if !defined (THR_DAEMON)
02243 #     define THR_DAEMON      0     /* ignore in most places */
02244 #   endif /* ! THR_DAEMON */
02245 #   if !defined (THR_BOUND)
02246 #     define THR_BOUND       0     /* ignore in most places */
02247 #   endif /* ! THR_BOUND */
02248 #   if !defined (THR_NEW_LWP)
02249 #     define THR_NEW_LWP     0     /* ignore in most places */
02250 #   endif /* ! THR_NEW_LWP */
02251 #   if !defined (THR_SUSPENDED)
02252 #     define THR_SUSPENDED   0     /* ignore in most places */
02253 #   endif /* ! THR_SUSPENDED */
02254 #   if !defined (THR_SCHED_FIFO)
02255 #     define THR_SCHED_FIFO 0
02256 #   endif /* ! THR_SCHED_FIFO */
02257 #   if !defined (THR_SCHED_RR)
02258 #     define THR_SCHED_RR 0
02259 #   endif /* ! THR_SCHED_RR */
02260 #   if !defined (THR_SCHED_DEFAULT)
02261 #     define THR_SCHED_DEFAULT 0
02262 #   endif /* ! THR_SCHED_DEFAULT */
02263 #   if !defined (USYNC_THREAD)
02264 #     define USYNC_THREAD 0
02265 #   endif /* ! USYNC_THREAD */
02266 #   if !defined (USYNC_PROCESS)
02267 #     define USYNC_PROCESS 0
02268 #   endif /* ! USYNC_PROCESS */
02269 #   if !defined (THR_SCOPE_PROCESS)
02270 #     define THR_SCOPE_PROCESS 0
02271 #   endif /* ! THR_SCOPE_PROCESS */
02272 #   if !defined (THR_SCOPE_SYSTEM)
02273 #     define THR_SCOPE_SYSTEM 0
02274 #   endif /* ! THR_SCOPE_SYSTEM */
02275 
02276 // These are dummies needed for class OS.h
02277 typedef int ACE_cond_t;
02278 struct ACE_OS_Export ACE_condattr_t
02279 {
02280   int type;
02281 };
02282 struct ACE_OS_Export ACE_mutexattr_t
02283 {
02284   int type;
02285 };
02286 typedef int ACE_mutex_t;
02287 typedef int ACE_thread_mutex_t;
02288 typedef int ACE_recursive_thread_mutex_t;
02289 typedef int ACE_recursive_mutex_state;
02290 #   if !defined (ACE_HAS_POSIX_SEM) && !defined (ACE_PSOS)
02291 typedef int ACE_sema_t;
02292 #   endif /* !ACE_HAS_POSIX_SEM && !ACE_PSOS */
02293 typedef int ACE_rwlock_t;
02294 typedef int ACE_thread_t;
02295 typedef int ACE_hthread_t;
02296 typedef u_int ACE_thread_key_t;
02297 
02298 // Ensure that ACE_THR_PRI_FIFO_DEF and ACE_THR_PRI_OTHER_DEF are
02299 // defined on non-threaded platforms, to support application source
02300 // code compatibility.  ACE_THR_PRI_FIFO_DEF should be used by
02301 // applications for default real-time thread priority.
02302 // ACE_THR_PRI_OTHER_DEF should be used for non-real-time priority.
02303 #   if !defined(ACE_THR_PRI_FIFO_DEF)
02304 #     define ACE_THR_PRI_FIFO_DEF 0
02305 #   endif /* ! ACE_THR_PRI_FIFO_DEF */
02306 #   if !defined(ACE_THR_PRI_OTHER_DEF)
02307 #     define ACE_THR_PRI_OTHER_DEF 0
02308 #   endif /* ! ACE_THR_PRI_OTHER_DEF */
02309 
02310 # endif /* ACE_HAS_THREADS */
02311 
02312 # if defined (ACE_PSOS)
02313 
02314 // Wrapper for NT events on pSOS.
02315 class ACE_OS_Export ACE_event_t
02316 {
02317   friend class ACE_OS;
02318 
02319 protected:
02320 
02321   /// Protect critical section.
02322   ACE_mutex_t lock_;
02323 
02324   /// Keeps track of waiters.
02325   ACE_cond_t condition_;
02326 
02327   /// Specifies if this is an auto- or manual-reset event.
02328   int manual_reset_;
02329 
02330   /// "True" if signaled.
02331   int is_signaled_;
02332 
02333   /// Number of waiting threads.
02334   u_long waiting_threads_;
02335 };
02336 
02337 # endif /* ACE_PSOS */
02338 
02339 // Standard C Library includes
02340 // NOTE: stdarg.h must be #included before stdio.h on LynxOS.
02341 # include /**/ <stdarg.h>
02342 # if !defined (ACE_HAS_WINCE)
02343 #   include /**/ <assert.h>
02344 #   include /**/ <stdio.h>
02345 // this is a nasty hack to get around problems with the
02346 // pSOS definition of BUFSIZ as the config table entry
02347 // (which is valued using the LC_BUFSIZ value anyway)
02348 #   if defined (ACE_PSOS)
02349 #     if defined (BUFSIZ)
02350 #       undef BUFSIZ
02351 #     endif /* defined (BUFSIZ) */
02352 #     define BUFSIZ LC_BUFSIZ
02353 #   endif /* defined (ACE_PSOS) */
02354 
02355 #if defined (ACE_PSOS_DIAB_MIPS)
02356 #undef size_t
02357 typedef unsigned int size_t;
02358 #endif
02359 
02360 #   if !defined (ACE_LACKS_NEW_H)
02361 #     if defined (ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB)
02362 #       include /**/ <new>
02363 #     else
02364 #       include /**/ <new.h>
02365 #     endif /* ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB */
02366 #   endif /* ! ACE_LACKS_NEW_H */
02367 
02368 #   if !defined (ACE_PSOS_DIAB_MIPS)  &&  !defined (VXWORKS)
02369 #   define ACE_DONT_INCLUDE_ACE_SIGNAL_H
02370 #     include /**/ <signal.h>
02371 #   undef ACE_DONT_INCLUDE_ACE_SIGNAL_H
02372 #   endif /* ! ACE_PSOS_DIAB_MIPS && ! VXWORKS */
02373 
02374 #   if ! defined (ACE_PSOS_DIAB_MIPS)
02375 #   include /**/ <fcntl.h>
02376 #   endif /* ! ACE_PSOS_DIAB_MIPS */
02377 # endif /* ACE_HAS_WINCE */
02378 
02379 # include /**/ <limits.h>
02380 # include /**/ <ctype.h>
02381 # if ! defined (ACE_PSOS_DIAB_MIPS)
02382 # include /**/ <string.h>
02383 # include /**/ <stdlib.h>
02384 # endif /* ! ACE_PSOS_DIAB_MIPS */
02385 # include /**/ <float.h>
02386 
02387 // This is defined by XOPEN to be a minimum of 16.  POSIX.1g
02388 // also defines this value.  platform-specific config.h can
02389 // override this if need be.
02390 # if !defined (IOV_MAX)
02391 #  define IOV_MAX 16
02392 # endif /* IOV_MAX */
02393 
02394 # if !defined (ACE_IOV_MAX)
02395 #define ACE_IOV_MAX IOV_MAX
02396 # endif /* ACE_IOV_MAX */
02397 
02398 # if defined (ACE_PSOS_SNARFS_HEADER_INFO)
02399   // Header information snarfed from compiler provided header files
02400   // that are not included because there is already an identically
02401   // named file provided with pSOS, which does not have this info
02402   // from compiler supplied stdio.h
02403   extern FILE *fdopen(int, const char *);
02404   extern int getopt(int, char *const *, const char *);
02405   extern char *tempnam(const char *, const char *);
02406   extern "C" int fileno(FILE *);
02407 
02408 //  #define fileno(stream) ((stream)->_file)
02409 
02410   // from compiler supplied string.h
02411   extern char *strdup (const char *);
02412 
02413   // from compiler supplied stat.h
02414   extern mode_t umask (mode_t);
02415   extern int mkfifo (const char *, mode_t);
02416   extern int mkdir (const char *, mode_t);
02417 
02418   // from compiler supplied stdlib.h
02419   extern int putenv (char *);
02420 
02421   int isatty (int h);
02422 
02423 # endif /* ACE_PSOS_SNARFS_HEADER_INFO */
02424 
02425 # if defined (ACE_NEEDS_SCHED_H)
02426 #   include /**/ <sched.h>
02427 # endif /* ACE_NEEDS_SCHED_H */
02428 
02429 #if !defined (ACE_OSTREAM_TYPE)
02430 # if defined (ACE_LACKS_IOSTREAM_TOTALLY)
02431 #   define ACE_OSTREAM_TYPE FILE
02432 # else  /* ! ACE_LACKS_IOSTREAM_TOTALLY */
02433 #   define ACE_OSTREAM_TYPE ostream
02434 # endif /* ! ACE_LACKS_IOSTREAM_TOTALLY */
02435 #endif /* ! ACE_OSTREAM_TYPE */
02436 
02437 #if !defined (ACE_DEFAULT_LOG_STREAM)
02438 # if defined (ACE_LACKS_IOSTREAM_TOTALLY)
02439 #   define ACE_DEFAULT_LOG_STREAM 0
02440 # else  /* ! ACE_LACKS_IOSTREAM_TOTALLY */
02441 #   define ACE_DEFAULT_LOG_STREAM (&cerr)
02442 # endif /* ! ACE_LACKS_IOSTREAM_TOTALLY */
02443 #endif /* ! ACE_DEFAULT_LOG_STREAM */
02444 
02445 // If the user wants minimum IOStream inclusion, we will just include
02446 // the forward declarations
02447 # if defined (ACE_HAS_MINIMUM_IOSTREAMH_INCLUSION)
02448 // Forward declaration for streams
02449 #   include "ace/iosfwd.h"
02450 # else /* ACE_HAS_MINIMUM_IOSTREAMH_INCLUSION */
02451 // Else they will get all the stream header files
02452 #   include "ace/streams.h"
02453 # endif /* ACE_HAS_MINIMUM_IOSTREAMH_INCLUSION */
02454 
02455 # if !defined (ACE_HAS_WINCE)
02456 #   if ! defined (ACE_PSOS_DIAB_MIPS)
02457 #   include /**/ <fcntl.h>
02458 #   endif /* ! ACE_PSOS_DIAB_MIPS */
02459 # endif /* ACE_HAS_WINCE */
02460 
02461 // This must come after signal.h is #included.
02462 # if defined (SCO)
02463 #   define SIGIO SIGPOLL
02464 #   include /**/ <sys/regset.h>
02465 # endif /* SCO */
02466 
02467 # if defined ACE_HAS_BYTESEX_H
02468 #   include /**/ <bytesex.h>
02469 # endif /* ACE_HAS_BYTESEX_H */
02470 # include "ace/Basic_Types.h"
02471 
02472 /* This should work for linux, solaris 5.6 and above, IRIX, OSF */
02473 # if defined (ACE_HAS_LLSEEK) || defined (ACE_HAS_LSEEK64)
02474 #   if ACE_SIZEOF_LONG == 8
02475       typedef off_t ACE_LOFF_T;
02476 #   elif defined (__sgi) || defined (AIX) || defined (HPUX) \
02477     || defined (__QNX__)
02478       typedef off64_t ACE_LOFF_T;
02479 #   elif defined (__sun)
02480       typedef offset_t ACE_LOFF_T;
02481 #   elif defined (WIN32) //Add by Nick Lin -- for win32 llseek
02482       typedef __int64  ACE_LOFF_T;  //Add by Nick Lin -- for win32 llseek
02483 #   else
02484       typedef loff_t ACE_LOFF_T;
02485 #   endif
02486 # endif /* ACE_HAS_LLSEEK || ACE_HAS_LSEEK64 */
02487 
02488 // Type-safe, and unsigned.
02489 static const ACE_UINT32 ACE_U_ONE_SECOND_IN_MSECS = 1000U;
02490 static const ACE_UINT32 ACE_U_ONE_SECOND_IN_USECS = 1000000U;
02491 static const ACE_UINT32 ACE_U_ONE_SECOND_IN_NSECS = 1000000000U;
02492 
02493 # if defined (ACE_HAS_SIG_MACROS)
02494 #   undef sigemptyset
02495 #   undef sigfillset
02496 #   undef sigaddset
02497 #   undef sigdelset
02498 #   undef sigismember
02499 # endif /* ACE_HAS_SIG_MACROS */
02500 
02501 // This must come after signal.h is #included.  It's to counteract
02502 // the sigemptyset and sigfillset #defines, which only happen
02503 // when __OPTIMIZE__ is #defined (really!) on Linux.
02504 # if defined (linux) && defined (__OPTIMIZE__)
02505 #   undef sigemptyset
02506 #   undef sigfillset
02507 # endif /* linux && __OPTIMIZE__ */
02508 
02509 // Prototypes should come after ace/Basic_Types.h since some types may
02510 // be used in the prototypes.
02511 
02512 #if defined (ACE_LACKS_GETPGID_PROTOTYPE) && \
02513     !defined (_XOPEN_SOURCE) && !defined (_XOPEN_SOURCE_EXTENDED)
02514 extern "C" pid_t getpgid (pid_t pid);
02515 #endif  /* ACE_LACKS_GETPGID_PROTOTYPE &&
02516            !_XOPEN_SOURCE && !_XOPEN_SOURCE_EXTENDED */
02517 
02518 #if defined (ACE_LACKS_STRPTIME_PROTOTYPE) && !defined (_XOPEN_SOURCE)
02519 extern "C" char *strptime (const char *s, const char *fmt, struct tm *tp);
02520 #endif  /* ACE_LACKS_STRPTIME_PROTOTYPE */
02521 
02522 #if defined (ACE_LACKS_STRTOK_R_PROTOTYPE) && !defined (_POSIX_SOURCE)
02523 extern "C" char *strtok_r (char *s, const char *delim, char **save_ptr);
02524 #endif  /* ACE_LACKS_STRTOK_R_PROTOTYPE */
02525 
02526 #if !defined (_LARGEFILE64_SOURCE)
02527 # if defined (ACE_LACKS_LSEEK64_PROTOTYPE) && \
02528      defined (ACE_LACKS_LLSEEK_PROTOTYPE)
02529 #   error Define either ACE_LACKS_LSEEK64_PROTOTYPE or ACE_LACKS_LLSEEK_PROTOTYPE, not both!
02530 # elif defined (ACE_LACKS_LSEEK64_PROTOTYPE)
02531 extern "C" ACE_LOFF_T lseek64 (int fd, ACE_LOFF_T offset, int whence);
02532 # elif defined (ACE_LACKS_LLSEEK_PROTOTYPE)
02533 extern "C" ACE_LOFF_T llseek (int fd, ACE_LOFF_T offset, int whence);
02534 # endif
02535 #endif  /* _LARGEFILE64_SOURCE */
02536 
02537 #if defined (ACE_LACKS_PREAD_PROTOTYPE) && (_XOPEN_SOURCE - 0) < 500
02538 // _XOPEN_SOURCE == 500    Single Unix conformance
02539 // It seems that _XOPEN_SOURCE == 500 means that the prototypes are
02540 // already defined in the system headers.
02541 extern "C" ssize_t pread (int fd,
02542                           void *buf,
02543                           size_t nbytes,
02544                           off_t offset);
02545 
02546 extern "C" ssize_t pwrite (int fd,
02547                            const void *buf,
02548                            size_t n,
02549                            off_t offset);
02550 #endif  /* ACE_LACKS_PREAD_PROTOTYPE && (_XOPEN_SOURCE - 0) < 500 */
02551 
02552 # if defined (ACE_LACKS_UALARM_PROTOTYPE)
02553 extern "C" u_int ualarm (u_int usecs, u_int interval);
02554 # endif /* ACE_LACKS_UALARM_PROTOTYPE */
02555 
02556 # if defined (ACE_HAS_BROKEN_SENDMSG)
02557 typedef struct msghdr ACE_SENDMSG_TYPE;
02558 # else
02559 typedef const struct msghdr ACE_SENDMSG_TYPE;
02560 # endif /* ACE_HAS_BROKEN_SENDMSG */
02561 
02562 # if defined (ACE_HAS_BROKEN_RANDR)
02563 // The SunOS 5.4.X version of rand_r is inconsistent with the header
02564 // files...
02565 typedef u_int ACE_RANDR_TYPE;
02566 extern "C" int rand_r (ACE_RANDR_TYPE seed);
02567 # else
02568 #   if defined (HPUX_10)
02569 // HP-UX 10.x's stdlib.h (long *) doesn't match that man page (u_int *)
02570 typedef long ACE_RANDR_TYPE;
02571 #   else
02572 typedef u_int ACE_RANDR_TYPE;
02573 #   endif /* HPUX_10 */
02574 # endif /* ACE_HAS_BROKEN_RANDR */
02575 
02576 # if defined (ACE_HAS_UTIME)
02577 #   include /**/ <utime.h>
02578 # endif /* ACE_HAS_UTIME */
02579 
02580 # if !defined (ACE_HAS_MSG) && !defined (SCO)
02581 struct msghdr {};
02582 # endif /* ACE_HAS_MSG */
02583 
02584 # if defined (ACE_HAS_MSG) && defined (ACE_LACKS_MSG_ACCRIGHTS)
02585 #   if !defined (msg_accrights)
02586 #     undef msg_control
02587 #     define msg_accrights msg_control
02588 #   endif /* ! msg_accrights */
02589 
02590 #   if !defined (msg_accrightslen)
02591 #     undef msg_controllen
02592 #     define msg_accrightslen msg_controllen
02593 #   endif /* ! msg_accrightslen */
02594 # endif /* ACE_HAS_MSG && ACE_LACKS_MSG_ACCRIGHTS */
02595 
02596 # if !defined (ACE_HAS_SIG_ATOMIC_T)
02597 typedef int sig_atomic_t;
02598 # endif /* !ACE_HAS_SIG_ATOMIC_T */
02599 
02600 # if defined (ACE_HAS_CONSISTENT_SIGNAL_PROTOTYPES)
02601 // Prototypes for both signal() and struct sigaction are consistent..
02602 #   if defined (ACE_HAS_SIG_C_FUNC)
02603 extern "C" {
02604 #   endif /* ACE_HAS_SIG_C_FUNC */
02605 #   if !defined (ACE_PSOS)
02606 typedef void (*ACE_SignalHandler)(int);
02607 typedef void (*ACE_SignalHandlerV)(int);
02608 #   endif /* !defined (ACE_PSOS) */
02609 #   if defined (ACE_HAS_SIG_C_FUNC)
02610 }
02611 #   endif /* ACE_HAS_SIG_C_FUNC */
02612 # elif defined (ACE_HAS_LYNXOS_SIGNALS)
02613 typedef void (*ACE_SignalHandler)(...);
02614 typedef void (*ACE_SignalHandlerV)(...);
02615 # elif defined (ACE_HAS_TANDEM_SIGNALS)
02616 typedef void (*ACE_SignalHandler)(...);
02617 typedef void (*ACE_SignalHandlerV)(...);
02618 # elif defined (ACE_HAS_IRIX_53_SIGNALS)
02619 typedef void (*ACE_SignalHandler)(...);
02620 typedef void (*ACE_SignalHandlerV)(...);
02621 # elif defined (ACE_HAS_SPARCWORKS_401_SIGNALS)
02622 typedef void (*ACE_SignalHandler)(int, ...);
02623 typedef void (*ACE_SignalHandlerV)(int,...);
02624 # elif defined (ACE_HAS_SUNOS4_SIGNAL_T)
02625 typedef void (*ACE_SignalHandler)(...);
02626 typedef void (*ACE_SignalHandlerV)(...);
02627 # elif defined (ACE_HAS_SVR4_SIGNAL_T)
02628 // SVR4 Signals are inconsistent (e.g., see struct sigaction)..
02629 typedef void (*ACE_SignalHandler)(int);
02630 #   if !defined (m88k)     /*  with SVR4_SIGNAL_T */
02631 typedef void (*ACE_SignalHandlerV)(void);
02632 #   else
02633 typedef void (*ACE_SignalHandlerV)(int);
02634 #   endif  /*  m88k */       /*  with SVR4_SIGNAL_T */
02635 # elif defined (ACE_WIN32)
02636 typedef void (__cdecl *ACE_SignalHandler)(int);
02637 typedef void (__cdecl *ACE_SignalHandlerV)(int);
02638 # elif defined (ACE_HAS_UNIXWARE_SVR4_SIGNAL_T)
02639 typedef void (*ACE_SignalHandler)(int);
02640 typedef void (*ACE_SignalHandlerV)(...);
02641 # else /* This is necessary for some older broken version of cfront */
02642 #   if defined (SIG_PF)
02643 #     define ACE_SignalHandler SIG_PF
02644 #   else
02645 typedef void (*ACE_SignalHandler)(int);
02646 #   endif /* SIG_PF */
02647 typedef void (*ACE_SignalHandlerV)(...);
02648 # endif /* ACE_HAS_CONSISTENT_SIGNAL_PROTOTYPES */
02649 
02650 # if defined (BUFSIZ)
02651 #   define ACE_STREAMBUF_SIZE BUFSIZ
02652 # else
02653 #   define ACE_STREAMBUF_SIZE 1024
02654 # endif /* BUFSIZ */
02655 
02656 # if defined (ACE_WIN32)
02657 // Turn off warnings for /W4
02658 // To resume any of these warning: #pragma warning(default: 4xxx)
02659 // which should be placed after these defines
02660 
02661 #   if !defined (ALL_WARNINGS) && defined(_MSC_VER) && !defined(ghs) && !defined(__MINGW32__)
02662 // #pragma warning(disable: 4101)  // unreferenced local variable
02663 #     pragma warning(disable: 4127)  /* constant expression for TRACE/ASSERT */
02664 #     pragma warning(disable: 4134)  /* message map member fxn casts */
02665 #     pragma warning(disable: 4511)  /* private copy constructors are good to have */
02666 #     pragma warning(disable: 4512)  /* private operator= are good to have */
02667 #     pragma warning(disable: 4514)  /* unreferenced inlines are common */
02668 #     pragma warning(disable: 4710)  /* private constructors are disallowed */
02669 #     pragma warning(disable: 4705)  /* statement has no effect in optimized code */
02670 // #pragma warning(disable: 4701)  // local variable *may* be used without init
02671 // #pragma warning(disable: 4702)  // unreachable code caused by optimizations
02672 #     pragma warning(disable: 4791)  /* loss of debugging info in retail version */
02673 // #pragma warning(disable: 4204)  // non-constant aggregate initializer
02674 #     pragma warning(disable: 4275)  /* deriving exported class from non-exported */
02675 #     pragma warning(disable: 4251)  /* using non-exported as public in exported */
02676 #     pragma warning(disable: 4786)  /* identifier was truncated to '255' characters in the browser information */
02677 #     pragma warning(disable: 4097)  /* typedef-name used as synonym for class-name */
02678 #   endif /* !ALL_WARNINGS && _MSV_VER && !ghs && !__MINGW32__ */
02679 
02680 // STRICT type checking in WINDOWS.H enhances type safety for Windows
02681 // programs by using distinct types to represent all the different
02682 // HANDLES in Windows. So for example, STRICT prevents you from
02683 // mistakenly passing an HPEN to a routine expecting an HBITMAP.
02684 // Note that we only use this if we
02685 #   if defined (ACE_HAS_STRICT) && (ACE_HAS_STRICT != 0)
02686 #     if !defined (STRICT)   /* may already be defined */
02687 #       define STRICT
02688 #     endif /* !STRICT */
02689 #   endif /* ACE_HAS_STRICT */
02690 
02691 #   if !defined (ACE_HAS_WINCE)
02692 #     include /**/ <sys/timeb.h>
02693 #   endif /* ACE_HAS_WINCE */
02694 
02695 // Need to work around odd glitches with NT.
02696 #   if !defined (ACE_MAX_DEFAULT_PORT)
02697 #     define ACE_MAX_DEFAULT_PORT 65535
02698 #   endif /* ACE_MAX_DEFAULT_PORT */
02699 
02700 // We're on WinNT or Win95
02701 #   define ACE_PLATFORM_A "Win32"
02702 #   define ACE_PLATFORM_EXE_SUFFIX_A ".exe"
02703 
02704 // Used for dynamic linking
02705 #   if !defined (ACE_DEFAULT_SVC_CONF)
02706 #     if (ACE_USES_CLASSIC_SVC_CONF == 1)
02707 #       define ACE_DEFAULT_SVC_CONF ACE_LIB_TEXT (".\\svc.conf")
02708 #     else
02709 #       define ACE_DEFAULT_SVC_CONF ACE_LIB_TEXT (".\\svc.conf.xml")
02710 #     endif /* ACE_USES_CLASSIC_SVC_CONF ==1 */
02711 #   endif /* ACE_DEFAULT_SVC_CONF */
02712 
02713 // The following are #defines and #includes that are specific to
02714 // WIN32.
02715 #   if defined (ACE_HAS_WINCE)
02716 #     define ACE_STDIN  _fileno (stdin)
02717 #     define ACE_STDOUT _fileno (stdout)
02718 #     define ACE_STDERR _fileno (stderr)
02719 #   else
02720 #   define ACE_STDIN GetStdHandle (STD_INPUT_HANDLE)
02721 #   define ACE_STDOUT GetStdHandle (STD_OUTPUT_HANDLE)
02722 #   define ACE_STDERR GetStdHandle (STD_ERROR_HANDLE)
02723 #   endif  // ACE_HAS_WINCE
02724 
02725 // Default semaphore key and mutex name
02726 #   if !defined (ACE_DEFAULT_SEM_KEY)
02727 #     define ACE_DEFAULT_SEM_KEY "ACE_SEM_KEY"
02728 #   endif /* ACE_DEFAULT_SEM_KEY */
02729 
02730 #   define ACE_INVALID_SEM_KEY 0
02731 
02732 #   if !defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS)
02733 #     define ACE_SEH_TRY if (1)
02734 #     define ACE_SEH_EXCEPT(X) while (0)
02735 #     define ACE_SEH_FINALLY if (1)
02736 #   elif defined(__BORLANDC__)
02737 #     if (__BORLANDC__ >= 0x0530) /* Borland C++ Builder 3.0 */
02738 #       define ACE_SEH_TRY try
02739 #       define ACE_SEH_EXCEPT(X) __except(X)
02740 #       define ACE_SEH_FINALLY __finally
02741 #     else
02742 #       define ACE_SEH_TRY if (1)
02743 #       define ACE_SEH_EXCEPT(X) while (0)
02744 #       define ACE_SEH_FINALLY if (1)
02745 #     endif
02746 #   elif defined (__IBMCPP__) && (__IBMCPP__ >= 400)
02747 #     define ACE_SEH_TRY if (1)
02748 #     define ACE_SEH_EXCEPT(X) while (0)
02749 #     define ACE_SEH_FINALLY if (1)
02750 #   else
02751 #     define ACE_SEH_TRY __try
02752 #     define ACE_SEH_EXCEPT(X) __except(X)
02753 #     define ACE_SEH_FINALLY __finally
02754 #   endif /* ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS */
02755 
02756 // The "null" device on Win32.
02757 #   define ACE_DEV_NULL "nul"
02758 
02759 // Define the pathname separator characters for Win32 (ugh).
02760 #   define ACE_DIRECTORY_SEPARATOR_STR_A "\\"
02761 #   define ACE_DIRECTORY_SEPARATOR_CHAR_A '\\'
02762 #   define ACE_LD_SEARCH_PATH ACE_LIB_TEXT ("PATH")
02763 #   define ACE_LD_SEARCH_PATH_SEPARATOR_STR ACE_LIB_TEXT (";")
02764 #   define ACE_DLL_SUFFIX ACE_LIB_TEXT (".dll")
02765 #   if defined (__MINGW32__)
02766 #     define ACE_DLL_PREFIX ACE_LIB_TEXT ("lib")
02767 #   else /* __MINGW32__ */
02768 #     define ACE_DLL_PREFIX ACE_LIB_TEXT ("")
02769 #   endif /* __MINGW32__ */
02770 
02771 // This will help until we figure out everything:
02772 #   define NFDBITS 32 /* only used in unused functions... */
02773 // These two may be used for internal flags soon:
02774 #   define MAP_PRIVATE 1
02775 #   define MAP_SHARED  2
02776 #   define MAP_FIXED   4
02777 
02778 #   define RUSAGE_SELF 1
02779 
02780 struct shmaddr { };
02781 struct msqid_ds {};
02782 
02783 /// Fake the UNIX rusage structure.  Perhaps we can add more to this
02784 /// later on?
02785 struct rusage
02786 {
02787   FILETIME ru_utime;
02788   FILETIME ru_stime;
02789 };
02790 
02791 // MMAP flags
02792 #   define PROT_READ PAGE_READONLY
02793 #   define PROT_WRITE PAGE_READWRITE
02794 #   define PROT_RDWR PAGE_READWRITE
02795 /* If we can find suitable use for these flags, here they are:
02796 PAGE_WRITECOPY
02797 PAGE_EXECUTE
02798 PAGE_EXECUTE_READ
02799 PAGE_EXECUTE_READWRITE
02800 PAGE_EXECUTE_WRITECOPY
02801 PAGE_GUARD
02802 PAGE_NOACCESS
02803 PAGE_NOCACHE  */
02804 
02805 #   if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
02806 #     include /**/ <ws2tcpip.h>
02807 #   endif /* ACE_HAS_WINSOCK2 */
02808 
02809 // error code mapping
02810 #   define ETIME                   ERROR_SEM_TIMEOUT
02811 #   define EWOULDBLOCK             WSAEWOULDBLOCK
02812 #   define EINPROGRESS             WSAEINPROGRESS
02813 #   define EALREADY                WSAEALREADY
02814 #   define ENOTSOCK                WSAENOTSOCK
02815 #   define EDESTADDRREQ            WSAEDESTADDRREQ
02816 #   define EMSGSIZE                WSAEMSGSIZE
02817 #   define EPROTOTYPE              WSAEPROTOTYPE
02818 #   define ENOPROTOOPT             WSAENOPROTOOPT
02819 #   define EPROTONOSUPPORT         WSAEPROTONOSUPPORT
02820 #   define ESOCKTNOSUPPORT         WSAESOCKTNOSUPPORT
02821 #   define EOPNOTSUPP              WSAEOPNOTSUPP
02822 #   define EPFNOSUPPORT            WSAEPFNOSUPPORT
02823 #   define EAFNOSUPPORT            WSAEAFNOSUPPORT
02824 #   define EADDRINUSE              WSAEADDRINUSE
02825 #   define EADDRNOTAVAIL           WSAEADDRNOTAVAIL
02826 #   define ENETDOWN                WSAENETDOWN
02827 #   define ENETUNREACH             WSAENETUNREACH
02828 #   define ENETRESET               WSAENETRESET
02829 #   define ECONNABORTED            WSAECONNABORTED
02830 #   define ECONNRESET              WSAECONNRESET
02831 #   define ENOBUFS                 WSAENOBUFS
02832 #   define EISCONN                 WSAEISCONN
02833 #   define ENOTCONN                WSAENOTCONN
02834 #   define ESHUTDOWN               WSAESHUTDOWN
02835 #   define ETOOMANYREFS            WSAETOOMANYREFS
02836 #   define ETIMEDOUT               WSAETIMEDOUT
02837 #   define ECONNREFUSED            WSAECONNREFUSED
02838 #   define ELOOP                   WSAELOOP
02839 #   define EHOSTDOWN               WSAEHOSTDOWN
02840 #   define EHOSTUNREACH            WSAEHOSTUNREACH
02841 #   define EPROCLIM                WSAEPROCLIM
02842 #   define EUSERS                  WSAEUSERS
02843 #   define EDQUOT                  WSAEDQUOT
02844 #   define ESTALE                  WSAESTALE
02845 #   define EREMOTE                 WSAEREMOTE
02846 // Grrr! ENAMETOOLONG and ENOTEMPTY are already defined by the horrible
02847 // 'standard' library.
02848 // #define ENAMETOOLONG            WSAENAMETOOLONG
02849 
02850 #   if defined (__BORLANDC__) && (__BORLANDC__ <= 0x540)
02851 #     define ENOTEMPTY               WSAENOTEMPTY
02852 #   endif /* __BORLANDC__  && __BORLANDC__ <= 0x540*/
02853 
02854 
02855 #   if !defined (ACE_HAS_WINCE)
02856 #     include /**/ <time.h>
02857 #     include /**/ <direct.h>
02858 #     include /**/ <process.h>
02859 #     include /**/ <io.h>
02860 #   endif /* ACE_HAS_WINCE */
02861 
02862 #   if defined (__BORLANDC__)
02863 #     include /**/ <fcntl.h>
02864 #     define _chdir chdir
02865 #     define _ftime ftime
02866 #     undef _access
02867 #     define _access access
02868 #     if (__BORLANDC__ <= 0x540)
02869 #       define _getcwd getcwd
02870 #       define _stat stat
02871 #     endif
02872 #     define _isatty isatty
02873 #     define _umask umask
02874 #     define _fstat fstat
02875 #     define _stricmp stricmp
02876 #     define _strnicmp strnicmp
02877 
02878 #     define _timeb timeb
02879 
02880 #     define _O_CREAT O_CREAT
02881 #     define _O_EXCL  O_EXCL
02882 #     define _O_TRUNC O_TRUNC
02883       // 0x0800 is used for O_APPEND.  0x08 looks free.
02884 #     define _O_TEMPORARY 0x08 /* see fcntl.h */
02885 #     define _O_RDWR   O_RDWR
02886 #     define _O_WRONLY O_WRONLY
02887 #     define _O_RDONLY O_RDONLY
02888 #     define _O_APPEND O_APPEND
02889 #     define _O_BINARY O_BINARY
02890 #     define _O_TEXT   O_TEXT
02891 #   endif /* __BORLANDC__ */
02892 
02893 typedef OVERLAPPED ACE_OVERLAPPED;
02894 
02895 typedef DWORD ACE_thread_t;
02896 #   if !defined(__MINGW32__)
02897 typedef long pid_t;
02898 #   endif /* __MINGW32__ */
02899 typedef HANDLE ACE_hthread_t;
02900 
02901 #define ACE_INVALID_PID ((pid_t) -1)
02902 #   if defined (ACE_HAS_TSS_EMULATION)
02903       typedef DWORD ACE_OS_thread_key_t;
02904       typedef u_int ACE_thread_key_t;
02905 #   else  /* ! ACE_HAS_TSS_EMULATION */
02906       typedef DWORD ACE_thread_key_t;
02907 #   endif /* ! ACE_HAS_TSS_EMULATION */
02908 
02909 #   if !defined (ACE_LACKS_LONGLONG_T)
02910 // 64-bit quad-word definitions.
02911 typedef unsigned __int64 ACE_QWORD;
02912 typedef unsigned __int64 ACE_hrtime_t;
02913 inline ACE_QWORD ACE_MAKE_QWORD (DWORD lo, DWORD hi) { return ACE_QWORD (lo) | (ACE_QWORD (hi) << 32); }
02914 inline DWORD ACE_LOW_DWORD  (ACE_QWORD q) { return (DWORD) q; }
02915 inline DWORD ACE_HIGH_DWORD (ACE_QWORD q) { return (DWORD) (q >> 32); }
02916 #   else
02917 // Can't find ANY place that ACE_QWORD is used, but hrtime_t is.
02918 typedef ACE_UINT64 ACE_hrtime_t;
02919 #   endif // ACE_LACKS_LONGLONG_T
02920 
02921 // Win32 dummies to help compilation.
02922 
02923 // These are used in SPIPE_Acceptor/Connector, but are ignored at runtime.
02924 #   if defined (ACE_HAS_WINCE)
02925 #     if !defined (PIPE_TYPE_MESSAGE)
02926 #       define PIPE_TYPE_MESSAGE  0
02927 #     endif
02928 #     if !defined (PIPE_READMODE_MESSAGE)
02929 #       define PIPE_READMODE_MESSAGE  0
02930 #     endif
02931 #     if !defined (PIPE_WAIT)
02932 #       define PIPE_WAIT  0
02933 #     endif
02934 #   endif /* ACE_HAS_WINCE */
02935 
02936 #   if !defined (__BORLANDC__)
02937 typedef DWORD nlink_t;
02938 #       if !defined(__MINGW32__)
02939 typedef u_short mode_t;
02940 #       endif /* !__MINGW32__ */
02941 typedef long uid_t;
02942 typedef long gid_t;
02943 #   endif /* __BORLANDC__ */
02944 typedef char *caddr_t;
02945 
02946 typedef DWORD ACE_exitcode;
02947 #   define ACE_SYSCALL_FAILED 0xFFFFFFFF
02948 
02949 // Needed to map calls to NT transparently.
02950 #   define MS_ASYNC 0
02951 #   define MS_INVALIDATE 0
02952 
02953 // Reliance on CRT - I don't really like this.
02954 
02955 #   define O_NDELAY    1
02956 #   if !defined (MAXPATHLEN)
02957 #     define MAXPATHLEN  _MAX_PATH
02958 #   endif /* !MAXPATHLEN */
02959 #   define MAXNAMLEN   _MAX_FNAME
02960 #   define EADDRINUSE WSAEADDRINUSE
02961 
02962 /// The ordering of the fields in this struct is important.  It has to
02963 /// match those in WSABUF.
02964 struct iovec
02965 {
02966   /// byte count to read/write
02967   u_long iov_len;
02968   /// data to be read/written
02969   char *iov_base;
02970 
02971   // WSABUF is a Winsock2-only type.
02972 #if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
02973   operator WSABUF &(void) { return *((WSABUF *) this); }
02974 #endif /* defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) */
02975 };
02976 
02977 struct msghdr
02978 {
02979   /// Optional address
02980   sockaddr * msg_name;
02981 
02982   /// Size of address
02983   int msg_namelen;
02984 
02985   /// Scatter/gather array
02986   iovec *msg_iov;
02987 
02988   /// # elements in msg_iov
02989   int msg_iovlen;
02990 
02991   /// Access rights sent/received
02992   caddr_t msg_accrights;
02993 
02994   int msg_accrightslen;
02995 };
02996 
02997 typedef int ACE_idtype_t;
02998 typedef DWORD ACE_id_t;
02999 #   define ACE_SELF (0)
03000 typedef int ACE_pri_t;
03001 
03002 // Dynamic loading-related types - used for dlopen and family.
03003 typedef HINSTANCE ACE_SHLIB_HANDLE;
03004 #   define ACE_SHLIB_INVALID_HANDLE 0
03005 #   define ACE_DEFAULT_SHLIB_MODE 0
03006 
03007 # elif defined (ACE_PSOS)
03008 
03009 typedef ACE_UINT64 ACE_hrtime_t;
03010 
03011 #   if defined (ACE_SIGINFO_IS_SIGINFO_T)
03012   typedef struct siginfo siginfo_t;
03013 #   endif /* ACE_LACKS_SIGINFO_H */
03014 
03015 # else /* !defined (ACE_WIN32) && !defined (ACE_PSOS) */
03016 
03017 #   if defined (m88k)
03018 #     define RUSAGE_SELF 1
03019 #   endif  /*  m88k */
03020 
03021 // Default port is MAX_SHORT.
03022 #   define ACE_MAX_DEFAULT_PORT 65535
03023 
03024 // Default semaphore key
03025 #   if !defined (ACE_DEFAULT_SEM_KEY)
03026 #     define ACE_DEFAULT_SEM_KEY 1234
03027 #   endif /* ACE_DEFAULT_SEM_KEY */
03028 
03029 #   define ACE_INVALID_SEM_KEY -1
03030 
03031 // Define the pathname separator characters for UNIX.
03032 #   define ACE_DIRECTORY_SEPARATOR_STR_A "/"
03033 #   define ACE_DIRECTORY_SEPARATOR_CHAR_A '/'
03034 
03035 // We're some kind of UNIX...
03036 #   define ACE_PLATFORM_A "UNIX"
03037 #   define ACE_PLATFORM_EXE_SUFFIX_A ""
03038 
03039 #   if !defined (ACE_LD_SEARCH_PATH)
03040 #     define ACE_LD_SEARCH_PATH "LD_LIBRARY_PATH"
03041 #   endif /* ACE_LD_SEARCH_PATH */
03042 #   if !defined (ACE_LD_SEARCH_PATH_SEPARATOR_STR)
03043 #     define ACE_LD_SEARCH_PATH_SEPARATOR_STR ":"
03044 #   endif /* ACE_LD_SEARCH_PATH_SEPARATOR_STR */
03045 
03046 #   if !defined (ACE_DLL_SUFFIX)
03047 #     define ACE_DLL_SUFFIX ".so"
03048 #   endif /* ACE_DLL_SUFFIX */
03049 #   if !defined (ACE_DLL_PREFIX)
03050 #     define ACE_DLL_PREFIX "lib"
03051 #   endif /* ACE_DLL_PREFIX */
03052 
03053 // Used for dynamic linking.
03054 #   if !defined (ACE_DEFAULT_SVC_CONF)
03055 #     if (ACE_USES_CLASSIC_SVC_CONF == 1)
03056 #       define ACE_DEFAULT_SVC_CONF ACE_LIB_TEXT ("./svc.conf")
03057 #     else
03058 #       define ACE_DEFAULT_SVC_CONF ACE_LIB_TEXT ("./svc.conf.xml")
03059 #     endif /* ACE_USES_CLASSIC_SVC_CONF ==1 */
03060 #   endif /* ACE_DEFAULT_SVC_CONF */
03061 
03062 // The following are #defines and #includes that are specific to UNIX.
03063 
03064 #   define ACE_STDIN 0
03065 #   define ACE_STDOUT 1
03066 #   define ACE_STDERR 2
03067 
03068 // Be consistent with Winsock naming
03069 typedef int ACE_exitcode;
03070 #   define ACE_INVALID_HANDLE -1
03071 #   define ACE_SYSCALL_FAILED -1
03072 
03073 #   define ACE_SEH_TRY if (1)
03074 #   define ACE_SEH_EXCEPT(X) while (0)
03075 #   define ACE_SEH_FINALLY if (1)
03076 
03077 # if !defined (ACE_INVALID_PID)
03078 # define ACE_INVALID_PID ((pid_t) -1)
03079 # endif /* ACE_INVALID_PID */
03080 
03081 // The "null" device on UNIX.
03082 #   define ACE_DEV_NULL "/dev/null"
03083 
03084 /**
03085  * @class ACE_event_t
03086  *
03087  * @brief Wrapper for NT events on UNIX.
03088  */
03089 class ACE_OS_Export ACE_event_t
03090 {
03091   friend class ACE_OS;
03092 protected:
03093   /// Protect critical section.
03094   ACE_mutex_t lock_;
03095 
03096   /// Keeps track of waiters.
03097   ACE_cond_t condition_;
03098 
03099   /// Specifies if this is an auto- or manual-reset event.
03100   int manual_reset_;
03101 
03102   /// "True" if signaled.
03103   int is_signaled_;
03104 
03105   /// Number of waiting threads.
03106   u_long waiting_threads_;
03107 };
03108 
03109 struct ACE_OVERLAPPED
03110 {
03111   u_long Internal;
03112   u_long InternalHigh;
03113   u_long Offset;
03114   u_long OffsetHigh;
03115   ACE_HANDLE hEvent;
03116 };
03117 
03118 
03119 // Add some typedefs and macros to enhance Win32 conformance...
03120 #   if !defined (LPSECURITY_ATTRIBUTES)
03121 #     define LPSECURITY_ATTRIBUTES int
03122 #   endif /* !defined LPSECURITY_ATTRIBUTES */
03123 #   if !defined (GENERIC_READ)
03124 #     define GENERIC_READ 0
03125 #   endif /* !defined GENERIC_READ */
03126 #   if !defined (FILE_SHARE_READ)
03127 #     define FILE_SHARE_READ 0
03128 #   endif /* !defined FILE_SHARE_READ */
03129 #   if !defined (OPEN_EXISTING)
03130 #     define OPEN_EXISTING 0
03131 #   endif /* !defined OPEN_EXISTING */
03132 #   if !defined (FILE_ATTRIBUTE_NORMAL)
03133 #     define FILE_ATTRIBUTE_NORMAL 0
03134 #   endif /* !defined FILE_ATTRIBUTE_NORMAL */
03135 #   if !defined (MAXIMUM_WAIT_OBJECTS)
03136 #     define MAXIMUM_WAIT_OBJECTS 0
03137 #   endif /* !defined MAXIMUM_WAIT_OBJECTS */
03138 #   if !defined (FILE_FLAG_OVERLAPPED)
03139 #     define FILE_FLAG_OVERLAPPED 0
03140 #   endif /* !defined FILE_FLAG_OVERLAPPED */
03141 #   if !defined (FILE_FLAG_SEQUENTIAL_SCAN)
03142 #     define FILE_FLAG_SEQUENTIAL_SCAN 0
03143 #   endif   /* FILE_FLAG_SEQUENTIAL_SCAN */
03144 #   if !defined(FILE_FLAG_WRITE_THROUGH)
03145 #     define FILE_FLAG_WRITE_THROUGH 0
03146 #   endif /* !defined FILE_FLAG_WRITE_THROUGH */
03147 #   if !defined(PIPE_WAIT)
03148 #     define PIPE_WAIT 0
03149 #   endif /* !defined PIPE_WAIT */
03150 #   if !defined(PIPE_NOWAIT)
03151 #     define PIPE_NOWAIT 0
03152 #   endif /* !defined PIPE_WAIT */
03153 #   if !defined(PIPE_READMODE_BYTE)
03154 #     define PIPE_READMODE_BYTE 0
03155 #   endif /* !defined PIPE_READMODE_BYTE */
03156 #   if !defined(PIPE_READMODE_MESSAGE)
03157 #     define PIPE_READMODE_MESSAGE 0
03158 #   endif /* !defined PIPE_READMODE_MESSAGE */
03159 #   if !defined(PIPE_TYPE_BYTE)
03160 #     define PIPE_TYPE_BYTE 0
03161 #   endif /* !defined PIPE_TYPE_BYTE */
03162 #   if !defined(PIPE_TYPE_MESSAGE)
03163 #     define PIPE_TYPE_MESSAGE 0
03164 #   endif /* !defined PIPE_TYPE_MESSAGE */
03165 
03166 #   if defined (ACE_HAS_BROKEN_IF_HEADER)
03167 struct ifafilt;
03168 #   endif /* ACE_HAS_BROKEN_IF_HEADER */
03169 
03170 #   if defined (ACE_HAS_AIX_BROKEN_SOCKET_HEADER)
03171 #     undef __cplusplus
03172 #     include /**/ <sys/socket.h>
03173 #     define __cplusplus
03174 #   else
03175 #     include /**/ <sys/socket.h>
03176 #   endif /* ACE_HAS_AIX_BROKEN_SOCKET_HEADER */
03177 
03178 extern "C"
03179 {
03180 #   if defined (VXWORKS)
03181   struct  hostent {
03182     char    *h_name;        /* official name of host */
03183     char    **h_aliases;    /* aliases:  not used on VxWorks */
03184     int     h_addrtype;     /* host address type */
03185     int     h_length;       /* address length */
03186     char    **h_addr_list;  /* (first, only) address from name server */
03187 #     define h_addr h_addr_list[0]   /* the first address */
03188   };
03189 #   elif defined (ACE_HAS_CYGWIN32_SOCKET_H)
03190 #     include /**/ <cygwin32/socket.h>
03191 #   else
03192 #     if defined (ACE_HAS_STL_QUEUE_CONFLICT)
03193 #       define queue _Queue_
03194 #     endif /* ACE_HAS_STL_QUEUE_CONFLICT */
03195 #     include /**/ <netdb.h>
03196 #     if defined (ACE_HAS_STL_QUEUE_CONFLICT)
03197 #       undef queue
03198 #     endif /* ACE_HAS_STL_QUEUE_CONFLICT */
03199 #   endif /* VXWORKS */
03200 
03201 
03202 // This part if to avoid STL name conflict with the map structure
03203 // in net/if.h.
03204 #   if defined (ACE_HAS_STL_MAP_CONFLICT)
03205 #     define map _Resource_Allocation_Map_
03206 #   endif /* ACE_HAS_STL_MAP_CONFLICT */
03207 #   include /**/ <net/if.h>
03208 #   if defined (ACE_HAS_STL_MAP_CONFLICT)
03209 #     undef map
03210 #   endif /* ACE_HAS_STL_MAP_CONFLICT */
03211 
03212 #   if defined (ACE_HAS_STL_QUEUE_CONFLICT)
03213 #     define queue _Queue_
03214 #   endif /* ACE_HAS_STL_QUEUE_CONFLICT */
03215 #   include /**/ <netinet/in.h>
03216 #   if defined (ACE_HAS_STL_QUEUE_CONFLICT)
03217 #     undef queue
03218 #   endif /* ACE_HAS_STL_QUEUE_CONFLICT */
03219 
03220 #   if defined (ACE_VXWORKS) && ACE_VXWORKS <= 0x540
03221       // Work around a lack of ANSI prototypes for these functions on VxWorks.
03222       unsigned long  inet_addr (const char *);
03223       char           *inet_ntoa (const struct in_addr);
03224       struct in_addr inet_makeaddr (const int, const int);
03225       unsigned long  inet_network (const char *);
03226 #   else  /* ! (ACE_VXWORKS) && ACE_VXWORKS <= 0x540 */
03227 #     include /**/ <arpa/inet.h>
03228 #   endif /* ! (ACE_VXWORKS) && ACE_VXWORKS <= 0x540 */
03229 }
03230 #   if !defined (ACE_LACKS_TCP_H)
03231 #     if defined(ACE_HAS_CONFLICTING_XTI_MACROS)
03232 #       if defined(TCP_NODELAY)
03233 #         undef TCP_NODELAY
03234 #       endif
03235 #       if defined(TCP_MAXSEG)
03236 #         undef TCP_MAXSEG
03237 #       endif
03238 #     endif
03239 #     include /**/ <netinet/tcp.h>
03240 #   endif /* ACE_LACKS_TCP_H */
03241 
03242 #   if defined (__Lynx__)
03243 #     ifndef howmany
03244 #       define howmany(x, y)   (((x)+((y)-1))/(y))
03245 #     endif /* howmany */
03246 #   endif /* __Lynx__ */
03247 
03248 #   if defined (CHORUS)
03249 #     include /**/ <chorus.h>
03250 #     if !defined(CHORUS_4)
03251 #       include /**/ <cx/select.h>
03252 #     else
03253 #       include /**/ <stdio.h>
03254 #     endif
03255 #     include /**/ <sys/uio.h>
03256 #     include /**/ <time.h>
03257 #     include /**/ <stdfileio.h>
03258 #     include /**/ <am/afexec.h>
03259 #     include /**/ <sys/types.h>
03260 #     include /**/ <sys/signal.h>
03261 #     include /**/ <sys/wait.h>
03262 #     include /**/ <pwd.h>
03263 #     include /**/ <timer/chBench.h>
03264 extern_C int      getgid          __((void));
03265 extern_C int      getuid          __((void));
03266 extern_C char*    getcwd          __((char* buf, size_t size));
03267 extern_C int      pipe            __((int* fildes));
03268 extern_C int      gethostname     __((char*, size_t));
03269 
03270 // This must come after limits.h is included
03271 #     define MAXPATHLEN _POSIX_PATH_MAX
03272 
03273 #     if  !defined(CHORUS_4)
03274 typedef cx_fd_mask fd_mask;
03275 typedef void (*__sighandler_t)(int); // keep Signal compilation happy
03276 #     endif
03277 #     ifndef howmany
03278 #       define howmany(x, y)   (((x)+((y)-1))/(y))
03279 #     endif /* howmany */
03280 #   elif defined (CYGWIN32)
03281 #     include /**/ <sys/uio.h>
03282 #     include /**/ <sys/file.h>
03283 #     include /**/ <sys/time.h>
03284 #     include /**/ <sys/resource.h>
03285 #     include /**/ <sys/wait.h>
03286 #     include /**/ <pwd.h>
03287 #   elif defined (__QNX__)
03288 #     include /**/ <sys/uio.h>
03289 #     include /**/ <sys/ipc.h>
03290 #     include /**/ <sys/sem.h>
03291 #     include /**/ <sys/time.h>
03292 #     include /**/ <sys/wait.h>
03293 #     include /**/ <sys/resource.h>
03294 #     include /**/ <pwd.h>
03295       // sets O_NDELAY
03296 #     include /**/ <unix.h>
03297 #     include /**/ <sys/param.h> /* for NBBY */
03298       typedef long fd_mask;
03299 #     if !defined (NFDBITS)
03300 #       define NFDBITS (sizeof(fd_mask) * NBBY)        /* bits per mask */
03301 #     endif /* ! NFDBITS */
03302 #     if !defined (howmany)
03303 #       define howmany(x, y)   (((x)+((y)-1))/(y))
03304 #     endif /* ! howmany */
03305 #   elif defined(__rtems__)
03306 #     include /**/ <sys/file.h>
03307 #     include /**/ <sys/resource.h>
03308 #     include /**/ <sys/fcntl.h>
03309 #     include /**/ <sys/time.h>
03310 #     include /**/ <sys/utsname.h>
03311 #     include /**/ <sys/wait.h>
03312 #     include /**/ <pwd.h>
03313 
03314 extern "C"
03315 {
03316   int select (int n, fd_set *readfds, fd_set *writefds,
03317               fd_set *exceptfds, const struct timeval *timeout);
03318 };
03319 #   elif ! defined (VXWORKS)
03320 #     include /**/ <sys/uio.h>
03321 #     include /**/ <sys/ipc.h>
03322 #     if !defined(ACE_LACKS_SYSV_SHMEM)
03323 // No reason to #include this if the platform lacks support for SHMEM
03324 #       include /**/ <sys/shm.h>
03325 #     endif /* ACE_LACKS_SYSV_SHMEM */
03326 #     include /**/ <sys/sem.h>
03327 #     include /**/ <sys/file.h>
03328 #     include /**/ <sys/time.h>
03329 #     include /**/ <sys/resource.h>
03330 #     include /**/ <sys/wait.h>
03331 #     include /**/ <pwd.h>
03332 #   endif /* ! VXWORKS */
03333 #   include /**/ <sys/ioctl.h>
03334 
03335 // IRIX5 defines bzero() in this odd file...
03336 #   if defined (ACE_HAS_BSTRING)
03337 #     include /**/ <bstring.h>
03338 #   endif /* ACE_HAS_BSTRING */
03339 
03340 // AIX defines bzero() in this odd file...
03341 #   if defined (ACE_HAS_STRINGS)
03342 #     include /**/ <strings.h>
03343 #   endif /* ACE_HAS_STRINGS */
03344 
03345 #   if defined (ACE_HAS_TERM_IOCTLS)
03346 #     if defined (__QNX__)
03347 #       include /**/ <termios.h>
03348 #     else  /* ! __QNX__ */
03349 #       include /**/ <sys/termios.h>
03350 #     endif /* ! __QNX__ */
03351 #     if defined (HPUX)
03352 #       include /**/ <sys/modem.h>
03353 #     endif /* HPUX */
03354 #   endif /* ACE_HAS_TERM_IOCTLS */
03355 
03356 #if !defined (VMIN)
03357 #define ACE_VMIN 4
03358 #else
03359 #define ACE_VMIN VMIN
03360 #endif /* VMIN */
03361 
03362 #if !defined (VTIME)
03363 #define ACE_VTIME 5
03364 #else
03365 #define ACE_VTIME VTIME
03366 #endif /* VTIME */
03367 
03368 #   if defined (ACE_HAS_AIO_CALLS)
03369 #     include /**/ <aio.h>
03370 #   endif /* ACE_HAS_AIO_CALLS */
03371 
03372 #   if !defined (ACE_LACKS_PARAM_H)
03373 #     include /**/ <sys/param.h>
03374 #   endif /* ACE_LACKS_PARAM_H */
03375 
03376 // This is here for ACE_OS::num_processors_online(). On HP-UX, it
03377 // needs sys/param.h (above) and sys/pstat.h. The implementation of the
03378 // num_processors_online() method also uses 'defined (__hpux)' to decide
03379 // whether or not to try the syscall.
03380 #   if defined (__hpux)
03381 #     include /**/ <sys/pstat.h>
03382 #   endif /* __hpux **/
03383 
03384 #   if !defined (ACE_LACKS_UNIX_DOMAIN_SOCKETS) && !defined (VXWORKS)
03385 #     include /**/ <sys/un.h>
03386 #   endif /* ACE_LACKS_UNIX_DOMAIN_SOCKETS */
03387 
03388 #   if defined (ACE_HAS_SIGINFO_T)
03389 #     if !defined (ACE_LACKS_SIGINFO_H)
03390 #       if defined (__QNX__) || defined (__OpenBSD__)
03391 #         include /**/ <sys/siginfo.h>
03392 #       elif defined(__rtems__)
03393 #         include /**/ <signal.h>
03394 #       else  /* __QNX__ || __OpenBSD__ */
03395 #         include /**/ <siginfo.h>
03396 #       endif /* __QNX__ || __OpenBSD__ */
03397 #     endif /* ACE_LACKS_SIGINFO_H */
03398 #     if !defined (ACE_LACKS_UCONTEXT_H)
03399 #       include /**/ <ucontext.h>
03400 #     endif /* ACE_LACKS_UCONTEXT_H */
03401 #   endif /* ACE_HAS_SIGINFO_T */
03402 
03403 #   if defined (ACE_HAS_POLL)
03404 #     include /**/ <poll.h>
03405 #   endif /* ACE_HAS_POLL */
03406 
03407 #   if defined (ACE_HAS_STREAMS)
03408 #     if defined (AIX)
03409 #       if !defined (_XOPEN_EXTENDED_SOURCE)
03410 #         define _XOPEN_EXTENDED_SOURCE
03411 #       endif /* !_XOPEN_EXTENDED_SOURCE */
03412 #       include /**/ <stropts.h>
03413 #       undef _XOPEN_EXTENDED_SOURCE
03414 #     else
03415 #       include /**/ <stropts.h>
03416 #     endif /* AIX */
03417 #   endif /* ACE_HAS_STREAMS */
03418 
03419 #   if defined (DIGITAL_UNIX)
03420   // sigwait is yet another macro on Digital UNIX 4.0, just causing
03421   // trouble when introducing member functions with the same name.
03422   // Thanks to Thilo Kielmann" <kielmann@informatik.uni-siegen.de> for
03423   // this fix.
03424 #     if defined  (__DECCXX_VER)
03425 #       undef sigwait
03426         // cxx on Digital Unix 4.0 needs this declaration.  With it,
03427         // <::_Psigwait> works with cxx -pthread.  g++ does _not_ need
03428         // it.
03429         extern "C" int _Psigwait __((const sigset_t *set, int *sig));
03430 #     elif defined (__KCC)
03431 #       undef sigwait
03432         inline int sigwait (const sigset_t* set, int* sig)
03433           { return _Psigwait (set, sig); }
03434 #     endif /* __DECCXX_VER */
03435 #   elif !defined (ACE_HAS_SIGWAIT)
03436 #      if defined(__rtems__)
03437   extern "C" int sigwait (const sigset_t *set, int *sig);
03438 #      else
03439    extern "C" int sigwait (sigset_t *set);
03440 #      endif /* __rtems__ */
03441 #   endif /* ! DIGITAL_UNIX && ! ACE_HAS_SIGWAIT */
03442 
03443 #   if defined (ACE_HAS_SELECT_H)
03444 #     include /**/ <sys/select.h>
03445 #   endif /* ACE_HAS_SELECT_H */
03446 
03447 #   if defined (ACE_HAS_ALLOCA_H)
03448 #     include /**/ <alloca.h>
03449 #   endif /* ACE_HAS_ALLOCA_H */
03450 
03451 /* Set the proper handle type for dynamically-loaded libraries. */
03452 /* Also define a default 'mode' for loading a library - the names and values */
03453 /* differ between OSes, so if you write code that uses the mode, be careful */
03454 /* of the platform differences. */
03455 #   if defined (ACE_HAS_SVR4_DYNAMIC_LINKING)
03456 #    if defined (ACE_HAS_DLFCN_H_BROKEN_EXTERN_C)
03457 extern "C" {
03458 #     endif /* ACE_HAS_DLFCN_H_BROKEN_EXTERN_C */
03459 #     include /**/ <dlfcn.h>
03460 #     if defined (ACE_HAS_DLFCN_H_BROKEN_EXTERN_C)
03461 }
03462 #     endif /* ACE_HAS_DLFCN_H_BROKEN_EXTERN_C */
03463   typedef void *ACE_SHLIB_HANDLE;
03464 #   define ACE_SHLIB_INVALID_HANDLE 0
03465 #   if defined (__KCC) && defined(RTLD_GROUP) && defined(RTLD_NODELETE)
03466 #   define ACE_DEFAULT_SHLIB_MODE RTLD_LAZY | RTLD_GROUP | RTLD_NODELETE
03467 #   else
03468 #   define ACE_DEFAULT_SHLIB_MODE RTLD_LAZY
03469 #   endif /* KCC */
03470 #   elif defined (__hpux)
03471 #     if defined(__GNUC__) || __cplusplus >= 199707L
03472 #       include /**/ <dl.h>
03473 #     else
03474 #       include /**/ <cxxdl.h>
03475 #     endif /* (g++ || HP aC++) vs. HP C++ */
03476   typedef shl_t ACE_SHLIB_HANDLE;
03477 #   define ACE_SHLIB_INVALID_HANDLE 0
03478 #   define ACE_DEFAULT_SHLIB_MODE BIND_DEFERRED
03479 #   else
03480   typedef void *ACE_SHLIB_HANDLE;
03481 #   define ACE_SHLIB_INVALID_HANDLE 0
03482 #   define ACE_DEFAULT_SHLIB_MODE RTLD_LAZY
03483 
03484 #   endif /* ACE_HAS_SVR4_DYNAMIC_LINKING */
03485 
03486 #if !defined (RTLD_LAZY)
03487 #define RTLD_LAZY 1
03488 #endif /* !RTLD_LAZY */
03489 
03490 #if !defined (RTLD_NOW)
03491 #define RTLD_NOW 2
03492 #endif /* !RTLD_NOW */
03493 
03494 #if !defined (RTLD_GLOBAL)
03495 #define RTLD_GLOBAL 3
03496 #endif /* !RTLD_GLOBAL */
03497 
03498 #   if defined (ACE_HAS_SOCKIO_H)
03499 #     include /**/ <sys/sockio.h>
03500 #   endif /* ACE_HAS_SOCKIO_ */
03501 
03502 // There must be a better way to do this...
03503 #   if !defined (RLIMIT_NOFILE)
03504 #     if defined (linux) || defined (AIX) || defined (SCO)
03505 #       if defined (RLIMIT_OFILE)
03506 #         define RLIMIT_NOFILE RLIMIT_OFILE
03507 #       else
03508 #         define RLIMIT_NOFILE 200
03509 #       endif /* RLIMIT_OFILE */
03510 #     endif /* defined (linux) || defined (AIX) || defined (SCO) */
03511 #   endif /* RLIMIT_NOFILE */
03512 
03513 #   if defined (ACE_LACKS_MMAP)
03514 #     define PROT_READ 0
03515 #     define PROT_WRITE 0
03516 #     define PROT_EXEC 0
03517 #     define PROT_NONE 0
03518 #     define PROT_RDWR 0
03519 #     define MAP_PRIVATE 0
03520 #     define MAP_SHARED 0
03521 #     define MAP_FIXED 0
03522 #   endif /* ACE_LACKS_MMAP */
03523 
03524 // Fixes a problem with HP/UX.
03525 #   if defined (ACE_HAS_BROKEN_MMAP_H)
03526 extern "C"
03527 {
03528 #     include /**/ <sys/mman.h>
03529 }
03530 #   elif !defined (ACE_LACKS_MMAP)
03531 #     include /**/ <sys/mman.h>
03532 #   endif /* ACE_HAS_BROKEN_MMAP_H */
03533 
03534 // OSF1 has problems with sys/msg.h and C++...
03535 #   if defined (ACE_HAS_BROKEN_MSG_H)
03536 #     define _KERNEL
03537 #   endif /* ACE_HAS_BROKEN_MSG_H */
03538 #   if !defined (ACE_LACKS_SYSV_MSG_H)
03539 #     include /**/ <sys/msg.h>
03540 #   endif /* ACE_LACKS_SYSV_MSG_H */
03541 #   if defined (ACE_HAS_BROKEN_MSG_H)
03542 #     undef _KERNEL
03543 #   endif /* ACE_HAS_BROKEN_MSG_H */
03544 
03545 #   if defined (ACE_LACKS_SYSV_MSQ_PROTOS)
03546 extern "C"
03547 {
03548   int msgget (key_t, int);
03549   int msgrcv (int, void *, size_t, long, int);
03550   int msgsnd (int, const void *, size_t, int);
03551   int msgctl (int, int, struct msqid_ds *);
03552 }
03553 #   endif /* ACE_LACKS_SYSV_MSQ_PROTOS */
03554 
03555 #   if defined (ACE_HAS_PRIOCNTL)
03556 #     include /**/ <sys/priocntl.h>
03557 #   endif /* ACE_HAS_PRIOCNTL */
03558 
03559 #   if defined (ACE_HAS_IDTYPE_T)
03560   typedef idtype_t ACE_idtype_t;
03561 #   else
03562   typedef int ACE_idtype_t;
03563 #   endif /* ACE_HAS_IDTYPE_T */
03564 
03565 #   if defined (ACE_HAS_STHREADS) || defined (DIGITAL_UNIX)
03566 #     if defined (ACE_LACKS_PRI_T)
03567     typedef int pri_t;
03568 #     endif /* ACE_LACKS_PRI_T */
03569   typedef id_t ACE_id_t;
03570 #     define ACE_SELF P_MYID
03571   typedef pri_t ACE_pri_t;
03572 #   else  /* ! ACE_HAS_STHREADS && ! DIGITAL_UNIX */
03573   typedef long ACE_id_t;
03574 #     define ACE_SELF (-1)
03575   typedef short ACE_pri_t;
03576 #   endif /* ! ACE_HAS_STHREADS && ! DIGITAL_UNIX */
03577 
03578 #   if defined (ACE_HAS_HI_RES_TIMER) &&  !defined (ACE_LACKS_LONGLONG_T)
03579   /* hrtime_t is defined on systems (Suns) with ACE_HAS_HI_RES_TIMER */
03580   typedef hrtime_t ACE_hrtime_t;
03581 #   else  /* ! ACE_HAS_HI_RES_TIMER  ||  ACE_LACKS_LONGLONG_T */
03582   typedef ACE_UINT64 ACE_hrtime_t;
03583 #   endif /* ! ACE_HAS_HI_RES_TIMER  ||  ACE_LACKS_LONGLONG_T */
03584 
03585 # endif /* !defined (ACE_WIN32) && !defined (ACE_PSOS) */
03586 
03587 // Define the Wide character and normal versions of some of the string macros
03588 #   if defined (ACE_HAS_WCHAR)
03589 #     define ACE_DIRECTORY_SEPARATOR_STR_W ACE_TEXT_WIDE(ACE_DIRECTORY_SEPARATOR_STR_A)
03590 #     define ACE_DIRECTORY_SEPARATOR_CHAR_W ACE_TEXT_WIDE(ACE_DIRECTORY_SEPARATOR_CHAR_A)
03591 #     define ACE_PLATFORM_W ACE_TEXT_WIDE(ACE_PLATFORM_A)
03592 #     define ACE_PLATFORM_EXE_SUFFIX_W ACE_TEXT_WIDE(ACE_PLATFORM_EXE_SUFFIX_A)
03593 #   endif /* ACE_HAS_WCHAR */
03594 
03595 #   define ACE_DIRECTORY_SEPARATOR_STR ACE_LIB_TEXT (ACE_DIRECTORY_SEPARATOR_STR_A)
03596 #   define ACE_DIRECTORY_SEPARATOR_CHAR ACE_LIB_TEXT (ACE_DIRECTORY_SEPARATOR_CHAR_A)
03597 #   define ACE_PLATFORM ACE_LIB_TEXT (ACE_PLATFORM_A)
03598 #   define ACE_PLATFORM_EXE_SUFFIX ACE_LIB_TEXT (ACE_PLATFORM_EXE_SUFFIX_A)
03599 
03600 // Theses defines are used by the ACE Name Server.
03601 #   if !defined (ACE_DEFAULT_LOCALNAME_A)
03602 #     define ACE_DEFAULT_LOCALNAME_A "localnames"
03603 #   endif /* ACE_DEFAULT_LOCALNAME_A */
03604 #   if !defined (ACE_DEFAULT_GLOBALNAME_A)
03605 #     define ACE_DEFAULT_GLOBALNAME_A "globalnames"
03606 #   endif /* ACE_DEFAULT_GLOBALNAME_A */
03607 
03608 // ACE_DEFAULT_NAMESPACE_DIR is for legacy mode apps.  A better
03609 // way of doing this is something like ACE_Lib_Find::get_temp_dir, since
03610 // this directory may not exist
03611 #   if defined (ACE_LEGACY_MODE)
03612 #     if defined (ACE_WIN32)
03613 #       define ACE_DEFAULT_NAMESPACE_DIR_A "C:\\temp"
03614 #     else /* ACE_WIN32 */
03615 #       define ACE_DEFAULT_NAMESPACE_DIR_A "/tmp"
03616 #     endif /* ACE_WIN32 */
03617 #     if defined (ACE_HAS_WCHAR)
03618 #       define ACE_DEFAULT_NAMESPACE_DIR_W ACE_TEXT_WIDE(ACE_DEFAULT_NAMESPACE_DIR_A)
03619 #     endif /* ACE_HAS_WCHAR */
03620 #     define ACE_DEFAULT_NAMESPACE_DIR ACE_LIB_TEXT(ACE_DEFAULT_NAMESPACE_DIR_A)
03621 #   endif /* ACE_LEGACY_MODE */
03622 
03623 #   if defined (ACE_HAS_WCHAR)
03624 #     define ACE_DEFAULT_LOCALNAME_W ACE_TEXT_WIDE(ACE_DEFAULT_LOCALNAME_A)
03625 #     define ACE_DEFAULT_GLOBALNAME_W ACE_TEXT_WIDE(ACE_DEFAULT_GLOBALNAME_A)
03626 #   endif /* ACE_HAS_WCHAR */
03627 
03628 #   define ACE_DEFAULT_LOCALNAME ACE_LIB_TEXT (ACE_DEFAULT_LOCALNAME_A)
03629 #   define ACE_DEFAULT_GLOBALNAME ACE_LIB_TEXT (ACE_DEFAULT_GLOBALNAME_A)
03630 
03631 // defined Win32 specific macros for UNIX platforms
03632 # if !defined (O_BINARY)
03633 #   define O_BINARY 0
03634 # endif /* O_BINARY */
03635 # if !defined (_O_BINARY)
03636 #   define _O_BINARY O_BINARY
03637 # endif /* _O_BINARY */
03638 # if !defined (O_TEXT)
03639 #   define O_TEXT 0
03640 # endif /* O_TEXT */
03641 # if !defined (_O_TEXT)
03642 #   define _O_TEXT O_TEXT
03643 # endif /* _O_TEXT */
03644 # if !defined (O_RAW)
03645 #   define O_RAW 0
03646 # endif /* O_RAW */
03647 # if !defined (_O_RAW)
03648 #   define _O_RAW O_RAW
03649 # endif /* _O_RAW */
03650 
03651 # if !defined (ACE_DEFAULT_SYNCH_TYPE)
03652 #   define ACE_DEFAULT_SYNCH_TYPE USYNC_THREAD
03653 # endif /* ! ACE_DEFAULT_SYNCH_TYPE */
03654 
03655 # if !defined (ACE_MAP_PRIVATE)
03656 #   define ACE_MAP_PRIVATE MAP_PRIVATE
03657 # endif /* ! ACE_MAP_PRIVATE */
03658 
03659 # if !defined (ACE_MAP_SHARED)
03660 #   define ACE_MAP_SHARED MAP_SHARED
03661 # endif /* ! ACE_MAP_SHARED */
03662 
03663 # if !defined (ACE_MAP_FIXED)
03664 #   define ACE_MAP_FIXED MAP_FIXED
03665 # endif /* ! ACE_MAP_FIXED */
03666 
03667 #if defined (ACE_LACKS_UTSNAME_T)
03668 #   if !defined (SYS_NMLN)
03669 #     define SYS_NMLN 257
03670 #   endif /* SYS_NMLN */
03671 #   if !defined (_SYS_NMLN)
03672 #     define _SYS_NMLN SYS_NMLN
03673 #   endif /* _SYS_NMLN */
03674 struct ACE_utsname
03675 {
03676   ACE_TCHAR sysname[_SYS_NMLN];
03677   ACE_TCHAR nodename[_SYS_NMLN];
03678   ACE_TCHAR release[_SYS_NMLN];
03679   ACE_TCHAR version[_SYS_NMLN];
03680   ACE_TCHAR machine[_SYS_NMLN];
03681 };
03682 # else
03683 #   include /**/ <sys/utsname.h>
03684 typedef struct utsname ACE_utsname;
03685 # endif /* ACE_LACKS_UTSNAME_T */
03686 
03687 // Increase the range of "address families".  Please note that this
03688 // must appear _after_ the include of sys/socket.h, for the AF_FILE
03689 // definition on Linux/glibc2.
03690 #if !defined (AF_ANY)
03691 # define AF_ANY (-1)
03692 #endif /* AF_ANY */
03693 
03694 # define AF_SPIPE (AF_MAX + 1)
03695 # if !defined (AF_FILE)
03696 #   define AF_FILE (AF_MAX + 2)
03697 # endif /* ! AF_FILE */
03698 # define AF_DEV (AF_MAX + 3)
03699 # define AF_UPIPE (AF_SPIPE)
03700 
03701 # if defined (ACE_SELECT_USES_INT)
03702 typedef int ACE_FD_SET_TYPE;
03703 # else
03704 typedef fd_set ACE_FD_SET_TYPE;
03705 # endif /* ACE_SELECT_USES_INT */
03706 
03707 # if !defined (MAXNAMELEN)
03708 #   if defined (FILENAME_MAX)
03709 #     define MAXNAMELEN FILENAME_MAX
03710 #   else
03711 #     define MAXNAMELEN 256
03712 #   endif /* FILENAME_MAX */
03713 # endif /* MAXNAMELEN */
03714 
03715 # if !defined(MAXHOSTNAMELEN)
03716 #   define MAXHOSTNAMELEN  256
03717 # endif /* MAXHOSTNAMELEN */
03718 
03719 // Define INET loopback address constant if it hasn't been defined
03720 // Dotted Decimal 127.0.0.1 == Hexidecimal 0x7f000001
03721 # if !defined (INADDR_LOOPBACK)
03722 #   define INADDR_LOOPBACK ((ACE_UINT32) 0x7f000001)
03723 # endif /* INADDR_LOOPBACK */
03724 
03725 // The INADDR_NONE address is generally 255.255.255.255.
03726 # if !defined (INADDR_NONE)
03727 #   define INADDR_NONE ((ACE_UINT32) 0xffffffff)
03728 # endif /* INADDR_NONE */
03729 
03730 // Define INET string length constants if they haven't been defined
03731 //
03732 // for IPv4 dotted-decimal
03733 # if !defined (INET_ADDRSTRLEN)
03734 #   define INET_ADDRSTRLEN 16
03735 # endif /* INET_ADDRSTRLEN */
03736 //
03737 // for IPv6 hex string
03738 # if !defined (INET6_ADDRSTRLEN)
03739 #   define INET6_ADDRSTRLEN 46
03740 # endif /* INET6_ADDRSTRLEN */
03741 
03742 #if defined (ACE_HAS_IPV6)
03743 
03744 #  if defined (ACE_USES_IPV4_IPV6_MIGRATION)
03745 #    define ACE_ADDRESS_FAMILY_INET  AF_UNSPEC
03746 #    define ACE_PROTOCOL_FAMILY_INET PF_UNSPEC
03747 #  else
03748 #    define ACE_ADDRESS_FAMILY_INET AF_INET6
03749 #    define ACE_PROTOCOL_FAMILY_INET PF_INET6
03750 #  endif /* ACE_USES_IPV4_IPV6_MIGRATION */
03751 
03752 #else
03753 #  define ACE_ADDRESS_FAMILY_INET AF_INET
03754 #  define ACE_PROTOCOL_FAMILY_INET PF_INET
03755 #endif
03756 
03757 # if defined (ACE_LACKS_SIGSET)
03758 #    if !defined(__MINGW32__)
03759 typedef u_int sigset_t;
03760 #    endif /* !__MINGW32__*/
03761 # endif /* ACE_LACKS_SIGSET */
03762 
03763 # if defined (ACE_LACKS_SIGACTION)
03764 struct sigaction
03765 {
03766   int sa_flags;
03767   ACE_SignalHandlerV sa_handler;
03768   sigset_t sa_mask;
03769 };
03770 # endif /* ACE_LACKS_SIGACTION */
03771 
03772 # if !defined (SIGHUP)
03773 #   define SIGHUP 0
03774 # endif /* SIGHUP */
03775 
03776 # if !defined (SIGINT)
03777 #   define SIGINT 0
03778 # endif /* SIGINT */
03779 
03780 # if !defined (SIGSEGV)
03781 #   define SIGSEGV 0
03782 # endif /* SIGSEGV */
03783 
03784 # if !defined (SIGIO)
03785 #   define SIGIO 0
03786 # endif /* SIGSEGV */
03787 
03788 # if !defined (SIGUSR1)
03789 #   define SIGUSR1 0
03790 # endif /* SIGUSR1 */
03791 
03792 # if !defined (SIGUSR2)
03793 #   define SIGUSR2 0
03794 # endif /* SIGUSR2 */
03795 
03796 # if !defined (SIGCHLD)
03797 #   define SIGCHLD 0
03798 # endif /* SIGCHLD */
03799 
03800 # if !defined (SIGCLD)
03801 #   define SIGCLD SIGCHLD
03802 # endif /* SIGCLD */
03803 
03804 # if !defined (SIGQUIT)
03805 #   define SIGQUIT 0
03806 # endif /* SIGQUIT */
03807 
03808 # if !defined (SIGPIPE)
03809 #   define SIGPIPE 0
03810 # endif /* SIGPIPE */
03811 
03812 # if !defined (SIGALRM)
03813 #   define SIGALRM 0
03814 # endif /* SIGALRM */
03815 
03816 # if !defined (SIG_DFL)
03817 #   if defined (ACE_PSOS_DIAB_MIPS) || defined (ACE_PSOS_DIAB_PPC)
03818 #     define SIG_DFL ((void *) 0)
03819 #   else
03820 #     define SIG_DFL ((__sighandler_t) 0)
03821 #   endif
03822 # endif /* SIG_DFL */
03823 
03824 # if !defined (SIG_IGN)
03825 #   if defined (ACE_PSOS_DIAB_MIPS) || defined (ACE_PSOS_DIAB_PPC)
03826 #     define SIG_IGN ((void *) 1)     /* ignore signal */
03827 #   else
03828 #     define SIG_IGN ((__sighandler_t) 1)     /* ignore signal */
03829 #   endif
03830 # endif /* SIG_IGN */
03831 
03832 # if !defined (SIG_ERR)
03833 #   if defined (ACE_PSOS_DIAB_MIPS) || defined (ACE_PSOS_DIAB_PPC)
03834 #     define SIG_ERR ((void *) -1)    /* error return from signal */
03835 #   else
03836 #     define SIG_ERR ((__sighandler_t) -1)    /* error return from signal */
03837 #   endif
03838 # endif /* SIG_ERR */
03839 
03840 # if !defined (O_NONBLOCK)
03841 #   define O_NONBLOCK  1
03842 # endif /* O_NONBLOCK  */
03843 
03844 # if !defined (SIG_BLOCK)
03845 #   define SIG_BLOCK   1
03846 # endif /* SIG_BLOCK   */
03847 
03848 # if !defined (SIG_UNBLOCK)
03849 #   define SIG_UNBLOCK 2
03850 # endif /* SIG_UNBLOCK */
03851 
03852 # if !defined (SIG_SETMASK)
03853 #   define SIG_SETMASK 3
03854 # endif /* SIG_SETMASK */
03855 
03856 # if !defined (IPC_CREAT)
03857 #   define IPC_CREAT 0
03858 # endif /* IPC_CREAT */
03859 
03860 # if !defined (IPC_NOWAIT)
03861 #   define IPC_NOWAIT 0
03862 # endif /* IPC_NOWAIT */
03863 
03864 # if !defined (IPC_RMID)
03865 #   define IPC_RMID 0
03866 # endif /* IPC_RMID */
03867 
03868 # if !defined (IPC_EXCL)
03869 #   define IPC_EXCL 0
03870 # endif /* IPC_EXCL */
03871 
03872 # if !defined (IP_DROP_MEMBERSHIP)
03873 #   define IP_DROP_MEMBERSHIP 0
03874 # endif /* IP_DROP_MEMBERSHIP */
03875 
03876 # if !defined (IP_ADD_MEMBERSHIP)
03877 #   define IP_ADD_MEMBERSHIP 0
03878 #   define ACE_LACKS_IP_ADD_MEMBERSHIP
03879 # endif /* IP_ADD_MEMBERSHIP */
03880 
03881 # if !defined (IP_DEFAULT_MULTICAST_TTL)
03882 #   define IP_DEFAULT_MULTICAST_TTL 0
03883 # endif /* IP_DEFAULT_MULTICAST_TTL */
03884 
03885 # if !defined (IP_DEFAULT_MULTICAST_LOOP)
03886 #   define IP_DEFAULT_MULTICAST_LOOP 0
03887 # endif /* IP_DEFAULT_MULTICAST_LOOP */
03888 
03889 # if !defined (IP_MULTICAST_IF)
03890 #   define IP_MULTICAST_IF 0
03891 #endif /* IP_MULTICAST_IF */
03892 
03893 # if !defined (IP_MULTICAST_TTL)
03894 #   define IP_MULTICAST_TTL 1
03895 #endif /* IP_MULTICAST_TTL */
03896 
03897 # if !defined (IP_MAX_MEMBERSHIPS)
03898 #   define IP_MAX_MEMBERSHIPS 0
03899 # endif /* IP_MAX_MEMBERSHIP */
03900 
03901 # if !defined (SIOCGIFBRDADDR)
03902 #   define SIOCGIFBRDADDR 0
03903 # endif /* SIOCGIFBRDADDR */
03904 
03905 # if !defined (SIOCGIFADDR)
03906 #   define SIOCGIFADDR 0
03907 # endif /* SIOCGIFADDR */
03908 
03909 # if !defined (IPC_PRIVATE)
03910 #   define IPC_PRIVATE ACE_INVALID_SEM_KEY
03911 # endif /* IPC_PRIVATE */
03912 
03913 # if !defined (IPC_STAT)
03914 #   define IPC_STAT 0
03915 # endif /* IPC_STAT */
03916 
03917 # if !defined (GETVAL)
03918 #   define GETVAL 0
03919 # endif /* GETVAL */
03920 
03921 # if !defined (F_GETFL)
03922 #   define F_GETFL 0
03923 # endif /* F_GETFL */
03924 
03925 # if !defined (SETVAL)
03926 #   define SETVAL 0
03927 # endif /* SETVAL */
03928 
03929 # if !defined (GETALL)
03930 #   define GETALL 0
03931 # endif /* GETALL */
03932 
03933 # if !defined (SETALL)
03934 #   define SETALL 0
03935 # endif /* SETALL */
03936 
03937 # if !defined (SEM_UNDO)
03938 #   define SEM_UNDO 0
03939 # endif /* SEM_UNDO */
03940 
03941 # if defined (__Lynx__)
03942     // LynxOS Neutrino sets NSIG to the highest-numbered signal.
03943 #   define ACE_NSIG (NSIG + 1)
03944 # elif defined (__rtems__)
03945 #   define ACE_NSIG (SIGRTMAX)
03946 # else
03947   // All other platforms set NSIG to one greater than the
03948   // highest-numbered signal.
03949 #   define ACE_NSIG NSIG
03950 # endif /* __Lynx__ */
03951 
03952 # if !defined (R_OK)
03953 #   define R_OK    04      /* Test for Read permission. */
03954 # endif /* R_OK */
03955 
03956 # if !defined (W_OK)
03957 #   define W_OK    02      /* Test for Write permission. */
03958 # endif /* W_OK */
03959 
03960 # if !defined (X_OK)
03961 #   define X_OK    01      /* Test for eXecute permission. */
03962 # endif /* X_OK */
03963 
03964 # if !defined (F_OK)
03965 #   define F_OK    0       /* Test for existence of File. */
03966 # endif /* F_OK */
03967 
03968 # if !defined (ESUCCESS)
03969 #   define ESUCCESS 0
03970 # endif /* !ESUCCESS */
03971 
03972 # if !defined (EIDRM)
03973 #   define EIDRM 0
03974 # endif /* !EIDRM */
03975 
03976 # if !defined (ENFILE)
03977 #   define ENFILE EMFILE /* No more socket descriptors are available. */
03978 # endif /* !ENFILE */
03979 
03980 # if !defined (ECOMM)
03981     // Not the same, but ECONNABORTED is provided on NT.
03982 #   define ECOMM ECONNABORTED
03983 # endif /* ECOMM */
03984 
03985 # if !defined (WNOHANG)
03986 #   define WNOHANG 0100
03987 # endif /* !WNOHANG */
03988 
03989 # if !defined (EDEADLK)
03990 #   define EDEADLK 1000 /* Some large number.... */
03991 # endif /* !EDEADLK */
03992 
03993 #if !defined (ENXIO)     /* Needed in SOCK_Dgram_Mcast */
03994 #   define ENXIO  6
03995 #endif /* ENXIO */
03996 
03997 # if !defined (MS_SYNC)
03998 #   define MS_SYNC 0x0
03999 # endif /* !MS_SYNC */
04000 
04001 # if !defined (PIPE_BUF)
04002 #   define PIPE_BUF 5120
04003 # endif /* PIPE_BUF */
04004 
04005 # if !defined (PROT_RDWR)
04006 #   define PROT_RDWR (PROT_READ|PROT_WRITE)
04007 # endif /* PROT_RDWR */
04008 
04009 # if defined (ACE_HAS_POSIX_NONBLOCK)
04010 #   define ACE_NONBLOCK O_NONBLOCK
04011 # else
04012 #   define ACE_NONBLOCK O_NDELAY
04013 # endif /* ACE_HAS_POSIX_NONBLOCK */
04014 
04015 // These are used by the <ACE_IPC_SAP::enable> and
04016 // <ACE_IPC_SAP::disable> methods.  They must be unique and cannot
04017 // conflict with the value of <ACE_NONBLOCK>.  We make the numbers
04018 // negative here so they won't conflict with other values like SIGIO,
04019 // etc.
04020 # define ACE_SIGIO -1
04021 # define ACE_SIGURG -2
04022 # define ACE_CLOEXEC -3
04023 
04024 # define LOCALNAME 0
04025 # define REMOTENAME 1
04026 
04027 # if !defined (ETIMEDOUT) && defined (ETIME)
04028 #   define ETIMEDOUT ETIME
04029 # endif /* ETIMEDOUT */
04030 
04031 # if !defined (ETIME) && defined (ETIMEDOUT)
04032 #   define ETIME ETIMEDOUT
04033 # endif /* ETIMED */
04034 
04035 # if !defined (EBUSY)
04036 #   define EBUSY ETIME
04037 # endif /* EBUSY */
04038 
04039 # if !defined (_SC_TIMER_MAX)
04040 #   define _SC_TIMER_MAX 44
04041 # endif /* _SC_TIMER_MAX */
04042 
04043 // Default number of <ACE_Event_Handler>s supported by
04044 // <ACE_Timer_Heap>.
04045 # if !defined (ACE_DEFAULT_TIMERS)
04046 #   define ACE_DEFAULT_TIMERS _SC_TIMER_MAX
04047 # endif /* ACE_DEFAULT_TIMERS */
04048 
04049 # if defined (ACE_HAS_STRUCT_NETDB_DATA)
04050 typedef char ACE_HOSTENT_DATA[sizeof(struct hostent_data)];
04051 typedef char ACE_SERVENT_DATA[sizeof(struct servent_data)];
04052 typedef char ACE_PROTOENT_DATA[sizeof(struct protoent_data)];
04053 # else
04054 #   if !defined ACE_HOSTENT_DATA_SIZE
04055 #     define ACE_HOSTENT_DATA_SIZE (4*1024)
04056 #   endif /*ACE_HOSTENT_DATA_SIZE */
04057 #   if !defined ACE_SERVENT_DATA_SIZE
04058 #     define ACE_SERVENT_DATA_SIZE (4*1024)
04059 #   endif /*ACE_SERVENT_DATA_SIZE */
04060 #   if !defined ACE_PROTOENT_DATA_SIZE
04061 #     define ACE_PROTOENT_DATA_SIZE (2*1024)
04062 #   endif /*ACE_PROTOENT_DATA_SIZE */
04063 typedef char ACE_HOSTENT_DATA[ACE_HOSTENT_DATA_SIZE];
04064 typedef char ACE_SERVENT_DATA[ACE_SERVENT_DATA_SIZE];
04065 typedef char ACE_PROTOENT_DATA[ACE_PROTOENT_DATA_SIZE];
04066 # endif /* ACE_HAS_STRUCT_NETDB_DATA */
04067 
04068 # if !defined (ACE_HAS_SEMUN) || (defined (__GLIBC__) && defined (_SEM_SEMUN_UNDEFINED))
04069 union semun
04070 {
04071   /// value for SETVAL
04072   int val;
04073   /// buffer for IPC_STAT & IPC_SET
04074   struct semid_ds *buf;
04075   /// array for GETALL & SETALL
04076   u_short *array;
04077 };
04078 # endif /* !ACE_HAS_SEMUN || (defined (__GLIBC__) && defined (_SEM_SEMUN_UNDEFINED)) */
04079 
04080 
04081 // Create some useful typedefs.
04082 
04083 typedef const char **SYS_SIGLIST;
04084 
04085 # if !defined (MAP_FAILED) || defined (ACE_HAS_BROKEN_MAP_FAILED)
04086 #   undef MAP_FAILED
04087 #   define MAP_FAILED ((void *) -1)
04088 # elif defined (ACE_HAS_LONG_MAP_FAILED)
04089 #   undef MAP_FAILED
04090 #   define MAP_FAILED ((void *) -1L)
04091 # endif /* !MAP_FAILED || ACE_HAS_BROKEN_MAP_FAILED */
04092 
04093 # if defined (ACE_HAS_CHARPTR_DL)
04094 typedef ACE_TCHAR * ACE_DL_TYPE;
04095 # else
04096 typedef const ACE_TCHAR * ACE_DL_TYPE;
04097 # endif /* ACE_HAS_CHARPTR_DL */
04098 
04099 # if !defined (ACE_HAS_SIGINFO_T)
04100 struct ACE_OS_Export siginfo_t
04101 {
04102   siginfo_t (ACE_HANDLE handle);
04103   siginfo_t (ACE_HANDLE *handles);      // JCEJ 12/23/96
04104 
04105   /// Win32 HANDLE that has become signaled.
04106   ACE_HANDLE si_handle_;
04107 
04108   /// Array of Win32 HANDLEs all of which have become signaled.
04109   ACE_HANDLE *si_handles_;
04110 };
04111 # endif /* ACE_HAS_SIGINFO_T */
04112 
04113 // Typedef for the null handler func.
04114 extern "C"
04115 {
04116   typedef void (*ACE_SIGNAL_C_FUNC)(int,siginfo_t*,void*);
04117 }
04118 
04119 # if !defined (ACE_HAS_UCONTEXT_T)
04120 typedef int ucontext_t;
04121 # endif /* ACE_HAS_UCONTEXT_T */
04122 
04123 # if !defined (SA_SIGINFO)
04124 #   define SA_SIGINFO 0
04125 # endif /* SA_SIGINFO */
04126 
04127 # if !defined (SA_RESTART)
04128 #   define SA_RESTART 0
04129 # endif /* SA_RESTART */
04130 
04131 # if defined (ACE_HAS_TIMOD_H)
04132 #   if defined (ACE_HAS_STL_QUEUE_CONFLICT)
04133 #     define queue _Queue_
04134 #   endif /* ACE_HAS_STL_QUEUE_CONFLICT */
04135 #   include /**/ <sys/timod.h>
04136 #   if defined (ACE_HAS_STL_QUEUE_CONFLICT)
04137 #     undef queue
04138 #   endif /* ACE_HAS_STL_QUEUE_CONFLICT */
04139 # elif defined (ACE_HAS_OSF_TIMOD_H)
04140 #   include /**/ <tli/timod.h>
04141 # endif /* ACE_HAS_TIMOD_H */
04142 
04143 /**
04144  * @class ACE_Thread_ID
04145  *
04146  * @brief Defines a platform-independent thread ID.
04147  */
04148 class ACE_OS_Export ACE_Thread_ID
04149 {
04150 public:
04151   // = Initialization method.
04152   ACE_Thread_ID (ACE_thread_t, ACE_hthread_t);
04153   ACE_Thread_ID (const ACE_Thread_ID &id);
04154 
04155   // = Set/Get the Thread ID.
04156   ACE_thread_t id (void);
04157   void id (ACE_thread_t);
04158 
04159   // = Set/Get the Thread handle.
04160   ACE_hthread_t handle (void);
04161   void handle (ACE_hthread_t);
04162 
04163   // != Comparison operator.
04164   int operator== (const ACE_Thread_ID &) const;
04165   int operator!= (const ACE_Thread_ID &) const;
04166 
04167 private:
04168   /// Identify the thread.
04169   ACE_thread_t thread_id_;
04170 
04171   /// Handle to the thread (typically used to "wait" on Win32).
04172   ACE_hthread_t thread_handle_;
04173 };
04174 
04175 // Type of the extended signal handler.
04176 typedef void (*ACE_Sig_Handler_Ex) (int, siginfo_t *siginfo, ucontext_t *ucontext);
04177 
04178 // = The ACE_Sched_Priority type should be used for platform-
04179 //   independent thread and process priorities, by convention.
04180 //   int should be used for OS-specific priorities.
04181 typedef int ACE_Sched_Priority;
04182 
04183 // forward declaration
04184 class ACE_Sched_Params;
04185 
04186 # if defined (ACE_LACKS_FILELOCKS)
04187 #   if ! defined (VXWORKS) && ! defined (ACE_PSOS) && ! defined (__rtems__)
04188 // VxWorks defines struct flock in sys/fcntlcom.h.  But it doesn't
04189 // appear to support flock ().  RTEMS defines struct flock but
04190 // currently does not support locking.
04191 struct flock
04192 {
04193   short l_type;
04194   short l_whence;
04195   off_t l_start;
04196   off_t l_len;          /* len == 0 means until end of file */
04197   long  l_sysid;
04198   pid_t l_pid;
04199   long  l_pad[4];               /* reserve area */
04200 };
04201 #   endif /* ! VXWORKS */
04202 # endif /* ACE_LACKS_FILELOCKS */
04203 
04204 # if !defined (ACE_HAS_IP_MULTICAST)  &&  defined (ACE_LACKS_IP_ADD_MEMBERSHIP)
04205   // Even if ACE_HAS_IP_MULTICAST is not defined, if IP_ADD_MEMBERSHIP
04206   // is defined, assume that the ip_mreq struct is also defined
04207   // (presumably in netinet/in.h).
04208   struct ip_mreq
04209   {
04210     /// IP multicast address of group
04211     struct in_addr imr_multiaddr;
04212     /// Local IP address of interface
04213     struct in_addr imr_interface;
04214   };
04215 # endif /* ! ACE_HAS_IP_MULTICAST  &&  ACE_LACKS_IP_ADD_MEMBERSHIP */
04216 
04217 # if !defined (ACE_HAS_STRBUF_T)
04218 struct strbuf
04219 {
04220   /// No. of bytes in buffer.
04221   int maxlen;
04222   /// No. of bytes returned.
04223   int len;
04224   /// Pointer to data.
04225   void *buf;
04226 };
04227 # endif /* ACE_HAS_STRBUF_T */
04228 
04229 /**
04230  * @class ACE_Str_Buf
04231  *
04232  * @brief Simple wrapper for STREAM pipes strbuf.
04233  */
04234 class ACE_OS_Export ACE_Str_Buf : public strbuf
04235 {
04236 public:
04237   // = Initialization method
04238   /// Constructor.
04239   ACE_Str_Buf (void *b = 0, int l = 0, int max = 0);
04240 
04241   /// Constructor.
04242   ACE_Str_Buf (strbuf &);
04243 };
04244 
04245 # if defined (ACE_HAS_BROKEN_BITSHIFT)
04246   // This might not be necessary any more:  it was added prior to the
04247   // (fd_mask) cast being added to the version below.  Maybe that cast
04248   // will fix the problem on tandems.    Fri Dec 12 1997 David L. Levine
04249 #   define ACE_MSB_MASK (~(ACE_UINT32 (1) << ACE_UINT32 (NFDBITS - 1)))
04250 # else
04251   // This needs to go here to avoid overflow problems on some compilers.
04252 #   if defined (ACE_WIN32)
04253     //  Does ACE_WIN32 have an fd_mask?
04254 #     define ACE_MSB_MASK (~(1 << (NFDBITS - 1)))
04255 #   else  /* ! ACE_WIN32 */
04256 #     define ACE_MSB_MASK (~((fd_mask) 1 << (NFDBITS - 1)))
04257 #   endif /* ! ACE_WIN32 */
04258 # endif /* ACE_HAS_BROKEN_BITSHIFT */
04259 
04260 // Signature for registering a cleanup function that is used by the
04261 // <ACE_Object_Manager> and the <ACE_Thread_Manager>.
04262 # if defined (ACE_HAS_SIG_C_FUNC)
04263 extern "C" {
04264 # endif /* ACE_HAS_SIG_C_FUNC */
04265 typedef void (*ACE_CLEANUP_FUNC)(void *object, void *param) /* throw () */;
04266 # if defined (ACE_HAS_SIG_C_FUNC)
04267 }
04268 # endif /* ACE_HAS_SIG_C_FUNC */
04269 
04270 # if defined (ACE_WIN32)
04271 // Default WIN32 structured exception handler.
04272 int ACE_SEH_Default_Exception_Selector (void *);
04273 int ACE_SEH_Default_Exception_Handler (void *);
04274 # endif /* ACE_WIN32 */
04275 
04276 /**
04277  * @class ACE_Cleanup
04278  *
04279  * @brief Base class for objects that are cleaned by ACE_Object_Manager.
04280  */
04281 class ACE_OS_Export ACE_Cleanup
04282 {
04283 public:
04284   /// No-op constructor.
04285   ACE_Cleanup (void);
04286 
04287   /// Destructor.
04288   virtual ~ACE_Cleanup (void);
04289 
04290   /// Cleanup method that, by default, simply deletes itself.
04291   virtual void cleanup (void *param = 0);
04292 };
04293 
04294 // Adapter for cleanup, used by ACE_Object_Manager.
04295 extern "C" ACE_OS_Export
04296 void ace_cleanup_destroyer (ACE_Cleanup *, void *param = 0);
04297 
04298 /**
04299  * @class ACE_Cleanup_Info
04300  *
04301  * @brief Hold cleanup information for thread/process
04302  */
04303 class ACE_OS_Export ACE_Cleanup_Info
04304 {
04305 public:
04306   /// Default constructor.
04307   ACE_Cleanup_Info (void);
04308 
04309   /// Equality operator.
04310   int operator== (const ACE_Cleanup_Info &o) const;
04311 
04312   /// Inequality operator.
04313   int operator!= (const ACE_Cleanup_Info &o) const;
04314 
04315   /// Point to object that gets passed into the <cleanup_hook_>.
04316   void *object_;
04317 
04318   /// Cleanup hook that gets called back.
04319   ACE_CLEANUP_FUNC cleanup_hook_;
04320 
04321   /// Parameter passed to the <cleanup_hook_>.
04322   void *param_;
04323 };
04324 
04325 class ACE_Cleanup_Info_Node;
04326 
04327 /**
04328  * @class ACE_OS_Exit_Info
04329  *
04330  * @brief Hold Object Manager cleanup (exit) information.
04331  *
04332  * For internal use by the ACE library, only.
04333  */
04334 class ACE_OS_Export ACE_OS_Exit_Info
04335 {
04336 public:
04337   /// Default constructor.
04338   ACE_OS_Exit_Info (void);
04339 
04340   /// Destructor.
04341   ~ACE_OS_Exit_Info (void);
04342 
04343   /// Use to register a cleanup hook.
04344   int at_exit_i (void *object, ACE_CLEANUP_FUNC cleanup_hook, void *param);
04345 
04346   /// Look for a registered cleanup hook object.  Returns 1 if already
04347   /// registered, 0 if not.
04348   int find (void *object);
04349 
04350   /// Call all registered cleanup hooks, in reverse order of
04351   /// registration.
04352   void call_hooks ();
04353 
04354 private:
04355   /**
04356    * Keeps track of all registered objects.  The last node is only
04357    * used to terminate the list (it doesn't contain a valid
04358    * ACE_Cleanup_Info).
04359    */
04360   ACE_Cleanup_Info_Node *registered_objects_;
04361 };
04362 
04363 class ACE_Base_Thread_Adapter;
04364 class ACE_Thread_Hook;
04365 
04366 # if defined (ACE_HAS_PHARLAP_RT)
04367 #define ACE_IPPROTO_TCP SOL_SOCKET
04368 # else
04369 #define ACE_IPPROTO_TCP IPPROTO_TCP
04370 # endif /* ACE_HAS_PHARLAP_RT */
04371 
04372 # if defined (ACE_LACKS_FLOATING_POINT)
04373 typedef ACE_UINT32 ACE_timer_t;
04374 # else
04375 typedef double ACE_timer_t;
04376 # endif /* ACE_LACKS_FLOATING_POINT */
04377 
04378 # if defined (ACE_HAS_PRUSAGE_T)
04379     typedef prusage_t ACE_Rusage;
04380 # elif defined (ACE_HAS_GETRUSAGE)
04381     typedef rusage ACE_Rusage;
04382 # else
04383     typedef int ACE_Rusage;
04384 # endif /* ACE_HAS_PRUSAGE_T */
04385 
04386 # if !defined (ACE_WIN32) && !defined (ACE_LACKS_UNIX_SYSLOG)
04387 # include /**/ <syslog.h>
04388 # endif /* !defined (ACE_WIN32) && !defined (ACE_LACKS_UNIX_SYSLOG) */
04389 
04390 # if defined (ACE_HAS_SYS_FILIO_H)
04391 # include /**/ <sys/filio.h>
04392 # endif /* ACE_HAS_SYS_FILIO_H */
04393 
04394 # if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE) && !defined (__BORLANDC__)
04395       typedef struct _stat ACE_stat;
04396 # else
04397       typedef struct stat ACE_stat;
04398 # endif /* ACE_WIN32 */
04399 
04400 // We need this for MVS...
04401 extern "C" {
04402   typedef int (*ACE_COMPARE_FUNC)(const void *, const void *);
04403 }
04404 
04405 #if defined (ACE_HAS_WINCE)
04406 // WinCE doesn't have most of the standard C library time functions. It
04407 // also doesn't define struct tm. SYSTEMTIME has pretty much the same
04408 // info though, so we can map it when needed. Define struct tm here and
04409 // use it when needed. This is taken from the standard C library.
04410 struct tm {
04411   int tm_sec;
04412   int tm_min;
04413   int tm_hour;
04414   int tm_mday;      // Day of the month
04415   int tm_mon;
04416   int tm_year;
04417   int tm_wday;      // Day of the week
04418   int tm_yday;      // Day in the year
04419   int tm_isdst;     // >0 if dst in effet; 0 if not; <0 if unknown
04420 };
04421 #endif /* ACE_HAS_WINCE */
04422 
04423 
04424 /// Helper for the ACE_OS::timezone() function
04425 /**
04426  * We put all the timezone stuff that used to be in ACE_OS::timezone()
04427  * here because on some platforms "timezone" is a macro.  Because of this,
04428  * the name ACE_OS::timezone will cause errors.  So in order to use the
04429  * macro as it is defined but also keep the name ACE_OS::timezone, we
04430  * use timezone first here in this inline function, and then undefine
04431  * timezone.
04432  */
04433 inline long ace_timezone()
04434 {
04435 #if !defined (VXWORKS) && !defined (ACE_PSOS) && !defined (CHORUS)
04436 # if defined (ACE_HAS_WINCE)
04437   TIME_ZONE_INFORMATION tz;
04438   GetTimeZoneInformation (&tz);
04439   return tz.Bias * 60;
04440 # elif defined (ACE_WIN32)
04441   return _timezone;  // For Win32.
04442 # elif ( defined (__Lynx__) || defined (__FreeBSD__) || defined (ACE_HAS_SUNOS4_GETTIMEOFDAY) ) && ( !defined (__linux__) )
04443   long result = 0;
04444   struct timeval time;
04445   struct timezone zone;
04446   ACE_UNUSED_ARG (result);
04447   ACE_OSCALL (::gettimeofday (&time, &zone), int, -1, result);
04448   return zone.tz_minuteswest * 60;
04449 # else  /* __Lynx__ || __FreeBSD__ ... */
04450 # if defined (__linux__)
04451   // Under Linux, gettimeofday() does not correctly set the timezone
04452   // struct, so we should use the global variable <timezone>.
04453   // However, it is initialized by tzset().  I assume other systems
04454   // are the same (i.e., tzset() needs to be called to set
04455   // <timezone>), but since no one is complaining, I will only make
04456   // the change for Linux.
04457   ::tzset();
04458 # endif
04459   return timezone;
04460 # endif /* __Lynx__ || __FreeBSD__ ... */
04461 #else
04462   ACE_NOTSUP_RETURN (0);
04463 #endif /* !ACE_HAS_WINCE && !VXWORKS && !ACE_PSOS */
04464 }
04465 
04466 
04467 #if !defined (ACE_LACKS_DIFFTIME)
04468 /// Helper for the ACE_OS::difftime() function
04469 /**
04470  * We moved the difftime code that used to be in ACE_OS::difftime()
04471  * here because on some platforms "difftime" is a macro.  Because of this,
04472  * the name ACE_OS::difftime will cause errors.  So in order to use the
04473  * macro as it is defined but also keep the name ACE_OS::difftime, we
04474  * use difftime first here in this inline function, and then undefine
04475  * it.
04476  */
04477 inline double ace_difftime(time_t t1, time_t t0)
04478 {
04479 # if defined (ACE_PSOS) && ! defined (ACE_PSOS_HAS_TIME)
04480   // simulate difftime ; just subtracting ; ACE_PSOS case
04481   return ((double)t1) - ((double)t0);
04482 # else
04483   return difftime (t1, t0);
04484 # endif /* ACE_PSOS !ACE_PSOS_HAS_TIME */
04485 }
04486 #endif /* !ACE_LACKS_DIFFTIME */
04487 
04488 
04489 /// Helper for the ACE_OS::cuserid() function
04490 /**
04491  * On some platforms cuserid is a macro.  Defining ACE_OS::cuserid()
04492  * becomes really hard, as there is no way to save the macro
04493  * definition using the pre-processor.
04494  * This inline function achieves the same effect, without namespace
04495  * pollution or performance penalties.
04496  *
04497  * @todo We maybe should move a lot of the code in ACE_OS::cuserid here so
04498  *       it is treated the same as the above ace_difftime and ace_timezone.
04499  *       But since there is a good deal more code in ACE_OS::cuserid, we
04500  *       probably need to move some of it off into some sort of emulation
04501  *       function.
04502  */
04503 #if !defined (ACE_LACKS_CUSERID) && !defined(ACE_HAS_ALT_CUSERID) \
04504     && !defined(ACE_WIN32) && !defined (VXWORKS)
04505 inline char *ace_cuserid(char *user)
04506 {
04507   return cuserid(user);
04508 }
04509 #endif /* !ACE_LACKS_CUSERID && !ACE_HAS_ALT_CUSERID && ... */
04510 
04511 #if defined (SD_RECEIVE)
04512 #define ACE_SHUTDOWN_READ SD_RECEIVE
04513 #elif defined (SHUT_RD)
04514 #define ACE_SHUTDOWN_READ SHUT_RD
04515 #else
04516 #define ACE_SHUTDOWN_READ 0
04517 #endif /* SD_RECEIVE */
04518 
04519 #if defined (SD_SEND)
04520 #define ACE_SHUTDOWN_WRITE SD_SEND
04521 #elif defined (SHUT_WR)
04522 #define ACE_SHUTDOWN_WRITE SHUT_WR
04523 #else
04524 #define ACE_SHUTDOWN_WRITE 1
04525 #endif /* SD_RECEIVE */
04526 
04527 #if defined (SD_BOTH)
04528 #define ACE_SHUTDOWN_BOTH SD_BOTH
04529 #elif defined (SHUT_RDWR)
04530 #define ACE_SHUTDOWN_BOTH SHUT_RDWR
04531 #else
04532 #define ACE_SHUTDOWN_BOTH 2
04533 #endif /* SD_RECEIVE */
04534 
04535 #if !defined (ACE_HAS_WINCE)
04536 // forward declarations of QoS data structures
04537 class ACE_QoS;
04538 class ACE_QoS_Params;
04539 class ACE_Accept_QoS_Params;
04540 #endif  // ACE_HAS_WINCE
04541 
04542 #if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
04543 typedef WSAPROTOCOL_INFO ACE_Protocol_Info;
04544 
04545 // Callback function that's used by the QoS-enabled <ACE_OS::ioctl>
04546 // method.
04547 typedef LPWSAOVERLAPPED_COMPLETION_ROUTINE ACE_OVERLAPPED_COMPLETION_FUNC;
04548 typedef GROUP ACE_SOCK_GROUP;
04549 #else  /*  (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) */
04550 struct ACE_Protocol_Info
04551 {
04552   u_long dwServiceFlags1;
04553   int iAddressFamily;
04554   int iProtocol;
04555   char szProtocol[255+1];
04556 };
04557 
04558 // Callback function that's used by the QoS-enabled <ACE_OS::ioctl>
04559 // method.
04560 typedef void (*ACE_OVERLAPPED_COMPLETION_FUNC) (u_long error,
04561                                                 u_long bytes_transferred,
04562                                                 ACE_OVERLAPPED *overlapped,
04563                                                 u_long flags);
04564 typedef u_long ACE_SOCK_GROUP;
04565 
04566 #endif /* (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) */
04567 
04568 /**
04569  * @class ACE_OS
04570  *
04571  * @brief This class defines an OS independent programming API that
04572  *     shields developers from nonportable aspects of writing
04573  *     efficient system programs on Win32, POSIX and other versions
04574  *     of UNIX, and various real-time operating systems.
04575  *
04576  * This class encapsulates the differences between various OS
04577  * platforms.  When porting ACE to a new platform, this class is
04578  * the place to focus on.  Once this file is ported to a new
04579  * platform, pretty much everything else comes for "free."  See
04580  * <www.cs.wustl.edu/~schmidt/ACE_wrappers/etc/ACE-porting.html>
04581  * for instructions on porting ACE.  Please see the README file
04582  * in this directory for complete information on the meaning of
04583  * the various macros.
04584  */
04585 class ACE_OS_Export ACE_OS
04586   : public ACE_OS_Dirent,
04587     public ACE_OS_String,
04588     public ACE_OS_Memory,
04589     public ACE_OS_TLI
04590 {
04591 
04592   ACE_CLASS_IS_NAMESPACE (ACE_OS);
04593 public:
04594   friend class ACE_Timeout_Manager;
04595 
04596 # if defined (CHORUS) && !defined (CHORUS_4)
04597   // We must format this code as follows to avoid confusing OSE.
04598   enum ACE_HRTimer_Op
04599     {
04600       ACE_HRTIMER_START = K_BSTART,
04601       ACE_HRTIMER_INCR = K_BPOINT,
04602       ACE_HRTIMER_STOP = K_BSTOP,
04603       ACE_HRTIMER_GETTIME = 0xFFFF
04604     };
04605 # else  /* ! CHORUS */
04606   enum ACE_HRTimer_Op
04607     {
04608       ACE_HRTIMER_START = 0x0,  // Only use these if you can stand
04609       ACE_HRTIMER_INCR = 0x1,   // for interrupts to be disabled during
04610       ACE_HRTIMER_STOP = 0x2,   // the timed interval!!!!
04611       ACE_HRTIMER_GETTIME = 0xFFFF
04612     };
04613 # endif /* ! CHORUS */
04614 
04615   /**
04616    * @class ace_flock_t
04617    *
04618    * @brief OS file locking structure.
04619    */
04620   class ACE_OS_Export ace_flock_t
04621   {
04622   public:
04623   /// Dump state of the object.
04624     void dump (void) const;
04625 
04626 # if defined (ACE_WIN32)
04627     ACE_OVERLAPPED overlapped_;
04628 # else
04629     struct flock lock_;
04630 # endif /* ACE_WIN32 */
04631 
04632     /// Name of this filelock.
04633     const ACE_TCHAR *lockname_;
04634 
04635     /// Handle to the underlying file.
04636     ACE_HANDLE handle_;
04637 
04638 # if defined (CHORUS)
04639     /// This is the mutex that's stored in shared memory.  It can only
04640     /// be destroyed by the actor that initialized it.
04641     ACE_mutex_t *process_lock_;
04642 # endif /* CHORUS */
04643   };
04644 
04645 # if defined (ACE_WIN32)
04646   // = Default Win32 Security Attributes definition.
04647   static LPSECURITY_ATTRIBUTES default_win32_security_attributes (LPSECURITY_ATTRIBUTES);
04648 
04649   // = Win32 OS version determination function.
04650   /// Return the win32 OSVERSIONINFO structure.
04651   static const OSVERSIONINFO &get_win32_versioninfo (void);
04652 
04653   // = A pair of functions for modifying ACE's Win32 resource usage.
04654   /// Return the handle of the module containing ACE's resources. By
04655   /// default, for a DLL build of ACE this is a handle to the ACE DLL
04656   /// itself, and for a static build it is a handle to the executable.
04657   static HINSTANCE get_win32_resource_module (void);
04658 
04659   /// Allow an application to modify which module contains ACE's
04660   /// resources. This is mainly useful for a static build of ACE where
04661   /// the required resources reside somewhere other than the executable.
04662   static void set_win32_resource_module (HINSTANCE);
04663 
04664 # endif /* ACE_WIN32 */
04665 
04666   // = A set of wrappers for miscellaneous operations.
04667   static int atoi (const char *s);
04668 
04669 # if defined (ACE_HAS_WCHAR)
04670   static int atoi (const wchar_t *s);
04671 # endif /* ACE_HAS_WCHAR */
04672 
04673 #if defined (atop)
04674 #undef atop
04675 #endif /* atop */
04676 
04677   static void *atop (const char *s);
04678 
04679 # if defined (ACE_HAS_WCHAR)
04680   static void *atop (const wchar_t *s);
04681 # endif /* ACE_HAS_WCHAR */
04682 
04683   /// This method computes the largest integral value not greater than x.
04684   static double floor (double x);
04685 
04686   /// This method computes the smallest integral value not less than x.
04687   static double ceil (double x);
04688 
04689   static char *getenv (const char *symbol);
04690 #   if defined (ACE_HAS_WCHAR) && defined (ACE_WIN32)
04691   static wchar_t *getenv (const wchar_t *symbol);
04692 #   endif /* ACE_HAS_WCHAR && ACE_WIN32 */
04693   static int putenv (const ACE_TCHAR *string);
04694   static ACE_TCHAR *strenvdup (const ACE_TCHAR *str);
04695   static ACE_TCHAR *getenvstrings (void);
04696 
04697   static int getopt (int argc,
04698                      char *const *argv,
04699                      const char *optstring);
04700   static int argv_to_string (ACE_TCHAR **argv,
04701                              ACE_TCHAR *&buf,
04702                              int substitute_env_args = 1);
04703   static int string_to_argv (ACE_TCHAR *buf,
04704                              int &argc,
04705                              ACE_TCHAR **&argv,
04706                              int substitute_env_args = 1);
04707   static long sysconf (int);
04708 
04709   //@{ @name A set of wrappers for condition variables.
04710   static int condattr_init (ACE_condattr_t &attributes,
04711                             int type = ACE_DEFAULT_SYNCH_TYPE);
04712   static int condattr_destroy (ACE_condattr_t &attributes);
04713   static int cond_broadcast (ACE_cond_t *cv);
04714   static int cond_destroy (ACE_cond_t *cv);
04715   static int cond_init (ACE_cond_t *cv,
04716                         short type = ACE_DEFAULT_SYNCH_TYPE,
04717                         const char *name = 0,
04718                         void *arg = 0);
04719   static int cond_init (ACE_cond_t *cv,
04720                         ACE_condattr_t &attributes,
04721                         const char *name = 0,
04722                         void *arg = 0);
04723 # if defined (ACE_HAS_WCHAR)
04724   static int cond_init (ACE_cond_t *cv,
04725                         short type,
04726                         const wchar_t *name,
04727                         void *arg = 0);
04728   static int cond_init (ACE_cond_t *cv,
04729                         ACE_condattr_t &attributes,
04730                         const wchar_t *name,
04731                         void *arg = 0);
04732 # endif /* ACE_HAS_WCHAR */
04733   static int cond_signal (ACE_cond_t *cv);
04734   static int cond_timedwait (ACE_cond_t *cv,
04735                              ACE_mutex_t *m,
04736                              ACE_Time_Value *);
04737   static int cond_wait (ACE_cond_t *cv,
04738                         ACE_mutex_t *m);
04739 # if defined (ACE_WIN32) && defined (ACE_HAS_WTHREADS)
04740   static int cond_timedwait (ACE_cond_t *cv,
04741                              ACE_thread_mutex_t *m,
04742                              ACE_Time_Value *);
04743   static int cond_wait (ACE_cond_t *cv,
04744                         ACE_thread_mutex_t *m);
04745 # endif /* ACE_WIN32 && ACE_HAS_WTHREADS */
04746   //@}
04747 
04748 
04749   //@{ @name Wrappers to obtain the current user id
04750 # if !defined (ACE_LACKS_CUSERID)
04751 #if defined(cuserid)
04752 # undef cuserid
04753 #endif /* cuserid */
04754   static char *cuserid (char *user,
04755                         size_t maxlen = ACE_MAX_USERID);
04756 
04757 #   if defined (ACE_HAS_WCHAR)
04758   static wchar_t *cuserid (wchar_t *user,
04759                            size_t maxlen = ACE_MAX_USERID);
04760 #   endif /* ACE_HAS_WCHAR */
04761 # endif /* ACE_LACKS_CUSERID */
04762   //@}
04763 
04764   //@{ @name Wrappers to obtain configuration info
04765   static int uname (ACE_utsname *name);
04766   static long sysinfo (int cmd,
04767                        char *buf,
04768                        long count);
04769   static int hostname (char *name,
04770                        size_t maxnamelen);
04771 
04772 #if defined (ACE_HAS_WCHAR)
04773   static int hostname (wchar_t *name,
04774                        size_t maxnamelen);
04775 #endif /* ACE_HAS_WCHAR */
04776   //@}
04777 
04778   //@{ @name A set of wrappers for explicit dynamic linking.
04779   static int dlclose (ACE_SHLIB_HANDLE handle);
04780 
04781   static ACE_TCHAR *dlerror (void);
04782   static ACE_SHLIB_HANDLE dlopen (const ACE_TCHAR *filename,
04783                                   int mode = ACE_DEFAULT_SHLIB_MODE);
04784   static void *dlsym (ACE_SHLIB_HANDLE handle,
04785                       const ACE_TCHAR *symbol);
04786   //@}
04787 
04788   //@{ @name A set of wrappers for stdio file operations.
04789   static int last_error (void);
04790   static void last_error (int);
04791   static int set_errno_to_last_error (void);
04792   static int set_errno_to_wsa_last_error (void);
04793   static int fclose (FILE *fp);
04794   static int fcntl (ACE_HANDLE handle,
04795                     int cmd,
04796                     long arg = 0);
04797   static int fdetach (const char *file);
04798 
04799   static int fsync (ACE_HANDLE handle);
04800 
04801 # if defined (ACE_USES_WCHAR)
04802   // If fp points to the Unicode format file, the file pointer will be moved right next
04803   // to the Unicode header (2 types).  Otherwise, file pointer will be at the beginning.
04804   static void checkUnicodeFormat (FILE* fp);
04805 # endif  // ACE_USES_WCHAR
04806 
04807   static FILE *fopen (const ACE_TCHAR *filename, const ACE_TCHAR *mode);
04808   static FILE *freopen (const ACE_TCHAR *filename, const ACE_TCHAR *mode, FILE* stream);
04809 # if defined (fdopen)
04810 #   undef fdopen
04811 # endif /* fdopen */
04812   static FILE *fdopen (ACE_HANDLE handle, const ACE_TCHAR *mode);
04813   static ACE_TCHAR *fgets (ACE_TCHAR *buf, int size, FILE *fp);
04814   static int stat (const ACE_TCHAR *file, ACE_stat *);
04815   static int truncate (const ACE_TCHAR *filename, off_t length);
04816 
04817   static int fprintf (FILE *fp, const char *format, ...);
04818   static int sprintf (char *buf, const char *format, ...);
04819   static int snprintf (char *buf, size_t maxlen, const char *format, ...);
04820   static int vsprintf (char *buffer, const char *format, va_list argptr);
04821   static int printf (const char *format, ...);
04822 # if defined (ACE_HAS_WCHAR)
04823   static int sprintf (wchar_t *buf, const wchar_t *format, ...);
04824   static int snprintf (wchar_t *buf, size_t maxlen, const wchar_t *format,...);
04825   static int fprintf (FILE *fp, const wchar_t *format, ...);
04826   static int vsprintf (wchar_t *buffer, const wchar_t *format, va_list argptr);
04827 # endif /* ACE_HAS_WCHAR */
04828 
04829   static void perror (const ACE_TCHAR *s);
04830 
04831   // The old gets () which directly maps to the evil, unprotected
04832   // gets () has been deprecated.  If you really need gets (),
04833   // consider the following one.
04834 
04835   // A better gets ().
04836   //   If n == 0, input is swallowed, but NULL is returned.
04837   //   Otherwise, reads up to n-1 bytes (not including the newline),
04838   //              then swallows rest up to newline
04839   //              then swallows newline
04840   static char *gets (char *str, int n = 0);
04841   static int puts (const ACE_TCHAR *s);
04842   static int fputs (const ACE_TCHAR *s,
04843                     FILE *stream);
04844 
04845   static int fflush (FILE *fp);
04846   static size_t fread (void *ptr,
04847                        size_t size,
04848                        size_t nelems,
04849                        FILE *fp);
04850 
04851   static int fgetc (FILE* fp);
04852 
04853 #if !defined (ACE_LACKS_CLEARERR)
04854   static void clearerr (FILE* fp);
04855 #endif /* !ACE_LACKS_CLEARERR */
04856 
04857 #if defined (ACE_HAS_WCHAR)
04858   static wint_t fgetwc (FILE* fp);
04859   static wint_t ungetwc (wint_t c, FILE* fp);
04860 #endif /* ACE_HAS_WCHAR */
04861 
04862   static int fseek (FILE *fp,
04863                     long offset,
04864                     int ptrname);
04865   static long ftell (FILE* fp);
04866   static int  fgetpos (FILE* fp, fpos_t* pos);
04867   static int  fsetpos (FILE* fp, fpos_t* pos);
04868   static int fstat (ACE_HANDLE,
04869                     ACE_stat *);
04870   static int lstat (const char *,
04871                     ACE_stat *);
04872   static int ftruncate (ACE_HANDLE,
04873                         off_t);
04874   static size_t fwrite (const void *ptr,
04875                         size_t size,
04876                         size_t nitems,
04877                         FILE *fp);
04878   static void rewind (FILE *fp);
04879   //@}
04880 
04881   //@{ @name Wrappers for searching and sorting.
04882   static void *bsearch (const void *key,
04883                         const void *base,
04884                         size_t nel,
04885                         size_t size,
04886                         ACE_COMPARE_FUNC);
04887   static void qsort (void *base,
04888                      size_t nel,
04889                      size_t width,
04890                      ACE_COMPARE_FUNC);
04891   //@}
04892 
04893   //@{ @name A set of wrappers for file locks.
04894   static int flock_init (ACE_OS::ace_flock_t *lock,
04895                          int flags = 0,
04896                          const ACE_TCHAR *name = 0,
04897                          mode_t perms = 0);
04898   static int flock_destroy (ACE_OS::ace_flock_t *lock,
04899                             int unlink_file = 1);
04900 # if defined (ACE_WIN32)
04901   static void adjust_flock_params (ACE_OS::ace_flock_t *lock,
04902                                    short whence,
04903                                    off_t &start,
04904                                    off_t &len);
04905 # endif /* ACE_WIN32 */
04906   static int flock_rdlock (ACE_OS::ace_flock_t *lock,
04907                            short whence = 0,
04908                            off_t start = 0,
04909                            off_t len = 0);
04910   static int flock_tryrdlock (ACE_OS::ace_flock_t *lock,
04911                               short whence = 0,
04912                               off_t start = 0,
04913                               off_t len = 0);
04914   static int flock_trywrlock (ACE_OS::ace_flock_t *lock,
04915                               short whence = 0,
04916                               off_t start = 0,
04917                               off_t len = 0);
04918   static int flock_unlock (ACE_OS::ace_flock_t *lock,
04919                            short whence = 0,
04920                            off_t start = 0,
04921                            off_t len = 0);
04922   static int flock_wrlock (ACE_OS::ace_flock_t *lock,
04923                            short whence = 0,
04924                            off_t start = 0,
04925                            off_t len = 0);
04926   //@}
04927 
04928   //@{ @name A set of wrappers for low-level process operations.
04929   static int atexit (ACE_EXIT_HOOK func);
04930   static int execl (const char *path,
04931                     const char *arg0, ...);
04932   static int execle (const char *path,
04933                      const char *arg0, ...);
04934   static int execlp (const char *file,
04935                      const char *arg0, ...);
04936   static int execv (const char *path,
04937                     char *const argv[]);
04938   static int execvp (const char *file,
04939                      char *const argv[]);
04940   static int execve (const char *path,
04941                      char *const argv[],
04942                      char *const envp[]);
04943   static void _exit (int status = 0);
04944   static void exit (int status = 0);
04945   static void abort (void);
04946   static pid_t fork (void);
04947 
04948   static int getpagesize (void);
04949   static int allocation_granularity (void);
04950 
04951   static gid_t getgid (void);
04952   static int setgid (gid_t);
04953   static pid_t getpid (void);
04954   static pid_t getpgid (pid_t pid);
04955   static pid_t getppid (void);
04956   static uid_t getuid (void);
04957   static int setuid (uid_t);
04958   static pid_t setsid (void);
04959   static int setpgid (pid_t pid, pid_t pgid);
04960   static int setreuid (uid_t ruid, uid_t euid);
04961   static int setregid (gid_t rgid, gid_t egid);
04962   static int system (const ACE_TCHAR *s);
04963   //@}
04964 
04965   //@{
04966   /// Forks and exec's a process in a manner that works on Solaris and
04967   /// NT.  argv[0] must be the full path name to the executable.
04968   static pid_t fork (const ACE_TCHAR *program_name);
04969   static pid_t fork_exec (ACE_TCHAR *argv[]);
04970   //@}
04971 
04972   /**
04973    * Calls <::waitpid> on UNIX/POSIX platforms and <::await> on
04974    * Chorus.  Does not work on Vxworks, or pSoS.
04975    * On Win32, <pid> is ignored if the <handle> is not equal to 0.
04976    * Passing the process <handle> is prefer on Win32 because using
04977    * <pid> to wait on the project doesn't always work correctly
04978    * if the waited process has already terminated.
04979    */
04980   static pid_t waitpid (pid_t pid,
04981                         ACE_exitcode *status = 0,
04982                         int wait_options = 0,
04983                         ACE_HANDLE handle = 0);
04984 
04985   /**
04986    * Calls <::WaitForSingleObject> on Win32 and <ACE::waitpid>
04987    * otherwise.  Returns the passed in <pid_t> on success and -1 on
04988    * failure.
04989    * On Win32, <pid> is ignored if the <handle> is not equal to 0.
04990    * Passing the process <handle> is prefer on Win32 because using
04991    * <pid> to wait on the project doesn't always work correctly
04992    * if the waited process has already terminated.
04993    */
04994   static pid_t wait (pid_t pid,
04995                      ACE_exitcode *status,
04996                      int wait_options = 0,
04997                      ACE_HANDLE handle = 0);
04998 
04999   /// Calls OS <::wait> function, so it's only portable to UNIX/POSIX
05000   /// platforms.
05001   static pid_t wait (int * = 0);
05002 
05003   //@{ @name A set of wrappers for timers and resource stats.
05004   static u_int alarm (u_int secs);
05005   static u_int ualarm (u_int usecs,
05006                        u_int interval = 0);
05007   static u_int ualarm (const ACE_Time_Value &tv,
05008                        const ACE_Time_Value &tv_interval = ACE_Time_Value::zero);
05009   static ACE_hrtime_t gethrtime (const ACE_HRTimer_Op = ACE_HRTIMER_GETTIME);
05010 # if defined (ACE_HAS_POWERPC_TIMER) && (defined (ghs) || defined (__GNUG__))
05011   static void readPPCTimeBase (u_long &most,
05012                                u_long &least);
05013 # endif /* ACE_HAS_POWERPC_TIMER  &&  (ghs or __GNUG__) */
05014   static int clock_gettime (clockid_t,
05015                             struct timespec *);
05016   static ACE_Time_Value gettimeofday (void);
05017   static int getrusage (int who,
05018                         struct rusage *rusage);
05019   static int getrlimit (int resource,
05020                         struct rlimit *rl);
05021   static int setrlimit (int resource,
05022                         ACE_SETRLIMIT_TYPE *rl);
05023   static int sleep (u_int seconds);
05024   static int sleep (const ACE_Time_Value &tv);
05025   static int nanosleep (const struct timespec *requested,
05026                         struct timespec *remaining = 0);
05027 
05028 # if defined (ACE_HAS_BROKEN_R_ROUTINES)
05029 #   undef ctime_r
05030 #   undef asctime_r
05031 #   undef rand_r
05032 #   undef getpwnam_r
05033 # endif /* ACE_HAS_BROKEN_R_ROUTINES */
05034   //@}
05035 
05036   //@{ @name A set of wrappers for operations on time.
05037 
05038   // Get the current time.
05039   static time_t mktime (struct tm *timeptr);
05040 
05041   // wrapper for time zone information.
05042   static void tzset (void);
05043 
05044 # if defined (timezone)
05045 #   undef timezone
05046 # endif /* timezone */
05047   static long timezone (void);
05048 
05049 # if defined (difftime)
05050 #   undef difftime
05051 # endif /* difftime */
05052   static double difftime (time_t t1,
05053                           time_t t0);
05054   static time_t time (time_t *tloc = 0);
05055   static struct tm *localtime (const time_t *clock);
05056   static struct tm *localtime_r (const time_t *clock,
05057                                  struct tm *res);
05058   static struct tm *gmtime (const time_t *clock);
05059   static struct tm *gmtime_r (const time_t *clock,
05060                               struct tm *res);
05061   static char *asctime (const struct tm *tm);
05062   static char *asctime_r (const struct tm *tm,
05063                           char *buf, int buflen);
05064   static ACE_TCHAR *ctime (const time_t *t);
05065   static ACE_TCHAR *ctime_r (const time_t *clock, ACE_TCHAR *buf, int buflen);
05066   static size_t strftime (char *s,
05067                           size_t maxsize,
05068                           const char *format,
05069                           const struct tm *timeptr);
05070   //@}
05071 
05072   //@{ @name A set of wrappers for System V message queues.
05073   static int msgctl (int msqid,
05074                      int cmd,
05075                      struct msqid_ds *);
05076   static int msgget (key_t key,
05077                      int msgflg);
05078   static int msgrcv (int int_id,
05079                      void *buf,
05080                      size_t len,
05081                      long type,
05082                      int flags);
05083   static int msgsnd (int int_id,
05084                      const void *buf,
05085                      size_t len,
05086                      int flags);
05087   //@}
05088 
05089   //@{ @name A set of wrappers for memory mapped files.
05090   static int madvise (caddr_t addr,
05091                       size_t len,
05092                       int advice);
05093   static void *mmap (void *addr,
05094                      size_t len,
05095                      int prot,
05096                      int flags,
05097                      ACE_HANDLE handle,
05098                      off_t off = 0,
05099                      ACE_HANDLE *file_mapping = 0,
05100                      LPSECURITY_ATTRIBUTES sa = 0,
05101                      const ACE_TCHAR *file_mapping_name = 0);
05102   static int mprotect (void *addr,
05103                        size_t len,
05104                        int prot);
05105   static int msync (void *addr,
05106                     size_t len,
05107                     int sync);
05108   static int munmap (void *addr,
05109                      size_t len);
05110   //@}
05111 
05112   //@{ @name A set of wrappers for recursive mutex locks.
05113   static int recursive_mutex_init (ACE_recursive_thread_mutex_t *m,
05114                                    const ACE_TCHAR *name = 0,
05115                                    ACE_mutexattr_t *arg = 0,
05116                                    LPSECURITY_ATTRIBUTES sa = 0);
05117   static int recursive_mutex_destroy (ACE_recursive_thread_mutex_t *m);
05118   static int recursive_mutex_lock (ACE_recursive_thread_mutex_t *m);
05119   static int recursive_mutex_trylock (ACE_recursive_thread_mutex_t *m);
05120   static int recursive_mutex_unlock (ACE_recursive_thread_mutex_t *m);
05121   // These two methods are primarily in support of
05122   // ACE_Condition<ACE_Recursive_Thread_Mutex> and should probably not
05123   // be called outside that context.
05124   static int recursive_mutex_cond_unlock (ACE_recursive_thread_mutex_t *m,
05125                                           ACE_recursive_mutex_state &state);
05126   static void recursive_mutex_cond_relock (ACE_recursive_thread_mutex_t *m,
05127                                            ACE_recursive_mutex_state &state);
05128   //@}
05129 
05130   //@{ @name A set of wrappers for mutex locks.
05131   static int mutex_init (ACE_mutex_t *m,
05132                          int type = ACE_DEFAULT_SYNCH_TYPE,
05133                          const char *name = 0,
05134                          ACE_mutexattr_t *arg = 0,
05135                          LPSECURITY_ATTRIBUTES sa = 0);
05136 #if defined (ACE_HAS_WCHAR)
05137   static int mutex_init (ACE_mutex_t *m,
05138                          int type,
05139                          const wchar_t *name,
05140                          ACE_mutexattr_t *arg = 0,
05141                          LPSECURITY_ATTRIBUTES sa = 0);
05142 #endif /* ACE_HAS_WCHAR */
05143   static int mutex_destroy (ACE_mutex_t *m);
05144 
05145   /// Win32 note: Abandoned mutexes are not treated differently. 0 is
05146   /// returned since the calling thread does get the ownership.
05147   static int mutex_lock (ACE_mutex_t *m);
05148 
05149   /// This method is only implemented for Win32.  For abandoned
05150   /// mutexes, <abandoned> is set to 1 and 0 is returned.
05151   static int mutex_lock (ACE_mutex_t *m,
05152                          int &abandoned);
05153 
05154   /**
05155    * This method attempts to acquire a lock, but gives up if the lock
05156    * has not been acquired by the given time.  If the lock is not
05157    * acquired within the given amount of time, then this method
05158    * returns -1 with an <ETIME> errno on platforms that actually
05159    * support timed mutexes.  The timeout should be an absolute time.
05160    * Note that the mutex should not be a recursive one, i.e., it
05161    * should only be a standard mutex or an error checking mutex.
05162    */
05163   static int mutex_lock (ACE_mutex_t *m,
05164                          const ACE_Time_Value &timeout);
05165 
05166   /**
05167    * If <timeout> == 0, calls <ACE_OS::mutex_lock(m)>.  Otherwise,
05168    * this method attempts to acquire a lock, but gives up if the lock
05169    * has not been acquired by the given time, in which case it returns
05170    * -1 with an <ETIME> errno on platforms that actually support timed
05171    * mutexes.  The timeout should be an absolute time.  Note that the
05172    * mutex should not be a recursive one, i.e., it should only be a
05173    * standard mutex or an error checking mutex.
05174    */
05175   static int mutex_lock (ACE_mutex_t *m,
05176                          const ACE_Time_Value *timeout);
05177 
05178   /// Win32 note: Abandoned mutexes are not treated differently. 0 is
05179   /// returned since the calling thread does get the ownership.
05180   static int mutex_trylock (ACE_mutex_t *m);
05181 
05182   /// This method is only implemented for Win32.  For abandoned
05183   /// mutexes, <abandoned> is set to 1 and 0 is returned.
05184   static int mutex_trylock (ACE_mutex_t *m,
05185                             int &abandoned);
05186 
05187   static int mutex_unlock (ACE_mutex_t *m);
05188   //@}
05189 
05190   //@{ @name A set of wrappers for mutex locks that only work within a single process.
05191   static int thread_mutex_init (ACE_thread_mutex_t *m,
05192                                 int type = ACE_DEFAULT_SYNCH_TYPE,
05193                                 const char *name = 0,
05194                                 ACE_mutexattr_t *arg = 0);
05195 #if defined (ACE_HAS_WCHAR)
05196   static int thread_mutex_init (ACE_thread_mutex_t *m,
05197                                 int type,
05198                                 const wchar_t *name,
05199                                 ACE_mutexattr_t *arg = 0);
05200 #endif /* ACE_HAS_WCHAR */
05201   static int thread_mutex_destroy (ACE_thread_mutex_t *m);
05202   static int thread_mutex_lock (ACE_thread_mutex_t *m);
05203   static int thread_mutex_lock (ACE_thread_mutex_t *m,
05204                                 const ACE_Time_Value &timeout);
05205   static int thread_mutex_lock (ACE_thread_mutex_t *m,
05206                                 const ACE_Time_Value *timeout);
05207   static int thread_mutex_trylock (ACE_thread_mutex_t *m);
05208   static int thread_mutex_unlock (ACE_thread_mutex_t *m);
05209   //@}
05210 
05211   //@{ @name A set of wrappers for low-level file operations.
05212   static int access (const char *path, int amode);
05213 #if defined (ACE_HAS_WCHAR)
05214   static int access (const wchar_t *path, int amode);
05215 #endif /* ACE_HAS_WCHAR */
05216 
05217   static int close (ACE_HANDLE handle);
05218   static ACE_HANDLE creat (const ACE_TCHAR *filename,
05219                            mode_t mode);
05220   static ACE_HANDLE dup (ACE_HANDLE handle);
05221   static int dup2 (ACE_HANDLE oldfd,
05222                    ACE_HANDLE newfd);
05223   static int fattach (int handle,
05224                       const char *path);
05225   static long filesize (ACE_HANDLE handle);
05226   static long filesize (const ACE_TCHAR *handle);
05227   static int getmsg (ACE_HANDLE handle,
05228                      struct strbuf *ctl,
05229                      struct strbuf
05230                      *data, int *flags);
05231   static int getpmsg (ACE_HANDLE handle,
05232                       struct strbuf *ctl,
05233                       struct strbuf
05234                       *data,
05235                       int *band,
05236                       int *flags);
05237 
05238   /// UNIX-style <ioctl>.
05239   static int ioctl (ACE_HANDLE handle,
05240                     int cmd,
05241                     void * = 0);
05242 
05243 #if !defined (ACE_HAS_WINCE)
05244   /// QoS-enabled <ioctl>.
05245   static int ioctl (ACE_HANDLE socket,
05246                     u_long io_control_code,
05247                     void *in_buffer_p,
05248                     u_long in_buffer,
05249                     void *out_buffer_p,
05250                     u_long out_buffer,
05251                     u_long *bytes_returned,
05252                     ACE_OVERLAPPED *overlapped,
05253                     ACE_OVERLAPPED_COMPLETION_FUNC func);
05254 
05255   /// QoS-enabled <ioctl> when the I/O control code is either
05256   /// SIO_SET_QOS or SIO_GET_QOS.
05257   static int ioctl (ACE_HANDLE socket,
05258                     u_long io_control_code,
05259                     ACE_QoS &ace_qos,
05260                     u_long *bytes_returned,
05261                     void *buffer_p = 0,
05262                     u_long buffer = 0,
05263                     ACE_OVERLAPPED *overlapped = 0,
05264                     ACE_OVERLAPPED_COMPLETION_FUNC func = 0);
05265 #endif  // ACE_HAS_WINCE
05266 
05267   static int isastream (ACE_HANDLE handle);
05268   static int isatty (int handle);
05269 #if defined (ACE_WIN32)
05270   static int isatty (ACE_HANDLE handle);
05271 #endif /* ACE_WIN32 */
05272   static off_t lseek (ACE_HANDLE handle,
05273                       off_t offset,
05274                       int whence);
05275 #if defined (ACE_HAS_LLSEEK) || defined (ACE_HAS_LSEEK64)
05276   static ACE_LOFF_T llseek (ACE_HANDLE handle, ACE_LOFF_T offset, int whence);
05277 #endif /* ACE_HAS_LLSEEK */
05278 
05279   // It used to be that the <perms> argument default was 0 on all
05280   // platforms. Further, the ACE_OS::open implementations ignored <perms>
05281   // for Win32 and always supplied read|write|delete. To preserve
05282   // backward compatibility and allow users to pass in values
05283   // that are used as desired, the defaults are now what the default
05284   // action used to be on Win32. The implementation now obeys what is passed.
05285 #if defined (ACE_WIN32)
05286 #  if defined (ACE_HAS_WINNT4) && (ACE_HAS_WINNT4 == 1)
05287 #    define ACE_DEFAULT_OPEN_PERMS (FILE_SHARE_READ | FILE_SHARE_WRITE | \
05288                                     FILE_SHARE_DELETE)
05289 #  else
05290 #    define ACE_DEFAULT_OPEN_PERMS (FILE_SHARE_READ | FILE_SHARE_WRITE)
05291 #  endif /* ACE_HAS_WINCE */
05292 #else
05293 #  define ACE_DEFAULT_OPEN_PERMS 0
05294 #endif  /* ACE_WIN32 */
05295 
05296   /// The O_APPEND flag is only partly supported on Win32. If you specify
05297   /// O_APPEND, then the file pointer will be positioned at the end of
05298   /// the file initially during open, but it is not re-positioned at
05299   /// the end prior to each write, as specified by POSIX.  This
05300   /// is generally good enough for typical situations, but it is ``not
05301   /// quite right'' in its semantics.
05302   static ACE_HANDLE open (const char *filename,
05303                           int mode,
05304                           int perms = ACE_DEFAULT_OPEN_PERMS,
05305                           LPSECURITY_ATTRIBUTES sa = 0);
05306 #if defined (ACE_HAS_WCHAR)
05307   static ACE_HANDLE open (const wchar_t *filename,
05308                           int mode,
05309                           int perms = ACE_DEFAULT_OPEN_PERMS,
05310                           LPSECURITY_ATTRIBUTES sa = 0);
05311 #endif /* ACE_HAS_WCHAR */
05312   static int putmsg (ACE_HANDLE handle,
05313                      const struct strbuf *ctl,
05314                      const struct strbuf *data,
05315                      int flags);
05316   static int putpmsg (ACE_HANDLE handle,
05317                       const struct strbuf *ctl,
05318                       const struct strbuf *data,
05319                       int band,
05320                       int flags);
05321   static ssize_t read (ACE_HANDLE handle,
05322                        void *buf,
05323                        size_t len);
05324   static ssize_t read (ACE_HANDLE handle,
05325                        void *buf,
05326                        size_t len,
05327                        ACE_OVERLAPPED *);
05328   /**
05329    * Receive <len> bytes into <buf> from <handle> (uses the
05330    * <ACE_OS::read> call, which uses the <read> system call on UNIX
05331    * and the <ReadFile> call on Win32). If errors occur, -1 is
05332    * returned.  If EOF occurs, 0 is returned.  Whatever data has been
05333    * transmitted will be returned to the caller through
05334    * <bytes_transferred>.
05335    */
05336   static ssize_t read_n (ACE_HANDLE handle,
05337                          void *buf,
05338                          size_t len,
05339                          size_t *bytes_transferred = 0);
05340 
05341   static int readlink (const char *path,
05342                        char *buf,
05343                        size_t bufsiz);
05344   static ssize_t pread (ACE_HANDLE handle,
05345                         void *buf,
05346                         size_t nbyte,
05347                         off_t offset);
05348   static int recvmsg (ACE_HANDLE handle,
05349                       struct msghdr *msg,
05350                       int flags);
05351   static int sendmsg (ACE_HANDLE handle,
05352                       const struct msghdr *msg,
05353                       int flags);
05354   static ssize_t write (ACE_HANDLE handle,
05355                         const void *buf,
05356                         size_t nbyte);
05357   static ssize_t write (ACE_HANDLE handle,
05358                         const void *buf,
05359                         size_t nbyte,
05360                         ACE_OVERLAPPED *);
05361 
05362   /**
05363    * Send <len> bytes from <buf> to <handle> (uses the <ACE_OS::write>
05364    * calls, which is uses the <write> system call on UNIX and the
05365    * <WriteFile> call on Win32).  If errors occur, -1 is returned.  If
05366    * EOF occurs, 0 is returned.  Whatever data has been transmitted
05367    * will be returned to the caller through <bytes_transferred>.
05368    */
05369   static ssize_t write_n (ACE_HANDLE handle,
05370                           const void *buf,
05371                           size_t len,
05372                           size_t *bytes_transferred = 0);
05373 
05374   static ssize_t pwrite (ACE_HANDLE handle,
05375                          const void *buf,
05376                          size_t nbyte,
05377                          off_t offset);
05378   static ssize_t readv (ACE_HANDLE handle,
05379                         iovec *iov,
05380                         int iovlen);
05381   static ssize_t writev (ACE_HANDLE handle,
05382                          const iovec *iov,
05383                          int iovcnt);
05384   static ssize_t recvv (ACE_HANDLE handle,
05385                         iovec *iov,
05386                         int iovlen);
05387   static ssize_t sendv (ACE_HANDLE handle,
05388                         const iovec *iov,
05389                         int iovcnt);
05390   //@}
05391 
05392   //@{ @name A set of wrappers for event demultiplexing and IPC.
05393   static int select (int width,
05394                      fd_set *rfds,
05395                      fd_set *wfds = 0,
05396                      fd_set *efds = 0,
05397                      const ACE_Time_Value *tv = 0);
05398   static int select (int width,
05399                      fd_set *rfds,
05400                      fd_set *wfds,
05401                      fd_set *efds,
05402                      const ACE_Time_Value &tv);
05403   static int poll (struct pollfd *pollfds,
05404                    u_long len,
05405                    const ACE_Time_Value *tv = 0);
05406   static int poll (struct pollfd *pollfds,
05407                    u_long len,
05408                    const ACE_Time_Value &tv);
05409   static int pipe (ACE_HANDLE handles[]);
05410 
05411   static ACE_HANDLE shm_open (const ACE_TCHAR *filename,
05412                               int mode,
05413                               int perms = 0,
05414                               LPSECURITY_ATTRIBUTES sa = 0);
05415   static int shm_unlink (const ACE_TCHAR *path);
05416   //@}
05417 
05418   //@{ @name A set of wrappers for directory operations.
05419   static mode_t umask (mode_t cmask);
05420 
05421 #if !defined (ACE_LACKS_CHDIR)
05422   static int chdir (const char *path);
05423 
05424 #if defined (ACE_HAS_WCHAR)
05425   static int chdir (const wchar_t *path);
05426 #endif /* ACE_HAS_WCHAR */
05427 #endif /* ACE_LACKS_CHDIR */
05428 
05429   static int mkdir (const ACE_TCHAR *path,
05430                     mode_t mode = ACE_DEFAULT_DIR_PERMS);
05431   static int mkfifo (const ACE_TCHAR *file,
05432                      mode_t mode = ACE_DEFAULT_FILE_PERMS);
05433   static ACE_TCHAR *mktemp (ACE_TCHAR *t);
05434   static ACE_HANDLE mkstemp (ACE_TCHAR *t);
05435   static ACE_TCHAR *getcwd (ACE_TCHAR *, size_t);
05436   static int rename (const ACE_TCHAR *old_name,
05437                      const ACE_TCHAR *new_name,
05438                      int flags = -1);
05439   static int unlink (const ACE_TCHAR *path);
05440   static ACE_TCHAR *tempnam (const ACE_TCHAR *dir = 0,
05441                              const ACE_TCHAR *pfx = 0);
05442   //@}
05443 
05444   //@{ @name A set of wrappers for random number operations.
05445   static int rand (void);
05446   static int rand_r (ACE_RANDR_TYPE &seed);
05447   static void srand (u_int seed);
05448   //@}
05449 
05450   //@{ @name A set of wrappers for readers/writer locks.
05451   static int rwlock_init (ACE_rwlock_t *rw,
05452                           int type = ACE_DEFAULT_SYNCH_TYPE,
05453                           const ACE_TCHAR *name = 0,
05454                           void *arg = 0);
05455   static int rwlock_destroy (ACE_rwlock_t *rw);
05456   static int rw_rdlock (ACE_rwlock_t *rw);
05457   static int rw_wrlock (ACE_rwlock_t *rw);
05458   static int rw_tryrdlock (ACE_rwlock_t *rw);
05459   static int rw_trywrlock (ACE_rwlock_t *rw);
05460   static int rw_trywrlock_upgrade (ACE_rwlock_t *rw);
05461   static int rw_unlock (ACE_rwlock_t *rw);
05462   //@}
05463 
05464   //@{ @name A set of wrappers for auto-reset and manual events.
05465   static int event_init (ACE_event_t *event,
05466                          int manual_reset = 0,
05467                          int initial_state = 0,
05468                          int type = ACE_DEFAULT_SYNCH_TYPE,
05469                          const char *name = 0,
05470                          void *arg = 0,
05471                          LPSECURITY_ATTRIBUTES sa = 0);
05472 # if defined (ACE_HAS_WCHAR)
05473   static int event_init (ACE_event_t *event,
05474                          int manual_reset,
05475                          int initial_state,
05476                          int type,
05477                          const wchar_t *name,
05478                          void *arg = 0,
05479                          LPSECURITY_ATTRIBUTES sa = 0);
05480 # endif /* ACE_HAS_WCHAR */
05481   static int event_destroy (ACE_event_t *event);
05482   static int event_wait (ACE_event_t *event);
05483   static int event_timedwait (ACE_event_t *event,
05484                               ACE_Time_Value *timeout,
05485                               int use_absolute_time = 1);
05486   static int event_signal (ACE_event_t *event);
05487   static int event_pulse (ACE_event_t *event);
05488   static int event_reset (ACE_event_t *event);
05489   //@}
05490 
05491   //@{ @name A set of wrappers for semaphores.
05492   static int sema_destroy (ACE_sema_t *s);
05493   static int sema_init (ACE_sema_t *s,
05494                         u_int count,
05495                         int type = ACE_DEFAULT_SYNCH_TYPE,
05496                         const char *name = 0,
05497                         void *arg = 0,
05498                         int max = 0x7fffffff,
05499                         LPSECURITY_ATTRIBUTES sa = 0);
05500 # if defined (ACE_HAS_WCHAR)
05501   static int sema_init (ACE_sema_t *s,
05502                         u_int count,
05503                         int type,
05504                         const wchar_t *name,
05505                         void *arg = 0,
05506                         int max = 0x7fffffff,
05507                         LPSECURITY_ATTRIBUTES sa = 0);
05508 # endif /* ACE_HAS_WCHAR */
05509   static int sema_post (ACE_sema_t *s);
05510   static int sema_post (ACE_sema_t *s,
05511                         u_int release_count);
05512   static int sema_trywait (ACE_sema_t *s);
05513   static int sema_wait (ACE_sema_t *s);
05514   static int sema_wait (ACE_sema_t *s,
05515                         ACE_Time_Value &tv);
05516   static int sema_wait (ACE_sema_t *s,
05517                         ACE_Time_Value *tv);
05518   //@}
05519 
05520   //@{ @name A set of wrappers for System V semaphores.
05521   static int semctl (int int_id,
05522                      int semnum,
05523                      int cmd,
05524                      semun);
05525   static int semget (key_t key,
05526                      int nsems,
05527                      int flags);
05528   static int semop (int int_id,
05529                     struct sembuf *sops,
05530                     size_t nsops);
05531   //@}
05532 
05533   //@{ @name Thread scheduler interface.
05534   /// Set scheduling parameters.  An id of ACE_SELF indicates, e.g.,
05535   /// set the parameters on the calling thread.
05536   static int sched_params (const ACE_Sched_Params &, ACE_id_t id = ACE_SELF);
05537   //@}
05538 
05539   //@{ @name A set of wrappers for System V shared memory.
05540   static void *shmat (int int_id,
05541                       void *shmaddr,
05542                       int shmflg);
05543   static int shmctl (int int_id,
05544                      int cmd,
05545                      struct shmid_ds *buf);
05546   static int shmdt (void *shmaddr);
05547   static int shmget (key_t key,
05548                      int size,
05549                      int flags);
05550   ///@}
05551 
05552   //@{ @name A set of wrappers for Signals.
05553   static int kill (pid_t pid,
05554                    int signum);
05555   static int sigaction (int signum,
05556                         const struct sigaction *nsa,
05557                         struct sigaction *osa);
05558   static int sigaddset (sigset_t *s,
05559                         int signum);
05560   static int sigdelset (sigset_t *s,
05561                         int signum);
05562   static int sigemptyset (sigset_t *s);
05563   static int sigfillset (sigset_t *s);
05564   static int sigismember (sigset_t *s,
05565                           int signum);
05566   static ACE_SignalHandler signal (int signum,
05567                                    ACE_SignalHandler);
05568   static int sigsuspend (const sigset_t *set);
05569   static int sigprocmask (int how,
05570                           const sigset_t *nsp,
05571                           sigset_t *osp);
05572 
05573   static int pthread_sigmask (int how,
05574                               const sigset_t *nsp,
05575                               sigset_t *osp);
05576   //@}
05577 
05578   //@{ @name A set of wrappers for sockets.
05579   /// BSD-style <accept> (no QoS).
05580   static ACE_HANDLE accept (ACE_HANDLE handle,
05581                             struct sockaddr *addr,
05582                             int *addrlen);
05583 
05584 #if !defined (ACE_HAS_WINCE)
05585   /**
05586    * QoS-enabled <accept>, which passes <qos_params> to <accept>.  If
05587    * the OS platform doesn't support QoS-enabled <accept> then the
05588    * <qos_params> are ignored and the BSD-style <accept> is called.
05589    */
05590   static ACE_HANDLE accept (ACE_HANDLE handle,
05591                             struct sockaddr *addr,
05592                             int *addrlen,
05593                             const ACE_Accept_QoS_Params &qos_params);
05594 #endif  // ACE_HAS_WINCE
05595 
05596   /// BSD-style <connect> (no QoS).
05597   static int connect (ACE_HANDLE handle,
05598                       struct sockaddr *addr,
05599                       int addrlen);
05600 
05601 #if !defined (ACE_HAS_WINCE)
05602   /**
05603    * QoS-enabled <connect>, which passes <qos_params> to <connect>.
05604    * If the OS platform doesn't support QoS-enabled <connect> then the
05605    * <qos_params> are ignored and the BSD-style <connect> is called.
05606    */
05607   static int connect (ACE_HANDLE handle,
05608                       const sockaddr *addr,
05609                       int addrlen,
05610                       const ACE_QoS_Params &qos_params);
05611 #endif  // ACE_HAS_WINCE
05612 
05613   static int bind (ACE_HANDLE s,
05614                    struct sockaddr *name,
05615                    int namelen);
05616 
05617   static int closesocket (ACE_HANDLE s);
05618   static struct hostent *gethostbyaddr (const char *addr,
05619                                         int length,
05620                                         int type);
05621   static struct hostent *gethostbyname (const char *name);
05622   static struct hostent *getipnodebyname (const char *name, int family,
05623                                           int flags = 0);
05624   static struct hostent *getipnodebyaddr (const void *src, size_t len,
05625                                           int family);
05626   static struct hostent *gethostbyaddr_r (const char *addr,
05627                                           int length,
05628                                           int type,
05629                                           struct hostent *result,
05630                                           ACE_HOSTENT_DATA buffer,
05631                                           int *h_errnop);
05632   static struct hostent *gethostbyname_r (const char *name,
05633                                           struct hostent *result,
05634                                           ACE_HOSTENT_DATA buffer,
05635                                           int *h_errnop);
05636   static int getpeername (ACE_HANDLE handle,
05637                           struct sockaddr *addr,
05638                           int *addrlen);
05639   static struct protoent *getprotobyname (const char *name);
05640   static struct protoent *getprotobyname_r (const char *name,
05641                                             struct protoent *result,
05642                                             ACE_PROTOENT_DATA buffer);
05643   static struct protoent *getprotobynumber (int proto);
05644   static struct protoent *getprotobynumber_r (int proto,
05645                                               struct protoent *result,
05646                                               ACE_PROTOENT_DATA buffer);
05647   static struct servent *getservbyname (const char *svc,
05648                                         const char *proto);
05649   static struct servent *getservbyname_r (const char *svc,
05650                                           const char *proto,
05651                                           struct servent *result,
05652                                           ACE_SERVENT_DATA buf);
05653   static int getsockname (ACE_HANDLE handle,
05654                           struct sockaddr *addr,
05655                           int *addrlen);
05656   static int getsockopt (ACE_HANDLE handle,
05657                          int level,
05658                          int optname,
05659                          char *optval,
05660                          int *optlen);
05661   static unsigned long inet_addr (const char *name);
05662   static char *inet_ntoa (const struct in_addr addr);
05663   static int inet_aton (const char *strptr,
05664                         struct in_addr *addr);
05665   static const char *inet_ntop (int family,
05666                                 const void *addrptr,
05667                                 char *strptr,
05668                                  size_t len);
05669   static int inet_pton (int family,
05670                         const char *strptr,
05671                         void *addrptr);
05672   /// Retrieve information about available transport protocols
05673   /// installed on the local machine.
05674   static int enum_protocols (int *protocols,
05675                              ACE_Protocol_Info *protocol_buffer,
05676                              u_long *buffer_length);
05677 
05678 #if !defined (ACE_HAS_WINCE)
05679   /// Joins a leaf node into a QoS-enabled multi-point session.
05680   static ACE_HANDLE join_leaf (ACE_HANDLE socket,
05681                                const sockaddr *name,
05682                                int namelen,
05683                                const ACE_QoS_Params &qos_params);
05684 #endif  // ACE_HAS_WINCE
05685 
05686   static int listen (ACE_HANDLE handle,
05687                      int backlog);
05688   static int recv (ACE_HANDLE handle,
05689                    char *buf,
05690                    size_t len,
05691                    int flags = 0);
05692   static int recvfrom (ACE_HANDLE handle,
05693                        char *buf,
05694                        size_t len,
05695                        int flags,
05696                        struct sockaddr *addr,
05697                        int *addrlen);
05698   static int recvfrom (ACE_HANDLE handle,
05699                        iovec *buffers,
05700                        int buffer_count,
05701                        size_t &number_of_bytes_recvd,
05702                        int &flags,
05703                        struct sockaddr *addr,
05704                        int *addrlen,
05705                        ACE_OVERLAPPED *overlapped,
05706                        ACE_OVERLAPPED_COMPLETION_FUNC func);
05707   static int send (ACE_HANDLE handle,
05708                    const char *buf,
05709                    size_t len,
05710                    int flags = 0);
05711   static int sendto (ACE_HANDLE handle,
05712                      const char *buf,
05713                      size_t len,
05714                      int flags,
05715                      const struct sockaddr *addr,
05716                      int addrlen);
05717   static int sendto (ACE_HANDLE handle,
05718                      const iovec *buffers,
05719                      int buffer_count,
05720                      size_t &number_of_bytes_sent,
05721                      int flags,
05722                      const struct sockaddr *addr,
05723                      int addrlen,
05724                      ACE_OVERLAPPED *overlapped,
05725                      ACE_OVERLAPPED_COMPLETION_FUNC func);
05726 
05727   /// Manipulate the options associated with a socket.
05728   static int setsockopt (ACE_HANDLE handle,
05729                          int level,
05730                          int optname,
05731                          const char *optval,
05732                          int optlen);
05733   static int shutdown (ACE_HANDLE handle,
05734                        int how);
05735 
05736   /// Create a BSD-style socket (no QoS).
05737   static ACE_HANDLE socket (int protocol_family,
05738                             int type,
05739                             int proto);
05740 
05741   /// Create a QoS-enabled socket.  If the OS platform doesn't support
05742   /// QoS-enabled <socket> then the BSD-style <socket> is called.
05743   static ACE_HANDLE socket (int protocol_family,
05744                             int type,
05745                             int proto,
05746                             ACE_Protocol_Info *protocolinfo,
05747                             ACE_SOCK_GROUP g,
05748                             u_long flags);
05749 
05750   static int socketpair (int domain,
05751                          int type,
05752                          int protocol,
05753                          ACE_HANDLE sv[2]);
05754 
05755   /// Initialize WinSock before first use (e.g., when a DLL is first
05756   /// loaded or the first use of a socket() call.
05757   static int socket_init (int version_high = 1,
05758                           int version_low = 1);
05759 
05760   /// Finalize WinSock after last use (e.g., when a DLL is unloaded).
05761   static int socket_fini (void);
05762   //@}
05763 
05764   //@{ @name A set of wrappers for password routines.
05765   static void setpwent (void);
05766   static void endpwent (void);
05767   static struct passwd *getpwent (void);
05768   static struct passwd *getpwnam (const char *user);
05769   static struct passwd *getpwnam_r (const char *name,
05770                                     struct passwd *pwent,
05771                                     char *buffer,
05772                                     int buflen);
05773   //@}
05774 
05775   //@{ @name A set of wrappers for regular expressions.
05776   static char *compile (const char *instring,
05777                         char *expbuf,
05778                         char *endbuf);
05779   static int step (const char *str,
05780                    char *expbuf);
05781   //@}
05782 
05783   //@{ @name Wide-character strings
05784   // @@ UNICODE: (brunsch) Can this be handled better?
05785   // The following WChar typedef and functions are used by TAO.  TAO
05786   // does not use wchar_t because the size of wchar_t is
05787   // platform-dependent. These are to be used for all
05788   // manipulate\ions of CORBA::WString.
05789   // @@ (othman) IMHO, it is the lesser of two evils to use the
05790   //    correct type for the platform rather than (forcibly) assume
05791   //    that all wide characters are 16 bits.
05792 #if defined (ACE_HAS_WCHAR) || defined (ACE_HAS_XPG4_MULTIBYTE_CHAR)
05793   typedef wchar_t WChar;
05794 #else
05795   typedef ACE_UINT16 WChar;
05796 #endif
05797   static u_int wslen (const WChar *);
05798   static WChar *wscpy (WChar *,
05799                        const WChar *);
05800   static int wscmp (const WChar *,
05801                     const WChar *);
05802   static int wsncmp (const WChar *,
05803                      const WChar *,
05804                      size_t len);
05805   //@}
05806 
05807 # if 0
05808   //@{ @name A set of wrappers for threads (these are portable since they use the ACE_Thread_ID).
05809   static int thr_continue (const ACE_Thread_ID &thread);
05810   static int thr_create (ACE_THR_FUNC,
05811                          void *args,
05812                          long flags,
05813                          ACE_Thread_ID *,
05814                          long priority = ACE_DEFAULT_THREAD_PRIORITY,
05815                          void *stack = 0,
05816                          size_t stacksize = 0);
05817   static int thr_getprio (ACE_Thread_ID thr_id,
05818                           int &prio,
05819                           int *policy = 0);
05820   static int thr_join (ACE_Thread_ID waiter_id,
05821                        ACE_THR_FUNC_RETURN *status);
05822   static int thr_kill (ACE_Thread_ID thr_id,
05823                        int signum);
05824   static ACE_Thread_ID thr_self (void);
05825   static int thr_setprio (ACE_Thread_ID thr_id,
05826                           int prio);
05827   static int thr_setprio (const ACE_Sched_Priority prio);
05828   static int thr_suspend (ACE_Thread_ID target_thread);
05829   static int thr_cancel (ACE_Thread_ID t_id);
05830   //@}
05831 # endif /* 0 */
05832 
05833   //@{ @name A set of wrappers for threads
05834 
05835   // These are non-portable since they use ACE_thread_t and
05836   // ACE_hthread_t and will go away in a future release.
05837   static int thr_continue (ACE_hthread_t target_thread);
05838 
05839   /*
05840    * Creates a new thread having <flags> attributes and running <func>
05841    * with <args> (if <thread_adapter> is non-0 then <func> and <args>
05842    * are ignored and are obtained from <thread_adapter>).  <thr_id>
05843    * and <t_handle> are set to the thread's ID and handle (?),
05844    * respectively.  The thread runs at <priority> priority (see
05845    * below).
05846    *
05847    * The <flags> are a bitwise-OR of the following:
05848    * = BEGIN<INDENT>
05849    * THR_CANCEL_DISABLE, THR_CANCEL_ENABLE, THR_CANCEL_DEFERRED,
05850    * THR_CANCEL_ASYNCHRONOUS, THR_BOUND, THR_NEW_LWP, THR_DETACHED,
05851    * THR_SUSPENDED, THR_DAEMON, THR_JOINABLE, THR_SCHED_FIFO,
05852    * THR_SCHED_RR, THR_SCHED_DEFAULT, THR_EXPLICIT_SCHED,
05853    * THR_SCOPE_SYSTEM, THR_SCOPE_PROCESS
05854    * = END<INDENT>
05855    *
05856    * By default, or if <priority> is set to
05857    * ACE_DEFAULT_THREAD_PRIORITY, an "appropriate" priority value for
05858    * the given scheduling policy (specified in <flags}>, e.g.,
05859    * <THR_SCHED_DEFAULT>) is used.  This value is calculated
05860    * dynamically, and is the median value between the minimum and
05861    * maximum priority values for the given policy.  If an explicit
05862    * value is given, it is used.  Note that actual priority values are
05863    * EXTREMEMLY implementation-dependent, and are probably best
05864    * avoided.
05865    *
05866    * Note that <thread_adapter> is always deleted by <thr_create>,
05867    * therefore it must be allocated with global operator new.
05868    */
05869   static int thr_create (ACE_THR_FUNC func,
05870                          void *args,
05871                          long flags,
05872                          ACE_thread_t *thr_id,
05873                          ACE_hthread_t *t_handle = 0,
05874                          long priority = ACE_DEFAULT_THREAD_PRIORITY,
05875                          void *stack = 0,
05876                          size_t stacksize = 0,
05877                          ACE_Base_Thread_Adapter *thread_adapter = 0);
05878 
05879   static int thr_join (ACE_hthread_t waiter_id,
05880                        ACE_THR_FUNC_RETURN *status);
05881   static int thr_join (ACE_thread_t waiter_id,
05882                        ACE_thread_t *thr_id,
05883                        ACE_THR_FUNC_RETURN *status);
05884   static int thr_kill (ACE_thread_t thr_id,
05885                        int signum);
05886   static ACE_thread_t thr_self (void);
05887   static void thr_self (ACE_hthread_t &);
05888   static int thr_getprio (ACE_hthread_t id,
05889                           int &priority);
05890   static int thr_getprio (ACE_hthread_t id,
05891                           int &priority,
05892                           int &policy);
05893   static int thr_setprio (ACE_hthread_t id,
05894                           int priority,
05895                           int policy = -1);
05896   static int thr_setprio (const ACE_Sched_Priority prio);
05897   static int thr_suspend (ACE_hthread_t target_thread);
05898   static int thr_cancel (ACE_thread_t t_id);
05899 
05900   static int thr_cmp (ACE_hthread_t t1,
05901                       ACE_hthread_t t2);
05902   static int thr_equal (ACE_thread_t t1,
05903                         ACE_thread_t t2);
05904   static void thr_exit (ACE_THR_FUNC_RETURN status = 0);
05905   static int thr_getconcurrency (void);
05906   static int lwp_getparams (ACE_Sched_Params &);
05907 # if defined (ACE_HAS_TSS_EMULATION) && defined (ACE_HAS_THREAD_SPECIFIC_STORAGE)
05908   static int thr_getspecific (ACE_OS_thread_key_t key,
05909                               void **data);
05910 # endif /* ACE_HAS_TSS_EMULATION && ACE_HAS_THREAD_SPECIFIC_STORAGE */
05911   static int thr_getspecific (ACE_thread_key_t key,
05912                               void **data);
05913   static int thr_keyfree (ACE_thread_key_t key);
05914   static int thr_key_detach (void *inst);
05915 # if defined (ACE_HAS_THR_C_DEST)
05916 #   if defined (ACE_HAS_TSS_EMULATION) && defined (ACE_HAS_THREAD_SPECIFIC_STORAGE)
05917   static int thr_keycreate (ACE_OS_thread_key_t *key,
05918                             ACE_THR_C_DEST,
05919                             void *inst = 0);
05920 #   endif /* ACE_HAS_TSS_EMULATION && ACE_HAS_THREAD_SPECIFIC_STORAGE */
05921   static int thr_keycreate (ACE_thread_key_t *key,
05922                             ACE_THR_C_DEST,
05923                             void *inst = 0);
05924 # else
05925 #   if defined (ACE_HAS_TSS_EMULATION) && defined (ACE_HAS_THREAD_SPECIFIC_STORAGE)
05926   static int thr_keycreate (ACE_OS_thread_key_t *key,
05927                             ACE_THR_DEST,
05928                             void *inst = 0);
05929 #   endif /* ACE_HAS_TSS_EMULATION && ACE_HAS_THREAD_SPECIFIC_STORAGE */
05930   static int thr_keycreate (ACE_thread_key_t *key,
05931                             ACE_THR_DEST,
05932                             void *inst = 0);
05933 # endif /* ACE_HAS_THR_C_DEST */
05934   static int thr_key_used (ACE_thread_key_t key);
05935   static size_t thr_min_stack (void);
05936   static int thr_setconcurrency (int hint);
05937   static int lwp_setparams (const ACE_Sched_Params &);
05938 # if defined (ACE_HAS_TSS_EMULATION) && defined (ACE_HAS_THREAD_SPECIFIC_STORAGE)
05939   static int thr_setspecific (ACE_OS_thread_key_t key,
05940                               void *data);
05941 # endif /* ACE_HAS_TSS_EMULATION && ACE_HAS_THREAD_SPECIFIC_STORAGE */
05942   static int thr_setspecific (ACE_thread_key_t key,
05943                               void *data);
05944   static int thr_sigsetmask (int how,
05945                              const sigset_t *nsm,
05946                              sigset_t *osm);
05947   static int thr_setcancelstate (int new_state,
05948                                  int *old_state);
05949   static int thr_setcanceltype (int new_type,
05950                                 int *old_type);
05951   static int sigwait (sigset_t *set,
05952                       int *sig = 0);
05953   static int sigtimedwait (const sigset_t *set,
05954                            siginfo_t *info,
05955                            const ACE_Time_Value *timeout);
05956   static int sigwaitinfo (const sigset_t *set,
05957                           siginfo_t *info);
05958   static void thr_testcancel (void);
05959   static void thr_yield (void);
05960 
05961   /**
05962    * This method uses process id and object pointer to come up with a
05963    * machine wide unique name.  The process ID will provide uniqueness
05964    * between processes on the same machine. The "this" pointer of the
05965    * <object> will provide uniqueness between other "live" objects in
05966    * the same process. The uniqueness of this name is therefore only
05967    * valid for the life of <object>.
05968    */
05969   static void unique_name (const void *object,
05970                            ACE_TCHAR *name,
05971                            size_t length);
05972 
05973   /// This is necessary to deal with POSIX pthreads and their use of
05974   /// structures for thread ids.
05975   static ACE_thread_t NULL_thread;
05976 
05977   /// This is necessary to deal with POSIX pthreads and their use of
05978   /// structures for thread handles.
05979   static ACE_hthread_t NULL_hthread;
05980 
05981   /// This is necessary to deal with POSIX pthreads and their use of
05982   /// structures for TSS keys.
05983   static ACE_thread_key_t NULL_key;
05984 
05985 # if defined (CHORUS)
05986   /// This is used to map an actor's id into a KnCap for killing and
05987   /// waiting actors.
05988   static KnCap actorcaps_[ACE_CHORUS_MAX_ACTORS];
05989 # endif /* CHORUS */
05990   //@}
05991 
05992 # if defined (ACE_WIN32)
05993   /// Keeps track of whether we've already initialized WinSock...
05994   static int socket_initialized_;
05995 # endif /* ACE_WIN32 */
05996 
05997   /// Handle asynchronous thread cancellation cleanup.
05998   static void mutex_lock_cleanup (void *mutex);
05999 
06000   /**
06001    * Call TSS destructors for the current thread.  If the current
06002    * thread is the main thread, then the argument must be 1.
06003    * For private use of ACE_Object_Manager and ACE_Thread_Adapter only.
06004    */
06005   static void cleanup_tss (const u_int main_thread);
06006 
06007 # if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) && defined (ACE_LACKS_NETDB_REENTRANT_FUNCTIONS)
06008   static int netdb_acquire (void);
06009   static int netdb_release (void);
06010 # endif /* defined (ACE_MT_SAFE) && ACE_LACKS_NETDB_REENTRANT_FUNCTIONS */
06011 
06012   /// Find the schedling class ID that corresponds to the class name.
06013   static int scheduling_class (const char *class_name, ACE_id_t &);
06014 
06015   /// Friendly interface to <priocntl>(2).
06016   static int set_scheduling_params (const ACE_Sched_Params &,
06017                                     ACE_id_t id = ACE_SELF);
06018 
06019   /// Low-level interface to <priocntl>(2).
06020   /**
06021    * Can't call the following priocntl, because that's a macro on
06022    * Solaris.
06023    */
06024   static int priority_control (ACE_idtype_t, ACE_id_t, int, void *);
06025 
06026 #if defined (ACE_HAS_STRPTIME)
06027   static char *strptime (char *buf,
06028                          const char *format,
06029                          struct tm *tm);
06030 
06031 # if defined (ACE_LACKS_NATIVE_STRPTIME)
06032   static int strptime_getnum (char *buf, int *num, int *bi,
06033                               int *fi, int min, int max);
06034 # endif /* ACE_LACKS_NATIVE_STRPTIME */
06035 #endif /* ACE_HAS_STRPTIME */
06036 
06037   /// Get the number of CPUs configured in the machine.
06038   static long num_processors (void);
06039 
06040   /// Get the number of CPUs currently online.
06041   static long num_processors_online (void);
06042 
06043 private:
06044 
06045 #if defined (ACE_LACKS_WRITEV)
06046   static int writev_emulation (ACE_HANDLE handle,
06047                                ACE_WRITEV_TYPE *iov,
06048                                int iovcnt);
06049 #endif /* ACE_LACKS_WRITEV */
06050 
06051 #if defined (ACE_LACKS_READV)
06052   static ssize_t readv_emulation (ACE_HANDLE handle,
06053                                   ACE_READV_TYPE *iov,
06054                                   int iovcnt);
06055 #endif /* ACE_LACKS_READV */
06056 
06057   /// Function that is called by <ACE_OS::exit>, if non-null.
06058   static ACE_EXIT_HOOK exit_hook_;
06059 
06060   /// For use by ACE_Object_Manager only, to register its exit hook..
06061   static ACE_EXIT_HOOK set_exit_hook (ACE_EXIT_HOOK hook);
06062 
06063   /// Allow the ACE_OS_Object_Manager to call set_exit_hook.
06064   friend class ACE_OS_Object_Manager;
06065 
06066 # if defined (ACE_WIN32)
06067 #   if defined (ACE_HAS_WINCE)
06068   /// Supporting data for ctime and ctime_r functions on WinCE.
06069   static const wchar_t *day_of_week_name[7];
06070   static const wchar_t *month_name[12];
06071 #   endif /* ACE_HAS_WINCE */
06072 
06073   /// Translate fopen's mode char to open's mode.  This helper function
06074   /// is here to avoid maintaining several pieces of identical code.
06075   static void fopen_mode_to_open_mode_converter (ACE_TCHAR x, int &hmode);
06076 
06077   static OSVERSIONINFO win32_versioninfo_;
06078 
06079   static HINSTANCE win32_resource_module_;
06080 
06081 # endif /* ACE_WIN32 */
06082 
06083 #if defined (ACE_HAS_VIRTUAL_TIME)
06084   static clock_t times (struct tms *buf);
06085 #endif /* ACE_HAS_VIRTUAL_TIME */
06086 
06087   //changed for ACE_HAS_VIRTUAL_TIME changes.
06088 
06089   static int cond_timedwait_i (ACE_cond_t *cv,
06090                        ACE_mutex_t *m,
06091                        ACE_Time_Value *);
06092 
06093   static u_int alarm_i (u_int secs);
06094 
06095   static u_int ualarm_i (u_int usecs, u_int interval = 0);
06096 
06097   static u_int ualarm_i (const ACE_Time_Value &tv,
06098                          const ACE_Time_Value &tv_interval = ACE_Time_Value::zero);
06099 
06100   static int sleep_i (u_int seconds);
06101 
06102   static int sleep_i (const ACE_Time_Value &tv);
06103 
06104   static int nanosleep_i (const struct timespec *requested,
06105                           struct timespec *remaining = 0);
06106 
06107   static int select_i (int width,
06108                        fd_set *rfds,
06109                        fd_set *wfds,
06110                        fd_set *efds,
06111                        const ACE_Time_Value *tv = 0);
06112 
06113   static int select_i (int width,
06114                        fd_set *rfds,
06115                        fd_set *wfds,
06116                        fd_set *efds,
06117                        const ACE_Time_Value &tv);
06118 
06119   static int poll_i (struct pollfd *pollfds,
06120                      u_long len,
06121                      const ACE_Time_Value *tv = 0);
06122 
06123   static int poll_i (struct pollfd *pollfds,
06124                      u_long len,
06125                      const ACE_Time_Value &tv);
06126 
06127   static int sema_wait_i (ACE_sema_t *s);
06128 
06129   static int sema_wait_i (ACE_sema_t *s,
06130                           ACE_Time_Value &tv);
06131 
06132   static int sigtimedwait_i (const sigset_t *set,
06133                              siginfo_t *info,
06134                              const ACE_Time_Value *timeout);
06135 
06136   static ACE_Time_Value gettimeofday_i (void);
06137 };
06138 
06139 /**
06140  * @class ACE_Object_Manager_Base
06141  *
06142  * @brief Base class for ACE_Object_Manager(s).
06143  *
06144  * Encapsulates the most useful ACE_Object_Manager data structures.
06145  */
06146 class ACE_OS_Export ACE_Object_Manager_Base
06147 {
06148 # if (defined (ACE_PSOS) && defined (__DIAB))  || \
06149      (defined (__DECCXX_VER) && __DECCXX_VER < 60000000)
06150   // The Diab compiler got confused and complained about access rights
06151   // if this section was protected (changing this to public makes it happy).
06152   // Similarly, DEC CXX 5.6 needs the methods to be public.
06153 public:
06154 # else  /* ! (ACE_PSOS && __DIAB)  ||  ! __DECCXX_VER < 60000000 */
06155 protected:
06156 # endif /* ! (ACE_PSOS && __DIAB)  ||  ! __DECCXX_VER < 60000000 */
06157   /// Default constructor.
06158   ACE_Object_Manager_Base (void);
06159 
06160   /// Destructor.
06161   virtual ~ACE_Object_Manager_Base (void);
06162 
06163 public:
06164   /**
06165    * Explicitly initialize.  Returns 0 on success, -1 on failure due
06166    * to dynamic allocation failure (in which case errno is set to
06167    * ENOMEM), or 1 if it had already been called.
06168    */
06169   virtual int init (void) = 0;
06170 
06171   /**
06172    * Explicitly destroy.  Returns 0 on success, -1 on failure because
06173    * the number of fini () calls hasn't reached the number of init ()
06174    * calls, or 1 if it had already been called.
06175    */
06176   virtual int fini (void) = 0;
06177 
06178   enum Object_Manager_State
06179     {
06180       OBJ_MAN_UNINITIALIZED = 0,
06181       OBJ_MAN_INITIALIZING,
06182       OBJ_MAN_INITIALIZED,
06183       OBJ_MAN_SHUTTING_DOWN,
06184       OBJ_MAN_SHUT_DOWN
06185     };
06186 
06187 protected:
06188   /**
06189    * Returns 1 before ACE_Object_Manager_Base has been constructed.
06190    * This flag can be used to determine if the program is constructing
06191    * static objects.  If no static object spawns any threads, the
06192    * program will be single-threaded when this flag returns 1.  (Note
06193    * that the program still might construct some static objects when
06194    * this flag returns 0, if ACE_HAS_NONSTATIC_OBJECT_MANAGER is not
06195    * defined.)
06196    */
06197   int starting_up_i (void);
06198 
06199   /**
06200    * Returns 1 after ACE_Object_Manager_Base has been destroyed.  This
06201    * flag can be used to determine if the program is in the midst of
06202    * destroying static objects.  (Note that the program might destroy
06203    * some static objects before this flag can return 1, if
06204    * ACE_HAS_NONSTATIC_OBJECT_MANAGER is not defined.)
06205    */
06206   int shutting_down_i (void);
06207 
06208   /// State of the Object_Manager;
06209   Object_Manager_State object_manager_state_;
06210 
06211   /**
06212    * Flag indicating whether the ACE_Object_Manager was dynamically
06213    * allocated by ACE.  (If is was dynamically allocated by the
06214    * application, then the application is responsible for destroying
06215    * it.)
06216    */
06217   u_int dynamically_allocated_;
06218 
06219   /// Link to next Object_Manager, for chaining.
06220   ACE_Object_Manager_Base *next_;
06221 private:
06222   // Disallow copying by not implementing the following . . .
06223   ACE_Object_Manager_Base (const ACE_Object_Manager_Base &);
06224   ACE_Object_Manager_Base &operator= (const ACE_Object_Manager_Base &);
06225 };
06226 
06227 extern "C"
06228 void
06229 ACE_OS_Object_Manager_Internal_Exit_Hook (void);
06230 
06231 
06232 // @@ This forward declaration should go away.
06233 class ACE_Log_Msg;
06234 
06235 class ACE_OS_Export ACE_OS_Object_Manager : public ACE_Object_Manager_Base
06236 {
06237 public:
06238   /// Explicitly initialize.
06239   virtual int init (void);
06240 
06241   /// Explicitly destroy.
06242   virtual int fini (void);
06243 
06244   /**
06245    * Returns 1 before the <ACE_OS_Object_Manager> has been
06246    * constructed.  See <ACE_Object_Manager::starting_up> for more
06247    * information.
06248    */
06249   static int starting_up (void);
06250 
06251   /// Returns 1 after the <ACE_OS_Object_Manager> has been destroyed.
06252   /// See <ACE_Object_Manager::shutting_down> for more information.
06253   static int shutting_down (void);
06254 
06255   /// Unique identifiers for preallocated objects.
06256   enum Preallocated_Object
06257     {
06258 # if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0)
06259       ACE_OS_MONITOR_LOCK,
06260       ACE_TSS_CLEANUP_LOCK,
06261       ACE_LOG_MSG_INSTANCE_LOCK,
06262 #   if defined (ACE_HAS_TSS_EMULATION)
06263       ACE_TSS_KEY_LOCK,
06264 #     if defined (ACE_HAS_THREAD_SPECIFIC_STORAGE)
06265       ACE_TSS_BASE_LOCK,
06266 #     endif /* ACE_HAS_THREAD_SPECIFIC_STORAGE */
06267 #   endif /* ACE_HAS_TSS_EMULATION */
06268 # else
06269       // Without ACE_MT_SAFE, There are no preallocated objects.  Make
06270       // sure that the preallocated_array size is at least one by
06271       // declaring this dummy . . .
06272       ACE_OS_EMPTY_PREALLOCATED_OBJECT,
06273 # endif /* ACE_MT_SAFE */
06274 
06275       /// This enum value must be last!
06276       ACE_OS_PREALLOCATED_OBJECTS
06277     };
06278 
06279   /// Accesses a default signal set used, for example, in
06280   /// <ACE_Sig_Guard> methods.
06281   static sigset_t *default_mask (void);
06282 
06283   /// Returns the current thread hook for the process.
06284   static ACE_Thread_Hook *thread_hook (void);
06285 
06286   /// Returns the existing thread hook and assign a <new_thread_hook>.
06287   static ACE_Thread_Hook *thread_hook (ACE_Thread_Hook *new_thread_hook);
06288 
06289 #if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS)
06290   /// Get/Set TSS exception action.
06291   static ACE_SEH_EXCEPT_HANDLER seh_except_selector (void);
06292   static ACE_SEH_EXCEPT_HANDLER seh_except_selector (ACE_SEH_EXCEPT_HANDLER);
06293 
06294   static ACE_SEH_EXCEPT_HANDLER seh_except_handler (void);
06295   static ACE_SEH_EXCEPT_HANDLER seh_except_handler (ACE_SEH_EXCEPT_HANDLER);
06296 #endif /* ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS */
06297 
06298 public:
06299   // = Applications shouldn't use these so they're hidden here.
06300 
06301   // They're public so that the <ACE_Object_Manager> can be
06302   // constructed/destructed in <main> with
06303   // <ACE_HAS_NONSTATIC_OBJECT_MANAGER>.
06304   /// Constructor.
06305   ACE_OS_Object_Manager (void);
06306 
06307   /// Destructor.
06308   ~ACE_OS_Object_Manager (void);
06309 
06310 private:
06311   /// Accessor to singleton instance.
06312   static ACE_OS_Object_Manager *instance (void);
06313 
06314   /// Singleton instance pointer.
06315   static ACE_OS_Object_Manager *instance_;
06316 
06317   /// Table of preallocated objects.
06318   static void *preallocated_object[ACE_OS_PREALLOCATED_OBJECTS];
06319 
06320   /// Default signal set used, for example, in ACE_Sig_Guard.
06321   sigset_t *default_mask_;
06322 
06323   /// Thread hook that's used by this process.
06324   ACE_Thread_Hook *thread_hook_;
06325 
06326   /// For at_exit support.
06327   ACE_OS_Exit_Info exit_info_;
06328 
06329 #if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS)
06330   /// These handlers determine how a thread handles win32 structured
06331   /// exception.
06332   ACE_SEH_EXCEPT_HANDLER seh_except_selector_;
06333   ACE_SEH_EXCEPT_HANDLER seh_except_handler_;
06334 #endif /* ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS */
06335 
06336   /// For <ACE_OS::atexit> support.
06337   int at_exit (ACE_EXIT_HOOK func);
06338 
06339   /// For use by init () and fini (), to consolidate error reporting.
06340   static void print_error_message (u_int line_number, const ACE_TCHAR *message);
06341 
06342   /// This class is for internal use by ACE_OS, etc., only.
06343   friend class ACE_OS;
06344   friend class ACE_Object_Manager;
06345   friend class ACE_OS_Object_Manager_Manager;
06346   friend class ACE_TSS_Cleanup;
06347   friend class ACE_TSS_Emulation;
06348   friend class ACE_Log_Msg;
06349   friend void ACE_OS_Object_Manager_Internal_Exit_Hook ();
06350 };
06351 
06352 # if defined (ACE_LACKS_TIMEDWAIT_PROTOTYPES)
06353 extern "C" ssize_t recv_timedwait (ACE_HANDLE handle,
06354                                    char *buf,
06355                                    int len,
06356                                    int flags,
06357                                    struct timespec *timeout);
06358 extern "C" ssize_t read_timedwait (ACE_HANDLE handle,
06359                                    char *buf,
06360                                    size_t n,
06361                                    struct timespec *timeout);
06362 extern "C" ssize_t recvmsg_timedwait (ACE_HANDLE handle,
06363                                       struct msghdr *msg,
06364                                       int flags,
06365                                       struct timespec *timeout);
06366 extern "C" ssize_t recvfrom_timedwait (ACE_HANDLE handle,
06367                                        char *buf,
06368                                        int len,
06369                                        int flags,
06370                                        struct sockaddr *addr,
06371                                        int
06372                                        *addrlen,
06373                                        struct timespec *timeout);
06374 extern "C" ssize_t readv_timedwait (ACE_HANDLE handle,
06375                                     iovec *iov,
06376                                     int iovcnt,
06377                                     struct timespec* timeout);
06378 extern "C" ssize_t send_timedwait (ACE_HANDLE handle,
06379                                    const char *buf,
06380                                    int len,
06381                                    int flags,
06382                                    struct timespec *timeout);
06383 extern "C" ssize_t write_timedwait (ACE_HANDLE handle,
06384                                     const void *buf,
06385                                     size_t n,
06386                                     struct timespec *timeout);
06387 extern "C" ssize_t sendmsg_timedwait (ACE_HANDLE handle,
06388                                       ACE_SENDMSG_TYPE *msg,
06389                                       int flags,
06390                                       struct timespec *timeout);
06391 extern "C" ssize_t sendto_timedwait (ACE_HANDLE handle,
06392                                      const char *buf,
06393                                      int len,
06394                                      int flags,
06395                                      const struct sockaddr *addr,
06396                                      int addrlen,
06397                                      struct timespec *timeout);
06398 extern "C" ssize_t writev_timedwait (ACE_HANDLE handle,
06399                                      ACE_WRITEV_TYPE *iov,
06400                                      int iovcnt,
06401                                      struct timespec *timeout);
06402 # endif /* ACE_LACKS_TIMEDWAIT_PROTOTYPES */
06403 
06404 # if defined (ACE_HAS_TSS_EMULATION)
06405     // Allow config.h to set the default number of thread keys.
06406 #   if !defined (ACE_DEFAULT_THREAD_KEYS)
06407 #     define ACE_DEFAULT_THREAD_KEYS 64
06408 #   endif /* ! ACE_DEFAULT_THREAD_KEYS */
06409 
06410 // forward declaration
06411 class ACE_TSS_Keys;
06412 
06413 /**
06414  * @class ACE_TSS_Emulation
06415  *
06416  * @brief Thread-specific storage emulation.
06417  *
06418  * This provides a thread-specific storage implementation.
06419  * It is intended for use on platforms that don't have a
06420  * native TSS, or have a TSS with limitations such as the
06421  * number of keys or lack of support for removing keys.
06422  */
06423 class ACE_OS_Export ACE_TSS_Emulation
06424 {
06425 public:
06426   typedef void (*ACE_TSS_DESTRUCTOR)(void *value) /* throw () */;
06427 
06428   /// Maximum number of TSS keys allowed over the life of the program.
06429   enum { ACE_TSS_THREAD_KEYS_MAX = ACE_DEFAULT_THREAD_KEYS };
06430 
06431   /// Returns the total number of keys allocated so far.
06432   static u_int total_keys ();
06433 
06434   /// Sets the argument to the next available key.  Returns 0 on success,
06435   /// -1 if no keys are available.
06436   static int next_key (ACE_thread_key_t &key);
06437 
06438   /// Release a key that was used. This way the key can be given out in a
06439   /// new request. Returns 0 on success, 1 if the key was not reserved.
06440   static int release_key (ACE_thread_key_t key);
06441 
06442   /// Returns the exit hook associated with the key.  Does _not_ check
06443   /// for a valid key.
06444   static ACE_TSS_DESTRUCTOR tss_destructor (const ACE_thread_key_t key);
06445 
06446   /// Associates the TSS destructor with the key.  Does _not_ check
06447   /// for a valid key.
06448   static void tss_destructor (const ACE_thread_key_t key,
06449                               ACE_TSS_DESTRUCTOR destructor);
06450 
06451   /// Accesses the object referenced by key in the current thread's TSS array.
06452   /// Does _not_ check for a valid key.
06453   static void *&ts_object (const ACE_thread_key_t key);
06454 
06455   /**
06456    * Setup an array to be used for local TSS.  Returns the array
06457    * address on success.  Returns 0 if local TSS had already been
06458    * setup for this thread.  There is no corresponding tss_close ()
06459    * because it is not needed.
06460    * NOTE: tss_open () is called by ACE for threads that it spawns.
06461    * If your application spawns threads without using ACE, and it uses
06462    * ACE's TSS emulation, each of those threads should call tss_open
06463    * ().  See the ace_thread_adapter () implementation for an example.
06464    */
06465   static void *tss_open (void *ts_storage[ACE_TSS_THREAD_KEYS_MAX]);
06466 
06467   /// Shutdown TSS emulation.  For use only by ACE_OS::cleanup_tss ().
06468   static void tss_close ();
06469 
06470 private:
06471   // Global TSS structures.
06472   /// Contains the possible value of the next key to be allocated. Which key
06473   /// is actually allocated is based on the tss_keys_used
06474   static u_int total_keys_;
06475 
06476   /// Array of thread exit hooks (TSS destructors) that are called for each
06477   /// key (that has one) when the thread exits.
06478   static ACE_TSS_DESTRUCTOR tss_destructor_ [ACE_TSS_THREAD_KEYS_MAX];
06479 
06480   /// TSS_Keys instance to administrate whether a specific key is in used
06481   /// or not
06482   static ACE_TSS_Keys tss_keys_used_;
06483 
06484 #   if defined (ACE_HAS_THREAD_SPECIFIC_STORAGE)
06485   /// Location of current thread's TSS array.
06486   static void **tss_base (void* ts_storage[] = 0, u_int *ts_created = 0);
06487 #   else  /* ! ACE_HAS_THREAD_SPECIFIC_STORAGE */
06488   /// Location of current thread's TSS array.
06489   static void **&tss_base ();
06490 #   endif /* ! ACE_HAS_THREAD_SPECIFIC_STORAGE */
06491 
06492 #   if defined (ACE_HAS_THREAD_SPECIFIC_STORAGE)
06493   // Rely on native thread specific storage for the implementation,
06494   // but just use one key.
06495   static ACE_OS_thread_key_t native_tss_key_;
06496 
06497   // Used to indicate if native tss key has been allocated
06498   static int key_created_;
06499 #   endif /* ACE_HAS_THREAD_SPECIFIC_STORAGE */
06500 };
06501 
06502 # else   /* ! ACE_HAS_TSS_EMULATION */
06503 #   if defined (TLS_MINIMUM_AVAILABLE)
06504     // WIN32 platforms define TLS_MINIMUM_AVAILABLE natively.
06505 #     define ACE_DEFAULT_THREAD_KEYS TLS_MINIMUM_AVAILABLE
06506 #   endif /* TSL_MINIMUM_AVAILABLE */
06507 
06508 # endif /* ACE_HAS_TSS_EMULATION */
06509 
06510 // moved ACE_TSS_Ref, ACE_TSS_Info, and ACE_TSS_Keys class
06511 // declarations from OS.cpp so they are visible to the single
06512 // file of template instantiations.
06513 # if defined (ACE_WIN32) || defined (ACE_HAS_TSS_EMULATION) || (defined (ACE_PSOS) && defined (ACE_PSOS_HAS_TSS))
06514 /**
06515  * @class ACE_TSS_Ref
06516  *
06517  * @brief "Reference count" for thread-specific storage keys.
06518  *
06519  * Since the <ACE_Unbounded_Stack> doesn't allow duplicates, the
06520  * "reference count" is the identify of the thread_id.
06521  */
06522 class ACE_TSS_Ref
06523 {
06524 public:
06525   /// Constructor
06526   ACE_TSS_Ref (ACE_thread_t id);
06527 
06528   /// Default constructor
06529   ACE_TSS_Ref (void);
06530 
06531   /// Check for equality.
06532   int operator== (const ACE_TSS_Ref &) const;
06533 
06534   /// Check for inequality.
06535   int operator!= (const ACE_TSS_Ref &) const;
06536 
06537 // private:
06538 
06539   /// ID of thread using a specific key.
06540   ACE_thread_t tid_;
06541 };
06542 
06543 /**
06544  * @class ACE_TSS_Info
06545  *
06546  * @brief Thread Specific Key management.
06547  *
06548  * This class maps a key to a "destructor."
06549  */
06550 class ACE_TSS_Info
06551 {
06552 public:
06553   /// Constructor
06554   ACE_TSS_Info (ACE_thread_key_t key,
06555                 void (*dest)(void *) = 0,
06556                 void *tss_inst = 0);
06557 
06558   /// Default constructor
06559   ACE_TSS_Info (void);
06560 
06561   /// Returns 1 if the key is in use, 0 if not.
06562   int key_in_use (void) const { return thread_count_ != -1; }
06563 
06564   /// Mark the key as being in use if the flag is non-zero, or
06565   /// not in use if the flag is 0.
06566   void key_in_use (int flag) { thread_count_ = flag == 0  ?  -1  :  1; }
06567 
06568   /// Check for equality.
06569   int operator== (const ACE_TSS_Info &) const;
06570 
06571   /// Check for inequality.
06572   int operator!= (const ACE_TSS_Info &) const;
06573 
06574   /// Dump the state.
06575   void dump (void);
06576 
06577 private:
06578   /// Key to the thread-specific storage item.
06579   ACE_thread_key_t key_;
06580 
06581   /// "Destructor" that gets called when the item is finally released.
06582   void (*destructor_)(void *);
06583 
06584   /// Pointer to ACE_TSS<xxx> instance that has/will allocate the key.
06585   void *tss_obj_;
06586 
06587   /// Count of threads that are using this key.  Contains -1 when the
06588   /// key is not in use.
06589   int thread_count_;
06590 
06591   friend class ACE_TSS_Cleanup;
06592 };
06593 
06594 /**
06595  * @class ACE_TSS_Keys
06596  *
06597  * @brief Collection of in-use flags for a thread's TSS keys.
06598  * For internal use only by ACE_TSS_Cleanup; it is public because
06599  * some compilers can't use nested classes for template instantiation
06600  * parameters.
06601  *
06602  * Wrapper around array of whether each key is in use.  A simple
06603  * typedef doesn't work with Sun C++ 4.2.
06604  */
06605 class ACE_TSS_Keys
06606 {
06607 public:
06608   /// Default constructor, to initialize all bits to zero (unused).
06609   ACE_TSS_Keys (void);
06610 
06611   /// Mark the specified key as being in use, if it was not already so marked.
06612   /// Returns 1 if the had already been marked, 0 if not.
06613   int test_and_set (const ACE_thread_key_t key);
06614 
06615   /// Mark the specified key as not being in use, if it was not already so
06616   /// cleared.  Returns 1 if the key had already been cleared, 0 if not.
06617   int test_and_clear (const ACE_thread_key_t key);
06618 
06619   /// Return whether the specific key is marked as in use.
06620   /// Returns 1 if the key is been marked, 0 if not.
06621   int is_set (const ACE_thread_key_t key) const;
06622 
06623 private:
06624   /// For a given key, find the word and bit number that represent it.
06625   static void find (const u_int key, u_int &word, u_int &bit);
06626 
06627   enum
06628     {
06629 #   if ACE_SIZEOF_LONG == 8
06630       ACE_BITS_PER_WORD = 64,
06631 #   elif ACE_SIZEOF_LONG == 4
06632       ACE_BITS_PER_WORD = 32,
06633 #   else
06634 #     error ACE_TSS_Keys only supports 32 or 64 bit longs.
06635 #   endif /* ACE_SIZEOF_LONG == 8 */
06636       ACE_WORDS = (ACE_DEFAULT_THREAD_KEYS - 1) / ACE_BITS_PER_WORD + 1
06637     };
06638 
06639   /// Bit flag collection.  A bit value of 1 indicates that the key is in
06640   /// use by this thread.
06641   u_long key_bit_words_[ACE_WORDS];
06642 };
06643 
06644 # endif /* defined (ACE_WIN32) || defined (ACE_HAS_TSS_EMULATION) */
06645 
06646 // Support non-scalar thread keys, such as with some POSIX
06647 // implementations, e.g., MVS.
06648 # if defined (ACE_HAS_NONSCALAR_THREAD_KEY_T)
06649 #   define ACE_KEY_INDEX(OBJ,KEY) \
06650   u_int OBJ; \
06651   ACE_OS::memcpy (&OBJ, &KEY, sizeof (u_int))
06652 # else
06653 #   define ACE_KEY_INDEX(OBJ,KEY) u_int OBJ = KEY
06654 # endif /* ACE_HAS_NONSCALAR_THREAD_KEY_T */
06655 
06656 // Some useful abstrations for expressions involving
06657 // ACE_Allocator.malloc ().  The difference between ACE_NEW_MALLOC*
06658 // with ACE_ALLOCATOR* is that they call constructors also.
06659 
06660 # define ACE_ALLOCATOR_RETURN(POINTER,ALLOCATOR,RET_VAL) \
06661    do { POINTER = ALLOCATOR; \
06662      if (POINTER == 0) { errno = ENOMEM; return RET_VAL; } \
06663    } while (0)
06664 # define ACE_ALLOCATOR(POINTER,ALLOCATOR) \
06665    do { POINTER = ALLOCATOR; \
06666      if (POINTER == 0) { errno = ENOMEM; return; } \
06667    } while (0)
06668 # define ACE_ALLOCATOR_NORETURN(POINTER,ALLOCATOR) \
06669    do { POINTER = ALLOCATOR; \
06670      if (POINTER == 0) { errno = ENOMEM; } \
06671    } while (0)
06672 
06673 # define ACE_NEW_MALLOC_RETURN(POINTER,ALLOCATOR,CONSTRUCTOR,RET_VAL) \
06674    do { POINTER = ALLOCATOR; \
06675      if (POINTER == 0) { errno = ENOMEM; return RET_VAL;} \
06676      else { new (POINTER) CONSTRUCTOR; } \
06677    } while (0)
06678 # define ACE_NEW_MALLOC(POINTER,ALLOCATOR,CONSTRUCTOR) \
06679    do { POINTER = ALLOCATOR; \
06680      if (POINTER == 0) { errno = ENOMEM; return;} \
06681      else { new (POINTER) CONSTRUCTOR; } \
06682    } while (0)
06683 # define ACE_NEW_MALLOC_NORETURN(POINTER,ALLOCATOR,CONSTRUCTOR) \
06684    do { POINTER = ALLOCATOR; \
06685      if (POINTER == 0) { errno = ENOMEM;} \
06686      else { new (POINTER) CONSTRUCTOR; } \
06687    } while (0)
06688 
06689 # define ACE_NOOP(x)
06690 
06691 # if defined (ACE_HAS_THR_C_FUNC)
06692 // This is necessary to work around nasty problems with MVS C++.
06693 extern "C" ACE_OS_Export void ace_mutex_lock_cleanup_adapter (void *args);
06694 #   define ACE_PTHREAD_CLEANUP_PUSH(A) pthread_cleanup_push (ace_mutex_lock_cleanup_adapter, (void *) A);
06695 #   define ACE_PTHREAD_CLEANUP_POP(A) pthread_cleanup_pop(A)
06696 # elif defined (ACE_HAS_PTHREADS) && !defined (ACE_LACKS_PTHREAD_CLEANUP)
06697 // Though we are defining a extern "C" function to match the prototype of
06698 // pthread_cleanup_push, it is undone by the Solaris header file
06699 // /usr/include/pthread.h. So this macro generates a warning under Solaris
06700 // with SunCC. This is a bug in the Solaris header file.
06701 extern "C" ACE_OS_Export void ace_mutex_lock_cleanup_adapter (void *args);
06702 #   define ACE_PTHREAD_CLEANUP_PUSH(A) pthread_cleanup_push (ace_mutex_lock_cleanup_adapter, (void *) A);
06703 #   define ACE_PTHREAD_CLEANUP_POP(A) pthread_cleanup_pop(A)
06704 # else
06705 #   define ACE_PTHREAD_CLEANUP_PUSH(A)
06706 #   define ACE_PTHREAD_CLEANUP_POP(A)
06707 # endif /* ACE_HAS_THR_C_FUNC */
06708 
06709 # if !defined (ACE_DEFAULT_MUTEX_A)
06710 #   define ACE_DEFAULT_MUTEX_A "ACE_MUTEX"
06711 # endif /* ACE_DEFAULT_MUTEX_A */
06712 
06713 # if defined (ACE_HAS_WCHAR)
06714 #   define ACE_DEFAULT_MUTEX_W ACE_TEXT_WIDE(ACE_DEFAULT_MUTEX_A)
06715 # endif /* ACE_HAS_WCHAR */
06716 
06717 # define ACE_DEFAULT_MUTEX ACE_LIB_TEXT (ACE_DEFAULT_MUTEX_A)
06718 
06719 # if !defined (ACE_MAIN)
06720 #   define ACE_MAIN main
06721 # endif /* ! ACE_MAIN */
06722 
06723 # if !defined (ACE_WMAIN)
06724 #   define ACE_WMAIN wmain
06725 # endif /* ! ACE_WMAIN */
06726 
06727 # if defined (ACE_WIN32) && defined (ACE_USES_WCHAR)
06728 #   define ACE_TMAIN wmain
06729 # else
06730 #   define ACE_TMAIN main
06731 # endif
06732 
06733 # if defined (ACE_DOESNT_INSTANTIATE_NONSTATIC_OBJECT_MANAGER)
06734 #   if !defined (ACE_HAS_NONSTATIC_OBJECT_MANAGER)
06735 #     define ACE_HAS_NONSTATIC_OBJECT_MANAGER
06736 #   endif /* ACE_HAS_NONSTATIC_OBJECT_MANAGER */
06737 # endif /* ACE_DOESNT_INSTANTIATE_NONSTATIC_OBJECT_MANAGER */
06738 
06739 # if defined (ACE_HAS_NONSTATIC_OBJECT_MANAGER) && !defined (ACE_DOESNT_INSTANTIATE_NONSTATIC_OBJECT_MANAGER)
06740 
06741 #   if !defined (ACE_HAS_MINIMAL_ACE_OS)
06742 #     include "ace/Object_Manager.h"
06743 #   endif /* ! ACE_HAS_MINIMAL_ACE_OS */
06744 
06745 // Rename "main ()" on platforms that don't allow it to be called "main ()".
06746 
06747 // Also, create ACE_Object_Manager static instance(s) in "main ()".
06748 // ACE_MAIN_OBJECT_MANAGER defines the ACE_Object_Manager(s) that will
06749 // be instantiated on the stack of main ().  Note that it is only used
06750 // when compiling main ():  its value does not affect the contents of
06751 // ace/OS.o.
06752 #   if !defined (ACE_MAIN_OBJECT_MANAGER)
06753 #     define ACE_MAIN_OBJECT_MANAGER \
06754         ACE_OS_Object_Manager ace_os_object_manager; \
06755         ACE_Object_Manager ace_object_manager;
06756 #   endif /* ! ACE_MAIN_OBJECT_MANAGER */
06757 
06758 #   if defined (ACE_PSOSIM)
06759 // PSOSIM root lacks the standard argc, argv command line parameters,
06760 // create dummy argc and argv in the "real" main  and pass to "user" main.
06761 // NOTE: ACE_MAIN must be defined to give the return type as well as the
06762 // name of the entry point.
06763 #     define main \
06764 ace_main_i (int, char *[]);                /* forward declaration */ \
06765 ACE_MAIN ()   /* user's entry point, e.g., "main" w/out argc, argv */ \
06766 { \
06767   int argc = 1;                            /* dummy arg count */ \
06768   char *argv[] = {"psosim"};               /* dummy arg list */ \
06769   ACE_MAIN_OBJECT_MANAGER \
06770   int ret_val = -1; /* assume the worst */ \
06771   if (ACE_PSOS_Time_t::init_simulator_time ()) /* init simulator time */ \
06772   { \
06773     ACE_ERROR((LM_ERROR, "init_simulator_time failed\n"));  /* report */ \
06774   } \
06775   else \
06776   { \
06777     ret_val = ace_main_i (argc, argv);   /* call user main, save result */ \
06778   } \
06779   ACE_OS::exit (ret_val);                /* pass code to simulator exit */ \
06780 } \
06781 int \
06782 ace_main_i
06783 #   elif defined (ACE_PSOS) && defined (ACE_PSOS_LACKS_ARGC_ARGV)
06784 // PSOS root lacks the standard argc, argv command line parameters,
06785 // create dummy argc and argv in the "real" main  and pass to "user" main.
06786 // Ignore return value from user main as well.  NOTE: ACE_MAIN must be
06787 // defined to give the return type as well as the name of the entry point
06788 #     define main \
06789 ace_main_i (int, char *[]);               /* forward declaration */ \
06790 ACE_MAIN ()   /* user's entry point, e.g., "main" w/out argc, argv */ \
06791 { \
06792   int argc = 1;                           /* dummy arg count */ \
06793   char *argv[] = {"root"};                /* dummy arg list */ \
06794   ACE_MAIN_OBJECT_MANAGER \
06795   ace_main_i (argc, argv);                /* call user main, ignore result */ \
06796 } \
06797 int \
06798 ace_main_i
06799 #   elif defined (ACE_HAS_WINCE)
06800 /**
06801  * @class ACE_CE_ARGV
06802  *
06803  * @brief This class is to hash input parameters, argc and argv, for
06804  * WinCE platform.
06805  *
06806  * Since WinCE only supports wchar_t as an input from OS, some
06807  * implementation detail, especially for CORBA spec, will not support
06808  * ACE_TCHAR (wchar_t) type parameter. Moreover, WinCE's input parameter
06809  * type is totally different than any other OS; all command line
06810  * parameters will be stored in a single wide-character string with
06811  * each unit parameter divided by blank space, and it does not provide
06812  * the name of executable (generally known as argv[0]).
06813  * This class is to convert CE's command line parameters and simulate as
06814  * in the same manner as other general platforms, adding 'root' as a
06815  * first argc, which is for the name of executable in other OS.
06816  */
06817 class ACE_OS_Export ACE_CE_ARGV
06818 {
06819 public:
06820     /**
06821      * Ctor accepts CE command line as a paramter.
06822      */
06823     ACE_CE_ARGV(ACE_TCHAR* cmdLine);
06824 
06825     /**
06826      * Default Dtor that deletes any memory allocated for the converted string.
06827      */
06828     ~ACE_CE_ARGV(void);
06829 
06830     /**
06831      * Returns the number of command line paramters, same as argc on Unix.
06832      */
06833     int argc(void);
06834 
06835     /**
06836      * Returns the char** that contains the converted command line parameters.
06837      */
06838     ACE_TCHAR** const argv(void);
06839 
06840 private:
06841     /**
06842      * Copy Ctor is not allowed.
06843      */
06844     ACE_CE_ARGV(void);
06845 
06846     /**
06847      * Copy Ctor is not allowed.
06848      */
06849     ACE_CE_ARGV(ACE_CE_ARGV&);
06850 
06851     /**
06852      * Pointer of converted command line paramters.
06853      */
06854     ACE_TCHAR** ce_argv_;
06855 
06856     /**
06857      * Integer that is same as argc on other OS's.
06858      */
06859     int ce_argc_;
06860 };
06861 #     if defined (ACE_TMAIN)  // Use WinMain on CE; others give warning/error.
06862 #       undef ACE_TMAIN
06863 #     endif  // ACE_TMAIN
06864 
06865 // Support for ACE_TMAIN, which is a recommended way.
06866 #     define ACE_TMAIN \
06867 ace_main_i (int, ACE_TCHAR *[]);  /* forward declaration */ \
06868 int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow) \
06869 { \
06870   ACE_CE_ARGV ce_argv(lpCmdLine); \
06871   ACE::init(); \
06872   ACE_MAIN_OBJECT_MANAGER \
06873   int i = ace_main_i (ce_argv.argc(), ce_argv.argv()); \
06874   ACE::fini(); \
06875   return i; \
06876 } \
06877 int ace_main_i
06878 
06879 // Support for wchar_t but still can't fit to CE because of the command line parameters.
06880 #     define wmain \
06881 ace_main_i (int, ACE_TCHAR *[]);  /* forward declaration */ \
06882 int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow) \
06883 { \
06884   ACE_CE_ARGV ce_argv(lpCmdLine); \
06885   ACE::init(); \
06886   ACE_MAIN_OBJECT_MANAGER \
06887   int i = ace_main_i (ce_argv.argc(), ce_argv.argv()); \
06888   ACE::fini(); \
06889   return i; \
06890 } \
06891 int ace_main_i
06892 
06893 // Supporting legacy 'main' is A LOT easier for users than changing existing
06894 // code on WinCE. Unfortunately, evc 3 can't grok a #include within the macro
06895 // expansion, so it needs to go out here.
06896 #     include "ace/Argv_Type_Converter.h"
06897 #     define main \
06898 ace_main_i (int, char *[]);  /* forward declaration */ \
06899 int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow) \
06900 { \
06901   ACE_CE_ARGV ce_argv (lpCmdLine); \
06902   ACE::init (); \
06903   ACE_MAIN_OBJECT_MANAGER \
06904   ACE_Argv_Type_Converter command_line (ce_argv.argc (), ce_argv.argv ()); \
06905   int i = ace_main_i (command_line.get_argc(), command_line.get_ASCII_argv());\
06906   ACE::fini (); \
06907   return i; \
06908 } \
06909 int ace_main_i
06910 
06911 #   else
06912 #     define main \
06913 ace_main_i (int, char *[]);                  /* forward declaration */ \
06914 int \
06915 ACE_MAIN (int argc, char *argv[]) /* user's entry point, e.g., main */ \
06916 { \
06917   ACE_MAIN_OBJECT_MANAGER \
06918   return ace_main_i (argc, argv);           /* what the user calls "main" */ \
06919 } \
06920 int \
06921 ace_main_i
06922 #     if defined (ACE_WIN32)
06923 #     define wmain \
06924 ace_main_i (int, ACE_TCHAR *[]);                  /* forward declaration */ \
06925 int \
06926 ACE_WMAIN (int argc, ACE_TCHAR *argv[]) /* user's entry point, e.g., main */ \
06927 { \
06928   ACE_MAIN_OBJECT_MANAGER \
06929   return ace_main_i (argc, argv);           /* what the user calls "main" */ \
06930 } \
06931 int \
06932 ace_main_i
06933 #     endif /* ACE_WIN32 && UNICODE */
06934 #   endif   /* ACE_PSOSIM */
06935 # endif /* ACE_HAS_NONSTATIC_OBJECT_MANAGER && !ACE_HAS_WINCE && !ACE_DOESNT_INSTANTIATE_NONSTATIC_OBJECT_MANAGER */
06936 
06937 # if defined (ACE_WIN32) && ! defined (ACE_HAS_WINCE) \
06938                          && ! defined (ACE_HAS_PHARLAP)
06939 typedef TRANSMIT_FILE_BUFFERS ACE_TRANSMIT_FILE_BUFFERS;
06940 typedef LPTRANSMIT_FILE_BUFFERS ACE_LPTRANSMIT_FILE_BUFFERS;
06941 typedef PTRANSMIT_FILE_BUFFERS ACE_PTRANSMIT_FILE_BUFFERS;
06942 
06943 #   define ACE_INFINITE INFINITE
06944 #   define ACE_STATUS_TIMEOUT STATUS_TIMEOUT
06945 #   define ACE_WAIT_FAILED WAIT_FAILED
06946 #   define ACE_WAIT_TIMEOUT WAIT_TIMEOUT
06947 # else /* ACE_WIN32 */
06948 struct ACE_TRANSMIT_FILE_BUFFERS
06949 {
06950   void *Head;
06951   size_t HeadLength;
06952   void *Tail;
06953   size_t TailLength;
06954 };
06955 typedef ACE_TRANSMIT_FILE_BUFFERS* ACE_PTRANSMIT_FILE_BUFFERS;
06956 typedef ACE_TRANSMIT_FILE_BUFFERS* ACE_LPTRANSMIT_FILE_BUFFERS;
06957 
06958 #   if !defined (ACE_INFINITE)
06959 #     define ACE_INFINITE LONG_MAX
06960 #   endif /* ACE_INFINITE */
06961 #   define ACE_STATUS_TIMEOUT LONG_MAX
06962 #   define ACE_WAIT_FAILED LONG_MAX
06963 #   define ACE_WAIT_TIMEOUT LONG_MAX
06964 # endif /* ACE_WIN32 */
06965 
06966 # if !defined (ACE_HAS_MINIMAL_ACE_OS)
06967 #   include "ace/Trace.h"
06968 # endif /* ! ACE_HAS_MINIMAL_ACE_OS */
06969 
06970 # if defined (ACE_HAS_INLINED_OSCALLS)
06971 #   if defined (ACE_INLINE)
06972 #     undef ACE_INLINE
06973 #   endif /* ACE_INLINE */
06974 #   define ACE_INLINE inline
06975 #   include "ace/OS.i"
06976 # endif /* ACE_HAS_INLINED_OSCALLS */
06977 
06978 // Byte swapping macros to deal with differences between little endian
06979 // and big endian machines.  Note that "long" here refers to 32 bit
06980 // quantities.
06981 # define ACE_SWAP_LONG(L) ((ACE_SWAP_WORD ((L) & 0xFFFF) << 16) \
06982             | ACE_SWAP_WORD(((L) >> 16) & 0xFFFF))
06983 # define ACE_SWAP_WORD(L) ((((L) & 0x00FF) << 8) | (((L) & 0xFF00) >> 8))
06984 
06985 # if defined (ACE_LITTLE_ENDIAN)
06986 #   define ACE_HTONL(X) ACE_SWAP_LONG (X)
06987 #   define ACE_NTOHL(X) ACE_SWAP_LONG (X)
06988 #   define ACE_IDL_NCTOHL(X) (X)
06989 #   define ACE_IDL_NSTOHL(X) (X)
06990 # else
06991 #   define ACE_HTONL(X) X
06992 #   define ACE_NTOHL(X) X
06993 #   define ACE_IDL_NCTOHL(X) (X << 24)
06994 #   define ACE_IDL_NSTOHL(X) ((X) << 16)
06995 # endif /* ACE_LITTLE_ENDIAN */
06996 
06997 # if defined (ACE_LITTLE_ENDIAN)
06998 #   define ACE_HTONS(x) ACE_SWAP_WORD(x)
06999 #   define ACE_NTOHS(x) ACE_SWAP_WORD(x)
07000 # else
07001 #   define ACE_HTONS(x) x
07002 #   define ACE_NTOHS(x) x
07003 # endif /* ACE_LITTLE_ENDIAN */
07004 
07005 # if defined (ACE_HAS_POSIX_REALTIME_SIGNALS)
07006   // = Giving unique ACE scoped names for some important
07007   // RTSignal-Related constants. Becuase sometimes, different
07008   // platforms use different names for these constants.
07009 
07010   // Number of realtime signals provided in the system.
07011   // _POSIX_RTSIG_MAX is the upper limit on the number of real time
07012   // signals supported in a posix-4 compliant system.
07013 #   if defined (_POSIX_RTSIG_MAX)
07014 #     define ACE_RTSIG_MAX _POSIX_RTSIG_MAX
07015 #   else /* not _POSIX_RTSIG_MAX */
07016   // POSIX-4 compilant system has to provide atleast 8 RT signals.
07017   // @@ Make sure the platform does *not* define this constant with
07018   // some other name. If yes, use that instead of 8.
07019 #     define ACE_RTSIG_MAX 8
07020 #   endif /* _POSIX_RTSIG_MAX */
07021 # endif /* ACE_HAS_POSIX_REALTIME_SIGNALS */
07022 
07023   // Wrapping around wait status <wstat> macros for platforms that
07024   // lack them.
07025 
07026   // Evaluates to a non-zero value if status was returned for a child
07027   // process that terminated normally.  0 means status wasn't
07028   // returned.
07029 #if !defined (WIFEXITED)
07030 #   define WIFEXITED(stat) 1
07031 #endif /* WIFEXITED */
07032 
07033   // If the value of WIFEXITED(stat) is non-zero, this macro evaluates
07034   // to the exit code that the child process exit(3C), or the value
07035   // that the child process returned from main.  Peaceful exit code is
07036   // 0.
07037 #if !defined (WEXITSTATUS)
07038 #   define WEXITSTATUS(stat) stat
07039 #endif /* WEXITSTATUS */
07040 
07041   // Evaluates to a non-zero value if status was returned for a child
07042   // process that terminated due to the receipt of a signal.  0 means
07043   // status wasnt returned.
07044 #if !defined (WIFSIGNALED)
07045 #   define WIFSIGNALED(stat) 0
07046 #endif /* WIFSIGNALED */
07047 
07048   // If the value of  WIFSIGNALED(stat)  is non-zero,  this macro
07049   // evaluates to the number of the signal that  caused  the
07050   // termination of the child process.
07051 #if !defined (WTERMSIG)
07052 #   define WTERMSIG(stat) 0
07053 #endif /* WTERMSIG */
07054 
07055 #if !defined (WIFSTOPPED)
07056 #   define WIFSTOPPED(stat) 0
07057 #endif /* WIFSTOPPED */
07058 
07059 #if !defined (WSTOPSIG)
07060 #   define WSTOPSIG(stat) 0
07061 #endif /* WSTOPSIG */
07062 
07063 #if !defined (WIFCONTINUED)
07064 #   define WIFCONTINUED(stat) 0
07065 #endif /* WIFCONTINUED */
07066 
07067 #if !defined (WCOREDUMP)
07068 #   define WCOREDUMP(stat) 0
07069 #endif /* WCOREDUMP */
07070 
07071 
07072 /**
07073  * In some environments it is useful to swap the bytes on write, for
07074  * instance: a fast server can be feeding a lot of slow clients that
07075  * happen to have the wrong byte order.
07076  * Because this is a rarely used feature we disable it by default to
07077  * minimize footprint.
07078  * This macro enables the functionality, but we still need a way to
07079  * activate it on a per-connection basis.
07080  */
07081 // #define ACE_ENABLE_SWAP_ON_WRITE
07082 
07083 /**
07084  * In some environements we never need to swap bytes when reading, for
07085  * instance embebbed systems (such as avionics) or homogenous
07086  * networks.
07087  * Setting this macro disables the capabilities to demarshall streams
07088  * in the wrong byte order.
07089  */
07090 // #define ACE_DISABLE_SWAP_ON_READ
07091 
07092 
07093 //@{
07094 /**
07095  * @name Efficiently compute aligned pointers to powers of 2 boundaries.
07096  */
07097 
07098 /**
07099  * Efficiently align "value" up to "alignment", knowing that all such
07100  * boundaries are binary powers and that we're using two's complement
07101  * arithmetic.
07102  *
07103  * Since the alignment is a power of two its binary representation is:
07104  *
07105  * alignment      = 0...010...0
07106  *
07107  * hence
07108  *
07109  * alignment - 1  = 0...001...1 = T1
07110  *
07111  * so the complement is:
07112  *
07113  * ~(alignment - 1) = 1...110...0 = T2
07114  *
07115  * Notice that there is a multiple of <alignment> in the range
07116  * [<value>,<value> + T1], also notice that if
07117  *
07118  * X = ( <value> + T1 ) & T2
07119  *
07120  * then
07121  *
07122  * <value> <= X <= <value> + T1
07123  *
07124  * because the & operator only changes the last bits, and since X is a
07125  * multiple of <alignment> (its last bits are zero) we have found the
07126  * multiple we wanted.
07127  */
07128 /// Return the next integer aligned to a required boundary
07129 /**
07130  * @param ptr the base pointer
07131  * @param alignment the required alignment
07132  */
07133 #define ACE_align_binary(ptr, alignment) \
07134     ((ptr + ((ptr_arith_t)((alignment)-1))) & (~((ptrdiff_t)((alignment)-1))))
07135 
07136 /// Return the next address aligned to a required boundary
07137 #define ACE_ptr_align_binary(ptr, alignment) \
07138         ((char *) ACE_align_binary (((ptrdiff_t) (ptr)), (alignment)))
07139 //@}
07140 
07141 // Defining POSIX4 real-time signal range.
07142 #if defined(ACE_HAS_POSIX_REALTIME_SIGNALS)
07143 #define ACE_SIGRTMIN SIGRTMIN
07144 #define ACE_SIGRTMAX SIGRTMAX
07145 
07146 #else /* !ACE_HAS_POSIX_REALTIME_SIGNALS */
07147 
07148 #ifndef ACE_SIGRTMIN
07149 #define ACE_SIGRTMIN 0
07150 #endif /* ACE_SIGRTMIN */
07151 
07152 #ifndef ACE_SIGRTMAX
07153 #define ACE_SIGRTMAX 0
07154 #endif /* ACE_SIGRTMAX */
07155 
07156 #endif /* ACE_HAS_POSIX_REALTIME_SIGNALS */
07157 
07158 # if defined (ACE_LACKS_SYS_NERR)
07159 extern ACE_OS_Export int sys_nerr;
07160 # endif /* ACE_LACKS_SYS_NERR */
07161 
07162 #if defined (ACE_LEGACY_MODE)
07163 # include "ace/Log_Msg.h"
07164 # include "ace/Thread_Hook.h"
07165 # include "ace/Thread_Adapter.h"
07166 # include "ace/Thread_Exit.h"
07167 # include "ace/Thread_Control.h"
07168 #endif  /* ACE_LEGACY_MODE */
07169 
07170 #include "ace/post.h"
07171 #endif  /* ACE_OS_H */

Generated on Mon Jun 16 11:20:37 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002