[m-rev.] diff: conditionalie references to EINTR

Simon Taylor stayl at cs.mu.OZ.AU
Sun Nov 10 00:19:55 AEDT 2002


Estimated hours taken: 1
Branches: main

Only refer to EINTR if it is defined.

runtime/mercury_std.h:
	Add a macro MR_is_eintr which tests whether its
	argument is EINTR, or returns false if EINTR
	not undefined.

trace/mercury_trace_internal.c:
compiler/process_util.m:
	Use MR_is_eintr.

Index: compiler/process_util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/process_util.m,v
retrieving revision 1.4
diff -u -u -r1.4 process_util.m
--- compiler/process_util.m	22 Jul 2002 07:13:03 -0000	1.4
+++ compiler/process_util.m	8 Nov 2002 15:38:24 -0000
@@ -354,7 +354,7 @@
 			Status = child_status;
 			break;
 		    } else if (wait_status == -1) {
-			if (errno == EINTR) {
+			if (MR_is_eintr(errno)) {
 			    if (MC_signalled) {
 				/*
 				** A normally fatal signal has been received,
Index: runtime/mercury_std.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_std.h,v
retrieving revision 1.23
diff -u -u -r1.23 mercury_std.h
--- runtime/mercury_std.h	14 Oct 2002 03:19:58 -0000	1.23
+++ runtime/mercury_std.h	8 Nov 2002 15:38:29 -0000
@@ -17,6 +17,7 @@
 #ifndef IN_GCC
   #include <ctype.h>	/* for isalnum(), etc. */
 #else
+#include <errno.h>
   /*
   ** When building compiler/gcc.m, we #include GCC back-end
   ** header files that include libiberty's "safe-ctype.h",
@@ -78,6 +79,14 @@
   #define MR_assert(ASSERTION)	assert(ASSERTION)
 #else
   #define MR_assert(ASSERTION)	((void)0)
+#endif
+
+/*---------------------------------------------------------------------------*/
+
+#ifdef EINTR
+  #define MR_is_eintr(x)	((x) == EINTR)
+#else
+  #define MR_is_eintr(x)	MR_FALSE
 #endif
 
 /*---------------------------------------------------------------------------*/
Index: trace/mercury_trace_internal.c
===================================================================
RCS file: /home/mercury1/repository/mercury/trace/mercury_trace_internal.c,v
retrieving revision 1.148
diff -u -u -r1.148 mercury_trace_internal.c
--- trace/mercury_trace_internal.c	8 Nov 2002 08:48:23 -0000	1.148
+++ trace/mercury_trace_internal.c	9 Nov 2002 12:32:58 -0000
@@ -882,15 +882,20 @@
 		MR_setup_signal_no_restart(SIGALRM,
 			MR_trace_internal_alarm_handler, MR_FALSE,
 			"error setting up alarm handler");
+		MR_got_alarm = MR_FALSE;
 		alarm(10);	/* 10 second timeout */
 		while (1) {
 			char c;
 			int status;
 			status = read(slave_fd, &c, 1);
 			if (status == -1) {
-				if (errno != EINTR || MR_got_alarm) {
+				if (MR_got_alarm) {
+					MR_mdb_warning(
+					    "timeout starting mdb window");
+					goto parent_error;
+				} else if (!MR_is_eintr(errno)) {
 					MR_mdb_perror(
-					"error reading from mdb window");
+					    "error reading from mdb window");
 					goto parent_error;
 				}
 			} else if (status == 0 || c == '\n') {
@@ -973,7 +978,7 @@
 		if (status != -1) {
 			do {
 				status = wait(NULL);
-				if (status == -1 && errno != EINTR) {
+				if (status == -1 && !MR_is_eintr(errno)) {
 					break;
 				}
 			} while (status != MR_mdb_window_pid);
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list