diff -Paur --no-dereference -- m4.upstream/lib/freadahead.c m4/lib/freadahead.c --- m4.upstream/lib/freadahead.c +++ m4/lib/freadahead.c @@ -30,6 +30,10 @@ /* This file is not used on systems that have the __freadahead function, namely musl libc. */ +#if defined(__sortix__) +#include +#endif + size_t freadahead (FILE *fp) { @@ -94,6 +98,10 @@ if (fp->state == 4 /* WR */ || fp->rp >= fp->wp) return 0; return fp->wp - fp->rp; +#elif defined __sortix__ + if ( !(fp->flags & _FILE_LAST_READ) ) + return 0; + return fp->amount_input_buffered - fp->offset_input_buffer; #elif defined SLOW_BUT_NO_HACKS /* users can define this */ abort (); return 0; diff -Paur --no-dereference -- m4.upstream/lib/spawn_faction_addclose.c m4/lib/spawn_faction_addclose.c --- m4.upstream/lib/spawn_faction_addclose.c +++ m4/lib/spawn_faction_addclose.c @@ -22,7 +22,9 @@ #include #include -#if !_LIBC +#if defined(__sortix__) +# define __sysconf(open_max) sysconf (open_max) +#elif !_LIBC # define __sysconf(open_max) getdtablesize () #endif diff -Paur --no-dereference -- m4.upstream/lib/spawn_faction_adddup2.c m4/lib/spawn_faction_adddup2.c --- m4.upstream/lib/spawn_faction_adddup2.c +++ m4/lib/spawn_faction_adddup2.c @@ -22,7 +22,9 @@ #include #include -#if !_LIBC +#if defined(__sortix__) +# define __sysconf(open_max) sysconf (open_max) +#elif !_LIBC # define __sysconf(open_max) getdtablesize () #endif diff -Paur --no-dereference -- m4.upstream/lib/spawn_faction_addopen.c m4/lib/spawn_faction_addopen.c --- m4.upstream/lib/spawn_faction_addopen.c +++ m4/lib/spawn_faction_addopen.c @@ -24,7 +24,9 @@ #include #include -#if !_LIBC +#if defined(__sortix__) +# define __sysconf(open_max) sysconf (open_max) +#elif !_LIBC # define __sysconf(open_max) getdtablesize () #endif diff -Paur --no-dereference -- m4.upstream/lib/spawni.c m4/lib/spawni.c --- m4.upstream/lib/spawni.c +++ m4/lib/spawni.c @@ -808,16 +808,20 @@ } #endif +#if !defined(__sortix__) /* Set the process group ID. */ if ((flags & POSIX_SPAWN_SETPGROUP) != 0 && setpgid (0, attrp->_pgrp) != 0) _exit (SPAWN_ERROR); +#endif +#if !defined(__sortix__) /* Set the effective user and group IDs. */ if ((flags & POSIX_SPAWN_RESETIDS) != 0 && (local_seteuid (getuid ()) != 0 || local_setegid (getgid ()) != 0)) _exit (SPAWN_ERROR); +#endif /* Execute the file actions. */ if (file_actions != NULL)