12 |
#include <stdarg.h> |
#include <stdarg.h> |
13 |
#include <unistd.h> |
#include <unistd.h> |
14 |
#include <time.h> |
#include <time.h> |
15 |
|
#include <signal.h> |
16 |
#include <sys/time.h> |
#include <sys/time.h> |
17 |
#include <sys/ioctl.h> |
#include <sys/ioctl.h> |
18 |
#include <sys/types.h> |
#include <sys/types.h> |
298 |
#ifdef __linux__ |
#ifdef __linux__ |
299 |
if (posix_memalign((void *)&p,boundary,size)) |
if (posix_memalign((void *)&p,boundary,size)) |
300 |
#else |
#else |
301 |
#ifdef __CYGWIN__ |
#if defined(__CYGWIN__) || defined(SUNOS) |
302 |
if (!(p = memalign(boundary,size))) |
if (!(p = memalign(boundary,size))) |
303 |
#else |
#else |
304 |
if (!(p = malloc(size))) |
if (!(p = malloc(size))) |
310 |
return p; |
return p; |
311 |
} |
} |
312 |
|
|
313 |
|
/* Block specified signal for calling thread */ |
314 |
|
int m_signal_block(int sig) |
315 |
|
{ |
316 |
|
sigset_t sig_mask; |
317 |
|
sigemptyset(&sig_mask); |
318 |
|
sigaddset(&sig_mask,sig); |
319 |
|
return(pthread_sigmask(SIG_BLOCK,&sig_mask,NULL)); |
320 |
|
} |
321 |
|
|
322 |
|
/* Unblock specified signal for calling thread */ |
323 |
|
int m_signal_unblock(int sig) |
324 |
|
{ |
325 |
|
sigset_t sig_mask; |
326 |
|
sigemptyset(&sig_mask); |
327 |
|
sigaddset(&sig_mask,sig); |
328 |
|
return(pthread_sigmask(SIG_UNBLOCK,&sig_mask,NULL)); |
329 |
|
} |
330 |
|
|
331 |
|
/* Set non-blocking mode on a file descriptor */ |
332 |
|
int m_fd_set_non_block(int fd) |
333 |
|
{ |
334 |
|
int flags; |
335 |
|
|
336 |
|
if ((flags = fcntl(fd,F_GETFL,0)) < 1) |
337 |
|
return(-1); |
338 |
|
|
339 |
|
return(fcntl(fd,F_SETFL, flags | O_NONBLOCK)); |
340 |
|
} |