diff --git a/glnx-macros.h b/glnx-macros.h
index 6d8aca93f8a36b49e378c59bc374e169e0991c71..700fc75ceed0ab1248a95e4fe03abb8b8bc6c6e9 100644
--- a/glnx-macros.h
+++ b/glnx-macros.h
@@ -31,6 +31,16 @@ G_BEGIN_DECLS
 /* All of these are for C only. */
 #ifndef __GI_SCANNER__
 
+/* fixes builds against musl, taken from glibc unistd.h */
+#ifndef TEMP_FAILURE_RETRY
+#define TEMP_FAILURE_RETRY(expression) \
+  (__extension__                                                              \
+    ({ long int __result;                                                     \
+       do __result = (long int) (expression);                                 \
+       while (__result == -1L && errno == EINTR);                             \
+       __result; }))
+#endif
+
 /* Taken from https://github.com/systemd/systemd/src/basic/string-util.h
  * at revision v228-666-gcf6c8c4
  */