]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[multiple changes]
authorArnaud Charlet <charlet@gcc.gnu.org>
Wed, 15 Apr 2009 10:51:32 +0000 (12:51 +0200)
committerArnaud Charlet <charlet@gcc.gnu.org>
Wed, 15 Apr 2009 10:51:32 +0000 (12:51 +0200)
2009-04-15  Pascal Obry  <obry@adacore.com>

Add support for Win32 native encoding for delete/rename routines.

* adaint.c (__gnat_unlink): New routine.
(__gnat_rename): New routine.
Simple wrapper routines used to convert to proper encoding on
Windows.

* s-os_lib.adb: Use __gnat_unlink and __gnat_rename instead of direct
call to the C library.

* g-sercom-mingw.adb, s-win32.ads: Update Win32 binding.

2009-04-15  Robert Dewar  <dewar@adacore.com>

* s-tassta.adb: Minor reformatting

From-SVN: r146101

gcc/ada/ChangeLog
gcc/ada/adaint.c
gcc/ada/g-sercom-mingw.adb
gcc/ada/s-os_lib.adb
gcc/ada/s-tassta.adb
gcc/ada/s-win32.ads

index 99395eb41910ca283efc62052ae79e89e1235027..4f332439a55c8e68f6a8d8ea8560c56d4b10dd50 100644 (file)
@@ -1,3 +1,21 @@
+2009-04-15  Pascal Obry  <obry@adacore.com>
+
+       Add support for Win32 native encoding for delete/rename routines.
+       
+       * adaint.c (__gnat_unlink): New routine.
+       (__gnat_rename): New routine.
+       Simple wrapper routines used to convert to proper encoding on
+       Windows.
+
+       * s-os_lib.adb: Use __gnat_unlink and __gnat_rename instead of direct
+       call to the C library.
+
+       * g-sercom-mingw.adb, s-win32.ads: Update Win32 binding.
+
+2009-04-15  Robert Dewar  <dewar@adacore.com>
+
+       * s-tassta.adb: Minor reformatting
+
 2009-04-15  Robert Dewar  <dewar@adacore.com>
 
        * frontend.adb (Frontend): Set proper default for
index a6e74299aef287c32a3dfbdd42ccad1e7e772cc8..c84cd3ed2dcba4f58600039dede356d0ddd431cf 100644 (file)
@@ -694,6 +694,41 @@ __gnat_os_filename (char *filename, char *w_filename ATTRIBUTE_UNUSED,
 #endif
 }
 
