This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix Ada bootstrap on newlib platforms (PR40578)


    Hi again,

  Following on from yesterday's thread(*), here is the (respun) patch to
rename the clashing macro definitions in adaint.h with a GNAT_ prefix.  It has
now completed bootstrap.

  Tests haven't finished running, but have gone far enough to see it's
basically working rather than massively failing, and since this bug prevented
bootstrap it's not like we have 'before' results to compare against anyway :)
 I'll post them to -testresults when they're done.

gcc/ada/ChangeLog:

	PR bootstrap/40578
	* adaint.h (FOPEN, STAT, FSTAT, LSTAT, STRUCT_STAT): Rename from these
	(GNAT_FOPEN, GNAT_STAT, GNAT_FSTAT, GNAT_LSTAT, GNAT_STRUCT_STAT): ...
	to these.
	(__gnat_stat): Adjust reference to STAT in prototype.
	* adaint.c (__gnat_try_lock, __gnat_fopen, __gnat_file_length,
	__gnat_named_file_length, __gnat_file_time_name, __gnat_file_time_fd,
	__gnat_get_libraries_from_registry, __gnat_stat, __gnat_file_exists,
	__gnat_is_regular_file, __gnat_is_directory, __gnat_is_readable_file,
	__gnat_is_writable_file, __gnat_is_executable_file,
	__gnat_set_writable, __gnat_set_executable, __gnat_set_non_writable,
	__gnat_set_readable, __gnat_set_non_readable, __gnat_is_symbolic_link,
	__gnat_copy_attribs): Adjust all references to the above.
	* cstreams.c (__gnat_is_regular_file_fd): Likewise.

  OK?

    cheers,
      DaveK
-- 
(*) - http://gcc.gnu.org/ml/gcc/2009-07/threads.html#00509

