bug-gawk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-gawk] Gawk compile error Mingw32


From: Eli Zaretskii
Subject: Re: [bug-gawk] Gawk compile error Mingw32
Date: Thu, 07 Apr 2016 19:55:20 +0300

> From: address@hidden (Vincent Belaïche)
> Cc:  Eli Zaretskii <address@hidden>, address@hidden
> Date: Thu, 07 Apr 2016 11:57:24 +0200
> 
> I had the same problem as Ivan, so I got the latest source from the git
> repo after seeing that Eli had provided some patch. And it still does
> not compile (MSW 10, GCC MinGW 32bits). I have not tried with the 64bits
> compiler chain. See attached log.

I fixed the WIF* problem in the repository (the patch is repeated
below).

As for the usleep problem, you will have to look at the cpp
conditionals that guard its definition in gawkmisc.pc, and figure out
why they don't work in your case.  I cannot do it from here,
especially since you didn't tell which version of MinGW runtime are
you using and where did you download it from.

HTH


--- builtin.c~0 2016-04-06 06:33:26.000000000 +0300
+++ builtin.c   2016-04-07 19:27:53.553000000 +0300
@@ -2101,7 +2101,11 @@
                        if (do_posix)
                                ;       /* leave it alone, full 16 bits */
                        else if (do_traditional)
+#ifdef __MINGW32__
+                               ret = (((unsigned)status) & ~0xC0000000);
+#else
                                ret = (status / 256.0);
+#endif
                        else if (WIFEXITED(status))
                                ret = WEXITSTATUS(status); /* normal exit */
                        else if (WIFSIGNALED(status)) {
--- nonposix.h~0        2015-04-05 11:13:50.000000000 +0300
+++ nonposix.h  2016-04-07 19:31:36.318625000 +0300
@@ -29,3 +29,18 @@
  */
 
 #define FAKE_FD_VALUE 42
+
+#ifdef __MINGW32__
+/* Replacements for sys/wait.h macros.  */
+# define WEXITSTATUS(stv) (((unsigned)(stv)) & ~0xC0000000)
+/* MS-Windows programs that crash due to a fatal exception exit with
+   an exit code whose 2 MSB bits are set.  */
+# define WIFEXITED(stv)   ((((unsigned)(stv)) & 0xC0000000) == 0)
+# define WIFSIGNALED(stv) ((((unsigned)(stv)) & 0xC0000000) == 0xC0000000)
+# define WTERMSIG(stv)    w32_status_to_termsig ((unsigned)stv)
+# define WIFSTOPPED(stv)  (0)
+# define WSTOPSIG(stv)    (0)
+
+int w32_status_to_termsig (unsigned);
+
+#endif
--- pc/config.sed~0     2015-04-05 11:13:50.000000000 +0300
+++ pc/config.sed       2016-04-07 19:30:43.303000000 +0300
@@ -297,8 +297,4 @@
 #if defined(__EMX__)\
 #define strcasecmp stricmp\
 #define strncasecmp strnicmp\
-#endif\
-\
-#if defined(__MINGW32__)\
-# define WEXITSTATUS(stat_val)  ((stat_val) & ~0xC0000000)\
 #endif
--- pc/gawkmisc.pc~0    2016-03-21 22:05:58.000000000 +0200
+++ pc/gawkmisc.pc      2016-04-07 19:18:08.928000000 +0300
@@ -852,6 +852,50 @@
 
 #endif /* HAVE_SOCKETS */
 
+/* Translate abnormal exit status of Windows programs into the signal
+   that terminated the program.  This is required to support scm_kill
+   and WTERMSIG.  */
+
+#include <signal.h>
+
+struct signal_and_status {
+  int sig;
+  unsigned status;
+};
+
+static const struct signal_and_status sigtbl[] = {
+  {SIGSEGV, 0xC0000005},       /* access to invalid address */
+  {SIGSEGV, 0xC0000008},       /* invalid handle */
+  {SIGILL,  0xC000001D},       /* illegal instruction */
+  {SIGILL,  0xC0000025},       /* non-continuable instruction */
+  {SIGSEGV, 0xC000008C},       /* array bounds exceeded */
+  {SIGFPE,  0xC000008D},       /* float denormal */
+  {SIGFPE,  0xC000008E},       /* float divide by zero */
+  {SIGFPE,  0xC000008F},       /* float inexact */
+  {SIGFPE,  0xC0000090},       /* float invalid operation */
+  {SIGFPE,  0xC0000091},       /* float overflow */
+  {SIGFPE,  0xC0000092},       /* float stack check */
+  {SIGFPE,  0xC0000093},       /* float underflow */
+  {SIGFPE,  0xC0000094},       /* integer divide by zero */
+  {SIGFPE,  0xC0000095},       /* integer overflow */
+  {SIGILL,  0xC0000096},       /* privileged instruction */
+  {SIGSEGV, 0xC00000FD},       /* stack overflow */
+  {SIGTERM, 0xC000013A},       /* Ctrl-C exit */
+  {SIGINT,  0xC000013A}
+};
+
+int
+w32_status_to_termsig (unsigned status)
+{
+  int i;
+
+  for (i = 0; i < sizeof (sigtbl) / sizeof (sigtbl[0]); i++)
+    if (status == sigtbl[i].status)
+      return sigtbl[i].sig;
+
+  return SIGTERM;
+}
+
 #endif /* __MINGW32__ */
 
 #if defined(__DJGPP__) || defined(__MINGW32__) || defined(__EMX__)
--- pc/config.h~        2016-04-06 06:35:54.000000000 +0300
+++ pc/config.h 2016-04-07 19:31:42.849875000 +0300
@@ -633,7 +633,3 @@
 #define strcasecmp stricmp
 #define strncasecmp strnicmp
 #endif
-
-#if defined(__MINGW32__)
-# define WEXITSTATUS(stat_val)  ((stat_val) & ~0xC0000000)
-#endif



reply via email to

[Prev in Thread] Current Thread [Next in Thread]