aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2026-05-11 09:10:11 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2026-05-11 09:10:11 +0000
commitc5d6bea6d9f98a593890f9694ef1575d744e5a32 (patch)
treef5611169470b25f621cda8073d66dec672d1e46f /src
parentb95dc9e9c6694df5d7925b1ba806b4e4a95d7db9 (diff)
downloadskalibs-c5d6bea6d9f98a593890f9694ef1575d744e5a32.tar.gz
Prepare for 2.15.0.1; add selectshorttimeout sysdeps (yay MacOS)
Diffstat (limited to 'src')
-rw-r--r--src/libstddjb/iopause_select.c8
-rw-r--r--src/sysdeps/tryselectshorttimeout.c41
2 files changed, 49 insertions, 0 deletions
diff --git a/src/libstddjb/iopause_select.c b/src/libstddjb/iopause_select.c
index 823f20b..863bea7 100644
--- a/src/libstddjb/iopause_select.c
+++ b/src/libstddjb/iopause_select.c
@@ -1,5 +1,6 @@
/* ISC license. */
+#include <skalibs/sysdeps.h>
#include <skalibs/bsdsnowflake.h>
#include <string.h> /* Solaris... */
@@ -29,6 +30,13 @@ int iopause_select (iopause_fd *x, unsigned int len, tain const *deadline, tain
if (errno != EOVERFLOW) return -1 ;
else deadline = 0 ;
}
+#ifdef SKALIBS_HASSELECTSHORTTIMEOUT
+ if (deadline && tv.tv_sec >= 100000000)
+ {
+ tv.tv_sec = 99999999 ;
+ tv.tv_usec = 0 ;
+ }
+#endif
}
for (unsigned int i = 0 ; i < len ; i++)
diff --git a/src/sysdeps/tryselectshorttimeout.c b/src/sysdeps/tryselectshorttimeout.c
new file mode 100644
index 0000000..9049079
--- /dev/null
+++ b/src/sysdeps/tryselectshorttimeout.c
@@ -0,0 +1,41 @@
+/* ISC license. */
+
+#undef _POSIX_C_SOURCE
+#undef _XOPEN_SOURCE
+
+#ifndef _BSD_SOURCE
+#define _BSD_SOURCE
+#endif
+#ifndef _NETBSD_SOURCE
+#define _NETBSD_SOURCE
+#endif
+#ifndef _DARWIN_C_SOURCE
+#define _DARWIN_C_SOURCE
+#endif
+
+#include <sys/types.h>
+#include <sys/time.h>
+#include <sys/select.h>
+#include <unistd.h>
+#include <signal.h>
+
+static void alrm_handler (int sig)
+{
+ (void)sig ;
+ _exit(1) ;
+}
+
+int main (void)
+{
+ struct sigaction action = { .sa_handler = &alrm_handler, .sa_flags = SA_NOCLDSTOP | SA_RESTART } ;
+ struct timeval tv = { .tv_sec = 100000000, .tv_usec = 0 } ;
+ fd_set r, w, x ;
+ FD_ZERO(&r) ;
+ FD_ZERO(&w) ;
+ FD_ZERO(&x) ;
+ sigfillset(&action.sa_mask) ;
+ if (sigaction(SIGALRM, &action, 0) == -1) _exit(111) ;
+ alarm(1) ;
+ if (select(1, &r, &w, &x, &tv) == -1) _exit(errno == EINVAL ? 0 : 111) ;
+ _exit(1) ;
+}