ACE_OS Namespace Reference

This namespace defines an OS independent programming API that shields developers from nonportable aspects of writing efficient system programs on Win32, POSIX and other versions of UNIX, and various real-time operating systems. More...


Classes

struct  macaddr_node_t
class  ace_flock_t
 OS file locking structure. More...


Functions from <cctype>

Included are the functions defined in and their equivalents.

Since they are often implemented as macros, we don't use the same name here. Instead, we change by prepending "ace_".

ACE_NAMESPACE_INLINE_FUNCTION
int 
ace_isalnum (ACE_TCHAR c)
 Returns true if the character is an alphanumeric character.

ACE_NAMESPACE_INLINE_FUNCTION
int 
ace_isalpha (ACE_TCHAR c)
 Returns true if the character is an alphabetic character.

ACE_NAMESPACE_INLINE_FUNCTION
int 
ace_iscntrl (ACE_TCHAR c)
 Returns true if the character is a control character.

ACE_NAMESPACE_INLINE_FUNCTION
int 
ace_isdigit (ACE_TCHAR c)
 Returns true if the character is a decimal-digit character.

ACE_NAMESPACE_INLINE_FUNCTION
int 
ace_isgraph (ACE_TCHAR c)
 Returns true if the character is a printable character other than a space.

ACE_NAMESPACE_INLINE_FUNCTION
int 
ace_islower (ACE_TCHAR c)
 Returns true if the character is a lowercase character.

ACE_NAMESPACE_INLINE_FUNCTION
int 
ace_isprint (ACE_TCHAR c)
 Returns true if the character is a printable character.

ACE_NAMESPACE_INLINE_FUNCTION
int 
ace_ispunct (ACE_TCHAR c)
 Returns true if the character is a punctuation character.

ACE_NAMESPACE_INLINE_FUNCTION
int 
ace_isspace (ACE_TCHAR c)
 Returns true if the character is a space character.

ACE_NAMESPACE_INLINE_FUNCTION
int 
ace_isupper (ACE_TCHAR c)
 Returns true if the character is an uppercase character.

ACE_NAMESPACE_INLINE_FUNCTION
int 
ace_isxdigit (ACE_TCHAR c)
 Returns true if the character is a hexadecimal-digit character.

ACE_NAMESPACE_INLINE_FUNCTION
int 
ace_tolower (int c)
 Converts a character to lower case (char version).

ACE_NAMESPACE_INLINE_FUNCTION
wint_t 
ace_towlower (wint_t c)
 Converts a character to lower case (wchar_t version).

ACE_NAMESPACE_INLINE_FUNCTION
int 
ace_toupper (int c)
 Converts a character to upper case (char version).

ACE_NAMESPACE_INLINE_FUNCTION
wint_t 
ace_towupper (wint_t c)
 Converts a character to upper case (wchar_t version).


A set of wrappers for explicit dynamic linking.

ACE_NAMESPACE_INLINE_FUNCTION
int 
dlclose (ACE_SHLIB_HANDLE handle)
ACE_NAMESPACE_INLINE_FUNCTION
ACE_TCHAR
dlerror (void)
ACE_NAMESPACE_INLINE_FUNCTION
ACE_SHLIB_HANDLE 
dlopen (const ACE_TCHAR *filename, int mode=ACE_DEFAULT_SHLIB_MODE)
ACE_NAMESPACE_INLINE_FUNCTION
void * 
dlsym (ACE_SHLIB_HANDLE handle, const ACE_TCHAR *symbol)

A set of wrappers for password routines.

ACE_NAMESPACE_INLINE_FUNCTION
void 
endpwent (void)
ACE_NAMESPACE_INLINE_FUNCTION
struct passwd * 
getpwent (void)
ACE_NAMESPACE_INLINE_FUNCTION
struct passwd * 
getpwnam (const char *user)
ACE_NAMESPACE_INLINE_FUNCTION
struct passwd * 
getpwnam_r (const char *name, struct passwd *pwent, char *buffer, int buflen)
ACE_NAMESPACE_INLINE_FUNCTION
void 
setpwent (void)

A set of wrappers for regular expressions.

ACE_NAMESPACE_INLINE_FUNCTION
char * 
compile (const char *instring, char *expbuf, char *endbuf)
ACE_NAMESPACE_INLINE_FUNCTION
int 
step (const char *str, char *expbuf)

A set of wrappers for Signals.

ACE_NAMESPACE_INLINE_FUNCTION
int 
kill (pid_t pid, int signum)
ACE_NAMESPACE_INLINE_FUNCTION
int 
pthread_sigmask (int how, const sigset_t *nsp, sigset_t *osp)
ACE_NAMESPACE_INLINE_FUNCTION
int 
sigaction (int signum, const ACE_SIGACTION *nsa, ACE_SIGACTION *osa)
ACE_NAMESPACE_INLINE_FUNCTION
int 
sigaddset (sigset_t *s, int signum)
ACE_NAMESPACE_INLINE_FUNCTION
int 
sigdelset (sigset_t *s, int signum)
ACE_NAMESPACE_INLINE_FUNCTION
int 
sigemptyset (sigset_t *s)
ACE_NAMESPACE_INLINE_FUNCTION
int 
sigfillset (sigset_t *s)
ACE_NAMESPACE_INLINE_FUNCTION
int 
sigismember (sigset_t *s, int signum)
ACE_NAMESPACE_INLINE_FUNCTION
ACE_SignalHandler 
signal (int signum, ACE_SignalHandler)
ACE_NAMESPACE_INLINE_FUNCTION
int 
sigprocmask (int how, const sigset_t *nsp, sigset_t *osp)
ACE_NAMESPACE_INLINE_FUNCTION
int 
sigsuspend (const sigset_t *set)

Wrappers to obtain the current user id

ACE_NAMESPACE_INLINE_FUNCTION
char * 
cuserid (char *user, size_t maxlen=ACE_MAX_USERID)
ACE_NAMESPACE_INLINE_FUNCTION
wchar_t * 
cuserid (wchar_t *user, size_t maxlen=ACE_MAX_USERID)

A set of wrappers for file locks.

ACE_NAMESPACE_INLINE_FUNCTION
void 
flock_adjust_params (ace_flock_t *lock, short whence, off_t &start, off_t &len)
ACE_NAMESPACE_INLINE_FUNCTION
int 
flock_init (ace_flock_t *lock, int flags=0, const ACE_TCHAR *name=0, mode_t perms=0)
ACE_NAMESPACE_INLINE_FUNCTION
int 
flock_destroy (ace_flock_t *lock, int unlink_file=1)
ACE_NAMESPACE_INLINE_FUNCTION
int 
flock_rdlock (ace_flock_t *lock, short whence=0, off_t start=0, off_t len=0)
ACE_NAMESPACE_INLINE_FUNCTION
int 
flock_tryrdlock (ace_flock_t *lock, short whence=0, off_t start=0, off_t len=0)
ACE_NAMESPACE_INLINE_FUNCTION
int 
flock_trywrlock (ace_flock_t *lock, short whence=0, off_t start=0, off_t len=0)
ACE_NAMESPACE_INLINE_FUNCTION
int 
flock_unlock (ace_flock_t *lock, short whence=0, off_t start=0, off_t len=0)
ACE_NAMESPACE_INLINE_FUNCTION
int 
flock_wrlock (ace_flock_t *lock, short whence=0, off_t start=0, off_t len=0)

Non-standard functions

These functions aren't in the standard.

ACE_NAMESPACE_INLINE_FUNCTION
void 
_exit (int status=0)
ACE_NAMESPACE_INLINE_FUNCTION
void 
abort (void)
ACE_NAMESPACE_INLINE_FUNCTION
int 
atexit (ACE_EXIT_HOOK func)
ACE_NAMESPACE_INLINE_FUNCTION
int 
atoi (const char *s)
ACE_NAMESPACE_INLINE_FUNCTION
int 
atoi (const wchar_t *s)
ACE_NAMESPACE_INLINE_FUNCTION
void * 
atop (const char *s)
ACE_NAMESPACE_INLINE_FUNCTION
void * 
atop (const wchar_t *s)
ACE_NAMESPACE_INLINE_FUNCTION
void * 
bsearch (const void *key, const void *base, size_t nel, size_t size, ACE_COMPARE_FUNC)
ACE_Export void * calloc (size_t elements, size_t sizeof_elements)
ACE_Export void exit (int status=0)
ACE_Export void free (void *)
ACE_NAMESPACE_INLINE_FUNCTION
char * 
getenv (const char *symbol)
ACE_NAMESPACE_INLINE_FUNCTION
wchar_t * 
getenv (const wchar_t *symbol)
ACE_Export ACE_TCHARgetenvstrings (void)
ACE_NAMESPACE_INLINE_FUNCTION
char * 
itoa (int value, char *string, int radix)
 Converts an integer to a string.

ACE_NAMESPACE_INLINE_FUNCTION
wchar_t * 
itoa (int value, wchar_t *string, int radix)
 Converts an integer to a string.

ACE_Export char * itoa_emulation (int value, char *string, int radix)
 Emulated itoa - Converts an integer to a string.

ACE_Export wchar_t * itow_emulation (int value, wchar_t *string, int radix)
 Emulated itow - Converts an integer to a string.

ACE_Export void * malloc (size_t)
ACE_NAMESPACE_INLINE_FUNCTION
ACE_HANDLE 
mkstemp (char *s)
ACE_NAMESPACE_INLINE_FUNCTION
ACE_HANDLE 
mkstemp (wchar_t *s)
ACE_NAMESPACE_INLINE_FUNCTION
char * 
mktemp (char *s)
ACE_NAMESPACE_INLINE_FUNCTION
wchar_t * 
mktemp (wchar_t *s)
ACE_NAMESPACE_INLINE_FUNCTION
int 
putenv (const char *string)
ACE_NAMESPACE_INLINE_FUNCTION
int 
putenv (const wchar_t *string)
ACE_NAMESPACE_INLINE_FUNCTION
void 
qsort (void *base, size_t nel, size_t width, ACE_COMPARE_FUNC)
ACE_NAMESPACE_INLINE_FUNCTION
int 
rand (void)
ACE_NAMESPACE_INLINE_FUNCTION
int 
rand_r (ACE_RANDR_TYPE &seed)
ACE_Export void * realloc (void *, size_t)
ACE_NAMESPACE_INLINE_FUNCTION
char * 
realpath (const char *file_name, char *resolved_name)
ACE_NAMESPACE_INLINE_FUNCTION
wchar_t * 
realpath (const wchar_t *file_name, wchar_t *resolved_name)
ACE_NAMESPACE_INLINE_FUNCTION
ACE_EXIT_HOOK 
set_exit_hook (ACE_EXIT_HOOK hook)
 For use by ACE_Object_Manager only, to register its exit hook..

ACE_NAMESPACE_INLINE_FUNCTION
void 
srand (u_int seed)
ACE_NAMESPACE_INLINE_FUNCTION
ACE_TCHAR
strenvdup (const ACE_TCHAR *str)
ACE_NAMESPACE_INLINE_FUNCTION
double 
strtod (const char *s, char **endptr)
 Converts a string to a double value (char version).

ACE_NAMESPACE_INLINE_FUNCTION
double 
strtod (const wchar_t *s, wchar_t **endptr)
 Converts a string to a double value (wchar_t version).

ACE_NAMESPACE_INLINE_FUNCTION
long 
strtol (const char *s, char **ptr, int base)
 Converts a string to a long value (char version).

ACE_NAMESPACE_INLINE_FUNCTION
long 
strtol (const wchar_t *s, wchar_t **ptr, int base)
 Converts a string to a long value (wchar_t version).

ACE_NAMESPACE_INLINE_FUNCTION
unsigned long 
strtoul (const char *s, char **ptr, int base)
 Converts a string to an unsigned long value (char version).

ACE_NAMESPACE_INLINE_FUNCTION
unsigned long 
strtoul (const wchar_t *s, wchar_t **ptr, int base)
 Converts a string to an unsigned long value (wchar_t version).

ACE_NAMESPACE_INLINE_FUNCTION
int 
system (const ACE_TCHAR *s)
ACE_Export ACE_EXIT_HOOK exit_hook_ = 0
 Function that is called by <ACE_OS::exit>, if non-null.


Functions from <cstring>

Included are the functions defined in and their equivalents.

Todo:
To be complete, we should add strcoll, and strxfrm.


ACE_NAMESPACE_INLINE_FUNCTION
const void * 
memchr (const void *s, int c, size_t len)
 Finds characters in a buffer (const void version).

ACE_NAMESPACE_INLINE_FUNCTION
void * 
memchr (void *s, int c, size_t len)
 Finds characters in a buffer (void version).

ACE_Export const void * memchr_emulation (const void *s, int c, size_t len)
 Emulated memchr - Finds a character in a buffer.

ACE_NAMESPACE_INLINE_FUNCTION
int 
memcmp (const void *t, const void *s, size_t len)
 Compares two buffers.

ACE_NAMESPACE_INLINE_FUNCTION
void * 
memcpy (void *t, const void *s, size_t len)
 Copies one buffer to another.

ACE_NAMESPACE_INLINE_FUNCTION
void * 
memmove (void *t, const void *s, size_t len)
 Moves one buffer to another.

ACE_NAMESPACE_INLINE_FUNCTION
void * 
memset (void *s, int c, size_t len)
 Fills a buffer with a character value.

ACE_NAMESPACE_INLINE_FUNCTION
char * 
strcat (char *s, const char *t)
 Appends a string to another string (char version).

ACE_NAMESPACE_INLINE_FUNCTION
wchar_t * 
strcat (wchar_t *s, const wchar_t *t)
 Appends a string to another string (wchar_t version).

ACE_NAMESPACE_INLINE_FUNCTION
const char * 
strchr (const char *s, int c)
ACE_NAMESPACE_INLINE_FUNCTION
const wchar_t * 
strchr (const wchar_t *s, wchar_t c)
ACE_NAMESPACE_INLINE_FUNCTION
char * 
strchr (char *s, int c)
 Finds the first occurance of a character in a string (char version).

ACE_NAMESPACE_INLINE_FUNCTION
wchar_t * 
strchr (wchar_t *s, wchar_t c)
 Finds the first occurance of a character in a string (wchar_t version).

ACE_NAMESPACE_INLINE_FUNCTION
int 
strcmp (const char *s, const char *t)
 Compares two strings (char version).

ACE_NAMESPACE_INLINE_FUNCTION
int 
strcmp (const ACE_WCHAR_T *s, const ACE_WCHAR_T *t)
 Compares two strings (wchar_t version).

ACE_NAMESPACE_INLINE_FUNCTION
char * 
strcpy (char *s, const char *t)
 Copies a string (char version).

ACE_NAMESPACE_INLINE_FUNCTION
wchar_t * 
strcpy (wchar_t *s, const wchar_t *t)
 Copies a string (wchar_t version).

ACE_NAMESPACE_INLINE_FUNCTION
size_t 
strcspn (const char *s, const char *reject)
ACE_NAMESPACE_INLINE_FUNCTION
size_t 
strcspn (const wchar_t *s, const wchar_t *reject)
ACE_NAMESPACE_INLINE_FUNCTION
char * 
strdup (const char *s)
 Returns a malloced duplicated string (char version).

ACE_NAMESPACE_INLINE_FUNCTION
wchar_t * 
strdup (const wchar_t *s)
 Returns a malloced duplicated string (wchar_t version).

ACE_Export char * strecpy (char *des, const char *src)
ACE_Export wchar_t * strecpy (wchar_t *s, const wchar_t *t)
ACE_Export char * strerror (int errnum)
 Finds characters in a buffer (const void version).

ACE_NAMESPACE_INLINE_FUNCTION
size_t 
strlen (const char *s)
 Finds the length of a string (char version).

ACE_NAMESPACE_INLINE_FUNCTION
size_t 
strlen (const ACE_WCHAR_T *s)
 Finds the length of a string (ACE_WCHAR_T version).

ACE_NAMESPACE_INLINE_FUNCTION
char * 
strncat (char *s, const char *t, size_t len)
 Appends part of a string to another string (char version).

ACE_NAMESPACE_INLINE_FUNCTION
ACE_WCHAR_T * 
strncat (ACE_WCHAR_T *s, const ACE_WCHAR_T *t, size_t len)
 Appends part of a string to another string (wchar_t version).

ACE_Export const char * strnchr (const char *s, int c, size_t len)
ACE_Export const ACE_WCHAR_T * strnchr (const ACE_WCHAR_T *s, ACE_WCHAR_T c, size_t len)
ACE_NAMESPACE_INLINE_FUNCTION
char * 
strnchr (char *s, int c, size_t len)
 Finds the first occurance of a character in an array (char version).

ACE_NAMESPACE_INLINE_FUNCTION
ACE_WCHAR_T * 
strnchr (ACE_WCHAR_T *s, ACE_WCHAR_T c, size_t len)
 Finds the first occurance of a character in an array (ACE_WCHAR_T version).

ACE_NAMESPACE_INLINE_FUNCTION
int 
strncmp (const char *s, const char *t, size_t len)
 Compares two arrays (char version).

ACE_NAMESPACE_INLINE_FUNCTION
int 
strncmp (const ACE_WCHAR_T *s, const ACE_WCHAR_T *t, size_t len)
 Compares two arrays (wchar_t version).

ACE_NAMESPACE_INLINE_FUNCTION
char * 
strncpy (char *s, const char *t, size_t len)
 Copies an array (char version).

ACE_NAMESPACE_INLINE_FUNCTION
ACE_WCHAR_T * 
strncpy (ACE_WCHAR_T *s, const ACE_WCHAR_T *t, size_t len)
 Copies an array (ACE_WCHAR_T version).

ACE_NAMESPACE_INLINE_FUNCTION
size_t 
strnlen (const char *s, size_t maxlen)
 Finds the length of a limited-length string (char version).

ACE_NAMESPACE_INLINE_FUNCTION
size_t 
strnlen (const ACE_WCHAR_T *s, size_t maxlen)
 Finds the length of a limited-length string (ACE_WCHAR_T version).

ACE_Export const char * strnstr (const char *s, const char *t, size_t len)
ACE_Export const ACE_WCHAR_T * strnstr (const ACE_WCHAR_T *s, const ACE_WCHAR_T *t, size_t len)
ACE_NAMESPACE_INLINE_FUNCTION
char * 
strnstr (char *s, const char *t, size_t len)
 Finds the first occurance of a substring in an array (char version).

ACE_NAMESPACE_INLINE_FUNCTION
ACE_WCHAR_T * 
strnstr (ACE_WCHAR_T *s, const ACE_WCHAR_T *t, size_t len)
 Finds the first occurance of a substring in an array (wchar_t version).

ACE_NAMESPACE_INLINE_FUNCTION
const char * 
strpbrk (const char *s1, const char *s2)
 Searches for characters in a string (const char version).

ACE_NAMESPACE_INLINE_FUNCTION
const wchar_t * 
strpbrk (const wchar_t *s1, const wchar_t *s2)
 Searches for characters in a string (const wchar_t version).

ACE_NAMESPACE_INLINE_FUNCTION
char * 
strpbrk (char *s1, const char *s2)
 Searches for characters in a string (char version).

ACE_NAMESPACE_INLINE_FUNCTION
wchar_t * 
strpbrk (wchar_t *s1, const wchar_t *s2)
 Searches for characters in a string (wchar_t version).

ACE_NAMESPACE_INLINE_FUNCTION
const char * 
strrchr (const char *s, int c)
ACE_NAMESPACE_INLINE_FUNCTION
const wchar_t * 
strrchr (const wchar_t *s, wchar_t c)
ACE_NAMESPACE_INLINE_FUNCTION
char * 
strrchr (char *s, int c)
 Finds the last occurance of a character in a string (char version).

ACE_NAMESPACE_INLINE_FUNCTION
wchar_t * 
strrchr (wchar_t *s, wchar_t c)
 Finds the last occurance of a character in a string (wchar_t version).

ACE_Export char * strrchr_emulation (char *s, int c)
ACE_Export const char * strrchr_emulation (const char *s, int c)
ACE_Export char * strsncpy (char *dst, const char *src, size_t maxlen)
 This is a "safe" c string copy function (char version).

ACE_Export ACE_WCHAR_T * strsncpy (ACE_WCHAR_T *dst, const ACE_WCHAR_T *src, size_t maxlen)
 This is a "safe" c string copy function (wchar_t version).

ACE_NAMESPACE_INLINE_FUNCTION
size_t 
strspn (const char *s1, const char *s2)
ACE_NAMESPACE_INLINE_FUNCTION
size_t 
strspn (const wchar_t *s1, const wchar_t *s2)
ACE_NAMESPACE_INLINE_FUNCTION
const char * 
strstr (const char *s, const char *t)
ACE_NAMESPACE_INLINE_FUNCTION
const wchar_t * 
strstr (const wchar_t *s, const wchar_t *t)
ACE_NAMESPACE_INLINE_FUNCTION
char * 
strstr (char *s, const char *t)
 Finds the first occurance of a substring in a string (char version).

ACE_NAMESPACE_INLINE_FUNCTION
wchar_t * 
strstr (wchar_t *s, const wchar_t *t)
 Finds the first occurance of a substring in a string (wchar_t version).

ACE_NAMESPACE_INLINE_FUNCTION
char * 
strtok (char *s, const char *tokens)
 Finds the next token in a string (char version).

ACE_NAMESPACE_INLINE_FUNCTION
wchar_t * 
strtok (wchar_t *s, const wchar_t *tokens)
 Finds the next token in a string (wchar_t version).


A set of wrappers for memory mapped files.

ACE_NAMESPACE_INLINE_FUNCTION
int 
madvise (caddr_t addr, size_t len, int map_advice)
ACE_NAMESPACE_INLINE_FUNCTION
void * 
mmap (void *addr, size_t len, int prot, int flags, ACE_HANDLE handle, off_t off=0, ACE_HANDLE *file_mapping=0, LPSECURITY_ATTRIBUTES sa=0, const ACE_TCHAR *file_mapping_name=0)
ACE_NAMESPACE_INLINE_FUNCTION
int 
mprotect (void *addr, size_t len, int prot)
ACE_NAMESPACE_INLINE_FUNCTION
int 
msync (void *addr, size_t len, int sync)
ACE_NAMESPACE_INLINE_FUNCTION
int 
munmap (void *addr, size_t len)

A set of wrappers for System V message queues.

ACE_NAMESPACE_INLINE_FUNCTION
int 
msgctl (int msqid, int cmd, struct msqid_ds *)
ACE_NAMESPACE_INLINE_FUNCTION
int 
msgget (key_t key, int msgflg)
ACE_NAMESPACE_INLINE_FUNCTION
ssize_t 
msgrcv (int int_id, void *buf, size_t len, long type, int flags)
ACE_NAMESPACE_INLINE_FUNCTION
int 
msgsnd (int int_id, const void *buf, size_t len, int flags)

A set of wrappers for System V shared memory.

ACE_NAMESPACE_INLINE_FUNCTION
void * 
shmat (int int_id, const void *shmaddr, int shmflg)
ACE_NAMESPACE_INLINE_FUNCTION
int 
shmctl (int int_id, int cmd, struct shmid_ds *buf)
ACE_NAMESPACE_INLINE_FUNCTION
int 
shmdt (const void *shmaddr)
ACE_NAMESPACE_INLINE_FUNCTION
int 
shmget (key_t key, size_t size, int flags)

A set of wrappers for sockets.

ACE_NAMESPACE_INLINE_FUNCTION
ACE_HANDLE 
accept (ACE_HANDLE handle, struct sockaddr *addr, int *addrlen)
 BSD-style (no QoS).

ACE_Export ACE_HANDLE accept (ACE_HANDLE handle, struct sockaddr *addr, int *addrlen, const ACE_Accept_QoS_Params &qos_params)
ACE_NAMESPACE_INLINE_FUNCTION
int 
bind (ACE_HANDLE s, struct sockaddr *name, int namelen)
 BSD-style (no QoS).

ACE_NAMESPACE_INLINE_FUNCTION
int 
closesocket (ACE_HANDLE s)
 BSD-style (no QoS).

ACE_NAMESPACE_INLINE_FUNCTION
int 
connect (ACE_HANDLE handle, struct sockaddr *addr, int addrlen)
 BSD-style (no QoS).

ACE_Export int connect (ACE_HANDLE handle, const sockaddr *addr, int addrlen, const ACE_QoS_Params &qos_params)
ACE_NAMESPACE_INLINE_FUNCTION
int 
enum_protocols (int *protocols, ACE_Protocol_Info *protocol_buffer, u_long *buffer_length)
ACE_NAMESPACE_INLINE_FUNCTION
int 
getpeername (ACE_HANDLE handle, struct sockaddr *addr, int *addrlen)
 BSD-style (no QoS).

ACE_NAMESPACE_INLINE_FUNCTION
int 
getsockname (ACE_HANDLE handle, struct sockaddr *addr, int *addrlen)
 BSD-style (no QoS).

ACE_NAMESPACE_INLINE_FUNCTION
int 
getsockopt (ACE_HANDLE handle, int level, int optname, char *optval, int *optlen)
 BSD-style (no QoS).

ACE_Export ACE_HANDLE join_leaf (ACE_HANDLE socket, const sockaddr *name, int namelen, const ACE_QoS_Params &qos_params)
 Joins a leaf node into a QoS-enabled multi-point session.

ACE_NAMESPACE_INLINE_FUNCTION
int 
listen (ACE_HANDLE handle, int backlog)
 BSD-style (no QoS).

ACE_NAMESPACE_INLINE_FUNCTION
ssize_t 
recv (ACE_HANDLE handle, char *buf, size_t len, int flags=0)
 BSD-style (no QoS).

ACE_NAMESPACE_INLINE_FUNCTION
ssize_t 
recvfrom (ACE_HANDLE handle, char *buf, size_t len, int flags, struct sockaddr *addr, int *addrlen)
 BSD-style (no QoS).

ACE_NAMESPACE_INLINE_FUNCTION
ssize_t 
recvfrom (ACE_HANDLE handle, iovec *buffers, int buffer_count, size_t &number_of_bytes_recvd, int &flags, struct sockaddr *addr, int *addrlen, ACE_OVERLAPPED *overlapped, ACE_OVERLAPPED_COMPLETION_FUNC func)
 BSD-style (no QoS).

ACE_NAMESPACE_INLINE_FUNCTION
ssize_t 
recvmsg (ACE_HANDLE handle, struct msghdr *msg, int flags)
 BSD-style (no QoS).

ACE_NAMESPACE_INLINE_FUNCTION
ssize_t 
recvv (ACE_HANDLE handle, iovec *iov, int iovlen)
 BSD-style (no QoS).

ACE_NAMESPACE_INLINE_FUNCTION
ssize_t 
send (ACE_HANDLE handle, const char *buf, size_t len, int flags=0)
 BSD-style (no QoS).

ACE_NAMESPACE_INLINE_FUNCTION
ssize_t 
sendmsg (ACE_HANDLE handle, const struct msghdr *msg, int flags)
 BSD-style (no QoS).

ACE_NAMESPACE_INLINE_FUNCTION
ssize_t 
sendto (ACE_HANDLE handle, const char *buf, size_t len, int flags, const struct sockaddr *addr, int addrlen)
 BSD-style (no QoS).

ACE_NAMESPACE_INLINE_FUNCTION
ssize_t 
sendto (ACE_HANDLE handle, const iovec *buffers, int buffer_count, size_t &number_of_bytes_sent, int flags, const struct sockaddr *addr, int addrlen, ACE_OVERLAPPED *overlapped, ACE_OVERLAPPED_COMPLETION_FUNC func)
 BSD-style (no QoS).

ACE_NAMESPACE_INLINE_FUNCTION
ssize_t 
sendv (ACE_HANDLE handle, const iovec *iov, int iovcnt)
 BSD-style (no QoS).

ACE_NAMESPACE_INLINE_FUNCTION
int 
setsockopt (ACE_HANDLE handle, int level, int optname, const char *optval, int optlen)
 Manipulate the options associated with a socket.

ACE_NAMESPACE_INLINE_FUNCTION
int 
shutdown (ACE_HANDLE handle, int how)
 BSD-style (no QoS).

ACE_Export int socket_init (int version_high=1, int version_low=1)
ACE_Export int socket_fini (void)
 Finalize WinSock after last use (e.g., when a DLL is unloaded).

ACE_NAMESPACE_INLINE_FUNCTION
ACE_HANDLE 
socket (int protocol_family, int type, int proto)
 Create a BSD-style socket (no QoS).

ACE_NAMESPACE_INLINE_FUNCTION
ACE_HANDLE 
socket (int protocol_family, int type, int proto, ACE_Protocol_Info *protocolinfo, ACE_SOCK_GROUP g, u_long flags)
ACE_NAMESPACE_INLINE_FUNCTION
int 
socketpair (int domain, int type, int protocol, ACE_HANDLE sv[2])
 BSD-style (no QoS).


A set of wrappers for low-level file operations.

ACE_NAMESPACE_INLINE_FUNCTION
ACE_LOFF_T 
filesize (ACE_HANDLE handle)
ACE_NAMESPACE_INLINE_FUNCTION
ACE_LOFF_T 
filesize (const ACE_TCHAR *handle)

A set of wrappers for condition variables.

ACE_NAMESPACE_INLINE_FUNCTION
int 
condattr_init (ACE_condattr_t &attributes, int type=ACE_DEFAULT_SYNCH_TYPE)
ACE_NAMESPACE_INLINE_FUNCTION
int 
condattr_destroy (ACE_condattr_t &attributes)
ACE_NAMESPACE_INLINE_FUNCTION
int 
cond_broadcast (ACE_cond_t *cv)
ACE_NAMESPACE_INLINE_FUNCTION
int 
cond_destroy (ACE_cond_t *cv)
ACE_Export int cond_init (ACE_cond_t *cv, short type=ACE_DEFAULT_SYNCH_TYPE, const char *name=0, void *arg=0)
ACE_NAMESPACE_INLINE_FUNCTION
int 
cond_init (ACE_cond_t *cv, ACE_condattr_t &attributes, const char *name=0, void *arg=0)
ACE_NAMESPACE_INLINE_FUNCTION
int 
cond_init (ACE_cond_t *cv, short type, const wchar_t *name, void *arg=0)
ACE_NAMESPACE_INLINE_FUNCTION
int 
cond_init (ACE_cond_t *cv, ACE_condattr_t &attributes, const wchar_t *name, void *arg=0)
ACE_NAMESPACE_INLINE_FUNCTION
int 
cond_signal (ACE_cond_t *cv)
ACE_NAMESPACE_INLINE_FUNCTION
int 
cond_timedwait (ACE_cond_t *cv, ACE_mutex_t *m, ACE_Time_Value *)
ACE_NAMESPACE_INLINE_FUNCTION
int 
cond_wait (ACE_cond_t *cv, ACE_mutex_t *m)

A set of wrappers for auto-reset and manual events.

ACE_Export int event_destroy (ACE_event_t *event)
ACE_Export int event_init (ACE_event_t *event, int manual_reset=0, int initial_state=0, int type=ACE_DEFAULT_SYNCH_TYPE, const char *name=0, void *arg=0, LPSECURITY_ATTRIBUTES sa=0)
ACE_NAMESPACE_INLINE_FUNCTION
int 
event_init (ACE_event_t *event, int manual_reset, int initial_state, int type, const wchar_t *name, void *arg=0, LPSECURITY_ATTRIBUTES sa=0)
ACE_Export int event_pulse (ACE_event_t *event)
ACE_Export int event_reset (ACE_event_t *event)
ACE_Export int event_signal (ACE_event_t *event)
ACE_Export int event_timedwait (ACE_event_t *event, ACE_Time_Value *timeout, int use_absolute_time=1)
ACE_Export int event_wait (ACE_event_t *event)

A set of wrappers for mutex locks.

ACE_Export int mutex_destroy (ACE_mutex_t *m)
ACE_Export int mutex_init (ACE_mutex_t *m, int lock_scope=ACE_DEFAULT_SYNCH_TYPE, const char *name=0, ACE_mutexattr_t *arg=0, LPSECURITY_ATTRIBUTES sa=0, int lock_type=0)
ACE_Export int mutex_init (ACE_mutex_t *m, int lock_scope, const wchar_t *name, ACE_mutexattr_t *arg=0, LPSECURITY_ATTRIBUTES sa=0, int lock_type=0)
ACE_Export int mutex_lock (ACE_mutex_t *m)
ACE_Export int mutex_lock (ACE_mutex_t *m, int &abandoned)
ACE_Export int mutex_lock (ACE_mutex_t *m, const ACE_Time_Value &timeout)
ACE_NAMESPACE_INLINE_FUNCTION
int 
mutex_lock (ACE_mutex_t *m, const ACE_Time_Value *timeout)
ACE_Export void mutex_lock_cleanup (void *mutex)
 Handle asynchronous thread cancellation cleanup.

ACE_Export int mutex_trylock (ACE_mutex_t *m)
ACE_Export int mutex_trylock (ACE_mutex_t *m, int &abandoned)
ACE_Export int mutex_unlock (ACE_mutex_t *m)

A set of wrappers for recursive mutex locks.

ACE_NAMESPACE_INLINE_FUNCTION
int 
recursive_mutex_cond_unlock (ACE_recursive_thread_mutex_t *m, ACE_recursive_mutex_state &state)
ACE_NAMESPACE_INLINE_FUNCTION
void 
recursive_mutex_cond_relock (ACE_recursive_thread_mutex_t *m, ACE_recursive_mutex_state &state)
ACE_NAMESPACE_INLINE_FUNCTION
int 
recursive_mutex_destroy (ACE_recursive_thread_mutex_t *m)
ACE_NAMESPACE_INLINE_FUNCTION
int 
recursive_mutex_init (ACE_recursive_thread_mutex_t *m, const ACE_TCHAR *name=0, ACE_mutexattr_t *arg=0, LPSECURITY_ATTRIBUTES sa=0)
ACE_NAMESPACE_INLINE_FUNCTION
int 
recursive_mutex_lock (ACE_recursive_thread_mutex_t *m)
ACE_NAMESPACE_INLINE_FUNCTION
int 
recursive_mutex_lock (ACE_recursive_thread_mutex_t *m, const ACE_Time_Value &timeout)
ACE_NAMESPACE_INLINE_FUNCTION
int 
recursive_mutex_lock (ACE_recursive_thread_mutex_t *m, const ACE_Time_Value *timeout)
ACE_NAMESPACE_INLINE_FUNCTION
int 
recursive_mutex_trylock (ACE_recursive_thread_mutex_t *m)
ACE_NAMESPACE_INLINE_FUNCTION
int 
recursive_mutex_unlock (ACE_recursive_thread_mutex_t *m)

A set of wrappers for readers/writer locks.

ACE_NAMESPACE_INLINE_FUNCTION
int 
rw_rdlock (ACE_rwlock_t *rw)
ACE_NAMESPACE_INLINE_FUNCTION
int 
rw_tryrdlock (ACE_rwlock_t *rw)
ACE_NAMESPACE_INLINE_FUNCTION
int 
rw_trywrlock (ACE_rwlock_t *rw)
ACE_NAMESPACE_INLINE_FUNCTION
int 
rw_trywrlock_upgrade (ACE_rwlock_t *rw)
ACE_NAMESPACE_INLINE_FUNCTION
int 
rw_unlock (ACE_rwlock_t *rw)
ACE_NAMESPACE_INLINE_FUNCTION
int 
rw_wrlock (ACE_rwlock_t *rw)
ACE_NAMESPACE_INLINE_FUNCTION
int 
rwlock_destroy (ACE_rwlock_t *rw)
ACE_Export int rwlock_init (ACE_rwlock_t *rw, int type=ACE_DEFAULT_SYNCH_TYPE, const ACE_TCHAR *name=0, void *arg=0)

Thread scheduler interface.

ACE_Export int sched_params (const ACE_Sched_Params &, ACE_id_t id=ACE_SELF)

A set of wrappers for semaphores.

ACE_NAMESPACE_INLINE_FUNCTION
int 
sema_destroy (ACE_sema_t *s)
ACE_NAMESPACE_INLINE_FUNCTION
int 
sema_init (ACE_sema_t *s, u_int count, int type=ACE_DEFAULT_SYNCH_TYPE, const char *name=0, void *arg=0, int max=0x7fffffff, LPSECURITY_ATTRIBUTES sa=0)
ACE_NAMESPACE_INLINE_FUNCTION
int 
sema_init (ACE_sema_t *s, u_int count, int type, const wchar_t *name, void *arg=0, int max=0x7fffffff, LPSECURITY_ATTRIBUTES sa=0)
ACE_NAMESPACE_INLINE_FUNCTION
int 
sema_post (ACE_sema_t *s)
ACE_NAMESPACE_INLINE_FUNCTION
int 
sema_post (ACE_sema_t *s, u_int release_count)
ACE_NAMESPACE_INLINE_FUNCTION
int 
sema_trywait (ACE_sema_t *s)
ACE_NAMESPACE_INLINE_FUNCTION
int 
sema_wait (ACE_sema_t *s)
ACE_NAMESPACE_INLINE_FUNCTION
int 
sema_wait (ACE_sema_t *s, ACE_Time_Value &tv)
ACE_NAMESPACE_INLINE_FUNCTION
int 
sema_wait (ACE_sema_t *s, ACE_Time_Value *tv)

A set of wrappers for System V semaphores.

ACE_NAMESPACE_INLINE_FUNCTION
int 
semctl (int int_id, int semnum, int cmd, semun)
ACE_NAMESPACE_INLINE_FUNCTION
int 
semget (key_t key, int nsems, int flags)
ACE_NAMESPACE_INLINE_FUNCTION
int 
semop (int int_id, struct sembuf *sops, size_t nsops)

A set of wrappers for mutex locks that only work within a single process.

ACE_NAMESPACE_INLINE_FUNCTION
int 
thread_mutex_destroy (ACE_thread_mutex_t *m)
ACE_NAMESPACE_INLINE_FUNCTION
int 
thread_mutex_init (ACE_thread_mutex_t *m, int lock_type=0, const char *name=0, ACE_mutexattr_t *arg=0)
ACE_NAMESPACE_INLINE_FUNCTION
int 
thread_mutex_init (ACE_thread_mutex_t *m, int lock_type, const wchar_t *name, ACE_mutexattr_t *arg=0)
ACE_NAMESPACE_INLINE_FUNCTION
int 
thread_mutex_lock (ACE_thread_mutex_t *m)
ACE_NAMESPACE_INLINE_FUNCTION
int 
thread_mutex_lock (ACE_thread_mutex_t *m, const ACE_Time_Value &timeout)
ACE_NAMESPACE_INLINE_FUNCTION
int 
thread_mutex_lock (ACE_thread_mutex_t *m, const ACE_Time_Value *timeout)
ACE_NAMESPACE_INLINE_FUNCTION
int 
thread_mutex_trylock (ACE_thread_mutex_t *m)
ACE_NAMESPACE_INLINE_FUNCTION
int 
thread_mutex_unlock (ACE_thread_mutex_t *m)

A set of wrappers for operations on time.

ACE_NAMESPACE_INLINE_FUNCTION
char * 
asctime (const struct tm *tm)
ACE_NAMESPACE_INLINE_FUNCTION
char * 
asctime_r (const struct tm *tm, char *buf, int buflen)
ACE_NAMESPACE_INLINE_FUNCTION
int 
clock_gettime (clockid_t, struct timespec *)
ACE_NAMESPACE_INLINE_FUNCTION
int 
clock_settime (clockid_t, const struct timespec *)
ACE_NAMESPACE_INLINE_FUNCTION
ACE_TCHAR
ctime (const time_t *t)
ACE_NAMESPACE_INLINE_FUNCTION
ACE_TCHAR
ctime_r (const time_t *clock, ACE_TCHAR *buf, int buflen)
ACE_NAMESPACE_INLINE_FUNCTION
double 
difftime (time_t t1, time_t t0)
ACE_NAMESPACE_INLINE_FUNCTION
ACE_hrtime_t 
gethrtime (const ACE_HRTimer_Op=ACE_HRTIMER_GETTIME)
ACE_NAMESPACE_INLINE_FUNCTION
struct tm * 
gmtime (const time_t *clock)
ACE_NAMESPACE_INLINE_FUNCTION
struct tm * 
gmtime_r (const time_t *clock, struct tm *res)
ACE_NAMESPACE_INLINE_FUNCTION
struct tm * 
localtime (const time_t *clock)
ACE_Export struct tm * localtime_r (const time_t *clock, struct tm *res)
ACE_Export time_t mktime (struct tm *timeptr)
ACE_NAMESPACE_INLINE_FUNCTION
int 
nanosleep (const struct timespec *requested, struct timespec *remaining=0)
ACE_NAMESPACE_INLINE_FUNCTION
size_t 
strftime (char *s, size_t maxsize, const char *format, const struct tm *timeptr)
ACE_NAMESPACE_INLINE_FUNCTION
char * 
strptime (const char *buf, const char *format, struct tm *tm)
ACE_NAMESPACE_INLINE_FUNCTION
time_t 
time (time_t *tloc=0)
ACE_NAMESPACE_INLINE_FUNCTION
long 
timezone (void)
ACE_NAMESPACE_INLINE_FUNCTION
void 
tzset (void)

[NOHEADER]

ACE_NAMESPACE_INLINE_FUNCTION
pid_t 
fork (void)
ACE_Export pid_t fork (const ACE_TCHAR *program_name)
ACE_Export pid_t fork_exec (ACE_TCHAR *argv[])

A set of wrappers for threads

ACE_Export ACE_thread_t NULL_thread
ACE_Export ACE_hthread_t NULL_hthread
ACE_Export ACE_thread_key_t NULL_key

Typedefs

typedef ACE_WCHAR_T WChar

Enumerations

enum  ACE_HRTimer_Op { ACE_HRTIMER_START = 0x0, ACE_HRTIMER_INCR = 0x1, ACE_HRTIMER_STOP = 0x2, ACE_HRTIMER_GETTIME = 0xFFFF }

Functions

ACE_NAMESPACE_INLINE_FUNCTION
unsigned long 
inet_addr (const char *name)
ACE_Export int inet_aton (const char *strptr, struct in_addr *addr)
ACE_NAMESPACE_INLINE_FUNCTION
char * 
inet_ntoa (const struct in_addr addr)
ACE_NAMESPACE_INLINE_FUNCTION
const char * 
inet_ntop (int family, const void *addrptr, char *strptr, size_t len)
ACE_NAMESPACE_INLINE_FUNCTION
int 
inet_pton (int family, const char *strptr, void *addrptr)
ACE_NAMESPACE_INLINE_FUNCTION
void 
closedir (ACE_DIR *)
ACE_NAMESPACE_INLINE_FUNCTION
ACE_DIR
opendir (const ACE_TCHAR *filename)
ACE_NAMESPACE_INLINE_FUNCTION
struct ACE_DIRENT * 
readdir (ACE_DIR *)
ACE_NAMESPACE_INLINE_FUNCTION
int 
readdir_r (ACE_DIR *dirp, struct ACE_DIRENT *entry, struct ACE_DIRENT **result)
ACE_NAMESPACE_INLINE_FUNCTION
void 
rewinddir (ACE_DIR *)
ACE_NAMESPACE_INLINE_FUNCTION
int 
scandir (const ACE_TCHAR *dirname, struct ACE_DIRENT **namelist[], int(*selector)(const struct ACE_DIRENT *filename), int(*comparator)(const struct ACE_DIRENT **f1, const struct ACE_DIRENT **f2))
ACE_NAMESPACE_INLINE_FUNCTION
void 
seekdir (ACE_DIR *, long loc)
ACE_NAMESPACE_INLINE_FUNCTION
long 
telldir (ACE_DIR *)
ACE_Export int scandir_emulation (const ACE_TCHAR *dirname, ACE_DIRENT **namelist[], int(*selector)(const ACE_DIRENT *entry), int(*comparator)(const ACE_DIRENT **f1, const ACE_DIRENT **f2))
ACE_INLINE int scandir (const ACE_TCHAR *dirname, struct ACE_DIRENT **namelist[], int(*selector)(const struct ACE_DIRENT *), int(*comparator)(const struct ACE_DIRENT **f1, const struct ACE_DIRENT **f2))
ACE_NAMESPACE_INLINE_FUNCTION
int 
last_error (void)
ACE_NAMESPACE_INLINE_FUNCTION
void 
last_error (int)
ACE_NAMESPACE_INLINE_FUNCTION
int 
set_errno_to_last_error (void)
ACE_NAMESPACE_INLINE_FUNCTION
int 
set_errno_to_wsa_last_error (void)
ACE_NAMESPACE_INLINE_FUNCTION
int 
fcntl (ACE_HANDLE handle, int cmd, long arg=0)
ACE_Export ACE_HANDLE open (const char *filename, int mode, int perms=ACE_DEFAULT_OPEN_PERMS, LPSECURITY_ATTRIBUTES sa=0)
ACE_Export ACE_HANDLE open (const wchar_t *filename, int mode, int perms=ACE_DEFAULT_OPEN_PERMS, LPSECURITY_ATTRIBUTES sa=0)
ACE_NAMESPACE_INLINE_FUNCTION
double 
floor (double x)
 This method computes the largest integral value not greater than x.

ACE_NAMESPACE_INLINE_FUNCTION
double 
ceil (double x)
 This method computes the smallest integral value not less than x.

ACE_NAMESPACE_INLINE_FUNCTION
struct hostent * 
gethostbyaddr (const char *addr, int length, int type)
ACE_NAMESPACE_INLINE_FUNCTION
struct hostent * 
gethostbyaddr_r (const char *addr, int length, int type, struct hostent *result, ACE_HOSTENT_DATA buffer, int *h_errnop)
ACE_NAMESPACE_INLINE_FUNCTION
struct hostent * 
gethostbyname (const char *name)
ACE_NAMESPACE_INLINE_FUNCTION
struct hostent * 
gethostbyname_r (const char *name, struct hostent *result, ACE_HOSTENT_DATA buffer, int *h_errnop)
ACE_NAMESPACE_INLINE_FUNCTION
struct hostent * 
getipnodebyaddr (const void *src, size_t len, int family)
ACE_NAMESPACE_INLINE_FUNCTION
struct hostent * 
getipnodebyname (const char *name, int family, int flags=0)
ACE_Export int getmacaddress (struct macaddr_node_t *node)
ACE_NAMESPACE_INLINE_FUNCTION
struct protoent * 
getprotobyname (const char *name)
ACE_NAMESPACE_INLINE_FUNCTION
struct protoent * 
getprotobyname_r (const char *name, struct protoent *result, ACE_PROTOENT_DATA buffer)
ACE_NAMESPACE_INLINE_FUNCTION
struct protoent * 
getprotobynumber (int proto)
ACE_NAMESPACE_INLINE_FUNCTION
struct protoent * 
getprotobynumber_r (int proto, struct protoent *result, ACE_PROTOENT_DATA buffer)
ACE_NAMESPACE_INLINE_FUNCTION
struct servent * 
getservbyname (const char *svc, const char *proto)
ACE_NAMESPACE_INLINE_FUNCTION
struct servent * 
getservbyname_r (const char *svc, const char *proto, struct servent *result, ACE_SERVENT_DATA buf)
ACE_NAMESPACE_INLINE_FUNCTION
int 
poll (struct pollfd *pollfds, unsigned long len, const ACE_Time_Value *tv=0)
ACE_NAMESPACE_INLINE_FUNCTION
int 
poll (struct pollfd *pollfds, unsigned long len, const ACE_Time_Value &tv)
ACE_NAMESPACE_INLINE_FUNCTION
void 
clearerr (FILE *fp)
ACE_NAMESPACE_INLINE_FUNCTION
int 
fclose (FILE *fp)
ACE_NAMESPACE_INLINE_FUNCTION
FILE * 
fdopen (ACE_HANDLE handle, const ACE_TCHAR *mode)
ACE_NAMESPACE_INLINE_FUNCTION
int 
fflush (FILE *fp)
ACE_NAMESPACE_INLINE_FUNCTION
int 
fgetc (FILE *fp)
ACE_NAMESPACE_INLINE_FUNCTION
int 
fgetpos (FILE *fp, fpos_t *pos)
ACE_NAMESPACE_INLINE_FUNCTION
char * 
fgets (char *buf, int size, FILE *fp)
ACE_NAMESPACE_INLINE_FUNCTION
wchar_t * 
fgets (wchar_t *buf, int size, FILE *fp)
ACE_Export FILE * fopen (const char *filename, const ACE_TCHAR *mode)
ACE_Export FILE * fopen (const wchar_t *filename, const ACE_TCHAR *mode)
ACE_NAMESPACE_INLINE_FUNCTION
LPSECURITY_ATTRIBUTES 
default_win32_security_attributes (LPSECURITY_ATTRIBUTES)
 Default Win32 Security Attributes definition.

ACE_NAMESPACE_INLINE_FUNCTION
LPSECURITY_ATTRIBUTES 
default_win32_security_attributes_r (LPSECURITY_ATTRIBUTES, LPSECURITY_ATTRIBUTES, SECURITY_DESCRIPTOR *)
ACE_NAMESPACE_INLINE_FUNCTION
const OSVERSIONINFO & 
get_win32_versioninfo (void)
 Return the win32 OSVERSIONINFO structure.

ACE_NAMESPACE_INLINE_FUNCTION
HINSTANCE 
get_win32_resource_module (void)
ACE_NAMESPACE_INLINE_FUNCTION
void 
set_win32_resource_module (HINSTANCE)
ACE_NAMESPACE_INLINE_FUNCTION
void 
fopen_mode_to_open_mode_converter (ACE_TCHAR x, int &hmode)
ACE_Export int fprintf (FILE *fp, const char *format,...)
ACE_Export int fprintf (FILE *fp, const wchar_t *format,...)
ACE_NAMESPACE_INLINE_FUNCTION
int 
fputs (const char *s, FILE *stream)
ACE_NAMESPACE_INLINE_FUNCTION
int 
fputs (const wchar_t *s, FILE *stream)
ACE_NAMESPACE_INLINE_FUNCTION
size_t 
fread (void *ptr, size_t size, size_t nelems, FILE *fp)
ACE_NAMESPACE_INLINE_FUNCTION
FILE * 
freopen (const ACE_TCHAR *filename, const ACE_TCHAR *mode, FILE *stream)
ACE_NAMESPACE_INLINE_FUNCTION
int 
fseek (FILE *fp, long offset, int ptrname)
ACE_NAMESPACE_INLINE_FUNCTION
int 
fsetpos (FILE *fp, fpos_t *pos)
ACE_NAMESPACE_INLINE_FUNCTION
long 
ftell (FILE *fp)
ACE_NAMESPACE_INLINE_FUNCTION
size_t 
fwrite (const void *ptr, size_t size, size_t nitems, FILE *fp)
ACE_NAMESPACE_INLINE_FUNCTION
void 
perror (const char *s)
ACE_NAMESPACE_INLINE_FUNCTION
void 
perror (const wchar_t *s)
ACE_Export int printf (const char *format,...)
ACE_NAMESPACE_INLINE_FUNCTION
int 
puts (const char *s)
ACE_NAMESPACE_INLINE_FUNCTION
int 
puts (const wchar_t *s)
ACE_NAMESPACE_INLINE_FUNCTION
int 
rename (const char *old_name, const char *new_name, int flags=-1)
ACE_NAMESPACE_INLINE_FUNCTION
int 
rename (const wchar_t *old_name, const wchar_t *new_name, int flags=-1)
ACE_NAMESPACE_INLINE_FUNCTION
void 
rewind (FILE *fp)
ACE_Export int snprintf (char *buf, size_t maxlen, const char *format,...)
ACE_Export int snprintf (wchar_t *buf, size_t maxlen, const wchar_t *format,...)
ACE_Export int sprintf (char *buf, const char *format,...)
ACE_Export int sprintf (wchar_t *buf, const wchar_t *format,...)
ACE_NAMESPACE_INLINE_FUNCTION
char * 
tempnam (const char *dir=0, const char *pfx=0)
ACE_NAMESPACE_INLINE_FUNCTION
wchar_t * 
tempnam (const wchar_t *dir, const wchar_t *pfx=0)
ACE_NAMESPACE_INLINE_FUNCTION
int 
vsprintf (char *buffer, const char *format, va_list argptr)
ACE_NAMESPACE_INLINE_FUNCTION
int 
vsnprintf (char *buffer, size_t maxlen, const char *format, va_list argptr)
ACE_NAMESPACE_INLINE_FUNCTION
int 
vsprintf (wchar_t *buffer, const wchar_t *format, va_list argptr)
ACE_NAMESPACE_INLINE_FUNCTION
int 
vsnprintf (wchar_t *buffer, size_t maxlen, const wchar_t *format, va_list argptr)
ACE_NAMESPACE_INLINE_FUNCTION
char * 
strtok_r (char *s, const char *tokens, char **lasts)
 Finds the next token in a string (safe char version).

ACE_NAMESPACE_INLINE_FUNCTION
wchar_t * 
strtok_r (ACE_WCHAR_T *s, const ACE_WCHAR_T *tokens, ACE_WCHAR_T **lasts)
 Finds the next token in a string (wchar_t version).

ACE_Export char * strtok_r_emulation (char *s, const char *tokens, char **lasts)
 Emulated strtok_r.

ACE_NAMESPACE_INLINE_FUNCTION
int 
strcasecmp (const char *s, const char *t)
 Compares two strings (case insensitive const char version).

ACE_NAMESPACE_INLINE_FUNCTION
int 
strcasecmp (const wchar_t *s, const wchar_t *t)
 Compares two strings (case insensitive const wchar_t version).

ACE_NAMESPACE_INLINE_FUNCTION
int 
strncasecmp (const char *s, const char *t, size_t len)
 Compares two arrays (case insensitive const char version).

ACE_NAMESPACE_INLINE_FUNCTION
int 
strncasecmp (const wchar_t *s, const wchar_t *t, size_t len)
 Compares two arrays (case insensitive const wchar_t version).

ACE_Export int strcasecmp_emulation (const char *s, const char *t)
 Emulated strcasecmp - Performs a case insensitive comparison of strings.

ACE_Export int strncasecmp_emulation (const char *s, const char *t, size_t len)
 Emulated strncasecmp - Performs a case insensitvie comparison of arrays.

ACE_NAMESPACE_INLINE_FUNCTION
int 
getmsg (ACE_HANDLE handle, struct strbuf *ctl, struct strbuf *data, int *flags)
ACE_NAMESPACE_INLINE_FUNCTION
int 
getpmsg (ACE_HANDLE handle, struct strbuf *ctl, struct strbuf *data, int *band, int *flags)
ACE_NAMESPACE_INLINE_FUNCTION
int 
fattach (int handle, const char *path)
ACE_NAMESPACE_INLINE_FUNCTION
int 
fdetach (const char *file)
ACE_NAMESPACE_INLINE_FUNCTION
int 
ioctl (ACE_HANDLE handle, ACE_IOCTL_TYPE_ARG2 cmd, void *=0)
 UNIX-style .

ACE_Export int ioctl (ACE_HANDLE socket, unsigned long io_control_code, void *in_buffer_p, unsigned long in_buffer, void *out_buffer_p, unsigned long out_buffer, unsigned long *bytes_returned, ACE_OVERLAPPED *overlapped, ACE_OVERLAPPED_COMPLETION_FUNC func)
 QoS-enabled .

ACE_Export int ioctl (ACE_HANDLE socket, unsigned long io_control_code, ACE_QoS &ace_qos, unsigned long *bytes_returned, void *buffer_p=0, unsigned long buffer=0, ACE_OVERLAPPED *overlapped=0, ACE_OVERLAPPED_COMPLETION_FUNC func=0)
ACE_NAMESPACE_INLINE_FUNCTION
int 
isastream (ACE_HANDLE handle)
ACE_NAMESPACE_INLINE_FUNCTION
int 
putmsg (ACE_HANDLE handle, const struct strbuf *ctl, const struct strbuf *data, int flags)
ACE_NAMESPACE_INLINE_FUNCTION
int 
putpmsg (ACE_HANDLE handle, const struct strbuf *ctl, const struct strbuf *data, int band, int flags)
ACE_NAMESPACE_INLINE_FUNCTION
ACE_HANDLE 
shm_open (const ACE_TCHAR *filename, int mode, int perms=0, LPSECURITY_ATTRIBUTES sa=0)
ACE_NAMESPACE_INLINE_FUNCTION
int 
shm_unlink (const ACE_TCHAR *path)
ACE_NAMESPACE_INLINE_FUNCTION
int 
getrlimit (int resource, struct rlimit *rl)
ACE_NAMESPACE_INLINE_FUNCTION
int 
getrusage (int who, struct rusage *rusage)
ACE_NAMESPACE_INLINE_FUNCTION
int 
setrlimit (int resource, const struct rlimit *rl)
ACE_NAMESPACE_INLINE_FUNCTION
int 
select (int width, fd_set *rfds, fd_set *wfds=0, fd_set *efds=0, const ACE_Time_Value *tv=0)
ACE_NAMESPACE_INLINE_FUNCTION
int 
select (int width, fd_set *rfds, fd_set *wfds, fd_set *efds, const ACE_Time_Value &tv)
ACE_NAMESPACE_INLINE_FUNCTION
ssize_t 
sendfile (ACE_HANDLE out_fd, ACE_HANDLE in_fd, off_t *offset, size_t count)
 Finds the length of a string (char version).

ACE_Export ssize_t sendfile_emulation (ACE_HANDLE out_fd, ACE_HANDLE in_fd, off_t *offset, size_t count)
ACE_NAMESPACE_INLINE_FUNCTION
ACE_HANDLE 
creat (const ACE_TCHAR *filename, mode_t mode)
ACE_NAMESPACE_INLINE_FUNCTION
int 
fstat (ACE_HANDLE, ACE_stat *)
ACE_NAMESPACE_INLINE_FUNCTION
int 
lstat (const char *, ACE_stat *)
ACE_NAMESPACE_INLINE_FUNCTION
int 
lstat (const wchar_t *, ACE_stat *)
ACE_NAMESPACE_INLINE_FUNCTION
int 
mkdir (const char *path, mode_t mode=ACE_DEFAULT_DIR_PERMS)
ACE_NAMESPACE_INLINE_FUNCTION
int 
mkdir (const wchar_t *path, mode_t mode=ACE_DEFAULT_DIR_PERMS)
ACE_NAMESPACE_INLINE_FUNCTION
int 
mkfifo (const ACE_TCHAR *file, mode_t mode=ACE_DEFAULT_FILE_PERMS)
ACE_NAMESPACE_INLINE_FUNCTION
int 
stat (const char *file, ACE_stat *)
ACE_NAMESPACE_INLINE_FUNCTION
int 
stat (const wchar_t *file, ACE_stat *)
ACE_NAMESPACE_INLINE_FUNCTION
mode_t 
umask (mode_t cmask)
ACE_NAMESPACE_INLINE_FUNCTION
ACE_Time_Value 
gettimeofday (void)
ACE_NAMESPACE_INLINE_FUNCTION
ssize_t 
readv (ACE_HANDLE handle, const iovec *iov, int iovlen)
ACE_NAMESPACE_INLINE_FUNCTION
ssize_t 
writev (ACE_HANDLE handle, const iovec *iov, int iovcnt)
ACE_Export int uname (ACE_utsname *name)
ACE_NAMESPACE_INLINE_FUNCTION
pid_t 
wait (int *=0)
ACE_NAMESPACE_INLINE_FUNCTION
pid_t 
wait (pid_t pid, ACE_exitcode *status, int wait_options=0, ACE_HANDLE handle=0)
ACE_NAMESPACE_INLINE_FUNCTION
pid_t 
waitpid (pid_t pid, ACE_exitcode *status=0, int wait_options=0, ACE_HANDLE handle=0)
ACE_Export void cleanup_tss (const u_int main_thread)
ACE_Export int lwp_getparams (ACE_Sched_Params &)
ACE_Export int lwp_setparams (const ACE_Sched_Params &)
ACE_NAMESPACE_INLINE_FUNCTION
long 
priority_control (ACE_idtype_t, ACE_id_t, int, void *)
 Low-level interface to (2).

ACE_Export int scheduling_class (const char *class_name, ACE_id_t &)
 Find the schedling class ID that corresponds to the class name.

ACE_Export int set_scheduling_params (const ACE_Sched_Params &, ACE_id_t id=ACE_SELF)
 Friendly interface to (2).

ACE_NAMESPACE_INLINE_FUNCTION
int 
sigtimedwait (const sigset_t *set, siginfo_t *info, const ACE_Time_Value *timeout)
ACE_NAMESPACE_INLINE_FUNCTION
int 
sigwait (sigset_t *set, int *sig=0)
ACE_NAMESPACE_INLINE_FUNCTION
int 
sigwaitinfo (const sigset_t *set, siginfo_t *info)
ACE_NAMESPACE_INLINE_FUNCTION
int 
thr_cancel (ACE_thread_t t_id)
ACE_NAMESPACE_INLINE_FUNCTION
int 
thr_cmp (ACE_hthread_t t1, ACE_hthread_t t2)
ACE_NAMESPACE_INLINE_FUNCTION
int 
thr_continue (ACE_hthread_t target_thread)
ACE_Export int thr_create (ACE_THR_FUNC func, void *args, long flags, ACE_thread_t *thr_id, ACE_hthread_t *t_handle=0, long priority=ACE_DEFAULT_THREAD_PRIORITY, void *stack=0, size_t stacksize=0, ACE_Base_Thread_Adapter *thread_adapter=0)
ACE_NAMESPACE_INLINE_FUNCTION
int 
thr_equal (ACE_thread_t t1, ACE_thread_t t2)
ACE_Export void thr_exit (ACE_THR_FUNC_RETURN status=0)
ACE_NAMESPACE_INLINE_FUNCTION
int 
thr_getconcurrency (void)
ACE_NAMESPACE_INLINE_FUNCTION
int 
thr_getprio (ACE_hthread_t id, int &priority)
ACE_NAMESPACE_INLINE_FUNCTION
int 
thr_getprio (ACE_hthread_t id, int &priority, int &policy)
ACE_NAMESPACE_INLINE_FUNCTION
int 
thr_getspecific (ACE_thread_key_t key, void **data)
ACE_NAMESPACE_INLINE_FUNCTION
int 
thr_join (ACE_hthread_t waiter_id, ACE_THR_FUNC_RETURN *status)
ACE_NAMESPACE_INLINE_FUNCTION
int 
thr_join (ACE_thread_t waiter_id, ACE_thread_t *thr_id, ACE_THR_FUNC_RETURN *status)
ACE_Export int thr_get_affinity (ACE_hthread_t id, size_t cpu_set_size, cpu_set_t *cpu_mask)
ACE_Export int thr_set_affinity (ACE_hthread_t thr_id, size_t cpu_set_size, const cpu_set_t *cpu_mask)
ACE_Export int thr_key_detach (ACE_thread_key_t key, void *inst)
ACE_Export int thr_key_used (ACE_thread_key_t key)
ACE_Export int thr_keycreate (ACE_thread_key_t *key, ACE_THR_DEST, void *inst=0)
ACE_Export int thr_keyfree (ACE_thread_key_t key)
ACE_NAMESPACE_INLINE_FUNCTION
int 
thr_kill (ACE_thread_t thr_id, int signum)
ACE_NAMESPACE_INLINE_FUNCTION
size_t 
thr_min_stack (void)
ACE_NAMESPACE_INLINE_FUNCTION
ACE_thread_t 
thr_self (void)
ACE_NAMESPACE_INLINE_FUNCTION
void 
thr_self (ACE_hthread_t &)
ACE_NAMESPACE_INLINE_FUNCTION
int 
thr_setcancelstate (int new_state, int *old_state)
ACE_NAMESPACE_INLINE_FUNCTION
int 
thr_setcanceltype (int new_type, int *old_type)
ACE_NAMESPACE_INLINE_FUNCTION
int 
thr_setconcurrency (int hint)
ACE_NAMESPACE_INLINE_FUNCTION
int 
thr_setprio (ACE_hthread_t ht_id, int priority, int policy=-1)
ACE_Export int thr_setprio (const ACE_Sched_Priority prio)
ACE_Export int thr_setspecific (ACE_thread_key_t key, void *data)
ACE_NAMESPACE_INLINE_FUNCTION
int 
thr_sigsetmask (int how, const sigset_t *nsm, sigset_t *osm)
ACE_NAMESPACE_INLINE_FUNCTION
int 
thr_suspend (ACE_hthread_t target_thread)
ACE_NAMESPACE_INLINE_FUNCTION
void 
thr_testcancel (void)
ACE_NAMESPACE_INLINE_FUNCTION
void 
thr_yield (void)
ACE_Export void unique_name (const void *object, char *name, size_t length)
ACE_NAMESPACE_INLINE_FUNCTION
int 
access (const char *path, int amode)
ACE_NAMESPACE_INLINE_FUNCTION
int 
access (const wchar_t *path, int amode)
ACE_NAMESPACE_INLINE_FUNCTION
unsigned int 
alarm (u_int secs)
ACE_NAMESPACE_INLINE_FUNCTION
long 
allocation_granularity (void)
ACE_Export int argv_to_string (ACE_TCHAR **argv, ACE_TCHAR *&buf, bool substitute_env_args=true)
ACE_NAMESPACE_INLINE_FUNCTION
int 
chdir (const char *path)
ACE_NAMESPACE_INLINE_FUNCTION
int 
chdir (const wchar_t *path)
ACE_NAMESPACE_INLINE_FUNCTION
int 
rmdir (const char *path)
ACE_NAMESPACE_INLINE_FUNCTION
int 
rmdir (const wchar_t *path)
ACE_NAMESPACE_INLINE_FUNCTION
int 
close (ACE_HANDLE handle)
ACE_NAMESPACE_INLINE_FUNCTION
ACE_HANDLE 
dup (ACE_HANDLE handle)
ACE_NAMESPACE_INLINE_FUNCTION
int 
dup2 (ACE_HANDLE oldfd, ACE_HANDLE newfd)
ACE_Export int execl (const char *path, const char *arg0,...)
ACE_Export int execle (const char *path, const char *arg0,...)
ACE_Export int execlp (const char *file, const char *arg0,...)
ACE_NAMESPACE_INLINE_FUNCTION
int 
execv (const char *path, char *const argv[])
ACE_NAMESPACE_INLINE_FUNCTION
int 
execve (const char *path, char *const argv[], char *const envp[])
ACE_NAMESPACE_INLINE_FUNCTION
int 
execvp (const char *file, char *const argv[])
ACE_NAMESPACE_INLINE_FUNCTION
int 
fsync (ACE_HANDLE handle)
ACE_NAMESPACE_INLINE_FUNCTION
int 
ftruncate (ACE_HANDLE, ACE_LOFF_T)
ACE_NAMESPACE_INLINE_FUNCTION
char * 
getcwd (char *, size_t)
ACE_NAMESPACE_INLINE_FUNCTION
wchar_t * 
getcwd (wchar_t *, size_t)
ACE_NAMESPACE_INLINE_FUNCTION
gid_t 
getgid (void)
ACE_NAMESPACE_INLINE_FUNCTION
gid_t 
getegid (void)
ACE_NAMESPACE_INLINE_FUNCTION
int 
getopt (int argc, char *const *argv, const char *optstring)
ACE_NAMESPACE_INLINE_FUNCTION
long 
getpagesize (void)
ACE_NAMESPACE_INLINE_FUNCTION
pid_t 
getpgid (pid_t pid)
ACE_NAMESPACE_INLINE_FUNCTION
pid_t 
getpid (void)
ACE_NAMESPACE_INLINE_FUNCTION
pid_t 
getppid (void)
ACE_NAMESPACE_INLINE_FUNCTION
uid_t 
getuid (void)
ACE_NAMESPACE_INLINE_FUNCTION
uid_t 
geteuid (void)
ACE_NAMESPACE_INLINE_FUNCTION
int 
hostname (char *name, size_t maxnamelen)
ACE_NAMESPACE_INLINE_FUNCTION
int 
hostname (wchar_t *name, size_t maxnamelen)
ACE_NAMESPACE_INLINE_FUNCTION
int 
isatty (int handle)
ACE_NAMESPACE_INLINE_FUNCTION
int 
isatty (ACE_HANDLE handle)
ACE_NAMESPACE_INLINE_FUNCTION
off_t 
lseek (ACE_HANDLE handle, off_t offset, int whence)
ACE_Export long num_processors (void)
 Get the number of CPUs configured in the machine.

ACE_Export long num_processors_online (void)
 Get the number of CPUs currently online.

ACE_NAMESPACE_INLINE_FUNCTION
int 
pipe (ACE_HANDLE handles[])
ACE_Export ssize_t pread (ACE_HANDLE handle, void *buf, size_t nbyte, off_t offset)
ACE_Export ssize_t pwrite (ACE_HANDLE handle, const void *buf, size_t nbyte, ACE_LOFF_T offset)
ACE_NAMESPACE_INLINE_FUNCTION
ssize_t 
read (ACE_HANDLE handle, void *buf, size_t len)
ACE_NAMESPACE_INLINE_FUNCTION
ssize_t 
read (ACE_HANDLE handle, void *buf, size_t len, ACE_OVERLAPPED *)
ACE_Export ssize_t read_n (ACE_HANDLE handle, void *buf, size_t len, size_t *bytes_transferred=0)
ACE_NAMESPACE_INLINE_FUNCTION
ssize_t 
readlink (const char *path, char *buf, size_t bufsiz)
ACE_NAMESPACE_INLINE_FUNCTION
void * 
sbrk (ptrdiff_t brk)
ACE_NAMESPACE_INLINE_FUNCTION
int 
setgid (gid_t)
ACE_NAMESPACE_INLINE_FUNCTION
int 
setegid (gid_t)
ACE_NAMESPACE_INLINE_FUNCTION
int 
setpgid (pid_t pid, pid_t pgid)
ACE_NAMESPACE_INLINE_FUNCTION
int 
setregid (gid_t rgid, gid_t egid)
ACE_NAMESPACE_INLINE_FUNCTION
int 
setreuid (uid_t ruid, uid_t euid)
ACE_NAMESPACE_INLINE_FUNCTION
pid_t 
setsid (void)
ACE_NAMESPACE_INLINE_FUNCTION
int 
setuid (uid_t)
ACE_NAMESPACE_INLINE_FUNCTION
int 
seteuid (uid_t)
ACE_NAMESPACE_INLINE_FUNCTION
int 
sleep (u_int seconds)
ACE_NAMESPACE_INLINE_FUNCTION
int 
sleep (const ACE_Time_Value &tv)
ACE_Export int string_to_argv (ACE_TCHAR *buf, int &argc, ACE_TCHAR **&argv, bool substitute_env_args=true)
ACE_NAMESPACE_INLINE_FUNCTION
void 
swab (const void *src, void *dest, ssize_t n)
ACE_NAMESPACE_INLINE_FUNCTION
long 
sysconf (int)
ACE_NAMESPACE_INLINE_FUNCTION
long 
sysinfo (int cmd, char *buf, long count)
ACE_NAMESPACE_INLINE_FUNCTION
int 
truncate (const ACE_TCHAR *filename, ACE_LOFF_T length)
ACE_NAMESPACE_INLINE_FUNCTION
u_long 
ualarm (u_long usecs, u_long interval=0)
ACE_NAMESPACE_INLINE_FUNCTION
u_long 
ualarm (const ACE_Time_Value &tv, const ACE_Time_Value &tv_interval=ACE_Time_Value::zero)
ACE_NAMESPACE_INLINE_FUNCTION
int 
unlink (const char *path)
ACE_NAMESPACE_INLINE_FUNCTION
int 
unlink (const wchar_t *path)
ACE_NAMESPACE_INLINE_FUNCTION
ssize_t 
write (ACE_HANDLE handle, const void *buf, size_t nbyte)
ACE_NAMESPACE_INLINE_FUNCTION
ssize_t 
write (ACE_HANDLE handle, const void *buf, size_t nbyte, ACE_OVERLAPPED *)
ACE_Export ssize_t write_n (ACE_HANDLE handle, const void *buf, size_t len, size_t *bytes_transferred=0)
ACE_NAMESPACE_INLINE_FUNCTION
wint_t 
fgetwc (FILE *fp)
ACE_Export wchar_t * wcscat_emulation (wchar_t *destination, const wchar_t *source)
 Emulated wcscat - Appends a string.

ACE_Export wchar_t * wcschr_emulation (const wchar_t *string, wint_t c)
 Emulated wcschr - Finds a character in a string.

ACE_Export int wcscmp_emulation (const ACE_WCHAR_T *string1, const ACE_WCHAR_T *string2)
 Emulated wcscmp - Compares strings.

ACE_Export wchar_t * wcscpy_emulation (wchar_t *destination, const wchar_t *source)
 Emulated wcscpy - Copies a string.

ACE_Export size_t wcscspn_emulation (const wchar_t *string, const wchar_t *reject)
 Emulated wcscspn.

ACE_Export int wcsicmp_emulation (const wchar_t *string1, const wchar_t *string2)
 Emulated wcsicmp - Performs a case insensitive comparison of strings.

ACE_Export size_t wcslen_emulation (const ACE_WCHAR_T *string)
 Emulated wcslen - Returns the length of a string.

ACE_Export ACE_WCHAR_T * wcsncat_emulation (ACE_WCHAR_T *destination, const ACE_WCHAR_T *source, size_t count)
 Emulated wcscat - Appends a string.

ACE_Export int wcsncmp_emulation (const ACE_WCHAR_T *string1, const ACE_WCHAR_T *string2, size_t len)
 Emulated wcsncmp - Compares two arrays.

ACE_Export ACE_WCHAR_T * wcsncpy_emulation (ACE_WCHAR_T *destination, const ACE_WCHAR_T *source, size_t len)
 Emulated wcsncpy - Copies an array.

ACE_Export int wcsnicmp_emulation (const wchar_t *string1, const wchar_t *string2, size_t len)
ACE_Export wchar_t * wcspbrk_emulation (const wchar_t *string, const wchar_t *charset)
 Emulated wcspbrk - Searches for characters in a string.

ACE_Export wchar_t * wcsrchr_emulation (wchar_t *string, wint_t c)
ACE_Export const wchar_t * wcsrchr_emulation (const wchar_t *string, wint_t c)
ACE_Export size_t wcsspn_emulation (const wchar_t *string, const wchar_t *charset)
 Emulated wcsspn.

ACE_Export wchar_t * wcsstr_emulation (const wchar_t *string, const wchar_t *charset)
 Emulated wcsstr - Performs a case insensitive comparison of two strings.

ACE_NAMESPACE_INLINE_FUNCTION
u_int 
wslen (const WChar *)
ACE_NAMESPACE_INLINE_FUNCTION
WChar
wscpy (WChar *, const WChar *)
ACE_NAMESPACE_INLINE_FUNCTION
int 
wscmp (const WChar *, const WChar *)
ACE_NAMESPACE_INLINE_FUNCTION
int 
wsncmp (const WChar *, const WChar *, size_t len)
ACE_NAMESPACE_INLINE_FUNCTION
wint_t 
ungetwc (wint_t c, FILE *fp)
ACE_NAMESPACE_INLINE_FUNCTION
int 
t_accept (ACE_HANDLE fildes, ACE_HANDLE resfd, struct t_call *call)
ACE_NAMESPACE_INLINE_FUNCTION
char * 
t_alloc (ACE_HANDLE fildes, int struct_type, int fields)
ACE_NAMESPACE_INLINE_FUNCTION
int 
t_bind (ACE_HANDLE fildes, struct t_bind *req, struct t_bind *ret)
ACE_NAMESPACE_INLINE_FUNCTION
int 
t_close (ACE_HANDLE fildes)
ACE_NAMESPACE_INLINE_FUNCTION
int 
t_connect (ACE_HANDLE fildes, struct t_call *sndcall, struct t_call *rcvcall)
ACE_NAMESPACE_INLINE_FUNCTION
void 
t_error (const char *errmsg)
ACE_NAMESPACE_INLINE_FUNCTION
int 
t_free (char *ptr, int struct_type)
ACE_NAMESPACE_INLINE_FUNCTION
int 
t_getinfo (ACE_HANDLE fildes, struct t_info *info)
ACE_NAMESPACE_INLINE_FUNCTION
int 
t_getname (ACE_HANDLE fildes, struct netbuf *namep, int type)
ACE_NAMESPACE_INLINE_FUNCTION
int 
t_getstate (ACE_HANDLE fildes)
ACE_NAMESPACE_INLINE_FUNCTION
int 
t_listen (ACE_HANDLE fildes, struct t_call *call)
ACE_NAMESPACE_INLINE_FUNCTION
int 
t_look (ACE_HANDLE fildes)
ACE_NAMESPACE_INLINE_FUNCTION
ACE_HANDLE 
t_open (char *path, int oflag, struct t_info *info)
ACE_NAMESPACE_INLINE_FUNCTION
int 
t_optmgmt (ACE_HANDLE handle, ACE_TOPTMGMT *req, ACE_TOPTMGMT *ret)
ACE_NAMESPACE_INLINE_FUNCTION
int 
t_rcv (ACE_HANDLE fildes, char *buf, unsigned int nbytes, int *flags)
ACE_NAMESPACE_INLINE_FUNCTION
int 
t_rcvdis (ACE_HANDLE fildes, struct t_discon *discon)
ACE_NAMESPACE_INLINE_FUNCTION
int 
t_rcvrel (ACE_HANDLE fildes)
ACE_NAMESPACE_INLINE_FUNCTION
int 
t_rcvudata (ACE_HANDLE fildes, struct t_unitdata *unitdata, int *flags)
ACE_NAMESPACE_INLINE_FUNCTION
int 
t_rcvuderr (ACE_HANDLE fildes, struct t_uderr *uderr)
ACE_NAMESPACE_INLINE_FUNCTION
int 
t_snd (ACE_HANDLE fildes, const char *buf, unsigned int nbytes, int flags)
ACE_NAMESPACE_INLINE_FUNCTION
int 
t_snddis (ACE_HANDLE fildes, struct t_call *call)
ACE_NAMESPACE_INLINE_FUNCTION
int 
t_sndrel (ACE_HANDLE fildes)
ACE_NAMESPACE_INLINE_FUNCTION
int 
t_sync (ACE_HANDLE fildes)
ACE_NAMESPACE_INLINE_FUNCTION
int 
t_unbind (ACE_HANDLE fildes)

Variables

ACE_Export OSVERSIONINFO win32_versioninfo_
ACE_Export HINSTANCE win32_resource_module_
ACE_Export int socket_initialized_
 Keeps track of whether we've already initialized WinSock...


Detailed Description

This namespace defines an OS independent programming API that shields developers from nonportable aspects of writing efficient system programs on Win32, POSIX and other versions of UNIX, and various real-time operating systems.

This namespace encapsulates the differences between various OS platforms. When porting ACE to a new platform, this class is the place to focus on. Once this file is ported to a new platform, pretty much everything else comes for "free." See <www.cs.wustl.edu/~schmidt/ACE_wrappers/etc/ACE-porting.html> for instructions on porting ACE. Please see the README file in this directory for complete information on the meaning of the various macros.


Typedef Documentation

typedef ACE_WCHAR_T ACE_OS::WChar
 

Definition at line 45 of file OS_NS_wchar.h.


Enumeration Type Documentation

enum ACE_OS::ACE_HRTimer_Op
 

Enumeration values:
ACE_HRTIMER_START 
ACE_HRTIMER_INCR 
ACE_HRTIMER_STOP 
ACE_HRTIMER_GETTIME 

Definition at line 161 of file OS_NS_time.h.

00162     {
00163       ACE_HRTIMER_START = 0x0,  // Only use these if you can stand
00164       ACE_HRTIMER_INCR = 0x1,   // for interrupts to be disabled during
00165       ACE_HRTIMER_STOP = 0x2,   // the timed interval!!!!
00166       ACE_HRTIMER_GETTIME = 0xFFFF
00167     };


Function Documentation

ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE void ACE_OS::_exit int  status = 0  ) 
 

Definition at line 23 of file OS_NS_stdlib.inl.

References ACE_OS_TRACE.

Referenced by ACE::fork(), and ACE_Process::spawn().

00024 {
00025   ACE_OS_TRACE ("ACE_OS::_exit");
00026 #if defined (ACE_VXWORKS)
00027   ::exit (status);
00028 #elif !defined (ACE_HAS_WINCE)
00029   ::_exit (status);
00030 #else
00031   ::TerminateProcess (::GetCurrentProcess (),
00032                       status);
00033 #endif /* ACE_VXWORKS */
00034 }

ACE_INLINE void ACE_OS::abort void   ) 
 

Definition at line 37 of file OS_NS_stdlib.inl.

References exit().

Referenced by ACE_Log_Msg::log().

00038 {
00039 #if !defined (ACE_HAS_WINCE)
00040   ::abort ();
00041 #else
00042   // @@ CE doesn't support abort?
00043   exit (1);
00044 #endif /* !ACE_HAS_WINCE */
00045 }

ACE_HANDLE ACE_OS::accept ACE_HANDLE  handle,
struct sockaddr *  addr,
int *  addrlen,
const ACE_Accept_QoS_Params qos_params
 

QoS-enabled , which passes to . If the OS platform doesn't support QoS-enabled then the are ignored and the BSD-style is called.

Definition at line 19 of file OS_NS_sys_socket.cpp.

References accept(), ACE_SOCKCALL_RETURN, ACE_SOCKET_LEN, ACE_Accept_QoS_Params::callback_data(), and ACE_Accept_QoS_Params::qos_condition_callback().

00023 {
00024 # if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
00025   ACE_SOCKCALL_RETURN (::WSAAccept ((ACE_SOCKET) handle,
00026                                     addr,
00027                                     (ACE_SOCKET_LEN *) addrlen,
00028                                     (LPCONDITIONPROC) qos_params.qos_condition_callback (),
00029                                     qos_params.callback_data ()),
00030                        ACE_HANDLE,
00031                        ACE_INVALID_HANDLE);
00032 # else
00033   ACE_UNUSED_ARG (qos_params);
00034   return ACE_OS::accept (handle,
00035                          addr,
00036                          addrlen);
00037 # endif /* ACE_HAS_WINSOCK2 */
00038 }

ACE_INLINE ACE_HANDLE ACE_OS::accept ACE_HANDLE  handle,
struct sockaddr *  addr,
int *  addrlen
 

BSD-style (no QoS).

Definition at line 29 of file OS_NS_sys_socket.inl.

References ACE_OS_TRACE, ACE_SOCKCALL_RETURN, ACE_SOCKET_LEN, and EWOULDBLOCK.

Referenced by accept(), ACE_ATM_Acceptor::accept(), and ACE_POSIX_Asynch_Accept::handle_input().

00032 {
00033   ACE_OS_TRACE ("ACE_OS::accept");
00034   // On a non-blocking socket with no connections to accept, this
00035   // system call will return EWOULDBLOCK or EAGAIN, depending on the
00036   // platform.  UNIX 98 allows either errno, and they may be the same
00037   // numeric value.  So to make life easier for upper ACE layers as
00038   // well as application programmers, always change EAGAIN to
00039   // EWOULDBLOCK.  Rather than hack the ACE_OSCALL_RETURN macro, it's
00040   // handled explicitly here.  If the ACE_OSCALL macro ever changes,
00041   // this function needs to be reviewed.  On Win32, the regular macros
00042   // can be used, as this is not an issue.
00043 
00044 #if defined (ACE_WIN32)
00045   ACE_SOCKCALL_RETURN (::accept ((ACE_SOCKET) handle,
00046                                  addr,
00047                                  (ACE_SOCKET_LEN *) addrlen),
00048                        ACE_HANDLE,
00049                        ACE_INVALID_HANDLE);
00050 #else
00051 #  if defined (ACE_HAS_BROKEN_ACCEPT_ADDR)
00052   // Apparently some platforms like VxWorks can't correctly deal with
00053   // a NULL addr.
00054 
00055    sockaddr_in fake_addr;
00056    int fake_addrlen;
00057 
00058    if (addrlen == 0)
00059      addrlen = &fake_addrlen;
00060 
00061    if (addr == 0)
00062      {
00063        addr = (sockaddr *) &fake_addr;
00064        *addrlen = sizeof fake_addr;
00065      }
00066 #  endif /* ACE_HAS_BROKEN_ACCEPT_ADDR */
00067   ACE_HANDLE ace_result = ::accept ((ACE_SOCKET) handle,
00068                                     addr,
00069                                     (ACE_SOCKET_LEN *) addrlen);
00070 
00071 # if !(defined (EAGAIN) && defined (EWOULDBLOCK) && EAGAIN == EWOULDBLOCK)
00072   // Optimize this code out if we can detect that EAGAIN ==
00073   // EWOULDBLOCK at compile time.  If we cannot detect equality at
00074   // compile-time (e.g. if EAGAIN or EWOULDBLOCK are not preprocessor
00075   // macros) perform the check at run-time.  The goal is to avoid two
00076   // TSS accesses in the _REENTRANT case when EAGAIN == EWOULDBLOCK.
00077   if (ace_result == ACE_INVALID_HANDLE
00078 #  if !defined (EAGAIN) || !defined (EWOULDBLOCK)
00079       && EAGAIN != EWOULDBLOCK
00080 #  endif  /* !EAGAIN || !EWOULDBLOCK */
00081       && errno == EAGAIN)
00082     {
00083       errno = EWOULDBLOCK;
00084     }
00085 # endif /* EAGAIN != EWOULDBLOCK*/
00086 
00087   return ace_result;
00088 
00089 #endif /* defined (ACE_WIN32) */
00090 }

ACE_INLINE int ACE_OS::access const wchar_t *  path,
int  amode
 

Definition at line 68 of file OS_NS_unistd.inl.

References access().

00069 {
00070 #if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)
00071   ACE_OSCALL_RETURN (::_waccess (path, amode), int, -1);
00072 #else /* ACE_WIN32 && !ACE_HAS_WINCE */
00073   return ACE_OS::access (ACE_Wide_To_Ascii (path).char_rep (), amode);
00074 #endif /* ACE_WIN32 && !ACE_HAS_WINCE */
00075 }

ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE int ACE_OS::access const char *  path,
int  amode
 

Definition at line 36 of file OS_NS_unistd.inl.

References access(), ACE_LIB_TEXT, ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_TEXT_CHAR_TO_TCHAR, fclose(), and fopen().

Referenced by access(), ACE_Filecache_Object::ACE_Filecache_Object(), ACE_Local_Name_Space<, ACE_LOCK >::create_manager_i(), ACE::ldfind(), open(), and ACE_Configuration_Heap::open().

00037 {
00038   ACE_OS_TRACE ("ACE_OS::access");
00039 #if defined (ACE_LACKS_ACCESS)
00040 #  if defined (ACE_HAS_WINCE) || defined (ACE_VXWORKS)
00041   // @@ WINCE: There should be a Win32 API that can do this.
00042   // Hard coded read access here.
00043   ACE_UNUSED_ARG (amode);
00044   FILE* handle = ACE_OS::fopen (ACE_TEXT_CHAR_TO_TCHAR(path),
00045                                 ACE_LIB_TEXT ("r"));
00046   if (handle != 0)
00047     {
00048       ACE_OS::fclose (handle);
00049       return 0;
00050     }
00051   return (-1);
00052 #  else
00053     ACE_UNUSED_ARG (path);
00054     ACE_UNUSED_ARG (amode);
00055     ACE_NOTSUP_RETURN (-1);
00056 #  endif  // ACE_HAS_WINCE
00057 #elif defined(ACE_WIN32)
00058   // Windows doesn't support checking X_OK(6)
00059   ACE_OSCALL_RETURN (::access (path, amode & 6), int, -1);
00060 #else
00061   ACE_OSCALL_RETURN (::access (path, amode), int, -1);
00062 #endif /* ACE_LACKS_ACCESS */
00063 }

ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE int ACE_OS::ace_isalnum ACE_TCHAR  c  ) 
 

Returns true if the character is an alphanumeric character.

Definition at line 13 of file OS_NS_ctype.inl.

References ACE_TCHAR.

Referenced by ACE_Get_Opt::long_option().

00014 {
00015 #if defined (ACE_USES_WCHAR)
00016   return iswalnum (c);
00017 #else /* ACE_USES_WCHAR */
00018   return isalnum ((unsigned char) c);
00019 #endif /* ACE_USES_WCHAR */
00020 }

ACE_INLINE int ACE_OS::ace_isalpha ACE_TCHAR  c  ) 
 

Returns true if the character is an alphabetic character.

Definition at line 23 of file OS_NS_ctype.inl.

References ACE_TCHAR.

00024 {
00025 #if defined (ACE_USES_WCHAR)
00026   return iswalpha (c);
00027 #else /* ACE_USES_WCHAR */
00028   return isalpha ((unsigned char) c);
00029 #endif /* ACE_USES_WCHAR */
00030 }

ACE_INLINE int ACE_OS::ace_iscntrl ACE_TCHAR  c  ) 
 

Returns true if the character is a control character.

Definition at line 33 of file OS_NS_ctype.inl.

References ACE_TCHAR.

00034 {
00035 #if defined (ACE_USES_WCHAR)
00036   return iswcntrl (c);
00037 #else /* ACE_USES_WCHAR */
00038   return iscntrl ((unsigned char) c);
00039 #endif /* ACE_USES_WCHAR */
00040 }

ACE_INLINE int ACE_OS::ace_isdigit ACE_TCHAR  c  ) 
 

Returns true if the character is a decimal-digit character.

Definition at line 43 of file OS_NS_ctype.inl.

References ACE_TCHAR.

Referenced by ACE_SOCK_Dgram::make_multicast_ifaddr6(), and ACE_Svc_Conf_Lexer::scan().

00044 {
00045 #if defined (ACE_USES_WCHAR)
00046   return iswdigit (c);
00047 #else /* ACE_USES_WCHAR */
00048   return isdigit ((unsigned char) c);
00049 #endif /* ACE_USES_WCHAR */
00050 }

ACE_INLINE int ACE_OS::ace_isgraph ACE_TCHAR  c  ) 
 

Returns true if the character is a printable character other than a space.

Definition at line 53 of file OS_NS_ctype.inl.

References ACE_TCHAR.

00054 {
00055 #if defined (ACE_USES_WCHAR)
00056   return iswgraph (c);
00057 #else /* ACE_USES_WCHAR */
00058   return isgraph ((unsigned char) c);
00059 #endif /* ACE_USES_WCHAR */
00060 }

ACE_INLINE int ACE_OS::ace_islower ACE_TCHAR  c  ) 
 

Returns true if the character is a lowercase character.

Definition at line 63 of file OS_NS_ctype.inl.

References ACE_TCHAR.

00064 {
00065 #if defined (ACE_USES_WCHAR)
00066   return iswlower (c);
00067 #else /* ACE_USES_WCHAR */
00068   return islower ((unsigned char) c);
00069 #endif /* ACE_USES_WCHAR */
00070 }

ACE_INLINE int ACE_OS::ace_isprint ACE_TCHAR  c  ) 
 

Returns true if the character is a printable character.

Definition at line 73 of file OS_NS_ctype.inl.

References ACE_TCHAR.

Referenced by ACE::format_hexdump().

00074 {
00075 #if defined (ACE_USES_WCHAR)
00076   return iswprint (c);
00077 #else /* ACE_USES_WCHAR */
00078   return isprint ((unsigned char) c);
00079 #endif /* ACE_USES_WCHAR */
00080 }

ACE_INLINE int ACE_OS::ace_ispunct ACE_TCHAR  c  ) 
 

Returns true if the character is a punctuation character.

Definition at line 83 of file OS_NS_ctype.inl.

References ACE_TCHAR.

00084 {
00085 #if defined (ACE_USES_WCHAR)
00086   return iswpunct (c);
00087 #else /* ACE_USES_WCHAR */
00088   return ispunct ((unsigned char) c);
00089 #endif /* ACE_USES_WCHAR */
00090 }

ACE_INLINE int ACE_OS::ace_isspace ACE_TCHAR  c  ) 
 

Returns true if the character is a space character.

Definition at line 93 of file OS_NS_ctype.inl.

References ACE_TCHAR.

Referenced by ACE_Base64::decode(), ACE_Base64::length(), ACE_Ini_ImpExp::squish(), and string_to_argv().

00094 {
00095 #if defined (ACE_USES_WCHAR)
00096   return iswspace (c);
00097 #else /* ACE_USES_WCHAR */
00098   return isspace ((unsigned char) c);
00099 #endif /* ACE_USES_WCHAR */
00100 }

ACE_INLINE int ACE_OS::ace_isupper ACE_TCHAR  c  ) 
 

Returns true if the character is an uppercase character.

Definition at line 103 of file OS_NS_ctype.inl.

References ACE_TCHAR.

00104 {
00105 #if defined (ACE_USES_WCHAR)
00106   return iswupper (c);
00107 #else /* ACE_USES_WCHAR */
00108   return isupper ((unsigned char) c);
00109 #endif /* ACE_USES_WCHAR */
00110 }

ACE_INLINE int ACE_OS::ace_isxdigit ACE_TCHAR  c  ) 
 

Returns true if the character is a hexadecimal-digit character.

Definition at line 113 of file OS_NS_ctype.inl.

References ACE_TCHAR.

00114 {
00115 #if defined (ACE_USES_WCHAR)
00116   return iswxdigit (c);
00117 #else /* ACE_USES_WCHAR */
00118   return isxdigit ((unsigned char) c);
00119 #endif /* ACE_USES_WCHAR */
00120 }

ACE_INLINE int ACE_OS::ace_tolower int  c  ) 
 

Converts a character to lower case (char version).

Definition at line 123 of file OS_NS_ctype.inl.

Referenced by equal_char(), ACE_Svc_Conf_Lexer::scan(), strcasecmp_emulation(), strncasecmp_emulation(), and wcsicmp_emulation().

00124 {
00125   return tolower (c);
00126 }

ACE_INLINE int ACE_OS::ace_toupper int  c  ) 
 

Converts a character to upper case (char version).

Definition at line 137 of file OS_NS_ctype.inl.

00138 {
00139   return toupper (c);
00140 }

ACE_INLINE wint_t ACE_OS::ace_towlower wint_t  c  ) 
 

Converts a character to lower case (wchar_t version).

Definition at line 130 of file OS_NS_ctype.inl.

Referenced by wcsicmp_emulation(), and wcsnicmp_emulation().

00131 {
00132   return towlower (c);
00133 }

ACE_INLINE wint_t ACE_OS::ace_towupper wint_t  c  ) 
 

Converts a character to upper case (wchar_t version).

Definition at line 144 of file OS_NS_ctype.inl.

00145 {
00146   return towupper (c);
00147 }

ACE_INLINE u_int ACE_OS::alarm u_int  secs  ) 
 

Definition at line 79 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, and ACE_OS_TRACE.

00080 {
00081   ACE_OS_TRACE ("ACE_OS::alarm");
00082 #if defined (ACE_LACKS_ALARM)
00083   ACE_UNUSED_ARG (secs);
00084   ACE_NOTSUP_RETURN (0);
00085 #else
00086   return ::alarm (secs);
00087 #endif /* ACE_LACKS_ALARM */
00088 }

ACE_INLINE long ACE_OS::allocation_granularity void   ) 
 

Definition at line 109 of file OS_NS_unistd.inl.

References getpagesize().

Referenced by ACE::round_to_allocation_granularity().

00110 {
00111 #if defined (ACE_WIN32)
00112   SYSTEM_INFO sys_info;
00113   ::GetSystemInfo (&sys_info);
00114   return sys_info.dwAllocationGranularity;
00115 #else
00116   return ACE_OS::getpagesize ();
00117 #endif /* ACE_WIN32 */
00118 }

ACE_BEGIN_VERSIONED_NAMESPACE_DECL int ACE_OS::argv_to_string ACE_TCHAR **  argv,
ACE_TCHAR *&  buf,
bool  substitute_env_args = true
 

Definition at line 40 of file OS_NS_unistd.cpp.

References ACE_LIB_TEXT, ACE_NEW_RETURN, ACE_TCHAR, ACE_TEXT_ALWAYS_CHAR, ACE_TEXT_CHAR_TO_TCHAR, getenv(), strecpy(), and strlen().

Referenced by ACE_ARGV_T< CHAR_TYPE >::ACE_ARGV_T(), ACE_ARGV_T< CHAR_TYPE >::argv_to_string(), and fork_exec().

00043 {
00044   if (argv == 0 || argv[0] == 0)
00045     return 0;
00046 
00047   size_t buf_len = 0;
00048 
00049   // Determine the length of the buffer.
00050 
00051   for (int i = 0; argv[i] != 0; i++)
00052     {
00053 #if !defined (ACE_LACKS_ENV)
00054       // Account for environment variables.
00055       if (substitute_env_args && argv[i][0] == ACE_LIB_TEXT ('$'))
00056         {
00057 #  if defined (ACE_WIN32) || !defined (ACE_HAS_WCHAR)
00058           ACE_TCHAR *temp = 0;
00059           // Win32 is the only platform with a wide-char ACE_OS::getenv().
00060           if ((temp = ACE_OS::getenv (&argv[i][1])) != 0)
00061             buf_len += ACE_OS::strlen (temp);
00062           else
00063             buf_len += ACE_OS::strlen (argv[i]);
00064 #  else
00065           // This is an ACE_HAS_WCHAR platform and not ACE_WIN32.
00066           // Convert the env variable name for getenv(), then add
00067           // the length of the returned char *string. Later, when we
00068           // actually use the returned env variable value, convert it
00069           // as well.
00070           char *ctemp = ACE_OS::getenv (ACE_TEXT_ALWAYS_CHAR (&argv[i][1]));
00071           if (ctemp == 0)
00072             buf_len += ACE_OS::strlen (argv[i]);
00073           else
00074             buf_len += ACE_OS::strlen (ctemp);
00075 #  endif /* ACE_WIN32 || !ACE_HAS_WCHAR */
00076         }
00077       else
00078 #endif /* ACE_LACKS_ENV */
00079         buf_len += ACE_OS::strlen (argv[i]);
00080 
00081       // Add one for the extra space between each string.
00082       buf_len++;
00083     }
00084 
00085   // Step through all argv params and copy each one into buf; separate
00086   // each param with white space.
00087 
00088   ACE_NEW_RETURN (buf,
00089                   ACE_TCHAR[buf_len + 1],
00090                   0);
00091 
00092   // Initial null charater to make it a null string.
00093   buf[0] = '\0';
00094   ACE_TCHAR *end = buf;
00095   int j;
00096 
00097   for (j = 0; argv[j] != 0; j++)
00098     {
00099 
00100 #if !defined (ACE_LACKS_ENV)
00101       // Account for environment variables.
00102       if (substitute_env_args && argv[j][0] == ACE_LIB_TEXT ('$'))
00103         {
00104 #  if defined (ACE_WIN32) || !defined (ACE_HAS_WCHAR)
00105           // Win32 is the only platform with a wide-char ACE_OS::getenv().
00106           ACE_TCHAR *temp = ACE_OS::getenv (&argv[j][1]);
00107           if (temp != 0)
00108             end = ACE_OS::strecpy (end, temp);
00109           else
00110             end = ACE_OS::strecpy (end, argv[j]);
00111 #  else
00112           // This is an ACE_HAS_WCHAR platform and not ACE_WIN32.
00113           // Convert the env variable name for getenv(), then convert
00114           // the returned char *string back to wchar_t.
00115           char *ctemp = ACE_OS::getenv (ACE_TEXT_ALWAYS_CHAR (&argv[j][1]));
00116           if (ctemp == 0)
00117             end = ACE_OS::strecpy (end, argv[j]);
00118           else
00119             end = ACE_OS::strecpy (end, ACE_TEXT_CHAR_TO_TCHAR (ctemp));
00120 #  endif /* ACE_WIN32 || !ACE_HAS_WCHAR */
00121         }
00122       else
00123 #endif /* ACE_LACKS_ENV */
00124         end = ACE_OS::strecpy (end, argv[j]);
00125 
00126       // Replace the null char that strecpy put there with white
00127       // space.
00128       end[-1] = ' ';
00129     }
00130 
00131   // Null terminate the string.
00132   *end = '\0';
00133   // The number of arguments.
00134   return j;
00135 }

ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE char * ACE_OS::asctime const struct tm *  tm  ) 
 

Definition at line 14 of file OS_NS_time.inl.

References ACE_NOTSUP_RETURN, and ACE_OS_TRACE.

Referenced by ctime().

00015 {
00016   ACE_OS_TRACE ("ACE_OS::asctime");
00017 #if defined (ACE_LACKS_ASCTIME)
00018   ACE_UNUSED_ARG (t);
00019   ACE_NOTSUP_RETURN (0);
00020 #else
00021   ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::asctime (t), char *, 0);
00022 #endif /* ACE_LACKS_ASCTIME */
00023 }

ACE_INLINE char * ACE_OS::asctime_r const struct tm *  tm,
char *  buf,
int  buflen
 

Definition at line 26 of file OS_NS_time.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, asctime_r(), and strsncpy().

Referenced by asctime_r().

00027 {
00028   ACE_OS_TRACE ("ACE_OS::asctime_r");
00029 #if defined (ACE_HAS_REENTRANT_FUNCTIONS)
00030 # if defined (ACE_HAS_2_PARAM_ASCTIME_R_AND_CTIME_R)
00031   char *result;
00032 #   if defined (DIGITAL_UNIX)
00033   ACE_OSCALL (::_Pasctime_r (t, buf), char *, 0, result);
00034 #   else
00035   ACE_OSCALL (::asctime_r (t, buf), char *, 0, result);
00036 #   endif /* DIGITAL_UNIX */
00037   ACE_OS::strsncpy (buf, result, buflen);
00038   return buf;
00039 # else
00040 #   if defined (ACE_HAS_SIZET_PTR_ASCTIME_R_AND_CTIME_R)
00041   ACE_OSCALL_RETURN (::asctime_r (t, buf, reinterpret_cast<size_t*>(&buflen)), char *, 0);
00042 #   else
00043   ACE_OSCALL_RETURN (::asctime_r (t, buf, buflen), char *, 0);
00044 #   endif /* ACE_HAS_SIZET_PTR_ASCTIME_R_AND_CTIME_R */
00045 # endif /* ACE_HAS_2_PARAM_ASCTIME_R_AND_CTIME_R */
00046 #elif defined (ACE_LACKS_ASCTIME_R)
00047   ACE_UNUSED_ARG (t);
00048   ACE_UNUSED_ARG (buf);
00049   ACE_UNUSED_ARG (buflen);
00050   ACE_NOTSUP_RETURN (0);
00051 #else
00052   char *result = 0;
00053   ACE_OSCALL (ACE_STD_NAMESPACE::asctime (t), char *, 0, result);
00054   ACE_OS::strsncpy (buf, result, buflen);
00055   return buf;
00056 #endif /* ACE_HAS_REENTRANT_FUNCTIONS */
00057 }

ACE_INLINE int ACE_OS::atexit ACE_EXIT_HOOK  func  ) 
 

Definition at line 48 of file OS_NS_stdlib.inl.

References ACE_OS_Object_Manager::at_exit(), and ACE_OS_Object_Manager::instance().

00049 {
00050   return ACE_OS_Object_Manager::instance ()->at_exit (func);
00051 }

ACE_INLINE int ACE_OS::atoi const wchar_t *  s  ) 
 

Definition at line 61 of file OS_NS_stdlib.inl.

References atoi().

00062 {
00063 #if defined (ACE_WIN32)
00064   ACE_OSCALL_RETURN (::_wtoi (s), int, -1);
00065 #else /* ACE_WIN32 */
00066   return ACE_OS::atoi (ACE_Wide_To_Ascii(s).char_rep());
00067 #endif /* ACE_WIN32 */
00068 }

ACE_INLINE int ACE_OS::atoi const char *  s  ) 
 

Definition at line 54 of file OS_NS_stdlib.inl.

References atoi().

Referenced by atoi(), atop(), ACE_High_Res_Timer::get_env_global_scale_factor(), ACE_Service_Manager::init(), ACE_SOCK_Dgram::make_multicast_ifaddr6(), ACE_Logging_Strategy::parse_args(), ACE_Service_Config::parse_args_i(), ACE_Registry_ImpExp::process_previous_line_format(), and ACE_INET_Addr::set_interface().

00055 {
00056   ACE_OSCALL_RETURN (::atoi (s), int, -1);
00057 }

ACE_INLINE void * ACE_OS::atop const wchar_t *  s  ) 
 

Definition at line 94 of file OS_NS_stdlib.inl.

References atoi().

00095 {
00096 #  if defined (ACE_WIN64)
00097   __int64 ip = ::_wtoi64 (s);
00098 #  else
00099   int ip = ACE_OS::atoi (s);
00100 #  endif /* ACE_WIN64 */
00101   void *p = reinterpret_cast<void *> (ip);
00102   return p;
00103 }

ACE_INLINE void * ACE_OS::atop const char *  s  ) 
 

Definition at line 76 of file OS_NS_stdlib.inl.

References ACE_TRACE.

Referenced by ACE_Name_Options::parse_args().

00077 {
00078   ACE_TRACE ("ACE_OS::atop");
00079   // It would be nice to make use of Basic_Types.h here, but that
00080   // file relies on OS.h. Fortunately, most platforms have int
00081   // the same as pointer size (IA32, IA64), with Win64 being the
00082   // exception.
00083 #if defined (ACE_WIN64)
00084   __int64 ip = ::_atoi64 (s);
00085 #else
00086   int ip = ::atoi (s);
00087 #endif /* ACE_WIN64 */
00088   void *p = reinterpret_cast<void *> (ip);
00089   return p;
00090 }

ACE_INLINE int ACE_OS::bind ACE_HANDLE  s,
struct sockaddr *  name,
int  namelen
 

BSD-style (no QoS).

Definition at line 93 of file OS_NS_sys_socket.inl.

References ACE_OS_TRACE, ACE_SOCKCALL_RETURN, and ACE_SOCKET_LEN.

Referenced by ACE::bind_port(), ACE_WIN32_Asynch_Connect::connect_i(), ACE_POSIX_Asynch_Connect::connect_i(), ACE_SOCK_CODgram::open(), ACE_ATM_Stream::open(), ACE_ATM_Acceptor::open(), ACE_Asynch_Acceptor< HANDLER >::open(), ACE_SOCK_SEQPACK_Connector::shared_connect_start(), ACE_SOCK_Connector::shared_connect_start(), ACE_SOCK_SEQPACK_Acceptor::shared_open(), ACE_SOCK_Dgram::shared_open(), ACE_SOCK_Acceptor::shared_open(), and ACE_ICMP_Socket::shared_open().

00094 {
00095   ACE_OS_TRACE ("ACE_OS::bind");
00096   ACE_SOCKCALL_RETURN (::bind ((ACE_SOCKET) handle,
00097                                addr,
00098                                (ACE_SOCKET_LEN) addrlen), int, -1);
00099 }

ACE_INLINE void * ACE_OS::bsearch const void *  key,
const void *  base,
size_t  nel,
size_t  size,
ACE_COMPARE_FUNC 
 

Definition at line 107 of file OS_NS_stdlib.inl.

References ACE_COMPARE_FUNC, and ACE_NOTSUP_RETURN.

00112 {
00113 #if !defined (ACE_LACKS_BSEARCH)
00114   return ::bsearch (key, base, nel, size, compar);
00115 #else
00116   ACE_UNUSED_ARG (key);
00117   ACE_UNUSED_ARG (base);
00118   ACE_UNUSED_ARG (nel);
00119   ACE_UNUSED_ARG (size);
00120   ACE_UNUSED_ARG (compar);
00121   ACE_NOTSUP_RETURN (0);
00122 #endif /* ACE_LACKS_BSEARCH */
00123 }

void * ACE_OS::calloc size_t  elements,
size_t  sizeof_elements
 

Definition at line 38 of file OS_NS_stdlib.cpp.

References ACE_CALLOC_FUNC, and ACE_MALLOC_FUNC.

00039 {
00040 #if !defined (ACE_HAS_WINCE)
00041   return ACE_CALLOC_FUNC (elements, sizeof_elements);
00042 #else
00043   // @@ This will probably not work since it doesn't consider
00044   // alignment properly.
00045   return ACE_MALLOC_FUNC (elements * sizeof_elements);
00046 #endif /* ACE_HAS_WINCE */
00047 }

ACE_INLINE double ACE_OS::ceil double  x  ) 
 

This method computes the smallest integral value not less than x.

Definition at line 22 of file OS_NS_math.inl.

00023   {
00024     // This method computes the smallest integral value not less than x.
00025     if (x < 0)
00026       return static_cast<long> (x);
00027     else if (static_cast<long> (x) == x)
00028       return x;
00029     else
00030       return static_cast<long> (x) + 1;
00031   }

ACE_INLINE int ACE_OS::chdir const wchar_t *  path  ) 
 

Definition at line 143 of file OS_NS_unistd.inl.

References chdir().

00144 {
00145 #if defined (ACE_WIN32)
00146   ACE_OSCALL_RETURN (::_wchdir (path), int, -1);
00147 #else /* ACE_WIN32 */
00148   return ACE_OS::chdir (ACE_Wide_To_Ascii (path).char_rep ());
00149 #endif /* ACE_WIN32 */
00150 }

ACE_INLINE int ACE_OS::chdir const char *  path  ) 
 

Definition at line 122 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and chdir().

Referenced by chdir(), ACE::daemonize(), and ACE_Process::spawn().

00123 {
00124   ACE_OS_TRACE ("ACE_OS::chdir");
00125 #if defined (ACE_HAS_NONCONST_CHDIR)
00126   ACE_OSCALL_RETURN (::chdir (const_cast<char *> (path)), int, -1);
00127 
00128 #elif defined (ACE_WIN32) && defined (__IBMCPP__) && (__IBMCPP__ >= 400)
00129   ACE_OSCALL_RETURN (::_chdir (const_cast<char *> (path)), int, -1);
00130 
00131 #elif defined (ACE_HAS_WINCE)
00132   ACE_UNUSED_ARG (path);
00133   ACE_NOTSUP_RETURN (-1);
00134 
00135 #else
00136   ACE_OSCALL_RETURN (::chdir (path), int, -1);
00137 
00138 #endif /* ACE_HAS_NONCONST_CHDIR */
00139 }

void ACE_OS::cleanup_tss const u_int  main_thread  ) 
 

Call TSS destructors for the current thread. If the current thread is the main thread, then the argument must be 1. For private use of ACE_Object_Manager and ACE_Thread_Adapter only.

Definition at line 1152 of file OS_NS_Thread.cpp.

References ACE_Base_Thread_Adapter::close_log_msg(), and TSS_Cleanup_Instance::valid().

Referenced by DllMain(), ACE_Object_Manager::fini(), ACE_OS_Thread_Adapter::invoke(), ACE_Thread_Adapter::invoke_i(), and thr_exit().

01153 {
01154 #if defined (ACE_HAS_TSS_EMULATION) || defined (ACE_WIN32)
01155   { // scope the cleanup instance
01156     // Call TSS destructors for current thread.
01157     TSS_Cleanup_Instance cleanup;
01158     if (cleanup.valid ())
01159       {
01160         cleanup->thread_exit ();
01161       }
01162   }
01163 #endif /* ACE_HAS_TSS_EMULATION || ACE_WIN32 */
01164 
01165   if (main_thread)
01166     {
01167 #if !defined (ACE_HAS_TSS_EMULATION)  &&  !defined (ACE_HAS_MINIMAL_ACE_OS)
01168       // Just close the ACE_Log_Msg for the current (which should be
01169       // main) thread.  We don't have TSS emulation; if there's native
01170       // TSS, it should call its destructors when the main thread
01171       // exits.
01172       ACE_Base_Thread_Adapter::close_log_msg ();
01173 #endif /* ! ACE_HAS_TSS_EMULATION  &&  ! ACE_HAS_MINIMAL_ACE_OS */
01174 
01175 #if defined (ACE_WIN32) || defined (ACE_HAS_TSS_EMULATION)
01176       // Finally, free up the ACE_TSS_Cleanup instance.  This method gets
01177       // called by the ACE_Object_Manager.
01178       TSS_Cleanup_Instance cleanup(TSS_Cleanup_Instance::DESTROY);
01179       if (cleanup.valid ())
01180       {
01181         ; // the pointer deletes the Cleanup when it goes out of scope
01182       }
01183 
01184 #endif /* WIN32 || ACE_HAS_TSS_EMULATION */
01185 
01186 #if defined (ACE_HAS_TSS_EMULATION)
01187       ACE_TSS_Emulation::tss_close ();
01188 #endif /* ACE_HAS_TSS_EMULATION */
01189     }
01190 }

ACE_INLINE void ACE_OS::clearerr FILE *  fp  ) 
 

Definition at line 369 of file OS_NS_stdio.inl.

Referenced by ACE_Svc_Conf_Lexer::input().

00370 {
00371 #if defined (__ace_clearerr_hack)
00372   __ace_clearerr(fp);
00373 #else
00374    ::clearerr(fp);
00375 #endif /* __ace_clearerr_hack */
00376 }

ACE_INLINE int ACE_OS::clock_gettime clockid_t  ,
struct timespec
 

Definition at line 60 of file OS_NS_time.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, clock_gettime(), and clockid_t.

Referenced by clock_gettime(), and gethrtime().

00061 {
00062   ACE_OS_TRACE ("ACE_OS::clock_gettime");
00063 #if defined (ACE_HAS_CLOCK_GETTIME)
00064   ACE_OSCALL_RETURN (::clock_gettime (clockid, ts), int, -1);
00065 #else
00066   ACE_UNUSED_ARG (clockid);
00067   ACE_UNUSED_ARG (ts);
00068   ACE_NOTSUP_RETURN (-1);
00069 #endif /* ACE_HAS_CLOCK_GETTIME */
00070 }

ACE_INLINE int ACE_OS::clock_settime clockid_t  ,
const struct timespec
 

Definition at line 73 of file OS_NS_time.inl.

References ACE_NOTSUP_RETURN, clock_settime(), and clockid_t.

Referenced by clock_settime().

00074 {
00075 #if defined (ACE_HAS_CLOCK_SETTIME)
00076 #  if defined (ACE_HAS_NONCONST_CLOCK_SETTIME)
00077   ACE_OSCALL_RETURN (::clock_settime (clockid, const_cast<struct timespec *>(ts)), int, -1);
00078 #  else
00079   ACE_OSCALL_RETURN (::clock_settime (clockid, ts), int, -1);
00080 #  endif /* ACE_HAS_NONCONST_CLOCK_SETTIME */
00081 #else
00082   ACE_UNUSED_ARG (clockid);
00083   ACE_UNUSED_ARG (ts);
00084   ACE_NOTSUP_RETURN (-1);
00085 #endif /* ACE_HAS_CLOCK_SETTIME */
00086 }

ACE_INLINE int ACE_OS::close ACE_HANDLE  handle  ) 
 

Definition at line 190 of file OS_NS_unistd.inl.

References ACE_ADAPT_RETVAL, and ACE_OS_TRACE.

Referenced by ACE_Filecache_Object::ACE_Filecache_Object(), ACE_Mutex::ACE_Mutex(), ACE_WIN32_Proactor::close(), ACE_TLI_Stream::close(), ACE_SPIPE::close(), ACE_FILE::close(), ACE_FIFO_Recv::close(), ACE_FIFO::close(), ACE_Dev_Poll_Reactor::close(), ACE_DEV::close(), ACE_Mem_Map::close_filemapping_handle(), ACE_Mem_Map::close_handle(), ACE_Handle_Gobbler::close_remaining_handles(), ACE_SPIPE_Connector::connect(), ACE_SPIPE_Acceptor::create_new_instance(), ACE::daemonize(), dlopen(), event_init(), filesize(), flock_destroy(), fopen(), fork_exec(), ACE_Handle_Gobbler::free_handles(), ACE::get_bcast_addr(), ACE::get_ip_interfaces(), getmacaddress(), ACE_Filecache_Object::release(), ACE_Process_Options::release_handles(), sema_destroy(), sema_init(), ACE_Process::spawn(), ACE::terminate_process(), ACE_Filecache_Handle::~ACE_Filecache_Handle(), ACE_Filecache_Object::~ACE_Filecache_Object(), and ACE_Process::~ACE_Process().

00191 {
00192   ACE_OS_TRACE ("ACE_OS::close");
00193 #if defined (ACE_WIN32)
00194   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::CloseHandle (handle), ace_result_), int, -1);
00195 #else
00196   ACE_OSCALL_RETURN (::close (handle), int, -1);
00197 #endif /* ACE_WIN32 */
00198 }

ACE_INLINE void ACE_OS::closedir ACE_DIR  ) 
 

Definition at line 13 of file OS_NS_dirent.inl.

References ACE_DIR.

Referenced by ACE_Dirent::close(), ACE_Dirent::open(), scandir_emulation(), and ACE_Dirent::~ACE_Dirent().

00014 {
00015 #if defined (ACE_HAS_DIRENT)
00016 # if defined (ACE_WIN32) && defined (ACE_LACKS_CLOSEDIR)
00017   ACE_OS::closedir_emulation (d);
00018   delete [] d->directory_name_;
00019   delete d;
00020 # elif defined (ACE_HAS_WCLOSEDIR) && defined (ACE_USES_WCHAR)
00021   ::wclosedir (d);
00022 # else /* ACE_WIN32 && ACE_LACKS_CLOSEDIR */
00023   ::closedir (d);
00024 # endif /* ACE_WIN32 && ACE_LACKS_CLOSEDIR */
00025 
00026 #else /* ACE_HAS_DIRENT */
00027   ACE_UNUSED_ARG (d);
00028 #endif /* ACE_HAS_DIRENT */
00029 }

ACE_INLINE int ACE_OS::closesocket ACE_HANDLE  s  ) 
 

BSD-style (no QoS).

Definition at line 102 of file OS_NS_sys_socket.inl.

References ACE_OS_TRACE, ACE_SHUTDOWN_WRITE, ACE_SOCKCALL_RETURN, closesocket(), and shutdown().

Referenced by ACE_WIN32_Asynch_Accept::accept(), ACE_SOCK::close(), ACE_POSIX_Asynch_Accept::close(), ACE_Pipe::close(), ACE_Process::close_dup_handles(), ACE_Process::close_passed_handles(), closesocket(), ACE_WIN32_Asynch_Accept_Result::complete(), ACE_Asynch_Acceptor< HANDLER >::handle_accept(), ACE_Asynch_Connector< HANDLER >::handle_connect(), ACE_POSIX_Asynch_Accept::handle_input(), ACE::ipv6_enabled(), ACE_Asynch_Acceptor< HANDLER >::open(), ACE_WIN32_Asynch_Connect::post_result(), ACE_POSIX_Asynch_Connect::post_result(), ACE_AIOCB_Notify_Pipe_Manager::~ACE_AIOCB_Notify_Pipe_Manager(), and ACE_Asynch_Acceptor< HANDLER >::~ACE_Asynch_Acceptor().

00103 {
00104   ACE_OS_TRACE ("ACE_OS::closesocket");
00105 #if defined (ACE_WIN32)
00106   ACE_OS::shutdown (handle, ACE_SHUTDOWN_WRITE);
00107   ACE_SOCKCALL_RETURN (::closesocket ((SOCKET) handle), int, -1);
00108 #else
00109   ACE_OSCALL_RETURN (::close (handle), int, -1);
00110 #endif /* ACE_WIN32 */
00111 }

ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE char * ACE_OS::compile const char *  instring,
char *  expbuf,
char *  endbuf
 

Definition at line 11 of file OS_NS_regex.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and compile().

Referenced by compile(), ACE_Local_Name_Space<, ACE_LOCK >::list_type_entries_i(), and ACE_Local_Name_Space<, ACE_LOCK >::list_types_i().

00012 {
00013   ACE_OS_TRACE ("ACE_OS::compile");
00014 #if defined (ACE_HAS_REGEX)
00015   ACE_OSCALL_RETURN (::compile (instring, expbuf, endbuf), char *, 0);
00016 #else
00017   ACE_UNUSED_ARG (instring);
00018   ACE_UNUSED_ARG (expbuf);
00019   ACE_UNUSED_ARG (endbuf);
00020 
00021   ACE_NOTSUP_RETURN (0);
00022 #endif /* ACE_HAS_REGEX */
00023 }

ACE_INLINE int ACE_OS::cond_broadcast ACE_cond_t *  cv  ) 
 

Definition at line 214 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, and cond_broadcast().

Referenced by ACE_Condition_Thread_Mutex::broadcast(), ACE_Condition< MUTEX >::broadcast(), ACE_Condition< ACE_Recursive_Thread_Mutex >::broadcast(), cond_broadcast(), event_destroy(), event_pulse(), event_signal(), ACE_Condition_Thread_Mutex::remove(), ACE_Condition< MUTEX >::remove(), and rw_unlock().

00215 {
00216   ACE_OS_TRACE ("ACE_OS::cond_broadcast");
00217 # if defined (ACE_HAS_THREADS)
00218 #   if defined (ACE_HAS_PTHREADS)
00219 #     if defined (ACE_HAS_PTHREADS_DRAFT4) || defined (ACE_HAS_PTHREADS_DRAFT6)
00220   ACE_OSCALL_RETURN (pthread_cond_broadcast (cv), int, -1);
00221 #     else
00222   int result;
00223   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_cond_broadcast (cv),
00224                                        result),
00225                      int, -1);
00226 #     endif /* ACE_HAS_PTHREADS_DRAFT4 || ACE_HAS_PTHREADS_DRAFT6 */
00227 #   elif defined (ACE_HAS_STHREADS)
00228   int result;
00229   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::cond_broadcast (cv),
00230                                        result),
00231                      int, -1);
00232 #   endif /* ACE_HAS_STHREADS */
00233 # else
00234   ACE_UNUSED_ARG (cv);
00235   ACE_NOTSUP_RETURN (-1);
00236 # endif /* ACE_HAS_THREADS */
00237 }

ACE_INLINE int ACE_OS::cond_destroy ACE_cond_t *  cv  ) 
 

Definition at line 240 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, and cond_destroy().

Referenced by cond_destroy(), event_destroy(), recursive_mutex_destroy(), ACE_Condition_Thread_Mutex::remove(), ACE_Condition< MUTEX >::remove(), ACE_Condition< ACE_Recursive_Thread_Mutex >::remove(), rwlock_destroy(), sema_destroy(), and sema_init().

00241 {
00242   ACE_OS_TRACE ("ACE_OS::cond_destroy");
00243 # if defined (ACE_HAS_THREADS)
00244 #   if defined (ACE_HAS_PTHREADS)
00245 #     if defined (ACE_HAS_PTHREADS_DRAFT4) || defined (ACE_HAS_PTHREADS_DRAFT6)
00246   ACE_OSCALL_RETURN (pthread_cond_destroy (cv), int, -1);
00247 #     else
00248   int result;
00249   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_cond_destroy (cv), result), int, -1);
00250 #     endif /* ACE_HAS_PTHREADS_DRAFT4 || ACE_HAS_PTHREADS_DRAFT6 */
00251 #   elif defined (ACE_HAS_STHREADS)
00252   int result;
00253   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::cond_destroy (cv), result), int, -1);
00254 #   endif /* ACE_HAS_STHREADS */
00255 # else
00256   ACE_UNUSED_ARG (cv);
00257   ACE_NOTSUP_RETURN (-1);
00258 # endif /* ACE_HAS_THREADS */
00259 }

ACE_INLINE int ACE_OS::cond_init ACE_cond_t *  cv,
ACE_condattr_t &  attributes,
const wchar_t *  name,
void *  arg = 0
 

Definition at line 317 of file OS_NS_Thread.inl.

References cond_init().

00321 {
00322   return ACE_OS::cond_init (cv, attributes, ACE_Wide_To_Ascii (name).char_rep (), arg);
00323 }

ACE_INLINE int ACE_OS::cond_init ACE_cond_t *  cv,
short  type,
const wchar_t *  name,
void *  arg = 0
 

Definition at line 328 of file OS_NS_Thread.inl.

References cond_init().

00329 {
00330   return ACE_OS::cond_init (cv, type, ACE_Wide_To_Ascii (name).char_rep (), arg);
00331 }

ACE_INLINE int ACE_OS::cond_init ACE_cond_t *  cv,
ACE_condattr_t &  attributes,
const char *  name = 0,
void *  arg = 0
 

Definition at line 262 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, cond_init(), and memset().

00266 {
00267   // ACE_OS_TRACE ("ACE_OS::cond_init");
00268   ACE_UNUSED_ARG (name);
00269   ACE_UNUSED_ARG (arg);
00270 # if defined (ACE_HAS_THREADS)
00271 #   if defined (ACE_HAS_PTHREADS)
00272   int result = -1;
00273 
00274 #     if defined (ACE_VXWORKS) && (ACE_VXWORKS >= 0x600) && (ACE_VXWORKS <= 0x620)
00275   /* VxWorks 6.x API reference states:
00276    *   If the memory for the condition variable object has been allocated
00277    *   dynamically, it is a good policy to always zero out the
00278    *   block of memory so as to avoid spurious EBUSY return code
00279    *   when calling this routine.
00280    */
00281   ACE_OS::memset (cv, 0, sizeof (*cv));
00282 #     endif
00283 
00284   if (
00285 #     if defined  (ACE_HAS_PTHREADS_DRAFT4)
00286       pthread_cond_init (cv, attributes) == 0
00287 #     elif defined (ACE_HAS_PTHREADS_STD) || defined (ACE_HAS_PTHREADS_DRAFT7)
00288       ACE_ADAPT_RETVAL (pthread_cond_init (cv, &attributes), result) == 0
00289 #     else  /* this is draft 6 */
00290       pthread_cond_init (cv, &attributes) == 0
00291 #     endif /* ACE_HAS_PTHREADS_DRAFT4 */
00292       )
00293      result = 0;
00294   else
00295      result = -1;       // ACE_ADAPT_RETVAL used it for intermediate status
00296 
00297   return result;
00298 #   elif defined (ACE_HAS_STHREADS)
00299   int result;
00300   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::cond_init (cv,
00301                                                     attributes.type,
00302                                                     arg),
00303                                        result),
00304                      int, -1);
00305 #   endif /* ACE_HAS_PTHREADS vs. ACE_HAS_STHREADS */
00306 # else
00307   ACE_UNUSED_ARG (cv);
00308   ACE_UNUSED_ARG (attributes);
00309   ACE_UNUSED_ARG (name);
00310   ACE_UNUSED_ARG (arg);
00311   ACE_NOTSUP_RETURN (-1);
00312 # endif /* ACE_HAS_THREADS */
00313 }

int ACE_OS::cond_init ACE_cond_t *  cv,
short  type = ACE_DEFAULT_SYNCH_TYPE,
const char *  name = 0,
void *  arg = 0
 

Definition at line 1810 of file OS_NS_Thread.cpp.

References condattr_destroy(), and condattr_init().

Referenced by ACE_Condition< MUTEX >::ACE_Condition(), ACE_Condition< ACE_Recursive_Thread_Mutex >::ACE_Condition(), ACE_Condition_Thread_Mutex::ACE_Condition_Thread_Mutex(), cond_init(), event_init(), recursive_mutex_init(), and sema_init().

01811 {
01812   ACE_condattr_t attributes;
01813   if (ACE_OS::condattr_init (attributes, type) == 0
01814       && ACE_OS::cond_init (cv, attributes, name, arg) == 0)
01815     {
01816       (void) ACE_OS::condattr_destroy (attributes);
01817       return 0;
01818     }
01819   return -1;
01820 }

ACE_INLINE int ACE_OS::cond_signal ACE_cond_t *  cv  ) 
 

Definition at line 335 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, and cond_signal().

Referenced by cond_signal(), event_pulse(), event_signal(), recursive_mutex_cond_unlock(), recursive_mutex_unlock(), rw_unlock(), sema_post(), ACE_Condition_Thread_Mutex::signal(), ACE_Condition< MUTEX >::signal(), and ACE_Condition< ACE_Recursive_Thread_Mutex >::signal().

00336 {
00337   ACE_OS_TRACE ("ACE_OS::cond_signal");
00338 # if defined (ACE_HAS_THREADS)
00339 #   if defined (ACE_HAS_PTHREADS)
00340 #     if defined (ACE_HAS_PTHREADS_DRAFT4) || defined (ACE_HAS_PTHREADS_DRAFT6)
00341   ACE_OSCALL_RETURN (pthread_cond_signal (cv), int, -1);
00342 #     else
00343   int result;
00344   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_cond_signal (cv), result),
00345                      int, -1);
00346 #     endif /* ACE_HAS_PTHREADS_DRAFT4 || ACE_HAS_PTHREADS_DRAFT6 */
00347 #   elif defined (ACE_HAS_STHREADS)
00348   int result;
00349   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::cond_signal (cv), result), int, -1);
00350 #   endif /* ACE_HAS_STHREADS */
00351 # else
00352   ACE_UNUSED_ARG (cv);
00353   ACE_NOTSUP_RETURN (-1);
00354 # endif /* ACE_HAS_THREADS */
00355 }

ACE_INLINE int ACE_OS::cond_timedwait ACE_cond_t *  cv,
ACE_mutex_t *  m,
ACE_Time_Value
 

Definition at line 384 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_TIMESPEC_PTR, cond_timedwait(), cond_wait(), ETIME, ETIMEDOUT, gettimeofday(), and timespec_t.

Referenced by cond_timedwait(), event_timedwait(), recursive_mutex_lock(), sema_wait(), ACE_Condition_Thread_Mutex::wait(), ACE_Condition< MUTEX >::wait(), and ACE_Condition< ACE_Recursive_Thread_Mutex >::wait().

00387 {
00388   ACE_OS_TRACE ("ACE_OS::cond_timedwait");
00389 # if defined (ACE_HAS_THREADS)
00390   int result;
00391   timespec_t ts;
00392 
00393   if (timeout != 0)
00394     ts = *timeout; // Calls ACE_Time_Value::operator timespec_t().
00395 
00396 #   if defined (ACE_HAS_PTHREADS)
00397 
00398 #     if defined (ACE_HAS_PTHREADS_DRAFT4) || defined (ACE_HAS_PTHREADS_DRAFT6)
00399   if (timeout == 0)
00400     ACE_OSCALL (pthread_cond_wait (cv, external_mutex),
00401                 int, -1, result);
00402   else
00403     {
00404 
00405 #     if defined (ACE_LYNXOS_MAJOR) && (ACE_LYNXOS_MAJOR == 3) && (ACE_LYNXOS_MINOR == 0)
00406       // Note that we must convert between absolute time (which is
00407       // passed as a parameter) and relative time (which is what the
00408       // LynxOS pthread_cond_timedwait expects).  This differs from 1003.4a
00409       // draft 4.
00410 
00411       timespec_t relative_time = *timeout - ACE_OS::gettimeofday ();
00412 
00413       ACE_OSCALL (pthread_cond_timedwait (cv, external_mutex,
00414                                             &relative_time),
00415                   int, -1, result);
00416 #     else
00417       ACE_OSCALL (pthread_cond_timedwait (cv, external_mutex,
00418                                             (ACE_TIMESPEC_PTR) &ts),
00419                   int, -1, result);
00420 #     endif /* ACE_LYNXOS_MAJOR ... */
00421     }
00422 
00423 #     else
00424   ACE_OSCALL (ACE_ADAPT_RETVAL (timeout == 0
00425                                 ? pthread_cond_wait (cv, external_mutex)
00426                                 : pthread_cond_timedwait (cv, external_mutex,
00427                                                             (ACE_TIMESPEC_PTR) &ts),
00428                                 result),
00429               int, -1, result);
00430 #     endif /* ACE_HAS_PTHREADS_DRAFT4 || ACE_HAS_PTHREADS_DRAFT6*/
00431   // We need to adjust this to make the POSIX and Solaris return
00432   // values consistent.  EAGAIN is from Pthreads DRAFT4 (HP-UX 10.20 and
00433   // down); EINTR is from LynxOS.
00434   if (result == -1 &&
00435       (errno == ETIMEDOUT || errno == EAGAIN || errno == EINTR))
00436     errno = ETIME;
00437 
00438 #   elif defined (ACE_HAS_STHREADS)
00439   ACE_OSCALL (ACE_ADAPT_RETVAL (timeout == 0
00440                                 ? ::cond_wait (cv, external_mutex)
00441                                 : ::cond_timedwait (cv,
00442                                                     external_mutex,
00443                                                     (timestruc_t*)&ts),
00444                                 result),
00445               int, -1, result);
00446 #   endif /* ACE_HAS_STHREADS */
00447   if (timeout != 0)
00448     timeout->set (ts); // Update the time value before returning.
00449 
00450   return result;
00451 # else
00452   ACE_UNUSED_ARG (cv);
00453   ACE_UNUSED_ARG (external_mutex);
00454   ACE_UNUSED_ARG (timeout);
00455   ACE_NOTSUP_RETURN (-1);
00456 # endif /* ACE_HAS_THREADS */
00457 }

ACE_INLINE int ACE_OS::cond_wait ACE_cond_t *  cv,
ACE_mutex_t *  m
 

Definition at line 358 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, and cond_wait().

Referenced by cond_timedwait(), cond_wait(), event_wait(), recursive_mutex_cond_relock(), recursive_mutex_lock(), rw_rdlock(), rw_trywrlock_upgrade(), rw_wrlock(), sema_wait(), ACE_Condition_Thread_Mutex::wait(), ACE_Condition< MUTEX >::wait(), and ACE_Condition< ACE_Recursive_Thread_Mutex >::wait().

00360 {
00361   ACE_OS_TRACE ("ACE_OS::cond_wait");
00362 # if defined (ACE_HAS_THREADS)
00363 #   if defined (ACE_HAS_PTHREADS)
00364 #     if defined (ACE_HAS_PTHREADS_DRAFT4) || defined (ACE_HAS_PTHREADS_DRAFT6)
00365   ACE_OSCALL_RETURN (pthread_cond_wait (cv, external_mutex), int, -1);
00366 #     else
00367   int result;
00368   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_cond_wait (cv, external_mutex), result),
00369                      int, -1);
00370 #     endif /* ACE_HAS_PTHREADS_DRAFT4 || ACE_HAS_PTHREADS_DRAFT6 */
00371 #   elif defined (ACE_HAS_STHREADS)
00372   int result;
00373   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::cond_wait (cv, external_mutex), result),
00374                      int, -1);
00375 #   endif /* ACE_HAS_PTHREADS */
00376 # else
00377   ACE_UNUSED_ARG (cv);
00378   ACE_UNUSED_ARG (external_mutex);
00379   ACE_NOTSUP_RETURN (-1);
00380 # endif /* ACE_HAS_THREADS */
00381 }

ACE_INLINE int ACE_OS::condattr_destroy ACE_condattr_t &  attributes  ) 
 

Definition at line 132 of file OS_NS_Thread.inl.

Referenced by cond_init(), and ACE_Condition_Attributes::~ACE_Condition_Attributes().

00133 {
00134 #if defined (ACE_HAS_THREADS)
00135 #   if defined (ACE_HAS_PTHREADS)
00136 
00137 #     if defined (ACE_HAS_PTHREADS_DRAFT4)
00138   pthread_condattr_delete (&attributes);
00139 #     else
00140   pthread_condattr_destroy (&attributes);
00141 #     endif /* ACE_HAS_PTHREADS_DRAFT4 */
00142 
00143 #   elif defined (ACE_HAS_STHREADS)
00144   attributes.type = 0;
00145 
00146 #   endif /* ACE_HAS_PTHREADS vs. ACE_HAS_STHREADS */
00147   return 0;
00148 # else
00149   ACE_UNUSED_ARG (attributes);
00150   return 0;
00151 # endif /* ACE_HAS_THREADS  */
00152 }

ACE_INLINE int ACE_OS::condattr_init ACE_condattr_t &  attributes,
int  type = ACE_DEFAULT_SYNCH_TYPE
 

Definition at line 155 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, and memset().

Referenced by ACE_Condition_Attributes::ACE_Condition_Attributes(), and cond_init().

00157 {
00158   ACE_UNUSED_ARG (type);
00159 # if defined (ACE_HAS_THREADS)
00160 #   if defined (ACE_HAS_PTHREADS)
00161   int result = -1;
00162 
00163 #   if defined (ACE_VXWORKS) && (ACE_VXWORKS >= 0x600) && (ACE_VXWORKS <= 0x620)
00164       /* Tests show that VxWorks 6.x pthread lib does not only
00165        * require zeroing of mutex/condition objects to function correctly
00166        * but also of the attribute objects.
00167        */
00168       ACE_OS::memset (&attributes, 0, sizeof (attributes));
00169 #   endif
00170   if (
00171 #     if defined  (ACE_HAS_PTHREADS_DRAFT4)
00172       pthread_condattr_create (&attributes) == 0
00173 #     elif defined (ACE_HAS_PTHREADS_STD) || defined (ACE_HAS_PTHREADS_DRAFT7)
00174       ACE_ADAPT_RETVAL (pthread_condattr_init (&attributes), result) == 0
00175 #       if defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_CONDATTR_PSHARED)
00176       && ACE_ADAPT_RETVAL (pthread_condattr_setpshared (&attributes, type),
00177                            result) == 0
00178 #       endif /* _POSIX_THREAD_PROCESS_SHARED && ! ACE_LACKS_CONDATTR_PSHARED */
00179 #     else  /* this is draft 6 */
00180       pthread_condattr_init (&attributes) == 0
00181 #       if !defined (ACE_LACKS_CONDATTR_PSHARED)
00182       && pthread_condattr_setpshared (&attributes, type) == 0
00183 #       endif /* ACE_LACKS_CONDATTR_PSHARED */
00184 #       if defined (ACE_HAS_PTHREAD_CONDATTR_SETKIND_NP)
00185       && pthread_condattr_setkind_np (&attributes, type) == 0
00186 #       endif /* ACE_HAS_PTHREAD_CONDATTR_SETKIND_NP */
00187 #     endif /* ACE_HAS_PTHREADS_DRAFT4 */
00188       )
00189      result = 0;
00190   else
00191      result = -1;       // ACE_ADAPT_RETVAL used it for intermediate status
00192 
00193   return result;
00194 #   elif defined (ACE_HAS_STHREADS)
00195   attributes.type = type;
00196 
00197   return 0;
00198 
00199 #   else
00200   ACE_UNUSED_ARG (attributes);
00201   ACE_UNUSED_ARG (type);
00202   ACE_NOTSUP_RETURN (-1);
00203 
00204 #   endif /* ACE_HAS_PTHREADS vs. ACE_HAS_STHREADS */
00205 
00206 # else
00207   ACE_UNUSED_ARG (attributes);
00208   ACE_UNUSED_ARG (type);
00209   ACE_NOTSUP_RETURN (-1);
00210 # endif /* ACE_HAS_THREADS */
00211 }

int ACE_OS::connect ACE_HANDLE  handle,
const sockaddr *  addr,
int  addrlen,
const ACE_QoS_Params qos_params
 

QoS-enabled , which passes to . If the OS platform doesn't support QoS-enabled then the are ignored and the BSD-style is called.

Definition at line 41 of file OS_NS_sys_socket.cpp.

References ACE_OS_TRACE, ACE_SOCKCALL_RETURN, ACE_SOCKET_LEN, ACE_QoS_Params::callee_data(), ACE_QoS_Params::caller_data(), connect(), ACE_QoS_Params::group_socket_qos(), and ACE_QoS_Params::socket_qos().

00045 {
00046   ACE_OS_TRACE ("ACE_OS::connect");
00047 # if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
00048   ACE_SOCKCALL_RETURN (::WSAConnect ((ACE_SOCKET) handle,
00049                                      (const sockaddr *) addr,
00050                                      (ACE_SOCKET_LEN) addrlen,
00051                                      (WSABUF *) qos_params.caller_data (),
00052                                      (WSABUF *) qos_params.callee_data (),
00053                                      (QOS *) qos_params.socket_qos (),
00054                                      (QOS *) qos_params.group_socket_qos ()),
00055                        int, -1);
00056 # else
00057   ACE_UNUSED_ARG (qos_params);
00058   return ACE_OS::connect (handle,
00059                           const_cast <sockaddr *> (addr),
00060                           addrlen);
00061 # endif /* ACE_HAS_WINSOCK2 */
00062 }

ACE_INLINE int ACE_OS::connect ACE_HANDLE  handle,
struct sockaddr *  addr,
int  addrlen
 

BSD-style (no QoS).

Definition at line 114 of file OS_NS_sys_socket.inl.

References ACE_OS_TRACE, ACE_SOCKCALL_RETURN, and ACE_SOCKET_LEN.

Referenced by ACE_SOCK_SEQPACK_Connector::connect(), ACE_SOCK_Connector::connect(), connect(), ACE_ATM_Connector::connect(), ACE_SOCK_CODgram::open(), and ACE_Ping_Socket::send_echo_check().

00117 {
00118   ACE_OS_TRACE ("ACE_OS::connect");
00119   ACE_SOCKCALL_RETURN (::connect ((ACE_SOCKET) handle,
00120                                   addr,
00121                                   (ACE_SOCKET_LEN) addrlen), int, -1);
00122 }

ACE_INLINE ACE_HANDLE ACE_OS::creat const ACE_TCHAR filename,
mode_t  mode
 

Definition at line 16 of file OS_NS_sys_stat.inl.

References ACE_OS_TRACE, ACE_TCHAR, ACE_TEXT_ALWAYS_CHAR, creat(), mode_t, and open().

Referenced by creat(), and ACE_SPIPE_Acceptor::create_new_instance().

00017   {
00018     ACE_OS_TRACE ("ACE_OS::creat");
00019 #if defined (ACE_WIN32)
00020     return ACE_OS::open (filename, O_CREAT|O_TRUNC|O_WRONLY, mode);
00021 #else
00022     ACE_OSCALL_RETURN (::creat (ACE_TEXT_ALWAYS_CHAR (filename), mode),
00023                        ACE_HANDLE, ACE_INVALID_HANDLE);
00024 #endif /* ACE_WIN32 */
00025   }

ACE_INLINE ACE_TCHAR * ACE_OS::ctime const time_t *  t  ) 
 

Definition at line 92 of file OS_NS_time.inl.

References ACE_OS_TRACE, ACE_TCHAR, asctime(), ctime(), ctime_buf_size, ctime_r(), and localtime().

Referenced by ctime(), and ctime_r().

00093 {
00094   ACE_OS_TRACE ("ACE_OS::ctime");
00095 #if defined (ACE_HAS_BROKEN_CTIME)
00096   ACE_OSCALL_RETURN (::asctime (::localtime (t)), char *, 0);
00097 #elif defined (ACE_HAS_WINCE)
00098   static ACE_TCHAR buf [ctime_buf_size];
00099   return ACE_OS::ctime_r (t,
00100                           buf,
00101                           ctime_buf_size);
00102 #elif defined (ACE_WIN32) && defined (ACE_USES_WCHAR)
00103   ACE_OSCALL_RETURN (::_wctime (t), wchar_t *, 0);
00104 #else
00105 #  if defined (ACE_USES_WCHAR)   /* Not Win32, else it would do the above */
00106   char *narrow_time;
00107   ACE_OSCALL (::ctime (t), char *, 0, narrow_time);
00108   if (narrow_time == 0)
00109     return 0;
00110   // ACE_Ascii_To_Wide::convert allocates (via new []) a wchar_t[]. If
00111   // we've done this before, free the previous one. Yes, this leaves a
00112   // small memory leak (26 characters) but there's no way around this
00113   // that I know of. (Steve Huston, 12-Feb-2003).
00114   static wchar_t *wide_time = 0;
00115   if (wide_time != 0)
00116     delete [] wide_time;
00117   wide_time = ACE_Ascii_To_Wide::convert (narrow_time);
00118   return wide_time;
00119 #  else
00120   ACE_OSCALL_RETURN (::ctime (t), char *, 0);
00121 #  endif /* ACE_USES_WCHAR */
00122 # endif /* ACE_HAS_BROKEN_CTIME */
00123 }

ACE_INLINE ACE_TCHAR * ACE_OS::ctime_r const time_t *  clock,
ACE_TCHAR buf,
int  buflen
 

Definition at line 127 of file OS_NS_time.inl.

References ACE_OS_TRACE, ACE_TCHAR, ctime(), ctime_buf_size, ctime_r(), and strsncpy().

Referenced by ctime(), ctime_r(), ACE_Log_Record::format_msg(), and ACE::timestamp().

00128 {
00129   ACE_OS_TRACE ("ACE_OS::ctime_r");
00130 
00131 #if defined (ACE_HAS_REENTRANT_FUNCTIONS)
00132 
00133   char *bufp = 0;
00134 #   if defined (ACE_USES_WCHAR)
00135   char narrow_buf[ctime_buf_size];
00136   bufp = narrow_buf;
00137 #   else
00138   bufp = buf;
00139 #   endif /* ACE_USES_WCHAR */
00140 
00141   if (buflen < ctime_buf_size)
00142     {
00143       errno = ERANGE;
00144       return 0;
00145     }
00146 #   if defined (ACE_HAS_2_PARAM_ASCTIME_R_AND_CTIME_R)
00147 #      if defined (DIGITAL_UNIX)
00148   ACE_OSCALL (::_Pctime_r (t, bufp), ACE_TCHAR *, 0, bufp);
00149 #      else /* DIGITAL_UNIX */
00150   ACE_OSCALL (::ctime_r (t, bufp), char *, 0, bufp);
00151 #      endif /* DIGITAL_UNIX */
00152 #   else /* ACE_HAS_2_PARAM_ASCTIME_R_AND_CTIME_R */
00153 
00154 #      if defined (ACE_HAS_SIZET_PTR_ASCTIME_R_AND_CTIME_R)
00155   bufp = ::ctime_r (t, bufp, reinterpret_cast<size_t*>(&buflen));
00156 #      else /* ACE_CTIME_R_RETURNS_INT */
00157   bufp = ::ctime_r (t, bufp, buflen);
00158 #      endif /* ACE_CTIME_R_RETURNS_INT */
00159 
00160 #   endif /* ACE_HAS_2_PARAM_ASCTIME_R_AND_CTIME_R */
00161 
00162   if (bufp == 0)
00163     return 0;
00164 
00165 #   if defined (ACE_USES_WCHAR)
00166   ACE_Ascii_To_Wide wide_buf (bufp);
00167   ACE_OS_String::strcpy (buf, wide_buf.wchar_rep ());
00168   return buf;
00169 #   else
00170   return bufp;
00171 #   endif /* ACE_USES_WCHAR */
00172 
00173 #else /* ACE_HAS_REENTRANT_FUNCTIONS */
00174   if (buflen < ctime_buf_size)
00175     {
00176       errno = ERANGE;
00177       return 0;
00178     }
00179 
00180   ACE_TCHAR *result;
00181 #     if defined (ACE_USES_WCHAR)
00182   ACE_OSCALL (::_wctime (t), wchar_t *, 0, result);
00183 #     else /* ACE_USES_WCHAR */
00184   ACE_OSCALL (::ctime (t), char *, 0, result);
00185 #     endif /* ACE_USES_WCHAR */
00186   if (result != 0)
00187     ACE_OS::strsncpy (buf, result, buflen);
00188   return buf;
00189 #endif /* ACE_HAS_REENTRANT_FUNCTIONS */
00190 }

ACE_INLINE wchar_t * ACE_OS::cuserid wchar_t *  user,
size_t  maxlen = ACE_MAX_USERID
 

Definition at line 480 of file OS_NS_stdio.inl.

References ACE_FAIL_RETURN, ACE_NEW_RETURN, cuserid(), and strcpy().

00481 {
00482 # if defined (ACE_WIN32)
00483   BOOL result = GetUserNameW (user, (u_long *) &maxlen);
00484   if (result == FALSE)
00485     ACE_FAIL_RETURN (0);
00486   else
00487     return user;
00488 # else /* ACE_WIN32 */
00489   char *char_user;
00490   wchar_t *result = 0;
00491 
00492   ACE_NEW_RETURN (char_user, char[maxlen + 1], 0);
00493 
00494   if (ACE_OS::cuserid (char_user, maxlen))
00495     {
00496       ACE_OS::strcpy (user, ACE_Ascii_To_Wide (char_user).wchar_rep ());
00497       result = user;
00498     }
00499 
00500   delete [] char_user;
00501 
00502   return result;
00503 # endif /* ACE_WIN32 */
00504 }

ACE_INLINE char * ACE_OS::cuserid char *  user,
size_t  maxlen = ACE_MAX_USERID
 

Definition at line 381 of file OS_NS_stdio.inl.

References ACE_FAIL_RETURN, ACE_NOTSUP_RETURN, ACE_OS_TRACE, strcpy(), and strlen().

Referenced by cuserid().

00382 {
00383   ACE_OS_TRACE ("ACE_OS::cuserid");
00384 #if defined (ACE_VXWORKS)
00385   ACE_UNUSED_ARG (maxlen);
00386   if (user == 0)
00387     {
00388       // Require that the user field be non-null, i.e., don't
00389       // allocate or use static storage.
00390       ACE_NOTSUP_RETURN (0);
00391     }
00392   else
00393     {
00394       ::remCurIdGet (user, 0);
00395       return user;
00396     }
00397 #elif defined (__QNXNTO__)
00398   ACE_UNUSED_ARG (user);
00399   ACE_UNUSED_ARG (maxlen);
00400   ACE_NOTSUP_RETURN (0);
00401 #elif defined (ACE_WIN32)
00402   BOOL result = GetUserNameA (user, (u_long *) &maxlen);
00403   if (result == FALSE)
00404     ACE_FAIL_RETURN (0);
00405   else
00406     return user;
00407 #elif defined (ACE_HAS_ALT_CUSERID)
00408 #  if defined (ACE_LACKS_PWD_FUNCTIONS)
00409 #    error Cannot use alternate cuserid() without POSIX password functions!
00410 #  endif  /* ACE_LACKS_PWD_FUNCTIONS */
00411 
00412   // POSIX.1 dropped the cuserid() function.
00413   // GNU GLIBC and other platforms correctly deprecate the cuserid()
00414   // function.
00415 
00416   if (maxlen == 0)
00417     {
00418       // It doesn't make sense to have a zero length user ID.
00419       errno = EINVAL;
00420       return 0;
00421     }
00422 
00423   struct passwd *pw = 0;
00424 
00425   // Make sure the file pointer is at the beginning of the password file
00426   ::setpwent ();
00427   // Should use ACE_OS::setpwent() but I didn't want to move this
00428   // method after it.
00429 
00430   // Use the effective user ID to determine the user name.
00431   pw = ::getpwuid (::geteuid ());
00432 
00433   // Make sure the password file is closed.
00434   ::endpwent ();
00435 
00436   size_t max_length = 0;
00437   char *userid = 0;
00438 
00439   if (user == 0)
00440     {
00441       // Not reentrant/thread-safe, but nothing else can be done if a
00442       // zero pointer was passed in as the destination.
00443 
00444 #if defined (_POSIX_SOURCE)
00445       const size_t ACE_L_cuserid = L_cuserid;
00446 #else
00447       const size_t ACE_L_cuserid = 9;  // 8 character user ID + NULL
00448 #endif  /* _POSIX_SOURCE */
00449 
00450       static char tmp[ACE_L_cuserid] = { '\0' };
00451       max_length = ACE_L_cuserid - 1; // Do not include NULL in length
00452 
00453       userid = tmp;
00454     }
00455   else
00456     {
00457       max_length = maxlen;
00458       userid = user;
00459     }
00460 
00461   // Extract the user name from the passwd structure.
00462   if (ACE_OS::strlen (pw->pw_name) <= max_length)
00463     {
00464       return ACE_OS::strcpy (userid, pw->pw_name);
00465     }
00466   else
00467     {
00468       errno = ENOSPC;  // Buffer is not large enough.
00469       return 0;
00470     }
00471 #else
00472   // Hackish because of missing buffer size!
00473   ACE_UNUSED_ARG (maxlen);
00474   ACE_OSCALL_RETURN (::ace_cuserid(user), char*, 0);
00475 #endif /* ACE_VXWORKS */
00476 }

ACE_NAMESPACE_INLINE_FUNCTION LPSECURITY_ATTRIBUTES default_win32_security_attributes LPSECURITY_ATTRIBUTES   ) 
 

Default Win32 Security Attributes definition.

ACE_NAMESPACE_INLINE_FUNCTION LPSECURITY_ATTRIBUTES default_win32_security_attributes_r LPSECURITY_ATTRIBUTES  ,
LPSECURITY_ATTRIBUTES  ,
SECURITY_DESCRIPTOR * 
 

Referenced by mmap(), and sema_init().

ACE_INLINE double ACE_OS::difftime time_t  t1,
time_t  t0
 

Definition at line 195 of file OS_NS_time.inl.

References ace_difftime().

Referenced by ACE_Filecache_Object::update().

00196 {
00197   return ::ace_difftime (t1, t0);
00198 }

ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE int ACE_OS::dlclose ACE_SHLIB_HANDLE  handle  ) 
 

Definition at line 26 of file OS_NS_dlfcn.inl.

References ACE_ADAPT_RETVAL, ACE_LIB_TEXT, ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_SHLIB_HANDLE, dlclose(), and dlsym().

Referenced by ACE_DLL_Handle::close(), and dlclose().

00027 {
00028   ACE_OS_TRACE ("ACE_OS::dlclose");
00029 #if defined (ACE_LACKS_DLCLOSE)
00030   ACE_UNUSED_ARG (handle);
00031   return 0;
00032 #elif defined (ACE_HAS_SVR4_DYNAMIC_LINKING)
00033 
00034 # if !defined (ACE_HAS_AUTOMATIC_INIT_FINI)
00035   // SunOS4 does not automatically call _fini()!
00036   void *ptr;
00037 
00038   ACE_OSCALL (::dlsym (handle, ACE_LIB_TEXT ("_fini")), void *, 0, ptr);
00039 
00040   if (ptr != 0)
00041     (*((int (*)(void)) ptr)) (); // Call _fini hook explicitly.
00042 # endif /* ACE_HAS_AUTOMATIC_INIT_FINI */
00043 #if defined (_M_UNIX)
00044   ACE_OSCALL_RETURN (::_dlclose (handle), int, -1);
00045 #else /* _MUNIX */
00046     ACE_OSCALL_RETURN (::dlclose (handle), int, -1);
00047 #endif /* _M_UNIX */
00048 #elif defined (ACE_WIN32)
00049   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::FreeLibrary (handle), ace_result_), int, -1);
00050 #elif defined (__hpux)
00051   // HP-UX 10.x and 32-bit 11.00 do not pay attention to the ref count
00052   // when unloading a dynamic lib.  So, if the ref count is more than
00053   // 1, do not unload the lib.  This will cause a library loaded more
00054   // than once to not be unloaded until the process runs down, but
00055   // that's life.  It's better than unloading a library that's in use.
00056   // So far as I know, there's no way to decrement the refcnt that the
00057   // kernel is looking at - the shl_descriptor is a copy of what the
00058   // kernel has, not the actual struct.  On 64-bit HP-UX using dlopen,
00059   // this problem has been fixed.
00060   struct shl_descriptor  desc;
00061   if (shl_gethandle_r (handle, &desc) == -1)
00062     return -1;
00063   if (desc.ref_count > 1)
00064     return 0;
00065 # if defined(__GNUC__) || __cplusplus >= 199707L
00066   ACE_OSCALL_RETURN (::shl_unload (handle), int, -1);
00067 # else
00068   ACE_OSCALL_RETURN (::cxxshl_unload (handle), int, -1);
00069 # endif  /* aC++ vs. Hp C++ */
00070 #else
00071   ACE_UNUSED_ARG (handle);
00072   ACE_NOTSUP_RETURN (-1);
00073 #endif /* ACE_HAS_SVR4_DYNAMIC_LINKING */
00074 }

ACE_INLINE ACE_TCHAR * ACE_OS::dlerror void   ) 
 

Definition at line 77 of file OS_NS_dlfcn.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_TCHAR, ACE_TEXT_CHAR_TO_TCHAR, dlerror(), sprintf(), strerror(), and strncpy().

Referenced by dlerror(), and ACE_DLL_Handle::error().

00078 {
00079   ACE_OS_TRACE ("ACE_OS::dlerror");
00080 # if defined (ACE_HAS_SVR4_DYNAMIC_LINKING)
00081   const char *err;
00082 #   if defined(_M_UNIX)
00083   ACE_OSCALL (::_dlerror (), const char *, 0, err);
00084 #   else /* _M_UNIX */
00085   ACE_OSCALL (::dlerror (), const char *, 0, err);
00086 #   endif /* _M_UNIX */
00087   if (err == 0)
00088     return 0;
00089 #   if defined (ACE_USES_WCHAR)
00090   const size_t BufLen = 256;
00091   static wchar_t buf[BufLen];
00092   ACE_OS::strncpy (buf, ACE_TEXT_CHAR_TO_TCHAR (err), BufLen);
00093   return buf;
00094 #   else
00095   return const_cast <char *> (err);
00096 #   endif /* ACE_USES_WCHAR */
00097 # elif defined (__hpux) || defined (ACE_VXWORKS)
00098   ACE_OSCALL_RETURN (::strerror(errno), char *, 0);
00099 # elif defined (ACE_WIN32)
00100   static ACE_TCHAR buf[128];
00101 #   if defined (ACE_HAS_PHARLAP)
00102   ACE_OS::sprintf (buf, "error code %d", GetLastError());
00103 #   else
00104   ACE_TEXT_FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM,
00105                           0,
00106                           ::GetLastError (),
00107                           0,
00108                           buf,
00109                           sizeof buf / sizeof buf[0],
00110                           0);
00111 #   endif /* ACE_HAS_PHARLAP */
00112   return buf;
00113 # else
00114   ACE_NOTSUP_RETURN (0);
00115 # endif /* ACE_HAS_SVR4_DYNAMIC_LINKING */
00116 }

ACE_INLINE ACE_SHLIB_HANDLE ACE_OS::dlopen const ACE_TCHAR filename,
int  mode = ACE_DEFAULT_SHLIB_MODE
 

Definition at line 119 of file OS_NS_dlfcn.inl.

References ACE_DEFAULT_FILE_PERMS, ACE_LIB_TEXT, ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_SHLIB_HANDLE, ACE_TCHAR, ACE_TEXT_ALWAYS_CHAR, close(), dlsym(), last_error(), and open().

Referenced by ACE_DLL_Strategy< SVC_HANDLER >::make_svc_handler(), and ACE_DLL_Handle::open().

00121 {
00122   ACE_OS_TRACE ("ACE_OS::dlopen");
00123 
00124 # if defined (ACE_HAS_SVR4_DYNAMIC_LINKING)
00125   void *handle;
00126 #   if defined (ACE_HAS_SGIDLADD)
00127   ACE_OSCALL
00128     (::sgidladd (ACE_TEXT_ALWAYS_CHAR (fname), mode), void *, 0, handle);
00129 #   elif defined (_M_UNIX)
00130   ACE_OSCALL
00131     (::_dlopen (ACE_TEXT_ALWAYS_CHAR (fname), mode), void *, 0, handle);
00132 #   else
00133   ACE_OSCALL
00134     (::dlopen (ACE_TEXT_ALWAYS_CHAR (fname), mode), void *, 0, handle);
00135 #   endif /* ACE_HAS_SGIDLADD */
00136 #   if !defined (ACE_HAS_AUTOMATIC_INIT_FINI)
00137   if (handle != 0)
00138     {
00139       void *ptr;
00140       // Some systems (e.g., SunOS4) do not automatically call _init(), so
00141       // we'll have to call it manually.
00142 
00143       ACE_OSCALL (::dlsym (handle, ACE_LIB_TEXT ("_init")), void *, 0, ptr);
00144 
00145       if (ptr != 0 && (*((int (*)(void)) ptr)) () == -1) // Call _init hook explicitly.
00146         {
00147           // Close down the handle to prevent leaks.
00148           ::dlclose (handle);
00149           return 0;
00150         }
00151     }
00152 #   endif /* ACE_HAS_AUTOMATIC_INIT_FINI */
00153   return handle;
00154 # elif defined (ACE_WIN32)
00155   ACE_UNUSED_ARG (mode);
00156 
00157   ACE_WIN32CALL_RETURN (ACE_TEXT_LoadLibrary (fname), ACE_SHLIB_HANDLE, 0);
00158 # elif defined (__hpux)
00159 
00160 #   if defined(__GNUC__) || __cplusplus >= 199707L
00161   ACE_OSCALL_RETURN (::shl_load(fname, mode, 0L), ACE_SHLIB_HANDLE, 0);
00162 #   else
00163   ACE_OSCALL_RETURN (::cxxshl_load(fname, mode, 0L), ACE_SHLIB_HANDLE, 0);
00164 #   endif  /* aC++ vs. Hp C++ */
00165 # elif defined (ACE_VXWORKS) && !defined (__RTP__)
00166   MODULE* handle = 0;
00167   // Open readonly
00168   ACE_HANDLE filehandle = ACE_OS::open (fname,
00169                                         O_RDONLY,
00170                                         ACE_DEFAULT_FILE_PERMS);
00171 
00172   if (filehandle != ACE_INVALID_HANDLE)
00173     {
00174       ACE_OS::last_error(0);
00175       ACE_OSCALL ( ::loadModule (filehandle, LOAD_GLOBAL_SYMBOLS|LOAD_COMMON_MATCH_ALL ), MODULE *, 0, handle);
00176       int loaderror = ACE_OS::last_error();
00177       ACE_OS::close (filehandle);
00178 
00179       if ( (loaderror != 0) && (handle != 0) )
00180         {
00181           // ouch something went wrong most likely unresolved externals
00182           if (handle)
00183             ::unldByModuleId ( handle, 0 );
00184           handle = 0;
00185         }
00186     }
00187   else
00188     {
00189       // couldn't open file
00190       handle = 0;
00191     }
00192   return handle;
00193 # else
00194   ACE_UNUSED_ARG (fname);
00195   ACE_UNUSED_ARG (mode);
00196   ACE_NOTSUP_RETURN (0);
00197 # endif /* ACE_HAS_SVR4_DYNAMIC_LINKING */
00198 }

ACE_INLINE void * ACE_OS::dlsym ACE_SHLIB_HANDLE  handle,
const ACE_TCHAR symbol
 

Definition at line 201 of file OS_NS_dlfcn.inl.

References ACE_NEW_RETURN, ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_SHLIB_HANDLE, ACE_SHLIB_INVALID_HANDLE, ACE_TCHAR, dlsym(), strcpy(), and strlen().

Referenced by dlclose(), dlopen(), dlsym(), ACE_DLL_Strategy< SVC_HANDLER >::make_svc_handler(), and ACE_DLL_Handle::symbol().

00203 {
00204   ACE_OS_TRACE ("ACE_OS::dlsym");
00205 
00206 #if defined (ACE_HAS_DLSYM_SEGFAULT_ON_INVALID_HANDLE)
00207   // Check if the handle is valid before making any calls using it.
00208   if (handle == ACE_SHLIB_INVALID_HANDLE)
00209     return 0;
00210 #endif /* ACE_HAS_DLSYM_SEGFAULT_ON_INVALID_HANDLE */
00211 
00212   // Get the correct OS type.
00213 #if defined (ACE_HAS_WINCE)
00214   // CE (at least thru Pocket PC 2003) offers GetProcAddressW, not ...A, so
00215   // we always need a wide-char string.
00216   const wchar_t *symbolname = 0;
00217 #  if defined (ACE_USES_WCHAR)
00218   symbolname = sname;
00219 #  else
00220   ACE_Ascii_To_Wide sname_xlate (sname);
00221   symbolname = sname_xlate.wchar_rep ();
00222 #  endif /* ACE_USES_WCHAR */
00223 #elif defined (ACE_USES_WCHAR)
00224   // WinCE is WCHAR always; other platforms need a char * symbol name
00225   ACE_Wide_To_Ascii w_sname (sname);
00226   char *symbolname = w_sname.char_rep ();
00227 #elif defined (ACE_VXWORKS)
00228   char *symbolname = const_cast<char *> (sname);
00229 #else
00230   const char *symbolname = sname;
00231 #endif /* ACE_HAS_WINCE */
00232 
00233 # if defined (ACE_HAS_SVR4_DYNAMIC_LINKING)
00234 
00235 #   if defined (ACE_USES_ASM_SYMBOL_IN_DLSYM)
00236   int l = ACE_OS::strlen (symbolname) + 2;
00237   char *asm_symbolname = 0;
00238   ACE_NEW_RETURN (asm_symbolname, char[l], 0);
00239   ACE_OS::strcpy (asm_symbolname, "_") ;
00240   ACE_OS::strcpy (asm_symbolname + 1, symbolname) ;
00241   void *ace_result;
00242   ACE_OSCALL (::dlsym (handle, asm_symbolname), void *, 0, ace_result);
00243   delete [] asm_symbolname;
00244   return ace_result;
00245 #   elif defined (_M_UNIX)
00246   ACE_OSCALL_RETURN (::_dlsym (handle, symbolname), void *, 0);
00247 #   else
00248   ACE_OSCALL_RETURN (::dlsym (handle, symbolname), void *, 0);
00249 #   endif /* ACE_USES_ASM_SYMBOL_IN_DLSYM */
00250 
00251 # elif defined (ACE_WIN32)
00252 
00253   ACE_WIN32CALL_RETURN (::GetProcAddress (handle, symbolname), void *, 0);
00254 
00255 # elif defined (__hpux)
00256 
00257   void *value;
00258   int status;
00259   shl_t _handle = handle;
00260   ACE_OSCALL (::shl_findsym(&_handle, symbolname, TYPE_UNDEFINED, &value), int, -1, status);
00261   return status == 0 ? value : 0;
00262 
00263 # elif defined (ACE_VXWORKS) && !defined (__RTP__)
00264 
00265   // For now we use the VxWorks global symbol table
00266   // which resolves the most recently loaded symbols .. which resolve mostly what we want..
00267   ACE_UNUSED_ARG (handle);
00268   SYM_TYPE symtype;
00269   void *value = 0;
00270   STATUS status;
00271   ACE_OSCALL (::symFindByName(sysSymTbl, symbolname, (char **)&value, &symtype), int, -1, status);
00272 
00273   return status == OK ? value : 0;
00274 
00275 # else
00276 
00277   ACE_UNUSED_ARG (handle);
00278   ACE_UNUSED_ARG (symbolname);
00279   ACE_NOTSUP_RETURN (0);
00280 
00281 # endif /* ACE_HAS_SVR4_DYNAMIC_LINKING */
00282 }

ACE_INLINE ACE_HANDLE ACE_OS::dup ACE_HANDLE  handle  ) 
 

Definition at line 201 of file OS_NS_unistd.inl.

References ACE_FAIL_RETURN, ACE_NOTSUP_RETURN, ACE_OS_TRACE, and dup().

Referenced by dup(), ACE_Filecache_Handle::handle(), ACE_Process_Options::set_handles(), and ACE_Process::spawn().

00202 {
00203   ACE_OS_TRACE ("ACE_OS::dup");
00204 #if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)
00205   ACE_HANDLE new_fd;
00206   if (::DuplicateHandle(::GetCurrentProcess (),
00207                         handle,
00208                         ::GetCurrentProcess(),
00209                         &new_fd,
00210                         0,
00211                         TRUE,
00212                         DUPLICATE_SAME_ACCESS))
00213     return new_fd;
00214   else
00215     ACE_FAIL_RETURN (ACE_INVALID_HANDLE);
00216   /* NOTREACHED */
00217 #elif defined (ACE_LACKS_DUP)
00218   ACE_UNUSED_ARG (handle);
00219   ACE_NOTSUP_RETURN (-1);
00220 #elif defined (ACE_HAS_WINCE)
00221   ACE_UNUSED_ARG (handle);
00222   ACE_NOTSUP_RETURN (0);
00223 #else
00224   ACE_OSCALL_RETURN (::dup (handle), ACE_HANDLE, ACE_INVALID_HANDLE);
00225 #endif /* ACE_WIN32 && !ACE_HAS_WINCE */
00226 }

ACE_INLINE int ACE_OS::dup2 ACE_HANDLE  oldfd,
ACE_HANDLE  newfd
 

Definition at line 229 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and dup2().

Referenced by dup2(), and ACE_Process::spawn().

00230 {
00231   ACE_OS_TRACE ("ACE_OS::dup2");
00232 #if defined (ACE_LACKS_DUP2)
00233   // msvcrt has _dup2 ?!
00234   ACE_UNUSED_ARG (oldhandle);
00235   ACE_UNUSED_ARG (newhandle);
00236   ACE_NOTSUP_RETURN (-1);
00237 #else
00238   ACE_OSCALL_RETURN (::dup2 (oldhandle, newhandle), int, -1);
00239 #endif /* ACE_LACKS_DUP2 */
00240 }

ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE void ACE_OS::endpwent void   ) 
 

Definition at line 12 of file OS_NS_pwd.inl.

00013 {
00014 #if !defined (ACE_LACKS_PWD_FUNCTIONS)
00015   ::endpwent ();
00016 #endif /* ! ACE_LACKS_PWD_FUNCTIONS */
00017 }

ACE_INLINE int ACE_OS::enum_protocols int *  protocols,
ACE_Protocol_Info protocol_buffer,
u_long *  buffer_length
 

Retrieve information about available transport protocols installed on the local machine. Windows specific...

Definition at line 125 of file OS_NS_sys_socket.inl.

References ACE_NOTSUP_RETURN, and ACE_SOCKCALL_RETURN.

00128 {
00129 #if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
00130 
00131   ACE_SOCKCALL_RETURN (::WSAEnumProtocols (protocols,
00132                                            protocol_buffer,
00133                                            buffer_length),
00134                        int,
00135                        SOCKET_ERROR);
00136 
00137 #else
00138   ACE_UNUSED_ARG (protocols);
00139   ACE_UNUSED_ARG (protocol_buffer);
00140   ACE_UNUSED_ARG (buffer_length);
00141   ACE_NOTSUP_RETURN (-1);
00142 #endif /* ACE_HAS_WINSOCK2 */
00143 }

int ACE_OS::event_destroy ACE_event_t *  event  ) 
 

Definition at line 2454 of file OS_NS_Thread.cpp.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_TEXT_CHAR_TO_TCHAR, cond_broadcast(), cond_destroy(), EBUSY, free(), munmap(), mutex_destroy(), sema_destroy(), shm_unlink(), and thr_yield().

Referenced by ACE_WFMO_Reactor_Handler_Repository::make_changes_in_current_infos(), ACE_WFMO_Reactor_Handler_Repository::make_changes_in_suspension_infos(), ACE_WFMO_Reactor_Handler_Repository::make_changes_in_to_be_added_infos(), ACE_Event::remove(), sema_destroy(), and sema_init().

02455 {
02456 #if defined (ACE_WIN32)
02457   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::CloseHandle (*event), ace_result_), int, -1);
02458 #elif defined (ACE_HAS_THREADS)
02459   if (event->eventdata_)
02460 {
02461       // mutex_destroy()/cond_destroy() are called in a loop if the object
02462       // is BUSY.  This avoids conditions where we fail to destroy these
02463       // objects because at time of destroy they were just being used in
02464       // another thread possibly causing deadlocks later on if they keep
02465       // being used after we're gone.
02466 
02467   if (event->eventdata_->type_ == USYNC_PROCESS)
02468   {
02469     if (event->name_)
02470     {
02471       // Only destroy the event data if we're the ones who initialized
02472       // it.
02473 
02474       int r1, r2;
02475 # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \
02476         (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \
02477      (!defined (ACE_USES_FIFO_SEM) && \
02478         (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
02479       // first destroy the mutex so locking after this will return errors
02480       while ((r1 = ACE_OS::mutex_destroy (&event->eventdata_->lock_)) == -1
02481               && errno == EBUSY)
02482       {
02483         ACE_OS::thr_yield ();
02484       }
02485 # else
02486       r1 = ACE_OS::sema_destroy(&event->lock_);
02487 # endif
02488 
02489 # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_CONDATTR_PSHARED)) || \
02490     (!defined (ACE_USES_FIFO_SEM) && \
02491       (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
02492       // now fix event to manual reset, raise signal and broadcast until is's
02493       // possible to destroy the condition
02494       event->eventdata_->manual_reset_ = 1;
02495       while ((r2 = ACE_OS::cond_destroy (&event->eventdata_->condition_)) == -1
02496               && errno == EBUSY)
02497       {
02498         event->eventdata_->is_signaled_ = 1;
02499         ACE_OS::cond_broadcast (&event->eventdata_->condition_);
02500         ACE_OS::thr_yield ();
02501       }
02502 # else
02503       r2 = ACE_OS::sema_destroy(&event->semaphore_);
02504 # endif
02505       ACE_OS::munmap (event->eventdata_,
02506                       sizeof (ACE_eventdata_t));
02507       ACE_OS::shm_unlink (ACE_TEXT_CHAR_TO_TCHAR(event->name_));
02508       ACE_OS::free (event->name_);
02509       return r1 != 0 || r2 != 0 ? -1 : 0;
02510     }
02511     else
02512     {
02513       ACE_OS::munmap (event->eventdata_,
02514                       sizeof (ACE_eventdata_t));
02515 # if (!defined (ACE_HAS_PTHREADS) || !defined (_POSIX_THREAD_PROCESS_SHARED) || \
02516         (defined (ACE_LACKS_MUTEXATTR_PSHARED) && defined (ACE_LACKS_CONDATTR_PSHARED))) && \
02517      (defined (ACE_USES_FIFO_SEM) || \
02518         (defined (ACE_HAS_POSIX_SEM) && defined (ACE_HAS_POSIX_TIMEOUT) && defined (ACE_LACKS_NAMED_POSIX_SEM)))
02519       ACE_OS::sema_destroy(&event->lock_);
02520 # endif
02521 # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_CONDATTR_PSHARED)) || \
02522     (!defined (ACE_USES_FIFO_SEM) && \
02523       (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
02524       return 0;
02525 # else
02526       return ACE_OS::sema_destroy(&event->semaphore_);
02527 # endif
02528     }
02529   }
02530   else
02531   {
02532     int r1, r2;
02533     // first destroy the mutex so locking after this will return errors
02534 # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \
02535         (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \
02536      (!defined (ACE_USES_FIFO_SEM) && \
02537         (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
02538       // first destroy the mutex so locking after this will return errors
02539       while ((r1 = ACE_OS::mutex_destroy (&event->eventdata_->lock_)) == -1
02540               && errno == EBUSY)
02541       {
02542         ACE_OS::thr_yield ();
02543       }
02544 # else
02545       r1 = ACE_OS::sema_destroy(&event->lock_);
02546 # endif
02547 
02548 # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_CONDATTR_PSHARED)) || \
02549     (!defined (ACE_USES_FIFO_SEM) && \
02550       (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
02551     // now fix event to manual reset, raise signal and broadcast until is's
02552     // possible to destroy the condition
02553     event->eventdata_->manual_reset_ = 1;
02554     while ((r2 = ACE_OS::cond_destroy (&event->eventdata_->condition_)) == -1
02555             && errno == EBUSY)
02556     {
02557       event->eventdata_->is_signaled_ = 1;
02558       ACE_OS::cond_broadcast (&event->eventdata_->condition_);
02559       ACE_OS::thr_yield ();
02560     }
02561 # else
02562     r2 = ACE_OS::sema_destroy(&event->semaphore_);
02563 # endif
02564     delete event->eventdata_;
02565     return r1 != 0 || r2 != 0 ? -1 : 0;
02566   }
02567 }
02568 
02569   return 0;
02570 #else
02571   ACE_UNUSED_ARG (event);
02572   ACE_NOTSUP_RETURN (-1);
02573 #endif /* ACE_WIN32 */
02574 }

ACE_INLINE int ACE_OS::event_init ACE_event_t *  event,
int  manual_reset,
int  initial_state,
int  type,
const wchar_t *  name,
void *  arg = 0,
LPSECURITY_ATTRIBUTES  sa = 0
 

Definition at line 469 of file OS_NS_Thread.inl.

References ACE_FAIL_RETURN, and event_init().

00476 {
00477 #if defined (ACE_WIN32)
00478   ACE_UNUSED_ARG (type);
00479   ACE_UNUSED_ARG (arg);
00480   SECURITY_ATTRIBUTES sa_buffer;
00481   SECURITY_DESCRIPTOR sd_buffer;
00482   *event = ::CreateEventW (ACE_OS::default_win32_security_attributes_r
00483       (sa, &sa_buffer, &sd_buffer),
00484   manual_reset,
00485   initial_state,
00486   name);
00487   if (*event == 0)
00488     ACE_FAIL_RETURN (-1);
00489 
00490   return 0;
00491 #else  /* ACE_WIN32 */
00492   return ACE_OS::event_init (event,
00493                              manual_reset,
00494                              initial_state,
00495                              type,
00496                              ACE_Wide_To_Ascii (name).char_rep (),
00497                              arg,
00498                              sa);
00499 #endif /* ACE_WIN32 */
00500 }

int ACE_OS::event_init ACE_event_t *  event,
int  manual_reset = 0,
int  initial_state = 0,
int  type = ACE_DEFAULT_SYNCH_TYPE,
const char *  name = 0,
void *  arg = 0,
LPSECURITY_ATTRIBUTES  sa = 0
 

Definition at line 2577 of file OS_NS_Thread.cpp.

References ACE_DEFAULT_FILE_PERMS, ACE_FAIL_RETURN, ACE_NEW_RETURN, ACE_NOTSUP_RETURN, ACE_TEXT_CHAR_TO_TCHAR, close(), cond_init(), ftruncate(), MAP_FAILED, MAP_SHARED, mmap(), mutex_init(), PROT_RDWR, sema_init(), sema_post(), shm_open(), shm_unlink(), strcat(), strdup(), and strncpy().

Referenced by ACE_Event::ACE_Event(), event_init(), and sema_init().

02584 {
02585 #if defined (ACE_WIN32)
02586   ACE_UNUSED_ARG (type);
02587   ACE_UNUSED_ARG (arg);
02588   SECURITY_ATTRIBUTES sa_buffer;
02589   SECURITY_DESCRIPTOR sd_buffer;
02590 # if defined (ACE_HAS_WINCE)
02591   // @@todo (brunsch) This idea should be moved into ACE_OS_Win32.
02592   *event = ::CreateEventW (ACE_OS::default_win32_security_attributes_r
02593                              (sa, &sa_buffer, &sd_buffer),
02594                            manual_reset,
02595                            initial_state,
02596                            ACE_Ascii_To_Wide (name).wchar_rep ());
02597 # else /* ACE_HAS_WINCE */
02598   *event = ::CreateEventA (ACE_OS::default_win32_security_attributes_r
02599                              (sa, &sa_buffer, &sd_buffer),
02600                            manual_reset,
02601                            initial_state,
02602                            name);
02603 # endif /* ACE_HAS_WINCE */
02604   if (*event == 0)
02605     ACE_FAIL_RETURN (-1);
02606   else
02607     return 0;
02608 #elif defined (ACE_HAS_THREADS)
02609   ACE_UNUSED_ARG (sa);
02610   event->eventdata_ = 0;
02611   ACE_eventdata_t* evtdata;
02612 
02613   if (type == USYNC_PROCESS)
02614     {
02615       int owner = 0;
02616       // Let's see if the shared memory entity already exists.
02617       ACE_HANDLE fd = ACE_OS::shm_open (ACE_TEXT_CHAR_TO_TCHAR (name),
02618                                         O_RDWR | O_CREAT | O_EXCL,
02619                                         ACE_DEFAULT_FILE_PERMS);
02620       if (fd == ACE_INVALID_HANDLE)
02621         {
02622           if (errno == EEXIST)
02623             fd = ACE_OS::shm_open (ACE_TEXT_CHAR_TO_TCHAR (name),
02624                                    O_RDWR | O_CREAT,
02625                                    ACE_DEFAULT_FILE_PERMS);
02626           if (fd == ACE_INVALID_HANDLE)   // Still can't get it.
02627             return -1;
02628         }
02629       else
02630         {
02631           // We own this shared memory object!  Let's set its size.
02632           if (ACE_OS::ftruncate (fd, sizeof (ACE_eventdata_t)) == -1)
02633             {
02634               ACE_OS::close (fd);
02635               return -1;
02636             }
02637           owner = 1;
02638         }
02639 
02640       evtdata =
02641         (ACE_eventdata_t *) ACE_OS::mmap (0,
02642                                           sizeof (ACE_eventdata_t),
02643                                           PROT_RDWR,
02644                                           MAP_SHARED,
02645                                           fd,
02646                                           0);
02647       ACE_OS::close (fd);
02648       if (evtdata == MAP_FAILED)
02649         {
02650           if (owner)
02651             ACE_OS::shm_unlink (ACE_TEXT_CHAR_TO_TCHAR (name));
02652           return -1;
02653         }
02654 
02655       if (owner)
02656         {
02657           event->name_ = ACE_OS::strdup (name);
02658           if (event->name_ == 0)
02659             {
02660               ACE_OS::shm_unlink (ACE_TEXT_CHAR_TO_TCHAR (name));
02661               return -1;
02662             }
02663           event->eventdata_ = evtdata;
02664           event->eventdata_->type_ = type;
02665           event->eventdata_->manual_reset_ = manual_reset;
02666           event->eventdata_->is_signaled_ = initial_state;
02667           event->eventdata_->auto_event_signaled_ = false;
02668           event->eventdata_->waiting_threads_ = 0;
02669           event->eventdata_->signal_count_ = 0;
02670 
02671 # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_CONDATTR_PSHARED)) || \
02672     (!defined (ACE_USES_FIFO_SEM) && \
02673       (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
02674           int result = ACE_OS::cond_init (&event->eventdata_->condition_,
02675                                           static_cast<short> (type),
02676                                           name,
02677                                           arg);
02678 # else
02679           char   sem_name[128];
02680           ACE_OS::strncpy (sem_name,
02681                            name,
02682                            sizeof (sem_name) - (1 + sizeof ("._ACE_EVTSEM_")));
02683           ACE_OS::strcat (sem_name, "._ACE_EVTSEM_");
02684           int result = ACE_OS::sema_init (&event->semaphore_,
02685                                           0,
02686                                           type,
02687                                           sem_name,
02688                                           arg);
02689 # endif
02690           if (result == 0)
02691 # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \
02692         (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \
02693      (!defined (ACE_USES_FIFO_SEM) && \
02694         (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
02695             result = ACE_OS::mutex_init (&event->eventdata_->lock_,
02696                                          type,
02697                                          name,
02698                                          (ACE_mutexattr_t *) arg);
02699 # else
02700           {
02701             char   lck_name[128];
02702             ACE_OS::strncpy
02703               (lck_name,
02704                name,
02705                sizeof (lck_name) - (1 + sizeof ("._ACE_EVTLCK_")));
02706             ACE_OS::strcat (lck_name, "._ACE_EVTLCK_");
02707             result = ACE_OS::sema_init (&event->lock_,
02708                                         0,
02709                                         type,
02710                                         lck_name,
02711                                         arg);
02712             if (result == 0)
02713               result = ACE_OS::sema_post (&event->lock_); /* Initially unlock */
02714           }
02715 # endif
02716           return result;
02717         }
02718       else
02719         {
02720           int result = 0;
02721 
02722           event->name_ = 0;
02723           event->eventdata_ = evtdata;
02724 #if (!defined (ACE_HAS_PTHREADS) || !defined (_POSIX_THREAD_PROCESS_SHARED) || defined (ACE_LACKS_CONDATTR_PSHARED)) && \
02725   (defined (ACE_USES_FIFO_SEM) || \
02726     (defined (ACE_HAS_POSIX_SEM) && defined (ACE_HAS_POSIX_SEM_TIMEOUT) && !defined (ACE_LACKS_NAMED_POSIX_SEM)))
02727           char   sem_name[128];
02728           ACE_OS::strncpy (sem_name,
02729                            name,
02730                            sizeof (sem_name) - (1 + sizeof ("._ACE_EVTSEM_")));
02731           ACE_OS::strcat (sem_name, "._ACE_EVTSEM_");
02732           result = ACE_OS::sema_init(&event->semaphore_,
02733                                      0,
02734                                      type,
02735                                      sem_name,
02736                                      arg);
02737 # endif
02738 
02739 # if (!defined (ACE_HAS_PTHREADS) || !defined (_POSIX_THREAD_PROCESS_SHARED) || \
02740         (defined (ACE_LACKS_MUTEXATTR_PSHARED) && defined (ACE_LACKS_CONDATTR_PSHARED))) && \
02741      (defined (ACE_USES_FIFO_SEM) || \
02742         (defined (ACE_HAS_POSIX_SEM) && defined (ACE_HAS_POSIX_TIMEOUT) && defined (ACE_LACKS_NAMED_POSIX_SEM)))
02743           if (result == 0)
02744             {
02745               char   lck_name[128];
02746               ACE_OS::strncpy
02747                 (lck_name,
02748                  name,
02749                  sizeof (lck_name) - (1 + sizeof ("._ACE_EVTLCK_")));
02750               ACE_OS::strcat (lck_name, "._ACE_EVTLCK_");
02751               result = ACE_OS::sema_init (&event->lock_,
02752                                           0,
02753                                           type,
02754                                           lck_name,
02755                                           arg);
02756             }
02757 # endif
02758           return result;
02759         }
02760 
02761       return 0;
02762     }
02763   else
02764     {
02765       ACE_NEW_RETURN (evtdata, ACE_eventdata_t, -1);
02766       event->name_ = 0;
02767       event->eventdata_ = evtdata;
02768       event->eventdata_->type_ = type;
02769       event->eventdata_->manual_reset_ = manual_reset;
02770       event->eventdata_->is_signaled_ = initial_state;
02771       event->eventdata_->auto_event_signaled_ = false;
02772       event->eventdata_->waiting_threads_ = 0;
02773       event->eventdata_->signal_count_ = 0;
02774 
02775 # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_CONDATTR_PSHARED)) || \
02776     (!defined (ACE_USES_FIFO_SEM) && \
02777       (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
02778       int result = ACE_OS::cond_init (&event->eventdata_->condition_,
02779                                       static_cast<short> (type),
02780                                       name,
02781                                       arg);
02782 # else
02783       int result = ACE_OS::sema_init (&event->semaphore_,
02784                                       0,
02785                                       type,
02786                                       name,
02787                                       arg);
02788 # endif
02789       if (result == 0)
02790 # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \
02791         (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \
02792      (!defined (ACE_USES_FIFO_SEM) && \
02793         (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
02794         result = ACE_OS::mutex_init (&event->eventdata_->lock_,
02795                                      type,
02796                                      name,
02797                                      (ACE_mutexattr_t *) arg);
02798 # else
02799       result = ACE_OS::sema_init (&event->lock_,
02800                                   0,
02801                                   type,
02802                                   name,
02803                                   arg);
02804       if (result == 0)
02805         result = ACE_OS::sema_post(&event->lock_);    /* initially unlock */
02806 # endif
02807 
02808       return result;
02809     }
02810 #else
02811   ACE_UNUSED_ARG (event);
02812   ACE_UNUSED_ARG (manual_reset);
02813   ACE_UNUSED_ARG (initial_state);
02814   ACE_UNUSED_ARG (type);
02815   ACE_UNUSED_ARG (name);
02816   ACE_UNUSED_ARG (arg);
02817   ACE_UNUSED_ARG (sa);
02818   ACE_NOTSUP_RETURN (-1);
02819 #endif /* ACE_WIN32 */
02820 }

int ACE_OS::event_pulse ACE_event_t *  event  ) 
 

Definition at line 2823 of file OS_NS_Thread.cpp.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, cond_broadcast(), cond_signal(), mutex_lock(), mutex_unlock(), sema_post(), sema_wait(), and thr_yield().

Referenced by ACE_Event::pulse().

02824 {
02825 #if defined (ACE_WIN32)
02826   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::PulseEvent (*event), ace_result_), int, -1);
02827 #elif defined (ACE_HAS_THREADS)
02828   int result = 0;
02829   int error = 0;
02830 
02831   // grab the lock first
02832 # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \
02833         (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \
02834      (!defined (ACE_USES_FIFO_SEM) && \
02835         (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
02836   if (ACE_OS::mutex_lock (&event->eventdata_->lock_) == 0)
02837 # else
02838   if (ACE_OS::sema_wait (&event->lock_) == 0)
02839 # endif
02840   {
02841     if (event->eventdata_->waiting_threads_ > 0)
02842     {
02843       // Manual-reset event.
02844       if (event->eventdata_->manual_reset_ == 1)
02845       {
02846         // Wakeup all waiters.
02847 # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_CONDATTR_PSHARED)) || \
02848     (!defined (ACE_USES_FIFO_SEM) && \
02849       (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
02850         if (ACE_OS::cond_broadcast (&event->eventdata_->condition_) != 0)
02851         {
02852           result = -1;
02853           error = errno;
02854         }
02855         if (result == 0)
02856           event->eventdata_->signal_count_ = event->eventdata_->waiting_threads_;
02857 # else
02858         event->eventdata_->signal_count_ = event->eventdata_->waiting_threads_;
02859         for (unsigned long i=0; i<event->eventdata_->signal_count_ ;++i)
02860           if (ACE_OS::sema_post(&event->semaphore_) != 0)
02861           {
02862             event->eventdata_->signal_count_ = 0;
02863             result = -1;
02864             error = errno;
02865           }
02866 
02867         if (result == 0)
02868           while(event->eventdata_->signal_count_!=0 && event->eventdata_->waiting_threads_!=0)
02869             ACE_OS::thr_yield ();
02870 # endif
02871       }
02872       // Auto-reset event: wakeup one waiter.
02873       else
02874       {
02875 # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_CONDATTR_PSHARED)) || \
02876     (!defined (ACE_USES_FIFO_SEM) && \
02877       (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
02878         if (ACE_OS::cond_signal (&event->eventdata_->condition_) != 0)
02879 # else
02880         if (ACE_OS::sema_post(&event->semaphore_) != 0)
02881 # endif
02882         {
02883           result = -1;
02884           error = errno;
02885         }
02886 
02887         event->eventdata_->auto_event_signaled_ = true;
02888       }
02889     }
02890 
02891     // Reset event.
02892     event->eventdata_->is_signaled_ = 0;
02893 
02894     // Now we can let go of the lock.
02895 # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \
02896         (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \
02897      (!defined (ACE_USES_FIFO_SEM) && \
02898         (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
02899     ACE_OS::mutex_unlock (&event->eventdata_->lock_);
02900 # else
02901     ACE_OS::sema_post (&event->lock_);
02902 # endif
02903     if (result == -1)
02904       // Reset errno in case mutex_unlock() also fails...
02905       errno = error;
02906   }
02907   else
02908     result = -1;
02909   return result;
02910 #else
02911   ACE_UNUSED_ARG (event);
02912   ACE_NOTSUP_RETURN (-1);
02913 #endif /* ACE_WIN32 */
02914 }

int ACE_OS::event_reset ACE_event_t *  event  ) 
 

Definition at line 2917 of file OS_NS_Thread.cpp.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, mutex_lock(), mutex_unlock(), sema_post(), and sema_wait().

Referenced by ACE_Event::reset(), sema_trywait(), and sema_wait().

02918 {
02919 #if defined (ACE_WIN32)
02920   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::ResetEvent (*event), ace_result_), int, -1);
02921 #elif defined (ACE_HAS_THREADS)
02922   int result = 0;
02923 
02924   // Grab the lock first.
02925 # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \
02926         (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \
02927      (!defined (ACE_USES_FIFO_SEM) && \
02928         (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
02929   if (ACE_OS::mutex_lock (&event->eventdata_->lock_) == 0)
02930 # else
02931   if (ACE_OS::sema_wait (&event->lock_) == 0)
02932 # endif
02933   {
02934     // Reset event.
02935     event->eventdata_->is_signaled_ = 0;
02936     event->eventdata_->auto_event_signaled_ = false;
02937 
02938     // Now we can let go of the lock.
02939 # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \
02940         (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \
02941      (!defined (ACE_USES_FIFO_SEM) && \
02942         (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
02943     ACE_OS::mutex_unlock (&event->eventdata_->lock_);
02944 # else
02945     ACE_OS::sema_post (&event->lock_);
02946 # endif
02947   }
02948   else
02949     result = -1;
02950   return result;
02951 #else
02952   ACE_UNUSED_ARG (event);
02953   ACE_NOTSUP_RETURN (-1);
02954 #endif /* ACE_WIN32 */
02955 }

int ACE_OS::event_signal ACE_event_t *  event  ) 
 

Definition at line 2958 of file OS_NS_Thread.cpp.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, cond_broadcast(), cond_signal(), mutex_lock(), mutex_unlock(), sema_post(), and sema_wait().

Referenced by ACE_WIN32_Proactor::post_completion(), sema_post(), and ACE_Event::signal().

02959 {
02960 #if defined (ACE_WIN32)
02961   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::SetEvent (*event), ace_result_), int, -1);
02962 #elif defined (ACE_HAS_THREADS)
02963   int result = 0;
02964   int error = 0;
02965 
02966   // grab the lock first
02967 # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \
02968         (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \
02969      (!defined (ACE_USES_FIFO_SEM) && \
02970         (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
02971   if (ACE_OS::mutex_lock (&event->eventdata_->lock_) == 0)
02972 # else
02973   if (ACE_OS::sema_wait (&event->lock_) == 0)
02974 # endif
02975   {
02976     // Manual-reset event.
02977     if (event->eventdata_->manual_reset_ == 1)
02978     {
02979       // wakeup all
02980 # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_CONDATTR_PSHARED)) || \
02981     (!defined (ACE_USES_FIFO_SEM) && \
02982       (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
02983       if (ACE_OS::cond_broadcast (&event->eventdata_->condition_) != 0)
02984       {
02985         result = -1;
02986         error = errno;
02987       }
02988 # else
02989       if (ACE_OS::sema_post(&event->semaphore_) != 0)
02990       {
02991         result = -1;
02992         error = errno;
02993       }
02994 # endif
02995 
02996       if (result == 0)
02997         // signal event
02998         event->eventdata_->is_signaled_ = 1;
02999     }
03000     // Auto-reset event
03001     else
03002     {
03003       if (event->eventdata_->waiting_threads_ == 0)
03004         // No waiters: signal event.
03005         event->eventdata_->is_signaled_ = 1;
03006       // Waiters: wakeup one waiter.
03007 # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_CONDATTR_PSHARED)) || \
03008     (!defined (ACE_USES_FIFO_SEM) && \
03009       (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
03010       else if (ACE_OS::cond_signal (&event->eventdata_->condition_) != 0)
03011 # else
03012       else if (ACE_OS::sema_post(&event->semaphore_) != 0)
03013 # endif
03014       {
03015         result = -1;
03016         error = errno;
03017       }
03018 
03019       event->eventdata_->auto_event_signaled_ = true;
03020     }
03021 
03022     // Now we can let go of the lock.
03023 # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \
03024         (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \
03025      (!defined (ACE_USES_FIFO_SEM) && \
03026         (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
03027     ACE_OS::mutex_unlock (&event->eventdata_->lock_);
03028 # else
03029     ACE_OS::sema_post (&event->lock_);
03030 # endif
03031 
03032     if (result == -1)
03033       // Reset errno in case mutex_unlock() also fails...
03034       errno = error;
03035   }
03036   else
03037     result = -1;
03038 
03039   return result;
03040 #else
03041   ACE_UNUSED_ARG (event);
03042   ACE_NOTSUP_RETURN (-1);
03043 #endif /* ACE_WIN32 */
03044 }

int ACE_OS::event_timedwait ACE_event_t *  event,
ACE_Time_Value timeout,
int  use_absolute_time = 1
 

Definition at line 3047 of file OS_NS_Thread.cpp.

References ACE_NOTSUP_RETURN, cond_timedwait(), ETIME, ETIMEDOUT, gettimeofday(), ACE_Time_Value::msec(), mutex_lock(), mutex_unlock(), ACE_Time_Value::sec(), sema_post(), sema_wait(), set_errno_to_last_error(), and ACE_Time_Value::usec().

Referenced by ACE_Event::wait().

03050 {
03051 #if defined (ACE_WIN32)
03052   DWORD result;
03053 
03054   if (timeout == 0)
03055     // Wait forever
03056     result = ::WaitForSingleObject (*event, INFINITE);
03057   else if (timeout->sec () == 0 && timeout->usec () == 0)
03058     // Do a "poll".
03059     result = ::WaitForSingleObject (*event, 0);
03060   else
03061   {
03062       // Wait for upto <relative_time> number of milliseconds.  Note
03063       // that we must convert between absolute time (which is passed
03064       // as a parameter) and relative time (which is what
03065       // WaitForSingleObjects() expects).
03066       // <timeout> parameter is given in absolute or relative value
03067       // depending on parameter <use_absolute_time>.
03068     int msec_timeout;
03069     if (use_absolute_time)
03070     {
03071           // Time is given in absolute time, we should use
03072           // gettimeofday() to calculate relative time
03073       ACE_Time_Value relative_time (*timeout - ACE_OS::gettimeofday ());
03074 
03075           // Watchout for situations where a context switch has caused
03076           // the current time to be > the timeout.  Thanks to Norbert
03077           // Rapp <NRapp@nexus-informatics.de> for pointing this.
03078       if (relative_time < ACE_Time_Value::zero)
03079         msec_timeout = 0;
03080       else
03081         msec_timeout = relative_time.msec ();
03082     }
03083     else
03084          // time is given in relative time, just convert it into
03085          // milliseconds and use it
03086       msec_timeout = timeout->msec ();
03087     result = ::WaitForSingleObject (*event, msec_timeout);
03088   }
03089 
03090   switch (result)
03091   {
03092     case WAIT_OBJECT_0:
03093       return 0;
03094     case WAIT_TIMEOUT:
03095       errno = ETIME;
03096       return -1;
03097     default:
03098       // This is a hack, we need to find an appropriate mapping...
03099       ACE_OS::set_errno_to_last_error ();
03100       return -1;
03101   }
03102 #elif defined (ACE_HAS_THREADS)
03103   int result = 0;
03104   int error = 0;
03105 
03106   // grab the lock first
03107 # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \
03108         (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \
03109      (!defined (ACE_USES_FIFO_SEM) && \
03110         (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
03111   if (ACE_OS::mutex_lock (&event->eventdata_->lock_) == 0)
03112 # else
03113   if (ACE_OS::sema_wait (&event->lock_) == 0)
03114 # endif
03115   {
03116     if (event->eventdata_->is_signaled_ == 1)
03117     // event is currently signaled
03118     {
03119       if (event->eventdata_->manual_reset_ == 0)
03120       {
03121         // AUTO: reset state
03122         event->eventdata_->is_signaled_ = 0;
03123         event->eventdata_->auto_event_signaled_ = false;
03124       }
03125     }
03126     else
03127     // event is currently not signaled
03128     {
03129       event->eventdata_->waiting_threads_++;
03130 
03131       ACE_Time_Value absolute_timeout = *timeout;
03132 
03133       // cond_timewait() expects absolute time, check
03134       // <use_absolute_time> flag.
03135       if (use_absolute_time == 0)
03136         absolute_timeout += ACE_OS::gettimeofday ();
03137 
03138       while (event->eventdata_->is_signaled_ == 0 &&
03139              event->eventdata_->auto_event_signaled_ == false)
03140       {
03141 # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_CONDATTR_PSHARED)) || \
03142     (!defined (ACE_USES_FIFO_SEM) && \
03143       (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
03144         if (ACE_OS::cond_timedwait (&event->eventdata_->condition_,
03145                                     &event->eventdata_->lock_,
03146                                     &absolute_timeout) != 0)
03147         {
03148           result = -1;
03149           error = errno;
03150           break;
03151         }
03152 
03153         if (event->eventdata_->signal_count_ > 0)
03154         {
03155           event->eventdata_->signal_count_--;
03156           break;
03157         }
03158 # else
03159 #   if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_MUTEXATTR_PSHARED)) || \
03160       (!defined (ACE_USES_FIFO_SEM) && (!defined (ACE_HAS_POSIX_SEM) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
03161         if (ACE_OS::mutex_unlock (&event->eventdata_->lock_) != 0)
03162 #   else
03163         if (ACE_OS::sema_post (&event->lock_) != 0)
03164 #   endif
03165         {
03166           event->eventdata_->waiting_threads_--;
03167           return -1;
03168         }
03169 
03170         if (ACE_OS::sema_wait(&event->semaphore_, absolute_timeout) !=0)
03171         {
03172           result = -1;
03173           if (errno == ETIMEDOUT) // Semaphores time out with ETIMEDOUT (POSIX)
03174             error = ETIME;
03175           else
03176             error = errno;
03177         }
03178 
03179         bool signalled = false;
03180         if (result == 0 && event->eventdata_->signal_count_ > 0)
03181         {
03182           event->eventdata_->signal_count_--;
03183           signalled = true;
03184         }
03185 
03186 #   if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_MUTEXATTR_PSHARED)) || \
03187       (!defined (ACE_USES_FIFO_SEM) && (!defined (ACE_HAS_POSIX_SEM) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
03188         if (ACE_OS::mutex_lock (&event->eventdata_->lock_) != 0)
03189 #   else
03190         if (ACE_OS::sema_wait (&event->lock_) != 0)
03191 #   endif
03192         {
03193           event->eventdata_->waiting_threads_--;  // yes, I know it's not save
03194           return -1;
03195         }
03196 
03197         if (result)
03198           break;
03199 
03200         if (event->eventdata_->manual_reset_ == 1 && event->eventdata_->is_signaled_ == 1)
03201           if (ACE_OS::sema_post(&event->semaphore_) != 0)
03202           {
03203             result = -1;
03204             error = errno;
03205             break;
03206           }
03207 
03208         if (signalled)
03209           break;
03210 # endif
03211       }
03212 
03213       // Reset the auto_event_signaled_ to false now that we have
03214       // woken up.
03215       if (event->eventdata_->auto_event_signaled_ == true)
03216         event->eventdata_->auto_event_signaled_ = false;
03217 
03218       event->eventdata_->waiting_threads_--;
03219     }
03220 
03221     // Now we can let go of the lock.
03222 # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \
03223         (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \
03224      (!defined (ACE_USES_FIFO_SEM) && \
03225         (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
03226     ACE_OS::mutex_unlock (&event->eventdata_->lock_);
03227 # else
03228     ACE_OS::sema_post (&event->lock_);
03229 # endif
03230 
03231     if (result == -1)
03232       // Reset errno in case mutex_unlock() also fails...
03233       errno = error;
03234   }
03235   else
03236     result = -1;
03237   return result;
03238 #else
03239   ACE_UNUSED_ARG (event);
03240   ACE_UNUSED_ARG (timeout);
03241   ACE_UNUSED_ARG (use_absolute_time);
03242   ACE_NOTSUP_RETURN (-1);
03243 #endif /* ACE_WIN32 */
03244 }

int ACE_OS::event_wait ACE_event_t *  event  ) 
 

Definition at line 3247 of file OS_NS_Thread.cpp.

References ACE_NOTSUP_RETURN, cond_wait(), mutex_lock(), mutex_unlock(), sema_post(), sema_wait(), and set_errno_to_last_error().

Referenced by ACE_Event::wait().

03248 {
03249 #if defined (ACE_WIN32)
03250   switch (::WaitForSingleObject (*event, INFINITE))
03251 {
03252   case WAIT_OBJECT_0:
03253     return 0;
03254   default:
03255     ACE_OS::set_errno_to_last_error ();
03256     return -1;
03257 }
03258 #elif defined (ACE_HAS_THREADS)
03259   int result = 0;
03260   int error = 0;
03261 
03262   // grab the lock first
03263 # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \
03264         (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \
03265      (!defined (ACE_USES_FIFO_SEM) && \
03266         (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
03267   if (ACE_OS::mutex_lock (&event->eventdata_->lock_) == 0)
03268 # else
03269   if (ACE_OS::sema_wait (&event->lock_) == 0)
03270 # endif
03271   {
03272     if (event->eventdata_->is_signaled_ == 1)
03273     // Event is currently signaled.
03274     {
03275       if (event->eventdata_->manual_reset_ == 0)
03276         // AUTO: reset state
03277         event->eventdata_->is_signaled_ = 0;
03278     }
03279     else // event is currently not signaled
03280     {
03281       event->eventdata_->waiting_threads_++;
03282 
03283       while (event->eventdata_->is_signaled_ == 0 &&
03284              event->eventdata_->auto_event_signaled_ == false)
03285       {
03286 # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_CONDATTR_PSHARED)) || \
03287     (!defined (ACE_USES_FIFO_SEM) && \
03288       (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
03289         if (ACE_OS::cond_wait (&event->eventdata_->condition_,
03290                                &event->eventdata_->lock_) != 0)
03291         {
03292           result = -1;
03293           error = errno;
03294           // Something went wrong...
03295           break;
03296         }
03297         if (event->eventdata_->signal_count_ > 0)
03298         {
03299           event->eventdata_->signal_count_--;
03300           break;
03301         }
03302 # else
03303 #   if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_MUTEXATTR_PSHARED)) || \
03304       (!defined (ACE_USES_FIFO_SEM) && (!defined (ACE_HAS_POSIX_SEM) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
03305         if (ACE_OS::mutex_unlock (&event->eventdata_->lock_) != 0)
03306 #   else
03307         if (ACE_OS::sema_post (&event->lock_) != 0)
03308 #   endif
03309         {
03310           event->eventdata_->waiting_threads_--;
03311           return -1;
03312         }
03313 
03314         if (ACE_OS::sema_wait(&event->semaphore_) !=0)
03315         {
03316           result = -1;
03317           error = errno;
03318         }
03319 
03320         bool signalled = false;
03321         if (result == 0 && event->eventdata_->signal_count_ > 0)
03322         {
03323           event->eventdata_->signal_count_--;
03324           signalled = true;
03325         }
03326 
03327 #   if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_MUTEXATTR_PSHARED)) || \
03328       (!defined (ACE_USES_FIFO_SEM) && (!defined (ACE_HAS_POSIX_SEM) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
03329         if (ACE_OS::mutex_lock (&event->eventdata_->lock_) != 0)
03330 #   else
03331         if (ACE_OS::sema_wait (&event->lock_) != 0)
03332 #   endif
03333         {
03334           event->eventdata_->waiting_threads_--;
03335           return -1;
03336         }
03337 
03338         if (result)
03339           break;
03340 
03341         if (event->eventdata_->manual_reset_ == 1 && event->eventdata_->is_signaled_ == 1)
03342           if (ACE_OS::sema_post(&event->semaphore_) != 0)
03343           {
03344             result = -1;
03345             error = errno;
03346             break;
03347           }
03348 
03349         if (signalled)
03350           break;
03351 # endif
03352     }
03353 
03354     // Reset it since we have woken up.
03355     if (event->eventdata_->auto_event_signaled_ == true)
03356       event->eventdata_->auto_event_signaled_ = false;
03357 
03358     event->eventdata_->waiting_threads_--;
03359   }
03360 
03361   // Now we can let go of the lock.
03362 # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \
03363         (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \
03364      (!defined (ACE_USES_FIFO_SEM) && \
03365         (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
03366     ACE_OS::mutex_unlock (&event->eventdata_->lock_);
03367 # else
03368     ACE_OS::sema_post (&event->lock_);
03369 # endif
03370 
03371   if (result == -1)
03372     // Reset errno in case mutex_unlock() also fails...
03373     errno = error;
03374 }
03375   else
03376     result = -1;
03377   return result;
03378 #else
03379   ACE_UNUSED_ARG (event);
03380   ACE_NOTSUP_RETURN (-1);
03381 #endif /* ACE_WIN32 */
03382 }

int ACE_OS::execl const char *  path,
const char *  arg0,
... 
 

Definition at line 138 of file OS_NS_unistd.cpp.

References ACE_NOTSUP_RETURN, and ACE_OS_TRACE.

00139 {
00140   ACE_OS_TRACE ("ACE_OS::execl");
00141   ACE_NOTSUP_RETURN (-1);
00142   // Need to write this code.
00143   // ACE_OSCALL_RETURN (::execv (path, argv), int, -1);
00144 }

int ACE_OS::execle const char *  path,
const char *  arg0,
... 
 

Definition at line 147 of file OS_NS_unistd.cpp.

References ACE_NOTSUP_RETURN, and ACE_OS_TRACE.

00148 {
00149   ACE_OS_TRACE ("ACE_OS::execle");
00150   ACE_NOTSUP_RETURN (-1);
00151   // Need to write this code.
00152   //  ACE_OSCALL_RETURN (::execve (path, argv, envp), int, -1);
00153 }

int ACE_OS::execlp const char *  file,
const char *  arg0,
... 
 

Definition at line 156 of file OS_NS_unistd.cpp.

References ACE_NOTSUP_RETURN, and ACE_OS_TRACE.

00157 {
00158   ACE_OS_TRACE ("ACE_OS::execlp");
00159   ACE_NOTSUP_RETURN (-1);
00160   // Need to write this code.
00161   //  ACE_OSCALL_RETURN (::execvp (file, argv), int, -1);
00162 }

ACE_INLINE int ACE_OS::execv const char *  path,
char *const  argv[]
 

Definition at line 243 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and execv().

Referenced by execv(), and fork_exec().

00245 {
00246   ACE_OS_TRACE ("ACE_OS::execv");
00247 #if defined (ACE_LACKS_EXEC)
00248   ACE_UNUSED_ARG (path);
00249   ACE_UNUSED_ARG (argv);
00250 
00251   ACE_NOTSUP_RETURN (-1);
00252 #elif defined (ACE_WIN32)
00253 # if defined (__BORLANDC__) /* VSB */
00254   return ::execv (path, argv);
00255 # elif defined (__MINGW32__)
00256   return ::_execv (path, (char *const *) argv);
00257 # else
00258   // Why this odd-looking code? If execv() returns at all, it's an error.
00259   // Windows defines this as returning an intptr_t rather than a simple int,
00260   // and the conversion triggers compile warnings. So just return -1 if
00261   // the call returns.
00262   ::_execv (path, (const char *const *) argv);
00263   return -1;
00264 # endif /* __BORLANDC__ */
00265 #else
00266   ACE_OSCALL_RETURN (::execv (path, argv), int, -1);
00267 #endif /* ACE_LACKS_EXEC */
00268 }

ACE_INLINE int ACE_OS::execve const char *  path,
char *const  argv[],
char *const  envp[]
 

Definition at line 271 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and execve().

Referenced by execve(), and ACE_Process::spawn().

00274 {
00275   ACE_OS_TRACE ("ACE_OS::execve");
00276 #if defined (ACE_LACKS_EXEC)
00277   ACE_UNUSED_ARG (path);
00278   ACE_UNUSED_ARG (argv);
00279   ACE_UNUSED_ARG (envp);
00280 
00281   ACE_NOTSUP_RETURN (-1);
00282 #elif defined (ACE_WIN32)
00283 # if defined (__BORLANDC__) /* VSB */
00284   return ::execve (path, argv, envp);
00285 # elif defined (__MINGW32__)
00286   return ::_execve (path, (char *const *) argv, (char *const *) envp);
00287 # else
00288   // Why this odd-looking code? If execv() returns at all, it's an error.
00289   // Windows defines this as returning an intptr_t rather than a simple int,
00290   // and the conversion triggers compile warnings. So just return -1 if
00291   // the call returns.
00292   ::_execve (path, (const char *const *) argv, (const char *const *) envp);
00293   return -1;
00294 # endif /* __BORLANDC__ */
00295 #else
00296   ACE_OSCALL_RETURN (::execve (path, argv, envp), int, -1);
00297 #endif /* ACE_LACKS_EXEC */
00298 }

ACE_INLINE int ACE_OS::execvp const char *  file,
char *const  argv[]
 

Definition at line 301 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and execvp().

Referenced by execvp(), and ACE_Process::spawn().

00303 {
00304   ACE_OS_TRACE ("ACE_OS::execvp");
00305 #if defined (ACE_LACKS_EXEC)
00306   ACE_UNUSED_ARG (file);
00307   ACE_UNUSED_ARG (argv);
00308 
00309   ACE_NOTSUP_RETURN (-1);
00310 #elif defined (ACE_WIN32)
00311 # if defined (__BORLANDC__) /* VSB */
00312   return ::execvp (file, argv);
00313 # elif defined (__MINGW32__)
00314   return ::_execvp (file, (char *const *) argv);
00315 # else
00316   // Why this odd-looking code? If execv() returns at all, it's an error.
00317   // Windows defines this as returning an intptr_t rather than a simple int,
00318   // and the conversion triggers compile warnings. So just return -1 if
00319   // the call returns.
00320   ::_execvp (file, (const char *const *) argv);
00321   return -1;
00322 # endif /* __BORLANDC__ */
00323 #else
00324   ACE_OSCALL_RETURN (::execvp (file, argv), int, -1);
00325 #endif /* ACE_LACKS_EXEC */
00326 }

void ACE_OS::exit int  status = 0  ) 
 

Definition at line 50 of file OS_NS_stdlib.cpp.

References ACE_OS_TRACE, and exit_hook_.

Referenced by abort(), ACE::daemonize(), fork_exec(), ACE_Svc_Conf_Lexer::input(), and ACE_Process::spawn().

00051 {
00052   ACE_OS_TRACE ("ACE_OS::exit");
00053 
00054 #if defined (ACE_HAS_NONSTATIC_OBJECT_MANAGER) && !defined (ACE_HAS_WINCE) && !defined (ACE_DOESNT_INSTANTIATE_NONSTATIC_OBJECT_MANAGER)
00055   // Shut down the ACE_Object_Manager, if it had registered its exit_hook.
00056   // With ACE_HAS_NONSTATIC_OBJECT_MANAGER, the ACE_Object_Manager is
00057   // instantiated on the main's stack.  ::exit () doesn't destroy it.
00058   if (exit_hook_)
00059     (*exit_hook_) ();
00060 #endif /* ACE_HAS_NONSTATIC_OBJECT_MANAGER && !ACE_HAS_WINCE && !ACE_DOESNT_INSTANTIATE_NONSTATIC_OBJECT_MANAGER */
00061 
00062 #if !defined (ACE_HAS_WINCE)
00063 # if defined (ACE_WIN32)
00064   ::ExitProcess ((UINT) status);
00065 # else
00066   ::exit (status);
00067 # endif /* ACE_WIN32 */
00068 #else
00069   // @@ This is not exactly the same as ExitProcess.  But this is the
00070   // closest one I can get.
00071   ::TerminateProcess (::GetCurrentProcess (), status);
00072 #endif /* ACE_HAS_WINCE */
00073 }

ACE_INLINE int ACE_OS::fattach int  handle,
const char *  path
 

Definition at line 81 of file OS_NS_stropts.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and fattach().

Referenced by fattach().

00082 {
00083   ACE_OS_TRACE ("ACE_OS::fattach");
00084 #if defined (ACE_HAS_STREAM_PIPES)
00085   ACE_OSCALL_RETURN (::fattach (handle, path), int, -1);
00086 #else
00087   ACE_UNUSED_ARG (handle);
00088   ACE_UNUSED_ARG (path);
00089 
00090   ACE_NOTSUP_RETURN (-1);
00091 #endif /* ACE_HAS_STREAM_PIPES */
00092 }

ACE_INLINE int ACE_OS::fclose FILE *  fp  ) 
 

Definition at line 509 of file OS_NS_stdio.inl.

References ACE_OS_TRACE.

Referenced by access(), ACE::count_interfaces(), ACE_Ini_ImpExp::export_config(), ACE_Registry_ImpExp::export_config(), ACE::get_ip_interfaces(), ACE_Capabilities::getent(), ACE_Logging_Strategy::handle_timeout(), ACE_Ini_ImpExp::import_config(), ACE_Registry_ImpExp::import_config(), ACE_Logging_Strategy::init(), ACE_Log_Msg::msg_ostream(), ACE_Service_Config::open_i(), ACE_Service_Gestalt::process_file(), ACE_Log_Msg::~ACE_Log_Msg(), and ACE_Read_Buffer::~ACE_Read_Buffer().

00510 {
00511   ACE_OS_TRACE ("ACE_OS::fclose");
00512   ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::fclose (fp), int, -1);
00513 }

ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE int ACE_OS::fcntl ACE_HANDLE  handle,
int  cmd,
long  arg = 0
 

Definition at line 10 of file OS_NS_fcntl.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and fcntl().

Referenced by ACE::clr_flags(), ACE_IPC_SAP::disable(), ACE_IO_SAP::disable(), ACE_IPC_SAP::enable(), ACE_IO_SAP::enable(), fcntl(), ACE::get_flags(), ACE_Select_Reactor_Notify::open(), ACE_Dev_Poll_Reactor_Notify::open(), sema_init(), sema_trywait(), and ACE::set_flags().

00011 {
00012   ACE_OS_TRACE ("ACE_OS::fcntl");
00013 # if defined (ACE_LACKS_FCNTL)
00014   ACE_UNUSED_ARG (handle);
00015   ACE_UNUSED_ARG (cmd);
00016   ACE_UNUSED_ARG (arg);
00017   ACE_NOTSUP_RETURN (-1);
00018 # else
00019   ACE_OSCALL_RETURN (::fcntl (handle, cmd, arg), int, -1);
00020 # endif /* ACE_LACKS_FCNTL */
00021 }

ACE_INLINE int ACE_OS::fdetach const char *  file  ) 
 

Definition at line 95 of file OS_NS_stropts.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and fdetach().

Referenced by ACE_SPIPE_Acceptor::close(), and fdetach().

00096 {
00097   ACE_OS_TRACE ("ACE_OS::fdetach");
00098 #if defined (ACE_HAS_STREAM_PIPES)
00099   ACE_OSCALL_RETURN (::fdetach (file), int, -1);
00100 #else
00101   ACE_UNUSED_ARG (file);
00102 
00103   ACE_NOTSUP_RETURN (-1);
00104 #endif /* ACE_HAS_STREAM_PIPES */
00105 }

ACE_INLINE FILE * ACE_OS::fdopen ACE_HANDLE  handle,
const ACE_TCHAR mode
 

Definition at line 516 of file OS_NS_stdio.inl.

References ACE_OS_TRACE, ACE_TCHAR, ACE_TEXT_ALWAYS_CHAR, and ACE_TEXT_ALWAYS_WCHAR.

00517 {
00518   ACE_OS_TRACE ("ACE_OS::fdopen");
00519 # if defined (ACE_HAS_WINCE)
00520   ACE_OSCALL_RETURN (::_wfdopen (handle, ACE_TEXT_ALWAYS_WCHAR (mode)),
00521                      FILE*,
00522                      0);
00523 # elif defined (ACE_WIN32)
00524   // kernel file handle -> FILE* conversion...
00525   // Options: _O_APPEND, _O_RDONLY and _O_TEXT are lost
00526 
00527   FILE *file = 0;
00528 
00529 #if defined (ACE_LACKS_INTPTR_T)
00530   int crt_handle = ::_open_osfhandle (long (handle), 0);
00531 #else
00532   int crt_handle = ::_open_osfhandle (intptr_t (handle), 0);
00533 #endif
00534 
00535   if (crt_handle != -1)
00536     {
00537 #   if defined(ACE_HAS_NONCONST_FDOPEN) && !defined (ACE_USES_WCHAR)
00538       file = ::_fdopen (crt_handle, const_cast<ACE_TCHAR *> (mode));
00539 #   elif defined (ACE_HAS_NONCONST_FDOPEN) && defined (ACE_USES_WCHAR)
00540       file = ::_wfdopen (crt_handle, const_cast<ACE_TCHAR *> (mode));
00541 #   elif defined (ACE_USES_WCHAR)
00542       file = ::_wfdopen (crt_handle, mode);
00543 #   else
00544       file = ::_fdopen (crt_handle, mode);
00545 #   endif /* __BORLANDC__ */
00546 
00547       if (!file)
00548         {
00549 #   if (defined(__BORLANDC__) && __BORLANDC__ >= 0x0530)
00550           ::_rtl_close (crt_handle);
00551 #   else
00552           ::_close (crt_handle);
00553 #   endif /* (defined(__BORLANDC__) && __BORLANDC__ >= 0x0530) */
00554         }
00555     }
00556 
00557   return file;
00558 # else
00559   ACE_OSCALL_RETURN
00560     (::fdopen (handle, ACE_TEXT_ALWAYS_CHAR (mode)), FILE *, 0);
00561 # endif /* ACE_HAS_WINCE */
00562 }

ACE_INLINE int ACE_OS::fflush FILE *  fp  ) 
 

Definition at line 565 of file OS_NS_stdio.inl.

References ACE_OS_TRACE.

Referenced by ACE_Log_Record::print().

00566 {
00567   ACE_OS_TRACE ("ACE_OS::fflush");
00568 #if defined (ACE_VXWORKS)
00569   if (fp == 0)
00570     {
00571       // Do not allow fflush(0) on VxWorks
00572       return 0;
00573     }
00574 #endif /* ACE_VXWORKS */
00575 
00576   ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::fflush (fp), int, -1);
00577 }

ACE_INLINE int ACE_OS::fgetc FILE *  fp  ) 
 

Definition at line 580 of file OS_NS_stdio.inl.

00581 {
00582   ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::fgetc (fp), int, -1);
00583 }

ACE_INLINE int ACE_OS::fgetpos FILE *  fp,
fpos_t *  pos
 

Definition at line 586 of file OS_NS_stdio.inl.

00587 {
00588   ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::fgetpos (fp, pos), int, -1);
00589 }

ACE_INLINE wchar_t * ACE_OS::fgets wchar_t *  buf,
int  size,
FILE *  fp
 

Definition at line 600 of file OS_NS_stdio.inl.

References ACE_OS_TRACE.

00601 {
00602   ACE_OS_TRACE ("ACE_OS::fgets");
00603   ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::fgetws (buf, size, fp), wchar_t *, 0);
00604 }

ACE_INLINE char * ACE_OS::fgets char *  buf,
int  size,
FILE *  fp
 

Definition at line 592 of file OS_NS_stdio.inl.

References ACE_OS_TRACE.

Referenced by ACE_Ini_ImpExp::import_config(), and ACE_Registry_ImpExp::import_config().

00593 {
00594   ACE_OS_TRACE ("ACE_OS::fgets");
00595   ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::fgets (buf, size, fp), char *, 0);
00596 }

ACE_NAMESPACE_INLINE_FUNCTION wint_t fgetwc FILE *  fp  ) 
 

ACE_INLINE ACE_LOFF_T ACE_OS::filesize const ACE_TCHAR handle  ) 
 

Definition at line 107 of file OS_NS_sys_stat.inl.

References ACE_LOFF_T, ACE_OS_TRACE, ACE_TCHAR, close(), filesize(), and open().

00108   {
00109     ACE_OS_TRACE ("ACE_OS::filesize");
00110 
00111     ACE_HANDLE h = ACE_OS::open (filename, O_RDONLY);
00112     if (h != ACE_INVALID_HANDLE)
00113       {
00114         ACE_LOFF_T size = ACE_OS::filesize (h);
00115         ACE_OS::close (h);
00116         return size;
00117       }
00118     else
00119       return -1;
00120   }

ACE_INLINE ACE_LOFF_T ACE_OS::filesize ACE_HANDLE  handle  ) 
 

Definition at line 99 of file OS_NS_sys_stat.inl.

References ACE_OS_TRACE, ACE_stat, and fstat().

Referenced by ACE_POSIX_Asynch_Transmit_Handler::ACE_POSIX_Asynch_Transmit_Handler(), filesize(), ACE_MMAP_Memory_Pool::handle_signal(), ACE_Mem_Map::map_it(), mmap(), ACE_FILE_IO::recvv(), ACE_MMAP_Memory_Pool::remap(), ACE_POSIX_Asynch_Transmit_File::transmit_file(), and ACE_Mem_Map::unmap().

00100   {
00101     ACE_OS_TRACE ("ACE_OS::filesize");
00102     ACE_stat sb;
00103     return ACE_OS::fstat (handle, &sb) == -1 ? -1 : sb.st_size;
00104   }

ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE void ACE_OS::flock_adjust_params ace_flock_t *  lock,
short  whence,
off_t &  start,
off_t &  len
 

Definition at line 26 of file OS_NS_stdio.inl.

References ACE_OS::ace_flock_t::handle_, and ACE_OS::ace_flock_t::overlapped_.

Referenced by flock_rdlock(), flock_tryrdlock(), flock_trywrlock(), flock_unlock(), and flock_wrlock().

00030 {
00031   switch (whence)
00032     {
00033     case SEEK_SET:
00034       break;
00035     case SEEK_CUR:
00036       start += SetFilePointer (lock->handle_, 0, 0, FILE_CURRENT);
00037       break;
00038     case SEEK_END:
00039       start += ::GetFileSize (lock->handle_, 0);
00040       break;
00041     }
00042   lock->overlapped_.Offset = start;
00043   if (len == 0)
00044     len = ::GetFileSize (lock->handle_,
00045                          0) - start;
00046 }

ACE_INLINE int ACE_OS::flock_destroy ace_flock_t *  lock,
int  unlink_file = 1
 

Definition at line 115 of file OS_NS_stdio.inl.

References ACE_OS_TRACE, close(), flock_unlock(), free(), ACE_OS::ace_flock_t::handle_, ACE_OS::ace_flock_t::lockname_, and unlink().

Referenced by ACE_File_Lock::remove().

00117 {
00118   ACE_OS_TRACE ("ACE_OS::flock_destroy");
00119   if (lock->handle_ != ACE_INVALID_HANDLE)
00120     {
00121       ACE_OS::flock_unlock (lock);
00122       // Close the handle.
00123       ACE_OS::close (lock->handle_);
00124       lock->handle_ = ACE_INVALID_HANDLE;
00125       if (lock->lockname_ != 0)
00126         {
00127           if (unlink_file)
00128             ACE_OS::unlink (lock->lockname_);
00129           ACE_OS::free (
00130             static_cast<void *> (const_cast<ACE_TCHAR *> (lock->lockname_)));
00131         }
00132       lock->lockname_ = 0;
00133     }
00134   return 0;
00135 }

ACE_INLINE int ACE_OS::flock_init ace_flock_t *  lock,
int  flags = 0,
const ACE_TCHAR name = 0,
mode_t  perms = 0
 

Definition at line 50 of file OS_NS_stdio.inl.

References ACE_OS_TRACE, ACE_TCHAR, ACE_OS::ace_flock_t::handle_, ACE_OS::ace_flock_t::lockname_, mode_t, ACE_OS::ace_flock_t::overlapped_, and strdup().

Referenced by ACE_File_Lock::ACE_File_Lock(), and ACE_File_Lock::open().

00054 {
00055   ACE_OS_TRACE ("ACE_OS::flock_init");
00056 #if defined (ACE_WIN32)
00057   // Once initialized, these values are never changed.
00058   lock->overlapped_.Internal = 0;
00059   lock->overlapped_.InternalHigh = 0;
00060   lock->overlapped_.OffsetHigh = 0;
00061   lock->overlapped_.hEvent = 0;
00062 #endif /* ACE_WIN32 */
00063   lock->handle_ = ACE_INVALID_HANDLE;
00064   lock->lockname_ = 0;
00065 
00066   if (name != 0)
00067     {
00068       ACE_OSCALL (ACE_OS::open (name, flags, perms),
00069                   ACE_HANDLE,
00070                   ACE_INVALID_HANDLE,
00071                   lock->handle_);
00072       if (lock->handle_ != ACE_INVALID_HANDLE)
00073         lock->lockname_ = ACE_OS::strdup (name);
00074       return lock->handle_ == ACE_INVALID_HANDLE ? -1 : 0;
00075     }
00076   else
00077     return 0;
00078 }

ACE_INLINE int ACE_OS::flock_rdlock ace_flock_t *  lock,
short  whence = 0,
off_t  start = 0,
off_t  len = 0
 

Definition at line 138 of file OS_NS_stdio.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, flock_adjust_params(), ACE_OS::ace_flock_t::handle_, and ACE_OS::ace_flock_t::overlapped_.

Referenced by ACE_File_Lock::acquire_read().

00142 {
00143   ACE_OS_TRACE ("ACE_OS::flock_rdlock");
00144 #if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)
00145   ACE_OS::flock_adjust_params (lock, whence, start, len);
00146 #  if defined (ACE_HAS_WINNT4) && (ACE_HAS_WINNT4 != 0)
00147   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::LockFileEx (lock->handle_,
00148                                                         0,
00149                                                         0,
00150                                                         len,
00151                                                         0,
00152                                                         &lock->overlapped_),
00153                                           ace_result_), int, -1);
00154 #  else /* ACE_HAS_WINNT4 && (ACE_HAS_WINNT4 != 0) */
00155   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::LockFile (lock->handle_,
00156                                                       lock->overlapped_.Offset,
00157                                                       0,
00158                                                       len,
00159                                                       0),
00160                                           ace_result_), int, -1);
00161 #  endif /* ACE_HAS_WINNT4 && (ACE_HAS_WINNT4 != 0) */
00162 #elif defined (ACE_LACKS_FILELOCKS)
00163   ACE_UNUSED_ARG (lock);
00164   ACE_UNUSED_ARG (whence);
00165   ACE_UNUSED_ARG (start);
00166   ACE_UNUSED_ARG (len);
00167   ACE_NOTSUP_RETURN (-1);
00168 #else
00169   lock->lock_.l_whence = whence;
00170   lock->lock_.l_start = start;
00171   lock->lock_.l_len = len;
00172   lock->lock_.l_type = F_RDLCK;         // set read lock
00173   // block, if no access
00174   ACE_OSCALL_RETURN (ACE_OS::fcntl (lock->handle_, F_SETLKW,
00175                                     reinterpret_cast<long> (&lock->lock_)),
00176                      int, -1);
00177 #endif /* ACE_WIN32 */
00178 }

ACE_INLINE int ACE_OS::flock_tryrdlock ace_flock_t *  lock,
short  whence = 0,
off_t  start = 0,
off_t  len = 0
 

Definition at line 181 of file OS_NS_stdio.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, EBUSY, flock_adjust_params(), ACE_OS::ace_flock_t::handle_, and ACE_OS::ace_flock_t::overlapped_.

Referenced by ACE_File_Lock::tryacquire_read().

00185 {
00186   ACE_OS_TRACE ("ACE_OS::ace_flock_tryrdlock");
00187 #if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)
00188 #  if defined (ACE_HAS_WINNT4) && (ACE_HAS_WINNT4 != 0)
00189   ACE_OS::flock_adjust_params (lock, whence, start, len);
00190   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::LockFileEx (lock->handle_,
00191                                                         LOCKFILE_FAIL_IMMEDIATELY,
00192                                                         0,
00193                                                         len,
00194                                                         0,
00195                                                         &lock->overlapped_),
00196                                           ace_result_), int, -1);
00197 #  else /* ACE_HAS_WINNT4 && (ACE_HAS_WINNT4 != 0) */
00198   ACE_UNUSED_ARG (lock);
00199   ACE_UNUSED_ARG (whence);
00200   ACE_UNUSED_ARG (start);
00201   ACE_UNUSED_ARG (len);
00202   ACE_NOTSUP_RETURN (-1);
00203 #  endif /* ACE_HAS_WINNT4 && (ACE_HAS_WINNT4 != 0) */
00204 #elif defined (ACE_LACKS_FILELOCKS)
00205   ACE_UNUSED_ARG (lock);
00206   ACE_UNUSED_ARG (whence);
00207   ACE_UNUSED_ARG (start);
00208   ACE_UNUSED_ARG (len);
00209   ACE_NOTSUP_RETURN (-1);
00210 #else
00211   lock->lock_.l_whence = whence;
00212   lock->lock_.l_start = start;
00213   lock->lock_.l_len = len;
00214   lock->lock_.l_type = F_RDLCK;         // set read lock
00215 
00216   int result = 0;
00217   // Does not block, if no access, returns -1 and set errno = EBUSY;
00218   ACE_OSCALL (ACE_OS::fcntl (lock->handle_, F_SETLK,
00219                              reinterpret_cast<long> (&lock->lock_)),
00220               int, -1, result);
00221 
00222   if (result == -1 && (errno == EACCES || errno == EAGAIN))
00223     errno = EBUSY;
00224 
00225   return result;
00226 #endif /* ACE_WIN32 */
00227 }

ACE_INLINE int ACE_OS::flock_trywrlock ace_flock_t *  lock,
short  whence = 0,
off_t  start = 0,
off_t  len = 0
 

Definition at line 230 of file OS_NS_stdio.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, EBUSY, flock_adjust_params(), ACE_OS::ace_flock_t::handle_, and ACE_OS::ace_flock_t::overlapped_.

Referenced by ACE_File_Lock::tryacquire_write(), and ACE_File_Lock::tryacquire_write_upgrade().

00234 {
00235   ACE_OS_TRACE ("ACE_OS::ace_flock_trywrlock");
00236 #if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)
00237 #  if defined (ACE_HAS_WINNT4) && (ACE_HAS_WINNT4 != 0)
00238   ACE_OS::flock_adjust_params (lock, whence, start, len);
00239   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::LockFileEx (lock->handle_,
00240                                                         LOCKFILE_FAIL_IMMEDIATELY | LOCKFILE_EXCLUSIVE_LOCK,
00241                                                         0,
00242                                                         len,
00243                                                         0,
00244                                                         &lock->overlapped_),
00245                                           ace_result_), int, -1);
00246 #  else /* ACE_HAS_WINNT4 && (ACE_HAS_WINNT4 != 0) */
00247   ACE_UNUSED_ARG (lock);
00248   ACE_UNUSED_ARG (whence);
00249   ACE_UNUSED_ARG (start);
00250   ACE_UNUSED_ARG (len);
00251   ACE_NOTSUP_RETURN (-1);
00252 #  endif /* ACE_HAS_WINNT4 && (ACE_HAS_WINNT4 != 0) */
00253 #elif defined (ACE_LACKS_FILELOCKS)
00254   ACE_UNUSED_ARG (lock);
00255   ACE_UNUSED_ARG (whence);
00256   ACE_UNUSED_ARG (start);
00257   ACE_UNUSED_ARG (len);
00258   ACE_NOTSUP_RETURN (-1);
00259 #else
00260   lock->lock_.l_whence = whence;
00261   lock->lock_.l_start = start;
00262   lock->lock_.l_len = len;
00263   lock->lock_.l_type = F_WRLCK;         // set write lock
00264 
00265   int result = 0;
00266   // Does not block, if no access, returns -1 and set errno = EBUSY;
00267   ACE_OSCALL (ACE_OS::fcntl (lock->handle_,
00268                              F_SETLK,
00269                              reinterpret_cast<long> (&lock->lock_)),
00270               int, -1, result);
00271 
00272   if (result == -1 && (errno == EACCES || errno == EAGAIN))
00273     errno = EBUSY;
00274 
00275   return result;
00276 #endif /* ACE_WIN32 */
00277 }

ACE_INLINE int ACE_OS::flock_unlock ace_flock_t *  lock,
short  whence = 0,
off_t  start = 0,
off_t  len = 0
 

Definition at line 81 of file OS_NS_stdio.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, flock_adjust_params(), ACE_OS::ace_flock_t::handle_, and ACE_OS::ace_flock_t::overlapped_.

Referenced by flock_destroy(), and ACE_File_Lock::release().

00085 {
00086   ACE_OS_TRACE ("ACE_OS::flock_unlock");
00087 #if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)
00088   ACE_OS::flock_adjust_params (lock, whence, start, len);
00089   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::UnlockFile (lock->handle_,
00090                                                         lock->overlapped_.Offset,
00091                                                         0,
00092                                                         len,
00093                                                         0),
00094                                           ace_result_), int, -1);
00095 #elif defined (ACE_LACKS_FILELOCKS)
00096   ACE_UNUSED_ARG (lock);
00097   ACE_UNUSED_ARG (whence);
00098   ACE_UNUSED_ARG (start);
00099   ACE_UNUSED_ARG (len);
00100   ACE_NOTSUP_RETURN (-1);
00101 #else
00102   lock->lock_.l_whence = whence;
00103   lock->lock_.l_start = start;
00104   lock->lock_.l_len = len;
00105   lock->lock_.l_type = F_UNLCK;   // Unlock file.
00106 
00107   // release lock
00108   ACE_OSCALL_RETURN (ACE_OS::fcntl (lock->handle_, F_SETLK,
00109                                     reinterpret_cast<long> (&lock->lock_)),
00110                      int, -1);
00111 #endif /* ACE_WIN32 */
00112 }

ACE_INLINE int ACE_OS::flock_wrlock ace_flock_t *  lock,
short  whence = 0,
off_t  start = 0,
off_t  len = 0
 

Definition at line 280 of file OS_NS_stdio.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, flock_adjust_params(), ACE_OS::ace_flock_t::handle_, and ACE_OS::ace_flock_t::overlapped_.

Referenced by ACE_File_Lock::acquire_write().

00284 {
00285   ACE_OS_TRACE ("ACE_OS::flock_wrlock");
00286 #if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)
00287   ACE_OS::flock_adjust_params (lock, whence, start, len);
00288 #  if defined (ACE_HAS_WINNT4) && (ACE_HAS_WINNT4 != 0)
00289   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::LockFileEx (lock->handle_,
00290                                                         LOCKFILE_EXCLUSIVE_LOCK,
00291                                                         0,
00292                                                         len,
00293                                                         0,
00294                                                         &lock->overlapped_),
00295                                           ace_result_), int, -1);
00296 #  else /* ACE_HAS_WINNT4 && (ACE_HAS_WINNT4 != 0) */
00297   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::LockFile (lock->handle_,
00298                                                       lock->overlapped_.Offset,
00299                                                       0,
00300                                                       len,
00301                                                       0),
00302                                           ace_result_), int, -1);
00303 #  endif /* ACE_HAS_WINNT4 && (ACE_HAS_WINNT4 != 0) */
00304 #elif defined (ACE_LACKS_FILELOCKS)
00305   ACE_UNUSED_ARG (lock);
00306   ACE_UNUSED_ARG (whence);
00307   ACE_UNUSED_ARG (start);
00308   ACE_UNUSED_ARG (len);
00309   ACE_NOTSUP_RETURN (-1);
00310 #else
00311   lock->lock_.l_whence = whence;
00312   lock->lock_.l_start = start;
00313   lock->lock_.l_len = len;
00314   lock->lock_.l_type = F_WRLCK;         // set write lock
00315   // block, if no access
00316   ACE_OSCALL_RETURN (ACE_OS::fcntl (lock->handle_, F_SETLKW,
00317                                     reinterpret_cast<long> (&lock->lock_)),
00318                      int, -1);
00319 #endif /* ACE_WIN32 */
00320 }

ACE_INLINE double ACE_OS::floor double  x  ) 
 

This method computes the largest integral value not greater than x.

Definition at line 10 of file OS_NS_math.inl.

00011   {
00012     // This method computes the largest integral value not greater than x.
00013     if(x > 0)
00014       return static_cast<long> (x);
00015     else if (static_cast<long> (x) == x)
00016       return x;
00017     else
00018       return static_cast<long>(x) - 1;
00019   }

FILE * ACE_OS::fopen const wchar_t *  filename,
const ACE_TCHAR mode
 

Definition at line 164 of file OS_NS_stdio.cpp.

References _O_TEXT, ACE_OS_TRACE, ACE_TCHAR, close(), fopen_mode_to_open_mode_converter(), and open().

00166 {
00167   ACE_OS_TRACE ("ACE_OS::fopen");
00168   int hmode = _O_TEXT;
00169 
00170   for (const ACE_TCHAR *mode_ptr = mode; *mode_ptr != 0; mode_ptr++)
00171     ACE_OS::fopen_mode_to_open_mode_converter (*mode_ptr, hmode);
00172 
00173   ACE_HANDLE handle = ACE_OS::open (filename, hmode);
00174   if (handle != ACE_INVALID_HANDLE)
00175     {
00176       hmode &= _O_TEXT | _O_RDONLY | _O_APPEND;
00177 
00178 #   if defined (ACE_LACKS_INTPTR_T)
00179       int fd = ::_open_osfhandle (long (handle), hmode);
00180 #   else
00181       int fd = ::_open_osfhandle (intptr_t (handle), hmode);
00182 #   endif
00183 
00184       if (fd != -1)
00185         {
00186 #   if defined (__BORLANDC__) && !defined (ACE_USES_WCHAR)
00187           FILE *fp = ::_fdopen (fd, const_cast<char *> (mode));
00188 #   elif defined (__BORLANDC__) && defined (ACE_USES_WCHAR)
00189           FILE *fp = ::_wfdopen (fd, const_cast<wchar_t *> (mode));
00190 #   elif defined (ACE_USES_WCHAR)
00191           FILE *fp = ::_wfdopen (fd, mode);
00192 #   else
00193           FILE *fp = ::fdopen (fd, mode);
00194 #   endif /* defined(__BORLANDC__) && !defined (ACE_USES_WCHAR)) */
00195           if (fp != 0)
00196           {
00197 #   if defined (ACE_USES_WCHAR)
00198             checkUnicodeFormat(fp);
00199 #   endif  // ACE_USES_WCHAR
00200             return fp;
00201           }
00202           ::_close (fd);
00203         }
00204 
00205       ACE_OS::close (handle);
00206     }
00207   return 0;
00208 }

FILE * ACE_OS::fopen const char *  filename,
const ACE_TCHAR mode
 

Definition at line 116 of file OS_NS_stdio.cpp.

References _O_TEXT, ACE_OS_TRACE, ACE_TCHAR, close(), fopen_mode_to_open_mode_converter(), and open().

Referenced by access(), ACE::count_interfaces(), ACE_Ini_ImpExp::export_config(), ACE_Registry_ImpExp::export_config(), ACE::get_ip_interfaces(), ACE_Capabilities::getent(), ACE_Logging_Strategy::handle_timeout(), ACE_Ini_ImpExp::import_config(), ACE_Registry_ImpExp::import_config(), ACE_Logging_Strategy::init(), ACE::ldopen(), ACE_Service_Config::open_i(), and ACE_Service_Gestalt::process_file().

00118 {
00119   ACE_OS_TRACE ("ACE_OS::fopen");
00120   int hmode = _O_TEXT;
00121 
00122   for (const ACE_TCHAR *mode_ptr = mode; *mode_ptr != 0; mode_ptr++)
00123     ACE_OS::fopen_mode_to_open_mode_converter (*mode_ptr, hmode);
00124 
00125   ACE_HANDLE handle = ACE_OS::open (filename, hmode);
00126   if (handle != ACE_INVALID_HANDLE)
00127     {
00128       hmode &= _O_TEXT | _O_RDONLY | _O_APPEND;
00129 
00130 #   if defined (ACE_LACKS_INTPTR_T)
00131       int fd = ::_open_osfhandle (long (handle), hmode);
00132 #   else
00133       int fd = ::_open_osfhandle (intptr_t (handle), hmode);
00134 #   endif
00135 
00136       if (fd != -1)
00137         {
00138 #   if defined (__BORLANDC__) && !defined (ACE_USES_WCHAR)
00139           FILE *fp = ::_fdopen (fd, const_cast<ACE_TCHAR *> (mode));
00140 #   elif defined (__BORLANDC__) && defined (ACE_USES_WCHAR)
00141           FILE *fp = ::_wfdopen (fd, const_cast<ACE_TCHAR *> (mode));
00142 #   elif defined (ACE_USES_WCHAR)
00143           FILE *fp = ::_wfdopen (fd, mode);
00144 #   else
00145           FILE *fp = ::fdopen (fd, mode);
00146 #   endif /* defined(__BORLANDC__) && !defined (ACE_USES_WCHAR)) */
00147           if (fp != 0)
00148           {
00149 #   if defined (ACE_USES_WCHAR)
00150             checkUnicodeFormat(fp);
00151 #   endif  // ACE_USES_WCHAR
00152             return fp;
00153           }
00154           ::_close (fd);
00155         }
00156 
00157       ACE_OS::close (handle);
00158     }
00159   return 0;
00160 }

ACE_INLINE void ACE_OS::fopen_mode_to_open_mode_converter ACE_TCHAR  x,
int &  hmode
 

Translate fopen's mode char to open's mode. This helper function is here to avoid maintaining several pieces of identical code.

Definition at line 324 of file OS_NS_stdio.inl.

References _O_BINARY, _O_TEXT, ACE_BIT_DISABLED, ACE_CLR_BITS, ACE_LIB_TEXT, ACE_SET_BITS, and ACE_TCHAR.

Referenced by fopen().

00325 {
00326     switch (x)
00327       {
00328       case ACE_LIB_TEXT ('r'):
00329         if (ACE_BIT_DISABLED (hmode, _O_RDWR))
00330           {
00331             ACE_CLR_BITS (hmode, _O_WRONLY);
00332             ACE_SET_BITS (hmode, _O_RDONLY);
00333           }
00334         break;
00335       case ACE_LIB_TEXT ('w'):
00336         if (ACE_BIT_DISABLED (hmode, _O_RDWR))
00337           {
00338             ACE_CLR_BITS (hmode, _O_RDONLY);
00339             ACE_SET_BITS (hmode, _O_WRONLY);
00340           }
00341         ACE_SET_BITS (hmode, _O_CREAT | _O_TRUNC);
00342         break;
00343       case ACE_LIB_TEXT ('a'):
00344         if (ACE_BIT_DISABLED (hmode, _O_RDWR))
00345           {
00346             ACE_CLR_BITS (hmode, _O_RDONLY);
00347             ACE_SET_BITS (hmode, _O_WRONLY);
00348           }
00349         ACE_SET_BITS (hmode, _O_CREAT | _O_APPEND);
00350         break;
00351       case ACE_LIB_TEXT ('+'):
00352         ACE_CLR_BITS (hmode, _O_RDONLY | _O_WRONLY);
00353         ACE_SET_BITS (hmode, _O_RDWR);
00354         break;
00355       case ACE_LIB_TEXT ('t'):
00356         ACE_CLR_BITS (hmode, _O_BINARY);
00357         ACE_SET_BITS (hmode, _O_TEXT);
00358         break;
00359       case ACE_LIB_TEXT ('b'):
00360         ACE_CLR_BITS (hmode, _O_TEXT);
00361         ACE_SET_BITS (hmode, _O_BINARY);
00362         break;
00363       }
00364 }

pid_t ACE_OS::fork const ACE_TCHAR program_name  ) 
 

Forks and exec's a process in a manner that works on Solaris and NT. argv[0] must be the full path name to the executable.

Definition at line 165 of file OS_NS_unistd.cpp.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_TCHAR, pid_t, and ACE_Base_Thread_Adapter::sync_log_msg().

00166 {
00167   ACE_OS_TRACE ("ACE_OS::fork");
00168 # if defined (ACE_LACKS_FORK)
00169   ACE_UNUSED_ARG (program_name);
00170   ACE_NOTSUP_RETURN (pid_t (-1));
00171 # else
00172   pid_t pid =
00173 # if defined (ACE_HAS_STHREADS)
00174     ::fork1 ();
00175 #else
00176     ::fork ();
00177 #endif /* ACE_HAS_STHREADS */
00178 
00179 #if !defined (ACE_HAS_MINIMAL_ACE_OS)
00180   if (pid == 0)
00181     ACE_Base_Thread_Adapter::sync_log_msg (program_name);
00182 #endif /* ! ACE_HAS_MINIMAL_ACE_OS */
00183 
00184   return pid;
00185 # endif /* ACE_WIN32 */
00186 }

ACE_INLINE pid_t ACE_OS::fork void   ) 
 

Forks and exec's a process in a manner that works on Solaris and NT. argv[0] must be the full path name to the executable.

Definition at line 329 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and pid_t.

Referenced by ACE::daemonize(), ACE::fork(), and fork_exec().

00330 {
00331   ACE_OS_TRACE ("ACE_OS::fork");
00332 #if defined (ACE_LACKS_FORK)
00333   ACE_NOTSUP_RETURN (pid_t (-1));
00334 #else
00335   ACE_OSCALL_RETURN (::fork (), pid_t, -1);
00336 #endif /* ACE_LACKS_FORK */
00337 }

pid_t ACE_OS::fork_exec ACE_TCHAR argv[]  ) 
 

Forks and exec's a process in a manner that works on Solaris and NT. argv[0] must be the full path name to the executable.

Definition at line 192 of file OS_NS_unistd.cpp.

References ACE_NEW_NORETURN, ACE_TCHAR, argv_to_string(), close(), execv(), exit(), fork(), memset(), and pid_t.

00193 {
00194 # if defined (ACE_WIN32)
00195   ACE_TCHAR *buf;
00196 
00197   if (ACE_OS::argv_to_string (argv, buf) != -1)
00198     {
00199       PROCESS_INFORMATION process_info;
00200 #   if !defined (ACE_HAS_WINCE)
00201       ACE_TEXT_STARTUPINFO startup_info;
00202       ACE_OS::memset ((void *) &startup_info,
00203                       0,
00204                       sizeof startup_info);
00205       startup_info.cb = sizeof startup_info;
00206 
00207       if (ACE_TEXT_CreateProcess (0,
00208                                   buf,
00209                                   0, // No process attributes.
00210                                   0,  // No thread attributes.
00211                                   TRUE, // Allow handle inheritance.
00212                                   0, // Don't create a new console window.
00213                                   0, // No environment.
00214                                   0, // No current directory.
00215                                   &startup_info,
00216                                   &process_info))
00217 #   else
00218       if (ACE_TEXT_CreateProcess (0,
00219                                   buf,
00220                                   0, // No process attributes.
00221                                   0,  // No thread attributes.
00222                                   FALSE, // Can's inherit handles on CE
00223                                   0, // Don't create a new console window.
00224                                   0, // No environment.
00225                                   0, // No current directory.
00226                                   0, // Can't use startup info on CE
00227                                   &process_info))
00228 #   endif /* ! ACE_HAS_WINCE */
00229         {
00230           // Free resources allocated in kernel.
00231           ACE_OS::close (process_info.hThread);
00232           ACE_OS::close (process_info.hProcess);
00233           // Return new process id.
00234           delete [] buf;
00235           return process_info.dwProcessId;
00236         }
00237     }
00238 
00239   // CreateProcess failed.
00240   return -1;
00241 # else
00242       pid_t result = ACE_OS::fork ();
00243 
00244 #   if defined (ACE_USES_WCHAR)
00245       // Wide-char builds need to convert the command-line args to
00246       // narrow char strings for execv().
00247       char **cargv;
00248       int arg_count;
00249 #   endif /* ACE_HAS_WCHAR */
00250 
00251       switch (result)
00252         {
00253         case -1:
00254           // Error.
00255           return -1;
00256         case 0:
00257           // Child process.
00258 #   if defined (ACE_USES_WCHAR)
00259           for (arg_count = 0; argv[arg_count] != 0; ++arg_count)
00260             ;
00261           ++arg_count;    // Need a 0-pointer end-of-array marker
00262           ACE_NEW_NORETURN (cargv, char*[arg_count]);
00263           if (cargv == 0)
00264             ACE_OS::exit (errno);
00265           --arg_count;    // Back to 0-indexed
00266           cargv[arg_count] = 0;
00267           while (--arg_count >= 0)
00268             cargv[arg_count] = ACE_Wide_To_Ascii::convert (argv[arg_count]);
00269           // Don't worry about freeing the cargv or the strings it points to.
00270           // Either the process will be replaced, or we'll exit.
00271           if (ACE_OS::execv (cargv[0], cargv) == -1)
00272             ACE_OS::exit (errno);
00273 #   else
00274           if (ACE_OS::execv (argv[0], argv) == -1)
00275             {
00276               // The OS layer should not print stuff out
00277               // ACE_ERROR ((LM_ERROR,
00278               //             "%p Exec failed\n"));
00279 
00280               // If the execv fails, this child needs to exit.
00281               ACE_OS::exit (errno);
00282             }
00283 #   endif /* ACE_HAS_WCHAR */
00284 
00285         default:
00286           // Server process.  The fork succeeded.
00287           return result;
00288         }
00289 # endif /* ACE_WIN32 */
00290 }

int ACE_OS::fprintf FILE *  fp,
const wchar_t *  format,
... 
 

Definition at line 227 of file OS_NS_stdio.cpp.

References ACE_NOTSUP_RETURN, and ACE_OS_TRACE.

00228 {
00229   ACE_OS_TRACE ("ACE_OS::fprintf");
00230 
00231 # if !defined (ACE_HAS_VFWPRINTF)
00232   ACE_UNUSED_ARG (fp);
00233   ACE_UNUSED_ARG (format);
00234   ACE_NOTSUP_RETURN (-1);
00235 
00236 # else
00237   int result = 0;
00238   va_list ap;
00239   va_start (ap, format);
00240   ACE_OSCALL (ACE_STD_NAMESPACE::vfwprintf (fp, format, ap), int, -1, result);
00241   va_end (ap);
00242   return result;
00243 
00244 # endif /* ACE_HAS_VFWPRINTF */
00245 }

int ACE_OS::fprintf FILE *  fp,
const char *  format,
... 
 

Definition at line 214 of file OS_NS_stdio.cpp.

References ACE_OS_TRACE.

Referenced by ACE_Service_Type::dump(), ACE_ATM_Stream::get_vpi_vci(), ACE_Svc_Conf_Lexer::input(), ACE_Service_Gestalt::insert(), ACE_Log_Msg::log(), ACE_Service_Config::open_i(), ACE_Name_Options::parse_args(), ACE_Log_Record::print(), ACE_Stats::print_summary(), socket_fini(), and socket_init().

00215 {
00216   ACE_OS_TRACE ("ACE_OS::fprintf");
00217   int result = 0;
00218   va_list ap;
00219   va_start (ap, format);
00220   ACE_OSCALL (::vfprintf (fp, format, ap), int, -1, result);
00221   va_end (ap);
00222   return result;
00223 }

ACE_INLINE int ACE_OS::fputs const wchar_t *  s,
FILE *  stream
 

Definition at line 645 of file OS_NS_stdio.inl.

References ACE_OS_TRACE.

00646 {
00647   ACE_OS_TRACE ("ACE_OS::fputs");
00648   ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::fputws (s, stream), int, -1);
00649 }

ACE_INLINE int ACE_OS::fputs const char *  s,
FILE *  stream
 

Definition at line 637 of file OS_NS_stdio.inl.

References ACE_OS_TRACE.

Referenced by ACE_Ini_ImpExp::export_section(), and ACE_Registry_ImpExp::export_section().

00638 {
00639   ACE_OS_TRACE ("ACE_OS::fputs");
00640   ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::fputs (s, stream), int, -1);
00641 }

ACE_INLINE size_t ACE_OS::fread void *  ptr,
size_t  size,
size_t  nelems,
FILE *  fp
 

Definition at line 653 of file OS_NS_stdio.inl.

References ACE_OS_TRACE.

Referenced by ACE_Svc_Conf_Lexer::input().

00654 {
00655   ACE_OS_TRACE ("ACE_OS::fread");
00656   ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::fread (ptr, size, nelems, fp),
00657                      size_t,
00658                      0);
00659 }

void ACE_OS::free void *   ) 
 

Definition at line 76 of file OS_NS_stdlib.cpp.

References ACE_FREE_FUNC, and ACE_MALLOC_T.

Referenced by ACE_ARGV_T< CHAR_TYPE >::add(), ACE_TLI_Acceptor::close(), ACE_Dirent_Selector::close(), ACE_ATM_QoS::construct_options(), ACE::count_interfaces(), ACE_Name_Options::database(), event_destroy(), flock_destroy(), ACE_ATM_Stream::get_vpi_vci(), ACE::ldfind(), ACE_Local_Name_Space<, ACE_LOCK >::list_type_entries_i(), ACE_Local_Name_Space<, ACE_LOCK >::list_types_i(), ACE_Log_Msg::local_host(), ACE_Name_Options::nameserver_host(), ACE_Name_Options::namespace_dir(), ACE_Log_Msg::open(), ACE_Name_Binding::operator=(), ACE_Name_Options::process_name(), putenv(), ACE_Mutex::remove(), ACE_Auto_String_Free::reset(), scandir_emulation(), sema_destroy(), ACE_SPIPE_Addr::set(), ACE_INET_Addr::string_to_addr(), ACE_Log_Msg::sync(), tempnam(), ACE_ARGV_T< CHAR_TYPE >::~ACE_ARGV_T(), ACE_Argv_Type_Converter::~ACE_Argv_Type_Converter(), ACE_Configuration_Section_Key_Heap::~ACE_Configuration_Section_Key_Heap(), ACE_Hash_Map_Entry< const ACE_TCHAR *, ACE_Filecache_Object * >::~ACE_Hash_Map_Entry(), ACE_Log_Msg::~ACE_Log_Msg(), ACE_Malloc_FIFO_Iterator_T<, ACE_LOCK, ACE_CB >::~ACE_Malloc_FIFO_Iterator_T(), ACE_Malloc_LIFO_Iterator_T<, ACE_LOCK, ACE_CB >::~ACE_Malloc_LIFO_Iterator_T(), ACE_Name_Binding::~ACE_Name_Binding(), ACE_Name_Options::~ACE_Name_Options(), and ACE_Strategy_Acceptor< SVC_HANDLER, >::~ACE_Strategy_Acceptor().

00077 {
00078   ACE_FREE_FUNC (ACE_MALLOC_T (ptr));
00079 }

ACE_INLINE FILE * ACE_OS::freopen const ACE_TCHAR filename,
const ACE_TCHAR mode,
FILE *  stream
 

Definition at line 662 of file OS_NS_stdio.inl.

References ACE_OS_TRACE, ACE_TCHAR, ACE_TEXT_ALWAYS_CHAR, and ACE_TEXT_ALWAYS_WCHAR.

00663 {
00664   ACE_OS_TRACE ("ACE_OS::freopen");
00665 #if defined (ACE_WIN32) && (defined(ACE_USES_WCHAR) || defined(ACE_HAS_WINCE))
00666   ACE_OSCALL_RETURN (::_wfreopen (ACE_TEXT_ALWAYS_WCHAR (filename),
00667                                   ACE_TEXT_ALWAYS_WCHAR (mode),
00668                                   stream),
00669                      FILE *, 0);
00670 #else
00671   ACE_OSCALL_RETURN
00672     (ACE_STD_NAMESPACE::freopen (ACE_TEXT_ALWAYS_CHAR (filename),
00673                                  ACE_TEXT_ALWAYS_CHAR (mode),
00674                                  stream),
00675      FILE *, 0);
00676 #endif /* ACE_WIN32 && ACE_USES_WCHAR */
00677 }

ACE_INLINE int ACE_OS::fseek FILE *  fp,
long  offset,
int  ptrname
 

Definition at line 680 of file OS_NS_stdio.inl.

Referenced by rewind().

00681 {
00682 # if defined (ACE_WIN32)
00683 #   if SEEK_SET != FILE_BEGIN || SEEK_CUR != FILE_CURRENT || SEEK_END != FILE_END
00684   //#error Windows NT is evil AND rude!
00685   switch (whence)
00686     {
00687     case SEEK_SET:
00688       whence = FILE_BEGIN;
00689       break;
00690     case SEEK_CUR:
00691       whence = FILE_CURRENT;
00692       break;
00693     case SEEK_END:
00694       whence = FILE_END;
00695       break;
00696     default:
00697       errno = EINVAL;
00698       return -1; // rather safe than sorry
00699     }
00700 #   endif  /* SEEK_SET != FILE_BEGIN || SEEK_CUR != FILE_CURRENT || SEEK_END != FILE_END */
00701 # endif   /* ACE_WIN32 */
00702   ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::fseek (fp, offset, whence), int, -1);
00703 }

ACE_INLINE int ACE_OS::fsetpos FILE *  fp,
fpos_t *  pos
 

Definition at line 706 of file OS_NS_stdio.inl.

References fsetpos().

Referenced by fsetpos().

00707 {
00708   ACE_OSCALL_RETURN (::fsetpos (fp, pos), int, -1);
00709 }

ACE_INLINE int ACE_OS::fstat ACE_HANDLE  ,
ACE_stat
 

Definition at line 51 of file OS_NS_sys_stat.inl.

References ACE_OS_TRACE, ACE_Time_Value, and set_errno_to_last_error().

Referenced by ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::check_handles(), filesize(), and ACE_FILE::get_info().

00052   {
00053     ACE_OS_TRACE ("ACE_OS::fstat");
00054 # if 1
00055     BY_HANDLE_FILE_INFORMATION fdata;
00056 
00057     if (::GetFileInformationByHandle (handle, &fdata) == FALSE)
00058       {
00059         ACE_OS::set_errno_to_last_error ();
00060         return -1;
00061       }
00062     else if (fdata.nFileSizeHigh != 0)
00063       {
00064         errno = EINVAL;
00065         return -1;
00066       }
00067     else
00068       {
00069         stp->st_size = fdata.nFileSizeLow;
00070         stp->st_atime = ACE_Time_Value (fdata.ftLastAccessTime).sec ();
00071         stp->st_mtime = ACE_Time_Value (fdata.ftLastWriteTime).sec ();
00072         stp->st_ctime = ACE_Time_Value (fdata.ftCreationTime).sec ();
00073         stp->st_nlink = static_cast<short> (fdata.nNumberOfLinks);
00074         stp->st_dev = stp->st_rdev = 0; // No equivalent conversion.
00075         stp->st_mode = S_IXOTH | S_IROTH |
00076           (fdata.dwFileAttributes & FILE_ATTRIBUTE_READONLY ? 0 : S_IWOTH) |
00077           (fdata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ? S_IFDIR : S_IFREG);
00078       }
00079     return 0;
00080 # else /* 1 */
00081     // This implementation close the handle.
00082     int retval = -1;
00083     int fd = ::_open_osfhandle ((long) handle, 0);
00084     if (fd != -1)
00085       retval = ::_fstat (fd, stp);
00086 
00087     ::_close (fd);
00088     // Remember to close the file handle.
00089     return retval;
00090 # endif /* 1 */
00091   }

ACE_INLINE int ACE_OS::fsync ACE_HANDLE  handle  ) 
 

Definition at line 340 of file OS_NS_unistd.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, and fsync().

Referenced by fsync().

00341 {
00342   ACE_OS_TRACE ("ACE_OS::fsync");
00343 # if defined (ACE_LACKS_FSYNC)
00344   ACE_UNUSED_ARG (handle);
00345   ACE_NOTSUP_RETURN (-1);
00346 # elif defined (ACE_WIN32)
00347   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::FlushFileBuffers (handle), ace_result_), int, -1);
00348 # else
00349   ACE_OSCALL_RETURN (::fsync (handle), int, -1);
00350 # endif /* ACE_LACKS_FSYNC */
00351 }

ACE_INLINE long ACE_OS::ftell FILE *  fp  ) 
 

Definition at line 712 of file OS_NS_stdio.inl.

Referenced by ACE_Logging_Strategy::handle_timeout().

00713 {
00714   ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::ftell (fp), long, -1);
00715 }

ACE_INLINE int ACE_OS::ftruncate ACE_HANDLE  ,
ACE_LOFF_T 
 

Definition at line 354 of file OS_NS_unistd.inl.

References ACE_ADAPT_RETVAL, ACE_FAIL_RETURN, ACE_LOFF_T, ACE_OS_TRACE, and ftruncate().

Referenced by ACE_Mutex::ACE_Mutex(), event_init(), ftruncate(), ACE_Mem_Map::remove(), sema_init(), and ACE_FILE::truncate().

00355 {
00356   ACE_OS_TRACE ("ACE_OS::ftruncate");
00357 #if defined (ACE_WIN32)
00358 #  if !defined (ACE_LACKS_SETFILEPOINTEREX)
00359   LARGE_INTEGER loff;
00360   loff.QuadPart = offset;
00361   if (::SetFilePointerEx (handle, loff, 0, FILE_BEGIN) != (unsigned) -1)
00362 #  else
00363   if (::SetFilePointer (handle, offset, 0, FILE_BEGIN) != (unsigned) -1)
00364 #  endif
00365     ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::SetEndOfFile (handle), ace_result_), int, -1);
00366   else
00367     ACE_FAIL_RETURN (-1);
00368 #else
00369   ACE_OSCALL_RETURN (::ftruncate (handle, offset), int, -1);
00370 #endif /* ACE_WIN32 */
00371 }

ACE_INLINE size_t ACE_OS::fwrite const void *  ptr,
size_t  size,
size_t  nitems,
FILE *  fp
 

Definition at line 718 of file OS_NS_stdio.inl.

References ACE_OS_TRACE.

00719 {
00720   ACE_OS_TRACE ("ACE_OS::fwrite");
00721   ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::fwrite (ptr, size, nitems, fp),
00722                      size_t,
00723                      0);
00724 }

ACE_NAMESPACE_INLINE_FUNCTION HINSTANCE get_win32_resource_module void   ) 
 

Return the handle of the module containing ACE's resources. By default, for a DLL build of ACE this is a handle to the ACE DLL itself, and for a static build it is a handle to the executable.

ACE_NAMESPACE_INLINE_FUNCTION const OSVERSIONINFO& get_win32_versioninfo void   ) 
 

Return the win32 OSVERSIONINFO structure.

ACE_INLINE wchar_t * ACE_OS::getcwd wchar_t *  ,
size_t 
 

Definition at line 390 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, getcwd(), and strsncpy().

00391 {
00392 #  if defined (ACE_HAS_WINCE)
00393   ACE_UNUSED_ARG (buf);
00394   ACE_UNUSED_ARG (size);
00395   ACE_NOTSUP_RETURN (0);
00396 #  elif defined (ACE_WIN32)
00397   return ::_wgetcwd (buf, static_cast<int> (size));
00398 #  else
00399   char *narrow_buf = new char[size];
00400   char *result = 0;
00401   result = ACE_OS::getcwd (narrow_buf, size);
00402   ACE_Ascii_To_Wide wide_buf (result);
00403   delete [] narrow_buf;
00404   if (result != 0)
00405     ACE_OS::strsncpy (buf, wide_buf.wchar_rep (), size);
00406   return result == 0 ? 0 : buf;
00407 #  endif /* ACE_WIN32 */
00408 }

ACE_INLINE char * ACE_OS::getcwd char *  ,
size_t 
 

Definition at line 374 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and getcwd().

Referenced by getcwd().

00375 {
00376   ACE_OS_TRACE ("ACE_OS::getcwd");
00377 #if defined (ACE_LACKS_GETCWD)
00378   ACE_UNUSED_ARG (buf);
00379   ACE_UNUSED_ARG (size);
00380   ACE_NOTSUP_RETURN (0);
00381 #elif defined (ACE_WIN32)
00382   return ::getcwd (buf, static_cast<int> (size));
00383 #else
00384   ACE_OSCALL_RETURN (::getcwd (buf, size), char *, 0);
00385 #endif /* ACE_LACKS_GETCWD */
00386 }

ACE_INLINE gid_t ACE_OS::getegid void   ) 
 

Definition at line 423 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, getegid(), and gid_t.

Referenced by getegid().

00424 {
00425   ACE_OS_TRACE ("ACE_OS::getegid");
00426 #if defined (ACE_LACKS_GETEGID)
00427   ACE_NOTSUP_RETURN (static_cast<gid_t> (-1));
00428 # else
00429   ACE_OSCALL_RETURN (::getegid (), gid_t, static_cast<gid_t> (-1));
00430 # endif /* ACE_LACKS_GETEGID */
00431 }

ACE_INLINE wchar_t * ACE_OS::getenv const wchar_t *  symbol  ) 
 

Definition at line 139 of file OS_NS_stdlib.inl.

References ACE_NOTSUP_RETURN.

00140 {
00141 #if defined (ACE_LACKS_ENV)
00142   ACE_UNUSED_ARG (symbol);
00143   ACE_NOTSUP_RETURN (0);
00144 #else
00145   ACE_OSCALL_RETURN (::_wgetenv (symbol), wchar_t *, 0);
00146 #endif /* ACE_LACKS_ENV */
00147 }

ACE_INLINE char * ACE_OS::getenv const char *  symbol  ) 
 

Definition at line 126 of file OS_NS_stdlib.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and getenv().

Referenced by ACE_Get_Opt::ACE_Get_Opt(), ACE_Log_Msg::ACE_Log_Msg(), argv_to_string(), ACE::debug(), ACE_Env_Value< T >::fetch_value(), ACE_High_Res_Timer::get_env_global_scale_factor(), ACE::get_temp_dir(), getenv(), ACE::ldfind(), and strenvdup().

00127 {
00128   ACE_OS_TRACE ("ACE_OS::getenv");
00129 #if defined (ACE_LACKS_ENV)
00130   ACE_UNUSED_ARG (symbol);
00131   ACE_NOTSUP_RETURN (0);
00132 #else /* ACE_LACKS_ENV */
00133   ACE_OSCALL_RETURN (::getenv (symbol), char *, 0);
00134 #endif /* ACE_LACKS_ENV */
00135 }

ACE_TCHAR * ACE_OS::getenvstrings void   ) 
 

Definition at line 91 of file OS_NS_stdlib.cpp.

References ACE_NOTSUP_RETURN.

Referenced by ACE_Process_Options::inherit_environment().

00092 {
00093 #if defined (ACE_LACKS_ENV)
00094   ACE_NOTSUP_RETURN (0);
00095 #elif defined (ACE_WIN32)
00096 # if defined (ACE_USES_WCHAR)
00097   return ::GetEnvironmentStringsW ();
00098 # else /* ACE_USES_WCHAR */
00099   return ::GetEnvironmentStrings ();
00100 # endif /* ACE_USES_WCHAR */
00101 #else /* ACE_WIN32 */
00102   ACE_NOTSUP_RETURN (0);
00103 #endif /* ACE_WIN32 */
00104 }

ACE_INLINE uid_t ACE_OS::geteuid void   ) 
 

Definition at line 501 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, geteuid(), and uid_t.

Referenced by geteuid().

00502 {
00503   ACE_OS_TRACE ("ACE_OS::geteuid");
00504 #if defined (ACE_LACKS_GETEUID)
00505   ACE_NOTSUP_RETURN (static_cast<uid_t> (-1));
00506 # else
00507   ACE_OSCALL_RETURN (::geteuid (), uid_t, (uid_t) -1);
00508 # endif /* ACE_LACKS_GETEUID */
00509 }

ACE_INLINE gid_t ACE_OS::getgid void   ) 
 

Definition at line 412 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, getgid(), and gid_t.

Referenced by getgid(), and ACE_SPIPE_Addr::set().

00413 {
00414   ACE_OS_TRACE ("ACE_OS::getgid");
00415 #if defined (ACE_LACKS_GETGID)
00416   ACE_NOTSUP_RETURN (static_cast<gid_t> (-1));
00417 # else
00418   ACE_OSCALL_RETURN (::getgid (), gid_t, static_cast<gid_t> (-1));
00419 # endif /* ACE_LACKS_GETGID */
00420 }

ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE struct hostent * ACE_OS::gethostbyaddr const char *  addr,
int  length,
int  type
 

Definition at line 48 of file OS_NS_netdb.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_SOCKCALL_RETURN, ACE_SOCKET_LEN, and gethostbyaddr().

Referenced by ACE_INET_Addr::get_host_name_i(), gethostbyaddr(), gethostbyaddr_r(), and getipnodebyaddr().

00049 {
00050   ACE_OS_TRACE ("ACE_OS::gethostbyaddr");
00051 # if defined (ACE_LACKS_GETHOSTBYADDR)
00052   ACE_UNUSED_ARG (addr);
00053   ACE_UNUSED_ARG (length);
00054   ACE_UNUSED_ARG (type);
00055   ACE_NOTSUP_RETURN (0);
00056 # elif defined (ACE_HAS_NONCONST_GETBY)
00057   ACE_SOCKCALL_RETURN (::gethostbyaddr (const_cast<char *> (addr),
00058                                         (ACE_SOCKET_LEN) length,
00059                                         type),
00060                        struct hostent *,
00061                        0);
00062 # else
00063   ACE_SOCKCALL_RETURN (::gethostbyaddr (addr,
00064                                         (ACE_SOCKET_LEN) length,
00065                                         type),
00066                        struct hostent *,
00067                        0);
00068 # endif /* ACE_HAS_NONCONST_GETBY */
00069 }

ACE_INLINE struct hostent * ACE_OS::gethostbyaddr_r const char *  addr,
int  length,
int  type,
struct hostent *  result,
ACE_HOSTENT_DATA  buffer,
int *  h_errnop
 

Definition at line 76 of file OS_NS_netdb.inl.

References ACE_HOSTENT_DATA, ACE_OS_TRACE, ACE_SOCKCALL_RETURN, ACE_SOCKET_LEN, gethostbyaddr(), gethostbyaddr_r(), and memset().

Referenced by ACE_INET_Addr::get_host_name_i(), and gethostbyaddr_r().

00082 {
00083   ACE_OS_TRACE ("ACE_OS::gethostbyaddr_r");
00084 # if defined (ACE_HAS_REENTRANT_FUNCTIONS) && !defined (UNIXWARE)
00085 #   if defined (AIX) || defined (DIGITAL_UNIX)
00086   ACE_OS::memset (buffer, 0, sizeof (ACE_HOSTENT_DATA));
00087 
00088   if (::gethostbyaddr_r ((char *) addr, length, type, result,
00089                          (struct hostent_data *) buffer)== 0)
00090     return result;
00091   else
00092     {
00093       *h_errnop = h_errno;
00094       return (struct hostent *) 0;
00095     }
00096 # elif defined (__GLIBC__)
00097   // GNU C library has a different signature
00098   ACE_OS::memset (buffer, 0, sizeof (ACE_HOSTENT_DATA));
00099 
00100   if (::gethostbyaddr_r ((char *) addr,
00101                          length,
00102                          type,
00103                          result,
00104                          buffer,
00105                          sizeof (ACE_HOSTENT_DATA),
00106                          &result,
00107                          h_errnop) == 0)
00108     return result;
00109   else
00110     return (struct hostent *) 0;
00111 #   else
00112 #     if defined(ACE_LACKS_NETDB_REENTRANT_FUNCTIONS)
00113   ACE_UNUSED_ARG (result);
00114   ACE_UNUSED_ARG (h_errnop);
00115   ACE_NETDBCALL_RETURN (::gethostbyaddr (addr, (ACE_SOCKET_LEN) length, type),
00116                         struct hostent *, 0,
00117                         buffer, sizeof (ACE_HOSTENT_DATA));
00118 #     else
00119   ACE_SOCKCALL_RETURN (::gethostbyaddr_r (addr, length, type, result,
00120                                           buffer, sizeof (ACE_HOSTENT_DATA),
00121                                           h_errnop),
00122                        struct hostent *, 0);
00123 #     endif /* ACE_LACKS_NETDB_REENTRANT_FUNCTIONS */
00124 #   endif /* defined (AIX) || defined (DIGITAL_UNIX) */
00125 # elif defined (ACE_HAS_NONCONST_GETBY)
00126   ACE_UNUSED_ARG (result);
00127   ACE_UNUSED_ARG (buffer);
00128   ACE_UNUSED_ARG (h_errnop);
00129   ACE_SOCKCALL_RETURN (::gethostbyaddr (const_cast<char *> (addr),
00130                                         (ACE_SOCKET_LEN) length,
00131                                         type),
00132                        struct hostent *,
00133                        0);
00134 # else
00135   ACE_UNUSED_ARG (h_errnop);
00136   ACE_UNUSED_ARG (buffer);
00137   ACE_UNUSED_ARG (result);
00138 
00139   ACE_SOCKCALL_RETURN (::gethostbyaddr (addr,
00140                                         (ACE_SOCKET_LEN) length,
00141                                         type),
00142                        struct hostent *,
00143                        0);
00144 # endif /* defined (ACE_HAS_REENTRANT_FUNCTIONS) && !defined (UNIXWARE) */
00145 }

ACE_INLINE struct hostent * ACE_OS::gethostbyname const char *  name  ) 
 

Definition at line 152 of file OS_NS_netdb.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_SOCKCALL_RETURN, and gethostbyname().

Referenced by ACE::get_bcast_addr(), gethostbyname(), gethostbyname_r(), getipnodebyname(), getmacaddress(), ACE_SOCK_Dgram_Bcast::mk_broadcast(), and ACE_INET_Addr::set().

00153 {
00154   ACE_OS_TRACE ("ACE_OS::gethostbyname");
00155 # if defined (ACE_LACKS_GETHOSTBYNAME)
00156   ACE_UNUSED_ARG (name);
00157   ACE_NOTSUP_RETURN (0);
00158 # elif defined (ACE_HAS_NONCONST_GETBY)
00159   ACE_SOCKCALL_RETURN (::gethostbyname (const_cast<char *> (name)),
00160                        struct hostent *,
00161                        0);
00162 # else
00163   ACE_SOCKCALL_RETURN (::gethostbyname (name),
00164                        struct hostent *,
00165                        0);
00166 # endif /* ACE_HAS_NONCONST_GETBY */
00167 }

ACE_INLINE struct hostent * ACE_OS::gethostbyname_r const char *  name,
struct hostent *  result,
ACE_HOSTENT_DATA  buffer,
int *  h_errnop
 

Definition at line 174 of file OS_NS_netdb.inl.

References ACE_HOSTENT_DATA, ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_SOCKCALL_RETURN, gethostbyname(), gethostbyname_r(), and memset().

Referenced by gethostbyname_r(), and ACE_INET_Addr::set().

00178 {
00179   ACE_OS_TRACE ("ACE_OS::gethostbyname_r");
00180 #if defined (ACE_LACKS_GETHOSTBYNAME)
00181   ACE_UNUSED_ARG (name);
00182   ACE_UNUSED_ARG (result);
00183   ACE_UNUSED_ARG (buffer);
00184   ACE_UNUSED_ARG (h_errnop);
00185   ACE_NOTSUP_RETURN (0);
00186 # elif defined (ACE_HAS_REENTRANT_FUNCTIONS) && !defined (UNIXWARE)
00187 #   if defined (DIGITAL_UNIX) || \
00188        (defined (ACE_AIX_MINOR_VERS) && (ACE_AIX_MINOR_VERS > 2))
00189   ACE_UNUSED_ARG (result);
00190   ACE_UNUSED_ARG (buffer);
00191   ACE_UNUSED_ARG (h_errnop);
00192 
00193   // gethostbyname returns thread-specific storage on Digital Unix and
00194   // AIX 4.3
00195   ACE_SOCKCALL_RETURN (::gethostbyname (name), struct hostent *, 0);
00196 #   elif defined (AIX)
00197   ACE_OS::memset (buffer, 0, sizeof (ACE_HOSTENT_DATA));
00198 
00199   if (::gethostbyname_r (name, result, (struct hostent_data *) buffer) == 0)
00200     return result;
00201   else
00202     {
00203       *h_errnop = h_errno;
00204       return (struct hostent *) 0;
00205     }
00206 # elif defined (__GLIBC__)
00207   // GNU C library has a different signature
00208   ACE_OS::memset (buffer, 0, sizeof (ACE_HOSTENT_DATA));
00209 
00210   if (::gethostbyname_r (name,
00211                          result,
00212                          buffer,
00213                          sizeof (ACE_HOSTENT_DATA),
00214                          &result,
00215                          h_errnop) == 0)
00216     return result;
00217   else
00218     return (struct hostent *) 0;
00219 #   else
00220 #     if defined(ACE_LACKS_NETDB_REENTRANT_FUNCTIONS)
00221   ACE_UNUSED_ARG (result);
00222   ACE_UNUSED_ARG (h_errnop);
00223   ACE_NETDBCALL_RETURN (::gethostbyname (name),
00224                         struct hostent *, 0,
00225                         buffer, sizeof (ACE_HOSTENT_DATA));
00226 #     else
00227   ACE_SOCKCALL_RETURN (::gethostbyname_r (name, result, buffer,
00228                                           sizeof (ACE_HOSTENT_DATA),
00229                                           h_errnop),
00230                        struct hostent *,
00231                        0);
00232 #     endif /* ACE_LACKS_NETDB_REENTRANT_FUNCTIONS */
00233 #   endif /* defined (AIX) || defined (DIGITAL_UNIX) */
00234 # elif defined (ACE_HAS_NONCONST_GETBY)
00235   ACE_UNUSED_ARG (result);
00236   ACE_UNUSED_ARG (buffer);
00237   ACE_UNUSED_ARG (h_errnop);
00238   ACE_SOCKCALL_RETURN (::gethostbyname (const_cast<char *> (name)),
00239                        struct hostent *,
00240                        0);
00241 # else
00242   ACE_UNUSED_ARG (result);
00243   ACE_UNUSED_ARG (buffer);
00244   ACE_UNUSED_ARG (h_errnop);
00245 
00246   ACE_SOCKCALL_RETURN (::gethostbyname (name),
00247                        struct hostent *,
00248                        0);
00249 # endif /* defined (ACE_HAS_REENTRANT_FUNCTIONS) && !defined (UNIXWARE) */
00250 }

ACE_INLINE ACE_hrtime_t ACE_OS::gethrtime const  ACE_HRTimer_Op = ACE_HRTIMER_GETTIME  ) 
 

Definition at line 206 of file OS_NS_time.inl.

References ACE_GETHRTIME_NAME, ACE_hrtime_t, ACE_ONE_SECOND_IN_NSECS, ACE_OS_TRACE, ACE_UINT64, clock_gettime(), CLOCK_REALTIME, gettimeofday(), memcpy(), ACE_Time_Value::sec(), timespec::tv_nsec, timespec::tv_sec, and ACE_Time_Value::usec().

Referenced by ACE_High_Res_Timer::calibrate(), ACE_High_Res_Timer::gettime(), ACE_Metrics_Cache< ACE_LOCK, ALLOCATOR >::report_dequeue_start(), ACE_Metrics_Cache< ACE_LOCK, ALLOCATOR >::report_dequeue_stop(), ACE_Metrics_Cache< ACE_LOCK, ALLOCATOR >::report_enqueue_start(), ACE_Metrics_Cache< ACE_LOCK, ALLOCATOR >::report_enqueue_stop(), and ACE_Timeprobe_Ex< ACE_LOCK, ALLOCATOR >::timeprobe().

00207 {
00208   ACE_OS_TRACE ("ACE_OS::gethrtime");
00209 #if defined (ACE_HAS_HI_RES_TIMER)
00210   ACE_UNUSED_ARG (op);
00211   return ::gethrtime ();
00212 #elif defined (ACE_HAS_AIX_HI_RES_TIMER)
00213   ACE_UNUSED_ARG (op);
00214   timebasestruct_t tb;
00215 
00216   ::read_real_time(&tb, TIMEBASE_SZ);
00217   ::time_base_to_time(&tb, TIMEBASE_SZ);
00218 
00219   return ACE_hrtime_t(tb.tb_high) * ACE_ONE_SECOND_IN_NSECS + tb.tb_low;
00220 #elif defined (ghs) && defined (ACE_HAS_PENTIUM) && !defined (ACE_WIN32)
00221   ACE_UNUSED_ARG (op);
00222   // Use .obj/gethrtime.o, which was compiled with g++.
00223   return ACE_GETHRTIME_NAME ();
00224 #elif (defined(__KCC) || defined (__GNUG__) || defined (__INTEL_COMPILER)) && !defined (ACE_WIN32) && !defined(ACE_VXWORKS) && defined (ACE_HAS_PENTIUM)
00225   ACE_UNUSED_ARG (op);
00226 # if defined (ACE_LACKS_LONGLONG_T)
00227   double now;
00228 # else  /* ! ACE_LACKS_LONGLONG_T */
00229   ACE_hrtime_t now;
00230 # endif /* ! ACE_LACKS_LONGLONG_T */
00231 
00232   // See comments about the RDTSC Pentium instruction for the ACE_WIN32
00233   // version of ACE_OS::gethrtime (), below.
00234   //
00235   // Read the high-res tick counter directly into memory variable "now".
00236   // The A constraint signifies a 64-bit int.
00237   asm volatile ("rdtsc" : "=A" (now) : : "memory");
00238 
00239 # if defined (ACE_LACKS_LONGLONG_T)
00240   ACE_UINT32 least, most;
00241   ACE_OS::memcpy (&least, &now, sizeof (ACE_UINT32));
00242   ACE_OS::memcpy (&most, (u_char *) &now + sizeof (ACE_UINT32),
00243                   sizeof (ACE_UINT32));
00244 
00245   ACE_hrtime_t ret (least, most);
00246   return ret;
00247 # else  /* ! ACE_LACKS_LONGLONG_T */
00248   return now;
00249 # endif /* ! ACE_LACKS_LONGLONG_T */
00250 #elif defined (linux) && defined (ACE_HAS_ALPHA_TIMER)
00251   // NOTE:  alphas only have a 32 bit tick (cycle) counter.  The rpcc
00252   // instruction actually reads 64 bits, but the high 32 bits are
00253   // implementation-specific.  Linux and Digital Unix, for example,
00254   // use them for virtual tick counts, i.e., taking into account only
00255   // the time that the process was running.  This information is from
00256   // David Mosberger's article, see comment below.
00257   ACE_UINT32 now;
00258 
00259   // The following statement is based on code published by:
00260   // Mosberger, David, "How to Make Your Applications Fly, Part 1",
00261   // Linux Journal Issue 42, October 1997, page 50.  It reads the
00262   // high-res tick counter directly into the memory variable.
00263   asm volatile ("rpcc %0" : "=r" (now) : : "memory");
00264 
00265   return now;
00266 #elif defined (ACE_WIN32)
00267   ACE_UNUSED_ARG(op);
00268   LARGE_INTEGER freq;
00269 
00270   ::QueryPerformanceCounter (&freq);
00271 
00272 #  if defined (ACE_LACKS_LONGLONG_T)
00273   ACE_UINT64 uint64_freq (freq.u.LowPart,
00274                           static_cast<unsigned int> (freq.u.HighPart));
00275   return uint64_freq;
00276 #  else
00277   return freq.QuadPart;
00278 #  endif //ACE_LACKS_LONGLONG_T
00279 
00280 #elif defined (ACE_HAS_POWERPC_TIMER) && (defined (ghs) || defined (__GNUG__))
00281   // PowerPC w/ GreenHills or g++.
00282 
00283   ACE_UNUSED_ARG (op);
00284   u_long most;
00285   u_long least;
00286 
00287 #if defined (ghs)
00288   ACE_OS::readPPCTimeBase (most, least);
00289 #else
00290   u_long scratch;
00291 
00292   do {
00293     asm volatile ("mftbu %0\n"
00294           "mftb  %1\n"
00295           "mftbu %2"
00296           : "=r" (most), "=r" (least), "=r" (scratch));
00297   } while (most != scratch);
00298 #endif
00299 
00300 #if defined (ACE_LACKS_LONGLONG_T)
00301   return ACE_U_LongLong (least, most);
00302 #else  /* ! ACE_LACKS_LONGLONG_T */
00303   return 0x100000000llu * most  +  least;
00304 #endif /* ! ACE_LACKS_LONGLONG_T */
00305 
00306 #elif defined (ACE_HAS_CLOCK_GETTIME)
00307   // e.g., VxWorks (besides POWERPC && GreenHills) . . .
00308   ACE_UNUSED_ARG (op);
00309   struct timespec ts;
00310 
00311   ACE_OS::clock_gettime (
00312 #if defined (ACE_HAS_CLOCK_GETTIME_MONOTONIC)
00313          CLOCK_MONOTONIC,
00314 #endif /* !ACE_HAS_CLOCK_GETTIME_MONOTONIC */
00315          CLOCK_REALTIME,
00316          &ts);
00317 
00318   // Carefully create the return value to avoid arithmetic overflow
00319   // if ACE_hrtime_t is ACE_U_LongLong.
00320   return static_cast<ACE_hrtime_t> (ts.tv_sec) *
00321     ACE_U_ONE_SECOND_IN_NSECS  +  static_cast<ACE_hrtime_t> (ts.tv_nsec);
00322 #else
00323   ACE_UNUSED_ARG (op);
00324   const ACE_Time_Value now = ACE_OS::gettimeofday ();
00325 
00326   // Carefully create the return value to avoid arithmetic overflow
00327   // if ACE_hrtime_t is ACE_U_LongLong.
00328   return (static_cast<ACE_hrtime_t> (now.sec ()) * (ACE_UINT32) 1000000  +
00329           static_cast<ACE_hrtime_t> (now.usec ())) * (ACE_UINT32) 1000;
00330 #endif /* ACE_HAS_HI_RES_TIMER */
00331 }

ACE_INLINE struct hostent * ACE_OS::getipnodebyaddr const void *  src,
size_t  len,
int  family
 

Definition at line 255 of file OS_NS_netdb.inl.

References ACE_NOTSUP_RETURN, and gethostbyaddr().

00256 {
00257 #if defined (ACE_HAS_IPV6) && !defined (ACE_WIN32)
00258 #  if defined (ACE_LACKS_GETIPNODEBYADDR)
00259   ACE_UNUSED_ARG (src);
00260   ACE_UNUSED_ARG (len);
00261   ACE_UNUSED_ARG (family);
00262   ACE_NOTSUP_RETURN (0);
00263 #  else
00264   struct hostent *hptr;
00265   int errnum;
00266   if ((hptr = ::getipnodebyaddr (src, len, family, &errnum)) == 0)
00267     {
00268       errno = errnum;
00269     }
00270   return hptr;
00271 #  endif /* ACE_LACKS_GETIPNODEBYADDR */
00272 #else
00273   // IPv4-only implementation
00274   if (family == AF_INET)
00275     return ACE_OS::gethostbyaddr (static_cast<const char *> (src),
00276                                   static_cast<int> (len),
00277                                   family);
00278 
00279   ACE_NOTSUP_RETURN (0);
00280 # endif /* defined (ACE_HAS_IPV6) && !defined (ACE_WIN32) */
00281 }

ACE_INLINE struct hostent * ACE_OS::getipnodebyname const char *  name,
int  family,
int  flags = 0
 

Definition at line 284 of file OS_NS_netdb.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_SOCKCALL_RETURN, and gethostbyname().

00285 {
00286   ACE_OS_TRACE ("ACE_OS::getipnodebyname");
00287 # if defined (ACE_HAS_IPV6) && !defined (ACE_WIN32)
00288 #   if defined (ACE_LACKS_GETIPNODEBYNAME)
00289   ACE_UNUSED_ARG (flags);
00290 #     if defined (ACE_HAS_NONCONST_GETBY)
00291   ACE_SOCKCALL_RETURN (::gethostbyname2 (const_cast<char *> (name),
00292                                          family),
00293                        struct hostent *, 0);
00294 #     else
00295   ACE_SOCKCALL_RETURN (::gethostbyname2 (name, family),
00296                        struct hostent *, 0);
00297 #     endif /* ACE_HAS_NONCONST_GETBY */
00298 #   else
00299   struct hostent *hptr;
00300   int errnum;
00301   if ((hptr = ::getipnodebyname (name, family, flags, &errnum)) == 0)
00302     {
00303       errno = errnum;
00304     }
00305   return hptr;
00306 #   endif /* ACE_LACKS_GETIPNODEBYNAME */
00307 # else
00308   // IPv4-only implementation
00309   ACE_UNUSED_ARG (flags);
00310   if (family == AF_INET)
00311     return ACE_OS::gethostbyname (name);
00312 
00313   ACE_NOTSUP_RETURN (0);
00314 # endif /* defined (ACE_HAS_IPV6) && !defined (ACE_WIN32) */
00315 }

ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_END_VERSIONED_NAMESPACE_DECL ACE_BEGIN_VERSIONED_NAMESPACE_DECL int ACE_OS::getmacaddress struct macaddr_node_t *  node  ) 
 

Definition at line 213 of file OS_NS_netdb.cpp.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_TCHAR, close(), gethostbyname(), hostname(), ioctl(), MAXHOSTNAMELEN, memcpy(), memset(), ACE_OS::macaddr_node_t::node, socket(), sprintf(), and strcpy().

Referenced by ACE_Utils::UUID_Generator::init().

00214 {
00215   ACE_OS_TRACE ("ACE_OS::getmacaddress");
00216 
00217 #if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)
00218 # if !defined (ACE_HAS_PHARLAP)
00219     /** Define a structure for use with the netbios routine */
00220     struct ADAPTERSTAT
00221     {
00222       ADAPTER_STATUS adapt;
00223       NAME_BUFFER    NameBuff [30];
00224     };
00225 
00226     NCB         ncb;
00227     LANA_ENUM   lenum;
00228     unsigned char result;
00229 
00230     ACE_OS::memset (&ncb, 0, sizeof(ncb));
00231     ncb.ncb_command = NCBENUM;
00232     ncb.ncb_buffer  = reinterpret_cast<unsigned char*> (&lenum);
00233     ncb.ncb_length  = sizeof(lenum);
00234 
00235     result = Netbios (&ncb);
00236 
00237     for(int i = 0; i < lenum.length; i++)
00238       {
00239         ACE_OS::memset (&ncb, 0, sizeof(ncb));
00240         ncb.ncb_command  = NCBRESET;
00241         ncb.ncb_lana_num = lenum.lana [i];
00242 
00243         /** Reset the netbios */
00244         result = Netbios (&ncb);
00245 
00246         if (ncb.ncb_retcode != NRC_GOODRET)
00247         {
00248           return -1;
00249         }
00250 
00251         ADAPTERSTAT adapter;
00252         ACE_OS::memset (&ncb, 0, sizeof (ncb));
00253         ACE_OS::strcpy (reinterpret_cast<char*> (ncb.ncb_callname), "*");
00254         ncb.ncb_command     = NCBASTAT;
00255         ncb.ncb_lana_num    = lenum.lana[i];
00256         ncb.ncb_buffer      = reinterpret_cast<unsigned char*> (&adapter);
00257         ncb.ncb_length      = sizeof (adapter);
00258 
00259         result = Netbios (&ncb);
00260 
00261         if (result == 0)
00262         {
00263           ACE_OS::memcpy (node->node,
00264               adapter.adapt.adapter_address,
00265               6);
00266           return 0;
00267         }
00268       }
00269     return 0;
00270 # else
00271 #   if defined (ACE_HAS_PHARLAP_RT)
00272       DEVHANDLE ip_dev = (DEVHANDLE)0;
00273       EK_TCPIPCFG *devp;
00274       size_t i;
00275       ACE_TCHAR dev_name[16];
00276 
00277       for (i = 0; i < 10; i++)
00278         {
00279           // Ethernet.
00280           ACE_OS::sprintf (dev_name,
00281                            "ether%d",
00282                            i);
00283           ip_dev = EtsTCPGetDeviceHandle (dev_name);
00284           if (ip_dev != 0)
00285             break;
00286         }
00287       if (ip_dev == 0)
00288         return -1;
00289       devp = EtsTCPGetDeviceCfg (ip_dev);
00290       if (devp == 0)
00291         return -1;
00292       ACE_OS::memcpy (node->node,
00293             &devp->EthernetAddress[0],
00294             6);
00295       return 0;
00296 #   else
00297       ACE_UNUSED_ARG (node);
00298       ACE_NOTSUP_RETURN (-1);
00299 #   endif /* ACE_HAS_PHARLAP_RT */
00300 # endif /* ACE_HAS_PHARLAP */
00301 #elif defined (sun)
00302 
00303   /** obtain the local host name */
00304   char hostname [MAXHOSTNAMELEN];
00305   ACE_OS::hostname (hostname, sizeof (hostname));
00306 
00307   /** Get the hostent to use with ioctl */
00308   struct hostent *phost =
00309     ACE_OS::gethostbyname (hostname);
00310 
00311   if (phost == 0)
00312     return -1;
00313 
00314   ACE_HANDLE handle =
00315     ACE_OS::socket (PF_INET, SOCK_DGRAM, IPPROTO_UDP);
00316 
00317   if (handle == ACE_INVALID_HANDLE)
00318     return -1;
00319 
00320   char **paddrs = phost->h_addr_list;
00321 
00322   struct arpreq ar;
00323 
00324   struct sockaddr_in *psa =
00325     (struct sockaddr_in *)&(ar.arp_pa);
00326 
00327   ACE_OS::memset (&ar,
00328                   0,
00329                   sizeof (struct arpreq));
00330 
00331   psa->sin_family = AF_INET;
00332 
00333   ACE_OS::memcpy (&(psa->sin_addr),
00334                   *paddrs,
00335                   sizeof (struct in_addr));
00336 
00337   if (ACE_OS::ioctl (handle,
00338                      SIOCGARP,
00339                      &ar) == -1)
00340     {
00341       ACE_OS::close (handle);
00342       return -1;
00343     }
00344 
00345   ACE_OS::close (handle);
00346 
00347   ACE_OS::memcpy (node->node,
00348                   ar.arp_ha.sa_data,
00349                   6);
00350 
00351   return 0;
00352 
00353 #elif defined (linux)
00354 
00355   struct ifreq ifr;
00356 
00357   ACE_HANDLE handle =
00358     ACE_OS::socket (PF_INET, SOCK_DGRAM, 0);
00359 
00360   if (handle == ACE_INVALID_HANDLE)
00361     return -1;
00362 
00363   ACE_OS::strcpy (ifr.ifr_name, "eth0");
00364 
00365   if (ACE_OS::ioctl (handle/*s*/, SIOCGIFHWADDR, &ifr) < 0)
00366     {
00367       ACE_OS::close (handle);
00368       return -1;
00369     }
00370 
00371   struct sockaddr* sa =
00372     (struct sockaddr *) &ifr.ifr_addr;
00373 
00374   ACE_OS::close (handle);
00375 
00376   ACE_OS::memcpy (node->node,
00377                   sa->sa_data,
00378                   6);
00379 
00380   return 0;
00381 
00382 #else
00383   ACE_UNUSED_ARG (node);
00384   ACE_NOTSUP_RETURN (-1);
00385 #endif
00386 }

ACE_INLINE int ACE_OS::getmsg ACE_HANDLE  handle,
struct strbuf ctl,
struct strbuf data,
int *  flags
 

Definition at line 39 of file OS_NS_stropts.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and getmsg().

Referenced by getmsg(), ACE_SPIPE_Stream::recv(), and ACE_FIFO_Recv_Msg::recv().

00043 {
00044   ACE_OS_TRACE ("ACE_OS::getmsg");
00045 #if defined (ACE_HAS_STREAM_PIPES)
00046   ACE_OSCALL_RETURN (::getmsg (handle, ctl, data, flags), int, -1);
00047 #else
00048   ACE_UNUSED_ARG (handle);
00049   ACE_UNUSED_ARG (ctl);
00050   ACE_UNUSED_ARG (data);
00051   ACE_UNUSED_ARG (flags);
00052 
00053   // I'm not sure how to implement this correctly.
00054   ACE_NOTSUP_RETURN (-1);
00055 #endif /* ACE_HAS_STREAM_PIPES */
00056 }

ACE_INLINE int ACE_OS::getopt int  argc,
char *const *  argv,
const char *  optstring
 

Definition at line 434 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and getopt().

Referenced by getopt().

00435 {
00436   ACE_OS_TRACE ("ACE_OS::getopt");
00437 #if defined (ACE_LACKS_GETOPT)
00438   ACE_UNUSED_ARG (argc);
00439   ACE_UNUSED_ARG (argv);
00440   ACE_UNUSED_ARG (optstring);
00441   ACE_NOTSUP_RETURN (-1);
00442 # else
00443   ACE_OSCALL_RETURN (::getopt (argc, argv, optstring), int, -1);
00444 # endif /* ACE_LACKS_GETOPT */
00445 }

ACE_INLINE long ACE_OS::getpagesize void   ) 
 

Definition at line 91 of file OS_NS_unistd.inl.

References ACE_OS_TRACE.

Referenced by allocation_granularity(), ACE_WIN32_Asynch_Write_File_Result::complete(), ACE_WIN32_Asynch_Read_File_Result::complete(), ACE_WIN32_Asynch_Read_File::readv(), ACE::round_to_pagesize(), and ACE_WIN32_Asynch_Write_File::writev().

00092 {
00093   ACE_OS_TRACE ("ACE_OS::getpagesize");
00094 #if defined (ACE_WIN32) && !defined (ACE_HAS_PHARLAP)
00095   SYSTEM_INFO sys_info;
00096   ::GetSystemInfo (&sys_info);
00097   return (long) sys_info.dwPageSize;
00098 #elif defined (_SC_PAGESIZE)
00099   return ::sysconf (_SC_PAGESIZE);
00100 #elif defined (ACE_HAS_GETPAGESIZE)
00101   return ::getpagesize ();
00102 #else
00103   // Use the default set in config.h
00104   return ACE_PAGE_SIZE;
00105 #endif /* ACE_WIN32 */
00106 }

ACE_INLINE int ACE_OS::getpeername ACE_HANDLE  handle,
struct sockaddr *  addr,
int *  addrlen
 

BSD-style (no QoS).

Definition at line 146 of file OS_NS_sys_socket.inl.

References ACE_OS_TRACE, ACE_SOCKCALL, ACE_SOCKCALL_RETURN, ACE_SOCKET_LEN, getpeername(), and memset().

Referenced by ACE_SOCK_SEQPACK_Connector::complete(), ACE_SOCK_Connector::complete(), ACE_ATM_Stream::get_peer_name(), ACE_SOCK::get_remote_addr(), ACE_SOCK_SEQPACK_Association::get_remote_addrs(), getpeername(), and ACE_Asynch_Connector< HANDLER >::parse_address().

00148 {
00149   ACE_OS_TRACE ("ACE_OS::getpeername");
00150 
00151 #if defined (ACE_GETNAME_RETURNS_RANDOM_SIN_ZERO) \
00152          && (ACE_GETNAME_RETURNS_RANDOM_SIN_ZERO == 1)
00153   int result;
00154   ACE_SOCKCALL (::getpeername ((ACE_SOCKET) handle,
00155                                addr,
00156                                (ACE_SOCKET_LEN *) addrlen),
00157                int,
00158                 -1,
00159                 result);
00160 
00161   // Some platforms, like older versions of the Linux kernel, do not
00162   // initialize the sin_zero field since that field is generally only
00163   // used for padding/alignment purposes.  On those platforms
00164   // memcmp()-based comparisons of the sockaddr_in structure, such as
00165   // the one in the ACE_INET_Addr equality operator, may fail due to
00166   // random bytes in the sin_zero field even though that field is
00167   // unused.  Prevent equality comparison of two different sockaddr_in
00168   // instances that refer to the same socket from failing by
00169   // explicitly initializing the sockaddr_in::sin_zero field to a
00170   // consistent value, e.g. zero.
00171   if (result != -1 && addr->sa_family == AF_INET)
00172     {
00173       ACE_OS::memset (reinterpret_cast<struct sockaddr_in *> (addr)->sin_zero,
00174                       0,
00175                       sizeof (reinterpret_cast<struct sockaddr_in *> (addr)->sin_zero));
00176     }
00177 
00178   return result;
00179 #else
00180   ACE_SOCKCALL_RETURN (::getpeername ((ACE_SOCKET) handle,
00181                                       addr,
00182                                       (ACE_SOCKET_LEN *) addrlen),
00183                        int,
00184                        -1);
00185 #endif /* ACE_GETNAME_RETURNS_RANDOM_SIN_ZERO */
00186 }

ACE_INLINE pid_t ACE_OS::getpgid pid_t  pid  ) 
 

Definition at line 448 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, getpgid(), and pid_t.

Referenced by getpgid().

00449 {
00450   ACE_OS_TRACE ("ACE_OS::getpgid");
00451 #if defined (ACE_LACKS_GETPGID)
00452   ACE_UNUSED_ARG (pid);
00453   ACE_NOTSUP_RETURN (-1);
00454 #elif defined (linux) && __GLIBC__ > 1 && __GLIBC_MINOR__ >= 0
00455   // getpgid() is from SVR4, which appears to be the reason why GLIBC
00456   // doesn't enable its prototype by default.
00457   // Rather than create our own extern prototype, just use the one
00458   // that is visible (ugh).
00459   ACE_OSCALL_RETURN (::__getpgid (pid), pid_t, -1);
00460 #else
00461   ACE_OSCALL_RETURN (::getpgid (pid), pid_t, -1);
00462 #endif /* ACE_LACKS_GETPGID */
00463 }

ACE_INLINE pid_t ACE_OS::getpid void   ) 
 

Definition at line 466 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN.

Referenced by ACE_IPC_SAP::enable(), ACE_IO_SAP::enable(), ACE_Log_Msg::getpid(), ACE_SPIPE_Stream::recv_handle(), and ACE_Log_Msg::sync().

00467 {
00468   // ACE_OS_TRACE ("ACE_OS::getpid");
00469 #if defined (ACE_LACKS_GETPID)
00470   ACE_NOTSUP_RETURN (-1);
00471 #elif defined (ACE_WIN32)
00472   return ::GetCurrentProcessId ();
00473 #else
00474   ACE_OSCALL_RETURN (::getpid (), int, -1);
00475 #endif /* ACE_LACKS_GETPID */
00476 }

ACE_INLINE int ACE_OS::getpmsg ACE_HANDLE  handle,
struct strbuf ctl,
struct strbuf data,
int *  band,
int *  flags
 

Definition at line 59 of file OS_NS_stropts.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and getpmsg().

Referenced by getpmsg(), and ACE_SPIPE_Stream::recv().

00064 {
00065   ACE_OS_TRACE ("ACE_OS::getpmsg");
00066 #if defined (ACE_HAS_STREAM_PIPES)
00067   ACE_OSCALL_RETURN (::getpmsg (handle, ctl, data, band, flags), int, -1);
00068 #else
00069   ACE_UNUSED_ARG (handle);
00070   ACE_UNUSED_ARG (ctl);
00071   ACE_UNUSED_ARG (data);
00072   ACE_UNUSED_ARG (band);
00073   ACE_UNUSED_ARG (flags);
00074 
00075   // I'm not sure how to implement this correctly.
00076   ACE_NOTSUP_RETURN (-1);
00077 #endif /* ACE_HAS_STREAM_PIPES */
00078 }

ACE_INLINE pid_t ACE_OS::getppid void   ) 
 

Definition at line 479 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, getppid(), and pid_t.

Referenced by getppid().

00480 {
00481   ACE_OS_TRACE ("ACE_OS::getppid");
00482 #if defined (ACE_LACKS_GETPPID)
00483   ACE_NOTSUP_RETURN (-1);
00484 #else
00485   ACE_OSCALL_RETURN (::getppid (), pid_t, -1);
00486 #endif /* ACE_LACKS_GETPPID */
00487 }

ACE_INLINE struct protoent * ACE_OS::getprotobyname const char *  name  ) 
 

Definition at line 318 of file OS_NS_netdb.inl.

References ACE_NOTSUP_RETURN, ACE_SOCKCALL_RETURN, and getprotobyname().

Referenced by getprotobyname(), and getprotobyname_r().

00319 {
00320 #if defined (ACE_LACKS_GETPROTOBYNAME)
00321   ACE_UNUSED_ARG (name);
00322   ACE_NOTSUP_RETURN (0);
00323 #elif defined (ACE_HAS_NONCONST_GETBY)
00324   ACE_SOCKCALL_RETURN (::getprotobyname (const_cast<char *> (name)),
00325                        struct protoent *,
00326                        0);
00327 #else
00328   ACE_SOCKCALL_RETURN (::getprotobyname (name),
00329                        struct protoent *,
00330                        0);
00331 #endif /* ACE_LACKS_GETPROTOBYNAME */
00332 }

ACE_INLINE struct protoent * ACE_OS::getprotobyname_r const char *  name,
struct protoent *  result,
ACE_PROTOENT_DATA  buffer
 

Definition at line 335 of file OS_NS_netdb.inl.

References ACE_NOTSUP_RETURN, ACE_PROTOENT_DATA, ACE_SOCKCALL_RETURN, getprotobyname(), and getprotobyname_r().

Referenced by getprotobyname_r().

00338 {
00339 #if defined (ACE_LACKS_GETPROTOBYNAME)
00340   ACE_UNUSED_ARG (name);
00341   ACE_UNUSED_ARG (result);
00342   ACE_UNUSED_ARG (buffer);
00343   ACE_NOTSUP_RETURN (0);
00344 #elif defined (ACE_HAS_REENTRANT_FUNCTIONS) && !defined (UNIXWARE)
00345 # if defined (AIX) || defined (DIGITAL_UNIX)
00346   if (::getprotobyname_r (name, result, (struct protoent_data *) buffer) == 0)
00347     return result;
00348   else
00349     return 0;
00350 # elif defined (__GLIBC__)
00351   // GNU C library has a different signature
00352   if (::getprotobyname_r (name,
00353                           result,
00354                           buffer,
00355                           sizeof (ACE_PROTOENT_DATA),
00356                           &result) == 0)
00357     return result;
00358   else
00359     return 0;
00360 # else
00361 #   if defined(ACE_LACKS_NETDB_REENTRANT_FUNCTIONS)
00362   ACE_UNUSED_ARG (result);
00363   ACE_NETDBCALL_RETURN (::getprotobyname (name),
00364                         struct protoent *, 0,
00365                         buffer, sizeof (ACE_PROTOENT_DATA));
00366 #   else
00367     ACE_SOCKCALL_RETURN (::getprotobyname_r (name,
00368                                              result,
00369                                              buffer,
00370                                              sizeof (ACE_PROTOENT_DATA)),
00371                        struct protoent *, 0);
00372 #   endif /* ACE_LACKS_NETDB_REENTRANT_FUNCTIONS */
00373 # endif /* defined (AIX) || defined (DIGITAL_UNIX) */
00374 #elif defined (ACE_HAS_NONCONST_GETBY)
00375   ACE_UNUSED_ARG (result);
00376   ACE_UNUSED_ARG (buffer);
00377   ACE_SOCKCALL_RETURN (::getprotobyname (const_cast<char *> (name)),
00378                        struct protoent *, 0);
00379 #else
00380   ACE_UNUSED_ARG (buffer);
00381   ACE_UNUSED_ARG (result);
00382 
00383   ACE_SOCKCALL_RETURN (::getprotobyname (name),
00384                        struct protoent *,
00385                        0);
00386 #endif /* defined (ACE_HAS_REENTRANT_FUNCTIONS) !defined (UNIXWARE) */
00387 }

ACE_INLINE struct protoent * ACE_OS::getprotobynumber int  proto  ) 
 

Definition at line 390 of file OS_NS_netdb.inl.

References ACE_NOTSUP_RETURN, ACE_SOCKCALL_RETURN, and getprotobynumber().

Referenced by getprotobynumber(), and getprotobynumber_r().

00391 {
00392 #if defined (ACE_LACKS_GETPROTOBYNUMBER)
00393   ACE_UNUSED_ARG (proto);
00394   ACE_NOTSUP_RETURN (0);
00395 #else
00396   ACE_SOCKCALL_RETURN (::getprotobynumber (proto),
00397                        struct protoent *, 0);
00398 #endif /* ACE_LACKS_GETPROTOBYNUMBER */
00399 }

ACE_INLINE struct protoent * ACE_OS::getprotobynumber_r int  proto,
struct protoent *  result,
ACE_PROTOENT_DATA  buffer
 

Definition at line 402 of file OS_NS_netdb.inl.

References ACE_NOTSUP_RETURN, ACE_PROTOENT_DATA, ACE_SOCKCALL_RETURN, getprotobynumber(), and getprotobynumber_r().

Referenced by getprotobynumber_r().

00405 {
00406 #if defined (ACE_LACKS_GETPROTOBYNUMBER)
00407   ACE_UNUSED_ARG (proto);
00408   ACE_UNUSED_ARG (result);
00409   ACE_UNUSED_ARG (buffer);
00410   ACE_NOTSUP_RETURN (0);
00411 #elif defined (ACE_HAS_REENTRANT_FUNCTIONS) && !defined (UNIXWARE)
00412 # if defined (AIX) || defined (DIGITAL_UNIX)
00413   if (::getprotobynumber_r (proto, result, (struct protoent_data *) buffer) == 0)
00414     return result;
00415   else
00416     return 0;
00417 # elif defined (__GLIBC__)
00418   // GNU C library has a different signature
00419   if (::getprotobynumber_r (proto,
00420                             result,
00421                             buffer,
00422                             sizeof (ACE_PROTOENT_DATA),
00423                             &result) == 0)
00424     return result;
00425   else
00426     return 0;
00427 # else
00428 #   if defined(ACE_LACKS_NETDB_REENTRANT_FUNCTIONS)
00429   ACE_UNUSED_ARG (result);
00430   ACE_NETDBCALL_RETURN (::getprotobynumber (proto),
00431                         struct protoent *, 0,
00432                         buffer, sizeof (ACE_PROTOENT_DATA));
00433 #   else
00434   ACE_SOCKCALL_RETURN (::getprotobynumber_r (proto, result, buffer, sizeof (ACE_PROTOENT_DATA)),
00435                        struct protoent *, 0);
00436 #   endif /* ACE_LACKS_NETDB_REENTRANT_FUNCTIONS */
00437 # endif /* defined (AIX) || defined (DIGITAL_UNIX) */
00438 #else
00439   ACE_UNUSED_ARG (buffer);
00440   ACE_UNUSED_ARG (result);
00441 
00442   ACE_SOCKCALL_RETURN (::getprotobynumber (proto),
00443                        struct protoent *, 0);
00444 #endif /* defined (ACE_HAS_REENTRANT_FUNCTIONS) && !defined (UNIXWARE) */
00445 }

ACE_INLINE struct passwd * ACE_OS::getpwent void   ) 
 

Definition at line 20 of file OS_NS_pwd.inl.

References ACE_NOTSUP_RETURN.

00021 {
00022 #if !defined (ACE_LACKS_PWD_FUNCTIONS)
00023   return ::getpwent ();
00024 #else
00025   ACE_NOTSUP_RETURN (0);
00026 #endif /* ! ACE_LACKS_PWD_FUNCTIONS */
00027 }

ACE_INLINE struct passwd * ACE_OS::getpwnam const char *  user  ) 
 

Definition at line 30 of file OS_NS_pwd.inl.

References ACE_NOTSUP_RETURN.

00031 {
00032 #if !defined (ACE_LACKS_PWD_FUNCTIONS)
00033   return ::getpwnam (name);
00034 # else
00035   ACE_UNUSED_ARG (name);
00036   ACE_NOTSUP_RETURN (0);
00037 #endif /* ACE_LACKS_PWD_FUNCTIONS */
00038 }

ACE_INLINE struct passwd * ACE_OS::getpwnam_r const char *  name,
struct passwd *  pwent,
char *  buffer,
int  buflen
 

Definition at line 41 of file OS_NS_pwd.inl.

References ACE_NOTSUP_RETURN.

00043 {
00044 #if defined (ACE_HAS_POSIX_GETPWNAM_R)
00045   struct passwd *result;
00046   int status;
00047 
00048   status = ::getpwnam_r (name, pwent, buffer, buflen, &result);
00049 
00050   if (status != 0)
00051   {
00052     errno = status;
00053     result = 0;
00054   }
00055   return result;
00056 #elif !defined (ACE_LACKS_PWD_FUNCTIONS)
00057 # if defined (ACE_HAS_REENTRANT_FUNCTIONS)
00058 #   if !defined (ACE_LACKS_PWD_REENTRANT_FUNCTIONS)
00059 #     if defined (ACE_HAS_PTHREADS_STD) && \
00060       !defined (ACE_HAS_STHREADS) || \
00061       defined (HPUX_11)  || \
00062       defined (__USLC__) // Added by Roland Gigler for SCO UnixWare 7.
00063   struct passwd *result;
00064   int status;
00065 #       if defined (DIGITAL_UNIX)
00066   ::_Pgetpwnam_r (name, pwent, buffer, buflen, &result);
00067 #       else
00068   // VAC++ doesn't correctly grok the ::getpwnam_r - the function is redefined
00069   // in pwd.h, and that redefinition is used here
00070 #         if defined (__IBMCPP__) && (__IBMCPP__ >= 400)   /* VAC++ 4 */
00071   status = _posix_getpwnam_r (name, pwent, buffer, buflen, &result);
00072 #         else
00073   status = ::getpwnam_r (name, pwent, buffer, buflen, &result);
00074 #         endif /* __IBMCPP__ && (__IBMCPP__ >= 400) */
00075   if (status != 0)
00076     {
00077       errno = status;
00078       result = 0;
00079     }
00080 #       endif /* (DIGITAL_UNIX) */
00081   return result;
00082 #     elif defined (AIX)
00083   if (::getpwnam_r (name, pwent, buffer, buflen) == -1)
00084     return 0;
00085   else
00086     return pwent;
00087 #     else
00088   return ::getpwnam_r (name, pwent, buffer, buflen);
00089 #     endif /* ACE_HAS_PTHREADS_STD */
00090 #   else
00091   ACE_UNUSED_ARG (name);
00092   ACE_UNUSED_ARG (pwent);
00093   ACE_UNUSED_ARG (buffer);
00094   ACE_UNUSED_ARG (buflen);
00095   ACE_NOTSUP_RETURN (0);
00096 #   endif /* ! ACE_LACKS_PWD_REENTRANT_FUNCTIONS */
00097 # else
00098   ACE_UNUSED_ARG (name);
00099   ACE_UNUSED_ARG (pwent);
00100   ACE_UNUSED_ARG (buffer);
00101   ACE_UNUSED_ARG (buflen);
00102   ACE_NOTSUP_RETURN (0);
00103 # endif /* ACE_HAS_REENTRANT_FUNCTIONS */
00104 #else
00105   ACE_UNUSED_ARG (name);
00106   ACE_UNUSED_ARG (pwent);
00107   ACE_UNUSED_ARG (buffer);
00108   ACE_UNUSED_ARG (buflen);
00109   ACE_NOTSUP_RETURN (0);
00110 #endif /* ACE_HAS_POSIX_GETPWNAM_R */
00111 }

ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE int ACE_OS::getrlimit int  resource,
struct rlimit *  rl
 

Definition at line 11 of file OS_NS_sys_resource.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and getrlimit().

Referenced by getrlimit(), ACE::max_handles(), and ACE::set_handle_limit().

00012 {
00013   ACE_OS_TRACE ("ACE_OS::getrlimit");
00014 
00015 #if defined (ACE_LACKS_RLIMIT)
00016   ACE_UNUSED_ARG (resource);
00017   ACE_UNUSED_ARG (rl);
00018 
00019   ACE_NOTSUP_RETURN (-1);
00020 #else
00021 # if defined (ACE_HAS_RLIMIT_RESOURCE_ENUM)
00022   ACE_OSCALL_RETURN (::getrlimit ((ACE_HAS_RLIMIT_RESOURCE_ENUM) resource, rl), int, -1);
00023 # else
00024   ACE_OSCALL_RETURN (::getrlimit (resource, rl), int, -1);
00025 # endif /* ACE_HAS_RLIMIT_RESOURCE_ENUM */
00026 #endif /* ACE_LACKS_RLIMIT */
00027 }

ACE_INLINE int ACE_OS::getrusage int  who,
struct rusage rusage
 

Definition at line 30 of file OS_NS_sys_resource.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, getrusage(), rusage::ru_stime, and rusage::ru_utime.

Referenced by getrusage(), ACE_Profile_Timer::start(), and ACE_Profile_Timer::stop().

00031 {
00032   ACE_OS_TRACE ("ACE_OS::getrusage");
00033 
00034 #if defined (ACE_HAS_SYSCALL_GETRUSAGE)
00035   // This nonsense is necessary for HP/UX...
00036   ACE_OSCALL_RETURN (::syscall (SYS_GETRUSAGE, who, ru), int, -1);
00037 #elif defined (ACE_HAS_GETRUSAGE)
00038 # if defined (ACE_WIN32)
00039   ACE_UNUSED_ARG (who);
00040 
00041   FILETIME dummy_1;
00042   FILETIME dummy_2;
00043   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::GetProcessTimes (::GetCurrentProcess(),
00044                                                              &dummy_1,   // start
00045                                                              &dummy_2,     // exited
00046                                                              &ru->ru_stime,
00047                                                              &ru->ru_utime),
00048                                           ace_result_),
00049                         int, -1);
00050 # else
00051 #   if defined (ACE_HAS_RUSAGE_WHO_ENUM)
00052   ACE_OSCALL_RETURN (::getrusage ((ACE_HAS_RUSAGE_WHO_ENUM) who, ru), int, -1);
00053 #   else
00054   ACE_OSCALL_RETURN (::getrusage (who, ru), int, -1);
00055 #   endif /* ACE_HAS_RUSAGE_WHO_ENUM */
00056 # endif /* ACE_WIN32 */
00057 #else
00058   ACE_UNUSED_ARG (who);
00059   ACE_UNUSED_ARG (ru);
00060   ACE_NOTSUP_RETURN (-1);
00061 #endif /* ACE_HAS_SYSCALL_GETRUSAGE */
00062 }

ACE_INLINE struct servent * ACE_OS::getservbyname const char *  svc,
const char *  proto
 

Definition at line 448 of file OS_NS_netdb.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_SOCKCALL_RETURN, and getservbyname().

Referenced by getservbyname(), and getservbyname_r().

00449 {
00450   ACE_OS_TRACE ("ACE_OS::getservbyname");
00451 #if defined (ACE_LACKS_GETSERVBYNAME)
00452   ACE_UNUSED_ARG (svc);
00453   ACE_UNUSED_ARG (proto);
00454   ACE_NOTSUP_RETURN (0);
00455 #elif defined (ACE_HAS_NONCONST_GETBY)
00456   ACE_SOCKCALL_RETURN (::getservbyname (const_cast<char *> (svc),
00457                                         const_cast<char *> (proto)),
00458                        struct servent *,
00459                        0);
00460 #else
00461   ACE_SOCKCALL_RETURN (::getservbyname (svc,
00462                                         proto),
00463                        struct servent *,
00464                        0);
00465 #endif /* ACE_HAS_NONCONST_GETBY */
00466 }

ACE_INLINE struct servent * ACE_OS::getservbyname_r const char *  svc,
const char *  proto,
struct servent *  result,
ACE_SERVENT_DATA  buf
 

Definition at line 469 of file OS_NS_netdb.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_SERVENT_DATA, ACE_SOCKCALL_RETURN, getservbyname(), getservbyname_r(), and memset().

Referenced by get_port_number_from_name(), and getservbyname_r().

00473 {
00474   ACE_OS_TRACE ("ACE_OS::getservbyname_r");
00475 #if defined (ACE_LACKS_GETSERVBYNAME)
00476   ACE_UNUSED_ARG (svc);
00477   ACE_UNUSED_ARG (proto);
00478   ACE_UNUSED_ARG (result);
00479   ACE_UNUSED_ARG (buf);
00480   ACE_NOTSUP_RETURN (0);
00481 #elif defined (ACE_HAS_REENTRANT_FUNCTIONS) && !defined (UNIXWARE)
00482 # if defined (AIX) || defined (DIGITAL_UNIX)
00483   ACE_OS::memset (buf, 0, sizeof (ACE_SERVENT_DATA));
00484 
00485   if (::getservbyname_r (svc, proto, result, (struct servent_data *) buf) == 0)
00486     return result;
00487   else
00488     return (struct servent *) 0;
00489 # elif defined (__GLIBC__)
00490   // GNU C library has a different signature
00491   ACE_OS::memset (buf, 0, sizeof (ACE_SERVENT_DATA));
00492 
00493   if (::getservbyname_r (svc,
00494                          proto,
00495                          result,
00496                          buf,
00497                          sizeof (ACE_SERVENT_DATA),
00498                          &result) == 0)
00499     return result;
00500   else
00501     return (struct servent *) 0;
00502 # else
00503 #   if defined(ACE_LACKS_NETDB_REENTRANT_FUNCTIONS)
00504   ACE_UNUSED_ARG (result);
00505   ACE_NETDBCALL_RETURN (::getservbyname (svc, proto),
00506                         struct servent *, 0,
00507                         buf, sizeof (ACE_SERVENT_DATA));
00508 #   else
00509   ACE_SOCKCALL_RETURN (::getservbyname_r (svc, proto, result, buf,
00510                                           sizeof (ACE_SERVENT_DATA)),
00511                        struct servent *, 0);
00512 #   endif /* ACE_LACKS_NETDB_REENTRANT_FUNCTIONS */
00513 # endif /* defined (AIX) || defined (DIGITAL_UNIX) */
00514 #elif defined (ACE_HAS_NONCONST_GETBY)
00515   ACE_UNUSED_ARG (buf);
00516   ACE_UNUSED_ARG (result);
00517   ACE_SOCKCALL_RETURN (::getservbyname (const_cast<char *> (svc),
00518                                         const_cast<char *> (proto)),
00519                        struct servent *,
00520                        0);
00521 #else
00522   ACE_UNUSED_ARG (buf);
00523   ACE_UNUSED_ARG (result);
00524 
00525   ACE_SOCKCALL_RETURN (::getservbyname (svc,
00526                                         proto),
00527                        struct servent *,
00528                        0);
00529 #endif /* defined (ACE_HAS_REENTRANT_FUNCTIONS) && !defined (UNIXWARE) */
00530 }

ACE_INLINE int ACE_OS::getsockname ACE_HANDLE  handle,
struct sockaddr *  addr,
int *  addrlen
 

BSD-style (no QoS).

Definition at line 189 of file OS_NS_sys_socket.inl.

References ACE_OS_TRACE, ACE_SOCKCALL, ACE_SOCKCALL_RETURN, ACE_SOCKET_LEN, getsockname(), and memset().

Referenced by ACE_SOCK::get_local_addr(), ACE_ATM_Acceptor::get_local_addr(), ACE_SOCK_SEQPACK_Association::get_local_addrs(), getsockname(), ACE_Asynch_Connector< HANDLER >::parse_address(), and ACE_SOCK_SEQPACK_Connector::shared_connect_start().

00192 {
00193   ACE_OS_TRACE ("ACE_OS::getsockname");
00194 #if defined (ACE_GETNAME_RETURNS_RANDOM_SIN_ZERO) \
00195          && (ACE_GETNAME_RETURNS_RANDOM_SIN_ZERO == 1)
00196   int result;
00197   ACE_SOCKCALL (::getsockname ((ACE_SOCKET) handle,
00198                                addr,
00199                                (ACE_SOCKET_LEN *) addrlen),
00200                int, -1, result);
00201 
00202   // Some platforms, like older versions of the Linux kernel, do not
00203   // initialize the sin_zero field since that field is generally only
00204   // used for padding/alignment purposes.  On those platforms
00205   // memcmp()-based comparisons of the sockaddr_in structure, such as
00206   // the one in the ACE_INET_Addr equality operator, may fail due to
00207   // random bytes in the sin_zero field even though that field is
00208   // unused.  Prevent equality comparison of two different sockaddr_in
00209   // instances that refer to the same socket from failing by
00210   // explicitly initializing the sockaddr_in::sin_zero field to a
00211   // consistent value, e.g. zero.
00212   if (result != -1 && addr->sa_family == AF_INET)
00213     {
00214       ACE_OS::memset (reinterpret_cast<struct sockaddr_in *> (addr)->sin_zero,
00215                       0,
00216                       sizeof (reinterpret_cast<struct sockaddr_in *> (addr)->sin_zero));
00217     }
00218 
00219   return result;
00220 #else
00221   ACE_SOCKCALL_RETURN (::getsockname ((ACE_SOCKET) handle,
00222                                       addr,
00223                                       (ACE_SOCKET_LEN *) addrlen),
00224                        int, -1);
00225 #endif /* ACE_GETNAME_RETURNS_RANDOM_SIN_ZERO */
00226 }

ACE_INLINE int ACE_OS::getsockopt ACE_HANDLE  handle,
int  level,
int  optname,
char *  optval,
int *  optlen
 

BSD-style (no QoS).

Definition at line 229 of file OS_NS_sys_socket.inl.

References ACE_OS_TRACE, ACE_SOCKCALL_RETURN, ACE_SOCKET_LEN, and getsockopt().

Referenced by ACE_SOCK::get_option(), ACE_ATM_Stream::get_vpi_vci(), getsockopt(), ACE_WIN32_Asynch_Connect::handle_output(), ACE_POSIX_Asynch_Connect::handle_output(), and ACE::handle_timed_complete().

00234 {
00235   ACE_OS_TRACE ("ACE_OS::getsockopt");
00236   ACE_SOCKCALL_RETURN (::getsockopt ((ACE_SOCKET) handle,
00237                                      level,
00238                                      optname,
00239                                      optval,
00240                                      (ACE_SOCKET_LEN *) optlen),
00241                        int,
00242                        -1);
00243 }

ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE ACE_Time_Value ACE_OS::gettimeofday void   ) 
 

Definition at line 25 of file OS_NS_sys_time.inl.

References ACE_Time_Value, CLOCK_REALTIME, timespec::tv_nsec, and timespec::tv_sec.

Referenced by ACE_Buffered_Svc_Handler<, >::ACE_Buffered_Svc_Handler(), ACE_Dev_Poll_Reactor::Token_Guard::acquire(), ACE_Dev_Poll_Reactor::Token_Guard::acquire_quietly(), ACE_TP_Token_Guard::acquire_read_token(), ACE_TP_Token_Guard::acquire_token(), ACE_High_Res_Timer::calibrate(), cond_timedwait(), ACE_SPIPE_Connector::connect(), ACE_Dynamic_Message_Queue<>::dequeue_head(), ACE_Dynamic_Message_Queue<>::enqueue_i(), event_timedwait(), ACE_Utils::UUID_Generator::get_systemtime(), gethrtime(), ACE_High_Res_Timer::gettime(), ACE_High_Res_Timer::gettimeofday(), ACE_POSIX_CB_Proactor::handle_events_i(), ACE_Buffered_Svc_Handler<, >::put(), ACE_Ping_Socket::receive_echo_reply(), ACE::recv(), ACE::recvfrom(), ACE::recvmsg(), ACE::recvv(), ACE_Dynamic_Message_Queue<>::remove_messages(), ACE_Async_Timer_Queue_Adapter< TQ >::schedule_ualarm(), sema_wait(), ACE::send(), ACE::sendmsg(), ACE::sendto(), ACE::sendv(), ACE_Countdown_Time::start(), ACE_Countdown_Time::stop(), ACE_Thread_Timer_Queue_Adapter< TQ >::svc(), time(), ACE::timestamp(), ACE_Thread_Manager::wait(), ACE_Process_Manager::wait(), and ACE_NT_Service::wait_for_service_state().

00026 {
00027   // ACE_OS_TRACE ("ACE_OS::gettimeofday");
00028 
00029 #if !defined (ACE_HAS_WINCE)&& !defined (ACE_WIN32)
00030   timeval tv;
00031   int result = 0;
00032 #endif // !defined (ACE_HAS_WINCE)&& !defined (ACE_WIN32)
00033 
00034 #if (0)
00035   struct timespec ts;
00036 
00037   ACE_OSCALL (ACE_OS::clock_gettime (CLOCK_REALTIME, &ts), int, -1, result);
00038   tv.tv_sec = ts.tv_sec;
00039   tv.tv_usec = ts.tv_nsec / 1000L;  // timespec has nsec, but timeval has usec
00040 
00041 #elif defined (ACE_HAS_WINCE)
00042   SYSTEMTIME tsys;
00043   FILETIME   tfile;
00044   ::GetSystemTime (&tsys);
00045   ::SystemTimeToFileTime (&tsys, &tfile);
00046   return ACE_Time_Value (tfile);
00047 #elif defined (ACE_WIN32)
00048   FILETIME   tfile;
00049   ::GetSystemTimeAsFileTime (&tfile);
00050   return ACE_Time_Value (tfile);
00051 #if 0
00052   // From Todd Montgomery...
00053   struct _timeb tb;
00054   ::_ftime (&tb);
00055   tv.tv_sec = tb.time;
00056   tv.tv_usec = 1000 * tb.millitm;
00057 #endif /* 0 */
00058 #elif defined (ACE_HAS_AIX_HI_RES_TIMER)
00059   timebasestruct_t tb;
00060 
00061   ::read_real_time (&tb, TIMEBASE_SZ);
00062   ::time_base_to_time (&tb, TIMEBASE_SZ);
00063 
00064   tv.tv_sec = tb.tb_high;
00065   tv.tv_usec = tb.tb_low / 1000L;
00066 #else
00067 # if defined (ACE_HAS_TIMEZONE_GETTIMEOFDAY) || \
00068   defined(ACE_HAS_VOIDPTR_GETTIMEOFDAY) || \
00069   (defined (ACE_HAS_SVR4_GETTIMEOFDAY) && !defined (m88k) && !defined (SCO))
00070   ACE_OSCALL (::gettimeofday (&tv, 0), int, -1, result);
00071 # elif defined (ACE_VXWORKS)
00072   // Assumes that struct timespec is same size as struct timeval,
00073   // which assumes that time_t is a long: it currently (VxWorks
00074   // 5.2/5.3) is.
00075   struct timespec ts;
00076 
00077   ACE_OSCALL (ACE_OS::clock_gettime (CLOCK_REALTIME, &ts), int, -1, result);
00078   tv.tv_sec = ts.tv_sec;
00079   tv.tv_usec = ts.tv_nsec / 1000L;  // timespec has nsec, but timeval has usec
00080 # else
00081   ACE_OSCALL (::gettimeofday (&tv), int, -1, result);
00082 # endif /* ACE_HAS_SVR4_GETTIMEOFDAY */
00083 #endif /* 0 */
00084 #if !defined (ACE_HAS_WINCE)&& !defined (ACE_WIN32)
00085   if (result == -1)
00086     return ACE_Time_Value (-1);
00087   else
00088     return ACE_Time_Value (tv);
00089 #endif // !defined (ACE_HAS_WINCE)&& !defined (ACE_WIN32)
00090 }

ACE_INLINE uid_t ACE_OS::getuid void   ) 
 

Definition at line 490 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, getuid(), and uid_t.

Referenced by getuid(), and ACE_SPIPE_Addr::set().

00491 {
00492   ACE_OS_TRACE ("ACE_OS::getuid");
00493 #if defined (ACE_LACKS_GETUID)
00494   ACE_NOTSUP_RETURN (static_cast<uid_t> (-1));
00495 # else
00496   ACE_OSCALL_RETURN (::getuid (), uid_t, static_cast<uid_t> (-1));
00497 # endif /* ACE_LACKS_GETUID*/
00498 }

ACE_INLINE struct tm * ACE_OS::gmtime const time_t *  clock  ) 
 

Definition at line 334 of file OS_NS_time.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and gmtime().

Referenced by gmtime(), and gmtime_r().

00335 {
00336   ACE_OS_TRACE ("ACE_OS::gmtime");
00337 #if defined (ACE_LACKS_GMTIME)
00338   ACE_UNUSED_ARG (t);
00339   ACE_NOTSUP_RETURN (0);
00340 #else
00341   ACE_OSCALL_RETURN (::gmtime (t), struct tm *, 0);
00342 #endif /* ACE_LACKS_GMTIME */
00343 }

ACE_INLINE struct tm * ACE_OS::gmtime_r const time_t *  clock,
struct tm *  res
 

Definition at line 346 of file OS_NS_time.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, gmtime(), and gmtime_r().

Referenced by gmtime_r().

00347 {
00348   ACE_OS_TRACE ("ACE_OS::gmtime_r");
00349 #if defined (ACE_HAS_REENTRANT_FUNCTIONS)
00350 # if defined (DIGITAL_UNIX)
00351   ACE_OSCALL_RETURN (::_Pgmtime_r (t, res), struct tm *, 0);
00352 # else
00353   ACE_OSCALL_RETURN (::gmtime_r (t, res), struct tm *, 0);
00354 # endif /* DIGITAL_UNIX */
00355 #elif defined (ACE_LACKS_GMTIME_R)
00356   ACE_UNUSED_ARG (t);
00357   ACE_UNUSED_ARG (res);
00358   ACE_NOTSUP_RETURN (0);
00359 #else
00360   struct tm *result;
00361   ACE_OSCALL (::gmtime (t), struct tm *, 0, result) ;
00362   if (result != 0)
00363     *res = *result;
00364   return res;
00365 #endif /* ACE_HAS_REENTRANT_FUNCTIONS */
00366 }

ACE_NAMESPACE_INLINE_FUNCTION int hostname wchar_t *  name,
size_t  maxnamelen
 

ACE_NAMESPACE_INLINE_FUNCTION int hostname char *  name,
size_t  maxnamelen
 

Referenced by ACE_TPQ_Entry::ACE_TPQ_Entry(), ACE_INET_Addr::get_host_name_i(), getmacaddress(), ACE_MEM_Addr::initialize_local(), ACE_Predefined_Naming_Contexts::is_local_host(), ACE_Naming_Context::open(), and uname().

ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE unsigned long ACE_OS::inet_addr const char *  name  ) 
 

Definition at line 11 of file OS_NS_arpa_inet.inl.

References ACE_OS_TRACE.

Referenced by inet_aton().

00012 {
00013   ACE_OS_TRACE ("ACE_OS::inet_addr");
00014 #if defined (ACE_HAS_NONCONST_GETBY)
00015   return ::inet_addr (const_cast <char*> (name));
00016 #else
00017   return ::inet_addr (name);
00018 #endif /* ACE_HAS_NONCONST_GETBY */
00019 }

ACE_BEGIN_VERSIONED_NAMESPACE_DECL int ACE_OS::inet_aton const char *  strptr,
struct in_addr *  addr
 

Definition at line 15 of file OS_NS_arpa_inet.cpp.

References INADDR_NONE, inet_addr(), inet_aton(), and strcmp().

Referenced by inet_aton(), inet_pton(), and ACE_INET_Addr::set().

00016 {
00017 #if defined (ACE_LACKS_INET_ATON)
00018 #  if defined (ACE_WIN32)
00019   // Windows Server 2003 changed the behavior of a zero-length input
00020   // string to inet_addr(). It used to return 0 (INADDR_ANY) but now
00021   // returns -1 (INADDR_NONE). It will return INADDR_ANY for a 1-space
00022   // string, though, as do previous versions of Windows.
00023   if (host_name == 0 || host_name[0] == '\0')
00024     host_name = " ";
00025 #  endif /* ACE_WIN32 */
00026   unsigned long ip_addr = ACE_OS::inet_addr (host_name);
00027 
00028   if (ip_addr == INADDR_NONE
00029       // Broadcast addresses are weird...
00030       && ACE_OS::strcmp (host_name, "255.255.255.255") != 0)
00031     return 0;
00032   else if (addr == 0)
00033     return 0;
00034   else
00035     {
00036       addr->s_addr = ip_addr;  // Network byte ordered
00037       return 1;
00038     }
00039 #elif defined (ACE_VXWORKS) && (ACE_VXWORKS <= 0x620)
00040   // inet_aton() returns OK (0) on success and ERROR (-1) on failure.
00041   // Must reset errno first. Refer to WindRiver SPR# 34949, SPR# 36026
00042   ::errnoSet(0);
00043   int result = ERROR;
00044   ACE_OSCALL (::inet_aton (const_cast <char*>(host_name), addr), int, ERROR, result);
00045   return (result == ERROR) ? 0 : 1;
00046 #else
00047   // inet_aton() returns 0 upon failure, not -1 since -1 is a valid
00048   // address (255.255.255.255).
00049   ACE_OSCALL_RETURN (::inet_aton (host_name, addr), int, 0);
00050 #endif  /* ACE_LACKS_INET_ATON */
00051 }

ACE_INLINE char * ACE_OS::inet_ntoa const struct in_addr  addr  ) 
 

Definition at line 22 of file OS_NS_arpa_inet.inl.

References ACE_OS_TRACE, and inet_ntoa().

Referenced by ACE_INET_Addr::get_host_addr(), and inet_ntoa().

00023 {
00024   ACE_OS_TRACE ("ACE_OS::inet_ntoa");
00025   ACE_OSCALL_RETURN (::inet_ntoa (addr),
00026                      char *,
00027                      0);
00028 }

ACE_INLINE const char * ACE_OS::inet_ntop int  family,
const void *  addrptr,
char *  strptr,
size_t  len
 

Definition at line 31 of file OS_NS_arpa_inet.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, INET_ADDRSTRLEN, inet_ntop(), sprintf(), strcpy(), and strlen().

Referenced by ACE_INET_Addr::get_host_addr(), and inet_ntop().

00032 {
00033   ACE_OS_TRACE ("ACE_OS::inet_ntop");
00034 
00035 #if defined (ACE_HAS_IPV6) && !defined (ACE_WIN32)
00036   ACE_OSCALL_RETURN (::inet_ntop (family, addrptr, strptr, len), const char *, 0);
00037 #else
00038   const u_char *p = reinterpret_cast<const u_char *> (addrptr);
00039 
00040   if (family == AF_INET)
00041     {
00042       char temp[INET_ADDRSTRLEN];
00043 
00044       // Stevens uses snprintf() in his implementation but snprintf()
00045       // doesn't appear to be very portable.  For now, hope that using
00046       // sprintf() will not cause any string/memory overrun problems.
00047       ACE_OS::sprintf (temp,
00048                        "%d.%d.%d.%d",
00049                        p[0], p[1], p[2], p[3]);
00050 
00051       if (ACE_OS::strlen (temp) >= len)
00052         {
00053           errno = ENOSPC;
00054           return 0; // Failure
00055         }
00056 
00057       ACE_OS::strcpy (strptr, temp);
00058       return strptr;
00059     }
00060 
00061   ACE_NOTSUP_RETURN(0);
00062 #endif /* ACE_HAS_IPV6 */
00063 }

ACE_INLINE int ACE_OS::inet_pton int  family,
const char *  strptr,
void *  addrptr
 

Definition at line 65 of file OS_NS_arpa_inet.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, inet_aton(), inet_pton(), and memcpy().

Referenced by inet_pton().

00066 {
00067   ACE_OS_TRACE ("ACE_OS::inet_pton");
00068 
00069 #if defined (ACE_HAS_IPV6) && !defined (ACE_WIN32)
00070   ACE_OSCALL_RETURN (::inet_pton (family, strptr, addrptr), int, -1);
00071 #else
00072   if (family == AF_INET)
00073     {
00074       struct in_addr in_val;
00075 
00076       if (ACE_OS::inet_aton (strptr, &in_val))
00077         {
00078           ACE_OS::memcpy (addrptr, &in_val, sizeof (struct in_addr));
00079           return 1; // Success
00080         }
00081 
00082       return 0; // Input is not a valid presentation format
00083     }
00084 
00085   ACE_NOTSUP_RETURN(-1);
00086 #endif  /* ACE_HAS_IPV6 */
00087 }

int ACE_OS::ioctl ACE_HANDLE  socket,
unsigned long  io_control_code,
ACE_QoS ace_qos,
unsigned long *  bytes_returned,
void *  buffer_p = 0,
unsigned long  buffer = 0,
ACE_OVERLAPPED overlapped = 0,
ACE_OVERLAPPED_COMPLETION_FUNC  func = 0
 

QoS-enabled when the I/O control code is either SIO_SET_QOS or SIO_GET_QOS.

Definition at line 52 of file OS_NS_stropts.cpp.

References ACE_NEW_RETURN, ACE_NOTSUP_RETURN, ACE_OVERLAPPED, ACE_OVERLAPPED_COMPLETION_FUNC, ACE_SOCKCALL_RETURN, iovec::iov_len, ACE_QoS::provider_specific(), ACE_QoS::receiving_flowspec(), and ACE_QoS::sending_flowspec().

00060 {
00061 # if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
00062 
00063   QOS qos;
00064   unsigned long qos_len = sizeof (QOS);
00065 
00066   if (io_control_code == SIO_SET_QOS)
00067     {
00068       qos.SendingFlowspec = *(ace_qos.sending_flowspec ());
00069       qos.ReceivingFlowspec = *(ace_qos.receiving_flowspec ());
00070       qos.ProviderSpecific = (WSABUF) ace_qos.provider_specific ();
00071 
00072       qos_len += ace_qos.provider_specific ().iov_len;
00073 
00074       ACE_SOCKCALL_RETURN (::WSAIoctl ((ACE_SOCKET) socket,
00075                                        io_control_code,
00076                                        &qos,
00077                                        qos_len,
00078                                        buffer_p,
00079                                        buffer,
00080                                        bytes_returned,
00081                                        (WSAOVERLAPPED *) overlapped,
00082                                        func),
00083                            int,
00084                            SOCKET_ERROR);
00085     }
00086   else
00087     {
00088       unsigned long dwBufferLen = 0;
00089 
00090       // Query for the buffer size.
00091       int result = ::WSAIoctl ((ACE_SOCKET) socket,
00092                                 io_control_code,
00093                                 NULL,
00094                                 0,
00095                                 &dwBufferLen,
00096                                 sizeof (dwBufferLen),
00097                                 bytes_returned,
00098                                 NULL,
00099                                 NULL);
00100 
00101 
00102       if (result == SOCKET_ERROR)
00103           {
00104                 unsigned long dwErr = ::WSAGetLastError ();
00105 
00106                 if (dwErr == WSAEWOULDBLOCK)
00107                 {
00108                         errno = dwErr;
00109                         return -1;
00110                 }
00111                 else
00112                         if (dwErr != WSAENOBUFS)
00113                         {
00114                                 errno = dwErr;
00115                                 return -1;
00116                         }
00117           }
00118 
00119     char *qos_buf;
00120         ACE_NEW_RETURN (qos_buf,
00121                                         char [dwBufferLen],
00122                                         -1);
00123 
00124         QOS *qos = reinterpret_cast<QOS*> (qos_buf);
00125 
00126         result = ::WSAIoctl ((ACE_SOCKET) socket,
00127                                    io_control_code,
00128                        NULL,
00129                        0,
00130                        qos,
00131                        dwBufferLen,
00132                        bytes_returned,
00133                        NULL,
00134                        NULL);
00135 
00136     if (result == SOCKET_ERROR)
00137                 return result;
00138 
00139     ACE_Flow_Spec sending_flowspec (qos->SendingFlowspec.TokenRate,
00140                                     qos->SendingFlowspec.TokenBucketSize,
00141                                     qos->SendingFlowspec.PeakBandwidth,
00142                                     qos->SendingFlowspec.Latency,
00143                                     qos->SendingFlowspec.DelayVariation,
00144 #  if defined(ACE_HAS_WINSOCK2_GQOS)
00145                                     qos->SendingFlowspec.ServiceType,
00146                                     qos->SendingFlowspec.MaxSduSize,
00147                                     qos->SendingFlowspec.MinimumPolicedSize,
00148 #  else /* ACE_HAS_WINSOCK2_GQOS */
00149                                     0,
00150                                     0,
00151                                     0,
00152 #  endif /* ACE_HAS_WINSOCK2_GQOS */
00153                                     0,
00154                                     0);
00155 
00156     ACE_Flow_Spec receiving_flowspec (qos->ReceivingFlowspec.TokenRate,
00157                                       qos->ReceivingFlowspec.TokenBucketSize,
00158                                       qos->ReceivingFlowspec.PeakBandwidth,
00159                                       qos->ReceivingFlowspec.Latency,
00160                                       qos->ReceivingFlowspec.DelayVariation,
00161 #  if defined(ACE_HAS_WINSOCK2_GQOS)
00162                                       qos->ReceivingFlowspec.ServiceType,
00163                                       qos->ReceivingFlowspec.MaxSduSize,
00164                                       qos->ReceivingFlowspec.MinimumPolicedSize,
00165 #  else /* ACE_HAS_WINSOCK2_GQOS */
00166                                       0,
00167                                       0,
00168                                       0,
00169 #  endif /* ACE_HAS_WINSOCK2_GQOS */
00170                                       0,
00171                                       0);
00172 
00173        ace_qos.sending_flowspec (&sending_flowspec);
00174        ace_qos.receiving_flowspec (&receiving_flowspec);
00175        ace_qos.provider_specific (*((struct iovec *) (&qos->ProviderSpecific)));
00176 
00177 
00178       return result;
00179     }
00180 
00181 # else
00182   ACE_UNUSED_ARG (socket);
00183   ACE_UNUSED_ARG (io_control_code);
00184   ACE_UNUSED_ARG (ace_qos);
00185   ACE_UNUSED_ARG (bytes_returned);
00186   ACE_UNUSED_ARG (buffer_p);
00187   ACE_UNUSED_ARG (buffer);
00188   ACE_UNUSED_ARG (overlapped);
00189   ACE_UNUSED_ARG (func);
00190   ACE_NOTSUP_RETURN (-1);
00191 # endif /* ACE_HAS_WINSOCK2 */
00192 }

ACE_BEGIN_VERSIONED_NAMESPACE_DECL int ACE_OS::ioctl ACE_HANDLE  socket,
unsigned long  io_control_code,
void *  in_buffer_p,
unsigned long  in_buffer,
void *  out_buffer_p,
unsigned long  out_buffer,
unsigned long *  bytes_returned,
ACE_OVERLAPPED overlapped,
ACE_OVERLAPPED_COMPLETION_FUNC  func
 

QoS-enabled .

Definition at line 14 of file OS_NS_stropts.cpp.

References ACE_NOTSUP_RETURN, ACE_OVERLAPPED, ACE_OVERLAPPED_COMPLETION_FUNC, and ACE_SOCKCALL_RETURN.

00023 {
00024 # if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
00025   ACE_SOCKCALL_RETURN (::WSAIoctl ((ACE_SOCKET) socket,
00026                                    io_control_code,
00027                                    in_buffer_p,
00028                                    in_buffer,
00029                                    out_buffer_p,
00030                                    out_buffer,
00031                                    bytes_returned,
00032                                    (WSAOVERLAPPED *) overlapped,
00033                                    func),
00034                        int,
00035                        SOCKET_ERROR);
00036 # else
00037   ACE_UNUSED_ARG (socket);
00038   ACE_UNUSED_ARG (io_control_code);
00039   ACE_UNUSED_ARG (in_buffer_p);
00040   ACE_UNUSED_ARG (in_buffer);
00041   ACE_UNUSED_ARG (out_buffer_p);
00042   ACE_UNUSED_ARG (out_buffer);
00043   ACE_UNUSED_ARG (bytes_returned);
00044   ACE_UNUSED_ARG (overlapped);
00045   ACE_UNUSED_ARG (func);
00046   ACE_NOTSUP_RETURN (-1);
00047 # endif /* ACE_HAS_WINSOCK2 */
00048 }

ACE_INLINE int ACE_OS::ioctl ACE_HANDLE  handle,
ACE_IOCTL_TYPE_ARG2  cmd,
void *  = 0
 

UNIX-style .

Definition at line 108 of file OS_NS_stropts.inl.

References ACE_OS_TRACE, ACE_SOCKCALL_RETURN, and ioctl().

Referenced by ACE_SPIPE_Acceptor::accept(), ACE::clr_flags(), ACE_TLI_Connector::connect(), ACE_IPC_SAP::control(), ACE_IO_SAP::control(), ACE::count_interfaces(), ACE_SPIPE_Acceptor::create_new_instance(), ACE_IPC_SAP::disable(), ACE_IPC_SAP::enable(), ACE::get_bcast_addr(), ACE::get_ip_interfaces(), getmacaddress(), ioctl(), ACE_SOCK_Dgram::make_multicast_ifaddr(), ACE_SOCK_Dgram_Bcast::mk_broadcast(), ACE_Pipe::open(), ACE_ATM_Acceptor::open(), open_new_endpoint(), ACE_SOCK_Dgram::recv(), ACE_SPIPE_Stream::recv_handle(), ACE_SOCK_IO::recvv(), ACE_SPIPE_Stream::send_handle(), ACE::set_flags(), and ACE_Dev_Poll_Reactor::work_pending_i().

00111 {
00112   ACE_OS_TRACE ("ACE_OS::ioctl");
00113 
00114 #if defined (ACE_WIN32)
00115   ACE_SOCKET sock = (ACE_SOCKET) handle;
00116   ACE_SOCKCALL_RETURN (::ioctlsocket (sock, cmd, reinterpret_cast<unsigned long *> (val)), int, -1);
00117 #elif defined (ACE_VXWORKS) && (ACE_VXWORKS <= 0x620)
00118   ACE_OSCALL_RETURN (::ioctl (handle, cmd, reinterpret_cast<int> (val)),
00119                      int, -1);
00120 #else
00121   ACE_OSCALL_RETURN (::ioctl (handle, cmd, val), int, -1);
00122 #endif /* ACE_WIN32 */
00123 }

ACE_INLINE int ACE_OS::isastream ACE_HANDLE  handle  ) 
 

Definition at line 126 of file OS_NS_stropts.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and isastream().

Referenced by ACE_UPIPE_Connector::connect(), and isastream().

00127 {
00128   ACE_OS_TRACE ("ACE_OS::isastream");
00129 #if defined (ACE_HAS_STREAM_PIPES)
00130   ACE_OSCALL_RETURN (::isastream (handle), int, -1);
00131 #else
00132   ACE_UNUSED_ARG (handle);
00133 
00134   ACE_NOTSUP_RETURN (-1);
00135 #endif /* ACE_HAS_STREAM_PIPES */
00136 }

ACE_INLINE int ACE_OS::isatty ACE_HANDLE  handle  ) 
 

Definition at line 593 of file OS_NS_unistd.inl.

00594 {
00595 #if defined (ACE_LACKS_ISATTY)
00596   ACE_UNUSED_ARG (handle);
00597   return 0;
00598 #else
00599 # if defined (ACE_LACKS_INTPTR_T)
00600    int fd = ::_open_osfhandle (long (handle), 0);
00601 # else
00602    int fd = ::_open_osfhandle (intptr_t (handle), 0);
00603 # endif
00604   int status = ::_isatty (fd);
00605   ::_close (fd);
00606   return status;
00607 #endif /* ACE_LACKS_ISATTY */
00608 }

ACE_INLINE int ACE_OS::isatty int  handle  ) 
 

Definition at line 578 of file OS_NS_unistd.inl.

References ACE_OS_TRACE, and isatty().

Referenced by isatty().

00579 {
00580   ACE_OS_TRACE ("ACE_OS::isatty");
00581 #if defined (ACE_LACKS_ISATTY)
00582   ACE_UNUSED_ARG (handle);
00583   return 0;
00584 # elif defined (ACE_WIN32)
00585   return ::_isatty (handle);
00586 # else
00587   ACE_OSCALL_RETURN (::isatty (handle), int, -1);
00588 # endif /* ACE_LACKS_ISATTY */
00589 }

ACE_INLINE wchar_t * ACE_OS::itoa int  value,
wchar_t *  string,
int  radix
 

Converts an integer to a string.

Definition at line 164 of file OS_NS_stdlib.inl.

References itow_emulation().

00165 {
00166 #if defined (ACE_LACKS_ITOW)
00167   return ACE_OS::itow_emulation (value, string, radix);
00168 #else /* ACE_LACKS_ITOW */
00169   return ::_itow (value, string, radix);
00170 #endif /* ACE_LACKS_ITOW */
00171 }

ACE_INLINE char * ACE_OS::itoa int  value,
char *  string,
int  radix
 

Converts an integer to a string.

Definition at line 151 of file OS_NS_stdlib.inl.

References itoa_emulation().

00152 {
00153 #if !defined (ACE_HAS_ITOA)
00154   return ACE_OS::itoa_emulation (value, string, radix);
00155 #elif defined (ACE_ITOA_EQUIVALENT)
00156   return ACE_ITOA_EQUIVALENT (value, string, radix);
00157 #else /* !ACE_HAS_ITOA */
00158   return ::itoa (value, string, radix);
00159 #endif /* !ACE_HAS_ITOA */
00160 }

char * ACE_OS::itoa_emulation int  value,
char *  string,
int  radix
 

Emulated itoa - Converts an integer to a string.

Definition at line 108 of file OS_NS_stdlib.cpp.

Referenced by itoa().

00109 {
00110   char *e = string;
00111   char *b = string;
00112 
00113   // Short circuit if 0
00114 
00115   if (value == 0)
00116     {
00117       string[0] = '0';
00118       string[1] = 0;
00119       return string;
00120     }
00121 
00122   // If negative and base 10, print a - and then do the
00123   // number.
00124 
00125   if (value < 0 && radix == 10)
00126     {
00127       string[0] = '-';
00128       ++b;
00129       ++e; // Don't overwrite the negative sign.
00130       value = -value; // Drop negative sign so character selection is correct.
00131     }
00132 
00133   // Convert to base <radix>, but in reverse order
00134 
00135   while (value != 0)
00136     {
00137       int mod = value % radix;
00138       value = value / radix;
00139 
00140       *e++ = (mod < 10) ? '0' + mod : 'a' + mod - 10;
00141     }
00142 
00143   *e-- = 0;
00144 
00145   // Now reverse the string to get the correct result
00146 
00147   while (e > b)
00148     {
00149       char temp = *e;
00150       *e = *b;
00151       *b = temp;
00152       ++b;
00153       --e;
00154     }
00155 
00156   return string;
00157 }

wchar_t * ACE_OS::itow_emulation int  value,
wchar_t *  string,
int  radix
 

Emulated itow - Converts an integer to a string.

Definition at line 162 of file OS_NS_stdlib.cpp.

Referenced by itoa().

00163 {
00164   wchar_t *e = string;
00165   wchar_t *b = string;
00166 
00167   // Short circuit if 0
00168 
00169   if (value == 0)
00170     {
00171       string[0] = '0';
00172       string[1] = 0;
00173       return string;
00174     }
00175 
00176   // If negative and base 10, print a - and then do the
00177   // number.
00178 
00179   if (value < 0 && radix == 10)
00180     {
00181       string[0] = '-';
00182       b++;
00183     }
00184 
00185   // Convert to base <radix>, but in reverse order
00186 
00187   while (value != 0)
00188     {
00189       int mod = value % radix;
00190       value = value / radix;
00191 
00192       *e++ = (mod < 10) ? '0' + mod : 'a' + mod - 10;
00193     }
00194 
00195   *e-- = 0;
00196 
00197   // Now reverse the string to get the correct result
00198 
00199   while (e > b)
00200   {
00201     wchar_t temp = *e;
00202     *e = *b;
00203     *b = temp;
00204     ++b;
00205     --e;
00206   }
00207 
00208   return string;
00209 }

ACE_HANDLE ACE_OS::join_leaf ACE_HANDLE  socket,
const sockaddr *  name,
int  namelen,
const ACE_QoS_Params qos_params
 

Joins a leaf node into a QoS-enabled multi-point session.

Definition at line 65 of file OS_NS_sys_socket.cpp.

References ACE_NOTSUP_RETURN, ACE_SOCKCALL_RETURN, ACE_QoS_Params::callee_data(), ACE_QoS_Params::caller_data(), ACE_QoS_Params::flags(), ACE_QoS_Params::group_socket_qos(), ACE_QoS::provider_specific(), ACE_QoS::receiving_flowspec(), ACE_QoS::sending_flowspec(), and ACE_QoS_Params::socket_qos().

Referenced by ACE_ATM_Connector::add_leaf().

00069 {
00070 # if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
00071 
00072   QOS qos;
00073   // Construct the WinSock2 QOS structure.
00074 
00075   qos.SendingFlowspec = *(qos_params.socket_qos ()->sending_flowspec ());
00076   qos.ReceivingFlowspec = *(qos_params.socket_qos ()->receiving_flowspec ());
00077   qos.ProviderSpecific = (WSABUF) qos_params.socket_qos ()->provider_specific ();
00078 
00079   ACE_SOCKCALL_RETURN (::WSAJoinLeaf ((ACE_SOCKET) socket,
00080                                       name,
00081                                       namelen,
00082                                       (WSABUF *) qos_params.caller_data (),
00083                                       (WSABUF *) qos_params.callee_data (),
00084                                       &qos,
00085                                       (QOS *) qos_params.group_socket_qos (),
00086                                       qos_params.flags ()),
00087                        ACE_HANDLE,
00088                        ACE_INVALID_HANDLE);
00089 
00090 # else
00091   ACE_UNUSED_ARG (socket);
00092   ACE_UNUSED_ARG (name);
00093   ACE_UNUSED_ARG (namelen);
00094   ACE_UNUSED_ARG (qos_params);
00095   ACE_NOTSUP_RETURN (ACE_INVALID_HANDLE);
00096 # endif /* ACE_HAS_WINSOCK2 */
00097 }

ACE_INLINE int ACE_OS::kill pid_t  pid,
int  signum
 

Definition at line 14 of file OS_NS_signal.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, kill(), and pid_t.

Referenced by ACE_Process::kill(), kill(), ACE::process_active(), ACE_Process::running(), ACE_Process_Manager::terminate(), ACE::terminate_process(), and thr_kill().

00015 {
00016   ACE_OS_TRACE ("ACE_OS::kill");
00017 #if defined (ACE_LACKS_KILL)
00018   ACE_UNUSED_ARG (pid);
00019   ACE_UNUSED_ARG (signum);
00020   ACE_NOTSUP_RETURN (-1);
00021 #else
00022   ACE_OSCALL_RETURN (::kill (pid, signum), int, -1);
00023 #endif /* ACE_LACKS_KILL */
00024 }

ACE_INLINE void ACE_OS::last_error int   ) 
 

Definition at line 29 of file OS_NS_errno.inl.

References ACE_OS_TRACE.

00030 {
00031   ACE_OS_TRACE ("ACE_OS::last_error");
00032 #if defined (ACE_WIN32)
00033   ::SetLastError (error);
00034 #endif /* ACE_WIN32 */
00035   errno = error;
00036 }

ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE int ACE_OS::last_error void   ) 
 

Definition at line 10 of file OS_NS_errno.inl.

Referenced by ACE_POSIX_Asynch_Accept::accept(), ACE_Connector< SVC_HANDLER, ACE_PEER_CONNECTOR_2 >::connect_i(), dlopen(), ACE_Service_Repository::insert(), ACE_Log_Msg::last_error_adapter(), ACE_Service_Gestalt::process_directives_i(), set_errno_to_last_error(), set_errno_to_wsa_last_error(), set_scheduling_params(), and t_getname().

00011 {
00012   // ACE_OS_TRACE ("ACE_OS::last_error");
00013 
00014 #if defined (ACE_WIN32)
00015   // ACE_OS::last_error() prefers errnor since started out as a way to
00016   // avoid directly accessing errno in ACE code - particularly the ACE
00017   // C++ socket wrapper facades.  On Windows, some things that would
00018   // use errno on UNIX require ::GetLastError(), so this method tries
00019   // to shield the rest of ACE from having to know about this.
00020   int lerror = ::GetLastError ();
00021   int lerrno = errno;
00022   return lerrno == 0 ? lerror : lerrno;
00023 #else
00024   return errno;
00025 #endif /* ACE_WIN32 */
00026 }

ACE_INLINE int ACE_OS::listen ACE_HANDLE  handle,
int  backlog
 

BSD-style (no QoS).

Definition at line 246 of file OS_NS_sys_socket.inl.

References ACE_OS_TRACE, ACE_SOCKCALL_RETURN, and listen().

Referenced by listen(), ACE_ATM_Acceptor::open(), ACE_Asynch_Acceptor< HANDLER >::open(), ACE_SOCK_SEQPACK_Acceptor::shared_open(), and ACE_SOCK_Acceptor::shared_open().

00247 {
00248   ACE_OS_TRACE ("ACE_OS::listen");
00249   ACE_SOCKCALL_RETURN (::listen ((ACE_SOCKET) handle, backlog), int, -1);
00250 }

ACE_INLINE struct tm * ACE_OS::localtime const time_t *  clock  ) 
 

Definition at line 369 of file OS_NS_time.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and localtime().

Referenced by ctime(), localtime(), and localtime_r().

00370 {
00371   ACE_OS_TRACE ("ACE_OS::localtime");
00372 #if defined (ACE_LACKS_LOCALTIME)
00373   ACE_UNUSED_ARG (t);
00374   ACE_NOTSUP_RETURN (0);
00375 #else
00376   ACE_OSCALL_RETURN (::localtime (t), struct tm *, 0);
00377 #endif /* ACE_LACKS_LOCALTIME */
00378 }

ACE_BEGIN_VERSIONED_NAMESPACE_DECL struct tm * ACE_OS::localtime_r const time_t *  clock,
struct tm *  res
 

Definition at line 226 of file OS_NS_time.cpp.

References ACE_NOTSUP_RETURN, ACE_OS_GUARD, ACE_OS_TRACE, localtime(), and localtime_r().

Referenced by localtime_r(), and ACE_Date_Time::update().

00227 {
00228   ACE_OS_TRACE ("ACE_OS::localtime_r");
00229 #if defined (ACE_HAS_REENTRANT_FUNCTIONS)
00230 # if defined (DIGITAL_UNIX)
00231   ACE_OSCALL_RETURN (::_Plocaltime_r (t, res), struct tm *, 0);
00232 # else
00233   ACE_OSCALL_RETURN (::localtime_r (t, res), struct tm *, 0);
00234 # endif /* DIGITAL_UNIX */
00235 #elif !defined (ACE_HAS_WINCE)
00236   ACE_OS_GUARD
00237 
00238   ACE_UNUSED_ARG (res);
00239   struct tm * res_ptr;
00240   ACE_OSCALL (::localtime (t), struct tm *, 0, res_ptr);
00241   if (res_ptr == 0)
00242     return 0;
00243   else
00244     {
00245       *res = *res_ptr;
00246       return res;
00247     }
00248 #elif defined (ACE_HAS_WINCE)
00249   // This is really stupid, converting FILETIME to timeval back and
00250   // forth.  It assumes FILETIME and DWORDLONG are the same structure
00251   // internally.
00252 
00253   TIME_ZONE_INFORMATION pTz;
00254 
00255   const unsigned short int __mon_yday[2][13] =
00256   {
00257     /* Normal years.  */
00258     { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 },
00259     /* Leap years.  */
00260     { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 }
00261   };
00262 
00263   ULARGE_INTEGER _100ns;
00264   ::GetTimeZoneInformation (&pTz);
00265 
00266   _100ns.QuadPart = (DWORDLONG) *t * 10000 * 1000 + ACE_Time_Value::FILETIME_to_timval_skew;
00267   FILETIME file_time;
00268   file_time.dwLowDateTime = _100ns.LowPart;
00269   file_time.dwHighDateTime = _100ns.HighPart;
00270 
00271   FILETIME localtime;
00272   SYSTEMTIME systime;
00273   FileTimeToLocalFileTime (&file_time, &localtime);
00274   FileTimeToSystemTime (&localtime, &systime);
00275 
00276   res->tm_hour = systime.wHour;
00277 
00278   if(pTz.DaylightBias!=0)
00279     res->tm_isdst = 1;
00280   else
00281     res->tm_isdst = 1;
00282 
00283    int iLeap;
00284    iLeap = (res->tm_year % 4 == 0 && (res->tm_year% 100 != 0 || res->tm_year % 400 == 0));
00285    // based on leap select which group to use
00286 
00287    res->tm_mday = systime.wDay;
00288    res->tm_min = systime.wMinute;
00289    res->tm_mon = systime.wMonth - 1;
00290    res->tm_sec = systime.wSecond;
00291    res->tm_wday = systime.wDayOfWeek;
00292    res->tm_yday = __mon_yday[iLeap][systime.wMonth] + systime.wDay;
00293    res->tm_year = systime.wYear;// this the correct year but bias the value to start at the 1900
00294    res->tm_year = res->tm_year - 1900;
00295 
00296    return res;
00297 #else
00298   // @@ Same as ACE_OS::localtime (), you need to implement it
00299   //    yourself.
00300   ACE_UNUSED_ARG (t);
00301   ACE_UNUSED_ARG (res);
00302   ACE_NOTSUP_RETURN (0);
00303 #endif /* ACE_HAS_REENTRANT_FUNCTIONS */
00304 }

ACE_INLINE off_t ACE_OS::lseek ACE_HANDLE  handle,
off_t  offset,
int  whence
 

Definition at line 613 of file OS_NS_unistd.inl.

References ACE_FAIL_RETURN, ACE_OS_TRACE, ACE_SYSCALL_FAILED, and lseek().

Referenced by ACE_MMAP_Memory_Pool::commit_backing_store_name(), lseek(), pread(), ACE_MMAP_Memory_Pool::protect(), pwrite(), ACE_FILE::seek(), ACE_MMAP_Memory_Pool::sync(), ACE_FILE::tell(), and ACE_Mem_Map::unmap().

00614 {
00615   ACE_OS_TRACE ("ACE_OS::lseek");
00616 #if defined (ACE_WIN32)
00617 # if SEEK_SET != FILE_BEGIN || SEEK_CUR != FILE_CURRENT || SEEK_END != FILE_END
00618   //#error Windows NT is evil AND rude!
00619   switch (whence)
00620     {
00621     case SEEK_SET:
00622       whence = FILE_BEGIN;
00623       break;
00624     case SEEK_CUR:
00625       whence = FILE_CURRENT;
00626       break;
00627     case SEEK_END:
00628       whence = FILE_END;
00629       break;
00630     default:
00631       errno = EINVAL;
00632       return static_cast<off_t> (-1); // rather safe than sorry
00633     }
00634 # endif  /* SEEK_SET != FILE_BEGIN || SEEK_CUR != FILE_CURRENT || SEEK_END != FILE_END */
00635   DWORD result = ::SetFilePointer (handle, offset, 0, whence);
00636   if (result == ACE_SYSCALL_FAILED)
00637     ACE_FAIL_RETURN (static_cast<off_t> (-1));
00638   else
00639     return result;
00640 #else
00641   ACE_OSCALL_RETURN (::lseek (handle, offset, whence), off_t, -1);
00642 #endif /* ACE_WIN32 */
00643 }

ACE_INLINE int ACE_OS::lstat const wchar_t *  ,
ACE_stat
 

Definition at line 139 of file OS_NS_sys_stat.inl.

References ACE_OS_TRACE, lstat(), and stat().

00140   {
00141     ACE_OS_TRACE ("ACE_OS::lstat");
00142 # if defined (ACE_LACKS_LSTAT)
00143     return ACE_OS::stat (file, stp);
00144 # else
00145     return ACE_OS::lstat (ACE_Wide_To_Ascii (file).char_rep (), stp);
00146 # endif /* ACE_LACKS_LSTAT */
00147   }

ACE_INLINE int ACE_OS::lstat const char *  ,
ACE_stat
 

Definition at line 123 of file OS_NS_sys_stat.inl.

References ACE_OS_TRACE, lstat(), and stat().

Referenced by lstat().

00124   {
00125     ACE_OS_TRACE ("ACE_OS::lstat");
00126 # if defined (ACE_LACKS_LSTAT)
00127     return ACE_OS::stat (file, stp);
00128 # elif defined (ACE_HAS_X86_STAT_MACROS)
00129     // Solaris for intel uses an macro for lstat(), this macro is a
00130     // wrapper for _lxstat().
00131     ACE_OSCALL_RETURN (::_lxstat (_STAT_VER, file, stp), int, -1);
00132 # else /* !ACE_HAS_X86_STAT_MACROS */
00133     ACE_OSCALL_RETURN (::lstat (file, stp), int, -1);
00134 # endif /* ACE_LACKS_LSTAT */
00135   }

int ACE_OS::lwp_getparams ACE_Sched_Params  ) 
 

Definition at line 3389 of file OS_NS_Thread.cpp.

References ACE_id_t, ACE_NOTSUP_RETURN, ACE_SCHED_FIFO, ACE_SCHED_OTHER, ACE_SCOPE_THREAD, memcpy(), memset(), priority_control(), sched_params(), and scheduling_class().

Referenced by thr_setprio().

03390 {
03391 #if defined (ACE_HAS_STHREADS) || defined (sun)
03392   // Get the class TS and RT class IDs.
03393   ACE_id_t rt_id;
03394   ACE_id_t ts_id;
03395   if (ACE_OS::scheduling_class ("RT", rt_id) == -1
03396       || ACE_OS::scheduling_class ("TS", ts_id) == -1)
03397     return -1;
03398 
03399   // Get this LWP's scheduling parameters.
03400   pcparms_t pcparms;
03401   // The following is just to avoid Purify warnings about unitialized
03402   // memory reads.
03403   ACE_OS::memset (&pcparms, 0, sizeof pcparms);
03404   pcparms.pc_cid = PC_CLNULL;
03405 
03406   if (ACE_OS::priority_control (P_LWPID,
03407                                 P_MYID,
03408                                 PC_GETPARMS,
03409                                 (char *) &pcparms) == -1)
03410     return -1;
03411   else if (pcparms.pc_cid == rt_id)
03412     {
03413       // RT class.
03414       rtparms_t rtparms;
03415       ACE_OS::memcpy (&rtparms, pcparms.pc_clparms, sizeof rtparms);
03416 
03417       sched_params.policy (ACE_SCHED_FIFO);
03418       sched_params.priority (rtparms.rt_pri);
03419       sched_params.scope (ACE_SCOPE_THREAD);
03420       ACE_Time_Value quantum (rtparms.rt_tqsecs,
03421                               rtparms.rt_tqnsecs == RT_TQINF
03422                               ? 0 : rtparms.rt_tqnsecs * 1000);
03423       sched_params.quantum (quantum);
03424       return 0;
03425     }
03426   else if (pcparms.pc_cid == ts_id)
03427     {
03428       /* TS class */
03429       tsparms_t tsparms;
03430       ACE_OS::memcpy (&tsparms, pcparms.pc_clparms, sizeof tsparms);
03431 
03432       sched_params.policy (ACE_SCHED_OTHER);
03433       sched_params.priority (tsparms.ts_upri);
03434       sched_params.scope (ACE_SCOPE_THREAD);
03435       return 0;
03436     }
03437   else
03438     return -1;
03439 
03440 #else  /* ! ACE_HAS_STHREADS && ! sun */
03441   ACE_UNUSED_ARG (sched_params);
03442   ACE_NOTSUP_RETURN (-1);
03443 #endif /* ! ACE_HAS_STHREADS && ! sun */
03444 }

int ACE_OS::lwp_setparams const ACE_Sched_Params  ) 
 

Definition at line 3447 of file OS_NS_Thread.cpp.

References ACE_NOTSUP_RETURN, ACE_SCOPE_LWP, sched_params(), and ACE_Sched_Params::scope().

Referenced by thr_create(), and thr_setprio().

03448 {
03449 #if defined (ACE_HAS_STHREADS) || defined (sun)
03450   ACE_Sched_Params lwp_params (sched_params);
03451   lwp_params.scope (ACE_SCOPE_LWP);
03452   return ACE_OS::sched_params (lwp_params);
03453 #else  /* ! ACE_HAS_STHREADS && ! sun */
03454   ACE_UNUSED_ARG (sched_params);
03455   ACE_NOTSUP_RETURN (-1);
03456 #endif /* ! ACE_HAS_STHREADS && ! sun */
03457 }

ACE_INLINE int ACE_OS::madvise caddr_t  addr,
size_t  len,
int  map_advice
 

Definition at line 25 of file OS_NS_sys_mman.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, caddr_t, and madvise().

Referenced by ACE_Mem_Map::advise(), and madvise().

00026 {
00027   ACE_OS_TRACE ("ACE_OS::madvise");
00028 #if !defined (ACE_LACKS_MADVISE)
00029   ACE_OSCALL_RETURN (::madvise (addr, len, map_advice), int, -1);
00030 #else
00031   ACE_UNUSED_ARG (addr);
00032   ACE_UNUSED_ARG (len);
00033   ACE_UNUSED_ARG (map_advice);
00034   ACE_NOTSUP_RETURN (-1);
00035 #endif /* ACE_WIN32 */
00036 }

void * ACE_OS::malloc size_t   ) 
 

Definition at line 213 of file OS_NS_stdlib.cpp.

References ACE_MALLOC_FUNC.

Referenced by ACE_ATM_QoS::ACE_ATM_QoS(), ACE_Name_Options::ACE_Name_Options(), ACE_ATM_QoS::construct_options(), ACE::count_interfaces(), ACE_ATM_Stream::get_vpi_vci(), ACE_Static_Object_Lock::instance(), ACE::ldfind(), scandir_emulation(), and tempnam().

00214 {
00215   return ACE_MALLOC_FUNC (nbytes);
00216 }

ACE_INLINE void * ACE_OS::memchr void *  s,
int  c,
size_t  len
 

Finds characters in a buffer (void version).

Definition at line 23 of file OS_NS_string.inl.

References memchr().

00024 {
00025   return const_cast<void *> (ACE_OS::memchr (static_cast<const void *> (s),
00026                                              c,
00027                                              len));
00028 }

ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE const void * ACE_OS::memchr const void *  s,
int  c,
size_t  len
 

Finds characters in a buffer (const void version).

Definition at line 13 of file OS_NS_string.inl.

References memchr_emulation().

Referenced by memchr().

00014 {
00015 #if defined (ACE_HAS_MEMCHR)
00016   return ::memchr (s, c, len);
00017 #else /* ACE_HAS_MEMCHR */
00018   return ACE_OS::memchr_emulation (s, c, len);
00019 #endif /* ACE_HAS_MEMCHR */
00020 }

ACE_BEGIN_VERSIONED_NAMESPACE_DECL const void * ACE_OS::memchr_emulation const void *  s,
int  c,
size_t  len
 

Emulated memchr - Finds a character in a buffer.

Definition at line 27 of file OS_NS_string.cpp.

Referenced by memchr().

00028 {
00029   const unsigned char *t = (const unsigned char *) s;
00030   const unsigned char *e = (const unsigned char *) s + len;
00031 
00032   while (t < e)
00033     if (((int) *t) == c)
00034       return t;
00035     else
00036       t++;
00037 
00038   return 0;
00039 }

ACE_INLINE int ACE_OS::memcmp const void *  t,
const void *  s,
size_t  len
 

Compares two buffers.

Definition at line 31 of file OS_NS_string.inl.

Referenced by ACE_String_Base< CHAR >::compare(), ACE_INET_Addr::get_host_name_i(), ACE_CDR::LongDouble::operator!=(), ACE_String_Base< CHAR >::operator==(), ACE_NS_String::operator==(), ACE_INET_Addr::operator==(), ACE_CDR::LongDouble::operator==(), ACE_ATM_Addr::operator==(), and strnstr().

00032 {
00033   return ::memcmp (t, s, len);
00034 }

ACE_INLINE void * ACE_OS::memcpy void *  t,
const void *  s,
size_t  len
 

Copies one buffer to another.

Definition at line 37 of file OS_NS_string.inl.

Referenced by ACE_TLI_Acceptor::accept(), ACE_ATM_QoS::ACE_ATM_QoS(), ACE_Handle_Set::ACE_Handle_Set(), ACE_Message_Block::ACE_Message_Block(), ACE_Metrics_Timeprobe< ACE_LOCK, ALLOCATOR >::ACE_Metrics_Timeprobe(), ACE_Name_Request::ACE_Name_Request(), ACE_NS_String::ACE_NS_String(), ACE_SString::ACE_SString(), ACE_ATM_Addr::addr_to_string(), ACE_String_Base< CHAR >::append(), ACE_Data_Block::clone(), ACE_InputCDR::clone_from(), ACE_TLI_Connector::connect(), ACE_ATM_QoS::construct_options(), ACE_Obstack_T< CHAR >::copy(), ACE_Message_Block::copy(), ACE_ARGV_T< CHAR_TYPE >::create_buf_from_queue(), ACE_Active_Map_Manager_Key::decode(), ACE_Active_Map_Manager_Key::encode(), ACE::get_bcast_addr(), ACE_Configuration_Heap::get_binary_value(), ACE_INET_Addr::get_host_name_i(), ACE_INET_Addr::get_ip_address(), ACE_ATM_Acceptor::get_local_addr(), ACE_TLI::get_option(), ACE_ATM_Stream::get_vpi_vci(), gethrtime(), getmacaddress(), ACE_Timer_Heap_T< TYPE, FUNCTOR, ACE_LOCK >::grow_heap(), ACE_Registry_ImpExp::import_config(), ACE_Timeprobe_Ex< ACE_LOCK, ALLOCATOR >::increase_size(), inet_pton(), ACE_Utils::UUID_Generator::init(), ACE_ATM_Addr::init(), ACE_Svc_Conf_Lexer::input(), ACE_Codeset_Registry::locale_to_registry_i(), lwp_getparams(), ACE_SOCK_Dgram::make_multicast_ifaddr6(), ACE_SOCK_Dgram_Bcast::mk_broadcast(), ACE_Name_Request::name(), ACE_Metrics_Timeprobe< ACE_LOCK, ALLOCATOR >::probe_name(), putmsg(), ACE_InputCDR::read_array(), ACE_UPIPE_Stream::recv(), ACE_SOCK_Dgram::recv(), ACE_MEM_IO::recv(), ACE_Codeset_Registry::registry_to_locale_i(), ACE_Obstack_T< CHAR >::request(), scandir_emulation(), ACE_SOCK_Dgram::send(), ACE_MEM_IO::send(), ACE_String_Base< CHAR >::set(), ACE_SPIPE_Addr::set(), ACE_Netlink_Addr::set(), ACE_INET_Addr::set(), ACE_ATM_Addr::set(), ACE_UNIX_Addr::set_addr(), ACE_SPIPE_Addr::set_addr(), ACE_ATM_Addr::set_addr(), ACE_INET_Addr::set_address(), ACE_Configuration_Heap::set_binary_value(), ACE_TLI::set_option(), set_scheduling_params(), ACE_Process_Options::setenv_i(), ACE_SOCK_SEQPACK_Connector::shared_connect_start(), ACE_SOCK_SEQPACK_Acceptor::shared_open(), ACE_Data_Block::size(), ACE_ATM_Addr::string_to_addr(), ACE_Name_Request::value(), and ACE_OutputCDR::write_array().

00038 {
00039 #if defined (ACE_HAS_MEMCPY_LOOP_UNROLL)
00040   return fast_memcpy (t, s, len);
00041 #else
00042   return ::memcpy (t, s, len);
00043 #endif /* ACE_HAS_MEMCPY_LOOP_UNROLL */
00044 }

ACE_INLINE void * ACE_OS::memmove void *  t,
const void *  s,
size_t  len
 

Moves one buffer to another.

Definition at line 47 of file OS_NS_string.inl.

Referenced by ACE_Message_Block::crunch(), ACE_Svc_Conf_Lexer::scan(), and ACE_Svc_Conf_Lexer::yylex().

00048 {
00049   return ::memmove (t, s, len);
00050 }

ACE_INLINE void * ACE_OS::memset void *  s,
int  c,
size_t  len
 

Fills a buffer with a character value.

Definition at line 53 of file OS_NS_string.inl.

Referenced by ACE_ATM_Addr::ACE_ATM_Addr(), ACE_ATM_QoS::ACE_ATM_QoS(), ACE_DEV_Addr::ACE_DEV_Addr(), ACE_INET_Addr::ACE_INET_Addr(), ACE_Mem_Map::ACE_Mem_Map(), ACE_Ping_Socket::ACE_Ping_Socket(), ACE_Process::ACE_Process(), ACE_Process_Options::ACE_Process_Options(), ACE_Profile_Timer::ACE_Profile_Timer(), ACE_SPIPE_Addr::ACE_SPIPE_Addr(), ACE_Token_Request::ACE_Token_Request(), ACE_UNIX_Addr::ACE_UNIX_Addr(), ACE_Malloc_T< ACE_MEM_POOL_2, ACE_LOCK, ACE_CB >::calloc(), ACE_Dynamic_Cached_Allocator< ACE_LOCK >::calloc(), ACE_Cached_Allocator< T, ACE_LOCK >::calloc(), ACE_Static_Allocator_Base::calloc(), ACE_New_Allocator::calloc(), cond_init(), condattr_init(), ACE::count_interfaces(), ACE_Thread::disablecancel(), fork_exec(), ACE::get_bcast_addr(), ACE::get_ip_interfaces(), ACE_SOCK_SEQPACK_Association::get_local_addrs(), ACE_ATM_Stream::get_peer_name(), ACE_SOCK_SEQPACK_Association::get_remote_addrs(), ACE_ATM_Stream::get_vpi_vci(), gethostbyaddr_r(), gethostbyname_r(), getmacaddress(), getpeername(), getservbyname_r(), getsockname(), ACE_Filecache_Object::init(), ACE_ATM_Addr::init(), lwp_getparams(), ACE_SOCK_Dgram::make_multicast_ifaddr6(), ACE_Dev_Poll_Reactor::mask_ops_i(), mutex_init(), ACE_ATM_Stream::open(), ACE_ATM_Acceptor::open(), ACE_Sched_Params::priority_max(), ACE_Sched_Params::priority_min(), ACE_Ping_Socket::receive_echo_reply(), ACE_Dev_Poll_Reactor::register_handler_i(), ACE_INET_Addr::reset(), ACE_String_Base< CHAR >::resize(), ACE_Dev_Poll_Reactor::resume_handler_i(), scheduling_class(), ACE_Ping_Socket::send_echo_check(), ACE_TTY_IO::Serial_Params::Serial_Params(), ACE_UNIX_Addr::set(), ACE_SPIPE_Addr::set(), ACE_Netlink_Addr::set(), ACE_INET_Addr::set(), ACE_DEV_Addr::set(), ACE_INET_Addr::set_address(), ACE_ATM_QoS::set_cbr_rate(), ACE::set_handle_limit(), set_scheduling_params(), ACE_SOCK_SEQPACK_Acceptor::shared_open(), ACE_SOCK_Acceptor::shared_open(), ACE_Dev_Poll_Reactor::suspend_handler_i(), thr_create(), and thr_setprio().

00054 {
00055   return ::memset (s, c, len);
00056 }

ACE_INLINE int ACE_OS::mkdir const wchar_t *  path,
mode_t  mode = ACE_DEFAULT_DIR_PERMS
 

Definition at line 172 of file OS_NS_sys_stat.inl.

References ACE_ADAPT_RETVAL, mkdir(), and mode_t.

00173   {
00174 #if defined (ACE_HAS_WINCE)
00175     ACE_UNUSED_ARG (mode);
00176     ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (CreateDirectoryW (path, 0),
00177                                             ace_result_),
00178                           int, -1);
00179 #elif defined (ACE_WIN32) && defined (ACE_USES_WCHAR)
00180     ACE_UNUSED_ARG (mode);
00181     ACE_OSCALL_RETURN (::_wmkdir (path), int, -1);
00182 #else
00183     return ACE_OS::mkdir (ACE_Wide_To_Ascii (path).char_rep (), mode);
00184 #endif /* ACE_HAS_WINCE */
00185   }

ACE_INLINE int ACE_OS::mkdir const char *  path,
mode_t  mode = ACE_DEFAULT_DIR_PERMS
 

Definition at line 151 of file OS_NS_sys_stat.inl.

References ACE_ADAPT_RETVAL, ACE_TEXT_CHAR_TO_TCHAR, mkdir(), and mode_t.

Referenced by mkdir().

00152   {
00153 #if defined (ACE_WIN32) && defined (__IBMCPP__) && (__IBMCPP__ >= 400)
00154     ACE_UNUSED_ARG (mode);
00155     ACE_OSCALL_RETURN (::_mkdir (const_cast <char *> (path)), int, -1);
00156 #elif defined (ACE_HAS_WINCE)
00157     ACE_UNUSED_ARG (mode);
00158     ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::CreateDirectory (ACE_TEXT_CHAR_TO_TCHAR (path), 0),
00159                                             ace_result_),
00160                           int, -1);
00161 #elif defined (ACE_MKDIR_LACKS_MODE)
00162     ACE_UNUSED_ARG (mode);
00163     ACE_OSCALL_RETURN (::mkdir (path), int, -1);
00164 #else
00165     ACE_OSCALL_RETURN (::mkdir (path, mode), int, -1);
00166 #endif
00167   }

ACE_INLINE int ACE_OS::mkfifo const ACE_TCHAR file,
mode_t  mode = ACE_DEFAULT_FILE_PERMS
 

Definition at line 190 of file OS_NS_sys_stat.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_TCHAR, ACE_TEXT_ALWAYS_CHAR, mkfifo(), and mode_t.

Referenced by mkfifo(), ACE_FIFO::open(), and sema_init().

00191   {
00192     ACE_OS_TRACE ("ACE_OS::mkfifo");
00193 #if defined (ACE_LACKS_MKFIFO)
00194     ACE_UNUSED_ARG (file);
00195     ACE_UNUSED_ARG (mode);
00196     ACE_NOTSUP_RETURN (-1);
00197 #else
00198     ACE_OSCALL_RETURN (::mkfifo (ACE_TEXT_ALWAYS_CHAR (file), mode), int, -1);
00199 #endif /* ACE_LACKS_MKFIFO */
00200   }

ACE_INLINE ACE_HANDLE ACE_OS::mkstemp wchar_t *  s  ) 
 

Definition at line 186 of file OS_NS_stdlib.inl.

References ACE_TEXT_ALWAYS_CHAR, and ACE_TEXT_WCHAR_TO_TCHAR.

00187 {
00188 #  if !defined (ACE_LACKS_MKSTEMP)
00189   return ::mkstemp (ACE_TEXT_WCHAR_TO_TCHAR (ACE_TEXT_ALWAYS_CHAR (s)));
00190 #  else
00191   return ACE_OS::mkstemp_emulation (ACE_TEXT_WCHAR_TO_TCHAR (s));
00192 #  endif  /* !ACE_LACKS_MKSTEMP */
00193 }

ACE_INLINE ACE_HANDLE ACE_OS::mkstemp char *  s  ) 
 

Definition at line 175 of file OS_NS_stdlib.inl.

References ACE_TEXT_CHAR_TO_TCHAR.

Referenced by ACE_FILE_Connector::connect().

00176 {
00177 #if !defined (ACE_LACKS_MKSTEMP)
00178   return ::mkstemp (s);
00179 #else
00180   return ACE_OS::mkstemp_emulation (ACE_TEXT_CHAR_TO_TCHAR (s));
00181 #endif  /* !ACE_LACKS_MKSTEMP */
00182 }

ACE_INLINE wchar_t * ACE_OS::mktemp wchar_t *  s  ) 
 

Definition at line 209 of file OS_NS_stdlib.inl.

References strcpy().

00210 {
00211 #    if defined (ACE_WIN32)
00212   return ::_wmktemp (s);
00213 #    else
00214   // For narrow-char filesystems, we must convert the wide-char input to
00215   // a narrow-char string for mktemp(), then convert the name back to
00216   // wide-char for the caller.
00217   ACE_Wide_To_Ascii narrow_s (s);
00218   if (::mktemp (narrow_s.char_rep ()) == 0)
00219     return 0;
00220   ACE_Ascii_To_Wide wide_s (narrow_s.char_rep ());
00221   ACE_OS::strcpy (s, wide_s.wchar_rep ());
00222   return s;
00223 #    endif
00224 }

ACE_INLINE char * ACE_OS::mktemp char *  s  ) 
 

Definition at line 198 of file OS_NS_stdlib.inl.

Referenced by ACE_MMAP_Memory_Pool::ACE_MMAP_Memory_Pool(), and ACE_FILE_Addr::set().

00199 {
00200 # if defined (ACE_WIN32)
00201   return ::_mktemp (s);
00202 # else /* ACE_WIN32 */
00203   return ::mktemp (s);
00204 # endif /* ACE_WIN32 */
00205 }

time_t ACE_OS::mktime struct tm *  timeptr  ) 
 

Definition at line 307 of file OS_NS_time.cpp.

References ACE_OS_GUARD, ACE_OS_TRACE, and ACE_Time_Value::sec().

00308 {
00309   ACE_OS_TRACE ("ACE_OS::mktime");
00310 #   if defined (ACE_HAS_WINCE)
00311   SYSTEMTIME t_sys;
00312   FILETIME t_file;
00313   t_sys.wSecond = t->tm_sec;
00314   t_sys.wMinute = t->tm_min;
00315   t_sys.wHour = t->tm_hour;
00316   t_sys.wDay = t->tm_mday;
00317   t_sys.wMonth = t->tm_mon + 1;  // SYSTEMTIME is 1-indexed, tm is 0-indexed
00318   t_sys.wYear = t->tm_year + 1900; // SYSTEMTIME is real; tm is since 1900
00319   t_sys.wDayOfWeek = t->tm_wday;  // Ignored in below function call.
00320   if (SystemTimeToFileTime (&t_sys, &t_file) == 0)
00321     return -1;
00322   ACE_Time_Value tv (t_file);
00323   return tv.sec ();
00324 #   else
00325 #     if defined (ACE_HAS_THREADS)  &&  !defined (ACE_HAS_MT_SAFE_MKTIME)
00326   ACE_OS_GUARD
00327 #     endif /* ACE_HAS_THREADS  &&  ! ACE_HAS_MT_SAFE_MKTIME */
00328 
00329   ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::mktime (t), time_t, (time_t) -1);
00330 #   endif /* ACE_HAS_WINCE */
00331 }

ACE_INLINE void * ACE_OS::mmap void *  addr,
size_t  len,
int  prot,
int  flags,
ACE_HANDLE  handle,
off_t  off = 0,
ACE_HANDLE *  file_mapping = 0,
LPSECURITY_ATTRIBUTES  sa = 0,
const ACE_TCHAR file_mapping_name = 0
 

Definition at line 39 of file OS_NS_sys_mman.inl.

References ACE_BIT_ENABLED, ACE_DEFAULT_FILE_PERMS, ACE_FAIL_RETURN, ACE_MMAP_TYPE, ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_TCHAR, default_win32_security_attributes_r(), filesize(), MAP_FAILED, MAP_FIXED, MAP_PRIVATE, MAP_SHARED, and sprintf().

Referenced by ACE_Mutex::ACE_Mutex(), event_init(), ACE_Mem_Map::map_it(), sema_init(), and sendfile_emulation().

00048 {
00049   ACE_OS_TRACE ("ACE_OS::mmap");
00050 #if !defined (ACE_WIN32) || defined (ACE_HAS_PHARLAP)
00051   ACE_UNUSED_ARG (file_mapping_name);
00052 #endif /* !defined (ACE_WIN32) || defined (ACE_HAS_PHARLAP) */
00053 
00054 #if defined (ACE_WIN32) && !defined (ACE_HAS_PHARLAP)
00055 
00056 #  if defined(ACE_HAS_WINCE)
00057   ACE_UNUSED_ARG (addr);
00058   if (ACE_BIT_ENABLED (flags, MAP_FIXED))     // not supported
00059   {
00060     errno = EINVAL;
00061     return MAP_FAILED;
00062   }
00063 #  else
00064   if (!ACE_BIT_ENABLED (flags, MAP_FIXED))
00065     addr = 0;
00066   else if (addr == 0)   // can not map to address 0
00067   {
00068     errno = EINVAL;
00069     return MAP_FAILED;
00070   }
00071 #  endif
00072 
00073   int nt_flags = 0;
00074   ACE_HANDLE local_handle = ACE_INVALID_HANDLE;
00075 
00076   // Ensure that file_mapping is non-zero.
00077   if (file_mapping == 0)
00078     file_mapping = &local_handle;
00079 
00080   if (ACE_BIT_ENABLED (flags, MAP_PRIVATE))
00081     {
00082 #  if !defined(ACE_HAS_WINCE)
00083       prot = PAGE_WRITECOPY;
00084 #  endif  // ACE_HAS_WINCE
00085       nt_flags = FILE_MAP_COPY;
00086     }
00087   else if (ACE_BIT_ENABLED (flags, MAP_SHARED))
00088     {
00089       if (ACE_BIT_ENABLED (prot, PAGE_READONLY))
00090         nt_flags = FILE_MAP_READ;
00091       if (ACE_BIT_ENABLED (prot, PAGE_READWRITE))
00092         nt_flags = FILE_MAP_WRITE;
00093     }
00094 
00095   // Only create a new handle if we didn't have a valid one passed in.
00096   if (*file_mapping == ACE_INVALID_HANDLE)
00097     {
00098 #  if !defined(ACE_HAS_WINCE) && (!defined (ACE_HAS_WINNT4) || (ACE_HAS_WINNT4 == 0))
00099       int try_create = 1;
00100       if ((file_mapping_name != 0) && (*file_mapping_name != 0))
00101         {
00102           // On Win9x, we first try to OpenFileMapping to
00103           // file_mapping_name. Only if there is no mapping object
00104           // with that name, and the desired name is valid, do we try
00105           // CreateFileMapping.
00106 
00107           *file_mapping = ACE_TEXT_OpenFileMapping (nt_flags,
00108                                                     0,
00109                                                     file_mapping_name);
00110           if (*file_mapping != 0
00111               || (::GetLastError () == ERROR_INVALID_NAME
00112                   && ::GetLastError () == ERROR_FILE_NOT_FOUND))
00113             try_create = 0;
00114         }
00115 
00116       if (try_create)
00117 #  endif /* !ACE_HAS_WINCE && (ACE_HAS_WINNT4 || ACE_HAS_WINNT4 == 0) */
00118         {
00119           SECURITY_ATTRIBUTES sa_buffer;
00120           SECURITY_DESCRIPTOR sd_buffer;
00121           const LPSECURITY_ATTRIBUTES attr =
00122             ACE_OS::default_win32_security_attributes_r (sa,
00123                                                          &sa_buffer,
00124                                                          &sd_buffer);
00125 
00126           *file_mapping = ACE_TEXT_CreateFileMapping (file_handle,
00127                                                       attr,
00128                                                       prot,
00129                                                       0,
00130                                                       0,
00131                                                       file_mapping_name);
00132         }
00133     }
00134 
00135   if (*file_mapping == 0)
00136     ACE_FAIL_RETURN (MAP_FAILED);
00137 
00138 #  if defined (ACE_OS_EXTRA_MMAP_FLAGS)
00139   nt_flags |= ACE_OS_EXTRA_MMAP_FLAGS;
00140 #  endif /* ACE_OS_EXTRA_MMAP_FLAGS */
00141 
00142 #  if !defined (ACE_HAS_WINCE)
00143   void *addr_mapping = ::MapViewOfFileEx (*file_mapping,
00144                                           nt_flags,
00145                                           0,
00146                                           off,
00147                                           len,
00148                                           addr);
00149 #  else
00150   void *addr_mapping = ::MapViewOfFile (*file_mapping,
00151                                         nt_flags,
00152                                         0,
00153                                         off,
00154                                         len);
00155 #  endif /* ! ACE_HAS_WINCE */
00156 
00157   // Only close this down if we used the temporary.
00158   if (file_mapping == &local_handle)
00159     ::CloseHandle (*file_mapping);
00160 
00161   if (addr_mapping == 0)
00162     ACE_FAIL_RETURN (MAP_FAILED);
00163   else
00164     return addr_mapping;
00165 #elif defined (ACE_HAS_LYNXOS_BROKEN_MMAP)
00166   // The LynxOS mmap doesn't allow operations on plain
00167   // file descriptors.  So, create a shm object and use that.
00168   ACE_UNUSED_ARG (sa);
00169 
00170   char name [128];
00171   sprintf (name, "%d", file_handle);
00172 
00173   // Assumes that this was called by ACE_Mem_Map, so &file_mapping !=
00174   // 0.  Otherwise, we don't support the incomplete LynxOS mmap
00175   // implementation.  We do support it by creating a hidden shared
00176   // memory object, and using that for the mapping.
00177   int shm_handle;
00178   if (! file_mapping)
00179     file_mapping = &shm_handle;
00180   if ((*file_mapping = ::shm_open (name,
00181                                    O_RDWR | O_CREAT | O_TRUNC,
00182                                    ACE_DEFAULT_FILE_PERMS)) == -1)
00183     return MAP_FAILED;
00184   else
00185     {
00186       // The size of the shared memory object must be explicitly set on LynxOS.
00187       const off_t filesize = ACE_OS::filesize (file_handle);
00188       if (::ftruncate (*file_mapping, filesize) == -1)
00189         return MAP_FAILED;
00190       else
00191         {
00192 #  if defined (ACE_OS_EXTRA_MMAP_FLAGS)
00193           flags |= ACE_OS_EXTRA_MMAP_FLAGS;
00194 #  endif /* ACE_OS_EXTRA_MMAP_FLAGS */
00195           char *map = (char *) ::mmap ((ACE_MMAP_TYPE) addr,
00196                                        len,
00197                                        prot,
00198                                        flags,
00199                                        *file_mapping,
00200                                        off);
00201           if (map == MAP_FAILED)
00202             return MAP_FAILED;
00203           else
00204             // Finally, copy the file contents to the shared memory object.
00205             return ::read (file_handle, map, (int) filesize) == filesize
00206               ? map
00207               : MAP_FAILED;
00208         }
00209     }
00210 #elif !defined (ACE_LACKS_MMAP)
00211   ACE_UNUSED_ARG (sa);
00212 
00213 #  if defined (ACE_OS_EXTRA_MMAP_FLAGS)
00214   flags |= ACE_OS_EXTRA_MMAP_FLAGS;
00215 #  endif /* ACE_OS_EXTRA_MMAP_FLAGS */
00216   ACE_UNUSED_ARG (file_mapping);
00217 #  if defined (ACE_OPENVMS)
00218   ::fsync(file_handle);
00219 #  endif
00220   ACE_OSCALL_RETURN ((void *) ::mmap ((ACE_MMAP_TYPE) addr,
00221                                       len,
00222                                       prot,
00223                                       flags,
00224                                       file_handle,
00225                                       off),
00226                      void *, MAP_FAILED);
00227 #else
00228   ACE_UNUSED_ARG (addr);
00229   ACE_UNUSED_ARG (len);
00230   ACE_UNUSED_ARG (prot);
00231   ACE_UNUSED_ARG (flags);
00232   ACE_UNUSED_ARG (file_handle);
00233   ACE_UNUSED_ARG (off);
00234   ACE_UNUSED_ARG (file_mapping);
00235   ACE_UNUSED_ARG (sa);
00236   ACE_NOTSUP_RETURN (MAP_FAILED);
00237 #endif /* ACE_WIN32 && !ACE_HAS_PHARLAP */
00238 }

ACE_INLINE int ACE_OS::mprotect void *  addr,
size_t  len,
int  prot
 

Definition at line 246 of file OS_NS_sys_mman.inl.

References ACE_MMAP_TYPE, ACE_NOTSUP_RETURN, ACE_OS_TRACE, and mprotect().

Referenced by mprotect(), ACE_MMAP_Memory_Pool::protect(), and ACE_Mem_Map::protect().

00247 {
00248   ACE_OS_TRACE ("ACE_OS::mprotect");
00249 #if defined (ACE_WIN32) && !defined (ACE_HAS_PHARLAP)
00250   DWORD dummy; // Sigh!
00251   return ::VirtualProtect(addr, len, prot, &dummy) ? 0 : -1;
00252 #elif !defined (ACE_LACKS_MPROTECT)
00253   ACE_OSCALL_RETURN (::mprotect ((ACE_MMAP_TYPE) addr, len, prot), int, -1);
00254 #else
00255   ACE_UNUSED_ARG (addr);
00256   ACE_UNUSED_ARG (len);
00257   ACE_UNUSED_ARG (prot);
00258   ACE_NOTSUP_RETURN (-1);
00259 #endif /* ACE_WIN32 && !ACE_HAS_PHARLAP */
00260 }

ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE int ACE_OS::msgctl int  msqid,
int  cmd,
struct msqid_ds * 
 

Definition at line 10 of file OS_NS_sys_msg.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and msgctl().

Referenced by ACE_SV_Message_Queue::control(), and msgctl().

00011 {
00012   ACE_OS_TRACE ("ACE_OS::msgctl");
00013 #if defined (ACE_HAS_SYSV_IPC)
00014   ACE_OSCALL_RETURN (::msgctl (msqid, cmd, val), int, -1);
00015 #else
00016   ACE_UNUSED_ARG (msqid);
00017   ACE_UNUSED_ARG (cmd);
00018   ACE_UNUSED_ARG (val);
00019 
00020   ACE_NOTSUP_RETURN (-1);
00021 #endif /* ACE_HAS_SYSV_IPC */
00022 }

ACE_INLINE int ACE_OS::msgget key_t  key,
int  msgflg
 

Definition at line 25 of file OS_NS_sys_msg.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and msgget().

Referenced by msgget(), and ACE_SV_Message_Queue::open().

00026 {
00027   ACE_OS_TRACE ("ACE_OS::msgget");
00028 #if defined (ACE_HAS_SYSV_IPC)
00029   ACE_OSCALL_RETURN (::msgget (key, msgflg), int, -1);
00030 #else
00031   ACE_UNUSED_ARG (key);
00032   ACE_UNUSED_ARG (msgflg);
00033 
00034   ACE_NOTSUP_RETURN (-1);
00035 #endif /* ACE_HAS_SYSV_IPC */
00036 }

ACE_INLINE ssize_t ACE_OS::msgrcv int  int_id,
void *  buf,
size_t  len,
long  type,
int  flags
 

Definition at line 39 of file OS_NS_sys_msg.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and msgrcv().

Referenced by msgrcv(), and ACE_SV_Message_Queue::recv().

00041 {
00042   ACE_OS_TRACE ("ACE_OS::msgrcv");
00043 #if defined (ACE_HAS_SYSV_IPC)
00044   ACE_OSCALL_RETURN (::msgrcv (int_id, buf, len, type, flags),
00045                      int, -1);
00046 #else
00047   ACE_UNUSED_ARG (int_id);
00048   ACE_UNUSED_ARG (buf);
00049   ACE_UNUSED_ARG (len);
00050   ACE_UNUSED_ARG (type);
00051   ACE_UNUSED_ARG (flags);
00052 
00053   ACE_NOTSUP_RETURN (-1);
00054 #endif /* ACE_HAS_SYSV_IPC */
00055 }

ACE_INLINE int ACE_OS::msgsnd int  int_id,
const void *  buf,
size_t  len,
int  flags
 

Definition at line 58 of file OS_NS_sys_msg.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and msgsnd().

Referenced by msgsnd(), and ACE_SV_Message_Queue::send().

00059 {
00060   ACE_OS_TRACE ("ACE_OS::msgsnd");
00061 #if defined (ACE_HAS_SYSV_IPC)
00062 # if defined (ACE_HAS_NONCONST_MSGSND)
00063   ACE_OSCALL_RETURN (::msgsnd (int_id,
00064                                const_cast<void *> (buf), len, flags), int, -1);
00065 # else
00066   ACE_OSCALL_RETURN (::msgsnd (int_id, buf, len, flags), int, -1);
00067 # endif /* ACE_HAS_NONCONST_MSGSND */
00068 #else
00069   ACE_UNUSED_ARG (int_id);
00070   ACE_UNUSED_ARG (buf);
00071   ACE_UNUSED_ARG (len);
00072   ACE_UNUSED_ARG (flags);
00073 
00074   ACE_NOTSUP_RETURN (-1);
00075 #endif /* ACE_HAS_SYSV_IPC */
00076 }

ACE_INLINE int ACE_OS::msync void *  addr,
size_t  len,
int  sync
 

Definition at line 263 of file OS_NS_sys_mman.inl.

References ACE_ADAPT_RETVAL, ACE_MMAP_TYPE, ACE_NOTSUP_RETURN, ACE_OS_TRACE, and msync().

Referenced by msync(), ACE_MMAP_Memory_Pool::sync(), and ACE_Mem_Map::sync().

00264 {
00265   ACE_OS_TRACE ("ACE_OS::msync");
00266 #if defined (ACE_WIN32) && !defined (ACE_HAS_PHARLAP)
00267   ACE_UNUSED_ARG (sync);
00268 
00269   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::FlushViewOfFile (addr, len), ace_result_), int, -1);
00270 #elif !defined (ACE_LACKS_MSYNC)
00271 # if !defined (ACE_HAS_BROKEN_NETBSD_MSYNC)
00272   ACE_OSCALL_RETURN (::msync ((ACE_MMAP_TYPE) addr, len, sync), int, -1);
00273 # else
00274   ACE_OSCALL_RETURN (::msync ((ACE_MMAP_TYPE) addr, len), int, -1);
00275   ACE_UNUSED_ARG (sync);
00276 # endif /* ACE_HAS_BROKEN_NETBSD_MSYNC */
00277 #else
00278   ACE_UNUSED_ARG (addr);
00279   ACE_UNUSED_ARG (len);
00280   ACE_UNUSED_ARG (sync);
00281   ACE_NOTSUP_RETURN (-1);
00282 #endif /* ACE_WIN32 && !ACE_HAS_PHARLAP */
00283 }

ACE_INLINE int ACE_OS::munmap void *  addr,
size_t  len
 

Definition at line 286 of file OS_NS_sys_mman.inl.

References ACE_ADAPT_RETVAL, ACE_MMAP_TYPE, ACE_NOTSUP_RETURN, ACE_OS_TRACE, and munmap().

Referenced by event_destroy(), munmap(), ACE_Mutex::remove(), sendfile_emulation(), and ACE_Mem_Map::unmap().

00287 {
00288   ACE_OS_TRACE ("ACE_OS::munmap");
00289 #if defined (ACE_WIN32)
00290   ACE_UNUSED_ARG (len);
00291 
00292   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::UnmapViewOfFile (addr), ace_result_), int, -1);
00293 #elif !defined (ACE_LACKS_MMAP)
00294   ACE_OSCALL_RETURN (::munmap ((ACE_MMAP_TYPE) addr, len), int, -1);
00295 #else
00296   ACE_UNUSED_ARG (addr);
00297   ACE_UNUSED_ARG (len);
00298   ACE_NOTSUP_RETURN (-1);
00299 #endif /* ACE_WIN32 */
00300 }

int ACE_OS::mutex_destroy ACE_mutex_t *  m  ) 
 

Definition at line 2014 of file OS_NS_Thread.cpp.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, mutex_destroy(), and thread_mutex_destroy().

Referenced by event_destroy(), mutex_destroy(), ACE_Mutex::remove(), rwlock_destroy(), sema_destroy(), sema_init(), and thread_mutex_destroy().

02015 {
02016   ACE_OS_TRACE ("ACE_OS::mutex_destroy");
02017 #if defined (ACE_HAS_THREADS)
02018 # if defined (ACE_HAS_PTHREADS)
02019 #   if (defined (ACE_HAS_PTHREADS_DRAFT4) || defined (ACE_HAS_PTHREADS_DRAFT6))
02020   ACE_OSCALL_RETURN (::pthread_mutex_destroy (m), int, -1);
02021 #   else
02022   int result;
02023   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_mutex_destroy (m),
02024                      result), int, -1);
02025 #   endif /* ACE_HAS_PTHREADS_DRAFT4 || ACE_HAS_PTHREADS_DRAFT6*/
02026 # elif defined (ACE_HAS_STHREADS)
02027   int result;
02028   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::mutex_destroy (m), result), int, -1);
02029 # elif defined (ACE_HAS_WTHREADS)
02030   switch (m->type_)
02031 {
02032   case USYNC_PROCESS:
02033     ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::CloseHandle (m->proc_mutex_),
02034                           ace_result_),
02035     int, -1);
02036   case USYNC_THREAD:
02037     return ACE_OS::thread_mutex_destroy (&m->thr_mutex_);
02038   default:
02039     errno = EINVAL;
02040     return -1;
02041 }
02042   /* NOTREACHED */
02043 # elif defined (ACE_VXWORKS)
02044   return ::semDelete (*m) == OK ? 0 : -1;
02045 # endif /* Threads variety case */
02046 #else
02047   ACE_UNUSED_ARG (m);
02048   ACE_NOTSUP_RETURN (-1);
02049 #endif /* ACE_HAS_THREADS */
02050 }

int ACE_OS::mutex_init ACE_mutex_t *  m,
int  lock_scope,
const wchar_t *  name,
ACE_mutexattr_t *  arg = 0,
LPSECURITY_ATTRIBUTES  sa = 0,
int  lock_type = 0
 

Definition at line 2054 of file OS_NS_Thread.cpp.

References ACE_FAIL_RETURN, mutex_init(), and thread_mutex_init().

02060 {
02061 #if defined (ACE_HAS_THREADS) && defined (ACE_HAS_WTHREADS)
02062   m->type_ = lock_scope;
02063   SECURITY_ATTRIBUTES sa_buffer;
02064   SECURITY_DESCRIPTOR sd_buffer;
02065   switch (lock_scope)
02066   {
02067     case USYNC_PROCESS:
02068       m->proc_mutex_ =
02069       ::CreateMutexW (ACE_OS::default_win32_security_attributes_r
02070           (sa, &sa_buffer, &sd_buffer),
02071       FALSE,
02072       name);
02073       if (m->proc_mutex_ == 0)
02074         ACE_FAIL_RETURN (-1);
02075       else
02076         return 0;
02077     case USYNC_THREAD:
02078       return ACE_OS::thread_mutex_init (&m->thr_mutex_,
02079                                          lock_type,
02080                                          name,
02081                                          attributes);
02082   }
02083 
02084   errno = EINVAL;
02085   return -1;
02086 #else /* ACE_HAS_THREADS && ACE_HAS_WTHREADS */
02087   return ACE_OS::mutex_init (m,
02088                              lock_scope,
02089                              ACE_Wide_To_Ascii (name).char_rep (),
02090                              attributes,
02091                              sa,
02092                              lock_type);
02093 #endif /* ACE_HAS_THREADS && ACE_HAS_WTHREADS */
02094 }

int ACE_OS::mutex_init ACE_mutex_t *  m,
int  lock_scope = ACE_DEFAULT_SYNCH_TYPE,
const char *  name = 0,
ACE_mutexattr_t *  arg = 0,
LPSECURITY_ATTRIBUTES  sa = 0,
int  lock_type = 0
 

Definition at line 1832 of file OS_NS_Thread.cpp.

References ACE_ADAPT_RETVAL, ACE_FAIL_RETURN, ACE_NOTSUP_RETURN, memset(), mutex_init(), set_errno_to_last_error(), and thread_mutex_init().

Referenced by ACE_Mutex::ACE_Mutex(), event_init(), mutex_init(), sema_init(), and thread_mutex_init().

01838 {
01839   // ACE_OS_TRACE ("ACE_OS::mutex_init");
01840 #if defined (ACE_HAS_THREADS)
01841 # if defined (ACE_HAS_PTHREADS)
01842   ACE_UNUSED_ARG (name);
01843   ACE_UNUSED_ARG (sa);
01844 
01845 # if defined (ACE_VXWORKS) && (ACE_VXWORKS >= 0x600) && (ACE_VXWORKS <= 0x620)
01846   /* Tests show that VxWorks 6.x pthread lib does not only
01847    * require zeroing of mutex/condition objects to function correctly
01848    * but also of the attribute objects.
01849    */
01850   pthread_mutexattr_t l_attributes = {0};
01851 # else
01852   pthread_mutexattr_t l_attributes;
01853 # endif
01854 
01855   if (attributes == 0)
01856     attributes = &l_attributes;
01857   int result = 0;
01858   int attr_init = 0;  // have we initialized the local attributes.
01859 
01860   // Only do these initializations if the <attributes> parameter
01861   // wasn't originally set.
01862   if (attributes == &l_attributes)
01863   {
01864 #   if defined (ACE_HAS_PTHREADS_DRAFT4)
01865       if (::pthread_mutexattr_create (attributes) == 0)
01866 #   elif defined (ACE_HAS_PTHREADS_DRAFT7) || defined (ACE_HAS_PTHREADS_STD)
01867       if (ACE_ADAPT_RETVAL (::pthread_mutexattr_init (attributes), result) == 0)
01868 #   else /* draft 6 */
01869       if (::pthread_mutexattr_init (attributes) == 0)
01870 #   endif /* ACE_HAS_PTHREADS_DRAFT4 */
01871 {
01872   result = 0;
01873   attr_init = 1; // we have initialized these attributes
01874 }
01875       else
01876         result = -1;        // ACE_ADAPT_RETVAL used it for intermediate status
01877   }
01878 
01879   if (result == 0 && lock_scope != 0)
01880 {
01881 #   if defined (ACE_HAS_PTHREADS_DRAFT7) || defined (ACE_HAS_PTHREADS_STD)
01882 #     if defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_MUTEXATTR_PSHARED)
01883       (void) ACE_ADAPT_RETVAL (::pthread_mutexattr_setpshared (attributes,
01884                                                                lock_scope),
01885                                result);
01886 #     endif /* _POSIX_THREAD_PROCESS_SHARED && !ACE_LACKS_MUTEXATTR_PSHARED */
01887 #   else /* Pthreads draft 6 */
01888 #     if !defined (ACE_LACKS_MUTEXATTR_PSHARED)
01889       if (::pthread_mutexattr_setpshared (attributes, lock_scope) != 0)
01890         result = -1;
01891 #     endif /* ACE_LACKS_MUTEXATTR_PSHARED */
01892 #   endif /* ACE_HAS_PTHREADS_DRAFT7 || ACE_HAS_PTHREADS_STD */
01893 }
01894 
01895   if (result == 0 && lock_type != 0)
01896 {
01897 #   if defined (ACE_HAS_PTHREADS_DRAFT4)
01898 #     if defined (ACE_HAS_PTHREAD_MUTEXATTR_SETKIND_NP)
01899       if (::pthread_mutexattr_setkind_np (attributes, lock_type) != 0)
01900         result = -1;
01901 #     endif /* ACE_HAS_PTHREAD_MUTEXATTR_SETKIND_NP */
01902 #   elif defined (ACE_HAS_RECURSIVE_MUTEXES)
01903       (void) ACE_ADAPT_RETVAL (::pthread_mutexattr_settype (attributes,
01904                                                             lock_type),
01905                                result);
01906 #   endif /* ACE_HAS_PTHREADS_DRAFT4 */
01907 }
01908 
01909   if (result == 0)
01910 {
01911 #   if defined (ACE_VXWORKS)&& (ACE_VXWORKS >= 0x600) && (ACE_VXWORKS <= 0x620)
01912       /* VxWorks 6.x API reference states:
01913        * If the memory for the mutex variable object has been allocated
01914        *   dynamically, it is a good policy to always zero out the
01915        *   block of memory so as to avoid spurious EBUSY return code
01916        *   when calling this routine.
01917        * Tests shows this to be necessary.
01918        */
01919       ACE_OS::memset (m, 0, sizeof (*m));
01920 #   endif
01921 #   if defined (ACE_HAS_PTHREADS_DRAFT4)
01922       if (::pthread_mutex_init (m, *attributes) == 0)
01923 #   elif defined (ACE_HAS_PTHREADS_DRAFT7) || defined (ACE_HAS_PTHREADS_STD)
01924       if (ACE_ADAPT_RETVAL (::pthread_mutex_init (m, attributes), result) == 0)
01925 #   else
01926       if (::pthread_mutex_init (m, attributes) == 0)
01927 #   endif /* ACE_HAS_PTHREADS_DRAFT4 */
01928         result = 0;
01929       else
01930         result = -1;        // ACE_ADAPT_RETVAL used it for intermediate status
01931 }
01932 
01933   // Only do the deletions if the <attributes> parameter wasn't
01934   // originally set.
01935   if (attributes == &l_attributes && attr_init)
01936 #   if defined (ACE_HAS_PTHREADS_DRAFT4)
01937   ::pthread_mutexattr_delete (&l_attributes);
01938 #   else
01939   ::pthread_mutexattr_destroy (&l_attributes);
01940 #   endif /* ACE_HAS_PTHREADS_DRAFT4 */
01941 
01942   return result;
01943 # elif defined (ACE_HAS_STHREADS)
01944   ACE_UNUSED_ARG (name);
01945   ACE_UNUSED_ARG (sa);
01946   ACE_UNUSED_ARG (lock_type);
01947   int result;
01948   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::mutex_init (m,
01949                      lock_scope,
01950                      attributes),
01951   result),
01952   int, -1);
01953 # elif defined (ACE_HAS_WTHREADS)
01954   m->type_ = lock_scope;
01955 
01956   SECURITY_ATTRIBUTES sa_buffer;
01957   SECURITY_DESCRIPTOR sd_buffer;
01958   switch (lock_scope)
01959 {
01960   case USYNC_PROCESS:
01961 #   if defined (ACE_HAS_WINCE)
01962       // @@todo (brunsch) This idea should be moved into ACE_OS_Win32.
01963       m->proc_mutex_ =
01964   ::CreateMutexW (ACE_OS::default_win32_security_attributes_r
01965                           (sa, &sa_buffer, &sd_buffer),
01966                         FALSE,
01967                         ACE_Ascii_To_Wide (name).wchar_rep ());
01968 #   else /* ACE_HAS_WINCE */
01969       m->proc_mutex_ =
01970   ::CreateMutexA (ACE_OS::default_win32_security_attributes_r
01971                           (sa, &sa_buffer, &sd_buffer),
01972                         FALSE,
01973                         name);
01974 #   endif /* ACE_HAS_WINCE */
01975       if (m->proc_mutex_ == 0)
01976         ACE_FAIL_RETURN (-1);
01977       else
01978       {
01979           // Make sure to set errno to ERROR_ALREADY_EXISTS if necessary.
01980         ACE_OS::set_errno_to_last_error ();
01981         return 0;
01982       }
01983   case USYNC_THREAD:
01984     return ACE_OS::thread_mutex_init (&m->thr_mutex_,
01985                                        lock_type,
01986                                        name,
01987                                        attributes);
01988   default:
01989     errno = EINVAL;
01990     return -1;
01991 }
01992   /* NOTREACHED */
01993 
01994 # elif defined (ACE_VXWORKS)
01995   ACE_UNUSED_ARG (name);
01996   ACE_UNUSED_ARG (attributes);
01997   ACE_UNUSED_ARG (sa);
01998   ACE_UNUSED_ARG (lock_type);
01999 
02000   return (*m = ::semMCreate (lock_scope)) == 0 ? -1 : 0;
02001 # endif /* ACE_HAS_PTHREADS */
02002 #else
02003   ACE_UNUSED_ARG (m);
02004   ACE_UNUSED_ARG (lock_scope);
02005   ACE_UNUSED_ARG (name);
02006   ACE_UNUSED_ARG (attributes);
02007   ACE_UNUSED_ARG (sa);
02008   ACE_UNUSED_ARG (lock_type);
02009   ACE_NOTSUP_RETURN (-1);
02010 #endif /* ACE_HAS_THREADS */
02011 }

ACE_INLINE int ACE_OS::mutex_lock ACE_mutex_t *  m,
const ACE_Time_Value timeout
 

If == 0, calls <ACE_OS::mutex_lock(m)>. Otherwise, this method attempts to acquire a lock, but gives up if the lock has not been acquired by the given time, in which case it returns -1 with an errno on platforms that actually support timed mutexes. The timeout should be an absolute time. Note that the mutex should not be a recursive one, i.e., it should only be a standard mutex or an error checking mutex since some implementations of this method don't support recursive mutexes. If you want to use a recursive mutex see the methods below.

Definition at line 461 of file OS_NS_Thread.inl.

References mutex_lock().

00463 {
00464   return timeout == 0 ? ACE_OS::mutex_lock (m) : ACE_OS::mutex_lock (m, *timeout);
00465 }

int ACE_OS::mutex_lock ACE_mutex_t *  m,
const ACE_Time_Value timeout
 

This method attempts to acquire a lock, but gives up if the lock has not been acquired by the given time. If the lock is not acquired within the given amount of time, then this method returns -1 with an errno on platforms that actually support timed mutexes. The timeout should be an absolute time. Note that the mutex should not be a recursive one, i.e., it should only be a standard mutex or an error checking mutex since some implementations of this method don't support recursive mutexes. If you want to use a recursive mutex see the methods below.

Definition at line 2189 of file OS_NS_Thread.cpp.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_ONE_SECOND_IN_USECS, EBUSY, ETIME, ETIMEDOUT, ACE_Time_Value::msec(), ACE_Time_Value::sec(), set_errno_to_last_error(), timespec_t, and ACE_Time_Value::usec().

02191 {
02192 #if defined (ACE_HAS_THREADS) && defined (ACE_HAS_MUTEX_TIMEOUTS)
02193 
02194 #  if defined (ACE_HAS_PTHREADS)
02195   int result;
02196 
02197   // "timeout" should be an absolute time.
02198 
02199   timespec_t ts = timeout;  // Calls ACE_Time_Value::operator timespec_t().
02200 
02201   // Note that the mutex should not be a recursive one, i.e., it
02202   // should only be a standard mutex or an error checking mutex.
02203 
02204   ACE_OSCALL (ACE_ADAPT_RETVAL (::pthread_mutex_timedlock (m, &ts), result), int, -1, result);
02205 
02206   // We need to adjust this to make the errno values consistent.
02207   if (result == -1 && errno == ETIMEDOUT)
02208     errno = ETIME;
02209   return result;
02210 
02211 #  elif defined (ACE_HAS_WTHREADS)
02212   // Note that we must convert between absolute time (which is passed
02213   // as a parameter) and relative time (which is what the system call
02214   // expects).
02215   ACE_Time_Value relative_time (timeout - ACE_OS::gettimeofday ());
02216 
02217   switch (m->type_)
02218   {
02219     case USYNC_PROCESS:
02220       switch (::WaitForSingleObject (m->proc_mutex_,
02221                 relative_time.msec ()))
02222       {
02223         case WAIT_OBJECT_0:
02224         case WAIT_ABANDONED:
02225           // We will ignore abandonments in this method
02226           // Note that we still hold the lock
02227           return 0;
02228         case WAIT_TIMEOUT:
02229           errno = ETIME;
02230           return -1;
02231         default:
02232           // This is a hack, we need to find an appropriate mapping...
02233           ACE_OS::set_errno_to_last_error ();
02234           return -1;
02235       }
02236     case USYNC_THREAD:
02237       ACE_NOTSUP_RETURN (-1);
02238     default:
02239       errno = EINVAL;
02240       return -1;
02241   }
02242   /* NOTREACHED */
02243 
02244 #  elif defined (ACE_VXWORKS)
02245 
02246   // Note that we must convert between absolute time (which is passed
02247   // as a parameter) and relative time (which is what the system call
02248   // expects).
02249   ACE_Time_Value relative_time (timeout - ACE_OS::gettimeofday ());
02250 
02251   int ticks_per_sec = ::sysClkRateGet ();
02252 
02253   int ticks = relative_time.sec() * ticks_per_sec +
02254       relative_time.usec () * ticks_per_sec / ACE_ONE_SECOND_IN_USECS;
02255   if (::semTake (*m, ticks) == ERROR)
02256   {
02257     if (errno == S_objLib_OBJ_TIMEOUT)
02258         // Convert the VxWorks errno to one that's common for to ACE
02259         // platforms.
02260       errno = ETIME;
02261     else if (errno == S_objLib_OBJ_UNAVAILABLE)
02262       errno = EBUSY;
02263     return -1;
02264   }
02265   else
02266     return 0;
02267 #  endif /* ACE_HAS_PTHREADS */
02268 
02269 #else
02270   ACE_UNUSED_ARG (m);
02271   ACE_UNUSED_ARG (timeout);
02272   ACE_NOTSUP_RETURN (-1);
02273 #endif /* ACE_HAS_THREADS && ACE_HAS_MUTEX_TIMEOUTS */
02274 }

int ACE_OS::mutex_lock ACE_mutex_t *  m,
int &  abandoned
 

This method is only implemented for Win32. For abandoned mutexes, is set to 1 and 0 is returned.

Definition at line 2150 of file OS_NS_Thread.cpp.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, set_errno_to_last_error(), and thread_mutex_lock().

02152 {
02153   ACE_OS_TRACE ("ACE_OS::mutex_lock");
02154 #if defined (ACE_HAS_THREADS) && defined (ACE_HAS_WTHREADS)
02155   abandoned = 0;
02156   switch (m->type_)
02157   {
02158     case USYNC_PROCESS:
02159       switch (::WaitForSingleObject (m->proc_mutex_, INFINITE))
02160       {
02161         //
02162           // Timeout can't occur, so don't bother checking...
02163         //
02164         case WAIT_OBJECT_0:
02165           return 0;
02166         case WAIT_ABANDONED:
02167           abandoned = 1;
02168           return 0;  // something goofed, but we hold the lock ...
02169         default:
02170           // This is a hack, we need to find an appropriate mapping...
02171           ACE_OS::set_errno_to_last_error ();
02172           return -1;
02173       }
02174     case USYNC_THREAD:
02175       return ACE_OS::thread_mutex_lock (&m->thr_mutex_);
02176     default:
02177       errno = EINVAL;
02178       return -1;
02179   }
02180   /* NOTREACHED */
02181 #else
02182   ACE_UNUSED_ARG (m);
02183   ACE_UNUSED_ARG (abandoned);
02184   ACE_NOTSUP_RETURN (-1);
02185 #endif /* ACE_HAS_THREADS and ACE_HAS_WTHREADS */
02186 }

int ACE_OS::mutex_lock ACE_mutex_t *  m  ) 
 

Win32 note: Abandoned mutexes are not treated differently. 0 is returned since the calling thread does get the ownership.

Definition at line 2098 of file OS_NS_Thread.cpp.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, mutex_lock(), set_errno_to_last_error(), and thread_mutex_lock().

Referenced by ACE_Mutex::acquire(), ACE_Mutex::acquire_read(), ACE_Mutex::acquire_write(), event_pulse(), event_reset(), event_signal(), event_timedwait(), event_wait(), ACE_Recursive_Thread_Mutex::get_nesting_level(), ACE_Recursive_Thread_Mutex::get_thread_id(), mutex_lock(), rw_rdlock(), rw_tryrdlock(), rw_trywrlock(), rw_trywrlock_upgrade(), rw_unlock(), rw_wrlock(), sema_init(), sema_post(), sema_trywait(), sema_wait(), and thread_mutex_lock().

02099 {
02100   // ACE_OS_TRACE ("ACE_OS::mutex_lock");
02101 #if defined (ACE_HAS_THREADS)
02102 # if defined (ACE_HAS_PTHREADS)
02103   // Note, don't use "::" here since the following call is often a macro.
02104 #   if (defined (ACE_HAS_PTHREADS_DRAFT4) || defined (ACE_HAS_PTHREADS_DRAFT6))
02105   ACE_OSCALL_RETURN (pthread_mutex_lock (m), int, -1);
02106 #   else
02107   int result;
02108   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_mutex_lock (m), result),
02109                      int, -1);
02110 #   endif /* ACE_HAS_PTHREADS_DRAFT4 || ACE_HAS_PTHREADS_DRAFT6 */
02111 # elif defined (ACE_HAS_STHREADS)
02112   int result;
02113   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::mutex_lock (m), result), int, -1);
02114 # elif defined (ACE_HAS_WTHREADS)
02115   switch (m->type_)
02116 {
02117   case USYNC_PROCESS:
02118     switch (::WaitForSingleObject (m->proc_mutex_, INFINITE))
02119       {
02120         //
02121         // Timeout can't occur, so don't bother checking...
02122         //
02123       case WAIT_OBJECT_0:
02124       case WAIT_ABANDONED:
02125         // We will ignore abandonments in this method
02126         // Note that we still hold the lock
02127         return 0;
02128       default:
02129         // This is a hack, we need to find an appropriate mapping...
02130         ACE_OS::set_errno_to_last_error ();
02131         return -1;
02132       }
02133   case USYNC_THREAD:
02134     return ACE_OS::thread_mutex_lock (&m->thr_mutex_);
02135   default:
02136     errno = EINVAL;
02137     return -1;
02138 }
02139   /* NOTREACHED */
02140 # elif defined (ACE_VXWORKS)
02141   return ::semTake (*m, WAIT_FOREVER) == OK ? 0 : -1;
02142 # endif /* Threads variety case */
02143 #else
02144   ACE_UNUSED_ARG (m);
02145   ACE_NOTSUP_RETURN (-1);
02146 #endif /* ACE_HAS_THREADS */
02147 }

void ACE_OS::mutex_lock_cleanup void *  mutex  ) 
 

Handle asynchronous thread cancellation cleanup.

Definition at line 2430 of file OS_NS_Thread.cpp.

References ACE_OS_TRACE, and mutex_unlock().

02431 {
02432   ACE_OS_TRACE ("ACE_OS::mutex_lock_cleanup");
02433 #if defined (ACE_HAS_THREADS)
02434 # if defined (ACE_HAS_PTHREADS)
02435   ACE_mutex_t *p_lock = (ACE_mutex_t *) mutex;
02436   ACE_OS::mutex_unlock (p_lock);
02437 # else
02438   ACE_UNUSED_ARG (mutex);
02439 # endif /* ACE_HAS_PTHREADS */
02440 #else
02441   ACE_UNUSED_ARG (mutex);
02442 #endif /* ACE_HAS_THREADS */
02443 }

int ACE_OS::mutex_trylock ACE_mutex_t *  m,
int &  abandoned
 

This method is only implemented for Win32. For abandoned mutexes, is set to 1 and 0 is returned.

Definition at line 2351 of file OS_NS_Thread.cpp.

References ACE_NOTSUP_RETURN, EBUSY, set_errno_to_last_error(), and thread_mutex_trylock().

02352 {
02353 #if defined (ACE_HAS_THREADS) && defined (ACE_HAS_WTHREADS)
02354   abandoned = 0;
02355   switch (m->type_)
02356   {
02357     case USYNC_PROCESS:
02358     {
02359         // Try for 0 milliseconds - i.e. nonblocking.
02360       switch (::WaitForSingleObject (m->proc_mutex_, 0))
02361       {
02362         case WAIT_OBJECT_0:
02363           return 0;
02364         case WAIT_ABANDONED:
02365           abandoned = 1;
02366           return 0;  // something goofed, but we hold the lock ...
02367         case WAIT_TIMEOUT:
02368           errno = EBUSY;
02369           return -1;
02370         default:
02371           ACE_OS::set_errno_to_last_error ();
02372           return -1;
02373       }
02374     }
02375     case USYNC_THREAD:
02376       return ACE_OS::thread_mutex_trylock (&m->thr_mutex_);
02377     default:
02378       errno = EINVAL;
02379       return -1;
02380   }
02381   /* NOTREACHED */
02382 #else
02383   ACE_UNUSED_ARG (m);
02384   ACE_UNUSED_ARG (abandoned);
02385   ACE_NOTSUP_RETURN (-1);
02386 #endif /* ACE_HAS_THREADS and ACE_HAS_WTHREADS */
02387 }

int ACE_OS::mutex_trylock ACE_mutex_t *  m  ) 
 

Win32 note: Abandoned mutexes are not treated differently. 0 is returned since the calling thread does get the ownership.

Definition at line 2277 of file OS_NS_Thread.cpp.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, EBUSY, mutex_trylock(), set_errno_to_last_error(), and thread_mutex_trylock().

Referenced by mutex_trylock(), thread_mutex_trylock(), ACE_Mutex::tryacquire(), ACE_Mutex::tryacquire_read(), and ACE_Mutex::tryacquire_write().

02278 {
02279   ACE_OS_TRACE ("ACE_OS::mutex_trylock");
02280 #if defined (ACE_HAS_THREADS)
02281 # if defined (ACE_HAS_PTHREADS)
02282   // Note, don't use "::" here since the following call is often a macro.
02283 #   if (defined (ACE_HAS_PTHREADS_DRAFT4) || defined (ACE_HAS_PTHREADS_DRAFT6))
02284   int status = pthread_mutex_trylock (m);
02285   if (status == 1)
02286     status = 0;
02287   else if (status == 0) {
02288     status = -1;
02289     errno = EBUSY;
02290   }
02291   return status;
02292 #   else
02293   int result;
02294   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_mutex_trylock (m), result),
02295                      int, -1);
02296 #   endif /* ACE_HAS_PTHREADS_DRAFT4 || ACE_HAS_PTHREADS_DRAFT6 */
02297 # elif defined (ACE_HAS_STHREADS)
02298   int result;
02299   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::mutex_trylock (m), result), int, -1);
02300 # elif defined (ACE_HAS_WTHREADS)
02301   switch (m->type_)
02302 {
02303   case USYNC_PROCESS:
02304   {
02305         // Try for 0 milliseconds - i.e. nonblocking.
02306     switch (::WaitForSingleObject (m->proc_mutex_, 0))
02307     {
02308       case WAIT_OBJECT_0:
02309         return 0;
02310       case WAIT_ABANDONED:
02311             // We will ignore abandonments in this method.  Note that
02312             // we still hold the lock.
02313         return 0;
02314       case WAIT_TIMEOUT:
02315         errno = EBUSY;
02316         return -1;
02317       default:
02318         ACE_OS::set_errno_to_last_error ();
02319         return -1;
02320     }
02321   }
02322   case USYNC_THREAD:
02323     return ACE_OS::thread_mutex_trylock (&m->thr_mutex_);
02324   default:
02325     errno = EINVAL;
02326     return -1;
02327 }
02328   /* NOTREACHED */
02329 # elif defined (ACE_VXWORKS)
02330   if (::semTake (*m, NO_WAIT) == ERROR)
02331     if (errno == S_objLib_OBJ_UNAVAILABLE)
02332 {
02333         // couldn't get the semaphore
02334   errno = EBUSY;
02335   return -1;
02336 }
02337     else
02338       // error
02339       return -1;
02340     else
02341     // got the semaphore
02342       return 0;
02343 # endif /* Threads variety case */
02344 #else
02345   ACE_UNUSED_ARG (m);
02346   ACE_NOTSUP_RETURN (-1);
02347 #endif /* ACE_HAS_THREADS */
02348 }

int ACE_OS::mutex_unlock ACE_mutex_t *  m  ) 
 

Definition at line 2390 of file OS_NS_Thread.cpp.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, mutex_unlock(), and thread_mutex_unlock().

Referenced by event_pulse(), event_reset(), event_signal(), event_timedwait(), event_wait(), ACE_Recursive_Thread_Mutex::get_nesting_level(), ACE_Recursive_Thread_Mutex::get_thread_id(), mutex_lock_cleanup(), mutex_unlock(), ACE_Mutex::release(), rw_rdlock(), rw_tryrdlock(), rw_trywrlock(), rw_trywrlock_upgrade(), rw_unlock(), rw_wrlock(), sema_init(), sema_post(), sema_trywait(), sema_wait(), and thread_mutex_unlock().

02391 {
02392   ACE_OS_TRACE ("ACE_OS::mutex_unlock");
02393 #if defined (ACE_HAS_THREADS)
02394 # if defined (ACE_HAS_PTHREADS)
02395   // Note, don't use "::" here since the following call is often a macro.
02396 #   if (defined (ACE_HAS_PTHREADS_DRAFT4) || defined (ACE_HAS_PTHREADS_DRAFT6))
02397   ACE_OSCALL_RETURN (pthread_mutex_unlock (m), int, -1);
02398 #   else
02399   int result;
02400   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_mutex_unlock (m), result),
02401                      int, -1);
02402 #   endif /* ACE_HAS_PTHREADS_DRAFT4 || ACE_HAS_PTHREADS_DRAFT6 */
02403 # elif defined (ACE_HAS_STHREADS)
02404   int result;
02405   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::mutex_unlock (m), result), int, -1);
02406 # elif defined (ACE_HAS_WTHREADS)
02407   switch (m->type_)
02408 {
02409   case USYNC_PROCESS:
02410     ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::ReleaseMutex (m->proc_mutex_),
02411                           ace_result_),
02412     int, -1);
02413   case USYNC_THREAD:
02414     return ACE_OS::thread_mutex_unlock (&m->thr_mutex_);
02415   default:
02416     errno = EINVAL;
02417     return -1;
02418 }
02419   /* NOTREACHED */
02420 # elif defined (ACE_VXWORKS)
02421   return ::semGive (*m) == OK ? 0 : -1;
02422 # endif /* Threads variety case */
02423 #else
02424   ACE_UNUSED_ARG (m);
02425   ACE_NOTSUP_RETURN (-1);
02426 #endif /* ACE_HAS_THREADS */
02427 }

ACE_INLINE int ACE_OS::nanosleep const struct timespec requested,
struct timespec remaining = 0
 

Definition at line 381 of file OS_NS_time.inl.

References ACE_OS_TRACE, ACE_TIMESPEC_PTR, and sleep().

Referenced by sleep().

00383 {
00384   ACE_OS_TRACE ("ACE_OS::nanosleep");
00385 #if defined (ACE_HAS_CLOCK_GETTIME)
00386   // ::nanosleep () is POSIX 1003.1b.  So is ::clock_gettime ().  So,
00387   // if ACE_HAS_CLOCK_GETTIME is defined, then ::nanosleep () should
00388   // be available on the platform.  On Solaris 2.x, both functions
00389   // require linking with -lposix4.
00390   return ::nanosleep ((ACE_TIMESPEC_PTR) requested, remaining);
00391 #else
00392   ACE_UNUSED_ARG (remaining);
00393 
00394   // Convert into seconds and microseconds.
00395   ACE_Time_Value tv (requested->tv_sec,
00396                      requested->tv_nsec / 1000);
00397   return ACE_OS::sleep (tv);
00398 #endif /* ACE_HAS_CLOCK_GETTIME */
00399 }

long ACE_OS::num_processors void   ) 
 

Get the number of CPUs configured in the machine.

Definition at line 293 of file OS_NS_unistd.cpp.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and num_processors().

Referenced by num_processors(), and num_processors_online().

00294 {
00295   ACE_OS_TRACE ("ACE_OS::num_processors");
00296 
00297 #if defined (ACE_HAS_PHARLAP)
00298   return 1;
00299 #elif defined (ACE_WIN32)
00300   SYSTEM_INFO sys_info;
00301   ::GetSystemInfo (&sys_info);
00302   return sys_info.dwNumberOfProcessors;
00303 #elif defined (_SC_NPROCESSORS_CONF)
00304   return ::sysconf (_SC_NPROCESSORS_CONF);
00305 #elif defined (ACE_HAS_SYSCTL)
00306   int num_processors;
00307   int mib[2] = { CTL_HW, HW_NCPU };
00308   size_t len = sizeof (num_processors);
00309 
00310   sysctl(mib, 2, &num_processors, &len, NULL, 0);
00311   return num_processors;
00312 #else
00313   ACE_NOTSUP_RETURN (-1);
00314 #endif
00315 }

long ACE_OS::num_processors_online void   ) 
 

Get the number of CPUs currently online.

Definition at line 318 of file OS_NS_unistd.cpp.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and num_processors().

00319 {
00320   ACE_OS_TRACE ("ACE_OS::num_processors_online");
00321 
00322 #if defined (ACE_HAS_PHARLAP)
00323   return 1;
00324 #elif defined (ACE_WIN32)
00325   SYSTEM_INFO sys_info;
00326   ::GetSystemInfo (&sys_info);
00327   return sys_info.dwNumberOfProcessors;
00328 #elif defined (_SC_NPROCESSORS_ONLN)
00329   return ::sysconf (_SC_NPROCESSORS_ONLN);
00330 #elif defined (ACE_HAS_SYSCTL)
00331   int num_processors;
00332   int mib[2] = { CTL_HW, HW_NCPU };
00333   size_t len = sizeof (num_processors);
00334 
00335   sysctl(mib, 2, &num_processors, &len, NULL, 0);
00336   return num_processors;
00337 #elif defined (__hpux)
00338   struct pst_dynamic psd;
00339   if (::pstat_getdynamic (&psd, sizeof (psd), (size_t) 1, 0) != -1)
00340     return psd.psd_proc_cnt;
00341   else
00342     return -1;
00343 #else
00344   ACE_NOTSUP_RETURN (-1);
00345 #endif
00346 }

ACE_HANDLE ACE_OS::open const wchar_t *  filename,
int  mode,
int  perms = ACE_DEFAULT_OPEN_PERMS,
LPSECURITY_ATTRIBUTES  sa = 0
 

Definition at line 133 of file OS_NS_fcntl.cpp.

References access(), ACE_BIT_ENABLED, ACE_FAIL_RETURN, open(), and thread_mutex_lock().

00137 {
00138 #if defined (ACE_WIN32)
00139   // @@ (brunsch) Yuck, maybe there is a way to combine the code
00140   // here with the char version
00141 
00142   DWORD access = GENERIC_READ;
00143   if (ACE_BIT_ENABLED (mode, O_WRONLY))
00144     access = GENERIC_WRITE;
00145   else if (ACE_BIT_ENABLED (mode, O_RDWR))
00146     access = GENERIC_READ | GENERIC_WRITE;
00147 
00148   DWORD creation = OPEN_EXISTING;
00149 
00150   if ((mode & (_O_CREAT | _O_EXCL)) == (_O_CREAT | _O_EXCL))
00151     creation = CREATE_NEW;
00152   else if ((mode & (_O_CREAT | _O_TRUNC)) == (_O_CREAT | _O_TRUNC))
00153     creation = CREATE_ALWAYS;
00154   else if (ACE_BIT_ENABLED (mode, _O_CREAT))
00155     creation = OPEN_ALWAYS;
00156   else if (ACE_BIT_ENABLED (mode, _O_TRUNC))
00157     creation = TRUNCATE_EXISTING;
00158 
00159   DWORD flags = 0;
00160 
00161   if (ACE_BIT_ENABLED (mode, _O_TEMPORARY))
00162     flags |= FILE_FLAG_DELETE_ON_CLOSE | FILE_ATTRIBUTE_TEMPORARY;
00163 
00164   if (ACE_BIT_ENABLED (mode, FILE_FLAG_WRITE_THROUGH))
00165     flags |= FILE_FLAG_WRITE_THROUGH;
00166   if (ACE_BIT_ENABLED (mode, FILE_FLAG_OVERLAPPED))
00167     flags |= FILE_FLAG_OVERLAPPED;
00168   if (ACE_BIT_ENABLED (mode, FILE_FLAG_NO_BUFFERING))
00169     flags |= FILE_FLAG_NO_BUFFERING;
00170   if (ACE_BIT_ENABLED (mode, FILE_FLAG_RANDOM_ACCESS))
00171     flags |= FILE_FLAG_RANDOM_ACCESS;
00172   if (ACE_BIT_ENABLED (mode, FILE_FLAG_SEQUENTIAL_SCAN))
00173     flags |= FILE_FLAG_SEQUENTIAL_SCAN;
00174   if (ACE_BIT_ENABLED (mode, FILE_FLAG_DELETE_ON_CLOSE))
00175     flags |= FILE_FLAG_DELETE_ON_CLOSE;
00176   if (ACE_BIT_ENABLED (mode, FILE_FLAG_BACKUP_SEMANTICS))
00177     flags |= FILE_FLAG_BACKUP_SEMANTICS;
00178   if (ACE_BIT_ENABLED (mode, FILE_FLAG_POSIX_SEMANTICS))
00179     flags |= FILE_FLAG_POSIX_SEMANTICS;
00180 
00181   ACE_MT (ACE_thread_mutex_t *ace_os_monitor_lock = 0;)
00182 
00183   if (ACE_BIT_ENABLED (mode, _O_APPEND))
00184     {
00185       ACE_MT
00186         (
00187           ace_os_monitor_lock = static_cast <ACE_thread_mutex_t *> (
00188             ACE_OS_Object_Manager::preallocated_object[
00189               ACE_OS_Object_Manager::ACE_OS_MONITOR_LOCK]);
00190           ACE_OS::thread_mutex_lock (ace_os_monitor_lock);
00191         )
00192     }
00193 
00194   DWORD shared_mode = perms;
00195   SECURITY_ATTRIBUTES sa_buffer;
00196   SECURITY_DESCRIPTOR sd_buffer;
00197 
00198   ACE_HANDLE h = ::CreateFileW (filename,
00199                                 access,
00200                                 shared_mode,
00201                                 ACE_OS::default_win32_security_attributes_r
00202                                   (sa, &sa_buffer, &sd_buffer),
00203                                 creation,
00204                                 flags,
00205                                 0);
00206 
00207   if (ACE_BIT_ENABLED (mode, _O_APPEND))
00208     {
00209       if (h != ACE_INVALID_HANDLE)
00210         {
00211           ::SetFilePointer (h, 0, 0, FILE_END);
00212         }
00213 
00214       ACE_MT (ACE_OS::thread_mutex_unlock (ace_os_monitor_lock);)
00215     }
00216 
00217   if (h == ACE_INVALID_HANDLE)
00218     ACE_FAIL_RETURN (h);
00219   else
00220     return h;
00221 #else /* ACE_WIN32 */
00222   // Just emulate with ascii version
00223   return ACE_OS::open (ACE_Wide_To_Ascii (filename).char_rep (),
00224                        mode,
00225                        perms,
00226                        sa);
00227 #endif /* ACE_WIN32 */
00228 }

ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_HANDLE ACE_OS::open const char *  filename,
int  mode,
int  perms = ACE_DEFAULT_OPEN_PERMS,
LPSECURITY_ATTRIBUTES  sa = 0
 

The O_APPEND flag is only partly supported on Win32. If you specify O_APPEND, then the file pointer will be positioned at the end of the file initially during open, but it is not re-positioned at the end prior to each write, as specified by POSIX. This is generally good enough for typical situations, but it is ``not quite right'' in its semantics.

Definition at line 19 of file OS_NS_fcntl.cpp.

References access(), ACE_BIT_ENABLED, ACE_DEV_NULL, ACE_FAIL_RETURN, ACE_OS_TRACE, strcmp(), and thread_mutex_lock().

Referenced by ACE_Filecache_Object::ACE_Filecache_Object(), ACE_SPIPE_Connector::connect(), ACE_Handle_Gobbler::consume_handles(), creat(), dlopen(), filesize(), fopen(), ACE::get_handle(), ACE::handle_timed_open(), open(), ACE_Mem_Map::open(), ACE_FIFO_Recv::open(), ACE_Dev_Poll_Reactor::open(), ACE::open_temp_file(), ACE_Filecache_Object::release(), sema_init(), shm_open(), and truncate().

00023 {
00024   ACE_OS_TRACE ("ACE_OS::open");
00025 
00026 #if defined (ACE_WIN32)
00027   DWORD access = GENERIC_READ;
00028   if (ACE_BIT_ENABLED (mode, O_WRONLY))
00029     access = GENERIC_WRITE;
00030   else if (ACE_BIT_ENABLED (mode, O_RDWR))
00031     access = GENERIC_READ | GENERIC_WRITE;
00032 
00033   DWORD creation = OPEN_EXISTING;
00034 
00035   if ((mode & (_O_CREAT | _O_EXCL)) == (_O_CREAT | _O_EXCL))
00036     creation = CREATE_NEW;
00037   else if ((mode & (_O_CREAT | _O_TRUNC)) == (_O_CREAT | _O_TRUNC))
00038     creation = CREATE_ALWAYS;
00039   else if (ACE_BIT_ENABLED (mode, _O_CREAT))
00040     creation = OPEN_ALWAYS;
00041   else if (ACE_BIT_ENABLED (mode, _O_TRUNC))
00042     creation = TRUNCATE_EXISTING;
00043 
00044   DWORD flags = 0;
00045 
00046   if (ACE_BIT_ENABLED (mode, _O_TEMPORARY))
00047     flags |= FILE_FLAG_DELETE_ON_CLOSE | FILE_ATTRIBUTE_TEMPORARY;
00048 
00049   if (ACE_BIT_ENABLED (mode, FILE_FLAG_WRITE_THROUGH))
00050     flags |= FILE_FLAG_WRITE_THROUGH;
00051   if (ACE_BIT_ENABLED (mode, FILE_FLAG_OVERLAPPED))
00052     flags |= FILE_FLAG_OVERLAPPED;
00053   if (ACE_BIT_ENABLED (mode, FILE_FLAG_NO_BUFFERING))
00054     flags |= FILE_FLAG_NO_BUFFERING;
00055   if (ACE_BIT_ENABLED (mode, FILE_FLAG_RANDOM_ACCESS))
00056     flags |= FILE_FLAG_RANDOM_ACCESS;
00057   if (ACE_BIT_ENABLED (mode, FILE_FLAG_SEQUENTIAL_SCAN))
00058     flags |= FILE_FLAG_SEQUENTIAL_SCAN;
00059   if (ACE_BIT_ENABLED (mode, FILE_FLAG_DELETE_ON_CLOSE))
00060     flags |= FILE_FLAG_DELETE_ON_CLOSE;
00061   if (ACE_BIT_ENABLED (mode, FILE_FLAG_BACKUP_SEMANTICS))
00062     flags |= FILE_FLAG_BACKUP_SEMANTICS;
00063   if (ACE_BIT_ENABLED (mode, FILE_FLAG_POSIX_SEMANTICS))
00064     flags |= FILE_FLAG_POSIX_SEMANTICS;
00065 
00066   ACE_MT (ACE_thread_mutex_t *ace_os_monitor_lock = 0;)
00067 
00068   if (ACE_BIT_ENABLED (mode, _O_APPEND))
00069     {
00070       ACE_MT
00071         (
00072           ace_os_monitor_lock = static_cast <ACE_thread_mutex_t *> (
00073             ACE_OS_Object_Manager::preallocated_object[
00074               ACE_OS_Object_Manager::ACE_OS_MONITOR_LOCK]);
00075           ACE_OS::thread_mutex_lock (ace_os_monitor_lock);
00076         )
00077     }
00078 
00079   DWORD shared_mode = perms;
00080   SECURITY_ATTRIBUTES sa_buffer;
00081   SECURITY_DESCRIPTOR sd_buffer;
00082 
00083 #if defined (ACE_HAS_WINCE)
00084   ACE_HANDLE h = ::CreateFileW (ACE_Ascii_To_Wide (filename).wchar_rep (),
00085                                 access,
00086                                 shared_mode,
00087                                 ACE_OS::default_win32_security_attributes_r
00088                                   (sa, &sa_buffer, &sd_buffer),
00089                                 creation,
00090                                 flags,
00091                                 0);
00092 #else /* ACE_HAS_WINCE */
00093   ACE_HANDLE h = ::CreateFileA (filename,
00094                                 access,
00095                                 shared_mode,
00096                                 ACE_OS::default_win32_security_attributes_r
00097                                   (sa, &sa_buffer, &sd_buffer),
00098                                 creation,
00099                                 flags,
00100                                 0);
00101 #endif /* ACE_HAS_WINCE */
00102 
00103   if (ACE_BIT_ENABLED (mode, _O_APPEND))
00104     {
00105       if (h != ACE_INVALID_HANDLE)
00106         {
00107           ::SetFilePointer (h, 0, 0, FILE_END);
00108         }
00109 
00110       ACE_MT (ACE_OS::thread_mutex_unlock (ace_os_monitor_lock);)
00111     }
00112 
00113   if (h == ACE_INVALID_HANDLE)
00114     ACE_FAIL_RETURN (h);
00115   else
00116     return h;
00117 #elif defined (INTEGRITY)
00118   ACE_UNUSED_ARG (sa);
00119   if(!strcmp(filename,ACE_DEV_NULL)) {
00120       ACE_OSCALL_RETURN (::AllocateNullConsoleDescriptor(), ACE_HANDLE, -1);
00121   }
00122   else {
00123       ACE_OSCALL_RETURN (::open (filename, mode, perms), ACE_HANDLE, -1);
00124   }
00125 #else
00126   ACE_UNUSED_ARG (sa);
00127   ACE_OSCALL_RETURN (::open (filename, mode, perms), ACE_HANDLE, ACE_INVALID_HANDLE);
00128 #endif /* ACE_WIN32 */
00129 }

ACE_INLINE ACE_DIR * ACE_OS::opendir const ACE_TCHAR filename  ) 
 

Definition at line 32 of file OS_NS_dirent.inl.

References ACE_NOTSUP_RETURN, ACE_TCHAR, and ACE_TEXT_ALWAYS_CHAR.

Referenced by ACE_Dirent::open(), and scandir_emulation().

00033 {
00034 #if defined (ACE_HAS_DIRENT)
00035 #    if defined (ACE_WIN32) && defined (ACE_LACKS_OPENDIR)
00036   return ::ACE_OS::opendir_emulation (filename);
00037 #  elif defined (ACE_HAS_WOPENDIR) && defined (ACE_USES_WCHAR)
00038   return ::wopendir (filename);
00039 #    elif defined (ACE_HAS_NONCONST_OPENDIR)
00040   return ::opendir (const_cast<char *> (filename));
00041 #    else /* ! ACE_WIN32 && ACE_LACKS_OPENDIR */
00042   return ::opendir (ACE_TEXT_ALWAYS_CHAR (filename));
00043 #    endif /* ACE_WIN32 && ACE_LACKS_OPENDIR */
00044 #else
00045   ACE_UNUSED_ARG (filename);
00046   ACE_NOTSUP_RETURN (0);
00047 #endif /* ACE_HAS_DIRENT */
00048 }

ACE_INLINE void ACE_OS::perror const wchar_t *  s  ) 
 

Definition at line 740 of file OS_NS_stdio.inl.

References ACE_OS_TRACE.

00741 {
00742   ACE_OS_TRACE ("ACE_OS::perror");
00743 #if defined (ACE_HAS_WINCE)
00744   // @@ WINCE: How should this be handled
00745   ACE_UNUSED_ARG (s);
00746 #elif defined (ACE_WIN32)
00747   ::_wperror (s);
00748 #else
00749   ACE_Wide_To_Ascii n_s (s);
00750   ::perror (n_s.char_rep ());
00751 #endif /* ACE_HAS_WINCE */
00752 }

ACE_INLINE void ACE_OS::perror const char *  s  ) 
 

Definition at line 727 of file OS_NS_stdio.inl.

References ACE_OS_TRACE.

Referenced by ACE_ATM_Stream::get_peer_name(), and ACE_ATM_Acceptor::open().

00728 {
00729   ACE_OS_TRACE ("ACE_OS::perror");
00730 #if defined (ACE_HAS_WINCE)
00731   // @@ WINCE: How should this be handled
00732   ACE_UNUSED_ARG (s);
00733 #else
00734   ::perror (s);
00735 #endif /* ACE_HAS_WINCE */
00736 }

ACE_INLINE int ACE_OS::pipe ACE_HANDLE  handles[]  ) 
 

Definition at line 751 of file OS_NS_unistd.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, and pipe().

Referenced by ACE_SPIPE_Acceptor::create_new_instance(), ACE_Pipe::open(), and pipe().

00752 {
00753   ACE_OS_TRACE ("ACE_OS::pipe");
00754 # if defined (ACE_LACKS_PIPE)
00755   ACE_UNUSED_ARG (fds);
00756   ACE_NOTSUP_RETURN (-1);
00757 # elif defined (ACE_WIN32)
00758   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL
00759                         (::CreatePipe (&fds[0], &fds[1], 0, 0),
00760                          ace_result_), int, -1);
00761 # else
00762   ACE_OSCALL_RETURN (::pipe (fds), int, -1);
00763 # endif /* ACE_LACKS_PIPE */
00764 }

ACE_INLINE int ACE_OS::poll struct pollfd *  pollfds,
unsigned long  len,
const ACE_Time_Value tv
 

Definition at line 29 of file OS_NS_poll.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_Time_Value::msec(), and poll().

00032 {
00033   ACE_OS_TRACE ("ACE_OS::poll");
00034 #if defined (ACE_HAS_POLL)
00035   ACE_OSCALL_RETURN (::poll (pollfds, len, int (timeout.msec ())), int, -1);
00036 #else
00037   ACE_UNUSED_ARG (timeout);
00038   ACE_UNUSED_ARG (len);
00039   ACE_UNUSED_ARG (pollfds);
00040 
00041   ACE_NOTSUP_RETURN (-1);
00042 #endif /* ACE_HAS_POLL */
00043 }

ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE int ACE_OS::poll struct pollfd *  pollfds,
unsigned long  len,
const ACE_Time_Value tv = 0
 

Definition at line 11 of file OS_NS_poll.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and poll().

Referenced by ACE::handle_ready(), ACE::handle_timed_accept(), ACE::handle_timed_complete(), and poll().

00014 {
00015   ACE_OS_TRACE ("ACE_OS::poll");
00016 #if defined (ACE_HAS_POLL)
00017   int to = timeout == 0 ? -1 : int (timeout->msec ());
00018   ACE_OSCALL_RETURN (::poll (pollfds, len, to), int, -1);
00019 #else
00020   ACE_UNUSED_ARG (timeout);
00021   ACE_UNUSED_ARG (len);
00022   ACE_UNUSED_ARG (pollfds);
00023 
00024   ACE_NOTSUP_RETURN (-1);
00025 #endif /* ACE_HAS_POLL */
00026 }

ssize_t ACE_OS::pread ACE_HANDLE  handle,
void *  buf,
size_t  nbyte,
off_t  offset
 

Definition at line 374 of file OS_NS_unistd.cpp.

References ACE_OS_GUARD, lseek(), read(), and ssize_t.

00378 {
00379 # if defined (ACE_HAS_P_READ_WRITE)
00380 #   if defined (ACE_WIN32)
00381 
00382   ACE_OS_GUARD
00383 
00384   // Remember the original file pointer position
00385   DWORD original_position = ::SetFilePointer (handle,
00386                                               0,
00387                                               0,
00388                                               FILE_CURRENT);
00389 
00390   if (original_position == 0xFFFFFFFF)
00391     return -1;
00392 
00393   // Go to the correct position
00394   DWORD altered_position = ::SetFilePointer (handle,
00395                                              offset,
00396                                              0,
00397                                              FILE_BEGIN);
00398   if (altered_position == 0xFFFFFFFF)
00399     return -1;
00400 
00401   DWORD bytes_read;
00402 
00403 #     if defined (ACE_HAS_WINNT4) && (ACE_HAS_WINNT4 != 0)
00404 
00405   OVERLAPPED overlapped;
00406   overlapped.Internal = 0;
00407   overlapped.InternalHigh = 0;
00408   overlapped.Offset = offset;
00409   overlapped.OffsetHigh = 0;
00410   overlapped.hEvent = 0;
00411 
00412   BOOL result = ::ReadFile (handle,
00413                             buf,
00414                             static_cast <DWORD> (nbytes),
00415                             &bytes_read,
00416                             &overlapped);
00417 
00418   if (result == FALSE)
00419     {
00420       if (::GetLastError () != ERROR_IO_PENDING)
00421         return -1;
00422 
00423       else
00424         {
00425           result = ::GetOverlappedResult (handle,
00426                                           &overlapped,
00427                                           &bytes_read,
00428                                           TRUE);
00429           if (result == FALSE)
00430             return -1;
00431         }
00432     }
00433 
00434 #     else /* ACE_HAS_WINNT4 && (ACE_HAS_WINNT4 != 0) */
00435 
00436   BOOL result = ::ReadFile (handle,
00437                             buf,
00438                             nbytes,
00439                             &bytes_read,
00440                             0);
00441   if (result == FALSE)
00442     return -1;
00443 
00444 #     endif /* ACE_HAS_WINNT4 && (ACE_HAS_WINNT4 != 0) */
00445 
00446   // Reset the original file pointer position
00447   if (::SetFilePointer (handle,
00448                         original_position,
00449                         0,
00450                         FILE_BEGIN) == 0xFFFFFFFF)
00451     return -1;
00452 
00453   return (ssize_t) bytes_read;
00454 
00455 #   else /* ACE_WIN32 */
00456 
00457   return ::pread (handle, buf, nbytes, offset);
00458 
00459 #   endif /* ACE_WIN32 */
00460 
00461 # else /* ACE_HAS_P_READ_WRITE */
00462 
00463   ACE_OS_GUARD
00464 
00465   // Remember the original file pointer position
00466   off_t original_position = ACE_OS::lseek (handle,
00467                                            0,
00468                                            SEEK_CUR);
00469 
00470   if (original_position == -1)
00471     return -1;
00472 
00473   // Go to the correct position
00474   off_t altered_position = ACE_OS::lseek (handle,
00475                                           offset,
00476                                           SEEK_SET);
00477 
00478   if (altered_position == -1)
00479     return -1;
00480 
00481   ssize_t bytes_read = ACE_OS::read (handle,
00482                                      buf,
00483                                      nbytes);
00484 
00485   if (bytes_read == -1)
00486     return -1;
00487 
00488   if (ACE_OS::lseek (handle,
00489                      original_position,
00490                      SEEK_SET) == -1)
00491     return -1;
00492 
00493   return bytes_read;
00494 
00495 # endif /* ACE_HAD_P_READ_WRITE */
00496 }

int ACE_OS::printf const char *  format,
... 
 

Definition at line 253 of file OS_NS_stdio.cpp.

References ACE_OS_TRACE.

Referenced by ACE_ATM_Acceptor::accept(), ACE_ATM_Connector::add_leaf(), ACE_ATM_Connector::connect(), ACE_ATM_Acceptor::get_local_addr(), ACE_ATM_Stream::get_vpi_vci(), ACE_ATM_Stream::open(), ACE_ATM_Acceptor::open(), ACE_ATM_QoS::set_cbr_rate(), and ACE_ATM_Addr::string_to_addr().

00254 {
00255   ACE_OS_TRACE ("ACE_OS::printf");
00256   int result;
00257   va_list ap;
00258   va_start (ap, format);
00259   ACE_OSCALL (::vprintf (format, ap), int, -1, result);
00260   va_end (ap);
00261   return result;
00262 }

ACE_INLINE long ACE_OS::priority_control ACE_idtype_t  ,
ACE_id_t  ,
int  ,
void * 
 

Low-level interface to (2).

Can't call the following priocntl, because that's a macro on Solaris.

Definition at line 504 of file OS_NS_Thread.inl.

References ACE_id_t, ACE_idtype_t, ACE_NOTSUP_RETURN, and ACE_OS_TRACE.

Referenced by lwp_getparams(), ACE_Sched_Params::priority_max(), ACE_Sched_Params::priority_min(), scheduling_class(), and set_scheduling_params().

00505 {
00506   ACE_OS_TRACE ("ACE_OS::priority_control");
00507 #if defined (ACE_HAS_PRIOCNTL)
00508   ACE_OSCALL_RETURN (priocntl (idtype, identifier, cmd, static_cast<caddr_t> (arg)),
00509                      long, -1);
00510 #else  /* ! ACE_HAS_PRIOCNTL*/
00511   ACE_UNUSED_ARG (idtype);
00512   ACE_UNUSED_ARG (identifier);
00513   ACE_UNUSED_ARG (cmd);
00514   ACE_UNUSED_ARG (arg);
00515   ACE_NOTSUP_RETURN (-1);
00516 #endif /* ! ACE_HAS_PRIOCNTL*/
00517 }

ACE_INLINE int ACE_OS::pthread_sigmask int  how,
const sigset_t *  nsp,
sigset_t *  osp
 

Definition at line 27 of file OS_NS_signal.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, and pthread_sigmask().

Referenced by pthread_sigmask(), ACE_Asynch_Pseudo_Task::svc(), and thr_sigsetmask().

00028 {
00029 #if defined (ACE_HAS_PTHREADS_STD) && !defined (ACE_LACKS_PTHREAD_SIGMASK)
00030   int result;
00031   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_sigmask (how, nsp, osp),
00032                                        result),
00033                      int,
00034                      -1);
00035 #else /* !ACE_HAS_PTHREADS_STD && !ACE_LACKS_PTHREAD_SIGMASK */
00036   ACE_UNUSED_ARG (how);
00037   ACE_UNUSED_ARG (nsp);
00038   ACE_UNUSED_ARG (osp);
00039   ACE_NOTSUP_RETURN (-1);
00040 #endif /* ACE_HAS_PTHREADS_STD && !ACE_LACKS_PTHREAD_SIGMASK */
00041 }

ACE_INLINE int ACE_OS::putenv const wchar_t *  string  ) 
 

Definition at line 276 of file OS_NS_stdlib.inl.

References ACE_NOTSUP_RETURN, and ACE_OS_TRACE.

00277 {
00278   ACE_OS_TRACE ("ACE_OS::putenv");
00279 #if defined (ACE_HAS_WINCE)
00280   // WinCE doesn't have the concept of environment variables.
00281   ACE_UNUSED_ARG (string);
00282   ACE_NOTSUP_RETURN (-1);
00283 #else
00284   ACE_OSCALL_RETURN (::_wputenv (string), int, -1);
00285 #endif /* ACE_HAS_WINCE */
00286 }

ACE_INLINE int ACE_OS::putenv const char *  string  ) 
 

Definition at line 236 of file OS_NS_stdlib.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, free(), strchr(), and strdup().

Referenced by ACE_Process::spawn().

00237 {
00238   ACE_OS_TRACE ("ACE_OS::putenv");
00239 #if defined (ACE_HAS_WINCE)
00240   // WinCE don't have the concept of environment variables.
00241   ACE_UNUSED_ARG (string);
00242   ACE_NOTSUP_RETURN (-1);
00243 #elif defined (ACE_LACKS_PUTENV) && defined (ACE_HAS_SETENV)
00244   int result = 0;
00245   char* sp = ACE_OS::strchr (const_cast <char *> (string), '=');
00246   if (sp)
00247     {
00248       char* stmp = ACE_OS::strdup (string);
00249       if (stmp)
00250         {
00251           stmp[sp - string] = '\0';
00252           ACE_OSCALL (::setenv(stmp, sp+sizeof(char), 1), int, -1, result);
00253           ACE_OS::free (stmp);
00254         }
00255       else
00256         {
00257           errno = ENOMEM;
00258           result = -1;
00259         }
00260     }
00261   else
00262     {
00263       ACE_OSCALL (::setenv(string, "", 1), int, -1, result);
00264     }
00265   return result;
00266 #elif defined (ACE_LACKS_ENV) || defined (ACE_LACKS_PUTENV)
00267   ACE_UNUSED_ARG (string);
00268   ACE_NOTSUP_RETURN (0);
00269 #else /* ! ACE_HAS_WINCE */
00270   ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::putenv (const_cast <char *> (string)), int, -1);
00271 #endif /* ACE_HAS_WINCE */
00272 }

ACE_INLINE int ACE_OS::putmsg ACE_HANDLE  handle,
const struct strbuf ctl,
const struct strbuf data,
int  flags
 

Definition at line 139 of file OS_NS_stropts.inl.

References ACE_NEW_RETURN, ACE_OS_TRACE, ACE_STRBUF_TYPE, memcpy(), putmsg(), ssize_t, and write().

Referenced by putmsg(), putpmsg(), ACE_SPIPE_Stream::send(), and ACE_FIFO_Send_Msg::send().

00141 {
00142   ACE_OS_TRACE ("ACE_OS::putmsg");
00143 #if defined (ACE_HAS_STREAM_PIPES)
00144   ACE_OSCALL_RETURN (::putmsg (handle,
00145                                (ACE_STRBUF_TYPE) ctl,
00146                                (ACE_STRBUF_TYPE) data,
00147                                flags), int, -1);
00148 #else
00149   ACE_UNUSED_ARG (flags);
00150   ssize_t result;
00151   if (ctl == 0 && data == 0)
00152     {
00153       errno = EINVAL;
00154       return 0;
00155     }
00156   // Handle the two easy cases.
00157   else if (ctl != 0)
00158     {
00159       result =  ACE_OS::write (handle, ctl->buf, ctl->len);
00160       return static_cast<int> (result);
00161     }
00162   else if (data != 0)
00163     {
00164       result = ACE_OS::write (handle, data->buf, data->len);
00165       return static_cast<int> (result);
00166     }
00167   else
00168     {
00169       // This is the hard case.
00170       char *buf;
00171       ACE_NEW_RETURN (buf, char [ctl->len + data->len], -1);
00172       ACE_OS::memcpy (buf, ctl->buf, ctl->len);
00173       ACE_OS::memcpy (buf + ctl->len, data->buf, data->len);
00174       result = ACE_OS::write (handle, buf, ctl->len + data->len);
00175       delete [] buf;
00176       return static_cast<int> (result);
00177     }
00178 #endif /* ACE_HAS_STREAM_PIPES */
00179 }

ACE_INLINE int ACE_OS::putpmsg ACE_HANDLE  handle,
const struct strbuf ctl,
const struct strbuf data,
int  band,
int  flags
 

Definition at line 182 of file OS_NS_stropts.inl.

References ACE_OS_TRACE, ACE_STRBUF_TYPE, putmsg(), and putpmsg().

Referenced by putpmsg(), and ACE_SPIPE_Stream::send().

00187 {
00188   ACE_OS_TRACE ("ACE_OS::putpmsg");
00189 #if defined (ACE_HAS_STREAM_PIPES)
00190   ACE_OSCALL_RETURN (::putpmsg (handle,
00191                                 (ACE_STRBUF_TYPE) ctl,
00192                                 (ACE_STRBUF_TYPE) data,
00193                                 band, flags), int, -1);
00194 #else
00195   ACE_UNUSED_ARG (flags);
00196   ACE_UNUSED_ARG (band);
00197   return ACE_OS::putmsg (handle, ctl, data, flags);
00198 #endif /* ACE_HAS_STREAM_PIPES */
00199 }

ACE_INLINE int ACE_OS::puts const wchar_t *  s  ) 
 

Definition at line 764 of file OS_NS_stdio.inl.

References ACE_OS_TRACE, and puts().

00765 {
00766   ACE_OS_TRACE ("ACE_OS::puts");
00767 #if defined (ACE_WIN32)
00768   ACE_OSCALL_RETURN (::_putws (s), int, -1);
00769 #else /* ACE_WIN32 */
00770   // There's no putws()...
00771   ACE_Wide_To_Ascii n_s (s);
00772   ACE_OSCALL_RETURN (::puts (n_s.char_rep ()), int, -1);
00773 #endif /* ACE_WIN32 */
00774 }

ACE_INLINE int ACE_OS::puts const char *  s  ) 
 

Definition at line 756 of file OS_NS_stdio.inl.

References ACE_OS_TRACE, and puts().

Referenced by puts().

00757 {
00758   ACE_OS_TRACE ("ACE_OS::puts");
00759   ACE_OSCALL_RETURN (::puts (s), int, -1);
00760 }

ssize_t ACE_OS::pwrite ACE_HANDLE  handle,
const void *  buf,
size_t  nbyte,
ACE_LOFF_T  offset
 

Definition at line 499 of file OS_NS_unistd.cpp.

References ACE_LOFF_T, ACE_OS_GUARD, lseek(), ssize_t, and write().

Referenced by ACE_Filecache_Object::ACE_Filecache_Object(), and ACE_Mem_Map::map_it().

00503 {
00504 # if defined (ACE_HAS_P_READ_WRITE)
00505 #   if defined (ACE_WIN32)
00506 
00507   ACE_OS_GUARD
00508 
00509   // Remember the original file pointer position
00510   DWORD original_position = ::SetFilePointer (handle,
00511                                               0,
00512                                               0,
00513                                               FILE_CURRENT);
00514 
00515   if (original_position == 0xFFFFFFFF)
00516     return -1;
00517 
00518   // Go to the correct position
00519   LARGE_INTEGER loffset;
00520   loffset.QuadPart = offset;
00521   DWORD altered_position = ::SetFilePointerEx (handle,
00522                                                loffset,
00523                                                0,
00524                                                FILE_BEGIN);
00525   if (altered_position == 0xFFFFFFFF)
00526     return -1;
00527 
00528   DWORD bytes_written;
00529 
00530 #     if defined (ACE_HAS_WINNT4) && (ACE_HAS_WINNT4 != 0)
00531 
00532   OVERLAPPED overlapped;
00533   overlapped.Internal = 0;
00534   overlapped.InternalHigh = 0;
00535   overlapped.Offset = offset;
00536   overlapped.OffsetHigh = 0;
00537   overlapped.hEvent = 0;
00538 
00539   BOOL result = ::WriteFile (handle,
00540                              buf,
00541                              static_cast <DWORD> (nbytes),
00542                              &bytes_written,
00543                              &overlapped);
00544 
00545   if (result == FALSE)
00546     {
00547       if (::GetLastError () != ERROR_IO_PENDING)
00548         return -1;
00549 
00550       else
00551         {
00552           result = ::GetOverlappedResult (handle,
00553                                           &overlapped,
00554                                           &bytes_written,
00555                                           TRUE);
00556           if (result == FALSE)
00557             return -1;
00558         }
00559     }
00560 
00561 #     else /* ACE_HAS_WINNT4 && (ACE_HAS_WINNT4 != 0) */
00562 
00563   BOOL result = ::WriteFile (handle,
00564                              buf,
00565                              nbytes,
00566                              &bytes_written,
00567                              0);
00568   if (result == FALSE)
00569     return -1;
00570 
00571 #     endif /* ACE_HAS_WINNT4 && (ACE_HAS_WINNT4 != 0) */
00572 
00573   // Reset the original file pointer position
00574   if (::SetFilePointer (handle,
00575                         original_position,
00576                         0,
00577                         FILE_BEGIN) == 0xFFFFFFFF)
00578     return -1;
00579 
00580   return (ssize_t) bytes_written;
00581 
00582 #   else /* ACE_WIN32 */
00583 
00584   return ::pwrite (handle, buf, nbytes, offset);
00585 #   endif /* ACE_WIN32 */
00586 # else /* ACE_HAS_P_READ_WRITE */
00587 
00588   ACE_OS_GUARD
00589 
00590   // Remember the original file pointer position
00591   off_t original_position = ACE_OS::lseek (handle,
00592                                            0,
00593                                            SEEK_CUR);
00594   if (original_position == -1)
00595     return -1;
00596 
00597   // Go to the correct position
00598   off_t altered_position = ACE_OS::lseek (handle,
00599                                           offset,
00600                                           SEEK_SET);
00601   if (altered_position == -1)
00602     return -1;
00603 
00604   ssize_t bytes_written = ACE_OS::write (handle,
00605                                          buf,
00606                                          nbytes);
00607   if (bytes_written == -1)
00608     return -1;
00609 
00610   if (ACE_OS::lseek (handle,
00611                      original_position,
00612                      SEEK_SET) == -1)
00613     return -1;
00614 
00615   return bytes_written;
00616 # endif /* ACE_HAD_P_READ_WRITE */
00617 }

ACE_INLINE void ACE_OS::qsort void *  base,
size_t  nel,
size_t  width,
ACE_COMPARE_FUNC 
 

Definition at line 290 of file OS_NS_stdlib.inl.

References ACE_COMPARE_FUNC.

Referenced by scandir_emulation().

00294 {
00295 #if !defined (ACE_LACKS_QSORT)
00296   ::qsort (base, nel, width, compar);
00297 #else
00298   ACE_UNUSED_ARG (base);
00299   ACE_UNUSED_ARG (nel);
00300   ACE_UNUSED_ARG (width);
00301   ACE_UNUSED_ARG (compar);
00302 #endif /* !ACE_LACKS_QSORT */
00303 }

ACE_INLINE int ACE_OS::rand void   ) 
 

Definition at line 306 of file OS_NS_stdlib.inl.

References ACE_OS_TRACE, and rand().

Referenced by ACE_Utils::UUID_Generator::init(), and rand().

00307 {
00308   ACE_OS_TRACE ("ACE_OS::rand");
00309   ACE_OSCALL_RETURN (::rand (), int, -1);
00310 }

ACE_INLINE int ACE_OS::rand_r ACE_RANDR_TYPE seed  ) 
 

Definition at line 336 of file OS_NS_stdlib.inl.

References ACE_OS_TRACE, and ACE_RANDR_TYPE.

00337 {
00338   ACE_OS_TRACE ("ACE_OS::rand_r");
00339 
00340   long new_seed = (long)(seed);
00341   if (new_seed == 0)
00342     new_seed = 0x12345987;
00343   long temp = new_seed / 127773;
00344   new_seed = 16807 * (new_seed - temp * 127773) - 2836 * temp;
00345   if (new_seed < 0)
00346     new_seed += 2147483647;
00347   (seed) = (unsigned int)new_seed;
00348   return (int)(new_seed & RAND_MAX);
00349 }

ACE_INLINE ssize_t ACE_OS::read ACE_HANDLE  handle,
void *  buf,
size_t  len,
ACE_OVERLAPPED
 

Definition at line 714 of file OS_NS_unistd.inl.

References ACE_FAIL_RETURN, ACE_OS_TRACE, ACE_OVERLAPPED, read(), and ssize_t.

00716 {
00717   ACE_OS_TRACE ("ACE_OS::read");
00718   overlapped = overlapped;
00719 #if defined (ACE_WIN32)
00720   DWORD ok_len;
00721   DWORD short_len = static_cast<DWORD> (len);
00722   if (::ReadFile (handle, buf, short_len, &ok_len, overlapped))
00723     return (ssize_t) ok_len;
00724   else
00725     ACE_FAIL_RETURN (-1);
00726 #else
00727   return ACE_OS::read (handle, buf, len);
00728 #endif /* ACE_WIN32 */
00729 }

ACE_INLINE ssize_t ACE_OS::read ACE_HANDLE  handle,
void *  buf,
size_t  len
 

Definition at line 674 of file OS_NS_unistd.inl.

References ACE_FAIL_RETURN, ACE_OS_TRACE, EWOULDBLOCK, and ssize_t.

Referenced by ACE_UPIPE_Acceptor::accept(), pread(), read(), read_n(), ACE_SPIPE_Stream::recv(), ACE_SOCK_IO::recv(), ACE_Pipe::recv(), ACE_FILE_IO::recv(), ACE_FIFO_Recv_Msg::recv(), ACE_FIFO_Recv::recv(), ACE_DEV_IO::recv(), ACE::recv_i(), sema_trywait(), and sema_wait().

00675 {
00676   ACE_OS_TRACE ("ACE_OS::read");
00677 #if defined (ACE_WIN32)
00678   DWORD ok_len;
00679   if (::ReadFile (handle, buf, static_cast<DWORD> (len), &ok_len, 0))
00680     return (ssize_t) ok_len;
00681   else
00682     ACE_FAIL_RETURN (-1);
00683 #else
00684 
00685   ssize_t result;
00686 
00687 # if defined (ACE_HAS_CHARPTR_SOCKOPT)
00688   ACE_OSCALL (::read (handle, static_cast <char *> (buf), len), ssize_t, -1, result);
00689 # else
00690   ACE_OSCALL (::read (handle, buf, len), ssize_t, -1, result);
00691 # endif /* ACE_HAS_CHARPTR_SOCKOPT */
00692 
00693 # if !(defined (EAGAIN) && defined (EWOULDBLOCK) && EAGAIN == EWOULDBLOCK)
00694   // Optimize this code out if we can detect that EAGAIN ==
00695   // EWOULDBLOCK at compile time.  If we cannot detect equality at
00696   // compile-time (e.g. if EAGAIN or EWOULDBLOCK are not preprocessor
00697   // macros) perform the check at run-time.  The goal is to avoid two
00698   // TSS accesses in the _REENTRANT case when EAGAIN == EWOULDBLOCK.
00699   if (result == -1
00700 #  if !defined (EAGAIN) || !defined (EWOULDBLOCK)
00701       && EAGAIN != EWOULDBLOCK
00702 #  endif  /* !EAGAIN || !EWOULDBLOCK */
00703       && errno == EAGAIN)
00704     {
00705       errno = EWOULDBLOCK;
00706     }
00707 # endif /* EAGAIN != EWOULDBLOCK*/
00708 
00709   return result;
00710 #endif /* ACE_WIN32 */
00711 }

ssize_t ACE_OS::read_n ACE_HANDLE  handle,
void *  buf,
size_t  len,
size_t *  bytes_transferred = 0
 

Receive bytes into from (uses the <ACE_OS::read> call, which uses the system call on UNIX and the call on Win32). If errors occur, -1 is returned. If EOF occurs, 0 is returned. Whatever data has been read will be returned to the caller through<bytes_transferred>.

Definition at line 349 of file OS_NS_unistd.cpp.

References read(), and ssize_t.

Referenced by ACE::read_n().

00353 {
00354   size_t temp;
00355   size_t &bytes_transferred = bt == 0 ? temp : *bt;
00356   ssize_t n;
00357 
00358   for (bytes_transferred = 0;
00359        bytes_transferred < len;
00360        bytes_transferred += n)
00361     {
00362       n = ACE_OS::read (handle,
00363                         (char *) buf + bytes_transferred,
00364                         len - bytes_transferred);
00365 
00366       if (n == -1 || n == 0)
00367         return n;
00368     }
00369 
00370   return bytes_transferred;
00371 }

ACE_INLINE struct ACE_DIRENT * ACE_OS::readdir ACE_DIR  ) 
 

Definition at line 52 of file OS_NS_dirent.inl.

References ACE_DIR, and ACE_NOTSUP_RETURN.

Referenced by ACE_Dirent::read(), readdir_r(), and scandir_emulation().

00053 {
00054 #if defined (ACE_HAS_DIRENT)
00055 #    if defined (ACE_WIN32) && defined (ACE_LACKS_READDIR)
00056   return ACE_OS::readdir_emulation (d);
00057 #  elif defined (ACE_HAS_WREADDIR) && defined (ACE_USES_WCHAR)
00058   return ::wreaddir (d);
00059 #    else /* ACE_WIN32 && ACE_LACKS_READDIR */
00060   return ::readdir (d);
00061 #    endif /* ACE_WIN32 && ACE_LACKS_READDIR */
00062 #else
00063   ACE_UNUSED_ARG (d);
00064   ACE_NOTSUP_RETURN (0);
00065 #endif /* ACE_HAS_DIRENT */
00066 }

ACE_INLINE int ACE_OS::readdir_r ACE_DIR dirp,
struct ACE_DIRENT *  entry,
struct ACE_DIRENT **  result
 

Definition at line 69 of file OS_NS_dirent.inl.

References ACE_DIR, ACE_NOTSUP_RETURN, and readdir().

Referenced by ACE_Dirent::read().

00072 {
00073 #if !defined (ACE_HAS_REENTRANT_FUNCTIONS)
00074   ACE_UNUSED_ARG (entry);
00075   // <result> has better not be 0!
00076   *result = ACE_OS::readdir (dirp);
00077   if (*result)
00078     return 0; // Keep iterating
00079   else
00080     return 1; // Oops, some type of error!
00081 #elif defined (ACE_HAS_DIRENT)  &&  !defined (ACE_LACKS_READDIR_R)
00082 #  if (defined (sun) && (defined (_POSIX_PTHREAD_SEMANTICS) || \
00083                         (_FILE_OFFSET_BITS == 64) || \
00084                         (_POSIX_C_SOURCE - 0 >= 199506L))) || \
00085       (!defined (sun) && (defined (ACE_HAS_PTHREADS_STD) || \
00086                          defined (ACE_HAS_PTHREADS_DRAFT7) || \
00087                          defined (__USE_POSIX) || \
00088                          defined (__FreeBSD__) || \
00089                          defined (HPUX_11)))
00090 #    if defined (__GNUG__) && defined (DIGITAL_UNIX)
00091   return readdir_r (dirp, entry, result);
00092 #    else
00093   return ::readdir_r (dirp, entry, result);
00094 #    endif /* defined (__GNUG__) && defined (DIGITAL_UNIX) */
00095 #  else  /* ! POSIX.1c - this is draft 4 or draft 6 */
00096 #    if defined(__GNUC__) && defined (_AIX)
00097         return ::readdir_r (dirp, entry, result);
00098 #    else
00099     // <result> had better not be 0!
00100     *result = ::readdir_r (dirp, entry);
00101     return 0;
00102 #    endif /* AIX */
00103 #  endif /* ! POSIX.1c */
00104 #else  /* ! ACE_HAS_DIRENT  ||  ACE_LACKS_READDIR_R */
00105   ACE_UNUSED_ARG (dirp);
00106   ACE_UNUSED_ARG (entry);
00107   ACE_UNUSED_ARG (result);
00108   ACE_NOTSUP_RETURN (0);
00109 
00110 #endif /* ACE_HAS_REENTRANT_FUNCTIONS */
00111 }

ACE_INLINE ssize_t ACE_OS::readlink const char *  path,
char *  buf,
size_t  bufsiz
 

Definition at line 732 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, readlink(), and ssize_t.

Referenced by readlink().

00733 {
00734   ACE_OS_TRACE ("ACE_OS::readlink");
00735 # if defined (ACE_LACKS_READLINK)
00736   ACE_UNUSED_ARG (path);
00737   ACE_UNUSED_ARG (buf);
00738   ACE_UNUSED_ARG (bufsiz);
00739   ACE_NOTSUP_RETURN (-1);
00740 # else
00741 #   if !defined(ACE_HAS_NONCONST_READLINK)
00742       ACE_OSCALL_RETURN (::readlink (path, buf, bufsiz), ssize_t, -1);
00743 #   else
00744       ACE_OSCALL_RETURN (
00745         ::readlink (const_cast <char *>(path), buf, bufsiz), ssize_t, -1);
00746 #   endif
00747 # endif /* ACE_LACKS_READLINK */
00748 }

ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE ssize_t ACE_OS::readv ACE_HANDLE  handle,
const iovec iov,
int  iovlen
 

Definition at line 10 of file OS_NS_sys_uio.inl.

References ACE_OS_TRACE, and ssize_t.

Referenced by ACE::readv_n(), ACE_SPIPE_Stream::recv(), ACE_Pipe::recv(), ACE_FILE_IO::recv(), ACE_DEV_IO::recv(), recvv(), ACE_SPIPE_Stream::recvv_n(), ACE_Pipe::recvv_n(), and ACE_FILE_IO::recvv_n().

00013 {
00014   ACE_OS_TRACE ("ACE_OS::readv");
00015 #if defined (ACE_LACKS_READV)
00016   ACE_OSCALL_RETURN (ACE_OS::readv_emulation (handle, iov, iovlen),
00017                      ssize_t,
00018                      -1);
00019 #else /* ACE_LACKS_READV */
00020 #if defined (ACE_HAS_NONCONST_READV)
00021   ACE_OSCALL_RETURN (::readv (handle,
00022                               const_cast<iovec *>(iov),
00023                               iovlen), ssize_t, -1);
00024 #else
00025   ACE_OSCALL_RETURN (::readv (handle,
00026                               iov,
00027                               iovlen), ssize_t, -1);
00028 #endif /* ACE_HAS_NONCONST_READV */
00029 #endif /* ACE_LACKS_READV */
00030 }

void * ACE_OS::realloc void *  ,
size_t 
 

Definition at line 269 of file OS_NS_stdlib.cpp.

References ACE_MALLOC_T, and ACE_REALLOC_FUNC.

Referenced by scandir_emulation().

00270 {
00271   return ACE_REALLOC_FUNC (ACE_MALLOC_T (ptr), nbytes);
00272 }

ACE_INLINE wchar_t * ACE_OS::realpath const wchar_t *  file_name,
wchar_t *  resolved_name
 

Definition at line 369 of file OS_NS_stdlib.inl.

References PATH_MAX, realpath(), and strcpy().

00371 {
00372 #    if defined (ACE_WIN32)
00373   return ::_wfullpath (resolved_name, file_name, PATH_MAX);
00374 #    else /* ACE_WIN32 */
00375   ACE_Wide_To_Ascii n_file_name (file_name);
00376   char n_resolved[PATH_MAX];
00377   if (0 != ACE_OS::realpath (n_file_name.char_rep (), n_resolved))
00378     {
00379       ACE_Ascii_To_Wide w_resolved (n_resolved);
00380       ACE_OS::strcpy (resolved_name, w_resolved.wchar_rep ());
00381       return resolved_name;
00382     }
00383   return 0;
00384 #    endif /* ! ACE_WIN32 */
00385 }

ACE_INLINE char * ACE_OS::realpath const char *  file_name,
char *  resolved_name
 

Definition at line 356 of file OS_NS_stdlib.inl.

References PATH_MAX.

Referenced by realpath().

00358 {
00359 #    if defined (ACE_WIN32)
00360   return ::_fullpath (resolved_name, file_name, PATH_MAX);
00361 #    else /* ACE_WIN32 */
00362   return ::realpath (file_name, resolved_name);
00363 #    endif /* ! ACE_WIN32 */
00364 }

ACE_INLINE void ACE_OS::recursive_mutex_cond_relock ACE_recursive_thread_mutex_t m,
ACE_recursive_mutex_state state
 

Definition at line 634 of file OS_NS_Thread.inl.

References ACE_OS_TRACE, cond_wait(), ACE_recursive_thread_mutex_t::lock_available_, ACE_recursive_mutex_state::nesting_level_, ACE_recursive_thread_mutex_t::nesting_level_, ACE_recursive_thread_mutex_t::nesting_mutex_, ACE_recursive_mutex_state::owner_id_, ACE_recursive_thread_mutex_t::owner_id_, recursive_mutex_lock(), and thread_mutex_unlock().

Referenced by ACE_Condition< ACE_Recursive_Thread_Mutex >::wait().

00636 {
00637 #if defined (ACE_HAS_THREADS)
00638   ACE_OS_TRACE ("ACE_OS::recursive_mutex_cond_relock");
00639 #  if defined (ACE_HAS_RECURSIVE_MUTEXES)
00640   // Windows need special handling since it has recursive mutexes, but
00641   // does not integrate them into a condition variable.
00642   // On entry, the OS has already reacquired the lock for us. Just
00643   // reacquire it the proper number of times so the recursion is the same as
00644   // before waiting on the condition.
00645 #    if defined (ACE_WIN32)
00646   while (state.relock_count_ > 0)
00647     {
00648       ACE_OS::recursive_mutex_lock (m);
00649       --state.relock_count_;
00650     }
00651   return;
00652 #    else /* not ACE_WIN32 */
00653     // prevent warnings for unused variables
00654     ACE_UNUSED_ARG (state);
00655     ACE_UNUSED_ARG (m);
00656 
00657 #    endif /* ACE_WIN32 */
00658 #  else
00659   // Without recursive mutex support, it's somewhat trickier. On entry,
00660   // the current thread holds the nesting_mutex_, but another thread may
00661   // still be holding the ACE_recursive_mutex_t. If so, mimic the code
00662   // in ACE_OS::recursive_mutex_lock that waits to acquire the mutex.
00663   // After acquiring it, restore the nesting counts and release the
00664   // nesting mutex. This will restore the conditions to what they were
00665   // before calling ACE_OS::recursive_mutex_cond_unlock().
00666   while (m->nesting_level_ > 0)
00667     ACE_OS::cond_wait (&m->lock_available_, &m->nesting_mutex_);
00668 
00669   // At this point, we still have nesting_mutex_ and the mutex is free.
00670   m->nesting_level_ = state.nesting_level_;
00671   m->owner_id_ = state.owner_id_;
00672   ACE_OS::thread_mutex_unlock (&m->nesting_mutex_);
00673   return;
00674 #  endif /* ACE_HAS_RECURSIVE_MUTEXES */
00675 #else
00676   ACE_UNUSED_ARG (m);
00677   ACE_UNUSED_ARG (state);
00678   return;
00679 #endif /* ACE_HAS_THREADS */
00680 }

ACE_INLINE int ACE_OS::recursive_mutex_cond_unlock ACE_recursive_thread_mutex_t m,
ACE_recursive_mutex_state state
 

Definition at line 526 of file OS_NS_Thread.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_thread_t, cond_signal(), ACE_recursive_thread_mutex_t::lock_available_, ACE_recursive_mutex_state::nesting_level_, ACE_recursive_thread_mutex_t::nesting_level_, ACE_recursive_thread_mutex_t::nesting_mutex_, ACE_recursive_mutex_state::owner_id_, ACE_recursive_thread_mutex_t::owner_id_, recursive_mutex_unlock(), thr_equal(), thr_self(), thread_mutex_lock(), and thread_mutex_unlock().

Referenced by ACE_Condition< ACE_Recursive_Thread_Mutex >::wait().

00528 {
00529 #if defined (ACE_HAS_THREADS)
00530   ACE_OS_TRACE ("ACE_OS::recursive_mutex_cond_unlock");
00531 #  if defined (ACE_HAS_RECURSIVE_MUTEXES)
00532   // Windows need special handling since it has recursive mutexes, but
00533   // does not integrate them into a condition variable.
00534 #    if defined (ACE_WIN32)
00535   // For Windows, the OS takes care of the mutex and its recursion. We just
00536   // need to release the lock one fewer times than this thread has acquired
00537   // it. Remember how many times, and reacquire it that many more times when
00538   // the condition is signaled.
00539   //
00540   // For WinCE, the situation is a bit trickier. CE doesn't have
00541   // RecursionCount, and LockCount is not an indicator of recursion on WinCE;
00542   // instead, see when it's unlocked by watching the OwnerThread, which will
00543   // change to something other than the current thread when it's been
00544   // unlocked "enough" times. Note that checking for 0 (unlocked) is not
00545   // sufficient. Another thread may acquire the lock between our unlock and
00546   // checking the OwnerThread. So grab our thread ID value first, then
00547   // compare to it in the loop condition.
00548 #      if defined (ACE_HAS_WINCE)
00549   ACE_thread_t me = ACE_OS::thr_self ();
00550 #      endif /* ACE_HAS_WINCE */
00551 
00552   state.relock_count_ = 0;
00553   while (m->LockCount > 0
00554 #      if defined (ACE_HAS_WINCE)
00555          // Although this is a thread ID, OwnerThread's type is HANDLE.
00556          // Not sure if this is a problem, but it appears to work.
00557          && m->OwnerThread == (HANDLE)me
00558 #      else
00559          && m->RecursionCount > 1
00560 #      endif
00561          )
00562     {
00563       // This may fail if the current thread doesn't own the mutex. If it
00564       // does fail, it'll be on the first try, so don't worry about resetting
00565       // the state.
00566       if (ACE_OS::recursive_mutex_unlock (m) == -1)
00567         return -1;
00568       ++state.relock_count_;
00569     }
00570 #    else /* not ACE_WIN32 */
00571     // prevent warnings for unused variables
00572     ACE_UNUSED_ARG (state);
00573     ACE_UNUSED_ARG (m);
00574 #    endif /* ACE_WIN32 */
00575   return 0;
00576 #  else /* ACE_HAS_RECURSIVE_MUTEXES */
00577   // For platforms without recursive mutexes, we obtain the nesting mutex
00578   // to gain control over the mutex internals. Then set the internals to say
00579   // the mutex is available. If there are waiters, signal the condition
00580   // to notify them (this is mostly like the recursive_mutex_unlock() method).
00581   // Then, return with the nesting mutex still held. The condition wait
00582   // will release it atomically, allowing mutex waiters to continue.
00583   // Note that this arrangement relies on the fact that on return from
00584   // the condition wait, this thread will again own the nesting mutex
00585   // and can either set the mutex internals directly or get in line for
00586   // the mutex... this part is handled in recursive_mutex_cond_relock().
00587   if (ACE_OS::thread_mutex_lock (&m->nesting_mutex_) == -1)
00588     return -1;
00589 
00590 #    if !defined (ACE_NDEBUG)
00591   if (m->nesting_level_ == 0
00592       || ACE_OS::thr_equal (ACE_OS::thr_self (), m->owner_id_) == 0)
00593     {
00594       ACE_OS::thread_mutex_unlock (&m->nesting_mutex_);
00595       errno = EINVAL;
00596       return -1;
00597     }
00598 #    endif /* ACE_NDEBUG */
00599 
00600   // To make error recovery a bit easier, signal the condition now. Any
00601   // waiter won't regain control until the mutex is released, which won't
00602   // be until the caller returns and does the wait on the condition.
00603   if (ACE_OS::cond_signal (&m->lock_available_) == -1)
00604     {
00605       // Save/restore errno.
00606       ACE_Errno_Guard error (errno);
00607       ACE_OS::thread_mutex_unlock (&m->nesting_mutex_);
00608       return -1;
00609     }
00610 
00611   // Ok, the nesting_mutex_ lock is still held, the condition has been
00612   // signaled... reset the nesting info and return _WITH_ the lock
00613   // held. The lock will be released when the condition waits, in the
00614   // caller.
00615   state.nesting_level_ = m->nesting_level_;
00616   state.owner_id_ = m->owner_id_;
00617   m->nesting_level_ = 0;
00618   m->owner_id_ = ACE_OS::NULL_thread;
00619   return 0;
00620 #  endif /* ACE_HAS_RECURSIVE_MUTEXES */
00621 #else
00622   ACE_UNUSED_ARG (m);
00623   ACE_UNUSED_ARG (state);
00624   ACE_NOTSUP_RETURN (-1);
00625 #endif /* ACE_HAS_THREADS */
00626 }

ACE_INLINE int ACE_OS::recursive_mutex_destroy ACE_recursive_thread_mutex_t m  ) 
 

Definition at line 683 of file OS_NS_Thread.inl.

References ACE_NOTSUP_RETURN, cond_destroy(), ACE_recursive_thread_mutex_t::lock_available_, ACE_recursive_thread_mutex_t::nesting_mutex_, and thread_mutex_destroy().

Referenced by ACE_Recursive_Thread_Mutex::remove().

00684 {
00685 #if defined (ACE_HAS_THREADS)
00686 #if defined (ACE_HAS_RECURSIVE_MUTEXES)
00687   return ACE_OS::thread_mutex_destroy (m);
00688 #else
00689   if (ACE_OS::thread_mutex_destroy (&m->nesting_mutex_) == -1)
00690     return -1;
00691   else if (ACE_OS::cond_destroy (&m->lock_available_) == -1)
00692     return -1;
00693   else
00694     return 0;
00695 #endif /* ACE_HAS_RECURSIVE_MUTEXES */
00696 #else
00697   ACE_UNUSED_ARG (m);
00698   ACE_NOTSUP_RETURN (-1);
00699 #endif /* ACE_HAS_THREADS */
00700 }

ACE_INLINE int ACE_OS::recursive_mutex_init ACE_recursive_thread_mutex_t m,
const ACE_TCHAR name = 0,
ACE_mutexattr_t *  arg = 0,
LPSECURITY_ATTRIBUTES  sa = 0
 

Definition at line 703 of file OS_NS_Thread.inl.

References ACE_NOTSUP_RETURN, ACE_TCHAR, cond_init(), ACE_recursive_thread_mutex_t::lock_available_, ACE_recursive_thread_mutex_t::nesting_level_, ACE_recursive_thread_mutex_t::nesting_mutex_, ACE_recursive_thread_mutex_t::owner_id_, and thread_mutex_init().

Referenced by ACE_Recursive_Thread_Mutex::ACE_Recursive_Thread_Mutex().

00707 {
00708   ACE_UNUSED_ARG (sa);
00709 #if defined (ACE_HAS_THREADS)
00710 #  if defined (ACE_HAS_RECURSIVE_MUTEXES)
00711 #    if defined (ACE_HAS_PTHREADS_UNIX98_EXT)
00712   return ACE_OS::thread_mutex_init (m, PTHREAD_MUTEX_RECURSIVE, name, arg);
00713 #    else
00714   return ACE_OS::thread_mutex_init (m, 0, name, arg);
00715 #    endif /* ACE_HAS_PTHREADS_UNIX98_EXT */
00716 #  else
00717   if (ACE_OS::thread_mutex_init (&m->nesting_mutex_, 0, name, arg) == -1)
00718     return -1;
00719   else if (ACE_OS::cond_init (&m->lock_available_,
00720                               (short) USYNC_THREAD,
00721                               name,
00722                               0) == -1)
00723     return -1;
00724   else
00725     {
00726       m->nesting_level_ = 0;
00727       m->owner_id_ = ACE_OS::NULL_thread;
00728       return 0;
00729     }
00730 #  endif /* ACE_HAS_RECURSIVE_MUTEXES */
00731 #else
00732   ACE_UNUSED_ARG (m);
00733   ACE_UNUSED_ARG (name);
00734   ACE_UNUSED_ARG (arg);
00735   ACE_NOTSUP_RETURN (-1);
00736 #endif /* ACE_HAS_THREADS */
00737 }

ACE_INLINE int ACE_OS::recursive_mutex_lock ACE_recursive_thread_mutex_t m,
const ACE_Time_Value timeout
 

Definition at line 856 of file OS_NS_Thread.inl.

References recursive_mutex_lock().

00858 {
00859   return timeout == 0
00860     ? ACE_OS::recursive_mutex_lock (m)
00861     : ACE_OS::recursive_mutex_lock (m, *timeout);
00862 }

ACE_INLINE int ACE_OS::recursive_mutex_lock ACE_recursive_thread_mutex_t m,
const ACE_Time_Value timeout
 

Definition at line 791 of file OS_NS_Thread.inl.

References ACE_NOTSUP_RETURN, ACE_thread_t, cond_timedwait(), ACE_recursive_thread_mutex_t::lock_available_, ACE_recursive_thread_mutex_t::nesting_level_, ACE_recursive_thread_mutex_t::nesting_mutex_, ACE_recursive_thread_mutex_t::owner_id_, thr_equal(), thr_self(), thread_mutex_lock(), and thread_mutex_unlock().

00793 {
00794 #if defined (ACE_HAS_THREADS)
00795 #if defined (ACE_HAS_RECURSIVE_MUTEXES)
00796   return ACE_OS::thread_mutex_lock (m, timeout);
00797 #else
00798   ACE_thread_t t_id = ACE_OS::thr_self ();
00799   int result = 0;
00800 
00801   // Try to acquire the guard.
00802   if (ACE_OS::thread_mutex_lock (&m->nesting_mutex_, timeout) == -1)
00803     result = -1;
00804   else
00805     {
00806       // If there's no contention, just grab the lock immediately
00807       // (since this is the common case we'll optimize for it).
00808       if (m->nesting_level_ == 0)
00809         m->owner_id_ = t_id;
00810       // If we already own the lock, then increment the nesting level
00811       // and return.
00812       else if (ACE_OS::thr_equal (t_id, m->owner_id_) == 0)
00813         {
00814           // Wait until the nesting level has dropped to zero, at
00815           // which point we can acquire the lock.
00816           while (m->nesting_level_ > 0)
00817             {
00818               result = ACE_OS::cond_timedwait (&m->lock_available_,
00819                                                &m->nesting_mutex_,
00820                                                const_cast <ACE_Time_Value *> (&timeout));
00821 
00822               // The mutex is reacquired even in the case of a timeout
00823               // release the mutex to prevent a deadlock
00824               if (result == -1)
00825                 {
00826                   // Save/restore errno.
00827                   ACE_Errno_Guard error (errno);
00828                   ACE_OS::thread_mutex_unlock (&m->nesting_mutex_);
00829 
00830                   return result;
00831                 }
00832             }
00833 
00834           // At this point the nesting_mutex_ is held...
00835           m->owner_id_ = t_id;
00836         }
00837 
00838       // At this point, we can safely increment the nesting_level_ no
00839       // matter how we got here!
00840       m->nesting_level_++;
00841 
00842       // Save/restore errno.
00843       ACE_Errno_Guard error (errno);
00844       ACE_OS::thread_mutex_unlock (&m->nesting_mutex_);
00845     }
00846   return result;
00847 #endif /* ACE_HAS_RECURSIVE_MUTEXES */
00848 #else
00849   ACE_UNUSED_ARG (m);
00850   ACE_UNUSED_ARG (timeout);
00851   ACE_NOTSUP_RETURN (-1);
00852 #endif /* ACE_HAS_THREADS */
00853 }

ACE_INLINE int ACE_OS::recursive_mutex_lock ACE_recursive_thread_mutex_t m  ) 
 

Definition at line 740 of file OS_NS_Thread.inl.

References ACE_NOTSUP_RETURN, ACE_thread_t, cond_wait(), ACE_recursive_thread_mutex_t::lock_available_, ACE_recursive_thread_mutex_t::nesting_level_, ACE_recursive_thread_mutex_t::nesting_mutex_, ACE_recursive_thread_mutex_t::owner_id_, thr_equal(), thr_self(), thread_mutex_lock(), and thread_mutex_unlock().

Referenced by ACE_Recursive_Thread_Mutex::acquire(), recursive_mutex_cond_relock(), and recursive_mutex_lock().

00741 {
00742 #if defined (ACE_HAS_THREADS)
00743 #if defined (ACE_HAS_RECURSIVE_MUTEXES)
00744   return ACE_OS::thread_mutex_lock (m);
00745 #else
00746   ACE_thread_t t_id = ACE_OS::thr_self ();
00747   int result = 0;
00748 
00749   // Acquire the guard.
00750   if (ACE_OS::thread_mutex_lock (&m->nesting_mutex_) == -1)
00751     result = -1;
00752   else
00753   {
00754       // If there's no contention, just grab the lock immediately
00755       // (since this is the common case we'll optimize for it).
00756     if (m->nesting_level_ == 0)
00757       m->owner_id_ = t_id;
00758       // If we already own the lock, then increment the nesting level
00759       // and return.
00760     else if (ACE_OS::thr_equal (t_id, m->owner_id_) == 0)
00761     {
00762           // Wait until the nesting level has dropped to zero, at
00763           // which point we can acquire the lock.
00764       while (m->nesting_level_ > 0)
00765         ACE_OS::cond_wait (&m->lock_available_,
00766                             &m->nesting_mutex_);
00767 
00768           // At this point the nesting_mutex_ is held...
00769       m->owner_id_ = t_id;
00770     }
00771 
00772       // At this point, we can safely increment the nesting_level_ no
00773       // matter how we got here!
00774     m->nesting_level_++;
00775   }
00776 
00777   {
00778     // Save/restore errno.
00779     ACE_Errno_Guard error (errno);
00780     ACE_OS::thread_mutex_unlock (&m->nesting_mutex_);
00781   }
00782   return result;
00783 #endif /* ACE_HAS_RECURSIVE_MUTEXES */
00784 #else
00785   ACE_UNUSED_ARG (m);
00786   ACE_NOTSUP_RETURN (-1);
00787 #endif /* ACE_HAS_THREADS */
00788 }

ACE_INLINE int ACE_OS::recursive_mutex_trylock ACE_recursive_thread_mutex_t m  ) 
 

Definition at line 865 of file OS_NS_Thread.inl.

References ACE_NOTSUP_RETURN, ACE_thread_t, EBUSY, ACE_recursive_thread_mutex_t::nesting_level_, ACE_recursive_thread_mutex_t::nesting_mutex_, ACE_recursive_thread_mutex_t::owner_id_, thr_equal(), thr_self(), thread_mutex_lock(), thread_mutex_trylock(), and thread_mutex_unlock().

Referenced by ACE_Recursive_Thread_Mutex::tryacquire().

00866 {
00867 #if defined (ACE_HAS_THREADS)
00868 #if defined (ACE_HAS_RECURSIVE_MUTEXES)
00869   return ACE_OS::thread_mutex_trylock (m);
00870 #else
00871   ACE_thread_t t_id = ACE_OS::thr_self ();
00872   int result = 0;
00873 
00874   // Acquire the guard.
00875   if (ACE_OS::thread_mutex_lock (&m->nesting_mutex_) == -1)
00876     result = -1;
00877   else
00878   {
00879       // If there's no contention, just grab the lock immediately.
00880     if (m->nesting_level_ == 0)
00881     {
00882       m->owner_id_ = t_id;
00883       m->nesting_level_ = 1;
00884     }
00885       // If we already own the lock, then increment the nesting level
00886       // and proceed.
00887     else if (ACE_OS::thr_equal (t_id, m->owner_id_))
00888       m->nesting_level_++;
00889     else
00890     {
00891       errno = EBUSY;
00892       result = -1;
00893     }
00894   }
00895 
00896   {
00897     // Save/restore errno.
00898     ACE_Errno_Guard error (errno);
00899     ACE_OS::thread_mutex_unlock (&m->nesting_mutex_);
00900   }
00901   return result;
00902 #endif /* ACE_HAS_RECURSIVE_MUTEXES */
00903 #else
00904   ACE_UNUSED_ARG (m);
00905   ACE_NOTSUP_RETURN (-1);
00906 #endif /* ACE_HAS_THREADS */
00907 }

ACE_INLINE int ACE_OS::recursive_mutex_unlock ACE_recursive_thread_mutex_t m  ) 
 

Definition at line 910 of file OS_NS_Thread.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_thread_t, cond_signal(), ACE_recursive_thread_mutex_t::lock_available_, ACE_recursive_thread_mutex_t::nesting_level_, ACE_recursive_thread_mutex_t::nesting_mutex_, ACE_recursive_thread_mutex_t::owner_id_, thr_equal(), thr_self(), thread_mutex_lock(), and thread_mutex_unlock().

Referenced by recursive_mutex_cond_unlock(), and ACE_Recursive_Thread_Mutex::release().

00911 {
00912 #if defined (ACE_HAS_THREADS)
00913 #  if defined (ACE_HAS_RECURSIVE_MUTEXES)
00914   return ACE_OS::thread_mutex_unlock (m);
00915 #  else
00916   ACE_OS_TRACE ("ACE_OS::recursive_mutex_unlock");
00917 #    if !defined (ACE_NDEBUG)
00918   ACE_thread_t t_id = ACE_OS::thr_self ();
00919 #    endif /* ACE_NDEBUG */
00920   int result = 0;
00921 
00922   if (ACE_OS::thread_mutex_lock (&m->nesting_mutex_) == -1)
00923     result = -1;
00924   else
00925   {
00926 #    if !defined (ACE_NDEBUG)
00927       if (m->nesting_level_ == 0
00928           || ACE_OS::thr_equal (t_id, m->owner_id_) == 0)
00929 {
00930   errno = EINVAL;
00931   result = -1;
00932 }
00933       else
00934 #    endif /* ACE_NDEBUG */
00935 {
00936   m->nesting_level_--;
00937   if (m->nesting_level_ == 0)
00938   {
00939               // This may not be strictly necessary, but it does put
00940               // the mutex into a known state...
00941     m->owner_id_ = ACE_OS::NULL_thread;
00942 
00943               // Inform a waiter that the lock is free.
00944     if (ACE_OS::cond_signal (&m->lock_available_) == -1)
00945       result = -1;
00946   }
00947 }
00948   }
00949 
00950 {
00951     // Save/restore errno.
00952   ACE_Errno_Guard error (errno);
00953   ACE_OS::thread_mutex_unlock (&m->nesting_mutex_);
00954 }
00955   return result;
00956 #  endif /* ACE_HAS_RECURSIVE_MUTEXES */
00957 #else
00958   ACE_UNUSED_ARG (m);
00959   ACE_NOTSUP_RETURN (-1);
00960 #endif /* ACE_HAS_THREADS */
00961 }

ACE_INLINE ssize_t ACE_OS::recv ACE_HANDLE  handle,
char *  buf,
size_t  len,
int  flags = 0
 

BSD-style (no QoS).

Definition at line 253 of file OS_NS_sys_socket.inl.

References ACE_OS_TRACE, ACE_SOCKCALL_RETURN, EWOULDBLOCK, and ssize_t.

Referenced by ACE_Pipe::recv(), ACE::recv(), ACE::recv_i(), and ACE::recv_n_i().

00254 {
00255   ACE_OS_TRACE ("ACE_OS::recv");
00256 
00257   // On UNIX, a non-blocking socket with no data to receive, this
00258   // system call will return EWOULDBLOCK or EAGAIN, depending on the
00259   // platform.  UNIX 98 allows either errno, and they may be the same
00260   // numeric value.  So to make life easier for upper ACE layers as
00261   // well as application programmers, always change EAGAIN to
00262   // EWOULDBLOCK.  Rather than hack the ACE_OSCALL_RETURN macro, it's
00263   // handled explicitly here.  If the ACE_OSCALL macro ever changes,
00264   // this function needs to be reviewed.  On Win32, the regular macros
00265   // can be used, as this is not an issue.
00266 #if defined (ACE_WIN32)
00267   ACE_SOCKCALL_RETURN (::recv ((ACE_SOCKET) handle, buf,
00268                                static_cast<int> (len), flags), ssize_t, -1);
00269 #else
00270   ssize_t ace_result_;
00271   ace_result_ = ::recv ((ACE_SOCKET) handle, buf, len, flags);
00272 
00273 # if !(defined (EAGAIN) && defined (EWOULDBLOCK) && EAGAIN == EWOULDBLOCK)
00274   // Optimize this code out if we can detect that EAGAIN ==
00275   // EWOULDBLOCK at compile time.  If we cannot detect equality at
00276   // compile-time (e.g. if EAGAIN or EWOULDBLOCK are not preprocessor
00277   // macros) perform the check at run-time.  The goal is to avoid two
00278   // TSS accesses in the _REENTRANT case when EAGAIN == EWOULDBLOCK.
00279   if (ace_result_ == -1
00280 #  if !defined (EAGAIN) || !defined (EWOULDBLOCK)
00281       && EAGAIN != EWOULDBLOCK
00282 #  endif  /* !EAGAIN || !EWOULDBLOCK */
00283       && errno == EAGAIN)
00284     {
00285       errno = EWOULDBLOCK;
00286     }
00287 # endif /* EAGAIN != EWOULDBLOCK*/
00288 
00289   return ace_result_;
00290 #endif /* defined (ACE_WIN32) */
00291 }

ACE_INLINE ssize_t ACE_OS::recvfrom ACE_HANDLE  handle,
iovec buffers,
int  buffer_count,
size_t &  number_of_bytes_recvd,
int &  flags,
struct sockaddr *  addr,
int *  addrlen,
ACE_OVERLAPPED overlapped,
ACE_OVERLAPPED_COMPLETION_FUNC  func
 

BSD-style (no QoS).

Definition at line 333 of file OS_NS_sys_socket.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_OVERLAPPED, ACE_OVERLAPPED_COMPLETION_FUNC, and set_errno_to_wsa_last_error().

00342 {
00343   ACE_OS_TRACE ("ACE_OS::recvfrom");
00344 
00345 #if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
00346   DWORD bytes_recvd;
00347   DWORD the_flags = flags;
00348   int result = ::WSARecvFrom ((SOCKET) handle,
00349                               (WSABUF*)buffers,
00350                               buffer_count,
00351                               &bytes_recvd,
00352                               &the_flags,
00353                               addr,
00354                               addrlen,
00355                               overlapped,
00356                               func);
00357   if (result != 0) {
00358     ACE_OS::set_errno_to_wsa_last_error ();
00359   }
00360   flags = the_flags;
00361   number_of_bytes_recvd = static_cast<size_t> (bytes_recvd);
00362   return result;
00363 #else
00364   ACE_UNUSED_ARG (handle);
00365   ACE_UNUSED_ARG (buffers);
00366   ACE_UNUSED_ARG (buffer_count);
00367   ACE_UNUSED_ARG (number_of_bytes_recvd);
00368   ACE_UNUSED_ARG (flags);
00369   ACE_UNUSED_ARG (addr);
00370   ACE_UNUSED_ARG (addrlen);
00371   ACE_UNUSED_ARG (overlapped);
00372   ACE_UNUSED_ARG (func);
00373   ACE_NOTSUP_RETURN (-1);
00374 #endif /* defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) */
00375 }

ACE_INLINE ssize_t ACE_OS::recvfrom ACE_HANDLE  handle,
char *  buf,
size_t  len,
int  flags,
struct sockaddr *  addr,
int *  addrlen
 

BSD-style (no QoS).

Definition at line 294 of file OS_NS_sys_socket.inl.

References ACE_BIT_ENABLED, ACE_OS_TRACE, ACE_SOCKCALL_RETURN, ACE_SOCKET_LEN, set_errno_to_wsa_last_error(), and ssize_t.

Referenced by ACE_WIN32_Asynch_Read_Dgram::recv(), ACE_SOCK_Dgram::recv(), ACE_ICMP_Socket::recv(), and ACE::recvfrom().

00300 {
00301   ACE_OS_TRACE ("ACE_OS::recvfrom");
00302 #if defined (ACE_WIN32)
00303   int shortened_len = static_cast<int> (len);
00304   int result = ::recvfrom ((ACE_SOCKET) handle,
00305                            buf,
00306                            shortened_len,
00307                            flags,
00308                            addr,
00309                            (ACE_SOCKET_LEN *) addrlen);
00310   if (result == SOCKET_ERROR)
00311     {
00312       ACE_OS::set_errno_to_wsa_last_error ();
00313       if (errno == WSAEMSGSIZE &&
00314           ACE_BIT_ENABLED (flags, MSG_PEEK))
00315         return shortened_len;
00316       else
00317         return -1;
00318     }
00319   else
00320     return result;
00321 #else /* non Win32 */
00322   ACE_SOCKCALL_RETURN (::recvfrom ((ACE_SOCKET) handle,
00323                                    buf,
00324                                    len,
00325                                    flags,
00326                                    addr,
00327                                    (ACE_SOCKET_LEN *) addrlen),
00328                        ssize_t, -1);
00329 #endif /* defined (ACE_WIN32) */
00330 }

ACE_INLINE ssize_t ACE_OS::recvmsg ACE_HANDLE  handle,
struct msghdr msg,
int  flags
 

BSD-style (no QoS).

Definition at line 378 of file OS_NS_sys_socket.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_SOCKCALL_RETURN, msghdr::msg_iov, msghdr::msg_iovlen, msghdr::msg_name, msghdr::msg_namelen, set_errno_to_wsa_last_error(), and ssize_t.

Referenced by ACE::recvmsg().

00379 {
00380   ACE_OS_TRACE ("ACE_OS::recvmsg");
00381 #if !defined (ACE_LACKS_RECVMSG)
00382 # if (defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0))
00383   DWORD bytes_received = 0;
00384 
00385   int result = ::WSARecvFrom ((SOCKET) handle,
00386                               (WSABUF *) msg->msg_iov,
00387                               msg->msg_iovlen,
00388                               &bytes_received,
00389                               (DWORD *) &flags,
00390                               msg->msg_name,
00391                               &msg->msg_namelen,
00392                               0,
00393                               0);
00394 
00395   if (result != 0)
00396     {
00397       ACE_OS::set_errno_to_wsa_last_error ();
00398       return -1;
00399     }
00400   else
00401     return bytes_received;
00402 # else /* ACE_HAS_WINSOCK2 */
00403   ACE_SOCKCALL_RETURN (::recvmsg (handle, msg, flags), ssize_t, -1);
00404 # endif /* ACE_HAS_WINSOCK2 */
00405 #else
00406   ACE_UNUSED_ARG (flags);
00407   ACE_UNUSED_ARG (msg);
00408   ACE_UNUSED_ARG (handle);
00409 
00410   ACE_NOTSUP_RETURN (-1);
00411 #endif /* ACE_LACKS_RECVMSG */
00412 }

ACE_INLINE ssize_t ACE_OS::recvv ACE_HANDLE  handle,
iovec iov,
int  iovlen
 

BSD-style (no QoS).

Definition at line 415 of file OS_NS_sys_socket.inl.

References iovec::iov_base, readv(), set_errno_to_wsa_last_error(), and ssize_t.

Referenced by ACE_SOCK_IO::recv(), ACE_Pipe::recv(), ACE::recv(), ACE::recvv(), and ACE::recvv_n_i().

00418 {
00419 #if defined (ACE_HAS_WINSOCK2)
00420 
00421   DWORD bytes_received = 0;
00422   int result = 1;
00423 
00424   // Winsock 2 has WSARecv and can do this directly, but Winsock 1 needs
00425   // to do the recvs piece-by-piece.
00426 
00427 # if (ACE_HAS_WINSOCK2 != 0)
00428   DWORD flags = 0;
00429   result = ::WSARecv ((SOCKET) handle,
00430                       (WSABUF *) buffers,
00431                       n,
00432                       &bytes_received,
00433                       &flags,
00434                       0,
00435                       0);
00436 # else
00437   int i, chunklen;
00438   char *chunkp = 0;
00439 
00440   // Step through the buffers requested by caller; for each one, cycle
00441   // through reads until it's filled or an error occurs.
00442   for (i = 0; i < n && result > 0; ++i)
00443     {
00444       chunkp = buffers[i].iov_base;     // Point to part of chunk being read
00445       chunklen = buffers[i].iov_len;    // Track how much to read to chunk
00446       while (chunklen > 0 && result > 0)
00447         {
00448           result = ::recv ((SOCKET) handle, chunkp, chunklen, 0);
00449           if (result > 0)
00450             {
00451               chunkp += result;
00452               chunklen -= result;
00453               bytes_received += result;
00454             }
00455         }
00456     }
00457 # endif /* ACE_HAS_WINSOCK2 != 0 */
00458 
00459   if (result == SOCKET_ERROR)
00460     {
00461       ACE_OS::set_errno_to_wsa_last_error ();
00462       return -1;
00463     }
00464   else
00465     return (ssize_t) bytes_received;
00466 #else
00467   return ACE_OS::readv (handle, buffers, n);
00468 #endif /* ACE_HAS_WINSOCK2 */
00469 }

ACE_INLINE int ACE_OS::rename const wchar_t *  old_name,
const wchar_t *  new_name,
int  flags = -1
 

Definition at line 812 of file OS_NS_stdio.inl.

References ACE_FAIL_RETURN, ACE_NOTSUP_RETURN, and rename().

00815 {
00816 # if defined (ACE_LACKS_RENAME)
00817   ACE_UNUSED_ARG (old_name);
00818   ACE_UNUSED_ARG (new_name);
00819   ACE_UNUSED_ARG (flags);
00820   ACE_NOTSUP_RETURN (-1);
00821 # elif defined (ACE_HAS_WINCE)
00822   ACE_UNUSED_ARG (flags);
00823   if (MoveFileW (old_name, new_name) != 0)
00824     ACE_FAIL_RETURN (-1);
00825   return 0;
00826 # elif defined (ACE_WIN32) && defined (ACE_HAS_WINNT4) && (ACE_HAS_WINNT4 == 1)
00827   // NT4 (and up) provides a way to rename/move a file with similar semantics
00828   // to what's usually done on UNIX - if there's an existing file with
00829   // <new_name> it is removed before the file is renamed/moved. The
00830   // MOVEFILE_COPY_ALLOWED is specified to allow such a rename across drives.
00831   if (flags == -1)
00832     flags = MOVEFILE_COPY_ALLOWED | MOVEFILE_REPLACE_EXISTING;
00833   if (::MoveFileExW (old_name, new_name, flags) == 0)
00834     ACE_FAIL_RETURN (-1);
00835   return 0;
00836 # elif defined (ACE_WIN32)
00837   ACE_UNUSED_ARG (flags);
00838   ACE_OSCALL_RETURN (::_wrename (old_name, new_name), int, -1);
00839 # else /* ACE_LACKS_RENAME */
00840   ACE_Wide_To_Ascii nold_name (old_name);
00841   ACE_Wide_To_Ascii nnew_name (new_name);
00842   return ACE_OS::rename (nold_name.char_rep (), nnew_name.char_rep (), flags);
00843 # endif /* ACE_LACKS_RENAME */
00844 }

ACE_INLINE int ACE_OS::rename const char *  old_name,
const char *  new_name,
int  flags = -1
 

Definition at line 778 of file OS_NS_stdio.inl.

References ACE_FAIL_RETURN, ACE_NOTSUP_RETURN, ACE_TEXT_CHAR_TO_TCHAR, and rename().

Referenced by ACE_Logging_Strategy::handle_timeout(), and rename().

00781 {
00782 # if defined (ACE_LACKS_RENAME)
00783   ACE_UNUSED_ARG (old_name);
00784   ACE_UNUSED_ARG (new_name);
00785   ACE_UNUSED_ARG (flags);
00786   ACE_NOTSUP_RETURN (-1);
00787 # elif defined (ACE_HAS_WINCE)
00788   // Win CE is always wide-char.
00789   ACE_UNUSED_ARG (flags);
00790   if (0 != MoveFile (ACE_TEXT_CHAR_TO_TCHAR (old_name),
00791                      ACE_TEXT_CHAR_TO_TCHAR (new_name)))
00792     ACE_FAIL_RETURN (-1);
00793   return 0;
00794 # elif defined (ACE_WIN32) && defined (ACE_HAS_WINNT4) && (ACE_HAS_WINNT4 == 1)
00795   // NT4 (and up) provides a way to rename/move a file with similar semantics
00796   // to what's usually done on UNIX - if there's an existing file with
00797   // <new_name> it is removed before the file is renamed/moved. The
00798   // MOVEFILE_COPY_ALLOWED is specified to allow such a rename across drives.
00799   if (flags == -1)
00800     flags = MOVEFILE_COPY_ALLOWED | MOVEFILE_REPLACE_EXISTING;
00801   if (::MoveFileExA (old_name, new_name, flags) == 0)
00802     ACE_FAIL_RETURN (-1);
00803   return 0;
00804 # else /* ACE_LACKS_RENAME */
00805   ACE_UNUSED_ARG (flags);
00806   ACE_OSCALL_RETURN (::rename (old_name, new_name), int, -1);
00807 # endif /* ACE_LACKS_RENAME */
00808 }

ACE_INLINE void ACE_OS::rewind FILE *  fp  ) 
 

Definition at line 848 of file OS_NS_stdio.inl.

References ACE_OS_TRACE, and fseek().

00849 {
00850 #if !defined (ACE_HAS_WINCE)
00851   ACE_OS_TRACE ("ACE_OS::rewind");
00852   ::rewind (fp);
00853 #else
00854   // This isn't perfect since it doesn't reset EOF, but it's probably
00855   // the closest we can get on WINCE.
00856   (void) fseek (fp, 0L, SEEK_SET);
00857 #endif /* ACE_HAS_WINCE */
00858 }

ACE_INLINE void ACE_OS::rewinddir ACE_DIR  ) 
 

Definition at line 114 of file OS_NS_dirent.inl.

References ACE_DIR.

Referenced by ACE_Dirent::rewind().

00115 {
00116 #if defined (ACE_HAS_DIRENT)
00117 # if defined (ACE_LACKS_SEEKDIR)
00118 #  if defined (ACE_LACKS_REWINDDIR)
00119   ACE_UNUSED_ARG (d);
00120 #  elif defined (ACE_HAS_WREWINDDIR) && defined (ACE_USES_WCHAR)
00121    ::wrewinddir (d);
00122 #  else /* ! defined (ACE_LACKS_REWINDDIR) */
00123    ::rewinddir (d);
00124 #  endif /* ! defined (ACE_LACKS_REWINDDIR) */
00125 # else  /* ! ACE_LACKS_SEEKDIR */
00126     // We need to implement <rewinddir> using <seekdir> since it's often
00127     // defined as a macro...
00128    ::seekdir (d, long (0));
00129 # endif /* ! ACE_LACKS_SEEKDIR */
00130 #else
00131   ACE_UNUSED_ARG (d);
00132 #endif /* ACE_HAS_DIRENT */
00133 }

ACE_INLINE int ACE_OS::rmdir const wchar_t *  path  ) 
 

Definition at line 170 of file OS_NS_unistd.inl.

References ACE_ADAPT_RETVAL, and rmdir().

00171 {
00172 #if defined (ACE_HAS_WINCE)
00173   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::RemoveDirectoryW (path),
00174                                           ace_result_),
00175                         int, -1);
00176 #elif defined (ACE_WIN32)
00177   ACE_OSCALL_RETURN (::_wrmdir (path), int, -1);
00178 #else
00179   ACE_Wide_To_Ascii n_path (path);
00180   return ACE_OS::rmdir (n_path.char_rep ());
00181 #endif /* ACE_HAS_WINCE */
00182 }

ACE_INLINE int ACE_OS::rmdir const char *  path  ) 
 

Definition at line 155 of file OS_NS_unistd.inl.

References ACE_ADAPT_RETVAL, ACE_TEXT_CHAR_TO_TCHAR, and rmdir().

Referenced by rmdir().

00156 {
00157 #if defined (ACE_WIN32) && defined (__IBMCPP__) && (__IBMCPP__ >= 400)
00158   ACE_OSCALL_RETURN (::_rmdir ((char *) path), int, -1);
00159 #elif defined (ACE_HAS_WINCE)
00160   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::RemoveDirectory (ACE_TEXT_CHAR_TO_TCHAR (path)),
00161                                           ace_result_),
00162                         int, -1);
00163 #else
00164   ACE_OSCALL_RETURN (::rmdir (path), int, -1);
00165 #endif /* ACE_WIN32 */
00166 }

ACE_INLINE int ACE_OS::rw_rdlock ACE_rwlock_t *  rw  ) 
 

Definition at line 964 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_PTHREAD_CLEANUP_POP, ACE_PTHREAD_CLEANUP_PUSH, cond_wait(), mutex_lock(), mutex_unlock(), and rw_rdlock().

Referenced by ACE_RW_Mutex::acquire_read(), and rw_rdlock().

00965 {
00966   ACE_OS_TRACE ("ACE_OS::rw_rdlock");
00967 #if defined (ACE_HAS_THREADS)
00968 # if !defined (ACE_LACKS_RWLOCK_T) || defined (ACE_HAS_PTHREADS_UNIX98_EXT)
00969 #  if defined (ACE_HAS_PTHREADS_UNIX98_EXT)
00970   int result;
00971   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_rwlock_rdlock (rw),
00972                                        result),
00973                      int, -1);
00974 #  else /* Solaris */
00975   int result;
00976   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::rw_rdlock (rw), result), int, -1);
00977 #  endif /* ACE_HAS_PTHREADS_UNIX98_EXT */
00978 # else /* NT, POSIX, and VxWorks don't support this natively. */
00979 #   if defined (ACE_HAS_PTHREADS)
00980   ACE_PTHREAD_CLEANUP_PUSH (&rw->lock_);
00981 #   endif /* ACE_HAS_PTHREADS */
00982   int result = 0;
00983   if (ACE_OS::mutex_lock (&rw->lock_) == -1)
00984     result = -1; // -1 means didn't get the mutex.
00985   else
00986     {
00987       // Give preference to writers who are waiting.
00988       while (rw->ref_count_ < 0 || rw->num_waiting_writers_ > 0)
00989         {
00990           rw->num_waiting_readers_++;
00991           if (ACE_OS::cond_wait (&rw->waiting_readers_, &rw->lock_) == -1)
00992             {
00993               result = -2; // -2 means that we need to release the mutex.
00994               break;
00995             }
00996           rw->num_waiting_readers_--;
00997         }
00998     }
00999   if (result == 0)
01000     rw->ref_count_++;
01001   if (result != -1)
01002     ACE_OS::mutex_unlock (&rw->lock_);
01003 #   if defined (ACE_HAS_PTHREADS)
01004   ACE_PTHREAD_CLEANUP_POP (0);
01005 #   endif /* defined (ACE_HAS_PTHREADS) */
01006   return 0;
01007 # endif /* ! ACE_LACKS_RWLOCK_T */
01008 #else
01009   ACE_UNUSED_ARG (rw);
01010   ACE_NOTSUP_RETURN (-1);
01011 #endif /* ACE_HAS_THREADS */
01012 }

ACE_INLINE int ACE_OS::rw_tryrdlock ACE_rwlock_t *  rw  ) 
 

Definition at line 1015 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, EBUSY, mutex_lock(), mutex_unlock(), and rw_tryrdlock().

Referenced by rw_tryrdlock(), and ACE_RW_Mutex::tryacquire_read().

01016 {
01017   ACE_OS_TRACE ("ACE_OS::rw_tryrdlock");
01018 #if defined (ACE_HAS_THREADS)
01019 # if !defined (ACE_LACKS_RWLOCK_T) || defined (ACE_HAS_PTHREADS_UNIX98_EXT)
01020 #  if defined (ACE_HAS_PTHREADS_UNIX98_EXT)
01021   int result;
01022   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_rwlock_tryrdlock (rw),
01023                                        result),
01024                      int, -1);
01025 #  else /* Solaris */
01026   int result;
01027   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::rw_tryrdlock (rw), result), int, -1);
01028 #  endif /* ACE_HAS_PTHREADS_UNIX98_EXT */
01029 # else /* NT, POSIX, and VxWorks don't support this natively. */
01030   int result = -1;
01031 
01032   if (ACE_OS::mutex_lock (&rw->lock_) != -1)
01033     {
01034       ACE_Errno_Guard error (errno);
01035 
01036       if (rw->ref_count_ == -1 || rw->num_waiting_writers_ > 0)
01037         {
01038           error = EBUSY;
01039           result = -1;
01040         }
01041       else
01042         {
01043           rw->ref_count_++;
01044           result = 0;
01045         }
01046 
01047       ACE_OS::mutex_unlock (&rw->lock_);
01048     }
01049   return result;
01050 # endif /* ! ACE_LACKS_RWLOCK_T */
01051 #else
01052   ACE_UNUSED_ARG (rw);
01053   ACE_NOTSUP_RETURN (-1);
01054 #endif /* ACE_HAS_THREADS */
01055 }

ACE_INLINE int ACE_OS::rw_trywrlock ACE_rwlock_t *  rw  ) 
 

Definition at line 1058 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, EBUSY, mutex_lock(), mutex_unlock(), and rw_trywrlock().

Referenced by rw_trywrlock(), and ACE_RW_Mutex::tryacquire_write().

01059 {
01060   ACE_OS_TRACE ("ACE_OS::rw_trywrlock");
01061 #if defined (ACE_HAS_THREADS)
01062 # if !defined (ACE_LACKS_RWLOCK_T) || defined (ACE_HAS_PTHREADS_UNIX98_EXT)
01063 #  if defined (ACE_HAS_PTHREADS_UNIX98_EXT)
01064   int result;
01065   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_rwlock_trywrlock (rw),
01066                                        result),
01067                      int, -1);
01068 #  else /* Solaris */
01069   int result;
01070   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::rw_trywrlock (rw), result), int, -1);
01071 #  endif /* ACE_HAS_PTHREADS_UNIX98_EXT */
01072 # else /* NT, POSIX, and VxWorks don't support this natively. */
01073   int result = -1;
01074 
01075   if (ACE_OS::mutex_lock (&rw->lock_) != -1)
01076     {
01077       ACE_Errno_Guard error (errno);
01078 
01079       if (rw->ref_count_ != 0)
01080         {
01081           error = EBUSY;
01082           result = -1;
01083         }
01084       else
01085         {
01086           rw->ref_count_ = -1;
01087           result = 0;
01088         }
01089 
01090       ACE_OS::mutex_unlock (&rw->lock_);
01091     }
01092   return result;
01093 # endif /* ! ACE_LACKS_RWLOCK_T */
01094 #else
01095   ACE_UNUSED_ARG (rw);
01096   ACE_NOTSUP_RETURN (-1);
01097 #endif /* ACE_HAS_THREADS */
01098 }

ACE_INLINE int ACE_OS::rw_trywrlock_upgrade ACE_rwlock_t *  rw  ) 
 

Definition at line 1107 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_PTHREAD_CLEANUP_POP, ACE_PTHREAD_CLEANUP_PUSH, cond_wait(), EBUSY, mutex_lock(), and mutex_unlock().

Referenced by ACE_RW_Thread_Mutex::tryacquire_write_upgrade(), and ACE_RW_Mutex::tryacquire_write_upgrade().

01108 {
01109   ACE_OS_TRACE ("ACE_OS::rw_trywrlock_upgrade");
01110 #if defined (ACE_HAS_THREADS)
01111 # if defined (ACE_HAS_PTHREADS_UNIX98_EXT)
01112   // This will probably result in -1, EDEADLK, at least on HP-UX, but let it
01113   // go - it's a more descriptive error than ENOTSUP.
01114   int result;
01115   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_rwlock_trywrlock (rw),
01116                                        result),
01117                      int, -1);
01118 # elif !defined (ACE_LACKS_RWLOCK_T)
01119   // Some native rwlocks, such as those on Solaris, don't
01120   // support the upgrade feature . . .
01121   ACE_UNUSED_ARG (rw);
01122   ACE_NOTSUP_RETURN (-1);
01123 # else /* NT, POSIX, and VxWorks don't support this natively. */
01124   // The ACE rwlock emulation does support upgrade . . .
01125   int result = 0;
01126 
01127 #   if defined (ACE_HAS_PTHREADS)
01128   ACE_PTHREAD_CLEANUP_PUSH (&rw->lock_);
01129 #   endif /* defined (ACE_HAS_PTHREADS) */
01130 
01131   if (ACE_OS::mutex_lock (&rw->lock_) == -1)
01132     return -1;
01133     // -1 means didn't get the mutex, error
01134   else if (rw->important_writer_)
01135     // an other reader upgrades already
01136     {
01137       result = -1;
01138       errno = EBUSY;
01139     }
01140   else
01141     {
01142       while (rw->ref_count_ > 1) // wait until only I am left
01143         {
01144           rw->num_waiting_writers_++; // prohibit any more readers
01145           rw->important_writer_ = 1;
01146 
01147           if (ACE_OS::cond_wait (&rw->waiting_important_writer_, &rw->lock_) == -1)
01148             {
01149               result = -1;
01150               // we know that we have the lock again, we have this guarantee,
01151               // but something went wrong
01152             }
01153           rw->important_writer_ = 0;
01154           rw->num_waiting_writers_--;
01155         }
01156       if (result == 0)
01157         {
01158           // nothing bad happend
01159           rw->ref_count_ = -1;
01160           // now I am a writer
01161           // everything is O.K.
01162         }
01163     }
01164 
01165   ACE_OS::mutex_unlock (&rw->lock_);
01166 
01167 #   if defined (ACE_HAS_PTHREADS)
01168   ACE_PTHREAD_CLEANUP_POP (0);
01169 #   endif /* defined (ACE_HAS_PTHREADS) */
01170 
01171   return result;
01172 
01173 # endif /* ! ACE_LACKS_RWLOCK_T */
01174 #else
01175   ACE_UNUSED_ARG (rw);
01176   ACE_NOTSUP_RETURN (-1);
01177 #endif /* ACE_HAS_THREADS */
01178 }

ACE_INLINE int ACE_OS::rw_unlock ACE_rwlock_t *  rw  ) 
 

Definition at line 1181 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, cond_broadcast(), cond_signal(), mutex_lock(), mutex_unlock(), and rw_unlock().

Referenced by ACE_RW_Mutex::release(), and rw_unlock().

01182 {
01183   ACE_OS_TRACE ("ACE_OS::rw_unlock");
01184 #if defined (ACE_HAS_THREADS)
01185 # if !defined (ACE_LACKS_RWLOCK_T) || defined (ACE_HAS_PTHREADS_UNIX98_EXT)
01186 #  if defined (ACE_HAS_PTHREADS_UNIX98_EXT)
01187   int result;
01188   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_rwlock_unlock (rw),
01189                                        result),
01190                      int, -1);
01191 #  else /* Solaris */
01192   int result;
01193   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::rw_unlock (rw), result), int, -1);
01194 #  endif /* ACE_HAS_PTHREADS_UNIX98_EXT */
01195 # else /* NT, POSIX, and VxWorks don't support this natively. */
01196   if (ACE_OS::mutex_lock (&rw->lock_) == -1)
01197     return -1;
01198 
01199   if (rw->ref_count_ > 0) // Releasing a reader.
01200     rw->ref_count_--;
01201   else if (rw->ref_count_ == -1) // Releasing a writer.
01202     rw->ref_count_ = 0;
01203   else
01204     return -1; // @@ ACE_ASSERT (!"count should not be 0!\n");
01205 
01206 
01207   int result = 0;
01208   ACE_Errno_Guard error (errno);
01209 
01210   if (rw->important_writer_ && rw->ref_count_ == 1)
01211     // only the reader requesting to upgrade its lock is left over.
01212     {
01213       result = ACE_OS::cond_signal (&rw->waiting_important_writer_);
01214       error = errno;
01215     }
01216   else if (rw->num_waiting_writers_ > 0 && rw->ref_count_ == 0)
01217     // give preference to writers over readers...
01218     {
01219       result = ACE_OS::cond_signal (&rw->waiting_writers_);
01220       error =  errno;
01221     }
01222   else if (rw->num_waiting_readers_ > 0 && rw->num_waiting_writers_ == 0)
01223     {
01224       result = ACE_OS::cond_broadcast (&rw->waiting_readers_);
01225       error = errno;
01226     }
01227 
01228   ACE_OS::mutex_unlock (&rw->lock_);
01229   return result;
01230 # endif /* ! ace_lacks_rwlock_t */
01231 #else
01232   ACE_UNUSED_ARG (rw);
01233   ACE_NOTSUP_RETURN (-1);
01234 #endif /* ace_has_threads */
01235 }

ACE_INLINE int ACE_OS::rw_wrlock ACE_rwlock_t *  rw  ) 
 

Definition at line 1238 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_PTHREAD_CLEANUP_POP, ACE_PTHREAD_CLEANUP_PUSH, cond_wait(), mutex_lock(), mutex_unlock(), and rw_wrlock().

Referenced by ACE_RW_Mutex::acquire(), ACE_RW_Mutex::acquire_write(), and rw_wrlock().

01239 {
01240   ACE_OS_TRACE ("ACE_OS::rw_wrlock");
01241 #if defined (ACE_HAS_THREADS)
01242 # if !defined (ACE_LACKS_RWLOCK_T) || defined (ACE_HAS_PTHREADS_UNIX98_EXT)
01243 #  if defined (ACE_HAS_PTHREADS_UNIX98_EXT)
01244   int result;
01245   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_rwlock_wrlock (rw),
01246                                        result),
01247                      int, -1);
01248 #  else /* Solaris */
01249   int result;
01250   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::rw_wrlock (rw), result), int, -1);
01251 #  endif /* ACE_HAS_PTHREADS_UNIX98_EXT */
01252 # else /* NT, POSIX, and VxWorks don't support this natively. */
01253 #   if defined (ACE_HAS_PTHREADS)
01254   ACE_PTHREAD_CLEANUP_PUSH (&rw->lock_);
01255 #   endif /* defined (ACE_HAS_PTHREADS) */
01256   int result = 0;
01257 
01258   if (ACE_OS::mutex_lock (&rw->lock_) == -1)
01259     result = -1; // -1 means didn't get the mutex.
01260   else
01261     {
01262       while (rw->ref_count_ != 0)
01263         {
01264           rw->num_waiting_writers_++;
01265 
01266           if (ACE_OS::cond_wait (&rw->waiting_writers_, &rw->lock_) == -1)
01267             {
01268               result = -2; // -2 means we need to release the mutex.
01269               break;
01270             }
01271 
01272           rw->num_waiting_writers_--;
01273         }
01274     }
01275   if (result == 0)
01276     rw->ref_count_ = -1;
01277   if (result != -1)
01278     ACE_OS::mutex_unlock (&rw->lock_);
01279 #   if defined (ACE_HAS_PTHREADS)
01280   ACE_PTHREAD_CLEANUP_POP (0);
01281 #   endif /* defined (ACE_HAS_PTHREADS) */
01282   return 0;
01283 # endif /* ! ACE_LACKS_RWLOCK_T */
01284 #else
01285   ACE_UNUSED_ARG (rw);
01286   ACE_NOTSUP_RETURN (-1);
01287 #endif /* ACE_HAS_THREADS */
01288 }

ACE_INLINE int ACE_OS::rwlock_destroy ACE_rwlock_t *  rw  ) 
 

Definition at line 1291 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, cond_destroy(), mutex_destroy(), and rwlock_destroy().

Referenced by ACE_RW_Mutex::remove(), and rwlock_destroy().

01292 {
01293   ACE_OS_TRACE ("ACE_OS::rwlock_destroy");
01294 #if defined (ACE_HAS_THREADS)
01295 # if !defined (ACE_LACKS_RWLOCK_T) || defined (ACE_HAS_PTHREADS_UNIX98_EXT)
01296 #  if defined (ACE_HAS_PTHREADS_UNIX98_EXT)
01297   int result;
01298   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_rwlock_destroy (rw),
01299                                        result),
01300                      int, -1);
01301 #  else /* Solaris */
01302   int result;
01303   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::rwlock_destroy (rw), result), int, -1);
01304 #  endif /* ACE_HAS_PTHREADS_UNIX98_EXT */
01305 # else /* NT, POSIX, and VxWorks don't support this natively. */
01306   ACE_OS::mutex_destroy (&rw->lock_);
01307   ACE_OS::cond_destroy (&rw->waiting_readers_);
01308   ACE_OS::cond_destroy (&rw->waiting_important_writer_);
01309   return ACE_OS::cond_destroy (&rw->waiting_writers_);
01310 # endif /* ACE_HAS_STHREADS && !defined (ACE_LACKS_RWLOCK_T) */
01311 #else
01312   ACE_UNUSED_ARG (rw);
01313   ACE_NOTSUP_RETURN (-1);
01314 #endif /* ACE_HAS_THREADS */
01315 }

ACE_INLINE int ACE_OS::rwlock_init ACE_rwlock_t *  rw,
int  type = ACE_DEFAULT_SYNCH_TYPE,
const ACE_TCHAR name = 0,
void *  arg = 0
 

Definition at line 1320 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_TCHAR, and rwlock_init().

Referenced by ACE_RW_Mutex::ACE_RW_Mutex(), and rwlock_init().

01324 {
01325   // ACE_OS_TRACE ("ACE_OS::rwlock_init");
01326 #  if defined (ACE_HAS_PTHREADS_UNIX98_EXT)
01327   ACE_UNUSED_ARG (name);
01328   ACE_UNUSED_ARG (arg);
01329 
01330   int status;
01331   pthread_rwlockattr_t attr;
01332   pthread_rwlockattr_init (&attr);
01333 #    if !defined (ACE_LACKS_RWLOCKATTR_PSHARED)
01334   pthread_rwlockattr_setpshared (&attr, (type == USYNC_THREAD ?
01335                                          PTHREAD_PROCESS_PRIVATE :
01336                                          PTHREAD_PROCESS_SHARED));
01337 #    else
01338   ACE_UNUSED_ARG (type);
01339 #    endif /* !ACE_LACKS_RWLOCKATTR_PSHARED */
01340   status = ACE_ADAPT_RETVAL (pthread_rwlock_init (rw, &attr), status);
01341   pthread_rwlockattr_destroy (&attr);
01342 
01343   return status;
01344 
01345 #  else
01346   type = type;
01347   name = name;
01348   int result;
01349   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::rwlock_init (rw, type, arg), result), int, -1);
01350 #  endif /* ACE_HAS_PTHREADS_UNIX98_EXT */
01351 }

ACE_INLINE void * ACE_OS::sbrk ptrdiff_t  brk  ) 
 

Definition at line 767 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, and sbrk().

Referenced by ACE_Sbrk_Memory_Pool::acquire(), and sbrk().

00768 {
00769 #if defined (ACE_LACKS_SBRK)
00770   ACE_UNUSED_ARG (brk);
00771   ACE_NOTSUP_RETURN (0);
00772 #else
00773   ACE_OSCALL_RETURN (::sbrk (brk), void *, 0);
00774 #endif /* ACE_LACKS_SBRK */
00775 }

ACE_INLINE int scandir const ACE_TCHAR dirname,
struct ACE_DIRENT **  namelist[],
int(*  selector)(const struct ACE_DIRENT *),
int(*  comparator)(const struct ACE_DIRENT **f1, const struct ACE_DIRENT **f2)
 

Definition at line 136 of file OS_NS_dirent.inl.

References ACE_TCHAR, ACE_TEXT_ALWAYS_CHAR, and scandir_emulation().

00141 {
00142 #if defined (ACE_HAS_SCANDIR)
00143   return ::scandir (ACE_TEXT_ALWAYS_CHAR (dirname),
00144                     namelist,
00145                     selector,
00146 #  if defined (ACE_SCANDIR_CMP_USES_VOIDPTR)
00147                     reinterpret_cast<int(*)(const void*, const void*)> (comparator));
00148 #  else
00149                     comparator);
00150 #  endif /* ACE_SCANDIR_CMP_USES_VOIDPTR */
00151 #else /* ! defined ( ACE_HAS_SCANDIR) */
00152   return ACE_OS::scandir_emulation (dirname, namelist, selector, comparator);
00153 #endif /* ACE_HAS_SCANDIR */
00154 }

ACE_NAMESPACE_INLINE_FUNCTION int scandir const ACE_TCHAR dirname,
struct ACE_DIRENT **  namelist[],
int(*  selector)(const struct ACE_DIRENT *filename),
int(*  comparator)(const struct ACE_DIRENT **f1, const struct ACE_DIRENT **f2)
 

Referenced by ACE_Dirent_Selector::open().

ACE_BEGIN_VERSIONED_NAMESPACE_DECL int ACE_OS::scandir_emulation const ACE_TCHAR dirname,
ACE_DIRENT **  namelist[],
int(*  selector)(const ACE_DIRENT *entry),
int(*  comparator)(const ACE_DIRENT **f1, const ACE_DIRENT **f2)
 

Definition at line 186 of file OS_NS_dirent.cpp.

References ACE_DIR, ACE_DIRENT, ACE_SCANDIR_COMPARATOR, ACE_TCHAR, closedir(), free(), malloc(), memcpy(), opendir(), qsort(), readdir(), realloc(), strcpy(), and strlen().

Referenced by scandir().

00191 {
00192   ACE_DIR *dirp = ACE_OS::opendir (dirname);
00193 
00194   if (dirp == 0)
00195     return -1;
00196   // A sanity check here.  "namelist" had better not be zero.
00197   else if (namelist == 0)
00198     return -1;
00199 
00200   ACE_DIRENT **vector = 0;
00201   ACE_DIRENT *dp = 0;
00202   int arena_size = 0;
00203 
00204   int nfiles = 0;
00205   int fail = 0;
00206 
00207   // @@ This code shoulduse readdir_r() rather than readdir().
00208   for (dp = ACE_OS::readdir (dirp);
00209        dp != 0;
00210        dp = ACE_OS::readdir (dirp))
00211     {
00212       if (selector && (*selector)(dp) == 0)
00213         continue;
00214 
00215       // If we get here, we have a dirent that the user likes.
00216       if (nfiles == arena_size)
00217         {
00218           ACE_DIRENT **newv = 0;
00219           if (arena_size == 0)
00220             arena_size = 10;
00221           else
00222             arena_size *= 2;
00223 
00224           newv = (ACE_DIRENT **) ACE_OS::realloc (vector,
00225                                               arena_size * sizeof (ACE_DIRENT *));
00226           if (newv == 0)
00227             {
00228               fail = 1;
00229               break;
00230             }
00231           vector = newv;
00232         }
00233 
00234 #if defined (ACE_LACKS_STRUCT_DIR)
00235       ACE_DIRENT *newdp = (ACE_DIRENT *) ACE_OS::malloc (sizeof (ACE_DIRENT));
00236 #else
00237       size_t dsize =
00238         sizeof (ACE_DIRENT) +
00239         ((ACE_OS::strlen (dp->d_name) + 1) * sizeof (ACE_TCHAR));
00240       ACE_DIRENT *newdp = (ACE_DIRENT *) ACE_OS::malloc (dsize);
00241 #endif /* ACE_LACKS_STRUCT_DIR */
00242 
00243       if (newdp == 0)
00244         {
00245           fail = 1;
00246           break;
00247         }
00248 
00249 #if defined (ACE_LACKS_STRUCT_DIR)
00250       newdp->d_name = (ACE_TCHAR*) ACE_OS::malloc (
00251         (ACE_OS::strlen (dp->d_name) + 1) * sizeof (ACE_TCHAR));
00252 
00253       if (newdp->d_name == 0)
00254         {
00255           fail = 1;
00256           ACE_OS::free (newdp);
00257           break;
00258         }
00259 
00260       // Don't use memcpy here since d_name is now a pointer
00261       newdp->d_ino = dp->d_ino;
00262       newdp->d_off = dp->d_off;
00263       newdp->d_reclen = dp->d_reclen;
00264       ACE_OS::strcpy (newdp->d_name, dp->d_name);
00265       vector[nfiles++] = newdp;
00266 #else
00267       vector[nfiles++] = (ACE_DIRENT *) ACE_OS::memcpy (newdp, dp, dsize);
00268 #endif /* ACE_LACKS_STRUCT_DIR */
00269     }
00270 
00271   if (fail)
00272     {
00273       ACE_OS::closedir (dirp);
00274       while (nfiles-- > 0)
00275         {
00276 #if defined (ACE_LACKS_STRUCT_DIR)
00277           ACE_OS::free (vector[nfiles]->d_name);
00278 #endif /* ACE_LACKS_STRUCT_DIR */
00279           ACE_OS::free (vector[nfiles]);
00280         }
00281       ACE_OS::free (vector);
00282       return -1;
00283     }
00284 
00285   ACE_OS::closedir (dirp);
00286 
00287   *namelist = vector;
00288 
00289   if (comparator)
00290     ACE_OS::qsort (*namelist,
00291                    nfiles,
00292                    sizeof (ACE_DIRENT *),
00293                    (ACE_SCANDIR_COMPARATOR) comparator);
00294 
00295   return nfiles;
00296 }

int ACE_OS::sched_params const ACE_Sched_Params ,
ACE_id_t  id = ACE_SELF
 

Set scheduling parameters. An id of ACE_SELF indicates, e.g., set the parameters on the calling thread.

Definition at line 3536 of file OS_NS_Thread.cpp.

References ACE_ADAPT_RETVAL, ACE_id_t, ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_SCHED_FIFO, ACE_SCHED_RR, ACE_SCOPE_LWP, ACE_SCOPE_PROCESS, ACE_SCOPE_THREAD, ACE_SELF, ACE_thread_t, sched_params(), set_errno_to_last_error(), set_scheduling_params(), thr_self(), and thr_setprio().

Referenced by lwp_getparams(), lwp_setparams(), sched_params(), ACE_Process_Manager::set_scheduler(), ACE_Process_Manager::set_scheduler_all(), set_scheduling_params(), thr_create(), and thr_setprio().

03538 {
03539   ACE_OS_TRACE ("ACE_OS::sched_params");
03540 #if defined (ACE_HAS_STHREADS)
03541   return ACE_OS::set_scheduling_params (sched_params, id);
03542 #elif defined (ACE_HAS_PTHREADS) && \
03543       (!defined (ACE_LACKS_SETSCHED) || defined (ACE_TANDEM_T1248_PTHREADS) || \
03544       defined (ACE_HAS_PTHREAD_SCHEDPARAM))
03545   if (sched_params.quantum () != ACE_Time_Value::zero)
03546     {
03547       // quantums not supported
03548       errno = EINVAL;
03549       return -1;
03550     }
03551 
03552   // Thanks to Thilo Kielmann <kielmann@informatik.uni-siegen.de> for
03553   // providing this code for 1003.1c PThreads.  Please note that this
03554   // has only been tested for POSIX 1003.1c threads, and may cause
03555   // problems with other PThreads flavors!
03556 
03557   struct sched_param param;
03558   param.sched_priority = sched_params.priority ();
03559 
03560   if (sched_params.scope () == ACE_SCOPE_PROCESS)
03561     {
03562 # if defined(ACE_TANDEM_T1248_PTHREADS) || defined (ACE_HAS_PTHREAD_SCHEDPARAM)
03563       ACE_NOTSUP_RETURN (-1);
03564 # else  /* ! ACE_TANDEM_T1248_PTHREADS */
03565       int result = ::sched_setscheduler (id == ACE_SELF ? 0 : id,
03566                                          sched_params.policy (),
03567                                          &param) == -1 ? -1 : 0;
03568 # if defined (DIGITAL_UNIX)
03569       return result == 0
03570         ? // Use priocntl (2) to set the process in the RT class,
03571         // if using an RT policy.
03572         ACE_OS::set_scheduling_params (sched_params)
03573         : result;
03574 # else  /* ! DIGITAL_UNIX */
03575       return result;
03576 # endif /* ! DIGITAL_UNIX */
03577 # endif /* ! ACE_TANDEM_T1248_PTHREADS */
03578     }
03579   else if (sched_params.scope () == ACE_SCOPE_THREAD)
03580     {
03581       ACE_thread_t thr_id = ACE_OS::thr_self ();
03582 
03583 # if defined (ACE_HAS_PTHREADS_DRAFT4)
03584       return (::pthread_setscheduler (thr_id,
03585                                       sched_params.policy (),
03586                                       sched_params.priority()) == -1 ? -1 : 0);
03587 # else
03588       int result;
03589       ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_setschedparam (thr_id,
03590                                                                     sched_params.policy (),
03591                                                                     &param),
03592                                            result),
03593                          int, -1);
03594 # endif  /* ACE_HAS_PTHREADS_DRAFT4 */
03595     }
03596 # if defined (sun)
03597   // We need to be able to set LWP priorities on Suns, even without
03598   // ACE_HAS_STHREADS, to obtain preemption.
03599   else if (sched_params.scope () == ACE_SCOPE_LWP)
03600     return ACE_OS::set_scheduling_params (sched_params, id);
03601 # endif /* sun */
03602   else // sched_params.scope () == ACE_SCOPE_LWP, which isn't POSIX
03603     {
03604       errno = EINVAL;
03605       return -1;
03606     }
03607 
03608 #elif defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)
03609 
03610   // PharLap ETS can act on the current thread - it can set the
03611   // quantum also, unlike Win32. All this only works on the RT
03612   // version.
03613 # if defined (ACE_HAS_PHARLAP_RT)
03614   if (id != ACE_SELF)
03615     ACE_NOTSUP_RETURN (-1);
03616 
03617   if (sched_params.quantum() != ACE_Time_Value::zero)
03618     EtsSetTimeSlice (sched_params.quantum().msec());
03619 
03620 # else
03621 
03622   if (sched_params.quantum () != ACE_Time_Value::zero)
03623     {
03624       // I don't know of a way to set the quantum on Win32.
03625       errno = EINVAL;
03626       return -1;
03627     }
03628 
03629   if (sched_params.scope () == ACE_SCOPE_THREAD)
03630     {
03631 
03632       // Setting the REALTIME_PRIORITY_CLASS on Windows is almost always
03633       // a VERY BAD THING. This include guard will allow people
03634       // to easily disable this feature in ACE.
03635 #ifndef ACE_DISABLE_WIN32_INCREASE_PRIORITY
03636       // Set the priority class of this process to the REALTIME process class
03637       // _if_ the policy is ACE_SCHED_FIFO.  Otherwise, set to NORMAL.
03638       if (!::SetPriorityClass (::GetCurrentProcess (),
03639                                (sched_params.policy () == ACE_SCHED_FIFO ||
03640                                 sched_params.policy () == ACE_SCHED_RR)
03641                                ? REALTIME_PRIORITY_CLASS
03642                                : NORMAL_PRIORITY_CLASS))
03643         {
03644           ACE_OS::set_errno_to_last_error ();
03645           return -1;
03646         }
03647 #endif /* ACE_DISABLE_WIN32_INCREASE_PRIORITY */
03648 
03649 # endif /* ACE_HAS_PHARLAP_RT */
03650       // Now that we have set the priority class of the process, set the
03651       // priority of the current thread to the desired value.
03652       return ACE_OS::thr_setprio (sched_params.priority ());
03653     }
03654   else if (sched_params.scope () == ACE_SCOPE_PROCESS)
03655     {
03656       HANDLE hProcess = ::OpenProcess (PROCESS_SET_INFORMATION,
03657                                        FALSE,
03658                                        id);
03659       if (!hProcess)
03660         {
03661           ACE_OS::set_errno_to_last_error();
03662           return -1;
03663         }
03664       // There is no way for us to set the priority of the thread when we
03665       // are setting the priority of a different process.  So just ignore
03666       // the priority argument when ACE_SCOPE_PROCESS is specified.
03667       // Setting the priority class will automatically increase the base
03668       // priority of all the threads within a process while maintaining the
03669       // relative priorities of the threads within it.
03670       if (!::SetPriorityClass (hProcess,
03671                                (sched_params.policy () == ACE_SCHED_FIFO ||
03672                                 sched_params.policy () == ACE_SCHED_RR)
03673                                ? REALTIME_PRIORITY_CLASS
03674                                : NORMAL_PRIORITY_CLASS))
03675         {
03676           ACE_OS::set_errno_to_last_error ();
03677           ::CloseHandle (hProcess);
03678           return -1;
03679         }
03680       ::CloseHandle (hProcess);
03681       return 0;
03682     }
03683   else
03684     {
03685       errno = EINVAL;
03686       return -1;
03687     }
03688 #elif defined (ACE_VXWORKS)
03689   ACE_UNUSED_ARG (id);
03690 
03691   // There is only one class of priorities on VxWorks, and no time
03692   // quanta.  So, just set the current thread's priority.
03693 
03694   if (sched_params.policy () != ACE_SCHED_FIFO
03695       || sched_params.scope () != ACE_SCOPE_PROCESS
03696       || sched_params.quantum () != ACE_Time_Value::zero)
03697     {
03698       errno = EINVAL;
03699       return -1;
03700     }
03701 
03702   // Set the thread priority on the current thread.
03703   return ACE_OS::thr_setprio (sched_params.priority ());
03704 #else
03705   ACE_UNUSED_ARG (sched_params);
03706   ACE_UNUSED_ARG (id);
03707   ACE_NOTSUP_RETURN (-1);
03708 #endif /* ACE_HAS_STHREADS */
03709 }

int ACE_OS::scheduling_class const char *  class_name,
ACE_id_t
 

Find the schedling class ID that corresponds to the class name.

Definition at line 3712 of file OS_NS_Thread.cpp.

References ACE_id_t, ACE_NOTSUP_RETURN, memset(), priority_control(), and strcpy().

Referenced by lwp_getparams(), and set_scheduling_params().

03713 {
03714 #if defined (ACE_HAS_PRIOCNTL)
03715   // Get the priority class ID.
03716   pcinfo_t pcinfo;
03717   // The following is just to avoid Purify warnings about unitialized
03718   // memory reads.
03719   ACE_OS::memset (&pcinfo, 0, sizeof pcinfo);
03720 
03721   ACE_OS::strcpy (pcinfo.pc_clname, class_name);
03722   if (ACE_OS::priority_control (P_ALL /* ignored */,
03723                                 P_MYID /* ignored */,
03724                                 PC_GETCID,
03725                                 (char *) &pcinfo) == -1)
03726     {
03727       return -1;
03728     }
03729   else
03730     {
03731       id = pcinfo.pc_cid;
03732       return 0;
03733     }
03734 #else  /* ! ACE_HAS_PRIOCNTL */
03735   ACE_UNUSED_ARG (class_name);
03736   ACE_UNUSED_ARG (id);
03737   ACE_NOTSUP_RETURN (-1);
03738 #endif /* ! ACE_HAS_PRIOCNTL */
03739 }

ACE_INLINE void ACE_OS::seekdir ACE_DIR ,
long  loc
 

Definition at line 157 of file OS_NS_dirent.inl.

References ACE_DIR.

Referenced by ACE_Dirent::seek().

00158 {
00159 #if defined (ACE_HAS_DIRENT)  &&  !defined (ACE_LACKS_SEEKDIR)
00160   ::seekdir (d, loc);
00161 #else  /* ! ACE_HAS_DIRENT  ||  ACE_LACKS_SEEKDIR */
00162   ACE_UNUSED_ARG (d);
00163   ACE_UNUSED_ARG (loc);
00164 #endif /* ! ACE_HAS_DIRENT  ||  ACE_LACKS_SEEKDIR */
00165 }

ACE_INLINE int ACE_OS::select int  width,
fd_set *  rfds,
fd_set *  wfds,
fd_set *  efds,
const ACE_Time_Value tv
 

Definition at line 52 of file OS_NS_sys_select.inl.

References ___ACE_TIMEOUT, ACE_FD_SET_TYPE, ACE_OS_TRACE, and ACE_SOCKCALL_RETURN.

00055 {
00056   ACE_OS_TRACE ("ACE_OS::select");
00057 #if defined (ACE_HAS_NONCONST_SELECT_TIMEVAL)
00058 # define ___ACE_TIMEOUT &copy
00059   timeval copy = timeout;
00060 #else
00061 # define ___ACE_TIMEOUT timep
00062   const timeval *timep = timeout;
00063 #endif /* ACE_HAS_NONCONST_SELECT_TIMEVAL */
00064 #if defined(ACE_TANDEM_T1248_PTHREADS)
00065   ACE_SOCKCALL_RETURN (::spt_select (width,
00066                                  (ACE_FD_SET_TYPE *) rfds,
00067                                  (ACE_FD_SET_TYPE *) wfds,
00068                                  (ACE_FD_SET_TYPE *) efds,
00069                                  ___ACE_TIMEOUT),
00070                        int, -1);
00071 #else
00072   ACE_SOCKCALL_RETURN (::select (width,
00073                                  (ACE_FD_SET_TYPE *) rfds,
00074                                  (ACE_FD_SET_TYPE *) wfds,
00075                                  (ACE_FD_SET_TYPE *) efds,
00076                                  ___ACE_TIMEOUT),
00077                        int, -1);
00078 #endif
00079 #undef ___ACE_TIMEOUT
00080 }

ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE int ACE_OS::select int  width,
fd_set *  rfds,
fd_set *  wfds = 0,
fd_set *  efds = 0,
const ACE_Time_Value tv = 0
 

Definition at line 14 of file OS_NS_sys_select.inl.

References ACE_FD_SET_TYPE, ACE_OS_TRACE, and ACE_SOCKCALL_RETURN.

Referenced by ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::check_handles(), ACE_FlReactor::fl_io_proc(), ACE_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_2 >::handle_input(), ACE::handle_ready(), ACE::handle_timed_accept(), ACE::handle_timed_complete(), ACE_XtReactor::InputCallbackProc(), ACE_TkReactor::InputCallbackProc(), ACE_QtReactor::QtWaitForMultipleEvents(), ACE_SOCK_Dgram::recv(), ACE_SOCK_Dgram_SC< STREAM >::recv(), ACE_SOCK_IO::recvv(), ACE::select(), sema_wait(), ACE_SOCK_Dgram::send(), ACE_TkReactor::TkWaitForMultipleEvents(), ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::wait_for_multiple_events(), ACE_FlReactor::wait_for_multiple_events(), ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::work_pending(), and ACE_XtReactor::XtWaitForMultipleEvents().

00017 {
00018   ACE_OS_TRACE ("ACE_OS::select");
00019 #if defined (ACE_HAS_NONCONST_SELECT_TIMEVAL)
00020   // We must defend against non-conformity!
00021   timeval copy;
00022   timeval *timep = 0;
00023 
00024   if (timeout != 0)
00025     {
00026       copy = *timeout;
00027       timep = &copy;
00028     }
00029   else
00030     timep = 0;
00031 #else
00032   const timeval *timep = (timeout == 0 ? (const timeval *)0 : *timeout);
00033 #endif /* ACE_HAS_NONCONST_SELECT_TIMEVAL */
00034 #if defined(ACE_TANDEM_T1248_PTHREADS)
00035   ACE_SOCKCALL_RETURN (::spt_select (width,
00036                                  (ACE_FD_SET_TYPE *) rfds,
00037                                  (ACE_FD_SET_TYPE *) wfds,
00038                                  (ACE_FD_SET_TYPE *) efds,
00039                                  timep),
00040                        int, -1);
00041 #else
00042   ACE_SOCKCALL_RETURN (::select (width,
00043                                  (ACE_FD_SET_TYPE *) rfds,
00044                                  (ACE_FD_SET_TYPE *) wfds,
00045                                  (ACE_FD_SET_TYPE *) efds,
00046                                  timep),
00047                        int, -1);
00048 #endif
00049 }

ACE_INLINE int ACE_OS::sema_destroy ACE_sema_t *  s  ) 
 

Definition at line 1355 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, close(), cond_destroy(), event_destroy(), free(), mutex_destroy(), sema_destroy(), shm_unlink(), thread_mutex_destroy(), and unlink().

Referenced by event_destroy(), ACE_Semaphore::remove(), and sema_destroy().

01356 {
01357   ACE_OS_TRACE ("ACE_OS::sema_destroy");
01358 # if defined (ACE_HAS_POSIX_SEM)
01359   int result;
01360 #   if !defined (ACE_HAS_POSIX_SEM_TIMEOUT)
01361   ACE_OS::mutex_destroy (&s->lock_);
01362   ACE_OS::cond_destroy (&s->count_nonzero_);
01363 #   endif /* !ACE_HAS_POSIX_SEM_TIMEOUT */
01364 #   if defined (ACE_LACKS_NAMED_POSIX_SEM)
01365   if (s->name_)
01366     {
01367       // Only destroy the semaphore if we're the ones who
01368       // initialized it.
01369       ACE_OSCALL (::sem_destroy (s->sema_),int, -1, result);
01370       ACE_OS::shm_unlink (s->name_);
01371       delete s->name_;
01372       return result;
01373     }
01374 #   else
01375   if (s->name_)
01376     {
01377       ACE_OSCALL (::sem_unlink (s->name_), int, -1, result);
01378       ACE_OS::free ((void *) s->name_);
01379       ACE_OSCALL_RETURN (::sem_close (s->sema_), int, -1);
01380     }
01381 #   endif /*  ACE_LACKS_NAMED_POSIX_SEM */
01382   else
01383     {
01384       ACE_OSCALL (::sem_destroy (s->sema_), int, -1, result);
01385 #   if defined (ACE_LACKS_NAMED_POSIX_SEM)
01386       if (s->new_sema_ != 0)
01387 #   endif /* ACE_LACKS_NAMED_POSIX_SEM */
01388         delete s->sema_;
01389       s->sema_ = 0;
01390       return result;
01391     }
01392 # elif defined (ACE_USES_FIFO_SEM)
01393   int r0 = 0;
01394   if (s->name_)
01395     {
01396       r0 = ACE_OS::unlink (s->name_);
01397       ACE_OS::free (s->name_);
01398       s->name_ = 0;
01399     }
01400   int r1 = ACE_OS::close (s->fd_[0]);      /* ignore error */
01401   int r2 = ACE_OS::close (s->fd_[1]);      /* ignore error */
01402   return r0 != 0 || r1 != 0 || r2 != 0 ? -1 : 0;
01403 # elif defined (ACE_HAS_THREADS)
01404 #   if defined (ACE_HAS_STHREADS)
01405   int result;
01406   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::sema_destroy (s), result), int, -1);
01407 #   elif defined (ACE_HAS_PTHREADS)
01408   int r1 = ACE_OS::mutex_destroy (&s->lock_);
01409   int r2 = ACE_OS::cond_destroy (&s->count_nonzero_);
01410   return r1 != 0 || r2 != 0 ? -1 : 0;
01411 #   elif defined (ACE_HAS_WTHREADS)
01412 #     if !defined (ACE_USES_WINCE_SEMA_SIMULATION)
01413   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::CloseHandle (*s), ace_result_), int, -1);
01414 #     else /* ACE_USES_WINCE_SEMA_SIMULATION */
01415   // Free up underlying objects of the simulated semaphore.
01416   int r1 = ACE_OS::thread_mutex_destroy (&s->lock_);
01417   int r2 = ACE_OS::event_destroy (&s->count_nonzero_);
01418   return r1 != 0 || r2 != 0 ? -1 : 0;
01419 #     endif /* ACE_USES_WINCE_SEMA_SIMULATION */
01420 #   elif defined (ACE_VXWORKS)
01421   int result;
01422   ACE_OSCALL (::semDelete (s->sema_), int, -1, result);
01423   s->sema_ = 0;
01424   return result;
01425 #   endif /* ACE_HAS_STHREADS */
01426 # else
01427   ACE_UNUSED_ARG (s);
01428   ACE_NOTSUP_RETURN (-1);
01429 # endif /* ACE_HAS_POSIX_SEM */
01430 }

ACE_INLINE int ACE_OS::sema_init ACE_sema_t *  s,
u_int  count,
int  type,
const wchar_t *  name,
void *  arg = 0,
int  max = 0x7fffffff,
LPSECURITY_ATTRIBUTES  sa = 0
 

Definition at line 1763 of file OS_NS_Thread.inl.

References ACE_FAIL_RETURN, default_win32_security_attributes_r(), event_destroy(), event_init(), sema_init(), thread_mutex_destroy(), thread_mutex_init(), thread_mutex_lock(), and thread_mutex_unlock().

01770 {
01771 # if defined (ACE_HAS_WTHREADS)
01772 #   if ! defined (ACE_USES_WINCE_SEMA_SIMULATION)
01773   ACE_UNUSED_ARG (type);
01774   ACE_UNUSED_ARG (arg);
01775   // Create the semaphore with its value initialized to <count> and
01776   // its maximum value initialized to <max>.
01777   SECURITY_ATTRIBUTES sa_buffer;
01778   SECURITY_DESCRIPTOR sd_buffer;
01779   *s = ::CreateSemaphoreW
01780     (ACE_OS::default_win32_security_attributes_r (sa, &sa_buffer, &sd_buffer),
01781      count,
01782      max,
01783      name);
01784 
01785   if (*s == 0)
01786     ACE_FAIL_RETURN (-1);
01787   /* NOTREACHED */
01788   else
01789     return 0;
01790 #   else /* ACE_USES_WINCE_SEMA_SIMULATION */
01791   int result = -1;
01792 
01793   // Initialize internal object for semaphore simulation.
01794   // Grab the lock as soon as possible when we initializing
01795   // the semaphore count.  Notice that we initialize the
01796   // event object as "manually reset" so we can amortize the
01797   // cost for singling/reseting the event.
01798   // @@ I changed the mutex type to thread_mutex.  Notice that this
01799   // is basically a CriticalSection object and doesn't not has
01800   // any security attribute whatsoever.  However, since this
01801   // semaphore implementation only works within a process, there
01802   // shouldn't any security issue at all.
01803   if (ACE_OS::thread_mutex_init (&s->lock_, type, name, (ACE_mutexattr_t *)arg) == 0
01804       && ACE_OS::event_init (&s->count_nonzero_, 1,
01805                              count > 0, type, name, arg, sa) == 0
01806       && ACE_OS::thread_mutex_lock (&s->lock_) == 0)
01807     {
01808       s->count_ = count;
01809 
01810       if (ACE_OS::thread_mutex_unlock (&s->lock_) == 0)
01811         result = 0;
01812     }
01813 
01814   // Destroy the internal objects if we didn't initialize
01815   // either of them successfully.  Don't bother to check
01816   // for errors.
01817   if (result == -1)
01818     {
01819       ACE_OS::thread_mutex_destroy (&s->lock_);
01820       ACE_OS::event_destroy (&s->count_nonzero_);
01821     }
01822   return result;
01823 #   endif /* ACE_USES_WINCE_SEMA_SIMULATION */
01824 # else /* ACE_HAS_WTHREADS */
01825   // Just call the normal char version.
01826   return ACE_OS::sema_init (s, count, type, ACE_Wide_To_Ascii (name).char_rep (), arg, max, sa);
01827 # endif /* ACE_HAS_WTHREADS */
01828 }

ACE_INLINE int ACE_OS::sema_init ACE_sema_t *  s,
u_int  count,
int  type = ACE_DEFAULT_SYNCH_TYPE,
const char *  name = 0,
void *  arg = 0,
int  max = 0x7fffffff,
LPSECURITY_ATTRIBUTES  sa = 0
 

Definition at line 1436 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_ALLOCATOR_RETURN, ACE_DEFAULT_FILE_PERMS, ACE_FAIL_RETURN, ACE_NEW_RETURN, ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_stat, ACE_TEXT_CHAR_TO_TCHAR, ACE_UNIQUE_NAME_LEN, close(), cond_destroy(), cond_init(), default_win32_security_attributes_r(), event_destroy(), event_init(), F_GETFL, fcntl(), ftruncate(), MAP_FAILED, MAP_SHARED, MAXPATHLEN, mkfifo(), mmap(), mode_t, mutex_destroy(), mutex_init(), mutex_lock(), mutex_unlock(), O_NONBLOCK, open(), PROT_RDWR, sema_init(), shm_open(), stat(), strcat(), strcpy(), strdup(), strrchr(), thread_mutex_destroy(), thread_mutex_init(), thread_mutex_lock(), thread_mutex_unlock(), uname(), unique_name(), unlink(), and write().

Referenced by ACE_Semaphore::ACE_Semaphore(), event_init(), and sema_init().

01443 {
01444   ACE_OS_TRACE ("ACE_OS::sema_init");
01445 #if defined (ACE_HAS_POSIX_SEM)
01446   ACE_UNUSED_ARG (max);
01447   ACE_UNUSED_ARG (sa);
01448 
01449   s->name_ = 0;
01450 #  if defined (ACE_HAS_POSIX_SEM_TIMEOUT)
01451   ACE_UNUSED_ARG (arg);
01452 #  else
01453   int result = -1;
01454 
01455   if (ACE_OS::mutex_init (&s->lock_, type, name,
01456                           (ACE_mutexattr_t *) arg) == 0
01457       && ACE_OS::cond_init (&s->count_nonzero_, (short)type, name, arg) == 0
01458       && ACE_OS::mutex_lock (&s->lock_) == 0)
01459     {
01460       if (ACE_OS::mutex_unlock (&s->lock_) == 0)
01461         result = 0;
01462     }
01463 
01464   if (result == -1)
01465     {
01466       ACE_OS::mutex_destroy (&s->lock_);
01467       ACE_OS::cond_destroy (&s->count_nonzero_);
01468       return result;
01469     }
01470 #  endif /* ACE_HAS_POSIX_SEM_TIMEOUT */
01471 
01472 #  if defined (ACE_LACKS_NAMED_POSIX_SEM)
01473   s->new_sema_ = 0;
01474   if (type == USYNC_PROCESS)
01475     {
01476       // Let's see if it already exists.
01477       ACE_HANDLE fd = ACE_OS::shm_open (ACE_TEXT_CHAR_TO_TCHAR (name),
01478                                         O_RDWR | O_CREAT | O_EXCL,
01479                                         ACE_DEFAULT_FILE_PERMS);
01480       if (fd == ACE_INVALID_HANDLE)
01481         {
01482           if (errno == EEXIST)
01483             fd = ACE_OS::shm_open (ACE_TEXT_CHAR_TO_TCHAR (name),
01484                                    O_RDWR | O_CREAT,
01485                                    ACE_DEFAULT_FILE_PERMS);
01486           else
01487             return -1;
01488         }
01489       else
01490         {
01491           // We own this shared memory object!  Let's set its
01492           // size.
01493           if (ACE_OS::ftruncate (fd,
01494                                  sizeof (ACE_sema_t)) == -1)
01495             return -1;
01496           s->name_ = ACE_OS::strdup (name);
01497           if (s->name_ == 0)
01498             return -1;
01499         }
01500       if (fd == -1)
01501         return -1;
01502 
01503       s->sema_ = (sem_t *)
01504         ACE_OS::mmap (0,
01505                       sizeof (ACE_sema_t),
01506                       PROT_RDWR,
01507                       MAP_SHARED,
01508                       fd,
01509                       0);
01510       ACE_OS::close (fd);
01511       if (s->sema_ == (sem_t *) MAP_FAILED)
01512         return -1;
01513       if (s->name_
01514           // @@ According UNIX Network Programming V2 by Stevens,
01515           //    sem_init() is currently not required to return zero on
01516           //    success, but it *does* return -1 upon failure.  For
01517           //    this reason, check for failure by comparing to -1,
01518           //    instead of checking for success by comparing to zero.
01519           //        -Ossama
01520           // Only initialize it if we're the one who created it.
01521           && ::sem_init (s->sema_, type == USYNC_PROCESS, count) == -1)
01522         return -1;
01523       return 0;
01524     }
01525 #  else
01526   if (name)
01527     {
01528 #    if defined (sun) || defined (HPUX)
01529       // Solaris and HP-UX require the name to start with a slash. Solaris
01530       // further requires that there be no other slashes than the first.
01531       const char *last_slash = ACE_OS::strrchr (name, '/');
01532       char name2[MAXPATHLEN];
01533       if (0 == last_slash)
01534         {
01535           ACE_OS::strcpy (name2, "/");
01536           ACE_OS::strcat (name2, name);
01537           name = name2;
01538         }
01539 #      if defined (sun)
01540       else
01541         name = last_slash;         // Chop off chars preceding last slash
01542 #      endif /* sun */
01543 #    endif /* sun || HPUX */
01544 
01545       ACE_ALLOCATOR_RETURN (s->name_,
01546                             ACE_OS::strdup (name),
01547                             -1);
01548       s->sema_ = ::sem_open (s->name_,
01549                              O_CREAT,
01550                              ACE_DEFAULT_FILE_PERMS,
01551                              count);
01552       if (s->sema_ == (sem_t *) SEM_FAILED)
01553         return -1;
01554       else
01555         return 0;
01556     }
01557 #  endif /* ACE_LACKS_NAMED_POSIX_SEM */
01558   else
01559     {
01560       ACE_NEW_RETURN (s->sema_,
01561                       sem_t,
01562                       -1);
01563 #  if defined (ACE_LACKS_NAMED_POSIX_SEM)
01564       s->new_sema_ = 1;
01565 #  endif /* ACE_LACKS_NAMED_POSIX_SEM */
01566       ACE_OSCALL_RETURN (::sem_init (s->sema_,
01567                                      type != USYNC_THREAD,
01568                                      count), int, -1);
01569     }
01570 
01571 #elif defined (ACE_USES_FIFO_SEM)
01572   ACE_UNUSED_ARG (arg);
01573   ACE_UNUSED_ARG (max);
01574   ACE_UNUSED_ARG (sa);
01575   int             flags = 0;
01576   mode_t          mode = S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP;
01577 
01578   if (type == USYNC_THREAD)
01579     {
01580       // Create systemwide unique name for semaphore
01581       char   uname[ACE_UNIQUE_NAME_LEN];
01582       ACE_OS::unique_name ((const void *) s,
01583                             uname,
01584                             ACE_UNIQUE_NAME_LEN);
01585       name = &uname[0];
01586     }
01587 
01588   s->name_ = 0;
01589   s->fd_[0] = s->fd_[1] = ACE_INVALID_HANDLE;
01590   bool creator = false;
01591 
01592   if (ACE_OS::mkfifo (ACE_TEXT_CHAR_TO_TCHAR (name), mode) < 0)
01593     {
01594       if (errno != EEXIST)    /* already exists OK else ERR */
01595         return -1;
01596       // check if this is a real FIFO, not just some other existing file
01597       ACE_stat fs;
01598       if (ACE_OS::stat (name, &fs))
01599         return -1;
01600       if (!S_ISFIFO (fs.st_mode))
01601         {
01602           // existing file is not a FIFO
01603           errno = EEXIST;
01604           return -1;
01605         }
01606     }
01607     else
01608       creator = true; // remember we created it for initialization at end
01609 
01610   // for processshared semaphores remember who we are to be able to remove
01611   // the FIFO when we're done with it
01612   if (type == USYNC_PROCESS)
01613     {
01614       s->name_ = ACE_OS::strdup (name);
01615       if (s->name_ == 0)
01616         {
01617           if (creator)
01618             ACE_OS::unlink (name);
01619           return -1;
01620         }
01621     }
01622 
01623   if ((s->fd_[0] = ACE_OS::open (name, O_RDONLY | O_NONBLOCK)) == ACE_INVALID_HANDLE
01624       || (s->fd_[1] = ACE_OS::open (name, O_WRONLY | O_NONBLOCK)) == ACE_INVALID_HANDLE)
01625     return (-1);
01626 
01627   /* turn off nonblocking for fd_[0] */
01628   if ((flags = ACE_OS::fcntl (s->fd_[0], F_GETFL, 0)) < 0)
01629     return (-1);
01630 
01631   flags &= ~O_NONBLOCK;
01632   if (ACE_OS::fcntl (s->fd_[0], F_SETFL, flags) < 0)
01633     return (-1);
01634 
01635   //if (s->name_ && count)
01636   if (creator && count)
01637     {
01638       char    c = 1;
01639       for (u_int i=0; i<count ;++i)
01640         if (ACE_OS::write (s->fd_[1], &c, sizeof (char)) != 1)
01641           return (-1);
01642     }
01643 
01644   // In the case of processscope semaphores we can already unlink the FIFO now that
01645   // we completely set it up (the opened handles will keep it active until we close
01646   // thos down). This way we're protected against unexpected crashes as far as removal
01647   // is concerned.
01648   // Unfortunately this does not work for processshared FIFOs since as soon as we
01649   // have unlinked the semaphore no other process will be able to open it anymore.
01650   if (type == USYNC_THREAD)
01651     {
01652       ACE_OS::unlink (name);
01653     }
01654 
01655   return (0);
01656 #elif defined (ACE_HAS_THREADS)
01657 #  if defined (ACE_HAS_STHREADS)
01658   ACE_UNUSED_ARG (name);
01659   ACE_UNUSED_ARG (max);
01660   ACE_UNUSED_ARG (sa);
01661   int result;
01662   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::sema_init (s, count, type, arg), result),
01663                      int, -1);
01664 #  elif defined (ACE_HAS_PTHREADS)
01665   ACE_UNUSED_ARG (max);
01666   ACE_UNUSED_ARG (sa);
01667   int result = -1;
01668 
01669   if (ACE_OS::mutex_init (&s->lock_, type, name,
01670                           (ACE_mutexattr_t *) arg) == 0
01671       && ACE_OS::cond_init (&s->count_nonzero_, type, name, arg) == 0
01672       && ACE_OS::mutex_lock (&s->lock_) == 0)
01673     {
01674       s->count_ = count;
01675       s->waiters_ = 0;
01676 
01677       if (ACE_OS::mutex_unlock (&s->lock_) == 0)
01678         result = 0;
01679     }
01680 
01681   if (result == -1)
01682     {
01683       ACE_OS::mutex_destroy (&s->lock_);
01684       ACE_OS::cond_destroy (&s->count_nonzero_);
01685     }
01686   return result;
01687 #  elif defined (ACE_HAS_WTHREADS)
01688 #    if ! defined (ACE_USES_WINCE_SEMA_SIMULATION)
01689   ACE_UNUSED_ARG (type);
01690   ACE_UNUSED_ARG (arg);
01691   // Create the semaphore with its value initialized to <count> and
01692   // its maximum value initialized to <max>.
01693   SECURITY_ATTRIBUTES sa_buffer;
01694   SECURITY_DESCRIPTOR sd_buffer;
01695   *s = ::CreateSemaphoreA
01696     (ACE_OS::default_win32_security_attributes_r (sa, &sa_buffer, &sd_buffer),
01697      count,
01698      max,
01699      name);
01700 
01701   if (*s == 0)
01702     ACE_FAIL_RETURN (-1);
01703   /* NOTREACHED */
01704   else
01705     return 0;
01706 #    else /* ACE_USES_WINCE_SEMA_SIMULATION */
01707   int result = -1;
01708 
01709   // Initialize internal object for semaphore simulation.
01710   // Grab the lock as soon as possible when we initializing
01711   // the semaphore count.  Notice that we initialize the
01712   // event object as "manually reset" so we can amortize the
01713   // cost for singling/reseting the event.
01714   // @@ I changed the mutex type to thread_mutex.  Notice that this
01715   // is basically a CriticalSection object and doesn't not has
01716   // any security attribute whatsoever.  However, since this
01717   // semaphore implementation only works within a process, there
01718   // shouldn't any security issue at all.
01719   if (ACE_OS::thread_mutex_init (&s->lock_, type, name, (ACE_mutexattr_t *)arg) == 0
01720       && ACE_OS::event_init (&s->count_nonzero_, 1,
01721                              count > 0, type, name, arg, sa) == 0
01722       && ACE_OS::thread_mutex_lock (&s->lock_) == 0)
01723     {
01724       s->count_ = count;
01725 
01726       if (ACE_OS::thread_mutex_unlock (&s->lock_) == 0)
01727         result = 0;
01728     }
01729 
01730   // Destroy the internal objects if we didn't initialize
01731   // either of them successfully.  Don't bother to check
01732   // for errors.
01733   if (result == -1)
01734     {
01735       ACE_OS::thread_mutex_destroy (&s->lock_);
01736       ACE_OS::event_destroy (&s->count_nonzero_);
01737     }
01738   return result;
01739 #    endif /* ACE_USES_WINCE_SEMA_SIMULATION */
01740 #  elif defined (ACE_VXWORKS)
01741   ACE_UNUSED_ARG (name);
01742   ACE_UNUSED_ARG (arg);
01743   ACE_UNUSED_ARG (max);
01744   ACE_UNUSED_ARG (sa);
01745   s->name_ = 0;
01746   s->sema_ = ::semCCreate (type, count);
01747   return s->sema_ ? 0 : -1;
01748 #  endif /* ACE_HAS_STHREADS */
01749 #else
01750   ACE_UNUSED_ARG (s);
01751   ACE_UNUSED_ARG (count);
01752   ACE_UNUSED_ARG (type);
01753   ACE_UNUSED_ARG (name);
01754   ACE_UNUSED_ARG (arg);
01755   ACE_UNUSED_ARG (max);
01756   ACE_UNUSED_ARG (sa);
01757   ACE_NOTSUP_RETURN (-1);
01758 #endif /* ACE_HAS_POSIX_SEM */
01759 }

ACE_INLINE int ACE_OS::sema_post ACE_sema_t *  s,
u_int  release_count
 

Definition at line 1908 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, and sema_post().

01909 {
01910 #if defined (ACE_WIN32) && !defined (ACE_USES_WINCE_SEMA_SIMULATION)
01911   // Win32 supports this natively.
01912   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::ReleaseSemaphore (*s, release_count, 0),
01913                                           ace_result_), int, -1);
01914 #else
01915   // On POSIX platforms we need to emulate this ourselves.
01916   // @@ We can optimize on this implementation.  However,
01917   // the semaphore promitive on Win32 doesn't allow one
01918   // to increase a semaphore to more than the count it was
01919   // first initialized.  Posix and solaris don't seem to have
01920   // this restriction.  Should we impose the restriction in
01921   // our semaphore simulation?
01922   for (size_t i = 0; i < release_count; i++)
01923     if (ACE_OS::sema_post (s) == -1)
01924       return -1;
01925 
01926   return 0;
01927 #endif /* ACE_WIN32 */
01928 }

ACE_INLINE int ACE_OS::sema_post ACE_sema_t *  s  ) 
 

Definition at line 1832 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, cond_signal(), event_signal(), mutex_lock(), mutex_unlock(), sema_post(), thread_mutex_lock(), thread_mutex_unlock(), and write().

Referenced by event_init(), event_pulse(), event_reset(), event_signal(), event_timedwait(), event_wait(), ACE_Semaphore::release(), and sema_post().

01833 {
01834   ACE_OS_TRACE ("ACE_OS::sema_post");
01835 # if defined (ACE_HAS_POSIX_SEM)
01836 #   if defined (ACE_HAS_POSIX_SEM_TIMEOUT)
01837   ACE_OSCALL_RETURN (::sem_post (s->sema_), int, -1);
01838 #   else
01839   int result = -1;
01840 
01841   if (ACE_OS::mutex_lock (&s->lock_) == 0)
01842     {
01843       if (::sem_post (s->sema_) == 0)
01844         result = ACE_OS::cond_signal (&s->count_nonzero_);
01845 
01846       ACE_OS::mutex_unlock (&s->lock_);
01847     }
01848   return result;
01849 #   endif /* ACE_HAS_POSIX_SEM_TIMEOUT */
01850 # elif defined (ACE_USES_FIFO_SEM)
01851   char    c = 1;
01852   if (ACE_OS::write (s->fd_[1], &c, sizeof (char)) == sizeof (char))
01853     return (0);
01854   return (-1);
01855 # elif defined (ACE_HAS_THREADS)
01856 #   if defined (ACE_HAS_STHREADS)
01857   int result;
01858   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::sema_post (s), result), int, -1);
01859 #   elif defined (ACE_HAS_PTHREADS)
01860   int result = -1;
01861 
01862   if (ACE_OS::mutex_lock (&s->lock_) == 0)
01863     {
01864       // Always allow a waiter to continue if there is one.
01865       if (s->waiters_ > 0)
01866         result = ACE_OS::cond_signal (&s->count_nonzero_);
01867       else
01868         result = 0;
01869 
01870       s->count_++;
01871       ACE_OS::mutex_unlock (&s->lock_);
01872     }
01873   return result;
01874 #   elif defined (ACE_HAS_WTHREADS)
01875 #     if !defined (ACE_USES_WINCE_SEMA_SIMULATION)
01876   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::ReleaseSemaphore (*s, 1, 0),
01877                                           ace_result_),
01878                         int, -1);
01879 #     else /* ACE_USES_WINCE_SEMA_SIMULATION */
01880   int result = -1;
01881 
01882   // Since we are simulating semaphores, we need to update semaphore
01883   // count manually.  Grab the lock to prevent race condition first.
01884   if (ACE_OS::thread_mutex_lock (&s->lock_) == 0)
01885     {
01886       // Check the original state of event object.  Single the event
01887       // object in transition from semaphore not available to
01888       // semaphore available.
01889       if (s->count_++ <= 0)
01890         result = ACE_OS::event_signal (&s->count_nonzero_);
01891       else
01892         result = 0;
01893 
01894       ACE_OS::thread_mutex_unlock (&s->lock_);
01895     }
01896   return result;
01897 #     endif /* ACE_USES_WINCE_SEMA_SIMULATION */
01898 #   elif defined (ACE_VXWORKS)
01899   ACE_OSCALL_RETURN (::semGive (s->sema_), int, -1);
01900 #   endif /* ACE_HAS_STHREADS */
01901 # else
01902   ACE_UNUSED_ARG (s);
01903   ACE_NOTSUP_RETURN (-1);
01904 # endif /* ACE_HAS_POSIX_SEM */
01905 }

ACE_INLINE int ACE_OS::sema_trywait ACE_sema_t *  s  ) 
 

Definition at line 1931 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, EBUSY, event_reset(), F_GETFL, fcntl(), mutex_lock(), mutex_unlock(), O_NONBLOCK, read(), sema_trywait(), set_errno_to_last_error(), thread_mutex_lock(), and thread_mutex_unlock().

Referenced by sema_trywait(), sema_wait(), and ACE_Semaphore::tryacquire().

01932 {
01933   ACE_OS_TRACE ("ACE_OS::sema_trywait");
01934 # if defined (ACE_HAS_POSIX_SEM)
01935   // POSIX semaphores set errno to EAGAIN if trywait fails
01936   ACE_OSCALL_RETURN (::sem_trywait (s->sema_), int, -1);
01937 # elif defined (ACE_USES_FIFO_SEM)
01938   char  c;
01939   int     rc, flags;
01940 
01941   /* turn on nonblocking for s->fd_[0] */
01942   if ((flags = ACE_OS::fcntl (s->fd_[0], F_GETFL, 0)) < 0)
01943     return (-1);
01944   flags |= O_NONBLOCK;
01945   if (ACE_OS::fcntl (s->fd_[0], F_SETFL, flags) < 0)
01946     return (-1);
01947 
01948   // read sets errno to EAGAIN if no input
01949   rc = ACE_OS::read (s->fd_[0], &c, sizeof (char));
01950 
01951   /* turn off nonblocking for fd_[0] */
01952   if ((flags = ACE_OS::fcntl (s->fd_[0], F_GETFL, 0)) >= 0)
01953   {
01954     flags &= ~O_NONBLOCK;
01955     ACE_OS::fcntl (s->fd_[0], F_SETFL, flags);
01956   }
01957 
01958   return rc == 1 ? 0 : (-1);
01959 # elif defined (ACE_HAS_THREADS)
01960 #   if defined (ACE_HAS_STHREADS)
01961   // STHREADS semaphores set errno to EBUSY if trywait fails.
01962   int result;
01963   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::sema_trywait (s),
01964                                        result),
01965                      int, -1);
01966 #   elif defined (ACE_HAS_PTHREADS)
01967 
01968   int result = -1;
01969 
01970   if (ACE_OS::mutex_lock (&s->lock_) == 0)
01971     {
01972       if (s->count_ > 0)
01973         {
01974           --s->count_;
01975           result = 0;
01976         }
01977       else
01978         errno = EBUSY;
01979 
01980       ACE_OS::mutex_unlock (&s->lock_);
01981     }
01982   return result;
01983 #   elif defined (ACE_HAS_WTHREADS)
01984 #     if !defined (ACE_USES_WINCE_SEMA_SIMULATION)
01985   int result = ::WaitForSingleObject (*s, 0);
01986 
01987   if (result == WAIT_OBJECT_0)
01988     return 0;
01989   else
01990     {
01991       if (result == WAIT_TIMEOUT)
01992         errno = EBUSY;
01993       else
01994         ACE_OS::set_errno_to_last_error ();
01995       // This is a hack, we need to find an appropriate mapping...
01996       return -1;
01997     }
01998 #     else /* ACE_USES_WINCE_SEMA_SIMULATION */
01999   // Check the status of semaphore first.  Return immediately
02000   // if the semaphore is not available and avoid grabing the
02001   // lock.
02002   int result = ::WaitForSingleObject (s->count_nonzero_, 0);
02003 
02004   if (result == WAIT_OBJECT_0)  // Proceed when it is available.
02005     {
02006       ACE_OS::thread_mutex_lock (&s->lock_);
02007 
02008       // Need to double check if the semaphore is still available.
02009       // The double checking scheme will slightly affect the
02010       // efficiency if most of the time semaphores are not blocked.
02011       result = ::WaitForSingleObject (s->count_nonzero_, 0);
02012       if (result == WAIT_OBJECT_0)
02013         {
02014           // Adjust the semaphore count.  Only update the event
02015           // object status when the state changed.
02016           s->count_--;
02017           if (s->count_ <= 0)
02018             ACE_OS::event_reset (&s->count_nonzero_);
02019           result = 0;
02020         }
02021 
02022       ACE_OS::thread_mutex_unlock (&s->lock_);
02023     }
02024 
02025   // Translate error message to errno used by ACE.
02026   if (result == WAIT_TIMEOUT)
02027     errno = EBUSY;
02028   else
02029     ACE_OS::set_errno_to_last_error ();
02030   // This is taken from the hack above. ;)
02031   return -1;
02032 #     endif /* ACE_USES_WINCE_SEMA_SIMULATION */
02033 #   elif defined (ACE_VXWORKS)
02034   if (::semTake (s->sema_, NO_WAIT) == ERROR)
02035     if (errno == S_objLib_OBJ_UNAVAILABLE)
02036       {
02037         // couldn't get the semaphore
02038         errno = EBUSY;
02039         return -1;
02040       }
02041     else
02042       // error
02043       return -1;
02044   else
02045     // got the semaphore
02046     return 0;
02047 #   endif /* ACE_HAS_STHREADS */
02048 # else
02049   ACE_UNUSED_ARG (s);
02050   ACE_NOTSUP_RETURN (-1);
02051 # endif /* ACE_HAS_POSIX_SEM */
02052 }

ACE_INLINE int ACE_OS::sema_wait ACE_sema_t *  s,
ACE_Time_Value tv
 

Definition at line 2436 of file OS_NS_Thread.inl.

References sema_wait().

02437 {
02438   return tv == 0 ? ACE_OS::sema_wait (s) : ACE_OS::sema_wait (s, *tv);
02439 }

ACE_INLINE int ACE_OS::sema_wait ACE_sema_t *  s,
ACE_Time_Value tv
 

Definition at line 2164 of file OS_NS_Thread.inl.

References ACE_NOTSUP_RETURN, ACE_ONE_SECOND_IN_USECS, ACE_OS_TRACE, ACE_PTHREAD_CLEANUP_POP, ACE_PTHREAD_CLEANUP_PUSH, cond_timedwait(), EBUSY, ETIME, ETIMEDOUT, event_reset(), gettimeofday(), ACE_Time_Value::msec(), mutex_lock(), mutex_unlock(), ACE_Time_Value::sec(), select(), sema_trywait(), ACE_Handle_Set::set_bit(), set_errno_to_last_error(), thread_mutex_lock(), thread_mutex_unlock(), timespec_t, and ACE_Time_Value::usec().

02165 {
02166   ACE_OS_TRACE ("ACE_OS::sema_wait");
02167 # if defined (ACE_HAS_POSIX_SEM)
02168 #   if defined (ACE_HAS_POSIX_SEM_TIMEOUT)
02169   int rc;
02170   timespec_t ts;
02171   ts = tv; // Calls ACE_Time_Value::operator timespec_t().
02172   ACE_OSCALL (::sem_timedwait (s->sema_, &ts), int, -1, rc);
02173   if (rc == -1 && errno == ETIMEDOUT)
02174     errno = ETIME;  /* POSIX returns ETIMEDOUT but we need ETIME */
02175   return rc;
02176 #   else
02177   int result = 0;
02178   bool expired = false;
02179   ACE_Errno_Guard error (errno);
02180 
02181   ACE_PTHREAD_CLEANUP_PUSH (&s->lock_);
02182 
02183   if (ACE_OS::mutex_lock (&s->lock_) != 0)
02184     result = -2;
02185   else
02186     {
02187       bool finished = true;
02188       do
02189       {
02190         result = ACE_OS::sema_trywait (s);
02191         if (result == -1 && errno == EAGAIN)
02192           expired = ACE_OS::gettimeofday () > tv;
02193         else
02194           expired = false;
02195 
02196         finished = result != -1 || expired ||
02197                    (result == -1 && errno != EAGAIN);
02198         if (!finished)
02199           {
02200             if (ACE_OS::cond_timedwait (&s->count_nonzero_,
02201                                         &s->lock_,
02202                                         &tv) == -1)
02203               {
02204                 error = errno;
02205                 result = -1;
02206                 break;
02207               }
02208           }
02209       } while (!finished);
02210 
02211       if (expired)
02212         error = ETIME;
02213 
02214 #     if defined (ACE_LACKS_COND_TIMEDWAIT_RESET)
02215       tv = ACE_OS::gettimeofday ();
02216 #     endif /* ACE_LACKS_COND_TIMEDWAIT_RESET */
02217     }
02218 
02219   if (result != -2)
02220     ACE_OS::mutex_unlock (&s->lock_);
02221   ACE_PTHREAD_CLEANUP_POP (0);
02222   return result < 0 ? -1 : result;
02223 #   endif /* !ACE_HAS_POSIX_SEM_TIMEOUT */
02224 # elif defined (ACE_USES_FIFO_SEM)
02225   int rc;
02226   ACE_Time_Value now = ACE_OS::gettimeofday ();
02227 
02228   while (tv > now)
02229     {
02230       ACE_Time_Value timeout = tv;
02231       timeout -= now;
02232 
02233       ACE_Handle_Set  fds_;
02234 
02235       fds_.set_bit (s->fd_[0]);
02236       if ((rc = ACE_OS::select (ACE_Handle_Set::MAXSIZE, fds_, 0, 0, timeout)) != 1)
02237         {
02238           if (rc == 0 || errno != EAGAIN)
02239           {
02240             if (rc == 0)
02241               errno = ETIME;
02242             return (-1);
02243           }
02244         }
02245 
02246       // try to read the signal *but* do *not* block
02247       if (rc == 1 && ACE_OS::sema_trywait (s) == 0)
02248         return (0);
02249 
02250       // we were woken for input but someone beat us to it
02251       // so we wait again if there is still time
02252       now = ACE_OS::gettimeofday ();
02253     }
02254 
02255   // make sure errno is set right
02256   errno = ETIME;
02257 
02258   return (-1);
02259 # elif defined (ACE_HAS_THREADS)
02260 #   if defined (ACE_HAS_STHREADS)
02261   ACE_UNUSED_ARG (s);
02262   ACE_UNUSED_ARG (tv);
02263   ACE_NOTSUP_RETURN (-1);
02264 #   elif defined (ACE_HAS_PTHREADS)
02265   int result = 0;
02266   ACE_Errno_Guard error (errno);
02267 
02268   ACE_PTHREAD_CLEANUP_PUSH (&s->lock_);
02269 
02270   if (ACE_OS::mutex_lock (&s->lock_) != 0)
02271     result = -1;
02272   else
02273     {
02274       // Keep track of the number of waiters so that we can signal
02275       // them properly in <ACE_OS::sema_post>.
02276       s->waiters_++;
02277 
02278       // Wait until the semaphore count is > 0 or until we time out.
02279       while (s->count_ == 0)
02280         if (ACE_OS::cond_timedwait (&s->count_nonzero_,
02281                                     &s->lock_,
02282                                     &tv) == -1)
02283           {
02284             error = errno;
02285             result = -2; // -2 means that we need to release the mutex.
02286             break;
02287           }
02288 
02289       --s->waiters_;
02290     }
02291 
02292   if (result == 0)
02293     {
02294 #     if defined (ACE_LACKS_COND_TIMEDWAIT_RESET)
02295       tv = ACE_OS::gettimeofday ();
02296 #     endif /* ACE_LACKS_COND_TIMEDWAIT_RESET */
02297       --s->count_;
02298     }
02299 
02300   if (result != -1)
02301     ACE_OS::mutex_unlock (&s->lock_);
02302   ACE_PTHREAD_CLEANUP_POP (0);
02303   return result < 0 ? -1 : result;
02304 #   elif defined (ACE_HAS_WTHREADS)
02305 #     if !defined (ACE_USES_WINCE_SEMA_SIMULATION)
02306   int msec_timeout;
02307 
02308   if (tv.sec () == 0 && tv.usec () == 0)
02309     msec_timeout = 0; // Do a "poll."
02310   else
02311     {
02312       // Note that we must convert between absolute time (which is
02313       // passed as a parameter) and relative time (which is what
02314       // <WaitForSingleObjects> expects).
02315       ACE_Time_Value relative_time (tv - ACE_OS::gettimeofday ());
02316 
02317       // Watchout for situations where a context switch has caused the
02318       // current time to be > the timeout.
02319       if (relative_time < ACE_Time_Value::zero)
02320         msec_timeout = 0;
02321       else
02322         msec_timeout = relative_time.msec ();
02323     }
02324 
02325   switch (::WaitForSingleObject (*s, msec_timeout))
02326     {
02327     case WAIT_OBJECT_0:
02328       tv = ACE_OS::gettimeofday ();     // Update time to when acquired
02329       return 0;
02330     case WAIT_TIMEOUT:
02331       errno = ETIME;
02332       return -1;
02333     default:
02334       // This is a hack, we need to find an appropriate mapping...
02335       ACE_OS::set_errno_to_last_error ();
02336       return -1;
02337     }
02338   /* NOTREACHED */
02339 #     else /* ACE_USES_WINCE_SEMA_SIMULATION */
02340   // Note that in this mode, the acquire is done in two steps, and
02341   // we may get signaled but cannot grab the semaphore before
02342   // timeout.  In that case, we'll need to restart the process with
02343   // updated timeout value.
02344 
02345   // <tv> is an absolute time
02346   ACE_Time_Value relative_time = tv - ACE_OS::gettimeofday ();
02347   int result = -1;
02348 
02349   // While we are not timeout yet.
02350   while (relative_time > ACE_Time_Value::zero)
02351     {
02352       // Wait for our turn to get the object.
02353       switch (::WaitForSingleObject (s->count_nonzero_, relative_time.msec ()))
02354         {
02355         case WAIT_OBJECT_0:
02356           ACE_OS::thread_mutex_lock (&s->lock_);
02357 
02358           // Need to double check if the semaphore is still available.
02359           // We can only do a "try lock" styled wait here to avoid
02360           // blocking threads that want to signal the semaphore.
02361           if (::WaitForSingleObject (s->count_nonzero_, 0) == WAIT_OBJECT_0)
02362             {
02363               // As before, only reset the object when the semaphore
02364               // is no longer available.
02365               s->count_--;
02366               if (s->count_ <= 0)
02367                 ACE_OS::event_reset (&s->count_nonzero_);
02368               result = 0;
02369             }
02370 
02371           ACE_OS::thread_mutex_unlock (&s->lock_);
02372 
02373           // Only return when we successfully get the semaphore.
02374           if (result == 0)
02375             {
02376               tv = ACE_OS::gettimeofday ();     // Update to time acquired
02377               return 0;
02378             }
02379           break;
02380 
02381           // We have timed out.
02382         case WAIT_TIMEOUT:
02383           errno = ETIME;
02384           return -1;
02385 
02386           // What?
02387         default:
02388           ACE_OS::set_errno_to_last_error ();
02389           // This is taken from the hack above. ;)
02390           return -1;
02391         };
02392 
02393       // Haven't been able to get the semaphore yet, update the
02394       // timeout value to reflect the remaining time we want to wait.
02395       relative_time = tv - ACE_OS::gettimeofday ();
02396     }
02397 
02398   // We have timed out.
02399   errno = ETIME;
02400   return -1;
02401 #     endif /* ACE_USES_WINCE_SEMA_SIMULATION */
02402 #   elif defined (ACE_VXWORKS)
02403   // Note that we must convert between absolute time (which is
02404   // passed as a parameter) and relative time (which is what
02405   // the system call expects).
02406   ACE_Time_Value relative_time (tv - ACE_OS::gettimeofday ());
02407 
02408   int ticks_per_sec = ::sysClkRateGet ();
02409 
02410   int ticks = relative_time.sec () * ticks_per_sec +
02411               relative_time.usec () * ticks_per_sec / ACE_ONE_SECOND_IN_USECS;
02412   if (::semTake (s->sema_, ticks) == ERROR)
02413     {
02414       if (errno == S_objLib_OBJ_TIMEOUT)
02415         // Convert the VxWorks errno to one that's common for to ACE
02416         // platforms.
02417         errno = ETIME;
02418       else if (errno == S_objLib_OBJ_UNAVAILABLE)
02419         errno = EBUSY;
02420       return -1;
02421     }
02422   else
02423     {
02424       tv = ACE_OS::gettimeofday ();  // Update to time acquired
02425       return 0;
02426     }
02427 #   endif /* ACE_HAS_STHREADS */
02428 # else
02429   ACE_UNUSED_ARG (s);
02430   ACE_UNUSED_ARG (tv);
02431   ACE_NOTSUP_RETURN (-1);
02432 # endif /* ACE_HAS_POSIX_SEM */
02433 }

ACE_INLINE int ACE_OS::sema_wait ACE_sema_t *  s  ) 
 

Definition at line 2055 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_PTHREAD_CLEANUP_POP, ACE_PTHREAD_CLEANUP_PUSH, cond_wait(), event_reset(), mutex_lock(), mutex_unlock(), read(), sema_wait(), set_errno_to_last_error(), thread_mutex_lock(), and thread_mutex_unlock().

Referenced by ACE_Semaphore::acquire(), event_pulse(), event_reset(), event_signal(), event_timedwait(), event_wait(), and sema_wait().

02056 {
02057   ACE_OS_TRACE ("ACE_OS::sema_wait");
02058 # if defined (ACE_HAS_POSIX_SEM)
02059   ACE_OSCALL_RETURN (::sem_wait (s->sema_), int, -1);
02060 # elif defined (ACE_USES_FIFO_SEM)
02061   char c;
02062   if (ACE_OS::read (s->fd_[0], &c, sizeof (char)) == 1)
02063     return (0);
02064   return (-1);
02065 # elif defined (ACE_HAS_THREADS)
02066 #   if defined (ACE_HAS_STHREADS)
02067   int result;
02068   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::sema_wait (s), result), int, -1);
02069 #   elif defined (ACE_HAS_PTHREADS)
02070   int result = 0;
02071 
02072   ACE_PTHREAD_CLEANUP_PUSH (&s->lock_);
02073 
02074   if (ACE_OS::mutex_lock (&s->lock_) != 0)
02075     result = -1;
02076   else
02077     {
02078       // Keep track of the number of waiters so that we can signal
02079       // them properly in <ACE_OS::sema_post>.
02080       s->waiters_++;
02081 
02082       // Wait until the semaphore count is > 0.
02083       while (s->count_ == 0)
02084         if (ACE_OS::cond_wait (&s->count_nonzero_,
02085                                &s->lock_) == -1)
02086           {
02087             result = -2; // -2 means that we need to release the mutex.
02088             break;
02089           }
02090 
02091       --s->waiters_;
02092     }
02093 
02094   if (result == 0)
02095     --s->count_;
02096 
02097   if (result != -1)
02098     ACE_OS::mutex_unlock (&s->lock_);
02099   ACE_PTHREAD_CLEANUP_POP (0);
02100   return result < 0 ? -1 : result;
02101 
02102 #   elif defined (ACE_HAS_WTHREADS)
02103 #     if !defined (ACE_USES_WINCE_SEMA_SIMULATION)
02104   switch (::WaitForSingleObject (*s, INFINITE))
02105     {
02106     case WAIT_OBJECT_0:
02107       return 0;
02108     default:
02109       // This is a hack, we need to find an appropriate mapping...
02110       ACE_OS::set_errno_to_last_error ();
02111       return -1;
02112     }
02113   /* NOTREACHED */
02114 #     else /* ACE_USES_WINCE_SEMA_SIMULATION */
02115   // Timed wait.
02116   int result = -1;
02117   for (;;)
02118     // Check if the semaphore is avialable or not and wait forever.
02119     // Don't bother to grab the lock if it is not available (to avoid
02120     // deadlock.)
02121     switch (::WaitForSingleObject (s->count_nonzero_, INFINITE))
02122       {
02123       case WAIT_OBJECT_0:
02124         ACE_OS::thread_mutex_lock (&s->lock_);
02125 
02126         // Need to double check if the semaphore is still available.
02127         // This time, we shouldn't wait at all.
02128         if (::WaitForSingleObject (s->count_nonzero_, 0) == WAIT_OBJECT_0)
02129           {
02130             // Decrease the internal counter.  Only update the event
02131             // object's status when the state changed.
02132             s->count_--;
02133             if (s->count_ <= 0)
02134               ACE_OS::event_reset (&s->count_nonzero_);
02135             result = 0;
02136           }
02137 
02138         ACE_OS::thread_mutex_unlock (&s->lock_);
02139         // if we didn't get a hold on the semaphore, the result won't
02140         // be 0 and thus, we'll start from the beginning again.
02141         if (result == 0)
02142           return 0;
02143         break;
02144 
02145       default:
02146         // Since we wait indefinitely, anything other than
02147         // WAIT_OBJECT_O indicates an error.
02148         ACE_OS::set_errno_to_last_error ();
02149         // This is taken from the hack above. ;)
02150         return -1;
02151       }
02152   /* NOTREACHED */
02153 #     endif /* ACE_USES_WINCE_SEMA_SIMULATION */
02154 #   elif defined (ACE_VXWORKS)
02155   ACE_OSCALL_RETURN (::semTake (s->sema_, WAIT_FOREVER), int, -1);
02156 #   endif /* ACE_HAS_STHREADS */
02157 # else
02158   ACE_UNUSED_ARG (s);
02159   ACE_NOTSUP_RETURN (-1);
02160 # endif /* ACE_HAS_POSIX_SEM */
02161 }

ACE_INLINE int ACE_OS::semctl int  int_id,
int  semnum,
int  cmd,
semun 
 

Definition at line 2442 of file OS_NS_Thread.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and semctl().

Referenced by ACE_SV_Semaphore_Simple::control(), ACE_SV_Semaphore_Simple::open(), and semctl().

02443 {
02444   ACE_OS_TRACE ("ACE_OS::semctl");
02445 #if defined (ACE_HAS_SYSV_IPC)
02446   ACE_OSCALL_RETURN (::semctl (int_id, semnum, cmd, value), int, -1);
02447 #else
02448   ACE_UNUSED_ARG (int_id);
02449   ACE_UNUSED_ARG (semnum);
02450   ACE_UNUSED_ARG (cmd);
02451   ACE_UNUSED_ARG (value);
02452 
02453   ACE_NOTSUP_RETURN (-1);
02454 #endif /* ACE_HAS_SYSV_IPC */
02455 }

ACE_INLINE int ACE_OS::semget key_t  key,
int  nsems,
int  flags
 

Definition at line 2458 of file OS_NS_Thread.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and semget().

Referenced by ACE_SV_Semaphore_Simple::open(), ACE_SV_Semaphore_Complex::open(), and semget().

02459 {
02460   ACE_OS_TRACE ("ACE_OS::semget");
02461 #if defined (ACE_HAS_SYSV_IPC)
02462   ACE_OSCALL_RETURN (::semget (key, nsems, flags), int, -1);
02463 #else
02464   ACE_UNUSED_ARG (key);
02465   ACE_UNUSED_ARG (nsems);
02466   ACE_UNUSED_ARG (flags);
02467 
02468   ACE_NOTSUP_RETURN (-1);
02469 #endif /* ACE_HAS_SYSV_IPC */
02470 }

ACE_INLINE int ACE_OS::semop int  int_id,
struct sembuf *  sops,
size_t  nsops
 

Definition at line 2473 of file OS_NS_Thread.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and semop().

Referenced by ACE_SV_Semaphore_Complex::close(), ACE_SV_Semaphore_Simple::op(), ACE_SV_Semaphore_Complex::open(), and semop().

02474 {
02475   ACE_OS_TRACE ("ACE_OS::semop");
02476 #if defined (ACE_HAS_SYSV_IPC)
02477   ACE_OSCALL_RETURN (::semop (int_id, sops, nsops), int, -1);
02478 #else
02479   ACE_UNUSED_ARG (int_id);
02480   ACE_UNUSED_ARG (sops);
02481   ACE_UNUSED_ARG (nsops);
02482 
02483   ACE_NOTSUP_RETURN (-1);
02484 #endif /* ACE_HAS_SYSV_IPC */
02485 }

ACE_INLINE ssize_t ACE_OS::send ACE_HANDLE  handle,
const char *  buf,
size_t  len,
int  flags = 0
 

BSD-style (no QoS).

Definition at line 472 of file OS_NS_sys_socket.inl.

References ACE_OS_TRACE, ACE_SOCKCALL_RETURN, EWOULDBLOCK, and ssize_t.

Referenced by ACE_Pipe::send(), ACE::send(), ACE::send_i(), ACE::send_n_i(), and sendfile_emulation().

00473 {
00474   ACE_OS_TRACE ("ACE_OS::send");
00475 
00476   // On UNIX, a non-blocking socket with no data to receive, this
00477   // system call will return EWOULDBLOCK or EAGAIN, depending on the
00478   // platform.  UNIX 98 allows either errno, and they may be the same
00479   // numeric value.  So to make life easier for upper ACE layers as
00480   // well as application programmers, always change EAGAIN to
00481   // EWOULDBLOCK.  Rather than hack the ACE_OSCALL_RETURN macro, it's
00482   // handled explicitly here.  If the ACE_OSCALL macro ever changes,
00483   // this function needs to be reviewed.  On Win32, the regular macros
00484   // can be used, as this is not an issue.
00485 #if defined (ACE_WIN32)
00486   ACE_SOCKCALL_RETURN (::send ((ACE_SOCKET) handle,
00487                                buf,
00488                                static_cast<int> (len),
00489                                flags), ssize_t, -1);
00490 #else
00491   ssize_t const ace_result_ = ::send ((ACE_SOCKET) handle, buf, len, flags);
00492 
00493 # if !(defined (EAGAIN) && defined (EWOULDBLOCK) && EAGAIN == EWOULDBLOCK)
00494   // Optimize this code out if we can detect that EAGAIN ==
00495   // EWOULDBLOCK at compile time.  If we cannot detect equality at
00496   // compile-time (e.g. if EAGAIN or EWOULDBLOCK are not preprocessor
00497   // macros) perform the check at run-time.  The goal is to avoid two
00498   // TSS accesses in the _REENTRANT case when EAGAIN == EWOULDBLOCK.
00499   if (ace_result_ == -1
00500 #  if !defined (EAGAIN) || !defined (EWOULDBLOCK)
00501       && EAGAIN != EWOULDBLOCK
00502 #  endif  /* !EAGAIN || !EWOULDBLOCK */
00503       && errno == EAGAIN)
00504     {
00505       errno = EWOULDBLOCK;
00506     }
00507 # endif /* EAGAIN != EWOULDBLOCK*/
00508 
00509   return ace_result_;
00510 #endif /* defined (ACE_WIN32) */
00511 }

ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE ssize_t ACE_OS::sendfile ACE_HANDLE  out_fd,
ACE_HANDLE  in_fd,
off_t *  offset,
size_t  count
 

Finds the length of a string (char version).

Definition at line 12 of file OS_NS_sys_sendfile.inl.

References sendfile_emulation().

00016 {
00017 #ifdef ACE_HAS_SENDFILE
00018   return ::sendfile (out_fd, in_fd, offset, count);
00019 #else
00020   return ACE_OS::sendfile_emulation (out_fd, in_fd, offset, count);
00021 #endif  /* ACE_HAS_SENDFILE */
00022 }

ACE_BEGIN_VERSIONED_NAMESPACE_DECL ssize_t ACE_OS::sendfile_emulation ACE_HANDLE  out_fd,
ACE_HANDLE  in_fd,
off_t *  offset,
size_t  count
 

Definition at line 20 of file OS_NS_sys_sendfile.cpp.

References MAP_FAILED, MAP_SHARED, mmap(), munmap(), PROT_READ, send(), ssize_t, and write().

Referenced by sendfile().

00024 {
00025   // @@ Is it possible to inline a call to ::TransmitFile() on
00026   //    MS Windows instead of emulating here?
00027 
00028   // @@ We may want set up a signal lease (or oplock) if supported by
00029   //    the platform so that we don't get a bus error if the mmap()ed
00030   //    file is truncated.
00031   void * const buf =
00032     ACE_OS::mmap (0, count, PROT_READ, MAP_SHARED, in_fd, *offset);
00033 
00034   if (buf == MAP_FAILED)
00035     return -1;
00036 
00037 #if defined (ACE_WIN32) || defined (HPUX)
00038   ssize_t const r =
00039     ACE_OS::send (out_fd, static_cast<const char *> (buf), count);
00040 #else
00041   ssize_t const r = ACE_OS::write (out_fd, buf, count);
00042 #endif /* ACE_WIN32 */
00043 
00044   (void) ACE_OS::munmap (buf, count);
00045 
00046   if (r > 0)
00047     *offset += static_cast<off_t> (r);
00048 
00049   return r;
00050 }

ACE_INLINE ssize_t ACE_OS::sendmsg ACE_HANDLE  handle,
const struct msghdr msg,
int  flags
 

BSD-style (no QoS).

Definition at line 514 of file OS_NS_sys_socket.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_SOCKCALL_RETURN, msghdr::msg_iov, msghdr::msg_iovlen, msghdr::msg_name, msghdr::msg_namelen, set_errno_to_wsa_last_error(), and ssize_t.

Referenced by ACE::sendmsg().

00517 {
00518   ACE_OS_TRACE ("ACE_OS::sendmsg");
00519 #if !defined (ACE_LACKS_SENDMSG)
00520 # if (defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0))
00521   DWORD bytes_sent = 0;
00522   int result = ::WSASendTo ((SOCKET) handle,
00523                             (WSABUF *) msg->msg_iov,
00524                             msg->msg_iovlen,
00525                             &bytes_sent,
00526                             flags,
00527                             msg->msg_name,
00528                             msg->msg_namelen,
00529                             0,
00530                             0);
00531 
00532   if (result != 0)
00533     {
00534       ACE_OS::set_errno_to_wsa_last_error ();
00535       return -1;
00536     }
00537   else
00538     return (ssize_t) bytes_sent;
00539 # elif defined (ACE_HAS_NONCONST_SENDMSG)
00540   ACE_SOCKCALL_RETURN (::sendmsg (handle,
00541                                   const_cast<struct msghdr *>(msg),
00542                                   flags), ssize_t, -1);
00543 # else
00544   ACE_SOCKCALL_RETURN (::sendmsg (handle, msg, flags), ssize_t, -1);
00545 # endif
00546 #else
00547   ACE_UNUSED_ARG (flags);
00548   ACE_UNUSED_ARG (msg);
00549   ACE_UNUSED_ARG (handle);
00550 
00551   ACE_NOTSUP_RETURN (-1);
00552 #endif /* ACE_LACKS_SENDMSG */
00553 }

ACE_INLINE ssize_t ACE_OS::sendto ACE_HANDLE  handle,
const iovec buffers,
int  buffer_count,
size_t &  number_of_bytes_sent,
int  flags,
const struct sockaddr *  addr,
int  addrlen,
ACE_OVERLAPPED overlapped,
ACE_OVERLAPPED_COMPLETION_FUNC  func
 

BSD-style (no QoS).

Definition at line 594 of file OS_NS_sys_socket.inl.

References ACE_OS_TRACE, ACE_OVERLAPPED, ACE_OVERLAPPED_COMPLETION_FUNC, sendto(), set_errno_to_wsa_last_error(), and ssize_t.

00603 {
00604   ACE_OS_TRACE ("ACE_OS::sendto");
00605 #if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
00606   DWORD bytes_sent;
00607   int result = ::WSASendTo ((SOCKET) handle,
00608                             (WSABUF*)buffers,
00609                             buffer_count,
00610                             &bytes_sent,
00611                             flags,
00612                             addr,
00613                             addrlen,
00614                             overlapped,
00615                             func);
00616   if (result != 0) {
00617     ACE_OS::set_errno_to_wsa_last_error ();
00618   }
00619   number_of_bytes_sent = static_cast<size_t> (bytes_sent);
00620   return (ssize_t) result;
00621 #else
00622   ACE_UNUSED_ARG (overlapped);
00623   ACE_UNUSED_ARG (func);
00624 
00625   number_of_bytes_sent = 0;
00626 
00627   ssize_t result = 0;
00628 
00629   for (int i = 0; i < buffer_count; ++i)
00630     {
00631        result = ACE_OS::sendto (handle,
00632                                 reinterpret_cast<char *> (
00633                                                  buffers[i].iov_base),
00634                                 buffers[i].iov_len,
00635                                 flags,
00636                                 addr,
00637                                 addrlen);
00638        if (result == -1)
00639          break;
00640        number_of_bytes_sent += static_cast<size_t> (result);
00641     }
00642 
00643   return result;
00644 #endif /* defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) */
00645 }

ACE_INLINE ssize_t ACE_OS::sendto ACE_HANDLE  handle,
const char *  buf,
size_t  len,
int  flags,
const struct sockaddr *  addr,
int  addrlen
 

BSD-style (no QoS).

Definition at line 556 of file OS_NS_sys_socket.inl.

References ACE_OS_TRACE, ACE_SOCKCALL_RETURN, and ssize_t.

Referenced by ACE_WIN32_Asynch_Write_Dgram::send(), ACE_SOCK_Dgram_Bcast::send(), ACE_SOCK_Dgram::send(), ACE_ICMP_Socket::send(), sendto(), and ACE::sendto().

00562 {
00563   ACE_OS_TRACE ("ACE_OS::sendto");
00564 #if defined (ACE_VXWORKS)
00565   ACE_SOCKCALL_RETURN (::sendto ((ACE_SOCKET) handle,
00566                                  const_cast <char *> (buf),
00567                                  len,
00568                                  flags,
00569                                  const_cast<struct sockaddr *> (addr),
00570                                  addrlen),
00571                        ssize_t, -1);
00572 #else
00573 #  if defined (ACE_WIN32)
00574   ACE_SOCKCALL_RETURN (::sendto ((ACE_SOCKET) handle,
00575                                  buf,
00576                                  static_cast<int> (len),
00577                                  flags,
00578                                  const_cast<struct sockaddr *> (addr),
00579                                  addrlen),
00580                        ssize_t, -1);
00581 #  else
00582   ACE_SOCKCALL_RETURN (::sendto ((ACE_SOCKET) handle,
00583                                  buf,
00584                                  len,
00585                                  flags,
00586                                  const_cast<struct sockaddr *> (addr),
00587                                  addrlen),
00588                        ssize_t, -1);
00589 #  endif /* ACE_WIN32 */
00590 #endif /* ACE_VXWORKS */
00591 }

ACE_INLINE ssize_t ACE_OS::sendv ACE_HANDLE  handle,
const iovec iov,
int  iovcnt
 

BSD-style (no QoS).

Definition at line 648 of file OS_NS_sys_socket.inl.

References ACE_IOV_MAX, iovec::iov_base, iovec::iov_len, set_errno_to_wsa_last_error(), ssize_t, and writev().

Referenced by ACE_Pipe::recvv_n(), ACE_SOCK_IO::send(), ACE_Pipe::send(), ACE::send(), ACE_Pipe::sendv(), ACE::sendv(), and ACE::sendv_n_i().

00651 {
00652 #if defined (ACE_HAS_WINSOCK2)
00653   DWORD bytes_sent = 0;
00654   ssize_t result = 0;
00655 
00656   // Winsock 2 has WSASend and can do this directly, but Winsock 1
00657   // needs to do the sends one-by-one.
00658 # if (ACE_HAS_WINSOCK2 != 0)
00659   result = ::WSASend ((SOCKET) handle,
00660                       (WSABUF *) buffers,
00661                       n,
00662                       &bytes_sent,
00663                       0,
00664                       0,
00665                       0);
00666   if (result == SOCKET_ERROR)
00667     {
00668       ACE_OS::set_errno_to_wsa_last_error ();
00669       return -1;
00670     }
00671 # else
00672   for (int i = 0; i < n; ++i)
00673     {
00674       result = ::send ((SOCKET) handle,
00675                        buffers[i].iov_base,
00676                        buffers[i].iov_len,
00677                        0);
00678 
00679       if (result == SOCKET_ERROR)
00680         {
00681           // There is a subtle difference in behaviour depending on
00682           // whether or not any data was sent.  If no data was sent,
00683           // then always return -1.  Otherwise return bytes_sent.
00684           // This gives the caller an opportunity to keep track of
00685           // bytes that have already been sent.
00686           if (bytes_sent > 0)
00687             break;
00688           else
00689             {
00690               ACE_OS::set_errno_to_wsa_last_error ();
00691               return -1;
00692             }
00693         }
00694       else
00695         {
00696           // Gets ignored on error anyway
00697           bytes_sent += result;
00698 
00699           // If the transfer isn't complete just drop out of the loop.
00700           if (result < (int)buffers[i].iov_len)
00701             break;
00702         }
00703     }
00704 # endif /* ACE_HAS_WINSOCK2 != 0 */
00705 
00706   return (ssize_t) bytes_sent;
00707 
00708 #elif defined (ACE_HAS_SOCK_BUF_SIZE_MAX)
00709 
00710   // Platform limits the maximum socket message size.  Pare down the
00711   // iovec, if necessary, to obey the limit.
00712   iovec local_iov[ACE_IOV_MAX];
00713   long total = 0;
00714   long new_total = 0;
00715   for (int i = 0; i < n; i++)
00716     {
00717       local_iov[i].iov_base = buffers[i].iov_base;
00718       local_iov[i].iov_len  = buffers[i].iov_len;
00719 
00720       new_total = total + buffers[i].iov_len;
00721       if ( new_total >= SSIZE_MAX )
00722         {
00723           local_iov[i].iov_len = SSIZE_MAX - total;
00724           n = i+1;
00725           break;
00726         }
00727       total = new_total;
00728     }
00729   return ACE_OS::writev (handle, local_iov, n);
00730 
00731 #else
00732   return ACE_OS::writev (handle, buffers, n);
00733 #endif /* ACE_HAS_WINSOCK2 */
00734 }

ACE_INLINE int ACE_OS::set_errno_to_last_error void   ) 
 

Definition at line 39 of file OS_NS_errno.inl.

References last_error().

Referenced by ACE_WIN32_Asynch_Accept::accept(), ACE_TTY_IO::control(), ACE_WFMO_Reactor::dispatch(), ACE_WFMO_Reactor::dispatch_handles(), event_timedwait(), event_wait(), fstat(), ACE_WIN32_Proactor::handle_events(), ACE_NT_Service::insert(), mutex_init(), mutex_lock(), mutex_trylock(), ACE_WFMO_Reactor::ok_to_wait(), ACE_WIN32_Asynch_Read_File::readv(), ACE_WIN32_Asynch_Read_Stream::readv(), ACE_WIN32_Asynch_Read_Dgram::recv(), ACE_WIN32_Proactor::register_handle(), sched_params(), sema_trywait(), sema_wait(), ACE_WIN32_Asynch_Write_Dgram::send(), ACE_WIN32_Asynch_Read_Stream::shared_read(), ACE_WIN32_Asynch_Write_Stream::shared_write(), stat(), ACE_NT_Service::svc_sc_handle(), ACE_WIN32_Asynch_Transmit_File::transmit_file(), ACE_Process::wait(), waitpid(), ACE_WIN32_Asynch_Write_File::writev(), and ACE_WIN32_Asynch_Write_Stream::writev().

00040 {
00041 # if defined (ACE_WIN32)
00042 // Borland C++ Builder 4 has a bug in the RTL that resets the
00043 // <GetLastError> value to zero when errno is accessed.  Thus, we have
00044 // to use this to set errno to GetLastError.  It's bad, but only for
00045 // WIN32.
00046 #   if defined(__BORLANDC__) && (__BORLANDC__ == 0x540) || defined (__IBMCPP__) && (__IBMCPP__ >= 400)
00047   int last_error = ::GetLastError ();
00048   return errno = last_error;
00049 #   else /* defined(__BORLANDC__) && (__BORLANDC__ == 0x540) */
00050   return errno = ::GetLastError ();
00051 #   endif /* defined(__BORLANDC__) && (__BORLANDC__ == 0x540) */
00052 #else
00053   return errno;
00054 # endif /* defined(ACE_WIN32) */
00055 }

ACE_INLINE int ACE_OS::set_errno_to_wsa_last_error void   ) 
 

Definition at line 58 of file OS_NS_errno.inl.

References last_error().

Referenced by ACE_INET_Addr::get_host_addr(), recvfrom(), recvmsg(), recvv(), ACE_SPIPE_Stream::send_handle(), sendmsg(), sendto(), and sendv().

00059 {
00060 # if defined (ACE_WIN32)
00061 // Borland C++ Builder 4 has a bug in the RTL that resets the
00062 // <GetLastError> value to zero when errno is accessed.  Thus, we have
00063 // to use this to set errno to GetLastError.  It's bad, but only for
00064 // WIN32
00065 #   if defined(__BORLANDC__) && (__BORLANDC__ == 0x540) || defined (__IBMCPP__) && (__IBMCPP__ >= 400)
00066   int last_error = ::WSAGetLastError ();
00067   return errno = last_error;
00068 #   else /* defined(__BORLANDC__) && (__BORLANDC__ == 0x540) */
00069   return errno = ::WSAGetLastError ();
00070 #   endif /* defined(__BORLANDC__) && (__BORLANDC__ == 0x540) */
00071 #else
00072   return errno;
00073 # endif /* defined(ACE_WIN32) */
00074 }

ACE_INLINE ACE_EXIT_HOOK ACE_OS::set_exit_hook ACE_EXIT_HOOK  hook  ) 
 

For use by ACE_Object_Manager only, to register its exit hook..

Definition at line 390 of file OS_NS_stdlib.inl.

References ACE_EXIT_HOOK, and exit_hook_.

Referenced by ACE_OS_Object_Manager::init().

00391 {
00392   ACE_EXIT_HOOK old_hook = exit_hook_;
00393   exit_hook_ = exit_hook;
00394   return old_hook;
00395 }

int ACE_OS::set_scheduling_params const ACE_Sched_Params ,
ACE_id_t  id = ACE_SELF
 

Friendly interface to (2).

Definition at line 3742 of file OS_NS_Thread.cpp.

References ACE_id_t, ACE_NOTSUP_RETURN, ACE_SCHED_FIFO, ACE_SCHED_OTHER, ACE_SCHED_RR, ACE_SCOPE_PROCESS, ACE_SCOPE_THREAD, last_error(), memcpy(), memset(), priority_control(), sched_params(), and scheduling_class().

Referenced by sched_params().

03744 {
03745 #if defined (ACE_HAS_PRIOCNTL)
03746   // Set priority class, priority, and quantum of this LWP or process as
03747   // specified in sched_params.
03748 
03749   // Get the priority class ID.
03750   ACE_id_t class_id;
03751   if (ACE_OS::scheduling_class (sched_params.policy() == ACE_SCHED_OTHER  ?
03752                                   "TS"  :
03753                                   "RT", class_id) == -1)
03754     {
03755       return -1;
03756     }
03757 
03758   pcparms_t pcparms;
03759   // The following is just to avoid Purify warnings about unitialized
03760   // memory reads.
03761   ACE_OS::memset (&pcparms, 0, sizeof pcparms);
03762 
03763   pcparms.pc_cid = class_id;
03764 
03765   if (sched_params.policy () == ACE_SCHED_OTHER  &&
03766       sched_params.quantum () == ACE_Time_Value::zero)
03767       // SunOS doesn't support non-zero quantums in time-sharing class:  use
03768       // real-time class instead.
03769     {
03770       tsparms_t tsparms;
03771       // The following is just to avoid Purify warnings about unitialized
03772       // memory reads.
03773       ACE_OS::memset (&tsparms, 0, sizeof tsparms);
03774 
03775       // Don't change ts_uprilim (user priority limit)
03776       tsparms.ts_uprilim = TS_NOCHANGE;
03777       tsparms.ts_upri = sched_params.priority ();
03778 
03779       // Package up the TS class ID and parameters for the
03780       // priority_control () call.
03781       ACE_OS::memcpy (pcparms.pc_clparms, &tsparms, sizeof tsparms);
03782     }
03783   else if (sched_params.policy () == ACE_SCHED_FIFO  ||
03784            (sched_params.policy () == ACE_SCHED_RR &&
03785             sched_params.quantum () != ACE_Time_Value::zero))
03786            // must have non-zero quantum for RR, to make it meaningful
03787            // A zero quantum with FIFO has special significance:  it actually
03788            // means infinite time quantum, i.e., run-to-completion.
03789     {
03790       rtparms_t rtparms;
03791       // The following is just to avoid Purify warnings about unitialized
03792       // memory reads.
03793       ACE_OS::memset (&rtparms, 0, sizeof rtparms);
03794 
03795       rtparms.rt_pri = sched_params.priority ();
03796 
03797       if (sched_params.quantum () == ACE_Time_Value::zero)
03798         {
03799           // rtparms.rt_tqsecs is ignored with RT_TQINF
03800           rtparms.rt_tqnsecs = RT_TQINF;
03801         }
03802       else
03803         {
03804           rtparms.rt_tqsecs = (ulong) sched_params.quantum ().sec ();
03805           rtparms.rt_tqnsecs = sched_params.quantum ().usec () * 1000;
03806         }
03807 
03808       // Package up the RT class ID and parameters for the
03809       // priority_control () call.
03810       ACE_OS::memcpy (pcparms.pc_clparms, &rtparms, sizeof rtparms);
03811     }
03812   else
03813     {
03814       errno = EINVAL;
03815       return -1;
03816     }
03817 
03818   if (ACE_OS::priority_control ((idtype_t) (sched_params.scope () == ACE_SCOPE_THREAD
03819                                             ? ACE_SCOPE_PROCESS
03820                                             : sched_params.scope ()),
03821                                 id,
03822                                 PC_SETPARMS,
03823                                 (char *) &pcparms) < 0)
03824     {
03825       return ACE_OS::last_error ();
03826     }
03827 
03828   return 0;
03829 #else  /* ! ACE_HAS_PRIOCNTL */
03830   ACE_UNUSED_ARG (sched_params);
03831   ACE_UNUSED_ARG (id);
03832   ACE_NOTSUP_RETURN (-1);
03833 #endif /* ! ACE_HAS_PRIOCNTL */
03834 }

ACE_NAMESPACE_INLINE_FUNCTION void set_win32_resource_module HINSTANCE   ) 
 

Allow an application to modify which module contains ACE's resources. This is mainly useful for a static build of ACE where the required resources reside somewhere other than the executable.

Referenced by DllMain().

ACE_INLINE int ACE_OS::setegid gid_t   ) 
 

Definition at line 790 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, gid_t, and setegid().

Referenced by setegid().

00791 {
00792   ACE_OS_TRACE ("ACE_OS::setegid");
00793 #if defined (ACE_LACKS_SETEGID)
00794   ACE_UNUSED_ARG (gid);
00795   ACE_NOTSUP_RETURN (-1);
00796 # else
00797   ACE_OSCALL_RETURN (::setegid (gid), int,  -1);
00798 # endif /* ACE_LACKS_SETEGID */
00799 }

ACE_INLINE int ACE_OS::seteuid uid_t   ) 
 

Definition at line 864 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, seteuid(), and uid_t.

Referenced by seteuid().

00865 {
00866   ACE_OS_TRACE ("ACE_OS::seteuid");
00867 #if defined (ACE_LACKS_SETEUID)
00868   ACE_UNUSED_ARG (uid);
00869   ACE_NOTSUP_RETURN (-1);
00870 # else
00871   ACE_OSCALL_RETURN (::seteuid (uid), int,  -1);
00872 # endif /* ACE_LACKS_SETEUID */
00873 }

ACE_INLINE int ACE_OS::setgid gid_t   ) 
 

Definition at line 778 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, gid_t, and setgid().

Referenced by setgid().

00779 {
00780   ACE_OS_TRACE ("ACE_OS::setgid");
00781 #if defined (ACE_LACKS_SETGID)
00782   ACE_UNUSED_ARG (gid);
00783   ACE_NOTSUP_RETURN (-1);
00784 # else
00785   ACE_OSCALL_RETURN (::setgid (gid), int,  -1);
00786 # endif /* ACE_LACKS_SETGID */
00787 }

ACE_INLINE int ACE_OS::setpgid pid_t  pid,
pid_t  pgid
 

Definition at line 802 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, pid_t, and setpgid().

Referenced by setpgid(), and ACE_Process::spawn().

00803 {
00804   ACE_OS_TRACE ("ACE_OS::setpgid");
00805 #if defined (ACE_LACKS_SETPGID)
00806   ACE_UNUSED_ARG (pid);
00807   ACE_UNUSED_ARG (pgid);
00808   ACE_NOTSUP_RETURN (-1);
00809 #else
00810   ACE_OSCALL_RETURN (::setpgid (pid, pgid), int, -1);
00811 #endif /* ACE_LACKS_SETPGID */
00812 }

ACE_INLINE void ACE_OS::setpwent void   ) 
 

Definition at line 114 of file OS_NS_pwd.inl.

00115 {
00116 #if !defined (ACE_LACKS_PWD_FUNCTIONS)
00117   ::setpwent ();
00118 #endif /* ! ACE_LACKS_PWD_FUNCTIONS */
00119 }

ACE_INLINE int ACE_OS::setregid gid_t  rgid,
gid_t  egid
 

Definition at line 815 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, gid_t, and setregid().

Referenced by setregid(), and ACE_Process::spawn().

00816 {
00817   ACE_OS_TRACE ("ACE_OS::setregid");
00818 #if defined (ACE_LACKS_SETREGID)
00819   ACE_UNUSED_ARG (rgid);
00820   ACE_UNUSED_ARG (egid);
00821   ACE_NOTSUP_RETURN (-1);
00822 #else
00823   ACE_OSCALL_RETURN (::setregid (rgid, egid), int, -1);
00824 #endif /* ACE_LACKS_SETREGID */
00825 }

ACE_INLINE int ACE_OS::setreuid uid_t  ruid,
uid_t  euid
 

Definition at line 828 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, setreuid(), and uid_t.

Referenced by setreuid(), and ACE_Process::spawn().

00829 {
00830   ACE_OS_TRACE ("ACE_OS::setreuid");
00831 #if defined (ACE_LACKS_SETREUID)
00832   ACE_UNUSED_ARG (ruid);
00833   ACE_UNUSED_ARG (euid);
00834   ACE_NOTSUP_RETURN (-1);
00835 #else
00836   ACE_OSCALL_RETURN (::setreuid (ruid, euid), int, -1);
00837 #endif /* ACE_LACKS_SETREUID */
00838 }

ACE_INLINE int ACE_OS::setrlimit int  resource,
const struct rlimit *  rl
 

Definition at line 65 of file OS_NS_sys_resource.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and setrlimit().

Referenced by ACE::set_handle_limit(), and setrlimit().

00066 {
00067   ACE_OS_TRACE ("ACE_OS::setrlimit");
00068 
00069 #if defined (ACE_LACKS_RLIMIT)
00070   ACE_UNUSED_ARG (resource);
00071   ACE_UNUSED_ARG (rl);
00072 
00073   ACE_NOTSUP_RETURN (-1);
00074 #else
00075 # if defined (ACE_HAS_RLIMIT_RESOURCE_ENUM)
00076 #  if defined (ACE_HAS_NONCONST_SETRLIMIT)
00077   ACE_OSCALL_RETURN (::setrlimit ((ACE_HAS_RLIMIT_RESOURCE_ENUM) resource,
00078                                   const_cast<struct rlimit *>(rl)
00079                                   ), int, -1);
00080 # else
00081   ACE_OSCALL_RETURN (::setrlimit ((ACE_HAS_RLIMIT_RESOURCE_ENUM) resource,
00082                                   rl
00083                                   ), int, -1);
00084 #  endif /* ACE_HAS_NONCONST_SETRLIMIT */
00085 # else /* ACE_HAS_RLIMIT_RESOURCE_ENUM */
00086 #  if defined (ACE_HAS_NONCONST_SETRLIMIT)
00087   ACE_OSCALL_RETURN (::setrlimit (resource, const_cast<struct rlimit *>(rl)
00088                                   ), int, -1);
00089 #  else
00090   ACE_OSCALL_RETURN (::setrlimit (resource, rl), int, -1);
00091 #  endif /* ACE_HAS_NONCONST_SETRLIMIT */
00092 # endif /* ACE_HAS_RLIMIT_RESOURCE_ENUM */
00093 #endif /* ACE_LACKS_RLIMIT */
00094 }

ACE_INLINE pid_t ACE_OS::setsid void   ) 
 

Definition at line 841 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and setsid().

Referenced by ACE::daemonize(), and setsid().

00842 {
00843   ACE_OS_TRACE ("ACE_OS::setsid");
00844 #if defined (ACE_LACKS_SETSID)
00845   ACE_NOTSUP_RETURN (-1);
00846 #else
00847   ACE_OSCALL_RETURN (::setsid (), int, -1);
00848 # endif /* ACE_LACKS_SETSID */
00849 }

ACE_INLINE int ACE_OS::setsockopt ACE_HANDLE  handle,
int  level,
int  optname,
const char *  optval,
int  optlen
 

Manipulate the options associated with a socket.

Definition at line 737 of file OS_NS_sys_socket.inl.

References ACE_OS_TRACE, ACE_SOCKCALL, ACE_SOCKOPT_TYPE1, ENOTSUP, and setsockopt().

Referenced by ACE_SOCK_SEQPACK_Association::abort(), ACE_ATM_Acceptor::accept(), ACE_ATM_Connector::connect(), ACE_WIN32_Asynch_Connect::connect_i(), ACE_POSIX_Asynch_Connect::connect_i(), ACE_Asynch_Acceptor< HANDLER >::handle_accept(), ACE_SOCK_Dgram_Bcast::mk_broadcast(), ACE_Pipe::open(), ACE_ATM_Acceptor::open(), ACE_Asynch_Acceptor< HANDLER >::open(), ACE_SOCK::set_option(), and setsockopt().

00742 {
00743   ACE_OS_TRACE ("ACE_OS::setsockopt");
00744 
00745   #if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) && defined(SO_REUSEPORT)
00746   // To work around an inconsistency with Microsofts implementation of
00747   // sockets, we will check for SO_REUSEADDR, and ignore it. Winsock
00748   // always behaves as if SO_REUSEADDR=1. Some implementations have
00749   // the same behaviour as Winsock, but use a new name for
00750   // it. SO_REUSEPORT.  If you want the normal behaviour for
00751   // SO_REUSEADDR=0, then NT 4 sp4 and later supports
00752   // SO_EXCLUSIVEADDRUSE. This also requires using an updated Platform
00753   // SDK so it was decided to ignore the option for now. (Especially
00754   // since Windows always sets SO_REUSEADDR=1, which we can mimic by doing
00755   // nothing.)
00756   if (level == SOL_SOCKET) {
00757     if (optname == SO_REUSEADDR) {
00758       return 0; // Not supported by Winsock
00759     }
00760     if (optname == SO_REUSEPORT) {
00761       optname = SO_REUSEADDR;
00762     }
00763   }
00764   #endif /*ACE_HAS_WINSOCK2*/
00765 
00766   int result;
00767   ACE_SOCKCALL (::setsockopt ((ACE_SOCKET) handle,
00768                               level,
00769                               optname,
00770                               (ACE_SOCKOPT_TYPE1) optval,
00771                               optlen),
00772                 int,
00773                 -1,
00774                 result);
00775 #if defined (WSAEOPNOTSUPP)
00776   if (result == -1 && errno == WSAEOPNOTSUPP)
00777 #else
00778   if (result == -1)
00779 #endif /* WSAEOPNOTSUPP */
00780     errno = ENOTSUP;
00781   return result;
00782 }

ACE_INLINE int ACE_OS::setuid uid_t   ) 
 

Definition at line 852 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, setuid(), and uid_t.

Referenced by setuid().

00853 {
00854   ACE_OS_TRACE ("ACE_OS::setuid");
00855 #if defined (ACE_LACKS_SETUID)
00856   ACE_UNUSED_ARG (uid);
00857   ACE_NOTSUP_RETURN (-1);
00858 # else
00859   ACE_OSCALL_RETURN (::setuid (uid), int,  -1);
00860 # endif /* ACE_LACKS_SETUID */
00861 }

ACE_INLINE ACE_HANDLE ACE_OS::shm_open const ACE_TCHAR filename,
int  mode,
int  perms = 0,
LPSECURITY_ATTRIBUTES  sa = 0
 

Definition at line 303 of file OS_NS_sys_mman.inl.

References ACE_OS_TRACE, ACE_TCHAR, ACE_TEXT, ACE_TEXT_ALWAYS_CHAR, open(), and shm_open().

Referenced by ACE_Mutex::ACE_Mutex(), event_init(), ACE_Mem_Map::open(), sema_init(), and shm_open().

00307 {
00308   ACE_OS_TRACE ("ACE_OS::shm_open");
00309 # if defined (ACE_HAS_SHM_OPEN)
00310   ACE_UNUSED_ARG (sa);
00311   ACE_OSCALL_RETURN (::shm_open (ACE_TEXT_ALWAYS_CHAR(filename), mode, perms), ACE_HANDLE, ACE_INVALID_HANDLE);
00312 # elif defined (ACE_OPENVMS)
00313   ACE_OSCALL_RETURN (::open (filename, mode, perms, ACE_TEXT("shr=get,put,upd")), ACE_HANDLE, ACE_INVALID_HANDLE);
00314 # else  /* ! ACE_HAS_SHM_OPEN */
00315   // Just use ::open.
00316   return ACE_OS::open (filename, mode, perms, sa);
00317 # endif /* ACE_HAS_SHM_OPEN */
00318 }

ACE_INLINE int ACE_OS::shm_unlink const ACE_TCHAR path  ) 
 

Definition at line 321 of file OS_NS_sys_mman.inl.

References ACE_OS_TRACE, ACE_TCHAR, ACE_TEXT_ALWAYS_CHAR, shm_unlink(), and unlink().

Referenced by event_destroy(), event_init(), ACE_Mutex::remove(), ACE_Mem_Map::remove(), sema_destroy(), and shm_unlink().

00322 {
00323   ACE_OS_TRACE ("ACE_OS::shm_unlink");
00324 # if defined (ACE_HAS_SHM_OPEN)
00325   ACE_OSCALL_RETURN (::shm_unlink (ACE_TEXT_ALWAYS_CHAR(path)), int, -1);
00326 # else  /* ! ACE_HAS_SHM_OPEN */
00327   // Just use ::unlink.
00328   return ACE_OS::unlink (path);
00329 # endif /* ACE_HAS_SHM_OPEN */
00330 }

ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE void * ACE_OS::shmat int  int_id,
const void *  shmaddr,
int  shmflg
 

Definition at line 10 of file OS_NS_sys_shm.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and shmat().

Referenced by ACE_SV_Shared_Memory::attach(), ACE_Shared_Memory_Pool::commit_backing_store_name(), ACE_Shared_Memory_Pool::handle_signal(), ACE_Shared_Memory_Pool::init_acquire(), and shmat().

00011 {
00012   ACE_OS_TRACE ("ACE_OS::shmat");
00013 #if defined (ACE_HAS_SYSV_IPC)
00014 #  if defined (ACE_HAS_CHARPTR_SHMAT)
00015   ACE_OSCALL_RETURN (::shmat (int_id, static_cast <char*> (const_cast <void *>(shmaddr)), shmflg), void *, (void *) -1);
00016 #  else
00017   ACE_OSCALL_RETURN (::shmat (int_id, shmaddr, shmflg), void *, (void *) -1);
00018 #  endif /* ACE_HAS_CHARPTR_SHMAT */
00019 #else
00020   ACE_UNUSED_ARG (int_id);
00021   ACE_UNUSED_ARG (shmaddr);
00022   ACE_UNUSED_ARG (shmflg);
00023 
00024   ACE_NOTSUP_RETURN ((void *) -1);
00025 #endif /* ACE_HAS_SYSV_IPC */
00026 }

ACE_INLINE int ACE_OS::shmctl int  int_id,
int  cmd,
struct shmid_ds *  buf
 

Definition at line 29 of file OS_NS_sys_shm.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and shmctl().

Referenced by ACE_SV_Shared_Memory::control(), ACE_Shared_Memory_Pool::find_seg(), ACE_Shared_Memory_Pool::in_use(), ACE_Shared_Memory_Pool::release(), ACE_SV_Shared_Memory::remove(), and shmctl().

00030 {
00031   ACE_OS_TRACE ("ACE_OS::shmctl");
00032 #if defined (ACE_HAS_SYSV_IPC)
00033   ACE_OSCALL_RETURN (::shmctl (int_id, cmd, buf), int, -1);
00034 #else
00035   ACE_UNUSED_ARG (buf);
00036   ACE_UNUSED_ARG (cmd);
00037   ACE_UNUSED_ARG (int_id);
00038 
00039   ACE_NOTSUP_RETURN (-1);
00040 #endif /* ACE_HAS_SYSV_IPC */
00041 }

ACE_INLINE int ACE_OS::shmdt const void *  shmaddr  ) 
 

Definition at line 44 of file OS_NS_sys_shm.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and shmdt().

Referenced by ACE_SV_Shared_Memory::detach(), and shmdt().

00045 {
00046   ACE_OS_TRACE ("ACE_OS::shmdt");
00047 #if defined (ACE_HAS_SYSV_IPC)
00048 #  if defined (ACE_HAS_CHARPTR_SHMDT)
00049      ACE_OSCALL_RETURN (::shmdt (
00050       static_cast <char*> (const_cast <void *>(shmaddr))), int, -1);
00051 # else
00052      ACE_OSCALL_RETURN (::shmdt (shmaddr), int, -1);
00053 #  endif /* ACE_HAS_CHARPTR_SHMDT */
00054 #else
00055   ACE_UNUSED_ARG (shmaddr);
00056 
00057   ACE_NOTSUP_RETURN (-1);
00058 #endif /* ACE_HAS_SYSV_IPC */
00059 }

ACE_INLINE int ACE_OS::shmget key_t  key,
size_t  size,
int  flags
 

Definition at line 62 of file OS_NS_sys_shm.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and shmget().

Referenced by ACE_Shared_Memory_Pool::commit_backing_store_name(), ACE_Shared_Memory_Pool::init_acquire(), ACE_SV_Shared_Memory::open(), and shmget().

00063 {
00064   ACE_OS_TRACE ("ACE_OS::shmget");
00065 #if defined (ACE_HAS_SYSV_IPC)
00066   ACE_OSCALL_RETURN (::shmget (key, size, flags), int, -1);
00067 #else
00068   ACE_UNUSED_ARG (flags);
00069   ACE_UNUSED_ARG (size);
00070   ACE_UNUSED_ARG (key);
00071 
00072   ACE_NOTSUP_RETURN (-1);
00073 #endif /* ACE_HAS_SYSV_IPC */
00074 }

ACE_INLINE int ACE_OS::shutdown ACE_HANDLE  handle,
int  how
 

BSD-style (no QoS).

Definition at line 785 of file OS_NS_sys_socket.inl.

References ACE_OS_TRACE, and ACE_SOCKCALL_RETURN.

Referenced by ACE_SOCK_Stream::close_reader(), ACE_SOCK_SEQPACK_Association::close_reader(), ACE_MEM_Stream::close_reader(), ACE_SOCK_Stream::close_writer(), ACE_SOCK_SEQPACK_Association::close_writer(), ACE_MEM_Stream::close_writer(), and closesocket().

00786 {
00787   ACE_OS_TRACE ("ACE_OS::shutdown");
00788   ACE_SOCKCALL_RETURN (::shutdown ((ACE_SOCKET) handle, how), int, -1);
00789 }

ACE_INLINE int ACE_OS::sigaction int  signum,
const ACE_SIGACTION nsa,
ACE_SIGACTION osa
 

Definition at line 44 of file OS_NS_signal.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, SIG_ERR, SIG_IGN, and sigaction().

Referenced by ACE_Sig_Action::ACE_Sig_Action(), ACE_Sig_Action::register_action(), ACE_Sig_Action::restore_action(), ACE_Sig_Action::retrieve_action(), and sigaction().

00045 {
00046   ACE_OS_TRACE ("ACE_OS::sigaction");
00047   if (signum == 0)
00048     return 0;
00049 #if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)
00050   struct sigaction sa;
00051 
00052   if (osa == 0)
00053     osa = &sa;
00054 
00055   if (nsa == 0)
00056     {
00057       osa->sa_handler = ::signal (signum, SIG_IGN);
00058       ::signal (signum, osa->sa_handler);
00059     }
00060   else
00061     osa->sa_handler = ::signal (signum, nsa->sa_handler);
00062   return osa->sa_handler == SIG_ERR ? -1 : 0;
00063 #elif defined (ACE_LACKS_SIGACTION)
00064   ACE_UNUSED_ARG (nsa);
00065   ACE_UNUSED_ARG (osa);
00066   ACE_NOTSUP_RETURN (-1);
00067 #elif !defined (ACE_HAS_SIGACTION_CONSTP2)
00068   ACE_OSCALL_RETURN (::sigaction (signum,
00069                                   const_cast<struct sigaction*> (nsa),
00070                                   osa),
00071                      int, -1);
00072 #else
00073   ACE_OSCALL_RETURN (::sigaction (signum, nsa, osa), int, -1);
00074 #endif /* ACE_WIN32 !ACE_HAS_WINCE */
00075 }

ACE_INLINE int ACE_OS::sigaddset sigset_t *  s,
int  signum
 

Definition at line 78 of file OS_NS_signal.inl.

References ACE_NSIG, ACE_OS_TRACE, and sigaddset().

Referenced by ACE_Sig_Set::sig_add(), and sigaddset().

00079 {
00080   ACE_OS_TRACE ("ACE_OS::sigaddset");
00081 #if defined (ACE_LACKS_SIGSET) || defined (ACE_LACKS_SIGSET_DEFINITIONS)
00082   if (s == 0)
00083     {
00084       errno = EFAULT;
00085       return -1;
00086     }
00087   else if (signum < 1 || signum >= ACE_NSIG)
00088     {
00089       errno = EINVAL;
00090       return -1;                 // Invalid signum, return error
00091     }
00092   *s |= (1 << (signum - 1)) ;
00093   return 0 ;
00094 #else
00095   ACE_OSCALL_RETURN (::sigaddset (s, signum), int, -1);
00096 #endif /* ACE_LACKS_SIGSET || ACE_LACKS_SIGSET_DEFINITIONS */
00097 }

ACE_INLINE int ACE_OS::sigdelset sigset_t *  s,
int  signum
 

Definition at line 100 of file OS_NS_signal.inl.

References ACE_NSIG, and sigdelset().

Referenced by ACE_Sig_Set::sig_del(), and sigdelset().

00101 {
00102 #if defined (ACE_LACKS_SIGSET) || defined (ACE_LACKS_SIGSET_DEFINITIONS)
00103   if (s == 0)
00104     {
00105       errno = EFAULT;
00106       return -1;
00107     }
00108   else if (signum < 1 || signum >= ACE_NSIG)
00109     {
00110       errno = EINVAL;
00111       return -1;                 // Invalid signum, return error
00112     }
00113   *s &= ~(1 << (signum - 1)) ;
00114   return 0;
00115 #else
00116   ACE_OSCALL_RETURN (::sigdelset (s, signum), int, -1);
00117 #endif /* ACE_LACKS_SIGSET || ACE_LACKS_SIGSET_DEFINITIONS */
00118 }

ACE_INLINE int ACE_OS::sigemptyset sigset_t *  s  ) 
 

Definition at line 121 of file OS_NS_signal.inl.

References sigemptyset().

Referenced by ACE_Sig_Action::ACE_Sig_Action(), ACE_Sig_Set::ACE_Sig_Set(), ACE_Sig_Set::empty_set(), sigemptyset(), sigsuspend(), and ACE_Sig_Set::~ACE_Sig_Set().

00122 {
00123 #if defined (ACE_LACKS_SIGSET) || defined (ACE_LACKS_SIGSET_DEFINITIONS)
00124   if (s == 0)
00125     {
00126       errno = EFAULT;
00127       return -1;
00128     }
00129   *s = 0 ;
00130   return 0 ;
00131 #else
00132   ACE_OSCALL_RETURN (::sigemptyset (s), int, -1);
00133 #endif /* ACE_LACKS_SIGSET || ACE_LACKS_SIGSET_DEFINITIONS */
00134 }

ACE_INLINE int ACE_OS::sigfillset sigset_t *  s  ) 
 

Definition at line 137 of file OS_NS_signal.inl.

References sigfillset().

Referenced by ACE_Sig_Set::ACE_Sig_Set(), ACE_Sig_Set::fill_set(), ACE_OS_Object_Manager::init(), and sigfillset().

00138 {
00139 #if defined (ACE_LACKS_SIGSET) || defined (ACE_LACKS_SIGSET_DEFINITIONS)
00140   if (s == 0)
00141     {
00142       errno = EFAULT;
00143       return -1;
00144     }
00145   *s = ~(sigset_t) 0;
00146   return 0 ;
00147 #else
00148   ACE_OSCALL_RETURN (::sigfillset (s), int, -1);
00149 #endif /* ACE_LACKS_SIGSET || ACE_LACKS_SIGSET_DEFINITIONS */
00150 }

ACE_INLINE int ACE_OS::sigismember sigset_t *  s,
int  signum
 

Definition at line 153 of file OS_NS_signal.inl.

References ACE_NSIG, and sigismember().

Referenced by ACE_Sig_Set::is_member(), and sigismember().

00154 {
00155 #if defined (ACE_LACKS_SIGSET) || defined (ACE_LACKS_SIGSET_DEFINITIONS)
00156   if (s == 0)
00157     {
00158       errno = EFAULT;
00159       return -1;
00160     }
00161   else if (signum < 1 || signum >= ACE_NSIG)
00162     {
00163       errno = EINVAL;
00164       return -1;                 // Invalid signum, return error
00165     }
00166   return ((*s & (1 << (signum - 1))) != 0) ;
00167 #else
00168 #  if defined (ACE_HAS_SIGISMEMBER_BUG)
00169   if (signum < 1 || signum >= ACE_NSIG)
00170     {
00171       errno = EINVAL;
00172       return -1;                 // Invalid signum, return error
00173     }
00174 #  endif /* ACE_HAS_SIGISMEMBER_BUG */
00175   ACE_OSCALL_RETURN (::sigismember (s, signum), int, -1);
00176 #endif /* ACE_LACKS_SIGSET || ACE_LACKS_SIGSET_DEFINITIONS */
00177 }

ACE_INLINE ACE_SignalHandler ACE_OS::signal int  signum,
ACE_SignalHandler 
 

Definition at line 180 of file OS_NS_signal.inl.

References ACE_NOTSUP_RETURN, and ACE_SignalHandler.

Referenced by ACE::daemonize().

00181 {
00182   if (signum == 0)
00183     return 0;
00184   else
00185 # if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE) || !defined (ACE_LACKS_UNIX_SIGNALS)
00186 #  if !defined (ACE_HAS_TANDEM_SIGNALS) && !defined (ACE_HAS_LYNXOS_SIGNALS)
00187     return ::signal (signum, func);
00188 #  else
00189     return (ACE_SignalHandler) ::signal (signum, (void (*)(int)) func);
00190 #  endif /* !ACE_HAS_TANDEM_SIGNALS */
00191 #else
00192     // @@ WINCE: Don't know how to implement signal on WinCE (yet.)
00193     ACE_UNUSED_ARG (signum);
00194     ACE_UNUSED_ARG (func);
00195     ACE_NOTSUP_RETURN (0);     // Should return SIG_ERR but it is not defined on WinCE.
00196 #endif /* defined (ACE_WIN32) && !defined (ACE_HAS_WINCE) || !defined (ACE_LACKS_UNIX_SIGNALS) */
00197 }

ACE_INLINE int ACE_OS::sigprocmask int  how,
const sigset_t *  nsp,
sigset_t *  osp
 

Definition at line 200 of file OS_NS_signal.inl.

References ACE_NOTSUP_RETURN, and sigprocmask().

Referenced by ACE_Sig_Guard::ACE_Sig_Guard(), sigprocmask(), thr_sigsetmask(), and ACE_Sig_Guard::~ACE_Sig_Guard().

00201 {
00202 #if defined (ACE_LACKS_SIGSET) || defined (ACE_LACKS_SIGSET_DEFINITIONS)
00203   ACE_UNUSED_ARG (how);
00204   ACE_UNUSED_ARG (nsp);
00205   ACE_UNUSED_ARG (osp);
00206   ACE_NOTSUP_RETURN (-1);
00207 #else
00208   ACE_OSCALL_RETURN (::sigprocmask (how, nsp, osp), int, -1);
00209 #endif /* ACE_LACKS_SIGSET || ACE_LACKS_SIGSET_DEFINITIONS */
00210 }

ACE_INLINE int ACE_OS::sigsuspend const sigset_t *  set  ) 
 

Definition at line 213 of file OS_NS_signal.inl.

References ACE_NOTSUP_RETURN, sigemptyset(), and sigsuspend().

Referenced by sigsuspend().

00214 {
00215 #if defined (ACE_HAS_SIGSUSPEND)
00216   sigset_t s;
00217 
00218   if (sigset == 0)
00219     {
00220       sigset = &s;
00221       ACE_OS::sigemptyset (&s);
00222     }
00223   ACE_OSCALL_RETURN (::sigsuspend (sigset), int, -1);
00224 #else
00225   ACE_UNUSED_ARG (sigset);
00226   ACE_NOTSUP_RETURN (-1);
00227 #endif /* ACE_HAS_SIGSUSPEND */
00228 }

ACE_INLINE int ACE_OS::sigtimedwait const sigset_t *  set,
siginfo_t info,
const ACE_Time_Value timeout
 

Definition at line 2488 of file OS_NS_Thread.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, sigtimedwait(), and timespec_t.

Referenced by sigtimedwait().

02491 {
02492   ACE_OS_TRACE ("ACE_OS::sigtimedwait");
02493 #if defined (ACE_HAS_SIGTIMEDWAIT)
02494   timespec_t ts;
02495   timespec_t *tsp;
02496 
02497   if (timeout != 0)
02498     {
02499       ts = *timeout; // Calls ACE_Time_Value::operator timespec_t().
02500       tsp = &ts;
02501     }
02502   else
02503     tsp = 0;
02504 
02505   ACE_OSCALL_RETURN (::sigtimedwait (sset, info, tsp),
02506                      int, -1);
02507 #else
02508     ACE_UNUSED_ARG (sset);
02509     ACE_UNUSED_ARG (info);
02510     ACE_UNUSED_ARG (timeout);
02511     ACE_NOTSUP_RETURN (-1);
02512 #endif /* ACE_HAS_SIGTIMEDWAIT */
02513 }

ACE_INLINE int ACE_OS::sigwait sigset_t *  set,
int *  sig = 0
 

Definition at line 2516 of file OS_NS_Thread.inl.

References ACE_NOTSUP_RETURN, and ACE_OS_TRACE.

02517 {
02518   ACE_OS_TRACE ("ACE_OS::sigwait");
02519   int local_sig;
02520   if (sig == 0)
02521     sig = &local_sig;
02522 #if defined (ACE_HAS_THREADS)
02523 # if (defined (__FreeBSD__) && (__FreeBSD__ < 3))
02524     ACE_UNUSED_ARG (sset);
02525     ACE_NOTSUP_RETURN (-1);
02526 # elif defined (ACE_HAS_STHREADS)
02527    # if (_POSIX_C_SOURCE - 0 >= 199506L) || defined (_POSIX_PTHREAD_SEMANTICS)
02528      errno = ::sigwait (sset, sig);
02529      return errno == 0  ?  *sig  :  -1;
02530    #else
02531      *sig = ::sigwait (sset);
02532      return *sig;
02533    #endif /* _POSIX_C_SOURCE - 0 >= 199506L || _POSIX_PTHREAD_SEMANTICS */
02534 # elif defined (ACE_HAS_PTHREADS)
02535   // LynxOS and Digital UNIX have their own hoops to jump through.
02536 #   if defined (__Lynx__)
02537     // Second arg is a void **, which we don't need (the selected
02538     // signal number is returned).
02539     *sig = ::sigwait (sset, 0);
02540     return *sig;
02541 #   elif defined (DIGITAL_UNIX)  &&  defined (__DECCXX_VER)
02542       // DEC cxx (but not g++) needs this direct call to its internal
02543       // sigwait ().  This allows us to #undef sigwait, so that we can
02544       // have ACE_OS::sigwait.  cxx gets confused by ACE_OS::sigwait
02545       // if sigwait is _not_ #undef'ed.
02546       errno = ::_Psigwait (sset, sig);
02547       return errno == 0  ?  *sig  :  -1;
02548 #   else /* ! __Lynx __ && ! (DIGITAL_UNIX && __DECCXX_VER) */
02549 #     if (defined (ACE_HAS_PTHREADS_DRAFT4) || (defined (ACE_HAS_PTHREADS_DRAFT6))) || (defined (_UNICOS) && _UNICOS == 9)
02550         *sig = ::sigwait (sset);
02551         return *sig;
02552 #     elif defined (CYGWIN32)
02553         // Cygwin has sigwait definition, but it is not implemented
02554         ACE_UNUSED_ARG (sset);
02555         ACE_NOTSUP_RETURN (-1);
02556 #     elif defined (ACE_TANDEM_T1248_PTHREADS)
02557         errno = ::spt_sigwait (sset, sig);
02558         return errno == 0  ?  *sig  :  -1;
02559 #     else   /* this is draft 7 or std */
02560         errno = ::sigwait (sset, sig);
02561         return errno == 0  ?  *sig  :  -1;
02562 #     endif /* ACE_HAS_PTHREADS_DRAFT4, 6 */
02563 #   endif /* ! __Lynx__ && ! (DIGITAL_UNIX && __DECCXX_VER) */
02564 # elif defined (ACE_HAS_WTHREADS)
02565     ACE_UNUSED_ARG (sset);
02566     ACE_NOTSUP_RETURN (-1);
02567 # elif defined (ACE_VXWORKS)
02568     // Second arg is a struct siginfo *, which we don't need (the
02569     // selected signal number is returned).  Third arg is timeout:  0
02570     // means forever.
02571     *sig = ::sigtimedwait (sset, 0, 0);
02572     return *sig;
02573 # endif /* __FreeBSD__ */
02574 #else
02575     ACE_UNUSED_ARG (sset);
02576     ACE_UNUSED_ARG (sig);
02577     ACE_NOTSUP_RETURN (-1);
02578 #endif /* ACE_HAS_THREADS */
02579 }

ACE_INLINE int ACE_OS::sigwaitinfo const sigset_t *  set,
siginfo_t info
 

Definition at line 2582 of file OS_NS_Thread.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and sigwaitinfo().

Referenced by sigwaitinfo().

02584 {
02585   ACE_OS_TRACE ("ACE_OS::sigwaitinfo");
02586   // If this platform has sigtimedwait, it should have sigwaitinfo as well.
02587   // If this isn't true somewhere, let me know and I'll fix this.
02588   // -Steve Huston <shuston@riverace.com>.
02589 #if defined (ACE_HAS_SIGTIMEDWAIT)
02590   ACE_OSCALL_RETURN (::sigwaitinfo (sset, info), int, -1);
02591 #else
02592   ACE_UNUSED_ARG (sset);
02593   ACE_UNUSED_ARG (info);
02594   ACE_NOTSUP_RETURN (-1);
02595 #endif /* ACE_HAS_SIGTIMEDWAIT */
02596 }

ACE_INLINE int ACE_OS::sleep const ACE_Time_Value tv  ) 
 

Definition at line 894 of file OS_NS_unistd.inl.

References ACE_OS_TRACE, ACE_Time_Value::msec(), nanosleep(), and timespec_t.

00895 {
00896   ACE_OS_TRACE ("ACE_OS::sleep");
00897 #if defined (ACE_WIN32)
00898   ::Sleep (tv.msec ());
00899   return 0;
00900 #elif defined (ACE_HAS_CLOCK_GETTIME)
00901   timespec_t rqtp = tv;
00902   ACE_OSCALL_RETURN (::nanosleep (&rqtp, 0), int, -1);
00903 #else
00904 # if defined (ACE_HAS_NONCONST_SELECT_TIMEVAL)
00905   // Copy the timeval, because this platform doesn't declare the timeval
00906   // as a pointer to const.
00907   timeval tv_copy = tv;
00908 #  if defined(ACE_TANDEM_T1248_PTHREADS)
00909      ACE_OSCALL_RETURN (::spt_select (0, 0, 0, 0, &tv_copy), int, -1);
00910 #  else
00911      ACE_OSCALL_RETURN (::select (0, 0, 0, 0, &tv_copy), int, -1);
00912 #  endif
00913 # else  /* ! ACE_HAS_NONCONST_SELECT_TIMEVAL */
00914   const timeval *tvp = tv;
00915   ACE_OSCALL_RETURN (::select (0, 0, 0, 0, tvp), int, -1);
00916 # endif /* ACE_HAS_NONCONST_SELECT_TIMEVAL */
00917 #endif /* ACE_WIN32 */
00918 }

ACE_INLINE int ACE_OS::sleep u_int  seconds  ) 
 

Definition at line 876 of file OS_NS_unistd.inl.

References ACE_ONE_SECOND_IN_MSECS, ACE_OS_TRACE, nanosleep(), sleep(), timespec::tv_nsec, and timespec::tv_sec.

Referenced by ACE_High_Res_Timer::calibrate(), ACE_SOCK_SEQPACK_Connector::complete(), ACE_SOCK_Connector::complete(), ACE_Connector< SVC_HANDLER, ACE_PEER_CONNECTOR_2 >::initialize_svc_handler(), nanosleep(), sleep(), ACE_Process_Manager::wait(), and ACE_Process::wait().

00877 {
00878   ACE_OS_TRACE ("ACE_OS::sleep");
00879 #if defined (ACE_WIN32)
00880   ::Sleep (seconds * ACE_ONE_SECOND_IN_MSECS);
00881   return 0;
00882 #elif defined (ACE_HAS_CLOCK_GETTIME)
00883   struct timespec rqtp;
00884   // Initializer doesn't work with Green Hills 1.8.7
00885   rqtp.tv_sec = seconds;
00886   rqtp.tv_nsec = 0L;
00887   ACE_OSCALL_RETURN (::nanosleep (&rqtp, 0), int, -1);
00888 #else
00889   ACE_OSCALL_RETURN (::sleep (seconds), int, -1);
00890 #endif /* ACE_WIN32 */
00891 }

int ACE_OS::snprintf wchar_t *  buf,
size_t  maxlen,
const wchar_t *  format,
... 
 

Definition at line 308 of file OS_NS_stdio.cpp.

References ACE_NOTSUP_RETURN, and ACE_SPRINTF_ADAPTER.

00309 {
00310   // ACE_OS_TRACE ("ACE_OS::snprintf");
00311 #if (defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) >= 500) || defined (ACE_WIN32)
00312   int result;
00313   va_list ap;
00314   va_start (ap, format);
00315 #  if defined (ACE_WIN32)
00316   // Microsoft's vswprintf() doesn't have the maxlen argument that
00317   // XPG4/UNIX98 define. They do, however, recommend use of _vsnwprintf()
00318   // as a substitute, which does have the same signature as the UNIX98 one.
00319   ACE_OSCALL (ACE_SPRINTF_ADAPTER (::_vsnwprintf (buf, maxlen, format, ap)),
00320               int, -1, result);
00321   // Win32 doesn't regard a full buffer with no 0-terminate as an
00322   // overrun.
00323   if (result == static_cast <int> (maxlen))
00324     result = -1;
00325 
00326   // Win32 doesn't 0-terminate the string if it overruns maxlen.
00327   if (result == -1)
00328     buf[maxlen-1] = '\0';
00329 #  else
00330   ACE_OSCALL (ACE_SPRINTF_ADAPTER (::vswprintf (buf, maxlen, format, ap)),
00331               int, -1, result);
00332 #  endif /* ACE_WIN32 */
00333   va_end (ap);
00334   // In out-of-range conditions, C99 defines vsnprintf to return the number
00335   // of characters that would have been written if enough space was available.
00336   // Earlier variants of the vsnprintf() (e.g. UNIX98) defined it to return
00337   // -1. This method follows the C99 standard, but needs to guess at the
00338   // value; uses maxlen + 1.
00339   if (result == -1)
00340     result = static_cast <int> (maxlen + 1);
00341   return result;
00342 
00343 #else
00344   ACE_UNUSED_ARG (buf);
00345   ACE_UNUSED_ARG (maxlen);
00346   ACE_UNUSED_ARG (format);
00347   ACE_NOTSUP_RETURN (-1);
00348 #endif /* ACE_HAS_SNPRINTF */
00349 }

int ACE_OS::snprintf char *  buf,
size_t  maxlen,
const char *  format,
... 
 

Definition at line 265 of file OS_NS_stdio.cpp.

References ACE_NOTSUP_RETURN, ACE_SPRINTF_ADAPTER, and vsnprintf().

Referenced by ACE_Log_Msg::log(), and ACE_Function_Node::make_func_name().

00266 {
00267   // ACE_OS_TRACE ("ACE_OS::snprintf");
00268 #if defined (ACE_HAS_SNPRINTF)
00269   int result;
00270   va_list ap;
00271   va_start (ap, format);
00272 #  if !defined (ACE_WIN32) || (defined (__BORLANDC__) && (__BORLANDC__ >= 0x600))
00273   ACE_OSCALL (ACE_SPRINTF_ADAPTER (::vsnprintf (buf, maxlen, format, ap)),
00274               int, -1, result);
00275 #  else
00276   ACE_OSCALL (ACE_SPRINTF_ADAPTER (::_vsnprintf (buf, maxlen, format, ap)),
00277               int, -1, result);
00278   // Win32 doesn't regard a full buffer with no 0-terminate as an
00279   // overrun.
00280   if (result == static_cast <int> (maxlen))
00281     result = -1;
00282 
00283   // Win32 doesn't 0-terminate the string if it overruns maxlen.
00284   if (result == -1)
00285     buf[maxlen-1] = '\0';
00286 #  endif /* !ACE_WIN32 || __BORLANDC__ >= 0x600 */
00287   va_end (ap);
00288   // In out-of-range conditions, C99 defines vsnprintf to return the number
00289   // of characters that would have been written if enough space was available.
00290   // Earlier variants of the vsnprintf() (e.g. UNIX98) defined it to return
00291   // -1. This method follows the C99 standard, but needs to guess at the
00292   // value; uses maxlen + 1.
00293   if (result == -1)
00294     result = static_cast <int> (maxlen + 1);
00295   return result;
00296 
00297 #else
00298   ACE_UNUSED_ARG (buf);
00299   ACE_UNUSED_ARG (maxlen);
00300   ACE_UNUSED_ARG (format);
00301   ACE_NOTSUP_RETURN (-1);
00302 #endif /* ACE_HAS_SNPRINTF */
00303 }

ACE_INLINE ACE_HANDLE ACE_OS::socket int  protocol_family,
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 then the BSD-style is called.

Definition at line 805 of file OS_NS_sys_socket.inl.

References ACE_OS_TRACE, ACE_SOCK_GROUP, ACE_SOCKCALL_RETURN, and socket().

00811 {
00812   ACE_OS_TRACE ("ACE_OS::socket");
00813 
00814 #if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
00815   ACE_SOCKCALL_RETURN (::WSASocket (domain,
00816                                     type,
00817                                     proto,
00818                                     protocolinfo,
00819                                     g,
00820                                     flags),
00821                        ACE_HANDLE,
00822                        ACE_INVALID_HANDLE);
00823 #else
00824   ACE_UNUSED_ARG (protocolinfo);
00825   ACE_UNUSED_ARG (g);
00826   ACE_UNUSED_ARG (flags);
00827 
00828   return ACE_OS::socket (domain,
00829                          type,
00830                          proto);
00831 #endif /* ACE_HAS_WINSOCK2 */
00832 }

ACE_INLINE ACE_HANDLE ACE_OS::socket int  protocol_family,
int  type,
int  proto
 

Create a BSD-style socket (no QoS).

Definition at line 792 of file OS_NS_sys_socket.inl.

References ACE_OS_TRACE, and ACE_SOCKCALL_RETURN.

Referenced by ACE_WIN32_Asynch_Accept::accept(), ACE_WIN32_Asynch_Connect::connect_i(), ACE_POSIX_Asynch_Connect::connect_i(), ACE::get_bcast_addr(), ACE::get_handle(), getmacaddress(), ACE::ipv6_enabled(), ACE_ATM_Acceptor::open(), ACE_Asynch_Acceptor< HANDLER >::open(), ACE_SPIPE_Stream::recv_handle(), and socket().

00795 {
00796   ACE_OS_TRACE ("ACE_OS::socket");
00797   ACE_SOCKCALL_RETURN (::socket (domain,
00798                                  type,
00799                                  proto),
00800                        ACE_HANDLE,
00801                        ACE_INVALID_HANDLE);
00802 }

int ACE_OS::socket_fini void   ) 
 

Finalize WinSock after last use (e.g., when a DLL is unloaded).

Definition at line 135 of file OS_NS_sys_socket.cpp.

References ACE_LIB_TEXT, ACE_TCHAR, fprintf(), and sprintf().

Referenced by ACE_OS_Object_Manager::fini().

00136 {
00137 # if defined (ACE_WIN32)
00138   if (ACE_OS::socket_initialized_ != 0)
00139     {
00140       if (WSACleanup () != 0)
00141         {
00142           int error = ::WSAGetLastError ();
00143 #   if defined (ACE_HAS_WINCE)
00144           ACE_TCHAR fmt[] = ACE_LIB_TEXT ("%s failed, WSAGetLastError returned %d");
00145           ACE_TCHAR buf[80];  // @@ Eliminate magic number.
00146           ACE_OS::sprintf (buf, fmt, ACE_LIB_TEXT ("WSACleanup"), error);
00147           ::MessageBox (0, buf , ACE_LIB_TEXT ("WSACleanup failed!"), MB_OK);
00148 #   else
00149           ACE_OS::fprintf (stderr,
00150                            "ACE_OS::socket_fini; WSACleanup failed, "
00151                              "WSAGetLastError returned %d\n",
00152                            error);
00153 #   endif /* ACE_HAS_WINCE */
00154         }
00155       ACE_OS::socket_initialized_ = 0;
00156     }
00157 # endif /* ACE_WIN32 */
00158   return 0;
00159 }

int ACE_OS::socket_init int  version_high = 1,
int  version_low = 1
 

Initialize WinSock before first use (e.g., when a DLL is first loaded or the first use of a socket() call.

Definition at line 101 of file OS_NS_sys_socket.cpp.

References ACE_LIB_TEXT, ACE_TCHAR, fprintf(), and sprintf().

Referenced by ACE_OS_Object_Manager::init().

00102 {
00103 # if defined (ACE_WIN32) && !defined(ACE_DONT_INIT_WINSOCK)
00104   if (ACE_OS::socket_initialized_ == 0)
00105     {
00106       WORD version_requested = MAKEWORD (version_high, version_low);
00107       WSADATA wsa_data;
00108       int error = WSAStartup (version_requested, &wsa_data);
00109 
00110       if (error != 0)
00111 #   if defined (ACE_HAS_WINCE)
00112         {
00113           ACE_TCHAR fmt[] = ACE_LIB_TEXT ("%s failed, WSAGetLastError returned %d");
00114           ACE_TCHAR buf[80];  // @@ Eliminate magic number.
00115           ACE_OS::sprintf (buf, fmt, ACE_LIB_TEXT ("WSAStartup"), error);
00116           ::MessageBox (0, buf, ACE_LIB_TEXT ("WSAStartup failed!"), MB_OK);
00117         }
00118 #   else
00119       ACE_OS::fprintf (stderr,
00120                        "ACE_OS::socket_init; WSAStartup failed, "
00121                          "WSAGetLastError returned %d\n",
00122                        error);
00123 #   endif /* ACE_HAS_WINCE */
00124 
00125       ACE_OS::socket_initialized_ = 1;
00126     }
00127 # else
00128   ACE_UNUSED_ARG (version_high);
00129   ACE_UNUSED_ARG (version_low);
00130 # endif /* ACE_WIN32 */
00131   return 0;
00132 }

ACE_INLINE int ACE_OS::socketpair int  domain,
int  type,
int  protocol,
ACE_HANDLE  sv[2]
 

BSD-style (no QoS).

Definition at line 835 of file OS_NS_sys_socket.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and socketpair().

Referenced by ACE_Pipe::open(), and socketpair().

00837 {
00838   ACE_OS_TRACE ("ACE_OS::socketpair");
00839 #if defined (ACE_LACKS_SOCKETPAIR)
00840   ACE_UNUSED_ARG (domain);
00841   ACE_UNUSED_ARG (type);
00842   ACE_UNUSED_ARG (protocol);
00843   ACE_UNUSED_ARG (sv);
00844 
00845   ACE_NOTSUP_RETURN (-1);
00846 #else
00847   ACE_OSCALL_RETURN (::socketpair (domain, type, protocol, sv),
00848                      int, -1);
00849 #endif /* ACE_LACKS_SOCKETPAIR */
00850 }

int ACE_OS::sprintf wchar_t *  buf,
const wchar_t *  format,
... 
 

Definition at line 367 of file OS_NS_stdio.cpp.

References ACE_NOTSUP_RETURN, and ACE_OS_TRACE.

00368 {
00369   ACE_OS_TRACE ("ACE_OS::sprintf");
00370 
00371 # if (defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) >= 500) || (defined ACE_HAS_DINKUM_STL) || defined (__DMC__)
00372 
00373   // The XPG4/UNIX98/C99 signature of the wide-char sprintf has a
00374   // maxlen argument. Since this method doesn't supply one, pass in
00375   // a length that works (ULONG_MAX doesn't on all platform since some check
00376   // to see if the operation will remain in bounds). If this isn't ok, use
00377   // ACE_OS::snprintf().
00378   int result;
00379   va_list ap;
00380   va_start (ap, format);
00381   ACE_OSCALL (ACE_STD_NAMESPACE::vswprintf (buf, 4096, format, ap), int, -1, result);
00382   va_end (ap);
00383   return result;
00384 
00385 # elif defined (ACE_WIN32)
00386   // Windows has vswprintf, but the signature is from the older ISO C
00387   // standard. Also see ACE_OS::snprintf() for more info on this.
00388 
00389   int result;
00390   va_list ap;
00391   va_start (ap, format);
00392   ACE_OSCALL (::vswprintf (buf, format, ap), int, -1, result);
00393   va_end (ap);
00394   return result;
00395 
00396 # else
00397 
00398   ACE_UNUSED_ARG (buf);
00399   ACE_UNUSED_ARG (format);
00400   ACE_NOTSUP_RETURN (-1);
00401 
00402 # endif /* XPG5 || ACE_HAS_DINKUM_STL */
00403 }

int ACE_OS::sprintf char *  buf,
const char *  format,
... 
 

Definition at line 353 of file OS_NS_stdio.cpp.

References ACE_SPRINTF_ADAPTER, and vsprintf().

Referenced by ACE_MEM_Acceptor::accept(), ACE_TPQ_Entry::ACE_TPQ_Entry(), ACE_INET_Addr::addr_to_string(), ACE_ATM_Addr::addr_to_string(), dlerror(), ACE_ATM_Addr::dump(), ACE_Ini_ImpExp::export_section(), ACE_Registry_ImpExp::export_section(), ACE::format_hexdump(), ACE_Log_Record::format_msg(), ACE_Utils::UUID_Generator::generateUUID(), ACE_INET_Addr::get_host_addr(), ACE::get_ip_interfaces(), getmacaddress(), ACE_Logging_Strategy::handle_timeout(), inet_ntop(), ACE_Stream_Type::info(), ACE_Module_Type::info(), ACE_Service_Manager::info(), ACE_Naming_Context::info(), ACE_Connector< SVC_HANDLER, ACE_PEER_CONNECTOR_2 >::info(), ACE_Oneshot_Acceptor< SVC_HANDLER, >::info(), ACE_Strategy_Acceptor< SVC_HANDLER, >::info(), ACE_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_2 >::info(), ACE::ldfind(), ACE_Log_Msg::log(), ACE_Log_Msg::log_hexdump(), mmap(), ACE_Token_Proxy::open(), ACE_High_Res_Timer::print_ave(), ACE_Stats::print_summary(), ACE_High_Res_Timer::print_total(), ACE_Process_Options::setenv(), ACE::sock_error(), socket_fini(), socket_init(), ACE_Process::spawn(), strerror(), ACE::timestamp(), ACE_Utils::UUID::to_string(), uname(), and unique_name().

00354 {
00355   // ACE_OS_TRACE ("ACE_OS::sprintf");
00356 
00357   int result;
00358   va_list ap;
00359   va_start (ap, format);
00360   ACE_OSCALL (ACE_SPRINTF_ADAPTER (::vsprintf (buf, format, ap)), int, -1, result);
00361   va_end (ap);
00362   return result;
00363 }

ACE_INLINE void ACE_OS::srand u_int  seed  ) 
 

Definition at line 398 of file OS_NS_stdlib.inl.

References ACE_OS_TRACE.

00399 {
00400   ACE_OS_TRACE ("ACE_OS::srand");
00401   ::srand (seed);
00402 }

ACE_INLINE int ACE_OS::stat const wchar_t *  file,
ACE_stat
 

Definition at line 253 of file OS_NS_sys_stat.inl.

References ACE_OS_TRACE, ACE_Time_Value, set_errno_to_last_error(), and stat().

00254   {
00255     ACE_OS_TRACE ("ACE_OS::stat");
00256 #if defined (ACE_HAS_WINCE)
00257     WIN32_FIND_DATAW fdata;
00258 
00259     HANDLE fhandle;
00260 
00261     fhandle = ::FindFirstFileW (file, &fdata);
00262     if (fhandle == INVALID_HANDLE_VALUE)
00263       {
00264         ACE_OS::set_errno_to_last_error ();
00265         return -1;
00266       }
00267     else if (fdata.nFileSizeHigh != 0)
00268       {
00269         errno = EINVAL;
00270         return -1;
00271       }
00272     else
00273       {
00274         stp->st_mode = static_cast<unsigned short>(fdata.dwFileAttributes);
00275         stp->st_size = fdata.nFileSizeLow;
00276         stp->st_atime = ACE_Time_Value (fdata.ftLastAccessTime);
00277         stp->st_mtime = ACE_Time_Value (fdata.ftLastWriteTime);
00278       }
00279     return 0;
00280 #elif defined (__BORLANDC__)
00281     ACE_OSCALL_RETURN (::_wstati64 (file, stp), int, -1);
00282 #elif defined (ACE_WIN32) && defined _MSC_VER && _MSC_VER >= 1300 && _MSC_VER < 1400 // vc71
00283     ACE_OSCALL_RETURN (::_wstati64 (file, stp), int, -1);
00284 #elif defined (__MINGW32__)
00285     ACE_OSCALL_RETURN (::_wstat (file, stp), int, -1);
00286 #elif defined (ACE_WIN32)
00287     ACE_OSCALL_RETURN (::_wstat64 (file, stp), int, -1);
00288 #else /* ACE_HAS_WINCE */
00289     ACE_Wide_To_Ascii nfile (file);
00290     return ACE_OS::stat (nfile.char_rep (), stp);
00291 #endif /* ACE_HAS_WINCE */
00292   }

ACE_INLINE int ACE_OS::stat const char *  file,
ACE_stat
 

Definition at line 203 of file OS_NS_sys_stat.inl.

References ACE_OS_TRACE, ACE_TEXT_CHAR_TO_TCHAR, ACE_Time_Value, set_errno_to_last_error(), and stat().

Referenced by ACE_Filecache_Object::ACE_Filecache_Object(), lstat(), ACE_Service_Gestalt::process_file(), ACE_Filecache_Object::release(), sema_init(), stat(), and ACE_Filecache_Object::update().

00204   {
00205     ACE_OS_TRACE ("ACE_OS::stat");
00206 #if defined (ACE_HAS_NONCONST_STAT)
00207     ACE_OSCALL_RETURN (::stat (const_cast <char *> (file), stp), int, -1);
00208 #elif defined (ACE_HAS_WINCE)
00209     ACE_TEXT_WIN32_FIND_DATA fdata;
00210 
00211     HANDLE fhandle;
00212 
00213     fhandle = ::FindFirstFile (ACE_TEXT_CHAR_TO_TCHAR (file), &fdata);
00214     if (fhandle == INVALID_HANDLE_VALUE)
00215       {
00216         ACE_OS::set_errno_to_last_error ();
00217         return -1;
00218       }
00219     else if (fdata.nFileSizeHigh != 0)
00220       {
00221         errno = EINVAL;
00222         return -1;
00223       }
00224     else
00225       {
00226         stp->st_mode = static_cast<unsigned short>(fdata.dwFileAttributes);
00227         stp->st_size = fdata.nFileSizeLow;
00228         stp->st_atime = ACE_Time_Value (fdata.ftLastAccessTime);
00229         stp->st_mtime = ACE_Time_Value (fdata.ftLastWriteTime);
00230       }
00231     return 0;
00232 #elif defined (ACE_HAS_X86_STAT_MACROS)
00233     // Solaris for intel uses an macro for stat(), this macro is a
00234     // wrapper for _xstat().
00235     ACE_OSCALL_RETURN (::_xstat (_STAT_VER, file, stp), int, -1);
00236 #elif defined (ACE_WIN32)
00237 # if defined(__IBMCPP__) || defined (__MINGW32__)
00238     ACE_OSCALL_RETURN (::_stat (file,  stp), int, -1);
00239 # elif defined (__BORLANDC__)
00240     ACE_OSCALL_RETURN (::_stati64 (file, stp), int, -1);
00241 # elif defined _MSC_VER && _MSC_VER >= 1300 && _MSC_VER < 1400 // vc71
00242     ACE_OSCALL_RETURN (::_stati64 (file, stp), int, -1);
00243 # else
00244     ACE_OSCALL_RETURN (::_stat64 (file, stp), int, -1);
00245 # endif /* __IBMCPP__ */
00246 #else /* ACE_HAS_NONCONST_STAT */
00247     ACE_OSCALL_RETURN (::stat (file, stp), int, -1);
00248 #endif /* ACE_HAS_NONCONST_STAT */
00249   }

ACE_INLINE int ACE_OS::step const char *  str,
char *  expbuf
 

Definition at line 26 of file OS_NS_regex.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and step().

Referenced by ACE_Local_Name_Space<, ACE_LOCK >::list_type_entries_i(), ACE_Local_Name_Space<, ACE_LOCK >::list_types_i(), and step().

00027 {
00028   ACE_OS_TRACE ("ACE_OS::step");
00029 #if defined (ACE_HAS_REGEX)
00030   ACE_OSCALL_RETURN (::step (str, expbuf), int, -1);
00031 #else
00032   ACE_UNUSED_ARG (str);
00033   ACE_UNUSED_ARG (expbuf);
00034 
00035   ACE_NOTSUP_RETURN (-1);
00036 #endif /* ACE_HAS_REGEX */
00037 }

ACE_NAMESPACE_INLINE_FUNCTION int strcasecmp const wchar_t *  s,
const wchar_t *  t
 

Compares two strings (case insensitive const wchar_t version).

ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE int ACE_OS::strcasecmp const char *  s,
const char *  t
 

Compares two strings (case insensitive const char version).

Definition at line 12 of file OS_NS_strings.inl.

References strcasecmp_emulation().

Referenced by ACE_POSIX_Proactor::ACE_POSIX_Proactor(), ACE_TTY_IO::control(), ACE::execname(), ACE::ldfind(), and ACE_Name_Options::parse_args().

00013 {
00014 #if defined (ACE_LACKS_STRCASECMP)
00015   return ACE_OS::strcasecmp_emulation (s, t);
00016 #elif defined (ACE_STRCASECMP_EQUIVALENT)
00017   return ACE_STRCASECMP_EQUIVALENT (s, t);
00018 #else /* ACE_LACKS_STRCASECMP */
00019   return ::strcasecmp (s, t);
00020 #endif /* ACE_LACKS_STRCASECMP */
00021 }

ACE_BEGIN_VERSIONED_NAMESPACE_DECL int ACE_OS::strcasecmp_emulation const char *  s,
const char *  t
 

Emulated strcasecmp - Performs a case insensitive comparison of strings.

Definition at line 19 of file OS_NS_strings.cpp.

References ace_tolower().

Referenced by strcasecmp().

00020 {
00021   const char *scan1 = s;
00022   const char *scan2 = t;
00023 
00024   while (*scan1 != 0
00025          && ACE_OS::ace_tolower (*scan1)
00026             == ACE_OS::ace_tolower (*scan2))
00027     {
00028       ++scan1;
00029       ++scan2;
00030     }
00031 
00032   // The following case analysis is necessary so that characters which
00033   // look negative collate low against normal characters but high
00034   // against the end-of-string NUL.
00035 
00036   if (*scan1 == '\0' && *scan2 == '\0')
00037     return 0;
00038   else if (*scan1 == '\0')
00039     return -1;
00040   else if (*scan2 == '\0')
00041     return 1;
00042   else
00043     return ACE_OS::ace_tolower (*scan1) - ACE_OS::ace_tolower (*scan2);
00044 }

ACE_INLINE wchar_t * ACE_OS::strcat wchar_t *  s,
const wchar_t *  t
 

Appends a string to another string (wchar_t version).

Definition at line 66 of file OS_NS_string.inl.

References wcscat_emulation().

00067 {
00068 #  if defined (ACE_LACKS_WCSCAT)
00069   return ACE_OS::wcscat_emulation (s, t);
00070 #  else /* ACE_LACKS_WCSCAT */
00071   return ::wcscat (s, t);
00072 #  endif /* ACE_LACKS_WCSCAT */
00073 }

ACE_INLINE char * ACE_OS::strcat char *  s,
const char *  t
 

Appends a string to another string (char version).

Definition at line 59 of file OS_NS_string.inl.

Referenced by ACE_MEM_Acceptor::accept(), ACE_ARGV_T< CHAR_TYPE >::ACE_ARGV_T(), ACE_Logging_Strategy::ACE_Logging_Strategy(), ACE_MMAP_Memory_Pool::ACE_MMAP_Memory_Pool(), ACE_Name_Options::ACE_Name_Options(), ACE_Pagefile_Memory_Pool::ACE_Pagefile_Memory_Pool(), ACE_System_Time::ACE_System_Time(), ACE_Process_Options::command_line(), ACE_Local_Name_Space<, ACE_LOCK >::create_manager_i(), event_init(), ACE_INET_Addr::get_host_addr(), ACE::get_ip_interfaces(), ACE_MT_MEM_IO::init(), ACE_NT_Service::insert(), ACE::ldfind(), ACE::ldname(), ACE_Service_Manager::list_services(), ACE_DLL_Handle::open(), sema_init(), ACE_SPIPE_Addr::set(), ACE_FILE_Addr::set(), and uname().

00060 {
00061   return ::strcat (s, t);
00062 }

ACE_INLINE wchar_t * ACE_OS::strchr wchar_t *  s,
wchar_t  c
 

Finds the first occurance of a character in a string (wchar_t version).

Definition at line 106 of file OS_NS_string.inl.

References strchr().

00107 {
00108   return
00109     const_cast<wchar_t *> (ACE_OS::strchr (const_cast<const wchar_t *> (s),
00110                                            c));
00111 }

ACE_INLINE char * ACE_OS::strchr char *  s,
int  c
 

Finds the first occurance of a character in a string (char version).

Definition at line 99 of file OS_NS_string.inl.

00100 {
00101   return ::strchr (s, c);
00102 }

ACE_INLINE const wchar_t * ACE_OS::strchr const wchar_t *  s,
wchar_t  c
 

Finds the first occurance of a character in a string (const wchar_t version).

Definition at line 88 of file OS_NS_string.inl.

References wcschr_emulation().

00089 {
00090 #  if defined (ACE_LACKS_WCSCHR)
00091   return ACE_OS::wcschr_emulation (s, c);
00092 #  else /* ACE_LACKS_WCSCHR */
00093   return ::wcschr (s, c);
00094 #  endif /* ACE_LACKS_WCSCHR */
00095 }

ACE_INLINE const char * ACE_OS::strchr const char *  s,
int  c
 

Finds the first occurance of a character in a string (const char version).

Definition at line 77 of file OS_NS_string.inl.

Referenced by ACE_SString::find(), ACE_Service_Manager::handle_input(), ACE_Ini_ImpExp::import_config(), ACE_Registry_ImpExp::import_config(), ACE_Get_Opt::long_option(), ACE_Configuration_Heap::open_section(), ACE_Registry_ImpExp::process_previous_line_format(), putenv(), ACE_Svc_Conf_Lexer::scan(), ACE_SPIPE_Addr::set(), ACE_Get_Opt::short_option_i(), strchr(), and ACE_INET_Addr::string_to_addr().

00078 {
00079 #if defined (ACE_LACKS_STRCHR)
00080   return ACE_OS::strchr_emulation (s, c);
00081 #else  /* ! ACE_LACKS_STRCHR */
00082   return (const char *) ::strchr (s, c);
00083 #endif /* ACE_LACKS_STRCHR */
00084 }

ACE_INLINE int ACE_OS::strcmp const ACE_WCHAR_T *  s,
const ACE_WCHAR_T *  t
 

Compares two strings (wchar_t version).

Definition at line 121 of file OS_NS_string.inl.

References wcscmp_emulation().

00122 {
00123 #  if !defined (ACE_HAS_WCHAR) || defined (ACE_LACKS_WCSCMP)
00124   return ACE_OS::wcscmp_emulation (s, t);
00125 #  else /* !ACE_HAS_WCHAR || ACE_LACKS_WCSCMP */
00126   return ::wcscmp (s, t);
00127 #  endif /* !ACE_HAS_WCHAR || ACE_LACKS_WCSCMP */
00128 }

ACE_INLINE int ACE_OS::strcmp const char *  s,
const char *  t
 

Compares two strings (char version).

Definition at line 115 of file OS_NS_string.inl.

Referenced by ace_get_module(), ACE_Log_Msg::ACE_Log_Msg(), ACE_Service_Gestalt::add_processed_static_svc(), ACE_Malloc_FIFO_Iterator_T<, ACE_LOCK, ACE_CB >::advance(), ACE_Malloc_LIFO_Iterator_T<, ACE_LOCK, ACE_CB >::advance(), ACE_SString::compare(), ACE_Predefined_Naming_Contexts::connect(), ACE_SOCK_Dgram_Mcast::dump(), ACE_Stream<>::find(), ACE_Stream_Type::find(), ACE_DLL_Manager::find_dll(), ACE_Service_Repository::find_i(), ACE_Service_Gestalt::find_processed_static_svc(), ACE_Service_Gestalt::find_static_svc_descriptor(), ACE::get_ip_interfaces(), inet_aton(), ACE_Stream<>::insert(), ACE_Service_Repository::insert(), ACE_Capabilities::is_entry(), ACE_Predefined_Naming_Contexts::is_local_host(), ACE::ldfind(), ACE_Local_Name_Space<, ACE_LOCK >::list_type_entries_i(), ACE_Local_Name_Space<, ACE_LOCK >::list_types_i(), ACE_Naming_Context::local(), ACE_Codeset_Registry::locale_to_registry_i(), ACE_SOCK_Dgram::make_multicast_ifaddr6(), open(), ACE_DLL_Handle::open(), ACE_Service_Config::open_i(), ACE_DLL::open_i(), ACE_Configuration_ExtId::operator!=(), ACE_Less_Than< wchar_t * >::operator()(), ACE_Less_Than< const wchar_t * >::operator()(), ACE_Equal_To< wchar_t * >::operator()(), ACE_Equal_To< const wchar_t * >::operator()(), ACE_Less_Than< char * >::operator()(), ACE_Less_Than< const char * >::operator()(), ACE_Equal_To< char * >::operator()(), ACE_Equal_To< const char * >::operator()(), ACE_SString::operator<(), ACE_SString::operator==(), ACE_SPIPE_Addr::operator==(), ACE_Static_Svc_Descriptor::operator==(), ACE_Name_Binding::operator==(), ACE_FILE_Addr::operator==(), ACE_DEV_Addr::operator==(), ACE_Configuration_ExtId::operator==(), ACE_SString::operator>(), ACE_RW_Token::owners(), ACE_Name_Options::parse_args(), ACE_Get_Opt::permute(), ACE_Logging_Strategy::priorities(), ACE_Service_Manager::process_request(), ACE_Stream<>::remove(), ACE_Framework_Repository::remove_component(), ACE_Framework_Repository::remove_dll_components_i(), ACE_Stream<>::replace(), ACE_Svc_Conf_Lexer::scan(), ACE_INET_Addr::set(), ACE_Malloc_T< ACE_MEM_POOL_2, ACE_LOCK, ACE_CB >::shared_find(), ACE_ATM_Addr::string_to_addr(), thr_equal(), ACE_Logging_Strategy::tokenize(), and ACE_Malloc_T< ACE_MEM_POOL_2, ACE_LOCK, ACE_CB >::unbind().

00116 {
00117   return ::strcmp (s, t);
00118 }

ACE_INLINE wchar_t * ACE_OS::strcpy wchar_t *  s,
const wchar_t *  t
 

Copies a string (wchar_t version).

Definition at line 138 of file OS_NS_string.inl.

References wcscpy_emulation().

00139 {
00140 #  if defined (ACE_LACKS_WCSCPY)
00141   return ACE_OS::wcscpy_emulation (s, t);
00142 #  else /* ACE_LACKS_WCSCPY */
00143   return ::wcscpy (s, t);
00144 #  endif /* ACE_LACKS_WCSCPY */
00145 }

ACE_INLINE char * ACE_OS::strcpy char *  s,
const char *  t
 

Copies a string (char version).

Definition at line 131 of file OS_NS_string.inl.

Referenced by ACE_ARGV_T< CHAR_TYPE >::ACE_ARGV_T(), ACE_Filecache_Object::ACE_Filecache_Object(), ACE_MMAP_Memory_Pool::ACE_MMAP_Memory_Pool(), ACE_PI_Control_Block::ACE_Name_Node::ACE_Name_Node(), ACE_Control_Block::ACE_Name_Node::ACE_Name_Node(), ACE_Name_Options::ACE_Name_Options(), ACE_SString::ACE_SString(), ACE_System_Time::ACE_System_Time(), ACE_Configuration_Heap::add_section(), ACE_SDM_helpers::addr_to_string(), ACE_ATM_Addr::addr_to_string(), ACE_Process_Options::command_line(), ACE_Local_Name_Space<, ACE_LOCK >::create_manager_i(), cuserid(), dlsym(), ACE_SOCK_Dgram_Mcast::dump(), ACE::execname(), ACE_Log_Record::format_msg(), ACE_INET_Addr::get_host_name(), ACE_INET_Addr::get_host_name_i(), ACE_ATM_Stream::get_peer_name(), get_reg_subkeys(), ACE::get_temp_dir(), getmacaddress(), inet_ntop(), ACE_MT_MEM_IO::init(), ACE::ldfind(), ACE::ldname(), ACE_Service_Manager::list_services(), ACE_Log_Msg_UNIX_Syslog::log(), ACE_Log_Msg::log(), ACE_SOCK_Dgram::make_multicast_ifaddr(), mktemp(), ACE_Configuration_Heap::new_section(), ACE_DLL_Strategy< SVC_HANDLER >::open(), ACE_Log_Msg_NT_Event_Log::open(), ACE_SOCK_Dgram_Mcast::open_i(), ACE_SString::operator=(), ACE_Sched_Params::priority_max(), ACE_Sched_Params::priority_min(), ACE_Process_Options::process_name(), ACE_Service_Gestalt::Processed_Static_Svc::Processed_Static_Svc(), ACE_InputCDR::read_string(), realpath(), ACE_Remote_Name_Space::resolve(), scandir_emulation(), scheduling_class(), sema_init(), ACE_UNIX_Addr::set(), ACE_SPIPE_Addr::set(), ACE_FILE_Addr::set(), ACE_Configuration_Heap::set_binary_value(), ACE_Configuration_Heap::set_integer_value(), ACE_Configuration_Heap::set_string_value(), ACE_Local_Name_Space<, ACE_LOCK >::shared_bind_i(), ACE::strnew(), tempnam(), uname(), and ACE_Process_Options::working_directory().

00132 {
00133   return ::strcpy (s, t);
00134 }

ACE_INLINE size_t ACE_OS::strcspn const wchar_t *  s,
const wchar_t *  reject
 

Searches for the first substring without any of the specified characters and returns the size of the substring (wchar_t version).

Definition at line 156 of file OS_NS_string.inl.

References wcscspn_emulation().

00157 {
00158 #  if defined (ACE_LACKS_WCSCSPN)
00159   return ACE_OS::wcscspn_emulation (s, reject);
00160 #  else /* ACE_LACKS_WCSCSPN */
00161   return ::wcscspn (s, reject);
00162 #  endif /* ACE_LACKS_WCSCSPN */
00163 }

ACE_INLINE size_t ACE_OS::strcspn const char *  s,
const char *  reject
 

Searches for the first substring without any of the specified characters and returns the size of the substring (char version).

Definition at line 149 of file OS_NS_string.inl.

Referenced by ACE_Configuration::validate_name().

00150 {
00151   return ::strcspn (s, reject);
00152 }

ACE_INLINE wchar_t * ACE_OS::strdup const wchar_t *  s  ) 
 

Returns a malloced duplicated string (wchar_t version).

Definition at line 183 of file OS_NS_string.inl.

00184 {
00185 #  if (defined (ACE_LACKS_WCSDUP) && !defined (ACE_WCSDUP_EQUIVALENT)) \
00186   || defined (ACE_HAS_WCSDUMP_EMULATION)
00187   return ACE_OS::strdup_emulation (s);
00188 #  elif defined (ACE_WCSDUP_EQUIVALENT)
00189   return ACE_WCSDUP_EQUIVALENT (s);
00190 #  elif defined (ACE_HAS_NONCONST_WCSDUP)
00191   return ::wcsdup (const_cast<wchar_t*> (s));
00192 #  else
00193   return ::wcsdup (s);
00194 #  endif /* (ACE_LACKS_WCSDUP && !ACE_WCSDUP_EQUIVALENT) || ... */
00195 }

ACE_INLINE char * ACE_OS::strdup const char *  s  ) 
 

Returns a malloced duplicated string (char version).

Definition at line 167 of file OS_NS_string.inl.

Referenced by ACE_Argv_Type_Converter::ACE_Argv_Type_Converter(), ACE_Configuration_Section_Key_Heap::ACE_Configuration_Section_Key_Heap(), ACE_Mutex::ACE_Mutex(), ACE_Name_Options::ACE_Name_Options(), ACE_Name_Options::database(), event_init(), flock_init(), ACE_Thru_Task<>::info(), ACE_Stream_Tail<>::info(), ACE_Stream_Head<>::info(), ACE_Stream_Type::info(), ACE_Module_Type::info(), ACE_Service_Manager::info(), ACE_Naming_Context::info(), ACE_Connector< SVC_HANDLER, ACE_PEER_CONNECTOR_2 >::info(), ACE_Oneshot_Acceptor< SVC_HANDLER, >::info(), ACE_Strategy_Acceptor< SVC_HANDLER, >::info(), ACE_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_2 >::info(), ACE::ldfind(), ACE_Local_Name_Space<, ACE_LOCK >::list_type_entries_i(), ACE_Name_Options::nameserver_host(), ACE_Name_Options::namespace_dir(), ACE_Name_Binding::operator=(), ACE_Name_Options::process_name(), putenv(), sema_init(), strenvdup(), string_to_argv(), and ACE_Log_Msg::sync().

00168 {
00169 #  if (defined (ACE_LACKS_STRDUP) && !defined(ACE_STRDUP_EQUIVALENT)) \
00170   || defined (ACE_HAS_STRDUP_EMULATION)
00171   return ACE_OS::strdup_emulation (s);
00172 #  elif defined (ACE_STRDUP_EQUIVALENT)
00173   return ACE_STRDUP_EQUIVALENT (s);
00174 #  elif defined (ACE_HAS_NONCONST_STRDUP)
00175   return ::strdup (const_cast<char *> (s));
00176 #else
00177   return ::strdup (s);
00178 #  endif /* (ACE_LACKS_STRDUP && !ACE_STRDUP_EQUIVALENT) || ... */
00179 }

wchar_t * ACE_OS::strecpy wchar_t *  s,
const wchar_t *  t
 

Copies a string, but returns a pointer to the end of the copied region (wchar_t version).

Definition at line 86 of file OS_NS_string.cpp.

References ACE_TEXT_WIDE.

00087 {
00088   register wchar_t *dscan = s;
00089   register const wchar_t *sscan = t;
00090 
00091   while ((*dscan++ = *sscan++) != ACE_TEXT_WIDE ('\0'))
00092     continue;
00093 
00094   return dscan;
00095 }

char * ACE_OS::strecpy char *  des,
const char *  src
 

Copies a string, but returns a pointer to the end of the copied region (char version).

Definition at line 73 of file OS_NS_string.cpp.

Referenced by argv_to_string(), and ACE::execname().

00074 {
00075   register char *dscan = s;
00076   register const char *sscan = t;
00077 
00078   while ((*dscan++ = *sscan++) != '\0')
00079     continue;
00080 
00081   return dscan;
00082 }

ACE_INLINE ACE_TCHAR * ACE_OS::strenvdup const ACE_TCHAR str  ) 
 

Definition at line 410 of file OS_NS_stdlib.inl.

References ACE_LIB_TEXT, ACE_NOTSUP_RETURN, ACE_TCHAR, ACE_TEXT_ALWAYS_CHAR, ACE_TEXT_CHAR_TO_TCHAR, getenv(), and strdup().

Referenced by ACE::strenvdup(), and string_to_argv().

00411 {
00412 #if defined (ACE_HAS_WINCE)
00413   // WinCE doesn't have environment variables so we just skip it.
00414   return ACE_OS::strdup (str);
00415 #elif defined (ACE_LACKS_ENV)
00416   ACE_UNUSED_ARG (str);
00417   ACE_NOTSUP_RETURN (0);
00418 #else
00419   if (str[0] == ACE_LIB_TEXT ('$'))
00420     {
00421 #  if defined (ACE_WIN32)
00422       // Always use the ACE_TCHAR for Windows.
00423       ACE_TCHAR *temp = 0;
00424       if ((temp = ACE_OS::getenv (&str[1])) != 0)
00425         return ACE_OS::strdup (temp);
00426 #  else
00427       // Use char * for environment on non-Windows.
00428       char *temp = 0;
00429       if ((temp = ACE_OS::getenv (ACE_TEXT_ALWAYS_CHAR (&str[1]))) != 0)
00430         return ACE_OS::strdup (ACE_TEXT_CHAR_TO_TCHAR (temp));
00431 #  endif /* ACE_WIN32 */
00432       return ACE_OS::strdup (str);
00433     }
00434   else
00435     return ACE_OS::strdup (str);
00436 #endif /* ACE_HAS_WINCE */
00437 }

char * ACE_OS::strerror int  errnum  ) 
 

Finds characters in a buffer (const void version).

Definition at line 99 of file OS_NS_string.cpp.

References ACE_TCHAR, ACE_TEXT_ALWAYS_CHAR, ACE::is_sock_error(), ACE::sock_error(), sprintf(), and strncpy().

Referenced by ACE_POSIX_AIOCB_Proactor::delete_result_aiocb_list(), dlerror(), and ACE_Log_Msg::log().

00100 {
00101   static char ret_errortext[128];
00102 
00103   if (ACE::is_sock_error (errnum))
00104     {
00105       const ACE_TCHAR *errortext = ACE::sock_error (errnum);
00106       ACE_OS::strncpy (ret_errortext,
00107                        ACE_TEXT_ALWAYS_CHAR (errortext),
00108                        sizeof (ret_errortext));
00109       return ret_errortext;
00110     }
00111 #if defined (ACE_LACKS_STRERROR)
00112   errno = EINVAL;
00113   return ACE_OS::strerror_emulation (errnum);
00114 #else /* ACE_LACKS_STRERROR */
00115   // Adapt to the various ways that strerror() indicates a bad errnum.
00116   // Most modern systems set errno to EINVAL. Some older platforms return
00117   // a pointer to a NULL string. This code makes the behavior more consistent
00118   // across platforms. On a bad errnum, we make a string with the error number
00119   // and set errno to EINVAL.
00120   ACE_Errno_Guard g (errno);
00121   errno = 0;
00122   char *errmsg;
00123 
00124 #if defined (ACE_WIN32)
00125    if (errnum < 0 || errnum >= _sys_nerr)
00126       errno = EINVAL;
00127 #endif /* ACE_WIN32 */
00128    errmsg = ::strerror (errnum);
00129 
00130   if (errno == EINVAL || errmsg == 0 || errmsg[0] == 0)
00131     {
00132       ACE_OS::sprintf (ret_errortext, "Unknown error %d", errnum);
00133       errmsg = ret_errortext;
00134       g = EINVAL;
00135     }
00136   return errmsg;
00137 #endif /* ACE_LACKS_STRERROR */
00138 }

ACE_INLINE size_t ACE_OS::strftime char *  s,
size_t  maxsize,
const char *  format,
const struct tm *  timeptr
 

Definition at line 402 of file OS_NS_time.inl.

References ACE_NOTSUP_RETURN.

00404 {
00405 #if defined (ACE_LACKS_STRFTIME)
00406   ACE_UNUSED_ARG (s);
00407   ACE_UNUSED_ARG (maxsize);
00408   ACE_UNUSED_ARG (format);
00409   ACE_UNUSED_ARG (timeptr);
00410   ACE_NOTSUP_RETURN (0);
00411 #else
00412   return ACE_STD_NAMESPACE::strftime (s, maxsize, format, timeptr);
00413 #endif /* ACE_LACKS_STRFTIME */
00414 }

int ACE_OS::string_to_argv ACE_TCHAR buf,
int &  argc,
ACE_TCHAR **&  argv,
bool  substitute_env_args = true
 

Definition at line 620 of file OS_NS_unistd.cpp.

References ACE_DEFAULT_ARGV_BUFSIZ, ace_isspace(), ACE_LIB_TEXT, ACE_NEW_RETURN, ACE_TCHAR, strdup(), and strenvdup().

Referenced by ACE_ARGV_T< CHAR_TYPE >::string_to_argv().

00624 {
00625   // Reset the number of arguments
00626   argc = 0;
00627 
00628   if (buf == 0)
00629     return -1;
00630 
00631   ACE_TCHAR *cp = buf;
00632 
00633   // First pass: count arguments.
00634 
00635   // '#' is the start-comment token..
00636   while (*cp != ACE_LIB_TEXT ('\0') && *cp != ACE_LIB_TEXT ('#'))
00637     {
00638       // Skip whitespace..
00639       while (ACE_OS::ace_isspace (*cp))
00640         cp++;
00641 
00642       // Increment count and move to next whitespace..
00643       if (*cp != ACE_LIB_TEXT ('\0'))
00644         argc++;
00645 
00646       while (*cp != ACE_LIB_TEXT ('\0') && !ACE_OS::ace_isspace (*cp))
00647         {
00648           // Grok quotes....
00649           if (*cp == ACE_LIB_TEXT ('\'') || *cp == ACE_LIB_TEXT ('"'))
00650             {
00651               ACE_TCHAR quote = *cp;
00652 
00653               // Scan past the string..
00654               for (cp++; *cp != ACE_LIB_TEXT ('\0') && *cp != quote; cp++)
00655                 continue;
00656 
00657               // '\0' implies unmatched quote..
00658               if (*cp == ACE_LIB_TEXT ('\0'))
00659                 {
00660                   argc--;
00661                   break;
00662                 }
00663               else
00664                 cp++;
00665             }
00666           else
00667             cp++;
00668         }
00669     }
00670 
00671   // Second pass: copy arguments.
00672   ACE_TCHAR arg[ACE_DEFAULT_ARGV_BUFSIZ];
00673   ACE_TCHAR *argp = arg;
00674 
00675   // Make sure that the buffer we're copying into is always large
00676   // enough.
00677   if (cp - buf >= ACE_DEFAULT_ARGV_BUFSIZ)
00678     ACE_NEW_RETURN (argp,
00679                     ACE_TCHAR[cp - buf + 1],
00680                     -1);
00681 
00682   // Make a new argv vector of argc + 1 elements.
00683   ACE_NEW_RETURN (argv,
00684                   ACE_TCHAR *[argc + 1],
00685                   -1);
00686 
00687   ACE_TCHAR *ptr = buf;
00688 
00689   for (int i = 0; i < argc; i++)
00690     {
00691       // Skip whitespace..
00692       while (ACE_OS::ace_isspace (*ptr))
00693         ptr++;
00694 
00695       // Copy next argument and move to next whitespace..
00696       cp = argp;
00697       while (*ptr != ACE_LIB_TEXT ('\0') && !ACE_OS::ace_isspace (*ptr))
00698         if (*ptr == ACE_LIB_TEXT ('\'') || *ptr == ACE_LIB_TEXT ('"'))
00699           {
00700             ACE_TCHAR quote = *ptr++;
00701 
00702             while (*ptr != ACE_LIB_TEXT ('\0') && *ptr != quote)
00703               *cp++ = *ptr++;
00704 
00705             if (*ptr == quote)
00706               ptr++;
00707           }
00708         else
00709           *cp++ = *ptr++;
00710 
00711       *cp = ACE_LIB_TEXT ('\0');
00712 
00713 #if !defined (ACE_LACKS_ENV)
00714       // Check for environment variable substitution here.
00715       if (substitute_env_args) {
00716           argv[i] = ACE_OS::strenvdup(argp);
00717 
00718           if (argv[i] == 0)
00719             {
00720               if (argp != arg)
00721                 delete [] argp;
00722               errno = ENOMEM;
00723               return -1;
00724             }
00725       }
00726       else
00727 #endif /* ACE_LACKS_ENV */
00728         {
00729           argv[i] = ACE_OS::strdup(argp);
00730 
00731           if (argv[i] == 0)
00732             {
00733               if (argp != arg)
00734                 delete [] argp;
00735               errno = ENOMEM;
00736               return -1;
00737             }
00738         }
00739     }
00740 
00741   if (argp != arg)
00742     delete [] argp;
00743 
00744   argv[argc] = 0;
00745   return 0;
00746 }

ACE_INLINE size_t ACE_OS::strlen const ACE_WCHAR_T *  s  ) 
 

Finds the length of a string (ACE_WCHAR_T version).

Definition at line 205 of file OS_NS_string.inl.

References wcslen_emulation().

00206 {
00207 # if !defined (ACE_HAS_WCHAR) || defined (ACE_LACKS_WCSLEN)
00208   return ACE_OS::wcslen_emulation (s);
00209 # else  /* !ACE_HAS_WCHAR || ACE_LACKS_WCSLEN */
00210   return ::wcslen (s);
00211 # endif /* !ACE_HAS_WCHAR || ACE_LACKS_WCSLEN */
00212 }

ACE_INLINE size_t ACE_OS::strlen const char *  s  ) 
 

Finds the length of a string (char version).

Definition at line 199 of file OS_NS_string.inl.

Referenced by ACE_MEM_Acceptor::accept(), ACE_ARGV_T< CHAR_TYPE >::ACE_ARGV_T(), ACE_NS_WString::ACE_NS_WString(), ACE_Pagefile_Memory_Pool::ACE_Pagefile_Memory_Pool(), ACE_SString::ACE_SString(), ACE_ARGV_T< CHAR_TYPE >::add(), ACE_INET_Addr::addr_to_string(), ACE_ATM_Addr::addr_to_string(), argv_to_string(), ACE_Remote_Name_Space::bind(), ACE_Message_Block::copy(), ACE_ARGV_T< CHAR_TYPE >::create_buf_from_queue(), ACE_Local_Name_Space<, ACE_LOCK >::create_manager_i(), ACE_Arg_Shifter_T< CHAR_TYPE >::cur_arg_strncasecmp(), cuserid(), ACE_Token_Request::decode(), dlsym(), ACE::execname(), ACE_String_Base< CHAR >::find(), ACE_INET_Addr::get_host_addr(), ACE_INET_Addr::get_host_name_i(), ACE_ATM_Stream::get_peer_name(), ACE::get_temp_dir(), ACE_Logging_Strategy::handle_timeout(), ACE_Ini_ImpExp::import_config(), ACE_Registry_ImpExp::import_config(), inet_ntop(), ACE_Thru_Task<>::info(), ACE_Stream_Tail<>::info(), ACE_Stream_Head<>::info(), ACE_Stream_Type::info(), ACE_Module_Type::info(), ACE_Service_Manager::info(), ACE_Naming_Context::info(), ACE_Connector< SVC_HANDLER, ACE_PEER_CONNECTOR_2 >::info(), ACE_Oneshot_Acceptor< SVC_HANDLER, >::info(), ACE_Strategy_Acceptor< SVC_HANDLER, >::info(), ACE_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_2 >::info(), ACE_Process_Options::inherit_environment(), ACE_Svc_Conf_Lexer::input(), ACE::ldfind(), ACE::ldname(), ACE_Service_Manager::list_services(), ACE_Log_Msg::log(), ACE_Log_Msg::log_hexdump(), ACE_Get_Opt::long_option_i(), ACE_Function_Node::make_func_name(), ACE_Registry::make_name(), ACE_Log_Record::msg_data_len(), ACE_Log_Msg_NT_Event_Log::open(), ACE_Configuration_Heap::open(), ACE_SOCK_Dgram_Mcast::open_i(), operator+(), ACE_String_Base< CHAR >::operator+=(), operator<<(), ACE_String_Base< CHAR >::operator==(), operator>>(), ACE_Log_Record::print(), ACE_Remote_Name_Space::rebind(), ACE_SString::rep(), ACE_Local_Name_Space<, ACE_LOCK >::resolve_i(), ACE_Log_Record::round_up(), scandir_emulation(), ACE_String_Base< CHAR >::set(), ACE_SPIPE_Addr::set(), ACE_DEV_Addr::set(), ACE_Local_Name_Space<, ACE_LOCK >::shared_bind_i(), ACE_Process::spawn(), ACE_Ini_ImpExp::squish(), strnstr(), strrchr_emulation(), ACE::strsplit_r(), strtok_r_emulation(), tempnam(), wcsrchr_emulation(), wcsstr_emulation(), ACE_OutputCDR::write_string(), ACE_SizeCDR::write_string(), ACE_OutputCDR::write_wstring(), and ACE_SizeCDR::write_wstring().

00200 {
00201   return ::strlen (s);
00202 }

ACE_NAMESPACE_INLINE_FUNCTION int strncasecmp const wchar_t *  s,
const wchar_t *  t,
size_t  len
 

Compares two arrays (case insensitive const wchar_t version).

ACE_INLINE int ACE_OS::strncasecmp const char *  s,
const char *  t,
size_t  len
 

Compares two arrays (case insensitive const char version).

Definition at line 36 of file OS_NS_strings.inl.

References strncasecmp_emulation().

Referenced by ACE_Arg_Shifter_T< CHAR_TYPE >::cur_arg_strncasecmp().

00037 {
00038 #if defined (ACE_LACKS_STRCASECMP)
00039   return ACE_OS::strncasecmp_emulation (s, t, len);
00040 #elif defined (ACE_STRNCASECMP_EQUIVALENT)
00041   return ACE_STRNCASECMP_EQUIVALENT (s, t, len);
00042 #else /* ACE_LACKS_STRCASECMP */
00043   return ::strncasecmp (s, t, len);
00044 #endif /* ACE_LACKS_STRCASECMP */
00045 }

int ACE_OS::strncasecmp_emulation const char *  s,
const char *  t,
size_t  len
 

Emulated strncasecmp - Performs a case insensitvie comparison of arrays.

Definition at line 49 of file OS_NS_strings.cpp.

References ace_tolower().

Referenced by strncasecmp().

00052 {
00053   const char *scan1 = s;
00054   const char *scan2 = t;
00055   size_t count = 0;
00056 
00057   while (count++ < len
00058          && *scan1 != 0
00059          && ACE_OS::ace_tolower (*scan1)
00060             == ACE_OS::ace_tolower (*scan2))
00061     {
00062       ++scan1;
00063       ++scan2;
00064     }
00065 
00066   if (count > len)
00067     return 0;
00068 
00069   // The following case analysis is necessary so that characters which
00070   // look negative collate low against normal characters but high
00071   // against the end-of-string NUL.
00072 
00073   if (*scan1 == '\0' && *scan2 == '\0')
00074     return 0;
00075   else if (*scan1 == '\0')
00076     return -1;
00077   else if (*scan2 == '\0')
00078     return 1;
00079   else
00080     return ACE_OS::ace_tolower (*scan1) - ACE_OS::ace_tolower (*scan2);
00081 }

ACE_INLINE ACE_WCHAR_T * ACE_OS::strncat ACE_WCHAR_T *  s,
const ACE_WCHAR_T *  t,
size_t  len
 

Appends part of a string to another string (wchar_t version).

Definition at line 221 of file OS_NS_string.inl.

References wcsncat_emulation().

00222 {
00223 #  if !defined (ACE_HAS_WCHAR) || defined (ACE_LACKS_WCSNCAT)
00224   return ACE_OS::wcsncat_emulation (s, t, len);
00225 #  else /* !ACE_HAS_WCHAR || ACE_LACKS_WCSNCAT */
00226   return ::wcsncat (s, t, len);
00227 #  endif /* !ACE_HAS_WCHAR || ACE_LACKS_WCSNCAT */
00228 }

ACE_INLINE char * ACE_OS::strncat char *  s,
const char *  t,
size_t  len
 

Appends part of a string to another string (char version).

Definition at line 215 of file OS_NS_string.inl.

Referenced by ACE_Local_Name_Space<, ACE_LOCK >::create_manager_i(), ACE_Log_Msg_NT_Event_Log::open(), and strsncpy().

00216 {
00217   return ::strncat (s, t, len);
00218 }

ACE_INLINE ACE_WCHAR_T * ACE_OS::strnchr ACE_WCHAR_T *  s,
ACE_WCHAR_T  c,
size_t  len
 

Finds the first occurance of a character in an array (ACE_WCHAR_T version).

Definition at line 239 of file OS_NS_string.inl.

References strnchr().

00240 {
00241   return
00242     const_cast<ACE_WCHAR_T *> (ACE_OS::strnchr (
00243                                  const_cast<const ACE_WCHAR_T *> (s),
00244                                  c,
00245                                  len));
00246 }

ACE_INLINE char * ACE_OS::strnchr char *  s,
int  c,
size_t  len
 

Finds the first occurance of a character in an array (char version).

Definition at line 231 of file OS_NS_string.inl.

References strnchr().

00232 {
00233   return const_cast<char *> (ACE_OS::strnchr (static_cast<const char *> (s),
00234                                               c,
00235                                               len));
00236 }

const ACE_WCHAR_T * ACE_OS::strnchr const ACE_WCHAR_T *  s,
ACE_WCHAR_T  c,
size_t  len
 

Finds the first occurance of a character in an array (const ACE_WCHAR_T version).

Definition at line 162 of file OS_NS_string.cpp.

00163 {
00164   for (size_t i = 0; i < len; ++i)
00165     if (s[i] == c)
00166       return s + i;
00167 
00168   return 0;
00169 }

const char * ACE_OS::strnchr const char *  s,
int  c,
size_t  len
 

Finds the first occurance of a character in an array (const char version).

Definition at line 152 of file OS_NS_string.cpp.

Referenced by ACE_String_Base< CHAR >::find(), and strnchr().

00153 {
00154   for (size_t i = 0; i < len; ++i)
00155     if (s[i] == c)
00156       return s + i;
00157 
00158   return 0;
00159 }

ACE_INLINE int ACE_OS::strncmp const ACE_WCHAR_T *  s,
const ACE_WCHAR_T *  t,
size_t  len
 

Compares two arrays (wchar_t version).

Definition at line 255 of file OS_NS_string.inl.

References wcsncmp_emulation().

00256 {
00257 #  if !defined (ACE_HAS_WCHAR) || defined (ACE_LACKS_WCSNCMP)
00258   return ACE_OS::wcsncmp_emulation (s, t, len);
00259 #  else /* !ACE_HAS_WCHAR || ACE_LACKS_WCSNCMP */
00260   return ::wcsncmp (s, t, len);
00261 #  endif /* !ACE_HAS_WCHAR || ACE_LACKS_WCSNCMP */
00262 }

ACE_INLINE int ACE_OS::strncmp const char *  s,
const char *  t,
size_t  len
 

Compares two arrays (char version).

Definition at line 249 of file OS_NS_string.inl.

Referenced by ACE_Registry_ImpExp::import_config(), ACE_Get_Opt::long_option_i(), ACE_Function_Node::make_func_name(), ACE_UNIX_Addr::operator==(), ACE_SPIPE_Addr::set(), and wcsstr_emulation().

00250 {
00251   return ::strncmp (s, t, len);
00252 }

ACE_INLINE ACE_WCHAR_T * ACE_OS::strncpy ACE_WCHAR_T *  s,
const ACE_WCHAR_T *  t,
size_t  len
 

Copies an array (ACE_WCHAR_T version).

Definition at line 271 of file OS_NS_string.inl.

References wcsncpy_emulation().

00272 {
00273 #  if !defined (ACE_HAS_WCHAR) || defined (ACE_LACKS_WCSNCPY)
00274   return ACE_OS::wcsncpy_emulation (s, t, len);
00275 #  else /* !ACE_HAS_WCHAR || ACE_LACKS_WCSNCPY */
00276   return ::wcsncpy (s, t, len);
00277 #  endif /* !ACE_HAS_WCHAR || ACE_LACKS_WCSNCPY */
00278 }

ACE_INLINE char * ACE_OS::strncpy char *  s,
const char *  t,
size_t  len
 

Copies an array (char version).

Definition at line 265 of file OS_NS_string.inl.

Referenced by dlerror(), event_init(), ACE_DLL_Handle::open(), ACE_Svc_Conf_Lexer::scan(), and strerror().

00266 {
00267   return ::strncpy (s, t, len);
00268 }

ACE_INLINE size_t ACE_OS::strnlen const ACE_WCHAR_T *  s,
size_t  maxlen
 

Finds the length of a limited-length string (ACE_WCHAR_T version).

Parameters:
s The character string to find the length of.
maxlen The maximum number of characters that will be scanned for the terminating nul character.
Returns:
The length of
  • s, if the terminating nul character is located, else
  • maxlen.

Definition at line 295 of file OS_NS_string.inl.

00296 {
00297 #if defined (ACE_HAS_WCHAR) && defined (ACE_HAS_WCSNLEN)
00298   return wcsnlen (s, maxlen);
00299 #else /* ACE_HAS_WCSNLEN */
00300   size_t i;
00301   for (i = 0; i < maxlen; ++i)
00302     if (s[i] == '\0')
00303       break;
00304   return i;
00305 #endif /* ACE_HAS_WCSNLEN */
00306 }

ACE_INLINE size_t ACE_OS::strnlen const char *  s,
size_t  maxlen
 

Finds the length of a limited-length string (char version).

Parameters:
s The character string to find the length of.
maxlen The maximum number of characters that will be scanned for the terminating nul character.
Returns:
The length of
  • s, if the terminating nul character is located, else
  • maxlen.

Definition at line 281 of file OS_NS_string.inl.

00282 {
00283 #if defined (ACE_HAS_STRNLEN)
00284   return ::strnlen (s, maxlen);
00285 #else /* ACE_HAS_STRNLEN */
00286   size_t i;
00287   for (i = 0; i < maxlen; ++i)
00288     if (s[i] == '\0')
00289       break;
00290   return i;
00291 #endif /* ACE_HAS_STRNLEN */
00292 }

ACE_INLINE ACE_WCHAR_T * ACE_OS::strnstr ACE_WCHAR_T *  s,
const ACE_WCHAR_T *  t,
size_t  len
 

Finds the first occurance of a substring in an array (wchar_t version).

Definition at line 315 of file OS_NS_string.inl.

References strnstr().

00316 {
00317   return
00318     const_cast<ACE_WCHAR_T *> (ACE_OS::strnstr (
00319                                  static_cast<const ACE_WCHAR_T *> (s),
00320                                  t,
00321                                  len));
00322 }

ACE_INLINE char * ACE_OS::strnstr char *  s,
const char *  t,
size_t  len
 

Finds the first occurance of a substring in an array (char version).

Definition at line 309 of file OS_NS_string.inl.

References strnstr().

00310 {
00311   return (char *) ACE_OS::strnstr ((const char *) s, t, len);
00312 }

const ACE_WCHAR_T * ACE_OS::strnstr const ACE_WCHAR_T *  s,
const ACE_WCHAR_T *  t,
size_t  len
 

Finds the first occurance of a substring in an array (const wchar_t version).

Definition at line 195 of file OS_NS_string.cpp.

References ACE_WCHAR_T, memcmp(), and strlen().

00196 {
00197   // Substring length
00198   const size_t len1 = ACE_OS::strlen (s1);
00199 
00200   // Check if the substring is longer than the string being searched.
00201   if (len2 > len1)
00202     return 0;
00203 
00204   // Go upto <len>
00205   const size_t len = len1 - len2;
00206 
00207   for (size_t i = 0; i <= len; i++)
00208     {
00209       if (ACE_OS::memcmp (s1 + i, s2, len2 * sizeof (ACE_WCHAR_T)) == 0)
00210         // Found a match!  Return the index.
00211         return s1 + i;
00212     }
00213 
00214   return 0;
00215 }

const char * ACE_OS::strnstr const char *  s,
const char *  t,
size_t  len
 

Finds the first occurance of a substring in an array (const char version).

Definition at line 172 of file OS_NS_string.cpp.

References memcmp(), and strlen().

Referenced by ACE_String_Base< CHAR >::find(), and strnstr().

00173 {
00174   // Substring length
00175   const size_t len1 = ACE_OS::strlen (s1);
00176 
00177   // Check if the substring is longer than the string being searched.
00178   if (len2 > len1)
00179     return 0;
00180 
00181   // Go upto <len>
00182   const size_t len = len1 - len2;
00183 
00184   for (size_t i = 0; i <= len; i++)
00185     {
00186       if (ACE_OS::memcmp (s1 + i, s2, len2) == 0)
00187         // Found a match!  Return the index.
00188         return s1 + i;
00189     }
00190 
00191   return 0;
00192 }

ACE_INLINE wchar_t * ACE_OS::strpbrk wchar_t *  s1,
const wchar_t *  s2
 

Searches for characters in a string (wchar_t version).

Definition at line 358 of file OS_NS_string.inl.

References strpbrk().

00359 {
00360   return const_cast<wchar_t *> (ACE_OS::strpbrk (
00361                                   const_cast<const wchar_t *> (s), t));
00362 }

ACE_INLINE char * ACE_OS::strpbrk char *  s1,
const char *  s2
 

Searches for characters in a string (char version).

Definition at line 347 of file OS_NS_string.inl.

00348 {
00349 #if defined (ACE_LACKS_STRPBRK)
00350   return ACE_OS::strpbrk_emulation (s1, s2);
00351 #else /* ACE_LACKS_STRPBRK */
00352   return ::strpbrk (s1, s2);
00353 #endif /* ACE_LACKS_STRPBRK */
00354 }

ACE_INLINE const wchar_t * ACE_OS::strpbrk const wchar_t *  s1,
const wchar_t *  s2
 

Searches for characters in a string (const wchar_t version).

Definition at line 336 of file OS_NS_string.inl.

References wcspbrk_emulation().

00337 {
00338 #  if defined (ACE_LACKS_WCSPBRK)
00339   return ACE_OS::wcspbrk_emulation (s, t);
00340 #  else /* ACE_LACKS_WCSPBRK */
00341   return ::wcspbrk (s, t);
00342 #  endif /* ACE_LACKS_WCSPBRK */
00343 }

ACE_INLINE const char * ACE_OS::strpbrk const char *  s1,
const char *  s2
 

Searches for characters in a string (const char version).

Definition at line 325 of file OS_NS_string.inl.

Referenced by ACE_Registry_ImpExp::process_previous_line_format(), and strpbrk().

00326 {
00327 #if defined (ACE_LACKS_STRPBRK)
00328   return ACE_OS::strpbrk_emulation (s1, s2);
00329 #else  /* ACE_LACKS_STRPBRK */
00330   return (const char *) ::strpbrk (s1, s2);
00331 #endif /* ACE_LACKS_STRPBRK */
00332 }

ACE_INLINE char * ACE_OS::strptime const char *  buf,
const char *  format,
struct tm *  tm
 

Definition at line 417 of file OS_NS_time.inl.

References ACE_NOTSUP_RETURN.

00418 {
00419 #if defined (ACE_LACKS_STRPTIME)
00420 #  if defined (ACE_REFUSE_STRPTIME_EMULATION)
00421   ACE_UNUSED_ARG (buf);
00422   ACE_UNUSED_ARG (format);
00423   ACE_UNUSED_ARG (tm);
00424   ACE_NOTSUP_RETURN (0);
00425 #  else
00426   return ACE_OS::strptime_emulation (buf, format, tm);
00427 #  endif /* ACE_REFUSE_STRPTIME_EMULATION */
00428 #else
00429   return ::strptime (buf, format, tm);
00430 #endif /* ACE_LACKS_STRPTIME */
00431 }

ACE_INLINE wchar_t * ACE_OS::strrchr wchar_t *  s,
wchar_t  c
 

Finds the last occurance of a character in a string (wchar_t version).

Definition at line 399 of file OS_NS_string.inl.

References strrchr().

00400 {
00401   return const_cast<wchar_t *> (ACE_OS::strrchr (
00402                      const_cast<const wchar_t *> (s), c));
00403 }

ACE_INLINE char * ACE_OS::strrchr char *  s,
int  c
 

Finds the last occurance of a character in a string (char version).

Definition at line 388 of file OS_NS_string.inl.

References strrchr_emulation().

00389 {
00390 #if defined (ACE_LACKS_STRRCHR)
00391   return ACE_OS::strrchr_emulation (s, c);
00392 #else  /* ! ACE_LACKS_STRRCHR */
00393   return ::strrchr (s, c);
00394 #endif /* ! ACE_LACKS_STRRCHR */
00395 }

ACE_INLINE const wchar_t * ACE_OS::strrchr const wchar_t *  s,
wchar_t  c
 

Finds the last occurance of a character in a string (const wchar_t version).

Definition at line 377 of file OS_NS_string.inl.

References wcsrchr_emulation().

00378 {
00379 #if defined (ACE_LACKS_WCSRCHR)
00380   return ACE_OS::wcsrchr_emulation (s, c);
00381 #else /* ! ACE_LACKS_WCSRCHR */
00382   return const_cast <const wchar_t *> (::wcsrchr (s, c));
00383 #endif /* ! ACE_LACKS_WCSRCHR */
00384 }

ACE_INLINE const char * ACE_OS::strrchr const char *  s,
int  c
 

Finds the last occurance of a character in a string (const char version).

Definition at line 366 of file OS_NS_string.inl.

References strrchr_emulation().

Referenced by ACE_SDM_helpers::addr_to_string(), ACE::basename(), ACE::dirname(), ACE::execname(), ACE_Ini_ImpExp::import_config(), ACE_Registry_ImpExp::import_config(), ACE::ldfind(), sema_init(), ACE_INET_Addr::string_to_addr(), and strrchr().

00367 {
00368 #if defined (ACE_LACKS_STRRCHR)
00369   return ACE_OS::strrchr_emulation (s, c);
00370 #else  /* ! ACE_LACKS_STRRCHR */
00371   return (const char *) ::strrchr (s, c);
00372 #endif /* ! ACE_LACKS_STRRCHR */
00373 }

const char * ACE_OS::strrchr_emulation const char *  s,
int  c
 

Emulated strrchr (const char version) - Finds the last occurance of a character in a string.

Definition at line 283 of file OS_NS_string.cpp.

References strlen().

00284 {
00285   const char *p = s + ACE_OS::strlen (s);
00286 
00287   while (*p != c)
00288     if (p == s)
00289       return 0;
00290     else
00291       --p;
00292 
00293   return p;
00294 }

char * ACE_OS::strrchr_emulation char *  s,
int  c
 

Emulated strrchr (char version) - Finds the last occurance of a character in a string.

Definition at line 269 of file OS_NS_string.cpp.

References strlen().

Referenced by strrchr().

00270 {
00271   char *p = s + ACE_OS::strlen (s);
00272 
00273   while (*p != c)
00274     if (p == s)
00275       return 0;
00276     else
00277       --p;
00278 
00279   return p;
00280 }

ACE_WCHAR_T * ACE_OS::strsncpy ACE_WCHAR_T *  dst,
const ACE_WCHAR_T *  src,
size_t  maxlen
 

This is a "safe" c string copy function (wchar_t version).

Unlike strncpy() this function will always add a terminating '' char if maxlen > 0. So the user doesn't has to provide an extra '' if the user wants a '' terminated dst. The function doesn't check for a 0 dst, because this will give problems anyway. When src is 0 an empty string is made. We do not "touch" * dst if maxlen is 0. Returns dst. Care should be taken when replacing strncpy() calls, because in some cases a strncpy() user is using the "not '\0' terminating" feature from strncpy(). This happens most when the call to strncpy() was optimized by using a maxlen which is 1 smaller than the size because there's always written a '' inside this last position. Very seldom it's possible that the '' padding feature from strncpy() is needed.

Definition at line 322 of file OS_NS_string.cpp.

References ACE_TEXT_WIDE, ACE_WCHAR_T, and strncat().

00323 {
00324   register ACE_WCHAR_T *rdst = dst;
00325   register const ACE_WCHAR_T *rsrc = src;
00326   register size_t rmaxlen = maxlen;
00327 
00328   if (rmaxlen > 0)
00329     {
00330       if (rdst!=rsrc)
00331         {
00332           *rdst = ACE_TEXT_WIDE ('\0');
00333           if (rsrc != 0)
00334             strncat (rdst, rsrc, --rmaxlen);
00335         }
00336       else
00337         {
00338           rdst += (rmaxlen - 1);
00339           *rdst = ACE_TEXT_WIDE ('\0');
00340         }
00341     }
00342   return dst;
00343 }

char * ACE_OS::strsncpy char *  dst,
const char *  src,
size_t  maxlen
 

This is a "safe" c string copy function (char version).

Unlike strncpy() this function will always add a terminating '' char if maxlen > 0. So the user doesn't has to provide an extra '' if the user wants a '' terminated dst. The function doesn't check for a 0 dst, because this will give problems anyway. When src is 0 an empty string is made. We do not "touch" * dst if maxlen is 0. Returns dst. Care should be taken when replacing strncpy() calls, because in some cases a strncpy() user is using the "not '\0' terminating" feature from strncpy(). This happens most when the call to strncpy() was optimized by using a maxlen which is 1 smaller than the size because there's always written a '' inside this last position. Very seldom it's possible that the '' padding feature from strncpy() is needed.

Definition at line 298 of file OS_NS_string.cpp.

References strncat().

Referenced by ACE_MMAP_Memory_Pool::ACE_MMAP_Memory_Pool(), ACE_Mutex_Token::ACE_Mutex_Token(), ACE_Pagefile_Memory_Pool::ACE_Pagefile_Memory_Pool(), ACE_RW_Token::ACE_RW_Token(), ACE_System_Time::ACE_System_Time(), ACE_Token_Collection::ACE_Token_Collection(), ACE_UNIX_Addr::addr_to_string(), ACE_SPIPE_Addr::addr_to_string(), ACE_FILE_Addr::addr_to_string(), ACE_DEV_Addr::addr_to_string(), asctime_r(), ACE_TPQ_Entry::client_id(), ACE_Local_Name_Space<, ACE_LOCK >::create_manager_i(), ctime_r(), ACE::dirname(), ACE_Log_Msg::file(), ACE_INET_Addr::get_host_addr(), getcwd(), ACE_Thru_Task<>::info(), ACE_Stream_Tail<>::info(), ACE_Stream_Head<>::info(), ACE_Stream_Type::info(), ACE_Module_Type::info(), ACE_Service_Manager::info(), ACE_Naming_Context::info(), ACE_Connector< SVC_HANDLER, ACE_PEER_CONNECTOR_2 >::info(), ACE_Oneshot_Acceptor< SVC_HANDLER, >::info(), ACE_Strategy_Acceptor< SVC_HANDLER, >::info(), ACE_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_2 >::info(), ACE_Log_Msg::log(), ACE_Log_Msg::msg(), ACE_Log_Record::msg_data(), ACE_Mem_Map::open(), ACE_FIFO::open(), ACE_String_Base< CHAR >::rep(), ACE_Local_Name_Space<, ACE_LOCK >::resolve_i(), ACE_UNIX_Addr::set(), ACE_SPIPE_Addr::set(), ACE_FILE_Addr::set(), ACE_DEV_Addr::set(), ACE_UNIX_Addr::string_to_addr(), ACE::strndup(), ACE::strnnew(), thr_create(), ACE::timestamp(), ACE_Name_Request::type(), and unique_name().

00299 {
00300   register char *rdst = dst;
00301   register const char *rsrc = src;
00302   register size_t rmaxlen = maxlen;
00303 
00304   if (rmaxlen > 0)
00305     {
00306       if (rdst!=rsrc)
00307         {
00308           *rdst = '\0';
00309           if (rsrc != 0)
00310             strncat (rdst, rsrc, --rmaxlen);
00311         }
00312       else
00313         {
00314           rdst += (rmaxlen - 1);
00315           *rdst = '\0';
00316         }
00317     }
00318   return dst;
00319 }

ACE_INLINE size_t ACE_OS::strspn const wchar_t *  s1,
const wchar_t *  s2
 

Searches for the first substring containing only the specified characters and returns the size of the substring (wchar_t version).

Definition at line 418 of file OS_NS_string.inl.

References wcsspn_emulation().

00419 {
00420 #  if defined (ACE_LACKS_WCSSPN)
00421   return ACE_OS::wcsspn_emulation (s, t);
00422 #  else /* ACE_LACKS_WCSSPN */
00423   return ::wcsspn (s, t);
00424 #  endif /* ACE_LACKS_WCSSPN */
00425 }

ACE_INLINE size_t ACE_OS::strspn const char *  s1,
const char *  s2
 

Searches for the first substring containing only the specified characters and returns the size of the substring (char version).

Definition at line 407 of file OS_NS_string.inl.

00408 {
00409 #if defined (ACE_LACKS_STRSPN)
00410   return ACE_OS::strspn_emulation (s, t);
00411 #else /* ACE_LACKS_STRSPN */
00412   return ::strspn (s, t);
00413 #endif /* ACE_LACKS_STRSPN */
00414 }

ACE_INLINE wchar_t * ACE_OS::strstr wchar_t *  s,
const wchar_t *  t
 

Finds the first occurance of a substring in a string (wchar_t version).

Definition at line 456 of file OS_NS_string.inl.

References wcsstr_emulation().

00457 {
00458 #  if defined (ACE_LACKS_WCSSTR)
00459   return ACE_OS::wcsstr_emulation (s, t);
00460 #  elif defined (HPUX)
00461   return ::wcswcs (s, t);
00462 #  else /* ACE_LACKS_WCSSTR */
00463   return ::wcsstr (s, t);
00464 #  endif /* ACE_LACKS_WCSSTR */
00465 }

ACE_INLINE char * ACE_OS::strstr char *  s,
const char *  t
 

Finds the first occurance of a substring in a string (char version).

Definition at line 449 of file OS_NS_string.inl.

00450 {
00451   return ::strstr (s, t);
00452 }

ACE_INLINE const wchar_t * ACE_OS::strstr const wchar_t *  s,
const wchar_t *  t
 

Finds the first occurance of a substring in a string (const wchar_t version).

Definition at line 436 of file OS_NS_string.inl.

References wcsstr_emulation().

00437 {
00438 #  if defined (ACE_LACKS_WCSSTR)
00439   return ACE_OS::wcsstr_emulation (s, t);
00440 #  elif defined (HPUX)
00441   return const_cast <const wchar_t *> (::wcswcs (s, t));
00442 #  else /* ACE_LACKS_WCSSTR */
00443   return const_cast <const wchar_t *> (::wcsstr (s, t));
00444 #  endif /* ACE_LACKS_WCSSTR */
00445 }

ACE_INLINE const char * ACE_OS::strstr const char *  s,
const char *  t
 

Finds the first occurance of a substring in a string (const char version).

Definition at line 429 of file OS_NS_string.inl.

Referenced by ACE_SString::find(), ACE_ATM_Stream::get_peer_name(), ACE_Local_Name_Space<, ACE_LOCK >::list_type_entries_i(), ACE_Local_Name_Space<, ACE_LOCK >::list_types_i(), and ACE::strsplit_r().

00430 {
00431   return (const char *) ::strstr (s, t);
00432 }

ACE_INLINE double ACE_OS::strtod const wchar_t *  s,
wchar_t **  endptr
 

Converts a string to a double value (wchar_t version).

Definition at line 449 of file OS_NS_stdlib.inl.

00450 {
00451   return ACE_WCHAR_STD_NAMESPACE::wcstod (s, endptr);
00452 }

ACE_INLINE double ACE_OS::strtod const char *  s,
char **  endptr
 

Converts a string to a double value (char version).

Definition at line 441 of file OS_NS_stdlib.inl.

Referenced by ACE_Convert().

00442 {
00443   return ::strtod (s, endptr);
00444 }

ACE_INLINE wchar_t * ACE_OS::strtok wchar_t *  s,
const wchar_t *  tokens
 

Finds the next token in a string (wchar_t version).

Definition at line 476 of file OS_NS_string.inl.

00477 {
00478 #if defined (ACE_HAS_3_PARAM_WCSTOK)
00479   static wchar_t *lasts;
00480   return ::wcstok (s, tokens, &lasts);
00481 #else
00482   return ::wcstok (s, tokens);
00483 #endif /* ACE_HAS_3_PARAM_WCSTOK */
00484 }

ACE_INLINE char * ACE_OS::strtok char *  s,
const char *  tokens
 

Finds the next token in a string (char version).

Definition at line 469 of file OS_NS_string.inl.

00470 {
00471   return ::strtok (s, tokens);
00472 }

ACE_INLINE wchar_t * ACE_OS::strtok_r ACE_WCHAR_T *  s,
const ACE_WCHAR_T *  tokens,
ACE_WCHAR_T **  lasts
 

Finds the next token in a string (wchar_t version).

Definition at line 499 of file OS_NS_string.inl.

References strtok_r_emulation().

00500 {
00501 #if defined (ACE_LACKS_WCSTOK)
00502     return ACE_OS::strtok_r_emulation (s, tokens, lasts);
00503 #else
00504 #  if defined (ACE_HAS_3_PARAM_WCSTOK)
00505     return ::wcstok (s, tokens, lasts);
00506 #  else /* ACE_HAS_3_PARAM_WCSTOK */
00507     *lasts = ::wcstok (s, tokens);
00508     return *lasts;
00509 #  endif /* ACE_HAS_3_PARAM_WCSTOK */
00510 #endif  /* ACE_LACKS_WCSTOK */
00511 }

ACE_INLINE char * ACE_OS::strtok_r char *  s,
const char *  tokens,
char **  lasts
 

Finds the next token in a string (safe char version).

Definition at line 488 of file OS_NS_string.inl.

References strtok_r_emulation().

Referenced by ACE_ATM_Stream::get_peer_name(), ACE_Log_Msg_UNIX_Syslog::log(), ACE_Logging_Strategy::priorities(), and ACE_Logging_Strategy::tokenize().

00489 {
00490 #if defined (ACE_HAS_REENTRANT_FUNCTIONS)
00491   return ::strtok_r (s, tokens, lasts);
00492 #else
00493   return ACE_OS::strtok_r_emulation (s, tokens, lasts);
00494 #endif /* (ACE_HAS_REENTRANT_FUNCTIONS) */
00495 }

char * ACE_OS::strtok_r_emulation char *  s,
const char *  tokens,
char **  lasts
 

Emulated strtok_r.

Definition at line 366 of file OS_NS_string.cpp.

References strlen().

Referenced by strtok_r().

00367 {
00368   if (s == 0)
00369     s = *lasts;
00370   else
00371     *lasts = s;
00372   if (*s == 0)                  // We have reached the end
00373     return 0;
00374   size_t l_org = ACE_OS::strlen (s);
00375   s = ::strtok (s, tokens);
00376   if (s == 0)
00377     return 0;
00378   const size_t l_sub = ACE_OS::strlen (s);
00379   if (s + l_sub < *lasts + l_org)
00380     *lasts = s + l_sub + 1;
00381   else
00382     *lasts = s + l_sub;
00383   return s ;
00384 }

ACE_INLINE long ACE_OS::strtol const wchar_t *  s,
wchar_t **  ptr,
int  base
 

Converts a string to a long value (wchar_t version).

Definition at line 467 of file OS_NS_stdlib.inl.

00468 {
00469   return ACE_WCHAR_STD_NAMESPACE::wcstol (s, ptr, base);
00470 }

ACE_INLINE long ACE_OS::strtol const char *  s,
char **  ptr,
int  base
 

Converts a string to a long value (char version).

Definition at line 456 of file OS_NS_stdlib.inl.

Referenced by ACE_Convert(), get_port_number_from_name(), and ACE_INET_Addr::string_to_addr().

00457 {
00458 #if defined (ACE_LACKS_STRTOL)
00459   return ACE_OS::strtol_emulation (s, ptr, base);
00460 #else  /* ACE_LACKS_STRTOL */
00461   return ::strtol (s, ptr, base);
00462 #endif /* ACE_LACKS_STRTOL */
00463 }

ACE_INLINE unsigned long ACE_OS::strtoul const wchar_t *  s,
wchar_t **  ptr,
int  base
 

Converts a string to an unsigned long value (wchar_t version).

Definition at line 485 of file OS_NS_stdlib.inl.

00486 {
00487   return ACE_WCHAR_STD_NAMESPACE::wcstoul (s, ptr, base);
00488 }

ACE_INLINE unsigned long ACE_OS::strtoul const char *  s,
char **  ptr,
int  base
 

Converts a string to an unsigned long value (char version).

Definition at line 474 of file OS_NS_stdlib.inl.

Referenced by ACE_Convert(), ACE_MEM_Addr::ACE_MEM_Addr(), ACE_Registry_ImpExp::import_config(), ACE_Logging_Strategy::parse_args(), and ACE_MEM_Addr::string_to_addr().

00475 {
00476 #if defined (ACE_LACKS_STRTOUL)
00477   return ACE_OS::strtoul_emulation (s, ptr, base);
00478 #else /* ACE_LACKS_STRTOUL */
00479   return ::strtoul (s, ptr, base);
00480 #endif /* ACE_LACKS_STRTOUL */
00481 }

ACE_INLINE void ACE_OS::swab const void *  src,
void *  dest,
ssize_t  n
 

Definition at line 921 of file OS_NS_unistd.inl.

References ssize_t.

00924 {
00925 #if defined (ACE_LACKS_SWAB)
00926   const char *from = static_cast<const char*> (src);
00927   char *to = static_cast<char *> (dest);
00928   ssize_t ptr = 0;
00929   for (ptr = 1; ptr < length; ptr += 2)
00930     {
00931       char p = from[ptr];
00932       char q = from[ptr-1];
00933       to[ptr-1] = p;
00934       to[ptr  ] = q;
00935     }
00936   if (ptr == length) /* I.e., if length is odd, */
00937     to[ptr-1] = 0;   /* then pad with a NUL. */
00938 #elif defined (ACE_HAS_NONCONST_SWAB)
00939   const char *tmp = static_cast<const char*> (src);
00940   char *from = const_cast<char *> (tmp);
00941   char *to = static_cast<char *> (dest);
00942   ::swab (from, to, length);
00943 #elif defined (ACE_HAS_CONST_CHAR_SWAB)
00944   const char *from = static_cast<const char*> (src);
00945   char *to = static_cast<char *> (dest);
00946   ::swab (from, to, length);
00947 #else
00948   ::swab (src, dest, length);
00949 #endif /* ACE_LACKS_SWAB */
00950 
00951 }

ACE_INLINE long ACE_OS::sysconf int   ) 
 

Definition at line 954 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and sysconf().

Referenced by ACE_POSIX_AIOCB_Proactor::check_max_aio_num(), ACE::max_handles(), sysconf(), and thr_min_stack().

00955 {
00956   ACE_OS_TRACE ("ACE_OS::sysconf");
00957 #if defined (ACE_LACKS_SYSCONF)
00958   ACE_UNUSED_ARG (name);
00959   ACE_NOTSUP_RETURN (-1);
00960 #else
00961   ACE_OSCALL_RETURN (::sysconf (name), long, -1);
00962 #endif /* ACE_LACKS_SYSCONF */
00963 }

ACE_INLINE long ACE_OS::sysinfo int  cmd,
char *  buf,
long  count
 

Definition at line 966 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and sysinfo().

Referenced by ACE_POSIX_Proactor::ACE_POSIX_Proactor(), and sysinfo().

00967 {
00968   ACE_OS_TRACE ("ACE_OS::sysinfo");
00969 #if defined (ACE_HAS_SYSINFO)
00970   ACE_OSCALL_RETURN (::sysinfo (cmd, buf, count), long, -1);
00971 #else
00972   ACE_UNUSED_ARG (cmd);
00973   ACE_UNUSED_ARG (buf);
00974   ACE_UNUSED_ARG (count);
00975 
00976   ACE_NOTSUP_RETURN (0);
00977 #endif /* ACE_HAS_SYSINFO */
00978 }

ACE_INLINE int ACE_OS::system const ACE_TCHAR s  ) 
 

Definition at line 492 of file OS_NS_stdlib.inl.

References ACE_NOTSUP_RETURN, ACE_TCHAR, ACE_TEXT_ALWAYS_CHAR, and system().

Referenced by system().

00493 {
00494   // ACE_OS_TRACE ("ACE_OS::system");
00495 #if defined (ACE_LACKS_SYSTEM)
00496   ACE_UNUSED_ARG (s);
00497   ACE_NOTSUP_RETURN (-1);
00498 #elif defined (ACE_WIN32) && defined (ACE_USES_WCHAR)
00499   ACE_OSCALL_RETURN (::_wsystem (s), int, -1);
00500 #elif defined(ACE_TANDEM_T1248_PTHREADS)
00501   ACE_OSCALL_RETURN (::spt_system (s), int, -1);
00502 #else
00503   ACE_OSCALL_RETURN (::system (ACE_TEXT_ALWAYS_CHAR (s)), int, -1);
00504 #endif /* ACE_LACKS_SYSTEM */
00505 }

ACE_INLINE int ACE_OS::t_accept ACE_HANDLE  fildes,
ACE_HANDLE  resfd,
struct t_call *  call
 

Definition at line 12 of file OS_TLI.inl.

References ACE_NOTSUP_RETURN, and t_accept().

Referenced by ACE_TLI_Acceptor::accept().

00013 {
00014 #if defined (ACE_HAS_TLI)
00015   ACE_OSCALL_RETURN (::t_accept (handle, reshandle, call), int, -1);
00016 #else
00017   ACE_UNUSED_ARG (call);
00018   ACE_UNUSED_ARG (reshandle);
00019   ACE_UNUSED_ARG (handle);
00020 
00021   ACE_NOTSUP_RETURN (-1);
00022 #endif /* ACE_HAS_TLI */
00023 }

ACE_INLINE char * ACE_OS::t_alloc ACE_HANDLE  fildes,
int  struct_type,
int  fields
 

Definition at line 26 of file OS_TLI.inl.

References ACE_NOTSUP_RETURN, and t_alloc().

Referenced by ACE_TLI_Connector::connect(), ACE_TLI_Acceptor::open(), and ACE_TLI_Request_Queue::open().

00027 {
00028 #if defined (ACE_HAS_TLI)
00029 #  if (defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) >= 500)
00030   // XPG5 changes t_alloc() return from char* to void*, so ACE_OSCALL_RETURN
00031   // doesn't compile correctly.
00032   char *result;
00033   ACE_OSCALL (::t_alloc (handle, struct_type, fields), char *, 0, result);
00034   return result;
00035 #  else
00036   ACE_OSCALL_RETURN (::t_alloc (handle, struct_type, fields),
00037                      char *, 0);
00038 #  endif /* XPG4 vs XPG5 */
00039 #else
00040   ACE_UNUSED_ARG (fields);
00041   ACE_UNUSED_ARG (struct_type);
00042   ACE_UNUSED_ARG (handle);
00043 
00044   ACE_NOTSUP_RETURN (0);
00045 #endif /* ACE_HAS_TLI */
00046 }

ACE_INLINE int ACE_OS::t_bind ACE_HANDLE  fildes,
struct t_bind *  req,
struct t_bind *  ret
 

Definition at line 49 of file OS_TLI.inl.

References ACE_NOTSUP_RETURN, and t_bind().

Referenced by ACE_TLI_Connector::connect(), ACE_TLI_Acceptor::open(), and open_new_endpoint().

00050 {
00051 #if defined (ACE_HAS_TLI)
00052   ACE_OSCALL_RETURN (::t_bind (handle, req, ret), int, -1);
00053 #else
00054   ACE_UNUSED_ARG (ret);
00055   ACE_UNUSED_ARG (req);
00056   ACE_UNUSED_ARG (handle);
00057 
00058   ACE_NOTSUP_RETURN (-1);
00059 #endif /* ACE_HAS_TLI */
00060 }

ACE_INLINE int ACE_OS::t_close ACE_HANDLE  fildes  ) 
 

Definition at line 63 of file OS_TLI.inl.

References ACE_NOTSUP_RETURN, and t_close().

Referenced by ACE_TLI_Acceptor::accept(), ACE_TLI_Stream::close(), ACE_TLI::close(), and ACE_TLI_Request_Queue::remove().

00064 {
00065 #if defined (ACE_HAS_TLI)
00066   ACE_OSCALL_RETURN (::t_close (handle), int, -1);
00067 #else
00068   ACE_UNUSED_ARG (handle);
00069 
00070   ACE_NOTSUP_RETURN (-1);
00071 #endif /* ACE_HAS_TLI */
00072 }

ACE_INLINE int ACE_OS::t_connect ACE_HANDLE  fildes,
struct t_call *  sndcall,
struct t_call *  rcvcall
 

Definition at line 75 of file OS_TLI.inl.

References ACE_NOTSUP_RETURN, and t_connect().

Referenced by ACE_TLI_Connector::connect().

00078 {
00079 #if defined (ACE_HAS_TLI)
00080   ACE_OSCALL_RETURN (::t_connect (fildes, sndcall, rcvcall), int, -1);
00081 #else
00082   ACE_UNUSED_ARG (fildes);
00083   ACE_UNUSED_ARG (sndcall);
00084   ACE_UNUSED_ARG (rcvcall);
00085 
00086   ACE_NOTSUP_RETURN (-1);
00087 #endif /* ACE_HAS_TLI */
00088 }

ACE_INLINE void ACE_OS::t_error const char *  errmsg  ) 
 

Definition at line 91 of file OS_TLI.inl.

Referenced by ACE_ATM_QoS::construct_options(), and ACE_ATM_Stream::get_vpi_vci().

00092 {
00093 #if defined (ACE_HAS_TLI)
00094 #if defined (ACE_HAS_BROKEN_T_ERROR)
00095   ::t_error (const_cast<char *> (errmsg));
00096 #else
00097   ::t_error (errmsg);
00098 #endif /* ACE_HAS_BROKEN_T_ERROR */
00099 #else
00100   ACE_UNUSED_ARG (errmsg);
00101 #endif /* ACE_HAS_TLI */
00102 }

ACE_INLINE int ACE_OS::t_free char *  ptr,
int  struct_type
 

Definition at line 105 of file OS_TLI.inl.

References ACE_NOTSUP_RETURN, and t_free().

Referenced by ACE_TLI_Acceptor::close(), ACE_TLI_Request_Queue::close(), and ACE_TLI_Connector::connect().

00106 {
00107 #if defined (ACE_HAS_TLI)
00108   if (ptr == 0)
00109     return 0;
00110   ACE_OSCALL_RETURN (::t_free (ptr, struct_type), int, -1);
00111 #else
00112   ACE_UNUSED_ARG (struct_type);
00113   ACE_UNUSED_ARG (ptr);
00114 
00115   ACE_NOTSUP_RETURN (-1);
00116 #endif /* ACE_HAS_TLI */
00117 }

ACE_INLINE int ACE_OS::t_getinfo ACE_HANDLE  fildes,
struct t_info *  info
 

Definition at line 120 of file OS_TLI.inl.

References ACE_NOTSUP_RETURN, and t_getinfo().

Referenced by ACE_ATM_QoS::construct_options(), and ACE_ATM_Stream::get_vpi_vci().

00121 {
00122 #if defined (ACE_HAS_TLI)
00123   ACE_OSCALL_RETURN (::t_getinfo (handle, info), int, -1);
00124 #else
00125   ACE_UNUSED_ARG (info);
00126   ACE_UNUSED_ARG (handle);
00127 
00128   ACE_NOTSUP_RETURN (-1);
00129 #endif /* ACE_HAS_TLI */
00130 }

ACE_INLINE int ACE_OS::t_getname ACE_HANDLE  fildes,
struct netbuf *  namep,
int  type
 

Definition at line 133 of file OS_TLI.inl.

References ACE_NOTSUP_RETURN, last_error(), t_bind(), and t_getname().

Referenced by ACE_TLI_Connector::complete(), ACE_ATM_QoS::construct_options(), ACE_TLI::get_local_addr(), ACE_ATM_Stream::get_peer_name(), and ACE_TLI_Stream::get_remote_addr().

00134 {
00135 #if defined (ACE_HAS_XTI)
00136   struct t_bind bound, peer;
00137   // Depending on which address the caller wants, fill caller's values
00138   // into one of the t_bind netbufs. The other is set up to ignore that
00139   // address.
00140   switch (type)
00141     {
00142     case LOCALNAME:
00143       bound.addr.buf = namep->buf;
00144       bound.addr.maxlen = namep->maxlen;
00145       bound.addr.len = 0;
00146       peer.addr.buf = 0;
00147       peer.addr.maxlen = 0;
00148       peer.addr.len = 0;
00149       break;
00150     case REMOTENAME:
00151       bound.addr.buf = 0;
00152       bound.addr.maxlen = 0;
00153       bound.addr.len = 0;
00154       peer.addr.buf = namep->buf;
00155       peer.addr.maxlen = namep->maxlen;
00156       peer.addr.len = 0;
00157       break;
00158     default:
00159       ACE_OS::last_error (EINVAL);
00160       return -1;
00161     }
00162   if (t_getprotaddr (handle, &bound, &peer) == -1)
00163     return -1;
00164   // Call succeeded; put the caller's desired address length in his netbuf.
00165   if (type == LOCALNAME)
00166     namep->len = bound.addr.len;
00167   else
00168     namep->len = peer.addr.len;
00169   return 0;
00170 
00171 #elif defined (ACE_HAS_SVR4_TLI)
00172   ACE_OSCALL_RETURN (::t_getname (handle, namep, type), int, -1);
00173 #else
00174   ACE_UNUSED_ARG (handle);
00175   ACE_UNUSED_ARG (namep);
00176   ACE_UNUSED_ARG (type);
00177 
00178   ACE_NOTSUP_RETURN (-1);
00179 #endif /* ACE_HAS_SVR4_TLI */
00180 }

ACE_INLINE int ACE_OS::t_getstate ACE_HANDLE  fildes  ) 
 

Definition at line 183 of file OS_TLI.inl.

References ACE_NOTSUP_RETURN, and t_getstate().

00184 {
00185 #if defined (ACE_HAS_TLI)
00186   ACE_OSCALL_RETURN (::t_getstate (handle), int, -1);
00187 #else
00188   ACE_UNUSED_ARG (handle);
00189 
00190   ACE_NOTSUP_RETURN (-1);
00191 #endif /* ACE_HAS_TLI */
00192 }

ACE_INLINE int ACE_OS::t_listen ACE_HANDLE  fildes,
struct t_call *  call
 

Definition at line 195 of file OS_TLI.inl.

References ACE_NOTSUP_RETURN, and t_listen().

Referenced by ACE_TLI_Acceptor::accept(), and ACE_TLI_Request_Queue::enqueue().

00196 {
00197 #if defined (ACE_HAS_TLI)
00198   ACE_OSCALL_RETURN (::t_listen (handle, call), int, -1);
00199 #else
00200   ACE_UNUSED_ARG (handle);
00201   ACE_UNUSED_ARG (call);
00202 
00203   ACE_NOTSUP_RETURN (-1);
00204 #endif /* ACE_HAS_TLI */
00205 }

ACE_INLINE int ACE_OS::t_look ACE_HANDLE  fildes  ) 
 

Definition at line 208 of file OS_TLI.inl.

References ACE_NOTSUP_RETURN, and t_look().

Referenced by ACE_XTI_ATM_Mcast::add_leaf(), ACE_TLI_Connector::complete(), and ACE_TLI::look().

00209 {
00210 #if defined (ACE_HAS_TLI)
00211   ACE_OSCALL_RETURN (::t_look (handle), int, -1);
00212 #else
00213   ACE_UNUSED_ARG (handle);
00214 
00215   ACE_NOTSUP_RETURN (-1);
00216 #endif /* ACE_HAS_TLI */
00217 }

ACE_INLINE ACE_HANDLE ACE_OS::t_open char *  path,
int  oflag,
struct t_info *  info
 

Definition at line 220 of file OS_TLI.inl.

References ACE_NOTSUP_RETURN, and t_open().

Referenced by open_new_endpoint().

00221 {
00222 #if defined (ACE_HAS_TLI)
00223   ACE_OSCALL_RETURN (::t_open (path, oflag, info), ACE_HANDLE, ACE_INVALID_HANDLE);
00224 #else
00225   ACE_UNUSED_ARG (path);
00226   ACE_UNUSED_ARG (oflag);
00227   ACE_UNUSED_ARG (info);
00228 
00229   ACE_NOTSUP_RETURN (ACE_INVALID_HANDLE);
00230 #endif /* ACE_HAS_TLI */
00231 }

ACE_INLINE int ACE_OS::t_optmgmt ACE_HANDLE  handle,
ACE_TOPTMGMT req,
ACE_TOPTMGMT ret
 

Definition at line 234 of file OS_TLI.inl.

References ACE_NOTSUP_RETURN, and t_optmgmt().

Referenced by ACE_TLI::get_option(), ACE_ATM_Stream::get_vpi_vci(), and ACE_TLI::set_option().

00235 {
00236 #if defined (ACE_HAS_TLI)
00237   ACE_OSCALL_RETURN (::t_optmgmt (handle, req, ret), int, -1);
00238 #else
00239   ACE_UNUSED_ARG (handle);
00240   ACE_UNUSED_ARG (req);
00241   ACE_UNUSED_ARG (ret);
00242 
00243   ACE_NOTSUP_RETURN (-1);
00244 #endif /* ACE_HAS_TLI */
00245 }

ACE_INLINE int ACE_OS::t_rcv ACE_HANDLE  fildes,
char *  buf,
unsigned int  nbytes,
int *  flags
 

Definition at line 248 of file OS_TLI.inl.

References ACE_NOTSUP_RETURN.

Referenced by ACE::t_rcv(), and ACE::t_rcv_n_i().

00252 {
00253 #if defined (ACE_HAS_TLI)
00254   ACE_OSCALL_RETURN (::t_rcv (handle, buf, nbytes, flags),
00255                      int, -1);
00256 #else
00257   ACE_UNUSED_ARG (handle);
00258   ACE_UNUSED_ARG (buf);
00259   ACE_UNUSED_ARG (nbytes);
00260   ACE_UNUSED_ARG (flags);
00261 
00262   ACE_NOTSUP_RETURN (-1);
00263 #endif /* ACE_HAS_TLI */
00264 }

ACE_INLINE int ACE_OS::t_rcvdis ACE_HANDLE  fildes,
struct t_discon *  discon
 

Definition at line 267 of file OS_TLI.inl.

References ACE_NOTSUP_RETURN, and t_rcvdis().

Referenced by ACE_TLI::rcvdis().

00268 {
00269 #if defined (ACE_HAS_TLI)
00270   ACE_OSCALL_RETURN (::t_rcvdis (handle, discon), int, -1);
00271 #else
00272   ACE_UNUSED_ARG (handle);
00273   ACE_UNUSED_ARG (discon);
00274 
00275   ACE_NOTSUP_RETURN (-1);
00276 #endif /* ACE_HAS_TLI */
00277 }

ACE_INLINE int ACE_OS::t_rcvrel ACE_HANDLE  fildes  ) 
 

Definition at line 280 of file OS_TLI.inl.

References ACE_NOTSUP_RETURN, and t_rcvrel().

Referenced by ACE_TLI::rcvrel().

00281 {
00282 #if defined (ACE_HAS_TLI)
00283   ACE_OSCALL_RETURN (::t_rcvrel (handle), int, -1);
00284 #else
00285   ACE_UNUSED_ARG (handle);
00286 
00287   ACE_NOTSUP_RETURN (-1);
00288 #endif /* ACE_HAS_TLI */
00289 }

ACE_INLINE int ACE_OS::t_rcvudata ACE_HANDLE  fildes,
struct t_unitdata *  unitdata,
int *  flags
 

Definition at line 292 of file OS_TLI.inl.

References ACE_NOTSUP_RETURN, and t_rcvudata().

00295 {
00296 #if defined (ACE_HAS_TLI)
00297   ACE_OSCALL_RETURN (::t_rcvudata (handle, unitdata, flags),
00298                      int, -1);
00299 #else
00300   ACE_UNUSED_ARG (handle);
00301   ACE_UNUSED_ARG (unitdata);
00302   ACE_UNUSED_ARG (flags);
00303 
00304   ACE_NOTSUP_RETURN (-1);
00305 #endif /* ACE_HAS_TLI */
00306 }

ACE_INLINE int ACE_OS::t_rcvuderr ACE_HANDLE  fildes,
struct t_uderr *  uderr
 

Definition at line 309 of file OS_TLI.inl.

References ACE_NOTSUP_RETURN, and t_rcvuderr().

00310 {
00311 #if defined (ACE_HAS_TLI)
00312   ACE_OSCALL_RETURN (::t_rcvuderr (handle, uderr), int, -1);
00313 #else
00314   ACE_UNUSED_ARG (handle);
00315   ACE_UNUSED_ARG (uderr);
00316 
00317   ACE_NOTSUP_RETURN (-1);
00318 #endif /* ACE_HAS_TLI */
00319 }

ACE_INLINE int ACE_OS::t_snd ACE_HANDLE  fildes,
const char *  buf,
unsigned int  nbytes,
int  flags
 

Definition at line 322 of file OS_TLI.inl.

References ACE_NOTSUP_RETURN.

Referenced by ACE::t_snd(), and ACE::t_snd_n_i().

00326 {
00327 #if defined (ACE_HAS_TLI)
00328   ACE_OSCALL_RETURN (::t_snd (handle, (char *) buf, nbytes, flags), int, -1);
00329 #else
00330   ACE_UNUSED_ARG (handle);
00331   ACE_UNUSED_ARG (buf);
00332   ACE_UNUSED_ARG (nbytes);
00333   ACE_UNUSED_ARG (flags);
00334 
00335   ACE_NOTSUP_RETURN (-1);
00336 #endif /* ACE_HAS_TLI */
00337 }

ACE_INLINE int ACE_OS::t_snddis ACE_HANDLE  fildes,
struct t_call *  call
 

Definition at line 340 of file OS_TLI.inl.

References ACE_NOTSUP_RETURN, and t_snddis().

Referenced by open_new_endpoint(), and ACE_TLI::snddis().

00341 {
00342 #if defined (ACE_HAS_TLI)
00343   ACE_OSCALL_RETURN (::t_snddis (handle, call), int, -1);
00344 #else
00345   ACE_UNUSED_ARG (handle);
00346   ACE_UNUSED_ARG (call);
00347 
00348   ACE_NOTSUP_RETURN (-1);
00349 #endif /* ACE_HAS_TLI */
00350 }

ACE_INLINE int ACE_OS::t_sndrel ACE_HANDLE  fildes  ) 
 

Definition at line 353 of file OS_TLI.inl.

References ACE_NOTSUP_RETURN, and t_sndrel().

Referenced by ACE_TLI::sndrel().

00354 {
00355 #if defined (ACE_HAS_TLI)
00356   ACE_OSCALL_RETURN (::t_sndrel (handle), int, -1);
00357 #else
00358   ACE_UNUSED_ARG (handle);
00359 
00360   ACE_NOTSUP_RETURN (-1);
00361 #endif /* ACE_HAS_TLI */
00362 }

ACE_INLINE int ACE_OS::t_sync ACE_HANDLE  fildes  ) 
 

Definition at line 365 of file OS_TLI.inl.

References ACE_NOTSUP_RETURN, and t_sync().

00366 {
00367 #if defined (ACE_HAS_TLI)
00368   ACE_OSCALL_RETURN (::t_sync (handle), int, -1);
00369 #else
00370   ACE_UNUSED_ARG (handle);
00371 
00372   ACE_NOTSUP_RETURN (-1);
00373 #endif /* ACE_HAS_TLI */
00374 }

ACE_INLINE int ACE_OS::t_unbind ACE_HANDLE  fildes  ) 
 

Definition at line 377 of file OS_TLI.inl.

References ACE_NOTSUP_RETURN, and t_unbind().

00378 {
00379 #if defined (ACE_HAS_TLI)
00380   ACE_OSCALL_RETURN (::t_unbind (handle), int, -1);
00381 #else
00382   ACE_UNUSED_ARG (handle);
00383 
00384   ACE_NOTSUP_RETURN (-1);
00385 #endif /* ACE_HAS_TLI */
00386 }

ACE_INLINE long ACE_OS::telldir ACE_DIR  ) 
 

Definition at line 168 of file OS_NS_dirent.inl.

References ACE_DIR, and ACE_NOTSUP_RETURN.

Referenced by ACE_Dirent::tell().

00169 {
00170 #if defined (ACE_HAS_DIRENT)  &&  !defined (ACE_LACKS_TELLDIR)
00171   return ::telldir (d);
00172 #else  /* ! ACE_HAS_DIRENT  ||  ACE_LACKS_TELLDIR */
00173   ACE_UNUSED_ARG (d);
00174   ACE_NOTSUP_RETURN (-1);
00175 #endif /* ! ACE_HAS_DIRENT  ||  ACE_LACKS_TELLDIR */
00176 }

ACE_INLINE wchar_t * ACE_OS::tempnam const wchar_t *  dir,
const wchar_t *  pfx = 0
 

Definition at line 877 of file OS_NS_stdio.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, free(), malloc(), strcpy(), strlen(), and tempnam().

00878 {
00879   ACE_OS_TRACE ("ACE_OS::tempnam");
00880 #if defined (ACE_LACKS_TEMPNAM)
00881   ACE_UNUSED_ARG (dir);
00882   ACE_UNUSED_ARG (pfx);
00883   ACE_NOTSUP_RETURN (0);
00884 #elif defined(ACE_WIN32)
00885 #  if defined (ACE_HAS_NONCONST_TEMPNAM)
00886   ACE_OSCALL_RETURN (::_wtempnam (const_cast <wchar_t*> (dir), const_cast <wchar_t*> (pfx)), wchar_t *, 0);
00887 #  else
00888   ACE_OSCALL_RETURN (::_wtempnam (dir, pfx), wchar_t *, 0);
00889 #  endif /* __BORLANDC__ */
00890 #else /* ACE_LACKS_TEMPNAM */
00891   // No native wide-char support; convert to narrow and call the char* variant.
00892   char *ndir = ACE_Wide_To_Ascii (dir).char_rep ();
00893   char *npfx = ACE_Wide_To_Ascii (pfx).char_rep ();
00894   char *name = ACE_OS::tempnam (ndir, npfx);
00895   // ACE_OS::tempnam returns a pointer to a malloc()-allocated space.
00896   // Convert that string to wide-char and free() the original.
00897   wchar_t *wname = 0;
00898   if (name != 0)
00899     {
00900       size_t namelen = ACE_OS::strlen (name) + 1;
00901       wname = reinterpret_cast<wchar_t *>
00902         (ACE_OS::malloc (namelen * sizeof (wchar_t)));
00903       if (wname != 0)
00904         ACE_OS::strcpy (wname, ACE_Ascii_To_Wide (name).wchar_rep ());
00905       ACE_OS::free (name);
00906     }
00907   return wname;
00908 #endif /* ACE_LACKS_TEMPNAM */
00909 }

ACE_INLINE char * ACE_OS::tempnam const char *  dir = 0,
const char *  pfx = 0
 

Definition at line 861 of file OS_NS_stdio.inl.

References ACE_NOTSUP_RETURN, and ACE_OS_TRACE.

Referenced by tempnam().

00862 {
00863   ACE_OS_TRACE ("ACE_OS::tempnam");
00864 #if defined (ACE_LACKS_TEMPNAM)
00865   ACE_UNUSED_ARG (dir);
00866   ACE_UNUSED_ARG (pfx);
00867   ACE_NOTSUP_RETURN (0);
00868 #elif defined (ACE_HAS_NONCONST_TEMPNAM)
00869   ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::tempnam (const_cast <char *> (dir), const_cast<char *> (pfx)), char *, 0);
00870 #else /* ACE_LACKS_TEMPNAM */
00871   ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::tempnam (dir, pfx), char *, 0);
00872 #endif /* ACE_LACKS_TEMPNAM */
00873 }

ACE_INLINE int ACE_OS::thr_cancel ACE_thread_t  t_id  ) 
 

Definition at line 2599 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_hthread_t, ACE_NOTSUP_RETURN, and ACE_OS_TRACE.

Referenced by ACE_Thread::cancel().

02600 {
02601   ACE_OS_TRACE ("ACE_OS::thr_cancel");
02602 #if defined (ACE_HAS_THREADS)
02603 # if defined (ACE_HAS_PTHREADS) && !defined (ACE_LACKS_PTHREAD_CANCEL)
02604 #   if defined (ACE_HAS_PTHREADS_DRAFT4) || defined (ACE_HAS_PTHREADS_DRAFT6)
02605 #     ifdef pthread_cancel
02606         // If it's a macro we can't say "pthread_cancel"...
02607         ACE_OSCALL_RETURN (pthread_cancel (thr_id), int, -1);
02608 #     else
02609         ACE_OSCALL_RETURN (pthread_cancel (thr_id), int, -1);
02610 #     endif /* pthread_cancel */
02611 #   else
02612   int result;
02613 #     ifdef pthread_cancel
02614         // If it's a macro we can't say "pthread_cancel"...
02615         ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_cancel (thr_id),
02616                                              result),
02617                            int, -1);
02618 #     else
02619         ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_cancel (thr_id),
02620                                              result),
02621                            int, -1);
02622 #     endif /* pthread_cancel */
02623 #   endif /* ACE_HAS_PTHREADS_DRAFT4 || ACE_HAS_PTHREADS_DRAFT6 */
02624 # elif defined (ACE_VXWORKS)
02625   ACE_hthread_t tid;
02626   ACE_OSCALL (::taskNameToId (thr_id), int, ERROR, tid);
02627 
02628   if (tid == ERROR)
02629     return -1;
02630   else
02631     ACE_OSCALL_RETURN (::taskDelete (tid), int, -1);
02632 # else /* Could be ACE_HAS_PTHREADS && ACE_LACKS_PTHREAD_CANCEL */
02633   ACE_UNUSED_ARG (thr_id);
02634   ACE_NOTSUP_RETURN (-1);
02635 # endif /* ACE_HAS_PTHREADS */
02636 #else
02637   ACE_UNUSED_ARG (thr_id);
02638   ACE_NOTSUP_RETURN (-1);
02639 #endif /* ACE_HAS_THREADS */
02640 }

ACE_INLINE int ACE_OS::thr_cmp ACE_hthread_t  t1,
ACE_hthread_t  t2
 

Definition at line 2643 of file OS_NS_Thread.inl.

References ACE_hthread_t.

Referenced by ACE_Thread_Manager::find_hthread(), ACE_Thread_Manager::hthread_within(), ACE_Thread_Descriptor_Base::operator==(), and ACE_Thread_ID::operator==().

02644 {
02645 #if defined (ACE_HAS_PTHREADS)
02646 # if defined (pthread_equal)
02647   // If it's a macro we can't say "pthread_equal"...
02648   return pthread_equal (t1, t2);
02649 # else
02650   return pthread_equal (t1, t2);
02651 # endif /* pthread_equal */
02652 #else /* For STHREADS, WTHREADS, and VXWORKS ... */
02653   // Hum, Do we need to treat WTHREAD differently?
02654   // levine 13 oct 98 % Probably, ACE_hthread_t is a HANDLE.
02655   return t1 == t2;
02656 #endif /* ACE_HAS_PTHREADS */
02657 }

ACE_INLINE int ACE_OS::thr_continue ACE_hthread_t  target_thread  ) 
 

Definition at line 2660 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_FAIL_RETURN, ACE_hthread_t, ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_SYSCALL_FAILED, and thr_continue().

Referenced by ACE_Thread::resume(), thr_continue(), and thr_create().

02661 {
02662   ACE_OS_TRACE ("ACE_OS::thr_continue");
02663 #if defined (ACE_HAS_THREADS)
02664 # if defined (ACE_HAS_STHREADS)
02665   int result;
02666   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_continue (target_thread), result), int, -1);
02667 # elif defined (ACE_HAS_PTHREADS)
02668 #  if defined (ACE_HAS_PTHREAD_CONTINUE)
02669   int result;
02670   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_continue (target_thread),
02671                                        result),
02672                      int, -1);
02673 #  elif defined (ACE_HAS_PTHREAD_CONTINUE_NP)
02674   int result;
02675   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_continue_np (target_thread),
02676                                        result),
02677                      int, -1);
02678 #  elif defined (ACE_HAS_PTHREAD_RESUME_NP)
02679   int result;
02680   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_resume_np (target_thread),
02681                                        result),
02682                      int, -1);
02683 #  else
02684   ACE_UNUSED_ARG (target_thread);
02685   ACE_NOTSUP_RETURN (-1);
02686 #  endif /* ACE_HAS_PTHREAD_CONTINUE */
02687 # elif defined (ACE_HAS_WTHREADS)
02688   DWORD result = ::ResumeThread (target_thread);
02689   if (result == ACE_SYSCALL_FAILED)
02690     ACE_FAIL_RETURN (-1);
02691   else
02692     return 0;
02693 # elif defined (ACE_VXWORKS)
02694   ACE_OSCALL_RETURN (::taskResume (target_thread), int, -1);
02695 # endif /* ACE_HAS_STHREADS */
02696 #else
02697   ACE_UNUSED_ARG (target_thread);
02698   ACE_NOTSUP_RETURN (-1);
02699 #endif /* ACE_HAS_THREADS */
02700 }

int ACE_OS::thr_create ACE_THR_FUNC  func,
void *  args,
long  flags,
ACE_thread_t thr_id,
ACE_hthread_t t_handle = 0,
long  priority = ACE_DEFAULT_THREAD_PRIORITY,
void *  stack = 0,
size_t  stacksize = 0,
ACE_Base_Thread_Adapter thread_adapter = 0
 

Definition at line 3837 of file OS_NS_Thread.cpp.

References ACE_ADAPT_RETVAL, ACE_AUTO_PTR_RESET, ACE_BIT_DISABLED, ACE_BIT_ENABLED, ACE_DEFAULT_THREAD_PRIORITY, ACE_FAIL_RETURN, ACE_hthread_t, ACE_MAX, ACE_MIN, ACE_NEW_RETURN, ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_SCHED_FIFO, ACE_SCHED_OTHER, ACE_SET_BITS, ACE_THR_PRI_FIFO_DEF, ACE_THR_PRI_OTHER_DEF, ACE_THREAD_ADAPTER_NAME, ACE_thread_t, ENOSYS, ENOTSUP, ACE_Base_Thread_Adapter::entry_point(), lwp_setparams(), memset(), ACE_Auto_Basic_Ptr< X >::release(), sched_params(), strsncpy(), thr_continue(), thr_create(), thr_getconcurrency(), thr_self(), thr_setconcurrency(), and thr_setprio().

Referenced by ACE_Thread::spawn(), ACE_Thread::spawn_n(), and thr_create().

03846 {
03847   ACE_OS_TRACE ("ACE_OS::thr_create");
03848 
03849   if (ACE_BIT_DISABLED (flags, THR_DETACHED) &&
03850       ACE_BIT_DISABLED (flags, THR_JOINABLE))
03851     ACE_SET_BITS (flags, THR_JOINABLE);
03852 
03853 #if defined (ACE_NO_THREAD_ADAPTER)
03854 # define  ACE_THREAD_FUNCTION  func
03855 # define  ACE_THREAD_ARGUMENT  args
03856 #else /* ! defined (ACE_NO_THREAD_ADAPTER) */
03857 # define  ACE_THREAD_FUNCTION  thread_args->entry_point ()
03858 # define  ACE_THREAD_ARGUMENT  thread_args
03859 #endif /* ! defined (ACE_NO_THREAD_ADAPTER) */
03860 
03861 
03862   ACE_Base_Thread_Adapter *thread_args = 0;
03863   if (thread_adapter == 0)
03864 #if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS)
03865     ACE_NEW_RETURN (thread_args,
03866                     ACE_OS_Thread_Adapter (func, args,
03867                                            (ACE_THR_C_FUNC) ACE_THREAD_ADAPTER_NAME,
03868                                            ACE_OS_Object_Manager::seh_except_selector(),
03869                                            ACE_OS_Object_Manager::seh_except_handler()),
03870                     -1);
03871 #else
03872   ACE_NEW_RETURN (thread_args,
03873                   ACE_OS_Thread_Adapter (func, args,
03874                                          (ACE_THR_C_FUNC) ACE_THREAD_ADAPTER_NAME),
03875                   -1);
03876 
03877 #endif /* ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS */
03878   else
03879     thread_args = thread_adapter;
03880 
03881   auto_ptr <ACE_Base_Thread_Adapter> auto_thread_args;
03882 
03883   if (thread_adapter == 0)
03884     ACE_AUTO_PTR_RESET (auto_thread_args,
03885                         thread_args,
03886                         ACE_Base_Thread_Adapter);
03887 
03888 #if defined (ACE_HAS_THREADS)
03889 
03890   // *** Set Stack Size
03891 # if defined (ACE_NEEDS_HUGE_THREAD_STACKSIZE)
03892   if (stacksize < ACE_NEEDS_HUGE_THREAD_STACKSIZE)
03893     stacksize = ACE_NEEDS_HUGE_THREAD_STACKSIZE;
03894 # endif /* ACE_NEEDS_HUGE_THREAD_STACKSIZE */
03895 
03896 # if !(defined (ACE_VXWORKS) && !defined (ACE_HAS_PTHREADS))
03897   // On VxWorks, using the task API, the OS will provide a task name if
03898   // the user doesn't. So, we don't need to create a tmp_thr.  If the
03899   // caller of this member function is the Thread_Manager, than thr_id
03900   // will be non-zero anyways.
03901   ACE_thread_t tmp_thr;
03902 
03903   if (thr_id == 0)
03904     thr_id = &tmp_thr;
03905 # endif /* !(ACE_VXWORKS && !ACE_HAS_PTHREADS) */
03906 
03907   ACE_hthread_t tmp_handle;
03908   if (thr_handle == 0)
03909     thr_handle = &tmp_handle;
03910 
03911 # if defined (ACE_HAS_PTHREADS)
03912 
03913   int result;
03914 # if defined (ACE_VXWORKS) && (ACE_VXWORKS >= 0x600) && (ACE_VXWORKS <= 0x620)
03915   /* Tests show that VxWorks 6.x pthread lib does not only
03916    * require zeroing of mutex/condition objects to function correctly
03917    * but also of the attribute objects.
03918    */
03919   pthread_attr_t attr = {0};
03920 #   else
03921   pthread_attr_t attr;
03922 #   endif
03923 #   if defined (ACE_HAS_PTHREADS_DRAFT4)
03924   if (ACE_ADAPT_RETVAL(::pthread_attr_create (&attr), result) != 0)
03925 #   else /* ACE_HAS_PTHREADS_DRAFT4 */
03926   if (ACE_ADAPT_RETVAL(::pthread_attr_init(&attr), result) != 0)
03927 #   endif /* ACE_HAS_PTHREADS_DRAFT4 */
03928       return -1;
03929 
03930   if (stacksize != 0)
03931     {
03932       size_t size = stacksize;
03933 
03934 #   if defined (PTHREAD_STACK_MIN)
03935       if (size < static_cast <size_t> (PTHREAD_STACK_MIN))
03936         size = PTHREAD_STACK_MIN;
03937 #   endif /* PTHREAD_STACK_MIN */
03938 
03939 #   if !defined (ACE_LACKS_THREAD_STACK_SIZE)      // JCEJ 12/17/96
03940 #     if defined (ACE_HAS_PTHREADS_DRAFT4) || defined (ACE_HAS_PTHREADS_DRAFT6)
03941       if (::pthread_attr_setstacksize (&attr, size) != 0)
03942 #     else
03943 #       if defined (ACE_HAS_PTHREAD_SETSTACK)
03944         int result;
03945         if (stack != 0)
03946           result = ACE_ADAPT_RETVAL (pthread_attr_setstack (&attr, stack, size), result);
03947         else
03948           result = ACE_ADAPT_RETVAL (pthread_attr_setstacksize (&attr, size), result);
03949         if (result == -1)
03950 #       else
03951         if (ACE_ADAPT_RETVAL (pthread_attr_setstacksize (&attr, size), result) == -1)
03952 #       endif /* ACE_HAS_PTHREAD_SETSTACK */
03953 #     endif /* ACE_HAS_PTHREADS_DRAFT4, 6 */
03954           {
03955 #     if defined (ACE_HAS_PTHREADS_DRAFT4)
03956             ::pthread_attr_delete (&attr);
03957 #     else /* ACE_HAS_PTHREADS_DRAFT4 */
03958             ::pthread_attr_destroy (&attr);
03959 #     endif /* ACE_HAS_PTHREADS_DRAFT4 */
03960             return -1;
03961           }
03962 #   else
03963       ACE_UNUSED_ARG (size);
03964 #   endif /* !ACE_LACKS_THREAD_STACK_SIZE */
03965     }
03966 
03967   // *** Set Stack Address
03968 #   if !defined (ACE_HAS_PTHREAD_SETSTACK)
03969 #     if !defined (ACE_LACKS_THREAD_STACK_ADDR)
03970   if (stack != 0)
03971     {
03972       if (ACE_ADAPT_RETVAL(::pthread_attr_setstackaddr (&attr, stack), result) != 0)
03973         {
03974 #       if defined (ACE_HAS_PTHREADS_DRAFT4)
03975           ::pthread_attr_delete (&attr);
03976 #       else /* ACE_HAS_PTHREADS_DRAFT4 */
03977           ::pthread_attr_destroy (&attr);
03978 #       endif /* ACE_HAS_PTHREADS_DRAFT4 */
03979           return -1;
03980         }
03981     }
03982 #     else
03983   ACE_UNUSED_ARG (stack);
03984 #     endif /* !ACE_LACKS_THREAD_STACK_ADDR */
03985 #   endif /* ACE_HAS_PTHREAD_SETSTACK */
03986 
03987   // *** Deal with various attributes
03988   if (flags != 0)
03989     {
03990       // *** Set Detach state
03991 #   if !defined (ACE_LACKS_SETDETACH)
03992       if (ACE_BIT_ENABLED (flags, THR_DETACHED)
03993           || ACE_BIT_ENABLED (flags, THR_JOINABLE))
03994         {
03995           int dstate = PTHREAD_CREATE_JOINABLE;
03996 
03997           if (ACE_BIT_ENABLED (flags, THR_DETACHED))
03998             dstate = PTHREAD_CREATE_DETACHED;
03999 
04000 #     if defined (ACE_HAS_PTHREADS_DRAFT4)
04001           if (::pthread_attr_setdetach_np (&attr, dstate) != 0)
04002 #     else /* ACE_HAS_PTHREADS_DRAFT4 */
04003 #       if defined (ACE_HAS_PTHREADS_DRAFT6)
04004             if (::pthread_attr_setdetachstate (&attr, &dstate) != 0)
04005 #       else
04006               if (ACE_ADAPT_RETVAL(::pthread_attr_setdetachstate (&attr, dstate),
04007                                    result) != 0)
04008 #       endif /* ACE_HAS_PTHREADS_DRAFT6 */
04009 #     endif /* ACE_HAS_PTHREADS_DRAFT4 */
04010                 {
04011 #     if defined (ACE_HAS_PTHREADS_DRAFT4)
04012                   ::pthread_attr_delete (&attr);
04013 #     else /* ACE_HAS_PTHREADS_DRAFT4 */
04014                   ::pthread_attr_destroy (&attr);
04015 #     endif /* ACE_HAS_PTHREADS_DRAFT4 */
04016                   return -1;
04017                 }
04018         }
04019 
04020       // Note: if ACE_LACKS_SETDETACH and THR_DETACHED is enabled, we
04021       // call ::pthread_detach () below.  If THR_DETACHED is not
04022       // enabled, we call ::pthread_detach () in the Thread_Manager,
04023       // after joining with the thread.
04024 #   endif /* ACE_LACKS_SETDETACH */
04025 
04026       // *** Set Policy
04027 #   if !defined (ACE_LACKS_SETSCHED) || defined (ACE_HAS_PTHREAD_SCHEDPARAM)
04028       // If we wish to set the priority explicitly, we have to enable
04029       // explicit scheduling, and a policy, too.
04030       if (priority != ACE_DEFAULT_THREAD_PRIORITY)
04031         {
04032           ACE_SET_BITS (flags, THR_EXPLICIT_SCHED);
04033           if (ACE_BIT_DISABLED (flags, THR_SCHED_FIFO)
04034               && ACE_BIT_DISABLED (flags, THR_SCHED_RR)
04035               && ACE_BIT_DISABLED (flags, THR_SCHED_DEFAULT))
04036             ACE_SET_BITS (flags, THR_SCHED_DEFAULT);
04037         }
04038 
04039       if (ACE_BIT_ENABLED (flags, THR_SCHED_FIFO)
04040           || ACE_BIT_ENABLED (flags, THR_SCHED_RR)
04041           || ACE_BIT_ENABLED (flags, THR_SCHED_DEFAULT))
04042         {
04043           int spolicy;
04044 
04045 #     if defined (ACE_HAS_ONLY_SCHED_OTHER)
04046           // SunOS, thru version 5.6, only supports SCHED_OTHER.
04047           spolicy = SCHED_OTHER;
04048 #     elif defined (ACE_HAS_ONLY_SCHED_FIFO)
04049           // NonStop OSS standard pthread supports only SCHED_FIFO.
04050           spolicy = SCHED_FIFO;
04051 #     else
04052           // Make sure to enable explicit scheduling, in case we didn't
04053           // enable it above (for non-default priority).
04054           ACE_SET_BITS (flags, THR_EXPLICIT_SCHED);
04055 
04056           if (ACE_BIT_ENABLED (flags, THR_SCHED_DEFAULT))
04057             spolicy = SCHED_OTHER;
04058           else if (ACE_BIT_ENABLED (flags, THR_SCHED_FIFO))
04059             spolicy = SCHED_FIFO;
04060 #       if defined (SCHED_IO)
04061           else if (ACE_BIT_ENABLED (flags, THR_SCHED_IO))
04062             spolicy = SCHED_IO;
04063 #       else
04064           else if (ACE_BIT_ENABLED (flags, THR_SCHED_IO))
04065             {
04066               errno = ENOSYS;
04067               return -1;
04068             }
04069 #       endif /* SCHED_IO */
04070           else
04071             spolicy = SCHED_RR;
04072 
04073 #       if defined (ACE_HAS_FSU_PTHREADS)
04074           int ret;
04075           switch (spolicy)
04076             {
04077             case SCHED_FIFO:
04078             case SCHED_RR:
04079               ret = 0;
04080               break;
04081             default:
04082               ret = 22;
04083               break;
04084             }
04085           if (ret != 0)
04086             {
04087               ::pthread_attr_destroy (&attr);
04088               return -1;
04089             }
04090 #       endif    /*  ACE_HAS_FSU_PTHREADS */
04091 
04092 #     endif /* ACE_HAS_ONLY_SCHED_OTHER */
04093 
04094 #     if defined (ACE_HAS_PTHREADS_DRAFT4)
04095           result = ::pthread_attr_setsched (&attr, spolicy);
04096 #     elif defined (ACE_HAS_PTHREADS_DRAFT6)
04097           result = ::pthread_attr_setschedpolicy (&attr, spolicy);
04098 #     else  /* draft 7 or std */
04099           (void) ACE_ADAPT_RETVAL(::pthread_attr_setschedpolicy (&attr, spolicy),
04100                            result);
04101 #     endif /* ACE_HAS_PTHREADS_DRAFT4 */
04102           if (result != 0)
04103             {
04104 #     if defined (ACE_HAS_PTHREADS_DRAFT4)
04105               ::pthread_attr_delete (&attr);
04106 #     else /* ACE_HAS_PTHREADS_DRAFT4 */
04107               ::pthread_attr_destroy (&attr);
04108 #     endif /* ACE_HAS_PTHREADS_DRAFT4 */
04109               return -1;
04110             }
04111         }
04112 
04113       // *** Set Priority (use reasonable default priorities)
04114 #     if defined(ACE_HAS_PTHREADS_STD)
04115       // If we wish to explicitly set a scheduling policy, we also
04116       // have to specify a priority.  We choose a "middle" priority as
04117       // default.  Maybe this is also necessary on other POSIX'ish
04118       // implementations?
04119       if ((ACE_BIT_ENABLED (flags, THR_SCHED_FIFO)
04120            || ACE_BIT_ENABLED (flags, THR_SCHED_RR)
04121            || ACE_BIT_ENABLED (flags, THR_SCHED_DEFAULT))
04122           && priority == ACE_DEFAULT_THREAD_PRIORITY)
04123         {
04124           if (ACE_BIT_ENABLED (flags, THR_SCHED_FIFO))
04125             priority = ACE_THR_PRI_FIFO_DEF;
04126           else if (ACE_BIT_ENABLED (flags, THR_SCHED_RR))
04127             priority = ACE_THR_PRI_RR_DEF;
04128           else // THR_SCHED_DEFAULT
04129             priority = ACE_THR_PRI_OTHER_DEF;
04130         }
04131 #     endif /* ACE_HAS_PTHREADS_STD */
04132       if (priority != ACE_DEFAULT_THREAD_PRIORITY)
04133         {
04134           struct sched_param sparam;
04135           ACE_OS::memset ((void *) &sparam, 0, sizeof sparam);
04136 
04137 #     if defined (ACE_HAS_IRIX62_THREADS)
04138           sparam.sched_priority = ACE_MIN (priority,
04139                                            (long) PTHREAD_MAX_PRIORITY);
04140 #     elif defined (PTHREAD_MAX_PRIORITY) && !defined(ACE_HAS_PTHREADS_STD)
04141           /* For MIT pthreads... */
04142           sparam.prio = ACE_MIN (priority, PTHREAD_MAX_PRIORITY);
04143 #     elif defined(ACE_HAS_PTHREADS_STD) && !defined (ACE_HAS_STHREADS)
04144           // The following code forces priority into range.
04145           if (ACE_BIT_ENABLED (flags, THR_SCHED_FIFO))
04146             sparam.sched_priority =
04147               ACE_MIN (ACE_THR_PRI_FIFO_MAX,
04148                        ACE_MAX (ACE_THR_PRI_FIFO_MIN, priority));
04149           else if (ACE_BIT_ENABLED(flags, THR_SCHED_RR))
04150             sparam.sched_priority =
04151               ACE_MIN (ACE_THR_PRI_RR_MAX,
04152                        ACE_MAX (ACE_THR_PRI_RR_MIN, priority));
04153           else // Default policy, whether set or not
04154             sparam.sched_priority =
04155               ACE_MIN (ACE_THR_PRI_OTHER_MAX,
04156                        ACE_MAX (ACE_THR_PRI_OTHER_MIN, priority));
04157 #     elif defined (PRIORITY_MAX)
04158           sparam.sched_priority = ACE_MIN (priority,
04159                                            (long) PRIORITY_MAX);
04160 #     else
04161           sparam.sched_priority = priority;
04162 #     endif /* ACE_HAS_IRIX62_THREADS */
04163 
04164 #     if defined (ACE_HAS_FSU_PTHREADS)
04165           if (sparam.sched_priority >= PTHREAD_MIN_PRIORITY
04166               && sparam.sched_priority <= PTHREAD_MAX_PRIORITY)
04167             attr.prio = sparam.sched_priority;
04168           else
04169             {
04170               pthread_attr_destroy (&attr);
04171               errno = EINVAL;
04172               return -1;
04173             }
04174 #     else
04175           {
04176 #       if defined (sun)  &&  defined (ACE_HAS_ONLY_SCHED_OTHER)
04177             // SunOS, through 5.6, POSIX only allows priorities > 0 to
04178             // ::pthread_attr_setschedparam.  If a priority of 0 was
04179             // requested, set the thread priority after creating it, below.
04180             if (priority > 0)
04181 #       endif /* sun && ACE_HAS_ONLY_SCHED_OTHER */
04182               {
04183 #       if defined (ACE_HAS_PTHREADS_DRAFT4) || defined (ACE_HAS_PTHREADS_DRAFT6)
04184                 result = ::pthread_attr_setprio (&attr,
04185                                                  sparam.sched_priority);
04186 #       else /* this is draft 7 or std */
04187                 (void) ACE_ADAPT_RETVAL(::pthread_attr_setschedparam (&attr, &sparam),
04188                                         result);
04189 #       endif /* ACE_HAS_PTHREADS_DRAFT4, 6 */
04190                 if (result != 0)
04191                   {
04192 #       if defined (ACE_HAS_PTHREADS_DRAFT4)
04193                     ::pthread_attr_delete (&attr);
04194 #       else /* ACE_HAS_PTHREADS_DRAFT4 */
04195                     ::pthread_attr_destroy (&attr);
04196 #       endif /* ACE_HAS_PTHREADS_DRAFT4 */
04197                     return -1;
04198                   }
04199               }
04200           }
04201 #     endif    /* ACE_HAS_FSU_PTHREADS */
04202         }
04203 
04204       // *** Set scheduling explicit or inherited
04205       if (ACE_BIT_ENABLED (flags, THR_INHERIT_SCHED)
04206           || ACE_BIT_ENABLED (flags, THR_EXPLICIT_SCHED))
04207         {
04208 #     if defined (ACE_HAS_PTHREADS_DRAFT4)
04209           int sched = PTHREAD_DEFAULT_SCHED;
04210 #     else /* ACE_HAS_PTHREADS_DRAFT4 */
04211           int sched = PTHREAD_EXPLICIT_SCHED;
04212 #     endif /* ACE_HAS_PTHREADS_DRAFT4 */
04213           if (ACE_BIT_ENABLED (flags, THR_INHERIT_SCHED))
04214             sched = PTHREAD_INHERIT_SCHED;
04215           if (ACE_ADAPT_RETVAL(::pthread_attr_setinheritsched (&attr, sched), result) != 0)
04216             {
04217 #     if defined (ACE_HAS_PTHREADS_DRAFT4)
04218               ::pthread_attr_delete (&attr);
04219 #     else /* ACE_HAS_PTHREADS_DRAFT4 */
04220               ::pthread_attr_destroy (&attr);
04221 #     endif /* ACE_HAS_PTHREADS_DRAFT4 */
04222               return -1;
04223             }
04224         }
04225 #   else /* ACE_LACKS_SETSCHED */
04226       ACE_UNUSED_ARG (priority);
04227 #   endif /* ACE_LACKS_SETSCHED */
04228 
04229       // *** Set Scope
04230 #   if !defined (ACE_LACKS_THREAD_PROCESS_SCOPING)
04231       if (ACE_BIT_ENABLED (flags, THR_SCOPE_SYSTEM)
04232           || ACE_BIT_ENABLED (flags, THR_SCOPE_PROCESS))
04233         {
04234 #     if defined (ACE_CONFIG_LINUX_H) || defined (HPUX)
04235           // LinuxThreads do not have support for PTHREAD_SCOPE_PROCESS.
04236           // Neither does HPUX (up to HP-UX 11.00, as far as I know).
04237           int scope = PTHREAD_SCOPE_SYSTEM;
04238 #     else /* ACE_CONFIG_LINUX_H */
04239           int scope = PTHREAD_SCOPE_PROCESS;
04240 #     endif /* ACE_CONFIG_LINUX_H */
04241           if (ACE_BIT_ENABLED (flags, THR_SCOPE_SYSTEM))
04242             scope = PTHREAD_SCOPE_SYSTEM;
04243 
04244           if (ACE_ADAPT_RETVAL(::pthread_attr_setscope (&attr, scope), result) != 0)
04245             {
04246 #     if defined (ACE_HAS_PTHREADS_DRAFT4)
04247               ::pthread_attr_delete (&attr);
04248 #     else /* ACE_HAS_PTHREADS_DRAFT4 */
04249               ::pthread_attr_destroy (&attr);
04250 #     endif /* ACE_HAS_PTHREADS_DRAFT4 */
04251               return -1;
04252             }
04253         }
04254 #   endif /* !ACE_LACKS_THREAD_PROCESS_SCOPING */
04255 
04256 #   ifdef ACE_HAS_PTHREAD_ATTR_SETCREATESUSPEND_NP
04257       if (ACE_BIT_ENABLED (flags, THR_SUSPENDED))
04258         {
04259            if (ACE_ADAPT_RETVAL(::pthread_attr_setcreatesuspend_np(&attr), result) != 0)
04260              {
04261 
04262 #     if defined (ACE_HAS_PTHREADS_DRAFT4)
04263               ::pthread_attr_delete (&attr);
04264 #     else /* ACE_HAS_PTHREADS_DRAFT4 */
04265               ::pthread_attr_destroy (&attr);
04266 #     endif /* ACE_HAS_PTHREADS_DRAFT4 */
04267               return -1;
04268             }
04269         }
04270 #   endif /* !ACE_HAS_PTHREAD_ATTR_SETCREATESUSPEND_NP */
04271 
04272       if (ACE_BIT_ENABLED (flags, THR_NEW_LWP))
04273         {
04274           // Increment the number of LWPs by one to emulate the
04275           // SunOS semantics.
04276           int lwps = ACE_OS::thr_getconcurrency ();
04277           if (lwps == -1)
04278             {
04279               if (errno == ENOTSUP)
04280                 // Suppress the ENOTSUP because it's harmless.
04281                 errno = 0;
04282               else
04283                 // This should never happen on SunOS:
04284                 // ::thr_getconcurrency () should always succeed.
04285                 return -1;
04286             }
04287           else if (ACE_OS::thr_setconcurrency (lwps + 1) == -1)
04288             {
04289               if (errno == ENOTSUP)
04290                 {
04291                   // Unlikely: ::thr_getconcurrency () is supported
04292                   // but ::thr_setconcurrency () is not?
04293                 }
04294               else
04295                 return -1;
04296             }
04297         }
04298     }
04299 
04300 #   if defined (ACE_HAS_PTHREADS_DRAFT4)
04301   ACE_OSCALL (::pthread_create (thr_id, attr,
04302                                 thread_args->entry_point (),
04303                                 thread_args),
04304               int, -1, result);
04305 
04306 #     if defined (ACE_LACKS_SETDETACH)
04307   if (ACE_BIT_ENABLED (flags, THR_DETACHED))
04308     {
04309       ::pthread_detach (thr_id);
04310     }
04311 #     endif /* ACE_LACKS_SETDETACH */
04312 
04313   ::pthread_attr_delete (&attr);
04314 
04315 #   elif defined (ACE_HAS_PTHREADS_DRAFT6)
04316   ACE_OSCALL (::pthread_create (thr_id, &attr,
04317                                 thread_args->entry_point (),
04318                                 thread_args),
04319               int, -1, result);
04320   ::pthread_attr_destroy (&attr);
04321 
04322 #   else /* this is draft 7 or std */
04323   ACE_OSCALL (ACE_ADAPT_RETVAL (::pthread_create (thr_id,
04324                                                   &attr,
04325                                                   thread_args->entry_point (),
04326                                                   thread_args),
04327                                 result),
04328               int, -1, result);
04329   ::pthread_attr_destroy (&attr);
04330 #   endif /* ACE_HAS_PTHREADS_DRAFT4 */
04331 
04332   // This is a SunOS or POSIX implementation of pthreads, where we
04333   // assume that ACE_thread_t and ACE_hthread_t are the same.  If this
04334   // *isn't* correct on some platform, please let us know.
04335   if (result != -1)
04336     *thr_handle = *thr_id;
04337 
04338 #   if defined (sun)  &&  defined (ACE_HAS_ONLY_SCHED_OTHER)
04339   // SunOS prior to 5.7:
04340 
04341   // If the priority is 0, then we might have to set it now because we
04342   // couldn't set it with ::pthread_attr_setschedparam, as noted
04343   // above.  This doesn't provide strictly correct behavior, because
04344   // the thread was created (above) with the priority of its parent.
04345   // (That applies regardless of the inherit_sched attribute: if it
04346   // was PTHREAD_INHERIT_SCHED, then it certainly inherited its
04347   // parent's priority.  If it was PTHREAD_EXPLICIT_SCHED, then "attr"
04348   // was initialized by the SunOS ::pthread_attr_init () to contain
04349   // NULL for the priority, which indicated to SunOS ::pthread_create
04350   // () to inherit the parent priority.)
04351   if (priority == 0)
04352     {
04353       // Check the priority of this thread, which is the parent
04354       // of the newly created thread.  If it is 0, then the
04355       // newly created thread will have inherited the priority
04356       // of 0, so there's no need to explicitly set it.
04357       struct sched_param sparam;
04358       int policy = 0;
04359       ACE_OSCALL (ACE_ADAPT_RETVAL (::pthread_getschedparam (thr_self (),
04360                                                              &policy,
04361                                                              &sparam),
04362                                     result), int,
04363                   -1, result);
04364 
04365       // The only policy supported by by SunOS, thru version 5.6,
04366       // is SCHED_OTHER, so that's hard-coded here.
04367       policy = ACE_SCHED_OTHER;
04368 
04369       if (sparam.sched_priority != 0)
04370         {
04371           ACE_OS::memset ((void *) &sparam, 0, sizeof sparam);
04372           // The memset to 0 sets the priority to 0, so we don't need
04373           // to explicitly set sparam.sched_priority.
04374 
04375           ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_setschedparam (*thr_id,
04376                                                                         policy,
04377                                                                         &sparam),
04378                                                result),
04379                              int, -1);
04380         }
04381     }
04382 
04383 #     if defined (ACE_NEEDS_LWP_PRIO_SET)
04384 #       if 0
04385   // It would be useful if we could make this work.  But, it requires
04386   // a mechanism for determining the ID of an LWP to which another
04387   // thread is bound.  Is there a way to do that?  Instead, just rely
04388   // on the code in ACE_Thread_Adapter::invoke () to set the LWP
04389   // priority.
04390 
04391   // If the thread is bound, then set the priority on its LWP.
04392   if (ACE_BIT_ENABLED (flags, THR_BOUND))
04393     {
04394       ACE_Sched_Params sched_params (ACE_BIT_ENABLED (flags, THR_SCHED_FIFO) ||
04395                                      ACE_BIT_ENABLED (flags, THR_SCHED_RR)  ?
04396                                      ACE_SCHED_FIFO  :
04397                                      ACE_SCHED_OTHER,
04398                                      priority);
04399       result = ACE_OS::lwp_setparams (sched_params,
04400                                       /* ? How do we find the ID of the LWP
04401                                          to which *thr_id is bound? */);
04402     }
04403 #       endif /* 0 */
04404 #     endif /* ACE_NEEDS_LWP_PRIO_SET */
04405 
04406 #   endif /* sun && ACE_HAS_ONLY_SCHED_OTHER */
04407   auto_thread_args.release ();
04408   return result;
04409 # elif defined (ACE_HAS_STHREADS)
04410   int result;
04411   int start_suspended = ACE_BIT_ENABLED (flags, THR_SUSPENDED);
04412 
04413   if (priority != ACE_DEFAULT_THREAD_PRIORITY)
04414     // If we need to set the priority, then we need to start the
04415     // thread in a suspended mode.
04416     ACE_SET_BITS (flags, THR_SUSPENDED);
04417 
04418   ACE_OSCALL (ACE_ADAPT_RETVAL (::thr_create (stack, stacksize,
04419                                               thread_args->entry_point (),
04420                                               thread_args,
04421                                               flags, thr_id), result),
04422               int, -1, result);
04423 
04424   if (result != -1)
04425     {
04426       // With SunOS threads, ACE_thread_t and ACE_hthread_t are the same.
04427       *thr_handle = *thr_id;
04428 
04429       if (priority != ACE_DEFAULT_THREAD_PRIORITY)
04430         {
04431           // Set the priority of the new thread and then let it
04432           // continue, but only if the user didn't start it suspended
04433           // in the first place!
04434           result = ACE_OS::thr_setprio (*thr_id, priority);
04435           if (result != 0)
04436             {
04437               errno = result;
04438               return -1;
04439             }
04440 
04441           if (start_suspended == 0)
04442             {
04443               result = ACE_OS::thr_continue (*thr_id);
04444               if (result != 0)
04445                 {
04446                   errno = result;
04447                   return -1;
04448                 }
04449             }
04450         }
04451     }
04452   auto_thread_args.release ();
04453   return result;
04454 # elif defined (ACE_HAS_WTHREADS)
04455   ACE_UNUSED_ARG (stack);
04456 #   if defined (ACE_HAS_MFC) && (ACE_HAS_MFC != 0)
04457   if (ACE_BIT_ENABLED (flags, THR_USE_AFX))
04458     {
04459       CWinThread *cwin_thread =
04460         ::AfxBeginThread ((AFX_THREADPROC) thread_args->entry_point (),
04461                           thread_args,
04462                           priority,
04463                           0,
04464                           flags | THR_SUSPENDED);
04465       // Have to duplicate the handle because
04466       // CWinThread::~CWinThread() closes the original handle.
04467 #     if !defined (ACE_HAS_WINCE)
04468       (void) ::DuplicateHandle (::GetCurrentProcess (),
04469                                 cwin_thread->m_hThread,
04470                                 ::GetCurrentProcess (),
04471                                 thr_handle,
04472                                 0,
04473                                 TRUE,
04474                                 DUPLICATE_SAME_ACCESS);
04475 #     endif /* ! ACE_HAS_WINCE */
04476       *thr_id = cwin_thread->m_nThreadID;
04477 
04478       if (ACE_BIT_ENABLED (flags, THR_SUSPENDED) == 0)
04479         cwin_thread->ResumeThread ();
04480       // cwin_thread will be deleted in AfxThreadExit()
04481       // Warning: If AfxThreadExit() is called from within the
04482       // thread, ACE_TSS_Cleanup->thread_exit() never gets called !
04483     }
04484   else
04485 #   endif /* ACE_HAS_MFC */
04486     {
04487       int start_suspended = ACE_BIT_ENABLED (flags, THR_SUSPENDED);
04488 
04489       if (priority != ACE_DEFAULT_THREAD_PRIORITY)
04490         // If we need to set the priority, then we need to start the
04491         // thread in a suspended mode.
04492         ACE_SET_BITS (flags, THR_SUSPENDED);
04493 
04494       *thr_handle = (void *) ACE_BEGINTHREADEX (0,
04495                                                 static_cast <u_int> (stacksize),
04496                                                 thread_args->entry_point (),
04497                                                 thread_args,
04498                                                 flags,
04499                                                 thr_id);
04500 
04501       if (priority != ACE_DEFAULT_THREAD_PRIORITY && *thr_handle != 0)
04502         {
04503           // Set the priority of the new thread and then let it
04504           // continue, but only if the user didn't start it suspended
04505           // in the first place!
04506           ACE_OS::thr_setprio (*thr_handle, priority);
04507 
04508           if (start_suspended == 0)
04509             ACE_OS::thr_continue (*thr_handle);
04510         }
04511     }
04512 #   if 0
04513   *thr_handle = ::CreateThread
04514     (0,
04515      stacksize,
04516      LPTHREAD_START_ROUTINE (thread_args->entry_point ()),
04517      thread_args,
04518      flags,
04519      thr_id);
04520 #   endif /* 0 */
04521 
04522   // Close down the handle if no one wants to use it.
04523   if (thr_handle == &tmp_handle && tmp_handle != 0)
04524     ::CloseHandle (tmp_handle);
04525 
04526   if (*thr_handle != 0)
04527     {
04528       auto_thread_args.release ();
04529       return 0;
04530     }
04531   else
04532     ACE_FAIL_RETURN (-1);
04533   /* NOTREACHED */
04534 
04535 # elif defined (ACE_VXWORKS)
04536   // The hard-coded values below are what ::sp () would use.  (::sp ()
04537   // hardcodes priority to 100, flags to VX_FP_TASK, and stacksize to
04538   // 20,000.)  stacksize should be an even integer.  If a stack is not
04539   // specified, ::taskSpawn () is used so that we can set the
04540   // priority, flags, and stacksize.  If a stack is specified,
04541   // ::taskInit ()/::taskActivate() are used.
04542 
04543   // If called with thr_create() defaults, use same default values as ::sp ():
04544   if (priority == ACE_DEFAULT_THREAD_PRIORITY) priority = 100;
04545   // Assumes that there is a floating point coprocessor.  As noted
04546   // above, ::sp () hardcodes this, so we should be safe with it.
04547   if (flags == 0) flags = VX_FP_TASK;
04548   if (stacksize == 0) stacksize = 20000;
04549 
04550   const u_int thr_id_provided =
04551     thr_id  &&  *thr_id  &&  (*thr_id)[0] != ACE_THR_ID_ALLOCATED;
04552 
04553   ACE_hthread_t tid;
04554 #   if 0 /* Don't support setting of stack, because it doesn't seem to work. */
04555   if (stack == 0)
04556     {
04557 #   else
04558       ACE_UNUSED_ARG (stack);
04559 #   endif /* 0 */
04560       // The call below to ::taskSpawn () causes VxWorks to assign a
04561       // unique task name of the form: "t" + an integer, because the
04562       // first argument is 0.
04563       tid = ::taskSpawn (thr_id_provided  ?  *thr_id  :  0,
04564                          priority,
04565                          (int) flags,
04566                          (int) stacksize,
04567                          thread_args->entry_point (),
04568                          (int) thread_args,
04569                          0, 0, 0, 0, 0, 0, 0, 0, 0);
04570 #   if 0 /* Don't support setting of stack, because it doesn't seem to work. */
04571     }
04572   else
04573     {
04574       // If a task name (thr_id) was not supplied, then the task will
04575       // not have a unique name.  That's VxWorks' behavior.
04576 
04577       // Carve out a TCB at the beginning of the stack space.  The TCB
04578       // occupies 400 bytes with VxWorks 5.3.1/I386.
04579       WIND_TCB *tcb = (WIND_TCB *) stack;
04580 
04581       // The TID is defined to be the address of the TCB.
04582       int status = ::taskInit (tcb,
04583                                thr_id_provided  ?  *thr_id  :  0,
04584                                priority,
04585                                (int) flags,
04586                                (char *) stack + sizeof (WIND_TCB),
04587                                (int) (stacksize - sizeof (WIND_TCB)),
04588                                thread_args->entry_point (),
04589                                (int) thread_args,
04590                                0, 0, 0, 0, 0, 0, 0, 0, 0);
04591 
04592       if (status == OK)
04593         {
04594           // The task was successfully initialized, now activate it.
04595           status = ::taskActivate ((ACE_hthread_t) tcb);
04596         }
04597 
04598       tid = status == OK  ?  (ACE_hthread_t) tcb  :  ERROR;
04599     }
04600 #   endif /* 0 */
04601 
04602   if (tid == ERROR)
04603     return -1;
04604   else
04605     {
04606       if (! thr_id_provided && thr_id)
04607         {
04608           if (*thr_id && (*thr_id)[0] == ACE_THR_ID_ALLOCATED)
04609             // *thr_id was allocated by the Thread_Manager.  ::taskTcb
04610             // (int tid) returns the address of the WIND_TCB (task
04611             // control block).  According to the ::taskSpawn()
04612             // documentation, the name of the new task is stored at
04613             // pStackBase, but is that of the current task?  If so, it
04614             // might be a bit quicker than this extraction of the tcb
04615             // . . .
04616             ACE_OS::strsncpy (*thr_id + 1, ::taskName (tid), 10);
04617           else
04618             // *thr_id was not allocated by the Thread_Manager.
04619             // Pass back the task name in the location pointed to
04620             // by thr_id.
04621             *thr_id = ::taskName (tid);
04622         }
04623       // else if the thr_id was provided, there's no need to overwrite
04624       // it with the same value (string).  If thr_id is 0, then we can't
04625       // pass the task name back.
04626 
04627       if (thr_handle)
04628         *thr_handle = tid;
04629 
04630       auto_thread_args.release ();
04631       return 0;
04632     }
04633 
04634 # endif /* ACE_HAS_STHREADS */
04635 #else
04636   ACE_UNUSED_ARG (func);
04637   ACE_UNUSED_ARG (args);
04638   ACE_UNUSED_ARG (flags);
04639   ACE_UNUSED_ARG (thr_id);
04640   ACE_UNUSED_ARG (thr_handle);
04641   ACE_UNUSED_ARG (priority);
04642   ACE_UNUSED_ARG (stack);
04643   ACE_UNUSED_ARG (stacksize);
04644   ACE_NOTSUP_RETURN (-1);
04645 #endif /* ACE_HAS_THREADS */
04646 }

ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE int ACE_OS::thr_equal ACE_thread_t  t1,
ACE_thread_t  t2
 

Definition at line 107 of file OS_NS_Thread.inl.

References strcmp().

Referenced by ACE_Thread_Manager::check_state(), ACE_Thread_Manager::find_thread(), ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::handle_events(), ACE_Thread_Manager::join(), ACE_Thread_Descriptor_Base::operator==(), ACE_Thread_ID::operator==(), recursive_mutex_cond_unlock(), recursive_mutex_lock(), recursive_mutex_trylock(), recursive_mutex_unlock(), ACE_Token::renew(), ACE_Token::shared_acquire(), ACE_Thread_Manager::thr_state(), ACE_Thread_Manager::thread_within(), ACE_Object_Manager_Manager::~ACE_Object_Manager_Manager(), and ACE_OS_Object_Manager_Manager::~ACE_OS_Object_Manager_Manager().

00108 {
00109 #if defined (ACE_HAS_PTHREADS)
00110 # if defined (pthread_equal)
00111   // If it's a macro we can't say "pthread_equal"...
00112   return pthread_equal (t1, t2);
00113 # else
00114   return pthread_equal (t1, t2);
00115 # endif /* pthread_equal */
00116 #elif defined (ACE_VXWORKS)
00117   return ! ACE_OS::strcmp (t1, t2);
00118 #else /* For both STHREADS and WTHREADS... */
00119   // Hum, Do we need to treat WTHREAD differently?
00120   // levine 13 oct 98 % I don't think so, ACE_thread_t is a DWORD.
00121   return t1 == t2;
00122 #endif /* ACE_HAS_PTHREADS */
00123 }

void ACE_OS::thr_exit ACE_THR_FUNC_RETURN  status = 0  ) 
 

Definition at line 4649 of file OS_NS_Thread.cpp.

References ACE_BIT_ENABLED, ACE_hthread_t, ACE_OS_TRACE, cleanup_tss(), ACE_OS_Thread_Descriptor::flags(), ACE_Base_Thread_Adapter::thr_desc_log_msg(), and thr_self().

Referenced by ACE_Thread_Control::exit(), and ACE_Thread::exit().

04650 {
04651   ACE_OS_TRACE ("ACE_OS::thr_exit");
04652 #if defined (ACE_HAS_THREADS)
04653 # if defined (ACE_HAS_PTHREADS)
04654     ::pthread_exit (status);
04655 # elif defined (ACE_HAS_STHREADS)
04656     ::thr_exit (status);
04657 # elif defined (ACE_HAS_WTHREADS)
04658     // Can't call it here because on NT, the thread is exited
04659     // directly by ACE_Thread_Adapter::invoke ().
04660     //   ACE_TSS_Cleanup::instance ()->thread_exit (status);
04661 
04662 #   if defined (ACE_HAS_MFC) && (ACE_HAS_MFC != 0)
04663     int using_afx = -1;
04664     // An ACE_Thread_Descriptor really is an ACE_OS_Thread_Descriptor.
04665     // But without #including ace/Thread_Manager.h, we don't know that.
04666     ACE_OS_Thread_Descriptor *td =
04667       ACE_Base_Thread_Adapter::thr_desc_log_msg ();
04668     if (td)
04669       using_afx = ACE_BIT_ENABLED (td->flags (), THR_USE_AFX);
04670 #   endif /* ACE_HAS_MFC && (ACE_HAS_MFC != 0) */
04671 
04672     // Call TSS destructors.
04673     ACE_OS::cleanup_tss (0 /* not main thread */);
04674 
04675     // Exit the thread.
04676     // Allow CWinThread-destructor to be invoked from AfxEndThread.
04677     // _endthreadex will be called from AfxEndThread so don't exit the
04678     // thread now if we are running an MFC thread.
04679 #   if defined (ACE_HAS_MFC) && (ACE_HAS_MFC != 0)
04680     if (using_afx != -1)
04681       {
04682         if (using_afx)
04683           ::AfxEndThread (status);
04684         else
04685           ACE_ENDTHREADEX (status);
04686       }
04687     else
04688       {
04689         // Not spawned by ACE_Thread_Manager, use the old buggy
04690         // version.  You should seriously consider using
04691         // ACE_Thread_Manager to spawn threads.  The following code is
04692         // know to cause some problem.
04693         CWinThread *pThread = ::AfxGetThread ();
04694         if (!pThread || pThread->m_nThreadID != ACE_OS::thr_self ())
04695           ACE_ENDTHREADEX (status);
04696         else
04697           ::AfxEndThread (status);
04698       }
04699 #   else
04700     ACE_ENDTHREADEX (status);
04701 #   endif /* ACE_HAS_MFC && ACE_HAS_MFS != 0*/
04702 
04703 # elif defined (ACE_VXWORKS)
04704     ACE_hthread_t tid;
04705     ACE_OS::thr_self (tid);
04706     *((int *) status) = ::taskDelete (tid);
04707 # endif /* ACE_HAS_PTHREADS */
04708 #else
04709   ACE_UNUSED_ARG (status);
04710 #endif /* ACE_HAS_THREADS */
04711 }

int ACE_OS::thr_get_affinity ACE_hthread_t  id,
size_t  cpu_set_size,
cpu_set_t cpu_mask
 

Get the thread affinity

Parameters:
thr_id For NPTL-threads, when ACE_HAS_PTHREAD_SETAFFINITY_NP defined, this is the thread-id. For linux-threads, when ACE_HAS_SCHED_SETAFFINITY defined, it expects a process-id. Since for linux-threads a thread is seen as a process, it does the job.
cpu_set_size The size of the cpu_mask
cpu_mask Is a bitmask of CPUs to bind to, e.g value 1 binds the thread to the "CPU 0", etc

Definition at line 4799 of file OS_NS_Thread.cpp.

References ACE_hthread_t, and ACE_NOTSUP_RETURN.

04802 {
04803 #if defined (ACE_HAS_PTHREAD_GETAFFINITY_NP)
04804   // Handle of the thread, which is NPTL thread-id, normally a big number
04805   if (::pthread_getaffinity_np (thr_id,
04806                                 cpu_set_size,
04807                                 cpu_mask) != 0)
04808     {
04809       return -1;
04810     }
04811   return 0;
04812 #elif defined (ACE_HAS_2_PARAM_SCHED_GETAFFINITY)
04813   // The process-id is expected as <thr_id>, which can be a thread-id of
04814   // linux-thread, thus making binding to cpu of that particular thread only.
04815   // If you are using this flag for NPTL-threads, however, please pass as a
04816   // thr_id process id obtained by ACE_OS::getpid ()
04817   ACE_UNUSED_ARG (cpu_set_size);
04818   if (::sched_getaffinity(thr_id,
04819                           cpu_mask) == -1)
04820     {
04821       return -1;
04822     }
04823   return 0;
04824 #elif defined (ACE_HAS_SCHED_GETAFFINITY)
04825   // The process-id is expected as <thr_id>, which can be a thread-id of
04826   // linux-thread, thus making binding to cpu of that particular thread only.
04827   // If you are using this flag for NPTL-threads, however, please pass as a
04828   // thr_id process id obtained by ACE_OS::getpid ()
04829   if (::sched_getaffinity(thr_id,
04830                           cpu_set_size,
04831                           cpu_mask) == -1)
04832     {
04833       return -1;
04834     }
04835   return 0;
04836 #else
04837   ACE_UNUSED_ARG (thr_id);
04838   ACE_UNUSED_ARG (cpu_set_size);
04839   ACE_UNUSED_ARG (cpu_mask);
04840   ACE_NOTSUP_RETURN (-1);
04841 #endif
04842 }

ACE_INLINE int ACE_OS::thr_getconcurrency void   ) 
 

Definition at line 2703 of file OS_NS_Thread.inl.

References ACE_NOTSUP_RETURN, and ACE_OS_TRACE.

Referenced by ACE_Thread::getconcurrency(), and thr_create().

02704 {
02705   ACE_OS_TRACE ("ACE_OS::thr_getconcurrency");
02706 #if defined (ACE_HAS_THREADS)
02707 # if defined (ACE_HAS_STHREADS)
02708   return ::thr_getconcurrency ();
02709 # elif defined (ACE_HAS_PTHREADS) && defined (ACE_HAS_PTHREAD_GETCONCURRENCY)
02710   return pthread_getconcurrency ();
02711 # else
02712   ACE_NOTSUP_RETURN (-1);
02713 # endif /* ACE_HAS_STHREADS */
02714 #else
02715   ACE_NOTSUP_RETURN (-1);
02716 #endif /* ACE_HAS_THREADS */
02717 }

ACE_INLINE int ACE_OS::thr_getprio ACE_hthread_t  id,
int &  priority,
int &  policy
 

Definition at line 2720 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_FAIL_RETURN, ACE_hthread_t, ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_SCHED_FIFO, ACE_SCHED_OTHER, and thr_getprio().

02721 {
02722   ACE_OS_TRACE ("ACE_OS::thr_getprio");
02723   ACE_UNUSED_ARG (policy);
02724 #if defined (ACE_HAS_THREADS)
02725 # if (defined (ACE_HAS_PTHREADS) && \
02726      (!defined (ACE_LACKS_SETSCHED) || defined (ACE_HAS_PTHREAD_SCHEDPARAM)))
02727 
02728 #   if defined (ACE_HAS_PTHREADS_DRAFT4)
02729   int const result = pthread_getprio (ht_id);
02730   if (result != -1)
02731     {
02732       priority = result;
02733       return 0;
02734     }
02735   else
02736     return -1;
02737 #   elif defined (ACE_HAS_PTHREADS_DRAFT6)
02738 
02739   pthread_attr_t  attr;
02740   if (pthread_getschedattr (ht_id, &attr) == 0)
02741     {
02742       priority = pthread_attr_getprio (&attr);
02743       return 0;
02744     }
02745   return -1;
02746 #   else
02747 
02748   struct sched_param param;
02749   int result;
02750 
02751   ACE_OSCALL (ACE_ADAPT_RETVAL (pthread_getschedparam (ht_id, &policy, &param),
02752                                 result), int,
02753               -1, result);
02754   priority = param.sched_priority;
02755   return result;
02756 #   endif /* ACE_HAS_PTHREADS_DRAFT4 */
02757 # elif defined (ACE_HAS_STHREADS)
02758   int result;
02759   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_getprio (ht_id, &priority), result), int, -1);
02760 # elif defined (ACE_HAS_WTHREADS) && !defined (ACE_HAS_WINCE)
02761   ACE_Errno_Guard error (errno);
02762 
02763   priority = ::GetThreadPriority (ht_id);
02764 
02765   DWORD priority_class = ::GetPriorityClass (::GetCurrentProcess ());
02766   if (priority_class == 0 && (error = ::GetLastError ()) != NO_ERROR)
02767     ACE_FAIL_RETURN (-1);
02768 
02769   policy =
02770     (priority_class ==
02771      REALTIME_PRIORITY_CLASS) ? ACE_SCHED_FIFO : ACE_SCHED_OTHER;
02772 
02773   return 0;
02774 # elif defined (ACE_VXWORKS)
02775   ACE_OSCALL_RETURN (::taskPriorityGet (ht_id, &priority), int, -1);
02776 # else
02777   ACE_UNUSED_ARG (ht_id);
02778   ACE_UNUSED_ARG (priority);
02779   ACE_NOTSUP_RETURN (-1);
02780 # endif /* ACE_HAS_STHREADS */
02781 #else
02782   ACE_UNUSED_ARG (ht_id);
02783   ACE_UNUSED_ARG (priority);
02784   ACE_NOTSUP_RETURN (-1);
02785 #endif /* ACE_HAS_THREADS */
02786 }

ACE_INLINE int ACE_OS::thr_getprio ACE_hthread_t  id,
int &  priority
 

Definition at line 2789 of file OS_NS_Thread.inl.

References ACE_hthread_t, and ACE_OS_TRACE.

Referenced by ACE_Thread::getprio(), ACE_OS_Thread_Adapter::invoke(), ACE_Thread_Adapter::invoke_i(), and thr_getprio().

02790 {
02791   ACE_OS_TRACE ("ACE_OS::thr_getprio");
02792   int policy = 0;
02793   return ACE_OS::thr_getprio (ht_id, priority, policy);
02794 }

ACE_INLINE int ACE_OS::thr_getspecific ACE_thread_key_t  key,
void **  data
 

Definition at line 2843 of file OS_NS_Thread.inl.

References ACE_NOTSUP_RETURN, and ACE_thread_key_t.

Referenced by ACE_TSS_Cleanup::find_tss_keys(), ACE_Thread::getspecific(), ACE_TSS_Cleanup::thread_release(), and ACE_TSS_Cleanup::tss_keys().

02844 {
02845 //   ACE_OS_TRACE ("ACE_OS::thr_getspecific");
02846 #if defined (ACE_HAS_THREADS)
02847 # if defined (ACE_HAS_TSS_EMULATION)
02848     if (ACE_TSS_Emulation::is_key (key) == 0)
02849       {
02850         errno = EINVAL;
02851         data = 0;
02852         return -1;
02853       }
02854     else
02855       {
02856         *data = ACE_TSS_Emulation::ts_object (key);
02857         return 0;
02858       }
02859 # elif defined (ACE_HAS_THREAD_SPECIFIC_STORAGE)
02860   return ACE_OS::thr_getspecific_native (key, data);
02861 #else
02862   ACE_UNUSED_ARG (key);
02863   ACE_UNUSED_ARG (data);
02864   ACE_NOTSUP_RETURN (-1);
02865 # endif /* ACE_HAS_TSS_EMULATION */
02866 #else
02867   ACE_UNUSED_ARG (key);
02868   ACE_UNUSED_ARG (data);
02869   ACE_NOTSUP_RETURN (-1);
02870 #endif /* ACE_HAS_THREADS */
02871 }

ACE_INLINE int ACE_OS::thr_join ACE_thread_t  waiter_id,
ACE_thread_t thr_id,
ACE_THR_FUNC_RETURN *  status
 

Definition at line 2936 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, and thr_join().

02939 {
02940   ACE_OS_TRACE ("ACE_OS::thr_join");
02941 #if defined (ACE_HAS_THREADS)
02942 # if defined (ACE_HAS_STHREADS)
02943   int result;
02944   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_join (waiter_id, thr_id, status), result),
02945                      int, -1);
02946 # elif defined (ACE_HAS_PTHREADS)
02947   ACE_UNUSED_ARG (thr_id);
02948 #   if defined (ACE_HAS_PTHREADS_DRAFT4) || defined (ACE_HAS_PTHREADS_DRAFT6)
02949 #     if defined (ACE_LACKS_NULL_PTHREAD_STATUS)
02950   void *temp;
02951   ACE_OSCALL_RETURN (pthread_join (waiter_id,
02952     status == 0  ?  &temp  :  status), int, -1);
02953 #     else
02954   ACE_OSCALL_RETURN (pthread_join (waiter_id, status), int, -1);
02955 #     endif
02956 #   else
02957   int result;
02958   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_join (waiter_id, status), result),
02959                      int, -1);
02960 #   endif /* ACE_HAS_PTHREADS_DRAFT4, 6 */
02961 # elif defined (ACE_HAS_WTHREADS)
02962   ACE_UNUSED_ARG (waiter_id);
02963   ACE_UNUSED_ARG (thr_id);
02964   ACE_UNUSED_ARG (status);
02965 
02966   // This could be implemented if the DLL-Main function or the
02967   // task exit base class some log the threads which have exited
02968   ACE_NOTSUP_RETURN (-1);
02969 # endif /* ACE_HAS_STHREADS */
02970 #else
02971   ACE_UNUSED_ARG (waiter_id);
02972   ACE_UNUSED_ARG (thr_id);
02973   ACE_UNUSED_ARG (status);
02974   ACE_NOTSUP_RETURN (-1);
02975 #endif /* ACE_HAS_THREADS */
02976 }

ACE_INLINE int ACE_OS::thr_join ACE_hthread_t  waiter_id,
ACE_THR_FUNC_RETURN *  status
 

Definition at line 2875 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_FAIL_RETURN, ACE_hthread_t, ACE_NOTSUP_RETURN, ACE_OS_TRACE, and thr_join().

Referenced by ACE_Thread::join(), and thr_join().

02877 {
02878   ACE_OS_TRACE ("ACE_OS::thr_join");
02879 #if defined (ACE_HAS_THREADS)
02880 # if defined (ACE_HAS_STHREADS)
02881   int result;
02882   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_join (thr_handle, 0, status), result),
02883                      int, -1);
02884 # elif defined (ACE_HAS_PTHREADS)
02885 #   if defined (ACE_HAS_PTHREADS_DRAFT4) || defined (ACE_HAS_PTHREADS_DRAFT6)
02886   int ace_result;
02887 #     if defined (ACE_LACKS_NULL_PTHREAD_STATUS)
02888   void *temp;
02889   ACE_OSCALL (pthread_join (thr_handle,
02890                               status == 0  ?  &temp  :  status),
02891               int, -1, ace_result);
02892 #     else
02893   ACE_OSCALL (pthread_join (thr_handle, status), int, -1, ace_result);
02894 #     endif /* ACE_LACKS_NULL_PTHREAD_STATUS */
02895   // Joinable threads need to be detached after joining on Pthreads
02896   // draft 4 (at least) to reclaim thread storage.
02897 #     if defined (ACE_HAS_PTHREADS_DRAFT4)
02898   pthread_detach (&thr_handle);
02899 #     endif /* ACE_HAS_PTHREADS_DRAFT4 */
02900 
02901     return ace_result;
02902 
02903 #   else
02904   int result;
02905   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_join (thr_handle, status), result),
02906                      int, -1);
02907 #   endif /* ACE_HAS_PTHREADS_DRAFT4, 6 */
02908 # elif defined (ACE_HAS_WTHREADS)
02909   ACE_THR_FUNC_RETURN local_status = 0;
02910 
02911   // Make sure that status is non-NULL.
02912   if (status == 0)
02913     status = &local_status;
02914 
02915   if (::WaitForSingleObject (thr_handle, INFINITE) == WAIT_OBJECT_0
02916       && ::GetExitCodeThread (thr_handle, status) != FALSE)
02917     {
02918       ::CloseHandle (thr_handle);
02919       return 0;
02920     }
02921   ACE_FAIL_RETURN (-1);
02922   /* NOTREACHED */
02923 # else
02924   ACE_UNUSED_ARG (thr_handle);
02925   ACE_UNUSED_ARG (status);
02926   ACE_NOTSUP_RETURN (-1);
02927 # endif /* ACE_HAS_STHREADS */
02928 #else
02929   ACE_UNUSED_ARG (thr_handle);
02930   ACE_UNUSED_ARG (status);
02931   ACE_NOTSUP_RETURN (-1);
02932 #endif /* ACE_HAS_THREADS */
02933 }

int ACE_OS::thr_key_detach ACE_thread_key_t  key,
void *  inst
 

Note:
the "inst" arg is deprecated. It will be ignored.

Definition at line 4780 of file OS_NS_Thread.cpp.

References ACE_NOTSUP_RETURN, ACE_thread_key_t, and TSS_Cleanup_Instance::valid().

Referenced by ACE_TSS< TYPE >::~ACE_TSS().

04781 {
04782 #if defined (ACE_HAS_WTHREADS) || defined (ACE_HAS_TSS_EMULATION)
04783   TSS_Cleanup_Instance cleanup;
04784   if (cleanup.valid ())
04785     {
04786       return cleanup->thread_detach_key (key);
04787     }
04788   else
04789     {
04790       return -1;
04791     }
04792 #else
04793   ACE_UNUSED_ARG (key);
04794   ACE_NOTSUP_RETURN (-1);
04795 #endif /* ACE_HAS_WTHREADS || ACE_HAS_TSS_EMULATION */
04796 }

int ACE_OS::thr_key_used ACE_thread_key_t  key  ) 
 

Definition at line 4892 of file OS_NS_Thread.cpp.

References ACE_NOTSUP_RETURN, ACE_thread_key_t, and TSS_Cleanup_Instance::valid().

04893 {
04894 #if defined (ACE_WIN32) || defined (ACE_HAS_TSS_EMULATION)
04895   TSS_Cleanup_Instance cleanup;
04896   if (cleanup.valid ())
04897     {
04898       cleanup->thread_use_key (key);
04899       return 0;
04900     }
04901   return -1;
04902 #else
04903   ACE_UNUSED_ARG (key);
04904   ACE_NOTSUP_RETURN (-1);
04905 #endif /* ACE_WIN32 || ACE_HAS_TSS_EMULATION */
04906 }

int ACE_OS::thr_keycreate ACE_thread_key_t key,
ACE_THR_DEST  ,
void *  inst = 0
 

Note:
the "inst" arge is deprecated. It will be ignored.

Definition at line 4959 of file OS_NS_Thread.cpp.

References ACE_NOTSUP_RETURN, ACE_thread_key_t, and TSS_Cleanup_Instance::valid().

Referenced by ACE_Thread::keycreate(), and ACE_TSS_Cleanup::tss_keys().

04966 {
04967   // ACE_OS_TRACE ("ACE_OS::thr_keycreate");
04968 #if defined (ACE_HAS_THREADS)
04969 #   if defined (ACE_HAS_TSS_EMULATION)
04970     if (ACE_TSS_Emulation::next_key (*key) == 0)
04971       {
04972         ACE_TSS_Emulation::tss_destructor (*key, dest);
04973 
04974         // Extract out the thread-specific table instance and stash away
04975         // the key and destructor so that we can free it up later on...
04976         TSS_Cleanup_Instance cleanup (TSS_Cleanup_Instance::CREATE);
04977         if (cleanup.valid ())
04978           {
04979             return cleanup->insert (*key, dest);
04980           }
04981         else
04982           {
04983             return -1;
04984           }
04985       }
04986     else
04987       return -1;
04988 #   elif defined (ACE_HAS_WTHREADS)
04989     if (ACE_OS::thr_keycreate_native (key, dest) == 0)
04990       {
04991         // Extract out the thread-specific table instance and stash away
04992         // the key and destructor so that we can free it up later on...
04993         TSS_Cleanup_Instance cleanup (TSS_Cleanup_Instance::CREATE);
04994         if (cleanup.valid ())
04995           {
04996             return cleanup->insert (*key, dest);
04997           }
04998         else
04999           {
05000             return -1;
05001           }
05002       }
05003     else
05004       return -1;
05005       /* NOTREACHED */
05006 #   elif defined (ACE_HAS_THREAD_SPECIFIC_STORAGE)
05007     return  ACE_OS::thr_keycreate_native (key, dest);
05008 #   else
05009     ACE_UNUSED_ARG (key);
05010     ACE_UNUSED_ARG (dest);
05011     ACE_NOTSUP_RETURN (-1);
05012 #   endif /* ACE_HAS_TSS_EMULATION */
05013 # else /* ACE_HAS_THREADS */
05014   ACE_UNUSED_ARG (key);
05015   ACE_UNUSED_ARG (dest);
05016   ACE_NOTSUP_RETURN (-1);
05017 # endif /* ACE_HAS_THREADS */
05018 }

int ACE_OS::thr_keyfree ACE_thread_key_t  key  ) 
 

Definition at line 5050 of file OS_NS_Thread.cpp.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_thread_key_t, and TSS_Cleanup_Instance::valid().

Referenced by ACE_Thread::keyfree(), and ACE_TSS< TYPE >::~ACE_TSS().

05051 {
05052   ACE_OS_TRACE ("ACE_OS::thr_keyfree");
05053 # if defined (ACE_HAS_THREADS)
05054 #   if defined (ACE_HAS_TSS_EMULATION)
05055     // Release the key in the TSS_Emulation administration
05056     ACE_TSS_Emulation::release_key (key);
05057     TSS_Cleanup_Instance cleanup;
05058     if (cleanup.valid ())
05059       {
05060         return cleanup->free_key (key);
05061       }
05062     return -1;
05063 #   elif defined (ACE_HAS_WTHREADS)
05064     // Extract out the thread-specific table instance and free up
05065     // the key and destructor.
05066     TSS_Cleanup_Instance cleanup;
05067     if (cleanup.valid ())
05068       {
05069         return cleanup->free_key (key);
05070       }
05071     return -1;
05072 #   elif defined (ACE_HAS_THREAD_SPECIFIC_STORAGE)
05073     return ACE_OS::thr_keyfree_native (key);
05074 #   else
05075     ACE_UNUSED_ARG (key);
05076     ACE_NOTSUP_RETURN (-1);
05077 #   endif /* ACE_HAS_TSS_EMULATION */
05078 # else /* ACE_HAS_THREADS */
05079   ACE_UNUSED_ARG (key);
05080   ACE_NOTSUP_RETURN (-1);
05081   return 0;
05082 # endif /* ACE_HAS_THREADS */
05083 }

ACE_INLINE int ACE_OS::thr_kill ACE_thread_t  thr_id,
int  signum
 

Definition at line 2980 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_hthread_t, ACE_NOTSUP_RETURN, ACE_OS_TRACE, kill(), and thr_kill().

Referenced by ACE_Thread::kill(), and thr_kill().

02981 {
02982   ACE_OS_TRACE ("ACE_OS::thr_kill");
02983 #if defined (ACE_HAS_THREADS)
02984 # if defined (ACE_HAS_PTHREADS)
02985 #   if defined (ACE_HAS_PTHREADS_DRAFT4) || defined (ACE_LACKS_PTHREAD_KILL)
02986   ACE_UNUSED_ARG (signum);
02987   ACE_UNUSED_ARG (thr_id);
02988   ACE_NOTSUP_RETURN (-1);
02989 #   else
02990   int result;
02991   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_kill (thr_id, signum),
02992                                        result),
02993                      int, -1);
02994 #   endif /* ACE_HAS_PTHREADS_DRAFT4 */
02995 # elif defined (ACE_HAS_STHREADS)
02996   int result;
02997   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_kill (thr_id, signum),
02998                                        result),
02999                      int, -1);
03000 # elif defined (ACE_VXWORKS)
03001   ACE_hthread_t tid;
03002   ACE_OSCALL (::taskNameToId (thr_id), int, ERROR, tid);
03003 
03004   if (tid == ERROR)
03005     return -1;
03006   else
03007     ACE_OSCALL_RETURN (::kill (tid, signum), int, -1);
03008 
03009 # else
03010   ACE_UNUSED_ARG (thr_id);
03011   ACE_UNUSED_ARG (signum);
03012   ACE_NOTSUP_RETURN (-1);
03013 # endif /* ACE_HAS_STHREADS */
03014 #else
03015   ACE_UNUSED_ARG (thr_id);
03016   ACE_UNUSED_ARG (signum);
03017   ACE_NOTSUP_RETURN (-1);
03018 #endif /* ACE_HAS_THREADS */
03019 }

ACE_INLINE size_t ACE_OS::thr_min_stack void   ) 
 

Definition at line 3022 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_hthread_t, ACE_NOTSUP_RETURN, ACE_OS_TRACE, sysconf(), and thr_self().

03023 {
03024   ACE_OS_TRACE ("ACE_OS::thr_min_stack");
03025 #if defined (ACE_HAS_THREADS)
03026 # if defined (ACE_HAS_STHREADS)
03027 #   if defined (ACE_HAS_THR_MINSTACK)
03028   // Tandem did some weirdo mangling of STHREAD names...
03029   return ::thr_minstack ();
03030 #   else
03031   return ::thr_min_stack ();
03032 #   endif /* !ACE_HAS_THR_MINSTACK */
03033 # elif defined (ACE_HAS_PTHREADS)
03034 #   if defined (_SC_THREAD_STACK_MIN)
03035   return (size_t) ACE_OS::sysconf (_SC_THREAD_STACK_MIN);
03036 #   elif defined (PTHREAD_STACK_MIN)
03037   return PTHREAD_STACK_MIN;
03038 #   else
03039   ACE_NOTSUP_RETURN (0);
03040 #   endif /* _SC_THREAD_STACK_MIN */
03041 # elif defined (ACE_HAS_WTHREADS)
03042   ACE_NOTSUP_RETURN (0);
03043 # elif defined (ACE_VXWORKS)
03044   TASK_DESC taskDesc;
03045   STATUS status;
03046 
03047   ACE_hthread_t tid;
03048   ACE_OS::thr_self (tid);
03049 
03050   ACE_OSCALL (ACE_ADAPT_RETVAL (::taskInfoGet (tid, &taskDesc),
03051                                 status),
03052               STATUS, -1, status);
03053   return status == OK ? taskDesc.td_stackSize : 0;
03054 # else /* Should not happen... */
03055   ACE_NOTSUP_RETURN (0);
03056 # endif /* ACE_HAS_STHREADS */
03057 #else
03058   ACE_NOTSUP_RETURN (0);
03059 #endif /* ACE_HAS_THREADS */
03060 }

ACE_INLINE void ACE_OS::thr_self ACE_hthread_t  ) 
 

Definition at line 3083 of file OS_NS_Thread.inl.

References ACE_hthread_t, and ACE_OS_TRACE.

03084 {
03085   ACE_OS_TRACE ("ACE_OS::thr_self");
03086 #if defined (ACE_HAS_THREADS)
03087 # if defined (ACE_HAS_PTHREADS)
03088   // Note, don't use "::" here since the following call is often a macro.
03089   self = pthread_self ();
03090 # elif defined (ACE_HAS_THREAD_SELF)
03091   self = ::thread_self ();
03092 # elif defined (ACE_HAS_STHREADS)
03093   self = ::thr_self ();
03094 # elif defined (ACE_HAS_WTHREADS)
03095   self = ::GetCurrentThread ();
03096 # elif defined (ACE_VXWORKS)
03097   self = ::taskIdSelf ();
03098 # endif /* ACE_HAS_STHREADS */
03099 #else
03100   self = 1; // Might as well make it the main thread ;-)
03101 #endif /* ACE_HAS_THREADS */
03102 }

ACE_INLINE ACE_thread_t ACE_OS::thr_self void   ) 
 

Definition at line 3063 of file OS_NS_Thread.inl.

References thr_self().

Referenced by ACE_Thread_Control::ACE_Thread_Control(), ACE_Thread_ID::ACE_Thread_ID(), ACE_Thread_Manager::exit(), ACE_Thread_Control::insert(), ACE_OS_Thread_Adapter::invoke(), ACE_Thread_Adapter::invoke_i(), recursive_mutex_cond_unlock(), recursive_mutex_lock(), recursive_mutex_trylock(), recursive_mutex_unlock(), sched_params(), ACE_Thread::self(), thr_create(), thr_exit(), thr_min_stack(), thr_self(), thr_setprio(), ACE_Thread_Manager::thread_desc_self(), and ACE_Timeprobe_Ex< ACE_LOCK, ALLOCATOR >::timeprobe().

03064 {
03065   // ACE_OS_TRACE ("ACE_OS::thr_self");
03066 #if defined (ACE_HAS_THREADS)
03067 # if defined (ACE_HAS_PTHREADS)
03068   // Note, don't use "::" here since the following call is often a macro.
03069   return pthread_self ();
03070 # elif defined (ACE_HAS_STHREADS)
03071   ACE_OSCALL_RETURN (::thr_self (), int, -1);
03072 # elif defined (ACE_HAS_WTHREADS)
03073   return ::GetCurrentThreadId ();
03074 # elif defined (ACE_VXWORKS)
03075   return ::taskName (::taskIdSelf ());
03076 # endif /* ACE_HAS_STHREADS */
03077 #else
03078   return 1; // Might as well make it the first thread ;-)
03079 #endif /* ACE_HAS_THREADS */
03080 }

int ACE_OS::thr_set_affinity ACE_hthread_t  thr_id,
size_t  cpu_set_size,
const cpu_set_t cpu_mask
 

Set the thread affinity

Parameters:
thr_id For NPTL-threads, when ACE_HAS_PTHREAD_SETAFFINITY_NP defined, this is the thread-id. For linux-threads, when ACE_HAS_SCHED_SETAFFINITY defined, it expects a process-id. Since for linux-threads a thread is seen as a process, it does the job.
cpu_set_size The size of the cpu_mask
cpu_mask Is a bitmask of CPUs to bind to, e.g value 1 binds the thread to the "CPU 0", etc

Definition at line 4845 of file OS_NS_Thread.cpp.

References ACE_hthread_t, and ACE_NOTSUP_RETURN.

04848 {
04849 #if defined (ACE_HAS_PTHREAD_SETAFFINITY_NP)
04850   if (::pthread_setaffinity_np (thr_id,
04851                                 cpu_set_size,
04852                                 cpu_mask) != 0)
04853     {
04854       return -1;
04855     }
04856   return 0;
04857 #elif defined (ACE_HAS_2_PARAM_SCHED_SETAFFINITY)
04858   // The process-id is expected as <thr_id>, which can be a thread-id of
04859   // linux-thread, thus making binding to cpu of that particular thread only.
04860   // If you are using this flag for NPTL-threads, however, please pass as a
04861   // thr_id process id obtained by ACE_OS::getpid (), but whole process will bind your CPUs
04862   //
04863   ACE_UNUSED_ARG (cpu_set_size);
04864   if (::sched_setaffinity (thr_id,
04865                            cpu_mask) == -1)
04866     {
04867       return -1;
04868     }
04869   return 0;
04870 #elif defined (ACE_HAS_SCHED_SETAFFINITY)
04871   // The process-id is expected as <thr_id>, which can be a thread-id of
04872   // linux-thread, thus making binding to cpu of that particular thread only.
04873   // If you are using this flag for NPTL-threads, however, please pass as a
04874   // thr_id process id obtained by ACE_OS::getpid (), but whole process will bind your CPUs
04875   //
04876   if (::sched_setaffinity (thr_id,
04877                            cpu_set_size,
04878                            cpu_mask) == -1)
04879     {
04880       return -1;
04881     }
04882   return 0;
04883 #else
04884   ACE_UNUSED_ARG (thr_id);
04885   ACE_UNUSED_ARG (cpu_set_size);
04886   ACE_UNUSED_ARG (cpu_mask);
04887   ACE_NOTSUP_RETURN (-1);
04888 #endif
04889 }

ACE_INLINE int ACE_OS::thr_setcancelstate int  new_state,
int *  old_state
 

Definition at line 3105 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, and ACE_OS_TRACE.

Referenced by ACE_Thread::disablecancel(), ACE_Thread::enablecancel(), and ACE_Thread::setcancelstate().

03106 {
03107   ACE_OS_TRACE ("ACE_OS::thr_setcancelstate");
03108 #if defined (ACE_HAS_THREADS)
03109 # if defined (ACE_HAS_PTHREADS) && !defined (ACE_LACKS_PTHREAD_CANCEL)
03110 #   if defined (ACE_HAS_PTHREADS_DRAFT4)
03111   int old;
03112   old = pthread_setcancel (new_state);
03113   if (old == -1)
03114     return -1;
03115   *old_state = old;
03116   return 0;
03117 #   elif defined (ACE_HAS_PTHREADS_DRAFT6)
03118   ACE_UNUSED_ARG (old_state);
03119   ACE_OSCALL_RETURN (pthread_setintr (new_state), int, -1);
03120 #   else /* this is draft 7 or std */
03121   int result;
03122   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_setcancelstate (new_state,
03123                                                                  old_state),
03124                                        result),
03125                      int, -1);
03126 #   endif /* ACE_HAS_PTHREADS_DRAFT4 */
03127 # elif defined (ACE_HAS_STHREADS)
03128   ACE_UNUSED_ARG (new_state);
03129   ACE_UNUSED_ARG (old_state);
03130   ACE_NOTSUP_RETURN (-1);
03131 # elif defined (ACE_HAS_WTHREADS)
03132   ACE_UNUSED_ARG (new_state);
03133   ACE_UNUSED_ARG (old_state);
03134   ACE_NOTSUP_RETURN (-1);
03135 # else /* Could be ACE_HAS_PTHREADS && ACE_LACKS_PTHREAD_CANCEL */
03136   ACE_UNUSED_ARG (new_state);
03137   ACE_UNUSED_ARG (old_state);
03138   ACE_NOTSUP_RETURN (-1);
03139 # endif /* ACE_HAS_PTHREADS */
03140 #else
03141   ACE_UNUSED_ARG (new_state);
03142   ACE_UNUSED_ARG (old_state);
03143   ACE_NOTSUP_RETURN (-1);
03144 #endif /* ACE_HAS_THREADS */
03145 }

ACE_INLINE int ACE_OS::thr_setcanceltype int  new_type,
int *  old_type
 

Definition at line 3148 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, and ACE_OS_TRACE.

Referenced by ACE_Thread::enablecancel(), and ACE_Thread::setcancelstate().

03149 {
03150   ACE_OS_TRACE ("ACE_OS::thr_setcanceltype");
03151 #if defined (ACE_HAS_THREADS)
03152 # if defined (ACE_HAS_PTHREADS) && !defined (ACE_LACKS_PTHREAD_CANCEL)
03153 #   if defined (ACE_HAS_PTHREADS_DRAFT4)
03154   int old;
03155   old = pthread_setasynccancel (new_type);
03156   if (old == -1)
03157     return -1;
03158   *old_type = old;
03159   return 0;
03160 #   elif defined (ACE_HAS_PTHREADS_DRAFT6)
03161   ACE_UNUSED_ARG (old_type);
03162   ACE_OSCALL_RETURN (pthread_setintrtype (new_type), int, -1);
03163 #   else /* this is draft 7 or std */
03164   int result;
03165   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_setcanceltype (new_type,
03166                                                                 old_type),
03167                                        result),
03168                      int, -1);
03169 #   endif /* ACE_HAS_PTHREADS_DRAFT4 */
03170 # else /* Could be ACE_HAS_PTHREADS && ACE_LACKS_PTHREAD_CANCEL */
03171   ACE_UNUSED_ARG (new_type);
03172   ACE_UNUSED_ARG (old_type);
03173   ACE_NOTSUP_RETURN (-1);
03174 # endif /* ACE_HAS_PTHREADS */
03175 #else
03176   ACE_UNUSED_ARG (new_type);
03177   ACE_UNUSED_ARG (old_type);
03178   ACE_NOTSUP_RETURN (-1);
03179 #endif /* ACE_HAS_THREADS */
03180 }

ACE_INLINE int ACE_OS::thr_setconcurrency int  hint  ) 
 

Definition at line 3183 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, and thr_setconcurrency().

Referenced by ACE_Thread::setconcurrency(), thr_create(), and thr_setconcurrency().

03184 {
03185   ACE_OS_TRACE ("ACE_OS::thr_setconcurrency");
03186 #if defined (ACE_HAS_THREADS)
03187 # if defined (ACE_HAS_STHREADS)
03188   int result;
03189   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_setconcurrency (hint),
03190                                        result),
03191                      int, -1);
03192 # elif defined (ACE_HAS_PTHREADS) && defined (ACE_HAS_PTHREAD_SETCONCURRENCY)
03193   int result;
03194   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_setconcurrency (hint),
03195                                        result),
03196                      int, -1);
03197 # else
03198   ACE_UNUSED_ARG (hint);
03199   ACE_NOTSUP_RETURN (-1);
03200 # endif /* ACE_HAS_STHREADS */
03201 #else
03202   ACE_UNUSED_ARG (hint);
03203   ACE_NOTSUP_RETURN (-1);
03204 #endif /* ACE_HAS_THREADS */
03205 }

int ACE_OS::thr_setprio const ACE_Sched_Priority  prio  ) 
 

Definition at line 5086 of file OS_NS_Thread.cpp.

References ACE_hthread_t, ACE_SCHED_FIFO, ACE_SCHED_OTHER, ACE_Sched_Priority, ACE_SCHED_RR, lwp_getparams(), lwp_setparams(), sched_params(), thr_self(), and thr_setprio().

05087 {
05088   // Set the thread priority on the current thread.
05089   ACE_hthread_t my_thread_id;
05090   ACE_OS::thr_self (my_thread_id);
05091 
05092   int status = ACE_OS::thr_setprio (my_thread_id, prio);
05093 
05094 #if defined (ACE_NEEDS_LWP_PRIO_SET)
05095   // If the thread is in the RT class, then set the priority on its
05096   // LWP.  (Instead of doing this if the thread is in the RT class, it
05097   // should be done for all bound threads.  But, there doesn't appear
05098   // to be an easy way to determine if the thread is bound.)
05099 
05100   if (status == 0)
05101     {
05102       // Find what scheduling class the thread's LWP is in.
05103       ACE_Sched_Params sched_params (ACE_SCHED_OTHER, 0);
05104       if (ACE_OS::lwp_getparams (sched_params) == -1)
05105         {
05106           return -1;
05107         }
05108       else if (sched_params.policy () == ACE_SCHED_FIFO  ||
05109                sched_params.policy () == ACE_SCHED_RR)
05110         {
05111           // This thread's LWP is in the RT class, so we need to set
05112           // its priority.
05113           sched_params.priority (prio);
05114           return ACE_OS::lwp_setparams (sched_params);
05115         }
05116       // else this is not an RT thread.  Nothing more needs to be
05117       // done.
05118     }
05119 #endif /* ACE_NEEDS_LWP_PRIO_SET */
05120 
05121   return status;
05122 }

ACE_INLINE int ACE_OS::thr_setprio ACE_hthread_t  ht_id,
int  priority,
int  policy = -1
 

Definition at line 3208 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_hthread_t, ACE_NOTSUP_RETURN, ACE_OS_TRACE, memset(), and thr_setprio().

Referenced by ACE_OS_Thread_Adapter::invoke(), ACE_Thread_Adapter::invoke_i(), sched_params(), ACE_Thread::setprio(), thr_create(), and thr_setprio().

03209 {
03210   ACE_OS_TRACE ("ACE_OS::thr_setprio");
03211   ACE_UNUSED_ARG (policy);
03212 #if defined (ACE_HAS_THREADS)
03213 # if (defined (ACE_HAS_PTHREADS) && \
03214       (!defined (ACE_LACKS_SETSCHED) || defined (ACE_HAS_PTHREAD_SCHEDPARAM)))
03215 
03216 #   if defined (ACE_HAS_PTHREADS_DRAFT4)
03217   int result;
03218   result = pthread_setprio (ht_id, priority);
03219   return (result == -1 ? -1 : 0);
03220 #   elif defined (ACE_HAS_PTHREADS_DRAFT6)
03221   pthread_attr_t  attr;
03222   if (pthread_getschedattr (ht_id, &attr) == -1)
03223     return -1;
03224   if (pthread_attr_setprio (attr, priority) == -1)
03225     return -1;
03226   return pthread_setschedattr (ht_id, attr);
03227 #   else
03228   int result;
03229   struct sched_param param;
03230   memset ((void *) &param, 0, sizeof param);
03231 
03232   // If <policy> is -1, we don't want to use it for
03233   // pthread_setschedparam().  Instead, obtain policy from
03234   // pthread_getschedparam().
03235   if (policy == -1)
03236     {
03237       ACE_OSCALL (ACE_ADAPT_RETVAL (pthread_getschedparam (ht_id, &policy, &param),
03238                                     result),
03239                   int, -1, result);
03240       if (result == -1)
03241         return result;
03242     }
03243 
03244   param.sched_priority = priority;
03245 
03246   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_setschedparam (ht_id,
03247                                                                 policy,
03248                                                                 &param),
03249                                        result),
03250                      int, -1);
03251 #   endif /* ACE_HAS_PTHREADS_DRAFT4 */
03252 # elif defined (ACE_HAS_STHREADS)
03253   int result;
03254   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_setprio (ht_id, priority),
03255                                        result),
03256                      int, -1);
03257 # elif defined (ACE_HAS_WTHREADS)
03258   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::SetThreadPriority (ht_id, priority),
03259                                           ace_result_),
03260                         int, -1);
03261 # elif defined (ACE_VXWORKS)
03262   ACE_OSCALL_RETURN (::taskPrioritySet (ht_id, priority), int, -1);
03263 # else
03264   // For example, platforms that support Pthreads but LACK_SETSCHED.
03265   ACE_UNUSED_ARG (ht_id);
03266   ACE_UNUSED_ARG (priority);
03267   ACE_NOTSUP_RETURN (-1);
03268 # endif /* ACE_HAS_STHREADS */
03269 #else
03270   ACE_UNUSED_ARG (ht_id);
03271   ACE_UNUSED_ARG (priority);
03272   ACE_NOTSUP_RETURN (-1);
03273 #endif /* ACE_HAS_THREADS */
03274 }

int ACE_OS::thr_setspecific ACE_thread_key_t  key,
void *  data
 

Definition at line 5170 of file OS_NS_Thread.cpp.

References ACE_NOTSUP_RETURN, ACE_thread_key_t, and TSS_Cleanup_Instance::valid().

Referenced by ACE_Thread::setspecific(), and ACE_TSS_Cleanup::tss_keys().

05171 {
05172   // ACE_OS_TRACE ("ACE_OS::thr_setspecific");
05173 #if defined (ACE_HAS_THREADS)
05174 #   if defined (ACE_HAS_TSS_EMULATION)
05175     if (ACE_TSS_Emulation::is_key (key) == 0)
05176       {
05177         errno = EINVAL;
05178         data = 0;
05179         return -1;
05180       }
05181     else
05182       {
05183         ACE_TSS_Emulation::ts_object (key) = data;
05184         TSS_Cleanup_Instance cleanup;
05185         if (cleanup.valid ())
05186           {
05187             cleanup->thread_use_key (key);
05188             // for TSS_Cleanup purposes treat stetting data to zero
05189             // like detaching.  This is a consequence of POSIX allowing
05190             // deletion of a "used" key.
05191             if (data == 0)
05192               {
05193                 cleanup->thread_detach_key (key);
05194               }
05195             return 0;
05196           }
05197         else
05198           {
05199             return -1;
05200           }
05201       }
05202 #   elif defined (ACE_HAS_WTHREADS)
05203     if (ACE_OS::thr_setspecific_native (key, data) == 0)
05204       {
05205         TSS_Cleanup_Instance cleanup;
05206         if (cleanup.valid ())
05207           {
05208             cleanup->thread_use_key (key);
05209             // for TSS_Cleanup purposes treat stetting data to zero
05210             // like detaching.  This is a consequence of POSIX allowing
05211             // deletion of a "used" key.
05212             if (data == 0)
05213               {
05214                 cleanup->thread_detach_key (key);
05215               }
05216             return 0;
05217           }
05218         return -1;
05219       }
05220     return -1;
05221 #   elif defined (ACE_HAS_THREAD_SPECIFIC_STORAGE)
05222       return ACE_OS::thr_setspecific_native (key, data);
05223 #   else /* ACE_HAS_TSS_EMULATION */
05224       ACE_UNUSED_ARG (key);
05225       ACE_UNUSED_ARG (data);
05226       ACE_NOTSUP_RETURN (-1);
05227 #   endif /* ACE_HAS_TSS_EMULATION */
05228 # else /* ACE_HAS_THREADS */
05229   ACE_UNUSED_ARG (key);
05230   ACE_UNUSED_ARG (data);
05231   ACE_NOTSUP_RETURN (-1);
05232 # endif /* ACE_HAS_THREADS */
05233 }

ACE_INLINE int ACE_OS::thr_sigsetmask int  how,
const sigset_t *  nsm,
sigset_t *  osm
 

Definition at line 3277 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, pthread_sigmask(), SIG_BLOCK, SIG_SETMASK, SIG_UNBLOCK, sigprocmask(), and thr_sigsetmask().

Referenced by ACE_Sig_Guard::ACE_Sig_Guard(), ACE_Thread::sigsetmask(), thr_sigsetmask(), and ACE_Sig_Guard::~ACE_Sig_Guard().

03280 {
03281   ACE_OS_TRACE ("ACE_OS::thr_sigsetmask");
03282 #if defined (ACE_HAS_THREADS)
03283 # if defined (ACE_LACKS_PTHREAD_THR_SIGSETMASK)
03284   // DCE threads and Solaris 2.4 have no such function.
03285   ACE_UNUSED_ARG (osm);
03286   ACE_UNUSED_ARG (nsm);
03287   ACE_UNUSED_ARG (how);
03288 
03289   ACE_NOTSUP_RETURN (-1);
03290 # elif defined (ACE_HAS_SIGTHREADMASK)
03291   int result;
03292   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::sigthreadmask (how, nsm, osm),
03293                                        result), int, -1);
03294 # elif defined (ACE_HAS_STHREADS)
03295   int result;
03296   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_sigsetmask (how, nsm, osm),
03297                                        result),
03298                      int, -1);
03299 # elif defined (ACE_HAS_PTHREADS)
03300 #   if defined (AIX)
03301   ACE_OSCALL_RETURN (sigthreadmask (how, nsm, osm), int, -1);
03302   // Draft 4 and 6 implementations will sometimes have a sigprocmask () that
03303   // modifies the calling thread's mask only.  If this is not so for your
03304   // platform, define ACE_LACKS_PTHREAD_THR_SIGSETMASK.
03305 #   elif defined (ACE_HAS_PTHREADS_DRAFT4) || \
03306     defined (ACE_HAS_PTHREADS_DRAFT6) || (defined (_UNICOS) && _UNICOS == 9)
03307   ACE_OSCALL_RETURN (::sigprocmask (how, nsm, osm), int, -1);
03308 #   elif !defined (ACE_LACKS_PTHREAD_SIGMASK)
03309   int result;
03310   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_sigmask (how, nsm, osm),
03311                                        result), int, -1);
03312 #   endif /* AIX */
03313 
03314 #if 0
03315   /* Don't know if anyt platform actually needs this... */
03316   // as far as I can tell, this is now pthread_sigaction() -- jwr
03317   int result;
03318   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_sigaction (how, nsm, osm),
03319                                        result), int, -1);
03320 #endif /* 0 */
03321 
03322 # elif defined (ACE_HAS_WTHREADS)
03323   ACE_UNUSED_ARG (osm);
03324   ACE_UNUSED_ARG (nsm);
03325   ACE_UNUSED_ARG (how);
03326 
03327   ACE_NOTSUP_RETURN (-1);
03328 # elif defined (ACE_VXWORKS)
03329   int old_mask = 0;
03330   switch (how)
03331     {
03332     case SIG_BLOCK:
03333     case SIG_UNBLOCK:
03334       {
03335         // get the old mask
03336                 old_mask = ::sigsetmask (*nsm);
03337         // create a new mask:  the following assumes that sigset_t is 4 bytes,
03338         // which it is on VxWorks 5.2, so bit operations are done simply . . .
03339         ::sigsetmask (how == SIG_BLOCK ? (old_mask |= *nsm) : (old_mask &= ~*nsm));
03340                 if (osm)
03341           *osm = old_mask;
03342         break;
03343       }
03344     case SIG_SETMASK:
03345           old_mask = ::sigsetmask (*nsm);
03346       if (osm)
03347         *osm = old_mask;
03348       break;
03349     default:
03350       return -1;
03351     }
03352 
03353   return 0;
03354 # else /* Should not happen. */
03355   ACE_UNUSED_ARG (how);
03356   ACE_UNUSED_ARG (nsm);
03357   ACE_UNUSED_ARG (osm);
03358   ACE_NOTSUP_RETURN (-1);
03359 # endif /* ACE_LACKS_PTHREAD_THR_SIGSETMASK */
03360 #else
03361   ACE_UNUSED_ARG (how);
03362   ACE_UNUSED_ARG (nsm);
03363   ACE_UNUSED_ARG (osm);
03364   ACE_NOTSUP_RETURN (-1);
03365 #endif /* ACE_HAS_THREADS */
03366 }

ACE_INLINE int ACE_OS::thr_suspend ACE_hthread_t  target_thread  ) 
 

Definition at line 3369 of file OS_NS_Thread.inl.

References ACE_ADAPT_RETVAL, ACE_FAIL_RETURN, ACE_hthread_t, ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_SYSCALL_FAILED, and thr_suspend().

Referenced by ACE_Thread::suspend(), and thr_suspend().

03370 {
03371   ACE_OS_TRACE ("ACE_OS::thr_suspend");
03372 #if defined (ACE_HAS_THREADS)
03373 # if defined (ACE_HAS_STHREADS)
03374   int result;
03375   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_suspend (target_thread), result), int, -1);
03376 # elif defined (ACE_HAS_PTHREADS)
03377 #  if defined (ACE_HAS_PTHREAD_SUSPEND)
03378   int result;
03379   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_suspend (target_thread),
03380                                        result),
03381                      int, -1);
03382 #  elif defined (ACE_HAS_PTHREAD_SUSPEND_NP)
03383   int result;
03384   ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_suspend_np (target_thread),
03385                                        result),
03386                      int, -1);
03387 #  else
03388   ACE_UNUSED_ARG (target_thread);
03389   ACE_NOTSUP_RETURN (-1);
03390 #  endif /* ACE_HAS_PTHREAD_SUSPEND */
03391 # elif defined (ACE_HAS_WTHREADS)
03392   if (::SuspendThread (target_thread) != ACE_SYSCALL_FAILED)
03393     return 0;
03394   else
03395     ACE_FAIL_RETURN (-1);
03396   /* NOTREACHED */
03397 # elif defined (ACE_VXWORKS)
03398   ACE_OSCALL_RETURN (::taskSuspend (target_thread), int, -1);
03399 # endif /* ACE_HAS_STHREADS */
03400 #else
03401   ACE_UNUSED_ARG (target_thread);
03402   ACE_NOTSUP_RETURN (-1);
03403 #endif /* ACE_HAS_THREADS */
03404 }

ACE_INLINE void ACE_OS::thr_testcancel void   ) 
 

Definition at line 3407 of file OS_NS_Thread.inl.

References ACE_OS_TRACE.

Referenced by ACE_Thread::testcancel().

03408 {
03409   ACE_OS_TRACE ("ACE_OS::thr_testcancel");
03410 #if defined (ACE_HAS_THREADS)
03411 # if defined (ACE_HAS_PTHREADS) && !defined (ACE_LACKS_PTHREAD_CANCEL)
03412 #if defined(ACE_HAS_PTHREADS_DRAFT6)
03413   pthread_testintr ();
03414 #else /* ACE_HAS_PTHREADS_DRAFT6 */
03415   pthread_testcancel ();
03416 #endif /* !ACE_HAS_PTHREADS_DRAFT6 */
03417 # elif defined (ACE_HAS_STHREADS)
03418 # elif defined (ACE_HAS_WTHREADS)
03419 # elif defined (ACE_VXWORKS)
03420 # else
03421   // no-op:  can't use ACE_NOTSUP_RETURN because there is no return value
03422 # endif /* ACE_HAS_PTHREADS */
03423 #else
03424 #endif /* ACE_HAS_THREADS */
03425 }

ACE_INLINE void ACE_OS::thr_yield void   ) 
 

Definition at line 3428 of file OS_NS_Thread.inl.

References ACE_OS_TRACE.

Referenced by event_destroy(), event_pulse(), ACE_Condition_Thread_Mutex::remove(), ACE_Condition< MUTEX >::remove(), and ACE_Thread::yield().

03429 {
03430   ACE_OS_TRACE ("ACE_OS::thr_yield");
03431 #if defined (ACE_HAS_THREADS)
03432 # if defined (ACE_HAS_PTHREADS)
03433 #   if defined (ACE_HAS_PTHREADS_STD)
03434   // Note - this is a POSIX.4 function - not a POSIX.1c function...
03435   ::sched_yield ();
03436 #   elif defined (ACE_HAS_PTHREADS_DRAFT6)
03437   pthread_yield (0);
03438 #   else    /* Draft 4 and 7 */
03439   pthread_yield ();
03440 #   endif  /* ACE_HAS_PTHREADS_STD */
03441 # elif defined (ACE_HAS_STHREADS)
03442   ::thr_yield ();
03443 # elif defined (ACE_HAS_WTHREADS)
03444   ::Sleep (0);
03445 # elif defined (ACE_VXWORKS)
03446   // An argument of 0 to ::taskDelay doesn't appear to yield the
03447   // current thread.
03448   // Now, it does seem to work.  The context_switch_time test
03449   // works fine with task_delay set to 0.
03450   ::taskDelay (0);
03451 # endif /* ACE_HAS_STHREADS */
03452 #else
03453   ;
03454 #endif /* ACE_HAS_THREADS */
03455 }

ACE_INLINE int ACE_OS::thread_mutex_destroy ACE_thread_mutex_t *  m  ) 
 

Definition at line 3458 of file OS_NS_Thread.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and mutex_destroy().

Referenced by mutex_destroy(), recursive_mutex_destroy(), ACE_Thread_Mutex::remove(), sema_destroy(), and sema_init().

03459 {
03460   ACE_OS_TRACE ("ACE_OS::thread_mutex_destroy");
03461 #if defined (ACE_HAS_THREADS)
03462 # if defined (ACE_HAS_WTHREADS)
03463   ::DeleteCriticalSection (m);
03464   return 0;
03465 
03466 # elif defined (ACE_HAS_STHREADS) || defined (ACE_HAS_PTHREADS) || defined (ACE_VXWORKS)
03467   return ACE_OS::mutex_destroy (m);
03468 
03469 # endif /* ACE_HAS_STHREADS || ACE_HAS_PTHREADS */
03470 
03471 #else
03472   ACE_UNUSED_ARG (m);
03473   ACE_NOTSUP_RETURN (-1);
03474 
03475 #endif /* ACE_HAS_THREADS */
03476 }

ACE_INLINE int ACE_OS::thread_mutex_init ACE_thread_mutex_t *  m,
int  lock_type,
const wchar_t *  name,
ACE_mutexattr_t *  arg = 0
 

Definition at line 3513 of file OS_NS_Thread.inl.

References ACE_NOTSUP_RETURN, and mutex_init().

03517 {
03518   // ACE_OS_TRACE ("ACE_OS::thread_mutex_init");
03519 #if defined (ACE_HAS_THREADS)
03520 # if defined (ACE_HAS_WTHREADS)
03521   ACE_UNUSED_ARG (lock_type);
03522   ACE_UNUSED_ARG (name);
03523   ACE_UNUSED_ARG (arg);
03524   ::InitializeCriticalSection (m);
03525   return 0;
03526 
03527 # elif defined (ACE_HAS_STHREADS) || defined (ACE_HAS_PTHREADS)
03528   // Force the use of USYNC_THREAD!
03529   return ACE_OS::mutex_init (m, USYNC_THREAD, name, arg, 0, lock_type);
03530 
03531 # elif defined (ACE_VXWORKS)
03532   return mutex_init (m, lock_type, name, arg);
03533 
03534 # endif /* ACE_HAS_STHREADS || ACE_HAS_PTHREADS */
03535 
03536 #else
03537   ACE_UNUSED_ARG (m);
03538   ACE_UNUSED_ARG (lock_type);
03539   ACE_UNUSED_ARG (name);
03540   ACE_UNUSED_ARG (arg);
03541   ACE_NOTSUP_RETURN (-1);
03542 
03543 #endif /* ACE_HAS_THREADS */
03544 }

ACE_INLINE int ACE_OS::thread_mutex_init ACE_thread_mutex_t *  m,
int  lock_type = 0,
const char *  name = 0,
ACE_mutexattr_t *  arg = 0
 

Definition at line 3479 of file OS_NS_Thread.inl.

References ACE_NOTSUP_RETURN, and mutex_init().

Referenced by ACE_Thread_Mutex::ACE_Thread_Mutex(), mutex_init(), recursive_mutex_init(), and sema_init().

03483 {
03484   // ACE_OS_TRACE ("ACE_OS::thread_mutex_init");
03485 #if defined (ACE_HAS_THREADS)
03486 # if defined (ACE_HAS_WTHREADS)
03487   ACE_UNUSED_ARG (lock_type);
03488   ACE_UNUSED_ARG (name);
03489   ACE_UNUSED_ARG (arg);
03490   ::InitializeCriticalSection (m);
03491   return 0;
03492 
03493 # elif defined (ACE_HAS_STHREADS) || defined (ACE_HAS_PTHREADS)
03494   // Force the use of USYNC_THREAD!
03495   return ACE_OS::mutex_init (m, USYNC_THREAD, name, arg, 0, lock_type);
03496 # elif defined (ACE_VXWORKS)
03497   return mutex_init (m, lock_type, name, arg);
03498 
03499 # endif /* ACE_HAS_STHREADS || ACE_HAS_PTHREADS */
03500 
03501 #else
03502   ACE_UNUSED_ARG (m);
03503   ACE_UNUSED_ARG (lock_type);
03504   ACE_UNUSED_ARG (name);
03505   ACE_UNUSED_ARG (arg);
03506   ACE_NOTSUP_RETURN (-1);
03507 
03508 #endif /* ACE_HAS_THREADS */
03509 }

ACE_INLINE int ACE_OS::thread_mutex_lock ACE_thread_mutex_t *  m,
const ACE_Time_Value timeout
 

Definition at line 3590 of file OS_NS_Thread.inl.

References thread_mutex_lock().

03592 {
03593   return timeout == 0
03594     ? ACE_OS::thread_mutex_lock (m)
03595     : ACE_OS::thread_mutex_lock (m, *timeout);
03596 }

ACE_INLINE int ACE_OS::thread_mutex_lock ACE_thread_mutex_t *  m,
const ACE_Time_Value timeout
 

Definition at line 3565 of file OS_NS_Thread.inl.

References ACE_NOTSUP_RETURN, and mutex_lock().

03567 {
03568   // ACE_OS_TRACE ("ACE_OS::thread_mutex_lock");
03569 
03570   // For all platforms, except MS Windows, this method is equivalent
03571   // to calling ACE_OS::mutex_lock() since ACE_thread_mutex_t and
03572   // ACE_mutex_t are the same type.  However, those typedefs evaluate
03573   // to different types on MS Windows.  The "thread mutex"
03574   // implementation in ACE for MS Windows cannot readily support
03575   // timeouts due to a lack of timeout features for this type of MS
03576   // Windows synchronization mechanism.
03577 
03578 #if defined (ACE_HAS_THREADS) && !defined (ACE_HAS_WTHREADS)
03579 # if defined (ACE_HAS_STHREADS) || defined (ACE_HAS_PTHREADS) || defined (ACE_VXWORKS)
03580   return ACE_OS::mutex_lock (m, timeout);
03581 #endif /* ACE_HAS_STHREADS || ACE_HAS_PTHREADS || VXWORKS */
03582 #else
03583   ACE_UNUSED_ARG (m);
03584   ACE_UNUSED_ARG (timeout);
03585   ACE_NOTSUP_RETURN (-1);
03586 #endif /* ACE_HAS_THREADS */
03587 }

ACE_INLINE int ACE_OS::thread_mutex_lock ACE_thread_mutex_t *  m  ) 
 

Definition at line 3548 of file OS_NS_Thread.inl.

References ACE_NOTSUP_RETURN, and mutex_lock().

Referenced by ACE_Thread_Mutex::acquire(), ACE_Thread_Mutex::acquire_read(), ACE_Thread_Mutex::acquire_write(), ACE_Log_Msg::close(), ACE_Log_Msg::instance(), mutex_lock(), open(), recursive_mutex_cond_unlock(), recursive_mutex_lock(), recursive_mutex_trylock(), recursive_mutex_unlock(), sema_init(), sema_post(), sema_trywait(), sema_wait(), and thread_mutex_lock().

03549 {
03550   // ACE_OS_TRACE ("ACE_OS::thread_mutex_lock");
03551 #if defined (ACE_HAS_THREADS)
03552 # if defined (ACE_HAS_WTHREADS)
03553   ::EnterCriticalSection (m);
03554   return 0;
03555 # elif defined (ACE_HAS_STHREADS) || defined (ACE_HAS_PTHREADS) || defined (ACE_VXWORKS)
03556   return ACE_OS::mutex_lock (m);
03557 # endif /* ACE_HAS_STHREADS || ACE_HAS_PTHREADS || VXWORKS */
03558 #else
03559   ACE_UNUSED_ARG (m);
03560   ACE_NOTSUP_RETURN (-1);
03561 #endif /* ACE_HAS_THREADS */
03562 }

ACE_INLINE int ACE_OS::thread_mutex_trylock ACE_thread_mutex_t *  m  ) 
 

Definition at line 3599 of file OS_NS_Thread.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, EBUSY, and mutex_trylock().

Referenced by mutex_trylock(), recursive_mutex_trylock(), ACE_Thread_Mutex::tryacquire(), ACE_Thread_Mutex::tryacquire_read(), and ACE_Thread_Mutex::tryacquire_write().

03600 {
03601   ACE_OS_TRACE ("ACE_OS::thread_mutex_trylock");
03602 
03603 #if defined (ACE_HAS_THREADS)
03604 # if defined (ACE_HAS_WTHREADS)
03605 #   if defined (ACE_HAS_WIN32_TRYLOCK)
03606   BOOL result = ::TryEnterCriticalSection (m);
03607   if (result == TRUE)
03608     return 0;
03609   else
03610     {
03611       errno = EBUSY;
03612       return -1;
03613     }
03614 #   else
03615   ACE_UNUSED_ARG (m);
03616   ACE_NOTSUP_RETURN (-1);
03617 #   endif /* ACE_HAS_WIN32_TRYLOCK */
03618 # elif defined (ACE_HAS_STHREADS) || defined (ACE_HAS_PTHREADS) || defined (ACE_VXWORKS)
03619   return ACE_OS::mutex_trylock (m);
03620 #endif /* Threads variety case */
03621 
03622 #else
03623   ACE_UNUSED_ARG (m);
03624   ACE_NOTSUP_RETURN (-1);
03625 #endif /* ACE_HAS_THREADS */
03626 }

ACE_INLINE int ACE_OS::thread_mutex_unlock ACE_thread_mutex_t *  m  ) 
 

Definition at line 3629 of file OS_NS_Thread.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and mutex_unlock().

Referenced by ACE_Log_Msg::close(), ACE_Log_Msg::instance(), mutex_unlock(), recursive_mutex_cond_relock(), recursive_mutex_cond_unlock(), recursive_mutex_lock(), recursive_mutex_trylock(), recursive_mutex_unlock(), ACE_Thread_Mutex::release(), sema_init(), sema_post(), sema_trywait(), and sema_wait().

03630 {
03631   ACE_OS_TRACE ("ACE_OS::thread_mutex_unlock");
03632 #if defined (ACE_HAS_THREADS)
03633 # if defined (ACE_HAS_WTHREADS)
03634   ::LeaveCriticalSection (m);
03635   return 0;
03636 # elif defined (ACE_HAS_STHREADS) || defined (ACE_HAS_PTHREADS) || defined (ACE_VXWORKS)
03637   return ACE_OS::mutex_unlock (m);
03638 # endif /* Threads variety case */
03639 #else
03640   ACE_UNUSED_ARG (m);
03641   ACE_NOTSUP_RETURN (-1);
03642 #endif /* ACE_HAS_THREADS */
03643 }

ACE_INLINE time_t ACE_OS::time time_t *  tloc = 0  ) 
 

Definition at line 434 of file OS_NS_time.inl.

References ACE_OS_TRACE, gettimeofday(), ACE_Time_Value::sec(), and time().

Referenced by ACE_System_Time::get_local_system_time(), ACE_Service_Config::reconfigure(), and time().

00435 {
00436   ACE_OS_TRACE ("ACE_OS::time");
00437 #if !defined (ACE_HAS_WINCE)
00438   ACE_OSCALL_RETURN (::time (tloc), time_t, (time_t) -1);
00439 #else
00440   time_t retv = ACE_OS::gettimeofday ().sec ();
00441   if (tloc)
00442     *tloc = retv;
00443   return retv;
00444 #endif /* ACE_HAS_WINCE */
00445 }

ACE_INLINE long ACE_OS::timezone void   ) 
 

Definition at line 458 of file OS_NS_time.inl.

References ace_timezone().

00459 {
00460   return ::ace_timezone ();
00461 }

ACE_INLINE int ACE_OS::truncate const ACE_TCHAR filename,
ACE_LOFF_T  length
 

Definition at line 981 of file OS_NS_unistd.inl.

References ACE_ADAPT_RETVAL, ACE_DEFAULT_FILE_PERMS, ACE_FAIL_RETURN, ACE_LOFF_T, ACE_NOTSUP_RETURN, ACE_OS_TRACE, ACE_TCHAR, ACE_TEXT_ALWAYS_CHAR, and open().

00983 {
00984   ACE_OS_TRACE ("ACE_OS::truncate");
00985 #if defined (ACE_WIN32)
00986   ACE_HANDLE handle = ACE_OS::open (filename,
00987                                     O_WRONLY,
00988                                     ACE_DEFAULT_FILE_PERMS);
00989 
00990   LARGE_INTEGER loffset;
00991   loffset.QuadPart = offset;
00992   if (handle == ACE_INVALID_HANDLE)
00993     ACE_FAIL_RETURN (-1);
00994 #  if !defined (ACE_LACKS_SETFILEPOINTEREX)
00995   else if (::SetFilePointerEx (handle,
00996                                loffset,
00997                                0,
00998                                FILE_BEGIN) != (unsigned) -1)
00999 #  else
01000   else if (::SetFilePointer (handle,
01001                              offset,
01002                              0,
01003                              FILE_BEGIN) != (unsigned) -1)
01004 #  endif
01005     {
01006       BOOL result = ::SetEndOfFile (handle);
01007       ::CloseHandle (handle);
01008       ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (result, ace_result_), int, -1);
01009     }
01010   else
01011     {
01012       ::CloseHandle (handle);
01013       ACE_FAIL_RETURN (-1);
01014     }
01015   /* NOTREACHED */
01016 #elif !defined (ACE_LACKS_TRUNCATE)
01017   ACE_OSCALL_RETURN
01018     (::truncate (ACE_TEXT_ALWAYS_CHAR (filename), offset), int, -1);
01019 #else
01020   ACE_UNUSED_ARG (filename);
01021   ACE_UNUSED_ARG (offset);
01022   ACE_NOTSUP_RETURN (-1);
01023 #endif /* ACE_WIN32 */
01024 }

ACE_INLINE void ACE_OS::tzset void   ) 
 

Definition at line 465 of file OS_NS_time.inl.

References ENOTSUP.

00466 {
00467 #if !defined (ACE_HAS_WINCE) && !defined (ACE_VXWORKS) && !defined(__rtems__) && !defined (ACE_HAS_DINKUM_STL)
00468 #   if defined (ACE_WIN32)
00469   ::_tzset ();  // For Win32.
00470 #   else
00471   ::tzset ();   // For UNIX platforms.
00472 #   endif /* ACE_WIN32 */
00473 # else
00474   errno = ENOTSUP;
00475 # endif /* ACE_HAS_WINCE && !VXWORKS && !__rtems__ && !ACE_HAS_DINKUM_STL */
00476 }

ACE_INLINE u_long ACE_OS::ualarm const ACE_Time_Value tv,
const ACE_Time_Value tv_interval = ACE_Time_Value::zero
 

Definition at line 1044 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_ONE_SECOND_IN_USECS, ACE_OS_TRACE, ACE_Time_Value::sec(), and ACE_Time_Value::usec().

01046 {
01047   ACE_OS_TRACE ("ACE_OS::ualarm");
01048 
01049 #if defined (ACE_HAS_UALARM)
01050   u_long usecs = (tv.sec () * ACE_ONE_SECOND_IN_USECS) + tv.usec ();
01051   u_long interval = (tv_interval.sec () * ACE_ONE_SECOND_IN_USECS) + tv_interval.usec ();
01052   return ::ualarm (usecs, interval);
01053 #elif !defined (ACE_LACKS_UNIX_SIGNALS)
01054   ACE_UNUSED_ARG (tv_interval);
01055   return ::alarm (tv.sec ());
01056 #else
01057   ACE_UNUSED_ARG (tv_interval);
01058   ACE_UNUSED_ARG (tv);
01059   ACE_NOTSUP_RETURN (0);
01060 #endif /* ACE_HAS_UALARM */
01061 }

ACE_INLINE u_long ACE_OS::ualarm u_long  usecs,
u_long  interval = 0
 

Definition at line 1027 of file OS_NS_unistd.inl.

References ACE_NOTSUP_RETURN, ACE_ONE_SECOND_IN_USECS, and ACE_OS_TRACE.

Referenced by ACE_Async_Timer_Queue_Adapter< TQ >::schedule_ualarm().

01028 {
01029   ACE_OS_TRACE ("ACE_OS::ualarm");
01030 
01031 #if defined (ACE_HAS_UALARM)
01032   return ::ualarm (usecs, interval);
01033 #elif !defined (ACE_LACKS_UNIX_SIGNALS)
01034   ACE_UNUSED_ARG (interval);
01035   return ::alarm (usecs * ACE_ONE_SECOND_IN_USECS);
01036 #else
01037   ACE_UNUSED_ARG (usecs);
01038   ACE_UNUSED_ARG (interval);
01039   ACE_NOTSUP_RETURN (0);
01040 #endif /* ACE_HAS_UALARM */
01041 }

ACE_INLINE mode_t ACE_OS::umask mode_t  cmask  ) 
 

Definition at line 296 of file OS_NS_sys_stat.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and mode_t.

Referenced by ACE::daemonize().

00297   {
00298     ACE_OS_TRACE ("ACE_OS::umask");
00299 # if defined (ACE_LACKS_UMASK)
00300     ACE_UNUSED_ARG (cmask);
00301     ACE_NOTSUP_RETURN ((mode_t)-1);
00302 # elif defined (ACE_WIN32) && !defined (__BORLANDC__)
00303     ACE_OSCALL_RETURN (::_umask (cmask), mode_t, -1);
00304 # else
00305     return ::umask (cmask); // This call shouldn't fail...
00306 # endif /* ACE_LACKS_UMASK */
00307   }

ACE_BEGIN_VERSIONED_NAMESPACE_DECL int ACE_OS::uname ACE_utsname name  ) 
 

Definition at line 19 of file OS_NS_sys_utsname.cpp.

References ACE_LIB_TEXT, ACE_OS_TRACE, ACE_TCHAR, hostname(), sprintf(), strcat(), strcpy(), and uname().

Referenced by sema_init(), and uname().

00020 {
00021   ACE_OS_TRACE ("ACE_OS::uname");
00022 #if !defined (ACE_LACKS_UNAME)
00023   ACE_OSCALL_RETURN (::uname (name), int, -1);
00024 #elif defined (ACE_WIN32)
00025   size_t maxnamelen = sizeof name->nodename;
00026   ACE_OS::strcpy (name->sysname,
00027                   ACE_LIB_TEXT ("Win32"));
00028 
00029   OSVERSIONINFO vinfo;
00030   vinfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
00031   ::GetVersionEx (&vinfo);
00032 
00033   SYSTEM_INFO sinfo;
00034 #   if defined (ACE_HAS_PHARLAP)
00035   // PharLap doesn't do GetSystemInfo.  What's really wanted is the
00036   // CPU architecture, so we can get that with EtsGetSystemInfo. Fill
00037   // in what's wanted in the SYSTEM_INFO structure, and carry on. Note
00038   // that the CPU type values in EK_KERNELINFO have the same values
00039   // are the ones defined for SYSTEM_INFO.
00040   EK_KERNELINFO ets_kern;
00041   EK_SYSTEMINFO ets_sys;
00042   EtsGetSystemInfo (&ets_kern, &ets_sys);
00043   sinfo.wProcessorLevel = static_cast<WORD> (ets_kern.CpuType);
00044   sinfo.wProcessorArchitecture = PROCESSOR_ARCHITECTURE_INTEL;
00045   sinfo.dwProcessorType = ets_kern.CpuType * 100 + 86;
00046 #   else
00047   ::GetSystemInfo(&sinfo);
00048 
00049   ACE_OS::strcpy (name->sysname, ACE_LIB_TEXT ("Win32"));
00050 #   endif /* ACE_HAS_PHARLAP */
00051 
00052   const ACE_TCHAR* unknown = ACE_LIB_TEXT ("???");
00053 
00054   if (
00055       vinfo.dwPlatformId == VER_PLATFORM_WIN32_NT
00056 #   if defined (VER_PLATFORM_WIN32_CE)
00057       || vinfo.dwPlatformId == VER_PLATFORM_WIN32_CE
00058 #   endif
00059       )
00060     {
00061       // Get information from the two structures
00062       const ACE_TCHAR *os;
00063       if (vinfo.dwPlatformId == VER_PLATFORM_WIN32_NT)
00064         os = ACE_LIB_TEXT ("Windows NT %d.%d");
00065       else
00066         os = ACE_LIB_TEXT ("Windows CE %d.%d");
00067       ACE_OS::sprintf (name->release,
00068                        os,
00069                        (int) vinfo.dwMajorVersion,
00070                        (int) vinfo.dwMinorVersion);
00071       ACE_OS::sprintf (name->version,
00072                        ACE_LIB_TEXT ("Build %d %s"),
00073                        (int) vinfo.dwBuildNumber,
00074                        vinfo.szCSDVersion);
00075 
00076       // We have to make sure that the size of (processor + subtype)
00077       // is not greater than the size of name->machine.  So we give
00078       // half the space to the processor and half the space to
00079       // subtype.  The -1 is necessary for because of the space
00080       // between processor and subtype in the machine name.
00081       const int bufsize = ((sizeof (name->machine) / sizeof (ACE_TCHAR)) / 2) - 1;
00082       ACE_TCHAR processor[bufsize] = ACE_LIB_TEXT ("Unknown");
00083       ACE_TCHAR subtype[bufsize] = ACE_LIB_TEXT ("Unknown");
00084 
00085 #   if defined (ghs)
00086     WORD arch = sinfo.u.s.wProcessorArchitecture;
00087 #   else
00088     WORD arch = sinfo.wProcessorArchitecture;
00089 #   endif
00090 
00091       switch (arch)
00092         {
00093         case PROCESSOR_ARCHITECTURE_INTEL:
00094           ACE_OS::strcpy (processor, ACE_LIB_TEXT ("Intel"));
00095           if (sinfo.wProcessorLevel == 3)
00096             ACE_OS::strcpy (subtype, ACE_LIB_TEXT ("80386"));
00097           else if (sinfo.wProcessorLevel == 4)
00098             ACE_OS::strcpy (subtype, ACE_LIB_TEXT ("80486"));
00099           else if (sinfo.wProcessorLevel == 5)
00100             ACE_OS::strcpy (subtype, ACE_LIB_TEXT ("Pentium"));
00101           else if (sinfo.wProcessorLevel == 6)
00102             ACE_OS::strcpy (subtype, ACE_LIB_TEXT ("Pentium Pro"));
00103           else if (sinfo.wProcessorLevel == 7)  // I'm guessing here
00104             ACE_OS::strcpy (subtype, ACE_LIB_TEXT ("Pentium II"));
00105           break;
00106         case PROCESSOR_ARCHITECTURE_MIPS:
00107           ACE_OS::strcpy (processor, ACE_LIB_TEXT ("MIPS"));
00108           ACE_OS::strcpy (subtype, ACE_LIB_TEXT ("R4000"));
00109           break;
00110         case PROCESSOR_ARCHITECTURE_ALPHA:
00111           ACE_OS::strcpy (processor, ACE_LIB_TEXT ("Alpha"));
00112           ACE_OS::sprintf (subtype, ACE_LIB_TEXT ("%d"), sinfo.wProcessorLevel);
00113           break;
00114         case PROCESSOR_ARCHITECTURE_PPC:
00115           ACE_OS::strcpy (processor, ACE_LIB_TEXT ("PPC"));
00116           if (sinfo.wProcessorLevel == 1)
00117             ACE_OS::strcpy (subtype, ACE_LIB_TEXT ("601"));
00118           else if (sinfo.wProcessorLevel == 3)
00119             ACE_OS::strcpy (subtype, ACE_LIB_TEXT ("603"));
00120           else if (sinfo.wProcessorLevel == 4)
00121             ACE_OS::strcpy (subtype, ACE_LIB_TEXT ("604"));
00122           else if (sinfo.wProcessorLevel == 6)
00123             ACE_OS::strcpy (subtype, ACE_LIB_TEXT ("603+"));
00124           else if (sinfo.wProcessorLevel == 9)
00125             ACE_OS::strcpy (subtype, ACE_LIB_TEXT ("804+"));
00126           else if (sinfo.wProcessorLevel == 20)
00127             ACE_OS::strcpy (subtype, ACE_LIB_TEXT ("620"));
00128           break;
00129 #     if defined PROCESSOR_ARCHITECTURE_IA64
00130         case PROCESSOR_ARCHITECTURE_IA64:
00131           ACE_OS::strcpy (processor, ACE_LIB_TEXT ("Itanium"));
00132           ACE_OS::sprintf (subtype, ACE_LIB_TEXT ("%d"),
00133                            sinfo.wProcessorLevel);
00134           break;
00135 #     endif
00136 #     if defined PROCESSOR_ARCHITECTURE_AMD64
00137         case PROCESSOR_ARCHITECTURE_AMD64:
00138           ACE_OS::strcpy (processor, ACE_LIB_TEXT ("x64"));
00139           ACE_OS::sprintf (subtype, ACE_LIB_TEXT ("%d"),
00140                            sinfo.wProcessorLevel);
00141           break;
00142 #     endif
00143 #     if defined PROCESSOR_ARCHITECTURE_IA32_ON_WIN64
00144         case PROCESSOR_ARCHITECTURE_IA32_ON_WIN64:
00145           ACE_OS::strcpy (processor, ACE_LIB_TEXT ("WOW64"));
00146           ACE_OS::sprintf (subtype, ACE_LIB_TEXT ("%d"),
00147                            sinfo.wProcessorLevel);
00148           break;
00149 #     endif
00150 #     if defined PROCESSOR_ARCHITECTURE_ARM
00151         case PROCESSOR_ARCHITECTURE_ARM:
00152           ACE_OS::strcpy (processor, ACE_LIB_TEXT ("ARM"));
00153           ACE_OS::sprintf (subtype, ACE_LIB_TEXT ("%d"),
00154                            sinfo.wProcessorLevel);
00155           break;
00156 #     endif
00157         case PROCESSOR_ARCHITECTURE_UNKNOWN:
00158         default:
00159           // @@ We could provide WinCE specific info here.  But let's
00160           //    defer that to some later point.
00161           ACE_OS::strcpy (processor, ACE_LIB_TEXT ("Unknown"));
00162           break;
00163         }
00164       ACE_OS::sprintf (name->machine,
00165                        ACE_LIB_TEXT ("%s %s"),
00166                        processor, subtype);
00167     }
00168   else if (vinfo.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS)
00169     {
00170       if (vinfo.dwMajorVersion == 4 && vinfo.dwMinorVersion == 0)
00171         {
00172           ACE_OS::strcpy (name->release, ACE_LIB_TEXT ("Windows 95"));
00173           if (vinfo.szCSDVersion[1] == 'C')
00174             ACE_OS::strcat (name->release, ACE_LIB_TEXT (" OSR2"));
00175         }
00176       else if (vinfo.dwMajorVersion == 4 && vinfo.dwMinorVersion == 10)
00177         {
00178           ACE_OS::strcpy (name->release, ACE_LIB_TEXT ("Windows 98"));
00179           if (vinfo.szCSDVersion[1] == 'A')
00180             ACE_OS::strcat (name->release, ACE_LIB_TEXT (" SE"));
00181         }
00182       else if (vinfo.dwMajorVersion == 4 && vinfo.dwMinorVersion == 90)
00183         {
00184           ACE_OS::strcpy (name->release, ACE_LIB_TEXT ("Windows Me"));
00185         }
00186       else
00187         {
00188           ACE_OS::strcpy (name->release, unknown);
00189         }
00190 
00191       ACE_OS::sprintf (name->version, ACE_LIB_TEXT ("%d"),
00192                        LOWORD (vinfo.dwBuildNumber));
00193       if (sinfo.dwProcessorType == PROCESSOR_INTEL_386)
00194         ACE_OS::strcpy (name->machine, ACE_LIB_TEXT ("Intel 80386"));
00195       else if (sinfo.dwProcessorType == PROCESSOR_INTEL_486)
00196         ACE_OS::strcpy (name->machine, ACE_LIB_TEXT ("Intel 80486"));
00197       else if (sinfo.dwProcessorType == PROCESSOR_INTEL_PENTIUM)
00198         ACE_OS::strcpy (name->machine, ACE_LIB_TEXT ("Intel Pentium"));
00199       else
00200         ACE_OS::strcpy (name->machine, unknown);
00201     }
00202   else
00203     {
00204       // We don't know what this is!
00205 
00206       ACE_OS::strcpy (name->release, unknown);
00207       ACE_OS::strcpy (name->version, unknown);
00208       ACE_OS::strcpy (name->machine, unknown);
00209     }
00210 
00211 # if defined (ACE_LACKS_HOSTNAME)
00212   return 0;
00213 # else /* ACE_LACKS_HOSTNAME */
00214   return ACE_OS::hostname (name->nodename, maxnamelen);
00215 # endif /* ACE_LACKS_HOSTNAME */
00216 
00217 #elif defined (ACE_VXWORKS)
00218   size_t maxnamelen = sizeof name->nodename;
00219   ACE_OS::strcpy (name->sysname, "VxWorks");
00220   ACE_OS::strcpy (name->release, "???");
00221   ACE_OS::strcpy (name->version, sysBspRev ());
00222   ACE_OS::strcpy (name->machine, sysModel ());
00223 
00224   return ACE_OS::hostname (name->nodename, maxnamelen);
00225 #elif defined (INTEGRITY)
00226   if(!name) {
00227     errno = EFAULT;
00228     return -1;
00229   }
00230   strcpy(name->sysname,"INTEGRITY");
00231   int status = gethostname(name->nodename,_SYS_NMLN);
00232   strcpy(name->release,"4.0");
00233   strcpy(name->version,"4.0.9");
00234   strcpy(name->machine,"a standard name");
00235   return status;
00236 #endif /* ACE_WIN32 */
00237 }

ACE_NAMESPACE_INLINE_FUNCTION wint_t ungetwc wint_t  c,
FILE *  fp
 

void ACE_OS::unique_name const void *  object,
char *  name,
size_t  length
 

This method uses process id and object pointer to come up with a machine wide unique name. The process ID will provide uniqueness between processes on the same machine. The "this" pointer of the will provide uniqueness between other "live" objects in the same process. The uniqueness of this name is therefore only valid for the life of .

Definition at line 5236 of file OS_NS_Thread.cpp.

References ACE_UNIQUE_NAME_LEN, sprintf(), and strsncpy().

Referenced by ACE_MEM_Acceptor::accept(), sema_init(), ACE_DLL::set_handle(), and ACE::unique_name().

05239 {
05240   // The process ID will provide uniqueness between processes on the
05241   // same machine. The "this" pointer of the <object> will provide
05242   // uniqueness between other "live" objects in the same process. The
05243   // uniqueness of this name is therefore only valid for the life of
05244   // <object>.
05245   char temp_name[ACE_UNIQUE_NAME_LEN];
05246   ACE_OS::sprintf (temp_name,
05247                    "%p%d",
05248                    object,
05249                    static_cast <int> (ACE_OS::getpid ()));
05250   ACE_OS::strsncpy (name,
05251                     temp_name,
05252                     length);
05253 }

ACE_INLINE int ACE_OS::unlink const wchar_t *  path  ) 
 

Definition at line 1083 of file OS_NS_unistd.inl.

References ACE_ADAPT_RETVAL, ACE_OS_TRACE, and unlink().

01084 {
01085   ACE_OS_TRACE ("ACE_OS::unlink");
01086 # if defined (ACE_HAS_WINCE)
01087   // @@ The problem is, DeleteFile is not actually equals to unlink. ;(
01088   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::DeleteFileW (path), ace_result_),
01089                         int, -1);
01090 # elif defined (ACE_WIN32)
01091   ACE_OSCALL_RETURN (::_wunlink (path), int, -1);
01092 # else
01093   ACE_Wide_To_Ascii npath (path);
01094   return ACE_OS::unlink (npath.char_rep ());
01095 # endif /* ACE_HAS_WINCE */
01096 }

ACE_INLINE int ACE_OS::unlink const char *  path  ) 
 

Definition at line 1064 of file OS_NS_unistd.inl.

References ACE_ADAPT_RETVAL, ACE_NOTSUP_RETURN, ACE_OS_TRACE, and ACE_TEXT_CHAR_TO_TCHAR.

Referenced by ACE_MEM_Acceptor::accept(), flock_destroy(), ACE_Logging_Strategy::handle_timeout(), ACE::open_temp_file(), ACE_Filecache_Object::release(), ACE_SPIPE_Acceptor::remove(), ACE_SPIPE::remove(), ACE_Mem_Map::remove(), ACE_LSOCK_Acceptor::remove(), ACE_FILE::remove(), ACE_FIFO::remove(), sema_destroy(), sema_init(), shm_unlink(), unlink(), and ACE_FILE::unlink().

01065 {
01066   ACE_OS_TRACE ("ACE_OS::unlink");
01067 # if defined (ACE_HAS_NONCONST_UNLINK)
01068   ACE_OSCALL_RETURN (::unlink (const_cast<char *> (path)), int, -1);
01069 # elif defined (ACE_HAS_WINCE)
01070   // @@ The problem is, DeleteFile is not actually equals to unlink. ;(
01071   ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::DeleteFile (ACE_TEXT_CHAR_TO_TCHAR (path)), ace_result_),
01072                         int, -1);
01073 # elif defined (ACE_LACKS_UNLINK)
01074   ACE_UNUSED_ARG (path);
01075   ACE_NOTSUP_RETURN (-1);
01076 # else
01077   ACE_OSCALL_RETURN (::unlink (path), int, -1);
01078 # endif /* ACE_HAS_NONCONST_UNLINK */
01079 }

ACE_INLINE int ACE_OS::vsnprintf wchar_t *  buffer,
size_t  maxlen,
const wchar_t *  format,
va_list  argptr
 

Definition at line 985 of file OS_NS_stdio.inl.

References ACE_NOTSUP_RETURN, and ACE_SPRINTF_ADAPTER.

00986 {
00987 # if (defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) >= 500) || \
00988      (defined (sun) && !(defined(_XOPEN_SOURCE) && (_XOPEN_VERSION-0==4))) || \
00989      (defined (ACE_HAS_DINKUM_STL) || defined (__DMC__))
00990 
00991   return vswprintf (buffer, maxlen, format, ap);
00992 
00993 # elif defined (ACE_WIN32)
00994 
00995   int result =
00996     ACE_SPRINTF_ADAPTER (::_vsnwprintf (buffer, maxlen, format, ap));
00997 
00998   // Win32 doesn't regard a full buffer with no 0-terminate as an
00999   // overrun.
01000   if (result == static_cast<int> (maxlen))
01001     result = -1;
01002 
01003   // Win32 doesn't 0-terminate the string if it overruns maxlen.
01004   if (result == -1)
01005     buffer[maxlen-1] = '\0';
01006 
01007   return result;
01008 
01009 # else
01010 
01011   ACE_UNUSED_ARG (buffer);
01012   ACE_UNUSED_ARG (maxlen);
01013   ACE_UNUSED_ARG (format);
01014   ACE_UNUSED_ARG (ap);
01015   ACE_NOTSUP_RETURN (-1);
01016 
01017 # endif /* platforms with a variant of vswprintf */
01018 }

ACE_INLINE int ACE_OS::vsnprintf char *  buffer,
size_t  maxlen,
const char *  format,
va_list  argptr
 

Definition at line 919 of file OS_NS_stdio.inl.

References ACE_NOTSUP_RETURN, ACE_SPRINTF_ADAPTER, and vsnprintf().

Referenced by ACE_Process_Options::command_line(), snprintf(), and vsnprintf().

00920 {
00921 #if defined (ACE_HAS_SNPRINTF)
00922 
00923 #  if !defined (ACE_WIN32) \
00924    || (defined (__BORLANDC__) && (__BORLANDC__ >= 0x600))
00925   return ACE_SPRINTF_ADAPTER (::vsnprintf (buffer, maxlen, format, ap));
00926 #  else
00927 
00928   int result =
00929     ACE_SPRINTF_ADAPTER (::_vsnprintf (buffer, maxlen, format, ap));
00930 
00931   // Win32 doesn't regard a full buffer with no 0-terminate as an
00932   // overrun.
00933   if (result == static_cast<int> (maxlen))
00934     result = -1;
00935 
00936   // Win32 doesn't 0-terminate the string if it overruns maxlen.
00937   if (result == -1)
00938     buffer[maxlen-1] = '\0';
00939 
00940   return result;
00941 
00942 # endif
00943 #else
00944   ACE_UNUSED_ARG (buffer);
00945   ACE_UNUSED_ARG (maxlen);
00946   ACE_UNUSED_ARG (format);
00947   ACE_UNUSED_ARG (ap);
00948   ACE_NOTSUP_RETURN (-1);
00949 #endif /* ACE_HAS_SNPRINTF */
00950 }

ACE_INLINE int ACE_OS::vsprintf wchar_t *  buffer,
const wchar_t *  format,
va_list  argptr
 

Definition at line 954 of file OS_NS_stdio.inl.

References ACE_NOTSUP_RETURN.

00955 {
00956 # if (defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) >= 500) || \
00957      (defined (sun) && !(defined(_XOPEN_SOURCE) && (_XOPEN_VERSION-0==4))) || \
00958      (defined (ACE_HAS_DINKUM_STL) || defined (__DMC__))
00959 
00960   // The XPG4/UNIX98/C99 signature of the wide-char sprintf has a
00961   // maxlen argument. Since this method doesn't supply one, pass in
00962   // a length that works (ULONG_MAX doesn't on all platform since some check
00963   // to see if the operation will remain in bounds). If this isn't ok, use
00964   // ACE_OS::snprintf().
00965   return vswprintf (buffer, 4096, format, argptr);
00966 
00967 # elif defined (ACE_WIN32)
00968   // Windows has vswprintf, but the signature is from the older ISO C
00969   // standard. Also see ACE_OS::snprintf() for more info on this.
00970 
00971   return vswprintf (buffer, format, argptr);
00972 
00973 # else
00974   ACE_UNUSED_ARG (buffer);
00975   ACE_UNUSED_ARG (format);
00976   ACE_UNUSED_ARG (argptr);
00977   ACE_NOTSUP_RETURN (-1);
00978 
00979 # endif /* XPG5 || ACE_HAS_DINKUM_STL */
00980 }

ACE_INLINE int ACE_OS::vsprintf char *  buffer,
const char *  format,
va_list  argptr
 

Definition at line 913 of file OS_NS_stdio.inl.

References ACE_SPRINTF_ADAPTER, and vsprintf().

Referenced by ACE_Process_Options::command_line(), ACE_Process_Options::setenv(), sprintf(), and vsprintf().

00914 {
00915   return ACE_SPRINTF_ADAPTER (::vsprintf (buffer, format, argptr));
00916 }

ACE_INLINE pid_t ACE_OS::wait pid_t  pid,
ACE_exitcode status,
int  wait_options = 0,
ACE_HANDLE  handle = 0
 

Calls ::WaitForSingleObject on Win32 and ACE::waitpid () otherwise. Returns the passed in pid_t on success and -1 on failure. On Win32, pid is ignored if the handle is not equal to 0. Passing the process handle is prefer on Win32 because using pid to wait on the project doesn't always work correctly if the waited process has already terminated.

Definition at line 97 of file OS_NS_sys_wait.inl.

References ACE_exitcode, ACE_OS_TRACE, pid_t, and waitpid().

00101 {
00102   ACE_OS_TRACE ("ACE_OS::wait");
00103   return ACE_OS::waitpid (pid,
00104                           status,
00105                           wait_options,
00106                           handle);
00107 }

ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE pid_t ACE_OS::wait int *  = 0  ) 
 

Calls OS wait function, so it's only portable to UNIX/POSIX platforms.

Definition at line 11 of file OS_NS_sys_wait.inl.

References ACE_NOTSUP_RETURN, ACE_OS_TRACE, and pid_t.

Referenced by ACE_Process::wait().

00012 {
00013   ACE_OS_TRACE ("ACE_OS::wait");
00014 #if defined (ACE_LACKS_WAIT)
00015   ACE_UNUSED_ARG (status);
00016   ACE_NOTSUP_RETURN (0);
00017 #else
00018 # if defined (ACE_HAS_UNION_WAIT)
00019   ACE_OSCALL_RETURN (::wait ((union wait *) status), pid_t, -1);
00020 # else
00021   ACE_OSCALL_RETURN (::wait (status), pid_t, -1);
00022 # endif /* ACE_HAS_UNION_WAIT */
00023 #endif /* ACE_LACKS_WAIT */
00024 }

ACE_INLINE pid_t ACE_OS::waitpid pid_t  pid,
ACE_exitcode status = 0,
int  wait_options = 0,
ACE_HANDLE  handle = 0
 

Calls waitpid on UNIX/POSIX platforms Does not work on Vxworks 5.5.x. On Win32, pid is ignored if the handle is not equal to 0. Passing the process handle is prefer on Win32 because using pid to wait on the project doesn't always work correctly if the waited process has already terminated.

Definition at line 27 of file OS_NS_sys_wait.inl.

References ACE_BIT_ENABLED, ACE_exitcode, ACE_NOTSUP_RETURN, ACE_OS_TRACE, ETIME, pid_t, set_errno_to_last_error(), waitpid(), and WNOHANG.

Referenced by ACE::fork(), ACE_Process_Manager::wait(), ACE_Process::wait(), wait(), and waitpid().

00031 {
00032   ACE_OS_TRACE ("ACE_OS::waitpid");
00033 #if defined (ACE_LACKS_WAITPID)
00034   ACE_UNUSED_ARG (pid);
00035   ACE_UNUSED_ARG (status);
00036   ACE_UNUSED_ARG (wait_options);
00037   ACE_UNUSED_ARG (handle);
00038 
00039   ACE_NOTSUP_RETURN (0);
00040 #elif defined (ACE_WIN32)
00041   int blocking_period = ACE_BIT_ENABLED (wait_options, WNOHANG)
00042     ? 0 /* don't hang */
00043     : INFINITE;
00044 
00045   ACE_HANDLE phandle = handle;
00046 
00047   if (phandle == 0)
00048     {
00049       phandle = ::OpenProcess (SYNCHRONIZE,
00050                                FALSE,
00051                                pid);
00052 
00053       if (phandle == 0)
00054         {
00055           ACE_OS::set_errno_to_last_error ();
00056           return -1;
00057         }
00058     }
00059 
00060   pid_t result = pid;
00061 
00062   // Don't try to get the process exit status if wait failed so we can
00063   // keep the original error code intact.
00064   switch (::WaitForSingleObject (phandle,
00065                                  blocking_period))
00066     {
00067     case WAIT_OBJECT_0:
00068       if (status != 0)
00069         // The error status of <GetExitCodeProcess> is nonetheless
00070         // not tested because we don't know how to return the value.
00071         ::GetExitCodeProcess (phandle,
00072                               status);
00073       break;
00074     case WAIT_TIMEOUT:
00075       errno = ETIME;
00076       result = 0;
00077       break;
00078     default:
00079       ACE_OS::set_errno_to_last_error ();
00080       result = -1;
00081     }
00082   if (handle == 0)
00083     ::CloseHandle (phandle);
00084   return result;
00085 #elif defined(ACE_TANDEM_T1248_PTHREADS)
00086   ACE_UNUSED_ARG (handle);
00087   ACE_OSCALL_RETURN (::spt_waitpid (pid, status, wait_options),
00088                      pid_t, -1);
00089 #else
00090   ACE_UNUSED_ARG (handle);
00091   ACE_OSCALL_RETURN (::waitpid (pid, status, wait_options),
00092                      pid_t, -1);
00093 #endif /* ACE_LACKS_WAITPID */
00094 }

ACE_BEGIN_VERSIONED_NAMESPACE_DECL wchar_t * ACE_OS::wcscat_emulation wchar_t *  destination,
const wchar_t *  source
 

Emulated wcscat - Appends a string.

Definition at line 57 of file OS_NS_wchar.cpp.

Referenced by strcat().

00059 {
00060   wchar_t *save = destination;
00061 
00062   for (; *destination; ++destination);
00063   while ((*destination++ = *source++));
00064   return save;
00065 }

wchar_t * ACE_OS::wcschr_emulation const wchar_t *  string,
wint_t  c
 

Emulated wcschr - Finds a character in a string.

Definition at line 70 of file OS_NS_wchar.cpp.

Referenced by strchr().

00071 {
00072   for (;*string ; ++string)
00073     if (*string == static_cast<wchar_t> (c))
00074       return const_cast<wchar_t *> (string);
00075 
00076   return 0;
00077 }

int ACE_OS::wcscmp_emulation const ACE_WCHAR_T *  string1,
const ACE_WCHAR_T *  string2
 

Emulated wcscmp - Compares strings.

Definition at line 82 of file OS_NS_wchar.cpp.

Referenced by strcmp().

00084 {
00085   while (*string1 == *string2++)
00086     if (*string1++ == 0)
00087       return (0);
00088   return (*string1 - *--string2);
00089 }

wchar_t * ACE_OS::wcscpy_emulation wchar_t *  destination,
const wchar_t *  source
 

Emulated wcscpy - Copies a string.

Definition at line 94 of file OS_NS_wchar.cpp.

Referenced by strcpy().

00096 {
00097   wchar_t *save = destination;
00098 
00099   for (; (*destination = *source); ++source, ++destination);
00100   return save;
00101 }

size_t ACE_OS::wcscspn_emulation const wchar_t *  string,
const wchar_t *  reject
 

Emulated wcscspn.

Definition at line 106 of file OS_NS_wchar.cpp.

Referenced by strcspn().

00107 {
00108   const wchar_t *scan;
00109   const wchar_t *rej_scan;
00110   int count = 0;
00111 
00112   for (scan = s; *scan; scan++)
00113     {
00114 
00115       for (rej_scan = reject; *rej_scan; rej_scan++)
00116         if (*scan == *rej_scan)
00117           return count;
00118 
00119       count++;
00120     }
00121 
00122   return count;
00123 }

int ACE_OS::wcsicmp_emulation const wchar_t *  string1,
const wchar_t *  string2
 

Emulated wcsicmp - Performs a case insensitive comparison of strings.

Definition at line 128 of file OS_NS_wchar.cpp.

References ace_tolower(), and ace_towlower().

00129 {
00130   const wchar_t *scan1 = s;
00131   const wchar_t *scan2 = t;
00132 
00133   while (*scan1 != 0
00134          && ACE_OS::ace_towlower (*scan1)
00135             == ACE_OS::ace_towlower (*scan2))
00136     {
00137       ++scan1;
00138       ++scan2;
00139     }
00140 
00141   // The following case analysis is necessary so that characters which
00142   // look negative collate low against normal characters but high
00143   // against the end-of-string NUL.
00144 
00145   if (*scan1 == '\0' && *scan2 == '\0')
00146     return 0;
00147   else if (*scan1 == '\0')
00148     return -1;
00149   else if (*scan2 == '\0')
00150     return 1;
00151   else
00152     return ACE_OS::ace_tolower (*scan1) - ACE_OS::ace_towlower (*scan2);
00153 }

size_t ACE_OS::wcslen_emulation const ACE_WCHAR_T *  string  ) 
 

Emulated wcslen - Returns the length of a string.

Definition at line 158 of file OS_NS_wchar.cpp.

References ACE_WCHAR_T.

Referenced by strlen().

00159 {
00160   const ACE_WCHAR_T *s;
00161 
00162   for (s = string; *s; ++s)
00163     continue;
00164 
00165   return s - string;
00166 }

ACE_WCHAR_T * ACE_OS::wcsncat_emulation ACE_WCHAR_T *  destination,
const ACE_WCHAR_T *  source,
size_t  count
 

Emulated wcscat - Appends a string.

Definition at line 171 of file OS_NS_wchar.cpp.

References ACE_WCHAR_T.

Referenced by strncat().

00174 {
00175   if (count != 0)
00176     {
00177       ACE_WCHAR_T *d = destination;
00178       const ACE_WCHAR_T *s = source;
00179 
00180       while (*d != 0)
00181         d++;
00182 
00183       do
00184         {
00185           if ((*d = *s++) == 0)
00186             break;
00187 
00188           d++;
00189         } while (--count != 0);
00190 
00191       *d = 0;
00192     }
00193 
00194   return destination;
00195 }

int ACE_OS::wcsncmp_emulation const ACE_WCHAR_T *  string1,
const ACE_WCHAR_T *  string2,
size_t  len
 

Emulated wcsncmp - Compares two arrays.

Definition at line 200 of file OS_NS_wchar.cpp.

Referenced by strncmp().

00203 {
00204   if (len == 0)
00205     return 0;
00206 
00207   do
00208     {
00209       if (*s1 != *s2++)
00210         return (*s1 - *--s2);
00211       if (*s1++ == 0)
00212         break;
00213     } while (--len != 0);
00214 
00215   return 0;
00216 }

ACE_WCHAR_T * ACE_OS::wcsncpy_emulation ACE_WCHAR_T *  destination,
const ACE_WCHAR_T *  source,
size_t  len
 

Emulated wcsncpy - Copies an array.

Definition at line 221 of file OS_NS_wchar.cpp.

References ACE_WCHAR_T.

Referenced by strncpy().

00224 {
00225   if (len != 0)
00226     {
00227       ACE_WCHAR_T *d = destination;
00228       const ACE_WCHAR_T *s = source;
00229 
00230       do
00231         {
00232           if ((*d++ = *s++) == 0)
00233             {
00234               // NUL pad the remaining n-1 bytes
00235               while (--len != 0)
00236                 *d++ = 0;
00237               break;
00238             }
00239         } while (--len != 0);
00240     }
00241 
00242   return destination;
00243 }

int ACE_OS::wcsnicmp_emulation const wchar_t *  string1,
const wchar_t *  string2,
size_t  len
 

Emulated wcsnicmp - Performs a case insensitive comparison of two arrays

Definition at line 248 of file OS_NS_wchar.cpp.

References ace_towlower().

00251 {
00252   const wchar_t *scan1 = s;
00253   const wchar_t *scan2 = t;
00254   size_t count = 0;
00255 
00256   while (count++ < len
00257          && *scan1 != 0
00258          && ACE_OS::ace_towlower (*scan1)
00259             == ACE_OS::ace_towlower (*scan2))
00260     {
00261       ++scan1;
00262       ++scan2;
00263     }
00264 
00265   if (count > len)
00266     return 0;
00267 
00268   // The following case analysis is necessary so that characters which
00269   // look negative collate low against normal characters but high
00270   // against the end-of-string NUL.
00271 
00272   if (*scan1 == '\0' && *scan2 == '\0')
00273     return 0;
00274   else if (*scan1 == '\0')
00275     return -1;
00276   else if (*scan2 == '\0')
00277     return 1;
00278   else
00279     return ACE_OS::ace_towlower (*scan1) - ACE_OS::ace_towlower (*scan2);
00280 }

wchar_t * ACE_OS::wcspbrk_emulation const wchar_t *  string,
const wchar_t *  charset
 

Emulated wcspbrk - Searches for characters in a string.

Definition at line 285 of file OS_NS_wchar.cpp.

Referenced by strpbrk().

00287 {
00288   const wchar_t *scanp;
00289   int c, sc;
00290 
00291   while ((c = *string++) != 0)
00292     {
00293       for (scanp = charset; (sc = *scanp++) != 0;)
00294         if (sc == c)
00295           return const_cast<wchar_t *> (string - 1);
00296     }
00297 
00298   return 0;
00299 }

const wchar_t * ACE_OS::wcsrchr_emulation const wchar_t *  string,
wint_t  c
 

Emulated wcsrchr (const wchar_t version) - Finds the last occurance of a character in a string.

Definition at line 304 of file OS_NS_wchar.cpp.

References strlen().

00305 {
00306   const wchar_t *p = s + ACE_OS::strlen (s);
00307 
00308   while (*p != static_cast<wchar_t> (c))
00309     if (p == s)
00310       return 0;
00311     else
00312       p--;
00313 
00314   return p;
00315 }

wchar_t * ACE_OS::wcsrchr_emulation wchar_t *  string,
wint_t  c
 

Emulated wcsrchr (wchar_t version) - Finds the last occurance of a character in a string.

Definition at line 318 of file OS_NS_wchar.cpp.

References strlen().

Referenced by strrchr().

00319 {
00320   wchar_t *p = s + ACE_OS::strlen (s);
00321 
00322   while (*p != static_cast<wchar_t> (c))
00323     if (p == s)
00324       return 0;
00325     else
00326       p--;
00327 
00328   return p;
00329 }

size_t ACE_OS::wcsspn_emulation const wchar_t *  string,
const wchar_t *  charset
 

Emulated wcsspn.

Definition at line 334 of file OS_NS_wchar.cpp.

Referenced by strspn().

00336 {
00337   const wchar_t *p = string;
00338   const wchar_t *spanp;
00339   wchar_t c, sc;
00340 
00341   // Skip any characters in charset, excluding the terminating \0.
00342 cont:
00343   c = *p++;
00344   for (spanp = charset; (sc = *spanp++) != 0;)
00345     if (sc == c)
00346       goto cont;
00347   return (p - 1 - string);
00348 }

wchar_t * ACE_OS::wcsstr_emulation const wchar_t *  string,
const wchar_t *  charset
 

Emulated wcsstr - Performs a case insensitive comparison of two strings.

Definition at line 353 of file OS_NS_wchar.cpp.

References strlen(), and strncmp().

Referenced by strstr().

00355 {
00356   wchar_t c, sc;
00357   size_t len;
00358 
00359   if ((c = *charset++) != 0)
00360     {
00361       len = ACE_OS::strlen (charset);
00362       do
00363         {
00364           do
00365             {
00366               if ((sc = *string++) == 0)
00367                 return 0;
00368             } while (sc != c);
00369         } while (ACE_OS::strncmp (string, charset, len) != 0);
00370       string--;
00371     }
00372 
00373   return const_cast<wchar_t *> (string);
00374 }

ACE_INLINE ssize_t ACE_OS::write ACE_HANDLE  handle,
const void *  buf,
size_t  nbyte,
ACE_OVERLAPPED
 

Definition at line 1123 of file OS_NS_unistd.inl.

References ACE_FAIL_RETURN, ACE_OS_TRACE, ACE_OVERLAPPED, ssize_t, and write().

01127 {
01128   ACE_OS_TRACE ("ACE_OS::write");
01129   overlapped = overlapped;
01130 #if defined (ACE_WIN32)
01131   DWORD bytes_written; // This is set to 0 byte WriteFile.
01132 
01133   DWORD short_nbyte = static_cast<DWORD> (nbyte);
01134   if (::WriteFile (handle, buf, short_nbyte, &bytes_written, overlapped))
01135     return (ssize_t) bytes_written;
01136   else
01137     ACE_FAIL_RETURN (-1);
01138 #else
01139   return ACE_OS::write (handle, buf, nbyte);
01140 #endif /* ACE_WIN32 */
01141 }

ACE_INLINE ssize_t ACE_OS::write ACE_HANDLE  handle,
const void *  buf,
size_t  nbyte
 

Definition at line 1100 of file OS_NS_unistd.inl.

References ACE_FAIL_RETURN, ACE_OS_TRACE, and ssize_t.

Referenced by ACE_MMAP_Memory_Pool::commit_backing_store_name(), ACE_UPIPE_Connector::connect(), ACE_Dev_Poll_Reactor::mask_ops_i(), ACE_High_Res_Timer::print_ave(), ACE_High_Res_Timer::print_total(), putmsg(), pwrite(), ACE_Dev_Poll_Reactor::register_handler_i(), ACE_Filecache_Object::release(), ACE_Dev_Poll_Reactor::resume_handler_i(), sema_init(), sema_post(), ACE_SPIPE_Stream::send(), ACE_SOCK_IO::send(), ACE_Pipe::send(), ACE_FILE_IO::send(), ACE_FIFO_Send::send(), ACE_DEV_IO::send(), ACE::send_i(), sendfile_emulation(), ACE_Dev_Poll_Reactor::suspend_handler_i(), ACE_Mem_Map::unmap(), write(), and write_n().

01101 {
01102   ACE_OS_TRACE ("ACE_OS::write");
01103 #if defined (ACE_WIN32)
01104   DWORD bytes_written; // This is set to 0 byte WriteFile.
01105 
01106   // Strictly correctly, we should loop writing all the data if more
01107   // than a DWORD length can hold.
01108   DWORD short_nbyte = static_cast<DWORD> (nbyte);
01109   if (::WriteFile (handle, buf, short_nbyte, &bytes_written, 0))
01110     return (ssize_t) bytes_written;
01111   else
01112     ACE_FAIL_RETURN (-1);
01113 #else
01114 # if defined (ACE_HAS_CHARPTR_SOCKOPT)
01115   ACE_OSCALL_RETURN (::write (handle, static_cast <char *> (const_cast <void *> (buf)), nbyte), ssize_t, -1);
01116 # else
01117   ACE_OSCALL_RETURN (::write (handle, buf, nbyte), ssize_t, -1);
01118 # endif /* ACE_HAS_CHARPTR_SOCKOPT */
01119 #endif /* ACE_WIN32 */
01120 }

ssize_t ACE_OS::write_n ACE_HANDLE  handle,
const void *  buf,
size_t  len,
size_t *  bytes_transferred = 0
 

Send bytes from to (uses the <ACE_OS::write> calls, which is uses the system call on UNIX and the call on Win32). If errors occur, -1 is returned. If EOF occurs, 0 is returned. Whatever data has been transmitted will be returned to the caller through .

Definition at line 752 of file OS_NS_unistd.cpp.

References ssize_t, and write().

Referenced by ACE::write_n().

00756 {
00757   size_t temp;
00758   size_t &bytes_transferred = bt == 0 ? temp : *bt;
00759   ssize_t n;
00760 
00761   for (bytes_transferred = 0;
00762        bytes_transferred < len;
00763        bytes_transferred += n)
00764     {
00765       n = ACE_OS::write (handle,
00766                          (char *) buf + bytes_transferred,
00767                          len - bytes_transferred);
00768 
00769       if (n == -1 || n == 0)
00770         return n;
00771     }
00772 
00773   return bytes_transferred;
00774 }

ACE_INLINE ssize_t ACE_OS::writev ACE_HANDLE  handle,
const iovec iov,
int  iovcnt
 

Definition at line 33 of file OS_NS_sys_uio.inl.

References ACE_OS_TRACE, and ssize_t.

Referenced by ACE_SPIPE_Stream::send(), ACE_Pipe::send(), ACE_FILE_IO::send(), ACE_FIFO_Send_Msg::send(), ACE_DEV_IO::send(), ACE_SPIPE_Stream::sendv(), ACE_Pipe::sendv(), sendv(), ACE_FILE_IO::sendv(), and ACE::writev_n().

00036 {
00037   ACE_OS_TRACE ("ACE_OS::writev");
00038 #if defined (ACE_LACKS_WRITEV)
00039   ACE_OSCALL_RETURN (ACE_OS::writev_emulation (handle,
00040                                                iov,
00041                                                iovcnt), ssize_t, -1);
00042 #else /* ACE_LACKS_WRITEV */
00043 #if defined (ACE_HAS_NONCONST_WRITEV)
00044   ACE_OSCALL_RETURN (::writev (handle,
00045                                const_cast<iovec *>(iov),
00046                                iovcnt), ssize_t, -1);
00047 #else
00048   ACE_OSCALL_RETURN (::writev (handle,
00049                                iov,
00050                                iovcnt), ssize_t, -1);
00051 #endif /* ACE_HAS_NONCONST_WRITEV */
00052 #endif /* ACE_LACKS_WRITEV */
00053 }

ACE_INLINE int ACE_OS::wscmp const WChar *  ,
const WChar * 
 

Definition at line 43 of file OS_NS_wchar.inl.

00044 {
00045   const WChar *scan1 = s;
00046   const WChar *scan2 = t;
00047 
00048   while (*scan1 != 0 && *scan1 == *scan2)
00049     {
00050       ++scan1;
00051       ++scan2;
00052     }
00053 
00054   return *scan1 - *scan2;
00055 }

ACE_INLINE ACE_OS::WChar * ACE_OS::wscpy WChar *  ,
const WChar * 
 

Definition at line 32 of file OS_NS_wchar.inl.

00033 {
00034   WChar *original_dest = dest;
00035 
00036   while ((*dest++ = *src++) != 0)
00037     continue;
00038 
00039   return original_dest;
00040 }

ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE u_int ACE_OS::wslen const WChar *   ) 
 

Definition at line 21 of file OS_NS_wchar.inl.

Referenced by ACE_Log_Msg::log().

00022 {
00023   u_int len = 0;
00024 
00025   while (*s++ != 0)
00026     len++;
00027 
00028   return len;
00029 }

ACE_INLINE int ACE_OS::wsncmp const WChar *  ,
const WChar *  ,
size_t  len
 

Definition at line 58 of file OS_NS_wchar.inl.

00059 {
00060   const WChar *scan1 = s;
00061   const WChar *scan2 = t;
00062 
00063   while (len != 0 && *scan1 != 0 && *scan1 == *scan2)
00064     {
00065       ++scan1;
00066       ++scan2;
00067       --len;
00068     }
00069 
00070   return len == 0 ? 0 : *scan1 - *scan2;
00071 }


Variable Documentation

ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_EXIT_HOOK ACE_OS::exit_hook_ = 0
 

Function that is called by <ACE_OS::exit>, if non-null.

Definition at line 35 of file OS_NS_stdlib.cpp.

Referenced by exit(), and set_exit_hook().

ACE_hthread_t ACE_OS::NULL_hthread
 

This is necessary to deal with POSIX pthreads and their use of structures for thread handles.

Definition at line 1142 of file OS_NS_Thread.cpp.

ACE_thread_key_t ACE_OS::NULL_key
 

This is necessary to deal with POSIX pthreads and their use of structures for TSS keys.

Definition at line 1146 of file OS_NS_Thread.cpp.

ACE_thread_t ACE_OS::NULL_thread
 

This is necessary to deal with POSIX pthreads and their use of structures for thread ids.

Definition at line 1141 of file OS_NS_Thread.cpp.

ACE_BEGIN_VERSIONED_NAMESPACE_DECL int ACE_OS::socket_initialized_
 

Keeps track of whether we've already initialized WinSock...

Definition at line 14 of file OS_NS_sys_socket.cpp.

HINSTANCE ACE_OS::win32_resource_module_
 

Definition at line 19 of file OS_NS_stdio.cpp.

ACE_BEGIN_VERSIONED_NAMESPACE_DECL OSVERSIONINFO ACE_OS::win32_versioninfo_
 

Definition at line 18 of file OS_NS_stdio.cpp.


Generated on Thu Nov 9 11:33:59 2006 for ACE by doxygen 1.3.6