1 | |
---|
2 | |
---|
3 | |
---|
4 | |
---|
5 | |
---|
6 | |
---|
7 | |
---|
8 | |
---|
9 | |
---|
10 | |
---|
11 | |
---|
12 | |
---|
13 | |
---|
14 | |
---|
15 | |
---|
16 | |
---|
17 | |
---|
18 | |
---|
19 | pragma License (Modified_Gpl); |
---|
20 | |
---|
21 | with Ada.Unchecked_Conversion; |
---|
22 | with GNAT.OS_Lib; |
---|
23 | with Interfaces.C; |
---|
24 | with System; |
---|
25 | |
---|
26 | package AdaCL.OS.Low_Level is |
---|
27 | |
---|
28 | |
---|
29 | |
---|
30 | |
---|
31 | |
---|
32 | type Pipe_Type is record |
---|
33 | Input : GNAT.OS_Lib.File_Descriptor; |
---|
34 | Output : GNAT.OS_Lib.File_Descriptor; |
---|
35 | end record; |
---|
36 | |
---|
37 | |
---|
38 | |
---|
39 | |
---|
40 | type Known_OS is |
---|
41 | (Windows, |
---|
42 | MacOS, |
---|
43 | Linux); |
---|
44 | |
---|
45 | |
---|
46 | |
---|
47 | |
---|
48 | function This_OS return Known_OS with |
---|
49 | Pure_Function, Inline, Post => This_OS'Result = MacOS; |
---|
50 | |
---|
51 | |
---|
52 | |
---|
53 | |
---|
54 | function Errno return Integer renames GNAT.OS_Lib.Errno; |
---|
55 | |
---|
56 | |
---|
57 | |
---|
58 | |
---|
59 | procedure Close (Fd : GNAT.OS_Lib.File_Descriptor); |
---|
60 | |
---|
61 | |
---|
62 | |
---|
63 | |
---|
64 | function Pipe (Files : access Pipe_Type) return Interfaces.C.int; |
---|
65 | |
---|
66 | |
---|
67 | |
---|
68 | |
---|
69 | function Create_Pipe (Pipe : access Pipe_Type) return Integer; |
---|
70 | |
---|
71 | |
---|
72 | |
---|
73 | |
---|
74 | function Portable_Wait (S : System.Address) return GNAT.OS_Lib.Process_Id; |
---|
75 | |
---|
76 | |
---|
77 | |
---|
78 | |
---|
79 | function Cast is new Ada.Unchecked_Conversion (Source => GNAT.OS_Lib.Process_Id, Target => Integer); |
---|
80 | |
---|
81 | |
---|
82 | |
---|
83 | function Cast is new Ada.Unchecked_Conversion (Source => GNAT.OS_Lib.File_Descriptor, Target => Integer); |
---|
84 | |
---|
85 | private |
---|
86 | |
---|
87 | function This_OS return Known_OS is (MacOS); |
---|
88 | |
---|
89 | pragma Import (Convention => C, Entity => Close); |
---|
90 | |
---|
91 | pragma Import (Convention => C, Entity => Pipe, External_Name => "pipe"); |
---|
92 | |
---|
93 | pragma Import (Convention => C, Entity => Portable_Wait, External_Name => "__gnat_portable_wait"); |
---|
94 | |
---|
95 | pragma Import (Convention => C, Entity => Create_Pipe, External_Name => "__gnat_pipe"); |
---|
96 | |
---|
97 | pragma Linker_Options ("-lgnat"); |
---|
98 | |
---|
99 | end AdaCL.OS.Low_Level; |
---|