TreeFrogFramework  1.18
tfcore_unix.h
Go to the documentation of this file.
1 #ifndef TFCORE_UNIX_H
2 #define TFCORE_UNIX_H
3 
4 #include <unistd.h>
5 #include <sys/types.h>
6 #include <sys/syscall.h>
7 #include <sys/wait.h>
8 #include <fcntl.h>
9 #include <aio.h>
10 #include "tfcore.h"
11 
12 #ifndef Q_OS_UNIX
13 # error "tfcore_unix.h included on a non-Unix system"
14 #endif
15 
16 
17 static inline int tf_aio_write(struct aiocb *aiocbp)
18 {
19  TF_EINTR_LOOP(::aio_write(aiocbp));
20 }
21 
22 
23 static inline pid_t gettid()
24 {
25 #if defined(Q_OS_LINUX)
26  return syscall(SYS_gettid);
27 #elif defined(Q_OS_DARWIN)
28  return syscall(SYS_thread_selfid);
29 #else
30  return 0;
31 #endif
32 }
33 
34 
35 #ifdef Q_OS_LINUX
36 #include <sys/epoll.h>
37 
38 static inline int tf_epoll_wait(int epfd, struct epoll_event *events,
39  int maxevents, int timeout)
40 {
41  TF_EINTR_LOOP(::epoll_wait(epfd, events, maxevents, timeout));
42 }
43 
44 
45 static inline int tf_epoll_ctl(int epfd, int op, int fd, struct epoll_event *event)
46 {
47  TF_EINTR_LOOP(::epoll_ctl(epfd, op, fd, event));
48 }
49 
50 
51 static inline int tf_accept4(int sockfd, struct sockaddr *addr, socklen_t *addrlen, int flags)
52 {
53  TF_EINTR_LOOP(::accept4(sockfd, addr, addrlen, flags));
54 }
55 
56 #endif // Q_OS_LINUX
57 
58 #endif // TFCORE_UNIX_H
#define TF_EINTR_LOOP(func)
Definition: tfcore.h:18