Import selfpipe code from skalibs 1.2.5

[andersk@mit.edu: Move code to new third/libstddjb directory]
This commit is contained in:
Quentin Smith
2012-02-26 15:58:37 -05:00
committed by Keith Winstein
parent 9a3ab83783
commit 77f3a9073f
24 changed files with 697 additions and 0 deletions
+31
View File
@@ -0,0 +1,31 @@
/* ISC license. */
/* MT-unsafe */
#include "sysdeps.h"
#include "allreadwrite.h"
#include "selfpipe-internal.h"
#include "selfpipe.h"
#ifdef HASSIGNALFD
#include <sys/signalfd.h>
int selfpipe_read (void)
{
struct signalfd_siginfo buf ;
register int r = sanitize_read(fd_read(selfpipe_fd, (char *)&buf, sizeof(struct signalfd_siginfo))) ;
return (r <= 0) ? r : (int)buf.ssi_signo ;
}
#else
int selfpipe_read (void)
{
char c ;
register int r = sanitize_read((fd_read(selfpipe_fd, &c, 1))) ;
return (r <= 0) ? r : (int)c ;
}
#endif