Index: gcc/ada/adaint.c
===================================================================
--- gcc/ada/adaint.c	(revision 149338)
+++ gcc/ada/adaint.c	(working copy)
@@ -520,7 +520,7 @@ __gnat_try_lock (char *dir, char *file)
 {
   char full_path[256];
   char temp_file[256];
-  STRUCT_STAT stat_result;
+  GNAT_STRUCT_STAT stat_result;
   int fd;
 
   sprintf (full_path, "%s%c%s", dir, DIR_SEPARATOR, file);
@@ -775,7 +775,7 @@ __gnat_fopen (char *path, char *mode, int encoding
 #elif defined (VMS)
   return decc$fopen (path, mode);
 #else
-  return FOPEN (path, mode);
+  return GNAT_FOPEN (path, mode);
 #endif
 }
 
@@ -1019,9 +1019,9 @@ long
 __gnat_file_length (int fd)
 {
   int ret;
-  STRUCT_STAT statbuf;
+  GNAT_STRUCT_STAT statbuf;
 
-  ret = FSTAT (fd, &statbuf);
+  ret = GNAT_FSTAT (fd, &statbuf);
   if (ret || !S_ISREG (statbuf.st_mode))
     return 0;
 
@@ -1038,7 +1038,7 @@ long
 __gnat_named_file_length (char *name)
 {
   int ret;
-  STRUCT_STAT statbuf;
+  GNAT_STRUCT_STAT statbuf;
 
   ret = __gnat_stat (name, &statbuf);
   if (ret || !S_ISREG (statbuf.st_mode))
@@ -1269,7 +1269,7 @@ __gnat_file_time_name (char *name)
     }
   return (OS_Time) ret;
 #else
-  STRUCT_STAT statbuf;
+  GNAT_STRUCT_STAT statbuf;
   if (__gnat_stat (name, &statbuf) != 0) {
      return (OS_Time)-1;
   } else {
@@ -1361,9 +1361,9 @@ __gnat_file_time_fd (int fd)
   return (OS_Time) ret;
 
 #else
-  STRUCT_STAT statbuf;
+  GNAT_STRUCT_STAT statbuf;
 
-  if (FSTAT (fd, &statbuf) != 0) {
+  if (GNAT_FSTAT (fd, &statbuf) != 0) {
      return (OS_Time) -1;
   } else {
 #ifdef VMS
@@ -1651,7 +1651,7 @@ __gnat_get_libraries_from_registry (void)
 }
 
 int
-__gnat_stat (char *name, STRUCT_STAT *statbuf)
+__gnat_stat (char *name, GNAT_STRUCT_STAT *statbuf)
 {
 #ifdef __MINGW32__
   /* Under Windows the directory name for the stat function must not be
@@ -1683,7 +1683,7 @@ int
   return _tstat (wname, (struct _stat *)statbuf);
 
 #else
-  return STAT (name, statbuf);
+  return GNAT_STAT (name, statbuf);
 #endif
 }
 
@@ -1699,7 +1699,7 @@ __gnat_file_exists (char *name)
   S2WSC (wname, name, GNAT_MAX_PATH_LEN + 2);
   return GetFileAttributes (wname) != INVALID_FILE_ATTRIBUTES;
 #else
-  STRUCT_STAT statbuf;
+  GNAT_STRUCT_STAT statbuf;
 
   return !__gnat_stat (name, &statbuf);
 #endif
@@ -1744,7 +1744,7 @@ int
 __gnat_is_regular_file (char *name)
 {
   int ret;
-  STRUCT_STAT statbuf;
+  GNAT_STRUCT_STAT statbuf;
 
   ret = __gnat_stat (name, &statbuf);
   return (!ret && S_ISREG (statbuf.st_mode));
@@ -1754,7 +1754,7 @@ int
 __gnat_is_directory (char *name)
 {
   int ret;
-  STRUCT_STAT statbuf;
+  GNAT_STRUCT_STAT statbuf;
 
   ret = __gnat_stat (name, &statbuf);
   return (!ret && S_ISDIR (statbuf.st_mode));
@@ -1972,9 +1972,9 @@ __gnat_is_readable_file (char *name)
 #else
   int ret;
   int mode;
-  STRUCT_STAT statbuf;
+  GNAT_STRUCT_STAT statbuf;
 
-  ret = STAT (name, &statbuf);
+  ret = GNAT_STAT (name, &statbuf);
   mode = statbuf.st_mode & S_IRUSR;
   return (!ret && mode);
 #endif
@@ -2004,9 +2004,9 @@ __gnat_is_writable_file (char *name)
 #else
   int ret;
   int mode;
-  STRUCT_STAT statbuf;
+  GNAT_STRUCT_STAT statbuf;
 
-  ret = STAT (name, &statbuf);
+  ret = GNAT_STAT (name, &statbuf);
   mode = statbuf.st_mode & S_IWUSR;
   return (!ret && mode);
 #endif
@@ -2034,9 +2034,9 @@ __gnat_is_executable_file (char *name)
 #else
   int ret;
   int mode;
-  STRUCT_STAT statbuf;
+  GNAT_STRUCT_STAT statbuf;
 
-  ret = STAT (name, &statbuf);
+  ret = GNAT_STAT (name, &statbuf);
   mode = statbuf.st_mode & S_IXUSR;
   return (!ret && mode);
 #endif
@@ -2056,9 +2056,9 @@ __gnat_set_writable (char *name)
   SetFileAttributes
     (wname, GetFileAttributes (wname) & ~FILE_ATTRIBUTE_READONLY);
 #elif ! defined (__vxworks) && ! defined(__nucleus__)
-  STRUCT_STAT statbuf;
+  GNAT_STRUCT_STAT statbuf;
 
-  if (STAT (name, &statbuf) == 0)
+  if (GNAT_STAT (name, &statbuf) == 0)
     {
       statbuf.st_mode = statbuf.st_mode | S_IWUSR;
       chmod (name, statbuf.st_mode);
@@ -2078,9 +2078,9 @@ __gnat_set_executable (char *name)
     __gnat_set_OWNER_ACL (wname, GRANT_ACCESS, FILE_GENERIC_EXECUTE);
 
 #elif ! defined (__vxworks) && ! defined(__nucleus__)
-  STRUCT_STAT statbuf;
+  GNAT_STRUCT_STAT statbuf;
 
-  if (STAT (name, &statbuf) == 0)
+  if (GNAT_STAT (name, &statbuf) == 0)
     {
       statbuf.st_mode = statbuf.st_mode | S_IXUSR;
       chmod (name, statbuf.st_mode);
@@ -2105,9 +2105,9 @@ __gnat_set_non_writable (char *name)
   SetFileAttributes
     (wname, GetFileAttributes (wname) | FILE_ATTRIBUTE_READONLY);
 #elif ! defined (__vxworks) && ! defined(__nucleus__)
-  STRUCT_STAT statbuf;
+  GNAT_STRUCT_STAT statbuf;
 
-  if (STAT (name, &statbuf) == 0)
+  if (GNAT_STAT (name, &statbuf) == 0)
     {
       statbuf.st_mode = statbuf.st_mode & 07577;
       chmod (name, statbuf.st_mode);
@@ -2127,9 +2127,9 @@ __gnat_set_readable (char *name)
     __gnat_set_OWNER_ACL (wname, GRANT_ACCESS, FILE_GENERIC_READ);
 
 #elif ! defined (__vxworks) && ! defined(__nucleus__)
-  STRUCT_STAT statbuf;
+  GNAT_STRUCT_STAT statbuf;
 
-  if (STAT (name, &statbuf) == 0)
+  if (GNAT_STAT (name, &statbuf) == 0)
     {
       chmod (name, statbuf.st_mode | S_IREAD);
     }
@@ -2148,9 +2148,9 @@ __gnat_set_non_readable (char *name)
     __gnat_set_OWNER_ACL (wname, DENY_ACCESS, FILE_GENERIC_READ);
 
 #elif ! defined (__vxworks) && ! defined(__nucleus__)
-  STRUCT_STAT statbuf;
+  GNAT_STRUCT_STAT statbuf;
 
-  if (STAT (name, &statbuf) == 0)
+  if (GNAT_STAT (name, &statbuf) == 0)
     {
       chmod (name, statbuf.st_mode & (~S_IREAD));
     }
@@ -2165,9 +2165,9 @@ __gnat_is_symbolic_link (char *name ATTRIBUTE_UNUS
 
 #elif defined (_AIX) || defined (__APPLE__) || defined (__unix__)
   int ret;
-  STRUCT_STAT statbuf;
+  GNAT_STRUCT_STAT statbuf;
 
-  ret = LSTAT (name, &statbuf);
+  ret = GNAT_LSTAT (name, &statbuf);
   return (!ret && S_ISLNK (statbuf.st_mode));
 
 #else
@@ -3435,10 +3435,10 @@ __gnat_copy_attribs (char *from, char *to, int mod
   return 0;
 
 #else
-  STRUCT_STAT fbuf;
+  GNAT_STRUCT_STAT fbuf;
   struct utimbuf tbuf;
 
-  if (STAT (from, &fbuf) == -1)
+  if (GNAT_STAT (from, &fbuf) == -1)
     {
       return -1;
     }
Index: gcc/ada/adaint.h
===================================================================
--- gcc/ada/adaint.h	(revision 149338)
+++ gcc/ada/adaint.h	(working copy)
@@ -49,17 +49,17 @@
    tested.  */
 
 #if defined (__GLIBC__) || defined (sun)  || defined (__sgi)
-#define FOPEN fopen64
-#define STAT stat64
-#define FSTAT fstat64
-#define LSTAT lstat64
-#define STRUCT_STAT struct stat64
+#define GNAT_FOPEN fopen64
+#define GNAT_STAT stat64
+#define GNAT_FSTAT fstat64
+#define GNAT_LSTAT lstat64
+#define GNAT_STRUCT_STAT struct stat64
 #else
-#define FOPEN fopen
-#define STAT stat
-#define FSTAT fstat
-#define LSTAT lstat
-#define STRUCT_STAT struct stat
+#define GNAT_FOPEN fopen
+#define GNAT_STAT stat
+#define GNAT_FSTAT fstat
+#define GNAT_LSTAT lstat
+#define GNAT_STRUCT_STAT struct stat
 #endif
 
 typedef long OS_Time; /* Type corresponding to GNAT.OS_Lib.OS_Time */
@@ -89,7 +89,7 @@ extern int    __gnat_open_new
 extern int    __gnat_open_new_temp		   (char *, int);
 extern int    __gnat_mkdir			   (char *);
 extern int    __gnat_stat			   (char *,
-						    STRUCT_STAT *);
+						    GNAT_STRUCT_STAT *);
 extern int    __gnat_unlink                        (char *);
 extern int    __gnat_rename                        (char *, char *);
 extern int    __gnat_chdir                         (char *);
Index: gcc/ada/cstreams.c
===================================================================
--- gcc/ada/cstreams.c	(revision 149338)
+++ gcc/ada/cstreams.c	(working copy)
@@ -96,7 +96,7 @@ int
 __gnat_is_regular_file_fd (int fd)
 {
   int ret;
-  STRUCT_STAT statbuf;
+  GNAT_STRUCT_STAT statbuf;
 
 #ifdef __EMX__
   /* Programs using screen I/O may need to reset the FPU after
@@ -107,7 +107,7 @@ __gnat_is_regular_file_fd (int fd)
   __gnat_init_float();
 #endif
 
-  ret = FSTAT (fd, &statbuf);
+  ret = GNAT_FSTAT (fd, &statbuf);
   return (!ret && S_ISREG (statbuf.st_mode));
 }
 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]