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 SINGULAR_SI_SIGNALS_H
 
#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, write,(int fd, const void *buf, size_t count),(fd, buf, count)) 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 si_open1
 
int status int void size_t count open
 
int status int void size_t count const charpathname
 
int status int 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 42 of file si_signals.h.

112{
113 int res = -1;
114 do
115 {
116 res = nanosleep(req, rem);
117 } while((rem != NULL) && (res < 0) && (errno == EINTR));
118 return res;
119}
120#endif
121
122static inline unsigned int
123si_sleep(unsigned int seconds)
124{
125 do
126 {
128 } while(seconds != 0);
129 return 0;
130}
131
132//SI_EINTR_SAVE_FUNC(int, dup, (int oldfd), (oldfd))
133SI_EINTR_SAVE_FUNC(int, dup2, (int oldfd, int newfd), (oldfd, newfd))
134//SI_EINTR_SAVE_FUNC(int, dup3, (int oldfd, int newfd, int flags),
135// (oldfd, newfd, flags))
136
137SI_EINTR_SAVE_FUNC(int, unlink, (const char *pathname), (pathname))
138
140 (const char *format, va_list ap),
141 (format, ap))
142
143static inline
144int si_scanf(const char *format, ...)
145{
147 va_start(argptr, format);
148 int res = si_vscanf(format, argptr);
149 va_end(argptr);
150 return res;
151}
152
154 (FILE *stream, const char *format, va_list ap),
155 (stream, format, ap))
156
157static inline int
158si_fscanf(FILE *stream, const char *format, ...)
159{
161 va_start(argptr, format);
162 int res = si_vfscanf(stream, format, argptr);
163 va_end(argptr);
164 return res;
165}
166
168 (const char *str, const char *format, va_list ap),
169 (str, format, ap))
170
171static inline int
172si_sscanf(const char *str, const char *format, ...)
173{
175 va_start(argptr, format);
176 int res = si_vsscanf(str, format, argptr);
177 va_end(argptr);
178 return res;
179}
180
181SI_EINTR_SAVE_FUNC(int, stat, (const char *path, struct stat *buf),
182 (path, buf))
183SI_EINTR_SAVE_FUNC(int, fstat, (int fd, struct stat *buf),
184 (fd, buf))
185SI_EINTR_SAVE_FUNC(int, lstat, (const char *path, struct stat *buf),
186 (path, buf))
187
188
190 (int signum, const struct sigaction *act,
191 struct sigaction *oldact),
192 (signum, act, oldact))
193
194
195#ifdef HAVE_SIGINTERRUPT
196SI_EINTR_SAVE_FUNC(int, siginterrupt, (int sig, int flag),
197 (sig, flag))
198#else
199#define si_siginterrupt(arg1, arg2)
200#endif
201
202
205//SI_EINTR_SAVE_FUNC(int, sem_timedwait,
206// (sem_t *sem, const struct timespec *abs_timeout),
207// (sem, abs_timeout))
208
209
210#undef SI_EINTR_SAVE_FUNC
211
212
213#endif /* SINGULAR_SI_SIGNALS_H */
CanonicalForm res
Definition facAbsFact.cc:60
STATIC_VAR scmon act
Definition hdegree.cc:1138
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:42
#define SI_EINTR_SAVE_SCANF(return_type, func, decl, args)
Definition si_signals.h:45
int status int fd
Definition si_signals.h:69
int status int void size_t count const char * pathname
Definition si_signals.h:83
int status int void * buf
Definition si_signals.h:69

◆ 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 31 of file si_signals.h.

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

◆ 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 45 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 
)

◆ SINGULAR_SI_SIGNALS_H

#define SINGULAR_SI_SIGNALS_H

Definition at line 29 of file si_signals.h.

Function Documentation

◆ SI_EINTR_SAVE_FUNC() [1/3]

◆ SI_EINTR_SAVE_FUNC() [2/3]

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

◆ SI_EINTR_SAVE_FUNC() [3/3]

int status int void size_t count SI_EINTR_SAVE_FUNC ( ssize_t  ,
write  ,
(int fd, const void *buf, size_t count ,
(fd, buf, count  
)

Variable Documentation

◆ buf

Definition at line 69 of file si_signals.h.

◆ count

Definition at line 69 of file si_signals.h.

◆ fd

Definition at line 69 of file si_signals.h.

◆ flags

Definition at line 83 of file si_signals.h.

◆ open

Definition at line 83 of file si_signals.h.

◆ pathname

Definition at line 83 of file si_signals.h.

◆ read

int status read

Definition at line 69 of file si_signals.h.

◆ si_open1

Definition at line 83 of file si_signals.h.

◆ status

int* status

Definition at line 61 of file si_signals.h.

◆ wait

wait

Definition at line 61 of file si_signals.h.