[Ada] adjustments for a powerpc-xcoff-lynxos port

Arnaud Charlet charlet@adacore.com
Thu Sep 27 14:48:00 GMT 2007


Tested on i686-linux, committed on trunk

The first part of this change addresses the fact that utime.h on Lynxos 3
only defines the entities we need if defined (VMOS_DEV).

The second part is to prevent errors from the indirect inclusion of GCC's
resource.h instead of the Lynxos version via the Lynxos wait.h header file.
This is a workaround: the header files conflict should be addressed in a
cleaner way at some point.

2007-09-26  Olivier Hainque  <hainque@adacore.com>

	* adaint.c (if defined (__Lynx__)): Wrap #def/#undef VMOS_DEV around
	#include <utime.h> and #define GCC_RESOURCE_H before
	#include <sys/wait.h>.
	Add more protections in __gnat_translate_vms.

	* expect.c (if defined (__Lynx__)): #define GCC_RESOURCE_H before
	#include <sys/wait.h>.

-------------- next part --------------
Index: adaint.c
===================================================================
--- adaint.c	(revision 128777)
+++ adaint.c	(working copy)
@@ -76,14 +76,22 @@
 #include "version.h"
 #endif
 
-#ifdef __MINGW32__
+#if defined (__MINGW32__)
+
 #include "mingw32.h"
 #include <sys/utime.h>
 #include <ctype.h>
-#else
-#ifndef VMS
+
+#elif defined (__Lynx__)
+
+/* Lynx utime.h only defines the entities of interest to us if
+   defined (VMOS_DEV), so ... */
+#define VMOS_DEV
+#include <utime.h>
+#undef VMOS_DEV
+
+#elif !defined (VMS)
 #include <utime.h>
-#endif
 #endif
 
 #ifdef __MINGW32__
@@ -92,6 +100,14 @@
 #endif
 #elif defined (__vxworks) && defined (__RTP__)
 #include <wait.h>
+#elif defined (__Lynx__)
+/* ??? We really need wait.h and it includes resource.h on Lynx.  GCC
+   has a resource.h header as well, included instead of the lynx
+   version in our setup, causing lots of errors.  We don't really need
+   the lynx contents of this file, so just workaround the issue by
+   preventing the inclusion of the GCC header from doing anything.  */
+#define GCC_RESOURCE_H
+#include <sys/wait.h>
 #else
 #include <sys/wait.h>
 #endif
@@ -2430,8 +2446,8 @@ __gnat_translate_vms (char *src)
         *(retpos++) = '.';
       }
 
-      /* There is qualified path */
-      while (*pos1 != ']' && *pos1 != '>') {
+      /* There is a qualified path */
+      while (*pos1 && *pos1 != ']' && *pos1 != '>') {
         switch (*pos1) {
           case '.':
             /* '.' is used to separate directories. Replace it with '/' but
@@ -2445,13 +2461,18 @@ __gnat_translate_vms (char *src)
             }
             break;
           case '-' :
-            /* Equivalent to Unix .. but there may be several in a row */
-            while (*pos1 == '-') {
-              pos1++;
-              *(retpos++) = '.'; *(retpos++) = '.'; *(retpos++) = '/';
+            /* When after '.' '[' '<' is equivalent to Unix ".." but there
+            may be several in a row */
+            if (*(pos1 - 1) == '.' || *(pos1 - 1) == '[' ||
+                *(pos1 - 1) == '<') {
+              while (*pos1 == '-') {
+                pos1++;
+                *(retpos++) = '.'; *(retpos++) = '.'; *(retpos++) = '/';
+              }
+              retpos--;
+              break;
             }
-            retpos--;
-            break;
+            /* otherwise fall through to default */
           default:
             *(retpos++) = *(pos1++);
         }
@@ -2540,7 +2561,7 @@ __gnat_to_canonical_file_spec (char *fil
 
   if (strchr (filespec, ']') || strchr (filespec, ':'))
     {
-      char *tspec = (char *) decc$translate_vms (filespec);
+      char *tspec = (char *) __gnat_translate_vms (filespec);
 
       if (tspec != (char *) -1)
 	strncpy (new_canonical_filespec, tspec, MAXPATH);
@@ -2549,7 +2570,7 @@ __gnat_to_canonical_file_spec (char *fil
 	    "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_"))
 	&& (filespec1 = getenv (filespec)))
     {
-      char *tspec = (char *) decc$translate_vms (filespec1);
+      char *tspec = (char *) __gnat_translate_vms (filespec1);
 
       if (tspec != (char *) -1)
 	strncpy (new_canonical_filespec, tspec, MAXPATH);
Index: expect.c
===================================================================
--- expect.c	(revision 128777)
+++ expect.c	(working copy)
@@ -6,7 +6,7 @@
  *                                                                          *
  *                          C Implementation File                           *
  *                                                                          *
- *                     Copyright (C) 2001-2005, AdaCore                     *
+ *                     Copyright (C) 2001-2007, AdaCore                     *
  *                                                                          *
  * GNAT is free software;  you can  redistribute it  and/or modify it under *
  * terms of the  GNU General Public License as published  by the Free Soft- *
@@ -51,6 +51,10 @@
 #endif
 #elif defined (__vxworks) && defined (__RTP__)
 #include <wait.h>
+#elif defined (__Lynx__)
+/* ??? See comment in adaint.c.  */
+#define GCC_RESOURCE_H
+#include <sys/wait.h>
 #else
 #include <sys/wait.h>
 #endif


More information about the Gcc-patches mailing list