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... | |
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 | |
unsigned long | inet_addr (const char *name) |
ACE_Export int | inet_aton (const char *strptr, struct in_addr *addr) |
char * | inet_ntoa (const struct in_addr addr) |
const char * | inet_ntop (int family, const void *addrptr, char *strptr, size_t len) |
int | inet_pton (int family, const char *strptr, void *addrptr) |
void | closedir (ACE_DIR *) |
ACE_DIR * | opendir (const ACE_TCHAR *filename) |
struct ACE_DIRENT * | readdir (ACE_DIR *) |
int | readdir_r (ACE_DIR *dirp, struct ACE_DIRENT *entry, struct ACE_DIRENT **result) |
void | rewinddir (ACE_DIR *) |
int | scandir (const ACE_TCHAR *dirname, struct ACE_DIRENT **namelist[], ACE_SCANDIR_SELECTOR selector, ACE_SCANDIR_COMPARATOR comparator) |
int | alphasort (const void *, const void *) |
void | seekdir (ACE_DIR *, long loc) |
long | telldir (ACE_DIR *) |
ACE_Export int | scandir_emulation (const ACE_TCHAR *dirname, ACE_DIRENT **namelist[], ACE_SCANDIR_SELECTOR selector, ACE_SCANDIR_COMPARATOR comparator) |
int | last_error (void) |
void | last_error (int error) |
int | set_errno_to_last_error (void) |
int | set_errno_to_wsa_last_error (void) |
int | fcntl (ACE_HANDLE handle, int cmd, long arg=0) |
ACE_Export ACE_HANDLE | open (const char *filename, int mode, mode_t 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. | |
template<typename T > | |
T | floor (T x) |
This method computes the largest integral value not greater than x. | |
template<typename T > | |
T | ceil (T x) |
This method computes the smallest integral value not less than x. | |
double | log2 (double x) |
This method computes the base-2 logarithm of x. | |
struct hostent * | gethostbyaddr (const char *addr, int length, int type) |
struct hostent * | gethostbyaddr_r (const char *addr, int length, int type, struct hostent *result, ACE_HOSTENT_DATA buffer, int *h_errnop) |
struct hostent * | gethostbyname (const char *name) |
struct hostent * | gethostbyname_r (const char *name, struct hostent *result, ACE_HOSTENT_DATA buffer, int *h_errnop) |
struct hostent * | getipnodebyaddr (const void *src, size_t len, int family) |
struct hostent * | getipnodebyname (const char *name, int family, int flags=0) |
ACE_Export int | getmacaddress (struct macaddr_node_t *node) |
struct protoent * | getprotobyname (const char *name) |
struct protoent * | getprotobyname_r (const char *name, struct protoent *result, ACE_PROTOENT_DATA buffer) |
struct protoent * | getprotobynumber (int proto) |
struct protoent * | getprotobynumber_r (int proto, struct protoent *result, ACE_PROTOENT_DATA buffer) |
struct servent * | getservbyname (const char *svc, const char *proto) |
struct servent * | getservbyname_r (const char *svc, const char *proto, struct servent *result, ACE_SERVENT_DATA buf) |
int | poll (struct pollfd *pollfds, unsigned long len, const ACE_Time_Value *tv=0) |
int | poll (struct pollfd *pollfds, unsigned long len, const ACE_Time_Value &tv) |
void | clearerr (FILE *fp) |
ACE_Export int | asprintf (char **bufp, const char *format,...) |
int | fclose (FILE *fp) |
FILE * | fdopen (ACE_HANDLE handle, const ACE_TCHAR *mode) |
int | fflush (FILE *fp) |
int | fgetc (FILE *fp) |
int | getc (FILE *fp) |
int | fgetpos (FILE *fp, fpos_t *pos) |
char * | fgets (char *buf, int size, FILE *fp) |
ACE_HANDLE | fileno (FILE *stream) |
FILE * | fopen (const char *filename, const char *mode) |
ACE_Export int | fprintf (FILE *fp, const char *format,...) |
int | ungetc (int c, FILE *fp) |
int | fputc (int c, FILE *fp) |
int | putc (int c, FILE *fp) |
int | fputs (const char *s, FILE *stream) |
size_t | fread (void *ptr, size_t size, size_t nelems, FILE *fp) |
FILE * | freopen (const ACE_TCHAR *filename, const ACE_TCHAR *mode, FILE *stream) |
int | fseek (FILE *fp, long offset, int ptrname) |
int | fsetpos (FILE *fp, fpos_t *pos) |
long | ftell (FILE *fp) |
size_t | fwrite (const void *ptr, size_t size, size_t nitems, FILE *fp) |
void | perror (const char *s) |
ACE_Export int | printf (const char *format,...) |
int | puts (const char *s) |
int | rename (const char *old_name, const char *new_name, int flags=-1) |
void | rewind (FILE *fp) |
ACE_Export int | snprintf (char *buf, size_t maxlen, const char *format,...) |
ACE_Export int | sprintf (char *buf, const char *format,...) |
char * | tempnam (const char *dir=0, const char *pfx=0) |
int | vasprintf (char **bufp, const char *format, va_list argptr) |
int | vprintf (const char *format, va_list argptr) |
int | vfprintf (FILE *fp, const char *format, va_list argptr) |
int | vsprintf (char *buffer, const char *format, va_list argptr) |
int | vsnprintf (char *buffer, size_t maxlen, const char *format, va_list argptr) |
ACE_Export int | vasprintf_emulation (char **bufp, const char *format, va_list argptr) |
char * | strtok_r (char *s, const char *tokens, char **lasts) |
Finds the next token in a string (safe char version). | |
ACE_Export char * | strtok_r_emulation (char *s, const char *tokens, char **lasts) |
Emulated strtok_r. | |
int | strcasecmp (const char *s, const char *t) |
Compares two strings (case insensitive const char version). | |
int | strncasecmp (const char *s, const char *t, size_t len) |
Compares two arrays (case insensitive const char version). | |
int | getmsg (ACE_HANDLE handle, struct strbuf *ctl, struct strbuf *data, int *flags) |
int | getpmsg (ACE_HANDLE handle, struct strbuf *ctl, struct strbuf *data, int *band, int *flags) |
int | fattach (int handle, const char *path) |
int | fdetach (const char *file) |
int | ioctl (ACE_HANDLE handle, ACE_IOCTL_TYPE_ARG2 cmd, void *=0) |
UNIX-style ioctl . | |
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 ioctl . | |
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) |
int | isastream (ACE_HANDLE handle) |
int | putmsg (ACE_HANDLE handle, const struct strbuf *ctl, const struct strbuf *data, int flags) |
int | putpmsg (ACE_HANDLE handle, const struct strbuf *ctl, const struct strbuf *data, int band, int flags) |
ACE_HANDLE | shm_open (const ACE_TCHAR *filename, int mode, mode_t perms=0, LPSECURITY_ATTRIBUTES sa=0) |
int | shm_unlink (const ACE_TCHAR *path) |
int | getrlimit (int resource, struct rlimit *rl) |
int | getrusage (int who, struct rusage *rusage) |
int | setrlimit (int resource, const struct rlimit *rl) |
int | select (int width, fd_set *rfds, fd_set *wfds=0, fd_set *efds=0, const ACE_Time_Value *tv=0) |
int | select (int width, fd_set *rfds, fd_set *wfds, fd_set *efds, const ACE_Time_Value &tv) |
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_HANDLE | creat (const ACE_TCHAR *filename, mode_t mode) |
int | fstat (ACE_HANDLE, ACE_stat *) |
int | lstat (const char *, ACE_stat *) |
int | mkdir (const char *path, mode_t mode=ACE_DEFAULT_DIR_PERMS) |
int | mkfifo (const ACE_TCHAR *file, mode_t mode=ACE_DEFAULT_FILE_PERMS) |
int | stat (const char *file, ACE_stat *) |
mode_t | umask (mode_t cmask) |
ACE_Time_Value | gettimeofday (void) |
ssize_t | readv (ACE_HANDLE handle, const iovec *iov, int iovlen) |
ssize_t | writev (ACE_HANDLE handle, const iovec *iov, int iovcnt) |
ACE_Export int | uname (ACE_utsname *name) |
pid_t | wait (int *=0) |
Calls OS wait function, so it's only portable to UNIX/POSIX /// platforms. | |
pid_t | wait (pid_t pid, ACE_exitcode *status, int wait_options=0, ACE_HANDLE handle=0) |
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 &) |
long | priority_control (ACE_idtype_t, ACE_id_t, int, void *) |
Low-level interface to priocntl(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 priocntl(2) . | |
int | sigtimedwait (const sigset_t *set, siginfo_t *info, const ACE_Time_Value *timeout) |
int | sigwait (sigset_t *set, int *sig=0) |
int | sigwaitinfo (const sigset_t *set, siginfo_t *info) |
int | thr_cancel (ACE_thread_t t_id) |
int | thr_cmp (ACE_hthread_t t1, ACE_hthread_t t2) |
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=ACE_DEFAULT_THREAD_STACKSIZE, ACE_Base_Thread_Adapter *thread_adapter=0, const char **thr_name=0) |
int | thr_equal (ACE_thread_t t1, ACE_thread_t t2) |
ACE_Export void | thr_exit (ACE_THR_FUNC_RETURN status=0) |
int | thr_getconcurrency (void) |
int | thr_getprio (ACE_hthread_t id, int &priority) |
int | thr_getprio (ACE_hthread_t id, int &priority, int &policy) |
int | thr_getspecific (ACE_thread_key_t key, void **data) |
int | thr_join (ACE_hthread_t waiter_id, ACE_THR_FUNC_RETURN *status) |
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 thr_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) |
int | thr_kill (ACE_thread_t thr_id, int signum) |
size_t | thr_min_stack (void) |
ACE_thread_t | thr_self (void) |
void | thr_self (ACE_hthread_t &) |
const char * | thr_name (void) |
int | thr_setcancelstate (int new_state, int *old_state) |
int | thr_setcanceltype (int new_type, int *old_type) |
int | thr_setconcurrency (int hint) |
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) |
int | thr_sigsetmask (int how, const sigset_t *nsm, sigset_t *osm) |
int | thr_suspend (ACE_hthread_t target_thread) |
void | thr_testcancel (void) |
void | thr_yield (void) |
ACE_Export void | unique_name (const void *object, char *name, size_t length) |
int | access (const char *path, int amode) |
unsigned int | alarm (u_int secs) |
long | allocation_granularity (void) |
ACE_Export int | argv_to_string (int argc, ACE_TCHAR **argv, ACE_TCHAR *&buf, bool substitute_env_args=true, bool quote_args=false) |
used by ARGV::argv_to_string() and ACE_OS::fork_exec() | |
ACE_Export int | argv_to_string (ACE_TCHAR **argv, ACE_TCHAR *&buf, bool substitute_env_args=true, bool quote_args=false) |
int | chdir (const char *path) |
int | rmdir (const char *path) |
int | close (ACE_HANDLE handle) |
ACE_HANDLE | dup (ACE_HANDLE handle) |
ACE_HANDLE | dup (ACE_HANDLE handle, pid_t pid) |
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,...) |
int | execv (const char *path, char *const argv[]) |
int | execve (const char *path, char *const argv[], char *const envp[]) |
int | execvp (const char *file, char *const argv[]) |
int | fsync (ACE_HANDLE handle) |
int | ftruncate (ACE_HANDLE handle, ACE_OFF_T offset) |
char * | getcwd (char *, size_t) |
gid_t | getgid (void) |
gid_t | getegid (void) |
int | getopt (int argc, char *const *argv, const char *optstring) |
long | getpagesize (void) |
pid_t | getpgid (pid_t pid) |
pid_t | getpid (void) |
pid_t | getppid (void) |
uid_t | getuid (void) |
uid_t | geteuid (void) |
int | hostname (char name[], size_t maxnamelen) |
int | isatty (int handle) |
ACE_OFF_T | lseek (ACE_HANDLE handle, ACE_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. | |
int | pipe (ACE_HANDLE handles[]) |
ACE_Export ssize_t | pread (ACE_HANDLE handle, void *buf, size_t nbyte, ACE_OFF_T offset) |
ACE_Export ssize_t | pwrite (ACE_HANDLE handle, const void *buf, size_t nbyte, ACE_OFF_T offset) |
ssize_t | read (ACE_HANDLE handle, void *buf, size_t len) |
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) |
ssize_t | readlink (const char *path, char *buf, size_t bufsiz) |
void * | sbrk (intptr_t brk) |
int | setgid (gid_t) |
int | setegid (gid_t) |
int | setpgid (pid_t pid, pid_t pgid) |
int | setregid (gid_t rgid, gid_t egid) |
int | setreuid (uid_t ruid, uid_t euid) |
pid_t | setsid (void) |
int | setuid (uid_t) |
int | seteuid (uid_t) |
int | sleep (u_int seconds) |
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) |
void | swab (const void *src, void *dest, ssize_t n) |
long | sysconf (int) |
long | sysinfo (int cmd, char *buf, long count) |
int | truncate (const ACE_TCHAR *filename, ACE_OFF_T length) |
useconds_t | ualarm (useconds_t usecs, useconds_t interval=0) |
useconds_t | ualarm (const ACE_Time_Value &tv, const ACE_Time_Value &tv_interval=ACE_Time_Value::zero) |
int | unlink (const char *path) |
ssize_t | write (ACE_HANDLE handle, const void *buf, size_t nbyte) |
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_Export int | wcscmp_emulation (const ACE_WCHAR_T *string1, const ACE_WCHAR_T *string2) |
Emulated wcscmp - Compares 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. | |
u_int | wslen (const WChar *) |
WChar * | wscpy (WChar *, const WChar *) |
int | wscmp (const WChar *, const WChar *) |
int | wsncmp (const WChar *, const WChar *, size_t len) |
int | t_accept (ACE_HANDLE fildes, ACE_HANDLE resfd, struct t_call *call) |
char * | t_alloc (ACE_HANDLE fildes, int struct_type, int fields) |
int | t_bind (ACE_HANDLE fildes, ACE_TBIND *req, ACE_TBIND *ret) |
int | t_close (ACE_HANDLE fildes) |
int | t_connect (ACE_HANDLE fildes, struct t_call *sndcall, struct t_call *rcvcall) |
void | t_error (const char *errmsg) |
int | t_free (char *ptr, int struct_type) |
int | t_getinfo (ACE_HANDLE fildes, struct t_info *info) |
int | t_getname (ACE_HANDLE fildes, struct netbuf *namep, int type) |
int | t_getstate (ACE_HANDLE fildes) |
int | t_listen (ACE_HANDLE fildes, struct t_call *call) |
int | t_look (ACE_HANDLE fildes) |
ACE_HANDLE | t_open (char *path, int oflag, struct t_info *info) |
int | t_optmgmt (ACE_HANDLE handle, ACE_TOPTMGMT *req, ACE_TOPTMGMT *ret) |
int | t_rcv (ACE_HANDLE fildes, char *buf, unsigned int nbytes, int *flags) |
int | t_rcvdis (ACE_HANDLE fildes, struct t_discon *discon) |
int | t_rcvrel (ACE_HANDLE fildes) |
int | t_rcvudata (ACE_HANDLE fildes, struct t_unitdata *unitdata, int *flags) |
int | t_rcvuderr (ACE_HANDLE fildes, struct t_uderr *uderr) |
int | t_snd (ACE_HANDLE fildes, const char *buf, unsigned int nbytes, int flags) |
int | t_snddis (ACE_HANDLE fildes, struct t_call *call) |
int | t_sndrel (ACE_HANDLE fildes) |
int | t_sync (ACE_HANDLE fildes) |
int | t_unbind (ACE_HANDLE fildes) |
Functions from <cctype> | |
int | ace_isalnum (ACE_TCHAR c) |
Returns true if the character is an alphanumeric character. | |
int | ace_isalpha (ACE_TCHAR c) |
Returns true if the character is an alphabetic character. | |
int | ace_isblank (ACE_TCHAR c) |
Returns true if the character is a control character. | |
int | ace_isascii (ACE_TCHAR c) |
Returns true if the character is a control character. | |
int | ace_iscntrl (ACE_TCHAR c) |
Returns true if the character is a control character. | |
int | ace_isdigit (ACE_TCHAR c) |
Returns true if the character is a decimal-digit character. | |
int | ace_isgraph (ACE_TCHAR c) |
Returns true if the character is a printable character other than a space. | |
int | ace_islower (ACE_TCHAR c) |
Returns true if the character is a lowercase character. | |
int | ace_isprint (ACE_TCHAR c) |
Returns true if the character is a printable character. | |
int | ace_ispunct (ACE_TCHAR c) |
Returns true if the character is a punctuation character. | |
int | ace_isspace (ACE_TCHAR c) |
Returns true if the character is a space character. | |
int | ace_isupper (ACE_TCHAR c) |
Returns true if the character is an uppercase character. | |
int | ace_isxdigit (ACE_TCHAR c) |
Returns true if the character is a hexadecimal-digit character. | |
int | ace_tolower (int c) |
Converts a character to lower case (char version). | |
int | ace_toupper (int c) |
Converts a character to upper case (char version). | |
int | ace_isctype (int c, ctype_t desc) |
Tests c for the property specified by the desc argument. | |
int | dlclose (ACE_SHLIB_HANDLE handle) |
ACE_TCHAR * | dlerror (void) |
ACE_SHLIB_HANDLE | dlopen (const ACE_TCHAR *filename, int mode=ACE_DEFAULT_SHLIB_MODE) |
void * | dlsym (ACE_SHLIB_HANDLE handle, const ACE_TCHAR *symbol) |
void | endpwent (void) |
struct passwd * | getpwent (void) |
struct passwd * | getpwnam (const char *user) |
struct passwd * | getpwnam_r (const char *name, struct passwd *pwent, char *buffer, int buflen) |
void | setpwent (void) |
char * | compile (const char *instring, char *expbuf, char *endbuf) |
int | step (const char *str, char *expbuf) |
int | kill (pid_t pid, int signum) |
int | pthread_sigmask (int how, const sigset_t *nsp, sigset_t *osp) |
int | sigaction (int signum, const ACE_SIGACTION *nsa, ACE_SIGACTION *osa) |
int | sigaddset (sigset_t *s, int signum) |
int | sigdelset (sigset_t *s, int signum) |
int | sigemptyset (sigset_t *s) |
int | sigfillset (sigset_t *s) |
int | sigismember (sigset_t *s, int signum) |
ACE_SignalHandler | signal (int signum, ACE_SignalHandler) |
int | sigprocmask (int how, const sigset_t *nsp, sigset_t *osp) |
int | sigsuspend (const sigset_t *s) |
int | raise (const int signum) |
char * | cuserid (char *user, size_t maxlen=ACE_MAX_USERID) |
int | flock_init (ace_flock_t *lock, int flags=0, const ACE_TCHAR *name=0, mode_t perms=0) |
int | flock_destroy (ace_flock_t *lock, int unlink_file=1) |
int | flock_rdlock (ace_flock_t *lock, short whence=0, ACE_OFF_T start=0, ACE_OFF_T len=0) |
int | flock_tryrdlock (ace_flock_t *lock, short whence=0, ACE_OFF_T start=0, ACE_OFF_T len=0) |
int | flock_trywrlock (ace_flock_t *lock, short whence=0, ACE_OFF_T start=0, ACE_OFF_T len=0) |
int | flock_unlock (ace_flock_t *lock, short whence=0, ACE_OFF_T start=0, ACE_OFF_T len=0) |
int | flock_wrlock (ace_flock_t *lock, short whence=0, ACE_OFF_T start=0, ACE_OFF_T len=0) |
Functions from <cstring> | |
Included are the functions defined in <cstring> and their <cwchar> equivalents.
| |
const void * | memchr (const void *s, int c, size_t len) |
Finds characters in a buffer (const void version). | |
void * | memchr (void *s, int c, size_t len) |
Finds characters in a buffer (void version). | |
int | memcmp (const void *t, const void *s, size_t len) |
Compares two buffers. | |
void * | memcpy (void *t, const void *s, size_t len) |
Copies one buffer to another. | |
void * | memmove (void *t, const void *s, size_t len) |
Moves one buffer to another. | |
void * | memset (void *s, int c, size_t len) |
Fills a buffer with a character value. | |
char * | strcat (char *s, const char *t) |
Appends a string to another string (char version). | |
const char * | strchr (const char *s, int c) |
char * | strchr (char *s, int c) |
Finds the first occurance of a character in a string (char version). | |
int | strcmp (const char *s, const char *t) |
Compares two strings (char version). | |
int | strcmp (const ACE_WCHAR_T *s, const ACE_WCHAR_T *t) |
Compares two strings (wchar_t version). | |
char * | strcpy (char *s, const char *t) |
Copies a string (char version). | |
size_t | strcspn (const char *s, const char *reject) |
char * | strdup (const char *s) |
Returns a malloced duplicated string (char version). | |
ACE_Export char * | strecpy (char *des, const char *src) |
ACE_Export char * | strerror (int errnum) |
ACE_Export char * | strsignal (int signum) |
size_t | strlen (const char *s) |
Finds the length of a string (char version). | |
size_t | strlen (const ACE_WCHAR_T *s) |
Finds the length of a string (ACE_WCHAR_T version). | |
char * | strncat (char *s, const char *t, size_t len) |
Appends part of a string to another string (char version). | |
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) |
char * | strnchr (char *s, int c, size_t len) |
Finds the first occurance of a character in an array (char version). | |
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). | |
int | strncmp (const char *s, const char *t, size_t len) |
Compares two arrays (char version). | |
int | strncmp (const ACE_WCHAR_T *s, const ACE_WCHAR_T *t, size_t len) |
Compares two arrays (wchar_t version). | |
char * | strncpy (char *s, const char *t, size_t len) |
Copies an array (char version). | |
ACE_WCHAR_T * | strncpy (ACE_WCHAR_T *s, const ACE_WCHAR_T *t, size_t len) |
Copies an array (ACE_WCHAR_T version). | |
size_t | strnlen (const char *s, size_t maxlen) |
Finds the length of a limited-length string (char version). | |
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) |
char * | strnstr (char *s, const char *t, size_t len) |
Finds the first occurance of a substring in an array (char version). | |
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). | |
const char * | strpbrk (const char *s1, const char *s2) |
Searches for characters in a string (const char version). | |
char * | strpbrk (char *s1, const char *s2) |
Searches for characters in a string (char version). | |
const char * | strrchr (const char *s, int c) |
char * | strrchr (char *s, int c) |
Finds the last occurance of a character in a string (char version). | |
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). | |
size_t | strspn (const char *s1, const char *s2) |
const char * | strstr (const char *s, const char *t) |
char * | strstr (char *s, const char *t) |
Finds the first occurance of a substring in a string (char version). | |
char * | strtok (char *s, const char *tokens) |
Finds the next token in a string (char version). | |
int | madvise (caddr_t addr, size_t len, int map_advice) |
void * | mmap (void *addr, size_t len, int prot, int flags, ACE_HANDLE handle, ACE_OFF_T off=0, ACE_HANDLE *file_mapping=0, LPSECURITY_ATTRIBUTES sa=0, const ACE_TCHAR *file_mapping_name=0) |
int | mprotect (void *addr, size_t len, int prot) |
int | msync (void *addr, size_t len, int sync) |
int | munmap (void *addr, size_t len) |
int | msgctl (int msqid, int cmd, struct msqid_ds *) |
int | msgget (key_t key, int msgflg) |
ssize_t | msgrcv (int int_id, void *buf, size_t len, long type, int flags) |
int | msgsnd (int int_id, const void *buf, size_t len, int flags) |
void * | shmat (int int_id, const void *shmaddr, int shmflg) |
int | shmctl (int int_id, int cmd, struct shmid_ds *buf) |
int | shmdt (const void *shmaddr) |
int | shmget (key_t key, size_t size, int flags) |
ACE_HANDLE | accept (ACE_HANDLE handle, struct sockaddr *addr, int *addrlen) |
BSD-style accept (no QoS). | |
ACE_Export ACE_HANDLE | accept (ACE_HANDLE handle, struct sockaddr *addr, int *addrlen, const ACE_Accept_QoS_Params &qos_params) |
int | bind (ACE_HANDLE s, struct sockaddr *name, int namelen) |
BSD-style accept (no QoS). | |
int | closesocket (ACE_HANDLE s) |
Takes care of windows specific requirement to call closesocket. | |
int | connect (ACE_HANDLE handle, struct sockaddr *addr, int addrlen) |
BSD-style connect (no QoS). | |
ACE_Export int | connect (ACE_HANDLE handle, const sockaddr *addr, int addrlen, const ACE_QoS_Params &qos_params) |
int | enum_protocols (int *protocols, ACE_Protocol_Info *protocol_buffer, u_long *buffer_length) |
int | getpeername (ACE_HANDLE handle, struct sockaddr *addr, int *addrlen) |
BSD-style accept (no QoS). | |
int | getsockname (ACE_HANDLE handle, struct sockaddr *addr, int *addrlen) |
BSD-style accept (no QoS). | |
int | getsockopt (ACE_HANDLE handle, int level, int optname, char *optval, int *optlen) |
BSD-style accept (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. | |
int | listen (ACE_HANDLE handle, int backlog) |
BSD-style accept (no QoS). | |
ssize_t | recv (ACE_HANDLE handle, char *buf, size_t len, int flags=0) |
BSD-style accept (no QoS). | |
ssize_t | recvfrom (ACE_HANDLE handle, char *buf, size_t len, int flags, struct sockaddr *addr, int *addrlen) |
BSD-style accept (no QoS). | |
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 accept (no QoS). | |
ssize_t | recvmsg (ACE_HANDLE handle, struct msghdr *msg, int flags) |
BSD-style accept (no QoS). | |
ssize_t | recvv (ACE_HANDLE handle, iovec *iov, int iovlen) |
BSD-style accept (no QoS). | |
ssize_t | send (ACE_HANDLE handle, const char *buf, size_t len, int flags=0) |
BSD-style accept (no QoS). | |
ssize_t | sendmsg (ACE_HANDLE handle, const struct msghdr *msg, int flags) |
BSD-style accept (no QoS). | |
ssize_t | sendto (ACE_HANDLE handle, const char *buf, size_t len, int flags, const struct sockaddr *addr, int addrlen) |
BSD-style accept (no QoS). | |
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 accept (no QoS). | |
ssize_t | sendv (ACE_HANDLE handle, const iovec *iov, int iovcnt) |
BSD-style accept (no QoS). | |
int | setsockopt (ACE_HANDLE handle, int level, int optname, const char *optval, int optlen) |
Manipulate the options associated with a socket. | |
int | shutdown (ACE_HANDLE handle, int how) |
BSD-style accept (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_HANDLE | socket (int protocol_family, int type, int proto) |
Create a BSD-style socket (no QoS). | |
ACE_HANDLE | socket (int protocol_family, int type, int proto, ACE_Protocol_Info *protocolinfo, ACE_SOCK_GROUP g, u_long flags) |
int | socketpair (int domain, int type, int protocol, ACE_HANDLE sv[2]) |
BSD-style accept (no QoS). | |
ACE_OFF_T | filesize (ACE_HANDLE handle) |
ACE_OFF_T | filesize (const ACE_TCHAR *handle) |
int | condattr_init (ACE_condattr_t &attributes, int type=ACE_DEFAULT_SYNCH_TYPE) |
int | condattr_destroy (ACE_condattr_t &attributes) |
int | cond_broadcast (ACE_cond_t *cv) |
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) |
int | cond_init (ACE_cond_t *cv, ACE_condattr_t &attributes, const char *name=0, void *arg=0) |
int | cond_signal (ACE_cond_t *cv) |
int | cond_timedwait (ACE_cond_t *cv, ACE_mutex_t *m, ACE_Time_Value *timeout) |
int | cond_wait (ACE_cond_t *cv, ACE_mutex_t *m) |
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_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) |
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_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) |
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) |
int | recursive_mutex_cond_unlock (ACE_recursive_thread_mutex_t *m, ACE_recursive_mutex_state &state) |
void | recursive_mutex_cond_relock (ACE_recursive_thread_mutex_t *m, ACE_recursive_mutex_state &state) |
int | recursive_mutex_destroy (ACE_recursive_thread_mutex_t *m) |
int | recursive_mutex_init (ACE_recursive_thread_mutex_t *m, const ACE_TCHAR *name=0, ACE_mutexattr_t *arg=0, LPSECURITY_ATTRIBUTES sa=0) |
int | recursive_mutex_lock (ACE_recursive_thread_mutex_t *m) |
int | recursive_mutex_lock (ACE_recursive_thread_mutex_t *m, const ACE_Time_Value &timeout) |
int | recursive_mutex_lock (ACE_recursive_thread_mutex_t *m, const ACE_Time_Value *timeout) |
int | recursive_mutex_trylock (ACE_recursive_thread_mutex_t *m) |
int | recursive_mutex_unlock (ACE_recursive_thread_mutex_t *m) |
int | rw_rdlock (ACE_rwlock_t *rw) |
int | rw_tryrdlock (ACE_rwlock_t *rw) |
int | rw_trywrlock (ACE_rwlock_t *rw) |
int | rw_trywrlock_upgrade (ACE_rwlock_t *rw) |
int | rw_unlock (ACE_rwlock_t *rw) |
int | rw_wrlock (ACE_rwlock_t *rw) |
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) |
ACE_Export int | sched_params (const ACE_Sched_Params &, ACE_id_t id=ACE_SELF) |
int | sema_destroy (ACE_sema_t *s) |
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) |
int | sema_post (ACE_sema_t *s) |
int | sema_post (ACE_sema_t *s, u_int release_count) |
int | sema_trywait (ACE_sema_t *s) |
int | sema_wait (ACE_sema_t *s) |
int | sema_wait (ACE_sema_t *s, ACE_Time_Value &tv) |
int | sema_wait (ACE_sema_t *s, ACE_Time_Value *tv) |
int | semctl (int int_id, int semnum, int cmd, semun) |
int | semget (key_t key, int nsems, int flags) |
int | semop (int int_id, struct sembuf *sops, size_t nsops) |
int | thread_mutex_destroy (ACE_thread_mutex_t *m) |
int | thread_mutex_init (ACE_thread_mutex_t *m, int lock_type=0, const char *name=0, ACE_mutexattr_t *arg=0) |
int | thread_mutex_lock (ACE_thread_mutex_t *m) |
int | thread_mutex_lock (ACE_thread_mutex_t *m, const ACE_Time_Value &timeout) |
int | thread_mutex_lock (ACE_thread_mutex_t *m, const ACE_Time_Value *timeout) |
int | thread_mutex_trylock (ACE_thread_mutex_t *m) |
int | thread_mutex_unlock (ACE_thread_mutex_t *m) |
char * | asctime (const struct tm *tm) |
char * | asctime_r (const struct tm *tm, char *buf, int buflen) |
int | clock_gettime (clockid_t, struct timespec *) |
int | clock_settime (clockid_t, const struct timespec *) |
ACE_TCHAR * | ctime (const time_t *t) |
ACE_TCHAR * | ctime_r (const time_t *clock, ACE_TCHAR *buf, int buflen) |
double | difftime (time_t t1, time_t t0) |
ACE_hrtime_t | gethrtime (const ACE_HRTimer_Op=ACE_HRTIMER_GETTIME) |
struct tm * | gmtime (const time_t *clock) |
struct tm * | gmtime_r (const time_t *clock, struct tm *res) |
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) |
int | nanosleep (const struct timespec *requested, struct timespec *remaining=0) |
size_t | strftime (char *s, size_t maxsize, const char *format, const struct tm *timeptr) |
char * | strptime (const char *buf, const char *format, struct tm *tm) |
time_t | time (time_t *tloc=0) |
long | timezone (void) |
void | tzset (void) |
pid_t | fork (void) |
ACE_Export pid_t | fork (const ACE_TCHAR *program_name) |
ACE_Export pid_t | fork_exec (ACE_TCHAR *argv[]) |
Variables | |
ACE_Export ACE_thread_t | NULL_thread |
ACE_Export ACE_hthread_t | NULL_hthread |
ACE_Export ACE_thread_key_t | NULL_key |
Non-standard functions | |
These functions aren't in the standard. | |
ACE_Export ACE_EXIT_HOOK | exit_hook_ |
Function that is called by <ACE_OS::exit>, if non-null. | |
void | _exit (int status=0) |
Function that is called by <ACE_OS::exit>, if non-null. | |
void | abort (void) |
Function that is called by <ACE_OS::exit>, if non-null. | |
int | atexit (ACE_EXIT_HOOK func, const char *name=0) |
int | atoi (const char *s) |
Function that is called by <ACE_OS::exit>, if non-null. | |
long | atol (const char *s) |
Function that is called by <ACE_OS::exit>, if non-null. | |
double | atof (const char *s) |
Function that is called by <ACE_OS::exit>, if non-null. | |
void * | atop (const char *s) |
Function that is called by <ACE_OS::exit>, if non-null. | |
void * | bsearch (const void *key, const void *base, size_t nel, size_t size, ACE_COMPARE_FUNC) |
Function that is called by <ACE_OS::exit>, if non-null. | |
ACE_Export void * | calloc (size_t elements, size_t sizeof_elements) |
Function that is called by <ACE_OS::exit>, if non-null. | |
ACE_Export void | exit (int status=0) |
Function that is called by <ACE_OS::exit>, if non-null. | |
ACE_Export void | free (void *) |
Function that is called by <ACE_OS::exit>, if non-null. | |
char * | getenv (const char *symbol) |
Function that is called by <ACE_OS::exit>, if non-null. | |
ACE_Export ACE_TCHAR * | getenvstrings (void) |
Function that is called by <ACE_OS::exit>, if non-null. | |
char * | itoa (int value, char *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 void * | malloc (size_t) |
Function that is called by <ACE_OS::exit>, if non-null. | |
ACE_HANDLE | mkstemp (char *s) |
Function that is called by <ACE_OS::exit>, if non-null. | |
char * | mktemp (char *s) |
Function that is called by <ACE_OS::exit>, if non-null. | |
int | putenv (const char *string) |
Function that is called by <ACE_OS::exit>, if non-null. | |
void | qsort (void *base, size_t nel, size_t width, ACE_COMPARE_FUNC) |
Function that is called by <ACE_OS::exit>, if non-null. | |
int | setenv (const char *envname, const char *envval, int overwrite) |
Function that is called by <ACE_OS::exit>, if non-null. | |
int | unsetenv (const char *name) |
Function that is called by <ACE_OS::exit>, if non-null. | |
int | rand (void) |
Function that is called by <ACE_OS::exit>, if non-null. | |
int | rand_r (ACE_RANDR_TYPE &seed) |
Function that is called by <ACE_OS::exit>, if non-null. | |
ACE_Export void * | realloc (void *, size_t) |
Function that is called by <ACE_OS::exit>, if non-null. | |
char * | realpath (const char *file_name, char *resolved_name) |
Function that is called by <ACE_OS::exit>, if non-null. | |
ACE_EXIT_HOOK | set_exit_hook (ACE_EXIT_HOOK hook) |
For use by ACE_Object_Manager only, to register its exit hook.. | |
void | srand (u_int seed) |
Function that is called by <ACE_OS::exit>, if non-null. | |
ACE_Export ACE_TCHAR * | strenvdup (const ACE_TCHAR *str) |
Function that is called by <ACE_OS::exit>, if non-null. | |
double | strtod (const char *s, char **endptr) |
Converts a string to a double value (char version). | |
long | strtol (const char *s, char **ptr, int base) |
Converts a string to a long value (char version). | |
unsigned long | strtoul (const char *s, char **ptr, int base) |
Converts a string to an unsigned long value (char version). | |
ACE_INT64 | strtoll (const char *s, char **ptr, int base) |
Converts a string to a signed 64 bit int value (char version). | |
ACE_UINT64 | strtoull (const char *s, char **ptr, int base) |
Converts a string to a unsigned 64 bit int value (char version). | |
int | system (const ACE_TCHAR *s) |
Function that is called by <ACE_OS::exit>, if non-null. | |
const char * | getprogname () |
ACE_Export const char * | getprogname_emulation () |
Function that is called by <ACE_OS::exit>, if non-null. | |
void | setprogname (const char *name) |
ACE_Export void | setprogname_emulation (const char *name) |
Function that is called by <ACE_OS::exit>, if non-null. |
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 class is a wrapper for the XTI/TLI operations.
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 ACE_WCHAR_T ACE_OS::WChar |
Definition at line 45 of file OS_NS_wchar.h.
Definition at line 159 of file OS_NS_time.h.
{ ACE_HRTIMER_START = 0x0, // Only use these if you can stand ACE_HRTIMER_INCR = 0x1, // for interrupts to be disabled during ACE_HRTIMER_STOP = 0x2, // the timed interval!!!! ACE_HRTIMER_GETTIME = 0xFFFF };
void ACE_OS::_exit | ( | int | status = 0 |
) | [inline] |
Function that is called by <ACE_OS::exit>, if non-null.
Definition at line 23 of file OS_NS_stdlib.inl.
{ ACE_OS_TRACE ("ACE_OS::_exit"); #if defined (ACE_VXWORKS) ::exit (status); #elif !defined (ACE_HAS_WINCE) ::_exit (status); #else ::TerminateProcess (::GetCurrentProcess (), status); #endif /* ACE_VXWORKS */ }
void ACE_OS::abort | ( | void | ) | [inline] |
Function that is called by <ACE_OS::exit>, if non-null.
Definition at line 36 of file OS_NS_stdlib.inl.
ACE_HANDLE ACE_OS::accept | ( | ACE_HANDLE | handle, | |
struct sockaddr * | addr, | |||
int * | addrlen | |||
) | [inline] |
BSD-style accept
(no QoS).
Definition at line 29 of file OS_NS_sys_socket.inl.
{ ACE_OS_TRACE ("ACE_OS::accept"); // On a non-blocking socket with no connections to accept, this // system call will return EWOULDBLOCK or EAGAIN, depending on the // platform. UNIX 98 allows either errno, and they may be the same // numeric value. So to make life easier for upper ACE layers as // well as application programmers, always change EAGAIN to // EWOULDBLOCK. Rather than hack the ACE_OSCALL_RETURN macro, it's // handled explicitly here. If the ACE_OSCALL macro ever changes, // this function needs to be reviewed. On Win32, the regular macros // can be used, as this is not an issue. #if defined (ACE_LACKS_ACCEPT) ACE_UNUSED_ARG (handle); ACE_UNUSED_ARG (addr); ACE_UNUSED_ARG (addrlen); ACE_NOTSUP_RETURN (ACE_INVALID_HANDLE); #elif defined (ACE_WIN32) ACE_SOCKCALL_RETURN (::accept ((ACE_SOCKET) handle, addr, (ACE_SOCKET_LEN *) addrlen), ACE_HANDLE, ACE_INVALID_HANDLE); #else # if defined (ACE_HAS_BROKEN_ACCEPT_ADDR) // Apparently some platforms like VxWorks can't correctly deal with // a NULL addr. sockaddr_in fake_addr; int fake_addrlen; if (addrlen == 0) addrlen = &fake_addrlen; if (addr == 0) { addr = (sockaddr *) &fake_addr; *addrlen = sizeof fake_addr; } # endif /* ACE_HAS_BROKEN_ACCEPT_ADDR */ ACE_HANDLE ace_result = ::accept ((ACE_SOCKET) handle, addr, (ACE_SOCKET_LEN *) addrlen); # if !(defined (EAGAIN) && defined (EWOULDBLOCK) && EAGAIN == EWOULDBLOCK) // Optimize this code out if we can detect that EAGAIN == // EWOULDBLOCK at compile time. If we cannot detect equality at // compile-time (e.g. if EAGAIN or EWOULDBLOCK are not preprocessor // macros) perform the check at run-time. The goal is to avoid two // TSS accesses in the _REENTRANT case when EAGAIN == EWOULDBLOCK. if (ace_result == ACE_INVALID_HANDLE # if !defined (EAGAIN) || !defined (EWOULDBLOCK) && EAGAIN != EWOULDBLOCK # endif /* !EAGAIN || !EWOULDBLOCK */ && errno == EAGAIN) { errno = EWOULDBLOCK; } # endif /* EAGAIN != EWOULDBLOCK*/ return ace_result; #endif /* defined (ACE_WIN32) */ }
ACE_HANDLE ACE_OS::accept | ( | ACE_HANDLE | handle, | |
struct sockaddr * | addr, | |||
int * | addrlen, | |||
const ACE_Accept_QoS_Params & | qos_params | |||
) |
QoS-enabled accept
, which passes qos_params to accept
. If the OS platform doesn't support QoS-enabled accept
then the qos_params are ignored and the BSD-style accept
is called.
Definition at line 18 of file OS_NS_sys_socket.cpp.
{ # if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) ACE_SOCKCALL_RETURN (::WSAAccept ((ACE_SOCKET) handle, addr, (ACE_SOCKET_LEN *) addrlen, (LPCONDITIONPROC) qos_params.qos_condition_callback (), qos_params.callback_data ()), ACE_HANDLE, ACE_INVALID_HANDLE); # else ACE_UNUSED_ARG (qos_params); return ACE_OS::accept (handle, addr, addrlen); # endif /* ACE_HAS_WINSOCK2 */ }
int ACE_OS::access | ( | const char * | path, | |
int | amode | |||
) | [inline] |
Definition at line 37 of file OS_NS_unistd.inl.
{ ACE_OS_TRACE ("ACE_OS::access"); #if defined (ACE_LACKS_ACCESS) # if defined (ACE_HAS_ACCESS_EMULATION) // @@ WINCE: There should be a Win32 API that can do this. // Hard coded read access here. ACE_UNUSED_ARG (amode); FILE* handle = ACE_OS::fopen (ACE_TEXT_CHAR_TO_TCHAR(path), ACE_TEXT ("r")); if (handle != 0) { ACE_OS::fclose (handle); return 0; } return -1; # else ACE_UNUSED_ARG (path); ACE_UNUSED_ARG (amode); ACE_NOTSUP_RETURN (-1); # endif /* ACE_HAS_ACCESS_EMULATION */ #elif defined(ACE_WIN32) // Windows doesn't support checking X_OK(6) ACE_OSCALL_RETURN (::access (path, amode & 6), int, -1); #else ACE_OSCALL_RETURN (::access (path, amode), int, -1); #endif /* ACE_LACKS_ACCESS */ }
int ACE_OS::ace_isalnum | ( | ACE_TCHAR | c | ) | [inline] |
Returns true if the character is an alphanumeric character.
Definition at line 16 of file OS_NS_ctype.inl.
{ #if defined (ACE_USES_WCHAR) # if defined (_MSC_VER) // For MSVC 7.x, we need to prevent "illegal" character getting into // isalnum, otherwise, it will crash the program. return c > 0 && c < 0xFF && iswalnum (c); # else return iswalnum (c); # endif /* _MSC_VER */ #else /* ACE_USES_WCHAR */ return isalnum ((unsigned char) c); #endif /* ACE_USES_WCHAR */ }
int ACE_OS::ace_isalpha | ( | ACE_TCHAR | c | ) | [inline] |
Returns true if the character is an alphabetic character.
Definition at line 73 of file OS_NS_ctype.inl.
{ #if defined (ACE_USES_WCHAR) return iswalpha (c); #else /* ACE_USES_WCHAR */ return isalpha ((unsigned char) c); #endif /* ACE_USES_WCHAR */ }
int ACE_OS::ace_isascii | ( | ACE_TCHAR | c | ) | [inline] |
Returns true if the character is a control character.
Definition at line 32 of file OS_NS_ctype.inl.
{ #if defined (ACE_USES_WCHAR) # if defined (ACE_LACKS_ISWASCII) if (c < 256) return isascii (static_cast<int> (c)); else return c; # else return iswascii (c); # endif #else /* ACE_USES_WCHAR */ # if defined (ACE_LACKS_ISASCII) return (static_cast<unsigned char>(c) <= 0x7F); #else return isascii ((unsigned char) c); #endif /* ACE_LACKS_ISASCII */ #endif /* ACE_USES_WCHAR */ }
int ACE_OS::ace_isblank | ( | ACE_TCHAR | c | ) | [inline] |
Returns true if the character is a control character.
Definition at line 53 of file OS_NS_ctype.inl.
{ #if defined (ACE_USES_WCHAR) # if defined (ACE_LACKS_ISWBLANK) # if !defined (ACE_LACKS_ISWCTYPE) return ace_iswctype (c, _BLANK); # else return (c == 0x9) || (c == 0x20); # endif /* !ACE_LACKS_ISWCTYPE */ # else return iswblank (c); # endif /* ACE_LACKS_ISWBLANK */ #elif defined (ACE_LACKS_ISBLANK) return (c == 0x9) || (c == 0x20); #else /* ACE_USES_WCHAR */ return isblank ((unsigned char) c); #endif /* ACE_USES_WCHAR */ }
int ACE_OS::ace_iscntrl | ( | ACE_TCHAR | c | ) | [inline] |
Returns true if the character is a control character.
Definition at line 83 of file OS_NS_ctype.inl.
{ #if defined (ACE_USES_WCHAR) return iswcntrl (c); #else /* ACE_USES_WCHAR */ return iscntrl ((unsigned char) c); #endif /* ACE_USES_WCHAR */ }
int ACE_OS::ace_isctype | ( | int | c, | |
ctype_t | desc | |||
) | [inline] |
Tests c for the property specified by the desc argument.
Definition at line 218 of file OS_NS_ctype.inl.
{ #if defined (ACE_ISCTYPE_EQUIVALENT) return ACE_ISCTYPE_EQUIVALENT (c, desc); #elif !defined (ACE_LACKS_ISCTYPE) return isctype (c, desc); #else ACE_UNUSED_ARG (c); ACE_UNUSED_ARG (desc); ACE_NOTSUP_RETURN (-1); #endif }
int ACE_OS::ace_isdigit | ( | ACE_TCHAR | c | ) | [inline] |
Returns true if the character is a decimal-digit character.
Definition at line 93 of file OS_NS_ctype.inl.
{ #if defined (ACE_USES_WCHAR) return iswdigit (c); #else /* ACE_USES_WCHAR */ return isdigit ((unsigned char) c); #endif /* ACE_USES_WCHAR */ }
int ACE_OS::ace_isgraph | ( | ACE_TCHAR | c | ) | [inline] |
Returns true if the character is a printable character other than a space.
Definition at line 103 of file OS_NS_ctype.inl.
{ #if defined (ACE_USES_WCHAR) return iswgraph (c); #else /* ACE_USES_WCHAR */ return isgraph ((unsigned char) c); #endif /* ACE_USES_WCHAR */ }
int ACE_OS::ace_islower | ( | ACE_TCHAR | c | ) | [inline] |
Returns true if the character is a lowercase character.
Definition at line 113 of file OS_NS_ctype.inl.
{ #if defined (ACE_USES_WCHAR) return iswlower (c); #else /* ACE_USES_WCHAR */ return islower ((unsigned char) c); #endif /* ACE_USES_WCHAR */ }
int ACE_OS::ace_isprint | ( | ACE_TCHAR | c | ) | [inline] |
Returns true if the character is a printable character.
Definition at line 123 of file OS_NS_ctype.inl.
{ #if defined (ACE_USES_WCHAR) # if defined (ACE_LACKS_CORRECT_ISWPRINT_TAB) /* The MS CRT has the bug that for tab (\t) iswprint returns true instead of * false. This has been reported to Microsoft: * https://connect.microsoft.com/VisualStudio/feedback ID# 381915 */ if (c == 0x9) { return 0; } # endif return iswprint (c); #else /* ACE_USES_WCHAR */ return isprint ((unsigned char) c); #endif /* ACE_USES_WCHAR */ }
int ACE_OS::ace_ispunct | ( | ACE_TCHAR | c | ) | [inline] |
Returns true if the character is a punctuation character.
Definition at line 143 of file OS_NS_ctype.inl.
{ #if defined (ACE_USES_WCHAR) return iswpunct (c); #else /* ACE_USES_WCHAR */ return ispunct ((unsigned char) c); #endif /* ACE_USES_WCHAR */ }
int ACE_OS::ace_isspace | ( | ACE_TCHAR | c | ) | [inline] |
Returns true if the character is a space character.
Definition at line 153 of file OS_NS_ctype.inl.
{ #if defined (ACE_USES_WCHAR) return iswspace (c); #else /* ACE_USES_WCHAR */ return isspace ((unsigned char) c); #endif /* ACE_USES_WCHAR */ }
int ACE_OS::ace_isupper | ( | ACE_TCHAR | c | ) | [inline] |
Returns true if the character is an uppercase character.
Definition at line 163 of file OS_NS_ctype.inl.
{ #if defined (ACE_USES_WCHAR) return iswupper (c); #else /* ACE_USES_WCHAR */ return isupper ((unsigned char) c); #endif /* ACE_USES_WCHAR */ }
int ACE_OS::ace_isxdigit | ( | ACE_TCHAR | c | ) | [inline] |
Returns true if the character is a hexadecimal-digit character.
Definition at line 173 of file OS_NS_ctype.inl.
{ #if defined (ACE_USES_WCHAR) return iswxdigit (c); #else /* ACE_USES_WCHAR */ return isxdigit ((unsigned char) c); #endif /* ACE_USES_WCHAR */ }
int ACE_OS::ace_tolower | ( | int | c | ) | [inline] |
Converts a character to lower case (char version).
Definition at line 183 of file OS_NS_ctype.inl.
{
return tolower (c);
}
int ACE_OS::ace_toupper | ( | int | c | ) | [inline] |
Converts a character to upper case (char version).
Definition at line 204 of file OS_NS_ctype.inl.
{
return toupper (c);
}
u_int ACE_OS::alarm | ( | u_int | secs | ) | [inline] |
Definition at line 80 of file OS_NS_unistd.inl.
{ ACE_OS_TRACE ("ACE_OS::alarm"); #if defined (ACE_LACKS_ALARM) ACE_UNUSED_ARG (secs); ACE_NOTSUP_RETURN (0); #else return ::alarm (secs); #endif /* ACE_LACKS_ALARM */ }
long ACE_OS::allocation_granularity | ( | void | ) | [inline] |
Definition at line 110 of file OS_NS_unistd.inl.
{ #if defined (ACE_WIN32) SYSTEM_INFO sys_info; ::GetSystemInfo (&sys_info); return sys_info.dwAllocationGranularity; #else return ACE_OS::getpagesize (); #endif /* ACE_WIN32 */ }
int ACE_OS::alphasort | ( | const void * | a, | |
const void * | b | |||
) | [inline] |
Definition at line 142 of file OS_NS_dirent.inl.
{ #if defined (ACE_LACKS_ALPHASORT) return ACE_OS::strcmp ((*static_cast<const struct ACE_DIRENT * const *>(a))->d_name, (*static_cast<const struct ACE_DIRENT * const *>(b))->d_name); #else # if defined (ACE_SCANDIR_CMP_USES_VOIDPTR) return ::alphasort (const_cast<void *>(a), const_cast<void *>(b)); # elif defined (ACE_SCANDIR_CMP_USES_CONST_VOIDPTR) return ::alphasort (a, b); # else return ::alphasort ((const struct ACE_DIRENT **)a, (const struct ACE_DIRENT **)b); # endif #endif }
int ACE_OS::argv_to_string | ( | int | argc, | |
ACE_TCHAR ** | argv, | |||
ACE_TCHAR *& | buf, | |||
bool | substitute_env_args = true , |
|||
bool | quote_args = false | |||
) |
used by ARGV::argv_to_string() and ACE_OS::fork_exec()
Definition at line 66 of file OS_NS_unistd.cpp.
{ #if defined (ACE_LACKS_STRENVDUP) ACE_UNUSED_ARG (substitute_env_args); #endif /* ACE_LACKS_STRENVDUP */ if (argc <= 0 || argv == 0 || argv[0] == 0) return 0; size_t buf_len = 0; // Determine the length of the buffer. ACE_TCHAR **argv_p = argv; for (int i = 0; i < argc; ++i) { #if !defined (ACE_LACKS_STRENVDUP) // Account for environment variables. if (substitute_env_args && ACE_OS::strchr (argv[i], ACE_TEXT ('$')) != 0) { if (argv_p == argv) { argv_p = (ACE_TCHAR **) ACE_OS::malloc (argc * sizeof (ACE_TCHAR *)); if (argv_p == 0) { errno = ENOMEM; return 0; } ACE_OS::memcpy (argv_p, argv, argc * sizeof (ACE_TCHAR *)); } argv_p[i] = ACE_OS::strenvdup (argv[i]); if (argv_p[i] == 0) { ACE_OS::free (argv_p); errno = ENOMEM; return 0; } } #endif /* ACE_LACKS_STRENVDUP */ // If must quote, we only do it if the arg contains spaces, or // is empty. Perhaps a check for other c | ord(c) <= 32 is in // order? if (quote_args && (ACE_OS::strchr (argv_p[i], ACE_TEXT (' ')) != 0 || ACE_OS::strchr (argv_p[i], ACE_TEXT ('\t')) != 0 || ACE_OS::strchr (argv_p[i], ACE_TEXT ('\n')) != 0 || *argv_p[i] == 0)) { if (argv_p == argv) { argv_p = (ACE_TCHAR **) ACE_OS::malloc (argc * sizeof (ACE_TCHAR *)); if (argv_p == 0) { errno = ENOMEM; return 0; } ACE_OS::memcpy (argv_p, argv, argc * sizeof (ACE_TCHAR *)); } int quotes = 0; ACE_TCHAR *temp = argv_p[i]; if (ACE_OS::strchr (temp, ACE_TEXT ('"')) != 0) { for (int j = 0; temp[j] != 0; ++j) if (temp[j] == ACE_TEXT ('"')) ++quotes; } argv_p[i] = (ACE_TCHAR *) ACE_OS::malloc ((ACE_OS::strlen (temp) + quotes + 3) * sizeof (ACE_TCHAR)); if (argv_p[i] == 0) { ACE_OS::free (argv_p); errno = ENOMEM; return 0; } ACE_TCHAR *end = argv_p[i]; *end++ = ACE_TEXT ('"'); if (quotes > 0) { for (ACE_TCHAR *p = temp; *p != 0; *end++ = *p++) if (*p == ACE_TEXT ('"')) *end++ = ACE_TEXT ('\\'); *end++ = ACE_TEXT ('\0'); } else end = ACE_OS::strecpy (end, temp); end[-1] = ACE_TEXT ('"'); *end = ACE_TEXT ('\0'); if (temp != argv[i]) ACE_OS::free (temp); } buf_len += ACE_OS::strlen (argv_p[i]); // Add one for the extra space between each string. buf_len++; } // Step through all argv params and copy each one into buf; separate // each param with white space. ACE_NEW_RETURN (buf, ACE_TCHAR[buf_len + 1], 0); // Initial null charater to make it a null string. buf[0] = ACE_TEXT ('\0'); ACE_TCHAR *end = buf; for (int i = 0; i < argc; ++i) { end = ACE_OS::strecpy (end, argv_p[i]); if (argv_p[i] != argv[i]) ACE_OS::free (argv_p[i]); // Replace the null char that strecpy put there with white // space. end[-1] = ACE_TEXT (' '); } // Null terminate the string. *end = ACE_TEXT ('\0'); if (argv_p != argv) ACE_OS::free (argv_p); // The number of arguments. return argc; }
int ACE_OS::argv_to_string | ( | ACE_TCHAR ** | argv, | |
ACE_TCHAR *& | buf, | |||
bool | substitute_env_args = true , |
|||
bool | quote_args = false | |||
) |
Definition at line 46 of file OS_NS_unistd.cpp.
{ if (argv == 0 || argv[0] == 0) return 0; int argc; for (argc = 0; argv[argc] != 0; ++argc) continue; return argv_to_string (argc, argv, buf, substitute_env_args, quote_args); }
char * ACE_OS::asctime | ( | const struct tm * | tm | ) | [inline] |
strptime wrapper. Note that the struct tm will always be set to zero
Definition at line 14 of file OS_NS_time.inl.
{ ACE_OS_TRACE ("ACE_OS::asctime"); #if defined (ACE_LACKS_ASCTIME) ACE_UNUSED_ARG (t); ACE_NOTSUP_RETURN (0); #else ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::asctime (t), char *, 0); #endif /* ACE_LACKS_ASCTIME */ }
char * ACE_OS::asctime_r | ( | const struct tm * | tm, | |
char * | buf, | |||
int | buflen | |||
) | [inline] |
strptime wrapper. Note that the struct tm will always be set to zero
Definition at line 26 of file OS_NS_time.inl.
{ ACE_OS_TRACE ("ACE_OS::asctime_r"); #if defined (ACE_HAS_REENTRANT_FUNCTIONS) # if defined (ACE_HAS_2_PARAM_ASCTIME_R_AND_CTIME_R) char *result; # if defined (DIGITAL_UNIX) ACE_OSCALL (::_Pasctime_r (t, buf), char *, 0, result); # else ACE_OSCALL (::asctime_r (t, buf), char *, 0, result); # endif /* DIGITAL_UNIX */ ACE_OS::strsncpy (buf, result, buflen); return buf; # else # if defined (ACE_HAS_SIZET_PTR_ASCTIME_R_AND_CTIME_R) ACE_OSCALL_RETURN (::asctime_r (t, buf, reinterpret_cast<size_t*>(&buflen)), char *, 0); # else ACE_OSCALL_RETURN (::asctime_r (t, buf, buflen), char *, 0); # endif /* ACE_HAS_SIZET_PTR_ASCTIME_R_AND_CTIME_R */ # endif /* ACE_HAS_2_PARAM_ASCTIME_R_AND_CTIME_R */ #elif defined (ACE_LACKS_ASCTIME_R) ACE_UNUSED_ARG (t); ACE_UNUSED_ARG (buf); ACE_UNUSED_ARG (buflen); ACE_NOTSUP_RETURN (0); #elif defined (ACE_HAS_TR24731_2005_CRT) char *result = buf; ACE_SECURECRTCALL (asctime_s (buf, static_cast<size_t> (buflen), t), \ char*, 0, result); return result; #else char *result = 0; ACE_OSCALL (ACE_STD_NAMESPACE::asctime (t), char *, 0, result); ACE_OS::strsncpy (buf, result, buflen); return buf; #endif /* ACE_HAS_REENTRANT_FUNCTIONS */ }
int ACE_OS::asprintf | ( | char ** | bufp, | |
const char * | format, | |||
... | ||||
) |
Definition at line 272 of file OS_NS_stdio.cpp.
{ // ACE_OS_TRACE ("ACE_OS::asprintf"); va_list ap; va_start (ap, format); int const result = ACE_OS::vasprintf (bufp, format, ap); va_end (ap); return result; }
int ACE_OS::atexit | ( | ACE_EXIT_HOOK | func, | |
const char * | name = 0 | |||
) | [inline] |
Register an at exit hook. The name can be used to analyze shutdown problems
Definition at line 47 of file OS_NS_stdlib.inl.
{ return ACE_OS_Object_Manager::instance ()->at_exit (func, name); }
double ACE_OS::atof | ( | const char * | s | ) | [inline] |
Function that is called by <ACE_OS::exit>, if non-null.
Definition at line 89 of file OS_NS_stdlib.inl.
{ ACE_OSCALL_RETURN (::atof (s), double, -1); }
int ACE_OS::atoi | ( | const char * | s | ) | [inline] |
Function that is called by <ACE_OS::exit>, if non-null.
Definition at line 53 of file OS_NS_stdlib.inl.
{ ACE_OSCALL_RETURN (::atoi (s), int, -1); }
long ACE_OS::atol | ( | const char * | s | ) | [inline] |
Function that is called by <ACE_OS::exit>, if non-null.
Definition at line 71 of file OS_NS_stdlib.inl.
{ ACE_OSCALL_RETURN (::atol (s), long, -1); }
void * ACE_OS::atop | ( | const char * | s | ) | [inline] |
Function that is called by <ACE_OS::exit>, if non-null.
Definition at line 109 of file OS_NS_stdlib.inl.
{ ACE_TRACE ("ACE_OS::atop"); #if defined (ACE_WIN64) intptr_t ip = ::_atoi64 (s); #elif defined (ACE_OPENVMS) # if !defined (__INITIAL_POINTER_SIZE) || (__INITIAL_POINTER_SIZE < 64) int ip = ::atoi (s); # else intptr_t ip = ::atoi (s); # endif #else intptr_t ip = ::atoi (s); #endif /* ACE_WIN64 */ void * p = reinterpret_cast<void *> (ip); return p; }
int ACE_OS::bind | ( | ACE_HANDLE | s, | |
struct sockaddr * | name, | |||
int | namelen | |||
) | [inline] |
BSD-style accept
(no QoS).
Definition at line 98 of file OS_NS_sys_socket.inl.
{ ACE_OS_TRACE ("ACE_OS::bind"); #if defined (ACE_LACKS_BIND) ACE_UNUSED_ARG (handle); ACE_UNUSED_ARG (addr); ACE_UNUSED_ARG (addrlen); ACE_NOTSUP_RETURN (-1); #elif defined (ACE_VXWORKS) && (ACE_VXWORKS <= 0x640) // VxWorks clears the sin_port member after a succesfull bind when // sin_addr != INADDR_ANY, so after the bind we do retrieve the // original address so that user code can safely check the addr // after the bind. See bugzilla 3107 for more details int result; ACE_SOCKCALL (::bind ((ACE_SOCKET) handle, addr, (ACE_SOCKET_LEN) addrlen), int, -1, result); if (result == -1) return -1; else return ACE_OS::getsockname (handle, addr, &addrlen); #else ACE_SOCKCALL_RETURN (::bind ((ACE_SOCKET) handle, addr, (ACE_SOCKET_LEN) addrlen), int, -1); #endif }
void * ACE_OS::bsearch | ( | const void * | key, | |
const void * | base, | |||
size_t | nel, | |||
size_t | size, | |||
ACE_COMPARE_FUNC | compar | |||
) | [inline] |
Function that is called by <ACE_OS::exit>, if non-null.
Definition at line 148 of file OS_NS_stdlib.inl.
{ #if !defined (ACE_LACKS_BSEARCH) return ::bsearch (key, base, nel, size, compar); #else ACE_UNUSED_ARG (key); ACE_UNUSED_ARG (base); ACE_UNUSED_ARG (nel); ACE_UNUSED_ARG (size); ACE_UNUSED_ARG (compar); ACE_NOTSUP_RETURN (0); #endif /* ACE_LACKS_BSEARCH */ }
ACE_Export void* ACE_OS::calloc | ( | size_t | elements, | |
size_t | sizeof_elements | |||
) |
Function that is called by <ACE_OS::exit>, if non-null.
T ACE_OS::ceil | ( | T | x | ) |
This method computes the smallest integral value not less than x.
Definition at line 99 of file OS_NS_math.h.
{ return ACE_STD_NAMESPACE::ceil (x); }
int ACE_OS::chdir | ( | const char * | path | ) | [inline] |
Definition at line 122 of file OS_NS_unistd.inl.
{ ACE_OS_TRACE ("ACE_OS::chdir"); #if defined (ACE_LACKS_CHDIR) ACE_UNUSED_ARG (path); ACE_NOTSUP_RETURN (-1); #elif defined (ACE_HAS_NONCONST_CHDIR) ACE_OSCALL_RETURN (::chdir (const_cast<char *> (path)), int, -1); #else ACE_OSCALL_RETURN (::chdir (path), int, -1); #endif /* ACE_HAS_NONCONST_CHDIR */ }
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 1098 of file OS_NS_Thread.cpp.
{ #if defined (ACE_HAS_TSS_EMULATION) || defined (ACE_WIN32) { // scope the cleanup instance // Call TSS destructors for current thread. TSS_Cleanup_Instance cleanup; if (cleanup.valid ()) { cleanup->thread_exit (); } } #endif /* ACE_HAS_TSS_EMULATION || ACE_WIN32 */ if (main_thread) { #if !defined (ACE_HAS_TSS_EMULATION) && !defined (ACE_HAS_MINIMAL_ACE_OS) // Just close the ACE_Log_Msg for the current (which should be // main) thread. We don't have TSS emulation; if there's native // TSS, it should call its destructors when the main thread // exits. ACE_Base_Thread_Adapter::close_log_msg (); #endif /* ! ACE_HAS_TSS_EMULATION && ! ACE_HAS_MINIMAL_ACE_OS */ #if defined (ACE_WIN32) || defined (ACE_HAS_TSS_EMULATION) // Finally, free up the ACE_TSS_Cleanup instance. This method gets // called by the ACE_Object_Manager. TSS_Cleanup_Instance cleanup(TSS_Cleanup_Instance::DESTROY); if (cleanup.valid ()) { ; // the pointer deletes the Cleanup when it goes out of scope } #endif /* WIN32 || ACE_HAS_TSS_EMULATION */ #if defined (ACE_HAS_TSS_EMULATION) ACE_TSS_Emulation::tss_close (); #endif /* ACE_HAS_TSS_EMULATION */ } }
void ACE_OS::clearerr | ( | FILE * | fp | ) | [inline] |
Definition at line 344 of file OS_NS_stdio.inl.
{ ace_clearerr_helper (fp); }
strptime wrapper. Note that the struct tm will always be set to zero
Definition at line 65 of file OS_NS_time.inl.
{ ACE_OS_TRACE ("ACE_OS::clock_gettime"); #if defined (ACE_HAS_CLOCK_GETTIME) ACE_OSCALL_RETURN (::clock_gettime (clockid, ts), int, -1); #else ACE_UNUSED_ARG (clockid); ACE_UNUSED_ARG (ts); ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_CLOCK_GETTIME */ }
strptime wrapper. Note that the struct tm will always be set to zero
Definition at line 78 of file OS_NS_time.inl.
{ #if defined (ACE_HAS_CLOCK_SETTIME) # if defined (ACE_HAS_NONCONST_CLOCK_SETTIME) ACE_OSCALL_RETURN (::clock_settime (clockid, const_cast<struct timespec *>(ts)), int, -1); # else ACE_OSCALL_RETURN (::clock_settime (clockid, ts), int, -1); # endif /* ACE_HAS_NONCONST_CLOCK_SETTIME */ #else ACE_UNUSED_ARG (clockid); ACE_UNUSED_ARG (ts); ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_CLOCK_SETTIME */ }
int ACE_OS::close | ( | ACE_HANDLE | handle | ) | [inline] |
Definition at line 184 of file OS_NS_unistd.inl.
{ ACE_OS_TRACE ("ACE_OS::close"); #if defined (ACE_WIN32) ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::CloseHandle (handle), ace_result_), int, -1); #else ACE_OSCALL_RETURN (::close (handle), int, -1); #endif /* ACE_WIN32 */ }
void ACE_OS::closedir | ( | ACE_DIR * | d | ) | [inline] |
Definition at line 17 of file OS_NS_dirent.inl.
{ #if defined (ACE_HAS_DIRENT) # if defined (ACE_WIN32) && defined (ACE_LACKS_CLOSEDIR) ACE_OS::closedir_emulation (d); delete [] d->directory_name_; delete d; # elif defined (ACE_HAS_WCLOSEDIR) && defined (ACE_USES_WCHAR) ::wclosedir (d); # else /* ACE_WIN32 && ACE_LACKS_CLOSEDIR */ ::closedir (d); # endif /* ACE_WIN32 && ACE_LACKS_CLOSEDIR */ #else /* ACE_HAS_DIRENT */ ACE_UNUSED_ARG (d); #endif /* ACE_HAS_DIRENT */ }
int ACE_OS::closesocket | ( | ACE_HANDLE | s | ) | [inline] |
Takes care of windows specific requirement to call closesocket.
Definition at line 127 of file OS_NS_sys_socket.inl.
{ ACE_OS_TRACE ("ACE_OS::closesocket"); #if defined (ACE_WIN32) // @note Do not shutdown the write end here. Doing so will break // applications that duplicate a handle on fork(), for // example, and expect to continue writing in the fork()ed // process. ACE_SOCKCALL_RETURN (::closesocket ((SOCKET) handle), int, -1); #else //FUZZ: disable check_for_lack_ACE_OS ACE_OSCALL_RETURN (::close (handle), int, -1); //FUZZ: enable check_for_lack_ACE_OS #endif /* ACE_WIN32 */ }
char * ACE_OS::compile | ( | const char * | instring, | |
char * | expbuf, | |||
char * | endbuf | |||
) | [inline] |
Definition at line 11 of file OS_NS_regex.inl.
{ ACE_OS_TRACE ("ACE_OS::compile"); #if defined (ACE_HAS_REGEX) ACE_OSCALL_RETURN (::compile (instring, expbuf, endbuf), char *, 0); #else ACE_UNUSED_ARG (instring); ACE_UNUSED_ARG (expbuf); ACE_UNUSED_ARG (endbuf); ACE_NOTSUP_RETURN (0); #endif /* ACE_HAS_REGEX */ }
int ACE_OS::cond_broadcast | ( | ACE_cond_t * | cv | ) | [inline] |
Definition at line 186 of file OS_NS_Thread.inl.
{ ACE_OS_TRACE ("ACE_OS::cond_broadcast"); # if defined (ACE_HAS_THREADS) # if defined (ACE_HAS_PTHREADS) int result; ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_cond_broadcast (cv), result), int, -1); # elif defined (ACE_HAS_STHREADS) int result; ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::cond_broadcast (cv), result), int, -1); # elif defined (ACE_HAS_WTHREADS) && defined (ACE_HAS_WTHREADS_CONDITION_VARIABLE) ::WakeAllConditionVariable (cv); return 0; # endif /* ACE_HAS_STHREADS */ # else ACE_UNUSED_ARG (cv); ACE_NOTSUP_RETURN (-1); # endif /* ACE_HAS_THREADS */ }
int ACE_OS::cond_destroy | ( | ACE_cond_t * | cv | ) | [inline] |
Definition at line 211 of file OS_NS_Thread.inl.
{ ACE_OS_TRACE ("ACE_OS::cond_destroy"); # if defined (ACE_HAS_THREADS) # if defined (ACE_HAS_PTHREADS) int result; ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_cond_destroy (cv), result), int, -1); # elif defined (ACE_HAS_STHREADS) int result; ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::cond_destroy (cv), result), int, -1); # elif defined (ACE_HAS_WTHREADS) && defined (ACE_HAS_WTHREADS_CONDITION_VARIABLE) // Windows doesn't have a destroy return 0; # endif /* ACE_HAS_STHREADS */ # else ACE_UNUSED_ARG (cv); ACE_NOTSUP_RETURN (-1); # endif /* ACE_HAS_THREADS */ }
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 1567 of file OS_NS_Thread.cpp.
{ ACE_condattr_t attributes; if (ACE_OS::condattr_init (attributes, type) == 0 && ACE_OS::cond_init (cv, attributes, name, arg) == 0) { (void) ACE_OS::condattr_destroy (attributes); return 0; } return -1; }
int ACE_OS::cond_init | ( | ACE_cond_t * | cv, | |
ACE_condattr_t & | attributes, | |||
const char * | name = 0 , |
|||
void * | arg = 0 | |||
) | [inline] |
Definition at line 232 of file OS_NS_Thread.inl.
{ // ACE_OS_TRACE ("ACE_OS::cond_init"); ACE_UNUSED_ARG (name); ACE_UNUSED_ARG (arg); # if defined (ACE_HAS_THREADS) # if defined (ACE_HAS_PTHREADS) int result = -1; # if defined (ACE_PTHREAD_COND_T_INITIALIZE) /* VxWorks 6.x API reference states: * If the memory for the condition variable object has been allocated * dynamically, it is a good policy to always zero out the * block of memory so as to avoid spurious EBUSY return code * when calling this routine. */ ACE_OS::memset (cv, 0, sizeof (*cv)); # endif if (ACE_ADAPT_RETVAL (pthread_cond_init (cv, &attributes), result) == 0) result = 0; else result = -1; // ACE_ADAPT_RETVAL used it for intermediate status return result; # elif defined (ACE_HAS_STHREADS) int result; ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::cond_init (cv, attributes.type, arg), result), int, -1); # elif defined (ACE_HAS_WTHREADS) && defined (ACE_HAS_WTHREADS_CONDITION_VARIABLE) ::InitializeConditionVariable (cv); return 0; # endif /* ACE_HAS_PTHREADS vs. ACE_HAS_STHREADS */ # else ACE_UNUSED_ARG (cv); ACE_UNUSED_ARG (attributes); ACE_UNUSED_ARG (name); ACE_UNUSED_ARG (arg); ACE_NOTSUP_RETURN (-1); # endif /* ACE_HAS_THREADS */ }
int ACE_OS::cond_signal | ( | ACE_cond_t * | cv | ) | [inline] |
Definition at line 300 of file OS_NS_Thread.inl.
{ ACE_OS_TRACE ("ACE_OS::cond_signal"); # if defined (ACE_HAS_THREADS) # if defined (ACE_HAS_PTHREADS) int result; ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_cond_signal (cv), result), int, -1); # elif defined (ACE_HAS_STHREADS) int result; ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::cond_signal (cv), result), int, -1); # elif defined (ACE_HAS_WTHREADS) && defined (ACE_HAS_WTHREADS_CONDITION_VARIABLE) ::WakeConditionVariable (cv); return 0; # endif /* ACE_HAS_STHREADS */ # else ACE_UNUSED_ARG (cv); ACE_NOTSUP_RETURN (-1); # endif /* ACE_HAS_THREADS */ }
int ACE_OS::cond_timedwait | ( | ACE_cond_t * | cv, | |
ACE_mutex_t * | m, | |||
ACE_Time_Value * | timeout | |||
) | [inline] |
Definition at line 348 of file OS_NS_Thread.inl.
{ ACE_OS_TRACE ("ACE_OS::cond_timedwait"); # if defined (ACE_HAS_THREADS) int result = 0; timespec_t ts; if (timeout != 0) ts = *timeout; // Calls ACE_Time_Value::operator timespec_t(). # if defined (ACE_HAS_PTHREADS) ACE_OSCALL (ACE_ADAPT_RETVAL (timeout == 0 ? pthread_cond_wait (cv, external_mutex) : pthread_cond_timedwait (cv, external_mutex, (ACE_TIMESPEC_PTR) &ts), result), int, -1, result); // We need to adjust this to make the POSIX and Solaris return // values consistent. EAGAIN is from Pthreads DRAFT4 (HP-UX 10.20 and down) if (result == -1 && (errno == ETIMEDOUT || errno == EAGAIN)) errno = ETIME; # elif defined (ACE_HAS_STHREADS) ACE_OSCALL (ACE_ADAPT_RETVAL (timeout == 0 ? ::cond_wait (cv, external_mutex) : ::cond_timedwait (cv, external_mutex, (timestruc_t*)&ts), result), int, -1, result); # elif defined (ACE_HAS_WTHREADS) && defined (ACE_HAS_WTHREADS_CONDITION_VARIABLE) int msec_timeout = 0; if (timeout != 0) { ACE_Time_Value relative_time (*timeout - ACE_OS::gettimeofday ()); // Watchout for situations where a context switch has caused the // current time to be > the timeout. if (relative_time > ACE_Time_Value::zero) msec_timeout = relative_time.msec (); } ACE_OSCALL (ACE_ADAPT_RETVAL (::SleepConditionVariableCS (cv, &external_mutex->thr_mutex_, msec_timeout), result), int, -1, result); return result; # endif /* ACE_HAS_STHREADS */ if (timeout != 0) timeout->set (ts); // Update the time value before returning. return result; # else ACE_UNUSED_ARG (cv); ACE_UNUSED_ARG (external_mutex); ACE_UNUSED_ARG (timeout); ACE_NOTSUP_RETURN (-1); # endif /* ACE_HAS_THREADS */ }
int ACE_OS::cond_wait | ( | ACE_cond_t * | cv, | |
ACE_mutex_t * | m | |||
) | [inline] |
Definition at line 322 of file OS_NS_Thread.inl.
{ ACE_OS_TRACE ("ACE_OS::cond_wait"); # if defined (ACE_HAS_THREADS) # if defined (ACE_HAS_PTHREADS) int result; ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_cond_wait (cv, external_mutex), result), int, -1); # elif defined (ACE_HAS_STHREADS) int result; ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::cond_wait (cv, external_mutex), result), int, -1); # elif defined (ACE_HAS_WTHREADS) && defined (ACE_HAS_WTHREADS_CONDITION_VARIABLE) int result; ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::SleepConditionVariableCS (cv, &external_mutex->thr_mutex_, INFINITE), result), int, -1); # endif /* ACE_HAS_PTHREADS */ # else ACE_UNUSED_ARG (cv); ACE_UNUSED_ARG (external_mutex); ACE_NOTSUP_RETURN (-1); # endif /* ACE_HAS_THREADS */ }
int ACE_OS::condattr_destroy | ( | ACE_condattr_t & | attributes | ) | [inline] |
Definition at line 125 of file OS_NS_Thread.inl.
{ #if defined (ACE_HAS_THREADS) # if defined (ACE_HAS_PTHREADS) pthread_condattr_destroy (&attributes); # else attributes.type = 0; # endif /* ACE_HAS_PTHREADS */ return 0; # else ACE_UNUSED_ARG (attributes); return 0; # endif /* ACE_HAS_THREADS */ }
int ACE_OS::condattr_init | ( | ACE_condattr_t & | attributes, | |
int | type = ACE_DEFAULT_SYNCH_TYPE | |||
) | [inline] |
Definition at line 141 of file OS_NS_Thread.inl.
{ ACE_UNUSED_ARG (type); # if defined (ACE_HAS_THREADS) # if defined (ACE_HAS_PTHREADS) int result = -1; # if defined (ACE_PTHREAD_CONDATTR_T_INITIALIZE) /* Tests show that VxWorks 6.x pthread lib does not only * require zeroing of mutex/condition objects to function correctly * but also of the attribute objects. */ ACE_OS::memset (&attributes, 0, sizeof (attributes)); # endif if ( ACE_ADAPT_RETVAL (pthread_condattr_init (&attributes), result) == 0 # if defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_CONDATTR_PSHARED) && ACE_ADAPT_RETVAL (pthread_condattr_setpshared (&attributes, type), result) == 0 # endif /* _POSIX_THREAD_PROCESS_SHARED && ! ACE_LACKS_CONDATTR_PSHARED */ ) result = 0; else result = -1; // ACE_ADAPT_RETVAL used it for intermediate status return result; # else attributes.type = type; return 0; # endif /* ACE_HAS_PTHREADS */ # else ACE_UNUSED_ARG (attributes); ACE_UNUSED_ARG (type); ACE_NOTSUP_RETURN (-1); # endif /* ACE_HAS_THREADS */ }
int ACE_OS::connect | ( | ACE_HANDLE | handle, | |
struct sockaddr * | addr, | |||
int | addrlen | |||
) | [inline] |
BSD-style connect
(no QoS).
Definition at line 145 of file OS_NS_sys_socket.inl.
{ ACE_OS_TRACE ("ACE_OS::connect"); #if defined (ACE_LACKS_CONNECT) ACE_UNUSED_ARG (handle); ACE_UNUSED_ARG (addr); ACE_UNUSED_ARG (addrlen); ACE_NOTSUP_RETURN (-1); #else ACE_SOCKCALL_RETURN (::connect ((ACE_SOCKET) handle, addr, (ACE_SOCKET_LEN) addrlen), int, -1); #endif /* ACE_LACKS_CONNECT */ }
int ACE_OS::connect | ( | ACE_HANDLE | handle, | |
const sockaddr * | addr, | |||
int | addrlen, | |||
const ACE_QoS_Params & | qos_params | |||
) |
QoS-enabled connect
, which passes qos_params to connect
. If the OS platform doesn't support QoS-enabled connect
then the qos_params are ignored and the BSD-style connect
is called.
Definition at line 40 of file OS_NS_sys_socket.cpp.
{ ACE_OS_TRACE ("ACE_OS::connect"); # if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) ACE_SOCKCALL_RETURN (::WSAConnect ((ACE_SOCKET) handle, (const sockaddr *) addr, (ACE_SOCKET_LEN) addrlen, (WSABUF *) qos_params.caller_data (), (WSABUF *) qos_params.callee_data (), (QOS *) qos_params.socket_qos (), (QOS *) qos_params.group_socket_qos ()), int, -1); # else ACE_UNUSED_ARG (qos_params); return ACE_OS::connect (handle, const_cast <sockaddr *> (addr), addrlen); # endif /* ACE_HAS_WINSOCK2 */ }
ACE_HANDLE ACE_OS::creat | ( | const ACE_TCHAR * | filename, | |
mode_t | mode | |||
) | [inline] |
Definition at line 16 of file OS_NS_sys_stat.inl.
{ ACE_OS_TRACE ("ACE_OS::creat"); #if defined (ACE_WIN32) return ACE_OS::open (filename, O_CREAT|O_TRUNC|O_WRONLY, mode); #else ACE_OSCALL_RETURN (::creat (ACE_TEXT_ALWAYS_CHAR (filename), mode), ACE_HANDLE, ACE_INVALID_HANDLE); #endif /* ACE_WIN32 */ }
ACE_TCHAR * ACE_OS::ctime | ( | const time_t * | t | ) | [inline] |
strptime wrapper. Note that the struct tm will always be set to zero
Definition at line 97 of file OS_NS_time.inl.
{ ACE_OS_TRACE ("ACE_OS::ctime"); #if defined (ACE_HAS_WINCE) static ACE_TCHAR buf [ctime_buf_size]; return ACE_OS::ctime_r (t, buf, ctime_buf_size); #elif defined (ACE_WIN32) && defined (ACE_USES_WCHAR) ACE_OSCALL_RETURN (::_wctime (t), wchar_t *, 0); #else # if defined (ACE_USES_WCHAR) /* Not Win32, else it would do the above */ char *narrow_time; ACE_OSCALL (::ctime (t), char *, 0, narrow_time); if (narrow_time == 0) return 0; // ACE_Ascii_To_Wide::convert allocates (via new []) a wchar_t[]. If // we've done this before, free the previous one. Yes, this leaves a // small memory leak (26 characters) but there's no way around this // that I know of. (Steve Huston, 12-Feb-2003). static wchar_t *wide_time = 0; if (wide_time != 0) delete [] wide_time; wide_time = ACE_Ascii_To_Wide::convert (narrow_time); return wide_time; # else ACE_OSCALL_RETURN (::ctime (t), char *, 0); # endif /* ACE_USES_WCHAR */ # endif /* ACE_HAS_WINCE */ }
strptime wrapper. Note that the struct tm will always be set to zero
Definition at line 130 of file OS_NS_time.inl.
{ ACE_OS_TRACE ("ACE_OS::ctime_r"); #if defined (ACE_HAS_REENTRANT_FUNCTIONS) char *bufp = 0; # if defined (ACE_USES_WCHAR) char narrow_buf[ctime_buf_size]; bufp = narrow_buf; # else bufp = buf; # endif /* ACE_USES_WCHAR */ if (buflen < ctime_buf_size) { errno = ERANGE; return 0; } # if defined (ACE_HAS_2_PARAM_ASCTIME_R_AND_CTIME_R) # if defined (DIGITAL_UNIX) ACE_OSCALL (::_Pctime_r (t, bufp), ACE_TCHAR *, 0, bufp); # else /* DIGITAL_UNIX */ ACE_OSCALL (::ctime_r (t, bufp), char *, 0, bufp); # endif /* DIGITAL_UNIX */ # else /* ACE_HAS_2_PARAM_ASCTIME_R_AND_CTIME_R */ # if defined (ACE_HAS_SIZET_PTR_ASCTIME_R_AND_CTIME_R) bufp = ::ctime_r (t, bufp, reinterpret_cast<size_t*>(&buflen)); # else /* ACE_CTIME_R_RETURNS_INT */ bufp = ::ctime_r (t, bufp, buflen); # endif /* ACE_CTIME_R_RETURNS_INT */ # endif /* ACE_HAS_2_PARAM_ASCTIME_R_AND_CTIME_R */ if (bufp == 0) return 0; # if defined (ACE_USES_WCHAR) ACE_Ascii_To_Wide wide_buf (bufp); ACE_OS_String::strcpy (buf, wide_buf.wchar_rep ()); return buf; # else return bufp; # endif /* ACE_USES_WCHAR */ #elif defined (ACE_HAS_TR24731_2005_CRT) if (buflen < ctime_buf_size) { errno = ERANGE; return 0; } ACE_TCHAR *result = buf; # if defined (ACE_USES_WCHAR) ACE_SECURECRTCALL (_wctime_s (buf, buflen, t), wchar_t *, 0, result); # else ACE_SECURECRTCALL (ctime_s (buf, buflen, t), char *, 0, result); # endif return result; #else /* ACE_HAS_REENTRANT_FUNCTIONS */ if (buflen < ctime_buf_size) { errno = ERANGE; return 0; } ACE_TCHAR *result = 0; # if defined (ACE_USES_WCHAR) ACE_OSCALL (::_wctime (t), wchar_t *, 0, result); # else /* ACE_USES_WCHAR */ ACE_OSCALL (::ctime (t), char *, 0, result); # endif /* ACE_USES_WCHAR */ if (result != 0) ACE_OS::strsncpy (buf, result, buflen); return buf; #endif /* ACE_HAS_REENTRANT_FUNCTIONS */ }
char * ACE_OS::cuserid | ( | char * | user, | |
size_t | maxlen = ACE_MAX_USERID | |||
) | [inline] |
Definition at line 352 of file OS_NS_stdio.inl.
{ ACE_OS_TRACE ("ACE_OS::cuserid"); #if defined (ACE_VXWORKS) ACE_UNUSED_ARG (maxlen); if (user == 0) { // Require that the user field be non-null, i.e., don't // allocate or use static storage. ACE_NOTSUP_RETURN (0); } else { ::remCurIdGet (user, 0); return user; } #elif defined (ACE_HAS_PHARLAP) || defined (ACE_HAS_WINCE) ACE_UNUSED_ARG (user); ACE_UNUSED_ARG (maxlen); ACE_NOTSUP_RETURN (0); #elif defined (ACE_WIN32) BOOL const result = GetUserNameA (user, (u_long *) &maxlen); if (result == FALSE) ACE_FAIL_RETURN (0); else return user; #elif defined (ACE_HAS_ALT_CUSERID) # if defined (ACE_LACKS_PWD_FUNCTIONS) # error Cannot use alternate cuserid() without POSIX password functions! # endif /* ACE_LACKS_PWD_FUNCTIONS */ // POSIX.1 dropped the cuserid() function. // GNU GLIBC and other platforms correctly deprecate the cuserid() // function. if (maxlen == 0) { // It doesn't make sense to have a zero length user ID. errno = EINVAL; return 0; } struct passwd *pw = 0; // Make sure the file pointer is at the beginning of the password file ACE_OS::setpwent (); // Should use ACE_OS::setpwent() but I didn't want to move this // method after it. // Use the effective user ID to determine the user name. pw = ::getpwuid (ACE_OS::geteuid ()); // Make sure the password file is closed. ACE_OS::endpwent (); if (pw == 0) { errno = ENOENT; return 0; } size_t max_length = 0; char *userid = 0; if (user == 0) { // Not reentrant/thread-safe, but nothing else can be done if a // zero pointer was passed in as the destination. #if defined (_POSIX_SOURCE) && defined (L_cuserid) const size_t ACE_L_cuserid = L_cuserid; #else const size_t ACE_L_cuserid = 9; // 8 character user ID + NULL #endif /* _POSIX_SOURCE */ static char tmp[ACE_L_cuserid] = { '\0' }; max_length = ACE_L_cuserid - 1; // Do not include NULL in length userid = tmp; } else { max_length = maxlen; userid = user; } // Extract the user name from the passwd structure. if (ACE_OS::strlen (pw->pw_name) <= max_length) { return ACE_OS::strcpy (userid, pw->pw_name); } else { errno = ENOSPC; // Buffer is not large enough. return 0; } #else // Hackish because of missing buffer size! ACE_UNUSED_ARG (maxlen); ACE_OSCALL_RETURN (::ace_cuserid(user), char*, 0); #endif /* ACE_VXWORKS */ }
double ACE_OS::difftime | ( | time_t | t1, | |
time_t | t0 | |||
) | [inline] |
strptime wrapper. Note that the struct tm will always be set to zero
Definition at line 212 of file OS_NS_time.inl.
{ return ::ace_difftime (t1, t0); }
int ACE_OS::dlclose | ( | ACE_SHLIB_HANDLE | handle | ) | [inline] |
Definition at line 26 of file OS_NS_dlfcn.inl.
{ ACE_OS_TRACE ("ACE_OS::dlclose"); #if defined (ACE_LACKS_DLCLOSE) ACE_UNUSED_ARG (handle); return 0; #elif defined (ACE_HAS_SVR4_DYNAMIC_LINKING) # if !defined (ACE_HAS_AUTOMATIC_INIT_FINI) // SunOS4 does not automatically call _fini()! void *ptr; ACE_OSCALL (::dlsym (handle, ACE_TEXT ("_fini")), void *, 0, ptr); if (ptr != 0) (*((int (*)(void)) ptr)) (); // Call _fini hook explicitly. # endif /* ACE_HAS_AUTOMATIC_INIT_FINI */ #if defined (_M_UNIX) ACE_OSCALL_RETURN (::_dlclose (handle), int, -1); #else /* _MUNIX */ ACE_OSCALL_RETURN (::dlclose (handle), int, -1); #endif /* _M_UNIX */ #elif defined (ACE_WIN32) ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::FreeLibrary (handle), ace_result_), int, -1); #elif defined (__hpux) // HP-UX 10.x and 32-bit 11.00 do not pay attention to the ref count // when unloading a dynamic lib. So, if the ref count is more than // 1, do not unload the lib. This will cause a library loaded more // than once to not be unloaded until the process runs down, but // that's life. It's better than unloading a library that's in use. // So far as I know, there's no way to decrement the refcnt that the // kernel is looking at - the shl_descriptor is a copy of what the // kernel has, not the actual struct. On 64-bit HP-UX using dlopen, // this problem has been fixed. struct shl_descriptor desc; if (shl_gethandle_r (handle, &desc) == -1) return -1; if (desc.ref_count > 1) return 0; # if defined(__GNUC__) || __cplusplus >= 199707L ACE_OSCALL_RETURN (::shl_unload (handle), int, -1); # else ACE_OSCALL_RETURN (::cxxshl_unload (handle), int, -1); # endif /* aC++ vs. Hp C++ */ #else ACE_UNUSED_ARG (handle); ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_SVR4_DYNAMIC_LINKING */ }
ACE_TCHAR * ACE_OS::dlerror | ( | void | ) | [inline] |
Definition at line 77 of file OS_NS_dlfcn.inl.
{ ACE_OS_TRACE ("ACE_OS::dlerror"); # if defined (ACE_HAS_SVR4_DYNAMIC_LINKING) const char *err = 0; # if defined(_M_UNIX) ACE_OSCALL (::_dlerror (), const char *, 0, err); # else /* _M_UNIX */ ACE_OSCALL (::dlerror (), const char *, 0, err); # endif /* _M_UNIX */ if (err == 0) return 0; # if defined (ACE_USES_WCHAR) const size_t BufLen = 256; static wchar_t buf[BufLen]; ACE_OS::strncpy (buf, ACE_TEXT_CHAR_TO_TCHAR (err), BufLen); return buf; # else return const_cast <char *> (err); # endif /* ACE_USES_WCHAR */ # elif defined (__hpux) || defined (ACE_VXWORKS) //FUZZ: disable check_for_lack_ACE_OS ACE_OSCALL_RETURN (::strerror(errno), char *, 0); //FUZZ: enable check_for_lack_ACE_OS # elif defined (ACE_WIN32) static ACE_TCHAR buf[128]; # if defined (ACE_HAS_PHARLAP) ACE_OS::sprintf (buf, "error code %d", GetLastError()); # else ACE_TEXT_FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM, 0, ::GetLastError (), 0, buf, sizeof buf / sizeof buf[0], 0); # endif /* ACE_HAS_PHARLAP */ return buf; # else ACE_NOTSUP_RETURN (0); # endif /* ACE_HAS_SVR4_DYNAMIC_LINKING */ }
ACE_SHLIB_HANDLE ACE_OS::dlopen | ( | const ACE_TCHAR * | filename, | |
int | mode = ACE_DEFAULT_SHLIB_MODE | |||
) | [inline] |
Definition at line 121 of file OS_NS_dlfcn.inl.
{ ACE_OS_TRACE ("ACE_OS::dlopen"); # if defined (ACE_HAS_SVR4_DYNAMIC_LINKING) void *handle; # if defined (ACE_HAS_SGIDLADD) ACE_OSCALL (::sgidladd (ACE_TEXT_ALWAYS_CHAR (fname), mode), void *, 0, handle); # elif defined (_M_UNIX) ACE_OSCALL (::_dlopen (ACE_TEXT_ALWAYS_CHAR (fname), mode), void *, 0, handle); # else ACE_OSCALL (::dlopen (ACE_TEXT_ALWAYS_CHAR (fname), mode), void *, 0, handle); # endif /* ACE_HAS_SGIDLADD */ # if !defined (ACE_HAS_AUTOMATIC_INIT_FINI) if (handle != 0) { void *ptr; // Some systems (e.g., SunOS4) do not automatically call _init(), so // we'll have to call it manually. ACE_OSCALL (::dlsym (handle, ACE_TEXT ("_init")), void *, 0, ptr); if (ptr != 0 && (*((int (*)(void)) ptr)) () == -1) // Call _init hook explicitly. { // Close down the handle to prevent leaks. ::dlclose (handle); return 0; } } # endif /* ACE_HAS_AUTOMATIC_INIT_FINI */ return handle; # elif defined (ACE_WIN32) ACE_UNUSED_ARG (mode); ACE_WIN32CALL_RETURN (ACE_TEXT_LoadLibrary (fname), ACE_SHLIB_HANDLE, 0); # elif defined (__hpux) # if defined(__GNUC__) || __cplusplus >= 199707L ACE_OSCALL_RETURN (::shl_load(fname, mode, 0L), ACE_SHLIB_HANDLE, 0); # else ACE_OSCALL_RETURN (::cxxshl_load(fname, mode, 0L), ACE_SHLIB_HANDLE, 0); # endif /* aC++ vs. Hp C++ */ # elif defined (ACE_VXWORKS) && !defined (__RTP__) MODULE* handle = 0; // Open readonly ACE_HANDLE filehandle = ACE_OS::open (fname, O_RDONLY, ACE_DEFAULT_FILE_PERMS); if (filehandle != ACE_INVALID_HANDLE) { ACE_OS::last_error(0); ACE_OSCALL ( ::loadModule (filehandle, LOAD_GLOBAL_SYMBOLS|LOAD_COMMON_MATCH_ALL ), MODULE *, 0, handle); int loaderror = ACE_OS::last_error(); ACE_OS::close (filehandle); if ( (loaderror != 0) && (handle != 0) ) { // ouch something went wrong most likely unresolved externals if (handle) ::unldByModuleId ( handle, 0 ); handle = 0; } } else { // couldn't open file handle = 0; } return handle; # else ACE_UNUSED_ARG (fname); ACE_UNUSED_ARG (mode); ACE_NOTSUP_RETURN (0); # endif /* ACE_HAS_SVR4_DYNAMIC_LINKING */ }
void * ACE_OS::dlsym | ( | ACE_SHLIB_HANDLE | handle, | |
const ACE_TCHAR * | symbol | |||
) | [inline] |
Definition at line 203 of file OS_NS_dlfcn.inl.
{ ACE_OS_TRACE ("ACE_OS::dlsym"); #if defined (ACE_HAS_DLSYM_SEGFAULT_ON_INVALID_HANDLE) // Check if the handle is valid before making any calls using it. if (handle == ACE_SHLIB_INVALID_HANDLE) return 0; #endif /* ACE_HAS_DLSYM_SEGFAULT_ON_INVALID_HANDLE */ // Get the correct OS type. #if defined (ACE_HAS_WINCE) // CE (at least thru Pocket PC 2003) offers GetProcAddressW, not ...A, so // we always need a wide-char string. const wchar_t *symbolname = 0; # if defined (ACE_USES_WCHAR) symbolname = sname; # else ACE_Ascii_To_Wide sname_xlate (sname); symbolname = sname_xlate.wchar_rep (); # endif /* ACE_USES_WCHAR */ #elif defined (ACE_USES_WCHAR) // WinCE is WCHAR always; other platforms need a char * symbol name ACE_Wide_To_Ascii w_sname (sname); char *symbolname = w_sname.char_rep (); #elif defined (ACE_VXWORKS) char *symbolname = const_cast<char *> (sname); #else const char *symbolname = sname; #endif /* ACE_HAS_WINCE */ # if defined (ACE_HAS_SVR4_DYNAMIC_LINKING) # if defined (ACE_USES_ASM_SYMBOL_IN_DLSYM) int l = ACE_OS::strlen (symbolname) + 2; char *asm_symbolname = 0; ACE_NEW_RETURN (asm_symbolname, char[l], 0); ACE_OS::strcpy (asm_symbolname, "_") ; ACE_OS::strcpy (asm_symbolname + 1, symbolname) ; void *ace_result; ACE_OSCALL (::dlsym (handle, asm_symbolname), void *, 0, ace_result); delete [] asm_symbolname; return ace_result; # elif defined (_M_UNIX) ACE_OSCALL_RETURN (::_dlsym (handle, symbolname), void *, 0); # else ACE_OSCALL_RETURN (::dlsym (handle, symbolname), void *, 0); # endif /* ACE_USES_ASM_SYMBOL_IN_DLSYM */ # elif defined (ACE_WIN32) ACE_WIN32CALL_RETURN (::GetProcAddress (handle, symbolname), void *, 0); # elif defined (__hpux) void *value = 0; int status; shl_t _handle = handle; ACE_OSCALL (::shl_findsym(&_handle, symbolname, TYPE_UNDEFINED, &value), int, -1, status); return status == 0 ? value : 0; # elif defined (ACE_VXWORKS) && !defined (__RTP__) // For now we use the VxWorks global symbol table // which resolves the most recently loaded symbols .. which resolve mostly what we want.. ACE_UNUSED_ARG (handle); SYM_TYPE symtype; char *value = 0; STATUS status; ACE_OSCALL (::symFindByName(sysSymTbl, symbolname, &value, &symtype), int, -1, status); return status == OK ? reinterpret_cast <void*>(value) : 0; # else ACE_UNUSED_ARG (handle); ACE_UNUSED_ARG (symbolname); ACE_NOTSUP_RETURN (0); # endif /* ACE_HAS_SVR4_DYNAMIC_LINKING */ }
ACE_HANDLE ACE_OS::dup | ( | ACE_HANDLE | handle | ) | [inline] |
Definition at line 195 of file OS_NS_unistd.inl.
{ ACE_OS_TRACE ("ACE_OS::dup"); #if defined (ACE_LACKS_DUP) ACE_UNUSED_ARG (handle); ACE_NOTSUP_RETURN (ACE_INVALID_HANDLE); #elif defined (ACE_WIN32) ACE_HANDLE new_fd; if (::DuplicateHandle(::GetCurrentProcess (), handle, ::GetCurrentProcess(), &new_fd, 0, TRUE, DUPLICATE_SAME_ACCESS)) return new_fd; else ACE_FAIL_RETURN (ACE_INVALID_HANDLE); /* NOTREACHED */ #else ACE_OSCALL_RETURN (::dup (handle), ACE_HANDLE, ACE_INVALID_HANDLE); #endif /* ACE_LACKS_DUP */ }
ACE_HANDLE ACE_OS::dup | ( | ACE_HANDLE | handle, | |
pid_t | pid | |||
) | [inline] |
Definition at line 220 of file OS_NS_unistd.inl.
{ ACE_OS_TRACE("ACE_OS::dup"); #if defined (ACE_LACKS_DUP) ACE_UNUSED_ARG (handle); ACE_UNUSED_ARG (pid); ACE_NOTSUP_RETURN (ACE_INVALID_HANDLE); #elif defined (ACE_WIN32) ACE_HANDLE new_fd; ACE_HANDLE hTargetProcess = ::OpenProcess (PROCESS_DUP_HANDLE, FALSE, pid); if(::DuplicateHandle(::GetCurrentProcess (), handle, hTargetProcess, &new_fd, 0, TRUE, DUPLICATE_SAME_ACCESS)) { ::CloseHandle (hTargetProcess); return new_fd; } else ACE_FAIL_RETURN (ACE_INVALID_HANDLE); /*NOTREACHED*/ #else ACE_UNUSED_ARG (pid); ACE_OSCALL_RETURN(::dup(handle), ACE_HANDLE, ACE_INVALID_HANDLE); #endif /*ACE_WIN32 && !ACE_HAS_WINCE*/ }
int ACE_OS::dup2 | ( | ACE_HANDLE | oldfd, | |
ACE_HANDLE | newfd | |||
) | [inline] |
Definition at line 253 of file OS_NS_unistd.inl.
{ ACE_OS_TRACE ("ACE_OS::dup2"); #if defined (ACE_LACKS_DUP2) // msvcrt has _dup2 ?! ACE_UNUSED_ARG (oldhandle); ACE_UNUSED_ARG (newhandle); ACE_NOTSUP_RETURN (-1); #else ACE_OSCALL_RETURN (::dup2 (oldhandle, newhandle), int, -1); #endif /* ACE_LACKS_DUP2 */ }
void ACE_OS::endpwent | ( | void | ) | [inline] |
Definition at line 12 of file OS_NS_pwd.inl.
{ #if !defined (ACE_LACKS_PWD_FUNCTIONS) ::endpwent (); #endif /* ! ACE_LACKS_PWD_FUNCTIONS */ }
int ACE_OS::enum_protocols | ( | int * | protocols, | |
ACE_Protocol_Info * | protocol_buffer, | |||
u_long * | buffer_length | |||
) | [inline] |
Retrieve information about available transport protocols installed on the local machine. Windows specific...
Definition at line 163 of file OS_NS_sys_socket.inl.
{ #if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) ACE_SOCKCALL_RETURN (::WSAEnumProtocols (protocols, protocol_buffer, buffer_length), int, SOCKET_ERROR); #else ACE_UNUSED_ARG (protocols); ACE_UNUSED_ARG (protocol_buffer); ACE_UNUSED_ARG (buffer_length); ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_WINSOCK2 */ }
int ACE_OS::event_destroy | ( | ACE_event_t * | event | ) |
Definition at line 2349 of file OS_NS_Thread.cpp.
{ #if defined (ACE_WIN32) ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::CloseHandle (*event), ace_result_), int, -1); #elif defined (ACE_HAS_THREADS) if (event->eventdata_) { // mutex_destroy()/cond_destroy() are called in a loop if the object // is BUSY. This avoids conditions where we fail to destroy these // objects because at time of destroy they were just being used in // another thread possibly causing deadlocks later on if they keep // being used after we're gone. if (event->eventdata_->type_ == USYNC_PROCESS) { if (event->name_) { // Only destroy the event data if we're the ones who initialized // it. int r1, r2; # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \ (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \ (!defined (ACE_USES_FIFO_SEM) && \ (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM))) // First destroy the mutex so locking after this will return // errors. while ((r1 = ACE_OS::mutex_destroy (&event->eventdata_->lock_)) == -1 && errno == EBUSY) { ACE_OS::thr_yield (); } # else r1 = ACE_OS::sema_destroy(&event->lock_); # endif # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_CONDATTR_PSHARED)) || \ (!defined (ACE_USES_FIFO_SEM) && \ (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM))) // Now fix event to manual reset, raise signal and broadcast // until is's possible to destroy the condition. event->eventdata_->manual_reset_ = 1; while ((r2 = ACE_OS::cond_destroy (&event->eventdata_->condition_)) == -1 && errno == EBUSY) { event->eventdata_->is_signaled_ = 1; ACE_OS::cond_broadcast (&event->eventdata_->condition_); ACE_OS::thr_yield (); } # else r2 = ACE_OS::sema_destroy(&event->semaphore_); # endif ACE_OS::munmap (event->eventdata_, sizeof (ACE_eventdata_t)); ACE_OS::shm_unlink (ACE_TEXT_CHAR_TO_TCHAR(event->name_)); ACE_OS::free (event->name_); return r1 != 0 || r2 != 0 ? -1 : 0; } else { ACE_OS::munmap (event->eventdata_, sizeof (ACE_eventdata_t)); # if (!defined (ACE_HAS_PTHREADS) || !defined (_POSIX_THREAD_PROCESS_SHARED) || \ (defined (ACE_LACKS_MUTEXATTR_PSHARED) && defined (ACE_LACKS_CONDATTR_PSHARED))) && \ (defined (ACE_USES_FIFO_SEM) || \ (defined (ACE_HAS_POSIX_SEM) && defined (ACE_HAS_POSIX_SEM_TIMEOUT) && defined (ACE_LACKS_NAMED_POSIX_SEM))) ACE_OS::sema_destroy(&event->lock_); # endif # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_CONDATTR_PSHARED)) || \ (!defined (ACE_USES_FIFO_SEM) && \ (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM))) return 0; # else return ACE_OS::sema_destroy(&event->semaphore_); # endif } } else { int r1, r2; // First destroy the mutex so locking after this will return errors. # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \ (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \ (!defined (ACE_USES_FIFO_SEM) && \ (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM))) // first destroy the mutex so locking after this will return errors while ((r1 = ACE_OS::mutex_destroy (&event->eventdata_->lock_)) == -1 && errno == EBUSY) { ACE_OS::thr_yield (); } # else r1 = ACE_OS::sema_destroy(&event->lock_); # endif # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_CONDATTR_PSHARED)) || \ (!defined (ACE_USES_FIFO_SEM) && \ (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM))) // Now fix event to manual reset, raise signal and broadcast until // it's possible to destroy the condition. event->eventdata_->manual_reset_ = 1; while ((r2 = ACE_OS::cond_destroy (&event->eventdata_->condition_)) == -1 && errno == EBUSY) { event->eventdata_->is_signaled_ = 1; ACE_OS::cond_broadcast (&event->eventdata_->condition_); ACE_OS::thr_yield (); } # else r2 = ACE_OS::sema_destroy(&event->semaphore_); # endif delete event->eventdata_; return r1 != 0 || r2 != 0 ? -1 : 0; } } return 0; #else ACE_UNUSED_ARG (event); ACE_NOTSUP_RETURN (-1); #endif /* ACE_WIN32 */ }
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 2473 of file OS_NS_Thread.cpp.
{ #if defined (ACE_WIN32) ACE_UNUSED_ARG (type); ACE_UNUSED_ARG (arg); SECURITY_ATTRIBUTES sa_buffer; SECURITY_DESCRIPTOR sd_buffer; # if defined (ACE_HAS_WINCE) // @@todo (brunsch) This idea should be moved into ACE_OS_Win32. *event = ::CreateEventW (ACE_OS::default_win32_security_attributes_r (sa, &sa_buffer, &sd_buffer), manual_reset, initial_state, ACE_Ascii_To_Wide (name).wchar_rep ()); # else /* ACE_HAS_WINCE */ *event = ::CreateEventA (ACE_OS::default_win32_security_attributes_r (sa, &sa_buffer, &sd_buffer), manual_reset, initial_state, name); # endif /* ACE_HAS_WINCE */ if (*event == 0) ACE_FAIL_RETURN (-1); else { // Make sure to set errno to ERROR_ALREADY_EXISTS if necessary. ACE_OS::set_errno_to_last_error (); return 0; } #elif defined (ACE_HAS_THREADS) ACE_UNUSED_ARG (sa); event->eventdata_ = 0; ACE_eventdata_t* evtdata; if (type == USYNC_PROCESS) { const char *name_p = 0; # if defined (ACE_SHM_OPEN_REQUIRES_ONE_SLASH) char adj_name[MAXPATHLEN]; if (name[0] != '/') { adj_name[0] = '/'; ACE_OS::strsncpy (&adj_name[1], name, MAXPATHLEN-1); name_p = adj_name; } else { name_p = name; } # else name_p = name; # endif /* ACE_SHM_OPEN_REQUIRES_ONE_SLASH */ int owner = 0; // Let's see if the shared memory entity already exists. ACE_HANDLE fd = ACE_OS::shm_open (ACE_TEXT_CHAR_TO_TCHAR (name_p), O_RDWR | O_CREAT | O_EXCL, ACE_DEFAULT_FILE_PERMS); if (fd == ACE_INVALID_HANDLE) { if (errno == EEXIST) fd = ACE_OS::shm_open (ACE_TEXT_CHAR_TO_TCHAR (name_p), O_RDWR | O_CREAT, ACE_DEFAULT_FILE_PERMS); if (fd == ACE_INVALID_HANDLE) // Still can't get it. return -1; } else { // We own this shared memory object! Let's set its size. if (ACE_OS::ftruncate (fd, sizeof (ACE_eventdata_t)) == -1) { ACE_OS::close (fd); return -1; } owner = 1; } evtdata = (ACE_eventdata_t *) ACE_OS::mmap (0, sizeof (ACE_eventdata_t), PROT_RDWR, MAP_SHARED, fd, 0); ACE_OS::close (fd); if (evtdata == MAP_FAILED) { if (owner) ACE_OS::shm_unlink (ACE_TEXT_CHAR_TO_TCHAR (name_p)); return -1; } if (owner) { event->name_ = ACE_OS::strdup (name_p); if (event->name_ == 0) { ACE_OS::shm_unlink (ACE_TEXT_CHAR_TO_TCHAR (name_p)); return -1; } event->eventdata_ = evtdata; event->eventdata_->type_ = type; event->eventdata_->manual_reset_ = manual_reset; event->eventdata_->is_signaled_ = initial_state; event->eventdata_->auto_event_signaled_ = false; event->eventdata_->waiting_threads_ = 0; event->eventdata_->signal_count_ = 0; # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_CONDATTR_PSHARED)) || \ (!defined (ACE_USES_FIFO_SEM) && \ (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM))) int result = ACE_OS::cond_init (&event->eventdata_->condition_, static_cast<short> (type), name, arg); # else char sem_name[128]; ACE_OS::strncpy (sem_name, name, sizeof (sem_name) - (1 + sizeof ("._ACE_EVTSEM_"))); ACE_OS::strcat (sem_name, "._ACE_EVTSEM_"); int result = ACE_OS::sema_init (&event->semaphore_, 0, type, sem_name, arg); # endif if (result == 0) # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \ (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \ (!defined (ACE_USES_FIFO_SEM) && \ (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM))) result = ACE_OS::mutex_init (&event->eventdata_->lock_, type, name, (ACE_mutexattr_t *) arg); # else { char lck_name[128]; ACE_OS::strncpy (lck_name, name, sizeof (lck_name) - (1 + sizeof ("._ACE_EVTLCK_"))); ACE_OS::strcat (lck_name, "._ACE_EVTLCK_"); result = ACE_OS::sema_init (&event->lock_, 0, type, lck_name, arg); if (result == 0) result = ACE_OS::sema_post (&event->lock_); /* Initially unlock */ } # endif return result; } else { int result = 0; event->name_ = 0; event->eventdata_ = evtdata; #if (!defined (ACE_HAS_PTHREADS) || !defined (_POSIX_THREAD_PROCESS_SHARED) || defined (ACE_LACKS_CONDATTR_PSHARED)) && \ (defined (ACE_USES_FIFO_SEM) || \ (defined (ACE_HAS_POSIX_SEM) && defined (ACE_HAS_POSIX_SEM_TIMEOUT) && !defined (ACE_LACKS_NAMED_POSIX_SEM))) char sem_name[128]; ACE_OS::strncpy (sem_name, name, sizeof (sem_name) - (1 + sizeof ("._ACE_EVTSEM_"))); ACE_OS::strcat (sem_name, "._ACE_EVTSEM_"); result = ACE_OS::sema_init(&event->semaphore_, 0, type, sem_name, arg); # endif # if (!defined (ACE_HAS_PTHREADS) || !defined (_POSIX_THREAD_PROCESS_SHARED) || \ (defined (ACE_LACKS_MUTEXATTR_PSHARED) && defined (ACE_LACKS_CONDATTR_PSHARED))) && \ (defined (ACE_USES_FIFO_SEM) || \ (defined (ACE_HAS_POSIX_SEM) && defined (ACE_HAS_POSIX_SEM_TIMEOUT) && defined (ACE_LACKS_NAMED_POSIX_SEM))) if (result == 0) { char lck_name[128]; ACE_OS::strncpy (lck_name, name, sizeof (lck_name) - (1 + sizeof ("._ACE_EVTLCK_"))); ACE_OS::strcat (lck_name, "._ACE_EVTLCK_"); result = ACE_OS::sema_init (&event->lock_, 0, type, lck_name, arg); } # endif return result; } } else { ACE_NEW_RETURN (evtdata, ACE_eventdata_t, -1); event->name_ = 0; event->eventdata_ = evtdata; event->eventdata_->type_ = type; event->eventdata_->manual_reset_ = manual_reset; event->eventdata_->is_signaled_ = initial_state; event->eventdata_->auto_event_signaled_ = false; event->eventdata_->waiting_threads_ = 0; event->eventdata_->signal_count_ = 0; # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_CONDATTR_PSHARED)) || \ (!defined (ACE_USES_FIFO_SEM) && \ (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM))) int result = ACE_OS::cond_init (&event->eventdata_->condition_, static_cast<short> (type), name, arg); # else int result = ACE_OS::sema_init (&event->semaphore_, 0, type, name, arg); # endif if (result == 0) # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \ (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \ (!defined (ACE_USES_FIFO_SEM) && \ (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM))) result = ACE_OS::mutex_init (&event->eventdata_->lock_, type, name, (ACE_mutexattr_t *) arg); # else result = ACE_OS::sema_init (&event->lock_, 0, type, name, arg); if (result == 0) result = ACE_OS::sema_post(&event->lock_); /* initially unlock */ # endif return result; } #else ACE_UNUSED_ARG (event); ACE_UNUSED_ARG (manual_reset); ACE_UNUSED_ARG (initial_state); ACE_UNUSED_ARG (type); ACE_UNUSED_ARG (name); ACE_UNUSED_ARG (arg); ACE_UNUSED_ARG (sa); ACE_NOTSUP_RETURN (-1); #endif /* ACE_WIN32 */ }
int ACE_OS::event_pulse | ( | ACE_event_t * | event | ) |
Definition at line 2737 of file OS_NS_Thread.cpp.
{ #if defined (ACE_WIN32) ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::PulseEvent (*event), ace_result_), int, -1); #elif defined (ACE_HAS_THREADS) int result = 0; int error = 0; // grab the lock first # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \ (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \ (!defined (ACE_USES_FIFO_SEM) && \ (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM))) if (ACE_OS::mutex_lock (&event->eventdata_->lock_) == 0) # else if (ACE_OS::sema_wait (&event->lock_) == 0) # endif { if (event->eventdata_->waiting_threads_ > 0) { // Manual-reset event. if (event->eventdata_->manual_reset_ == 1) { // Wakeup all waiters. # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_CONDATTR_PSHARED)) || \ (!defined (ACE_USES_FIFO_SEM) && \ (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM))) if (ACE_OS::cond_broadcast (&event->eventdata_->condition_) != 0) { result = -1; error = errno; } if (result == 0) event->eventdata_->signal_count_ = event->eventdata_->waiting_threads_; # else event->eventdata_->signal_count_ = event->eventdata_->waiting_threads_; for (unsigned long i=0; i<event->eventdata_->signal_count_ ;++i) if (ACE_OS::sema_post(&event->semaphore_) != 0) { event->eventdata_->signal_count_ = 0; result = -1; error = errno; } if (result == 0) while(event->eventdata_->signal_count_!=0 && event->eventdata_->waiting_threads_!=0) ACE_OS::thr_yield (); # endif } // Auto-reset event: wakeup one waiter. else { # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_CONDATTR_PSHARED)) || \ (!defined (ACE_USES_FIFO_SEM) && \ (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM))) if (ACE_OS::cond_signal (&event->eventdata_->condition_) != 0) # else if (ACE_OS::sema_post(&event->semaphore_) != 0) # endif { result = -1; error = errno; } event->eventdata_->auto_event_signaled_ = true; } } // Reset event. event->eventdata_->is_signaled_ = 0; // Now we can let go of the lock. # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \ (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \ (!defined (ACE_USES_FIFO_SEM) && \ (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM))) ACE_OS::mutex_unlock (&event->eventdata_->lock_); # else ACE_OS::sema_post (&event->lock_); # endif if (result == -1) // Reset errno in case mutex_unlock() also fails... errno = error; } else result = -1; return result; #else ACE_UNUSED_ARG (event); ACE_NOTSUP_RETURN (-1); #endif /* ACE_WIN32 */ }
int ACE_OS::event_reset | ( | ACE_event_t * | event | ) |
Definition at line 2831 of file OS_NS_Thread.cpp.
{ #if defined (ACE_WIN32) ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::ResetEvent (*event), ace_result_), int, -1); #elif defined (ACE_HAS_THREADS) int result = 0; // Grab the lock first. # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \ (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \ (!defined (ACE_USES_FIFO_SEM) && \ (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM))) if (ACE_OS::mutex_lock (&event->eventdata_->lock_) == 0) # else if (ACE_OS::sema_wait (&event->lock_) == 0) # endif { // Reset event. event->eventdata_->is_signaled_ = 0; event->eventdata_->auto_event_signaled_ = false; // Now we can let go of the lock. # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \ (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \ (!defined (ACE_USES_FIFO_SEM) && \ (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM))) ACE_OS::mutex_unlock (&event->eventdata_->lock_); # else ACE_OS::sema_post (&event->lock_); # endif } else result = -1; return result; #else ACE_UNUSED_ARG (event); ACE_NOTSUP_RETURN (-1); #endif /* ACE_WIN32 */ }
int ACE_OS::event_signal | ( | ACE_event_t * | event | ) |
Definition at line 2872 of file OS_NS_Thread.cpp.
{ #if defined (ACE_WIN32) ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::SetEvent (*event), ace_result_), int, -1); #elif defined (ACE_HAS_THREADS) int result = 0; int error = 0; // grab the lock first # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \ (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \ (!defined (ACE_USES_FIFO_SEM) && \ (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM))) if (ACE_OS::mutex_lock (&event->eventdata_->lock_) == 0) # else if (ACE_OS::sema_wait (&event->lock_) == 0) # endif { // Manual-reset event. if (event->eventdata_->manual_reset_ == 1) { // wakeup all # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_CONDATTR_PSHARED)) || \ (!defined (ACE_USES_FIFO_SEM) && \ (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM))) if (ACE_OS::cond_broadcast (&event->eventdata_->condition_) != 0) { result = -1; error = errno; } # else if (ACE_OS::sema_post(&event->semaphore_) != 0) { result = -1; error = errno; } # endif if (result == 0) // signal event event->eventdata_->is_signaled_ = 1; } // Auto-reset event else { if (event->eventdata_->waiting_threads_ == 0) // No waiters: signal event. event->eventdata_->is_signaled_ = 1; // Waiters: wakeup one waiter. # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_CONDATTR_PSHARED)) || \ (!defined (ACE_USES_FIFO_SEM) && \ (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM))) else if (ACE_OS::cond_signal (&event->eventdata_->condition_) != 0) # else else if (ACE_OS::sema_post(&event->semaphore_) != 0) # endif { result = -1; error = errno; } event->eventdata_->auto_event_signaled_ = true; } // Now we can let go of the lock. # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \ (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \ (!defined (ACE_USES_FIFO_SEM) && \ (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM))) ACE_OS::mutex_unlock (&event->eventdata_->lock_); # else ACE_OS::sema_post (&event->lock_); # endif if (result == -1) // Reset errno in case mutex_unlock() also fails... errno = error; } else result = -1; return result; #else ACE_UNUSED_ARG (event); ACE_NOTSUP_RETURN (-1); #endif /* ACE_WIN32 */ }
int ACE_OS::event_timedwait | ( | ACE_event_t * | event, | |
ACE_Time_Value * | timeout, | |||
int | use_absolute_time = 1 | |||
) |
Definition at line 2961 of file OS_NS_Thread.cpp.
{ if (timeout == 0) // Wait indefinitely. return ACE_OS::event_wait (event); #if defined (ACE_WIN32) DWORD result; if (*timeout == ACE_Time_Value::zero) // Do a "poll". result = ::WaitForSingleObject (*event, 0); else { // Wait for upto <relative_time> number of milliseconds. Note // that we must convert between absolute time (which is passed // as a parameter) and relative time (which is what // WaitForSingleObjects() expects). // <timeout> parameter is given in absolute or relative value // depending on parameter <use_absolute_time>. int msec_timeout = 0; if (use_absolute_time) { // Time is given in absolute time, we should use // gettimeofday() to calculate relative time ACE_Time_Value relative_time (*timeout - ACE_OS::gettimeofday ()); // Watchout for situations where a context switch has caused // the current time to be > the timeout. Thanks to Norbert // Rapp <NRapp@nexus-informatics.de> for pointing this. if (relative_time > ACE_Time_Value::zero) msec_timeout = relative_time.msec (); } else // time is given in relative time, just convert it into // milliseconds and use it msec_timeout = timeout->msec (); result = ::WaitForSingleObject (*event, msec_timeout); } switch (result) { case WAIT_OBJECT_0: return 0; case WAIT_TIMEOUT: errno = ETIME; return -1; default: // This is a hack, we need to find an appropriate mapping... ACE_OS::set_errno_to_last_error (); return -1; } #elif defined (ACE_HAS_THREADS) int result = 0; int error = 0; // grab the lock first # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \ (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \ (!defined (ACE_USES_FIFO_SEM) && \ (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM))) if (ACE_OS::mutex_lock (&event->eventdata_->lock_) == 0) # else if (ACE_OS::sema_wait (&event->lock_) == 0) # endif { if (event->eventdata_->is_signaled_ == 1) // event is currently signaled { if (event->eventdata_->manual_reset_ == 0) { // AUTO: reset state event->eventdata_->is_signaled_ = 0; event->eventdata_->auto_event_signaled_ = false; } } else // event is currently not signaled { event->eventdata_->waiting_threads_++; ACE_Time_Value absolute_timeout = *timeout; // cond_timewait() expects absolute time, check // <use_absolute_time> flag. if (use_absolute_time == 0) absolute_timeout += ACE_OS::gettimeofday (); while (event->eventdata_->is_signaled_ == 0 && event->eventdata_->auto_event_signaled_ == false) { # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_CONDATTR_PSHARED)) || \ (!defined (ACE_USES_FIFO_SEM) && \ (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM))) if (ACE_OS::cond_timedwait (&event->eventdata_->condition_, &event->eventdata_->lock_, &absolute_timeout) != 0) { result = -1; error = errno; break; } if (event->eventdata_->signal_count_ > 0) { event->eventdata_->signal_count_--; break; } # else # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_MUTEXATTR_PSHARED)) || \ (!defined (ACE_USES_FIFO_SEM) && (!defined (ACE_HAS_POSIX_SEM) || defined (ACE_LACKS_NAMED_POSIX_SEM))) if (ACE_OS::mutex_unlock (&event->eventdata_->lock_) != 0) # else if (ACE_OS::sema_post (&event->lock_) != 0) # endif { event->eventdata_->waiting_threads_--; return -1; } if (ACE_OS::sema_wait(&event->semaphore_, absolute_timeout) !=0) { result = -1; if (errno == ETIMEDOUT) // Semaphores time out with ETIMEDOUT (POSIX) error = ETIME; else error = errno; } bool signalled = false; if (result == 0 && event->eventdata_->signal_count_ > 0) { event->eventdata_->signal_count_--; signalled = true; } # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_MUTEXATTR_PSHARED)) || \ (!defined (ACE_USES_FIFO_SEM) && (!defined (ACE_HAS_POSIX_SEM) || defined (ACE_LACKS_NAMED_POSIX_SEM))) if (ACE_OS::mutex_lock (&event->eventdata_->lock_) != 0) # else if (ACE_OS::sema_wait (&event->lock_) != 0) # endif { event->eventdata_->waiting_threads_--; // yes, I know it's not save return -1; } if (result) break; if (event->eventdata_->manual_reset_ == 1 && event->eventdata_->is_signaled_ == 1) if (ACE_OS::sema_post(&event->semaphore_) != 0) { result = -1; error = errno; break; } if (signalled) break; # endif } // Reset the auto_event_signaled_ to false now that we have // woken up. if (event->eventdata_->auto_event_signaled_ == true) event->eventdata_->auto_event_signaled_ = false; event->eventdata_->waiting_threads_--; } // Now we can let go of the lock. # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \ (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \ (!defined (ACE_USES_FIFO_SEM) && \ (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM))) ACE_OS::mutex_unlock (&event->eventdata_->lock_); # else ACE_OS::sema_post (&event->lock_); # endif if (result == -1) // Reset errno in case mutex_unlock() also fails... errno = error; } else result = -1; return result; #else ACE_UNUSED_ARG (event); ACE_UNUSED_ARG (timeout); ACE_UNUSED_ARG (use_absolute_time); ACE_NOTSUP_RETURN (-1); #endif /* ACE_WIN32 */ }
int ACE_OS::event_wait | ( | ACE_event_t * | event | ) |
Definition at line 3160 of file OS_NS_Thread.cpp.
{ #if defined (ACE_WIN32) switch (::WaitForSingleObject (*event, INFINITE)) { case WAIT_OBJECT_0: return 0; default: { ACE_OS::set_errno_to_last_error (); return -1; } } #elif defined (ACE_HAS_THREADS) int result = 0; int error = 0; // grab the lock first # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \ (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \ (!defined (ACE_USES_FIFO_SEM) && \ (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM))) if (ACE_OS::mutex_lock (&event->eventdata_->lock_) == 0) # else if (ACE_OS::sema_wait (&event->lock_) == 0) # endif { if (event->eventdata_->is_signaled_ == 1) // Event is currently signaled. { if (event->eventdata_->manual_reset_ == 0) // AUTO: reset state event->eventdata_->is_signaled_ = 0; } else // event is currently not signaled { event->eventdata_->waiting_threads_++; while (event->eventdata_->is_signaled_ == 0 && event->eventdata_->auto_event_signaled_ == false) { # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_CONDATTR_PSHARED)) || \ (!defined (ACE_USES_FIFO_SEM) && \ (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM))) if (ACE_OS::cond_wait (&event->eventdata_->condition_, &event->eventdata_->lock_) != 0) { result = -1; error = errno; // Something went wrong... break; } if (event->eventdata_->signal_count_ > 0) { event->eventdata_->signal_count_--; break; } # else # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_MUTEXATTR_PSHARED)) || \ (!defined (ACE_USES_FIFO_SEM) && (!defined (ACE_HAS_POSIX_SEM) || defined (ACE_LACKS_NAMED_POSIX_SEM))) if (ACE_OS::mutex_unlock (&event->eventdata_->lock_) != 0) # else if (ACE_OS::sema_post (&event->lock_) != 0) # endif { event->eventdata_->waiting_threads_--; return -1; } if (ACE_OS::sema_wait (&event->semaphore_) !=0) { result = -1; error = errno; } bool signalled = false; if (result == 0 && event->eventdata_->signal_count_ > 0) { event->eventdata_->signal_count_--; signalled = true; } # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_MUTEXATTR_PSHARED)) || \ (!defined (ACE_USES_FIFO_SEM) && (!defined (ACE_HAS_POSIX_SEM) || defined (ACE_LACKS_NAMED_POSIX_SEM))) if (ACE_OS::mutex_lock (&event->eventdata_->lock_) != 0) # else if (ACE_OS::sema_wait (&event->lock_) != 0) # endif { event->eventdata_->waiting_threads_--; return -1; } if (result) break; if (event->eventdata_->manual_reset_ == 1 && event->eventdata_->is_signaled_ == 1) if (ACE_OS::sema_post(&event->semaphore_) != 0) { result = -1; error = errno; break; } if (signalled) break; # endif } // Reset it since we have woken up. if (event->eventdata_->auto_event_signaled_ == true) event->eventdata_->auto_event_signaled_ = false; event->eventdata_->waiting_threads_--; } // Now we can let go of the lock. # if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \ (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \ (!defined (ACE_USES_FIFO_SEM) && \ (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM))) ACE_OS::mutex_unlock (&event->eventdata_->lock_); # else ACE_OS::sema_post (&event->lock_); # endif if (result == -1) // Reset errno in case mutex_unlock() also fails... errno = error; } else result = -1; return result; #else ACE_UNUSED_ARG (event); ACE_NOTSUP_RETURN (-1); #endif /* ACE_WIN32 */ }
int ACE_OS::execl | ( | const char * | path, | |
const char * | arg0, | |||
... | ||||
) |
Definition at line 208 of file OS_NS_unistd.cpp.
{ ACE_OS_TRACE ("ACE_OS::execl"); ACE_NOTSUP_RETURN (-1); // Need to write this code. // ACE_OSCALL_RETURN (::execv (path, argv), int, -1); }
int ACE_OS::execle | ( | const char * | path, | |
const char * | arg0, | |||
... | ||||
) |
Definition at line 217 of file OS_NS_unistd.cpp.
{ ACE_OS_TRACE ("ACE_OS::execle"); ACE_NOTSUP_RETURN (-1); // Need to write this code. // ACE_OSCALL_RETURN (::execve (path, argv, envp), int, -1); }
int ACE_OS::execlp | ( | const char * | file, | |
const char * | arg0, | |||
... | ||||
) |
Definition at line 226 of file OS_NS_unistd.cpp.
{ ACE_OS_TRACE ("ACE_OS::execlp"); ACE_NOTSUP_RETURN (-1); // Need to write this code. // ACE_OSCALL_RETURN (::execvp (file, argv), int, -1); }
int ACE_OS::execv | ( | const char * | path, | |
char *const | argv[] | |||
) | [inline] |
Definition at line 267 of file OS_NS_unistd.inl.
{ ACE_OS_TRACE ("ACE_OS::execv"); #if defined (ACE_LACKS_EXEC) ACE_UNUSED_ARG (path); ACE_UNUSED_ARG (argv); ACE_NOTSUP_RETURN (-1); #elif defined (ACE_WIN32) # if defined (__BORLANDC__) /* VSB */ return ::execv (path, argv); # elif defined (__MINGW32__) return ::_execv (path, (char *const *) argv); # else // Why this odd-looking code? If execv() returns at all, it's an error. // Windows defines this as returning an intptr_t rather than a simple int, // and the conversion triggers compile warnings. So just return -1 if // the call returns. ::_execv (path, (const char *const *) argv); return -1; # endif /* __BORLANDC__ */ #else ACE_OSCALL_RETURN (::execv (path, argv), int, -1); #endif /* ACE_LACKS_EXEC */ }
int ACE_OS::execve | ( | const char * | path, | |
char *const | argv[], | |||
char *const | envp[] | |||
) | [inline] |
Definition at line 295 of file OS_NS_unistd.inl.
{ ACE_OS_TRACE ("ACE_OS::execve"); #if defined (ACE_LACKS_EXEC) ACE_UNUSED_ARG (path); ACE_UNUSED_ARG (argv); ACE_UNUSED_ARG (envp); ACE_NOTSUP_RETURN (-1); #elif defined (ACE_WIN32) # if defined (__BORLANDC__) /* VSB */ return ::execve (path, argv, envp); # elif defined (__MINGW32__) return ::_execve (path, (char *const *) argv, (char *const *) envp); # else // Why this odd-looking code? If execv() returns at all, it's an error. // Windows defines this as returning an intptr_t rather than a simple int, // and the conversion triggers compile warnings. So just return -1 if // the call returns. ::_execve (path, (const char *const *) argv, (const char *const *) envp); return -1; # endif /* __BORLANDC__ */ #else ACE_OSCALL_RETURN (::execve (path, argv, envp), int, -1); #endif /* ACE_LACKS_EXEC */ }
int ACE_OS::execvp | ( | const char * | file, | |
char *const | argv[] | |||
) | [inline] |
Definition at line 325 of file OS_NS_unistd.inl.
{ ACE_OS_TRACE ("ACE_OS::execvp"); #if defined (ACE_LACKS_EXEC) ACE_UNUSED_ARG (file); ACE_UNUSED_ARG (argv); ACE_NOTSUP_RETURN (-1); #elif defined (ACE_WIN32) # if defined (__BORLANDC__) /* VSB */ return ::execvp (file, argv); # elif defined (__MINGW32__) return ::_execvp (file, (char *const *) argv); # else // Why this odd-looking code? If execv() returns at all, it's an error. // Windows defines this as returning an intptr_t rather than a simple int, // and the conversion triggers compile warnings. So just return -1 if // the call returns. ::_execvp (file, (const char *const *) argv); return -1; # endif /* __BORLANDC__ */ #else ACE_OSCALL_RETURN (::execvp (file, argv), int, -1); #endif /* ACE_LACKS_EXEC */ }
void ACE_OS::exit | ( | int | status = 0 |
) |
Function that is called by <ACE_OS::exit>, if non-null.
Definition at line 52 of file OS_NS_stdlib.cpp.
{ ACE_OS_TRACE ("ACE_OS::exit"); #if defined (ACE_HAS_NONSTATIC_OBJECT_MANAGER) && !defined (ACE_HAS_WINCE) && !defined (ACE_DOESNT_INSTANTIATE_NONSTATIC_OBJECT_MANAGER) // Shut down the ACE_Object_Manager, if it had registered its exit_hook. // With ACE_HAS_NONSTATIC_OBJECT_MANAGER, the ACE_Object_Manager is // instantiated on the main's stack. ::exit () doesn't destroy it. if (exit_hook_) (*exit_hook_) (); #endif /* ACE_HAS_NONSTATIC_OBJECT_MANAGER && !ACE_HAS_WINCE && !ACE_DOESNT_INSTANTIATE_NONSTATIC_OBJECT_MANAGER */ #if defined (ACE_WIN32) ::ExitProcess ((UINT) status); #else ::exit (status); #endif /* ACE_WIN32 */ }
int ACE_OS::fattach | ( | int | handle, | |
const char * | path | |||
) | [inline] |
Definition at line 81 of file OS_NS_stropts.inl.
{ ACE_OS_TRACE ("ACE_OS::fattach"); #if defined (ACE_HAS_STREAM_PIPES) ACE_OSCALL_RETURN (::fattach (handle, path), int, -1); #else ACE_UNUSED_ARG (handle); ACE_UNUSED_ARG (path); ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_STREAM_PIPES */ }
int ACE_OS::fclose | ( | FILE * | fp | ) | [inline] |
Definition at line 490 of file OS_NS_stdio.inl.
{ ACE_OS_TRACE ("ACE_OS::fclose"); ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::fclose (fp), int, -1); }
int ACE_OS::fcntl | ( | ACE_HANDLE | handle, | |
int | cmd, | |||
long | arg = 0 | |||
) | [inline] |
Definition at line 10 of file OS_NS_fcntl.inl.
{ ACE_OS_TRACE ("ACE_OS::fcntl"); # if defined (ACE_LACKS_FCNTL) ACE_UNUSED_ARG (handle); ACE_UNUSED_ARG (cmd); ACE_UNUSED_ARG (arg); ACE_NOTSUP_RETURN (-1); # else ACE_OSCALL_RETURN (::fcntl (handle, cmd, arg), int, -1); # endif /* ACE_LACKS_FCNTL */ }
int ACE_OS::fdetach | ( | const char * | file | ) | [inline] |
Definition at line 95 of file OS_NS_stropts.inl.
{ ACE_OS_TRACE ("ACE_OS::fdetach"); #if defined (ACE_HAS_STREAM_PIPES) ACE_OSCALL_RETURN (::fdetach (file), int, -1); #else ACE_UNUSED_ARG (file); ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_STREAM_PIPES */ }
FILE * ACE_OS::fdopen | ( | ACE_HANDLE | handle, | |
const ACE_TCHAR * | mode | |||
) | [inline] |
Definition at line 497 of file OS_NS_stdio.inl.
{ ACE_OS_TRACE ("ACE_OS::fdopen"); #if defined (ACE_HAS_WINCE) # if defined (ACE_HAS_NONCONST_WFDOPEN) ACE_OSCALL_RETURN (::_wfdopen ((int)handle, const_cast <ACE_TCHAR*> (ACE_TEXT_ALWAYS_WCHAR (mode))), FILE*, 0); # else ACE_OSCALL_RETURN (::_wfdopen (handle, ACE_TEXT_ALWAYS_WCHAR (mode)), FILE*, 0); # endif #elif defined (ACE_WIN32) // kernel file handle -> FILE* conversion... // Options: _O_APPEND, _O_RDONLY and _O_TEXT are lost FILE * file = 0; int const crt_handle = ::_open_osfhandle (intptr_t (handle), 0); if (crt_handle != -1) { # if defined (ACE_USES_WCHAR) file = ::_wfdopen (crt_handle, mode); # else file = ::_fdopen (crt_handle, mode); # endif /* ACE_USES_WCHAR */ if (!file) { ::_close (crt_handle); } } return file; #elif defined (ACE_LACKS_FDOPEN) ACE_UNUSED_ARG (handle); ACE_UNUSED_ARG (mode); ACE_NOTSUP_RETURN (0); #else ACE_OSCALL_RETURN (::fdopen (handle, ACE_TEXT_ALWAYS_CHAR (mode)), FILE *, 0); #endif /* ACE_HAS_WINCE */ }
int ACE_OS::fflush | ( | FILE * | fp | ) | [inline] |
Definition at line 544 of file OS_NS_stdio.inl.
{ ACE_OS_TRACE ("ACE_OS::fflush"); ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::fflush (fp), int, -1); }
int ACE_OS::fgetc | ( | FILE * | fp | ) | [inline] |
Definition at line 551 of file OS_NS_stdio.inl.
{ return ace_fgetc_helper (fp); }
int ACE_OS::fgetpos | ( | FILE * | fp, | |
fpos_t * | pos | |||
) | [inline] |
Definition at line 563 of file OS_NS_stdio.inl.
{ ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::fgetpos (fp, pos), int, -1); }
char * ACE_OS::fgets | ( | char * | buf, | |
int | size, | |||
FILE * | fp | |||
) | [inline] |
Definition at line 569 of file OS_NS_stdio.inl.
{ ACE_OS_TRACE ("ACE_OS::fgets"); ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::fgets (buf, size, fp), char *, 0); }
ACE_HANDLE ACE_OS::fileno | ( | FILE * | stream | ) | [inline] |
Definition at line 585 of file OS_NS_stdio.inl.
{ #if defined ACE_FILENO_EQUIVALENT return (ACE_HANDLE)ACE_FILENO_EQUIVALENT (stream); #else return ace_fileno_helper (stream); #endif }
ACE_OFF_T ACE_OS::filesize | ( | ACE_HANDLE | handle | ) | [inline] |
Definition at line 76 of file OS_NS_sys_stat.inl.
{ ACE_OS_TRACE ("ACE_OS::filesize"); #if defined (ACE_WIN32) # if defined (_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64 LARGE_INTEGER size; return (::GetFileSizeEx (handle, &size) ? size.QuadPart : (ACE_OS::set_errno_to_last_error (), -1)); # else DWORD const size = ::GetFileSize (handle, 0); return (size != INVALID_FILE_SIZE ? static_cast<ACE_OFF_T> (size) : (ACE_OS::set_errno_to_last_error (), -1)); # endif /* _FILE_OFFSET_BITS == 64 */ #else /* !ACE_WIN32 */ ACE_stat sb; return ACE_OS::fstat (handle, &sb) == -1 ? static_cast<ACE_OFF_T> (-1) : sb.st_size; #endif }
Definition at line 101 of file OS_NS_sys_stat.inl.
{ ACE_OS_TRACE ("ACE_OS::filesize"); ACE_HANDLE const h = ACE_OS::open (filename, O_RDONLY); if (h != ACE_INVALID_HANDLE) { ACE_OFF_T size = ACE_OS::filesize (h); ACE_OS::close (h); return size; } else return -1; }
int ACE_OS::flock_destroy | ( | ACE_OS::ace_flock_t * | lock, | |
int | unlink_file = 1 | |||
) | [inline] |
Definition at line 158 of file OS_NS_stdio.inl.
{ ACE_OS_TRACE ("ACE_OS::flock_destroy"); if (lock->handle_ != ACE_INVALID_HANDLE) { ACE_OS::flock_unlock (lock); // Close the handle. ACE_OS::close (lock->handle_); lock->handle_ = ACE_INVALID_HANDLE; if (lock->lockname_ != 0) { if (unlink_file) ACE_OS::unlink (lock->lockname_); ACE_OS::free ( static_cast<void *> (const_cast<ACE_TCHAR *> (lock->lockname_))); } lock->lockname_ = 0; } return 0; }
int ACE_OS::flock_init | ( | ACE_OS::ace_flock_t * | lock, | |
int | flags = 0 , |
|||
const ACE_TCHAR * | name = 0 , |
|||
mode_t | perms = 0 | |||
) | [inline] |
Definition at line 90 of file OS_NS_stdio.inl.
{ ACE_OS_TRACE ("ACE_OS::flock_init"); #if defined (ACE_WIN32) // Once initialized, these values are never changed. lock->overlapped_.Internal = 0; lock->overlapped_.InternalHigh = 0; lock->overlapped_.OffsetHigh = 0; lock->overlapped_.hEvent = 0; #endif /* ACE_WIN32 */ lock->handle_ = ACE_INVALID_HANDLE; lock->lockname_ = 0; if (name != 0) { ACE_OSCALL (ACE_OS::open (name, flags, perms), ACE_HANDLE, ACE_INVALID_HANDLE, lock->handle_); if (lock->handle_ != ACE_INVALID_HANDLE) lock->lockname_ = ACE_OS::strdup (name); return lock->handle_ == ACE_INVALID_HANDLE ? -1 : 0; } else return 0; }
int ACE_OS::flock_rdlock | ( | ACE_OS::ace_flock_t * | lock, | |
short | whence = 0 , |
|||
ACE_OFF_T | start = 0 , |
|||
ACE_OFF_T | len = 0 | |||
) | [inline] |
Definition at line 181 of file OS_NS_stdio.inl.
{ ACE_OS_TRACE ("ACE_OS::flock_rdlock"); #if defined (ACE_LACKS_FILELOCKS) ACE_UNUSED_ARG (lock); ACE_UNUSED_ARG (whence); ACE_UNUSED_ARG (start); ACE_UNUSED_ARG (len); ACE_NOTSUP_RETURN (-1); #elif defined (ACE_WIN32) ACE_OS::flock_adjust_params (lock, whence, start, len); DWORD low_len = ACE_LOW_PART (len); DWORD high_len = ACE_HIGH_PART (len); ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::LockFileEx (lock->handle_, 0, 0, low_len, high_len, &lock->overlapped_), ace_result_), int, -1); #else lock->lock_.l_whence = whence; lock->lock_.l_start = start; lock->lock_.l_len = len; lock->lock_.l_type = F_RDLCK; // set read lock // block, if no access ACE_OSCALL_RETURN (ACE_OS::fcntl (lock->handle_, F_SETLKW, reinterpret_cast<long> (&lock->lock_)), int, -1); #endif /* ACE_WIN32 */ }
int ACE_OS::flock_tryrdlock | ( | ACE_OS::ace_flock_t * | lock, | |
short | whence = 0 , |
|||
ACE_OFF_T | start = 0 , |
|||
ACE_OFF_T | len = 0 | |||
) | [inline] |
Definition at line 217 of file OS_NS_stdio.inl.
{ ACE_OS_TRACE ("ACE_OS::ace_flock_tryrdlock"); #if defined (ACE_LACKS_FILELOCKS) ACE_UNUSED_ARG (lock); ACE_UNUSED_ARG (whence); ACE_UNUSED_ARG (start); ACE_UNUSED_ARG (len); ACE_NOTSUP_RETURN (-1); #elif defined (ACE_WIN32) ACE_OS::flock_adjust_params (lock, whence, start, len); DWORD low_len = ACE_LOW_PART (len); DWORD high_len = ACE_HIGH_PART (len); ACE_WIN32CALL_RETURN ( ACE_ADAPT_RETVAL (::LockFileEx (lock->handle_, LOCKFILE_FAIL_IMMEDIATELY, 0, low_len, high_len, &lock->overlapped_), ace_result_), int, -1); #else lock->lock_.l_whence = whence; lock->lock_.l_start = start; lock->lock_.l_len = len; lock->lock_.l_type = F_RDLCK; // set read lock int result = 0; // Does not block, if no access, returns -1 and set errno = EBUSY; ACE_OSCALL (ACE_OS::fcntl (lock->handle_, F_SETLK, reinterpret_cast<long> (&lock->lock_)), int, -1, result); if (result == -1 && (errno == EACCES || errno == EAGAIN)) errno = EBUSY; return result; #endif /* ACE_WIN32 */ }
int ACE_OS::flock_trywrlock | ( | ACE_OS::ace_flock_t * | lock, | |
short | whence = 0 , |
|||
ACE_OFF_T | start = 0 , |
|||
ACE_OFF_T | len = 0 | |||
) | [inline] |
Definition at line 261 of file OS_NS_stdio.inl.
{ ACE_OS_TRACE ("ACE_OS::ace_flock_trywrlock"); #if defined (ACE_LACKS_FILELOCKS) ACE_UNUSED_ARG (lock); ACE_UNUSED_ARG (whence); ACE_UNUSED_ARG (start); ACE_UNUSED_ARG (len); ACE_NOTSUP_RETURN (-1); #elif defined (ACE_WIN32) ACE_OS::flock_adjust_params (lock, whence, start, len); DWORD low_len = ACE_LOW_PART (len); DWORD high_len = ACE_HIGH_PART (len); ACE_WIN32CALL_RETURN ( ACE_ADAPT_RETVAL (::LockFileEx (lock->handle_, LOCKFILE_FAIL_IMMEDIATELY | LOCKFILE_EXCLUSIVE_LOCK, 0, low_len, high_len, &lock->overlapped_), ace_result_), int, -1); #else lock->lock_.l_whence = whence; lock->lock_.l_start = start; lock->lock_.l_len = len; lock->lock_.l_type = F_WRLCK; // set write lock int result = 0; // Does not block, if no access, returns -1 and set errno = EBUSY; ACE_OSCALL (ACE_OS::fcntl (lock->handle_, F_SETLK, reinterpret_cast<long> (&lock->lock_)), int, -1, result); if (result == -1 && (errno == EACCES || errno == EAGAIN)) errno = EBUSY; return result; #endif /* ACE_WIN32 */ }
int ACE_OS::flock_unlock | ( | ACE_OS::ace_flock_t * | lock, | |
short | whence = 0 , |
|||
ACE_OFF_T | start = 0 , |
|||
ACE_OFF_T | len = 0 | |||
) | [inline] |
Definition at line 121 of file OS_NS_stdio.inl.
{ ACE_OS_TRACE ("ACE_OS::flock_unlock"); #if defined (ACE_LACKS_FILELOCKS) ACE_UNUSED_ARG (lock); ACE_UNUSED_ARG (whence); ACE_UNUSED_ARG (start); ACE_UNUSED_ARG (len); ACE_NOTSUP_RETURN (-1); #elif defined (ACE_WIN32) ACE_OS::flock_adjust_params (lock, whence, start, len); DWORD low_len = ACE_LOW_PART (len); DWORD high_len = ACE_HIGH_PART (len); ACE_WIN32CALL_RETURN ( ACE_ADAPT_RETVAL (::UnlockFileEx (lock->handle_, 0, low_len, high_len, &lock->overlapped_), ace_result_), int, -1); #else lock->lock_.l_whence = whence; lock->lock_.l_start = start; lock->lock_.l_len = len; lock->lock_.l_type = F_UNLCK; // Unlock file. // release lock ACE_OSCALL_RETURN (ACE_OS::fcntl (lock->handle_, F_SETLK, reinterpret_cast<long> (&lock->lock_)), int, -1); #endif /* ACE_WIN32 */ }
int ACE_OS::flock_wrlock | ( | ACE_OS::ace_flock_t * | lock, | |
short | whence = 0 , |
|||
ACE_OFF_T | start = 0 , |
|||
ACE_OFF_T | len = 0 | |||
) | [inline] |
Definition at line 306 of file OS_NS_stdio.inl.
{ ACE_OS_TRACE ("ACE_OS::flock_wrlock"); #if defined (ACE_LACKS_FILELOCKS) ACE_UNUSED_ARG (lock); ACE_UNUSED_ARG (whence); ACE_UNUSED_ARG (start); ACE_UNUSED_ARG (len); ACE_NOTSUP_RETURN (-1); #elif defined (ACE_WIN32) ACE_OS::flock_adjust_params (lock, whence, start, len); DWORD low_len = ACE_LOW_PART (len); DWORD high_len = ACE_HIGH_PART (len); ACE_WIN32CALL_RETURN ( ACE_ADAPT_RETVAL (::LockFileEx (lock->handle_, LOCKFILE_EXCLUSIVE_LOCK, 0, low_len, high_len, &lock->overlapped_), ace_result_), int, -1); #else lock->lock_.l_whence = whence; lock->lock_.l_start = start; lock->lock_.l_len = len; lock->lock_.l_type = F_WRLCK; // set write lock // block, if no access ACE_OSCALL_RETURN (ACE_OS::fcntl (lock->handle_, F_SETLKW, reinterpret_cast<long> (&lock->lock_)), int, -1); #endif /* ACE_WIN32 */ }
T ACE_OS::floor | ( | T | x | ) |
This method computes the largest integral value not greater than x.
Definition at line 92 of file OS_NS_math.h.
{ return ACE_STD_NAMESPACE::floor (x); }
FILE * ACE_OS::fopen | ( | const char * | filename, | |
const char * | mode | |||
) | [inline] |
Definition at line 597 of file OS_NS_stdio.inl.
{ ACE_OS_TRACE ("ACE_OS::fopen"); ACE_OSCALL_RETURN (::fopen (filename, mode), FILE *, 0); }
pid_t ACE_OS::fork | ( | void | ) | [inline] |
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 353 of file OS_NS_unistd.inl.
{ ACE_OS_TRACE ("ACE_OS::fork"); #if defined (ACE_LACKS_FORK) ACE_NOTSUP_RETURN (pid_t (-1)); #else ACE_OSCALL_RETURN (::fork (), pid_t, -1); #endif /* ACE_LACKS_FORK */ }
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 235 of file OS_NS_unistd.cpp.
{ ACE_OS_TRACE ("ACE_OS::fork"); # if defined (ACE_LACKS_FORK) ACE_UNUSED_ARG (program_name); ACE_NOTSUP_RETURN (pid_t (-1)); # else pid_t const pid = # if defined (ACE_HAS_STHREADS) ::fork1 (); #else ::fork (); #endif /* ACE_HAS_STHREADS */ #if !defined (ACE_HAS_MINIMAL_ACE_OS) && !defined (ACE_HAS_THREADS) // ACE_Base_Thread_Adapter::sync_log_msg() is used to update the // program name and process id in ACE's log framework. However, we // can't invoke it from (the child process of) threaded programs // because it calls async signal unsafe functions, which will result // in undefined behavior (only async signal safe functions can be // called after fork() until an exec()). // // This is no great loss. Using the ACE log framework in the child // process will undoubtedly call async signal unsafe functions too. // So it doesn't really matter that the program name and process id // will not be updated. if (pid == 0) ACE_Base_Thread_Adapter::sync_log_msg (program_name); #else ACE_UNUSED_ARG (program_name); #endif /* ! ACE_HAS_MINIMAL_ACE_OS && !ACE_HAS_THREADS */ return pid; # endif /* ACE_WIN32 */ }
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 280 of file OS_NS_unistd.cpp.
{ # if defined (ACE_WIN32) ACE_TCHAR *buf = 0; ACE_Auto_Basic_Array_Ptr<ACE_TCHAR> safe_ptr (buf); if (ACE_OS::argv_to_string (argv, buf) != -1) { PROCESS_INFORMATION process_info; # if !defined (ACE_HAS_WINCE) ACE_TEXT_STARTUPINFO startup_info; ACE_OS::memset ((void *) &startup_info, 0, sizeof startup_info); startup_info.cb = sizeof startup_info; if (ACE_TEXT_CreateProcess (0, buf, 0, // No process attributes. 0, // No thread attributes. TRUE, // Allow handle inheritance. 0, // Don't create a new console window. 0, // No environment. 0, // No current directory. &startup_info, &process_info)) # else if (ACE_TEXT_CreateProcess (0, buf, 0, // No process attributes. 0, // No thread attributes. FALSE, // Can's inherit handles on CE 0, // Don't create a new console window. 0, // No environment. 0, // No current directory. 0, // Can't use startup info on CE &process_info)) # endif /* ! ACE_HAS_WINCE */ { // Free resources allocated in kernel. ACE_OS::close (process_info.hThread); ACE_OS::close (process_info.hProcess); // Return new process id. return process_info.dwProcessId; } } // CreateProcess failed. return -1; # else pid_t const result = ACE_OS::fork (); # if defined (ACE_USES_WCHAR) // Wide-char builds need to convert the command-line args to // narrow char strings for execv (). char **cargv = 0; int arg_count; # endif /* ACE_HAS_WCHAR */ switch (result) { case -1: // Error. return -1; case 0: // Child process. # if defined (ACE_USES_WCHAR) for (arg_count = 0; argv[arg_count] != 0; ++arg_count) ; ++arg_count; // Need a 0-pointer end-of-array marker ACE_NEW_NORETURN (cargv, char*[arg_count]); if (cargv == 0) ACE_OS::exit (errno); --arg_count; // Back to 0-indexed cargv[arg_count] = 0; while (--arg_count >= 0) cargv[arg_count] = ACE_Wide_To_Ascii::convert (argv[arg_count]); // Don't worry about freeing the cargv or the strings it points to. // Either the process will be replaced, or we'll exit. if (ACE_OS::execv (cargv[0], cargv) == -1) ACE_OS::exit (errno); # else if (ACE_OS::execv (argv[0], argv) == -1) { // The OS layer should not print stuff out // ACE_ERROR ((LM_ERROR, // "%p Exec failed\n")); // If the execv fails, this child needs to exit. ACE_OS::exit (errno); } # endif /* ACE_HAS_WCHAR */ default: // Server process. The fork succeeded. return result; } # endif /* ACE_WIN32 */ }
int ACE_OS::fprintf | ( | FILE * | fp, | |
const char * | format, | |||
... | ||||
) |
Definition at line 248 of file OS_NS_stdio.cpp.
{ // ACE_OS_TRACE ("ACE_OS::fprintf"); va_list ap; va_start (ap, format); int const result = ACE_OS::vfprintf (fp, format, ap); va_end (ap); return result; }
int ACE_OS::fputc | ( | int | c, | |
FILE * | fp | |||
) | [inline] |
Definition at line 655 of file OS_NS_stdio.inl.
{ return ace_fputc_helper (c, fp); }
int ACE_OS::fputs | ( | const char * | s, | |
FILE * | stream | |||
) | [inline] |
Definition at line 667 of file OS_NS_stdio.inl.
{ ACE_OS_TRACE ("ACE_OS::fputs"); ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::fputs (s, stream), int, -1); }
size_t ACE_OS::fread | ( | void * | ptr, | |
size_t | size, | |||
size_t | nelems, | |||
FILE * | fp | |||
) | [inline] |
Definition at line 683 of file OS_NS_stdio.inl.
{ ACE_OS_TRACE ("ACE_OS::fread"); ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::fread (ptr, size, nelems, fp), size_t, 0); }
void ACE_OS::free | ( | void * | ptr | ) |
Function that is called by <ACE_OS::exit>, if non-null.
Definition at line 72 of file OS_NS_stdlib.cpp.
{ ACE_FREE_FUNC (ACE_MALLOC_T (ptr)); }
FILE * ACE_OS::freopen | ( | const ACE_TCHAR * | filename, | |
const ACE_TCHAR * | mode, | |||
FILE * | stream | |||
) | [inline] |
Definition at line 692 of file OS_NS_stdio.inl.
{ ACE_OS_TRACE ("ACE_OS::freopen"); #if defined (ACE_WIN32) && defined(ACE_USES_WCHAR) ACE_OSCALL_RETURN (::_wfreopen (ACE_TEXT_ALWAYS_WCHAR (filename), ACE_TEXT_ALWAYS_WCHAR (mode), stream), FILE *, 0); #else ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::freopen (ACE_TEXT_ALWAYS_CHAR (filename), ACE_TEXT_ALWAYS_CHAR (mode), stream), FILE *, 0); #endif /* ACE_WIN32 && ACE_USES_WCHAR */ }
int ACE_OS::fseek | ( | FILE * | fp, | |
long | offset, | |||
int | ptrname | |||
) | [inline] |
Definition at line 710 of file OS_NS_stdio.inl.
{ # if defined (ACE_WIN32) # if SEEK_SET != FILE_BEGIN || SEEK_CUR != FILE_CURRENT || SEEK_END != FILE_END //#error Windows NT is evil AND rude! switch (whence) { case SEEK_SET: whence = FILE_BEGIN; break; case SEEK_CUR: whence = FILE_CURRENT; break; case SEEK_END: whence = FILE_END; break; default: errno = EINVAL; return -1; // rather safe than sorry } # endif /* SEEK_SET != FILE_BEGIN || SEEK_CUR != FILE_CURRENT || SEEK_END != FILE_END */ # endif /* ACE_WIN32 */ ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::fseek (fp, offset, whence), int, -1); }
int ACE_OS::fsetpos | ( | FILE * | fp, | |
fpos_t * | pos | |||
) | [inline] |
Definition at line 736 of file OS_NS_stdio.inl.
{ ACE_OSCALL_RETURN (::fsetpos (fp, pos), int, -1); }
int ACE_OS::fstat | ( | ACE_HANDLE | handle, | |
ACE_stat * | stp | |||
) | [inline] |
Definition at line 28 of file OS_NS_sys_stat.inl.
{ ACE_OS_TRACE ("ACE_OS::fstat"); #if defined (ACE_HAS_X86_STAT_MACROS) // Solaris for intel uses an macro for fstat(), this is a wrapper // for _fxstat() use of the macro. // causes compile and runtime problems. ACE_OSCALL_RETURN (::_fxstat (_STAT_VER, handle, stp), int, -1); #elif defined (ACE_WIN32) BY_HANDLE_FILE_INFORMATION fdata; if (::GetFileInformationByHandle (handle, &fdata) == FALSE) { ACE_OS::set_errno_to_last_error (); return -1; } else if (fdata.nFileSizeHigh != 0) { errno = EINVAL; return -1; } else { stp->st_size = fdata.nFileSizeLow; stp->st_atime = ACE_Time_Value (fdata.ftLastAccessTime).sec (); stp->st_mtime = ACE_Time_Value (fdata.ftLastWriteTime).sec (); stp->st_ctime = ACE_Time_Value (fdata.ftCreationTime).sec (); stp->st_nlink = static_cast<short> (fdata.nNumberOfLinks); stp->st_dev = stp->st_rdev = 0; // No equivalent conversion. stp->st_mode = S_IXOTH | S_IROTH | (fdata.dwFileAttributes & FILE_ATTRIBUTE_READONLY ? 0 : S_IWOTH) | (fdata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ? S_IFDIR : S_IFREG); } return 0; #else # if defined (ACE_OPENVMS) //FUZZ: disable check_for_lack_ACE_OS ::fsync(handle); //FUZZ: enable check_for_lack_ACE_OS #endif ACE_OSCALL_RETURN (::fstat (handle, stp), int, -1); # endif /* !ACE_HAS_X86_STAT_MACROS */ }
int ACE_OS::fsync | ( | ACE_HANDLE | handle | ) | [inline] |
Definition at line 364 of file OS_NS_unistd.inl.
{ ACE_OS_TRACE ("ACE_OS::fsync"); # if defined (ACE_LACKS_FSYNC) ACE_UNUSED_ARG (handle); ACE_NOTSUP_RETURN (-1); # elif defined (ACE_WIN32) ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::FlushFileBuffers (handle), ace_result_), int, -1); # else ACE_OSCALL_RETURN (::fsync (handle), int, -1); # endif /* ACE_LACKS_FSYNC */ }
long ACE_OS::ftell | ( | FILE * | fp | ) | [inline] |
Definition at line 742 of file OS_NS_stdio.inl.
{ ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::ftell (fp), long, -1); }
int ACE_OS::ftruncate | ( | ACE_HANDLE | handle, | |
ACE_OFF_T | offset | |||
) | [inline] |
Definition at line 378 of file OS_NS_unistd.inl.
{ ACE_OS_TRACE ("ACE_OS::ftruncate"); #if defined (ACE_WIN32) # if !defined (ACE_LACKS_WIN32_SETFILEPOINTEREX) LARGE_INTEGER loff; loff.QuadPart = offset; if (::SetFilePointerEx (handle, loff, 0, FILE_BEGIN)) # else if (::SetFilePointer (handle, offset, 0, FILE_BEGIN) != INVALID_SET_FILE_POINTER) # endif ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::SetEndOfFile (handle), ace_result_), int, -1); else ACE_FAIL_RETURN (-1); #else ACE_OSCALL_RETURN (::ftruncate (handle, offset), int, -1); #endif /* ACE_WIN32 */ }
size_t ACE_OS::fwrite | ( | const void * | ptr, | |
size_t | size, | |||
size_t | nitems, | |||
FILE * | fp | |||
) | [inline] |
Definition at line 748 of file OS_NS_stdio.inl.
{ ACE_OS_TRACE ("ACE_OS::fwrite"); ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::fwrite (ptr, size, nitems, fp), size_t, 0); }
int ACE_OS::getc | ( | FILE * | fp | ) | [inline] |
Definition at line 557 of file OS_NS_stdio.inl.
{ return ace_getc_helper (fp); }
char * ACE_OS::getcwd | ( | char * | buf, | |
size_t | size | |||
) | [inline] |
Definition at line 401 of file OS_NS_unistd.inl.
{ ACE_OS_TRACE ("ACE_OS::getcwd"); #if defined (ACE_LACKS_GETCWD) ACE_UNUSED_ARG (buf); ACE_UNUSED_ARG (size); ACE_NOTSUP_RETURN (0); #elif defined (ACE_WIN32) return ::getcwd (buf, static_cast<int> (size)); #else ACE_OSCALL_RETURN (::getcwd (buf, size), char *, 0); #endif /* ACE_LACKS_GETCWD */ }
gid_t ACE_OS::getegid | ( | void | ) | [inline] |
Definition at line 450 of file OS_NS_unistd.inl.
{ ACE_OS_TRACE ("ACE_OS::getegid"); #if defined (ACE_LACKS_GETEGID) ACE_NOTSUP_RETURN (static_cast<gid_t> (-1)); # else ACE_OSCALL_RETURN (::getegid (), gid_t, static_cast<gid_t> (-1)); # endif /* ACE_LACKS_GETEGID */ }
char * ACE_OS::getenv | ( | const char * | symbol | ) | [inline] |
Function that is called by <ACE_OS::exit>, if non-null.
Definition at line 167 of file OS_NS_stdlib.inl.
{ ACE_OS_TRACE ("ACE_OS::getenv"); #if defined (ACE_LACKS_GETENV) ACE_UNUSED_ARG (symbol); ACE_NOTSUP_RETURN (0); #else /* ACE_LACKS_GETENV */ ACE_OSCALL_RETURN (::getenv (symbol), char *, 0); #endif /* ACE_LACKS_GETENV */ }
ACE_TCHAR * ACE_OS::getenvstrings | ( | void | ) |
Function that is called by <ACE_OS::exit>, if non-null.
Definition at line 87 of file OS_NS_stdlib.cpp.
{ #if defined (ACE_LACKS_GETENVSTRINGS) ACE_NOTSUP_RETURN (0); #elif defined (ACE_WIN32) # if defined (ACE_USES_WCHAR) return ::GetEnvironmentStringsW (); # else /* ACE_USES_WCHAR */ return ::GetEnvironmentStrings (); # endif /* ACE_USES_WCHAR */ #else /* ACE_WIN32 */ ACE_NOTSUP_RETURN (0); #endif /* ACE_WIN32 */ }
uid_t ACE_OS::geteuid | ( | void | ) | [inline] |
Definition at line 528 of file OS_NS_unistd.inl.
{ ACE_OS_TRACE ("ACE_OS::geteuid"); #if defined (ACE_LACKS_GETEUID) ACE_NOTSUP_RETURN (static_cast<uid_t> (-1)); # else ACE_OSCALL_RETURN (::geteuid (), uid_t, (uid_t) -1); # endif /* ACE_LACKS_GETEUID */ }
gid_t ACE_OS::getgid | ( | void | ) | [inline] |
Definition at line 439 of file OS_NS_unistd.inl.
{ ACE_OS_TRACE ("ACE_OS::getgid"); #if defined (ACE_LACKS_GETGID) ACE_NOTSUP_RETURN (static_cast<gid_t> (-1)); # else ACE_OSCALL_RETURN (::getgid (), gid_t, static_cast<gid_t> (-1)); # endif /* ACE_LACKS_GETGID */ }
struct hostent * ACE_OS::gethostbyaddr | ( | const char * | addr, | |
int | length, | |||
int | type | |||
) | [read] |
Definition at line 48 of file OS_NS_netdb.inl.
{ ACE_OS_TRACE ("ACE_OS::gethostbyaddr"); # if defined (ACE_LACKS_GETHOSTBYADDR) ACE_UNUSED_ARG (addr); ACE_UNUSED_ARG (length); ACE_UNUSED_ARG (type); ACE_NOTSUP_RETURN (0); # else if (0 == addr || '\0' == addr[0]) return 0; # if defined (ACE_VXWORKS) // VxWorks 6.x has a gethostbyaddr() that is threadsafe and // returns an heap-allocated hostentry structure. // just call ACE_OS::gethostbyaddr_r () which knows how to handle this. struct hostent hentry; ACE_HOSTENT_DATA buf; int h_error; // Not the same as errno! return ACE_OS::gethostbyaddr_r (addr, length, type, &hentry, buf, &h_error); # elif defined (ACE_HAS_NONCONST_GETBY) //FUZZ: disable check_for_lack_ACE_OS ACE_SOCKCALL_RETURN (::gethostbyaddr (const_cast<char *> (addr), (ACE_SOCKET_LEN) length, type), struct hostent *, 0); //FUZZ: enable check_for_lack_ACE_OS # else //FUZZ: disable check_for_lack_ACE_OS ACE_SOCKCALL_RETURN (::gethostbyaddr (addr, (ACE_SOCKET_LEN) length, type), struct hostent *, 0); //FUZZ: enable check_for_lack_ACE_OS # endif /* ACE_HAS_NONCONST_GETBY */ # endif /* !ACE_LACKS_GETHOSTBYADDR */ }
struct hostent * ACE_OS::gethostbyaddr_r | ( | const char * | addr, | |
int | length, | |||
int | type, | |||
struct hostent * | result, | |||
ACE_HOSTENT_DATA | buffer, | |||
int * | h_errnop | |||
) | [read] |
Definition at line 94 of file OS_NS_netdb.inl.
{ ACE_OS_TRACE ("ACE_OS::gethostbyaddr_r"); # if defined (ACE_LACKS_GETHOSTBYADDR_R) ACE_UNUSED_ARG (addr); ACE_UNUSED_ARG (length); ACE_UNUSED_ARG (type); ACE_UNUSED_ARG (result); ACE_UNUSED_ARG (buffer); ACE_UNUSED_ARG (h_errnop); ACE_NOTSUP_RETURN (0); # elif defined (ACE_HAS_REENTRANT_FUNCTIONS) && !defined (UNIXWARE) if (0 == addr || '\0' == addr[0]) return 0; # if defined (AIX) || defined (DIGITAL_UNIX) ACE_OS::memset (buffer, 0, sizeof (ACE_HOSTENT_DATA)); //FUZZ: disable check_for_lack_ACE_OS if (::gethostbyaddr_r ((char *) addr, length, type, result, (struct hostent_data *) buffer)== 0) return result; //FUZZ: enable check_for_lack_ACE_OS else { *h_errnop = h_errno; return (struct hostent *) 0; } # elif defined (__GLIBC__) // GNU C library has a different signature ACE_OS::memset (buffer, 0, sizeof (ACE_HOSTENT_DATA)); //FUZZ: disable check_for_lack_ACE_OS if (::gethostbyaddr_r ((char *) addr, length, type, result, buffer, sizeof (ACE_HOSTENT_DATA), &result, h_errnop) == 0) return result; //FUZZ: enable check_for_lack_ACE_OS else return (struct hostent *) 0; # elif defined (ACE_VXWORKS) // VxWorks 6.x has a threadsafe gethostbyaddr() which returns a heap-allocated // data structure which needs to be freed with hostentFree() //FUZZ: disable check_for_lack_ACE_OS struct hostent* hp = ::gethostbyaddr (addr, length, type); //FUZZ: enable check_for_lack_ACE_OS if (hp) { result->h_addrtype = hp->h_addrtype; result->h_length = hp->h_length; // buffer layout: // buffer[0-3]: h_addr_list[0], pointer to the addr. // buffer[4-7]: h_addr_list[1], null terminator for the h_addr_list. // buffer[8..(8+h_length)]: the first (and only) addr. // buffer[(8+h_length)...]: hostname // Store the address list in buffer. result->h_addr_list = (char **) buffer; // Store the actual address _after_ the address list. result->h_addr_list[0] = (char *) &result->h_addr_list[2]; ACE_OS::memcpy (result->h_addr_list[0], hp->h_addr_list[0], hp->h_length); // Null-terminate the list of addresses. result->h_addr_list[1] = 0; // And no aliases, so null-terminate h_aliases. result->h_aliases = &result->h_addr_list[1]; if (((2*sizeof(char*))+hp->h_length+ACE_OS::strlen (hp->h_name)+1) <= sizeof (ACE_HOSTENT_DATA)) { result->h_name = (char *) result->h_addr_list[0] + hp->h_length; ACE_OS::strcpy (result->h_name, hp->h_name); } else { result->h_name = (char *)0; } // free hostent memory ::hostentFree (hp); return result; } else { return (struct hostent *) 0; } # else # if defined(ACE_LACKS_NETDB_REENTRANT_FUNCTIONS) ACE_UNUSED_ARG (result); ACE_UNUSED_ARG (h_errnop); //FUZZ: disable check_for_lack_ACE_OS ACE_NETDBCALL_RETURN (::gethostbyaddr (addr, (ACE_SOCKET_LEN) length, type), struct hostent *, 0, buffer, sizeof (ACE_HOSTENT_DATA)); //FUZZ: enable check_for_lack_ACE_OS # else //FUZZ: disable check_for_lack_ACE_OS ACE_SOCKCALL_RETURN (::gethostbyaddr_r (addr, length, type, result, buffer, sizeof (ACE_HOSTENT_DATA), h_errnop), struct hostent *, 0); //FUZZ: enable check_for_lack_ACE_OS # endif /* ACE_LACKS_NETDB_REENTRANT_FUNCTIONS */ # endif /* defined (AIX) || defined (DIGITAL_UNIX) */ # elif defined (ACE_HAS_NONCONST_GETBY) ACE_UNUSED_ARG (result); ACE_UNUSED_ARG (buffer); ACE_UNUSED_ARG (h_errnop); //FUZZ: disable check_for_lack_ACE_OS ACE_SOCKCALL_RETURN (::gethostbyaddr (const_cast<char *> (addr), (ACE_SOCKET_LEN) length, type), struct hostent *, 0); //FUZZ: enable check_for_lack_ACE_OS # else ACE_UNUSED_ARG (h_errnop); ACE_UNUSED_ARG (buffer); ACE_UNUSED_ARG (result); //FUZZ: disable check_for_lack_ACE_OS ACE_SOCKCALL_RETURN (::gethostbyaddr (addr, (ACE_SOCKET_LEN) length, type), struct hostent *, 0); //FUZZ: enable check_for_lack_ACE_OS # endif /* ACE_LACKS_GETHOSTBYADDR_R */ }
struct hostent * ACE_OS::gethostbyname | ( | const char * | name | ) | [read] |
Definition at line 241 of file OS_NS_netdb.inl.
{ ACE_OS_TRACE ("ACE_OS::gethostbyname"); # if defined (ACE_LACKS_GETHOSTBYNAME) ACE_UNUSED_ARG (name); ACE_NOTSUP_RETURN (0); # else if (0 == name || '\0' == name[0]) return 0; # if defined (ACE_VXWORKS) // VxWorks 6.x has a gethostbyname() that is threadsafe and // returns an heap-allocated hostentry structure. // just call ACE_OS::gethostbyname_r () which knows how to handle this. struct hostent hentry; ACE_HOSTENT_DATA buf; int h_error; // Not the same as errno! return ACE_OS::gethostbyname_r (name, &hentry, buf, &h_error); # elif defined (ACE_HAS_NONCONST_GETBY) //FUZZ: disable check_for_lack_ACE_OS ACE_SOCKCALL_RETURN (::gethostbyname (const_cast<char *> (name)), struct hostent *, 0); //FUZZ: enable check_for_lack_ACE_OS # else //FUZZ: disable check_for_lack_ACE_OS ACE_SOCKCALL_RETURN (::gethostbyname (name), struct hostent *, 0); //FUZZ: enable check_for_lack_ACE_OS # endif /* ACE_HAS_NONCONST_GETBY */ # endif /* !ACE_LACKS_GETHOSTBYNAME */ }
struct hostent * ACE_OS::gethostbyname_r | ( | const char * | name, | |
struct hostent * | result, | |||
ACE_HOSTENT_DATA | buffer, | |||
int * | h_errnop | |||
) | [read] |
Definition at line 281 of file OS_NS_netdb.inl.
{ ACE_OS_TRACE ("ACE_OS::gethostbyname_r"); #if defined (ACE_LACKS_GETHOSTBYNAME) ACE_UNUSED_ARG (name); ACE_UNUSED_ARG (result); ACE_UNUSED_ARG (buffer); ACE_UNUSED_ARG (h_errnop); ACE_NOTSUP_RETURN (0); # elif defined (ACE_HAS_REENTRANT_FUNCTIONS) && !defined (UNIXWARE) if (0 == name || '\0' == name[0]) return (struct hostent *)0; # if defined (DIGITAL_UNIX) || \ (defined (ACE_AIX_MINOR_VERS) && (ACE_AIX_MINOR_VERS > 2)) ACE_UNUSED_ARG (result); ACE_UNUSED_ARG (buffer); ACE_UNUSED_ARG (h_errnop); // gethostbyname returns thread-specific storage on Digital Unix and // AIX 4.3 //FUZZ: disable check_for_lack_ACE_OS ACE_SOCKCALL_RETURN (::gethostbyname (name), struct hostent *, 0); //FUZZ: enable check_for_lack_ACE_OS # elif defined (AIX) ACE_OS::memset (buffer, 0, sizeof (ACE_HOSTENT_DATA)); //FUZZ: disable check_for_lack_ACE_OS if (::gethostbyname_r (name, result, (struct hostent_data *) buffer) == 0) return result; //FUZZ: enable check_for_lack_ACE_OS else { *h_errnop = h_errno; return (struct hostent *) 0; } # elif defined (__GLIBC__) // GNU C library has a different signature ACE_OS::memset (buffer, 0, sizeof (ACE_HOSTENT_DATA)); //FUZZ: disable check_for_lack_ACE_OS if (::gethostbyname_r (name, result, buffer, sizeof (ACE_HOSTENT_DATA), &result, h_errnop) == 0) return result; //FUZZ: enable check_for_lack_ACE_OS else return (struct hostent *) 0; # elif defined (ACE_VXWORKS) // VxWorks 6.x has a threadsafe gethostbyname() which returns a heap-allocated // data structure which needs to be freed with hostentFree() //FUZZ: disable check_for_lack_ACE_OS struct hostent* hp = ::gethostbyname (name); //FUZZ: enable check_for_lack_ACE_OS if (hp) { result->h_addrtype = hp->h_addrtype; result->h_length = hp->h_length; // buffer layout: // buffer[0-3]: h_addr_list[0], pointer to the addr. // buffer[4-7]: h_addr_list[1], null terminator for the h_addr_list. // buffer[8...]: the first (and only) addr. // Store the address list in buffer. result->h_addr_list = (char **) buffer; // Store the actual address _after_ the address list. result->h_addr_list[0] = (char *) &result->h_addr_list[2]; ACE_OS::memcpy (result->h_addr_list[0], hp->h_addr_list[0], hp->h_length); // Null-terminate the list of addresses. result->h_addr_list[1] = 0; // And no aliases, so null-terminate h_aliases. result->h_aliases = &result->h_addr_list[1]; if (((2*sizeof(char*))+hp->h_length+ACE_OS::strlen (hp->h_name)+1) <= sizeof (ACE_HOSTENT_DATA)) { result->h_name = (char *) result->h_addr_list[0] + hp->h_length; ACE_OS::strcpy (result->h_name, hp->h_name); } else { result->h_name = (char *)0; } // free hostent memory ::hostentFree (hp); return result; } else { return (struct hostent *) 0; } # else # if defined(ACE_LACKS_NETDB_REENTRANT_FUNCTIONS) ACE_UNUSED_ARG (result); ACE_UNUSED_ARG (h_errnop); //FUZZ: disable check_for_lack_ACE_OS ACE_NETDBCALL_RETURN (::gethostbyname (name), struct hostent *, 0, buffer, sizeof (ACE_HOSTENT_DATA)); //FUZZ: enable check_for_lack_ACE_OS # else //FUZZ: disable check_for_lack_ACE_OS ACE_SOCKCALL_RETURN (::gethostbyname_r (name, result, buffer, sizeof (ACE_HOSTENT_DATA), h_errnop), struct hostent *, 0); //FUZZ: enable check_for_lack_ACE_OS # endif /* ACE_LACKS_NETDB_REENTRANT_FUNCTIONS */ # endif /* defined (AIX) || defined (DIGITAL_UNIX) */ # elif defined (ACE_HAS_NONCONST_GETBY) ACE_UNUSED_ARG (result); ACE_UNUSED_ARG (buffer); ACE_UNUSED_ARG (h_errnop); //FUZZ: disable check_for_lack_ACE_OS ACE_SOCKCALL_RETURN (::gethostbyname (const_cast<char *> (name)), struct hostent *, 0); //FUZZ: enable check_for_lack_ACE_OS # else ACE_UNUSED_ARG (result); ACE_UNUSED_ARG (buffer); // FUZZ: disable check_for_lack_ACE_OS struct hostent *result2 = 0; ACE_SOCKCALL (::gethostbyname (name), struct hostent *, 0, result2); if (result2 == 0 && h_errnop) *h_errnop = errno; return result2; //FUZZ: enable check_for_lack_ACE_OS # endif /* defined (ACE_HAS_REENTRANT_FUNCTIONS) && !defined (UNIXWARE) */ }
ACE_hrtime_t ACE_OS::gethrtime | ( | const ACE_HRTimer_Op | op = ACE_HRTIMER_GETTIME |
) | [inline] |
strptime wrapper. Note that the struct tm will always be set to zero
Definition at line 223 of file OS_NS_time.inl.
{ ACE_OS_TRACE ("ACE_OS::gethrtime"); #if defined (ACE_HAS_HI_RES_TIMER) ACE_UNUSED_ARG (op); return ::gethrtime (); #elif defined (ACE_HAS_AIX_HI_RES_TIMER) ACE_UNUSED_ARG (op); timebasestruct_t tb; ::read_real_time(&tb, TIMEBASE_SZ); ::time_base_to_time(&tb, TIMEBASE_SZ); return ACE_hrtime_t(tb.tb_high) * ACE_ONE_SECOND_IN_NSECS + tb.tb_low; #elif defined (ACE_WIN32) ACE_UNUSED_ARG(op); LARGE_INTEGER freq; ::QueryPerformanceCounter (&freq); # if defined (ACE_LACKS_LONGLONG_T) ACE_UINT64 uint64_freq (freq.u.LowPart, static_cast<unsigned int> (freq.u.HighPart)); return uint64_freq; # else return freq.QuadPart; # endif //ACE_LACKS_LONGLONG_T #elif defined (ghs) && defined (ACE_HAS_PENTIUM) ACE_UNUSED_ARG (op); // Use .obj/gethrtime.o, which was compiled with g++. return ACE_GETHRTIME_NAME (); #elif (defined (__GNUG__) || defined (__INTEL_COMPILER)) && !defined(ACE_VXWORKS) && defined (ACE_HAS_PENTIUM) ACE_UNUSED_ARG (op); # if defined (ACE_LACKS_LONGLONG_T) double now; # else /* ! ACE_LACKS_LONGLONG_T */ ACE_hrtime_t now; # endif /* ! ACE_LACKS_LONGLONG_T */ #if defined (__amd64__) || defined (__x86_64__) // Read the high res tick counter into 32 bit int variables "eax" and // "edx", and then combine them into 64 bit int "now" ACE_UINT32 eax, edx; asm volatile ("rdtsc" : "=a" (eax), "=d" (edx) : : "memory"); now = (((ACE_UINT64) eax) | (((ACE_UINT64) edx) << 32)); #else // Read the high-res tick counter directly into memory variable "now". // The A constraint signifies a 64-bit int. asm volatile ("rdtsc" : "=A" (now) : : "memory"); #endif # if defined (ACE_LACKS_LONGLONG_T) ACE_UINT32 least, most; ACE_OS::memcpy (&least, &now, sizeof (ACE_UINT32)); ACE_OS::memcpy (&most, (u_char *) &now + sizeof (ACE_UINT32), sizeof (ACE_UINT32)); ACE_hrtime_t ret (least, most); return ret; # else /* ! ACE_LACKS_LONGLONG_T */ return now; # endif /* ! ACE_LACKS_LONGLONG_T */ #elif defined (linux) && defined (ACE_HAS_ALPHA_TIMER) // NOTE: alphas only have a 32 bit tick (cycle) counter. The rpcc // instruction actually reads 64 bits, but the high 32 bits are // implementation-specific. Linux and Digital Unix, for example, // use them for virtual tick counts, i.e., taking into account only // the time that the process was running. This information is from // David Mosberger's article, see comment below. ACE_UINT32 now; // The following statement is based on code published by: // Mosberger, David, "How to Make Your Applications Fly, Part 1", // Linux Journal Issue 42, October 1997, page 50. It reads the // high-res tick counter directly into the memory variable. asm volatile ("rpcc %0" : "=r" (now) : : "memory"); return now; #elif defined (ACE_HAS_POWERPC_TIMER) && (defined (ghs) || defined (__GNUG__)) // PowerPC w/ GreenHills or g++. ACE_UNUSED_ARG (op); u_long most; u_long least; #if defined (ghs) ACE_OS::readPPCTimeBase (most, least); #else u_long scratch; do { asm volatile ("mftbu %0\n" "mftb %1\n" "mftbu %2" : "=r" (most), "=r" (least), "=r" (scratch)); } while (most != scratch); #endif #if defined (ACE_LACKS_LONGLONG_T) return ACE_U_LongLong (least, most); #else /* ! ACE_LACKS_LONGLONG_T */ return 0x100000000llu * most + least; #endif /* ! ACE_LACKS_LONGLONG_T */ #elif defined (ACE_HAS_CLOCK_GETTIME) // e.g., VxWorks (besides POWERPC && GreenHills) . . . ACE_UNUSED_ARG (op); struct timespec ts; ACE_OS::clock_gettime ( #if defined (ACE_HAS_CLOCK_GETTIME_MONOTONIC) CLOCK_MONOTONIC, #else CLOCK_REALTIME, #endif /* !ACE_HAS_CLOCK_GETTIME_MONOTONIC */ &ts); // Carefully create the return value to avoid arithmetic overflow // if ACE_hrtime_t is ACE_U_LongLong. return static_cast<ACE_hrtime_t> (ts.tv_sec) * ACE_U_ONE_SECOND_IN_NSECS + static_cast<ACE_hrtime_t> (ts.tv_nsec); #else ACE_UNUSED_ARG (op); ACE_Time_Value const now = ACE_OS::gettimeofday (); // Carefully create the return value to avoid arithmetic overflow // if ACE_hrtime_t is ACE_U_LongLong. return (static_cast<ACE_hrtime_t> (now.sec ()) * (ACE_UINT32) 1000000 + static_cast<ACE_hrtime_t> (now.usec ())) * (ACE_UINT32) 1000; #endif /* ACE_HAS_HI_RES_TIMER */ }
struct hostent * ACE_OS::getipnodebyaddr | ( | const void * | src, | |
size_t | len, | |||
int | family | |||
) | [read] |
Definition at line 430 of file OS_NS_netdb.inl.
{ #if defined (ACE_HAS_IPV6) && !defined (ACE_WIN32) # if defined (ACE_LACKS_GETIPNODEBYADDR) ACE_UNUSED_ARG (src); ACE_UNUSED_ARG (len); ACE_UNUSED_ARG (family); ACE_NOTSUP_RETURN (0); # else struct hostent *hptr = 0; int errnum; //FUZZ: disable check_for_lack_ACE_OS if ((hptr = ::getipnodebyaddr (src, len, family, &errnum)) == 0) { errno = errnum; } //FUZZ: enable check_for_lack_ACE_OS return hptr; # endif /* ACE_LACKS_GETIPNODEBYADDR */ #else // IPv4-only implementation if (family == AF_INET) return ACE_OS::gethostbyaddr (static_cast<const char *> (src), static_cast<int> (len), family); ACE_NOTSUP_RETURN (0); # endif /* defined (ACE_HAS_IPV6) && !defined (ACE_WIN32) */ }
struct hostent * ACE_OS::getipnodebyname | ( | const char * | name, | |
int | family, | |||
int | flags = 0 | |||
) | [read] |
Definition at line 461 of file OS_NS_netdb.inl.
{ ACE_OS_TRACE ("ACE_OS::getipnodebyname"); # if defined (ACE_HAS_IPV6) && !defined (ACE_LACKS_GETIPNODEBYNAME_IPV6) # if defined (ACE_LACKS_GETIPNODEBYNAME) ACE_UNUSED_ARG (flags); # if defined (ACE_HAS_NONCONST_GETBY) ACE_SOCKCALL_RETURN (::gethostbyname2 (const_cast<char *> (name), family), struct hostent *, 0); # else ACE_SOCKCALL_RETURN (::gethostbyname2 (name, family), struct hostent *, 0); # endif /* ACE_HAS_NONCONST_GETBY */ # else struct hostent *hptr = 0; int errnum; //FUZZ: disable check_for_lack_ACE_OS if ((hptr = ::getipnodebyname (name, family, flags, &errnum)) == 0) { errno = errnum; } //FUZZ: enable check_for_lack_ACE_OS return hptr; # endif /* ACE_LACKS_GETIPNODEBYNAME */ # else // IPv4-only implementation ACE_UNUSED_ARG (flags); if (family == AF_INET) return ACE_OS::gethostbyname (name); ACE_NOTSUP_RETURN (0); # endif /* defined (ACE_HAS_IPV6) && !ACE_LACKS_GETIPNODEBYNAME_IPV6 */ }
int ACE_OS::getmacaddress | ( | struct macaddr_node_t * | node | ) |
Definition at line 219 of file OS_NS_netdb.cpp.
{ ACE_OS_TRACE ("ACE_OS::getmacaddress"); #if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE) # if !defined (ACE_HAS_PHARLAP) /** Define a structure for use with the netbios routine */ struct ADAPTERSTAT { ADAPTER_STATUS adapt; NAME_BUFFER NameBuff [30]; }; NCB ncb; LANA_ENUM lenum; unsigned char result; ACE_OS::memset (&ncb, 0, sizeof(ncb)); ncb.ncb_command = NCBENUM; ncb.ncb_buffer = reinterpret_cast<unsigned char*> (&lenum); ncb.ncb_length = sizeof(lenum); result = Netbios (&ncb); for(int i = 0; i < lenum.length; i++) { ACE_OS::memset (&ncb, 0, sizeof(ncb)); ncb.ncb_command = NCBRESET; ncb.ncb_lana_num = lenum.lana [i]; /** Reset the netbios */ result = Netbios (&ncb); if (ncb.ncb_retcode != NRC_GOODRET) { return -1; } ADAPTERSTAT adapter; ACE_OS::memset (&ncb, 0, sizeof (ncb)); ACE_OS::strcpy (reinterpret_cast<char*> (ncb.ncb_callname), "*"); ncb.ncb_command = NCBASTAT; ncb.ncb_lana_num = lenum.lana[i]; ncb.ncb_buffer = reinterpret_cast<unsigned char*> (&adapter); ncb.ncb_length = sizeof (adapter); result = Netbios (&ncb); if (result == 0) { ACE_OS::memcpy (node->node, adapter.adapt.adapter_address, 6); return 0; } } return 0; # else # if defined (ACE_HAS_PHARLAP_RT) DEVHANDLE ip_dev = (DEVHANDLE)0; EK_TCPIPCFG *devp = 0; size_t i; ACE_TCHAR dev_name[16]; for (i = 0; i < 10; i++) { // Ethernet. ACE_OS::sprintf (dev_name, "ether%d", i); ip_dev = EtsTCPGetDeviceHandle (dev_name); if (ip_dev != 0) break; } if (ip_dev == 0) return -1; devp = EtsTCPGetDeviceCfg (ip_dev); if (devp == 0) return -1; ACE_OS::memcpy (node->node, &devp->EthernetAddress[0], 6); return 0; # else ACE_UNUSED_ARG (node); ACE_NOTSUP_RETURN (-1); # endif /* ACE_HAS_PHARLAP_RT */ # endif /* ACE_HAS_PHARLAP */ #elif defined (sun) /** obtain the local host name */ char hostname [MAXHOSTNAMELEN]; ACE_OS::hostname (hostname, sizeof (hostname)); /** Get the hostent to use with ioctl */ struct hostent *phost = ACE_OS::gethostbyname (hostname); if (phost == 0) return -1; ACE_HANDLE handle = ACE_OS::socket (PF_INET, SOCK_DGRAM, IPPROTO_UDP); if (handle == ACE_INVALID_HANDLE) return -1; char **paddrs = phost->h_addr_list; struct arpreq ar; struct sockaddr_in *psa = (struct sockaddr_in *)&(ar.arp_pa); ACE_OS::memset (&ar, 0, sizeof (struct arpreq)); psa->sin_family = AF_INET; ACE_OS::memcpy (&(psa->sin_addr), *paddrs, sizeof (struct in_addr)); if (ACE_OS::ioctl (handle, SIOCGARP, &ar) == -1) { ACE_OS::close (handle); return -1; } ACE_OS::close (handle); ACE_OS::memcpy (node->node, ar.arp_ha.sa_data, 6); return 0; #elif defined (linux) && !defined (ACE_LACKS_NETWORKING) struct ifreq ifr; ACE_HANDLE handle = ACE_OS::socket (PF_INET, SOCK_DGRAM, 0); if (handle == ACE_INVALID_HANDLE) return -1; ACE_OS::strcpy (ifr.ifr_name, "eth0"); if (ACE_OS::ioctl (handle/*s*/, SIOCGIFHWADDR, &ifr) < 0) { ACE_OS::close (handle); return -1; } struct sockaddr* sa = (struct sockaddr *) &ifr.ifr_addr; ACE_OS::close (handle); ACE_OS::memcpy (node->node, sa->sa_data, 6); return 0; #elif defined (ACE_HAS_IPHONE) || defined (ACE_HAS_MAC_OSX) const long BUFFERSIZE = 4000; char buffer[BUFFERSIZE]; struct ifconf ifc; struct ifreq* ifr = 0; ACE_HANDLE handle = ACE_OS::socket (AF_INET, SOCK_DGRAM, 0); if (handle == ACE_INVALID_HANDLE) { return -1; } ifc.ifc_len = BUFFERSIZE; ifc.ifc_buf = buffer; if (ACE_OS::ioctl (handle, SIOCGIFCONF, &ifc) < 0) { ACE_OS::close (handle); return -1; } for(char* ptr=buffer; ptr < buffer + ifc.ifc_len; ) { ifr = (struct ifreq *) ptr; if (ifr->ifr_addr.sa_family == AF_LINK) { if(ACE_OS::strcmp (ifr->ifr_name, "en0") == 0) { struct sockaddr_dl* sdl = (struct sockaddr_dl *) &ifr->ifr_addr; ACE_OS::memcpy (node->node, LLADDR(sdl), 6); } } ptr += sizeof(ifr->ifr_name); if(sizeof(ifr->ifr_addr) > ifr->ifr_addr.sa_len) ptr += sizeof(ifr->ifr_addr); else ptr += ifr->ifr_addr.sa_len; } ACE_OS::close (handle); return 0; #else ACE_UNUSED_ARG (node); ACE_NOTSUP_RETURN (-1); #endif }
int ACE_OS::getmsg | ( | ACE_HANDLE | handle, | |
struct strbuf * | ctl, | |||
struct strbuf * | data, | |||
int * | flags | |||
) | [inline] |
Definition at line 39 of file OS_NS_stropts.inl.
{ ACE_OS_TRACE ("ACE_OS::getmsg"); #if defined (ACE_HAS_STREAM_PIPES) ACE_OSCALL_RETURN (::getmsg (handle, ctl, data, flags), int, -1); #else ACE_UNUSED_ARG (handle); ACE_UNUSED_ARG (ctl); ACE_UNUSED_ARG (data); ACE_UNUSED_ARG (flags); // I'm not sure how to implement this correctly. ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_STREAM_PIPES */ }
int ACE_OS::getopt | ( | int | argc, | |
char *const * | argv, | |||
const char * | optstring | |||
) | [inline] |
Definition at line 461 of file OS_NS_unistd.inl.
{ ACE_OS_TRACE ("ACE_OS::getopt"); #if defined (ACE_LACKS_GETOPT) ACE_UNUSED_ARG (argc); ACE_UNUSED_ARG (argv); ACE_UNUSED_ARG (optstring); ACE_NOTSUP_RETURN (-1); # else ACE_OSCALL_RETURN (::getopt (argc, argv, optstring), int, -1); # endif /* ACE_LACKS_GETOPT */ }
long ACE_OS::getpagesize | ( | void | ) | [inline] |
Definition at line 92 of file OS_NS_unistd.inl.
{ ACE_OS_TRACE ("ACE_OS::getpagesize"); #if defined (ACE_WIN32) && !defined (ACE_HAS_PHARLAP) SYSTEM_INFO sys_info; ::GetSystemInfo (&sys_info); return (long) sys_info.dwPageSize; #elif defined (_SC_PAGESIZE) && !defined (ACE_HAS_NOTSUP_SC_PAGESIZE) return ::sysconf (_SC_PAGESIZE); #elif defined (ACE_HAS_GETPAGESIZE) return ::getpagesize (); #else // Use the default set in config.h return ACE_PAGE_SIZE; #endif /* ACE_WIN32 */ }
int ACE_OS::getpeername | ( | ACE_HANDLE | handle, | |
struct sockaddr * | addr, | |||
int * | addrlen | |||
) | [inline] |
BSD-style accept
(no QoS).
Definition at line 184 of file OS_NS_sys_socket.inl.
{ ACE_OS_TRACE ("ACE_OS::getpeername"); #if defined (ACE_LACKS_GETPEERNAME) ACE_UNUSED_ARG (handle); ACE_UNUSED_ARG (addr); ACE_UNUSED_ARG (addrlen); ACE_NOTSUP_RETURN (-1); #elif defined (ACE_GETNAME_RETURNS_RANDOM_SIN_ZERO) \ && (ACE_GETNAME_RETURNS_RANDOM_SIN_ZERO == 1) int result; ACE_SOCKCALL (::getpeername ((ACE_SOCKET) handle, addr, (ACE_SOCKET_LEN *) addrlen), int, -1, result); // Some platforms, like older versions of the Linux kernel, do not // initialize the sin_zero field since that field is generally only // used for padding/alignment purposes. On those platforms // memcmp()-based comparisons of the sockaddr_in structure, such as // the one in the ACE_INET_Addr equality operator, may fail due to // random bytes in the sin_zero field even though that field is // unused. Prevent equality comparison of two different sockaddr_in // instances that refer to the same socket from failing by // explicitly initializing the sockaddr_in::sin_zero field to a // consistent value, e.g. zero. if (result != -1 && addr->sa_family == AF_INET) { ACE_OS::memset (reinterpret_cast<struct sockaddr_in *> (addr)->sin_zero, 0, sizeof (reinterpret_cast<struct sockaddr_in *> (addr)->sin_zero)); } return result; #else ACE_SOCKCALL_RETURN (::getpeername ((ACE_SOCKET) handle, addr, (ACE_SOCKET_LEN *) addrlen), int, -1); #endif /* ACE_GETNAME_RETURNS_RANDOM_SIN_ZERO */ }
pid_t ACE_OS::getpgid | ( | pid_t | pid | ) | [inline] |
Definition at line 475 of file OS_NS_unistd.inl.
{ ACE_OS_TRACE ("ACE_OS::getpgid"); #if defined (ACE_LACKS_GETPGID) ACE_UNUSED_ARG (pid); ACE_NOTSUP_RETURN (-1); #elif defined (linux) && __GLIBC__ > 1 && __GLIBC_MINOR__ >= 0 // getpgid() is from SVR4, which appears to be the reason why GLIBC // doesn't enable its prototype by default. // Rather than create our own extern prototype, just use the one // that is visible (ugh). ACE_OSCALL_RETURN (::__getpgid (pid), pid_t, -1); #else ACE_OSCALL_RETURN (::getpgid (pid), pid_t, -1); #endif /* ACE_LACKS_GETPGID */ }
pid_t ACE_OS::getpid | ( | void | ) | [inline] |
Definition at line 493 of file OS_NS_unistd.inl.
{ // ACE_OS_TRACE ("ACE_OS::getpid"); #if defined (ACE_LACKS_GETPID) ACE_NOTSUP_RETURN (-1); #elif defined (ACE_WIN32) return ::GetCurrentProcessId (); #else ACE_OSCALL_RETURN (::getpid (), int, -1); #endif /* ACE_LACKS_GETPID */ }
int ACE_OS::getpmsg | ( | ACE_HANDLE | handle, | |
struct strbuf * | ctl, | |||
struct strbuf * | data, | |||
int * | band, | |||
int * | flags | |||
) | [inline] |
Definition at line 59 of file OS_NS_stropts.inl.
{ ACE_OS_TRACE ("ACE_OS::getpmsg"); #if defined (ACE_HAS_STREAM_PIPES) ACE_OSCALL_RETURN (::getpmsg (handle, ctl, data, band, flags), int, -1); #else ACE_UNUSED_ARG (handle); ACE_UNUSED_ARG (ctl); ACE_UNUSED_ARG (data); ACE_UNUSED_ARG (band); ACE_UNUSED_ARG (flags); // I'm not sure how to implement this correctly. ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_STREAM_PIPES */ }
pid_t ACE_OS::getppid | ( | void | ) | [inline] |
Definition at line 506 of file OS_NS_unistd.inl.
{ ACE_OS_TRACE ("ACE_OS::getppid"); #if defined (ACE_LACKS_GETPPID) ACE_NOTSUP_RETURN (-1); #else ACE_OSCALL_RETURN (::getppid (), pid_t, -1); #endif /* ACE_LACKS_GETPPID */ }
const char * ACE_OS::getprogname | ( | ) | [inline] |
Get the name of the current program
Originally from NetBSD, now found in *BSD, Cygwin, Darwin, etc.
Definition at line 625 of file OS_NS_stdlib.inl.
{ #if defined (ACE_HAS_GETPROGNAME) return ::getprogname (); #else return ACE_OS::getprogname_emulation (); #endif /* ACE_HAS_GETPROGNAME */ }
const char * ACE_OS::getprogname_emulation | ( | ) |
Function that is called by <ACE_OS::exit>, if non-null.
Definition at line 1193 of file OS_NS_stdlib.cpp.
{ return __progname; }
struct protoent * ACE_OS::getprotobyname | ( | const char * | name | ) | [read] |
Definition at line 497 of file OS_NS_netdb.inl.
{ #if defined (ACE_LACKS_GETPROTOBYNAME) ACE_UNUSED_ARG (name); ACE_NOTSUP_RETURN (0); #elif defined (ACE_HAS_NONCONST_GETBY) //FUZZ: disable check_for_lack_ACE_OS ACE_SOCKCALL_RETURN (::getprotobyname (const_cast<char *> (name)), struct protoent *, 0); //FUZZ: enable check_for_lack_ACE_OS #else //FUZZ: disable check_for_lack_ACE_OS ACE_SOCKCALL_RETURN (::getprotobyname (name), struct protoent *, 0); //FUZZ: enable check_for_lack_ACE_OS #endif /* ACE_LACKS_GETPROTOBYNAME */ }
struct protoent * ACE_OS::getprotobyname_r | ( | const char * | name, | |
struct protoent * | result, | |||
ACE_PROTOENT_DATA | buffer | |||
) | [read] |
Definition at line 518 of file OS_NS_netdb.inl.
{ #if defined (ACE_LACKS_GETPROTOBYNAME) ACE_UNUSED_ARG (name); ACE_UNUSED_ARG (result); ACE_UNUSED_ARG (buffer); ACE_NOTSUP_RETURN (0); #elif defined (ACE_HAS_REENTRANT_FUNCTIONS) && !defined (UNIXWARE) # if defined (AIX) || defined (DIGITAL_UNIX) //FUZZ: disable check_for_lack_ACE_OS if (::getprotobyname_r (name, result, (struct protoent_data *) buffer) == 0) return result; else return 0; //FUZZ: enable check_for_lack_ACE_OS # elif defined (__GLIBC__) // GNU C library has a different signature //FUZZ: disable check_for_lack_ACE_OS if (::getprotobyname_r (name, result, buffer, sizeof (ACE_PROTOENT_DATA), &result) == 0) //FUZZ: enable check_for_lack_ACE_OS return result; else return 0; # else # if defined(ACE_LACKS_NETDB_REENTRANT_FUNCTIONS) ACE_UNUSED_ARG (result); //FUZZ: disable check_for_lack_ACE_OS ACE_NETDBCALL_RETURN (::getprotobyname (name), struct protoent *, 0, buffer, sizeof (ACE_PROTOENT_DATA)); //FUZZ: enable check_for_lack_ACE_OS # else //FUZZ: disable check_for_lack_ACE_OS ACE_SOCKCALL_RETURN (::getprotobyname_r (name, result, buffer, sizeof (ACE_PROTOENT_DATA)), struct protoent *, 0); //FUZZ: enable check_for_lack_ACE_OS # endif /* ACE_LACKS_NETDB_REENTRANT_FUNCTIONS */ # endif /* defined (AIX) || defined (DIGITAL_UNIX) */ #elif defined (ACE_HAS_NONCONST_GETBY) ACE_UNUSED_ARG (result); ACE_UNUSED_ARG (buffer); //FUZZ: disable check_for_lack_ACE_OS ACE_SOCKCALL_RETURN (::getprotobyname (const_cast<char *> (name)), struct protoent *, 0); //FUZZ: enable check_for_lack_ACE_OS #else ACE_UNUSED_ARG (buffer); ACE_UNUSED_ARG (result); //FUZZ: disable check_for_lack_ACE_OS ACE_SOCKCALL_RETURN (::getprotobyname (name), struct protoent *, 0); //FUZZ: enable check_for_lack_ACE_OS #endif /* defined (ACE_HAS_REENTRANT_FUNCTIONS) !defined (UNIXWARE) */ }
struct protoent * ACE_OS::getprotobynumber | ( | int | proto | ) | [read] |
Definition at line 585 of file OS_NS_netdb.inl.
{ #if defined (ACE_LACKS_GETPROTOBYNUMBER) ACE_UNUSED_ARG (proto); ACE_NOTSUP_RETURN (0); #else //FUZZ: disable check_for_lack_ACE_OS ACE_SOCKCALL_RETURN (::getprotobynumber (proto), struct protoent *, 0); //FUZZ: enable check_for_lack_ACE_OS #endif /* ACE_LACKS_GETPROTOBYNUMBER */ }
struct protoent * ACE_OS::getprotobynumber_r | ( | int | proto, | |
struct protoent * | result, | |||
ACE_PROTOENT_DATA | buffer | |||
) | [read] |
Definition at line 599 of file OS_NS_netdb.inl.
{ #if defined (ACE_LACKS_GETPROTOBYNUMBER) ACE_UNUSED_ARG (proto); ACE_UNUSED_ARG (result); ACE_UNUSED_ARG (buffer); ACE_NOTSUP_RETURN (0); #elif defined (ACE_HAS_REENTRANT_FUNCTIONS) && !defined (UNIXWARE) # if defined (AIX) || defined (DIGITAL_UNIX) //FUZZ: disable check_for_lack_ACE_OS if (::getprotobynumber_r (proto, result, (struct protoent_data *) buffer) == 0) return result; //FUZZ: enable check_for_lack_ACE_OS else return 0; # elif defined (__GLIBC__) // GNU C library has a different signature //FUZZ: disable check_for_lack_ACE_OS if (::getprotobynumber_r (proto, result, buffer, sizeof (ACE_PROTOENT_DATA), &result) == 0) //FUZZ: enable check_for_lack_ACE_OS return result; else return 0; # else # if defined(ACE_LACKS_NETDB_REENTRANT_FUNCTIONS) ACE_UNUSED_ARG (result); //FUZZ: disable check_for_lack_ACE_OS ACE_NETDBCALL_RETURN (::getprotobynumber (proto), struct protoent *, 0, buffer, sizeof (ACE_PROTOENT_DATA)); //FUZZ: enable check_for_lack_ACE_OS # else //FUZZ: disable check_for_lack_ACE_OS ACE_SOCKCALL_RETURN (::getprotobynumber_r (proto, result, buffer, sizeof (ACE_PROTOENT_DATA)), struct protoent *, 0); //FUZZ: enable check_for_lack_ACE_OS # endif /* ACE_LACKS_NETDB_REENTRANT_FUNCTIONS */ # endif /* defined (AIX) || defined (DIGITAL_UNIX) */ #else ACE_UNUSED_ARG (buffer); ACE_UNUSED_ARG (result); //FUZZ: disable check_for_lack_ACE_OS ACE_SOCKCALL_RETURN (::getprotobynumber (proto), struct protoent *, 0); //FUZZ: enable check_for_lack_ACE_OS #endif /* defined (ACE_HAS_REENTRANT_FUNCTIONS) && !defined (UNIXWARE) */ }
struct passwd * ACE_OS::getpwent | ( | void | ) | [read] |
Definition at line 20 of file OS_NS_pwd.inl.
{ #if !defined (ACE_LACKS_PWD_FUNCTIONS) return ::getpwent (); #else ACE_NOTSUP_RETURN (0); #endif /* ! ACE_LACKS_PWD_FUNCTIONS */ }
struct passwd * ACE_OS::getpwnam | ( | const char * | user | ) | [read] |
Definition at line 30 of file OS_NS_pwd.inl.
{ #if !defined (ACE_LACKS_PWD_FUNCTIONS) return ::getpwnam (name); # else ACE_UNUSED_ARG (name); ACE_NOTSUP_RETURN (0); #endif /* ACE_LACKS_PWD_FUNCTIONS */ }
struct passwd * ACE_OS::getpwnam_r | ( | const char * | name, | |
struct passwd * | pwent, | |||
char * | buffer, | |||
int | buflen | |||
) | [read] |
Definition at line 41 of file OS_NS_pwd.inl.
{ #if defined (ACE_HAS_POSIX_GETPWNAM_R) struct passwd *result = 0; int const status = ::getpwnam_r (name, pwent, buffer, buflen, &result); if (status != 0) { errno = status; result = 0; } return result; #elif !defined (ACE_LACKS_PWD_FUNCTIONS) # if defined (ACE_HAS_REENTRANT_FUNCTIONS) # if !defined (ACE_LACKS_PWD_REENTRANT_FUNCTIONS) # if defined (ACE_HAS_PTHREADS) && \ !defined (ACE_HAS_STHREADS) || \ defined (HPUX_11) || \ defined (__USLC__) // Added by Roland Gigler for SCO UnixWare 7. struct passwd *result; int status; # if defined (DIGITAL_UNIX) ::_Pgetpwnam_r (name, pwent, buffer, buflen, &result); # else // VAC++ doesn't correctly grok the ::getpwnam_r - the function is redefined // in pwd.h, and that redefinition is used here # if defined (__IBMCPP__) && (__IBMCPP__ >= 400) /* VAC++ 4 */ status = _posix_getpwnam_r (name, pwent, buffer, buflen, &result); # else status = ::getpwnam_r (name, pwent, buffer, buflen, &result); # endif /* __IBMCPP__ && (__IBMCPP__ >= 400) */ if (status != 0) { errno = status; result = 0; } # endif /* (DIGITAL_UNIX) */ return result; # elif defined (AIX) if (::getpwnam_r (name, pwent, buffer, buflen) == -1) return 0; else return pwent; # else return ::getpwnam_r (name, pwent, buffer, buflen); # endif /* ACE_HAS_PTHREADS */ # else ACE_UNUSED_ARG (name); ACE_UNUSED_ARG (pwent); ACE_UNUSED_ARG (buffer); ACE_UNUSED_ARG (buflen); ACE_NOTSUP_RETURN (0); # endif /* ! ACE_LACKS_PWD_REENTRANT_FUNCTIONS */ # else ACE_UNUSED_ARG (name); ACE_UNUSED_ARG (pwent); ACE_UNUSED_ARG (buffer); ACE_UNUSED_ARG (buflen); ACE_NOTSUP_RETURN (0); # endif /* ACE_HAS_REENTRANT_FUNCTIONS */ #else ACE_UNUSED_ARG (name); ACE_UNUSED_ARG (pwent); ACE_UNUSED_ARG (buffer); ACE_UNUSED_ARG (buflen); ACE_NOTSUP_RETURN (0); #endif /* ACE_HAS_POSIX_GETPWNAM_R */ }
int ACE_OS::getrlimit | ( | int | resource, | |
struct rlimit * | rl | |||
) | [inline] |
Definition at line 11 of file OS_NS_sys_resource.inl.
{ ACE_OS_TRACE ("ACE_OS::getrlimit"); #if defined (ACE_LACKS_RLIMIT) ACE_UNUSED_ARG (resource); ACE_UNUSED_ARG (rl); ACE_NOTSUP_RETURN (-1); #else # if defined (ACE_HAS_RLIMIT_RESOURCE_ENUM) ACE_OSCALL_RETURN (::getrlimit ((ACE_HAS_RLIMIT_RESOURCE_ENUM) resource, rl), int, -1); # else ACE_OSCALL_RETURN (::getrlimit (resource, rl), int, -1); # endif /* ACE_HAS_RLIMIT_RESOURCE_ENUM */ #endif /* ACE_LACKS_RLIMIT */ }
int ACE_OS::getrusage | ( | int | who, | |
struct rusage * | rusage | |||
) | [inline] |
Definition at line 30 of file OS_NS_sys_resource.inl.
{ ACE_OS_TRACE ("ACE_OS::getrusage"); #if defined (ACE_HAS_GETRUSAGE) # if defined (ACE_WIN32) ACE_UNUSED_ARG (who); # if defined (ACE_LACKS_GETPROCESSTIMES) ACE_UNUSED_ARG (ru); ACE_NOTSUP_RETURN (-1); # else FILETIME dummy_1; FILETIME dummy_2; ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::GetProcessTimes (::GetCurrentProcess(), &dummy_1, // start &dummy_2, // exited &ru->ru_stime, &ru->ru_utime), ace_result_), int, -1); # endif /* ACE_LACKS_WIN32_GETPROCESSTIMES */ # else # if defined (ACE_HAS_RUSAGE_WHO_ENUM) ACE_OSCALL_RETURN (::getrusage ((ACE_HAS_RUSAGE_WHO_ENUM) who, ru), int, -1); # else ACE_OSCALL_RETURN (::getrusage (who, ru), int, -1); # endif /* ACE_HAS_RUSAGE_WHO_ENUM */ # endif /* ACE_WIN32 */ #else ACE_UNUSED_ARG (who); ACE_UNUSED_ARG (ru); ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_GETRUSAGE */ }
struct servent * ACE_OS::getservbyname | ( | const char * | svc, | |
const char * | proto | |||
) | [read] |
Definition at line 655 of file OS_NS_netdb.inl.
{ ACE_OS_TRACE ("ACE_OS::getservbyname"); #if defined (ACE_LACKS_GETSERVBYNAME) ACE_UNUSED_ARG (svc); ACE_UNUSED_ARG (proto); ACE_NOTSUP_RETURN (0); #elif defined (ACE_HAS_NONCONST_GETBY) //FUZZ: disable check_for_lack_ACE_OS ACE_SOCKCALL_RETURN (::getservbyname (const_cast<char *> (svc), const_cast<char *> (proto)), struct servent *, 0); //FUZZ: enable check_for_lack_ACE_OS #else //FUZZ: disable check_for_lack_ACE_OS ACE_SOCKCALL_RETURN (::getservbyname (svc, proto), struct servent *, 0); //FUZZ: enable check_for_lack_ACE_OS #endif /* ACE_HAS_NONCONST_GETBY */ }
struct servent * ACE_OS::getservbyname_r | ( | const char * | svc, | |
const char * | proto, | |||
struct servent * | result, | |||
ACE_SERVENT_DATA | buf | |||
) | [read] |
Definition at line 680 of file OS_NS_netdb.inl.
{ ACE_OS_TRACE ("ACE_OS::getservbyname_r"); #if defined (ACE_LACKS_GETSERVBYNAME) ACE_UNUSED_ARG (svc); ACE_UNUSED_ARG (proto); ACE_UNUSED_ARG (result); ACE_UNUSED_ARG (buf); ACE_NOTSUP_RETURN (0); #elif defined (ACE_HAS_REENTRANT_FUNCTIONS) && !defined (UNIXWARE) # if defined (AIX) || defined (DIGITAL_UNIX) ACE_OS::memset (buf, 0, sizeof (ACE_SERVENT_DATA)); //FUZZ: disable check_for_lack_ACE_OS if (::getservbyname_r (svc, proto, result, (struct servent_data *) buf) == 0) return result; //FUZZ: enable check_for_lack_ACE_OS else return (struct servent *) 0; # elif defined (__GLIBC__) // GNU C library has a different signature ACE_OS::memset (buf, 0, sizeof (ACE_SERVENT_DATA)); //FUZZ: disable check_for_lack_ACE_OS if (::getservbyname_r (svc, proto, result, buf, sizeof (ACE_SERVENT_DATA), &result) == 0) return result; //FUZZ: enable check_for_lack_ACE_OS else return (struct servent *) 0; # else # if defined(ACE_LACKS_NETDB_REENTRANT_FUNCTIONS) ACE_UNUSED_ARG (result); //FUZZ: disable check_for_lack_ACE_OS ACE_NETDBCALL_RETURN (::getservbyname (svc, proto), struct servent *, 0, buf, sizeof (ACE_SERVENT_DATA)); //FUZZ: enable check_for_lack_ACE_OS # else //FUZZ: disable check_for_lack_ACE_OS ACE_SOCKCALL_RETURN (::getservbyname_r (svc, proto, result, buf, sizeof (ACE_SERVENT_DATA)), struct servent *, 0); //FUZZ: enable check_for_lack_ACE_OS # endif /* ACE_LACKS_NETDB_REENTRANT_FUNCTIONS */ # endif /* defined (AIX) || defined (DIGITAL_UNIX) */ #elif defined (ACE_HAS_NONCONST_GETBY) ACE_UNUSED_ARG (buf); ACE_UNUSED_ARG (result); //FUZZ: disable check_for_lack_ACE_OS ACE_SOCKCALL_RETURN (::getservbyname (const_cast<char *> (svc), const_cast<char *> (proto)), struct servent *, 0); //FUZZ: enable check_for_lack_ACE_OS #else ACE_UNUSED_ARG (buf); ACE_UNUSED_ARG (result); //FUZZ: disable check_for_lack_ACE_OS ACE_SOCKCALL_RETURN (::getservbyname (svc, proto), struct servent *, 0); //FUZZ: enable check_for_lack_ACE_OS #endif /* defined (ACE_HAS_REENTRANT_FUNCTIONS) && !defined (UNIXWARE) */ }
int ACE_OS::getsockname | ( | ACE_HANDLE | handle, | |
struct sockaddr * | addr, | |||
int * | addrlen | |||
) | [inline] |
BSD-style accept
(no QoS).
Definition at line 232 of file OS_NS_sys_socket.inl.
{ ACE_OS_TRACE ("ACE_OS::getsockname"); #if defined (ACE_LACKS_GETSOCKNAME) ACE_UNUSED_ARG (handle); ACE_UNUSED_ARG (addr); ACE_UNUSED_ARG (addrlen); ACE_NOTSUP_RETURN (-1); #elif defined (ACE_GETNAME_RETURNS_RANDOM_SIN_ZERO) \ && (ACE_GETNAME_RETURNS_RANDOM_SIN_ZERO == 1) int result; ACE_SOCKCALL (::getsockname ((ACE_SOCKET) handle, addr, (ACE_SOCKET_LEN *) addrlen), int, -1, result); // Some platforms, like older versions of the Linux kernel, do not // initialize the sin_zero field since that field is generally only // used for padding/alignment purposes. On those platforms // memcmp()-based comparisons of the sockaddr_in structure, such as // the one in the ACE_INET_Addr equality operator, may fail due to // random bytes in the sin_zero field even though that field is // unused. Prevent equality comparison of two different sockaddr_in // instances that refer to the same socket from failing by // explicitly initializing the sockaddr_in::sin_zero field to a // consistent value, e.g. zero. if (result != -1 && addr->sa_family == AF_INET) { ACE_OS::memset (reinterpret_cast<struct sockaddr_in *> (addr)->sin_zero, 0, sizeof (reinterpret_cast<struct sockaddr_in *> (addr)->sin_zero)); } return result; #else ACE_SOCKCALL_RETURN (::getsockname ((ACE_SOCKET) handle, addr, (ACE_SOCKET_LEN *) addrlen), int, -1); #endif /* ACE_GETNAME_RETURNS_RANDOM_SIN_ZERO */ }
int ACE_OS::getsockopt | ( | ACE_HANDLE | handle, | |
int | level, | |||
int | optname, | |||
char * | optval, | |||
int * | optlen | |||
) | [inline] |
BSD-style accept
(no QoS).
Definition at line 277 of file OS_NS_sys_socket.inl.
{ ACE_OS_TRACE ("ACE_OS::getsockopt"); #if defined (ACE_LACKS_GETSOCKOPT) ACE_UNUSED_ARG (handle); ACE_UNUSED_ARG (level); ACE_UNUSED_ARG (optname); ACE_UNUSED_ARG (optval); ACE_UNUSED_ARG (optlen); ACE_NOTSUP_RETURN (-1); #else ACE_SOCKCALL_RETURN (::getsockopt ((ACE_SOCKET) handle, level, optname, optval, (ACE_SOCKET_LEN *) optlen), int, -1); #endif /* ACE_LACKS_GETSOCKOPT */ }
ACE_Time_Value ACE_OS::gettimeofday | ( | void | ) | [inline] |
Definition at line 15 of file OS_NS_sys_time.inl.
{ // ACE_OS_TRACE ("ACE_OS::gettimeofday"); #if !defined (ACE_WIN32) timeval tv; int result = 0; #endif // !defined (ACE_WIN32) #if defined (ACE_HAS_CLOCK_GETTIME_REALTIME) struct timespec ts; ACE_OSCALL (ACE_OS::clock_gettime (CLOCK_REALTIME, &ts), int, -1, result); tv.tv_sec = ts.tv_sec; tv.tv_usec = ts.tv_nsec / 1000L; // timespec has nsec, but timeval has usec #elif defined (ACE_WIN32) && defined (ACE_LACKS_GETSYSTEMTIMEASFILETIME) SYSTEMTIME tsys; FILETIME tfile; ::GetSystemTime (&tsys); ::SystemTimeToFileTime (&tsys, &tfile); return ACE_Time_Value (tfile); #elif defined (ACE_WIN32) FILETIME tfile; ::GetSystemTimeAsFileTime (&tfile); return ACE_Time_Value (tfile); #elif defined (ACE_HAS_AIX_HI_RES_TIMER) timebasestruct_t tb; ::read_real_time (&tb, TIMEBASE_SZ); ::time_base_to_time (&tb, TIMEBASE_SZ); tv.tv_sec = tb.tb_high; tv.tv_usec = tb.tb_low / 1000L; #else # if defined (ACE_HAS_TIMEZONE_GETTIMEOFDAY) || \ defined(ACE_HAS_VOIDPTR_GETTIMEOFDAY) || \ (defined (ACE_HAS_SVR4_GETTIMEOFDAY) && !defined (SCO)) ACE_OSCALL (::gettimeofday (&tv, 0), int, -1, result); # elif defined (ACE_VXWORKS) // Assumes that struct timespec is same size as struct timeval, // which assumes that time_t is a long: it currently (VxWorks // 5.2/5.3) is. struct timespec ts; ACE_OSCALL (ACE_OS::clock_gettime (CLOCK_REALTIME, &ts), int, -1, result); tv.tv_sec = ts.tv_sec; tv.tv_usec = ts.tv_nsec / 1000L; // timespec has nsec, but timeval has usec # else ACE_OSCALL (::gettimeofday (&tv), int, -1, result); # endif /* ACE_HAS_SVR4_GETTIMEOFDAY */ #endif /* 0 */ #if !defined (ACE_WIN32) if (result == -1) return ACE_Time_Value ((time_t)-1); else return ACE_Time_Value (tv); #endif // !defined (ACE_WIN32) }
uid_t ACE_OS::getuid | ( | void | ) | [inline] |
Definition at line 517 of file OS_NS_unistd.inl.
{ ACE_OS_TRACE ("ACE_OS::getuid"); #if defined (ACE_LACKS_GETUID) ACE_NOTSUP_RETURN (static_cast<uid_t> (-1)); # else ACE_OSCALL_RETURN (::getuid (), uid_t, static_cast<uid_t> (-1)); # endif /* ACE_LACKS_GETUID*/ }
struct tm * ACE_OS::gmtime | ( | const time_t * | clock | ) | [read] |
strptime wrapper. Note that the struct tm will always be set to zero
Definition at line 356 of file OS_NS_time.inl.
{ ACE_OS_TRACE ("ACE_OS::gmtime"); #if defined (ACE_LACKS_GMTIME) ACE_UNUSED_ARG (t); ACE_NOTSUP_RETURN (0); #else ACE_OSCALL_RETURN (::gmtime (t), struct tm *, 0); #endif /* ACE_LACKS_GMTIME */ }
struct tm * ACE_OS::gmtime_r | ( | const time_t * | clock, | |
struct tm * | res | |||
) | [read] |
strptime wrapper. Note that the struct tm will always be set to zero
Definition at line 368 of file OS_NS_time.inl.
{ ACE_OS_TRACE ("ACE_OS::gmtime_r"); #if defined (ACE_HAS_REENTRANT_FUNCTIONS) # if defined (DIGITAL_UNIX) ACE_OSCALL_RETURN (::_Pgmtime_r (t, res), struct tm *, 0); # else ACE_OSCALL_RETURN (::gmtime_r (t, res), struct tm *, 0); # endif /* DIGITAL_UNIX */ #elif defined (ACE_HAS_TR24731_2005_CRT) struct tm *tm_p = res; ACE_SECURECRTCALL (gmtime_s (res, t), struct tm *, 0, tm_p); return tm_p; #elif defined (ACE_LACKS_GMTIME_R) ACE_UNUSED_ARG (t); ACE_UNUSED_ARG (res); ACE_NOTSUP_RETURN (0); #else struct tm *result; ACE_OSCALL (::gmtime (t), struct tm *, 0, result) ; if (result != 0) *res = *result; return res; #endif /* ACE_HAS_REENTRANT_FUNCTIONS */ }
int ACE_OS::hostname | ( | char | name[], | |
size_t | maxnamelen | |||
) | [inline] |
Definition at line 539 of file OS_NS_unistd.inl.
{ ACE_OS_TRACE ("ACE_OS::hostname"); #if defined (ACE_HAS_PHARLAP) // PharLap only can do net stuff with the RT version. # if defined (ACE_HAS_PHARLAP_RT) // @@This is not at all reliable... requires ethernet and BOOTP to be used. // A more reliable way is to go thru the devices w/ EtsTCPGetDeviceCfg until // a legit IP address is found, then get its name w/ gethostbyaddr. ACE_SOCKCALL_RETURN (gethostname (name, maxnamelen), int, SOCKET_ERROR); # else ACE_UNUSED_ARG (name); ACE_UNUSED_ARG (maxnamelen); ACE_NOTSUP_RETURN (-1); # endif /* ACE_HAS_PHARLAP_RT */ #elif defined (ACE_VXWORKS) || defined (ACE_HAS_WINCE) ACE_OSCALL_RETURN (::gethostname (name, maxnamelen), int, -1); #elif defined (ACE_WIN32) if (::gethostname (name, ACE_Utils::truncate_cast<int> (maxnamelen)) == 0) { return 0; } else { ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::GetComputerNameA (name, LPDWORD (&maxnamelen)), ace_result_), int, -1); } #else /* ACE_HAS_PHARLAP */ ACE_utsname host_info; if (ACE_OS::uname (&host_info) == -1) return -1; else { ACE_OS::strsncpy (name, host_info.nodename, maxnamelen); return 0; } #endif /* ACE_HAS_PHARLAP */ }
unsigned long ACE_OS::inet_addr | ( | const char * | name | ) | [inline] |
Definition at line 11 of file OS_NS_arpa_inet.inl.
{ ACE_OS_TRACE ("ACE_OS::inet_addr"); #if defined (ACE_LACKS_INET_ADDR) ACE_UNUSED_ARG (name); ACE_NOTSUP_RETURN (0); #elif defined (ACE_HAS_NONCONST_INET_ADDR) return ::inet_addr (const_cast <char*> (name)); #else return ::inet_addr (name); #endif /* ACE_HAS_NONCONST_INET_ADDR */ }
int ACE_OS::inet_aton | ( | const char * | strptr, | |
struct in_addr * | addr | |||
) |
Definition at line 15 of file OS_NS_arpa_inet.cpp.
{ #if defined (ACE_LACKS_INET_ATON) # if defined (ACE_WIN32) // Windows Server 2003 changed the behavior of a zero-length input // string to inet_addr(). It used to return 0 (INADDR_ANY) but now // returns -1 (INADDR_NONE). It will return INADDR_ANY for a 1-space // string, though, as do previous versions of Windows. if (host_name == 0 || host_name[0] == '\0') host_name = " "; # endif /* ACE_WIN32 */ unsigned long ip_addr = ACE_OS::inet_addr (host_name); if (ip_addr == INADDR_NONE // Broadcast addresses are weird... && ACE_OS::strcmp (host_name, "255.255.255.255") != 0) return 0; else if (addr == 0) return 0; else { addr->s_addr = ip_addr; // Network byte ordered return 1; } #elif defined (ACE_VXWORKS) && (ACE_VXWORKS <= 0x680) // inet_aton() returns OK (0) on success and ERROR (-1) on failure. // Must reset errno first. Refer to WindRiver SPR# 34949, SPR# 36026 ::errnoSet(0); int result = ERROR; ACE_OSCALL (::inet_aton (const_cast <char*>(host_name), addr), int, ERROR, result); return (result == ERROR) ? 0 : 1; #else // inet_aton() returns 0 upon failure, not -1 since -1 is a valid // address (255.255.255.255). ACE_OSCALL_RETURN (::inet_aton (host_name, addr), int, 0); #endif /* ACE_LACKS_INET_ATON */ }
char * ACE_OS::inet_ntoa | ( | const struct in_addr | addr | ) | [inline] |
Definition at line 25 of file OS_NS_arpa_inet.inl.
{ ACE_OS_TRACE ("ACE_OS::inet_ntoa"); #if defined (ACE_LACKS_INET_NTOA) ACE_UNUSED_ARG (addr); ACE_NOTSUP_RETURN (0); #else ACE_OSCALL_RETURN (::inet_ntoa (addr), char *, 0); #endif }
const char * ACE_OS::inet_ntop | ( | int | family, | |
const void * | addrptr, | |||
char * | strptr, | |||
size_t | len | |||
) | [inline] |
Definition at line 39 of file OS_NS_arpa_inet.inl.
{ ACE_OS_TRACE ("ACE_OS::inet_ntop"); #if defined (ACE_HAS_IPV6) && !defined (ACE_WIN32) ACE_OSCALL_RETURN (::inet_ntop (family, addrptr, strptr, len), const char *, 0); #else const u_char *p = reinterpret_cast<const u_char *> (addrptr); if (family == AF_INET) { char temp[INET_ADDRSTRLEN]; // Stevens uses snprintf() in his implementation but snprintf() // doesn't appear to be very portable. For now, hope that using // sprintf() will not cause any string/memory overrun problems. ACE_OS::sprintf (temp, "%d.%d.%d.%d", p[0], p[1], p[2], p[3]); if (ACE_OS::strlen (temp) >= len) { errno = ENOSPC; return 0; // Failure } ACE_OS::strcpy (strptr, temp); return strptr; } ACE_NOTSUP_RETURN(0); #endif /* ACE_HAS_IPV6 */ }
int ACE_OS::inet_pton | ( | int | family, | |
const char * | strptr, | |||
void * | addrptr | |||
) | [inline] |
Definition at line 74 of file OS_NS_arpa_inet.inl.
{ ACE_OS_TRACE ("ACE_OS::inet_pton"); #if defined (ACE_HAS_IPV6) && !defined (ACE_WIN32) ACE_OSCALL_RETURN (::inet_pton (family, strptr, addrptr), int, -1); #else if (family == AF_INET) { struct in_addr in_val; if (ACE_OS::inet_aton (strptr, &in_val)) { ACE_OS::memcpy (addrptr, &in_val, sizeof (struct in_addr)); return 1; // Success } return 0; // Input is not a valid presentation format } ACE_NOTSUP_RETURN(-1); #endif /* ACE_HAS_IPV6 */ }
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 ioctl
.
Definition at line 14 of file OS_NS_stropts.cpp.
{ # if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) ACE_SOCKCALL_RETURN (::WSAIoctl ((ACE_SOCKET) socket, io_control_code, in_buffer_p, in_buffer, out_buffer_p, out_buffer, bytes_returned, (WSAOVERLAPPED *) overlapped, func), int, SOCKET_ERROR); # else ACE_UNUSED_ARG (socket); ACE_UNUSED_ARG (io_control_code); ACE_UNUSED_ARG (in_buffer_p); ACE_UNUSED_ARG (in_buffer); ACE_UNUSED_ARG (out_buffer_p); ACE_UNUSED_ARG (out_buffer); ACE_UNUSED_ARG (bytes_returned); ACE_UNUSED_ARG (overlapped); ACE_UNUSED_ARG (func); ACE_NOTSUP_RETURN (-1); # endif /* ACE_HAS_WINSOCK2 */ }
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 ioctl
when the I/O control code is either SIO_SET_QOS or SIO_GET_QOS.
Definition at line 51 of file OS_NS_stropts.cpp.
{ # if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) QOS qos; unsigned long qos_len = sizeof (QOS); if (io_control_code == SIO_SET_QOS) { qos.SendingFlowspec = *(ace_qos.sending_flowspec ()); qos.ReceivingFlowspec = *(ace_qos.receiving_flowspec ()); qos.ProviderSpecific = (WSABUF) ace_qos.provider_specific (); qos_len += ace_qos.provider_specific ().iov_len; ACE_SOCKCALL_RETURN (::WSAIoctl ((ACE_SOCKET) socket, io_control_code, &qos, qos_len, buffer_p, buffer, bytes_returned, (WSAOVERLAPPED *) overlapped, func), int, SOCKET_ERROR); } else { unsigned long dwBufferLen = 0; // Query for the buffer size. int result = ::WSAIoctl ((ACE_SOCKET) socket, io_control_code, 0, 0, &dwBufferLen, sizeof (dwBufferLen), bytes_returned, 0, 0); if (result == SOCKET_ERROR) { unsigned long dwErr = ::WSAGetLastError (); if (dwErr == WSAEWOULDBLOCK) { errno = dwErr; return -1; } else if (dwErr != WSAENOBUFS) { errno = dwErr; return -1; } } char *qos_buf = 0; ACE_NEW_RETURN (qos_buf, char [dwBufferLen], -1); QOS *qos = reinterpret_cast<QOS*> (qos_buf); result = ::WSAIoctl ((ACE_SOCKET) socket, io_control_code, 0, 0, qos, dwBufferLen, bytes_returned, 0, 0); if (result == SOCKET_ERROR) return result; ACE_Flow_Spec sending_flowspec (qos->SendingFlowspec.TokenRate, qos->SendingFlowspec.TokenBucketSize, qos->SendingFlowspec.PeakBandwidth, qos->SendingFlowspec.Latency, qos->SendingFlowspec.DelayVariation, # if defined(ACE_HAS_WINSOCK2_GQOS) qos->SendingFlowspec.ServiceType, qos->SendingFlowspec.MaxSduSize, qos->SendingFlowspec.MinimumPolicedSize, # else /* ACE_HAS_WINSOCK2_GQOS */ 0, 0, 0, # endif /* ACE_HAS_WINSOCK2_GQOS */ 0, 0); ACE_Flow_Spec receiving_flowspec (qos->ReceivingFlowspec.TokenRate, qos->ReceivingFlowspec.TokenBucketSize, qos->ReceivingFlowspec.PeakBandwidth, qos->ReceivingFlowspec.Latency, qos->ReceivingFlowspec.DelayVariation, # if defined(ACE_HAS_WINSOCK2_GQOS) qos->ReceivingFlowspec.ServiceType, qos->ReceivingFlowspec.MaxSduSize, qos->ReceivingFlowspec.MinimumPolicedSize, # else /* ACE_HAS_WINSOCK2_GQOS */ 0, 0, 0, # endif /* ACE_HAS_WINSOCK2_GQOS */ 0, 0); ace_qos.sending_flowspec (&sending_flowspec); ace_qos.receiving_flowspec (&receiving_flowspec); ace_qos.provider_specific (*((struct iovec *) (&qos->ProviderSpecific))); return result; } # else ACE_UNUSED_ARG (socket); ACE_UNUSED_ARG (io_control_code); ACE_UNUSED_ARG (ace_qos); ACE_UNUSED_ARG (bytes_returned); ACE_UNUSED_ARG (buffer_p); ACE_UNUSED_ARG (buffer); ACE_UNUSED_ARG (overlapped); ACE_UNUSED_ARG (func); ACE_NOTSUP_RETURN (-1); # endif /* ACE_HAS_WINSOCK2 */ }
int ACE_OS::ioctl | ( | ACE_HANDLE | handle, | |
ACE_IOCTL_TYPE_ARG2 | cmd, | |||
void * | val = 0 | |||
) | [inline] |
UNIX-style ioctl
.
Definition at line 108 of file OS_NS_stropts.inl.
{ ACE_OS_TRACE ("ACE_OS::ioctl"); #if defined (ACE_WIN32) ACE_SOCKET sock = (ACE_SOCKET) handle; ACE_SOCKCALL_RETURN (::ioctlsocket (sock, cmd, reinterpret_cast<unsigned long *> (val)), int, -1); #elif defined (ACE_HAS_IOCTL_INT_3_PARAM) ACE_OSCALL_RETURN (::ioctl (handle, cmd, reinterpret_cast<int> (val)), int, -1); #else ACE_OSCALL_RETURN (::ioctl (handle, cmd, val), int, -1); #endif /* ACE_WIN32 */ }
int ACE_OS::isastream | ( | ACE_HANDLE | handle | ) | [inline] |
Definition at line 126 of file OS_NS_stropts.inl.
{ ACE_OS_TRACE ("ACE_OS::isastream"); #if defined (ACE_HAS_STREAM_PIPES) ACE_OSCALL_RETURN (::isastream (handle), int, -1); #else ACE_UNUSED_ARG (handle); ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_STREAM_PIPES */ }
int ACE_OS::isatty | ( | int | handle | ) | [inline] |
Definition at line 604 of file OS_NS_unistd.inl.
{ ACE_OS_TRACE ("ACE_OS::isatty"); #if defined (ACE_LACKS_ISATTY) ACE_UNUSED_ARG (handle); return 0; # elif defined (ACE_WIN32) return ::_isatty (handle); # else ACE_OSCALL_RETURN (::isatty (handle), int, -1); # endif /* ACE_LACKS_ISATTY */ }
char * ACE_OS::itoa | ( | int | value, | |
char * | string, | |||
int | radix | |||
) | [inline] |
Converts an integer to a string.
Definition at line 192 of file OS_NS_stdlib.inl.
{ #if !defined (ACE_HAS_ITOA) return ACE_OS::itoa_emulation (value, string, radix); #elif defined (ACE_ITOA_EQUIVALENT) return ACE_ITOA_EQUIVALENT (value, string, radix); #else /* !ACE_HAS_ITOA */ return ::itoa (value, string, radix); #endif /* !ACE_HAS_ITOA */ }
char * ACE_OS::itoa_emulation | ( | int | value, | |
char * | string, | |||
int | radix | |||
) |
Emulated itoa - Converts an integer to a string.
Definition at line 174 of file OS_NS_stdlib.cpp.
{ char *e = string; char *b = string; // Short circuit if 0 if (value == 0) { string[0] = '0'; string[1] = 0; return string; } // If negative and base 10, print a - and then do the // number. if (value < 0 && radix == 10) { string[0] = '-'; ++b; ++e; // Don't overwrite the negative sign. value = -value; // Drop negative sign so character selection is correct. } // Convert to base <radix>, but in reverse order while (value != 0) { int mod = value % radix; value = value / radix; *e++ = (mod < 10) ? '0' + mod : 'a' + mod - 10; } *e-- = 0; // Now reverse the string to get the correct result while (e > b) { char temp = *e; *e = *b; *b = temp; ++b; --e; } return string; }
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 64 of file OS_NS_sys_socket.cpp.
{ # if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) QOS qos; // Construct the WinSock2 QOS structure. qos.SendingFlowspec = *(qos_params.socket_qos ()->sending_flowspec ()); qos.ReceivingFlowspec = *(qos_params.socket_qos ()->receiving_flowspec ()); qos.ProviderSpecific = (WSABUF) qos_params.socket_qos ()->provider_specific (); ACE_SOCKCALL_RETURN (::WSAJoinLeaf ((ACE_SOCKET) socket, name, namelen, (WSABUF *) qos_params.caller_data (), (WSABUF *) qos_params.callee_data (), &qos, (QOS *) qos_params.group_socket_qos (), qos_params.flags ()), ACE_HANDLE, ACE_INVALID_HANDLE); # else ACE_UNUSED_ARG (socket); ACE_UNUSED_ARG (name); ACE_UNUSED_ARG (namelen); ACE_UNUSED_ARG (qos_params); ACE_NOTSUP_RETURN (ACE_INVALID_HANDLE); # endif /* ACE_HAS_WINSOCK2 */ }
int ACE_OS::kill | ( | pid_t | pid, | |
int | signum | |||
) | [inline] |
Definition at line 14 of file OS_NS_signal.inl.
{ ACE_OS_TRACE ("ACE_OS::kill"); #if defined (ACE_LACKS_KILL) ACE_UNUSED_ARG (pid); ACE_UNUSED_ARG (signum); ACE_NOTSUP_RETURN (-1); #else ACE_OSCALL_RETURN (::kill (pid, signum), int, -1); #endif /* ACE_LACKS_KILL */ }
int ACE_OS::last_error | ( | void | ) | [inline] |
Definition at line 10 of file OS_NS_errno.inl.
{ // ACE_OS_TRACE ("ACE_OS::last_error"); #if defined (ACE_WIN32) // ACE_OS::last_error() prefers errnor since started out as a way to // avoid directly accessing errno in ACE code - particularly the ACE // C++ socket wrapper facades. On Windows, some things that would // use errno on UNIX require ::GetLastError(), so this method tries // to shield the rest of ACE from having to know about this. int lerror = ::GetLastError (); int lerrno = errno; return lerrno == 0 ? lerror : lerrno; #else return errno; #endif /* ACE_WIN32 */ }
void ACE_OS::last_error | ( | int | error | ) | [inline] |
Definition at line 29 of file OS_NS_errno.inl.
{ ACE_OS_TRACE ("ACE_OS::last_error"); #if defined (ACE_WIN32) ::SetLastError (error); #endif /* ACE_WIN32 */ errno = error; }
int ACE_OS::listen | ( | ACE_HANDLE | handle, | |
int | backlog | |||
) | [inline] |
BSD-style accept
(no QoS).
Definition at line 303 of file OS_NS_sys_socket.inl.
{ ACE_OS_TRACE ("ACE_OS::listen"); #if defined (ACE_LACKS_LISTEN) ACE_UNUSED_ARG (handle); ACE_UNUSED_ARG (backlog); ACE_NOTSUP_RETURN (-1); #else ACE_SOCKCALL_RETURN (::listen ((ACE_SOCKET) handle, backlog), int, -1); #endif /* ACE_LACKS_LISTEN */ }
struct tm * ACE_OS::localtime | ( | const time_t * | clock | ) | [read] |
strptime wrapper. Note that the struct tm will always be set to zero
Definition at line 395 of file OS_NS_time.inl.
{ ACE_OS_TRACE ("ACE_OS::localtime"); #if defined (ACE_LACKS_LOCALTIME) ACE_UNUSED_ARG (t); ACE_NOTSUP_RETURN (0); #else ACE_OSCALL_RETURN (::localtime (t), struct tm *, 0); #endif /* ACE_LACKS_LOCALTIME */ }
struct tm * ACE_OS::localtime_r | ( | const time_t * | clock, | |
struct tm * | res | |||
) | [read] |
strptime wrapper. Note that the struct tm will always be set to zero
Definition at line 225 of file OS_NS_time.cpp.
{ ACE_OS_TRACE ("ACE_OS::localtime_r"); #if defined (ACE_HAS_REENTRANT_FUNCTIONS) # if defined (DIGITAL_UNIX) ACE_OSCALL_RETURN (::_Plocaltime_r (t, res), struct tm *, 0); # else ACE_OSCALL_RETURN (::localtime_r (t, res), struct tm *, 0); # endif /* DIGITAL_UNIX */ #elif defined (ACE_HAS_TR24731_2005_CRT) ACE_SECURECRTCALL (localtime_s (res, t), struct tm *, 0, res); return res; #elif !defined (ACE_HAS_WINCE) ACE_OS_GUARD ACE_UNUSED_ARG (res); struct tm * res_ptr = 0; ACE_OSCALL (::localtime (t), struct tm *, 0, res_ptr); if (res_ptr == 0) return 0; else { *res = *res_ptr; return res; } #elif defined (ACE_HAS_WINCE) // This is really stupid, converting FILETIME to timeval back and // forth. It assumes FILETIME and DWORDLONG are the same structure // internally. TIME_ZONE_INFORMATION pTz; const unsigned short int __mon_yday[2][13] = { /* Normal years. */ { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 }, /* Leap years. */ { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 } }; ULARGE_INTEGER _100ns; ::GetTimeZoneInformation (&pTz); _100ns.QuadPart = (DWORDLONG) *t * 10000 * 1000 + ACE_Time_Value::FILETIME_to_timval_skew; FILETIME file_time; file_time.dwLowDateTime = _100ns.LowPart; file_time.dwHighDateTime = _100ns.HighPart; FILETIME localtime; SYSTEMTIME systime; FileTimeToLocalFileTime (&file_time, &localtime); FileTimeToSystemTime (&localtime, &systime); res->tm_hour = systime.wHour; if(pTz.DaylightBias!=0) res->tm_isdst = 1; else res->tm_isdst = 1; int iLeap; iLeap = (res->tm_year % 4 == 0 && (res->tm_year% 100 != 0 || res->tm_year % 400 == 0)); // based on leap select which group to use res->tm_mday = systime.wDay; res->tm_min = systime.wMinute; res->tm_mon = systime.wMonth - 1; res->tm_sec = systime.wSecond; res->tm_wday = systime.wDayOfWeek; res->tm_yday = __mon_yday[iLeap][systime.wMonth] + systime.wDay; res->tm_year = systime.wYear;// this the correct year but bias the value to start at the 1900 res->tm_year = res->tm_year - 1900; return res; #else // @@ Same as ACE_OS::localtime (), you need to implement it // yourself. ACE_UNUSED_ARG (t); ACE_UNUSED_ARG (res); ACE_NOTSUP_RETURN (0); #endif /* ACE_HAS_REENTRANT_FUNCTIONS */ }
double ACE_OS::log2 | ( | double | x | ) | [inline] |
This method computes the base-2 logarithm of x.
Definition at line 10 of file OS_NS_math.inl.
{ return ace_log2_helper (x); }
Definition at line 639 of file OS_NS_unistd.inl.
{ ACE_OS_TRACE ("ACE_OS::lseek"); #if defined (ACE_WIN32) # if SEEK_SET != FILE_BEGIN || SEEK_CUR != FILE_CURRENT || SEEK_END != FILE_END //#error Windows NT is evil AND rude! switch (whence) { case SEEK_SET: whence = FILE_BEGIN; break; case SEEK_CUR: whence = FILE_CURRENT; break; case SEEK_END: whence = FILE_END; break; default: errno = EINVAL; return static_cast<ACE_OFF_T> (-1); // rather safe than sorry } # endif /* SEEK_SET != FILE_BEGIN || SEEK_CUR != FILE_CURRENT || SEEK_END != FILE_END */ LONG low_offset = ACE_LOW_PART(offset); LONG high_offset = ACE_HIGH_PART(offset); DWORD const result = ::SetFilePointer (handle, low_offset, &high_offset, whence); if (result == INVALID_SET_FILE_POINTER && GetLastError() != NO_ERROR) ACE_FAIL_RETURN (static_cast<ACE_OFF_T> (-1)); else return result; #else ACE_OSCALL_RETURN (::lseek (handle, offset, whence), ACE_OFF_T, -1); #endif /* ACE_WIN32 */ }
int ACE_OS::lstat | ( | const char * | file, | |
ACE_stat * | stp | |||
) | [inline] |
Definition at line 117 of file OS_NS_sys_stat.inl.
{ ACE_OS_TRACE ("ACE_OS::lstat"); # if defined (ACE_LACKS_LSTAT) return ACE_OS::stat (file, stp); # elif defined (ACE_HAS_X86_STAT_MACROS) // Solaris for intel uses an macro for lstat(), this macro is a // wrapper for _lxstat(). ACE_OSCALL_RETURN (::_lxstat (_STAT_VER, file, stp), int, -1); # else /* !ACE_HAS_X86_STAT_MACROS */ ACE_OSCALL_RETURN (::lstat (file, stp), int, -1); # endif /* ACE_LACKS_LSTAT */ }
int ACE_OS::lwp_getparams | ( | ACE_Sched_Params & | sched_params | ) |
Definition at line 3304 of file OS_NS_Thread.cpp.
{ #if defined (ACE_HAS_STHREADS) || defined (sun) // Get the class TS and RT class IDs. ACE_id_t rt_id; ACE_id_t ts_id; if (ACE_OS::scheduling_class ("RT", rt_id) == -1 || ACE_OS::scheduling_class ("TS", ts_id) == -1) return -1; // Get this LWP's scheduling parameters. pcparms_t pcparms; // The following is just to avoid Purify warnings about unitialized // memory reads. ACE_OS::memset (&pcparms, 0, sizeof pcparms); pcparms.pc_cid = PC_CLNULL; if (ACE_OS::priority_control (P_LWPID, P_MYID, PC_GETPARMS, (char *) &pcparms) == -1) return -1; else if (pcparms.pc_cid == rt_id) { // RT class. rtparms_t rtparms; ACE_OS::memcpy (&rtparms, pcparms.pc_clparms, sizeof rtparms); sched_params.policy (ACE_SCHED_FIFO); sched_params.priority (rtparms.rt_pri); sched_params.scope (ACE_SCOPE_THREAD); ACE_Time_Value quantum (rtparms.rt_tqsecs, rtparms.rt_tqnsecs == RT_TQINF ? 0 : rtparms.rt_tqnsecs * 1000); sched_params.quantum (quantum); return 0; } else if (pcparms.pc_cid == ts_id) { /* TS class */ tsparms_t tsparms; ACE_OS::memcpy (&tsparms, pcparms.pc_clparms, sizeof tsparms); sched_params.policy (ACE_SCHED_OTHER); sched_params.priority (tsparms.ts_upri); sched_params.scope (ACE_SCOPE_THREAD); return 0; } else return -1; #else /* ! ACE_HAS_STHREADS && ! sun */ ACE_UNUSED_ARG (sched_params); ACE_NOTSUP_RETURN (-1); #endif /* ! ACE_HAS_STHREADS && ! sun */ }
int ACE_OS::lwp_setparams | ( | const ACE_Sched_Params & | sched_params | ) |
Definition at line 3362 of file OS_NS_Thread.cpp.
{ #if defined (ACE_HAS_STHREADS) || defined (sun) ACE_Sched_Params lwp_params (sched_params); lwp_params.scope (ACE_SCOPE_LWP); return ACE_OS::sched_params (lwp_params); #else /* ! ACE_HAS_STHREADS && ! sun */ ACE_UNUSED_ARG (sched_params); ACE_NOTSUP_RETURN (-1); #endif /* ! ACE_HAS_STHREADS && ! sun */ }
int ACE_OS::madvise | ( | caddr_t | addr, | |
size_t | len, | |||
int | map_advice | |||
) | [inline] |
Definition at line 21 of file OS_NS_sys_mman.inl.
{ ACE_OS_TRACE ("ACE_OS::madvise"); #if !defined (ACE_LACKS_MADVISE) ACE_OSCALL_RETURN (::madvise (addr, len, map_advice), int, -1); #else ACE_UNUSED_ARG (addr); ACE_UNUSED_ARG (len); ACE_UNUSED_ARG (map_advice); ACE_NOTSUP_RETURN (-1); #endif /* ACE_WIN32 */ }
void * ACE_OS::malloc | ( | size_t | nbytes | ) |
Function that is called by <ACE_OS::exit>, if non-null.
Definition at line 279 of file OS_NS_stdlib.cpp.
{ return ACE_MALLOC_FUNC (nbytes); }
const void * ACE_OS::memchr | ( | const void * | s, | |
int | c, | |||
size_t | len | |||
) | [inline] |
Finds characters in a buffer (const void version).
Definition at line 13 of file OS_NS_string.inl.
{ #if !defined (ACE_LACKS_MEMCHR) return ::memchr (s, c, len); #else /* ACE_LACKS_MEMCHR */ return ACE_OS::memchr_emulation (s, c, len); #endif /* !ACE_LACKS_MEMCHR */ }
void * ACE_OS::memchr | ( | void * | s, | |
int | c, | |||
size_t | len | |||
) | [inline] |
Finds characters in a buffer (void version).
Definition at line 23 of file OS_NS_string.inl.
{ return const_cast<void *> (ACE_OS::memchr (static_cast<const void *> (s), c, len)); }
int ACE_OS::memcmp | ( | const void * | t, | |
const void * | s, | |||
size_t | len | |||
) | [inline] |
Compares two buffers.
Definition at line 31 of file OS_NS_string.inl.
{ return ::memcmp (t, s, len); }
void * ACE_OS::memcpy | ( | void * | t, | |
const void * | s, | |||
size_t | len | |||
) | [inline] |
Copies one buffer to another.
Definition at line 37 of file OS_NS_string.inl.
{ #if defined (ACE_HAS_MEMCPY_LOOP_UNROLL) return fast_memcpy (t, s, len); #else return ::memcpy (t, s, len); #endif /* ACE_HAS_MEMCPY_LOOP_UNROLL */ }
void * ACE_OS::memmove | ( | void * | t, | |
const void * | s, | |||
size_t | len | |||
) | [inline] |
Moves one buffer to another.
Definition at line 47 of file OS_NS_string.inl.
{ return ::memmove (t, s, len); }
void * ACE_OS::memset | ( | void * | s, | |
int | c, | |||
size_t | len | |||
) | [inline] |
Fills a buffer with a character value.
Definition at line 53 of file OS_NS_string.inl.
{ #if defined (ACE_HAS_SLOW_MEMSET) // This section requires a high optimization level (-xO4 with SunCC) // in order to actually be inlined. char* ptr = static_cast<char*> (s); switch (len) { case 16: ptr[15] = c; case 15: ptr[14] = c; case 14: ptr[13] = c; case 13: ptr[12] = c; case 12: ptr[11] = c; case 11: ptr[10] = c; case 10: ptr[9] = c; case 9: ptr[8] = c; case 8: ptr[7] = c; case 7: ptr[6] = c; case 6: ptr[5] = c; case 5: ptr[4] = c; case 4: ptr[3] = c; case 3: ptr[2] = c; case 2: ptr[1] = c; case 1: ptr[0] = c; break; default: for (size_t i = 0; i < len; ++i) { ptr[i] = c; } } return s; #else return ::memset (s, c, len); #endif /* ACE_HAS_SLOW_MEMSET */ }
int ACE_OS::mkdir | ( | const char * | path, | |
mode_t | mode = ACE_DEFAULT_DIR_PERMS | |||
) | [inline] |
Definition at line 145 of file OS_NS_sys_stat.inl.
{ #if defined (ACE_HAS_WINCE) ACE_UNUSED_ARG (mode); ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::CreateDirectory (ACE_TEXT_CHAR_TO_TCHAR (path), 0), ace_result_), int, -1); #elif defined (ACE_MKDIR_LACKS_MODE) ACE_UNUSED_ARG (mode); ACE_OSCALL_RETURN (::mkdir (path), int, -1); #else ACE_OSCALL_RETURN (::mkdir (path, mode), int, -1); #endif }
int ACE_OS::mkfifo | ( | const ACE_TCHAR * | file, | |
mode_t | mode = ACE_DEFAULT_FILE_PERMS | |||
) | [inline] |
Definition at line 181 of file OS_NS_sys_stat.inl.
{ ACE_OS_TRACE ("ACE_OS::mkfifo"); #if defined (ACE_LACKS_MKFIFO) ACE_UNUSED_ARG (file); ACE_UNUSED_ARG (mode); ACE_NOTSUP_RETURN (-1); #else ACE_OSCALL_RETURN (::mkfifo (ACE_TEXT_ALWAYS_CHAR (file), mode), int, -1); #endif /* ACE_LACKS_MKFIFO */ }
ACE_HANDLE ACE_OS::mkstemp | ( | char * | s | ) | [inline] |
Function that is called by <ACE_OS::exit>, if non-null.
Definition at line 216 of file OS_NS_stdlib.inl.
{ #if !defined (ACE_LACKS_MKSTEMP) return ::mkstemp (s); #elif defined (ACE_USES_WCHAR) // For wide-char filesystems, we must convert the narrow-char input to // a wide-char string for mkstemp_emulation(), then convert the name // back to narrow-char for the caller. ACE_Ascii_To_Wide wide_s (s); const ACE_HANDLE fh = ACE_OS::mkstemp_emulation (wide_s.wchar_rep ()); if (fh != ACE_INVALID_HANDLE) { ACE_Wide_To_Ascii narrow_s (wide_s.wchar_rep ()); ACE_OS::strcpy (s, narrow_s.char_rep ()); } return fh; #else return ACE_OS::mkstemp_emulation (s); #endif /* !ACE_LACKS_MKSTEMP */ }
char * ACE_OS::mktemp | ( | char * | s | ) | [inline] |
Function that is called by <ACE_OS::exit>, if non-null.
Definition at line 273 of file OS_NS_stdlib.inl.
{ # if defined (ACE_WIN32) return ::_mktemp (s); # else /* ACE_WIN32 */ return ::mktemp (s); # endif /* ACE_WIN32 */ }
time_t ACE_OS::mktime | ( | struct tm * | timeptr | ) |
strptime wrapper. Note that the struct tm will always be set to zero
Definition at line 309 of file OS_NS_time.cpp.
{ ACE_OS_TRACE ("ACE_OS::mktime"); # if defined (ACE_HAS_WINCE) SYSTEMTIME t_sys; FILETIME t_file; t_sys.wSecond = t->tm_sec; t_sys.wMinute = t->tm_min; t_sys.wHour = t->tm_hour; t_sys.wDay = t->tm_mday; t_sys.wMonth = t->tm_mon + 1; // SYSTEMTIME is 1-indexed, tm is 0-indexed t_sys.wYear = t->tm_year + 1900; // SYSTEMTIME is real; tm is since 1900 t_sys.wDayOfWeek = t->tm_wday; // Ignored in below function call. t_sys.wMilliseconds = 0; if (SystemTimeToFileTime (&t_sys, &t_file) == 0) return -1; ACE_Time_Value tv (t_file); return tv.sec (); # else # if defined (ACE_HAS_THREADS) && !defined (ACE_HAS_MT_SAFE_MKTIME) ACE_OS_GUARD # endif /* ACE_HAS_THREADS && ! ACE_HAS_MT_SAFE_MKTIME */ ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::mktime (t), time_t, (time_t) -1); # endif /* ACE_HAS_WINCE */ }
void * ACE_OS::mmap | ( | void * | addr, | |
size_t | len, | |||
int | prot, | |||
int | flags, | |||
ACE_HANDLE | handle, | |||
ACE_OFF_T | off = 0 , |
|||
ACE_HANDLE * | file_mapping = 0 , |
|||
LPSECURITY_ATTRIBUTES | sa = 0 , |
|||
const ACE_TCHAR * | file_mapping_name = 0 | |||
) | [inline] |
Definition at line 35 of file OS_NS_sys_mman.inl.
{ ACE_OS_TRACE ("ACE_OS::mmap"); #if !defined (ACE_WIN32) || defined (ACE_HAS_PHARLAP) ACE_UNUSED_ARG (file_mapping_name); #endif /* !defined (ACE_WIN32) || defined (ACE_HAS_PHARLAP) */ #if defined (ACE_WIN32) && !defined (ACE_HAS_PHARLAP) # if defined(ACE_HAS_WINCE) ACE_UNUSED_ARG (addr); if (ACE_BIT_ENABLED (flags, MAP_FIXED)) // not supported { errno = EINVAL; return MAP_FAILED; } # else if (!ACE_BIT_ENABLED (flags, MAP_FIXED)) addr = 0; else if (addr == 0) // can not map to address 0 { errno = EINVAL; return MAP_FAILED; } # endif int nt_flags = 0; ACE_HANDLE local_handle = ACE_INVALID_HANDLE; // Ensure that file_mapping is non-zero. if (file_mapping == 0) file_mapping = &local_handle; if (ACE_BIT_ENABLED (flags, MAP_PRIVATE)) { # if defined(ACE_HAS_WINCE) // PAGE_WRITECOPY is not avaible on CE, but this should be the same // as PAGE_READONLY according to MSDN nt_flags = FILE_MAP_ALL_ACCESS; # else prot = PAGE_WRITECOPY; nt_flags = FILE_MAP_COPY; # endif // ACE_HAS_WINCE } else if (ACE_BIT_ENABLED (flags, MAP_SHARED)) { if (ACE_BIT_ENABLED (prot, PAGE_READONLY)) nt_flags = FILE_MAP_READ; if (ACE_BIT_ENABLED (prot, PAGE_READWRITE)) nt_flags = FILE_MAP_WRITE; } // Only create a new handle if we didn't have a valid one passed in. if (*file_mapping == ACE_INVALID_HANDLE) { SECURITY_ATTRIBUTES sa_buffer; SECURITY_DESCRIPTOR sd_buffer; LPSECURITY_ATTRIBUTES const attr = ACE_OS::default_win32_security_attributes_r (sa, &sa_buffer, &sd_buffer); *file_mapping = ACE_TEXT_CreateFileMapping (file_handle, attr, prot, 0, (file_handle == ACE_INVALID_HANDLE) ? len : 0, file_mapping_name); } if (*file_mapping == 0) ACE_FAIL_RETURN (MAP_FAILED); # if defined (ACE_OS_EXTRA_MMAP_FLAGS) nt_flags |= ACE_OS_EXTRA_MMAP_FLAGS; # endif /* ACE_OS_EXTRA_MMAP_FLAGS */ DWORD low_off = ACE_LOW_PART (off); DWORD high_off = ACE_HIGH_PART (off); # if defined (ACE_HAS_WINCE) void *addr_mapping = ::MapViewOfFile (*file_mapping, nt_flags, high_off, low_off, len); # else void *addr_mapping = ::MapViewOfFileEx (*file_mapping, nt_flags, high_off, low_off, len, addr); # endif /* ACE_HAS_WINCE */ // Only close this down if we used the temporary. if (file_mapping == &local_handle) ::CloseHandle (*file_mapping); if (addr_mapping == 0) ACE_FAIL_RETURN (MAP_FAILED); else return addr_mapping; #elif !defined (ACE_LACKS_MMAP) ACE_UNUSED_ARG (sa); # if defined (ACE_OS_EXTRA_MMAP_FLAGS) flags |= ACE_OS_EXTRA_MMAP_FLAGS; # endif /* ACE_OS_EXTRA_MMAP_FLAGS */ ACE_UNUSED_ARG (file_mapping); # if defined (ACE_OPENVMS) //FUZZ: disable check_for_lack_ACE_OS ::fsync(file_handle); //FUZZ: enable check_for_lack_ACE_OS # endif //FUZZ: disable check_for_lack_ACE_OS ACE_OSCALL_RETURN ((void *) ::mmap ((ACE_MMAP_TYPE) addr, len, prot, flags, file_handle, off), void *, MAP_FAILED); //FUZZ: enable check_for_lack_ACE_OS #else ACE_UNUSED_ARG (addr); ACE_UNUSED_ARG (len); ACE_UNUSED_ARG (prot); ACE_UNUSED_ARG (flags); ACE_UNUSED_ARG (file_handle); ACE_UNUSED_ARG (off); ACE_UNUSED_ARG (file_mapping); ACE_UNUSED_ARG (sa); ACE_NOTSUP_RETURN (MAP_FAILED); #endif /* ACE_WIN32 && !ACE_HAS_PHARLAP */ }
int ACE_OS::mprotect | ( | void * | addr, | |
size_t | len, | |||
int | prot | |||
) | [inline] |
Definition at line 186 of file OS_NS_sys_mman.inl.
{ ACE_OS_TRACE ("ACE_OS::mprotect"); #if defined (ACE_WIN32) && !defined (ACE_HAS_PHARLAP) DWORD dummy; // Sigh! return ::VirtualProtect(addr, len, prot, &dummy) ? 0 : -1; #elif !defined (ACE_LACKS_MPROTECT) ACE_OSCALL_RETURN (::mprotect ((ACE_MMAP_TYPE) addr, len, prot), int, -1); #else ACE_UNUSED_ARG (addr); ACE_UNUSED_ARG (len); ACE_UNUSED_ARG (prot); ACE_NOTSUP_RETURN (-1); #endif /* ACE_WIN32 && !ACE_HAS_PHARLAP */ }
int ACE_OS::msgctl | ( | int | msqid, | |
int | cmd, | |||
struct msqid_ds * | val | |||
) | [inline] |
Definition at line 10 of file OS_NS_sys_msg.inl.
{ ACE_OS_TRACE ("ACE_OS::msgctl"); #if defined (ACE_HAS_SYSV_IPC) ACE_OSCALL_RETURN (::msgctl (msqid, cmd, val), int, -1); #else ACE_UNUSED_ARG (msqid); ACE_UNUSED_ARG (cmd); ACE_UNUSED_ARG (val); ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_SYSV_IPC */ }
int ACE_OS::msgget | ( | key_t | key, | |
int | msgflg | |||
) | [inline] |
Definition at line 25 of file OS_NS_sys_msg.inl.
{ ACE_OS_TRACE ("ACE_OS::msgget"); #if defined (ACE_HAS_SYSV_IPC) ACE_OSCALL_RETURN (::msgget (key, msgflg), int, -1); #else ACE_UNUSED_ARG (key); ACE_UNUSED_ARG (msgflg); ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_SYSV_IPC */ }
ssize_t ACE_OS::msgrcv | ( | int | int_id, | |
void * | buf, | |||
size_t | len, | |||
long | type, | |||
int | flags | |||
) | [inline] |
Definition at line 39 of file OS_NS_sys_msg.inl.
{ ACE_OS_TRACE ("ACE_OS::msgrcv"); #if defined (ACE_HAS_SYSV_IPC) ACE_OSCALL_RETURN (::msgrcv (int_id, buf, len, type, flags), int, -1); #else ACE_UNUSED_ARG (int_id); ACE_UNUSED_ARG (buf); ACE_UNUSED_ARG (len); ACE_UNUSED_ARG (type); ACE_UNUSED_ARG (flags); ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_SYSV_IPC */ }
int ACE_OS::msgsnd | ( | int | int_id, | |
const void * | buf, | |||
size_t | len, | |||
int | flags | |||
) | [inline] |
Definition at line 58 of file OS_NS_sys_msg.inl.
{ ACE_OS_TRACE ("ACE_OS::msgsnd"); #if defined (ACE_HAS_SYSV_IPC) # if defined (ACE_HAS_NONCONST_MSGSND) ACE_OSCALL_RETURN (::msgsnd (int_id, const_cast<void *> (buf), len, flags), int, -1); # else ACE_OSCALL_RETURN (::msgsnd (int_id, buf, len, flags), int, -1); # endif /* ACE_HAS_NONCONST_MSGSND */ #else ACE_UNUSED_ARG (int_id); ACE_UNUSED_ARG (buf); ACE_UNUSED_ARG (len); ACE_UNUSED_ARG (flags); ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_SYSV_IPC */ }
int ACE_OS::msync | ( | void * | addr, | |
size_t | len, | |||
int | sync | |||
) | [inline] |
Definition at line 203 of file OS_NS_sys_mman.inl.
{ ACE_OS_TRACE ("ACE_OS::msync"); #if defined (ACE_WIN32) && !defined (ACE_HAS_PHARLAP) ACE_UNUSED_ARG (sync); ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::FlushViewOfFile (addr, len), ace_result_), int, -1); #elif !defined (ACE_LACKS_MSYNC) ACE_OSCALL_RETURN (::msync ((ACE_MMAP_TYPE) addr, len, sync), int, -1); #else ACE_UNUSED_ARG (addr); ACE_UNUSED_ARG (len); ACE_UNUSED_ARG (sync); ACE_NOTSUP_RETURN (-1); #endif /* ACE_WIN32 && !ACE_HAS_PHARLAP */ }
int ACE_OS::munmap | ( | void * | addr, | |
size_t | len | |||
) | [inline] |
Definition at line 221 of file OS_NS_sys_mman.inl.
{ ACE_OS_TRACE ("ACE_OS::munmap"); #if defined (ACE_WIN32) ACE_UNUSED_ARG (len); ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::UnmapViewOfFile (addr), ace_result_), int, -1); #elif !defined (ACE_LACKS_MMAP) ACE_OSCALL_RETURN (::munmap ((ACE_MMAP_TYPE) addr, len), int, -1); #else ACE_UNUSED_ARG (addr); ACE_UNUSED_ARG (len); ACE_NOTSUP_RETURN (-1); #endif /* ACE_WIN32 */ }
int ACE_OS::mutex_destroy | ( | 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 1928 of file OS_NS_Thread.cpp.
{ ACE_OS_TRACE ("ACE_OS::mutex_destroy"); #if defined (ACE_HAS_THREADS) # if defined (ACE_HAS_PTHREADS) int result; ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_mutex_destroy (m), result), int, -1); # elif defined (ACE_HAS_STHREADS) int result; ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::mutex_destroy (m), result), int, -1); # elif defined (ACE_HAS_WTHREADS) switch (m->type_) { case USYNC_PROCESS: ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::CloseHandle (m->proc_mutex_), ace_result_), int, -1); case USYNC_THREAD: return ACE_OS::thread_mutex_destroy (&m->thr_mutex_); default: errno = EINVAL; return -1; } /* NOTREACHED */ # elif defined (ACE_VXWORKS) return ::semDelete (*m) == OK ? 0 : -1; # endif /* Threads variety case */ #else ACE_UNUSED_ARG (m); ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_THREADS */ }
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 | |||
) |
Win32 note: Abandoned mutexes are not treated differently. 0 is returned since the calling thread does get the ownership.
Definition at line 1772 of file OS_NS_Thread.cpp.
{ // ACE_OS_TRACE ("ACE_OS::mutex_init"); #if defined (ACE_HAS_THREADS) # if defined (ACE_HAS_PTHREADS) ACE_UNUSED_ARG (name); ACE_UNUSED_ARG (sa); # if defined (ACE_PTHREAD_MUTEXATTR_T_INITIALIZE) /* Tests show that VxWorks 6.x pthread lib does not only * require zeroing of mutex/condition objects to function correctly * but also of the attribute objects. */ pthread_mutexattr_t l_attributes = {0}; # else pthread_mutexattr_t l_attributes; # endif if (attributes == 0) attributes = &l_attributes; int result = 0; int attr_init = 0; // have we initialized the local attributes. // Only do these initializations if the <attributes> parameter // wasn't originally set. if (attributes == &l_attributes) { if (ACE_ADAPT_RETVAL (::pthread_mutexattr_init (attributes), result) == 0) { result = 0; attr_init = 1; // we have initialized these attributes } else { result = -1; // ACE_ADAPT_RETVAL used it for intermediate status } } if (result == 0 && lock_scope != 0) { # if defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_MUTEXATTR_PSHARED) (void) ACE_ADAPT_RETVAL (::pthread_mutexattr_setpshared (attributes, lock_scope), result); # endif /* _POSIX_THREAD_PROCESS_SHARED && !ACE_LACKS_MUTEXATTR_PSHARED */ } if (result == 0 && lock_type != 0) { # if defined (ACE_HAS_RECURSIVE_MUTEXES) (void) ACE_ADAPT_RETVAL (::pthread_mutexattr_settype (attributes, lock_type), result); # endif /* ACE_HAS_RECURSIVE_MUTEXES */ } if (result == 0) { # if defined (ACE_PTHREAD_MUTEX_T_INITIALIZE) /* VxWorks 6.x API reference states: * If the memory for the mutex variable object has been allocated * dynamically, it is a good policy to always zero out the * block of memory so as to avoid spurious EBUSY return code * when calling this routine. * Tests shows this to be necessary. */ ACE_OS::memset (m, 0, sizeof (*m)); # endif if (ACE_ADAPT_RETVAL (::pthread_mutex_init (m, attributes), result) == 0) result = 0; else result = -1; // ACE_ADAPT_RETVAL used it for intermediate status } // Only do the deletions if the <attributes> parameter wasn't // originally set. if (attributes == &l_attributes && attr_init) ::pthread_mutexattr_destroy (&l_attributes); return result; # elif defined (ACE_HAS_STHREADS) ACE_UNUSED_ARG (name); ACE_UNUSED_ARG (sa); ACE_UNUSED_ARG (lock_type); int result; ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::mutex_init (m, lock_scope, attributes), result), int, -1); # elif defined (ACE_HAS_WTHREADS) m->type_ = lock_scope; SECURITY_ATTRIBUTES sa_buffer; SECURITY_DESCRIPTOR sd_buffer; switch (lock_scope) { case USYNC_PROCESS: # if defined (ACE_HAS_WINCE) // @@todo (brunsch) This idea should be moved into ACE_OS_Win32. m->proc_mutex_ = ::CreateMutexW (ACE_OS::default_win32_security_attributes_r (sa, &sa_buffer, &sd_buffer), FALSE, ACE_Ascii_To_Wide (name).wchar_rep ()); # else /* ACE_HAS_WINCE */ m->proc_mutex_ = ::CreateMutexA (ACE_OS::default_win32_security_attributes_r (sa, &sa_buffer, &sd_buffer), FALSE, name); # endif /* ACE_HAS_WINCE */ if (m->proc_mutex_ == 0) ACE_FAIL_RETURN (-1); else { // Make sure to set errno to ERROR_ALREADY_EXISTS if necessary. ACE_OS::set_errno_to_last_error (); return 0; } case USYNC_THREAD: return ACE_OS::thread_mutex_init (&m->thr_mutex_, lock_type, name, attributes); default: errno = EINVAL; return -1; } /* NOTREACHED */ # elif defined (ACE_VXWORKS) ACE_UNUSED_ARG (name); ACE_UNUSED_ARG (attributes); ACE_UNUSED_ARG (sa); ACE_UNUSED_ARG (lock_type); return (*m = ::semMCreate (lock_scope)) == 0 ? -1 : 0; # endif /* ACE_HAS_PTHREADS */ #else ACE_UNUSED_ARG (m); ACE_UNUSED_ARG (lock_scope); ACE_UNUSED_ARG (name); ACE_UNUSED_ARG (attributes); ACE_UNUSED_ARG (sa); ACE_UNUSED_ARG (lock_type); ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_THREADS */ }
int ACE_OS::mutex_lock | ( | ACE_mutex_t * | m, | |
const ACE_Time_Value * | timeout | |||
) | [inline] |
If <timeout> == 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 ETIME
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 413 of file OS_NS_Thread.inl.
{ return timeout == 0 ? ACE_OS::mutex_lock (m) : ACE_OS::mutex_lock (m, *timeout); }
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 2012 of file OS_NS_Thread.cpp.
{ // ACE_OS_TRACE ("ACE_OS::mutex_lock"); #if defined (ACE_HAS_THREADS) # if defined (ACE_HAS_PTHREADS) // Note, don't use "::" here since the following call is often a macro. int result; ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_mutex_lock (m), result), int, -1); # elif defined (ACE_HAS_STHREADS) int result; ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::mutex_lock (m), result), int, -1); # elif defined (ACE_HAS_WTHREADS) switch (m->type_) { case USYNC_PROCESS: switch (::WaitForSingleObject (m->proc_mutex_, INFINITE)) { // // Timeout can't occur, so don't bother checking... // case WAIT_OBJECT_0: case WAIT_ABANDONED: // We will ignore abandonments in this method // Note that we still hold the lock return 0; default: // This is a hack, we need to find an appropriate mapping... ACE_OS::set_errno_to_last_error (); return -1; } case USYNC_THREAD: return ACE_OS::thread_mutex_lock (&m->thr_mutex_); default: errno = EINVAL; return -1; } /* NOTREACHED */ # elif defined (ACE_VXWORKS) return ::semTake (*m, WAIT_FOREVER) == OK ? 0 : -1; # endif /* Threads variety case */ #else ACE_UNUSED_ARG (m); ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_THREADS */ }
int ACE_OS::mutex_lock | ( | ACE_mutex_t * | m, | |
int & | abandoned | |||
) |
This method is only implemented for Win32. For abandoned mutexes, abandoned is set to 1 and 0 is returned.
Definition at line 2060 of file OS_NS_Thread.cpp.
{ ACE_OS_TRACE ("ACE_OS::mutex_lock"); #if defined (ACE_HAS_THREADS) && defined (ACE_HAS_WTHREADS) abandoned = 0; switch (m->type_) { case USYNC_PROCESS: switch (::WaitForSingleObject (m->proc_mutex_, INFINITE)) { // // Timeout can't occur, so don't bother checking... // case WAIT_OBJECT_0: return 0; case WAIT_ABANDONED: abandoned = 1; return 0; // something goofed, but we hold the lock ... default: // This is a hack, we need to find an appropriate mapping... ACE_OS::set_errno_to_last_error (); return -1; } case USYNC_THREAD: return ACE_OS::thread_mutex_lock (&m->thr_mutex_); default: errno = EINVAL; return -1; } /* NOTREACHED */ #else ACE_UNUSED_ARG (m); ACE_UNUSED_ARG (abandoned); ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_THREADS and ACE_HAS_WTHREADS */ }
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 ETIME
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 2099 of file OS_NS_Thread.cpp.
{ #if defined (ACE_HAS_THREADS) && defined (ACE_HAS_MUTEX_TIMEOUTS) # if defined (ACE_HAS_PTHREADS) int result; // "timeout" should be an absolute time. timespec_t ts = timeout; // Calls ACE_Time_Value::operator timespec_t(). // Note that the mutex should not be a recursive one, i.e., it // should only be a standard mutex or an error checking mutex. ACE_OSCALL (ACE_ADAPT_RETVAL (::pthread_mutex_timedlock (m, &ts), result), int, -1, result); // We need to adjust this to make the errno values consistent. if (result == -1 && errno == ETIMEDOUT) errno = ETIME; return result; # elif defined (ACE_HAS_WTHREADS) // Note that we must convert between absolute time (which is passed // as a parameter) and relative time (which is what the system call // expects). ACE_Time_Value relative_time (timeout - ACE_OS::gettimeofday ()); switch (m->type_) { case USYNC_PROCESS: switch (::WaitForSingleObject (m->proc_mutex_, relative_time.msec ())) { case WAIT_OBJECT_0: case WAIT_ABANDONED: // We will ignore abandonments in this method // Note that we still hold the lock return 0; case WAIT_TIMEOUT: errno = ETIME; return -1; default: // This is a hack, we need to find an appropriate mapping... ACE_OS::set_errno_to_last_error (); return -1; } case USYNC_THREAD: ACE_NOTSUP_RETURN (-1); default: errno = EINVAL; return -1; } /* NOTREACHED */ # elif defined (ACE_VXWORKS) // Note that we must convert between absolute time (which is passed // as a parameter) and relative time (which is what the system call // expects). ACE_Time_Value relative_time (timeout - ACE_OS::gettimeofday ()); int ticks_per_sec = ::sysClkRateGet (); int ticks = relative_time.sec() * ticks_per_sec + relative_time.usec () * ticks_per_sec / ACE_ONE_SECOND_IN_USECS; if (::semTake (*m, ticks) == ERROR) { if (errno == S_objLib_OBJ_TIMEOUT) // Convert the VxWorks errno to one that's common for to ACE // platforms. errno = ETIME; else if (errno == S_objLib_OBJ_UNAVAILABLE) errno = EBUSY; return -1; } else return 0; # endif /* ACE_HAS_PTHREADS */ #else ACE_UNUSED_ARG (m); ACE_UNUSED_ARG (timeout); ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_THREADS && ACE_HAS_MUTEX_TIMEOUTS */ }
void ACE_OS::mutex_lock_cleanup | ( | void * | mutex | ) |
Handle asynchronous thread cancellation cleanup.
Definition at line 2325 of file OS_NS_Thread.cpp.
{ ACE_OS_TRACE ("ACE_OS::mutex_lock_cleanup"); #if defined (ACE_HAS_THREADS) # if defined (ACE_HAS_PTHREADS) ACE_mutex_t *p_lock = (ACE_mutex_t *) mutex; ACE_OS::mutex_unlock (p_lock); # else ACE_UNUSED_ARG (mutex); # endif /* ACE_HAS_PTHREADS */ #else ACE_UNUSED_ARG (mutex); #endif /* ACE_HAS_THREADS */ }
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 2187 of file OS_NS_Thread.cpp.
{ ACE_OS_TRACE ("ACE_OS::mutex_trylock"); #if defined (ACE_HAS_THREADS) # if defined (ACE_HAS_PTHREADS) // Note, don't use "::" here since the following call is often a macro. int result; ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_mutex_trylock (m), result), int, -1); # elif defined (ACE_HAS_STHREADS) int result; ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::mutex_trylock (m), result), int, -1); # elif defined (ACE_HAS_WTHREADS) switch (m->type_) { case USYNC_PROCESS: { // Try for 0 milliseconds - i.e. nonblocking. switch (::WaitForSingleObject (m->proc_mutex_, 0)) { case WAIT_OBJECT_0: return 0; case WAIT_ABANDONED: // We will ignore abandonments in this method. Note that // we still hold the lock. return 0; case WAIT_TIMEOUT: errno = EBUSY; return -1; default: ACE_OS::set_errno_to_last_error (); return -1; } } case USYNC_THREAD: return ACE_OS::thread_mutex_trylock (&m->thr_mutex_); default: errno = EINVAL; return -1; } /* NOTREACHED */ # elif defined (ACE_VXWORKS) if (::semTake (*m, NO_WAIT) == ERROR) if (errno == S_objLib_OBJ_UNAVAILABLE) { // couldn't get the semaphore errno = EBUSY; return -1; } else // error return -1; else // got the semaphore return 0; # endif /* Threads variety case */ #else ACE_UNUSED_ARG (m); ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_THREADS */ }
int ACE_OS::mutex_trylock | ( | ACE_mutex_t * | m, | |
int & | abandoned | |||
) |
This method is only implemented for Win32. For abandoned mutexes, <abandoned> is set to 1 and 0 is returned.
Definition at line 2250 of file OS_NS_Thread.cpp.
{ #if defined (ACE_HAS_THREADS) && defined (ACE_HAS_WTHREADS) abandoned = 0; switch (m->type_) { case USYNC_PROCESS: { // Try for 0 milliseconds - i.e. nonblocking. switch (::WaitForSingleObject (m->proc_mutex_, 0)) { case WAIT_OBJECT_0: return 0; case WAIT_ABANDONED: abandoned = 1; return 0; // something goofed, but we hold the lock ... case WAIT_TIMEOUT: errno = EBUSY; return -1; default: ACE_OS::set_errno_to_last_error (); return -1; } } case USYNC_THREAD: return ACE_OS::thread_mutex_trylock (&m->thr_mutex_); default: errno = EINVAL; return -1; } /* NOTREACHED */ #else ACE_UNUSED_ARG (m); ACE_UNUSED_ARG (abandoned); ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_THREADS and ACE_HAS_WTHREADS */ }
int ACE_OS::mutex_unlock | ( | 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 2289 of file OS_NS_Thread.cpp.
{ ACE_OS_TRACE ("ACE_OS::mutex_unlock"); #if defined (ACE_HAS_THREADS) # if defined (ACE_HAS_PTHREADS) // Note, don't use "::" here since the following call is often a macro. int result; ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_mutex_unlock (m), result), int, -1); # elif defined (ACE_HAS_STHREADS) int result; ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::mutex_unlock (m), result), int, -1); # elif defined (ACE_HAS_WTHREADS) switch (m->type_) { case USYNC_PROCESS: ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::ReleaseMutex (m->proc_mutex_), ace_result_), int, -1); case USYNC_THREAD: return ACE_OS::thread_mutex_unlock (&m->thr_mutex_); default: errno = EINVAL; return -1; } /* NOTREACHED */ # elif defined (ACE_VXWORKS) return ::semGive (*m) == OK ? 0 : -1; # endif /* Threads variety case */ #else ACE_UNUSED_ARG (m); ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_THREADS */ }
int ACE_OS::nanosleep | ( | const struct timespec * | requested, | |
struct timespec * | remaining = 0 | |||
) | [inline] |
strptime wrapper. Note that the struct tm will always be set to zero
Definition at line 407 of file OS_NS_time.inl.
{ ACE_OS_TRACE ("ACE_OS::nanosleep"); #if defined (ACE_HAS_CLOCK_GETTIME) // ::nanosleep () is POSIX 1003.1b. So is ::clock_gettime (). So, // if ACE_HAS_CLOCK_GETTIME is defined, then ::nanosleep () should // be available on the platform. On Solaris 2.x, both functions // require linking with -lposix4. return ::nanosleep ((ACE_TIMESPEC_PTR) requested, remaining); #else ACE_UNUSED_ARG (remaining); // Convert into seconds and microseconds. ACE_Time_Value tv (requested->tv_sec, requested->tv_nsec / 1000); return ACE_OS::sleep (tv); #endif /* ACE_HAS_CLOCK_GETTIME */ }
long ACE_OS::num_processors | ( | void | ) |
Get the number of CPUs configured in the machine.
Definition at line 381 of file OS_NS_unistd.cpp.
{ ACE_OS_TRACE ("ACE_OS::num_processors"); #if defined (ACE_HAS_PHARLAP) return 1; #elif defined (ACE_WIN32) SYSTEM_INFO sys_info; ::GetSystemInfo (&sys_info); return sys_info.dwNumberOfProcessors; #elif defined (ACE_HAS_VXCPULIB) return vxCpuConfiguredGet(); #elif defined (_SC_NPROCESSORS_CONF) return ::sysconf (_SC_NPROCESSORS_CONF); #elif defined (ACE_HAS_SYSCTL) int num_processors = 0; int mib[2] = { CTL_HW, HW_NCPU }; size_t len = sizeof (num_processors); if (::sysctl (mib, 2, &num_processors, &len, 0, 0) != -1) return num_processors; else return -1; #elif defined (__hpux) struct pst_dynamic psd; if (::pstat_getdynamic (&psd, sizeof (psd), (size_t) 1, 0) != -1) return psd.psd_max_proc_cnt; else return -1; #else ACE_NOTSUP_RETURN (-1); #endif }
long ACE_OS::num_processors_online | ( | void | ) |
Get the number of CPUs currently online.
Definition at line 415 of file OS_NS_unistd.cpp.
{ ACE_OS_TRACE ("ACE_OS::num_processors_online"); #if defined (ACE_HAS_PHARLAP) return 1; #elif defined (ACE_WIN32) SYSTEM_INFO sys_info; ::GetSystemInfo (&sys_info); long active_processors = 0; DWORD_PTR mask = sys_info.dwActiveProcessorMask; while (mask != 0) { if (mask & 1) ++active_processors; mask >>= 1; } return active_processors; #elif defined (ACE_HAS_VXCPULIB) long num_cpu = 0; cpuset_t cpuset; CPUSET_ZERO (cpuset); cpuset = vxCpuEnabledGet(); unsigned int const maxcpu = vxCpuConfiguredGet(); for (unsigned int i =0; i < maxcpu; i++) { if (CPUSET_ISSET (cpuset, i)) { ++num_cpu; } } return num_cpu; #elif defined (_SC_NPROCESSORS_ONLN) return ::sysconf (_SC_NPROCESSORS_ONLN); #elif defined (ACE_HAS_SYSCTL) int num_processors; int mib[2] = { CTL_HW, HW_NCPU }; size_t len = sizeof (num_processors); if (::sysctl (mib, 2, &num_processors, &len, 0, 0) != -1) return num_processors; else return -1; #elif defined (__hpux) struct pst_dynamic psd; if (::pstat_getdynamic (&psd, sizeof (psd), (size_t) 1, 0) != -1) return psd.psd_proc_cnt; else return -1; #else ACE_NOTSUP_RETURN (-1); #endif }
ACE_HANDLE ACE_OS::open | ( | const char * | filename, | |
int | mode, | |||
mode_t | 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.
{ ACE_OS_TRACE ("ACE_OS::open"); #if defined (ACE_WIN32) DWORD access = GENERIC_READ; if (ACE_BIT_ENABLED (mode, O_WRONLY)) access = GENERIC_WRITE; else if (ACE_BIT_ENABLED (mode, O_RDWR)) access = GENERIC_READ | GENERIC_WRITE; DWORD creation = OPEN_EXISTING; if ((mode & (_O_CREAT | _O_EXCL)) == (_O_CREAT | _O_EXCL)) creation = CREATE_NEW; else if ((mode & (_O_CREAT | _O_TRUNC)) == (_O_CREAT | _O_TRUNC)) creation = CREATE_ALWAYS; else if (ACE_BIT_ENABLED (mode, _O_CREAT)) creation = OPEN_ALWAYS; else if (ACE_BIT_ENABLED (mode, _O_TRUNC)) creation = TRUNCATE_EXISTING; DWORD flags = 0; if (ACE_BIT_ENABLED (mode, _O_TEMPORARY)) flags |= FILE_FLAG_DELETE_ON_CLOSE | FILE_ATTRIBUTE_TEMPORARY; if (ACE_BIT_ENABLED (mode, FILE_FLAG_WRITE_THROUGH)) flags |= FILE_FLAG_WRITE_THROUGH; if (ACE_BIT_ENABLED (mode, FILE_FLAG_OVERLAPPED)) flags |= FILE_FLAG_OVERLAPPED; if (ACE_BIT_ENABLED (mode, FILE_FLAG_NO_BUFFERING)) flags |= FILE_FLAG_NO_BUFFERING; if (ACE_BIT_ENABLED (mode, FILE_FLAG_RANDOM_ACCESS)) flags |= FILE_FLAG_RANDOM_ACCESS; if (ACE_BIT_ENABLED (mode, FILE_FLAG_SEQUENTIAL_SCAN)) flags |= FILE_FLAG_SEQUENTIAL_SCAN; if (ACE_BIT_ENABLED (mode, FILE_FLAG_DELETE_ON_CLOSE)) flags |= FILE_FLAG_DELETE_ON_CLOSE; if (ACE_BIT_ENABLED (mode, FILE_FLAG_BACKUP_SEMANTICS)) flags |= FILE_FLAG_BACKUP_SEMANTICS; if (ACE_BIT_ENABLED (mode, FILE_FLAG_POSIX_SEMANTICS)) flags |= FILE_FLAG_POSIX_SEMANTICS; ACE_MT (ACE_thread_mutex_t *ace_os_monitor_lock = 0;) if (ACE_BIT_ENABLED (mode, _O_APPEND)) { ACE_MT ( ace_os_monitor_lock = static_cast <ACE_thread_mutex_t *> ( ACE_OS_Object_Manager::preallocated_object[ ACE_OS_Object_Manager::ACE_OS_MONITOR_LOCK]); ACE_OS::thread_mutex_lock (ace_os_monitor_lock); ) } DWORD shared_mode = perms; SECURITY_ATTRIBUTES sa_buffer; SECURITY_DESCRIPTOR sd_buffer; #if defined (ACE_HAS_WINCE) ACE_HANDLE h = ::CreateFileW (ACE_Ascii_To_Wide (filename).wchar_rep (), access, shared_mode, ACE_OS::default_win32_security_attributes_r (sa, &sa_buffer, &sd_buffer), creation, flags, 0); #else /* ACE_HAS_WINCE */ ACE_HANDLE h = ::CreateFileA (filename, access, shared_mode, ACE_OS::default_win32_security_attributes_r (sa, &sa_buffer, &sd_buffer), creation, flags, 0); #endif /* ACE_HAS_WINCE */ if (ACE_BIT_ENABLED (mode, _O_APPEND)) { LONG high_size = 0; if (h != ACE_INVALID_HANDLE && ::SetFilePointer (h, 0, &high_size, FILE_END) == INVALID_SET_FILE_POINTER && GetLastError () != NO_ERROR) { ACE_MT (ACE_OS::thread_mutex_unlock (ace_os_monitor_lock);) ACE_FAIL_RETURN (ACE_INVALID_HANDLE); } ACE_MT (ACE_OS::thread_mutex_unlock (ace_os_monitor_lock);) } if (h == ACE_INVALID_HANDLE) ACE_FAIL_RETURN (h); else return h; #elif defined (INTEGRITY) ACE_UNUSED_ARG (sa); if(!strcmp(filename,ACE_DEV_NULL)) { ACE_OSCALL_RETURN (::AllocateNullConsoleDescriptor(), ACE_HANDLE, -1); } else { ACE_OSCALL_RETURN (::open (filename, mode, perms), ACE_HANDLE, -1); } #else ACE_UNUSED_ARG (sa); ACE_OSCALL_RETURN (::open (filename, mode, perms), ACE_HANDLE, ACE_INVALID_HANDLE); #endif /* ACE_WIN32 */ }
Definition at line 36 of file OS_NS_dirent.inl.
{ #if defined (ACE_HAS_DIRENT) # if defined (ACE_WIN32) && defined (ACE_LACKS_OPENDIR) return ::ACE_OS::opendir_emulation (filename); # elif defined (ACE_HAS_WOPENDIR) && defined (ACE_USES_WCHAR) return ::wopendir (filename); # elif defined (ACE_HAS_NONCONST_OPENDIR) return ::opendir (const_cast<char *> (filename)); # else /* ! ACE_WIN32 && ACE_LACKS_OPENDIR */ return ::opendir (ACE_TEXT_ALWAYS_CHAR (filename)); # endif /* ACE_WIN32 && ACE_LACKS_OPENDIR */ #else ACE_UNUSED_ARG (filename); ACE_NOTSUP_RETURN (0); #endif /* ACE_HAS_DIRENT */ }
void ACE_OS::perror | ( | const char * | s | ) | [inline] |
Definition at line 757 of file OS_NS_stdio.inl.
{ ACE_OS_TRACE ("ACE_OS::perror"); #if defined (ACE_LACKS_PERROR) ACE_UNUSED_ARG (s); #else ::perror (s); #endif /* ACE_HAS_WINCE */ }
int ACE_OS::pipe | ( | ACE_HANDLE | handles[] | ) | [inline] |
Definition at line 797 of file OS_NS_unistd.inl.
{ ACE_OS_TRACE ("ACE_OS::pipe"); # if defined (ACE_LACKS_PIPE) ACE_UNUSED_ARG (fds); ACE_NOTSUP_RETURN (-1); # elif defined (ACE_WIN32) ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::CreatePipe (&fds[0], &fds[1], 0, 0), ace_result_), int, -1); # else ACE_OSCALL_RETURN (::pipe (fds), int, -1); # endif /* ACE_LACKS_PIPE */ }
int ACE_OS::poll | ( | struct pollfd * | pollfds, | |
unsigned long | len, | |||
const ACE_Time_Value * | tv = 0 | |||
) | [inline] |
Definition at line 11 of file OS_NS_poll.inl.
{ ACE_OS_TRACE ("ACE_OS::poll"); #if defined (ACE_HAS_POLL) int to = timeout == 0 ? -1 : int (timeout->msec ()); ACE_OSCALL_RETURN (::poll (pollfds, len, to), int, -1); #else ACE_UNUSED_ARG (timeout); ACE_UNUSED_ARG (len); ACE_UNUSED_ARG (pollfds); ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_POLL */ }
int ACE_OS::poll | ( | struct pollfd * | pollfds, | |
unsigned long | len, | |||
const ACE_Time_Value & | tv | |||
) | [inline] |
Definition at line 29 of file OS_NS_poll.inl.
{ ACE_OS_TRACE ("ACE_OS::poll"); #if defined (ACE_HAS_POLL) ACE_OSCALL_RETURN (::poll (pollfds, len, int (timeout.msec ())), int, -1); #else ACE_UNUSED_ARG (timeout); ACE_UNUSED_ARG (len); ACE_UNUSED_ARG (pollfds); ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_POLL */ }
Definition at line 496 of file OS_NS_unistd.cpp.
{ # if defined (ACE_HAS_P_READ_WRITE) # if defined (ACE_WIN32) ACE_OS_GUARD // Remember the original file pointer position LONG original_high_position = 0; DWORD original_low_position = ::SetFilePointer (handle, 0, &original_high_position, FILE_CURRENT); if (original_low_position == INVALID_SET_FILE_POINTER && GetLastError () != NO_ERROR) { ACE_OS::set_errno_to_last_error (); return -1; } // Go to the correct position LONG low_offset = ACE_LOW_PART (offset); LONG high_offset = ACE_HIGH_PART (offset); DWORD altered_position = ::SetFilePointer (handle, low_offset, &high_offset, FILE_BEGIN); if (altered_position == INVALID_SET_FILE_POINTER && GetLastError () != NO_ERROR) { ACE_OS::set_errno_to_last_error (); return -1; } DWORD bytes_read; # if defined (ACE_HAS_WIN32_OVERLAPPED_IO) OVERLAPPED overlapped; overlapped.Internal = 0; overlapped.InternalHigh = 0; overlapped.Offset = low_offset; overlapped.OffsetHigh = high_offset; overlapped.hEvent = 0; BOOL result = ::ReadFile (handle, buf, static_cast <DWORD> (nbytes), &bytes_read, &overlapped); if (result == FALSE) { if (::GetLastError () != ERROR_IO_PENDING) return -1; else { result = ::GetOverlappedResult (handle, &overlapped, &bytes_read, TRUE); if (result == FALSE) return -1; } } # else /* ACE_HAS_WIN32_OVERLAPPED_IO */ BOOL result = ::ReadFile (handle, buf, nbytes, &bytes_read, 0); if (result == FALSE) return -1; # endif /* ACE_HAS_WIN32_OVERLAPPED_IO */ // Reset the original file pointer position if (::SetFilePointer (handle, original_low_position, &original_high_position, FILE_BEGIN) == INVALID_SET_FILE_POINTER && GetLastError () != NO_ERROR) { ACE_OS::set_errno_to_last_error (); return -1; } return (ssize_t) bytes_read; # else /* ACE_WIN32 */ return ::pread (handle, buf, nbytes, offset); # endif /* ACE_WIN32 */ # else /* ACE_HAS_P_READ_WRITE */ ACE_OS_GUARD // Remember the original file pointer position ACE_OFF_T original_position = ACE_OS::lseek (handle, 0, SEEK_CUR); if (original_position == -1) return -1; // Go to the correct position ACE_OFF_T altered_position = ACE_OS::lseek (handle, offset, SEEK_SET); if (altered_position == -1) return -1; ssize_t const bytes_read = ACE_OS::read (handle, buf, nbytes); if (bytes_read == -1) return -1; if (ACE_OS::lseek (handle, original_position, SEEK_SET) == -1) return -1; return bytes_read; # endif /* ACE_HAD_P_READ_WRITE */ }
int ACE_OS::printf | ( | const char * | format, | |
... | ||||
) |
Definition at line 296 of file OS_NS_stdio.cpp.
{ // ACE_OS_TRACE ("ACE_OS::printf"); va_list ap; va_start (ap, format); int const result = ACE_OS::vprintf (format, ap); va_end (ap); return result; }
long ACE_OS::priority_control | ( | ACE_idtype_t | idtype, | |
ACE_id_t | identifier, | |||
int | cmd, | |||
void * | arg | |||
) | [inline] |
Low-level interface to priocntl(2)
.
Can't call the following priocntl, because that's a macro on Solaris.
Definition at line 458 of file OS_NS_Thread.inl.
{ ACE_OS_TRACE ("ACE_OS::priority_control"); #if defined (ACE_HAS_PRIOCNTL) ACE_OSCALL_RETURN (priocntl (idtype, identifier, cmd, static_cast<caddr_t> (arg)), long, -1); #else /* ! ACE_HAS_PRIOCNTL*/ ACE_UNUSED_ARG (idtype); ACE_UNUSED_ARG (identifier); ACE_UNUSED_ARG (cmd); ACE_UNUSED_ARG (arg); ACE_NOTSUP_RETURN (-1); #endif /* ! ACE_HAS_PRIOCNTL*/ }
int ACE_OS::pthread_sigmask | ( | int | how, | |
const sigset_t * | nsp, | |||
sigset_t * | osp | |||
) | [inline] |
Definition at line 27 of file OS_NS_signal.inl.
{ #if defined (ACE_HAS_PTHREADS) && !defined (ACE_LACKS_PTHREAD_SIGMASK) int result; ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_sigmask (how, nsp, osp), result), int, -1); #else /* !ACE_HAS_PTHREADS && !ACE_LACKS_PTHREAD_SIGMASK */ ACE_UNUSED_ARG (how); ACE_UNUSED_ARG (nsp); ACE_UNUSED_ARG (osp); ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_PTHREADS && !ACE_LACKS_PTHREAD_SIGMASK */ }
int ACE_OS::putc | ( | int | c, | |
FILE * | fp | |||
) | [inline] |
Definition at line 661 of file OS_NS_stdio.inl.
{ return ace_putc_helper (c, fp); }
int ACE_OS::putenv | ( | const char * | string | ) | [inline] |
Function that is called by <ACE_OS::exit>, if non-null.
Definition at line 305 of file OS_NS_stdlib.inl.
{ ACE_OS_TRACE ("ACE_OS::putenv"); #if defined (ACE_LACKS_PUTENV) && defined (ACE_HAS_SETENV) int result = 0; char *sp = ACE_OS::strchr (const_cast <char *> (string), '='); if (sp) { char *stmp = ACE_OS::strdup (string); if (stmp) { stmp[sp - string] = '\0'; result = ACE_OS::setenv (stmp, sp+sizeof (char), 1); ACE_OS::free (stmp); } else { errno = ENOMEM; result = -1; } } else { result = ACE_OS::setenv (string, "", 1); } return result; #elif defined (ACE_LACKS_PUTENV) ACE_UNUSED_ARG (string); ACE_NOTSUP_RETURN (0); #else /* ! ACE_HAS_WINCE */ ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::putenv (const_cast <char *> (string)), int, -1); #endif /* ACE_LACKS_PUTENV && ACE_HAS_SETENV */ }
int ACE_OS::putmsg | ( | ACE_HANDLE | handle, | |
const struct strbuf * | ctl, | |||
const struct strbuf * | data, | |||
int | flags | |||
) | [inline] |
Definition at line 139 of file OS_NS_stropts.inl.
{ ACE_OS_TRACE ("ACE_OS::putmsg"); #if defined (ACE_HAS_STREAM_PIPES) ACE_OSCALL_RETURN (::putmsg (handle, (ACE_STRBUF_TYPE) ctl, (ACE_STRBUF_TYPE) data, flags), int, -1); #else ACE_UNUSED_ARG (flags); ssize_t result; if (ctl == 0 && data == 0) { errno = EINVAL; return 0; } // Handle the two easy cases. else if (ctl != 0) { result = ACE_OS::write (handle, ctl->buf, ctl->len); return static_cast<int> (result); } else if (data != 0) { result = ACE_OS::write (handle, data->buf, data->len); return static_cast<int> (result); } else { // This is the hard case. char *buf; ACE_NEW_RETURN (buf, char [ctl->len + data->len], -1); ACE_OS::memcpy (buf, ctl->buf, ctl->len); ACE_OS::memcpy (buf + ctl->len, data->buf, data->len); result = ACE_OS::write (handle, buf, ctl->len + data->len); delete [] buf; return static_cast<int> (result); } #endif /* ACE_HAS_STREAM_PIPES */ }
int ACE_OS::putpmsg | ( | ACE_HANDLE | handle, | |
const struct strbuf * | ctl, | |||
const struct strbuf * | data, | |||
int | band, | |||
int | flags | |||
) | [inline] |
Definition at line 182 of file OS_NS_stropts.inl.
{ ACE_OS_TRACE ("ACE_OS::putpmsg"); #if defined (ACE_HAS_STREAM_PIPES) ACE_OSCALL_RETURN (::putpmsg (handle, (ACE_STRBUF_TYPE) ctl, (ACE_STRBUF_TYPE) data, band, flags), int, -1); #else ACE_UNUSED_ARG (flags); ACE_UNUSED_ARG (band); return ACE_OS::putmsg (handle, ctl, data, flags); #endif /* ACE_HAS_STREAM_PIPES */ }
int ACE_OS::puts | ( | const char * | s | ) | [inline] |
Definition at line 784 of file OS_NS_stdio.inl.
{ ACE_OS_TRACE ("ACE_OS::puts"); ACE_OSCALL_RETURN (::puts (s), int, -1); }
Definition at line 632 of file OS_NS_unistd.cpp.
{ # if defined (ACE_HAS_P_READ_WRITE) # if defined (ACE_WIN32) ACE_OS_GUARD // Remember the original file pointer position LONG original_high_position = 0; DWORD original_low_position = ::SetFilePointer (handle, 0, &original_high_position, FILE_CURRENT); if (original_low_position == INVALID_SET_FILE_POINTER && GetLastError () != NO_ERROR) { ACE_OS::set_errno_to_last_error (); return -1; } DWORD bytes_written; LONG low_offset = ACE_LOW_PART (offset); LONG high_offset = ACE_HIGH_PART (offset); # if defined (ACE_HAS_WIN32_OVERLAPPED_IO) OVERLAPPED overlapped; overlapped.Internal = 0; overlapped.InternalHigh = 0; overlapped.Offset = low_offset; overlapped.OffsetHigh = high_offset; overlapped.hEvent = 0; BOOL result = ::WriteFile (handle, buf, static_cast <DWORD> (nbytes), &bytes_written, &overlapped); if (result == FALSE) { if (::GetLastError () != ERROR_IO_PENDING) { return -1; } else { result = ::GetOverlappedResult (handle, &overlapped, &bytes_written, TRUE); if (result == FALSE) return -1; } } # else /* ACE_HAS_WIN32_OVERLAPPED_IO */ if (::SetFilePointer (handle, low_offset, &high_offset, FILE_BEGIN) == INVALID_SET_FILE_POINTER && ::GetLastError () != NO_ERROR) { ACE_OS::set_errno_to_last_error (); return -1; } BOOL result = ::WriteFile (handle, buf, nbytes, &bytes_written, 0); if (result == FALSE) return -1; # endif /* ACE_HAS_WIN32_OVERLAPPED_IO */ // Reset the original file pointer position if (::SetFilePointer (handle, original_low_position, &original_high_position, FILE_BEGIN) == INVALID_SET_FILE_POINTER && GetLastError () != NO_ERROR) { ACE_OS::set_errno_to_last_error (); return -1; } return (ssize_t) bytes_written; # else /* ACE_WIN32 */ return ::pwrite (handle, buf, nbytes, offset); # endif /* ACE_WIN32 */ # else /* ACE_HAS_P_READ_WRITE */ ACE_OS_GUARD // Remember the original file pointer position ACE_OFF_T original_position = ACE_OS::lseek (handle, 0, SEEK_CUR); if (original_position == -1) return -1; // Go to the correct position ACE_OFF_T altered_position = ACE_OS::lseek (handle, offset, SEEK_SET); if (altered_position == -1) return -1; ssize_t const bytes_written = ACE_OS::write (handle, buf, nbytes); if (bytes_written == -1) return -1; if (ACE_OS::lseek (handle, original_position, SEEK_SET) == -1) return -1; return bytes_written; # endif /* ACE_HAS_P_READ_WRITE */ }
void ACE_OS::qsort | ( | void * | base, | |
size_t | nel, | |||
size_t | width, | |||
ACE_COMPARE_FUNC | compar | |||
) | [inline] |
Function that is called by <ACE_OS::exit>, if non-null.
Definition at line 384 of file OS_NS_stdlib.inl.
{ #if !defined (ACE_LACKS_QSORT) ::qsort (base, nel, width, compar); #else ACE_UNUSED_ARG (base); ACE_UNUSED_ARG (nel); ACE_UNUSED_ARG (width); ACE_UNUSED_ARG (compar); #endif /* !ACE_LACKS_QSORT */ }
int ACE_OS::raise | ( | const int | signum | ) | [inline] |
Definition at line 231 of file OS_NS_signal.inl.
{ #if defined (ACE_LACKS_RAISE) ACE_UNUSED_ARG (signum); ACE_NOTSUP_RETURN (-1); #else ACE_OSCALL_RETURN (::raise (signum), int, -1); #endif /* ACE_LACKS_RAISE */ }
int ACE_OS::rand | ( | void | ) | [inline] |
Function that is called by <ACE_OS::exit>, if non-null.
Definition at line 400 of file OS_NS_stdlib.inl.
{ ACE_OS_TRACE ("ACE_OS::rand"); ACE_OSCALL_RETURN (::rand (), int, -1); }
int ACE_OS::rand_r | ( | ACE_RANDR_TYPE & | seed | ) | [inline] |
Function that is called by <ACE_OS::exit>, if non-null.
Definition at line 409 of file OS_NS_stdlib.inl.
{ ACE_OS_TRACE ("ACE_OS::rand_r"); # if defined (ACE_HAS_REENTRANT_FUNCTIONS) && \ !defined (ACE_LACKS_RAND_REENTRANT_FUNCTIONS) # if defined (DIGITAL_UNIX) ACE_OSCALL_RETURN (::_Prand_r (&seed), int, -1); # elif defined (ACE_HAS_BROKEN_RANDR) ACE_OSCALL_RETURN (::rand_r (seed), int, -1); # else ACE_OSCALL_RETURN (::rand_r (&seed), int, -1); # endif /* DIGITAL_UNIX */ # else ACE_UNUSED_ARG (seed); ACE_OSCALL_RETURN (::rand (), int, -1); # endif /* ACE_HAS_REENTRANT_FUNCTIONS */ }
ssize_t ACE_OS::read | ( | ACE_HANDLE | handle, | |
void * | buf, | |||
size_t | len | |||
) | [inline] |
Definition at line 722 of file OS_NS_unistd.inl.
{ ACE_OS_TRACE ("ACE_OS::read"); #if defined (ACE_WIN32) DWORD ok_len; if (::ReadFile (handle, buf, static_cast<DWORD> (len), &ok_len, 0)) return (ssize_t) ok_len; else ACE_FAIL_RETURN (-1); #else ssize_t result; # if defined (ACE_HAS_CHARPTR_SOCKOPT) ACE_OSCALL (::read (handle, static_cast <char *> (buf), len), ssize_t, -1, result); # else ACE_OSCALL (::read (handle, buf, len), ssize_t, -1, result); # endif /* ACE_HAS_CHARPTR_SOCKOPT */ # if !(defined (EAGAIN) && defined (EWOULDBLOCK) && EAGAIN == EWOULDBLOCK) // Optimize this code out if we can detect that EAGAIN == // EWOULDBLOCK at compile time. If we cannot detect equality at // compile-time (e.g. if EAGAIN or EWOULDBLOCK are not preprocessor // macros) perform the check at run-time. The goal is to avoid two // TSS accesses in the _REENTRANT case when EAGAIN == EWOULDBLOCK. if (result == -1 # if !defined (EAGAIN) || !defined (EWOULDBLOCK) && EAGAIN != EWOULDBLOCK # endif /* !EAGAIN || !EWOULDBLOCK */ && errno == EAGAIN) { errno = EWOULDBLOCK; } # endif /* EAGAIN != EWOULDBLOCK*/ return result; #endif /* ACE_WIN32 */ }
ssize_t ACE_OS::read | ( | ACE_HANDLE | handle, | |
void * | buf, | |||
size_t | len, | |||
ACE_OVERLAPPED * | overlapped | |||
) | [inline] |
Definition at line 762 of file OS_NS_unistd.inl.
{ ACE_OS_TRACE ("ACE_OS::read"); overlapped = overlapped; #if defined (ACE_WIN32) DWORD ok_len; DWORD short_len = static_cast<DWORD> (len); if (::ReadFile (handle, buf, short_len, &ok_len, overlapped)) return (ssize_t) ok_len; else ACE_FAIL_RETURN (-1); #else return ACE_OS::read (handle, buf, len); #endif /* ACE_WIN32 */ }
ssize_t ACE_OS::read_n | ( | ACE_HANDLE | handle, | |
void * | buf, | |||
size_t | len, | |||
size_t * | bytes_transferred = 0 | |||
) |
Receive len bytes into buf from handle (uses the <ACE_OS::read> call, which uses the <read> system call on UNIX and the <ReadFile> 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 469 of file OS_NS_unistd.cpp.
{ size_t temp; size_t &bytes_transferred = bt == 0 ? temp : *bt; ssize_t n = 0; for (bytes_transferred = 0; bytes_transferred < len; bytes_transferred += n) { n = ACE_OS::read (handle, (char *) buf + bytes_transferred, len - bytes_transferred); if (n == -1 || n == 0) { return n; } } return ACE_Utils::truncate_cast<ssize_t> (bytes_transferred); }
struct ACE_DIRENT * ACE_OS::readdir | ( | ACE_DIR * | d | ) | [read] |
Definition at line 55 of file OS_NS_dirent.inl.
{ #if defined (ACE_HAS_DIRENT) # if defined (ACE_WIN32) && defined (ACE_LACKS_READDIR) return ACE_OS::readdir_emulation (d); # elif defined (ACE_HAS_WREADDIR) && defined (ACE_USES_WCHAR) return ::wreaddir (d); # else /* ACE_WIN32 && ACE_LACKS_READDIR */ return ::readdir (d); # endif /* ACE_WIN32 && ACE_LACKS_READDIR */ #else ACE_UNUSED_ARG (d); ACE_NOTSUP_RETURN (0); #endif /* ACE_HAS_DIRENT */ }
int ACE_OS::readdir_r | ( | ACE_DIR * | dirp, | |
struct ACE_DIRENT * | entry, | |||
struct ACE_DIRENT ** | result | |||
) | [inline] |
Definition at line 72 of file OS_NS_dirent.inl.
{ #if !defined (ACE_HAS_REENTRANT_FUNCTIONS) ACE_UNUSED_ARG (entry); // <result> has better not be 0! *result = ACE_OS::readdir (dirp); if (*result) return 0; // Keep iterating else return 1; // Oops, some type of error! #elif defined (ACE_HAS_DIRENT) && !defined (ACE_LACKS_READDIR_R) # if defined (ACE_HAS_3_PARAM_READDIR_R) return ::readdir_r (dirp, entry, result); # else // <result> had better not be 0! *result = ::readdir_r (dirp, entry); return 0; # endif /* sun */ #else /* ! ACE_HAS_DIRENT || ACE_LACKS_READDIR_R */ ACE_UNUSED_ARG (dirp); ACE_UNUSED_ARG (entry); ACE_UNUSED_ARG (result); ACE_NOTSUP_RETURN (0); #endif /* ACE_HAS_REENTRANT_FUNCTIONS */ }
ssize_t ACE_OS::readlink | ( | const char * | path, | |
char * | buf, | |||
size_t | bufsiz | |||
) | [inline] |
Definition at line 780 of file OS_NS_unistd.inl.
{ ACE_OS_TRACE ("ACE_OS::readlink"); # if defined (ACE_LACKS_READLINK) ACE_UNUSED_ARG (path); ACE_UNUSED_ARG (buf); ACE_UNUSED_ARG (bufsiz); ACE_NOTSUP_RETURN (-1); # elif defined(ACE_HAS_NONCONST_READLINK) ACE_OSCALL_RETURN ( ::readlink (const_cast <char *>(path), buf, bufsiz), ssize_t, -1); # else ACE_OSCALL_RETURN (::readlink (path, buf, bufsiz), ssize_t, -1); # endif /* ACE_LACKS_READLINK */ }
ssize_t ACE_OS::readv | ( | ACE_HANDLE | handle, | |
const iovec * | iov, | |||
int | iovlen | |||
) | [inline] |
Definition at line 10 of file OS_NS_sys_uio.inl.
{ ACE_OS_TRACE ("ACE_OS::readv"); #if defined (ACE_LACKS_READV) ACE_OSCALL_RETURN (ACE_OS::readv_emulation (handle, iov, iovlen), ssize_t, -1); #else /* ACE_LACKS_READV */ #if defined (ACE_HAS_NONCONST_READV) ACE_OSCALL_RETURN (::readv (handle, const_cast<iovec *>(iov), iovlen), ssize_t, -1); #else ACE_OSCALL_RETURN (::readv (handle, iov, iovlen), ssize_t, -1); #endif /* ACE_HAS_NONCONST_READV */ #endif /* ACE_LACKS_READV */ }
void * ACE_OS::realloc | ( | void * | ptr, | |
size_t | nbytes | |||
) |
Function that is called by <ACE_OS::exit>, if non-null.
Definition at line 335 of file OS_NS_stdlib.cpp.
{ return ACE_REALLOC_FUNC (ACE_MALLOC_T (ptr), nbytes); }
char * ACE_OS::realpath | ( | const char * | file_name, | |
char * | resolved_name | |||
) | [inline] |
Function that is called by <ACE_OS::exit>, if non-null.
Definition at line 449 of file OS_NS_stdlib.inl.
{ # if defined (ACE_WIN32) return ::_fullpath (resolved_name, file_name, PATH_MAX); # else /* ACE_WIN32 */ return ::realpath (file_name, resolved_name); # endif /* ! ACE_WIN32 */ }
void ACE_OS::recursive_mutex_cond_relock | ( | ACE_recursive_thread_mutex_t * | m, | |
ACE_recursive_mutex_state & | state | |||
) | [inline] |
Definition at line 581 of file OS_NS_Thread.inl.
{ #if defined (ACE_HAS_THREADS) ACE_OS_TRACE ("ACE_OS::recursive_mutex_cond_relock"); # if defined (ACE_HAS_RECURSIVE_MUTEXES) // Windows need special handling since it has recursive mutexes, but // does not integrate them into a condition variable. // On entry, the OS has already reacquired the lock for us. Just // reacquire it the proper number of times so the recursion is the same as // before waiting on the condition. # if defined (ACE_WIN32) while (state.relock_count_ > 0) { ACE_OS::recursive_mutex_lock (m); --state.relock_count_; } return; # else /* not ACE_WIN32 */ // prevent warnings for unused variables ACE_UNUSED_ARG (state); ACE_UNUSED_ARG (m); # endif /* ACE_WIN32 */ # else // Without recursive mutex support, it's somewhat trickier. On entry, // the current thread holds the nesting_mutex_, but another thread may // still be holding the ACE_recursive_mutex_t. If so, mimic the code // in ACE_OS::recursive_mutex_lock that waits to acquire the mutex. // After acquiring it, restore the nesting counts and release the // nesting mutex. This will restore the conditions to what they were // before calling ACE_OS::recursive_mutex_cond_unlock(). while (m->nesting_level_ > 0) ACE_OS::cond_wait (&m->lock_available_, &m->nesting_mutex_); // At this point, we still have nesting_mutex_ and the mutex is free. m->nesting_level_ = state.nesting_level_; m->owner_id_ = state.owner_id_; ACE_OS::thread_mutex_unlock (&m->nesting_mutex_); return; # endif /* ACE_HAS_RECURSIVE_MUTEXES */ #else ACE_UNUSED_ARG (m); ACE_UNUSED_ARG (state); return; #endif /* ACE_HAS_THREADS */ }
int ACE_OS::recursive_mutex_cond_unlock | ( | ACE_recursive_thread_mutex_t * | m, | |
ACE_recursive_mutex_state & | state | |||
) | [inline] |
Definition at line 480 of file OS_NS_Thread.inl.
{ #if defined (ACE_HAS_THREADS) ACE_OS_TRACE ("ACE_OS::recursive_mutex_cond_unlock"); # if defined (ACE_HAS_RECURSIVE_MUTEXES) // Windows need special handling since it has recursive mutexes, but // does not integrate them into a condition variable. # if defined (ACE_WIN32) // For Windows, the OS takes care of the mutex and its recursion. We just // need to release the lock one fewer times than this thread has acquired // it. Remember how many times, and reacquire it that many more times when // the condition is signaled. // We're using undocumented fields in the CRITICAL_SECTION structure // and they've been known to change across Windows variants and versions./ // So be careful if you need to change these - there may be other // Windows variants that depend on existing values and limits. state.relock_count_ = 0; while ( # if !defined (ACE_HAS_WINCE) m->LockCount > 0 && m->RecursionCount > 1 # else // WinCE doesn't have RecursionCount and the LockCount semantic // Mobile 5 has it 1-indexed. m->LockCount > 1 # endif /* ACE_HAS_WINCE */ ) { // This may fail if the current thread doesn't own the mutex. If it // does fail, it'll be on the first try, so don't worry about resetting // the state. if (ACE_OS::recursive_mutex_unlock (m) == -1) return -1; ++state.relock_count_; } # else /* not ACE_WIN32 */ // prevent warnings for unused variables ACE_UNUSED_ARG (state); ACE_UNUSED_ARG (m); # endif /* ACE_WIN32 */ return 0; # else /* ACE_HAS_RECURSIVE_MUTEXES */ // For platforms without recursive mutexes, we obtain the nesting mutex // to gain control over the mutex internals. Then set the internals to say // the mutex is available. If there are waiters, signal the condition // to notify them (this is mostly like the recursive_mutex_unlock() method). // Then, return with the nesting mutex still held. The condition wait // will release it atomically, allowing mutex waiters to continue. // Note that this arrangement relies on the fact that on return from // the condition wait, this thread will again own the nesting mutex // and can either set the mutex internals directly or get in line for // the mutex... this part is handled in recursive_mutex_cond_relock(). if (ACE_OS::thread_mutex_lock (&m->nesting_mutex_) == -1) return -1; # if !defined (ACE_NDEBUG) if (m->nesting_level_ == 0 || ACE_OS::thr_equal (ACE_OS::thr_self (), m->owner_id_) == 0) { ACE_OS::thread_mutex_unlock (&m->nesting_mutex_); errno = EINVAL; return -1; } # endif /* ACE_NDEBUG */ // To make error recovery a bit easier, signal the condition now. Any // waiter won't regain control until the mutex is released, which won't // be until the caller returns and does the wait on the condition. if (ACE_OS::cond_signal (&m->lock_available_) == -1) { // Save/restore errno. ACE_Errno_Guard error (errno); ACE_OS::thread_mutex_unlock (&m->nesting_mutex_); return -1; } // Ok, the nesting_mutex_ lock is still held, the condition has been // signaled... reset the nesting info and return _WITH_ the lock // held. The lock will be released when the condition waits, in the // caller. state.nesting_level_ = m->nesting_level_; state.owner_id_ = m->owner_id_; m->nesting_level_ = 0; m->owner_id_ = ACE_OS::NULL_thread; return 0; # endif /* ACE_HAS_RECURSIVE_MUTEXES */ #else ACE_UNUSED_ARG (m); ACE_UNUSED_ARG (state); ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_THREADS */ }
int ACE_OS::recursive_mutex_destroy | ( | ACE_recursive_thread_mutex_t * | m | ) | [inline] |
Definition at line 630 of file OS_NS_Thread.inl.
{ #if defined (ACE_HAS_THREADS) #if defined (ACE_HAS_RECURSIVE_MUTEXES) return ACE_OS::thread_mutex_destroy (m); #else if (ACE_OS::thread_mutex_destroy (&m->nesting_mutex_) == -1) return -1; else if (ACE_OS::cond_destroy (&m->lock_available_) == -1) return -1; else return 0; #endif /* ACE_HAS_RECURSIVE_MUTEXES */ #else ACE_UNUSED_ARG (m); ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_THREADS */ }
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 | |||
) | [inline] |
Definition at line 650 of file OS_NS_Thread.inl.
{ ACE_UNUSED_ARG (sa); #if defined (ACE_HAS_THREADS) # if defined (ACE_HAS_RECURSIVE_MUTEXES) # if defined (ACE_HAS_PTHREADS_UNIX98_EXT) return ACE_OS::thread_mutex_init (m, PTHREAD_MUTEX_RECURSIVE, name, arg); # else return ACE_OS::thread_mutex_init (m, 0, name, arg); # endif /* ACE_HAS_PTHREADS_UNIX98_EXT */ # else if (ACE_OS::thread_mutex_init (&m->nesting_mutex_, 0, name, arg) == -1) return -1; else if (ACE_OS::cond_init (&m->lock_available_, (short) USYNC_THREAD, name, 0) == -1) return -1; else { m->nesting_level_ = 0; m->owner_id_ = ACE_OS::NULL_thread; return 0; } # endif /* ACE_HAS_RECURSIVE_MUTEXES */ #else ACE_UNUSED_ARG (m); ACE_UNUSED_ARG (name); ACE_UNUSED_ARG (arg); ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_THREADS */ }
int ACE_OS::recursive_mutex_lock | ( | ACE_recursive_thread_mutex_t * | m, | |
const ACE_Time_Value * | timeout | |||
) | [inline] |
Definition at line 803 of file OS_NS_Thread.inl.
{ return timeout == 0 ? ACE_OS::recursive_mutex_lock (m) : ACE_OS::recursive_mutex_lock (m, *timeout); }
int ACE_OS::recursive_mutex_lock | ( | ACE_recursive_thread_mutex_t * | m | ) | [inline] |
Definition at line 687 of file OS_NS_Thread.inl.
{ #if defined (ACE_HAS_THREADS) #if defined (ACE_HAS_RECURSIVE_MUTEXES) return ACE_OS::thread_mutex_lock (m); #else ACE_thread_t const t_id = ACE_OS::thr_self (); int result = 0; // Acquire the guard. if (ACE_OS::thread_mutex_lock (&m->nesting_mutex_) == -1) result = -1; else { // If there's no contention, just grab the lock immediately // (since this is the common case we'll optimize for it). if (m->nesting_level_ == 0) m->owner_id_ = t_id; // If we already own the lock, then increment the nesting level // and return. else if (ACE_OS::thr_equal (t_id, m->owner_id_) == 0) { // Wait until the nesting level has dropped to zero, at // which point we can acquire the lock. while (m->nesting_level_ > 0) ACE_OS::cond_wait (&m->lock_available_, &m->nesting_mutex_); // At this point the nesting_mutex_ is held... m->owner_id_ = t_id; } // At this point, we can safely increment the nesting_level_ no // matter how we got here! ++m->nesting_level_; } { // Save/restore errno. ACE_Errno_Guard error (errno); ACE_OS::thread_mutex_unlock (&m->nesting_mutex_); } return result; #endif /* ACE_HAS_RECURSIVE_MUTEXES */ #else ACE_UNUSED_ARG (m); ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_THREADS */ }
int ACE_OS::recursive_mutex_lock | ( | ACE_recursive_thread_mutex_t * | m, | |
const ACE_Time_Value & | timeout | |||
) | [inline] |
Definition at line 738 of file OS_NS_Thread.inl.
{ #if defined (ACE_HAS_THREADS) #if defined (ACE_HAS_RECURSIVE_MUTEXES) return ACE_OS::thread_mutex_lock (m, timeout); #else ACE_thread_t t_id = ACE_OS::thr_self (); int result = 0; // Try to acquire the guard. if (ACE_OS::thread_mutex_lock (&m->nesting_mutex_, timeout) == -1) result = -1; else { // If there's no contention, just grab the lock immediately // (since this is the common case we'll optimize for it). if (m->nesting_level_ == 0) m->owner_id_ = t_id; // If we already own the lock, then increment the nesting level // and return. else if (ACE_OS::thr_equal (t_id, m->owner_id_) == 0) { // Wait until the nesting level has dropped to zero, at // which point we can acquire the lock. while (m->nesting_level_ > 0) { result = ACE_OS::cond_timedwait (&m->lock_available_, &m->nesting_mutex_, const_cast <ACE_Time_Value *> (&timeout)); // The mutex is reacquired even in the case of a timeout // release the mutex to prevent a deadlock if (result == -1) { // Save/restore errno. ACE_Errno_Guard error (errno); ACE_OS::thread_mutex_unlock (&m->nesting_mutex_); return result; } } // At this point the nesting_mutex_ is held... m->owner_id_ = t_id; } // At this point, we can safely increment the nesting_level_ no // matter how we got here! m->nesting_level_++; // Save/restore errno. ACE_Errno_Guard error (errno); ACE_OS::thread_mutex_unlock (&m->nesting_mutex_); } return result; #endif /* ACE_HAS_RECURSIVE_MUTEXES */ #else ACE_UNUSED_ARG (m); ACE_UNUSED_ARG (timeout); ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_THREADS */ }
int ACE_OS::recursive_mutex_trylock | ( | ACE_recursive_thread_mutex_t * | m | ) | [inline] |
Definition at line 812 of file OS_NS_Thread.inl.
{ #if defined (ACE_HAS_THREADS) #if defined (ACE_HAS_RECURSIVE_MUTEXES) return ACE_OS::thread_mutex_trylock (m); #else ACE_thread_t t_id = ACE_OS::thr_self (); int result = 0; // Acquire the guard. if (ACE_OS::thread_mutex_lock (&m->nesting_mutex_) == -1) result = -1; else { // If there's no contention, just grab the lock immediately. if (m->nesting_level_ == 0) { m->owner_id_ = t_id; m->nesting_level_ = 1; } // If we already own the lock, then increment the nesting level // and proceed. else if (ACE_OS::thr_equal (t_id, m->owner_id_)) m->nesting_level_++; else { errno = EBUSY; result = -1; } } { // Save/restore errno. ACE_Errno_Guard error (errno); ACE_OS::thread_mutex_unlock (&m->nesting_mutex_); } return result; #endif /* ACE_HAS_RECURSIVE_MUTEXES */ #else ACE_UNUSED_ARG (m); ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_THREADS */ }
int ACE_OS::recursive_mutex_unlock | ( | ACE_recursive_thread_mutex_t * | m | ) | [inline] |
Definition at line 857 of file OS_NS_Thread.inl.
{ #if defined (ACE_HAS_THREADS) # if defined (ACE_HAS_RECURSIVE_MUTEXES) return ACE_OS::thread_mutex_unlock (m); # else ACE_OS_TRACE ("ACE_OS::recursive_mutex_unlock"); # if !defined (ACE_NDEBUG) ACE_thread_t t_id = ACE_OS::thr_self (); # endif /* ACE_NDEBUG */ int result = 0; if (ACE_OS::thread_mutex_lock (&m->nesting_mutex_) == -1) result = -1; else { # if !defined (ACE_NDEBUG) if (m->nesting_level_ == 0 || ACE_OS::thr_equal (t_id, m->owner_id_) == 0) { errno = EINVAL; result = -1; } else # endif /* ACE_NDEBUG */ { m->nesting_level_--; if (m->nesting_level_ == 0) { // This may not be strictly necessary, but it does put // the mutex into a known state... m->owner_id_ = ACE_OS::NULL_thread; // Inform a waiter that the lock is free. if (ACE_OS::cond_signal (&m->lock_available_) == -1) result = -1; } } } { // Save/restore errno. ACE_Errno_Guard error (errno); ACE_OS::thread_mutex_unlock (&m->nesting_mutex_); } return result; # endif /* ACE_HAS_RECURSIVE_MUTEXES */ #else ACE_UNUSED_ARG (m); ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_THREADS */ }
ssize_t ACE_OS::recv | ( | ACE_HANDLE | handle, | |
char * | buf, | |||
size_t | len, | |||
int | flags = 0 | |||
) | [inline] |
BSD-style accept
(no QoS).
Definition at line 316 of file OS_NS_sys_socket.inl.
{ ACE_OS_TRACE ("ACE_OS::recv"); // On UNIX, a non-blocking socket with no data to receive, this // system call will return EWOULDBLOCK or EAGAIN, depending on the // platform. UNIX 98 allows either errno, and they may be the same // numeric value. So to make life easier for upper ACE layers as // well as application programmers, always change EAGAIN to // EWOULDBLOCK. Rather than hack the ACE_OSCALL_RETURN macro, it's // handled explicitly here. If the ACE_OSCALL macro ever changes, // this function needs to be reviewed. On Win32, the regular macros // can be used, as this is not an issue. #if defined (ACE_LACKS_RECV) ACE_UNUSED_ARG (handle); ACE_UNUSED_ARG (buf); ACE_UNUSED_ARG (len); ACE_UNUSED_ARG (flags); ACE_NOTSUP_RETURN (-1); #elif defined (ACE_WIN32) ACE_SOCKCALL_RETURN (::recv ((ACE_SOCKET) handle, buf, static_cast<int> (len), flags), ssize_t, -1); #else ssize_t ace_result_; ace_result_ = ::recv ((ACE_SOCKET) handle, buf, len, flags); # if !(defined (EAGAIN) && defined (EWOULDBLOCK) && EAGAIN == EWOULDBLOCK) // Optimize this code out if we can detect that EAGAIN == // EWOULDBLOCK at compile time. If we cannot detect equality at // compile-time (e.g. if EAGAIN or EWOULDBLOCK are not preprocessor // macros) perform the check at run-time. The goal is to avoid two // TSS accesses in the _REENTRANT case when EAGAIN == EWOULDBLOCK. if (ace_result_ == -1 # if !defined (EAGAIN) || !defined (EWOULDBLOCK) && EAGAIN != EWOULDBLOCK # endif /* !EAGAIN || !EWOULDBLOCK */ && errno == EAGAIN) { errno = EWOULDBLOCK; } # endif /* EAGAIN != EWOULDBLOCK*/ return ace_result_; #endif /* ACE_LACKS_RECV */ }
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 | |||
) | [inline] |
BSD-style accept
(no QoS).
Definition at line 419 of file OS_NS_sys_socket.inl.
{ ACE_OS_TRACE ("ACE_OS::recvfrom"); #if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) DWORD bytes_recvd; DWORD the_flags = flags; int result = ::WSARecvFrom ((SOCKET) handle, (WSABUF*)buffers, buffer_count, &bytes_recvd, &the_flags, addr, addrlen, overlapped, func); if (result != 0) { ACE_OS::set_errno_to_wsa_last_error (); } flags = the_flags; number_of_bytes_recvd = static_cast<size_t> (bytes_recvd); return result; #else ACE_UNUSED_ARG (handle); ACE_UNUSED_ARG (buffers); ACE_UNUSED_ARG (buffer_count); ACE_UNUSED_ARG (number_of_bytes_recvd); ACE_UNUSED_ARG (flags); ACE_UNUSED_ARG (addr); ACE_UNUSED_ARG (addrlen); ACE_UNUSED_ARG (overlapped); ACE_UNUSED_ARG (func); ACE_NOTSUP_RETURN (-1); #endif /* defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) */ }
ssize_t ACE_OS::recvfrom | ( | ACE_HANDLE | handle, | |
char * | buf, | |||
size_t | len, | |||
int | flags, | |||
struct sockaddr * | addr, | |||
int * | addrlen | |||
) | [inline] |
BSD-style accept
(no QoS).
Definition at line 363 of file OS_NS_sys_socket.inl.
{ ACE_OS_TRACE ("ACE_OS::recvfrom"); #if defined (ACE_LACKS_RECVFROM) ACE_UNUSED_ARG (handle); ACE_UNUSED_ARG (buf); ACE_UNUSED_ARG (len); ACE_UNUSED_ARG (flags); ACE_UNUSED_ARG (addr); ACE_UNUSED_ARG (addrlen); ACE_NOTSUP_RETURN (-1); #elif defined (ACE_WIN32) int const shortened_len = static_cast<int> (len); int const result = ::recvfrom ((ACE_SOCKET) handle, buf, shortened_len, flags, addr, (ACE_SOCKET_LEN *) addrlen); if (result == SOCKET_ERROR) { ACE_OS::set_errno_to_wsa_last_error (); if (errno == WSAEMSGSIZE && ACE_BIT_ENABLED (flags, MSG_PEEK)) return shortened_len; else return -1; } else { # if defined (ACE_HAS_PHARLAP) // Pharlap ETS (at least to v13) returns a legit address but doesn't // include the sin_zero[8] bytes in the count. Correct for this here. if (addrlen != 0 && addr != 0 && *addrlen == 8 && addr->sa_family == AF_INET) *addrlen = sizeof(sockaddr_in); # endif /* ACE_HAS_PHARLAP */ return result; } #else /* non Win32 */ ACE_SOCKCALL_RETURN (::recvfrom ((ACE_SOCKET) handle, buf, len, flags, addr, (ACE_SOCKET_LEN *) addrlen), ssize_t, -1); #endif /* ACE_LACKS_RECVFROM */ }
BSD-style accept
(no QoS).
Definition at line 464 of file OS_NS_sys_socket.inl.
{ ACE_OS_TRACE ("ACE_OS::recvmsg"); #if !defined (ACE_LACKS_RECVMSG) # if (defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)) DWORD bytes_received = 0; int result = ::WSARecvFrom ((SOCKET) handle, (WSABUF *) msg->msg_iov, msg->msg_iovlen, &bytes_received, (DWORD *) &flags, msg->msg_name, &msg->msg_namelen, 0, 0); if (result != 0) { ACE_OS::set_errno_to_wsa_last_error (); return -1; } else return bytes_received; # else /* ACE_HAS_WINSOCK2 */ ACE_SOCKCALL_RETURN (::recvmsg (handle, msg, flags), ssize_t, -1); # endif /* ACE_HAS_WINSOCK2 */ #else ACE_UNUSED_ARG (flags); ACE_UNUSED_ARG (msg); ACE_UNUSED_ARG (handle); ACE_NOTSUP_RETURN (-1); #endif /* ACE_LACKS_RECVMSG */ }
ssize_t ACE_OS::recvv | ( | ACE_HANDLE | handle, | |
iovec * | iov, | |||
int | iovlen | |||
) | [inline] |
BSD-style accept
(no QoS).
Definition at line 501 of file OS_NS_sys_socket.inl.
{ #if defined (ACE_HAS_WINSOCK2) DWORD bytes_received = 0; int result = 1; // Winsock 2 has WSARecv and can do this directly, but Winsock 1 needs // to do the recvs piece-by-piece. # if (ACE_HAS_WINSOCK2 != 0) DWORD flags = 0; result = ::WSARecv ((SOCKET) handle, (WSABUF *) buffers, n, &bytes_received, &flags, 0, 0); # else // Step through the buffers requested by caller; for each one, cycle // through reads until it's filled or an error occurs. for (int i = 0; i < n && result > 0; ++i) { char *chunkp = buffers[i].iov_base; // Point to part of chunk being read int chunklen = buffers[i].iov_len; // Track how much to read to chunk while (chunklen > 0 && result > 0) { result = ::recv ((SOCKET) handle, chunkp, chunklen, 0); if (result > 0) { chunkp += result; chunklen -= result; bytes_received += result; } } } # endif /* ACE_HAS_WINSOCK2 != 0 */ if (result == SOCKET_ERROR) { ACE_OS::set_errno_to_wsa_last_error (); return -1; } else return (ssize_t) bytes_received; #else return ACE_OS::readv (handle, buffers, n); #endif /* ACE_HAS_WINSOCK2 */ }
int ACE_OS::rename | ( | const char * | old_name, | |
const char * | new_name, | |||
int | flags = -1 | |||
) | [inline] |
Definition at line 806 of file OS_NS_stdio.inl.
{ # if defined (ACE_LACKS_RENAME) ACE_UNUSED_ARG (old_name); ACE_UNUSED_ARG (new_name); ACE_UNUSED_ARG (flags); ACE_NOTSUP_RETURN (-1); # elif defined (ACE_HAS_WINCE) // Win CE is always wide-char. ACE_UNUSED_ARG (flags); if (0 == ::MoveFile (ACE_TEXT_CHAR_TO_TCHAR (old_name), ACE_TEXT_CHAR_TO_TCHAR (new_name))) ACE_FAIL_RETURN (-1); return 0; # elif defined (ACE_WIN32) && !defined (ACE_LACKS_WIN32_MOVEFILEEX) // NT4 (and up) provides a way to rename/move a file with similar semantics // to what's usually done on UNIX - if there's an existing file with // <new_name> it is removed before the file is renamed/moved. The // MOVEFILE_COPY_ALLOWED is specified to allow such a rename across drives. if (flags == -1) flags = MOVEFILE_COPY_ALLOWED | MOVEFILE_REPLACE_EXISTING; if (::MoveFileExA (old_name, new_name, flags) == 0) ACE_FAIL_RETURN (-1); return 0; # else /* ACE_LACKS_RENAME */ ACE_UNUSED_ARG (flags); ACE_OSCALL_RETURN (::rename (old_name, new_name), int, -1); # endif /* ACE_LACKS_RENAME */ }
void ACE_OS::rewind | ( | FILE * | fp | ) | [inline] |
Definition at line 876 of file OS_NS_stdio.inl.
{ #if !defined (ACE_HAS_WINCE) ACE_OS_TRACE ("ACE_OS::rewind"); ::rewind (fp); #else // This isn't perfect since it doesn't reset EOF, but it's probably // the closest we can get on WINCE. (void) ::fseek (fp, 0L, SEEK_SET); #endif /* ACE_HAS_WINCE */ }
void ACE_OS::rewinddir | ( | ACE_DIR * | d | ) | [inline] |
Definition at line 102 of file OS_NS_dirent.inl.
{ #if defined (ACE_HAS_DIRENT) # if defined (ACE_HAS_WREWINDDIR) && defined (ACE_USES_WCHAR) ::wrewinddir (d); # elif !defined (ACE_LACKS_REWINDDIR) ace_rewinddir_helper (d); # else ACE_UNUSED_ARG (d); # endif /* !defined (ACE_LACKS_REWINDDIR) */ #endif /* ACE_HAS_DIRENT */ }
int ACE_OS::rmdir | ( | const char * | path | ) | [inline] |
Definition at line 151 of file OS_NS_unistd.inl.
{ #if defined (ACE_HAS_WINCE) ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::RemoveDirectory (ACE_TEXT_CHAR_TO_TCHAR(path)), ace_result_), int, -1); #else ACE_OSCALL_RETURN (::rmdir (path), int, -1); #endif /* ACE_WIN32 */ }
int ACE_OS::rw_rdlock | ( | ACE_rwlock_t * | rw | ) | [inline] |
Definition at line 911 of file OS_NS_Thread.inl.
{ ACE_OS_TRACE ("ACE_OS::rw_rdlock"); #if defined (ACE_HAS_THREADS) # if !defined (ACE_LACKS_RWLOCK_T) || defined (ACE_HAS_PTHREADS_UNIX98_EXT) # if defined (ACE_HAS_PTHREADS_UNIX98_EXT) int result; ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_rwlock_rdlock (rw), result), int, -1); # else /* Solaris */ int result; ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::rw_rdlock (rw), result), int, -1); # endif /* ACE_HAS_PTHREADS_UNIX98_EXT */ # else /* NT, POSIX, and VxWorks don't support this natively. */ # if defined (ACE_HAS_PTHREADS) ACE_PTHREAD_CLEANUP_PUSH (&rw->lock_); # endif /* ACE_HAS_PTHREADS */ int result = 0; if (ACE_OS::mutex_lock (&rw->lock_) == -1) result = -1; // -1 means didn't get the mutex. else { // Give preference to writers who are waiting. while (rw->ref_count_ < 0 || rw->num_waiting_writers_ > 0) { rw->num_waiting_readers_++; if (ACE_OS::cond_wait (&rw->waiting_readers_, &rw->lock_) == -1) { result = -2; // -2 means that we need to release the mutex. break; } rw->num_waiting_readers_--; } } if (result == 0) rw->ref_count_++; if (result != -1) ACE_OS::mutex_unlock (&rw->lock_); # if defined (ACE_HAS_PTHREADS) ACE_PTHREAD_CLEANUP_POP (0); # endif /* defined (ACE_HAS_PTHREADS) */ return 0; # endif /* ! ACE_LACKS_RWLOCK_T */ #else ACE_UNUSED_ARG (rw); ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_THREADS */ }
int ACE_OS::rw_tryrdlock | ( | ACE_rwlock_t * | rw | ) | [inline] |
Definition at line 962 of file OS_NS_Thread.inl.
{ ACE_OS_TRACE ("ACE_OS::rw_tryrdlock"); #if defined (ACE_HAS_THREADS) # if !defined (ACE_LACKS_RWLOCK_T) || defined (ACE_HAS_PTHREADS_UNIX98_EXT) # if defined (ACE_HAS_PTHREADS_UNIX98_EXT) int result; ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_rwlock_tryrdlock (rw), result), int, -1); # else /* Solaris */ int result; ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::rw_tryrdlock (rw), result), int, -1); # endif /* ACE_HAS_PTHREADS_UNIX98_EXT */ # else /* NT, POSIX, and VxWorks don't support this natively. */ int result = -1; if (ACE_OS::mutex_lock (&rw->lock_) != -1) { ACE_Errno_Guard error (errno); if (rw->ref_count_ == -1 || rw->num_waiting_writers_ > 0) { error = EBUSY; result = -1; } else { rw->ref_count_++; result = 0; } ACE_OS::mutex_unlock (&rw->lock_); } return result; # endif /* ! ACE_LACKS_RWLOCK_T */ #else ACE_UNUSED_ARG (rw); ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_THREADS */ }
int ACE_OS::rw_trywrlock | ( | ACE_rwlock_t * | rw | ) | [inline] |
Definition at line 1005 of file OS_NS_Thread.inl.
{ ACE_OS_TRACE ("ACE_OS::rw_trywrlock"); #if defined (ACE_HAS_THREADS) # if !defined (ACE_LACKS_RWLOCK_T) || defined (ACE_HAS_PTHREADS_UNIX98_EXT) # if defined (ACE_HAS_PTHREADS_UNIX98_EXT) int result; ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_rwlock_trywrlock (rw), result), int, -1); # else /* Solaris */ int result; ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::rw_trywrlock (rw), result), int, -1); # endif /* ACE_HAS_PTHREADS_UNIX98_EXT */ # else /* NT, POSIX, and VxWorks don't support this natively. */ int result = -1; if (ACE_OS::mutex_lock (&rw->lock_) != -1) { ACE_Errno_Guard error (errno); if (rw->ref_count_ != 0) { error = EBUSY; result = -1; } else { rw->ref_count_ = -1; result = 0; } ACE_OS::mutex_unlock (&rw->lock_); } return result; # endif /* ! ACE_LACKS_RWLOCK_T */ #else ACE_UNUSED_ARG (rw); ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_THREADS */ }
int ACE_OS::rw_trywrlock_upgrade | ( | ACE_rwlock_t * | rw | ) | [inline] |
Definition at line 1054 of file OS_NS_Thread.inl.
{ ACE_OS_TRACE ("ACE_OS::rw_trywrlock_upgrade"); #if defined (ACE_HAS_THREADS) # if defined (ACE_HAS_PTHREADS_UNIX98_EXT) // This will probably result in -1, EDEADLK, at least on HP-UX, but let it // go - it's a more descriptive error than ENOTSUP. int result; ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_rwlock_trywrlock (rw), result), int, -1); # elif !defined (ACE_LACKS_RWLOCK_T) // Some native rwlocks, such as those on Solaris, don't // support the upgrade feature . . . ACE_UNUSED_ARG (rw); ACE_NOTSUP_RETURN (-1); # else /* NT, POSIX, and VxWorks don't support this natively. */ // The ACE rwlock emulation does support upgrade . . . int result = 0; # if defined (ACE_HAS_PTHREADS) ACE_PTHREAD_CLEANUP_PUSH (&rw->lock_); # endif /* defined (ACE_HAS_PTHREADS) */ if (ACE_OS::mutex_lock (&rw->lock_) == -1) return -1; // -1 means didn't get the mutex, error else if (rw->important_writer_) // an other reader upgrades already { result = -1; errno = EBUSY; } else { while (rw->ref_count_ > 1) // wait until only I am left { rw->num_waiting_writers_++; // prohibit any more readers rw->important_writer_ = true; if (ACE_OS::cond_wait (&rw->waiting_important_writer_, &rw->lock_) == -1) { result = -1; // we know that we have the lock again, we have this guarantee, // but something went wrong } rw->important_writer_ = false; rw->num_waiting_writers_--; } if (result == 0) { // nothing bad happend rw->ref_count_ = -1; // now I am a writer // everything is O.K. } } ACE_OS::mutex_unlock (&rw->lock_); # if defined (ACE_HAS_PTHREADS) ACE_PTHREAD_CLEANUP_POP (0); # endif /* defined (ACE_HAS_PTHREADS) */ return result; # endif /* ! ACE_LACKS_RWLOCK_T */ #else ACE_UNUSED_ARG (rw); ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_THREADS */ }
int ACE_OS::rw_unlock | ( | ACE_rwlock_t * | rw | ) | [inline] |
Definition at line 1128 of file OS_NS_Thread.inl.
{ ACE_OS_TRACE ("ACE_OS::rw_unlock"); #if defined (ACE_HAS_THREADS) # if !defined (ACE_LACKS_RWLOCK_T) || defined (ACE_HAS_PTHREADS_UNIX98_EXT) # if defined (ACE_HAS_PTHREADS_UNIX98_EXT) int result; ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_rwlock_unlock (rw), result), int, -1); # else /* Solaris */ int result; ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::rw_unlock (rw), result), int, -1); # endif /* ACE_HAS_PTHREADS_UNIX98_EXT */ # else /* NT, POSIX, and VxWorks don't support this natively. */ if (ACE_OS::mutex_lock (&rw->lock_) == -1) return -1; if (rw->ref_count_ > 0) // Releasing a reader. rw->ref_count_--; else if (rw->ref_count_ == -1) // Releasing a writer. rw->ref_count_ = 0; else { (void) ACE_OS::mutex_unlock (&rw->lock_); return -1; // @@ ACE_ASSERT (!"count should not be 0!\n"); } int result = 0; ACE_Errno_Guard error (errno); if (rw->important_writer_ && rw->ref_count_ == 1) // only the reader requesting to upgrade its lock is left over. { result = ACE_OS::cond_signal (&rw->waiting_important_writer_); error = errno; } else if (rw->num_waiting_writers_ > 0 && rw->ref_count_ == 0) // give preference to writers over readers... { result = ACE_OS::cond_signal (&rw->waiting_writers_); error = errno; } else if (rw->num_waiting_readers_ > 0 && rw->num_waiting_writers_ == 0) { result = ACE_OS::cond_broadcast (&rw->waiting_readers_); error = errno; } (void) ACE_OS::mutex_unlock (&rw->lock_); return result; # endif /* ! ace_lacks_rwlock_t */ #else ACE_UNUSED_ARG (rw); ACE_NOTSUP_RETURN (-1); #endif /* ace_has_threads */ }
int ACE_OS::rw_wrlock | ( | ACE_rwlock_t * | rw | ) | [inline] |
Definition at line 1187 of file OS_NS_Thread.inl.
{ ACE_OS_TRACE ("ACE_OS::rw_wrlock"); #if defined (ACE_HAS_THREADS) # if !defined (ACE_LACKS_RWLOCK_T) || defined (ACE_HAS_PTHREADS_UNIX98_EXT) # if defined (ACE_HAS_PTHREADS_UNIX98_EXT) int result; ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_rwlock_wrlock (rw), result), int, -1); # else /* Solaris */ int result; ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::rw_wrlock (rw), result), int, -1); # endif /* ACE_HAS_PTHREADS_UNIX98_EXT */ # else /* NT, POSIX, and VxWorks don't support this natively. */ # if defined (ACE_HAS_PTHREADS) ACE_PTHREAD_CLEANUP_PUSH (&rw->lock_); # endif /* defined (ACE_HAS_PTHREADS) */ int result = 0; if (ACE_OS::mutex_lock (&rw->lock_) == -1) result = -1; // -1 means didn't get the mutex. else { while (rw->ref_count_ != 0) { rw->num_waiting_writers_++; if (ACE_OS::cond_wait (&rw->waiting_writers_, &rw->lock_) == -1) { result = -2; // -2 means we need to release the mutex. break; } rw->num_waiting_writers_--; } } if (result == 0) rw->ref_count_ = -1; if (result != -1) ACE_OS::mutex_unlock (&rw->lock_); # if defined (ACE_HAS_PTHREADS) ACE_PTHREAD_CLEANUP_POP (0); # endif /* defined (ACE_HAS_PTHREADS) */ return 0; # endif /* ! ACE_LACKS_RWLOCK_T */ #else ACE_UNUSED_ARG (rw); ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_THREADS */ }
int ACE_OS::rwlock_destroy | ( | ACE_rwlock_t * | rw | ) | [inline] |
Definition at line 1240 of file OS_NS_Thread.inl.
{ ACE_OS_TRACE ("ACE_OS::rwlock_destroy"); #if defined (ACE_HAS_THREADS) # if !defined (ACE_LACKS_RWLOCK_T) || defined (ACE_HAS_PTHREADS_UNIX98_EXT) # if defined (ACE_HAS_PTHREADS_UNIX98_EXT) int result; ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_rwlock_destroy (rw), result), int, -1); # else /* Solaris */ int result; ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::rwlock_destroy (rw), result), int, -1); # endif /* ACE_HAS_PTHREADS_UNIX98_EXT */ # else /* NT, POSIX, and VxWorks don't support this natively. */ ACE_OS::mutex_destroy (&rw->lock_); ACE_OS::cond_destroy (&rw->waiting_readers_); ACE_OS::cond_destroy (&rw->waiting_important_writer_); return ACE_OS::cond_destroy (&rw->waiting_writers_); # endif /* ACE_HAS_STHREADS && !defined (ACE_LACKS_RWLOCK_T) */ #else ACE_UNUSED_ARG (rw); ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_THREADS */ }
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 3377 of file OS_NS_Thread.cpp.
{ // ACE_OS_TRACE ("ACE_OS::rwlock_init"); # if defined (ACE_HAS_THREADS) && defined (ACE_LACKS_RWLOCK_T) // NT, POSIX, and VxWorks don't support this natively. ACE_UNUSED_ARG (name); int result = -1; // Since we cannot use the user specified name for all three // objects, we will create three completely new names. ACE_TCHAR name1[ACE_UNIQUE_NAME_LEN]; ACE_TCHAR name2[ACE_UNIQUE_NAME_LEN]; ACE_TCHAR name3[ACE_UNIQUE_NAME_LEN]; ACE_TCHAR name4[ACE_UNIQUE_NAME_LEN]; ACE_OS::unique_name ((const void *) &rw->lock_, name1, ACE_UNIQUE_NAME_LEN); ACE_OS::unique_name ((const void *) &rw->waiting_readers_, name2, ACE_UNIQUE_NAME_LEN); ACE_OS::unique_name ((const void *) &rw->waiting_writers_, name3, ACE_UNIQUE_NAME_LEN); ACE_OS::unique_name ((const void *) &rw->waiting_important_writer_, name4, ACE_UNIQUE_NAME_LEN); ACE_condattr_t attributes; if (ACE_OS::condattr_init (attributes, type) == 0) { if (ACE_OS::mutex_init (&rw->lock_, type, name1, (ACE_mutexattr_t *) arg) == 0 && ACE_OS::cond_init (&rw->waiting_readers_, attributes, name2, arg) == 0 && ACE_OS::cond_init (&rw->waiting_writers_, attributes, name3, arg) == 0 && ACE_OS::cond_init (&rw->waiting_important_writer_, attributes, name4, arg) == 0) { // Success! rw->ref_count_ = 0; rw->num_waiting_writers_ = 0; rw->num_waiting_readers_ = 0; rw->important_writer_ = false; result = 0; } ACE_OS::condattr_destroy (attributes); } if (result == -1) { // Save/restore errno. ACE_Errno_Guard error (errno); ACE_OS::mutex_destroy (&rw->lock_); ACE_OS::cond_destroy (&rw->waiting_readers_); ACE_OS::cond_destroy (&rw->waiting_writers_); ACE_OS::cond_destroy (&rw->waiting_important_writer_); } return result; # else ACE_UNUSED_ARG (rw); ACE_UNUSED_ARG (type); ACE_UNUSED_ARG (name); ACE_UNUSED_ARG (arg); ACE_NOTSUP_RETURN (-1); # endif /* ACE_HAS_THREADS */ }
void * ACE_OS::sbrk | ( | intptr_t | brk | ) | [inline] |
Definition at line 813 of file OS_NS_unistd.inl.
{ #if defined (ACE_LACKS_SBRK) ACE_UNUSED_ARG (brk); ACE_NOTSUP_RETURN (0); #else ACE_OSCALL_RETURN (::sbrk (brk), void *, 0); #endif /* ACE_LACKS_SBRK */ }
int ACE_OS::scandir | ( | const ACE_TCHAR * | dirname, | |
struct ACE_DIRENT ** | namelist[], | |||
ACE_SCANDIR_SELECTOR | selector, | |||
ACE_SCANDIR_COMPARATOR | comparator | |||
) | [inline] |
Definition at line 116 of file OS_NS_dirent.inl.
{ #if defined (ACE_HAS_SCANDIR) return ::scandir (ACE_TEXT_ALWAYS_CHAR (dirname), namelist, # if defined (ACE_SCANDIR_SEL_LACKS_CONST) reinterpret_cast<ACE_SCANDIR_OS_SELECTOR> (selector), # else selector, # endif /* ACE_SCANDIR_SEL_LACKS_CONST */ # if defined (ACE_SCANDIR_CMP_USES_VOIDPTR) || \ defined (ACE_SCANDIR_CMP_USES_CONST_VOIDPTR) reinterpret_cast<ACE_SCANDIR_OS_COMPARATOR> (comparator)); # else comparator); # endif /* ACE_SCANDIR_CMP_USES_VOIDPTR */ #else /* ! defined ( ACE_HAS_SCANDIR) */ return ACE_OS::scandir_emulation (dirname, namelist, selector, comparator); #endif /* ACE_HAS_SCANDIR */ }
ACE_Export int ACE_OS::scandir_emulation | ( | const ACE_TCHAR * | dirname, | |
ACE_DIRENT ** | namelist[], | |||
ACE_SCANDIR_SELECTOR | selector, | |||
ACE_SCANDIR_COMPARATOR | comparator | |||
) |
int ACE_OS::sched_params | ( | const ACE_Sched_Params & | 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 3451 of file OS_NS_Thread.cpp.
{ ACE_OS_TRACE ("ACE_OS::sched_params"); #if defined (ACE_HAS_STHREADS) return ACE_OS::set_scheduling_params (sched_params, id); #elif defined (ACE_HAS_PTHREADS) && \ (!defined (ACE_LACKS_SETSCHED) || defined (ACE_TANDEM_T1248_PTHREADS) || \ defined (ACE_HAS_PTHREAD_SCHEDPARAM)) if (sched_params.quantum () != ACE_Time_Value::zero) { // quantums not supported errno = EINVAL; return -1; } // Thanks to Thilo Kielmann <kielmann@informatik.uni-siegen.de> for // providing this code for 1003.1c PThreads. Please note that this // has only been tested for POSIX 1003.1c threads, and may cause // problems with other PThreads flavors! struct sched_param param; param.sched_priority = sched_params.priority (); if (sched_params.scope () == ACE_SCOPE_PROCESS) { # if defined(ACE_TANDEM_T1248_PTHREADS) || defined (ACE_HAS_PTHREAD_SCHEDPARAM) ACE_UNUSED_ARG (id); ACE_NOTSUP_RETURN (-1); # else /* ! ACE_TANDEM_T1248_PTHREADS */ int result = ::sched_setscheduler (id == ACE_SELF ? 0 : id, sched_params.policy (), ¶m) == -1 ? -1 : 0; # if defined (DIGITAL_UNIX) return result == 0 ? // Use priocntl (2) to set the process in the RT class, // if using an RT policy. ACE_OS::set_scheduling_params (sched_params) : result; # else /* ! DIGITAL_UNIX */ return result; # endif /* ! DIGITAL_UNIX */ # endif /* ! ACE_TANDEM_T1248_PTHREADS */ } else if (sched_params.scope () == ACE_SCOPE_THREAD) { ACE_thread_t thr_id = ACE_OS::thr_self (); int result; ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_setschedparam (thr_id, sched_params.policy (), ¶m), result), int, -1); } # if defined (sun) // We need to be able to set LWP priorities on Suns, even without // ACE_HAS_STHREADS, to obtain preemption. else if (sched_params.scope () == ACE_SCOPE_LWP) return ACE_OS::set_scheduling_params (sched_params, id); # endif /* sun */ else // sched_params.scope () == ACE_SCOPE_LWP, which isn't POSIX { errno = EINVAL; return -1; } #elif defined (ACE_WIN32) && !defined (ACE_HAS_WINCE) // PharLap ETS can act on the current thread - it can set the // quantum also, unlike Win32. All this only works on the RT // version. # if defined (ACE_HAS_PHARLAP_RT) if (id != ACE_SELF) ACE_NOTSUP_RETURN (-1); # if !defined (ACE_PHARLAP_LABVIEW_RT) if (sched_params.quantum() != ACE_Time_Value::zero) EtsSetTimeSlice (sched_params.quantum().msec()); # endif # else if (sched_params.quantum () != ACE_Time_Value::zero) { // I don't know of a way to set the quantum on Win32. errno = EINVAL; return -1; } # endif /* ACE_HAS_PHARLAP_RT */ if (sched_params.scope () == ACE_SCOPE_THREAD) { // Setting the REALTIME_PRIORITY_CLASS on Windows is almost always // a VERY BAD THING. This include guard will allow people // to easily disable this feature in ACE. // It won't work at all for Pharlap since there's no SetPriorityClass. #if !defined (ACE_HAS_PHARLAP) && \ !defined (ACE_DISABLE_WIN32_INCREASE_PRIORITY) // Set the priority class of this process to the REALTIME process class // _if_ the policy is ACE_SCHED_FIFO. Otherwise, set to NORMAL. if (!::SetPriorityClass (::GetCurrentProcess (), (sched_params.policy () == ACE_SCHED_FIFO || sched_params.policy () == ACE_SCHED_RR) ? REALTIME_PRIORITY_CLASS : NORMAL_PRIORITY_CLASS)) { ACE_OS::set_errno_to_last_error (); return -1; } #endif /* ACE_DISABLE_WIN32_INCREASE_PRIORITY */ // Now that we have set the priority class of the process, set the // priority of the current thread to the desired value. return ACE_OS::thr_setprio (sched_params.priority ()); } else if (sched_params.scope () == ACE_SCOPE_PROCESS) { # if defined (ACE_HAS_PHARLAP_RT) ACE_NOTSUP_RETURN (-1); # else HANDLE hProcess = ::OpenProcess (PROCESS_SET_INFORMATION, FALSE, id == ACE_SELF ? ::GetCurrentProcessId() : id); if (!hProcess) { ACE_OS::set_errno_to_last_error(); return -1; } // There is no way for us to set the priority of the thread when we // are setting the priority of a different process. So just ignore // the priority argument when ACE_SCOPE_PROCESS is specified. // Setting the priority class will automatically increase the base // priority of all the threads within a process while maintaining the // relative priorities of the threads within it. if (!::SetPriorityClass (hProcess, (sched_params.policy () == ACE_SCHED_FIFO || sched_params.policy () == ACE_SCHED_RR) ? REALTIME_PRIORITY_CLASS : NORMAL_PRIORITY_CLASS)) { ACE_OS::set_errno_to_last_error (); ::CloseHandle (hProcess); return -1; } ::CloseHandle (hProcess); return 0; #endif /* ACE_HAS_PHARLAP_RT */ } else { errno = EINVAL; return -1; } #elif defined (ACE_VXWORKS) ACE_UNUSED_ARG (id); // There is only one class of priorities on VxWorks, and no time // quanta. So, just set the current thread's priority. if (sched_params.policy () != ACE_SCHED_FIFO || sched_params.scope () != ACE_SCOPE_PROCESS || sched_params.quantum () != ACE_Time_Value::zero) { errno = EINVAL; return -1; } // Set the thread priority on the current thread. return ACE_OS::thr_setprio (sched_params.priority ()); #else ACE_UNUSED_ARG (sched_params); ACE_UNUSED_ARG (id); ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_STHREADS */ }
int ACE_OS::scheduling_class | ( | const char * | class_name, | |
ACE_id_t & | id | |||
) |
Find the schedling class ID that corresponds to the class name.
Definition at line 3634 of file OS_NS_Thread.cpp.
{ #if defined (ACE_HAS_PRIOCNTL) // Get the priority class ID. pcinfo_t pcinfo; // The following is just to avoid Purify warnings about unitialized // memory reads. ACE_OS::memset (&pcinfo, 0, sizeof pcinfo); ACE_OS::strcpy (pcinfo.pc_clname, class_name); if (ACE_OS::priority_control (P_ALL /* ignored */, P_MYID /* ignored */, PC_GETCID, (char *) &pcinfo) == -1) { return -1; } else { id = pcinfo.pc_cid; return 0; } #else /* ! ACE_HAS_PRIOCNTL */ ACE_UNUSED_ARG (class_name); ACE_UNUSED_ARG (id); ACE_NOTSUP_RETURN (-1); #endif /* ! ACE_HAS_PRIOCNTL */ }
void ACE_OS::seekdir | ( | ACE_DIR * | d, | |
long | loc | |||
) | [inline] |
Definition at line 161 of file OS_NS_dirent.inl.
{ #if defined (ACE_HAS_DIRENT) && !defined (ACE_LACKS_SEEKDIR) ::seekdir (d, loc); #else /* ! ACE_HAS_DIRENT || ACE_LACKS_SEEKDIR */ ACE_UNUSED_ARG (d); ACE_UNUSED_ARG (loc); #endif /* ! ACE_HAS_DIRENT || ACE_LACKS_SEEKDIR */ }
int ACE_OS::select | ( | int | width, | |
fd_set * | rfds, | |||
fd_set * | wfds = 0 , |
|||
fd_set * | efds = 0 , |
|||
const ACE_Time_Value * | tv = 0 | |||
) | [inline] |
Definition at line 14 of file OS_NS_sys_select.inl.
{ ACE_OS_TRACE ("ACE_OS::select"); #if defined (ACE_HAS_NONCONST_SELECT_TIMEVAL) // We must defend against non-conformity! timeval copy; timeval *timep = 0; if (timeout != 0) { copy = *timeout; timep = © } else timep = 0; #else const timeval *timep = (timeout == 0 ? (const timeval *)0 : *timeout); #endif /* ACE_HAS_NONCONST_SELECT_TIMEVAL */ #if defined (ACE_LACKS_SELECT) ACE_UNUSED_ARG (width); ACE_UNUSED_ARG (rfds); ACE_UNUSED_ARG (wfds); ACE_UNUSED_ARG (efds); ACE_UNUSED_ARG (timeout); ACE_NOTSUP_RETURN (-1); #elif defined(ACE_TANDEM_T1248_PTHREADS) ACE_SOCKCALL_RETURN (::spt_select (width, rfds, wfds, efds, timep), int, -1); #else ACE_SOCKCALL_RETURN (::select (width, rfds, wfds, efds, timep), int, -1); #endif }
int ACE_OS::select | ( | int | width, | |
fd_set * | rfds, | |||
fd_set * | wfds, | |||
fd_set * | efds, | |||
const ACE_Time_Value & | tv | |||
) | [inline] |
Definition at line 51 of file OS_NS_sys_select.inl.
{ ACE_OS_TRACE ("ACE_OS::select"); #if defined (ACE_HAS_NONCONST_SELECT_TIMEVAL) # define ___ACE_TIMEOUT © timeval copy = timeout; #else # define ___ACE_TIMEOUT timep const timeval *timep = timeout; #endif /* ACE_HAS_NONCONST_SELECT_TIMEVAL */ #if defined (ACE_LACKS_SELECT) ACE_UNUSED_ARG (width); ACE_UNUSED_ARG (rfds); ACE_UNUSED_ARG (wfds); ACE_UNUSED_ARG (efds); ACE_UNUSED_ARG (timeout); ACE_NOTSUP_RETURN (-1); #elif defined(ACE_TANDEM_T1248_PTHREADS) ACE_SOCKCALL_RETURN (::spt_select (width, rfds, wfds, efds, ___ACE_TIMEOUT), int, -1); #else ACE_SOCKCALL_RETURN (::select (width, rfds, wfds, efds, ___ACE_TIMEOUT), int, -1); #endif #undef ___ACE_TIMEOUT }
int ACE_OS::sema_destroy | ( | ACE_sema_t * | s | ) | [inline] |
Definition at line 1304 of file OS_NS_Thread.inl.
{ ACE_OS_TRACE ("ACE_OS::sema_destroy"); # if defined (ACE_HAS_POSIX_SEM) int result; # if !defined (ACE_HAS_POSIX_SEM_TIMEOUT) && !defined (ACE_DISABLE_POSIX_SEM_TIMEOUT_EMULATION) ACE_OS::mutex_destroy (&s->lock_); ACE_OS::cond_destroy (&s->count_nonzero_); # endif /* !ACE_HAS_POSIX_SEM_TIMEOUT && !ACE_DISABLE_POSIX_SEM_TIMEOUT_EMULATION */ # if defined (ACE_LACKS_NAMED_POSIX_SEM) if (s->name_) { // Only destroy the semaphore if we're the ones who // initialized it. ACE_OSCALL (::sem_destroy (s->sema_),int, -1, result); ACE_OS::shm_unlink (s->name_); delete s->name_; return result; } # else if (s->name_) { ACE_OSCALL (::sem_unlink (s->name_), int, -1, result); ACE_OS::free ((void *) s->name_); ACE_OSCALL_RETURN (::sem_close (s->sema_), int, -1); } # endif /* ACE_LACKS_NAMED_POSIX_SEM */ else { ACE_OSCALL (::sem_destroy (s->sema_), int, -1, result); # if defined (ACE_LACKS_NAMED_POSIX_SEM) if (s->new_sema_) # endif /* ACE_LACKS_NAMED_POSIX_SEM */ delete s->sema_; s->sema_ = 0; return result; } # elif defined (ACE_USES_FIFO_SEM) int r0 = 0; if (s->name_) { r0 = ACE_OS::unlink (s->name_); ACE_OS::free (s->name_); s->name_ = 0; } int r1 = ACE_OS::close (s->fd_[0]); /* ignore error */ int r2 = ACE_OS::close (s->fd_[1]); /* ignore error */ return r0 != 0 || r1 != 0 || r2 != 0 ? -1 : 0; # elif defined (ACE_HAS_THREADS) # if defined (ACE_HAS_STHREADS) int result; ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::sema_destroy (s), result), int, -1); # elif defined (ACE_HAS_PTHREADS) int r1 = ACE_OS::mutex_destroy (&s->lock_); int r2 = ACE_OS::cond_destroy (&s->count_nonzero_); return r1 != 0 || r2 != 0 ? -1 : 0; # elif defined (ACE_HAS_WTHREADS) # if !defined (ACE_USES_WINCE_SEMA_SIMULATION) ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::CloseHandle (*s), ace_result_), int, -1); # else /* ACE_USES_WINCE_SEMA_SIMULATION */ // Free up underlying objects of the simulated semaphore. int const r1 = ACE_OS::thread_mutex_destroy (&s->lock_); int const r2 = ACE_OS::event_destroy (&s->count_nonzero_); return r1 != 0 || r2 != 0 ? -1 : 0; # endif /* ACE_USES_WINCE_SEMA_SIMULATION */ # elif defined (ACE_VXWORKS) int result; ACE_OSCALL (::semDelete (s->sema_), int, -1, result); s->sema_ = 0; return result; # endif /* ACE_HAS_STHREADS */ # else ACE_UNUSED_ARG (s); ACE_NOTSUP_RETURN (-1); # endif /* ACE_HAS_POSIX_SEM */ }
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 | |||
) | [inline] |
Definition at line 1385 of file OS_NS_Thread.inl.
{ ACE_OS_TRACE ("ACE_OS::sema_init"); #if defined (ACE_HAS_POSIX_SEM) ACE_UNUSED_ARG (max); ACE_UNUSED_ARG (sa); s->name_ = 0; # if defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_DISABLE_POSIX_SEM_TIMEOUT_EMULATION) ACE_UNUSED_ARG (arg); # else int result = -1; if (ACE_OS::mutex_init (&s->lock_, type, name, (ACE_mutexattr_t *) arg) == 0 && ACE_OS::cond_init (&s->count_nonzero_, (short)type, name, arg) == 0 && ACE_OS::mutex_lock (&s->lock_) == 0) { if (ACE_OS::mutex_unlock (&s->lock_) == 0) result = 0; } if (result == -1) { ACE_OS::mutex_destroy (&s->lock_); ACE_OS::cond_destroy (&s->count_nonzero_); return result; } # endif /* ACE_HAS_POSIX_SEM_TIMEOUT || ACE_DISABLE_POSIX_SEM_TIMEOUT_EMULATION */ # if defined (ACE_LACKS_NAMED_POSIX_SEM) s->new_sema_ = false; if (type == USYNC_PROCESS) { // Let's see if it already exists. ACE_HANDLE fd = ACE_OS::shm_open (ACE_TEXT_CHAR_TO_TCHAR (name), O_RDWR | O_CREAT | O_EXCL, ACE_DEFAULT_FILE_PERMS); if (fd == ACE_INVALID_HANDLE) { if (errno == EEXIST) fd = ACE_OS::shm_open (ACE_TEXT_CHAR_TO_TCHAR (name), O_RDWR | O_CREAT, ACE_DEFAULT_FILE_PERMS); else return -1; } else { // We own this shared memory object! Let's set its // size. if (ACE_OS::ftruncate (fd, sizeof (ACE_sema_t)) == -1) return -1; s->name_ = ACE_OS::strdup (name); if (s->name_ == 0) return -1; } if (fd == -1) return -1; s->sema_ = (sem_t *) ACE_OS::mmap (0, sizeof (ACE_sema_t), PROT_RDWR, MAP_SHARED, fd, 0); ACE_OS::close (fd); if (s->sema_ == (sem_t *) MAP_FAILED) return -1; if (s->name_ // @@ According UNIX Network Programming V2 by Stevens, // sem_init() is currently not required to return zero on // success, but it *does* return -1 upon failure. For // this reason, check for failure by comparing to -1, // instead of checking for success by comparing to zero. // -Ossama // Only initialize it if we're the one who created it. && ::sem_init (s->sema_, type == USYNC_PROCESS, count) == -1) return -1; return 0; } # else if (name) { # if defined (sun) || defined (HPUX) // Solaris and HP-UX require the name to start with a slash. Solaris // further requires that there be no other slashes than the first. const char *last_slash = ACE_OS::strrchr (name, '/'); char name2[MAXPATHLEN]; if (0 == last_slash) { ACE_OS::strcpy (name2, "/"); ACE_OS::strcat (name2, name); name = name2; } # if defined (sun) else name = last_slash; // Chop off chars preceding last slash # endif /* sun */ # endif /* sun || HPUX */ ACE_ALLOCATOR_RETURN (s->name_, ACE_OS::strdup (name), -1); s->sema_ = ::sem_open (s->name_, O_CREAT, ACE_DEFAULT_FILE_PERMS, count); if (s->sema_ == (sem_t *) SEM_FAILED) return -1; else return 0; } # endif /* ACE_LACKS_NAMED_POSIX_SEM */ else { ACE_NEW_RETURN (s->sema_, sem_t, -1); # if defined (ACE_LACKS_NAMED_POSIX_SEM) s->new_sema_ = true; # endif /* ACE_LACKS_NAMED_POSIX_SEM */ ACE_OSCALL_RETURN (::sem_init (s->sema_, type != USYNC_THREAD, count), int, -1); } #elif defined (ACE_USES_FIFO_SEM) ACE_UNUSED_ARG (arg); ACE_UNUSED_ARG (max); ACE_UNUSED_ARG (sa); int flags = 0; mode_t mode = S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP; if (type == USYNC_THREAD) { // Create systemwide unique name for semaphore char uname[ACE_UNIQUE_NAME_LEN]; ACE_OS::unique_name ((const void *) s, uname, ACE_UNIQUE_NAME_LEN); name = &uname[0]; } s->name_ = 0; s->fd_[0] = s->fd_[1] = ACE_INVALID_HANDLE; bool creator = false; if (ACE_OS::mkfifo (ACE_TEXT_CHAR_TO_TCHAR (name), mode) < 0) { if (errno != EEXIST) /* already exists OK else ERR */ return -1; // check if this is a real FIFO, not just some other existing file ACE_stat fs; if (ACE_OS::stat (name, &fs)) return -1; if (!S_ISFIFO (fs.st_mode)) { // existing file is not a FIFO errno = EEXIST; return -1; } } else creator = true; // remember we created it for initialization at end // for processshared semaphores remember who we are to be able to remove // the FIFO when we're done with it if (type == USYNC_PROCESS) { s->name_ = ACE_OS::strdup (name); if (s->name_ == 0) { if (creator) ACE_OS::unlink (name); return -1; } } if ((s->fd_[0] = ACE_OS::open (name, O_RDONLY | O_NONBLOCK)) == ACE_INVALID_HANDLE || (s->fd_[1] = ACE_OS::open (name, O_WRONLY | O_NONBLOCK)) == ACE_INVALID_HANDLE) return -1; /* turn off nonblocking for fd_[0] */ if ((flags = ACE_OS::fcntl (s->fd_[0], F_GETFL, 0)) < 0) return -1; flags &= ~O_NONBLOCK; if (ACE_OS::fcntl (s->fd_[0], F_SETFL, flags) < 0) return -1; //if (s->name_ && count) if (creator && count) { char c = 1; for (u_int i=0; i<count ;++i) if (ACE_OS::write (s->fd_[1], &c, sizeof (char)) != 1) return -1; } // In the case of process scope semaphores we can already unlink the FIFO now that // we completely set it up (the opened handles will keep it active until we close // thos down). This way we're protected against unexpected crashes as far as removal // is concerned. // Unfortunately this does not work for processshared FIFOs since as soon as we // have unlinked the semaphore no other process will be able to open it anymore. if (type == USYNC_THREAD) { ACE_OS::unlink (name); } return 0; #elif defined (ACE_HAS_THREADS) # if defined (ACE_HAS_STHREADS) ACE_UNUSED_ARG (name); ACE_UNUSED_ARG (max); ACE_UNUSED_ARG (sa); int result; ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::sema_init (s, count, type, arg), result), int, -1); # elif defined (ACE_HAS_PTHREADS) ACE_UNUSED_ARG (max); ACE_UNUSED_ARG (sa); int result = -1; if (ACE_OS::mutex_init (&s->lock_, type, name, (ACE_mutexattr_t *) arg) == 0 && ACE_OS::cond_init (&s->count_nonzero_, type, name, arg) == 0 && ACE_OS::mutex_lock (&s->lock_) == 0) { s->count_ = count; s->waiters_ = 0; if (ACE_OS::mutex_unlock (&s->lock_) == 0) result = 0; } if (result == -1) { ACE_OS::mutex_destroy (&s->lock_); ACE_OS::cond_destroy (&s->count_nonzero_); } return result; # elif defined (ACE_HAS_WTHREADS) # if ! defined (ACE_USES_WINCE_SEMA_SIMULATION) ACE_UNUSED_ARG (type); ACE_UNUSED_ARG (arg); // Create the semaphore with its value initialized to <count> and // its maximum value initialized to <max>. SECURITY_ATTRIBUTES sa_buffer; SECURITY_DESCRIPTOR sd_buffer; *s = ACE_TEXT_CreateSemaphore (ACE_OS::default_win32_security_attributes_r (sa, &sa_buffer, &sd_buffer), count, max, ACE_TEXT_CHAR_TO_TCHAR (name)); if (*s == 0) ACE_FAIL_RETURN (-1); /* NOTREACHED */ else { // Make sure to set errno to ERROR_ALREADY_EXISTS if necessary. ACE_OS::set_errno_to_last_error (); return 0; } # else /* ACE_USES_WINCE_SEMA_SIMULATION */ int result = -1; // Initialize internal object for semaphore simulation. // Grab the lock as soon as possible when we initializing // the semaphore count. Notice that we initialize the // event object as "manually reset" so we can amortize the // cost for singling/reseting the event. // @@ I changed the mutex type to thread_mutex. Notice that this // is basically a CriticalSection object and doesn't not has // any security attribute whatsoever. However, since this // semaphore implementation only works within a process, there // shouldn't any security issue at all. if (ACE_OS::thread_mutex_init (&s->lock_, type, name, (ACE_mutexattr_t *)arg) == 0 && ACE_OS::event_init (&s->count_nonzero_, 1, count > 0, type, name, arg, sa) == 0 && ACE_OS::thread_mutex_lock (&s->lock_) == 0) { s->count_ = count; if (ACE_OS::thread_mutex_unlock (&s->lock_) == 0) result = 0; } // Destroy the internal objects if we didn't initialize // either of them successfully. Don't bother to check // for errors. if (result == -1) { ACE_OS::thread_mutex_destroy (&s->lock_); ACE_OS::event_destroy (&s->count_nonzero_); } return result; # endif /* ACE_USES_WINCE_SEMA_SIMULATION */ # elif defined (ACE_VXWORKS) ACE_UNUSED_ARG (name); ACE_UNUSED_ARG (arg); ACE_UNUSED_ARG (max); ACE_UNUSED_ARG (sa); s->name_ = 0; s->sema_ = ::semCCreate (type, count); return s->sema_ ? 0 : -1; # endif /* ACE_HAS_STHREADS */ #else ACE_UNUSED_ARG (s); ACE_UNUSED_ARG (count); ACE_UNUSED_ARG (type); ACE_UNUSED_ARG (name); ACE_UNUSED_ARG (arg); ACE_UNUSED_ARG (max); ACE_UNUSED_ARG (sa); ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_POSIX_SEM */ }
int ACE_OS::sema_post | ( | ACE_sema_t * | s, | |
u_int | release_count | |||
) | [inline] |
Definition at line 1865 of file OS_NS_Thread.inl.
{ #if defined (ACE_WIN32) && !defined (ACE_USES_WINCE_SEMA_SIMULATION) // Win32 supports this natively. ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::ReleaseSemaphore (*s, release_count, 0), ace_result_), int, -1); #else // On POSIX platforms we need to emulate this ourselves. // @@ We can optimize on this implementation. However, // the semaphore promitive on Win32 doesn't allow one // to increase a semaphore to more than the count it was // first initialized. Posix and solaris don't seem to have // this restriction. Should we impose the restriction in // our semaphore simulation? for (size_t i = 0; i < release_count; i++) if (ACE_OS::sema_post (s) == -1) return -1; return 0; #endif /* ACE_WIN32 */ }
int ACE_OS::sema_post | ( | ACE_sema_t * | s | ) | [inline] |
Definition at line 1789 of file OS_NS_Thread.inl.
{ ACE_OS_TRACE ("ACE_OS::sema_post"); # if defined (ACE_HAS_POSIX_SEM) # if defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_DISABLE_POSIX_SEM_TIMEOUT_EMULATION) ACE_OSCALL_RETURN (::sem_post (s->sema_), int, -1); # else int result = -1; if (ACE_OS::mutex_lock (&s->lock_) == 0) { if (::sem_post (s->sema_) == 0) result = ACE_OS::cond_signal (&s->count_nonzero_); ACE_OS::mutex_unlock (&s->lock_); } return result; # endif /* ACE_HAS_POSIX_SEM_TIMEOUT || ACE_DISABLE_POSIX_SEM_TIMEOUT_EMULATION */ # elif defined (ACE_USES_FIFO_SEM) char c = 1; if (ACE_OS::write (s->fd_[1], &c, sizeof (char)) == sizeof (char)) return 0; return -1; # elif defined (ACE_HAS_THREADS) # if defined (ACE_HAS_STHREADS) int result; ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::sema_post (s), result), int, -1); # elif defined (ACE_HAS_PTHREADS) int result = -1; if (ACE_OS::mutex_lock (&s->lock_) == 0) { // Always allow a waiter to continue if there is one. if (s->waiters_ > 0) result = ACE_OS::cond_signal (&s->count_nonzero_); else result = 0; s->count_++; ACE_OS::mutex_unlock (&s->lock_); } return result; # elif defined (ACE_HAS_WTHREADS) # if !defined (ACE_USES_WINCE_SEMA_SIMULATION) ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::ReleaseSemaphore (*s, 1, 0), ace_result_), int, -1); # else /* ACE_USES_WINCE_SEMA_SIMULATION */ int result = -1; // Since we are simulating semaphores, we need to update semaphore // count manually. Grab the lock to prevent race condition first. if (ACE_OS::thread_mutex_lock (&s->lock_) == 0) { // Check the original state of event object. Single the event // object in transition from semaphore not available to // semaphore available. if (s->count_++ <= 0) result = ACE_OS::event_signal (&s->count_nonzero_); else result = 0; ACE_OS::thread_mutex_unlock (&s->lock_); } return result; # endif /* ACE_USES_WINCE_SEMA_SIMULATION */ # elif defined (ACE_VXWORKS) ACE_OSCALL_RETURN (::semGive (s->sema_), int, -1); # endif /* ACE_HAS_STHREADS */ # else ACE_UNUSED_ARG (s); ACE_NOTSUP_RETURN (-1); # endif /* ACE_HAS_POSIX_SEM */ }
int ACE_OS::sema_trywait | ( | ACE_sema_t * | s | ) | [inline] |
Definition at line 1888 of file OS_NS_Thread.inl.
{ ACE_OS_TRACE ("ACE_OS::sema_trywait"); # if defined (ACE_HAS_POSIX_SEM) // POSIX semaphores set errno to EAGAIN if trywait fails ACE_OSCALL_RETURN (::sem_trywait (s->sema_), int, -1); # elif defined (ACE_USES_FIFO_SEM) char c; int rc, flags; /* turn on nonblocking for s->fd_[0] */ if ((flags = ACE_OS::fcntl (s->fd_[0], F_GETFL, 0)) < 0) return -1; flags |= O_NONBLOCK; if (ACE_OS::fcntl (s->fd_[0], F_SETFL, flags) < 0) return -1; // read sets errno to EAGAIN if no input rc = ACE_OS::read (s->fd_[0], &c, sizeof (char)); /* turn off nonblocking for fd_[0] */ if ((flags = ACE_OS::fcntl (s->fd_[0], F_GETFL, 0)) >= 0) { flags &= ~O_NONBLOCK; ACE_OS::fcntl (s->fd_[0], F_SETFL, flags); } return rc == 1 ? 0 : (-1); # elif defined (ACE_HAS_THREADS) # if defined (ACE_HAS_STHREADS) // STHREADS semaphores set errno to EBUSY if trywait fails. int result; ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::sema_trywait (s), result), int, -1); # elif defined (ACE_HAS_PTHREADS) int result = -1; if (ACE_OS::mutex_lock (&s->lock_) == 0) { if (s->count_ > 0) { --s->count_; result = 0; } else errno = EBUSY; ACE_OS::mutex_unlock (&s->lock_); } return result; # elif defined (ACE_HAS_WTHREADS) # if !defined (ACE_USES_WINCE_SEMA_SIMULATION) DWORD result = ::WaitForSingleObject (*s, 0); if (result == WAIT_OBJECT_0) return 0; else { if (result == WAIT_TIMEOUT) errno = EBUSY; else ACE_OS::set_errno_to_last_error (); // This is a hack, we need to find an appropriate mapping... return -1; } # else /* ACE_USES_WINCE_SEMA_SIMULATION */ // Check the status of semaphore first. Return immediately // if the semaphore is not available and avoid grabing the // lock. DWORD result = ::WaitForSingleObject (s->count_nonzero_, 0); if (result == WAIT_OBJECT_0) // Proceed when it is available. { ACE_OS::thread_mutex_lock (&s->lock_); // Need to double check if the semaphore is still available. // The double checking scheme will slightly affect the // efficiency if most of the time semaphores are not blocked. result = ::WaitForSingleObject (s->count_nonzero_, 0); if (result == WAIT_OBJECT_0) { // Adjust the semaphore count. Only update the event // object status when the state changed. s->count_--; if (s->count_ <= 0) ACE_OS::event_reset (&s->count_nonzero_); result = 0; } ACE_OS::thread_mutex_unlock (&s->lock_); } // Translate error message to errno used by ACE. if (result == WAIT_TIMEOUT) errno = EBUSY; else ACE_OS::set_errno_to_last_error (); // This is taken from the hack above. ;) return -1; # endif /* ACE_USES_WINCE_SEMA_SIMULATION */ # elif defined (ACE_VXWORKS) if (::semTake (s->sema_, NO_WAIT) == ERROR) if (errno == S_objLib_OBJ_UNAVAILABLE) { // couldn't get the semaphore errno = EBUSY; return -1; } else // error return -1; else // got the semaphore return 0; # endif /* ACE_HAS_STHREADS */ # else ACE_UNUSED_ARG (s); ACE_NOTSUP_RETURN (-1); # endif /* ACE_HAS_POSIX_SEM */ }
int ACE_OS::sema_wait | ( | ACE_sema_t * | s, | |
ACE_Time_Value * | tv | |||
) | [inline] |
Definition at line 2406 of file OS_NS_Thread.inl.
{ return tv == 0 ? ACE_OS::sema_wait (s) : ACE_OS::sema_wait (s, *tv); }
int ACE_OS::sema_wait | ( | ACE_sema_t * | s | ) | [inline] |
Definition at line 2012 of file OS_NS_Thread.inl.
{ ACE_OS_TRACE ("ACE_OS::sema_wait"); # if defined (ACE_HAS_POSIX_SEM) ACE_OSCALL_RETURN (::sem_wait (s->sema_), int, -1); # elif defined (ACE_USES_FIFO_SEM) char c; if (ACE_OS::read (s->fd_[0], &c, sizeof (char)) == 1) return 0; return -1; # elif defined (ACE_HAS_THREADS) # if defined (ACE_HAS_STHREADS) int result; ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::sema_wait (s), result), int, -1); # elif defined (ACE_HAS_PTHREADS) int result = 0; ACE_PTHREAD_CLEANUP_PUSH (&s->lock_); if (ACE_OS::mutex_lock (&s->lock_) != 0) result = -1; else { // Keep track of the number of waiters so that we can signal // them properly in <ACE_OS::sema_post>. s->waiters_++; // Wait until the semaphore count is > 0. while (s->count_ == 0) if (ACE_OS::cond_wait (&s->count_nonzero_, &s->lock_) == -1) { result = -2; // -2 means that we need to release the mutex. break; } --s->waiters_; } if (result == 0) --s->count_; if (result != -1) ACE_OS::mutex_unlock (&s->lock_); ACE_PTHREAD_CLEANUP_POP (0); return result < 0 ? -1 : result; # elif defined (ACE_HAS_WTHREADS) # if !defined (ACE_USES_WINCE_SEMA_SIMULATION) switch (::WaitForSingleObject (*s, INFINITE)) { case WAIT_OBJECT_0: return 0; default: // This is a hack, we need to find an appropriate mapping... ACE_OS::set_errno_to_last_error (); return -1; } /* NOTREACHED */ # else /* ACE_USES_WINCE_SEMA_SIMULATION */ // Timed wait. int result = -1; for (;;) // Check if the semaphore is avialable or not and wait forever. // Don't bother to grab the lock if it is not available (to avoid // deadlock.) switch (::WaitForSingleObject (s->count_nonzero_, INFINITE)) { case WAIT_OBJECT_0: ACE_OS::thread_mutex_lock (&s->lock_); // Need to double check if the semaphore is still available. // This time, we shouldn't wait at all. if (::WaitForSingleObject (s->count_nonzero_, 0) == WAIT_OBJECT_0) { // Decrease the internal counter. Only update the event // object's status when the state changed. s->count_--; if (s->count_ <= 0) ACE_OS::event_reset (&s->count_nonzero_); result = 0; } ACE_OS::thread_mutex_unlock (&s->lock_); // if we didn't get a hold on the semaphore, the result won't // be 0 and thus, we'll start from the beginning again. if (result == 0) return 0; break; default: // Since we wait indefinitely, anything other than // WAIT_OBJECT_O indicates an error. ACE_OS::set_errno_to_last_error (); // This is taken from the hack above. ;) return -1; } /* NOTREACHED */ # endif /* ACE_USES_WINCE_SEMA_SIMULATION */ # elif defined (ACE_VXWORKS) ACE_OSCALL_RETURN (::semTake (s->sema_, WAIT_FOREVER), int, -1); # endif /* ACE_HAS_STHREADS */ # else ACE_UNUSED_ARG (s); ACE_NOTSUP_RETURN (-1); # endif /* ACE_HAS_POSIX_SEM */ }
int ACE_OS::sema_wait | ( | ACE_sema_t * | s, | |
ACE_Time_Value & | tv | |||
) | [inline] |
Definition at line 2121 of file OS_NS_Thread.inl.
{ ACE_OS_TRACE ("ACE_OS::sema_wait"); # if defined (ACE_HAS_POSIX_SEM) # if defined (ACE_HAS_POSIX_SEM_TIMEOUT) int rc; timespec_t ts; ts = tv; // Calls ACE_Time_Value::operator timespec_t(). ACE_OSCALL (::sem_timedwait (s->sema_, &ts), int, -1, rc); if (rc == -1 && errno == ETIMEDOUT) errno = ETIME; /* POSIX returns ETIMEDOUT but we need ETIME */ return rc; # elif !defined (ACE_DISABLE_POSIX_SEM_TIMEOUT_EMULATION) int result = 0; bool expired = false; ACE_Errno_Guard error (errno); ACE_PTHREAD_CLEANUP_PUSH (&s->lock_); if (ACE_OS::mutex_lock (&s->lock_) != 0) result = -2; else { bool finished = true; do { result = ACE_OS::sema_trywait (s); if (result == -1 && errno == EAGAIN) expired = ACE_OS::gettimeofday () > tv; else expired = false; finished = result != -1 || expired || (result == -1 && errno != EAGAIN); if (!finished) { if (ACE_OS::cond_timedwait (&s->count_nonzero_, &s->lock_, &tv) == -1) { error = errno; result = -1; break; } } } while (!finished); if (expired) error = ETIME; # if defined (ACE_LACKS_COND_TIMEDWAIT_RESET) tv = ACE_OS::gettimeofday (); # endif /* ACE_LACKS_COND_TIMEDWAIT_RESET */ } if (result != -2) ACE_OS::mutex_unlock (&s->lock_); ACE_PTHREAD_CLEANUP_POP (0); return result < 0 ? -1 : result; # else /* No native sem_timedwait(), and emulation disabled */ ACE_UNUSED_ARG (s); ACE_UNUSED_ARG (tv); ACE_NOTSUP_RETURN (-1); # endif /* ACE_HAS_POSIX_SEM_TIMEOUT */ # elif defined (ACE_USES_FIFO_SEM) int rc; ACE_Time_Value now = ACE_OS::gettimeofday (); while (tv > now) { ACE_Time_Value timeout = tv; timeout -= now; ACE_Handle_Set fds_; fds_.set_bit (s->fd_[0]); if ((rc = ACE_OS::select (ACE_Handle_Set::MAXSIZE, fds_, 0, 0, timeout)) != 1) { if (rc == 0 || errno != EAGAIN) { if (rc == 0) errno = ETIME; return -1; } } // try to read the signal *but* do *not* block if (rc == 1 && ACE_OS::sema_trywait (s) == 0) return 0; // we were woken for input but someone beat us to it // so we wait again if there is still time now = ACE_OS::gettimeofday (); } // make sure errno is set right errno = ETIME; return -1; # elif defined (ACE_HAS_THREADS) # if defined (ACE_HAS_STHREADS) ACE_UNUSED_ARG (s); ACE_UNUSED_ARG (tv); ACE_NOTSUP_RETURN (-1); # elif defined (ACE_HAS_PTHREADS) int result = 0; ACE_Errno_Guard error (errno); ACE_PTHREAD_CLEANUP_PUSH (&s->lock_); if (ACE_OS::mutex_lock (&s->lock_) != 0) result = -1; else { // Keep track of the number of waiters so that we can signal // them properly in <ACE_OS::sema_post>. s->waiters_++; // Wait until the semaphore count is > 0 or until we time out. while (s->count_ == 0) if (ACE_OS::cond_timedwait (&s->count_nonzero_, &s->lock_, &tv) == -1) { error = errno; result = -2; // -2 means that we need to release the mutex. break; } --s->waiters_; } if (result == 0) { # if defined (ACE_LACKS_COND_TIMEDWAIT_RESET) tv = ACE_OS::gettimeofday (); # endif /* ACE_LACKS_COND_TIMEDWAIT_RESET */ --s->count_; } if (result != -1) ACE_OS::mutex_unlock (&s->lock_); ACE_PTHREAD_CLEANUP_POP (0); return result < 0 ? -1 : result; # elif defined (ACE_HAS_WTHREADS) # if !defined (ACE_USES_WINCE_SEMA_SIMULATION) int msec_timeout; if (tv == ACE_Time_Value::zero) msec_timeout = 0; // Do a "poll." else { // Note that we must convert between absolute time (which is // passed as a parameter) and relative time (which is what // <WaitForSingleObjects> expects). ACE_Time_Value relative_time (tv - ACE_OS::gettimeofday ()); // Watchout for situations where a context switch has caused the // current time to be > the timeout. if (relative_time < ACE_Time_Value::zero) msec_timeout = 0; else msec_timeout = relative_time.msec (); } switch (::WaitForSingleObject (*s, msec_timeout)) { case WAIT_OBJECT_0: tv = ACE_OS::gettimeofday (); // Update time to when acquired return 0; case WAIT_TIMEOUT: errno = ETIME; return -1; default: // This is a hack, we need to find an appropriate mapping... ACE_OS::set_errno_to_last_error (); return -1; } /* NOTREACHED */ # else /* ACE_USES_WINCE_SEMA_SIMULATION */ // Note that in this mode, the acquire is done in two steps, and // we may get signaled but cannot grab the semaphore before // timeout. In that case, we'll need to restart the process with // updated timeout value. // tv is an absolute time, but we need relative to work with the Windows // API. Also, some users have become accustomed to using a 0 time value // as a shortcut for "now", which works on non-Windows because 0 is // always earlier than now. However, the need to convert to relative time // means we need to watch out for this case. ACE_Time_Value end_time = tv; if (tv == ACE_Time_Value::zero) end_time = ACE_OS::gettimeofday (); ACE_Time_Value relative_time = end_time - ACE_OS::gettimeofday (); int result = -1; // While we are not timeout yet. >= 0 will let this go through once // and if not able to get the object, it should hit WAIT_TIMEOUT // right away. while (relative_time >= ACE_Time_Value::zero) { // Wait for our turn to get the object. switch (::WaitForSingleObject (s->count_nonzero_, relative_time.msec ())) { case WAIT_OBJECT_0: ACE_OS::thread_mutex_lock (&s->lock_); // Need to double check if the semaphore is still available. // We can only do a "try lock" styled wait here to avoid // blocking threads that want to signal the semaphore. if (::WaitForSingleObject (s->count_nonzero_, 0) == WAIT_OBJECT_0) { // As before, only reset the object when the semaphore // is no longer available. s->count_--; if (s->count_ <= 0) ACE_OS::event_reset (&s->count_nonzero_); result = 0; } ACE_OS::thread_mutex_unlock (&s->lock_); // Only return when we successfully get the semaphore. if (result == 0) { tv = ACE_OS::gettimeofday (); // Update to time acquired return 0; } break; // We have timed out. case WAIT_TIMEOUT: errno = ETIME; return -1; // What? default: ACE_OS::set_errno_to_last_error (); // This is taken from the hack above. ;) return -1; }; // Haven't been able to get the semaphore yet, update the // timeout value to reflect the remaining time we want to wait. relative_time = end_time - ACE_OS::gettimeofday (); } // We have timed out. errno = ETIME; return -1; # endif /* ACE_USES_WINCE_SEMA_SIMULATION */ # elif defined (ACE_VXWORKS) // Note that we must convert between absolute time (which is // passed as a parameter) and relative time (which is what // the system call expects). ACE_Time_Value relative_time (tv - ACE_OS::gettimeofday ()); int ticks_per_sec = ::sysClkRateGet (); int ticks = relative_time.sec () * ticks_per_sec + relative_time.usec () * ticks_per_sec / ACE_ONE_SECOND_IN_USECS; if (::semTake (s->sema_, ticks) == ERROR) { if (errno == S_objLib_OBJ_TIMEOUT) // Convert the VxWorks errno to one that's common for to ACE // platforms. errno = ETIME; else if (errno == S_objLib_OBJ_UNAVAILABLE) errno = EBUSY; return -1; } else { tv = ACE_OS::gettimeofday (); // Update to time acquired return 0; } # endif /* ACE_HAS_STHREADS */ # else ACE_UNUSED_ARG (s); ACE_UNUSED_ARG (tv); ACE_NOTSUP_RETURN (-1); # endif /* ACE_HAS_POSIX_SEM */ }
int ACE_OS::semctl | ( | int | int_id, | |
int | semnum, | |||
int | cmd, | |||
semun | value | |||
) | [inline] |
Definition at line 2412 of file OS_NS_Thread.inl.
{ ACE_OS_TRACE ("ACE_OS::semctl"); #if defined (ACE_HAS_SYSV_IPC) ACE_OSCALL_RETURN (::semctl (int_id, semnum, cmd, value), int, -1); #else ACE_UNUSED_ARG (int_id); ACE_UNUSED_ARG (semnum); ACE_UNUSED_ARG (cmd); ACE_UNUSED_ARG (value); ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_SYSV_IPC */ }
int ACE_OS::semget | ( | key_t | key, | |
int | nsems, | |||
int | flags | |||
) | [inline] |
Definition at line 2428 of file OS_NS_Thread.inl.
{ ACE_OS_TRACE ("ACE_OS::semget"); #if defined (ACE_HAS_SYSV_IPC) ACE_OSCALL_RETURN (::semget (key, nsems, flags), int, -1); #else ACE_UNUSED_ARG (key); ACE_UNUSED_ARG (nsems); ACE_UNUSED_ARG (flags); ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_SYSV_IPC */ }
int ACE_OS::semop | ( | int | int_id, | |
struct sembuf * | sops, | |||
size_t | nsops | |||
) | [inline] |
Definition at line 2443 of file OS_NS_Thread.inl.
{ ACE_OS_TRACE ("ACE_OS::semop"); #if defined (ACE_HAS_SYSV_IPC) ACE_OSCALL_RETURN (::semop (int_id, sops, nsops), int, -1); #else ACE_UNUSED_ARG (int_id); ACE_UNUSED_ARG (sops); ACE_UNUSED_ARG (nsops); ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_SYSV_IPC */ }
ssize_t ACE_OS::send | ( | ACE_HANDLE | handle, | |
const char * | buf, | |||
size_t | len, | |||
int | flags = 0 | |||
) | [inline] |
BSD-style accept
(no QoS).
Definition at line 555 of file OS_NS_sys_socket.inl.
{ ACE_OS_TRACE ("ACE_OS::send"); // On UNIX, a non-blocking socket with no data to receive, this // system call will return EWOULDBLOCK or EAGAIN, depending on the // platform. UNIX 98 allows either errno, and they may be the same // numeric value. So to make life easier for upper ACE layers as // well as application programmers, always change EAGAIN to // EWOULDBLOCK. Rather than hack the ACE_OSCALL_RETURN macro, it's // handled explicitly here. If the ACE_OSCALL macro ever changes, // this function needs to be reviewed. On Win32, the regular macros // can be used, as this is not an issue. #if defined (ACE_LACKS_SEND) ACE_UNUSED_ARG (handle); ACE_UNUSED_ARG (buf); ACE_UNUSED_ARG (len); ACE_UNUSED_ARG (flags); ACE_NOTSUP_RETURN (-1); #elif defined (ACE_WIN32) ACE_SOCKCALL_RETURN (::send ((ACE_SOCKET) handle, buf, static_cast<int> (len), flags), ssize_t, -1); #else ssize_t const ace_result_ = ::send ((ACE_SOCKET) handle, buf, len, flags); # if !(defined (EAGAIN) && defined (EWOULDBLOCK) && EAGAIN == EWOULDBLOCK) // Optimize this code out if we can detect that EAGAIN == // EWOULDBLOCK at compile time. If we cannot detect equality at // compile-time (e.g. if EAGAIN or EWOULDBLOCK are not preprocessor // macros) perform the check at run-time. The goal is to avoid two // TSS accesses in the _REENTRANT case when EAGAIN == EWOULDBLOCK. if (ace_result_ == -1 # if !defined (EAGAIN) || !defined (EWOULDBLOCK) && EAGAIN != EWOULDBLOCK # endif /* !EAGAIN || !EWOULDBLOCK */ && errno == EAGAIN) { errno = EWOULDBLOCK; } # endif /* EAGAIN != EWOULDBLOCK*/ return ace_result_; #endif /* defined (ACE_WIN32) */ }
ssize_t ACE_OS::sendfile | ( | ACE_HANDLE | out_fd, | |
ACE_HANDLE | in_fd, | |||
off_t * | offset, | |||
size_t | count | |||
) | [inline] |
Finds the length of a string (char version).
Definition at line 12 of file OS_NS_sys_sendfile.inl.
{ #if defined ACE_HAS_SENDFILE && ACE_HAS_SENDFILE == 1 return ::sendfile (out_fd, in_fd, offset, count); #else return ACE_OS::sendfile_emulation (out_fd, in_fd, offset, count); #endif /* ACE_HAS_SENDFILE==1 */ }
BSD-style accept
(no QoS).
Definition at line 603 of file OS_NS_sys_socket.inl.
{ ACE_OS_TRACE ("ACE_OS::sendmsg"); #if !defined (ACE_LACKS_SENDMSG) # if (defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)) DWORD bytes_sent = 0; int result = ::WSASendTo ((SOCKET) handle, (WSABUF *) msg->msg_iov, msg->msg_iovlen, &bytes_sent, flags, msg->msg_name, msg->msg_namelen, 0, 0); if (result != 0) { ACE_OS::set_errno_to_wsa_last_error (); return -1; } else return (ssize_t) bytes_sent; # elif defined (ACE_HAS_NONCONST_SENDMSG) ACE_SOCKCALL_RETURN (::sendmsg (handle, const_cast<struct msghdr *>(msg), flags), ssize_t, -1); # else ACE_SOCKCALL_RETURN (::sendmsg (handle, msg, flags), ssize_t, -1); # endif #else ACE_UNUSED_ARG (flags); ACE_UNUSED_ARG (msg); ACE_UNUSED_ARG (handle); ACE_NOTSUP_RETURN (-1); #endif /* ACE_LACKS_SENDMSG */ }
ssize_t ACE_OS::sendto | ( | ACE_HANDLE | handle, | |
const char * | buf, | |||
size_t | len, | |||
int | flags, | |||
const struct sockaddr * | addr, | |||
int | addrlen | |||
) | [inline] |
BSD-style accept
(no QoS).
Definition at line 645 of file OS_NS_sys_socket.inl.
{ ACE_OS_TRACE ("ACE_OS::sendto"); #if defined (ACE_LACKS_SENDTO) ACE_UNUSED_ARG (handle); ACE_UNUSED_ARG (buf); ACE_UNUSED_ARG (len); ACE_UNUSED_ARG (flags); ACE_UNUSED_ARG (addr); ACE_UNUSED_ARG (addrlen); ACE_NOTSUP_RETURN (-1); #elif defined (ACE_VXWORKS) ACE_SOCKCALL_RETURN (::sendto ((ACE_SOCKET) handle, const_cast <char *> (buf), len, flags, const_cast<struct sockaddr *> (addr), addrlen), ssize_t, -1); #elif defined (ACE_WIN32) ACE_SOCKCALL_RETURN (::sendto ((ACE_SOCKET) handle, buf, static_cast<int> (len), flags, const_cast<struct sockaddr *> (addr), addrlen), ssize_t, -1); #else ACE_SOCKCALL_RETURN (::sendto ((ACE_SOCKET) handle, buf, len, flags, const_cast<struct sockaddr *> (addr), addrlen), ssize_t, -1); #endif /* ACE_LACKS_SENDTO */ }
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 | |||
) | [inline] |
BSD-style accept
(no QoS).
Definition at line 689 of file OS_NS_sys_socket.inl.
{ ACE_OS_TRACE ("ACE_OS::sendto"); #if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) DWORD bytes_sent = 0; int result = ::WSASendTo ((SOCKET) handle, (WSABUF*) buffers, buffer_count, &bytes_sent, flags, addr, addrlen, overlapped, func); if (result != 0) { ACE_OS::set_errno_to_wsa_last_error (); } number_of_bytes_sent = static_cast<size_t> (bytes_sent); return (ssize_t) result; #else ACE_UNUSED_ARG (overlapped); ACE_UNUSED_ARG (func); number_of_bytes_sent = 0; ssize_t result = 0; for (int i = 0; i < buffer_count; ++i) { result = ACE_OS::sendto (handle, reinterpret_cast<char *> ( buffers[i].iov_base), buffers[i].iov_len, flags, addr, addrlen); if (result == -1) break; number_of_bytes_sent += static_cast<size_t> (result); } return result; #endif /* defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) */ }
ssize_t ACE_OS::sendv | ( | ACE_HANDLE | handle, | |
const iovec * | iov, | |||
int | iovcnt | |||
) | [inline] |
BSD-style accept
(no QoS).
Definition at line 743 of file OS_NS_sys_socket.inl.
{ #if defined (ACE_HAS_WINSOCK2) DWORD bytes_sent = 0; ssize_t result = 0; // Winsock 2 has WSASend and can do this directly, but Winsock 1 // needs to do the sends one-by-one. # if (ACE_HAS_WINSOCK2 != 0) && !defined (ACE_DONT_USE_WSASEND) result = ::WSASend ((SOCKET) handle, (WSABUF *) buffers, n, &bytes_sent, 0, 0, 0); if (result == SOCKET_ERROR) { ACE_OS::set_errno_to_wsa_last_error (); return -1; } # else for (int i = 0; i < n; ++i) { result = ::send ((SOCKET) handle, buffers[i].iov_base, buffers[i].iov_len, 0); if (result == SOCKET_ERROR) { // There is a subtle difference in behaviour depending on // whether or not any data was sent. If no data was sent, // then always return -1. Otherwise return bytes_sent. // This gives the caller an opportunity to keep track of // bytes that have already been sent. if (bytes_sent > 0) break; else { ACE_OS::set_errno_to_wsa_last_error (); return -1; } } else { // Gets ignored on error anyway bytes_sent += result; // If the transfer isn't complete just drop out of the loop. if (result < (int)buffers[i].iov_len) break; } } # endif /* ACE_HAS_WINSOCK2 != 0 */ return (ssize_t) bytes_sent; #elif defined (ACE_HAS_SOCK_BUF_SIZE_MAX) // Platform limits the maximum socket message size. Pare down the // iovec, if necessary, to obey the limit. iovec local_iov[ACE_IOV_MAX]; long total = 0; long new_total = 0; for (int i = 0; i < n; i++) { local_iov[i].iov_base = buffers[i].iov_base; local_iov[i].iov_len = buffers[i].iov_len; new_total = total + buffers[i].iov_len; if (new_total >= ACE_HAS_SOCK_BUF_SIZE_MAX_VALUE) { local_iov[i].iov_len = ACE_HAS_SOCK_BUF_SIZE_MAX_VALUE - total; n = i+1; break; } total = new_total; } return ACE_OS::writev (handle, local_iov, n); #else return ACE_OS::writev (handle, buffers, n); #endif /* ACE_HAS_WINSOCK2 */ }
int ACE_OS::set_errno_to_last_error | ( | void | ) | [inline] |
Definition at line 39 of file OS_NS_errno.inl.
{ # if defined (ACE_WIN32) return errno = ::GetLastError (); #else return errno; # endif /* defined(ACE_WIN32) */ }
int ACE_OS::set_errno_to_wsa_last_error | ( | void | ) | [inline] |
Definition at line 49 of file OS_NS_errno.inl.
{ # if defined (ACE_WIN32) return errno = ::WSAGetLastError (); #else return errno; # endif /* defined(ACE_WIN32) */ }
ACE_EXIT_HOOK ACE_OS::set_exit_hook | ( | ACE_EXIT_HOOK | hook | ) | [inline] |
For use by ACE_Object_Manager only, to register its exit hook..
Definition at line 482 of file OS_NS_stdlib.inl.
{ ACE_EXIT_HOOK old_hook = exit_hook_; exit_hook_ = exit_hook; return old_hook; }
int ACE_OS::set_scheduling_params | ( | const ACE_Sched_Params & | sched_params, | |
ACE_id_t | id = ACE_SELF | |||
) |
Friendly interface to priocntl(2)
.
Definition at line 3664 of file OS_NS_Thread.cpp.
{ #if defined (ACE_HAS_PRIOCNTL) // Set priority class, priority, and quantum of this LWP or process as // specified in sched_params. // Get the priority class ID. ACE_id_t class_id; if (ACE_OS::scheduling_class (sched_params.policy() == ACE_SCHED_OTHER ? "TS" : "RT", class_id) == -1) { return -1; } pcparms_t pcparms; // The following is just to avoid Purify warnings about unitialized // memory reads. ACE_OS::memset (&pcparms, 0, sizeof pcparms); pcparms.pc_cid = class_id; if (sched_params.policy () == ACE_SCHED_OTHER && sched_params.quantum () == ACE_Time_Value::zero) // SunOS doesn't support non-zero quantums in time-sharing class: use // real-time class instead. { tsparms_t tsparms; // The following is just to avoid Purify warnings about unitialized // memory reads. ACE_OS::memset (&tsparms, 0, sizeof tsparms); // Don't change ts_uprilim (user priority limit) tsparms.ts_uprilim = TS_NOCHANGE; tsparms.ts_upri = sched_params.priority (); // Package up the TS class ID and parameters for the // priority_control () call. ACE_OS::memcpy (pcparms.pc_clparms, &tsparms, sizeof tsparms); } else if (sched_params.policy () == ACE_SCHED_FIFO || (sched_params.policy () == ACE_SCHED_RR && sched_params.quantum () != ACE_Time_Value::zero)) // must have non-zero quantum for RR, to make it meaningful // A zero quantum with FIFO has special significance: it actually // means infinite time quantum, i.e., run-to-completion. { rtparms_t rtparms; // The following is just to avoid Purify warnings about unitialized // memory reads. ACE_OS::memset (&rtparms, 0, sizeof rtparms); rtparms.rt_pri = sched_params.priority (); if (sched_params.quantum () == ACE_Time_Value::zero) { // rtparms.rt_tqsecs is ignored with RT_TQINF rtparms.rt_tqnsecs = RT_TQINF; } else { rtparms.rt_tqsecs = (ulong) sched_params.quantum ().sec (); rtparms.rt_tqnsecs = sched_params.quantum ().usec () * 1000; } // Package up the RT class ID and parameters for the // priority_control () call. ACE_OS::memcpy (pcparms.pc_clparms, &rtparms, sizeof rtparms); } else { errno = EINVAL; return -1; } if (ACE_OS::priority_control ((idtype_t) (sched_params.scope () == ACE_SCOPE_THREAD ? ACE_SCOPE_PROCESS : sched_params.scope ()), id, PC_SETPARMS, (char *) &pcparms) < 0) { return ACE_OS::last_error (); } return 0; #else /* ! ACE_HAS_PRIOCNTL */ ACE_UNUSED_ARG (sched_params); ACE_UNUSED_ARG (id); ACE_NOTSUP_RETURN (-1); #endif /* ! ACE_HAS_PRIOCNTL */ }
int ACE_OS::setegid | ( | gid_t | gid | ) | [inline] |
Definition at line 836 of file OS_NS_unistd.inl.
{ ACE_OS_TRACE ("ACE_OS::setegid"); #if defined (ACE_LACKS_SETEGID) ACE_UNUSED_ARG (gid); ACE_NOTSUP_RETURN (-1); # else ACE_OSCALL_RETURN (::setegid (gid), int, -1); # endif /* ACE_LACKS_SETEGID */ }
int ACE_OS::setenv | ( | const char * | envname, | |
const char * | envval, | |||
int | overwrite | |||
) | [inline] |
Function that is called by <ACE_OS::exit>, if non-null.
Definition at line 341 of file OS_NS_stdlib.inl.
{ #if defined (ACE_LACKS_SETENV) ACE_UNUSED_ARG (envname); ACE_UNUSED_ARG (envval); ACE_UNUSED_ARG (overwrite); ACE_NOTSUP_RETURN (-1); #else ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::setenv (envname, envval, overwrite), int, -1); #endif }
int ACE_OS::seteuid | ( | uid_t | uid | ) | [inline] |
Definition at line 910 of file OS_NS_unistd.inl.
{ ACE_OS_TRACE ("ACE_OS::seteuid"); #if defined (ACE_LACKS_SETEUID) ACE_UNUSED_ARG (uid); ACE_NOTSUP_RETURN (-1); # else ACE_OSCALL_RETURN (::seteuid (uid), int, -1); # endif /* ACE_LACKS_SETEUID */ }
int ACE_OS::setgid | ( | gid_t | gid | ) | [inline] |
Definition at line 824 of file OS_NS_unistd.inl.
{ ACE_OS_TRACE ("ACE_OS::setgid"); #if defined (ACE_LACKS_SETGID) ACE_UNUSED_ARG (gid); ACE_NOTSUP_RETURN (-1); # else ACE_OSCALL_RETURN (::setgid (gid), int, -1); # endif /* ACE_LACKS_SETGID */ }
int ACE_OS::setpgid | ( | pid_t | pid, | |
pid_t | pgid | |||
) | [inline] |
Definition at line 848 of file OS_NS_unistd.inl.
{ ACE_OS_TRACE ("ACE_OS::setpgid"); #if defined (ACE_LACKS_SETPGID) ACE_UNUSED_ARG (pid); ACE_UNUSED_ARG (pgid); ACE_NOTSUP_RETURN (-1); #else ACE_OSCALL_RETURN (::setpgid (pid, pgid), int, -1); #endif /* ACE_LACKS_SETPGID */ }
void ACE_OS::setprogname | ( | const char * | name | ) | [inline] |
Set the name of the current program
Originally from NetBSD, now found in *BSD, Cygwin, Darwin, etc.
Definition at line 635 of file OS_NS_stdlib.inl.
{ #if defined (ACE_HAS_SETPROGNAME) ::setprogname (name); #else ACE_OS::setprogname_emulation (name); #endif /* ACE_HAS_SETPROGNAME */ }
void ACE_OS::setprogname_emulation | ( | const char * | name | ) |
Function that is called by <ACE_OS::exit>, if non-null.
Definition at line 1201 of file OS_NS_stdlib.cpp.
{ const char *p = ACE_OS::strrchr (progname, '/'); if (p != 0) __progname = p + 1; else __progname = progname; }
void ACE_OS::setpwent | ( | void | ) | [inline] |
Definition at line 113 of file OS_NS_pwd.inl.
{ #if !defined (ACE_LACKS_PWD_FUNCTIONS) ::setpwent (); #endif /* ! ACE_LACKS_PWD_FUNCTIONS */ }
int ACE_OS::setregid | ( | gid_t | rgid, | |
gid_t | egid | |||
) | [inline] |
Definition at line 861 of file OS_NS_unistd.inl.
{ ACE_OS_TRACE ("ACE_OS::setregid"); #if defined (ACE_LACKS_SETREGID) ACE_UNUSED_ARG (rgid); ACE_UNUSED_ARG (egid); ACE_NOTSUP_RETURN (-1); #else ACE_OSCALL_RETURN (::setregid (rgid, egid), int, -1); #endif /* ACE_LACKS_SETREGID */ }
int ACE_OS::setreuid | ( | uid_t | ruid, | |
uid_t | euid | |||
) | [inline] |
Definition at line 874 of file OS_NS_unistd.inl.
{ ACE_OS_TRACE ("ACE_OS::setreuid"); #if defined (ACE_LACKS_SETREUID) ACE_UNUSED_ARG (ruid); ACE_UNUSED_ARG (euid); ACE_NOTSUP_RETURN (-1); #else ACE_OSCALL_RETURN (::setreuid (ruid, euid), int, -1); #endif /* ACE_LACKS_SETREUID */ }
int ACE_OS::setrlimit | ( | int | resource, | |
const struct rlimit * | rl | |||
) | [inline] |
Definition at line 67 of file OS_NS_sys_resource.inl.
{ ACE_OS_TRACE ("ACE_OS::setrlimit"); #if defined (ACE_LACKS_RLIMIT) ACE_UNUSED_ARG (resource); ACE_UNUSED_ARG (rl); ACE_NOTSUP_RETURN (-1); #else # if defined (ACE_HAS_RLIMIT_RESOURCE_ENUM) # if defined (ACE_HAS_NONCONST_SETRLIMIT) ACE_OSCALL_RETURN (::setrlimit ((ACE_HAS_RLIMIT_RESOURCE_ENUM) resource, const_cast<struct rlimit *>(rl) ), int, -1); # else ACE_OSCALL_RETURN (::setrlimit ((ACE_HAS_RLIMIT_RESOURCE_ENUM) resource, rl ), int, -1); # endif /* ACE_HAS_NONCONST_SETRLIMIT */ # else /* ACE_HAS_RLIMIT_RESOURCE_ENUM */ # if defined (ACE_HAS_NONCONST_SETRLIMIT) ACE_OSCALL_RETURN (::setrlimit (resource, const_cast<struct rlimit *>(rl) ), int, -1); # else ACE_OSCALL_RETURN (::setrlimit (resource, rl), int, -1); # endif /* ACE_HAS_NONCONST_SETRLIMIT */ # endif /* ACE_HAS_RLIMIT_RESOURCE_ENUM */ #endif /* ACE_LACKS_RLIMIT */ }
pid_t ACE_OS::setsid | ( | void | ) | [inline] |
Definition at line 887 of file OS_NS_unistd.inl.
{ ACE_OS_TRACE ("ACE_OS::setsid"); #if defined (ACE_LACKS_SETSID) ACE_NOTSUP_RETURN (-1); #else ACE_OSCALL_RETURN (::setsid (), int, -1); # endif /* ACE_LACKS_SETSID */ }
int ACE_OS::setsockopt | ( | ACE_HANDLE | handle, | |
int | level, | |||
int | optname, | |||
const char * | optval, | |||
int | optlen | |||
) | [inline] |
Manipulate the options associated with a socket.
Definition at line 832 of file OS_NS_sys_socket.inl.
{ ACE_OS_TRACE ("ACE_OS::setsockopt"); #if defined (ACE_LACKS_SETSOCKOPT) ACE_UNUSED_ARG (handle); ACE_UNUSED_ARG (level); ACE_UNUSED_ARG (optname); ACE_UNUSED_ARG (optval); ACE_UNUSED_ARG (optlen); ACE_NOTSUP_RETURN (-1); #else #if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) && defined(SO_REUSEPORT) // To work around an inconsistency with Microsofts implementation of // sockets, we will check for SO_REUSEADDR, and ignore it. Winsock // always behaves as if SO_REUSEADDR=1. Some implementations have // the same behaviour as Winsock, but use a new name for // it. SO_REUSEPORT. If you want the normal behaviour for // SO_REUSEADDR=0, then NT 4 sp4 and later supports // SO_EXCLUSIVEADDRUSE. This also requires using an updated Platform // SDK so it was decided to ignore the option for now. (Especially // since Windows always sets SO_REUSEADDR=1, which we can mimic by doing // nothing.) if (level == SOL_SOCKET) { if (optname == SO_REUSEADDR) { return 0; // Not supported by Winsock } if (optname == SO_REUSEPORT) { optname = SO_REUSEADDR; } } #endif /*ACE_HAS_WINSOCK2*/ int result; ACE_SOCKCALL (::setsockopt ((ACE_SOCKET) handle, level, optname, (ACE_SOCKOPT_TYPE1) optval, optlen), int, -1, result); #if defined (WSAEOPNOTSUPP) if (result == -1 && (errno == WSAEOPNOTSUPP || errno == WSAENOPROTOOPT)) #else if (result == -1) #endif /* WSAEOPNOTSUPP */ errno = ENOTSUP; return result; #endif }
int ACE_OS::setuid | ( | uid_t | uid | ) | [inline] |
Definition at line 898 of file OS_NS_unistd.inl.
{ ACE_OS_TRACE ("ACE_OS::setuid"); #if defined (ACE_LACKS_SETUID) ACE_UNUSED_ARG (uid); ACE_NOTSUP_RETURN (-1); # else ACE_OSCALL_RETURN (::setuid (uid), int, -1); # endif /* ACE_LACKS_SETUID */ }
ACE_HANDLE ACE_OS::shm_open | ( | const ACE_TCHAR * | filename, | |
int | mode, | |||
mode_t | perms = 0 , |
|||
LPSECURITY_ATTRIBUTES | sa = 0 | |||
) | [inline] |
Definition at line 238 of file OS_NS_sys_mman.inl.
{ ACE_OS_TRACE ("ACE_OS::shm_open"); #if defined (ACE_HAS_SHM_OPEN) ACE_UNUSED_ARG (sa); #if defined (ACE_VXWORKS) && (ACE_VXWORKS <= 0x670) // With VxWorks the file should just start with / and no other // slashes, so replace all other / by _ ACE_TCHAR buf [MAXPATHLEN + 1]; ACE_OS::sprintf (buf, ACE_TEXT ("%s"), filename); for (size_t i = 1; i < MAXPATHLEN + 1; i++) { if (buf[i] == '/') { buf[i] = '_'; } } filename = buf; #endif ACE_OSCALL_RETURN (::shm_open (ACE_TEXT_ALWAYS_CHAR(filename), mode, perms), ACE_HANDLE, ACE_INVALID_HANDLE); #elif defined (ACE_OPENVMS) //FUZZ: disable check_for_lack_ACE_OS ACE_OSCALL_RETURN (::open (filename, mode, perms, ACE_TEXT("shr=get,put,upd")), ACE_HANDLE, ACE_INVALID_HANDLE); //FUZZ: enable check_for_lack_ACE_OS #else /* ! ACE_HAS_SHM_OPEN */ // Just use ::open. return ACE_OS::open (filename, mode, perms, sa); #endif /* ACE_HAS_SHM_OPEN */ }
int ACE_OS::shm_unlink | ( | const ACE_TCHAR * | path | ) | [inline] |
Definition at line 274 of file OS_NS_sys_mman.inl.
{ ACE_OS_TRACE ("ACE_OS::shm_unlink"); #if defined (ACE_HAS_SHM_OPEN) #if defined (ACE_VXWORKS) && (ACE_VXWORKS <= 0x670) // With VxWorks the file should just start with / and no other // slashes, so replace all other / by _ ACE_TCHAR buf [MAXPATHLEN + 1]; ACE_OS::sprintf (buf, ACE_TEXT ("%s"), path); for (size_t i = 1; i < MAXPATHLEN + 1; i++) { if (buf[i] == '/') { buf[i] = '_'; } } path = buf; #endif ACE_OSCALL_RETURN (::shm_unlink (ACE_TEXT_ALWAYS_CHAR(path)), int, -1); #else /* ! ACE_HAS_SHM_OPEN */ // Just use ::unlink. return ACE_OS::unlink (path); #endif /* ACE_HAS_SHM_OPEN */ }
void * ACE_OS::shmat | ( | int | int_id, | |
const void * | shmaddr, | |||
int | shmflg | |||
) | [inline] |
Definition at line 10 of file OS_NS_sys_shm.inl.
{ ACE_OS_TRACE ("ACE_OS::shmat"); #if defined (ACE_HAS_SYSV_IPC) # if defined (ACE_HAS_CHARPTR_SHMAT) ACE_OSCALL_RETURN (::shmat (int_id, static_cast <char*> (const_cast <void *>(shmaddr)), shmflg), void *, (void *) -1); # else ACE_OSCALL_RETURN (::shmat (int_id, shmaddr, shmflg), void *, (void *) -1); # endif /* ACE_HAS_CHARPTR_SHMAT */ #else ACE_UNUSED_ARG (int_id); ACE_UNUSED_ARG (shmaddr); ACE_UNUSED_ARG (shmflg); ACE_NOTSUP_RETURN ((void *) -1); #endif /* ACE_HAS_SYSV_IPC */ }
int ACE_OS::shmctl | ( | int | int_id, | |
int | cmd, | |||
struct shmid_ds * | buf | |||
) | [inline] |
Definition at line 29 of file OS_NS_sys_shm.inl.
{ ACE_OS_TRACE ("ACE_OS::shmctl"); #if defined (ACE_HAS_SYSV_IPC) ACE_OSCALL_RETURN (::shmctl (int_id, cmd, buf), int, -1); #else ACE_UNUSED_ARG (buf); ACE_UNUSED_ARG (cmd); ACE_UNUSED_ARG (int_id); ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_SYSV_IPC */ }
int ACE_OS::shmdt | ( | const void * | shmaddr | ) | [inline] |
Definition at line 44 of file OS_NS_sys_shm.inl.
{ ACE_OS_TRACE ("ACE_OS::shmdt"); #if defined (ACE_HAS_SYSV_IPC) # if defined (ACE_HAS_CHARPTR_SHMDT) ACE_OSCALL_RETURN (::shmdt ( static_cast <char*> (const_cast <void *>(shmaddr))), int, -1); # else ACE_OSCALL_RETURN (::shmdt (shmaddr), int, -1); # endif /* ACE_HAS_CHARPTR_SHMDT */ #else ACE_UNUSED_ARG (shmaddr); ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_SYSV_IPC */ }
int ACE_OS::shmget | ( | key_t | key, | |
size_t | size, | |||
int | flags | |||
) | [inline] |
Definition at line 62 of file OS_NS_sys_shm.inl.
{ ACE_OS_TRACE ("ACE_OS::shmget"); #if defined (ACE_HAS_SYSV_IPC) ACE_OSCALL_RETURN (::shmget (key, size, flags), int, -1); #else ACE_UNUSED_ARG (flags); ACE_UNUSED_ARG (size); ACE_UNUSED_ARG (key); ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_SYSV_IPC */ }
int ACE_OS::shutdown | ( | ACE_HANDLE | handle, | |
int | how | |||
) | [inline] |
BSD-style accept
(no QoS).
Definition at line 888 of file OS_NS_sys_socket.inl.
{ ACE_OS_TRACE ("ACE_OS::shutdown"); #if defined (ACE_LACKS_SHUTDOWN) ACE_UNUSED_ARG (handle); ACE_UNUSED_ARG (how); ACE_NOTSUP_RETURN (-1); #else ACE_SOCKCALL_RETURN (::shutdown ((ACE_SOCKET) handle, how), int, -1); #endif /* ACE_LACKS_SHUTDOWN */ }
int ACE_OS::sigaction | ( | int | signum, | |
const ACE_SIGACTION * | nsa, | |||
ACE_SIGACTION * | osa | |||
) | [inline] |
Definition at line 44 of file OS_NS_signal.inl.
{ ACE_OS_TRACE ("ACE_OS::sigaction"); if (signum == 0) return 0; #if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE) struct sigaction sa; if (osa == 0) osa = &sa; if (nsa == 0) { osa->sa_handler = ::signal (signum, SIG_IGN); ::signal (signum, osa->sa_handler); } else osa->sa_handler = ::signal (signum, nsa->sa_handler); return osa->sa_handler == SIG_ERR ? -1 : 0; #elif defined (ACE_LACKS_SIGACTION) ACE_UNUSED_ARG (nsa); ACE_UNUSED_ARG (osa); ACE_NOTSUP_RETURN (-1); #elif !defined (ACE_HAS_SIGACTION_CONSTP2) ACE_OSCALL_RETURN (::sigaction (signum, const_cast<ACE_SIGACTION*> (nsa), osa), int, -1); #else ACE_OSCALL_RETURN (::sigaction (signum, nsa, osa), int, -1); #endif /* ACE_WIN32 !ACE_HAS_WINCE */ }
int ACE_OS::sigaddset | ( | sigset_t * | s, | |
int | signum | |||
) | [inline] |
Definition at line 78 of file OS_NS_signal.inl.
{ ACE_OS_TRACE ("ACE_OS::sigaddset"); #if defined (ACE_LACKS_SIGSET) if (s == 0) { errno = EFAULT; return -1; } else if (signum < 1 || signum >= ACE_NSIG) { errno = EINVAL; return -1; // Invalid signum, return error } *s |= (1 << (signum - 1)) ; return 0 ; #else return ace_sigaddset_helper (s, signum); #endif /* ACE_LACKS_SIGSET */ }
int ACE_OS::sigdelset | ( | sigset_t * | s, | |
int | signum | |||
) | [inline] |
Definition at line 100 of file OS_NS_signal.inl.
{ #if defined (ACE_LACKS_SIGSET) if (s == 0) { errno = EFAULT; return -1; } else if (signum < 1 || signum >= ACE_NSIG) { errno = EINVAL; return -1; // Invalid signum, return error } *s &= ~(1 << (signum - 1)) ; return 0; #else return ace_sigdelset_helper (s, signum); #endif /* ACE_LACKS_SIGSET */ }
int ACE_OS::sigemptyset | ( | sigset_t * | s | ) | [inline] |
Definition at line 121 of file OS_NS_signal.inl.
{ #if defined (ACE_LACKS_SIGSET) if (s == 0) { errno = EFAULT; return -1; } *s = 0 ; return 0; #else return ace_sigemptyset_helper (s); #endif /* ACE_LACKS_SIGSET */ }
int ACE_OS::sigfillset | ( | sigset_t * | s | ) | [inline] |
Definition at line 137 of file OS_NS_signal.inl.
{ #if defined (ACE_LACKS_SIGSET) if (s == 0) { errno = EFAULT; return -1; } *s = ~(sigset_t) 0; return 0 ; #else return ace_sigfillset_helper (s); #endif /* ACE_LACKS_SIGSET */ }
int ACE_OS::sigismember | ( | sigset_t * | s, | |
int | signum | |||
) | [inline] |
Definition at line 153 of file OS_NS_signal.inl.
{ #if defined (ACE_LACKS_SIGSET) if (s == 0) { errno = EFAULT; return -1; } else if (signum < 1 || signum >= ACE_NSIG) { errno = EINVAL; return -1; // Invalid signum, return error } return ((*s & (1 << (signum - 1))) != 0) ; #else # if defined (ACE_HAS_SIGISMEMBER_BUG) if (signum < 1 || signum >= ACE_NSIG) { errno = EINVAL; return -1; // Invalid signum, return error } # endif /* ACE_HAS_SIGISMEMBER_BUG */ return ace_sigismember_helper (s, signum); #endif /* ACE_LACKS_SIGSET */ }
ACE_SignalHandler ACE_OS::signal | ( | int | signum, | |
ACE_SignalHandler | func | |||
) | [inline] |
Definition at line 180 of file OS_NS_signal.inl.
{ if (signum == 0) return 0; else # if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE) || !defined (ACE_LACKS_UNIX_SIGNALS) # if !defined (ACE_HAS_TANDEM_SIGNALS) && !defined (ACE_HAS_LYNXOS4_SIGNALS) return ::signal (signum, func); # else return (ACE_SignalHandler) ::signal (signum, (void (*)(int)) func); # endif /* !ACE_HAS_TANDEM_SIGNALS && !ACE_HAS_LYNXOS4_SIGNALS */ #else // @@ WINCE: Don't know how to implement signal on WinCE (yet.) ACE_UNUSED_ARG (signum); ACE_UNUSED_ARG (func); ACE_NOTSUP_RETURN (0); // Should return SIG_ERR but it is not defined on WinCE. #endif /* defined (ACE_WIN32) && !defined (ACE_HAS_WINCE) || !defined (ACE_LACKS_UNIX_SIGNALS) */ }
int ACE_OS::sigprocmask | ( | int | how, | |
const sigset_t * | nsp, | |||
sigset_t * | osp | |||
) | [inline] |
Definition at line 200 of file OS_NS_signal.inl.
{ #if defined (ACE_LACKS_SIGSET) ACE_UNUSED_ARG (how); ACE_UNUSED_ARG (nsp); ACE_UNUSED_ARG (osp); ACE_NOTSUP_RETURN (-1); #else ACE_OSCALL_RETURN (::sigprocmask (how, nsp, osp), int, -1); #endif /* ACE_LACKS_SIGSET */ }
int ACE_OS::sigsuspend | ( | const sigset_t * | s | ) | [inline] |
Definition at line 213 of file OS_NS_signal.inl.
{ #if defined (ACE_HAS_SIGSUSPEND) sigset_t sigset; if (s == 0) { ACE_OS::sigemptyset (&sigset); s = &sigset; } return ace_sigsuspend_helper (s); #else ACE_UNUSED_ARG (s); ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_SIGSUSPEND */ }
int ACE_OS::sigtimedwait | ( | const sigset_t * | set, | |
siginfo_t * | info, | |||
const ACE_Time_Value * | timeout | |||
) | [inline] |
Definition at line 2458 of file OS_NS_Thread.inl.
{ ACE_OS_TRACE ("ACE_OS::sigtimedwait"); #if defined (ACE_HAS_SIGTIMEDWAIT) timespec_t ts; timespec_t *tsp = 0; if (timeout != 0) { ts = *timeout; // Calls ACE_Time_Value::operator timespec_t(). tsp = &ts; } ACE_OSCALL_RETURN (::sigtimedwait (sset, info, tsp), int, -1); #else ACE_UNUSED_ARG (sset); ACE_UNUSED_ARG (info); ACE_UNUSED_ARG (timeout); ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_SIGTIMEDWAIT */ }
int ACE_OS::sigwait | ( | sigset_t * | set, | |
int * | sig = 0 | |||
) | [inline] |
Definition at line 2484 of file OS_NS_Thread.inl.
{ ACE_OS_TRACE ("ACE_OS::sigwait"); int local_sig; if (sig == 0) sig = &local_sig; #if defined (ACE_HAS_THREADS) # if (defined (__FreeBSD__) && (__FreeBSD__ < 3)) ACE_UNUSED_ARG (sset); ACE_NOTSUP_RETURN (-1); # elif defined (ACE_HAS_STHREADS) # if (_POSIX_C_SOURCE - 0 >= 199506L) || defined (_POSIX_PTHREAD_SEMANTICS) errno = ::sigwait (sset, sig); return errno == 0 ? *sig : -1; #else *sig = ::sigwait (sset); return *sig; #endif /* _POSIX_C_SOURCE - 0 >= 199506L || _POSIX_PTHREAD_SEMANTICS */ # elif defined (ACE_HAS_PTHREADS) // Digital UNIX has own hoops to jump through. # if defined (DIGITAL_UNIX) && defined (__DECCXX_VER) // DEC cxx (but not g++) needs this direct call to its internal // sigwait (). This allows us to #undef sigwait, so that we can // have ACE_OS::sigwait. cxx gets confused by ACE_OS::sigwait // if sigwait is _not_ #undef'ed. errno = ::_Psigwait (sset, sig); return errno == 0 ? *sig : -1; # else /* !(DIGITAL_UNIX && __DECCXX_VER) */ # if defined (CYGWIN32) // Cygwin has sigwait definition, but it is not implemented ACE_UNUSED_ARG (sset); ACE_NOTSUP_RETURN (-1); # elif defined (ACE_TANDEM_T1248_PTHREADS) errno = ::spt_sigwait (sset, sig); return errno == 0 ? *sig : -1; # else /* this is draft 7 or std */ errno = ::sigwait (sset, sig); return errno == 0 ? *sig : -1; # endif /* CYGWIN32 */ # endif /* !(DIGITAL_UNIX && __DECCXX_VER) */ # elif defined (ACE_HAS_WTHREADS) ACE_UNUSED_ARG (sset); ACE_NOTSUP_RETURN (-1); # elif defined (ACE_VXWORKS) // Second arg is a struct siginfo *, which we don't need (the // selected signal number is returned). Third arg is timeout: 0 // means forever. *sig = ::sigtimedwait (sset, 0, 0); return *sig; # endif /* __FreeBSD__ */ #else ACE_UNUSED_ARG (sset); ACE_UNUSED_ARG (sig); ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_THREADS */ }
int ACE_OS::sigwaitinfo | ( | const sigset_t * | set, | |
siginfo_t * | info | |||
) | [inline] |
Definition at line 2542 of file OS_NS_Thread.inl.
{ ACE_OS_TRACE ("ACE_OS::sigwaitinfo"); // If this platform has sigtimedwait, it should have sigwaitinfo as well. // If this isn't true somewhere, let me know and I'll fix this. // -Steve Huston <shuston@riverace.com>. #if defined (ACE_HAS_SIGTIMEDWAIT) ACE_OSCALL_RETURN (::sigwaitinfo (sset, info), int, -1); #else ACE_UNUSED_ARG (sset); ACE_UNUSED_ARG (info); ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_SIGTIMEDWAIT */ }
int ACE_OS::sleep | ( | u_int | seconds | ) | [inline] |
Definition at line 922 of file OS_NS_unistd.inl.
{ ACE_OS_TRACE ("ACE_OS::sleep"); #if defined (ACE_WIN32) ::Sleep (seconds * ACE_ONE_SECOND_IN_MSECS); return 0; #elif defined (ACE_HAS_CLOCK_GETTIME) struct timespec rqtp; // Initializer doesn't work with Green Hills 1.8.7 rqtp.tv_sec = seconds; rqtp.tv_nsec = 0L; //FUZZ: disable check_for_lack_ACE_OS ACE_OSCALL_RETURN (::nanosleep (&rqtp, 0), int, -1); //FUZZ: enable check_for_lack_ACE_OS #else ACE_OSCALL_RETURN (::sleep (seconds), int, -1); #endif /* ACE_WIN32 */ }
int ACE_OS::sleep | ( | const ACE_Time_Value & | tv | ) | [inline] |
Definition at line 942 of file OS_NS_unistd.inl.
{ ACE_OS_TRACE ("ACE_OS::sleep"); #if defined (ACE_WIN32) ::Sleep (tv.msec ()); return 0; #elif defined (ACE_HAS_CLOCK_GETTIME) timespec_t rqtp = tv; //FUZZ: disable check_for_lack_ACE_OS ACE_OSCALL_RETURN (::nanosleep (&rqtp, 0), int, -1); //FUZZ: enable check_for_lack_ACE_OS #else # if defined (ACE_HAS_NONCONST_SELECT_TIMEVAL) // Copy the timeval, because this platform doesn't declare the timeval // as a pointer to const. timeval tv_copy = tv; # if defined(ACE_TANDEM_T1248_PTHREADS) ACE_OSCALL_RETURN (::spt_select (0, 0, 0, 0, &tv_copy), int, -1); # else //FUZZ: disable check_for_lack_ACE_OS ACE_OSCALL_RETURN (::select (0, 0, 0, 0, &tv_copy), int, -1); //FUZZ: enable check_for_lack_ACE_OS # endif # else /* ! ACE_HAS_NONCONST_SELECT_TIMEVAL */ const timeval *tvp = tv; //FUZZ: disable check_for_lack_ACE_OS ACE_OSCALL_RETURN (::select (0, 0, 0, 0, tvp), int, -1); //FUZZ: enable check_for_lack_ACE_OS # endif /* ACE_HAS_NONCONST_SELECT_TIMEVAL */ #endif /* ACE_WIN32 */ }
int ACE_OS::snprintf | ( | char * | buf, | |
size_t | maxlen, | |||
const char * | format, | |||
... | ||||
) |
Definition at line 320 of file OS_NS_stdio.cpp.
{ // ACE_OS_TRACE ("ACE_OS::snprintf"); va_list ap; va_start (ap, format); int const result = ACE_OS::vsnprintf (buf, maxlen, format, ap); va_end (ap); return result; }
ACE_HANDLE ACE_OS::socket | ( | int | protocol_family, | |
int | type, | |||
int | proto | |||
) | [inline] |
Create a BSD-style socket (no QoS).
Definition at line 901 of file OS_NS_sys_socket.inl.
{ ACE_OS_TRACE ("ACE_OS::socket"); #if defined (ACE_LACKS_SOCKET) ACE_UNUSED_ARG (domain); ACE_UNUSED_ARG (type); ACE_UNUSED_ARG (proto); ACE_NOTSUP_RETURN (ACE_INVALID_HANDLE); #else ACE_SOCKCALL_RETURN (::socket (domain, type, proto), ACE_HANDLE, ACE_INVALID_HANDLE); #endif /* ACE_LACKS_SOCKET */ }
ACE_HANDLE ACE_OS::socket | ( | int | protocol_family, | |
int | type, | |||
int | proto, | |||
ACE_Protocol_Info * | protocolinfo, | |||
ACE_SOCK_GROUP | g, | |||
u_long | flags | |||
) | [inline] |
Create a QoS-enabled socket. If the OS platform doesn't support QoS-enabled <socket> then the BSD-style <socket> is called.
Definition at line 921 of file OS_NS_sys_socket.inl.
{ ACE_OS_TRACE ("ACE_OS::socket"); #if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) ACE_SOCKCALL_RETURN (::WSASocket (domain, type, proto, protocolinfo, g, flags), ACE_HANDLE, ACE_INVALID_HANDLE); #else ACE_UNUSED_ARG (protocolinfo); ACE_UNUSED_ARG (g); ACE_UNUSED_ARG (flags); return ACE_OS::socket (domain, type, proto); #endif /* ACE_HAS_WINSOCK2 */ }
int ACE_OS::socket_fini | ( | void | ) |
Finalize WinSock after last use (e.g., when a DLL is unloaded).
Definition at line 133 of file OS_NS_sys_socket.cpp.
{ # if defined (ACE_WIN32) if (ACE_OS::socket_initialized_ != 0) { if (WSACleanup () != 0) { int error = ::WSAGetLastError (); # if defined (ACE_HAS_WINCE) ACE_TCHAR fmt[] = ACE_TEXT ("%s failed, WSAGetLastError returned %d"); ACE_TCHAR buf[80]; // @@ Eliminate magic number. ACE_OS::sprintf (buf, fmt, ACE_TEXT ("WSACleanup"), error); ::MessageBox (0, buf , ACE_TEXT ("WSACleanup failed!"), MB_OK); # else ACE_OS::fprintf (stderr, "ACE_OS::socket_fini; WSACleanup failed, " "WSAGetLastError returned %d\n", error); # endif /* ACE_HAS_WINCE */ } ACE_OS::socket_initialized_ = 0; } # endif /* ACE_WIN32 */ return 0; }
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 99 of file OS_NS_sys_socket.cpp.
{ # if defined (ACE_WIN32) && !defined(ACE_DONT_INIT_WINSOCK) if (ACE_OS::socket_initialized_ == 0) { WORD version_requested = MAKEWORD (version_high, version_low); WSADATA wsa_data; int error = WSAStartup (version_requested, &wsa_data); if (error != 0) # if defined (ACE_HAS_WINCE) { ACE_TCHAR fmt[] = ACE_TEXT ("%s failed, WSAGetLastError returned %d"); ACE_TCHAR buf[80]; // @@ Eliminate magic number. ACE_OS::sprintf (buf, fmt, ACE_TEXT ("WSAStartup"), error); ::MessageBox (0, buf, ACE_TEXT ("WSAStartup failed!"), MB_OK); } # else ACE_OS::fprintf (stderr, "ACE_OS::socket_init; WSAStartup failed, " "WSAGetLastError returned %d\n", error); # endif /* ACE_HAS_WINCE */ ACE_OS::socket_initialized_ = 1; } # else ACE_UNUSED_ARG (version_high); ACE_UNUSED_ARG (version_low); # endif /* ACE_WIN32 */ return 0; }
int ACE_OS::socketpair | ( | int | domain, | |
int | type, | |||
int | protocol, | |||
ACE_HANDLE | sv[2] | |||
) | [inline] |
BSD-style accept
(no QoS).
Definition at line 951 of file OS_NS_sys_socket.inl.
{ ACE_OS_TRACE ("ACE_OS::socketpair"); #if defined (ACE_LACKS_SOCKETPAIR) ACE_UNUSED_ARG (domain); ACE_UNUSED_ARG (type); ACE_UNUSED_ARG (protocol); ACE_UNUSED_ARG (sv); ACE_NOTSUP_RETURN (-1); #else ACE_OSCALL_RETURN (::socketpair (domain, type, protocol, sv), int, -1); #endif /* ACE_LACKS_SOCKETPAIR */ }
int ACE_OS::sprintf | ( | char * | buf, | |
const char * | format, | |||
... | ||||
) |
Definition at line 344 of file OS_NS_stdio.cpp.
{ // ACE_OS_TRACE ("ACE_OS::sprintf"); va_list ap; va_start (ap, format); int const result = ACE_OS::vsprintf (buf, format, ap); va_end (ap); return result; }
void ACE_OS::srand | ( | u_int | seed | ) | [inline] |
Function that is called by <ACE_OS::exit>, if non-null.
Definition at line 490 of file OS_NS_stdlib.inl.
{ ACE_OS_TRACE ("ACE_OS::srand"); ::srand (seed); }
int ACE_OS::stat | ( | const char * | file, | |
ACE_stat * | stp | |||
) | [inline] |
Definition at line 194 of file OS_NS_sys_stat.inl.
{ ACE_OS_TRACE ("ACE_OS::stat"); #if defined (ACE_HAS_NONCONST_STAT) ACE_OSCALL_RETURN (::stat (const_cast <char *> (file), stp), int, -1); #elif defined (ACE_HAS_WINCE) ACE_TEXT_WIN32_FIND_DATA fdata; HANDLE fhandle; fhandle = ::FindFirstFile (ACE_TEXT_CHAR_TO_TCHAR (file), &fdata); if (fhandle == INVALID_HANDLE_VALUE) { ACE_OS::set_errno_to_last_error (); return -1; } else if (fdata.nFileSizeHigh != 0) { errno = EINVAL; return -1; } else { stp->st_mode = static_cast<mode_t>(fdata.dwFileAttributes); stp->st_size = fdata.nFileSizeLow; stp->st_atime = ACE_Time_Value (fdata.ftLastAccessTime).sec (); stp->st_mtime = ACE_Time_Value (fdata.ftLastWriteTime).sec (); stp->st_ctime = ACE_Time_Value (fdata.ftCreationTime).sec (); } return 0; #elif defined (ACE_HAS_X86_STAT_MACROS) // Solaris for intel uses an macro for stat(), this macro is a // wrapper for _xstat(). ACE_OSCALL_RETURN (::_xstat (_STAT_VER, file, stp), int, -1); #else ACE_OSCALL_RETURN (ACE_STAT_FUNC_NAME (file, stp), int, -1); #endif /* ACE_HAS_NONCONST_STAT */ }
int ACE_OS::step | ( | const char * | str, | |
char * | expbuf | |||
) | [inline] |
Definition at line 26 of file OS_NS_regex.inl.
{ ACE_OS_TRACE ("ACE_OS::step"); #if defined (ACE_HAS_REGEX) ACE_OSCALL_RETURN (::step (str, expbuf), int, -1); #else ACE_UNUSED_ARG (str); ACE_UNUSED_ARG (expbuf); ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_REGEX */ }
int ACE_OS::strcasecmp | ( | const char * | s, | |
const char * | t | |||
) | [inline] |
Compares two strings (case insensitive const char version).
Definition at line 12 of file OS_NS_strings.inl.
{ #if defined (ACE_LACKS_STRCASECMP) return ACE_OS::strcasecmp_emulation (s, t); #elif defined (ACE_STRCASECMP_EQUIVALENT) return ACE_STRCASECMP_EQUIVALENT (s, t); #else /* ACE_LACKS_STRCASECMP */ return ::strcasecmp (s, t); #endif /* ACE_LACKS_STRCASECMP */ }
char * ACE_OS::strcat | ( | char * | s, | |
const char * | t | |||
) | [inline] |
Appends a string to another string (char version).
Definition at line 108 of file OS_NS_string.inl.
{ return ::strcat (s, t); }
char * ACE_OS::strchr | ( | char * | s, | |
int | c | |||
) | [inline] |
Finds the first occurance of a character in a string (char version).
Definition at line 144 of file OS_NS_string.inl.
{ return ::strchr (s, c); }
const char * ACE_OS::strchr | ( | const char * | s, | |
int | c | |||
) | [inline] |
Finds the first occurance of a character in a string (const char version).
Definition at line 126 of file OS_NS_string.inl.
{ return const_cast <const char *> (::strchr (s, c)); }
int ACE_OS::strcmp | ( | const ACE_WCHAR_T * | s, | |
const ACE_WCHAR_T * | t | |||
) | [inline] |
Compares two strings (wchar_t version).
Definition at line 166 of file OS_NS_string.inl.
{ # if !defined (ACE_HAS_WCHAR) || defined (ACE_LACKS_WCSCMP) return ACE_OS::wcscmp_emulation (s, t); # else /* !ACE_HAS_WCHAR || ACE_LACKS_WCSCMP */ return ::wcscmp (s, t); # endif /* !ACE_HAS_WCHAR || ACE_LACKS_WCSCMP */ }
int ACE_OS::strcmp | ( | const char * | s, | |
const char * | t | |||
) | [inline] |
Compares two strings (char version).
Definition at line 160 of file OS_NS_string.inl.
{ return ::strcmp (s, t); }
char * ACE_OS::strcpy | ( | char * | s, | |
const char * | t | |||
) | [inline] |
Copies a string (char version).
Definition at line 176 of file OS_NS_string.inl.
{ return ::strcpy (s, t); }
size_t ACE_OS::strcspn | ( | const char * | s, | |
const char * | reject | |||
) | [inline] |
Searches for the first substring without any of the specified characters and returns the size of the substring (char version).
Definition at line 194 of file OS_NS_string.inl.
{ return ::strcspn (s, reject); }
char * ACE_OS::strdup | ( | const char * | s | ) | [inline] |
Returns a malloced duplicated string (char version).
Definition at line 212 of file OS_NS_string.inl.
{ # if (defined (ACE_LACKS_STRDUP) && !defined(ACE_STRDUP_EQUIVALENT)) \ || defined (ACE_HAS_STRDUP_EMULATION) return ACE_OS::strdup_emulation (s); # elif defined (ACE_STRDUP_EQUIVALENT) return ACE_STRDUP_EQUIVALENT (s); # elif defined (ACE_HAS_NONCONST_STRDUP) return ::strdup (const_cast<char *> (s)); #else return ::strdup (s); # endif /* (ACE_LACKS_STRDUP && !ACE_STRDUP_EQUIVALENT) || ... */ }
ACE_Export 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).
Function that is called by <ACE_OS::exit>, if non-null.
Definition at line 108 of file OS_NS_stdlib.cpp.
{ #if defined (ACE_HAS_WINCE) // WinCE doesn't have environment variables so we just skip it. return ACE_OS::strdup (str); #elif defined (ACE_LACKS_STRENVDUP) ACE_UNUSED_ARG (str); ACE_NOTSUP_RETURN (0); #else const ACE_TCHAR * start = 0; if ((start = ACE_OS::strchr (str, ACE_TEXT ('$'))) != 0) { ACE_TCHAR buf[ACE_DEFAULT_ARGV_BUFSIZ]; size_t var_len = ACE_OS::strcspn (&start[1], ACE_TEXT ("$~!#%^&*()-+=\\|/?,.;:'\"`[]{} \t\n\r")); ACE_OS::strncpy (buf, &start[1], var_len); buf[var_len++] = ACE_TEXT ('\0'); # if defined (ACE_WIN32) // Always use the ACE_TCHAR for Windows. ACE_TCHAR *temp = ACE_OS::getenv (buf); # else // Use char * for environment on non-Windows. char *temp = ACE_OS::getenv (ACE_TEXT_ALWAYS_CHAR (buf)); # endif /* ACE_WIN32 */ size_t buf_len = ACE_OS::strlen (str) + 1; if (temp != 0) buf_len += ACE_OS::strlen (temp) - var_len; ACE_TCHAR * buf_p = buf; if (buf_len > ACE_DEFAULT_ARGV_BUFSIZ) { buf_p = (ACE_TCHAR *) ACE_OS::malloc (buf_len * sizeof (ACE_TCHAR)); if (buf_p == 0) { errno = ENOMEM; return 0; } } ACE_TCHAR * p = buf_p; size_t len = start - str; ACE_OS::strncpy (p, str, len); p += len; if (temp != 0) { # if defined (ACE_WIN32) p = ACE_OS::strecpy (p, temp) - 1; # else p = ACE_OS::strecpy (p, ACE_TEXT_CHAR_TO_TCHAR (temp)) - 1; # endif /* ACE_WIN32 */ } else { ACE_OS::strncpy (p, start, var_len); p += var_len; *p = ACE_TEXT ('\0'); } ACE_OS::strcpy (p, &start[var_len]); return (buf_p == buf) ? ACE_OS::strdup (buf) : buf_p; } else return ACE_OS::strdup (str); #endif /* ACE_HAS_WINCE */ }
char * ACE_OS::strerror | ( | int | errnum | ) |
Returns a system error message. If the supplied errnum is out of range, a string of the form "Unknown error %d" is used to format the string whose pointer is returned and errno is set to EINVAL.
Definition at line 92 of file OS_NS_string.cpp.
{ static char ret_errortext[128]; if (ACE::is_sock_error (errnum)) { const ACE_TCHAR *errortext = ACE::sock_error (errnum); ACE_OS::strncpy (ret_errortext, ACE_TEXT_ALWAYS_CHAR (errortext), sizeof (ret_errortext)); return ret_errortext; } #if defined (ACE_LACKS_STRERROR) errno = EINVAL; return ACE_OS::strerror_emulation (errnum); #else /* ACE_LACKS_STRERROR */ // Adapt to the various ways that strerror() indicates a bad errnum. // Most modern systems set errno to EINVAL. Some older platforms return // a pointer to a NULL string. This code makes the behavior more consistent // across platforms. On a bad errnum, we make a string with the error number // and set errno to EINVAL. ACE_Errno_Guard g (errno); errno = 0; char *errmsg = 0; #if defined (ACE_HAS_TR24731_2005_CRT) errmsg = ret_errortext; ACE_SECURECRTCALL (strerror_s (ret_errortext, sizeof(ret_errortext), errnum), char *, 0, errmsg); if (errnum < 0 || errnum >= _sys_nerr) g = EINVAL; return errmsg; #elif defined (ACE_WIN32) if (errnum < 0 || errnum >= _sys_nerr) errno = EINVAL; #endif /* ACE_WIN32 */ errmsg = ::strerror (errnum); if (errno == EINVAL || errmsg == 0 || errmsg[0] == 0) { ACE_OS::sprintf (ret_errortext, "Unknown error %d", errnum); errmsg = ret_errortext; g = EINVAL; } return errmsg; #endif /* ACE_LACKS_STRERROR */ }
size_t ACE_OS::strftime | ( | char * | s, | |
size_t | maxsize, | |||
const char * | format, | |||
const struct tm * | timeptr | |||
) | [inline] |
strptime wrapper. Note that the struct tm will always be set to zero
Definition at line 428 of file OS_NS_time.inl.
{ #if defined (ACE_LACKS_STRFTIME) ACE_UNUSED_ARG (s); ACE_UNUSED_ARG (maxsize); ACE_UNUSED_ARG (format); ACE_UNUSED_ARG (timeptr); ACE_NOTSUP_RETURN (0); #else return ACE_STD_NAMESPACE::strftime (s, maxsize, format, timeptr); #endif /* ACE_LACKS_STRFTIME */ }
int ACE_OS::string_to_argv | ( | ACE_TCHAR * | buf, | |
int & | argc, | |||
ACE_TCHAR **& | argv, | |||
bool | substitute_env_args = true | |||
) |
Definition at line 765 of file OS_NS_unistd.cpp.
{ #if defined (ACE_LACKS_STRENVDUP) ACE_UNUSED_ARG (substitute_env_args); #endif /* ACE_LACKS_STRENVDUP */ // Reset the number of arguments argc = 0; if (buf == 0) return -1; ACE_TCHAR *cp = buf; // First pass: count arguments. // '#' is the start-comment token.. while (*cp != ACE_TEXT ('\0') && *cp != ACE_TEXT ('#')) { // Skip whitespace.. while (ACE_OS::ace_isspace (*cp)) ++cp; // Increment count and move to next whitespace.. if (*cp != ACE_TEXT ('\0')) ++argc; while (*cp != ACE_TEXT ('\0') && !ACE_OS::ace_isspace (*cp)) { // Grok quotes.... if (*cp == ACE_TEXT ('\'') || *cp == ACE_TEXT ('"')) { ACE_TCHAR quote = *cp; // Scan past the string.. for (++cp; *cp != ACE_TEXT ('\0') && (*cp != quote || cp[-1] == ACE_TEXT ('\\')); ++cp) continue; // '\0' implies unmatched quote.. if (*cp == ACE_TEXT ('\0')) { --argc; break; } else ++cp; } else ++cp; } } // Second pass: copy arguments. ACE_TCHAR arg[ACE_DEFAULT_ARGV_BUFSIZ]; ACE_TCHAR *argp = arg; // Make sure that the buffer we're copying into is always large // enough. if (cp - buf >= ACE_DEFAULT_ARGV_BUFSIZ) ACE_NEW_RETURN (argp, ACE_TCHAR[cp - buf + 1], -1); // Make a new argv vector of argc + 1 elements. ACE_NEW_RETURN (argv, ACE_TCHAR *[argc + 1], -1); ACE_TCHAR *ptr = buf; for (int i = 0; i < argc; ++i) { // Skip whitespace.. while (ACE_OS::ace_isspace (*ptr)) ++ptr; // Copy next argument and move to next whitespace.. cp = argp; while (*ptr != ACE_TEXT ('\0') && !ACE_OS::ace_isspace (*ptr)) if (*ptr == ACE_TEXT ('\'') || *ptr == ACE_TEXT ('"')) { ACE_TCHAR quote = *ptr++; while (*ptr != ACE_TEXT ('\0') && (*ptr != quote || ptr[-1] == ACE_TEXT ('\\'))) { if (*ptr == quote && ptr[-1] == ACE_TEXT ('\\')) --cp; *cp++ = *ptr++; } if (*ptr == quote) ++ptr; } else *cp++ = *ptr++; *cp = ACE_TEXT ('\0'); #if !defined (ACE_LACKS_STRENVDUP) // Check for environment variable substitution here. if (substitute_env_args) { argv[i] = ACE_OS::strenvdup (argp); if (argv[i] == 0) { if (argp != arg) delete [] argp; errno = ENOMEM; return -1; } } else #endif /* ACE_LACKS_STRENVDUP */ { argv[i] = ACE_OS::strdup (argp); if (argv[i] == 0) { if (argp != arg) { delete [] argp; } errno = ENOMEM; return -1; } } } if (argp != arg) { delete [] argp; } argv[argc] = 0; return 0; }
size_t ACE_OS::strlen | ( | const char * | s | ) | [inline] |
Finds the length of a string (char version).
Definition at line 244 of file OS_NS_string.inl.
{ return ::strlen (s); }
size_t ACE_OS::strlen | ( | const ACE_WCHAR_T * | s | ) | [inline] |
Finds the length of a string (ACE_WCHAR_T version).
Definition at line 250 of file OS_NS_string.inl.
{ # if !defined (ACE_HAS_WCHAR) || defined (ACE_LACKS_WCSLEN) return ACE_OS::wcslen_emulation (s); # else /* !ACE_HAS_WCHAR || ACE_LACKS_WCSLEN */ return ::wcslen (s); # endif /* !ACE_HAS_WCHAR || ACE_LACKS_WCSLEN */ }
int ACE_OS::strncasecmp | ( | const char * | s, | |
const char * | t, | |||
size_t | len | |||
) | [inline] |
Compares two arrays (case insensitive const char version).
Definition at line 36 of file OS_NS_strings.inl.
{ #if defined (ACE_LACKS_STRCASECMP) return ACE_OS::strncasecmp_emulation (s, t, len); #elif defined (ACE_STRNCASECMP_EQUIVALENT) return ACE_STRNCASECMP_EQUIVALENT (s, t, len); #else /* ACE_LACKS_STRCASECMP */ return ::strncasecmp (s, t, len); #endif /* ACE_LACKS_STRCASECMP */ }
char * ACE_OS::strncat | ( | char * | s, | |
const char * | t, | |||
size_t | len | |||
) | [inline] |
Appends part of a string to another string (char version).
Definition at line 260 of file OS_NS_string.inl.
{ #if 0 /* defined (ACE_HAS_TR24731_2005_CRT) */ strncat_s (s, len + 1, t, _TRUNCATE); return s; #else return ::strncat (s, t, len); #endif /* ACE_HAS_TR24731_2005_CRT */ }
ACE_WCHAR_T * ACE_OS::strncat | ( | ACE_WCHAR_T * | s, | |
const ACE_WCHAR_T * | t, | |||
size_t | len | |||
) | [inline] |
Appends part of a string to another string (wchar_t version).
Definition at line 271 of file OS_NS_string.inl.
{ # if !defined (ACE_HAS_WCHAR) || defined (ACE_LACKS_WCSNCAT) return ACE_OS::wcsncat_emulation (s, t, len); # elif 0 /* defined (ACE_HAS_TR24731_2005_CRT) */ wcsncat_s (s, len + 1, t, _TRUNCATE); return s; # else /* !ACE_HAS_WCHAR || ACE_LACKS_WCSNCAT */ return ::wcsncat (s, t, len); # endif /* !ACE_HAS_WCHAR || ACE_LACKS_WCSNCAT */ }
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 199 of file OS_NS_string.cpp.
{ for (size_t i = 0; i < len; ++i) { if (s[i] == c) { return s + i; } } return 0; }
char * ACE_OS::strnchr | ( | char * | s, | |
int | c, | |||
size_t | len | |||
) | [inline] |
Finds the first occurance of a character in an array (char version).
Definition at line 284 of file OS_NS_string.inl.
{ return const_cast<char *> (ACE_OS::strnchr (static_cast<const char *> (s), c, len)); }
ACE_WCHAR_T * ACE_OS::strnchr | ( | ACE_WCHAR_T * | s, | |
ACE_WCHAR_T | c, | |||
size_t | len | |||
) | [inline] |
Finds the first occurance of a character in an array (ACE_WCHAR_T version).
Definition at line 292 of file OS_NS_string.inl.
{ return const_cast<ACE_WCHAR_T *> (ACE_OS::strnchr ( const_cast<const ACE_WCHAR_T *> (s), c, len)); }
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 189 of file OS_NS_string.cpp.
{ for (size_t i = 0; i < len; ++i) if (s[i] == c) return s + i; return 0; }
int ACE_OS::strncmp | ( | const ACE_WCHAR_T * | s, | |
const ACE_WCHAR_T * | t, | |||
size_t | len | |||
) | [inline] |
Compares two arrays (wchar_t version).
Definition at line 308 of file OS_NS_string.inl.
{ # if !defined (ACE_HAS_WCHAR) || defined (ACE_LACKS_WCSNCMP) return ACE_OS::wcsncmp_emulation (s, t, len); # else /* !ACE_HAS_WCHAR || ACE_LACKS_WCSNCMP */ return ::wcsncmp (s, t, len); # endif /* !ACE_HAS_WCHAR || ACE_LACKS_WCSNCMP */ }
int ACE_OS::strncmp | ( | const char * | s, | |
const char * | t, | |||
size_t | len | |||
) | [inline] |
Compares two arrays (char version).
Definition at line 302 of file OS_NS_string.inl.
{ return ::strncmp (s, t, len); }
char * ACE_OS::strncpy | ( | char * | s, | |
const char * | t, | |||
size_t | len | |||
) | [inline] |
Copies an array (char version).
Definition at line 318 of file OS_NS_string.inl.
{ return ::strncpy (s, t, len); }
ACE_WCHAR_T * ACE_OS::strncpy | ( | ACE_WCHAR_T * | s, | |
const ACE_WCHAR_T * | t, | |||
size_t | len | |||
) | [inline] |
Copies an array (ACE_WCHAR_T version).
Definition at line 324 of file OS_NS_string.inl.
{ # if !defined (ACE_HAS_WCHAR) || defined (ACE_LACKS_WCSNCPY) return ACE_OS::wcsncpy_emulation (s, t, len); # else /* !ACE_HAS_WCHAR || ACE_LACKS_WCSNCPY */ return ::wcsncpy (s, t, len); # endif /* !ACE_HAS_WCHAR || ACE_LACKS_WCSNCPY */ }
size_t ACE_OS::strnlen | ( | const char * | s, | |
size_t | maxlen | |||
) | [inline] |
Finds the length of a limited-length string (char version).
s | The character string to find the length of. | |
maxlen | The maximum number of characters that will be scanned for the terminating nul character. |
Definition at line 334 of file OS_NS_string.inl.
{ #if defined (ACE_HAS_STRNLEN) return ::strnlen (s, maxlen); #else /* ACE_HAS_STRNLEN */ size_t i; for (i = 0; i < maxlen; ++i) if (s[i] == '\0') break; return i; #endif /* ACE_HAS_STRNLEN */ }
size_t ACE_OS::strnlen | ( | const ACE_WCHAR_T * | s, | |
size_t | maxlen | |||
) | [inline] |
Finds the length of a limited-length string (ACE_WCHAR_T version).
s | The character string to find the length of. | |
maxlen | The maximum number of characters that will be scanned for the terminating nul character. |
Definition at line 348 of file OS_NS_string.inl.
{ #if defined (ACE_HAS_WCHAR) && defined (ACE_HAS_WCSNLEN) return wcsnlen (s, maxlen); #else /* ACE_HAS_WCSNLEN */ size_t i; for (i = 0; i < maxlen; ++i) if (s[i] == '\0') break; return i; #endif /* ACE_HAS_WCSNLEN */ }
char * ACE_OS::strnstr | ( | char * | s, | |
const char * | t, | |||
size_t | len | |||
) | [inline] |
Finds the first occurance of a substring in an array (char version).
Definition at line 362 of file OS_NS_string.inl.
{ return const_cast <char *> (ACE_OS::strnstr (const_cast <const char *> (s), t, len)); }
ACE_WCHAR_T * ACE_OS::strnstr | ( | ACE_WCHAR_T * | s, | |
const ACE_WCHAR_T * | t, | |||
size_t | len | |||
) | [inline] |
Finds the first occurance of a substring in an array (wchar_t version).
Definition at line 369 of file OS_NS_string.inl.
{ return const_cast<ACE_WCHAR_T *> (ACE_OS::strnstr ( static_cast<const ACE_WCHAR_T *> (s), t, len)); }
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 213 of file OS_NS_string.cpp.
{ // Substring length size_t const len1 = ACE_OS::strlen (s1); // Check if the substring is longer than the string being searched. if (len2 > len1) return 0; // Go upto <len> size_t const len = len1 - len2; for (size_t i = 0; i <= len; i++) { if (ACE_OS::memcmp (s1 + i, s2, len2) == 0) { // Found a match! Return the index. return s1 + i; } } return 0; }
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 238 of file OS_NS_string.cpp.
{ // Substring length size_t const len1 = ACE_OS::strlen (s1); // Check if the substring is longer than the string being searched. if (len2 > len1) return 0; // Go upto <len> size_t const len = len1 - len2; for (size_t i = 0; i <= len; i++) { if (ACE_OS::memcmp (s1 + i, s2, len2 * sizeof (ACE_WCHAR_T)) == 0) { // Found a match! Return the index. return s1 + i; } } return 0; }
const char * ACE_OS::strpbrk | ( | const char * | s1, | |
const char * | s2 | |||
) | [inline] |
Searches for characters in a string (const char version).
Definition at line 379 of file OS_NS_string.inl.
{ return const_cast <const char *> (::strpbrk (s1, s2)); }
char * ACE_OS::strpbrk | ( | char * | s1, | |
const char * | s2 | |||
) | [inline] |
Searches for characters in a string (char version).
Definition at line 397 of file OS_NS_string.inl.
{ return ::strpbrk (s1, s2); }
char * ACE_OS::strptime | ( | const char * | buf, | |
const char * | format, | |||
struct tm * | tm | |||
) | [inline] |
strptime wrapper. Note that the struct tm will always be set to zero
Definition at line 443 of file OS_NS_time.inl.
{ ACE_OS::memset (tm, 0, sizeof (struct tm)); #if defined (ACE_LACKS_STRPTIME) return ACE_OS::strptime_emulation (buf, format, tm); #else return ACE_STD_NAMESPACE::strptime (buf, format, tm); #endif /* ACE_LACKS_STRPTIME */ }
const char * ACE_OS::strrchr | ( | const char * | s, | |
int | c | |||
) | [inline] |
Finds the last occurance of a character in a string (const char version).
Definition at line 412 of file OS_NS_string.inl.
{ #if defined (ACE_LACKS_STRRCHR) return ACE_OS::strrchr_emulation (s, c); #else /* ! ACE_LACKS_STRRCHR */ return (const char *) ::strrchr (s, c); #endif /* ! ACE_LACKS_STRRCHR */ }
char * ACE_OS::strrchr | ( | char * | s, | |
int | c | |||
) | [inline] |
Finds the last occurance of a character in a string (char version).
Definition at line 434 of file OS_NS_string.inl.
{ #if defined (ACE_LACKS_STRRCHR) return ACE_OS::strrchr_emulation (s, c); #else /* ! ACE_LACKS_STRRCHR */ return ::strrchr (s, c); #endif /* ! ACE_LACKS_STRRCHR */ }
char * ACE_OS::strsignal | ( | int | signum | ) |
Returns a string describing the signal number passed in the argument signum. If the supplied signal number is out of range, a string of the form "Unknown signal %d" is used to format the string whose pointer is returned.
Definition at line 154 of file OS_NS_string.cpp.
{ static char signal_text[128]; #if defined (ACE_HAS_STRSIGNAL) char *ret_val = 0; # if defined (ACE_NEEDS_STRSIGNAL_RANGE_CHECK) if (signum < 0 || signum >= ACE_NSIG) ret_val = 0; else # endif /* (ACE_NEEDS_STRSIGNAL_RANGE_CHECK */ ret_val = ACE_STD_NAMESPACE::strsignal (signum); if (ret_val <= reinterpret_cast<char *> (0)) { ACE_OS::sprintf (signal_text, "Unknown signal: %d", signum); ret_val = signal_text; } return ret_val; #else if (signum < 0 || signum >= ACE_NSIG) { ACE_OS::sprintf (signal_text, "Unknown signal: %d", signum); return signal_text; } # if defined (ACE_SYS_SIGLIST) return ACE_SYS_SIGLIST[signum]; # else ACE_OS::sprintf (signal_text, "Signal: %d", signum); return signal_text; # endif /* ACE_SYS_SIGLIST */ #endif /* ACE_HAS_STRSIGNAL */ }
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 324 of file OS_NS_string.cpp.
{ register char *rdst = dst; register const char *rsrc = src; register size_t rmaxlen = maxlen; if (rmaxlen > 0) { if (rdst!=rsrc) { *rdst = '\0'; if (rsrc != 0) { ACE_OS::strncat (rdst, rsrc, --rmaxlen); } } else { rdst += (rmaxlen - 1); *rdst = '\0'; } } return dst; }
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 350 of file OS_NS_string.cpp.
{ register ACE_WCHAR_T *rdst = dst; register const ACE_WCHAR_T *rsrc = src; register size_t rmaxlen = maxlen; if (rmaxlen > 0) { if (rdst!= rsrc) { *rdst = ACE_TEXT_WIDE ('\0'); if (rsrc != 0) { ACE_OS::strncat (rdst, rsrc, --rmaxlen); } } else { rdst += (rmaxlen - 1); *rdst = ACE_TEXT_WIDE ('\0'); } } return dst; }
size_t ACE_OS::strspn | ( | const char * | s1, | |
const char * | s2 | |||
) | [inline] |
Searches for the first substring containing only the specified characters and returns the size of the substring (char version).
Definition at line 453 of file OS_NS_string.inl.
{ return ::strspn (s, t); }
char * ACE_OS::strstr | ( | char * | s, | |
const char * | t | |||
) | [inline] |
Finds the first occurance of a substring in a string (char version).
Definition at line 491 of file OS_NS_string.inl.
{ return ::strstr (s, t); }
const char * ACE_OS::strstr | ( | const char * | s, | |
const char * | t | |||
) | [inline] |
Finds the first occurance of a substring in a string (const char version).
Definition at line 471 of file OS_NS_string.inl.
{ return (const char *) ::strstr (s, t); }
double ACE_OS::strtod | ( | const char * | s, | |
char ** | endptr | |||
) | [inline] |
Converts a string to a double value (char version).
Definition at line 498 of file OS_NS_stdlib.inl.
{ return ::strtod (s, endptr); }
char * ACE_OS::strtok | ( | char * | s, | |
const char * | tokens | |||
) | [inline] |
Finds the next token in a string (char version).
Definition at line 511 of file OS_NS_string.inl.
{ return ::strtok (s, tokens); }
char * ACE_OS::strtok_r | ( | char * | s, | |
const char * | tokens, | |||
char ** | lasts | |||
) | [inline] |
Finds the next token in a string (safe char version).
Definition at line 530 of file OS_NS_string.inl.
{ #if defined (ACE_HAS_TR24731_2005_CRT) return strtok_s (s, tokens, lasts); #elif defined (ACE_HAS_REENTRANT_FUNCTIONS) && !defined (ACE_LACKS_STRTOK_R) return ::strtok_r (s, tokens, lasts); #else return ACE_OS::strtok_r_emulation (s, tokens, lasts); #endif /* (ACE_HAS_REENTRANT_FUNCTIONS) */ }
char * ACE_OS::strtok_r_emulation | ( | char * | s, | |
const char * | tokens, | |||
char ** | lasts | |||
) |
Emulated strtok_r.
Definition at line 378 of file OS_NS_string.cpp.
{ if (s == 0) s = *lasts; else *lasts = s; if (*s == 0) // We have reached the end return 0; size_t const l_org = ACE_OS::strlen (s); s = ::strtok (s, tokens); if (s == 0) return 0; size_t const l_sub = ACE_OS::strlen (s); if (s + l_sub < *lasts + l_org) *lasts = s + l_sub + 1; else *lasts = s + l_sub; return s ; }
long ACE_OS::strtol | ( | const char * | s, | |
char ** | ptr, | |||
int | base | |||
) | [inline] |
Converts a string to a long value (char version).
Definition at line 513 of file OS_NS_stdlib.inl.
{ #if defined (ACE_LACKS_STRTOL) return ACE_OS::strtol_emulation (s, ptr, base); #else /* ACE_LACKS_STRTOL */ return ::strtol (s, ptr, base); #endif /* ACE_LACKS_STRTOL */ }
ACE_INT64 ACE_OS::strtoll | ( | const char * | s, | |
char ** | ptr, | |||
int | base | |||
) | [inline] |
Converts a string to a signed 64 bit int value (char version).
Definition at line 557 of file OS_NS_stdlib.inl.
{ #if defined (ACE_LACKS_STRTOLL) return ACE_OS::strtoll_emulation (s, ptr, base); #elif defined (ACE_STRTOLL_EQUIVALENT) return ACE_STRTOLL_EQUIVALENT (s, ptr, base); #else return ace_strtoll_helper (s, ptr, base); #endif /* ACE_LACKS_STRTOLL */ }
unsigned long ACE_OS::strtoul | ( | const char * | s, | |
char ** | ptr, | |||
int | base | |||
) | [inline] |
Converts a string to an unsigned long value (char version).
Definition at line 535 of file OS_NS_stdlib.inl.
{ #if defined (ACE_LACKS_STRTOUL) return ACE_OS::strtoul_emulation (s, ptr, base); #else /* ACE_LACKS_STRTOUL */ return ::strtoul (s, ptr, base); #endif /* ACE_LACKS_STRTOUL */ }
ACE_UINT64 ACE_OS::strtoull | ( | const char * | s, | |
char ** | ptr, | |||
int | base | |||
) | [inline] |
Converts a string to a unsigned 64 bit int value (char version).
Definition at line 583 of file OS_NS_stdlib.inl.
{ #if defined (ACE_LACKS_STRTOULL) return ACE_OS::strtoull_emulation (s, ptr, base); #elif defined (ACE_STRTOULL_EQUIVALENT) return ACE_STRTOULL_EQUIVALENT (s, ptr, base); #else return ace_strtoull_helper (s, ptr, base); #endif /* ACE_LACKS_STRTOULL */ }
void ACE_OS::swab | ( | const void * | src, | |
void * | dest, | |||
ssize_t | n | |||
) | [inline] |
Definition at line 975 of file OS_NS_unistd.inl.
{ #if defined (ACE_LACKS_SWAB) // ------------------------------------------------------------ // The following copyright notice applies to the swab() // implementation within this "ACE_LACKS_SWAB" block of code. // ------------------------------------------------------------ /* Copyright (c) 1994-2006 Red Hat, Inc. All rights reserved. This copyrighted material is made available to anyone wishing to use, modify, copy, or redistribute it subject to the terms and conditions of the BSD License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. A copy of this license is available at http://www.opensource.org/licenses. Any Red Hat trademarks that are incorporated in the source code or documentation are not subject to the BSD License and may only be used or replicated with the express permission of Red Hat, Inc. */ const char *from = static_cast<const char*> (src); char *to = static_cast<char *> (dest); ssize_t ptr = 0; for (ptr = 1; ptr < length; ptr += 2) { char p = from[ptr]; char q = from[ptr-1]; to[ptr-1] = p; to[ptr ] = q; } if (ptr == length) /* I.e., if length is odd, */ to[ptr-1] = 0; /* then pad with a NUL. */ #elif defined (ACE_HAS_NONCONST_SWAB) const char *tmp = static_cast<const char*> (src); char *from = const_cast<char *> (tmp); char *to = static_cast<char *> (dest); ::swab (from, to, length); #elif defined (ACE_HAS_CONST_CHAR_SWAB) const char *from = static_cast<const char*> (src); char *to = static_cast<char *> (dest); ::swab (from, to, length); #else ::swab (src, dest, length); #endif /* ACE_LACKS_SWAB */ }
long ACE_OS::sysconf | ( | int | name | ) | [inline] |
Definition at line 1028 of file OS_NS_unistd.inl.
{ ACE_OS_TRACE ("ACE_OS::sysconf"); #if defined (ACE_LACKS_SYSCONF) ACE_UNUSED_ARG (name); ACE_NOTSUP_RETURN (-1); #else ACE_OSCALL_RETURN (::sysconf (name), long, -1); #endif /* ACE_LACKS_SYSCONF */ }
long ACE_OS::sysinfo | ( | int | cmd, | |
char * | buf, | |||
long | count | |||
) | [inline] |
Definition at line 1040 of file OS_NS_unistd.inl.
{ ACE_OS_TRACE ("ACE_OS::sysinfo"); #if defined (ACE_HAS_SYSV_SYSINFO) ACE_OSCALL_RETURN (::sysinfo (cmd, buf, count), long, -1); #else ACE_UNUSED_ARG (cmd); ACE_UNUSED_ARG (buf); ACE_UNUSED_ARG (count); ACE_NOTSUP_RETURN (0); #endif /* ACE_HAS_SYSV_SYSINFO */ }
int ACE_OS::system | ( | const ACE_TCHAR * | s | ) | [inline] |
Function that is called by <ACE_OS::exit>, if non-null.
Definition at line 609 of file OS_NS_stdlib.inl.
{ // ACE_OS_TRACE ("ACE_OS::system"); #if defined (ACE_LACKS_SYSTEM) ACE_UNUSED_ARG (s); ACE_NOTSUP_RETURN (-1); #elif defined (ACE_WIN32) && defined (ACE_USES_WCHAR) ACE_OSCALL_RETURN (::_wsystem (s), int, -1); #elif defined (ACE_TANDEM_T1248_PTHREADS) ACE_OSCALL_RETURN (::spt_system (s), int, -1); #else ACE_OSCALL_RETURN (::system (ACE_TEXT_ALWAYS_CHAR (s)), int, -1); #endif /* ACE_LACKS_SYSTEM */ }
int ACE_OS::t_accept | ( | ACE_HANDLE | fildes, | |
ACE_HANDLE | resfd, | |||
struct t_call * | call | |||
) | [inline] |
Definition at line 12 of file OS_TLI.inl.
{ #if defined (ACE_HAS_TLI) ACE_OSCALL_RETURN (::t_accept (handle, reshandle, call), int, -1); #else ACE_UNUSED_ARG (call); ACE_UNUSED_ARG (reshandle); ACE_UNUSED_ARG (handle); ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_TLI */ }
char * ACE_OS::t_alloc | ( | ACE_HANDLE | fildes, | |
int | struct_type, | |||
int | fields | |||
) | [inline] |
Definition at line 26 of file OS_TLI.inl.
{ #if defined (ACE_HAS_TLI) # if (defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) >= 500) // XPG5 changes t_alloc() return from char* to void*, so ACE_OSCALL_RETURN // doesn't compile correctly. char *result; ACE_OSCALL (::t_alloc (handle, struct_type, fields), char *, 0, result); return result; # else ACE_OSCALL_RETURN (::t_alloc (handle, struct_type, fields), char *, 0); # endif /* XPG4 vs XPG5 */ #else ACE_UNUSED_ARG (fields); ACE_UNUSED_ARG (struct_type); ACE_UNUSED_ARG (handle); ACE_NOTSUP_RETURN (0); #endif /* ACE_HAS_TLI */ }
Definition at line 49 of file OS_TLI.inl.
{ #if defined (ACE_HAS_TLI) ACE_OSCALL_RETURN (::t_bind (handle, req, ret), int, -1); #else ACE_UNUSED_ARG (ret); ACE_UNUSED_ARG (req); ACE_UNUSED_ARG (handle); ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_TLI */ }
int ACE_OS::t_close | ( | ACE_HANDLE | fildes | ) | [inline] |
Definition at line 63 of file OS_TLI.inl.
{ #if defined (ACE_HAS_TLI) ACE_OSCALL_RETURN (::t_close (handle), int, -1); #else ACE_UNUSED_ARG (handle); ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_TLI */ }
int ACE_OS::t_connect | ( | ACE_HANDLE | fildes, | |
struct t_call * | sndcall, | |||
struct t_call * | rcvcall | |||
) | [inline] |
Definition at line 75 of file OS_TLI.inl.
{ #if defined (ACE_HAS_TLI) ACE_OSCALL_RETURN (::t_connect (fildes, sndcall, rcvcall), int, -1); #else ACE_UNUSED_ARG (fildes); ACE_UNUSED_ARG (sndcall); ACE_UNUSED_ARG (rcvcall); ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_TLI */ }
void ACE_OS::t_error | ( | const char * | errmsg | ) | [inline] |
Definition at line 91 of file OS_TLI.inl.
int ACE_OS::t_free | ( | char * | ptr, | |
int | struct_type | |||
) | [inline] |
Definition at line 105 of file OS_TLI.inl.
{ #if defined (ACE_HAS_TLI) if (ptr == 0) return 0; ACE_OSCALL_RETURN (::t_free (ptr, struct_type), int, -1); #else ACE_UNUSED_ARG (struct_type); ACE_UNUSED_ARG (ptr); ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_TLI */ }
int ACE_OS::t_getinfo | ( | ACE_HANDLE | fildes, | |
struct t_info * | info | |||
) | [inline] |
Definition at line 120 of file OS_TLI.inl.
{ #if defined (ACE_HAS_TLI) ACE_OSCALL_RETURN (::t_getinfo (handle, info), int, -1); #else ACE_UNUSED_ARG (info); ACE_UNUSED_ARG (handle); ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_TLI */ }
int ACE_OS::t_getname | ( | ACE_HANDLE | fildes, | |
struct netbuf * | namep, | |||
int | type | |||
) | [inline] |
Definition at line 133 of file OS_TLI.inl.
{ #if defined (ACE_HAS_XTI) ACE_TBIND bound, peer; // Depending on which address the caller wants, fill caller's values // into one of the t_bind netbufs. The other is set up to ignore that // address. switch (type) { case LOCALNAME: bound.addr.buf = namep->buf; bound.addr.maxlen = namep->maxlen; bound.addr.len = 0; peer.addr.buf = 0; peer.addr.maxlen = 0; peer.addr.len = 0; break; case REMOTENAME: bound.addr.buf = 0; bound.addr.maxlen = 0; bound.addr.len = 0; peer.addr.buf = namep->buf; peer.addr.maxlen = namep->maxlen; peer.addr.len = 0; break; default: ACE_OS::last_error (EINVAL); return -1; } if (t_getprotaddr (handle, &bound, &peer) == -1) return -1; // Call succeeded; put the caller's desired address length in his netbuf. if (type == LOCALNAME) namep->len = bound.addr.len; else namep->len = peer.addr.len; return 0; #elif defined (ACE_HAS_SVR4_TLI) ACE_OSCALL_RETURN (::t_getname (handle, namep, type), int, -1); #else ACE_UNUSED_ARG (handle); ACE_UNUSED_ARG (namep); ACE_UNUSED_ARG (type); ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_SVR4_TLI */ }
int ACE_OS::t_getstate | ( | ACE_HANDLE | fildes | ) | [inline] |
Definition at line 183 of file OS_TLI.inl.
{ #if defined (ACE_HAS_TLI) ACE_OSCALL_RETURN (::t_getstate (handle), int, -1); #else ACE_UNUSED_ARG (handle); ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_TLI */ }
int ACE_OS::t_listen | ( | ACE_HANDLE | fildes, | |
struct t_call * | call | |||
) | [inline] |
Definition at line 195 of file OS_TLI.inl.
{ #if defined (ACE_HAS_TLI) ACE_OSCALL_RETURN (::t_listen (handle, call), int, -1); #else ACE_UNUSED_ARG (handle); ACE_UNUSED_ARG (call); ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_TLI */ }
int ACE_OS::t_look | ( | ACE_HANDLE | fildes | ) | [inline] |
Definition at line 208 of file OS_TLI.inl.
{ #if defined (ACE_HAS_TLI) ACE_OSCALL_RETURN (::t_look (handle), int, -1); #else ACE_UNUSED_ARG (handle); ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_TLI */ }
ACE_HANDLE ACE_OS::t_open | ( | char * | path, | |
int | oflag, | |||
struct t_info * | info | |||
) | [inline] |
Definition at line 220 of file OS_TLI.inl.
{ #if defined (ACE_HAS_TLI) ACE_OSCALL_RETURN (::t_open (path, oflag, info), ACE_HANDLE, ACE_INVALID_HANDLE); #else ACE_UNUSED_ARG (path); ACE_UNUSED_ARG (oflag); ACE_UNUSED_ARG (info); ACE_NOTSUP_RETURN (ACE_INVALID_HANDLE); #endif /* ACE_HAS_TLI */ }
int ACE_OS::t_optmgmt | ( | ACE_HANDLE | handle, | |
ACE_TOPTMGMT * | req, | |||
ACE_TOPTMGMT * | ret | |||
) | [inline] |
Definition at line 234 of file OS_TLI.inl.
{ #if defined (ACE_HAS_TLI) ACE_OSCALL_RETURN (::t_optmgmt (handle, req, ret), int, -1); #else ACE_UNUSED_ARG (handle); ACE_UNUSED_ARG (req); ACE_UNUSED_ARG (ret); ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_TLI */ }
int ACE_OS::t_rcv | ( | ACE_HANDLE | fildes, | |
char * | buf, | |||
unsigned int | nbytes, | |||
int * | flags | |||
) | [inline] |
Definition at line 248 of file OS_TLI.inl.
{ #if defined (ACE_HAS_TLI) ACE_OSCALL_RETURN (::t_rcv (handle, buf, nbytes, flags), int, -1); #else ACE_UNUSED_ARG (handle); ACE_UNUSED_ARG (buf); ACE_UNUSED_ARG (nbytes); ACE_UNUSED_ARG (flags); ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_TLI */ }
int ACE_OS::t_rcvdis | ( | ACE_HANDLE | fildes, | |
struct t_discon * | discon | |||
) | [inline] |
Definition at line 267 of file OS_TLI.inl.
{ #if defined (ACE_HAS_TLI) ACE_OSCALL_RETURN (::t_rcvdis (handle, discon), int, -1); #else ACE_UNUSED_ARG (handle); ACE_UNUSED_ARG (discon); ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_TLI */ }
int ACE_OS::t_rcvrel | ( | ACE_HANDLE | fildes | ) | [inline] |
Definition at line 280 of file OS_TLI.inl.
{ #if defined (ACE_HAS_TLI) ACE_OSCALL_RETURN (::t_rcvrel (handle), int, -1); #else ACE_UNUSED_ARG (handle); ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_TLI */ }
int ACE_OS::t_rcvudata | ( | ACE_HANDLE | fildes, | |
struct t_unitdata * | unitdata, | |||
int * | flags | |||
) | [inline] |
Definition at line 292 of file OS_TLI.inl.
{ #if defined (ACE_HAS_TLI) ACE_OSCALL_RETURN (::t_rcvudata (handle, unitdata, flags), int, -1); #else ACE_UNUSED_ARG (handle); ACE_UNUSED_ARG (unitdata); ACE_UNUSED_ARG (flags); ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_TLI */ }
int ACE_OS::t_rcvuderr | ( | ACE_HANDLE | fildes, | |
struct t_uderr * | uderr | |||
) | [inline] |
Definition at line 309 of file OS_TLI.inl.
{ #if defined (ACE_HAS_TLI) ACE_OSCALL_RETURN (::t_rcvuderr (handle, uderr), int, -1); #else ACE_UNUSED_ARG (handle); ACE_UNUSED_ARG (uderr); ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_TLI */ }
int ACE_OS::t_snd | ( | ACE_HANDLE | fildes, | |
const char * | buf, | |||
unsigned int | nbytes, | |||
int | flags | |||
) | [inline] |
Definition at line 322 of file OS_TLI.inl.
{ #if defined (ACE_HAS_TLI) ACE_OSCALL_RETURN (::t_snd (handle, (char *) buf, nbytes, flags), int, -1); #else ACE_UNUSED_ARG (handle); ACE_UNUSED_ARG (buf); ACE_UNUSED_ARG (nbytes); ACE_UNUSED_ARG (flags); ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_TLI */ }
int ACE_OS::t_snddis | ( | ACE_HANDLE | fildes, | |
struct t_call * | call | |||
) | [inline] |
Definition at line 340 of file OS_TLI.inl.
{ #if defined (ACE_HAS_TLI) ACE_OSCALL_RETURN (::t_snddis (handle, call), int, -1); #else ACE_UNUSED_ARG (handle); ACE_UNUSED_ARG (call); ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_TLI */ }
int ACE_OS::t_sndrel | ( | ACE_HANDLE | fildes | ) | [inline] |
Definition at line 353 of file OS_TLI.inl.
{ #if defined (ACE_HAS_TLI) ACE_OSCALL_RETURN (::t_sndrel (handle), int, -1); #else ACE_UNUSED_ARG (handle); ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_TLI */ }
int ACE_OS::t_sync | ( | ACE_HANDLE | fildes | ) | [inline] |
Definition at line 365 of file OS_TLI.inl.
{ #if defined (ACE_HAS_TLI) ACE_OSCALL_RETURN (::t_sync (handle), int, -1); #else ACE_UNUSED_ARG (handle); ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_TLI */ }
int ACE_OS::t_unbind | ( | ACE_HANDLE | fildes | ) | [inline] |
Definition at line 377 of file OS_TLI.inl.
{ #if defined (ACE_HAS_TLI) ACE_OSCALL_RETURN (::t_unbind (handle), int, -1); #else ACE_UNUSED_ARG (handle); ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_TLI */ }
long ACE_OS::telldir | ( | ACE_DIR * | d | ) | [inline] |
Definition at line 172 of file OS_NS_dirent.inl.
{ #if defined (ACE_HAS_DIRENT) && !defined (ACE_LACKS_TELLDIR) return ::telldir (d); #else /* ! ACE_HAS_DIRENT || ACE_LACKS_TELLDIR */ ACE_UNUSED_ARG (d); ACE_NOTSUP_RETURN (-1); #endif /* ! ACE_HAS_DIRENT || ACE_LACKS_TELLDIR */ }
char * ACE_OS::tempnam | ( | const char * | dir = 0 , |
|
const char * | pfx = 0 | |||
) | [inline] |
Definition at line 889 of file OS_NS_stdio.inl.
{ ACE_OS_TRACE ("ACE_OS::tempnam"); #if defined (ACE_LACKS_TEMPNAM) ACE_UNUSED_ARG (dir); ACE_UNUSED_ARG (pfx); ACE_NOTSUP_RETURN (0); #elif defined (ACE_HAS_NONCONST_TEMPNAM) ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::tempnam (const_cast <char *> (dir), const_cast<char *> (pfx)), char *, 0); #else /* ACE_LACKS_TEMPNAM */ ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::tempnam (dir, pfx), char *, 0); #endif /* ACE_LACKS_TEMPNAM */ }
int ACE_OS::thr_cancel | ( | ACE_thread_t | t_id | ) | [inline] |
Definition at line 2559 of file OS_NS_Thread.inl.
{ ACE_OS_TRACE ("ACE_OS::thr_cancel"); #if defined (ACE_HAS_THREADS) # if defined (ACE_HAS_PTHREADS) && !defined (ACE_LACKS_PTHREAD_CANCEL) int result; ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_cancel (thr_id), result), int, -1); # elif defined (ACE_HAS_VXTHREADS) ACE_OSCALL_RETURN (::taskDelete (thr_id), int, -1); # else /* Could be ACE_HAS_PTHREADS && ACE_LACKS_PTHREAD_CANCEL */ ACE_UNUSED_ARG (thr_id); ACE_NOTSUP_RETURN (-1); # endif /* ACE_HAS_PTHREADS */ #else ACE_UNUSED_ARG (thr_id); ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_THREADS */ }
int ACE_OS::thr_cmp | ( | ACE_hthread_t | t1, | |
ACE_hthread_t | t2 | |||
) | [inline] |
Definition at line 2581 of file OS_NS_Thread.inl.
{ #if defined (ACE_HAS_PTHREADS) # if defined (pthread_equal) // If it's a macro we can't say "pthread_equal"... return pthread_equal (t1, t2); # else return pthread_equal (t1, t2); # endif /* pthread_equal */ #else /* For STHREADS, WTHREADS, and VXWORKS ... */ // Hum, Do we need to treat WTHREAD differently? // levine 13 oct 98 % Probably, ACE_hthread_t is a HANDLE. return t1 == t2; #endif /* ACE_HAS_PTHREADS */ }
int ACE_OS::thr_continue | ( | ACE_hthread_t | target_thread | ) | [inline] |
Definition at line 2598 of file OS_NS_Thread.inl.
{ ACE_OS_TRACE ("ACE_OS::thr_continue"); #if defined (ACE_HAS_THREADS) # if defined (ACE_HAS_STHREADS) int result; ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_continue (target_thread), result), int, -1); # elif defined (ACE_HAS_PTHREADS) # if defined (ACE_HAS_PTHREAD_CONTINUE) int result; ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_continue (target_thread), result), int, -1); # elif defined (ACE_HAS_PTHREAD_CONTINUE_NP) int result; ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_continue_np (target_thread), result), int, -1); # elif defined (ACE_HAS_PTHREAD_RESUME_NP) int result; ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_resume_np (target_thread), result), int, -1); # else ACE_UNUSED_ARG (target_thread); ACE_NOTSUP_RETURN (-1); # endif /* ACE_HAS_PTHREAD_CONTINUE */ # elif defined (ACE_HAS_WTHREADS) DWORD result = ::ResumeThread (target_thread); if (result == ACE_SYSCALL_FAILED) ACE_FAIL_RETURN (-1); else return 0; # elif defined (ACE_HAS_VXTHREADS) ACE_OSCALL_RETURN (::taskResume (target_thread), int, -1); # endif /* ACE_HAS_STHREADS */ #else ACE_UNUSED_ARG (target_thread); ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_THREADS */ }
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 = ACE_DEFAULT_THREAD_STACKSIZE , |
|||
ACE_Base_Thread_Adapter * | thread_adapter = 0 , |
|||
const char ** | thr_name = 0 | |||
) |
Definition at line 3759 of file OS_NS_Thread.cpp.
{ ACE_OS_TRACE ("ACE_OS::thr_create"); if (ACE_BIT_DISABLED (flags, THR_DETACHED) && ACE_BIT_DISABLED (flags, THR_JOINABLE)) ACE_SET_BITS (flags, THR_JOINABLE); #if defined (ACE_NO_THREAD_ADAPTER) # define ACE_THREAD_FUNCTION func # define ACE_THREAD_ARGUMENT args #else /* ! defined (ACE_NO_THREAD_ADAPTER) */ # define ACE_THREAD_FUNCTION thread_args->entry_point () # define ACE_THREAD_ARGUMENT thread_args #endif /* ! defined (ACE_NO_THREAD_ADAPTER) */ ACE_Base_Thread_Adapter *thread_args = 0; if (thread_adapter == 0) #if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS) ACE_NEW_RETURN (thread_args, ACE_OS_Thread_Adapter (func, args, (ACE_THR_C_FUNC) ACE_THREAD_ADAPTER_NAME, ACE_OS_Object_Manager::seh_except_selector(), ACE_OS_Object_Manager::seh_except_handler()), -1); #else ACE_NEW_RETURN (thread_args, ACE_OS_Thread_Adapter (func, args, (ACE_THR_C_FUNC) ACE_THREAD_ADAPTER_NAME), -1); #endif /* ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS */ else thread_args = thread_adapter; auto_ptr <ACE_Base_Thread_Adapter> auto_thread_args; if (thread_adapter == 0) ACE_AUTO_PTR_RESET (auto_thread_args, thread_args, ACE_Base_Thread_Adapter); #if defined (ACE_HAS_THREADS) // *** Set Stack Size # if defined (ACE_NEEDS_HUGE_THREAD_STACKSIZE) if (stacksize < ACE_NEEDS_HUGE_THREAD_STACKSIZE) stacksize = ACE_NEEDS_HUGE_THREAD_STACKSIZE; # endif /* ACE_NEEDS_HUGE_THREAD_STACKSIZE */ ACE_thread_t tmp_thr; if (thr_id == 0) thr_id = &tmp_thr; ACE_hthread_t tmp_handle; if (thr_handle == 0) thr_handle = &tmp_handle; # if defined (ACE_HAS_PTHREADS) int result; # if defined (ACE_PTHREAD_ATTR_T_INITIALIZE) /* Tests show that VxWorks 6.x pthread lib does not only * require zeroing of mutex/condition objects to function correctly * but also of the attribute objects. */ pthread_attr_t attr = {0}; # else pthread_attr_t attr; # endif if (ACE_ADAPT_RETVAL(::pthread_attr_init(&attr), result) != 0) return -1; if (stacksize != 0) { size_t size = stacksize; # if defined (PTHREAD_STACK_MIN) if (size < static_cast <size_t> (PTHREAD_STACK_MIN)) size = PTHREAD_STACK_MIN; # endif /* PTHREAD_STACK_MIN */ # if !defined (ACE_LACKS_PTHREAD_ATTR_SETSTACKSIZE) # if !defined (ACE_LACKS_PTHREAD_ATTR_SETSTACK) int result; if (stack != 0) result = ACE_ADAPT_RETVAL (pthread_attr_setstack (&attr, stack, size), result); else result = ACE_ADAPT_RETVAL (pthread_attr_setstacksize (&attr, size), result); if (result == -1) # else if (ACE_ADAPT_RETVAL (pthread_attr_setstacksize (&attr, size), result) == -1) # endif /* !ACE_LACKS_PTHREAD_ATTR_SETSTACK */ { ::pthread_attr_destroy (&attr); return -1; } # else ACE_UNUSED_ARG (size); # endif /* !ACE_LACKS_PTHREAD_ATTR_SETSTACKSIZE */ } // *** Set Stack Address # if defined (ACE_LACKS_PTHREAD_ATTR_SETSTACK) # if !defined (ACE_LACKS_PTHREAD_ATTR_SETSTACKADDR) if (stack != 0) { if (ACE_ADAPT_RETVAL(::pthread_attr_setstackaddr (&attr, stack), result) != 0) { ::pthread_attr_destroy (&attr); return -1; } } # else ACE_UNUSED_ARG (stack); # endif /* !ACE_LACKS_PTHREAD_ATTR_SETSTACKADDR */ # endif /* ACE_LACKS_PTHREAD_ATTR_SETSTACK */ // *** Deal with various attributes if (flags != 0) { // *** Set Detach state # if !defined (ACE_LACKS_SETDETACH) if (ACE_BIT_ENABLED (flags, THR_DETACHED) || ACE_BIT_ENABLED (flags, THR_JOINABLE)) { int dstate = PTHREAD_CREATE_JOINABLE; if (ACE_BIT_ENABLED (flags, THR_DETACHED)) dstate = PTHREAD_CREATE_DETACHED; if (ACE_ADAPT_RETVAL(::pthread_attr_setdetachstate (&attr, dstate), result) != 0) { ::pthread_attr_destroy (&attr); return -1; } } // Note: if ACE_LACKS_SETDETACH and THR_DETACHED is enabled, we // call ::pthread_detach () below. If THR_DETACHED is not // enabled, we call ::pthread_detach () in the Thread_Manager, // after joining with the thread. # endif /* ACE_LACKS_SETDETACH */ // *** Set Policy # if !defined (ACE_LACKS_SETSCHED) || defined (ACE_HAS_PTHREAD_SCHEDPARAM) // If we wish to set the priority explicitly, we have to enable // explicit scheduling, and a policy, too. if (priority != ACE_DEFAULT_THREAD_PRIORITY) { ACE_SET_BITS (flags, THR_EXPLICIT_SCHED); if (ACE_BIT_DISABLED (flags, THR_SCHED_FIFO) && ACE_BIT_DISABLED (flags, THR_SCHED_RR) && ACE_BIT_DISABLED (flags, THR_SCHED_DEFAULT)) ACE_SET_BITS (flags, THR_SCHED_DEFAULT); } if (ACE_BIT_ENABLED (flags, THR_SCHED_FIFO) || ACE_BIT_ENABLED (flags, THR_SCHED_RR) || ACE_BIT_ENABLED (flags, THR_SCHED_DEFAULT)) { int spolicy; # if defined (ACE_HAS_ONLY_SCHED_OTHER) // SunOS, thru version 5.6, only supports SCHED_OTHER. spolicy = SCHED_OTHER; # elif defined (ACE_HAS_ONLY_SCHED_FIFO) // NonStop OSS standard pthread supports only SCHED_FIFO. spolicy = SCHED_FIFO; # else // Make sure to enable explicit scheduling, in case we didn't // enable it above (for non-default priority). ACE_SET_BITS (flags, THR_EXPLICIT_SCHED); if (ACE_BIT_ENABLED (flags, THR_SCHED_DEFAULT)) spolicy = SCHED_OTHER; else if (ACE_BIT_ENABLED (flags, THR_SCHED_FIFO)) spolicy = SCHED_FIFO; # if defined (SCHED_IO) else if (ACE_BIT_ENABLED (flags, THR_SCHED_IO)) spolicy = SCHED_IO; # else else if (ACE_BIT_ENABLED (flags, THR_SCHED_IO)) { errno = ENOSYS; return -1; } # endif /* SCHED_IO */ else spolicy = SCHED_RR; # endif /* ACE_HAS_ONLY_SCHED_OTHER */ (void) ACE_ADAPT_RETVAL(::pthread_attr_setschedpolicy (&attr, spolicy), result); if (result != 0) { ::pthread_attr_destroy (&attr); return -1; } } // *** Set Priority (use reasonable default priorities) # if defined(ACE_HAS_PTHREADS) // If we wish to explicitly set a scheduling policy, we also // have to specify a priority. We choose a "middle" priority as // default. Maybe this is also necessary on other POSIX'ish // implementations? if ((ACE_BIT_ENABLED (flags, THR_SCHED_FIFO) || ACE_BIT_ENABLED (flags, THR_SCHED_RR) || ACE_BIT_ENABLED (flags, THR_SCHED_DEFAULT)) && priority == ACE_DEFAULT_THREAD_PRIORITY) { if (ACE_BIT_ENABLED (flags, THR_SCHED_FIFO)) priority = ACE_THR_PRI_FIFO_DEF; else if (ACE_BIT_ENABLED (flags, THR_SCHED_RR)) priority = ACE_THR_PRI_RR_DEF; else // THR_SCHED_DEFAULT priority = ACE_THR_PRI_OTHER_DEF; } # endif /* ACE_HAS_PTHREADS */ if (priority != ACE_DEFAULT_THREAD_PRIORITY) { struct sched_param sparam; ACE_OS::memset ((void *) &sparam, 0, sizeof sparam); # if defined (ACE_HAS_IRIX62_THREADS) sparam.sched_priority = ACE_MIN (priority, (long) PTHREAD_MAX_PRIORITY); # elif defined (PTHREAD_MAX_PRIORITY) && !defined(ACE_HAS_PTHREADS) /* For MIT pthreads... */ sparam.prio = ACE_MIN (priority, PTHREAD_MAX_PRIORITY); # elif defined(ACE_HAS_PTHREADS) && !defined (ACE_HAS_STHREADS) // The following code forces priority into range. if (ACE_BIT_ENABLED (flags, THR_SCHED_FIFO)) sparam.sched_priority = ACE_MIN (ACE_THR_PRI_FIFO_MAX, ACE_MAX (ACE_THR_PRI_FIFO_MIN, priority)); else if (ACE_BIT_ENABLED(flags, THR_SCHED_RR)) sparam.sched_priority = ACE_MIN (ACE_THR_PRI_RR_MAX, ACE_MAX (ACE_THR_PRI_RR_MIN, priority)); else // Default policy, whether set or not sparam.sched_priority = ACE_MIN (ACE_THR_PRI_OTHER_MAX, ACE_MAX (ACE_THR_PRI_OTHER_MIN, priority)); # elif defined (PRIORITY_MAX) sparam.sched_priority = ACE_MIN (priority, (long) PRIORITY_MAX); # else sparam.sched_priority = priority; # endif /* ACE_HAS_IRIX62_THREADS */ { # if defined (sun) && defined (ACE_HAS_ONLY_SCHED_OTHER) // SunOS, through 5.6, POSIX only allows priorities > 0 to // ::pthread_attr_setschedparam. If a priority of 0 was // requested, set the thread priority after creating it, below. if (priority > 0) # endif /* sun && ACE_HAS_ONLY_SCHED_OTHER */ { (void) ACE_ADAPT_RETVAL(::pthread_attr_setschedparam (&attr, &sparam), result); if (result != 0) { ::pthread_attr_destroy (&attr); return -1; } } } } // *** Set scheduling explicit or inherited if (ACE_BIT_ENABLED (flags, THR_INHERIT_SCHED) || ACE_BIT_ENABLED (flags, THR_EXPLICIT_SCHED)) { int sched = PTHREAD_EXPLICIT_SCHED; if (ACE_BIT_ENABLED (flags, THR_INHERIT_SCHED)) sched = PTHREAD_INHERIT_SCHED; if (ACE_ADAPT_RETVAL(::pthread_attr_setinheritsched (&attr, sched), result) != 0) { ::pthread_attr_destroy (&attr); return -1; } } # else /* ACE_LACKS_SETSCHED */ ACE_UNUSED_ARG (priority); # endif /* ACE_LACKS_SETSCHED */ // *** Set pthread name # if defined (ACE_HAS_PTHREAD_ATTR_SETNAME) if (thr_name && *thr_name) { if (ACE_ADAPT_RETVAL(::pthread_attr_setname (&attr, const_cast<char*>(*thr_name)), result) != 0) { ::pthread_attr_destroy (&attr); return -1; } } #else ACE_UNUSED_ARG (thr_name); # endif // *** Set Scope # if !defined (ACE_LACKS_THREAD_PROCESS_SCOPING) if (ACE_BIT_ENABLED (flags, THR_SCOPE_SYSTEM) || ACE_BIT_ENABLED (flags, THR_SCOPE_PROCESS)) { # if defined (ACE_CONFIG_LINUX_H) || defined (HPUX) || defined (ACE_VXWORKS) // LinuxThreads do not have support for PTHREAD_SCOPE_PROCESS. // Neither does HPUX (up to HP-UX 11.00, as far as I know). // Also VxWorks only delivers scope system int scope = PTHREAD_SCOPE_SYSTEM; # else /* ACE_CONFIG_LINUX_H */ int scope = PTHREAD_SCOPE_PROCESS; # endif /* ACE_CONFIG_LINUX_H */ if (ACE_BIT_ENABLED (flags, THR_SCOPE_SYSTEM)) scope = PTHREAD_SCOPE_SYSTEM; if (ACE_ADAPT_RETVAL(::pthread_attr_setscope (&attr, scope), result) != 0) { ::pthread_attr_destroy (&attr); return -1; } } # endif /* !ACE_LACKS_THREAD_PROCESS_SCOPING */ # ifdef ACE_HAS_PTHREAD_ATTR_SETCREATESUSPEND_NP if (ACE_BIT_ENABLED (flags, THR_SUSPENDED)) { if (ACE_ADAPT_RETVAL(::pthread_attr_setcreatesuspend_np(&attr), result) != 0) { ::pthread_attr_destroy (&attr); return -1; } } # endif /* !ACE_HAS_PTHREAD_ATTR_SETCREATESUSPEND_NP */ # if ! defined(ACE_LACKS_THR_CONCURRENCY_FUNCS) if (ACE_BIT_ENABLED (flags, THR_NEW_LWP)) { // Increment the number of LWPs by one to emulate the // SunOS semantics. int lwps = ACE_OS::thr_getconcurrency (); if (lwps == -1) { if (errno == ENOTSUP) // Suppress the ENOTSUP because it's harmless. errno = 0; else // This should never happen on SunOS: // ::thr_getconcurrency () should always succeed. return -1; } else if (ACE_OS::thr_setconcurrency (lwps + 1) == -1) { if (errno == ENOTSUP) { // Unlikely: ::thr_getconcurrency () is supported // but ::thr_setconcurrency () is not? } else return -1; } } # endif /* ! ACE_LACKS_THR_CONCURRENCY_FUNCS */ } ACE_OSCALL (ACE_ADAPT_RETVAL (::pthread_create (thr_id, &attr, thread_args->entry_point (), thread_args), result), int, -1, result); ::pthread_attr_destroy (&attr); // This is a SunOS or POSIX implementation of pthreads, where we // assume that ACE_thread_t and ACE_hthread_t are the same. If this // *isn't* correct on some platform, please let us know. if (result != -1) *thr_handle = *thr_id; # if defined (sun) && defined (ACE_HAS_ONLY_SCHED_OTHER) // SunOS prior to 5.7: // If the priority is 0, then we might have to set it now because we // couldn't set it with ::pthread_attr_setschedparam, as noted // above. This doesn't provide strictly correct behavior, because // the thread was created (above) with the priority of its parent. // (That applies regardless of the inherit_sched attribute: if it // was PTHREAD_INHERIT_SCHED, then it certainly inherited its // parent's priority. If it was PTHREAD_EXPLICIT_SCHED, then "attr" // was initialized by the SunOS ::pthread_attr_init () to contain // NULL for the priority, which indicated to SunOS ::pthread_create // () to inherit the parent priority.) if (priority == 0) { // Check the priority of this thread, which is the parent // of the newly created thread. If it is 0, then the // newly created thread will have inherited the priority // of 0, so there's no need to explicitly set it. struct sched_param sparam; int policy = 0; ACE_OSCALL (ACE_ADAPT_RETVAL (::pthread_getschedparam (thr_self (), &policy, &sparam), result), int, -1, result); // The only policy supported by by SunOS, thru version 5.6, // is SCHED_OTHER, so that's hard-coded here. policy = ACE_SCHED_OTHER; if (sparam.sched_priority != 0) { ACE_OS::memset ((void *) &sparam, 0, sizeof sparam); // The memset to 0 sets the priority to 0, so we don't need // to explicitly set sparam.sched_priority. ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_setschedparam (*thr_id, policy, &sparam), result), int, -1); } } # if defined (ACE_NEEDS_LWP_PRIO_SET) # if 0 // It would be useful if we could make this work. But, it requires // a mechanism for determining the ID of an LWP to which another // thread is bound. Is there a way to do that? Instead, just rely // on the code in ACE_Thread_Adapter::invoke () to set the LWP // priority. // If the thread is bound, then set the priority on its LWP. if (ACE_BIT_ENABLED (flags, THR_BOUND)) { ACE_Sched_Params sched_params (ACE_BIT_ENABLED (flags, THR_SCHED_FIFO) || ACE_BIT_ENABLED (flags, THR_SCHED_RR) ? ACE_SCHED_FIFO : ACE_SCHED_OTHER, priority); result = ACE_OS::lwp_setparams (sched_params, /* ? How do we find the ID of the LWP to which *thr_id is bound? */); } # endif /* 0 */ # endif /* ACE_NEEDS_LWP_PRIO_SET */ # endif /* sun && ACE_HAS_ONLY_SCHED_OTHER */ auto_thread_args.release (); return result; # elif defined (ACE_HAS_STHREADS) int result; int start_suspended = ACE_BIT_ENABLED (flags, THR_SUSPENDED); if (priority != ACE_DEFAULT_THREAD_PRIORITY) // If we need to set the priority, then we need to start the // thread in a suspended mode. ACE_SET_BITS (flags, THR_SUSPENDED); ACE_OSCALL (ACE_ADAPT_RETVAL (::thr_create (stack, stacksize, thread_args->entry_point (), thread_args, flags, thr_id), result), int, -1, result); if (result != -1) { // With SunOS threads, ACE_thread_t and ACE_hthread_t are the same. *thr_handle = *thr_id; if (priority != ACE_DEFAULT_THREAD_PRIORITY) { // Set the priority of the new thread and then let it // continue, but only if the user didn't start it suspended // in the first place! result = ACE_OS::thr_setprio (*thr_id, priority); if (result != 0) { errno = result; return -1; } if (start_suspended == 0) { result = ACE_OS::thr_continue (*thr_id); if (result != 0) { errno = result; return -1; } } } } auto_thread_args.release (); return result; # elif defined (ACE_HAS_WTHREADS) ACE_UNUSED_ARG (thr_name); ACE_UNUSED_ARG (stack); # if defined (ACE_HAS_MFC) && (ACE_HAS_MFC != 0) if (ACE_BIT_ENABLED (flags, THR_USE_AFX)) { CWinThread *cwin_thread = ::AfxBeginThread ((AFX_THREADPROC) thread_args->entry_point (), thread_args, priority, 0, flags | THR_SUSPENDED); // Have to duplicate the handle because // CWinThread::~CWinThread() closes the original handle. # if !defined (ACE_HAS_WINCE) (void) ::DuplicateHandle (::GetCurrentProcess (), cwin_thread->m_hThread, ::GetCurrentProcess (), thr_handle, 0, TRUE, DUPLICATE_SAME_ACCESS); # endif /* ! ACE_HAS_WINCE */ *thr_id = cwin_thread->m_nThreadID; if (ACE_BIT_ENABLED (flags, THR_SUSPENDED) == 0) cwin_thread->ResumeThread (); // cwin_thread will be deleted in AfxThreadExit() // Warning: If AfxThreadExit() is called from within the // thread, ACE_TSS_Cleanup->thread_exit() never gets called ! } else # endif /* ACE_HAS_MFC */ { int start_suspended = ACE_BIT_ENABLED (flags, THR_SUSPENDED); if (priority != ACE_DEFAULT_THREAD_PRIORITY) // If we need to set the priority, then we need to start the // thread in a suspended mode. ACE_SET_BITS (flags, THR_SUSPENDED); *thr_handle = (void *) ACE_BEGINTHREADEX (0, static_cast <u_int> (stacksize), thread_args->entry_point (), thread_args, flags, thr_id); if (priority != ACE_DEFAULT_THREAD_PRIORITY && *thr_handle != 0) { // Set the priority of the new thread and then let it // continue, but only if the user didn't start it suspended // in the first place! if (ACE_OS::thr_setprio (*thr_handle, priority) != 0) { return -1; } if (start_suspended == 0) { ACE_OS::thr_continue (*thr_handle); } } } # if 0 *thr_handle = ::CreateThread (0, stacksize, LPTHREAD_START_ROUTINE (thread_args->entry_point ()), thread_args, flags, thr_id); # endif /* 0 */ // Close down the handle if no one wants to use it. if (thr_handle == &tmp_handle && tmp_handle != 0) ::CloseHandle (tmp_handle); if (*thr_handle != 0) { auto_thread_args.release (); return 0; } else ACE_FAIL_RETURN (-1); /* NOTREACHED */ # elif defined (ACE_VXWORKS) // The hard-coded values below are what ::sp () would use. (::sp () // hardcodes priority to 100, flags to VX_FP_TASK, and stacksize to // 20,000.) stacksize should be an even integer. If a stack is not // specified, ::taskSpawn () is used so that we can set the // priority, flags, and stacksize. If a stack is specified, // ::taskInit ()/::taskActivate() are used. // If called with thr_create() defaults, use same default values as ::sp (): if (priority == ACE_DEFAULT_THREAD_PRIORITY) priority = 100; // Assumes that there is a floating point coprocessor. As noted // above, ::sp () hardcodes this, so we should be safe with it. if (flags == 0) flags = VX_FP_TASK; if (stacksize == 0) stacksize = 20000; ACE_thread_t tid; # if 0 /* Don't support setting of stack, because it doesn't seem to work. */ if (stack == 0) { # else ACE_UNUSED_ARG (stack); # endif /* 0 */ // The call below to ::taskSpawn () causes VxWorks to assign a // unique task name of the form: "t" + an integer, because the // first argument is 0. tid = ::taskSpawn (thr_name && *thr_name ? const_cast <char*> (*thr_name) : 0, priority, (int) flags, (int) stacksize, thread_args->entry_point (), (int) thread_args, 0, 0, 0, 0, 0, 0, 0, 0, 0); # if 0 /* Don't support setting of stack, because it doesn't seem to work. */ } else { // If a task name (thr_id) was not supplied, then the task will // not have a unique name. That's VxWorks' behavior. // Carve out a TCB at the beginning of the stack space. The TCB // occupies 400 bytes with VxWorks 5.3.1/I386. WIND_TCB *tcb = (WIND_TCB *) stack; // The TID is defined to be the address of the TCB. int status = ::taskInit (tcb, thr_name && *thr_name ? const_cast <char*>(*thr_name) : 0, priority, (int) flags, (char *) stack + sizeof (WIND_TCB), (int) (stacksize - sizeof (WIND_TCB)), thread_args->entry_point (), (int) thread_args, 0, 0, 0, 0, 0, 0, 0, 0, 0); if (status == OK) { // The task was successfully initialized, now activate it. status = ::taskActivate ((ACE_hthread_t) tcb); } tid = status == OK ? (ACE_thread_t) tcb : ERROR; } # endif /* 0 */ if (tid == ERROR) return -1; else { if (thr_id) *thr_id = tid; if (thr_handle) *thr_handle = tid; if (thr_name && !(*thr_name)) *thr_name = ::taskName (tid); auto_thread_args.release (); return 0; } # endif /* ACE_HAS_STHREADS */ #else ACE_UNUSED_ARG (func); ACE_UNUSED_ARG (args); ACE_UNUSED_ARG (flags); ACE_UNUSED_ARG (thr_id); ACE_UNUSED_ARG (thr_handle); ACE_UNUSED_ARG (priority); ACE_UNUSED_ARG (stack); ACE_UNUSED_ARG (stacksize); ACE_UNUSED_ARG (thr_name); ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_THREADS */ }
int ACE_OS::thr_equal | ( | ACE_thread_t | t1, | |
ACE_thread_t | t2 | |||
) | [inline] |
Definition at line 108 of file OS_NS_Thread.inl.
{ #if defined (ACE_HAS_PTHREADS) # if defined (pthread_equal) // If it's a macro we can't say "pthread_equal"... return pthread_equal (t1, t2); # else return pthread_equal (t1, t2); # endif /* pthread_equal */ #else /* For both STHREADS and WTHREADS... */ // Hum, Do we need to treat WTHREAD differently? // levine 13 oct 98 % I don't think so, ACE_thread_t is a DWORD. return t1 == t2; #endif /* ACE_HAS_PTHREADS */ }
void ACE_OS::thr_exit | ( | ACE_THR_FUNC_RETURN | status = 0 |
) |
Definition at line 4451 of file OS_NS_Thread.cpp.
{ ACE_OS_TRACE ("ACE_OS::thr_exit"); #if defined (ACE_HAS_THREADS) # if defined (ACE_HAS_PTHREADS) ::pthread_exit (status); # elif defined (ACE_HAS_STHREADS) ::thr_exit (status); # elif defined (ACE_HAS_WTHREADS) // Can't call it here because on NT, the thread is exited // directly by ACE_Thread_Adapter::invoke (). // ACE_TSS_Cleanup::instance ()->thread_exit (status); # if defined (ACE_HAS_MFC) && (ACE_HAS_MFC != 0) int using_afx = -1; // An ACE_Thread_Descriptor really is an ACE_OS_Thread_Descriptor. // But without #including ace/Thread_Manager.h, we don't know that. ACE_OS_Thread_Descriptor *td = ACE_Base_Thread_Adapter::thr_desc_log_msg (); if (td) using_afx = ACE_BIT_ENABLED (td->flags (), THR_USE_AFX); # endif /* ACE_HAS_MFC && (ACE_HAS_MFC != 0) */ // Call TSS destructors. ACE_OS::cleanup_tss (0 /* not main thread */); // Exit the thread. // Allow CWinThread-destructor to be invoked from AfxEndThread. // _endthreadex will be called from AfxEndThread so don't exit the // thread now if we are running an MFC thread. # if defined (ACE_HAS_MFC) && (ACE_HAS_MFC != 0) if (using_afx != -1) { if (using_afx) ::AfxEndThread (status); else ACE_ENDTHREADEX (status); } else { // Not spawned by ACE_Thread_Manager, use the old buggy // version. You should seriously consider using // ACE_Thread_Manager to spawn threads. The following code is // know to cause some problem. CWinThread *pThread = ::AfxGetThread (); if (!pThread || pThread->m_nThreadID != ACE_OS::thr_self ()) ACE_ENDTHREADEX (status); else ::AfxEndThread (status); } # else ACE_ENDTHREADEX (status); # endif /* ACE_HAS_MFC && ACE_HAS_MFS != 0*/ # elif defined (ACE_HAS_VXTHREADS) ACE_thread_t tid = ACE_OS::thr_self (); *((int *) status) = ::taskDelete (tid); # endif /* ACE_HAS_PTHREADS */ #else ACE_UNUSED_ARG (status); #endif /* ACE_HAS_THREADS */ }
int ACE_OS::thr_get_affinity | ( | ACE_hthread_t | thr_id, | |
size_t | cpu_set_size, | |||
cpu_set_t * | cpu_mask | |||
) |
Get the thread affinity
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, in bytes. | |
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 4599 of file OS_NS_Thread.cpp.
{ #if defined (ACE_HAS_PTHREAD_GETAFFINITY_NP) // Handle of the thread, which is NPTL thread-id, normally a big number if (::pthread_getaffinity_np (thr_id, cpu_set_size, cpu_mask) != 0) { return -1; } return 0; #elif defined (ACE_HAS_2_PARAM_SCHED_GETAFFINITY) // The process-id is expected as <thr_id>, which can be a thread-id of // linux-thread, thus making binding to cpu of that particular thread only. // If you are using this flag for NPTL-threads, however, please pass as a // thr_id process id obtained by ACE_OS::getpid () ACE_UNUSED_ARG (cpu_set_size); if (::sched_getaffinity(thr_id, cpu_mask) == -1) { return -1; } return 0; #elif defined (ACE_HAS_SCHED_GETAFFINITY) // The process-id is expected as <thr_id>, which can be a thread-id of // linux-thread, thus making binding to cpu of that particular thread only. // If you are using this flag for NPTL-threads, however, please pass as a // thr_id process id obtained by ACE_OS::getpid () if (::sched_getaffinity(thr_id, cpu_set_size, cpu_mask) == -1) { return -1; } return 0; #elif defined (ACE_HAS_TASKCPUAFFINITYSET) ACE_UNUSED_ARG (cpu_set_size); int result = 0; if (ACE_ADAPT_RETVAL (::taskCpuAffinitySet (thr_id, *cpu_mask), result) == -1) { return -1; } return 0; #else ACE_UNUSED_ARG (thr_id); ACE_UNUSED_ARG (cpu_set_size); ACE_UNUSED_ARG (cpu_mask); ACE_NOTSUP_RETURN (-1); #endif }
int ACE_OS::thr_getconcurrency | ( | void | ) | [inline] |
Definition at line 2641 of file OS_NS_Thread.inl.
{ ACE_OS_TRACE ("ACE_OS::thr_getconcurrency"); #if defined (ACE_HAS_THREADS) # if defined (ACE_HAS_STHREADS) return ::thr_getconcurrency (); # elif defined (ACE_HAS_PTHREADS) && defined (ACE_HAS_PTHREAD_GETCONCURRENCY) return pthread_getconcurrency (); # else ACE_NOTSUP_RETURN (-1); # endif /* ACE_HAS_STHREADS */ #else ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_THREADS */ }
int ACE_OS::thr_getprio | ( | ACE_hthread_t | id, | |
int & | priority | |||
) | [inline] |
Definition at line 2719 of file OS_NS_Thread.inl.
{ ACE_OS_TRACE ("ACE_OS::thr_getprio"); int policy = 0; return ACE_OS::thr_getprio (ht_id, priority, policy); }
int ACE_OS::thr_getprio | ( | ACE_hthread_t | id, | |
int & | priority, | |||
int & | policy | |||
) | [inline] |
Definition at line 2658 of file OS_NS_Thread.inl.
{ ACE_OS_TRACE ("ACE_OS::thr_getprio"); ACE_UNUSED_ARG (policy); #if defined (ACE_HAS_THREADS) # if (defined (ACE_HAS_PTHREADS) && \ (!defined (ACE_LACKS_SETSCHED) || defined (ACE_HAS_PTHREAD_SCHEDPARAM))) struct sched_param param; int result; ACE_OSCALL (ACE_ADAPT_RETVAL (pthread_getschedparam (ht_id, &policy, ¶m), result), int, -1, result); priority = param.sched_priority; return result; # elif defined (ACE_HAS_STHREADS) int result; ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_getprio (ht_id, &priority), result), int, -1); # elif defined (ACE_HAS_WTHREADS) ACE_Errno_Guard error (errno); # if defined (ACE_HAS_WINCE) && !defined (ACE_LACKS_CE_THREAD_PRIORITY) priority = ::CeGetThreadPriority (ht_id); # else priority = ::GetThreadPriority (ht_id); # endif /* defined (ACE_HAS_WINCE) && !defined (ACE_LACKS_CE_THREAD_PRIORITY) */ # if defined (ACE_HAS_PHARLAP) # if defined (ACE_PHARLAP_LABVIEW_RT) policy = ACE_SCHED_FIFO; # else DWORD timeslice = ::EtsGetTimeSlice (); policy = timeslice == 0 ? ACE_SCHED_OTHER : ACE_SCHED_FIFO; # endif /* ACE_PHARLAP_LABVIEW_RT */ # elif !defined (ACE_HAS_WINCE) DWORD priority_class = ::GetPriorityClass (::GetCurrentProcess ()); if (priority_class == 0 && (error = ::GetLastError ()) != NO_ERROR) ACE_FAIL_RETURN (-1); policy = (priority_class == REALTIME_PRIORITY_CLASS) ? ACE_SCHED_FIFO : ACE_SCHED_OTHER; # endif /* ACE_HAS_PHARLAP */ return 0; # elif defined (ACE_HAS_VXTHREADS) ACE_OSCALL_RETURN (::taskPriorityGet (ht_id, &priority), int, -1); # else ACE_UNUSED_ARG (ht_id); ACE_UNUSED_ARG (priority); ACE_NOTSUP_RETURN (-1); # endif /* ACE_HAS_STHREADS */ #else ACE_UNUSED_ARG (ht_id); ACE_UNUSED_ARG (priority); ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_THREADS */ }
int ACE_OS::thr_getspecific | ( | ACE_thread_key_t | key, | |
void ** | data | |||
) | [inline] |
Definition at line 2755 of file OS_NS_Thread.inl.
{ // ACE_OS_TRACE ("ACE_OS::thr_getspecific"); #if defined (ACE_HAS_THREADS) # if defined (ACE_HAS_TSS_EMULATION) if (ACE_TSS_Emulation::is_key (key) == 0) { errno = EINVAL; data = 0; return -1; } else { *data = ACE_TSS_Emulation::ts_object (key); return 0; } # elif defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) return ACE_OS::thr_getspecific_native (key, data); #else ACE_UNUSED_ARG (key); ACE_UNUSED_ARG (data); ACE_NOTSUP_RETURN (-1); # endif /* ACE_HAS_TSS_EMULATION */ #else ACE_UNUSED_ARG (key); ACE_UNUSED_ARG (data); ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_THREADS */ }
int ACE_OS::thr_join | ( | ACE_hthread_t | waiter_id, | |
ACE_THR_FUNC_RETURN * | status | |||
) | [inline] |
Definition at line 2787 of file OS_NS_Thread.inl.
{ ACE_OS_TRACE ("ACE_OS::thr_join"); #if defined (ACE_HAS_THREADS) # if defined (ACE_HAS_STHREADS) int result; ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_join (thr_handle, 0, status), result), int, -1); # elif defined (ACE_HAS_PTHREADS) int result; ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_join (thr_handle, status), result), int, -1); # elif defined (ACE_HAS_WTHREADS) ACE_THR_FUNC_RETURN local_status = 0; // Make sure that status is non-NULL. if (status == 0) status = &local_status; if (::WaitForSingleObject (thr_handle, INFINITE) == WAIT_OBJECT_0 && ::GetExitCodeThread (thr_handle, status) != FALSE) { ::CloseHandle (thr_handle); return 0; } ACE_FAIL_RETURN (-1); /* NOTREACHED */ # else ACE_UNUSED_ARG (thr_handle); ACE_UNUSED_ARG (status); ACE_NOTSUP_RETURN (-1); # endif /* ACE_HAS_STHREADS */ #else ACE_UNUSED_ARG (thr_handle); ACE_UNUSED_ARG (status); ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_THREADS */ }
int ACE_OS::thr_join | ( | ACE_thread_t | waiter_id, | |
ACE_thread_t * | thr_id, | |||
ACE_THR_FUNC_RETURN * | status | |||
) | [inline] |
Definition at line 2828 of file OS_NS_Thread.inl.
{ ACE_OS_TRACE ("ACE_OS::thr_join"); #if defined (ACE_HAS_THREADS) # if defined (ACE_HAS_STHREADS) int result; ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_join (waiter_id, thr_id, status), result), int, -1); # elif defined (ACE_HAS_PTHREADS) ACE_UNUSED_ARG (thr_id); int result; ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_join (waiter_id, status), result), int, -1); # elif defined (ACE_HAS_WTHREADS) ACE_UNUSED_ARG (waiter_id); ACE_UNUSED_ARG (thr_id); ACE_UNUSED_ARG (status); // This could be implemented if the DLL-Main function or the // task exit base class some log the threads which have exited ACE_NOTSUP_RETURN (-1); # endif /* ACE_HAS_STHREADS */ #else ACE_UNUSED_ARG (waiter_id); ACE_UNUSED_ARG (thr_id); ACE_UNUSED_ARG (status); ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_THREADS */ }
int ACE_OS::thr_key_detach | ( | ACE_thread_key_t | key, | |
void * | inst | |||
) |
Definition at line 4580 of file OS_NS_Thread.cpp.
{ #if defined (ACE_HAS_WTHREADS) || defined (ACE_HAS_TSS_EMULATION) TSS_Cleanup_Instance cleanup; if (cleanup.valid ()) { return cleanup->thread_detach_key (key); } else { return -1; } #else ACE_UNUSED_ARG (key); ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_WTHREADS || ACE_HAS_TSS_EMULATION */ }
int ACE_OS::thr_key_used | ( | ACE_thread_key_t | key | ) |
Definition at line 4697 of file OS_NS_Thread.cpp.
{ #if defined (ACE_WIN32) || defined (ACE_HAS_TSS_EMULATION) TSS_Cleanup_Instance cleanup; if (cleanup.valid ()) { cleanup->thread_use_key (key); return 0; } return -1; #else ACE_UNUSED_ARG (key); ACE_NOTSUP_RETURN (-1); #endif /* ACE_WIN32 || ACE_HAS_TSS_EMULATION */ }
int ACE_OS::thr_keycreate | ( | ACE_thread_key_t * | key, | |
ACE_THR_DEST | dest, | |||
void * | inst = 0 | |||
) |
Definition at line 4753 of file OS_NS_Thread.cpp.
{ // ACE_OS_TRACE ("ACE_OS::thr_keycreate"); #if defined (ACE_HAS_THREADS) # if defined (ACE_HAS_TSS_EMULATION) if (ACE_TSS_Emulation::next_key (*key) == 0) { ACE_TSS_Emulation::tss_destructor (*key, dest); // Extract out the thread-specific table instance and stash away // the key and destructor so that we can free it up later on... TSS_Cleanup_Instance cleanup (TSS_Cleanup_Instance::CREATE); if (cleanup.valid ()) { return cleanup->insert (*key, dest); } else { return -1; } } else return -1; # elif defined (ACE_HAS_WTHREADS) if (ACE_OS::thr_keycreate_native (key, dest) == 0) { // Extract out the thread-specific table instance and stash away // the key and destructor so that we can free it up later on... TSS_Cleanup_Instance cleanup (TSS_Cleanup_Instance::CREATE); if (cleanup.valid ()) { return cleanup->insert (*key, dest); } else { return -1; } } else return -1; /* NOTREACHED */ # elif defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) return ACE_OS::thr_keycreate_native (key, dest); # else ACE_UNUSED_ARG (key); ACE_UNUSED_ARG (dest); ACE_NOTSUP_RETURN (-1); # endif /* ACE_HAS_TSS_EMULATION */ # else /* ACE_HAS_THREADS */ ACE_UNUSED_ARG (key); ACE_UNUSED_ARG (dest); ACE_NOTSUP_RETURN (-1); # endif /* ACE_HAS_THREADS */ }
int ACE_OS::thr_keyfree | ( | ACE_thread_key_t | key | ) |
Definition at line 4850 of file OS_NS_Thread.cpp.
{ ACE_OS_TRACE ("ACE_OS::thr_keyfree"); # if defined (ACE_HAS_THREADS) # if defined (ACE_HAS_TSS_EMULATION) // Release the key in the TSS_Emulation administration ACE_TSS_Emulation::release_key (key); TSS_Cleanup_Instance cleanup; if (cleanup.valid ()) { return cleanup->free_key (key); } return -1; # elif defined (ACE_HAS_WTHREADS) // Extract out the thread-specific table instance and free up // the key and destructor. TSS_Cleanup_Instance cleanup; if (cleanup.valid ()) { return cleanup->free_key (key); } return -1; # elif defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) return ACE_OS::thr_keyfree_native (key); # else ACE_UNUSED_ARG (key); ACE_NOTSUP_RETURN (-1); # endif /* ACE_HAS_TSS_EMULATION */ # else /* ACE_HAS_THREADS */ ACE_UNUSED_ARG (key); ACE_NOTSUP_RETURN (-1); return 0; # endif /* ACE_HAS_THREADS */ }
int ACE_OS::thr_kill | ( | ACE_thread_t | thr_id, | |
int | signum | |||
) | [inline] |
Definition at line 2862 of file OS_NS_Thread.inl.
{ ACE_OS_TRACE ("ACE_OS::thr_kill"); #if defined (ACE_HAS_THREADS) # if defined (ACE_HAS_PTHREADS) # if defined (ACE_LACKS_PTHREAD_KILL) ACE_UNUSED_ARG (signum); ACE_UNUSED_ARG (thr_id); ACE_NOTSUP_RETURN (-1); # else int result; ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_kill (thr_id, signum), result), int, -1); # endif /* ACE_LACKS_PTHREAD_KILL */ # elif defined (ACE_HAS_STHREADS) int result; ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_kill (thr_id, signum), result), int, -1); # elif defined (ACE_HAS_VXTHREADS) //FUZZ: disable check_for_lack_ACE_OS ACE_OSCALL_RETURN (::kill (thr_id, signum), int, -1); //FUZZ: enable check_for_lack_ACE_OS # else ACE_UNUSED_ARG (thr_id); ACE_UNUSED_ARG (signum); ACE_NOTSUP_RETURN (-1); # endif /* ACE_HAS_STHREADS */ #else ACE_UNUSED_ARG (thr_id); ACE_UNUSED_ARG (signum); ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_THREADS */ }
size_t ACE_OS::thr_min_stack | ( | void | ) | [inline] |
Definition at line 2899 of file OS_NS_Thread.inl.
{ ACE_OS_TRACE ("ACE_OS::thr_min_stack"); #if defined (ACE_HAS_THREADS) # if defined (ACE_HAS_STHREADS) # if defined (ACE_HAS_THR_MINSTACK) // Tandem did some weirdo mangling of STHREAD names... return ::thr_minstack (); # else return ::thr_min_stack (); # endif /* !ACE_HAS_THR_MINSTACK */ # elif defined (ACE_HAS_PTHREADS) # if defined (_SC_THREAD_STACK_MIN) return (size_t) ACE_OS::sysconf (_SC_THREAD_STACK_MIN); # elif defined (PTHREAD_STACK_MIN) return PTHREAD_STACK_MIN; # else ACE_NOTSUP_RETURN (0); # endif /* _SC_THREAD_STACK_MIN */ # elif defined (ACE_HAS_WTHREADS) ACE_NOTSUP_RETURN (0); # elif defined (ACE_HAS_VXTHREADS) TASK_DESC taskDesc; STATUS status; ACE_thread_t tid = ACE_OS::thr_self (); ACE_OSCALL (ACE_ADAPT_RETVAL (::taskInfoGet (tid, &taskDesc), status), STATUS, -1, status); return status == OK ? taskDesc.td_stackSize : 0; # else /* Should not happen... */ ACE_NOTSUP_RETURN (0); # endif /* ACE_HAS_STHREADS */ #else ACE_NOTSUP_RETURN (0); #endif /* ACE_HAS_THREADS */ }
const char * ACE_OS::thr_name | ( | void | ) | [inline] |
Definition at line 2959 of file OS_NS_Thread.inl.
{ #if defined (ACE_HAS_THREADS) #if defined (ACE_HAS_VXTHREADS) return ::taskName (ACE_OS::thr_self ()); #else ACE_NOTSUP_RETURN (0); #endif #else ACE_NOTSUP_RETURN (0); #endif }
void ACE_OS::thr_self | ( | ACE_hthread_t & | self | ) | [inline] |
Definition at line 2973 of file OS_NS_Thread.inl.
{ ACE_OS_TRACE ("ACE_OS::thr_self"); #if defined (ACE_HAS_THREADS) # if defined (ACE_HAS_PTHREADS) // Note, don't use "::" here since the following call is often a macro. self = pthread_self (); # elif defined (ACE_HAS_THREAD_SELF) self = ::thread_self (); # elif defined (ACE_HAS_STHREADS) self = ::thr_self (); # elif defined (ACE_HAS_WTHREADS) self = ::GetCurrentThread (); # elif defined (ACE_HAS_VXTHREADS) self = ::taskIdSelf (); # endif /* ACE_HAS_STHREADS */ #else self = 1; // Might as well make it the main thread ;-) #endif /* ACE_HAS_THREADS */ }
ACE_thread_t ACE_OS::thr_self | ( | void | ) | [inline] |
Definition at line 2939 of file OS_NS_Thread.inl.
{ // ACE_OS_TRACE ("ACE_OS::thr_self"); #if defined (ACE_HAS_THREADS) # if defined (ACE_HAS_PTHREADS) // Note, don't use "::" here since the following call is often a macro. return pthread_self (); # elif defined (ACE_HAS_STHREADS) ACE_OSCALL_RETURN (::thr_self (), int, -1); # elif defined (ACE_HAS_WTHREADS) return ::GetCurrentThreadId (); # elif defined (ACE_HAS_VXTHREADS) return ::taskIdSelf (); # endif /* ACE_HAS_STHREADS */ #else return 1; // Might as well make it the first thread ;-) #endif /* ACE_HAS_THREADS */ }
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
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, in bytes. | |
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 4648 of file OS_NS_Thread.cpp.
{ #if defined (ACE_HAS_PTHREAD_SETAFFINITY_NP) if (::pthread_setaffinity_np (thr_id, cpu_set_size, cpu_mask) != 0) { return -1; } return 0; #elif defined (ACE_HAS_2_PARAM_SCHED_SETAFFINITY) // The process-id is expected as <thr_id>, which can be a thread-id of // linux-thread, thus making binding to cpu of that particular thread only. // If you are using this flag for NPTL-threads, however, please pass as a // thr_id process id obtained by ACE_OS::getpid (), but whole process will bind your CPUs // ACE_UNUSED_ARG (cpu_set_size); if (::sched_setaffinity (thr_id, cpu_mask) == -1) { return -1; } return 0; #elif defined (ACE_HAS_SCHED_SETAFFINITY) // The process-id is expected as <thr_id>, which can be a thread-id of // linux-thread, thus making binding to cpu of that particular thread only. // If you are using this flag for NPTL-threads, however, please pass as a // thr_id process id obtained by ACE_OS::getpid (), but whole process will bind your CPUs // if (::sched_setaffinity (thr_id, cpu_set_size, cpu_mask) == -1) { return -1; } return 0; #elif defined (ACE_HAS_TASKCPUAFFINITYSET) int result = 0; if (ACE_ADAPT_RETVAL (::taskCpuAffinitySet (thr_id, *cpu_mask), result) == -1) { return -1; } return 0; #else ACE_UNUSED_ARG (thr_id); ACE_UNUSED_ARG (cpu_set_size); ACE_UNUSED_ARG (cpu_mask); ACE_NOTSUP_RETURN (-1); #endif }
int ACE_OS::thr_setcancelstate | ( | int | new_state, | |
int * | old_state | |||
) | [inline] |
Definition at line 2995 of file OS_NS_Thread.inl.
{ ACE_OS_TRACE ("ACE_OS::thr_setcancelstate"); #if defined (ACE_HAS_THREADS) # if defined (ACE_HAS_PTHREADS) && !defined (ACE_LACKS_PTHREAD_CANCEL) int result; ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_setcancelstate (new_state, old_state), result), int, -1); # elif defined (ACE_HAS_STHREADS) ACE_UNUSED_ARG (new_state); ACE_UNUSED_ARG (old_state); ACE_NOTSUP_RETURN (-1); # elif defined (ACE_HAS_WTHREADS) ACE_UNUSED_ARG (new_state); ACE_UNUSED_ARG (old_state); ACE_NOTSUP_RETURN (-1); # else /* Could be ACE_HAS_PTHREADS && ACE_LACKS_PTHREAD_CANCEL */ ACE_UNUSED_ARG (new_state); ACE_UNUSED_ARG (old_state); ACE_NOTSUP_RETURN (-1); # endif /* ACE_HAS_PTHREADS */ #else ACE_UNUSED_ARG (new_state); ACE_UNUSED_ARG (old_state); ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_THREADS */ }
int ACE_OS::thr_setcanceltype | ( | int | new_type, | |
int * | old_type | |||
) | [inline] |
Definition at line 3026 of file OS_NS_Thread.inl.
{ ACE_OS_TRACE ("ACE_OS::thr_setcanceltype"); #if defined (ACE_HAS_THREADS) # if defined (ACE_HAS_PTHREADS) && !defined (ACE_LACKS_PTHREAD_CANCEL) int result; ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_setcanceltype (new_type, old_type), result), int, -1); # else /* Could be ACE_HAS_PTHREADS && ACE_LACKS_PTHREAD_CANCEL */ ACE_UNUSED_ARG (new_type); ACE_UNUSED_ARG (old_type); ACE_NOTSUP_RETURN (-1); # endif /* ACE_HAS_PTHREADS */ #else ACE_UNUSED_ARG (new_type); ACE_UNUSED_ARG (old_type); ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_THREADS */ }
int ACE_OS::thr_setconcurrency | ( | int | hint | ) | [inline] |
Definition at line 3049 of file OS_NS_Thread.inl.
{ ACE_OS_TRACE ("ACE_OS::thr_setconcurrency"); #if defined (ACE_HAS_THREADS) # if defined (ACE_HAS_STHREADS) int result; ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_setconcurrency (hint), result), int, -1); # elif defined (ACE_HAS_PTHREADS) && defined (ACE_HAS_PTHREAD_SETCONCURRENCY) int result; ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_setconcurrency (hint), result), int, -1); # else ACE_UNUSED_ARG (hint); ACE_NOTSUP_RETURN (-1); # endif /* ACE_HAS_STHREADS */ #else ACE_UNUSED_ARG (hint); ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_THREADS */ }
int ACE_OS::thr_setprio | ( | const ACE_Sched_Priority | prio | ) |
Definition at line 4886 of file OS_NS_Thread.cpp.
{ // Set the thread priority on the current thread. ACE_hthread_t my_thread_id; ACE_OS::thr_self (my_thread_id); int const status = ACE_OS::thr_setprio (my_thread_id, prio); #if defined (ACE_NEEDS_LWP_PRIO_SET) // If the thread is in the RT class, then set the priority on its // LWP. (Instead of doing this if the thread is in the RT class, it // should be done for all bound threads. But, there doesn't appear // to be an easy way to determine if the thread is bound.) if (status == 0) { // Find what scheduling class the thread's LWP is in. ACE_Sched_Params sched_params (ACE_SCHED_OTHER, 0); if (ACE_OS::lwp_getparams (sched_params) == -1) { return -1; } else if (sched_params.policy () == ACE_SCHED_FIFO || sched_params.policy () == ACE_SCHED_RR) { // This thread's LWP is in the RT class, so we need to set // its priority. sched_params.priority (prio); return ACE_OS::lwp_setparams (sched_params); } // else this is not an RT thread. Nothing more needs to be // done. } #endif /* ACE_NEEDS_LWP_PRIO_SET */ return status; }
int ACE_OS::thr_setprio | ( | ACE_hthread_t | ht_id, | |
int | priority, | |||
int | policy = -1 | |||
) | [inline] |
Definition at line 3074 of file OS_NS_Thread.inl.
{ ACE_OS_TRACE ("ACE_OS::thr_setprio"); ACE_UNUSED_ARG (policy); #if defined (ACE_HAS_THREADS) # if (defined (ACE_HAS_PTHREADS) && \ (!defined (ACE_LACKS_SETSCHED) || defined (ACE_HAS_PTHREAD_SCHEDPARAM))) int result; struct sched_param param; ACE_OS::memset ((void *) ¶m, 0, sizeof param); // If <policy> is -1, we don't want to use it for // pthread_setschedparam(). Instead, obtain policy from // pthread_getschedparam(). if (policy == -1) { ACE_OSCALL (ACE_ADAPT_RETVAL (pthread_getschedparam (ht_id, &policy, ¶m), result), int, -1, result); if (result == -1) return result; } param.sched_priority = priority; ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_setschedparam (ht_id, policy, ¶m), result), int, -1); # elif defined (ACE_HAS_STHREADS) int result; ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_setprio (ht_id, priority), result), int, -1); # elif defined (ACE_HAS_WTHREADS) # if defined (ACE_HAS_WINCE) && !defined (ACE_LACKS_CE_THREAD_PRIORITY) ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::CeSetThreadPriority (ht_id, priority), ace_result_), int, -1); # else ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::SetThreadPriority (ht_id, priority), ace_result_), int, -1); # endif /* defined (ACE_HAS_WINCE) && !defined (ACE_LACKS_CE_THREAD_PRIORITY) */ # elif defined (ACE_HAS_VXTHREADS) ACE_OSCALL_RETURN (::taskPrioritySet (ht_id, priority), int, -1); # else // For example, platforms that support Pthreads but LACK_SETSCHED. ACE_UNUSED_ARG (ht_id); ACE_UNUSED_ARG (priority); ACE_NOTSUP_RETURN (-1); # endif /* ACE_HAS_STHREADS */ #else ACE_UNUSED_ARG (ht_id); ACE_UNUSED_ARG (priority); ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_THREADS */ }
int ACE_OS::thr_setspecific | ( | ACE_thread_key_t | key, | |
void * | data | |||
) |
Definition at line 4955 of file OS_NS_Thread.cpp.
{ // ACE_OS_TRACE ("ACE_OS::thr_setspecific"); #if defined (ACE_HAS_THREADS) # if defined (ACE_HAS_TSS_EMULATION) if (ACE_TSS_Emulation::is_key (key) == 0) { errno = EINVAL; data = 0; return -1; } else { ACE_TSS_Emulation::ts_object (key) = data; TSS_Cleanup_Instance cleanup; if (cleanup.valid ()) { cleanup->thread_use_key (key); // for TSS_Cleanup purposes treat stetting data to zero // like detaching. This is a consequence of POSIX allowing // deletion of a "used" key. if (data == 0) { cleanup->thread_detach_key (key); } return 0; } else { return -1; } } # elif defined (ACE_HAS_WTHREADS) if (ACE_OS::thr_setspecific_native (key, data) == 0) { TSS_Cleanup_Instance cleanup; if (cleanup.valid ()) { cleanup->thread_use_key (key); // for TSS_Cleanup purposes treat stetting data to zero // like detaching. This is a consequence of POSIX allowing // deletion of a "used" key. if (data == 0) { cleanup->thread_detach_key (key); } return 0; } return -1; } return -1; # elif defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) return ACE_OS::thr_setspecific_native (key, data); # else /* ACE_HAS_TSS_EMULATION */ ACE_UNUSED_ARG (key); ACE_UNUSED_ARG (data); ACE_NOTSUP_RETURN (-1); # endif /* ACE_HAS_TSS_EMULATION */ # else /* ACE_HAS_THREADS */ ACE_UNUSED_ARG (key); ACE_UNUSED_ARG (data); ACE_NOTSUP_RETURN (-1); # endif /* ACE_HAS_THREADS */ }
int ACE_OS::thr_sigsetmask | ( | int | how, | |
const sigset_t * | nsm, | |||
sigset_t * | osm | |||
) | [inline] |
Definition at line 3138 of file OS_NS_Thread.inl.
{ ACE_OS_TRACE ("ACE_OS::thr_sigsetmask"); #if defined (ACE_HAS_THREADS) # if defined (ACE_LACKS_PTHREAD_THR_SIGSETMASK) // DCE threads and Solaris 2.4 have no such function. ACE_UNUSED_ARG (osm); ACE_UNUSED_ARG (nsm); ACE_UNUSED_ARG (how); ACE_NOTSUP_RETURN (-1); # elif defined (ACE_HAS_SIGTHREADMASK) int result; ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::sigthreadmask (how, nsm, osm), result), int, -1); # elif defined (ACE_HAS_STHREADS) int result; ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_sigsetmask (how, nsm, osm), result), int, -1); # elif defined (ACE_HAS_PTHREADS) # if !defined (ACE_LACKS_PTHREAD_SIGMASK) int result; //FUZZ: disable check_for_lack_ACE_OS ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_sigmask (how, nsm, osm), result), int, -1); //FUZZ: enable check_for_lack_ACE_OS # endif /* !ACE_LACKS_PTHREAD_SIGMASK */ #if 0 /* Don't know if any platform actually needs this... */ // as far as I can tell, this is now pthread_sigaction() -- jwr int result; ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_sigaction (how, nsm, osm), result), int, -1); #endif /* 0 */ # elif defined (ACE_HAS_WTHREADS) ACE_UNUSED_ARG (osm); ACE_UNUSED_ARG (nsm); ACE_UNUSED_ARG (how); ACE_NOTSUP_RETURN (-1); # elif defined (ACE_VXWORKS) int old_mask = 0; switch (how) { case SIG_BLOCK: case SIG_UNBLOCK: { // get the old mask old_mask = ::sigsetmask (*nsm); // create a new mask: the following assumes that sigset_t is 4 bytes, // which it is on VxWorks 5.2, so bit operations are done simply . . . ::sigsetmask (how == SIG_BLOCK ? (old_mask |= *nsm) : (old_mask &= ~*nsm)); if (osm) *osm = old_mask; break; } case SIG_SETMASK: old_mask = ::sigsetmask (*nsm); if (osm) *osm = old_mask; break; default: return -1; } return 0; # else /* Should not happen. */ ACE_UNUSED_ARG (how); ACE_UNUSED_ARG (nsm); ACE_UNUSED_ARG (osm); ACE_NOTSUP_RETURN (-1); # endif /* ACE_LACKS_PTHREAD_THR_SIGSETMASK */ #else ACE_UNUSED_ARG (how); ACE_UNUSED_ARG (nsm); ACE_UNUSED_ARG (osm); ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_THREADS */ }
int ACE_OS::thr_suspend | ( | ACE_hthread_t | target_thread | ) | [inline] |
Definition at line 3224 of file OS_NS_Thread.inl.
{ ACE_OS_TRACE ("ACE_OS::thr_suspend"); #if defined (ACE_HAS_THREADS) # if defined (ACE_HAS_STHREADS) int result; ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_suspend (target_thread), result), int, -1); # elif defined (ACE_HAS_PTHREADS) # if defined (ACE_HAS_PTHREAD_SUSPEND) int result; ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_suspend (target_thread), result), int, -1); # elif defined (ACE_HAS_PTHREAD_SUSPEND_NP) int result; ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_suspend_np (target_thread), result), int, -1); # else ACE_UNUSED_ARG (target_thread); ACE_NOTSUP_RETURN (-1); # endif /* ACE_HAS_PTHREAD_SUSPEND */ # elif defined (ACE_HAS_WTHREADS) if (::SuspendThread (target_thread) != ACE_SYSCALL_FAILED) return 0; else ACE_FAIL_RETURN (-1); /* NOTREACHED */ # elif defined (ACE_HAS_VXTHREADS) ACE_OSCALL_RETURN (::taskSuspend (target_thread), int, -1); # endif /* ACE_HAS_STHREADS */ #else ACE_UNUSED_ARG (target_thread); ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_THREADS */ }
void ACE_OS::thr_testcancel | ( | void | ) | [inline] |
Definition at line 3262 of file OS_NS_Thread.inl.
{ ACE_OS_TRACE ("ACE_OS::thr_testcancel"); #if defined (ACE_HAS_THREADS) # if defined (ACE_HAS_PTHREADS) && !defined (ACE_LACKS_PTHREAD_CANCEL) pthread_testcancel (); # elif defined (ACE_HAS_STHREADS) # elif defined (ACE_HAS_WTHREADS) # elif defined (ACE_HAS_VXTHREADS) # else // no-op: can't use ACE_NOTSUP_RETURN because there is no return value # endif /* ACE_HAS_PTHREADS */ #else #endif /* ACE_HAS_THREADS */ }
void ACE_OS::thr_yield | ( | void | ) | [inline] |
Definition at line 3279 of file OS_NS_Thread.inl.
{ ACE_OS_TRACE ("ACE_OS::thr_yield"); #if defined (ACE_HAS_THREADS) # if defined (ACE_HAS_PTHREADS) ::sched_yield (); # elif defined (ACE_HAS_STHREADS) ::thr_yield (); # elif defined (ACE_HAS_WTHREADS) ::Sleep (0); # elif defined (ACE_HAS_VXTHREADS) // An argument of 0 to ::taskDelay doesn't appear to yield the // current thread. // Now, it does seem to work. The context_switch_time test // works fine with task_delay set to 0. ::taskDelay (0); # endif /* ACE_HAS_STHREADS */ #else ; #endif /* ACE_HAS_THREADS */ }
int ACE_OS::thread_mutex_destroy | ( | ACE_thread_mutex_t * | m | ) | [inline] |
Definition at line 3302 of file OS_NS_Thread.inl.
{ ACE_OS_TRACE ("ACE_OS::thread_mutex_destroy"); #if defined (ACE_HAS_THREADS) # if defined (ACE_HAS_WTHREADS) ::DeleteCriticalSection (m); return 0; # else return ACE_OS::mutex_destroy (m); # endif /* ACE_HAS_WTHREADS */ #else ACE_UNUSED_ARG (m); ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_THREADS */ }
int ACE_OS::thread_mutex_init | ( | ACE_thread_mutex_t * | m, | |
int | lock_type = 0 , |
|||
const char * | name = 0 , |
|||
ACE_mutexattr_t * | arg = 0 | |||
) | [inline] |
Definition at line 3320 of file OS_NS_Thread.inl.
{ // ACE_OS_TRACE ("ACE_OS::thread_mutex_init"); #if defined (ACE_HAS_THREADS) # if defined (ACE_HAS_WTHREADS) ACE_UNUSED_ARG (lock_type); ACE_UNUSED_ARG (name); ACE_UNUSED_ARG (arg); ACE_SEH_TRY { ::InitializeCriticalSection (m); } ACE_SEH_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { errno = ENOMEM; return -1; } return 0; # elif defined (ACE_HAS_STHREADS) || defined (ACE_HAS_PTHREADS) // Force the use of USYNC_THREAD! return ACE_OS::mutex_init (m, USYNC_THREAD, name, arg, 0, lock_type); # elif defined (ACE_HAS_VXTHREADS) return mutex_init (m, lock_type, name, arg); # endif /* ACE_HAS_STHREADS || ACE_HAS_PTHREADS */ #else ACE_UNUSED_ARG (m); ACE_UNUSED_ARG (lock_type); ACE_UNUSED_ARG (name); ACE_UNUSED_ARG (arg); ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_THREADS */ }
int ACE_OS::thread_mutex_lock | ( | ACE_thread_mutex_t * | m, | |
const ACE_Time_Value * | timeout | |||
) | [inline] |
Definition at line 3444 of file OS_NS_Thread.inl.
{ return timeout == 0 ? ACE_OS::thread_mutex_lock (m) : ACE_OS::thread_mutex_lock (m, *timeout); }
int ACE_OS::thread_mutex_lock | ( | ACE_thread_mutex_t * | m | ) | [inline] |
Definition at line 3404 of file OS_NS_Thread.inl.
{ // ACE_OS_TRACE ("ACE_OS::thread_mutex_lock"); #if defined (ACE_HAS_THREADS) # if defined (ACE_HAS_WTHREADS) ::EnterCriticalSection (m); return 0; # else return ACE_OS::mutex_lock (m); # endif /* ACE_HAS_WTHREADS */ #else ACE_UNUSED_ARG (m); ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_THREADS */ }
int ACE_OS::thread_mutex_lock | ( | ACE_thread_mutex_t * | m, | |
const ACE_Time_Value & | timeout | |||
) | [inline] |
Definition at line 3421 of file OS_NS_Thread.inl.
{ // ACE_OS_TRACE ("ACE_OS::thread_mutex_lock"); // For all platforms, except MS Windows, this method is equivalent // to calling ACE_OS::mutex_lock() since ACE_thread_mutex_t and // ACE_mutex_t are the same type. However, those typedefs evaluate // to different types on MS Windows. The "thread mutex" // implementation in ACE for MS Windows cannot readily support // timeouts due to a lack of timeout features for this type of MS // Windows synchronization mechanism. #if defined (ACE_HAS_THREADS) && !defined (ACE_HAS_WTHREADS) return ACE_OS::mutex_lock (m, timeout); #else ACE_UNUSED_ARG (m); ACE_UNUSED_ARG (timeout); ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_THREADS */ }
int ACE_OS::thread_mutex_trylock | ( | ACE_thread_mutex_t * | m | ) | [inline] |
Definition at line 3453 of file OS_NS_Thread.inl.
{ ACE_OS_TRACE ("ACE_OS::thread_mutex_trylock"); #if defined (ACE_HAS_THREADS) # if defined (ACE_HAS_WTHREADS) # if defined (ACE_HAS_WIN32_TRYLOCK) BOOL result = ::TryEnterCriticalSection (m); if (result == TRUE) return 0; else { errno = EBUSY; return -1; } # else ACE_UNUSED_ARG (m); ACE_NOTSUP_RETURN (-1); # endif /* ACE_HAS_WIN32_TRYLOCK */ # elif defined (ACE_HAS_STHREADS) || defined (ACE_HAS_PTHREADS) || defined (ACE_VXWORKS) return ACE_OS::mutex_trylock (m); #endif /* Threads variety case */ #else ACE_UNUSED_ARG (m); ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_THREADS */ }
int ACE_OS::thread_mutex_unlock | ( | ACE_thread_mutex_t * | m | ) | [inline] |
Definition at line 3483 of file OS_NS_Thread.inl.
{ ACE_OS_TRACE ("ACE_OS::thread_mutex_unlock"); #if defined (ACE_HAS_THREADS) # if defined (ACE_HAS_WTHREADS) ::LeaveCriticalSection (m); return 0; # else return ACE_OS::mutex_unlock (m); # endif /* ACE_HAS_WTHREADS */ #else ACE_UNUSED_ARG (m); ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_THREADS */ }
time_t ACE_OS::time | ( | time_t * | tloc = 0 |
) | [inline] |
strptime wrapper. Note that the struct tm will always be set to zero
Definition at line 454 of file OS_NS_time.inl.
{ ACE_OS_TRACE ("ACE_OS::time"); #if defined (ACE_LACKS_TIME) time_t const retv = ACE_OS::gettimeofday ().sec (); if (tloc) *tloc = retv; return retv; #else ACE_OSCALL_RETURN (::time (tloc), time_t, (time_t) -1); #endif /* ACE_LACKS_TIME */ }
long ACE_OS::timezone | ( | void | ) | [inline] |
strptime wrapper. Note that the struct tm will always be set to zero
Definition at line 478 of file OS_NS_time.inl.
{ return ::ace_timezone (); }
Definition at line 1055 of file OS_NS_unistd.inl.
{ ACE_OS_TRACE ("ACE_OS::truncate"); #if defined (ACE_WIN32) ACE_HANDLE handle = ACE_OS::open (filename, O_WRONLY, ACE_DEFAULT_FILE_PERMS); # if !defined (ACE_LACKS_WIN32_SETFILEPOINTEREX) LARGE_INTEGER loffset; loffset.QuadPart = offset; #else LONG low_offset = ACE_LOW_PART(offset); LONG high_offset = ACE_HIGH_PART(offset); #endif if (handle == ACE_INVALID_HANDLE) ACE_FAIL_RETURN (-1); # if !defined (ACE_LACKS_WIN32_SETFILEPOINTEREX) else if (::SetFilePointerEx (handle, loffset, 0, FILE_BEGIN)) # else else if (::SetFilePointer (handle, low_offset, &high_offset, FILE_BEGIN) != INVALID_SET_FILE_POINTER || GetLastError () == NO_ERROR) # endif /* ACE_LACKS_WIN32_SETFILEPOINTEREX */ { BOOL result = ::SetEndOfFile (handle); ::CloseHandle (handle); ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (result, ace_result_), int, -1); } else { ::CloseHandle (handle); ACE_FAIL_RETURN (-1); } /* NOTREACHED */ #elif !defined (ACE_LACKS_TRUNCATE) ACE_OSCALL_RETURN (::truncate (ACE_TEXT_ALWAYS_CHAR (filename), offset), int, -1); #else ACE_UNUSED_ARG (filename); ACE_UNUSED_ARG (offset); ACE_NOTSUP_RETURN (-1); #endif /* ACE_WIN32 */ }
void ACE_OS::tzset | ( | void | ) | [inline] |
strptime wrapper. Note that the struct tm will always be set to zero
Definition at line 485 of file OS_NS_time.inl.
{ #if defined (ACE_LACKS_TZSET) errno = ENOTSUP; #elif defined (ACE_WIN32) ::_tzset (); // For Win32. #else ::tzset (); // For UNIX platforms. #endif /* ACE_LACKS_TZSET */ }
useconds_t ACE_OS::ualarm | ( | useconds_t | usecs, | |
useconds_t | interval = 0 | |||
) | [inline] |
Definition at line 1109 of file OS_NS_unistd.inl.
{ ACE_OS_TRACE ("ACE_OS::ualarm"); #if defined (ACE_HAS_UALARM) return ::ualarm (usecs, interval); #elif !defined (ACE_LACKS_UNIX_SIGNALS) ACE_UNUSED_ARG (interval); return ::alarm (usecs * ACE_ONE_SECOND_IN_USECS); #else ACE_UNUSED_ARG (usecs); ACE_UNUSED_ARG (interval); ACE_NOTSUP_RETURN (0); #endif /* ACE_HAS_UALARM */ }
useconds_t ACE_OS::ualarm | ( | const ACE_Time_Value & | tv, | |
const ACE_Time_Value & | tv_interval = ACE_Time_Value::zero | |||
) | [inline] |
Definition at line 1126 of file OS_NS_unistd.inl.
{ ACE_OS_TRACE ("ACE_OS::ualarm"); #if defined (ACE_HAS_UALARM) useconds_t usecs = (tv.sec () * ACE_ONE_SECOND_IN_USECS) + tv.usec (); useconds_t interval = (tv_interval.sec () * ACE_ONE_SECOND_IN_USECS) + tv_interval.usec (); return ::ualarm (usecs, interval); #elif !defined (ACE_LACKS_UNIX_SIGNALS) ACE_UNUSED_ARG (tv_interval); return ::alarm (tv.sec ()); #else ACE_UNUSED_ARG (tv_interval); ACE_UNUSED_ARG (tv); ACE_NOTSUP_RETURN (0); #endif /* ACE_HAS_UALARM */ }
mode_t ACE_OS::umask | ( | mode_t | cmask | ) | [inline] |
Definition at line 275 of file OS_NS_sys_stat.inl.
{ ACE_OS_TRACE ("ACE_OS::umask"); # if defined (ACE_LACKS_UMASK) ACE_UNUSED_ARG (cmask); ACE_NOTSUP_RETURN ((mode_t)-1); # elif defined (ACE_HAS_TR24731_2005_CRT) int old_mode; int new_mode = static_cast<int> (cmask); ACE_SECURECRTCALL (_umask_s (new_mode, &old_mode), mode_t, -1, old_mode); return static_cast<mode_t> (old_mode); # elif defined (ACE_WIN32) && !defined (__BORLANDC__) ACE_OSCALL_RETURN (::_umask (cmask), mode_t, -1); # else return ::umask (cmask); // This call shouldn't fail... # endif /* ACE_LACKS_UMASK */ }
int ACE_OS::uname | ( | ACE_utsname * | name | ) |
Definition at line 21 of file OS_NS_sys_utsname.cpp.
{ ACE_OS_TRACE ("ACE_OS::uname"); #if !defined (ACE_LACKS_UNAME) ACE_OSCALL_RETURN (::uname (name), int, -1); #elif defined (ACE_WIN32) size_t maxnamelen = sizeof name->nodename; ACE_OS::strcpy (name->sysname, "Win32"); ACE_TEXT_OSVERSIONINFO vinfo; vinfo.dwOSVersionInfoSize = sizeof(ACE_TEXT_OSVERSIONINFO); ACE_TEXT_GetVersionEx (&vinfo); SYSTEM_INFO sinfo; # if defined (ACE_HAS_PHARLAP) // PharLap doesn't do GetSystemInfo. What's really wanted is the // CPU architecture, so we can get that with EtsGetSystemInfo. Fill // in what's wanted in the SYSTEM_INFO structure, and carry on. Note // that the CPU type values in EK_KERNELINFO have the same values // are the ones defined for SYSTEM_INFO. EK_KERNELINFO ets_kern; EK_SYSTEMINFO ets_sys; EtsGetSystemInfo (&ets_kern, &ets_sys); sinfo.wProcessorLevel = static_cast<WORD> (ets_kern.CpuType); sinfo.wProcessorArchitecture = PROCESSOR_ARCHITECTURE_INTEL; sinfo.dwProcessorType = ets_kern.CpuType * 100 + 86; # else ::GetSystemInfo(&sinfo); # endif /* ACE_HAS_PHARLAP */ const char* unknown = "???"; if ( vinfo.dwPlatformId == VER_PLATFORM_WIN32_NT # if defined (VER_PLATFORM_WIN32_CE) || vinfo.dwPlatformId == VER_PLATFORM_WIN32_CE # endif ) { // Get information from the two structures const char *os = 0; if (vinfo.dwPlatformId == VER_PLATFORM_WIN32_NT) os = "Windows NT %d.%d"; else os = "Windows CE %d.%d"; ACE_OS::sprintf (name->release, os, (int) vinfo.dwMajorVersion, (int) vinfo.dwMinorVersion); ACE_OS::sprintf (name->version, "Build %d %s", (int) vinfo.dwBuildNumber, ACE_TEXT_ALWAYS_CHAR (vinfo.szCSDVersion)); // We have to make sure that the size of (processor + subtype) // is not greater than the size of name->machine. So we give // half the space to the processor and half the space to // subtype. The -1 is necessary for because of the space // between processor and subtype in the machine name. int const bufsize = (sizeof (name->machine) / 2) - 1; char processor[bufsize] = "Unknown"; char subtype[bufsize] = "Unknown"; # if defined (ghs) WORD arch = sinfo.u.s.wProcessorArchitecture; # else WORD arch = sinfo.wProcessorArchitecture; # endif switch (arch) { case PROCESSOR_ARCHITECTURE_INTEL: ACE_OS::strcpy (processor, "Intel"); if (sinfo.wProcessorLevel == 3) ACE_OS::strcpy (subtype, "80386"); else if (sinfo.wProcessorLevel == 4) ACE_OS::strcpy (subtype, "80486"); else if (sinfo.wProcessorLevel == 5) ACE_OS::strcpy (subtype, "Pentium"); else if (sinfo.wProcessorLevel == 6) ACE_OS::strcpy (subtype, "Pentium Pro"); else if (sinfo.wProcessorLevel == 7) // I'm guessing here ACE_OS::strcpy (subtype, "Pentium II"); else ACE_OS::sprintf (subtype, "%d", sinfo.wProcessorLevel); break; case PROCESSOR_ARCHITECTURE_MIPS: ACE_OS::strcpy (processor, "MIPS"); if (sinfo.wProcessorLevel == 3) ACE_OS::strcpy (subtype, "R3000"); else if (sinfo.wProcessorLevel == 4) ACE_OS::strcpy (subtype, "R4000"); else ACE_OS::sprintf (subtype, "%d", sinfo.wProcessorLevel); break; case PROCESSOR_ARCHITECTURE_ALPHA: ACE_OS::strcpy (processor, "Alpha"); ACE_OS::sprintf (subtype, "%d", sinfo.wProcessorLevel); break; case PROCESSOR_ARCHITECTURE_PPC: ACE_OS::strcpy (processor, "PPC"); if (sinfo.wProcessorLevel == 1) ACE_OS::strcpy (subtype, "601"); else if (sinfo.wProcessorLevel == 3) ACE_OS::strcpy (subtype, "603"); else if (sinfo.wProcessorLevel == 4) ACE_OS::strcpy (subtype, "604"); else if (sinfo.wProcessorLevel == 6) ACE_OS::strcpy (subtype, "603+"); else if (sinfo.wProcessorLevel == 9) ACE_OS::strcpy (subtype, "804+"); else if (sinfo.wProcessorLevel == 20) ACE_OS::strcpy (subtype, "620"); break; # if defined PROCESSOR_ARCHITECTURE_IA64 case PROCESSOR_ARCHITECTURE_IA64: ACE_OS::strcpy (processor, "Itanium"); ACE_OS::sprintf (subtype, "%d", sinfo.wProcessorLevel); break; # endif # if defined PROCESSOR_ARCHITECTURE_AMD64 case PROCESSOR_ARCHITECTURE_AMD64: ACE_OS::strcpy (processor, "x64"); ACE_OS::sprintf (subtype, "%d", sinfo.wProcessorLevel); break; # endif # if defined PROCESSOR_ARCHITECTURE_IA32_ON_WIN64 case PROCESSOR_ARCHITECTURE_IA32_ON_WIN64: ACE_OS::strcpy (processor, "WOW64"); ACE_OS::sprintf (subtype, "%d", sinfo.wProcessorLevel); break; # endif # if defined PROCESSOR_ARCHITECTURE_ARM case PROCESSOR_ARCHITECTURE_ARM: ACE_OS::strcpy (processor, "ARM"); ACE_OS::sprintf (subtype, "%d", sinfo.wProcessorLevel); break; # endif case PROCESSOR_ARCHITECTURE_UNKNOWN: default: // @@ We could provide WinCE specific info here. But let's // defer that to some later point. ACE_OS::strcpy (processor, "Unknown"); break; } ACE_OS::sprintf (name->machine, "%s %s", processor, subtype); } else if (vinfo.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) { if (vinfo.dwMajorVersion == 4 && vinfo.dwMinorVersion == 0) { ACE_OS::strcpy (name->release, "Windows 95"); if (vinfo.szCSDVersion[1] == ACE_TEXT('C')) ACE_OS::strcat (name->release, " OSR2"); } else if (vinfo.dwMajorVersion == 4 && vinfo.dwMinorVersion == 10) { ACE_OS::strcpy (name->release, "Windows 98"); if (vinfo.szCSDVersion[1] == ACE_TEXT('A')) ACE_OS::strcat (name->release, " SE"); } else if (vinfo.dwMajorVersion == 4 && vinfo.dwMinorVersion == 90) { ACE_OS::strcpy (name->release, "Windows Me"); } else { ACE_OS::strcpy (name->release, unknown); } ACE_OS::sprintf (name->version, "%d", LOWORD (vinfo.dwBuildNumber)); if (sinfo.dwProcessorType == PROCESSOR_INTEL_386) ACE_OS::strcpy (name->machine, "Intel 80386"); else if (sinfo.dwProcessorType == PROCESSOR_INTEL_486) ACE_OS::strcpy (name->machine, "Intel 80486"); else if (sinfo.dwProcessorType == PROCESSOR_INTEL_PENTIUM) ACE_OS::strcpy (name->machine, "Intel Pentium"); else ACE_OS::strcpy (name->machine, unknown); } else { // We don't know what this is! ACE_OS::strcpy (name->release, unknown); ACE_OS::strcpy (name->version, unknown); ACE_OS::strcpy (name->machine, unknown); } # if defined (ACE_LACKS_HOSTNAME) return 0; # else /* ACE_LACKS_HOSTNAME */ return ACE_OS::hostname (name->nodename, maxnamelen); # endif /* ACE_LACKS_HOSTNAME */ #elif defined (ACE_VXWORKS) size_t const maxnamelen = sizeof name->nodename; ACE_OS::strcpy (name->sysname, "VxWorks"); ACE_OS::strcpy (name->release, kernelVersion()); ACE_OS::strcpy (name->version, sysBspRev ()); ACE_OS::strcpy (name->machine, sysModel ()); return ACE_OS::hostname (name->nodename, maxnamelen); #elif defined (INTEGRITY) if(!name) { errno = EFAULT; return -1; } strcpy(name->sysname,"INTEGRITY"); int status = gethostname(name->nodename,_SYS_NMLN); strcpy(name->release,"4.0"); strcpy(name->version,"4.0.9"); strcpy(name->machine,"a standard name"); return status; #endif /* ACE_WIN32 */ }
int ACE_OS::ungetc | ( | int | c, | |
FILE * | fp | |||
) | [inline] |
Definition at line 649 of file OS_NS_stdio.inl.
{ return ace_ungetc_helper (c, 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 object will provide uniqueness between other "live" objects in the same process. The uniqueness of this name is therefore only valid for the life of object.
Definition at line 5021 of file OS_NS_Thread.cpp.
{ // The process ID will provide uniqueness between processes on the // same machine. The "this" pointer of the <object> will provide // uniqueness between other "live" objects in the same process. The // uniqueness of this name is therefore only valid for the life of // <object>. char temp_name[ACE_UNIQUE_NAME_LEN]; ACE_OS::sprintf (temp_name, "%p%d", object, static_cast <int> (ACE_OS::getpid ())); ACE_OS::strsncpy (name, temp_name, length); }
int ACE_OS::unlink | ( | const char * | path | ) | [inline] |
Definition at line 1147 of file OS_NS_unistd.inl.
{ ACE_OS_TRACE ("ACE_OS::unlink"); # if defined (ACE_HAS_NONCONST_UNLINK) ACE_OSCALL_RETURN (::unlink (const_cast<char *> (path)), int, -1); # elif defined (ACE_HAS_WINCE) // @@ The problem is, DeleteFile is not actually equals to unlink. ;( ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::DeleteFile (ACE_TEXT_CHAR_TO_TCHAR (path)), ace_result_), int, -1); # elif defined (ACE_LACKS_UNLINK) ACE_UNUSED_ARG (path); ACE_NOTSUP_RETURN (-1); # else ACE_OSCALL_RETURN (::unlink (path), int, -1); # endif /* ACE_HAS_NONCONST_UNLINK */ }
int ACE_OS::unsetenv | ( | const char * | name | ) | [inline] |
Function that is called by <ACE_OS::exit>, if non-null.
Definition at line 354 of file OS_NS_stdlib.inl.
{ #if defined (ACE_LACKS_UNSETENV) ACE_UNUSED_ARG (name); ACE_NOTSUP_RETURN (-1); #else # if defined (ACE_HAS_VOID_UNSETENV) ::unsetenv (name); return 0; #else ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::unsetenv (name), int, -1); # endif /* ACE_HAS_VOID_UNSETENV */ #endif /* ACE_LACKS_UNSETENV */ }
int ACE_OS::vasprintf | ( | char ** | bufp, | |
const char * | format, | |||
va_list | argptr | |||
) | [inline] |
Definition at line 941 of file OS_NS_stdio.inl.
{ #if defined (ACE_HAS_VASPRINTF) return ::vasprintf (bufp, format, argptr); #else return ACE_OS::vasprintf_emulation (bufp, format, argptr); #endif /* ACE_HAS_VASPRINTF */ }
int ACE_OS::vasprintf_emulation | ( | char ** | bufp, | |
const char * | format, | |||
va_list | argptr | |||
) |
Definition at line 369 of file OS_NS_stdio.cpp.
{ va_list ap; va_copy (ap, argptr); int size = ACE_OS::vsnprintf (0, 0, format, ap); va_end (ap); if (size != -1) { char *buf = reinterpret_cast<char*>(ACE_OS::malloc(size + 1)); if (!buf) return -1; va_list aq; va_copy (aq, argptr); size = ACE_OS::vsnprintf(buf, size + 1, format, aq); va_end (aq); if (size != -1) *bufp = buf; } return size; }
int ACE_OS::vfprintf | ( | FILE * | fp, | |
const char * | format, | |||
va_list | argptr | |||
) | [inline] |
Definition at line 983 of file OS_NS_stdio.inl.
{ return ACE_STD_NAMESPACE::vfprintf (fp, format, argptr); }
int ACE_OS::vprintf | ( | const char * | format, | |
va_list | argptr | |||
) | [inline] |
Definition at line 963 of file OS_NS_stdio.inl.
{ return ::vprintf (format, argptr); }
int ACE_OS::vsnprintf | ( | char * | buffer, | |
size_t | maxlen, | |||
const char * | format, | |||
va_list | argptr | |||
) | [inline] |
Definition at line 1046 of file OS_NS_stdio.inl.
{ #if !defined (ACE_LACKS_VSNPRINTF) int result; # if 0 /* defined (ACE_HAS_TR24731_2005_CRT) */ // _vsnprintf_s() doesn't report the length needed when it truncates. This // info is needed and relied on by others things in ACE+TAO, so don't use // this. There's adequate protection via the maxlen. result = _vsnprintf_s (buffer, maxlen, _TRUNCATE, format, ap); # elif !defined (ACE_WIN32) result = ::vsnprintf (buffer, maxlen, format, ap); # else result = ::_vsnprintf (buffer, maxlen, format, ap); // Win32 doesn't regard a full buffer with no 0-terminate as an overrun. if (result == static_cast<int> (maxlen) && maxlen > 0) buffer[maxlen-1] = '\0'; // Win32 doesn't 0-terminate the string if it overruns maxlen. if (result == -1 && maxlen > 0) buffer[maxlen-1] = '\0'; # endif // In out-of-range conditions, C99 defines vsnprintf() to return the number // of characters that would have been written if enough space was available. // Earlier variants of the vsnprintf() (e.g. UNIX98) defined it to return // -1. This method follows the C99 standard, but needs to guess at the // value; uses maxlen + 1. if (result == -1) { result = static_cast <int> (maxlen + 1); } return result; #elif defined (ACE_HAS_TRIO) return trio_vsnprintf (buffer, maxlen, format, ap); #else ACE_UNUSED_ARG (buffer); ACE_UNUSED_ARG (maxlen); ACE_UNUSED_ARG (format); ACE_UNUSED_ARG (ap); ACE_NOTSUP_RETURN (-1); #endif /* ACE_LACKS_VSNPRINTF */ }
int ACE_OS::vsprintf | ( | char * | buffer, | |
const char * | format, | |||
va_list | argptr | |||
) | [inline] |
Definition at line 1004 of file OS_NS_stdio.inl.
{ return ::vsprintf (buffer, format, argptr); }
pid_t ACE_OS::wait | ( | pid_t | pid, | |
ACE_exitcode * | status, | |||
int | wait_options = 0 , |
|||
ACE_HANDLE | handle = 0 | |||
) | [inline] |
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 93 of file OS_NS_sys_wait.inl.
{ ACE_OS_TRACE ("ACE_OS::wait"); return ACE_OS::waitpid (pid, status, wait_options, handle); }
pid_t ACE_OS::wait | ( | int * | status = 0 |
) | [inline] |
Calls OS wait
function, so it's only portable to UNIX/POSIX /// platforms.
Definition at line 11 of file OS_NS_sys_wait.inl.
{ ACE_OS_TRACE ("ACE_OS::wait"); #if defined (ACE_LACKS_WAIT) ACE_UNUSED_ARG (status); ACE_NOTSUP_RETURN (0); #else ACE_OSCALL_RETURN (::wait (status), pid_t, -1); #endif /* ACE_LACKS_WAIT */ }
pid_t ACE_OS::waitpid | ( | pid_t | pid, | |
ACE_exitcode * | status = 0 , |
|||
int | wait_options = 0 , |
|||
ACE_HANDLE | handle = 0 | |||
) | [inline] |
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 23 of file OS_NS_sys_wait.inl.
{ ACE_OS_TRACE ("ACE_OS::waitpid"); #if defined (ACE_LACKS_WAITPID) ACE_UNUSED_ARG (pid); ACE_UNUSED_ARG (status); ACE_UNUSED_ARG (wait_options); ACE_UNUSED_ARG (handle); ACE_NOTSUP_RETURN (0); #elif defined (ACE_WIN32) int blocking_period = ACE_BIT_ENABLED (wait_options, WNOHANG) ? 0 /* don't hang */ : INFINITE; ACE_HANDLE phandle = handle; if (phandle == 0) { phandle = ::OpenProcess (SYNCHRONIZE, FALSE, pid); if (phandle == 0) { ACE_OS::set_errno_to_last_error (); return -1; } } pid_t result = pid; // Don't try to get the process exit status if wait failed so we can // keep the original error code intact. switch (::WaitForSingleObject (phandle, blocking_period)) { case WAIT_OBJECT_0: if (status != 0) // The error status of <GetExitCodeProcess> is nonetheless // not tested because we don't know how to return the value. ::GetExitCodeProcess (phandle, status); break; case WAIT_TIMEOUT: errno = ETIME; result = 0; break; default: ACE_OS::set_errno_to_last_error (); result = -1; } if (handle == 0) ::CloseHandle (phandle); return result; #elif defined(ACE_TANDEM_T1248_PTHREADS) ACE_UNUSED_ARG (handle); ACE_OSCALL_RETURN (::spt_waitpid (pid, status, wait_options), pid_t, -1); #else ACE_UNUSED_ARG (handle); ACE_OSCALL_RETURN (::waitpid (pid, status, wait_options), pid_t, -1); #endif /* ACE_LACKS_WAITPID */ }
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.
{ while (*string1 == *string2++) if (*string1++ == 0) return 0; return (*string1 - *--string2); }
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.
{ const ACE_WCHAR_T *s = 0; for (s = string; *s; ++s) continue; return s - string; }
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.
{ if (count != 0) { ACE_WCHAR_T *d = destination; const ACE_WCHAR_T *s = source; while (*d != 0) ++d; do { if ((*d = *s++) == 0) break; ++d; } while (--count != 0); *d = 0; } return destination; }
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.
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.
{ if (len != 0) { ACE_WCHAR_T *d = destination; const ACE_WCHAR_T *s = source; do { if ((*d++ = *s++) == 0) { // NUL pad the remaining n-1 bytes while (--len != 0) *d++ = 0; break; } } while (--len != 0); } return destination; }
ssize_t ACE_OS::write | ( | ACE_HANDLE | handle, | |
const void * | buf, | |||
size_t | nbyte, | |||
ACE_OVERLAPPED * | overlapped | |||
) | [inline] |
Definition at line 1206 of file OS_NS_unistd.inl.
{ ACE_OS_TRACE ("ACE_OS::write"); overlapped = overlapped; #if defined (ACE_WIN32) DWORD bytes_written; // This is set to 0 byte WriteFile. DWORD short_nbyte = static_cast<DWORD> (nbyte); if (::WriteFile (handle, buf, short_nbyte, &bytes_written, overlapped)) return (ssize_t) bytes_written; else ACE_FAIL_RETURN (-1); #else return ACE_OS::write (handle, buf, nbyte); #endif /* ACE_WIN32 */ }
ssize_t ACE_OS::write | ( | ACE_HANDLE | handle, | |
const void * | buf, | |||
size_t | nbyte | |||
) | [inline] |
Definition at line 1183 of file OS_NS_unistd.inl.
{ ACE_OS_TRACE ("ACE_OS::write"); #if defined (ACE_WIN32) DWORD bytes_written; // This is set to 0 byte WriteFile. // Strictly correctly, we should loop writing all the data if more // than a DWORD length can hold. DWORD short_nbyte = static_cast<DWORD> (nbyte); if (::WriteFile (handle, buf, short_nbyte, &bytes_written, 0)) return (ssize_t) bytes_written; else ACE_FAIL_RETURN (-1); #else # if defined (ACE_HAS_CHARPTR_SOCKOPT) ACE_OSCALL_RETURN (::write (handle, static_cast <char *> (const_cast <void *> (buf)), nbyte), ssize_t, -1); # else ACE_OSCALL_RETURN (::write (handle, buf, nbyte), ssize_t, -1); # endif /* ACE_HAS_CHARPTR_SOCKOPT */ #endif /* ACE_WIN32 */ }
ssize_t ACE_OS::write_n | ( | ACE_HANDLE | handle, | |
const void * | buf, | |||
size_t | len, | |||
size_t * | bytes_transferred = 0 | |||
) |
Send len bytes from buf to handle (uses the <ACE_OS::write> calls, which is uses the <write> system call on UNIX and the <WriteFile> 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 bytes_transferred.
Definition at line 911 of file OS_NS_unistd.cpp.
{ size_t temp; size_t &bytes_transferred = bt == 0 ? temp : *bt; ssize_t n; for (bytes_transferred = 0; bytes_transferred < len; bytes_transferred += n) { n = ACE_OS::write (handle, (char *) buf + bytes_transferred, len - bytes_transferred); if (n == -1 || n == 0) { return n; } } return ACE_Utils::truncate_cast<ssize_t> (bytes_transferred); }
ssize_t ACE_OS::writev | ( | ACE_HANDLE | handle, | |
const iovec * | iov, | |||
int | iovcnt | |||
) | [inline] |
Definition at line 33 of file OS_NS_sys_uio.inl.
{ ACE_OS_TRACE ("ACE_OS::writev"); #if defined (ACE_LACKS_WRITEV) ACE_OSCALL_RETURN (ACE_OS::writev_emulation (handle, iov, iovcnt), ssize_t, -1); #else /* ACE_LACKS_WRITEV */ #if defined (ACE_HAS_NONCONST_WRITEV) ACE_OSCALL_RETURN (::writev (handle, const_cast<iovec *>(iov), iovcnt), ssize_t, -1); #else ACE_OSCALL_RETURN (::writev (handle, iov, iovcnt), ssize_t, -1); #endif /* ACE_HAS_NONCONST_WRITEV */ #endif /* ACE_LACKS_WRITEV */ }
int ACE_OS::wscmp | ( | const WChar * | s, | |
const WChar * | t | |||
) | [inline] |
Definition at line 43 of file OS_NS_wchar.inl.
ACE_OS::WChar * ACE_OS::wscpy | ( | WChar * | dest, | |
const WChar * | src | |||
) | [inline] |
Definition at line 32 of file OS_NS_wchar.inl.
{ WChar *original_dest = dest; while ((*dest++ = *src++) != 0) continue; return original_dest; }
u_int ACE_OS::wslen | ( | const WChar * | s | ) | [inline] |
Definition at line 21 of file OS_NS_wchar.inl.
{ u_int len = 0; while (*s++ != 0) len++; return len; }
int ACE_OS::wsncmp | ( | const WChar * | s, | |
const WChar * | t, | |||
size_t | len | |||
) | [inline] |
ACE_Export ACE_EXIT_HOOK ACE_OS::exit_hook_ |
Function that is called by <ACE_OS::exit>, if non-null.
This is necessary to deal with POSIX pthreads and their use of structures for thread handles.
Definition at line 1088 of file OS_NS_Thread.cpp.
This is necessary to deal with POSIX pthreads and their use of structures for TSS keys.
Definition at line 1092 of file OS_NS_Thread.cpp.
This is necessary to deal with POSIX pthreads and their use of structures for thread ids.
Definition at line 1087 of file OS_NS_Thread.cpp.