+/* Delete a file.  */
+
+int
+__gnat_unlink (char *path)
+{
+#if defined (__MINGW32__) && ! defined (__vxworks) && ! defined (CROSS_COMPILE)
+  {
+    TCHAR wpath[GNAT_MAX_PATH_LEN];
+
+    S2WSU (wpath, path, GNAT_MAX_PATH_LEN);
+    return _tunlink (wpath);
+  }
+#else
+  return unlink (path);
+#endif
+}
+
+/* Rename a file.  */
+
+int
+__gnat_rename (char *from, char *to)
+{
+#if defined (__MINGW32__) && ! defined (__vxworks) && ! defined (CROSS_COMPILE)
+  {
+    TCHAR wfrom[GNAT_MAX_PATH_LEN], wto[GNAT_MAX_PATH_LEN];
+
+    S2WSU (wfrom, from, GNAT_MAX_PATH_LEN);
+    S2WSU (wto, to, GNAT_MAX_PATH_LEN);
+    return _trename (wfrom, wto);
+  }
+#else
+  return rename (from, to);
+#endif
+}
+
 FILE *
 __gnat_fopen (char *path, char *mode, int encoding ATTRIBUTE_UNUSED)
 {
index abb32274e4c8b7f5f497f8058e63f95ba4cfde25..03bd6aba191d851f1485cd0a93826f76eef44f38 100644 (file)
@@ -106,7 +106,7 @@ package body GNAT.Serial_Communications is
          Success := CloseHandle (HANDLE (Port.H.all));
       end if;
 
-      Port.H.all := CreateFile
+      Port.H.all := CreateFileA
         (lpFileName            => C_Name (C_Name'First)'Address,
          dwDesiredAccess       => GENERIC_READ or GENERIC_WRITE,
          dwShareMode           => 0,
index 0e1c6c756b895db10e51620b8903e90884cdd5ac..0add64f94d13183e4fb62cfea764bd04d3d9f1fb 100755 (executable)
@@ -848,7 +848,7 @@ package body System.OS_Lib is
       R : Integer;
 
       function unlink (A : Address) return Integer;
-      pragma Import (C, unlink, "unlink");
+      pragma Import (C, unlink, "__gnat_unlink");
 
    begin
       R := unlink (Name);
@@ -2246,7 +2246,7 @@ package body System.OS_Lib is
       Success  : out Boolean)
    is
       function rename (From, To : Address) return Integer;
-      pragma Import (C, rename, "rename");
+      pragma Import (C, rename, "__gnat_rename");
       R : Integer;
    begin
       R := rename (Old_Name, New_Name);
index 836f332334caf6c21826409547b12de016bad636..9a5ce9fd8c15cd15a59af0b610c69596755ce68e 100644 (file)
@@ -1388,6 +1388,8 @@ package body System.Tasking.Stages is
       --  unwound. The common notification routine has been called at the
       --  raise point already.
 
+      --  Lock to prevent unsynchronized output
+
       Initialization.Task_Lock (Self_Id);
       To_Stderr ("task ");
 
index f8856fb3bfa298d4528db3965dcbb34588c3ed82..35975919edd36534c0c509fceb7e084fee65c119 100644 (file)
@@ -82,51 +82,53 @@ package System.Win32 is
    -- Files --
    -----------
 
-   GENERIC_READ  : constant := 16#80000000#;
-   GENERIC_WRITE : constant := 16#40000000#;
-
-   CREATE_NEW        : constant := 1;
-   CREATE_ALWAYS     : constant := 2;
-   OPEN_EXISTING     : constant := 3;
-   OPEN_ALWAYS       : constant := 4;
-   TRUNCATE_EXISTING : constant := 5;
-
-   FILE_SHARE_DELETE : constant := 16#00000004#;
-   FILE_SHARE_READ   : constant := 16#00000001#;
-   FILE_SHARE_WRITE  : constant := 16#00000002#;
-
-   FILE_BEGIN        : constant := 0;
-   FILE_CURRENT      : constant := 1;
-   FILE_END          : constant := 2;
-
-   PAGE_NOACCESS       : constant := 16#0001#;
-   PAGE_READONLY       : constant := 16#0002#;
-   PAGE_READWRITE      : constant := 16#0004#;
-   PAGE_WRITECOPY      : constant := 16#0008#;
-   PAGE_EXECUTE        : constant := 16#0010#;
-
-   FILE_MAP_ALL_ACCESS : constant := 16#F001f#;
-   FILE_MAP_READ       : constant := 4;
-   FILE_MAP_WRITE      : constant := 2;
-   FILE_MAP_COPY       : constant := 1;
-
-   FILE_ADD_FILE             : constant := 16#0002#;
-   FILE_ADD_SUBDIRECTORY     : constant := 16#0004#;
-   FILE_APPEND_DATA          : constant := 16#0004#;
-   FILE_CREATE_PIPE_INSTANCE : constant := 16#0004#;
-   FILE_DELETE_CHILD         : constant := 16#0040#;
-   FILE_EXECUTE              : constant := 16#0020#;
-   FILE_LIST_DIRECTORY       : constant := 16#0001#;
-   FILE_READ_ATTRIBUTES      : constant := 16#0080#;
-   FILE_READ_DATA            : constant := 16#0001#;
-   FILE_READ_EA              : constant := 16#0008#;
-   FILE_TRAVERSE             : constant := 16#0020#;
-   FILE_WRITE_ATTRIBUTES     : constant := 16#0100#;
-   FILE_WRITE_DATA           : constant := 16#0002#;
-   FILE_WRITE_EA             : constant := 16#0010#;
-   STANDARD_RIGHTS_READ      : constant := 16#20000#;
-   STANDARD_RIGHTS_WRITE     : constant := 16#20000#;
-   SYNCHRONIZE               : constant := 16#100000#;
+   CP_UTF8                            : constant := 65001;
+
+   GENERIC_READ                       : constant := 16#80000000#;
+   GENERIC_WRITE                      : constant := 16#40000000#;
+
+   CREATE_NEW                         : constant := 1;
+   CREATE_ALWAYS                      : constant := 2;
+   OPEN_EXISTING                      : constant := 3;
+   OPEN_ALWAYS                        : constant := 4;
+   TRUNCATE_EXISTING                  : constant := 5;
+
+   FILE_SHARE_DELETE                  : constant := 16#00000004#;
+   FILE_SHARE_READ                    : constant := 16#00000001#;
+   FILE_SHARE_WRITE                   : constant := 16#00000002#;
+
+   FILE_BEGIN                         : constant := 0;
+   FILE_CURRENT                       : constant := 1;
+   FILE_END                           : constant := 2;
+
+   PAGE_NOACCESS                      : constant := 16#0001#;
+   PAGE_READONLY                      : constant := 16#0002#;
+   PAGE_READWRITE                     : constant := 16#0004#;
+   PAGE_WRITECOPY                     : constant := 16#0008#;
+   PAGE_EXECUTE                       : constant := 16#0010#;
+
+   FILE_MAP_ALL_ACCESS                : constant := 16#F001f#;
+   FILE_MAP_READ                      : constant := 4;
+   FILE_MAP_WRITE                     : constant := 2;
+   FILE_MAP_COPY                      : constant := 1;
+
+   FILE_ADD_FILE                      : constant := 16#0002#;
+   FILE_ADD_SUBDIRECTORY              : constant := 16#0004#;
+   FILE_APPEND_DATA                   : constant := 16#0004#;
+   FILE_CREATE_PIPE_INSTANCE          : constant := 16#0004#;
+   FILE_DELETE_CHILD                  : constant := 16#0040#;
+   FILE_EXECUTE                       : constant := 16#0020#;
+   FILE_LIST_DIRECTORY                : constant := 16#0001#;
+   FILE_READ_ATTRIBUTES               : constant := 16#0080#;
+   FILE_READ_DATA                     : constant := 16#0001#;
+   FILE_READ_EA                       : constant := 16#0008#;
+   FILE_TRAVERSE                      : constant := 16#0020#;
+   FILE_WRITE_ATTRIBUTES              : constant := 16#0100#;
+   FILE_WRITE_DATA                    : constant := 16#0002#;
+   FILE_WRITE_EA                      : constant := 16#0010#;
+   STANDARD_RIGHTS_READ               : constant := 16#20000#;
+   STANDARD_RIGHTS_WRITE              : constant := 16#20000#;
+   SYNCHRONIZE                        : constant := 16#100000#;
 
    FILE_ATTRIBUTE_READONLY            : constant := 16#00000001#;
    FILE_ATTRIBUTE_HIDDEN              : constant := 16#00000002#;
@@ -159,6 +161,16 @@ package System.Win32 is
       bInheritHandle      : BOOL;
    end record;
 
+   function CreateFileA
+     (lpFileName            : Address;
+      dwDesiredAccess       : DWORD;
+      dwShareMode           : DWORD;
+      lpSecurityAttributes  : access SECURITY_ATTRIBUTES;
+      dwCreationDisposition : DWORD;
+      dwFlagsAndAttributes  : DWORD;
+      hTemplateFile         : HANDLE) return HANDLE;
+   pragma Import (Stdcall, CreateFileA, "CreateFileA");
+
    function CreateFile
      (lpFileName            : Address;
       dwDesiredAccess       : DWORD;
@@ -167,7 +179,7 @@ package System.Win32 is
       dwCreationDisposition : DWORD;
       dwFlagsAndAttributes  : DWORD;
       hTemplateFile         : HANDLE) return HANDLE;
-   pragma Import (Stdcall, CreateFile, "CreateFileA");
+   pragma Import (Stdcall, CreateFile, "CreateFileW");
 
    function GetFileSize
      (hFile          : HANDLE;
@@ -220,6 +232,15 @@ package System.Win32 is
    function UnmapViewOfFile (lpBaseAddress : System.Address) return BOOL;
    pragma Import (Stdcall, UnmapViewOfFile, "UnmapViewOfFile");
 
+   function MultiByteToWideChar
+     (CodePage       : WORD;
+      dwFlags        : DWORD;
+      lpMultiByteStr : System.Address;
+      cchMultiByte   : WORD;
+      lpWideCharStr  : System.Address;
+      cchWideChar    : WORD) return BOOL;
+   pragma Import (Stdcall, MultiByteToWideChar, "MultiByteToWideChar");
+
    ------------------------
    -- System Information --
    ------------------------