diff options
Diffstat (limited to 'ace/OS.h')
-rw-r--r-- | ace/OS.h | 370 |
1 files changed, 21 insertions, 349 deletions
@@ -296,12 +296,6 @@ # define ACE_DEFAULT_SERVER_HOST "localhost" # endif /* ACE_DEFAULT_SERVER_HOST */ -// The way to specify the local host for loopback IP. This is usually -// "localhost" but it may need changing on some platforms. -# if !defined (ACE_LOCALHOST) -# define ACE_LOCALHOST ASYS_TEXT("localhost") -# endif - // Default shared memory key # if !defined (ACE_DEFAULT_SHM_KEY) # define ACE_DEFAULT_SHM_KEY 1234 @@ -1114,7 +1108,6 @@ private: // This needs to go here *first* to avoid problems with AIX. # if defined (ACE_HAS_PTHREADS) extern "C" { -# include /**/ <signal.h> # include /**/ <pthread.h> # if defined (DIGITAL_UNIX) # define pthread_self __pthread_self @@ -2018,31 +2011,19 @@ typedef pthread_mutex_t ACE_thread_mutex_t; # if defined (ACE_HAS_PTHREADS_DRAFT4) # if defined (PTHREAD_PROCESS_PRIVATE) -# if !defined (USYNC_THREAD) # define USYNC_THREAD PTHREAD_PROCESS_PRIVATE -# endif /* ! USYNC_THREAD */ # else -# if !defined (USYNC_THREAD) # define USYNC_THREAD MUTEX_NONRECURSIVE_NP -# endif /* ! USYNC_THREAD */ # endif /* PTHREAD_PROCESS_PRIVATE */ # if defined (PTHREAD_PROCESS_SHARED) -# if !defined (USYNC_PROCESS) # define USYNC_PROCESS PTHREAD_PROCESS_SHARED -# endif /* ! USYNC_PROCESS */ # else -# if !defined (USYNC_PROCESS) # define USYNC_PROCESS MUTEX_NONRECURSIVE_NP -# endif /* ! USYNC_PROCESS */ # endif /* PTHREAD_PROCESS_SHARED */ # elif !defined (ACE_HAS_STHREADS) -# if !defined (USYNC_THREAD) # define USYNC_THREAD PTHREAD_PROCESS_PRIVATE -# endif /* ! USYNC_THREAD */ -# if !defined (USYNC_PROCESS) # define USYNC_PROCESS PTHREAD_PROCESS_SHARED -# endif /* ! USYNC_PROCESS */ # endif /* ACE_HAS_PTHREADS_DRAFT4 */ # define THR_BOUND 0x00000001 @@ -2091,8 +2072,14 @@ protected: # endif /* !ACE_HAS_POSIX_SEM */ # if defined (ACE_LACKS_PTHREAD_YIELD) && defined (ACE_HAS_THR_YIELD) - // If we are on Solaris we can just reuse the existing - // implementations of these synchronization types. +# if defined (USYNC_THREAD) +# undef USYNC_THREAD +# endif /* USYNC_THREAD */ +# if defined (USYNC_PROCESS) +# undef USYNC_PROCESS +# endif /* USYNC_PROCESS */ +// If we are on Solaris we can just reuse the existing implementations +// of these synchronization types. # if !defined (ACE_LACKS_RWLOCK_T) # include /**/ <synch.h> typedef rwlock_t ACE_rwlock_t; @@ -2318,11 +2305,11 @@ public: # define THR_CANCEL_ENABLE 0 # define THR_CANCEL_DEFERRED 0 # define THR_CANCEL_ASYNCHRONOUS 0 -# define THR_DETACHED 0x02000000 /* ignore in most places */ -# define THR_BOUND 0 /* ignore in most places */ -# define THR_NEW_LWP 0 /* ignore in most places */ -# define THR_DAEMON 0 /* ignore in most places */ -# define THR_JOINABLE 0 /* ignore in most places */ +# define THR_DETACHED 0x02000000 /* ?? ignore in most places */ +# define THR_BOUND 0 /* ?? ignore in most places */ +# define THR_NEW_LWP 0 /* ?? ignore in most places */ +# define THR_DAEMON 0 /* ?? ignore in most places */ +# define THR_JOINABLE 0 /* ?? ignore in most places */ # define THR_SUSPENDED CREATE_SUSPENDED # define THR_USE_AFX 0x01000000 # define THR_SCHED_FIFO 0 @@ -3126,8 +3113,6 @@ struct iovec { size_t iov_len; // byte count to read/write char *iov_base; // data to be read/written - - operator WSABUF &(void) { return *((WSABUF *) this); } }; struct msghdr @@ -3483,16 +3468,9 @@ typedef void (*__sighandler_t)(int); // keep Signal compilation happy # include /**/ <sys/time.h> # include /**/ <sys/wait.h> # include /**/ <pwd.h> - // sets O_NDELAY -# include /**/ <unix.h> -# include /**/ <sys/param.h> /* for NBBY */ - typedef long fd_mask; -# if !defined (NFDBITS) -# define NFDBITS (sizeof(fd_mask) * NBBY) /* bits per mask */ -# endif /* ! NFDBITS */ -# if !defined (howmany) +# ifndef howmany # define howmany(x, y) (((x)+((y)-1))/(y)) -# endif /* ! howmany */ +# endif /* howmany */ # elif ! defined (VXWORKS) # include /**/ <sys/uio.h> # include /**/ <sys/ipc.h> @@ -4165,9 +4143,7 @@ union semun // Max size of an ACE Token client ID. # define ACE_MAXCLIENTIDLEN MAXHOSTNAMELEN + 20 -// // Create some useful typedefs. -// typedef const char **SYS_SIGLIST; typedef void *(*ACE_THR_FUNC)(void *); // This is for C++ static methods. @@ -4231,12 +4207,6 @@ struct ACE_Export siginfo_t }; # endif /* ACE_HAS_SIGINFO_T */ -// Typedef for the null handler func. -extern "C" -{ - typedef void (*ACE_SIGNAL_C_FUNC)(int,siginfo_t*,void*); -} - # if !defined (ACE_HAS_UCONTEXT_T) typedef int ucontext_t; # endif /* ACE_HAS_UCONTEXT_T */ @@ -4709,251 +4679,6 @@ extern "C" { typedef int (*ACE_COMPARE_FUNC)(const void *, const void *); } -class ACE_Export ACE_Errno_Guard -{ - // = TITLE - // Provides a wrapper to improve performance when thread-specific - // errno must be saved and restored in a block of code. - // - // = DESCRIPTION - // The typical use-case for this is the following: - // - // int error = errno; - // call_some_function_that_might_change_errno (); - // errno = error; - // - // This can be replaced with - // - // { - // ACE_Errno_Guard guard (errno); - // call_some_function_that_might_change_errno (); - // } - // - // This implementation is more elegant and more efficient since it - // avoids an unnecessary second access to thread-specific storage - // by caching a pointer to the value of errno in TSS. -public: - // = Initialization and termination methods. - ACE_Errno_Guard (int &errno_ref, - int error); - // Stash the value of <error> into <error_> and initialize the - // <errno_ptr_> to the address of <errno_ref>. - - ACE_Errno_Guard (int &errno_ref); - // Stash the value of <errno> into <error_> and initialize the - // <errno_ptr_> to the address of <errno_ref>. - - ~ACE_Errno_Guard (void); - // Reset the value of <errno> to <error>. - - int operator= (int error); - // Assign <error> to <error_>. - - int operator== (int error); - // Compare <error> with <error_> for equality. - - int operator!= (int error); - // Compare <error> with <error_> for inequality. - -private: -#if defined (ACE_MT_SAFE) - int *errno_ptr_; -#endif /* ACE_MT_SAFE */ - int error_; -}; - -#if defined (ACE_HAS_WINSOCK2) -typedef SERVICETYPE ACE_SERVICE_TYPE; -typedef GROUP ACE_SOCK_GROUP; -typedef WSAPROTOCOL_INFO ACE_Protocol_Info; -#else -typedef u_long ACE_SOCK_GROUP; -typedef u_long ACE_SERVICE_TYPE; -typedef u_long ACE_Protocol_Info; -#endif /* SERVICETYPE */ - -class ACE_Export ACE_Flow_Spec -#if defined (ACE_HAS_WINSOCK2) - : public FLOWSPEC -#endif /* ACE_HAS_WINSOCK2 */ -{ - // = TITLE - // Wrapper class that defines the flow spec QoS information, which - // is used by RSVP. -public: - // = Get/set the token rate in bytes/sec. - u_long token_rate (void); - void token_rate (u_long tr); - - // = Get/set the token bucket size in bytes. - u_long token_bucket_size (void); - void token_bucket_size (u_long tbs); - - // = Get/set the PeakBandwidth in bytes/sec. - u_long peak_bandwidth (void); - void peak_bandwidth (u_long pb); - - // = Get/set the latency in microseconds. - u_long latency (void); - void latency (u_long l); - - // = Get/set the delay variation in microseconds. - u_long delay_variation (void); - void delay_variation (u_long dv); - - // = Get/set the service type. - ACE_SERVICE_TYPE service_type (void); - void service_type (ACE_SERVICE_TYPE st); - - // = Get/set the maximum SDU size in bytes. - u_long max_sdu_size (void); - void max_sdu_size (u_long mss); - - // = Get/set the minimum policed size in bytes. - u_long minimum_policed_size (void); - void minimum_policed_size (u_long mps); -}; - -class ACE_Export ACE_QoS -#if defined (ACE_HAS_WINSOCK2) - : public QOS -#endif /* ACE_HAS_WINSOCK2 */ -{ - // = TITLE - // Wrapper class that holds the sender and receiver flow spec - // information, which is used by RSVP. -public: - // = Get/set the flow spec for data sending. - ACE_Flow_Spec sending_flowspec (void); - void sending_flowspec (const ACE_Flow_Spec &fs); - - // = Get/set the flow spec for data receiving. - ACE_Flow_Spec receiving_flowspec (void); - void receiving_flowspec (const ACE_Flow_Spec &fs); - - // = Get/set the provider specific information. - iovec provider_specific (void); - void provider_specific (const iovec &ps); -}; - -class ACE_Export ACE_Connect_QoS_Params -{ - // = TITLE - // Wrapper class that simplifies the information passed to the QoS - // enabled <ACE_OS::connect> and <ACE_OS::join_leaf> methods. -public: - ACE_Connect_QoS_Params (iovec *caller_data = 0, - iovec *callee_data = 0, - ACE_QoS *socket_qos = 0, - ACE_QoS *group_socket_qos = 0, - u_long flags = 0); - // Initialize the data members. The <caller_data> is a pointer to - // the user data that is to be transferred to the peer during - // connection establishment. The <callee_data> is a pointer to the - // user data that is to be transferred back from the peer during - // connection establishment. The_<socket_qos> is a pointer to the - // flow speicfications for the socket, one for each direction. The - // <group_socket_qos> is a pointer to the flow speicfications for - // the socket group, if applicable. The_<flags> indicate if we're a - // sender, receiver, or both. - - // = Get/set caller data. - iovec *caller_data (void) const; - void caller_data (iovec *); - - // = Get/set callee data. - iovec *callee_data (void) const; - void callee_data (iovec *); - - // = Get/set socket qos. - ACE_QoS *socket_qos (void) const; - void socket_qos (ACE_QoS *); - - // = Get/set group socket qos. - ACE_QoS *group_socket_qos (void) const; - void group_socket_qos (ACE_QoS *); - - // = Get/set flags. - u_long flags (void) const; - void flags (u_long); - -private: - iovec *caller_data_; - // A pointer to the user data that is to be transferred to the peer - // during connection establishment. - - iovec *callee_data_; - // A pointer to the user data that is to be transferred back from - // the peer during connection establishment. - - ACE_QoS *socket_qos_; - // A pointer to the flow speicfications for the socket, one for each - // direction. - - ACE_QoS *group_socket_qos_; - // A pointer to the flow speicfications for the socket group, if - // applicable. - - u_long flags_; - // Flags that indicate if we're a sender, receiver, or both. -}; - -// Callback function that's used by the QoS-enabled <ACE_OS::accept> -// method. -typedef int (*ACE_QOS_CONDITION_FUNC) (iovec *caller_id, - iovec *caller_data, - ACE_QoS *socket_qos, - ACE_QoS *group_socket_qos, - iovec *callee_id, - iovec *callee_data, - ACE_SOCK_GROUP *g, - u_long callbackdata); - -// Callback function that's used by the QoS-enabled <ACE_OS::ioctl> -// method. -typedef void (*ACE_OVERLAPPED_COMPLETION_FUNC) (u_long error, - u_long bytes_transferred, - ACE_OVERLAPPED *overlapped, - u_long flags); -class ACE_Export ACE_Accept_QoS_Params -{ - // = TITLE - // Wrapper class that simplifies the information passed to the QoS - // enabled <ACE_OS::accept> method. -public: - ACE_Accept_QoS_Params (ACE_QOS_CONDITION_FUNC qos_condition_callback = 0, - u_long callback_data = 0); - // Initialize the data members. The <qos_condition_callback> is the - // address of an optional, application-supplied condition function - // that will make an accept/reject decision based on the caller - // information pass in as parameters, and optionally create or join - // a socket group by assinging an appropriate value to the result - // parameter <g> of this function. The <callback_data> data is - // passed back to the application as a condition function parameter, - // i.e., it is an Asynchronous Completion Token (ACT). - - // = Get/set QoS condition callback. - ACE_QOS_CONDITION_FUNC qos_condition_callback (void) const; - void qos_condition_callback (ACE_QOS_CONDITION_FUNC qcc); - - // = Get/Set callback data. - u_long callback_data (void) const; - void callback_data (u_long cd); - -private: - ACE_QOS_CONDITION_FUNC qos_condition_callback_; - // This is the address of an optional, application-supplied - // condition function that will make an accept/reject decision based - // on the caller information pass in as parameters, and optionally - // create or join a socket group by assinging an appropriate value - // to the result parameter <g> of this function. - - u_long callback_data_; - // This data is passed back to the application as a condition - // function parameter, i.e., it is an Asynchronous Completion Token - // (ACT). -}; - class ACE_Export ACE_OS { // = TITLE @@ -5338,9 +5063,9 @@ public: static int memcmp (const void *t, const void *s, size_t len); - static const void *memchr (const void *s, - int c, - size_t len); + static void *memchr(const void *s, + int c, + size_t len); static void *memcpy (void *t, const void *s, size_t len); @@ -5465,17 +5190,6 @@ public: static int ioctl (ACE_HANDLE handle, int cmd, void * = 0); - // UNIX-style <ioctl>. - static int ioctl (ACE_HANDLE socket, - u_long io_control_code, - void *in_buffer_p, - u_long in_buffer, - void *out_buffer_p, - u_long out_buffer, - u_long *bytes_returned, - ACE_OVERLAPPED *overlapped, - ACE_OVERLAPPED_COMPLETION_FUNC func); - // QoS-enabled <ioctl>. static int isastream (ACE_HANDLE handle); static int isatty (ACE_HANDLE handle); static off_t lseek (ACE_HANDLE handle, @@ -5704,29 +5418,12 @@ public: static ACE_HANDLE accept (ACE_HANDLE handle, struct sockaddr *addr, int *addrlen); - // BSD-style <accept> (no QoS). - static ACE_HANDLE accept (ACE_HANDLE handle, - struct sockaddr *addr, - int *addrlen, - const ACE_Accept_QoS_Params &qos_params); - // QoS-enabled <accept>, which passes <qos_params> to <accept>. If - // the OS platform doesn't support QoS-enabled <accept> then the - // <qos_params> are ignored and the BSD-style <accept> is called. static int bind (ACE_HANDLE s, struct sockaddr *name, int namelen); static int connect (ACE_HANDLE handle, struct sockaddr *addr, int addrlen); - // BSD-style <connect> (no QoS). - static int connect (ACE_HANDLE handle, - const sockaddr *addr, - int addrlen, - const ACE_Connect_QoS_Params &qos_params); - // QoS-enabled <connect>, which passes <qos_params> to <connect>. - // If the OS platform doesn't support QoS-enabled <connect> then the - // <qos_params> are ignored and the BSD-style <connect> is called. - static int closesocket (ACE_HANDLE s); static struct hostent *gethostbyaddr (const char *addr, int length, @@ -5772,6 +5469,7 @@ public: static char *inet_ntoa (const struct in_addr addr); static int inet_aton (const char *strptr, struct in_addr *addr); + static const char *inet_ntop (int family, const void *addrptr, char *strptr, @@ -5779,11 +5477,8 @@ public: static int inet_pton (int family, const char *strptr, void *addrptr); - static ACE_HANDLE join_leaf (ACE_HANDLE socket, - const sockaddr *name, - int namelen, - const ACE_Connect_QoS_Params &qos_params); - // Joins a leaf node into a QoS-enabled multi-point session. + + static int listen (ACE_HANDLE handle, int backlog); static int recv (ACE_HANDLE handle, @@ -5814,22 +5509,11 @@ public: int optname, const char *optval, int optlen); - // QoS-enabled <ioctl> wrapper. static int shutdown (ACE_HANDLE handle, int how); static ACE_HANDLE socket (int domain, int type, int proto); - // Create a BSD-style socket (no QoS). - static ACE_HANDLE socket (int domain, - int type, - int proto, - ACE_Protocol_Info *protocolinfo, - ACE_SOCK_GROUP g, - u_long flags); - // Create a QoS-enabled socket. If the OS platform doesn't support - // QoS-enabled <socket> then the BSD-style <socket> is called. - static int socketpair (int domain, int type, int protocol, @@ -7277,18 +6961,6 @@ ACE_MAIN (int argc, ASYS_TCHAR *argv[]) /* user's entry point, e.g., main */ \ } \ int \ ace_main_i -# if defined (ACE_WIN32) && defined (UNICODE) -# define wmain \ -ace_main_i (int, ASYS_TCHAR *[]); /* forward declaration */ \ -int \ -wmain (int argc, ASYS_TCHAR *argv[]) /* user's entry point, e.g., main */ \ -{ \ - ACE_MAIN_OBJECT_MANAGER \ - return ace_main_i (argc, argv); /* what the user calls "main" */ \ -} \ -int \ -ace_main_i -# endif /* ACE_WIN32 && UNICODE */ # endif /* ACE_PSOSIM */ # endif /* ACE_HAS_NONSTATIC_OBJECT_MANAGER && !ACE_HAS_WINCE && !ACE_DOESNT_INSTANTIATE_NONSTATIC_OBJECT_MANAGER */ |