Re: [PATCH] Portability of dash to legacy systems, such as AT&T Unix PC : 14-broken-wait-h

Alain Knaff <[email protected]> Tue, 12 Nov 2024 23:51:20 +0100
Newsgroups org.kernel.vger.dash
Message-ID <[email protected]>
Hi,

UnixPC ships with a wait.h for the wrong endianness.

This patch provides a local replacement (triggered by absence
WEXITSTATUS flag)

After having applied the patches until and including this one, it should
compile for UnixPC, but not yet work. The next couple of patches address
issues that only become apparent at runtime or optional features.

Regards,

Alain
dash-0.5.12+14-broken-wait-h.diff (text/x-patch, 1.4 KB)
diff -X ../exclude.txt -urN dash-0.5.12+13-wait3-replacement/src/system.h dash-0.5.12+14-broken-wait-h/src/system.h
--- dash-0.5.12+13-wait3-replacement/src/system.h	2024-11-10 14:53:08.418618090 +0000
+++ dash-0.5.12+14-broken-wait-h/src/system.h	2024-11-10 14:53:08.422618183 +0000
@@ -167,6 +167,42 @@
 # define FD_CLOEXEC 1
 #endif
 
+#ifndef WEXITSTATUS
+
+/* If WIFEXITED(STATUS), the low-order 8 bits of the status.  */
+#undef WEXITSTATUS
+#define	WEXITSTATUS(status)	(((status) & 0xff00) >> 8)
+
+/* If WIFSIGNALED(STATUS), the terminating signal.  */
+#undef WTERMSIG
+#define	WTERMSIG(status)	((status) & 0x7f)
+
+/* If WIFSTOPPED(STATUS), the signal that stopped the child.  */
+#undef WSTOPSIG
+#define	WSTOPSIG(status)	WEXITSTATUS(status)
+
+/* Nonzero if STATUS indicates normal termination.  */
+#undef WIFEXITED
+#define	WIFEXITED(status)	(WTERMSIG(status) == 0)
+
+/* Nonzero if STATUS indicates termination by a signal.  */
+#undef WIFSIGNALED
+#define WIFSIGNALED(status) \
+  (((signed char) (((status) & 0x7f) + 1) >> 1) > 0)
+
+/* Nonzero if STATUS indicates the child is stopped.  */
+#undef WIFSTOPPED
+#define	WIFSTOPPED(status)	(((status) & 0xff) == 0x7f)
+
+/* Nonzero if STATUS indicates the child dumped core.  */
+#undef WCOREDUMP
+#ifndef WCOREFLAG
+# define	WCOREFLAG		0x80
+#endif
+#define	WCOREDUMP(status)	((status) & WCOREFLAG)
+
+#endif
+
 #ifndef HAVE_STRSTR
 extern char * strstr (const char* haystack, const char *needle);
 #endif