My Project
Loading...
Searching...
No Matches
Macros | Functions | Variables
si_signals.h File Reference
#include <signal.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/select.h>
#include <unistd.h>
#include <sys/uio.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/socket.h>
#include <time.h>
#include <stdio.h>
#include <semaphore.h>
#include <stdarg.h>

Go to the source code of this file.

Macros

#define SI_EINTR_SAVE_FUNC_TEMPLATE(return_type, newfunc, func, decl, args, err_domain)
 
#define SI_EINTR_SAVE_FUNC(return_type, func, decl, args)    SI_EINTR_SAVE_FUNC_TEMPLATE(return_type, si_##func, func, decl, args, < 0)
 
#define SI_EINTR_SAVE_SCANF(return_type, func, decl, args)    SI_EINTR_SAVE_FUNC_TEMPLATE(return_type, si_##func, func, decl, args, == EOF)
 
#define SI_GET_FIFTH(_4, _3, _2, _1, N, ...)   N
 
#define si_open(...)   SI_GET_FIFTH(X,##__VA_ARGS__, si_open2, si_open1)(__VA_ARGS__)
 
#define si_siginterrupt(arg1, arg2)
 

Functions

 SI_EINTR_SAVE_FUNC (int, select,(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout),(nfds, readfds, writefds, exceptfds, timeout)) SI_EINTR_SAVE_FUNC(pid_t
 
int status SI_EINTR_SAVE_FUNC (pid_t, waitpid,(pid_t pid, int *status, int options),(pid, status, options)) SI_EINTR_SAVE_FUNC(ssize_t
 
int status int void size_t count SI_EINTR_SAVE_FUNC (ssize_t, readv,(int fd, const struct iovec *iov, int iovcnt),(fd, iov, iovcnt)) SI_EINTR_SAVE_FUNC(ssize_t
 
int status int void size_t count int const void size_t count SI_EINTR_SAVE_FUNC (ssize_t, writev,(int fd, const struct iovec *iov, int iovcnt),(fd, iov, iovcnt)) SI_EINTR_SAVE_FUNC_TEMPLATE(int
 

Variables

 wait
 
intstatus
 
int status read
 
int status int fd
 
int status int voidbuf
 
int status int void size_t count
 
int status int void size_t count write
 
int status int void size_t count int const void size_t count si_open1
 
int status int void size_t count int const void size_t count open
 
int status int void size_t count int const void size_t count const charpathname
 
int status int void size_t count int const void size_t count const char int flags
 

Macro Definition Documentation

◆ SI_EINTR_SAVE_FUNC

#define SI_EINTR_SAVE_FUNC (   return_type,
  func,
  decl,
  args 
)     SI_EINTR_SAVE_FUNC_TEMPLATE(return_type, si_##func, func, decl, args, < 0)

Definition at line 39 of file si_signals.h.

100 {
101
102 int res = -1;
103 do
104 {
105 res = nanosleep(req, rem);
106 } while((rem != NULL) && (res < 0) && (errno == EINTR));
107 return res;
108}
109
110static inline unsigned int
111si_sleep(unsigned int seconds)
112{
113 do
114 {
116 } while(seconds != 0);
117 return 0;
118}
119
120SI_EINTR_SAVE_FUNC(int, dup, (int oldfd), (oldfd))
121SI_EINTR_SAVE_FUNC(int, dup2, (int oldfd, int newfd), (oldfd, newfd))
122//SI_EINTR_SAVE_FUNC(int, dup3, (int oldfd, int newfd, int flags),
123// (oldfd, newfd, flags))
124
125SI_EINTR_SAVE_FUNC(int, unlink, (const char *pathname), (pathname))
126
128 (const char *format, va_list ap),
129 (format, ap))
130
131static inline
132int si_scanf(const char *format, ...)
133{
135 va_start(argptr, format);
136 int res = si_vscanf(format, argptr);
137 va_end(argptr);
138 return res;
139}
140
142 (FILE *stream, const char *format, va_list ap),
143 (stream, format, ap))
144
145static inline int
146si_fscanf(FILE *stream, const char *format, ...)
147{
149 va_start(argptr, format);
150 int res = si_vfscanf(stream, format, argptr);
151 va_end(argptr);
152 return res;
153}
154
156 (const char *str, const char *format, va_list ap),
157 (str, format, ap))
158
159static inline int
160si_sscanf(const char *str, const char *format, ...)
161{
163 va_start(argptr, format);
164 int res = si_vsscanf(str, format, argptr);
165 va_end(argptr);
166 return res;
167}
168
169SI_EINTR_SAVE_FUNC(int, stat, (const char *path, struct stat *buf),
170 (path, buf))
171SI_EINTR_SAVE_FUNC(int, fstat, (int fd, struct stat *buf),
172 (fd, buf))
173SI_EINTR_SAVE_FUNC(int, lstat, (const char *path, struct stat *buf),
174 (path, buf))
175
176
178 (int signum, const struct sigaction *act,
179 struct sigaction *oldact),
180 (signum, act, oldact))
181
182
183#ifdef HAVE_SIGINTERRUPT
184SI_EINTR_SAVE_FUNC(int, siginterrupt, (int sig, int flag),
185 (sig, flag))
186#else
187#define si_siginterrupt(arg1, arg2)
188#endif
189
190
193//SI_EINTR_SAVE_FUNC(int, sem_timedwait,
194// (sem_t *sem, const struct timespec *abs_timeout),
195// (sem, abs_timeout))
196
197
198#undef SI_EINTR_SAVE_FUNC
199
200
201#endif /* SINGULAR_SI_SIGNALS_H */
CanonicalForm res
Definition facAbsFact.cc:60
STATIC_VAR scmon act
Definition hdegree.cc:1173
void rem(unsigned long *a, unsigned long *q, unsigned long p, int &dega, int degq)
Definition minpoly.cc:572
Definition ap.h:40
#define NULL
Definition omList.c:12
#define SI_EINTR_SAVE_FUNC(return_type, func, decl, args)
Definition si_signals.h:39
#define SI_EINTR_SAVE_SCANF(return_type, func, decl, args)
Definition si_signals.h:42
int status int void * buf
Definition si_signals.h:59
int status int fd
Definition si_signals.h:59
int status int void size_t count int const void size_t count const char * pathname
Definition si_signals.h:73

