This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Ada; Patch to ada/adint.c (mingw32)
- From: Danny Smith <danny_r_smith_2001 at yahoo dot co dot nz>
- To: GCC Patches <gcc-patches at gcc dot gnu dot org>, Geert Bosch <bosch at gnat dot com>
- Date: Fri, 21 Dec 2001 14:39:24 +1100 (EST)
- Subject: Ada; Patch to ada/adint.c (mingw32)
The following patch to ada/adaint.c allows Gnat to build under mingw32
with current mingw headers and libs. Note there is duplicated code in
the original adaint.c at about line 310 with this comment:
/* More cases that do not use link; identical code, to solve too long
line problem ??? */
I have left the duplication in because I do know if the reason for it is
still valid. I have, however reorganised the duplication slighty to use
the HAVE_DOS_BASED_FILE_SYSTEM define. The duplication is easy enough to
clean up.
Bootstrapped and make gnatlib_and_tools on i586-pc-mingw32.
Changelog
2001-12-20 Danny Smith <daanysmith@users.sourceforge.net>
* ada/adaint.h (__gnat_plist_init): Add prototype for _WIN32.
* ada/adaint.c: Don't include sys/wait.h if __MINGW32__.
(HAVE_DOS_BASED_FILE_SYSTEM): Define if necessary for
__EMX__, MSDOS, and _WIN32. Use throughout to check for
DOS-based filesystems.
(IS_DIR_SEPARATOR): Define if necessary. Use throughout for
testing for dir separators.
Include ctype.h for DOS-based filesystems.
(plist_leave, remove_handle): Make static.
(win32_filetime, win32_no_block_spawn, win32_wait, remove_handle,
add_handle, plist_enter, plist_leave: Add prototypes.
Don't use POSIX file permission masks if __MINGW32__.
Remove duplicate include of windows.h.
Index: ada/adaint.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/ada/adaint.c,v
retrieving revision 1.6
diff -u -p -r1.6 adaint.c
--- adaint.c 2001/12/16 00:56:17 1.6
+++ adaint.c 2001/12/20 18:52:37
@@ -65,9 +65,17 @@
#include "config.h"
#include "system.h"
#endif
+
+#if !defined __MINGW32__
#include <sys/wait.h>
+#endif
#if defined (__EMX__) || defined (MSDOS) || defined (_WIN32)
+#include <process.h>
+#include <ctype.h> /* for isalpha() */
+#ifndef HAVE_DOS_BASED_FILE_SYSTEM
+#define HAVE_DOS_BASED_FILE_SYSTEM 1
+#endif
#elif defined (VMS)
/* Header files and definitions for __gnat_set_file_time_name. */
@@ -117,13 +125,17 @@ struct vstring
#include <utime.h>
#endif
-#if defined (__EMX__) || defined (MSDOS) || defined (_WIN32)
-#include <process.h>
-#endif
-
#if defined (_WIN32)
#include <dir.h>
#include <windows.h>
+static time_t win32_filetime PARAMS ((HANDLE));
+static int win32_no_block_spawn PARAMS ((char *, char **));
+static int win32_wait PARAMS ((int *));
+static void remove_handle PARAMS ((HANDLE));
+static void add_handle PARAMS ((HANDLE));
+static void plist_enter PARAMS ((void));
+static void plist_leave PARAMS ((void));
+
#endif
#include "adaint.h"
@@ -166,6 +178,16 @@ struct vstring
#define DIR_SEPARATOR '/'
#endif
+/* Define IS_DIR_SEPARATOR. */
+#ifndef IS_DIR_SEPARATOR
+# ifndef DIR_SEPARATOR_2
+# define IS_DIR_SEPARATOR(CH) ((CH) == DIR_SEPARATOR)
+# else /* DIR_SEPARATOR_2 */
+# define IS_DIR_SEPARATOR(CH) \
+ (((CH) == DIR_SEPARATOR) || ((CH) == DIR_SEPARATOR_2))
+# endif /* DIR_SEPARATOR_2 */
+#endif /* IS_DIR_SEPARATOR */
+
char __gnat_dir_separator = DIR_SEPARATOR;
char __gnat_path_separator = PATH_SEPARATOR;
@@ -243,7 +265,7 @@ __gnat_to_gm_time (p_time, p_year, p_mon
/* Place the contents of the symbolic link named PATH in the buffer BUF,
which has size BUFSIZ. If PATH is a symbolic link, then return the
number
of characters of its content in BUF. Otherwise, return -1. For
Windows,
- OS/2 and vxworks, always return -1. */
+ OS/2 and vxworks, always return -1. CYGWIN supports symlinks. */
int
__gnat_readlink (path, buf, bufsiz)
@@ -251,7 +273,7 @@ __gnat_readlink (path, buf, bufsiz)
char *buf;
size_t bufsiz;
{
-#if defined (MSDOS) || defined (_WIN32) || defined (__EMX__)
+#if defined (HAVE_DOS_BASED_FILE_SYSTEM) && !defined (__CYGWIN__)
return -1;
#elif defined (__INTERIX) || defined (VMS)
return -1;
@@ -272,7 +294,7 @@ __gnat_symlink (oldpath, newpath)
char *oldpath;
char *newpath;
{
-#if defined (MSDOS) || defined (_WIN32) || defined (__EMX__)
+#if defined (HAVE_DOS_BASED_FILE_SYSTEM) && !defined (__CYGWIN__)
return -1;
#elif defined (__INTERIX) || defined (VMS)
return -1;
@@ -285,7 +307,7 @@ __gnat_symlink (oldpath, newpath)
/* Try to lock a file, return 1 if success */
-#if defined (__vxworks) || defined (MSDOS) || defined (_WIN32)
+#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
/* Version that does not use link. */
@@ -306,7 +328,7 @@ __gnat_try_lock (dir, file)
return 1;
}
-#elif defined (__EMX__) || defined (VMS)
+#elif defined (__vxworks) || defined (VMS)
/* More cases that do not use link; identical code, to solve too long
line problem ??? */
@@ -396,7 +418,7 @@ __gnat_get_switch_character ()
int
__gnat_get_file_names_case_sensitive ()
{
-#if defined (__EMX__) || defined (MSDOS) || defined (VMS) ||
defined(WINNT)
+#if defined (HAVE_DOS_BASED_FILE_SYSTEM) || defined (VMS)
return 0;
#else
return 1;
@@ -513,7 +535,7 @@ __gnat_open_read (path, fmode)
return fd < 0 ? -1 : fd;
}
-#if defined (__EMX__)
+#if defined (__EMX__) || defined (__MINGW32__)
#define PERM (S_IREAD | S_IWRITE)
#else
#define PERM (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)
@@ -1220,10 +1242,6 @@ __gnat_set_env_value (name, value)
#endif
}
-#ifdef _WIN32
-#include <windows.h>
-#endif
-
/* Get the list of installed standard libraries from the
HKEY_LOCAL_MACHINE\SOFTWARE\Ada Core Technologies\GNAT\Standard
Libraries
key. */
@@ -1327,9 +1345,9 @@ int
__gnat_is_absolute_path (name)
char *name;
{
- return (*name == '/' || *name == DIR_SEPARATOR
-#if defined(__EMX__) || defined(MSDOS) || defined(WINNT)
- || strlen (name) > 1 && isalpha (name [0]) && name [1] == ':'
+ return ((*name == '/') || IS_DIR_SEPARATOR (*name)
+#if defined(HAVE_DOS_BASED_FILE_SYSTEM)
+ || (strlen (name) > 1 && isalpha (name [0]) && name [1] == ':')
#endif
);
}
@@ -1450,7 +1468,7 @@ plist_enter ()
EnterCriticalSection (&plist_cs);
}
-void
+static void
plist_leave ()
{
LeaveCriticalSection (&plist_cs);
@@ -1486,7 +1504,7 @@ add_handle (h)
plist_leave();
}
-void remove_handle (h)
+static void remove_handle (h)
HANDLE h;
{
Process_List *pl, *prev;
@@ -1715,12 +1733,13 @@ __gnat_locate_regular_file (file_name, p
char *ptr;
/* Handle absolute pathnames. */
- for (ptr = file_name; *ptr && *ptr != '/' && *ptr != DIR_SEPARATOR;
ptr++)
+ for (ptr = file_name;
+ *ptr && *ptr != '/' && !IS_DIR_SEPARATOR (*ptr); ptr++)
;
if (*ptr != 0
-#if defined(__EMX__) || defined(MSDOS) || defined(WINNT)
- || isalpha (file_name [0]) && file_name [1] == ':'
+#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
+ || (isalpha (file_name [0]) && file_name [1] == ':')
#endif
)
{
@@ -1749,7 +1768,7 @@ __gnat_locate_regular_file (file_name, p
*ptr++ = *path_val++;
ptr--;
- if (*ptr != '/' && *ptr != DIR_SEPARATOR)
+ if (*ptr != '/' && !IS_DIR_SEPARATOR (*ptr))
*++ptr = DIR_SEPARATOR;
strcpy (++ptr, file_name);
Index: ada/adaint.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/ada/adaint.h,v
retrieving revision 1.4
diff -u -p -r1.4 adaint.h
--- adaint.h 2001/12/04 16:37:55 1.4
+++ adaint.h 2001/12/20 18:52:37
@@ -138,3 +138,7 @@ extern char *__gnat_ttyname PARAM
/* Portable definition of strdup, which is not available on all systems.
*/
#define xstrdup(S) strcpy ((char *) malloc (strlen (S) + 1), S)
#endif
+
+#ifdef _WIN32
+extern void __gnat_plist_init PARAMS ((void));
+#endif
http://greetings.yahoo.com.au - Yahoo! Greetings
- Send your festive greetings online!