Patchwork : Fix for PR 52123 gcc bootstrap with ada fails on mingw target

login
register
mail settings
Submitter Rainer Emrich
Date Jan. 3, 2013, 1:06 p.m.
Message ID <50E5823E.7010404@emrich-ebersheim.de>
Download mbox | patch
Permalink /patch/209246/
State New
Headers show

Comments

Rainer Emrich - Jan. 3, 2013, 1:06 p.m.
Hello,

this trivial patch fixes the bootstrap with ada on mingw targets.
The right casts fix the invalid conversion issues. Patch is against trunk.

	ada/

	PR 52123
	* adaint.c (__gnat_check_OWNER_ACL): Cast from pointer via
	SECURITY_DESCRIPTOR *
	(__gnat_set_OWNER_ACL): Cast from DWORD to ACCESS_MODE
	(__gnat_portable_spawn): Fix cast to char* const*
	(add_handle): Cast from pointer via void **
	(add_handle): Cast from pointer via int *
	(__gnat_locate_exec_on_path): Cast from pointer via TCHAR *
	(__gnat_locate_exec_on_path): Cast from pointer via char *
	* initialize.c (append_arg): Cast from pointer via LPWSTR
	(__gnat_initialize): Cast from pointer via LPWSTR
	* seh_init.c (__gnat_map_SEH): Cast from pointer via FARPROC

If OK for apply, Kai please commit.

Regards,

Rainer
Rainer Emrich - Jan. 3, 2013, 1:27 p.m.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Forgot to mention, tested on x86_64-w64-mingw32 and x86_64-unknown-gnu-linux.