◆ SI_EINTR_SAVE_FUNC_TEMPLATE

#define SI_EINTR_SAVE_FUNC_TEMPLATE (   return_type,
  newfunc,
  func,
  decl,
  args,
  err_domain 
)
Value:
static inline return_type newfunc decl \
{ \
int res = -1; \
do \
{ \
res = func args; \
} while((res err_domain) && (errno == EINTR));\
return res; \
}

Definition at line 28 of file si_signals.h.

30{ \
31 int res = -1; \
32 do \
33 { \
34 res = func args; \
35 } while((res err_domain) && (errno == EINTR));\
36 return res; \
37}

◆ SI_EINTR_SAVE_SCANF

#define SI_EINTR_SAVE_SCANF (   return_type,
  func,
  decl,
  args 
)     SI_EINTR_SAVE_FUNC_TEMPLATE(return_type, si_##func, func, decl, args, == EOF)

Definition at line 42 of file si_signals.h.

◆ SI_GET_FIFTH

#define SI_GET_FIFTH (   _4,
  _3,
  _2,
  _1,
  N,
  ... 
)    N

◆ si_open

#define si_open (   ...)    SI_GET_FIFTH(X,##__VA_ARGS__, si_open2, si_open1)(__VA_ARGS__)

◆ si_siginterrupt

#define si_siginterrupt (   arg1,
  arg2 
)

Function Documentation

◆ SI_EINTR_SAVE_FUNC() [1/4]

◆ SI_EINTR_SAVE_FUNC() [2/4]

int status SI_EINTR_SAVE_FUNC ( pid_t  ,
waitpid  ,
(pid_t pid, int *status, int options)  ,
(pid, status, options)   
)

◆ SI_EINTR_SAVE_FUNC() [3/4]

int status int void size_t count SI_EINTR_SAVE_FUNC ( ssize_t  ,
readv  ,
(int fd, const struct iovec *iov, int iovcnt ,
(fd, iov, iovcnt  
)

◆ SI_EINTR_SAVE_FUNC() [4/4]

int status int void size_t count int const void size_t count SI_EINTR_SAVE_FUNC ( ssize_t  ,
writev  ,
(int fd, const struct iovec *iov, int iovcnt ,
(fd, iov, iovcnt  
)

Variable Documentation

◆ buf

Definition at line 59 of file si_signals.h.

◆ count

Definition at line 59 of file si_signals.h.

◆ fd

Definition at line 59 of file si_signals.h.

◆ flags

Definition at line 73 of file si_signals.h.

◆ open

Definition at line 73 of file si_signals.h.

◆ pathname

Definition at line 73 of file si_signals.h.

◆ read

int status read

Definition at line 59 of file si_signals.h.

◆ si_open1

Definition at line 73 of file si_signals.h.

◆ status

int* status

Definition at line 51 of file si_signals.h.

◆ wait

wait

Definition at line 51 of file si_signals.h.

◆ write

Definition at line 67 of file si_signals.h.