Add a GNU-compatible TEMP_FAILURE_RETRY.
I wondered about #ifndef, but the other macros in here don't use it.
I also wondered about __GNUC__, since this macro uses two GCC extensions.
diff --git a/libc/include/unistd.h b/libc/include/unistd.h
index 1ada37e..67cb5fe 100644
--- a/libc/include/unistd.h
+++ b/libc/include/unistd.h
@@ -185,6 +185,14 @@
extern pid_t tcgetpgrp(int fd);
extern int tcsetpgrp(int fd, pid_t _pid);
+/* Used to retry syscalls that can return EINTR. */
+#define TEMP_FAILURE_RETRY(exp) ({ \
+ typeof (exp) _rc; \
+ do { \
+ _rc = (exp); \
+ } while (_rc == -1 && errno == EINTR); \
+ _rc; })
+
__END_DECLS
#endif /* _UNISTD_H_ */