diff mbox

[1/4,Ada,DJGPP] Ada support for DJGPP

Message ID 0c9adcbe-e2ca-1708-e634-3625c0644bc3@iki.fi
State New
Headers show

Commit Message

Andris Pavēnis Aug. 17, 2016, 4:26 a.m. UTC
On 08/15/2016 11:27 AM, Eric Botcazou wrote:
>> Both '/' and '\' must be supported as directory separators. So
>> DIR_SEPARATOR='/' is not OK in this case.
> Understood.
>   
>> Unconditional converting '/' to '\' in case of DJGPP native build causes
>> gnatmake to break. Retested it today it with gcc-6.1.0. The problem is that
>> special directory name /dev/env/DJDIR is used as prefix for DJGPP (it
>> resolves to $DJDIR in execution time)
> So it's only because of the /dev/ thing, i.e. this would work without it?  If
> so, can we restrict the special-casing to this block of code?
>
>        --  Replace all '/' by Directory Separators (this is for Windows)
>
>        if Directory_Separator /= '/' then
>           for Index in 1 .. End_Path loop
>              if Path_Buffer (Index) = '/' then
>                 Path_Buffer (Index) := Directory_Separator;
>              end if;
>           end loop;
>        end if;
>
> IOW, can we disable it for the /dev/ thing and leave the rest untouched?
> Since DIR_SEPARATOR=='\', the block immediately below will be disabled too.
>
Some more study shows that smaller patch (attached) is sufficient. There is no harm from 
pre-pending drive letter (like 'c:'). Specifying '\dev\' do not however work. Disabling conversion 
for '/dev/' alone would influence Windows port as such directory name is OK for Windows.

Updated changelog entry is inside the attachment.

Andris

Comments

Andris Pavēnis Oct. 10, 2016, 3:47 p.m. UTC | #1
I'd like to ping this patch.

Last version of the patch together with Changelog entry can be found in mailing list archive:

https://gcc.gnu.org/ml/gcc-patches/2016-08/msg01229.html

Andris
Arnaud Charlet Oct. 11, 2016, 8:44 a.m. UTC | #2
> I'd like to ping this patch.
> 
> Last version of the patch together with Changelog entry can be found in
> mailing list archive:
> 
> https://gcc.gnu.org/ml/gcc-patches/2016-08/msg01229.html

This patch isn't OK, we don't want to add such special case in s-os_lib.adb

Arno
diff mbox

Patch

From d746c4fa913a2eca6f1d93b614fd0aa908cfd13a Mon Sep 17 00:00:00 2001
From: Andris Pavenis <andris.pavenis@iki.fi>
Date: Tue, 16 Aug 2016 06:15:57 +0300
Subject: [PATCH 1/4] [DJGPP, Ada] File path handling for DJGPP host

* ada/adaint.c (__gnat_is_djgpp): define (1 for DJGPP host, 0 otherwise).
* ada/s-os_lib.ads (Is_Djgpp): import __gnat_is_djgpp as constant.
* ada/s-os_lib.adb (Normalize_Pathname): do not convert '/' to '\' for DJGPP host
---
 gcc/ada/adaint.c     | 6 ++++++
 gcc/ada/s-os_lib.adb | 5 ++++-
 gcc/ada/s-os_lib.ads | 3 +++
 3 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/gcc/ada/adaint.c b/gcc/ada/adaint.c
index e011fef..f317865 100644
--- a/gcc/ada/adaint.c
+++ b/gcc/ada/adaint.c
@@ -226,6 +226,12 @@  char __gnat_dir_separator = DIR_SEPARATOR;
 
 char __gnat_path_separator = PATH_SEPARATOR;
 
+#ifdef __DJGPP__
+int __gnat_is_djgpp = 1;
+#else
+int __gnat_is_djgpp = 0;
+#endif
+
 /* The GNAT_LIBRARY_TEMPLATE contains a list of expressions that define
    the base filenames that libraries specified with -lsomelib options
    may have. This is used by GNATMAKE to check whether an executable
diff --git a/gcc/ada/s-os_lib.adb b/gcc/ada/s-os_lib.adb
index 31b2f08..21173db 100644
--- a/gcc/ada/s-os_lib.adb
+++ b/gcc/ada/s-os_lib.adb
@@ -2242,8 +2242,11 @@  package body System.OS_Lib is
       end File_Name_Conversion;
 
       --  Replace all '/' by Directory Separators (this is for Windows)
+      --  No need to do that however for DJGPP
 
-      if Directory_Separator /= '/' then
+      if Directory_Separator /= '/'
+        and then Is_Djgpp = 0
+      then
          for Index in 1 .. End_Path loop
             if Path_Buffer (Index) = '/' then
                Path_Buffer (Index) := Directory_Separator;
diff --git a/gcc/ada/s-os_lib.ads b/gcc/ada/s-os_lib.ads
index 9004874..5c8bfe2 100644
--- a/gcc/ada/s-os_lib.ads
+++ b/gcc/ada/s-os_lib.ads
@@ -1068,9 +1068,12 @@  package System.OS_Lib is
    Path_Separator : constant Character;
    --  The character to separate paths in an environment variable value
 
+   Is_Djgpp : constant Integer;
+
 private
    pragma Import (C, Path_Separator, "__gnat_path_separator");
    pragma Import (C, Directory_Separator, "__gnat_dir_separator");
+   pragma Import (C, Is_Djgpp, "__gnat_is_djgpp");
    pragma Import (C, Current_Time, "__gnat_current_time");
    pragma Import (C, Current_Process_Id, "__gnat_current_process_id");
 
-- 
2.7.4