Am 03.01.2013 14:06, schrieb Rainer Emrich:
> Hello,
> 
> this trivial patch fixes the bootstrap with ada on mingw targets. The
> right casts fix the invalid conversion issues. Patch is against trunk.
> 
> ada/
> 
> PR 52123 * adaint.c (__gnat_check_OWNER_ACL): Cast from pointer via 
> SECURITY_DESCRIPTOR * (__gnat_set_OWNER_ACL): Cast from DWORD to 
> ACCESS_MODE (__gnat_portable_spawn): Fix cast to char* const*
> (add_handle): Cast from pointer via void ** (add_handle): Cast from pointer
> via int * (__gnat_locate_exec_on_path): Cast from pointer via TCHAR * 
> (__gnat_locate_exec_on_path): Cast from pointer via char * * initialize.c 
> (append_arg): Cast from pointer via LPWSTR (__gnat_initialize): Cast from 
> pointer via LPWSTR * seh_init.c (__gnat_map_SEH): Cast from pointer via 
> FARPROC
> 
> If OK for apply, Kai please commit.
> 
> Regards,
> 
> Rainer
> 
> 
> Index: ada/adaint.c 
> =================================================================== --- 
> ada/adaint.c	(Revision 194638) +++ ada/adaint.c	(Arbeitskopie) @@ -1982,7 
> +1982,7 @@ __gnat_check_OWNER_ACL GROUP_SECURITY_INFORMATION | 
> DACL_SECURITY_INFORMATION, NULL, 0, &nLength);
> 
> -  if ((pSD = (PSECURITY_DESCRIPTOR) HeapAlloc +  if ((pSD = 
> (SECURITY_DESCRIPTOR *) HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, 
> nLength)) == NULL) return 0;
> 
> @@ -2059,7 +2059,7 @@ __gnat_set_OWNER_ACL return;
> 
> BuildExplicitAccessWithName -    (&ea, username, AccessPermissions, 
> AccessMode, NO_INHERITANCE); +    (&ea, username, AccessPermissions, 
> (ACCESS_MODE) AccessMode, NO_INHERITANCE);
> 
> if (AccessMode == SET_ACCESS) { @@ -2384,7 +2384,7 @@
> __gnat_portable_spawn (char *args[]) strcat (args[0], args_0); strcat
> (args[0], "\"");
> 
> -  status = spawnvp (P_WAIT, args_0, (const char* const*)args); +  status
> = spawnvp (P_WAIT, args_0, (char* const*)args);
> 
> /* restore previous value */ free (args[0]); @@ -2540,9 +2540,9 @@ 
> add_handle (HANDLE h, int pid) { plist_max_length += 1000; HANDLES_LIST =
> - xrealloc (HANDLES_LIST, sizeof (HANDLE) * plist_max_length); +
> (void **) xrealloc (HANDLES_LIST, sizeof (HANDLE) * plist_max_length);
> PID_LIST = -        xrealloc (PID_LIST, sizeof (int) * plist_max_length);
> + (int *) xrealloc (PID_LIST, sizeof (int) * plist_max_length); }
> 
> HANDLES_LIST[plist_length] = h; @@ -2931,7 +2931,7 @@ 
> __gnat_locate_exec_on_path (char *exec_n
> 
> #define EXPAND_BUFFER_SIZE 32767
> 
> -  wapath_val = alloca (EXPAND_BUFFER_SIZE); +  wapath_val = (TCHAR *) 
> alloca (EXPAND_BUFFER_SIZE);
> 
> wapath_val [0] = '.'; wapath_val [1] = ';'; @@ -2941,7 +2941,7 @@ 
> __gnat_locate_exec_on_path (char *exec_n
> 
> if (!res) wapath_val [0] = _T('\0');
> 
> -  apath_val = alloca (EXPAND_BUFFER_SIZE); +  apath_val = (char *) alloca 
> (EXPAND_BUFFER_SIZE);
> 
> WS2SC (apath_val, wapath_val, EXPAND_BUFFER_SIZE); return 
> __gnat_locate_exec (exec_name, apath_val); Index: ada/initialize.c 
> =================================================================== --- 
> ada/initialize.c	(Revision 194638) +++ ada/initialize.c	(Arbeitskopie) @@ 
> -88,14 +88,14 @@ append_arg (int *index, LPWSTR dir, LPWS { /* no dir 
> prefix */ dirlen = 0; -      fullvalue = xmalloc ((vallen + 1) * 
> sizeof(TCHAR)); +      fullvalue = (LPWSTR) xmalloc ((vallen + 1) * 
> sizeof(TCHAR)); } else { /* Add dir first */ dirlen = _tcslen (dir);
> 
> -      fullvalue = xmalloc ((dirlen + vallen + 1) * sizeof(TCHAR)); + 
> fullvalue = (LPWSTR) xmalloc ((dirlen + vallen + 1) * sizeof(TCHAR)); 
> _tcscpy (fullvalue, dir); }
> 
> @@ -203,7 +203,7 @@ __gnat_initialize (void *eh ATTRIBUTE_UN if (ldir != 
> NULL) { int n = ldir - wargv[k] + 1; -			 dir = xmalloc ((n + 1) * sizeof 
> (TCHAR)); +			 dir = (LPWSTR) xmalloc ((n + 1) * sizeof (TCHAR)); _tcsncpy 
> (dir, wargv[k], n); dir[n] = _T('\0'); } Index: ada/seh_init.c 
> =================================================================== --- 
> ada/seh_init.c	(Revision 194638) +++ ada/seh_init.c	(Arbeitskopie) @@
> -91,7 +91,7 @@ __gnat_map_SEH (EXCEPTION_RECORD* Except */ if 
> ((ExceptionRecord->ExceptionInformation[1] & 3) != 0 || IsBadCodePtr - 
> ((void *)(ExceptionRecord->ExceptionInformation[1] + 4096))) + 
> ((FARPROC)(ExceptionRecord->ExceptionInformation[1] + 4096))) { *msg = 
> "EXCEPTION_ACCESS_VIOLATION"; return &program_error;
> 

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with undefined - http://www.enigmail.net/

iQEcBAEBAgAGBQJQ5YcuAAoJEB3HOsWs+KJbw/MH/jJZxT7cheP/yKJzNI6icRlD
14XNGJ+9qMD9tTwNS20JML/gqaFrVg1IW69fxwPouNqsVngludbqvgV3dboNQiTn
1CA6/n/mkjGmmx9YcmtBvYsKhk7WLmQVOb1m+NAd/PDw92raCCUyxTrGPLRo3V4J
iLOUPsDHi27JOjIdgUyyqMFPUpKmvdyRC/yrHWGiZuRPgWXA/vaVtEtSefNlQvxB
oW3JuRW59epcxE+tV/cpxfc9uCsYEE6ZRGymh68bJb/+FNemO3252F4qf4788B95
CmxZ/AYuLTIbfaEaClXVWm3of3hM1l2mvputPLodweghGm1c1bHtWS0x8YaK7Do=
=dA5H
-----END PGP SIGNATURE-----
Rainer Emrich - Feb. 6, 2013, 10:24 a.m.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I like to have this in trunk as soon as possible, because I want to backport
to 4.7.3 before the release.

Tested on x86_64-w64-mingw32 and x86_64-unknown-gnu-linux.

Cheers

Rainer

Am 03.01.2013 14:06, schrieb Rainer Emrich:
> Hello,
> 
> this trivial patch fixes the bootstrap with ada on mingw targets. The right
> casts fix the invalid conversion issues. Patch is against trunk.
> 
> ada/
> 
> PR 52123 * adaint.c (__gnat_check_OWNER_ACL): Cast from pointer via 
> SECURITY_DESCRIPTOR * (__gnat_set_OWNER_ACL): Cast from DWORD to
> ACCESS_MODE (__gnat_portable_spawn): Fix cast to char* const* (add_handle):
> Cast from pointer via void ** (add_handle): Cast from pointer via int * 
> (__gnat_locate_exec_on_path): Cast from pointer via TCHAR * 
> (__gnat_locate_exec_on_path): Cast from pointer via char * * initialize.c
> (append_arg): Cast from pointer via LPWSTR (__gnat_initialize): Cast from
> pointer via LPWSTR * seh_init.c (__gnat_map_SEH): Cast from pointer via
> FARPROC
> 
> If OK for apply, Kai please commit.
> 
> Regards,
> 
> Rainer
> 
> 
> Index: ada/adaint.c 
> =================================================================== ---
> ada/adaint.c	(Revision 194638) +++ ada/adaint.c	(Arbeitskopie) @@ -1982,7
> +1982,7 @@ __gnat_check_OWNER_ACL GROUP_SECURITY_INFORMATION |
> DACL_SECURITY_INFORMATION, NULL, 0, &nLength);
> 
> -  if ((pSD = (PSECURITY_DESCRIPTOR) HeapAlloc +  if ((pSD =
> (SECURITY_DESCRIPTOR *) HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY,
> nLength)) == NULL) return 0;
> 
> @@ -2059,7 +2059,7 @@ __gnat_set_OWNER_ACL return;
> 
> BuildExplicitAccessWithName -    (&ea, username, AccessPermissions,
> AccessMode, NO_INHERITANCE); +    (&ea, username, AccessPermissions,
> (ACCESS_MODE) AccessMode, NO_INHERITANCE);
> 
> if (AccessMode == SET_ACCESS) { @@ -2384,7 +2384,7 @@ __gnat_portable_spawn
> (char *args[]) strcat (args[0], args_0); strcat (args[0], "\"");
> 
> -  status = spawnvp (P_WAIT, args_0, (const char* const*)args); +  status =
> spawnvp (P_WAIT, args_0, (char* const*)args);
> 
> /* restore previous value */ free (args[0]); @@ -2540,9 +2540,9 @@
> add_handle (HANDLE h, int pid) { plist_max_length += 1000; HANDLES_LIST = -
> xrealloc (HANDLES_LIST, sizeof (HANDLE) * plist_max_length); +        (void
> **) xrealloc (HANDLES_LIST, sizeof (HANDLE) * plist_max_length); PID_LIST
> = -        xrealloc (PID_LIST, sizeof (int) * plist_max_length); +
> (int *) xrealloc (PID_LIST, sizeof (int) * plist_max_length); }
> 
> HANDLES_LIST[plist_length] = h; @@ -2931,7 +2931,7 @@
> __gnat_locate_exec_on_path (char *exec_n
> 
> #define EXPAND_BUFFER_SIZE 32767
> 
> -  wapath_val = alloca (EXPAND_BUFFER_SIZE); +  wapath_val = (TCHAR *)
> alloca (EXPAND_BUFFER_SIZE);
> 
> wapath_val [0] = '.'; wapath_val [1] = ';'; @@ -2941,7 +2941,7 @@
> __gnat_locate_exec_on_path (char *exec_n
> 
> if (!res) wapath_val [0] = _T('\0');
> 
> -  apath_val = alloca (EXPAND_BUFFER_SIZE); +  apath_val = (char *) alloca
> (EXPAND_BUFFER_SIZE);
> 
> WS2SC (apath_val, wapath_val, EXPAND_BUFFER_SIZE); return
> __gnat_locate_exec (exec_name, apath_val); Index: ada/initialize.c 
> =================================================================== ---
> ada/initialize.c	(Revision 194638) +++ ada/initialize.c	(Arbeitskopie) @@
> -88,14 +88,14 @@ append_arg (int *index, LPWSTR dir, LPWS { /* no dir
> prefix */ dirlen = 0; -      fullvalue = xmalloc ((vallen + 1) *
> sizeof(TCHAR)); +      fullvalue = (LPWSTR) xmalloc ((vallen + 1) *
> sizeof(TCHAR)); } else { /* Add dir first */ dirlen = _tcslen (dir);
> 
> -      fullvalue = xmalloc ((dirlen + vallen + 1) * sizeof(TCHAR)); +
> fullvalue = (LPWSTR) xmalloc ((dirlen + vallen + 1) * sizeof(TCHAR)); 
> _tcscpy (fullvalue, dir); }
> 
> @@ -203,7 +203,7 @@ __gnat_initialize (void *eh ATTRIBUTE_UN if (ldir !=
> NULL) { int n = ldir - wargv[k] + 1; -			 dir = xmalloc ((n + 1) * sizeof
> (TCHAR)); +			 dir = (LPWSTR) xmalloc ((n + 1) * sizeof (TCHAR)); _tcsncpy
> (dir, wargv[k], n); dir[n] = _T('\0'); } Index: ada/seh_init.c 
> =================================================================== ---
> ada/seh_init.c	(Revision 194638) +++ ada/seh_init.c	(Arbeitskopie) @@ -91,7
> +91,7 @@ __gnat_map_SEH (EXCEPTION_RECORD* Except */ if
> ((ExceptionRecord->ExceptionInformation[1] & 3) != 0 || IsBadCodePtr -
> ((void *)(ExceptionRecord->ExceptionInformation[1] + 4096))) +
> ((FARPROC)(ExceptionRecord->ExceptionInformation[1] + 4096))) { *msg =
> "EXCEPTION_ACCESS_VIOLATION"; return &program_error;
> 

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQEcBAEBAgAGBQJREi9mAAoJEB3HOsWs+KJb0bsIAIs+KEdqYhTqyB3AJ97YqYqq
JwqIUtORJwvyEdEVE6vsCpnMv4pLn3cvkQS2VwkTkFX8NW7xxq1tbsGOoojGajVV
9fyUCwplCb+n4QhwtEQv9Jh2PNSF68w7S4MkTyhLrEdROg+u3XuRAO7QbzxWQf6A
09U4VqyUT3si0m53VypKkRWagqk2F6l09uIf7MxYl2jQe1ppdI1L3Z4fwJrV//ae
jyoIm8ufHI2n2tBfNPKIY3/nelut2DC1By7hWNIyafMql/SQ3ekZMrn/kvelSMrk
9ioeUG14bqKjcYWviKFtBorZV4LWXLHpjsCkBlnvOSHUoDY52NUT9sMEpKZM9kU=
=+FZk
-----END PGP SIGNATURE-----
Arnaud Charlet - Feb. 6, 2013, 10:31 a.m.
> I like to have this in trunk as soon as possible, because I want to backport
> to 4.7.3 before the release.
> 
> Tested on x86_64-w64-mingw32 and x86_64-unknown-gnu-linux.

Did you check that this patch also works fine with mingw64? This is the main
environment now used, so it's important to verify that these changes are
compatible with both mingw32 and mingw64.

Also, your mailer corrupted the formatting, so it's no longer possible to
review this patch. Probably better to post a link to the previous
submit to ease reviews.

Arno
Arnaud Charlet - Feb. 6, 2013, 10:59 a.m.
> > Did you check that this patch also works fine with mingw64? This is the
> > main environment now used, so it's important to verify that these changes
> > are compatible with both mingw32 and mingw64.
> I'm only able ot test for mingw64 at the moment as you see above,
> x86_64-w64-mingw32 is mingw64. If someone is able to test mingw.org for me
> would be fine. Otherwise I have to setup a mingw.org environment.

OK, thanks for the clarification.

> Here the link to the original post:
> http://gcc.gnu.org/ml/gcc-patches/2013-01/msg00114.html

Patch is OK although I'm a bit surprised we're not seeing these
errors at AdaCore where we also use mingw64. Perhaps we're using a different
version.

Anyway, go ahead.

Arno

Patch

Index: ada/adaint.c
===================================================================
--- ada/adaint.c	(Revision 194638)
+++ ada/adaint.c	(Arbeitskopie)
@@ -1982,7 +1982,7 @@  __gnat_check_OWNER_ACL
      GROUP_SECURITY_INFORMATION | DACL_SECURITY_INFORMATION,
      NULL, 0, &nLength);

-  if ((pSD = (PSECURITY_DESCRIPTOR) HeapAlloc
+  if ((pSD = (SECURITY_DESCRIPTOR *) HeapAlloc
        (GetProcessHeap (), HEAP_ZERO_MEMORY, nLength)) == NULL)
     return 0;

@@ -2059,7 +2059,7 @@  __gnat_set_OWNER_ACL
     return;

   BuildExplicitAccessWithName
-    (&ea, username, AccessPermissions, AccessMode, NO_INHERITANCE);
+    (&ea, username, AccessPermissions, (ACCESS_MODE) AccessMode,
	NO_INHERITANCE);

   if (AccessMode == SET_ACCESS)
     {
@@ -2384,7 +2384,7 @@  __gnat_portable_spawn (char *args[])
   strcat (args[0], args_0);
   strcat (args[0], "\"");

-  status = spawnvp (P_WAIT, args_0, (const char* const*)args);
+  status = spawnvp (P_WAIT, args_0, (char* const*)args);

   /* restore previous value */
   free (args[0]);
@@ -2540,9 +2540,9 @@  add_handle (HANDLE h, int pid)
     {
       plist_max_length += 1000;
       HANDLES_LIST =
-        xrealloc (HANDLES_LIST, sizeof (HANDLE) * plist_max_length);
+        (void **) xrealloc (HANDLES_LIST, sizeof (HANDLE) * plist_max_length);
       PID_LIST =
-        xrealloc (PID_LIST, sizeof (int) * plist_max_length);
+        (int *) xrealloc (PID_LIST, sizeof (int) * plist_max_length);
     }

   HANDLES_LIST[plist_length] = h;
@@ -2931,7 +2931,7 @@  __gnat_locate_exec_on_path (char *exec_n

   #define EXPAND_BUFFER_SIZE 32767

-  wapath_val = alloca (EXPAND_BUFFER_SIZE);
+  wapath_val = (TCHAR *) alloca (EXPAND_BUFFER_SIZE);

   wapath_val [0] = '.';
   wapath_val [1] = ';';
@@ -2941,7 +2941,7 @@  __gnat_locate_exec_on_path (char *exec_n

   if (!res) wapath_val [0] = _T('\0');

-  apath_val = alloca (EXPAND_BUFFER_SIZE);
+  apath_val = (char *) alloca (EXPAND_BUFFER_SIZE);

   WS2SC (apath_val, wapath_val, EXPAND_BUFFER_SIZE);
   return __gnat_locate_exec (exec_name, apath_val);
Index: ada/initialize.c
===================================================================
--- ada/initialize.c	(Revision 194638)
+++ ada/initialize.c	(Arbeitskopie)
@@ -88,14 +88,14 @@  append_arg (int *index, LPWSTR dir, LPWS
     {
       /* no dir prefix */
       dirlen = 0;
-      fullvalue = xmalloc ((vallen + 1) * sizeof(TCHAR));
+      fullvalue = (LPWSTR) xmalloc ((vallen + 1) * sizeof(TCHAR));
     }
   else
     {
       /* Add dir first */
       dirlen = _tcslen (dir);

-      fullvalue = xmalloc ((dirlen + vallen + 1) * sizeof(TCHAR));
+      fullvalue = (LPWSTR) xmalloc ((dirlen + vallen + 1) * sizeof(TCHAR));
       _tcscpy (fullvalue, dir);
     }

@@ -203,7 +203,7 @@  __gnat_initialize (void *eh ATTRIBUTE_UN
 		     if (ldir != NULL)
 		       {
 			 int n = ldir - wargv[k] + 1;
-			 dir = xmalloc ((n + 1) * sizeof (TCHAR));
+			 dir = (LPWSTR) xmalloc ((n + 1) * sizeof (TCHAR));
 			 _tcsncpy (dir, wargv[k], n);
 			 dir[n] = _T('\0');
 		       }
Index: ada/seh_init.c
===================================================================
--- ada/seh_init.c	(Revision 194638)
+++ ada/seh_init.c	(Arbeitskopie)
@@ -91,7 +91,7 @@  __gnat_map_SEH (EXCEPTION_RECORD* Except
       */
       if ((ExceptionRecord->ExceptionInformation[1] & 3) != 0
 	  || IsBadCodePtr
-	  ((void *)(ExceptionRecord->ExceptionInformation[1] + 4096)))
+	  ((FARPROC)(ExceptionRecord->ExceptionInformation[1] + 4096)))
 	{
 	  *msg = "EXCEPTION_ACCESS_VIOLATION";
 	  return &program_error;