aboutsummaryrefslogtreecommitdiffstats
path: root/src/grt
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2020-04-13 17:02:45 +0200
committerTristan Gingold <tgingold@free.fr>2020-04-13 17:02:45 +0200
commit0aac4efd094b6b7ec0254f2bc4c2b994ed35c417 (patch)
tree7eafc1378abe8336cf79d0aa3b7fd0398a2b0107 /src/grt
parent25b2dfe55c659ac84e54b0db82dff2461d9bd286 (diff)
downloadghdl-0aac4efd094b6b7ec0254f2bc4c2b994ed35c417.tar.gz
ghdl-0aac4efd094b6b7ec0254f2bc4c2b994ed35c417.tar.bz2
ghdl-0aac4efd094b6b7ec0254f2bc4c2b994ed35c417.zip
synth: also try to open files (during synthesis) relative to current unit.
Fix #1190
Diffstat (limited to 'src/grt')
-rw-r--r--src/grt/grt-files_operations.adb8
-rw-r--r--src/grt/grt-files_operations.ads16
2 files changed, 22 insertions, 2 deletions
diff --git a/src/grt/grt-files_operations.adb b/src/grt/grt-files_operations.adb
index b1f504dc9..a98579bb7 100644
--- a/src/grt/grt-files_operations.adb
+++ b/src/grt/grt-files_operations.adb
@@ -249,6 +249,12 @@ package body Grt.Files_Operations is
return;
end Ghdl_File_Endfile;
+ function Simple_Open (Name : Ghdl_C_String; Mode : Ghdl_C_String)
+ return C_Files is
+ begin
+ return fopen (To_Address (Name), To_Address (Mode));
+ end Simple_Open;
+
Sig_Header : constant String := "#GHDL-BINARY-FILE-0.0" & Nl;
Std_Output_Name : constant String := "STD_OUTPUT" & NUL;
@@ -309,7 +315,7 @@ package body Grt.Files_Operations is
Str_Mode (2) := 'b';
Str_Mode (3) := NUL;
end if;
- F := fopen (To_Address (Name), Str_Mode'Address);
+ F := Open_Handler (Name, To_Ghdl_C_String (Str_Mode'Address));
if F = NULL_Stream then
Status := Op_Name_Error;
return;
diff --git a/src/grt/grt-files_operations.ads b/src/grt/grt-files_operations.ads
index 176d4f06c..4dfee186f 100644
--- a/src/grt/grt-files_operations.ads
+++ b/src/grt/grt-files_operations.ads
@@ -22,9 +22,12 @@
-- covered by the GNU General Public License. This exception does not
-- however invalidate any other reasons why the executable file might be
-- covered by the GNU Public License.
-with Grt.Types; use Grt.Types;
+
with Interfaces;
+with Grt.Types; use Grt.Types;
+with Grt.Stdio;
+
package Grt.Files_Operations is
type Ghdl_File_Index is new Interfaces.Integer_32;
@@ -143,4 +146,15 @@ package Grt.Files_Operations is
Status : out Op_Status);
procedure Ghdl_File_Flush (File : Ghdl_File_Index; Status : out Op_Status);
+
+ type Open_Handler_Acc is access function
+ (Name : Ghdl_C_String; Mode : Ghdl_C_String) return Grt.Stdio.FILEs;
+
+ -- Like fopen(3)
+ function Simple_Open (Name : Ghdl_C_String; Mode : Ghdl_C_String)
+ return Grt.Stdio.FILEs;
+
+ -- Function called to open a file. This hook can be used to search a file
+ -- on a path.
+ Open_Handler : Open_Handler_Acc := Simple_Open'Access;
end Grt.Files_Operations;