| @@ -1,3441 +1,3441 @@ | | | @@ -1,3441 +1,3441 @@ |
1 | --- /dev/null | | 1 | --- /dev/null |
2 | +++ gcc/ada/a-intnam-dragonfly.ads | | 2 | +++ gcc/ada/a-intnam-dragonfly.ads |
3 | @@ -0,0 +1,133 @@ | | 3 | @@ -0,0 +1,133 @@ |
4 | +------------------------------------------------------------------------------ | | 4 | +------------------------------------------------------------------------------ |
5 | +-- -- | | 5 | +-- -- |
6 | +-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS -- | | 6 | +-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS -- |
7 | +-- -- | | 7 | +-- -- |
8 | +-- A D A . I N T E R R U P T S . N A M E S -- | | 8 | +-- A D A . I N T E R R U P T S . N A M E S -- |
9 | +-- -- | | 9 | +-- -- |
10 | +-- S p e c -- | | 10 | +-- S p e c -- |
11 | +-- -- | | 11 | +-- -- |
12 | +-- Copyright (C) 1991-2009, Free Software Foundation, Inc. -- | | 12 | +-- Copyright (C) 1991-2009, Free Software Foundation, Inc. -- |
13 | +-- -- | | 13 | +-- -- |
14 | +-- GNARL is free software; you can redistribute it and/or modify it under -- | | 14 | +-- GNARL is free software; you can redistribute it and/or modify it under -- |
15 | +-- terms of the GNU General Public License as published by the Free Soft- -- | | 15 | +-- terms of the GNU General Public License as published by the Free Soft- -- |
16 | +-- ware Foundation; either version 3, or (at your option) any later ver- -- | | 16 | +-- ware Foundation; either version 3, or (at your option) any later ver- -- |
17 | +-- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- | | 17 | +-- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- |
18 | +-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- | | 18 | +-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- |
19 | +-- or FITNESS FOR A PARTICULAR PURPOSE. -- | | 19 | +-- or FITNESS FOR A PARTICULAR PURPOSE. -- |
20 | +-- -- | | 20 | +-- -- |
21 | +-- As a special exception under Section 7 of GPL version 3, you are granted -- | | 21 | +-- As a special exception under Section 7 of GPL version 3, you are granted -- |
22 | +-- additional permissions described in the GCC Runtime Library Exception, -- | | 22 | +-- additional permissions described in the GCC Runtime Library Exception, -- |
23 | +-- version 3.1, as published by the Free Software Foundation. -- | | 23 | +-- version 3.1, as published by the Free Software Foundation. -- |
24 | +-- -- | | 24 | +-- -- |
25 | +-- You should have received a copy of the GNU General Public License and -- | | 25 | +-- You should have received a copy of the GNU General Public License and -- |
26 | +-- a copy of the GCC Runtime Library Exception along with this program; -- | | 26 | +-- a copy of the GCC Runtime Library Exception along with this program; -- |
27 | +-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- | | 27 | +-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- |
28 | +-- <http://www.gnu.org/licenses/>. -- | | 28 | +-- <http://www.gnu.org/licenses/>. -- |
29 | +-- -- | | 29 | +-- -- |
30 | +-- GNARL was developed by the GNARL team at Florida State University. -- | | 30 | +-- GNARL was developed by the GNARL team at Florida State University. -- |
31 | +-- Extensive contributions were provided by Ada Core Technologies, Inc. -- | | 31 | +-- Extensive contributions were provided by Ada Core Technologies, Inc. -- |
32 | +-- -- | | 32 | +-- -- |
33 | +-- Copyright (C) 2010 John Marino <draco@marino.st> -- | | 33 | +-- Copyright (C) 2010 John Marino <draco@marino.st> -- |
34 | +------------------------------------------------------------------------------ | | 34 | +------------------------------------------------------------------------------ |
35 | + | | 35 | + |
36 | +-- This is the DragonFly BSD THREADS version of this package | | 36 | +-- This is the DragonFly BSD THREADS version of this package |
37 | + | | 37 | + |
38 | +with System.OS_Interface; | | 38 | +with System.OS_Interface; |
39 | + | | 39 | + |
40 | +package Ada.Interrupts.Names is | | 40 | +package Ada.Interrupts.Names is |
41 | + | | 41 | + |
42 | + -- Beware that the mapping of names to signals may be many-to-one. There | | 42 | + -- Beware that the mapping of names to signals may be many-to-one. There |
43 | + -- may be aliases. Also, for all signal names that are not supported on | | 43 | + -- may be aliases. Also, for all signal names that are not supported on |
44 | + -- the current system the value of the corresponding constant will be zero. | | 44 | + -- the current system the value of the corresponding constant will be zero. |
45 | + | | 45 | + |
46 | + SIGHUP : constant Interrupt_ID := | | 46 | + SIGHUP : constant Interrupt_ID := |
47 | + System.OS_Interface.SIGHUP; -- hangup | | 47 | + System.OS_Interface.SIGHUP; -- hangup |
48 | + | | 48 | + |
49 | + SIGINT : constant Interrupt_ID := | | 49 | + SIGINT : constant Interrupt_ID := |
50 | + System.OS_Interface.SIGINT; -- interrupt (rubout) | | 50 | + System.OS_Interface.SIGINT; -- interrupt (rubout) |
51 | + | | 51 | + |
52 | + SIGQUIT : constant Interrupt_ID := | | 52 | + SIGQUIT : constant Interrupt_ID := |
53 | + System.OS_Interface.SIGQUIT; -- quit (ASCD FS) | | 53 | + System.OS_Interface.SIGQUIT; -- quit (ASCD FS) |
54 | + | | 54 | + |
55 | + SIGILL : constant Interrupt_ID := | | 55 | + SIGILL : constant Interrupt_ID := |
56 | + System.OS_Interface.SIGILL; -- illegal instruction (not reset) | | 56 | + System.OS_Interface.SIGILL; -- illegal instruction (not reset) |
57 | + | | 57 | + |
58 | + SIGTRAP : constant Interrupt_ID := | | 58 | + SIGTRAP : constant Interrupt_ID := |
59 | + System.OS_Interface.SIGTRAP; -- trace trap (not reset) | | 59 | + System.OS_Interface.SIGTRAP; -- trace trap (not reset) |
60 | + | | 60 | + |
61 | + SIGIOT : constant Interrupt_ID := | | 61 | + SIGIOT : constant Interrupt_ID := |
62 | + System.OS_Interface.SIGIOT; -- IOT instruction | | 62 | + System.OS_Interface.SIGIOT; -- IOT instruction |
63 | + | | 63 | + |
64 | + SIGABRT : constant Interrupt_ID := -- used by abort, | | 64 | + SIGABRT : constant Interrupt_ID := -- used by abort, |
65 | + System.OS_Interface.SIGABRT; -- replace SIGIOT in the future | | 65 | + System.OS_Interface.SIGABRT; -- replace SIGIOT in the future |
66 | + | | 66 | + |
67 | + SIGFPE : constant Interrupt_ID := | | 67 | + SIGFPE : constant Interrupt_ID := |
68 | + System.OS_Interface.SIGFPE; -- floating point exception | | 68 | + System.OS_Interface.SIGFPE; -- floating point exception |
69 | + | | 69 | + |
70 | + SIGKILL : constant Interrupt_ID := | | 70 | + SIGKILL : constant Interrupt_ID := |
71 | + System.OS_Interface.SIGKILL; -- kill (cannot be caught or ignored) | | 71 | + System.OS_Interface.SIGKILL; -- kill (cannot be caught or ignored) |
72 | + | | 72 | + |
73 | + SIGBUS : constant Interrupt_ID := | | 73 | + SIGBUS : constant Interrupt_ID := |
74 | + System.OS_Interface.SIGBUS; -- bus error | | 74 | + System.OS_Interface.SIGBUS; -- bus error |
75 | + | | 75 | + |
76 | + SIGSEGV : constant Interrupt_ID := | | 76 | + SIGSEGV : constant Interrupt_ID := |
77 | + System.OS_Interface.SIGSEGV; -- segmentation violation | | 77 | + System.OS_Interface.SIGSEGV; -- segmentation violation |
78 | + | | 78 | + |
79 | + SIGPIPE : constant Interrupt_ID := -- write on a pipe with | | 79 | + SIGPIPE : constant Interrupt_ID := -- write on a pipe with |
80 | + System.OS_Interface.SIGPIPE; -- no one to read it | | 80 | + System.OS_Interface.SIGPIPE; -- no one to read it |
81 | + | | 81 | + |
82 | + SIGALRM : constant Interrupt_ID := | | 82 | + SIGALRM : constant Interrupt_ID := |
83 | + System.OS_Interface.SIGALRM; -- alarm clock | | 83 | + System.OS_Interface.SIGALRM; -- alarm clock |
84 | + | | 84 | + |
85 | + SIGTERM : constant Interrupt_ID := | | 85 | + SIGTERM : constant Interrupt_ID := |
86 | + System.OS_Interface.SIGTERM; -- software termination signal from kill | | 86 | + System.OS_Interface.SIGTERM; -- software termination signal from kill |
87 | + | | 87 | + |
88 | + SIGURG : constant Interrupt_ID := | | 88 | + SIGURG : constant Interrupt_ID := |
89 | + System.OS_Interface.SIGURG; -- urgent condition on IO channel | | 89 | + System.OS_Interface.SIGURG; -- urgent condition on IO channel |
90 | + | | 90 | + |
91 | + SIGSTOP : constant Interrupt_ID := | | 91 | + SIGSTOP : constant Interrupt_ID := |
92 | + System.OS_Interface.SIGSTOP; -- stop (cannot be caught or ignored) | | 92 | + System.OS_Interface.SIGSTOP; -- stop (cannot be caught or ignored) |
93 | + | | 93 | + |
94 | + SIGTSTP : constant Interrupt_ID := | | 94 | + SIGTSTP : constant Interrupt_ID := |
95 | + System.OS_Interface.SIGTSTP; -- user stop requested from tty | | 95 | + System.OS_Interface.SIGTSTP; -- user stop requested from tty |
96 | + | | 96 | + |
97 | + SIGCONT : constant Interrupt_ID := | | 97 | + SIGCONT : constant Interrupt_ID := |
98 | + System.OS_Interface.SIGCONT; -- stopped process has been continued | | 98 | + System.OS_Interface.SIGCONT; -- stopped process has been continued |
99 | + | | 99 | + |
100 | + SIGCHLD : constant Interrupt_ID := | | 100 | + SIGCHLD : constant Interrupt_ID := |
101 | + System.OS_Interface.SIGCHLD; -- 4.3BSD's/POSIX name for SIGCLD | | 101 | + System.OS_Interface.SIGCHLD; -- 4.3BSD's/POSIX name for SIGCLD |
102 | + | | 102 | + |
103 | + SIGCLD : constant Interrupt_ID := | | 103 | + SIGCLD : constant Interrupt_ID := |
104 | + System.OS_Interface.SIGCLD; -- child status change | | 104 | + System.OS_Interface.SIGCLD; -- child status change |
105 | + | | 105 | + |
106 | + SIGTTIN : constant Interrupt_ID := | | 106 | + SIGTTIN : constant Interrupt_ID := |
107 | + System.OS_Interface.SIGTTIN; -- background tty read attempted | | 107 | + System.OS_Interface.SIGTTIN; -- background tty read attempted |
108 | + | | 108 | + |
109 | + SIGTTOU : constant Interrupt_ID := | | 109 | + SIGTTOU : constant Interrupt_ID := |
110 | + System.OS_Interface.SIGTTOU; -- background tty write attempted | | 110 | + System.OS_Interface.SIGTTOU; -- background tty write attempted |
111 | + | | 111 | + |
112 | + SIGIO : constant Interrupt_ID := -- input/output possible, | | 112 | + SIGIO : constant Interrupt_ID := -- input/output possible, |
113 | + System.OS_Interface.SIGIO; -- SIGPOLL alias (Solaris) | | 113 | + System.OS_Interface.SIGIO; -- SIGPOLL alias (Solaris) |
114 | + | | 114 | + |
115 | + SIGXCPU : constant Interrupt_ID := | | 115 | + SIGXCPU : constant Interrupt_ID := |
116 | + System.OS_Interface.SIGXCPU; -- CPU time limit exceeded | | 116 | + System.OS_Interface.SIGXCPU; -- CPU time limit exceeded |
117 | + | | 117 | + |
118 | + SIGXFSZ : constant Interrupt_ID := | | 118 | + SIGXFSZ : constant Interrupt_ID := |
119 | + System.OS_Interface.SIGXFSZ; -- filesize limit exceeded | | 119 | + System.OS_Interface.SIGXFSZ; -- filesize limit exceeded |
120 | + | | 120 | + |
121 | + SIGVTALRM : constant Interrupt_ID := | | 121 | + SIGVTALRM : constant Interrupt_ID := |
122 | + System.OS_Interface.SIGVTALRM; -- virtual timer expired | | 122 | + System.OS_Interface.SIGVTALRM; -- virtual timer expired |
123 | + | | 123 | + |
124 | + SIGPROF : constant Interrupt_ID := | | 124 | + SIGPROF : constant Interrupt_ID := |
125 | + System.OS_Interface.SIGPROF; -- profiling timer expired | | 125 | + System.OS_Interface.SIGPROF; -- profiling timer expired |
126 | + | | 126 | + |
127 | + SIGWINCH : constant Interrupt_ID := | | 127 | + SIGWINCH : constant Interrupt_ID := |
128 | + System.OS_Interface.SIGWINCH; -- window size change | | 128 | + System.OS_Interface.SIGWINCH; -- window size change |
129 | + | | 129 | + |
130 | + SIGUSR1 : constant Interrupt_ID := | | 130 | + SIGUSR1 : constant Interrupt_ID := |
131 | + System.OS_Interface.SIGUSR1; -- user defined signal 1 | | 131 | + System.OS_Interface.SIGUSR1; -- user defined signal 1 |
132 | + | | 132 | + |
133 | + SIGUSR2 : constant Interrupt_ID := | | 133 | + SIGUSR2 : constant Interrupt_ID := |
134 | + System.OS_Interface.SIGUSR2; -- user defined signal 2 | | 134 | + System.OS_Interface.SIGUSR2; -- user defined signal 2 |
135 | + | | 135 | + |
136 | +end Ada.Interrupts.Names; | | 136 | +end Ada.Interrupts.Names; |
137 | --- /dev/null | | 137 | --- /dev/null |
138 | +++ gcc/ada/a-intnam-netbsd.ads | | 138 | +++ gcc/ada/a-intnam-netbsd.ads |
139 | @@ -0,0 +1,136 @@ | | 139 | @@ -0,0 +1,136 @@ |
140 | +------------------------------------------------------------------------------ | | 140 | +------------------------------------------------------------------------------ |
141 | +-- -- | | 141 | +-- -- |
142 | +-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS -- | | 142 | +-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS -- |
143 | +-- -- | | 143 | +-- -- |
144 | +-- A D A . I N T E R R U P T S . N A M E S -- | | 144 | +-- A D A . I N T E R R U P T S . N A M E S -- |
145 | +-- -- | | 145 | +-- -- |
146 | +-- S p e c -- | | 146 | +-- S p e c -- |
147 | +-- -- | | 147 | +-- -- |
148 | +-- Copyright (C) 1991-2009, Free Software Foundation, Inc. -- | | 148 | +-- Copyright (C) 1991-2009, Free Software Foundation, Inc. -- |
149 | +-- -- | | 149 | +-- -- |
150 | +-- GNARL is free software; you can redistribute it and/or modify it under -- | | 150 | +-- GNARL is free software; you can redistribute it and/or modify it under -- |
151 | +-- terms of the GNU General Public License as published by the Free Soft- -- | | 151 | +-- terms of the GNU General Public License as published by the Free Soft- -- |
152 | +-- ware Foundation; either version 3, or (at your option) any later ver- -- | | 152 | +-- ware Foundation; either version 3, or (at your option) any later ver- -- |
153 | +-- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- | | 153 | +-- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- |
154 | +-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- | | 154 | +-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- |
155 | +-- or FITNESS FOR A PARTICULAR PURPOSE. -- | | 155 | +-- or FITNESS FOR A PARTICULAR PURPOSE. -- |
156 | +-- -- | | 156 | +-- -- |
157 | +-- As a special exception under Section 7 of GPL version 3, you are granted -- | | 157 | +-- As a special exception under Section 7 of GPL version 3, you are granted -- |
158 | +-- additional permissions described in the GCC Runtime Library Exception, -- | | 158 | +-- additional permissions described in the GCC Runtime Library Exception, -- |
159 | +-- version 3.1, as published by the Free Software Foundation. -- | | 159 | +-- version 3.1, as published by the Free Software Foundation. -- |
160 | +-- -- | | 160 | +-- -- |
161 | +-- You should have received a copy of the GNU General Public License and -- | | 161 | +-- You should have received a copy of the GNU General Public License and -- |
162 | +-- a copy of the GCC Runtime Library Exception along with this program; -- | | 162 | +-- a copy of the GCC Runtime Library Exception along with this program; -- |
163 | +-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- | | 163 | +-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- |
164 | +-- <http://www.gnu.org/licenses/>. -- | | 164 | +-- <http://www.gnu.org/licenses/>. -- |
165 | +-- -- | | 165 | +-- -- |
166 | +-- GNARL was developed by the GNARL team at Florida State University. -- | | 166 | +-- GNARL was developed by the GNARL team at Florida State University. -- |
167 | +-- Extensive contributions were provided by Ada Core Technologies, Inc. -- | | 167 | +-- Extensive contributions were provided by Ada Core Technologies, Inc. -- |
168 | +-- -- | | 168 | +-- -- |
169 | +-- Copyright (C) 2010 John Marino <draco@marino.st> -- | | 169 | +-- Copyright (C) 2010 John Marino <draco@marino.st> -- |
170 | +------------------------------------------------------------------------------ | | 170 | +------------------------------------------------------------------------------ |
171 | + | | 171 | + |
172 | +-- This is the NetBSD THREADS version of this package | | 172 | +-- This is the NetBSD THREADS version of this package |
173 | + | | 173 | + |
174 | +with System.OS_Interface; | | 174 | +with System.OS_Interface; |
175 | + | | 175 | + |
176 | +package Ada.Interrupts.Names is | | 176 | +package Ada.Interrupts.Names is |
177 | + | | 177 | + |
178 | + -- Beware that the mapping of names to signals may be many-to-one. There | | 178 | + -- Beware that the mapping of names to signals may be many-to-one. There |
179 | + -- may be aliases. Also, for all signal names that are not supported on | | 179 | + -- may be aliases. Also, for all signal names that are not supported on |
180 | + -- the current system the value of the corresponding constant will be zero. | | 180 | + -- the current system the value of the corresponding constant will be zero. |
181 | + | | 181 | + |
182 | + SIGHUP : constant Interrupt_ID := | | 182 | + SIGHUP : constant Interrupt_ID := |
183 | + System.OS_Interface.SIGHUP; -- hangup | | 183 | + System.OS_Interface.SIGHUP; -- hangup |
184 | + | | 184 | + |
185 | + SIGINT : constant Interrupt_ID := | | 185 | + SIGINT : constant Interrupt_ID := |
186 | + System.OS_Interface.SIGINT; -- interrupt (rubout) | | 186 | + System.OS_Interface.SIGINT; -- interrupt (rubout) |
187 | + | | 187 | + |
188 | + SIGQUIT : constant Interrupt_ID := | | 188 | + SIGQUIT : constant Interrupt_ID := |
189 | + System.OS_Interface.SIGQUIT; -- quit (ASCD FS) | | 189 | + System.OS_Interface.SIGQUIT; -- quit (ASCD FS) |
190 | + | | 190 | + |
191 | + SIGILL : constant Interrupt_ID := | | 191 | + SIGILL : constant Interrupt_ID := |
192 | + System.OS_Interface.SIGILL; -- illegal instruction (not reset) | | 192 | + System.OS_Interface.SIGILL; -- illegal instruction (not reset) |
193 | + | | 193 | + |
194 | + SIGTRAP : constant Interrupt_ID := | | 194 | + SIGTRAP : constant Interrupt_ID := |
195 | + System.OS_Interface.SIGTRAP; -- trace trap (not reset) | | 195 | + System.OS_Interface.SIGTRAP; -- trace trap (not reset) |
196 | + | | 196 | + |
197 | + SIGIOT : constant Interrupt_ID := | | 197 | + SIGIOT : constant Interrupt_ID := |
198 | + System.OS_Interface.SIGIOT; -- IOT instruction | | 198 | + System.OS_Interface.SIGIOT; -- IOT instruction |
199 | + | | 199 | + |
200 | + SIGABRT : constant Interrupt_ID := -- used by abort, | | 200 | + SIGABRT : constant Interrupt_ID := -- used by abort, |
201 | + System.OS_Interface.SIGABRT; -- replace SIGIOT in the future | | 201 | + System.OS_Interface.SIGABRT; -- replace SIGIOT in the future |
202 | + | | 202 | + |
203 | + SIGFPE : constant Interrupt_ID := | | 203 | + SIGFPE : constant Interrupt_ID := |
204 | + System.OS_Interface.SIGFPE; -- floating point exception | | 204 | + System.OS_Interface.SIGFPE; -- floating point exception |
205 | + | | 205 | + |
206 | + SIGKILL : constant Interrupt_ID := | | 206 | + SIGKILL : constant Interrupt_ID := |
207 | + System.OS_Interface.SIGKILL; -- kill (cannot be caught or ignored) | | 207 | + System.OS_Interface.SIGKILL; -- kill (cannot be caught or ignored) |
208 | + | | 208 | + |
209 | + SIGBUS : constant Interrupt_ID := | | 209 | + SIGBUS : constant Interrupt_ID := |
210 | + System.OS_Interface.SIGBUS; -- bus error | | 210 | + System.OS_Interface.SIGBUS; -- bus error |
211 | + | | 211 | + |
212 | + SIGSEGV : constant Interrupt_ID := | | 212 | + SIGSEGV : constant Interrupt_ID := |
213 | + System.OS_Interface.SIGSEGV; -- segmentation violation | | 213 | + System.OS_Interface.SIGSEGV; -- segmentation violation |
214 | + | | 214 | + |
215 | + SIGPIPE : constant Interrupt_ID := -- write on a pipe with | | 215 | + SIGPIPE : constant Interrupt_ID := -- write on a pipe with |
216 | + System.OS_Interface.SIGPIPE; -- no one to read it | | 216 | + System.OS_Interface.SIGPIPE; -- no one to read it |
217 | + | | 217 | + |
218 | + SIGALRM : constant Interrupt_ID := | | 218 | + SIGALRM : constant Interrupt_ID := |
219 | + System.OS_Interface.SIGALRM; -- alarm clock | | 219 | + System.OS_Interface.SIGALRM; -- alarm clock |
220 | + | | 220 | + |
221 | + SIGTERM : constant Interrupt_ID := | | 221 | + SIGTERM : constant Interrupt_ID := |
222 | + System.OS_Interface.SIGTERM; -- software termination signal from kill | | 222 | + System.OS_Interface.SIGTERM; -- software termination signal from kill |
223 | + | | 223 | + |
224 | + SIGURG : constant Interrupt_ID := | | 224 | + SIGURG : constant Interrupt_ID := |
225 | + System.OS_Interface.SIGURG; -- urgent condition on IO channel | | 225 | + System.OS_Interface.SIGURG; -- urgent condition on IO channel |
226 | + | | 226 | + |
227 | + SIGSTOP : constant Interrupt_ID := | | 227 | + SIGSTOP : constant Interrupt_ID := |
228 | + System.OS_Interface.SIGSTOP; -- stop (cannot be caught or ignored) | | 228 | + System.OS_Interface.SIGSTOP; -- stop (cannot be caught or ignored) |
229 | + | | 229 | + |
230 | + SIGTSTP : constant Interrupt_ID := | | 230 | + SIGTSTP : constant Interrupt_ID := |
231 | + System.OS_Interface.SIGTSTP; -- user stop requested from tty | | 231 | + System.OS_Interface.SIGTSTP; -- user stop requested from tty |
232 | + | | 232 | + |
233 | + SIGCONT : constant Interrupt_ID := | | 233 | + SIGCONT : constant Interrupt_ID := |
234 | + System.OS_Interface.SIGCONT; -- stopped process has been continued | | 234 | + System.OS_Interface.SIGCONT; -- stopped process has been continued |
235 | + | | 235 | + |
236 | + SIGCHLD : constant Interrupt_ID := | | 236 | + SIGCHLD : constant Interrupt_ID := |
237 | + System.OS_Interface.SIGCHLD; -- 4.3BSD's/POSIX name for SIGCLD | | 237 | + System.OS_Interface.SIGCHLD; -- 4.3BSD's/POSIX name for SIGCLD |
238 | + | | 238 | + |
239 | + SIGCLD : constant Interrupt_ID := | | 239 | + SIGCLD : constant Interrupt_ID := |
240 | + System.OS_Interface.SIGCLD; -- child status change | | 240 | + System.OS_Interface.SIGCLD; -- child status change |
241 | + | | 241 | + |
242 | + SIGTTIN : constant Interrupt_ID := | | 242 | + SIGTTIN : constant Interrupt_ID := |
243 | + System.OS_Interface.SIGTTIN; -- background tty read attempted | | 243 | + System.OS_Interface.SIGTTIN; -- background tty read attempted |
244 | + | | 244 | + |
245 | + SIGTTOU : constant Interrupt_ID := | | 245 | + SIGTTOU : constant Interrupt_ID := |
246 | + System.OS_Interface.SIGTTOU; -- background tty write attempted | | 246 | + System.OS_Interface.SIGTTOU; -- background tty write attempted |
247 | + | | 247 | + |
248 | + SIGIO : constant Interrupt_ID := -- input/output possible, | | 248 | + SIGIO : constant Interrupt_ID := -- input/output possible, |
249 | + System.OS_Interface.SIGIO; -- SIGPOLL alias (Solaris) | | 249 | + System.OS_Interface.SIGIO; -- SIGPOLL alias (Solaris) |
250 | + | | 250 | + |
251 | + SIGXCPU : constant Interrupt_ID := | | 251 | + SIGXCPU : constant Interrupt_ID := |
252 | + System.OS_Interface.SIGXCPU; -- CPU time limit exceeded | | 252 | + System.OS_Interface.SIGXCPU; -- CPU time limit exceeded |
253 | + | | 253 | + |
254 | + SIGXFSZ : constant Interrupt_ID := | | 254 | + SIGXFSZ : constant Interrupt_ID := |
255 | + System.OS_Interface.SIGXFSZ; -- filesize limit exceeded | | 255 | + System.OS_Interface.SIGXFSZ; -- filesize limit exceeded |
256 | + | | 256 | + |
257 | + SIGVTALRM : constant Interrupt_ID := | | 257 | + SIGVTALRM : constant Interrupt_ID := |
258 | + System.OS_Interface.SIGVTALRM; -- virtual timer expired | | 258 | + System.OS_Interface.SIGVTALRM; -- virtual timer expired |
259 | + | | 259 | + |
260 | + SIGPROF : constant Interrupt_ID := | | 260 | + SIGPROF : constant Interrupt_ID := |
261 | + System.OS_Interface.SIGPROF; -- profiling timer expired | | 261 | + System.OS_Interface.SIGPROF; -- profiling timer expired |
262 | + | | 262 | + |
263 | + SIGWINCH : constant Interrupt_ID := | | 263 | + SIGWINCH : constant Interrupt_ID := |
264 | + System.OS_Interface.SIGWINCH; -- window size change | | 264 | + System.OS_Interface.SIGWINCH; -- window size change |
265 | + | | 265 | + |
266 | + SIGUSR1 : constant Interrupt_ID := | | 266 | + SIGUSR1 : constant Interrupt_ID := |
267 | + System.OS_Interface.SIGUSR1; -- user defined signal 1 | | 267 | + System.OS_Interface.SIGUSR1; -- user defined signal 1 |
268 | + | | 268 | + |
269 | + SIGUSR2 : constant Interrupt_ID := | | 269 | + SIGUSR2 : constant Interrupt_ID := |
270 | + System.OS_Interface.SIGUSR2; -- user defined signal 2 | | 270 | + System.OS_Interface.SIGUSR2; -- user defined signal 2 |
271 | + | | 271 | + |
272 | + SIGPWR : constant Interrupt_ID := | | 272 | + SIGPWR : constant Interrupt_ID := |
273 | + System.OS_Interface.SIGPWR; -- power fail/restart | | 273 | + System.OS_Interface.SIGPWR; -- power fail/restart |
274 | + | | 274 | + |
275 | +end Ada.Interrupts.Names; | | 275 | +end Ada.Interrupts.Names; |
276 | --- /dev/null | | 276 | --- /dev/null |
277 | +++ gcc/ada/a-intnam-openbsd.ads | | 277 | +++ gcc/ada/a-intnam-openbsd.ads |
278 | @@ -0,0 +1,133 @@ | | 278 | @@ -0,0 +1,133 @@ |
279 | +------------------------------------------------------------------------------ | | 279 | +------------------------------------------------------------------------------ |
280 | +-- -- | | 280 | +-- -- |
281 | +-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS -- | | 281 | +-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS -- |
282 | +-- -- | | 282 | +-- -- |
283 | +-- A D A . I N T E R R U P T S . N A M E S -- | | 283 | +-- A D A . I N T E R R U P T S . N A M E S -- |
284 | +-- -- | | 284 | +-- -- |
285 | +-- S p e c -- | | 285 | +-- S p e c -- |
286 | +-- -- | | 286 | +-- -- |
287 | +-- Copyright (C) 1991-2009, Free Software Foundation, Inc. -- | | 287 | +-- Copyright (C) 1991-2009, Free Software Foundation, Inc. -- |
288 | +-- -- | | 288 | +-- -- |
289 | +-- GNARL is free software; you can redistribute it and/or modify it under -- | | 289 | +-- GNARL is free software; you can redistribute it and/or modify it under -- |
290 | +-- terms of the GNU General Public License as published by the Free Soft- -- | | 290 | +-- terms of the GNU General Public License as published by the Free Soft- -- |
291 | +-- ware Foundation; either version 3, or (at your option) any later ver- -- | | 291 | +-- ware Foundation; either version 3, or (at your option) any later ver- -- |
292 | +-- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- | | 292 | +-- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- |
293 | +-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- | | 293 | +-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- |
294 | +-- or FITNESS FOR A PARTICULAR PURPOSE. -- | | 294 | +-- or FITNESS FOR A PARTICULAR PURPOSE. -- |
295 | +-- -- | | 295 | +-- -- |
296 | +-- As a special exception under Section 7 of GPL version 3, you are granted -- | | 296 | +-- As a special exception under Section 7 of GPL version 3, you are granted -- |
297 | +-- additional permissions described in the GCC Runtime Library Exception, -- | | 297 | +-- additional permissions described in the GCC Runtime Library Exception, -- |
298 | +-- version 3.1, as published by the Free Software Foundation. -- | | 298 | +-- version 3.1, as published by the Free Software Foundation. -- |
299 | +-- -- | | 299 | +-- -- |
300 | +-- You should have received a copy of the GNU General Public License and -- | | 300 | +-- You should have received a copy of the GNU General Public License and -- |
301 | +-- a copy of the GCC Runtime Library Exception along with this program; -- | | 301 | +-- a copy of the GCC Runtime Library Exception along with this program; -- |
302 | +-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- | | 302 | +-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- |
303 | +-- <http://www.gnu.org/licenses/>. -- | | 303 | +-- <http://www.gnu.org/licenses/>. -- |
304 | +-- -- | | 304 | +-- -- |
305 | +-- GNARL was developed by the GNARL team at Florida State University. -- | | 305 | +-- GNARL was developed by the GNARL team at Florida State University. -- |
306 | +-- Extensive contributions were provided by Ada Core Technologies, Inc. -- | | 306 | +-- Extensive contributions were provided by Ada Core Technologies, Inc. -- |
307 | +-- -- | | 307 | +-- -- |
308 | +-- Copyright (C) 2010 John Marino <draco@marino.st> -- | | 308 | +-- Copyright (C) 2010 John Marino <draco@marino.st> -- |
309 | +------------------------------------------------------------------------------ | | 309 | +------------------------------------------------------------------------------ |
310 | + | | 310 | + |
311 | +-- This is the OpenBSD THREADS version of this package | | 311 | +-- This is the OpenBSD THREADS version of this package |
312 | + | | 312 | + |
313 | +with System.OS_Interface; | | 313 | +with System.OS_Interface; |
314 | + | | 314 | + |
315 | +package Ada.Interrupts.Names is | | 315 | +package Ada.Interrupts.Names is |
316 | + | | 316 | + |
317 | + -- Beware that the mapping of names to signals may be many-to-one. There | | 317 | + -- Beware that the mapping of names to signals may be many-to-one. There |
318 | + -- may be aliases. Also, for all signal names that are not supported on | | 318 | + -- may be aliases. Also, for all signal names that are not supported on |
319 | + -- the current system the value of the corresponding constant will be zero. | | 319 | + -- the current system the value of the corresponding constant will be zero. |
320 | + | | 320 | + |
321 | + SIGHUP : constant Interrupt_ID := | | 321 | + SIGHUP : constant Interrupt_ID := |
322 | + System.OS_Interface.SIGHUP; -- hangup | | 322 | + System.OS_Interface.SIGHUP; -- hangup |
323 | + | | 323 | + |
324 | + SIGINT : constant Interrupt_ID := | | 324 | + SIGINT : constant Interrupt_ID := |
325 | + System.OS_Interface.SIGINT; -- interrupt (rubout) | | 325 | + System.OS_Interface.SIGINT; -- interrupt (rubout) |
326 | + | | 326 | + |
327 | + SIGQUIT : constant Interrupt_ID := | | 327 | + SIGQUIT : constant Interrupt_ID := |
328 | + System.OS_Interface.SIGQUIT; -- quit (ASCD FS) | | 328 | + System.OS_Interface.SIGQUIT; -- quit (ASCD FS) |
329 | + | | 329 | + |
330 | + SIGILL : constant Interrupt_ID := | | 330 | + SIGILL : constant Interrupt_ID := |
331 | + System.OS_Interface.SIGILL; -- illegal instruction (not reset) | | 331 | + System.OS_Interface.SIGILL; -- illegal instruction (not reset) |
332 | + | | 332 | + |
333 | + SIGTRAP : constant Interrupt_ID := | | 333 | + SIGTRAP : constant Interrupt_ID := |
334 | + System.OS_Interface.SIGTRAP; -- trace trap (not reset) | | 334 | + System.OS_Interface.SIGTRAP; -- trace trap (not reset) |
335 | + | | 335 | + |
336 | + SIGIOT : constant Interrupt_ID := | | 336 | + SIGIOT : constant Interrupt_ID := |
337 | + System.OS_Interface.SIGIOT; -- IOT instruction | | 337 | + System.OS_Interface.SIGIOT; -- IOT instruction |
338 | + | | 338 | + |
339 | + SIGABRT : constant Interrupt_ID := -- used by abort, | | 339 | + SIGABRT : constant Interrupt_ID := -- used by abort, |
340 | + System.OS_Interface.SIGABRT; -- replace SIGIOT in the future | | 340 | + System.OS_Interface.SIGABRT; -- replace SIGIOT in the future |
341 | + | | 341 | + |
342 | + SIGFPE : constant Interrupt_ID := | | 342 | + SIGFPE : constant Interrupt_ID := |
343 | + System.OS_Interface.SIGFPE; -- floating point exception | | 343 | + System.OS_Interface.SIGFPE; -- floating point exception |
344 | + | | 344 | + |
345 | + SIGKILL : constant Interrupt_ID := | | 345 | + SIGKILL : constant Interrupt_ID := |
346 | + System.OS_Interface.SIGKILL; -- kill (cannot be caught or ignored) | | 346 | + System.OS_Interface.SIGKILL; -- kill (cannot be caught or ignored) |
347 | + | | 347 | + |
348 | + SIGBUS : constant Interrupt_ID := | | 348 | + SIGBUS : constant Interrupt_ID := |
349 | + System.OS_Interface.SIGBUS; -- bus error | | 349 | + System.OS_Interface.SIGBUS; -- bus error |
350 | + | | 350 | + |
351 | + SIGSEGV : constant Interrupt_ID := | | 351 | + SIGSEGV : constant Interrupt_ID := |
352 | + System.OS_Interface.SIGSEGV; -- segmentation violation | | 352 | + System.OS_Interface.SIGSEGV; -- segmentation violation |
353 | + | | 353 | + |
354 | + SIGPIPE : constant Interrupt_ID := -- write on a pipe with | | 354 | + SIGPIPE : constant Interrupt_ID := -- write on a pipe with |
355 | + System.OS_Interface.SIGPIPE; -- no one to read it | | 355 | + System.OS_Interface.SIGPIPE; -- no one to read it |
356 | + | | 356 | + |
357 | + SIGALRM : constant Interrupt_ID := | | 357 | + SIGALRM : constant Interrupt_ID := |
358 | + System.OS_Interface.SIGALRM; -- alarm clock | | 358 | + System.OS_Interface.SIGALRM; -- alarm clock |
359 | + | | 359 | + |
360 | + SIGTERM : constant Interrupt_ID := | | 360 | + SIGTERM : constant Interrupt_ID := |
361 | + System.OS_Interface.SIGTERM; -- software termination signal from kill | | 361 | + System.OS_Interface.SIGTERM; -- software termination signal from kill |
362 | + | | 362 | + |
363 | + SIGURG : constant Interrupt_ID := | | 363 | + SIGURG : constant Interrupt_ID := |
364 | + System.OS_Interface.SIGURG; -- urgent condition on IO channel | | 364 | + System.OS_Interface.SIGURG; -- urgent condition on IO channel |
365 | + | | 365 | + |
366 | + SIGSTOP : constant Interrupt_ID := | | 366 | + SIGSTOP : constant Interrupt_ID := |
367 | + System.OS_Interface.SIGSTOP; -- stop (cannot be caught or ignored) | | 367 | + System.OS_Interface.SIGSTOP; -- stop (cannot be caught or ignored) |
368 | + | | 368 | + |
369 | + SIGTSTP : constant Interrupt_ID := | | 369 | + SIGTSTP : constant Interrupt_ID := |
370 | + System.OS_Interface.SIGTSTP; -- user stop requested from tty | | 370 | + System.OS_Interface.SIGTSTP; -- user stop requested from tty |
371 | + | | 371 | + |
372 | + SIGCONT : constant Interrupt_ID := | | 372 | + SIGCONT : constant Interrupt_ID := |
373 | + System.OS_Interface.SIGCONT; -- stopped process has been continued | | 373 | + System.OS_Interface.SIGCONT; -- stopped process has been continued |
374 | + | | 374 | + |
375 | + SIGCHLD : constant Interrupt_ID := | | 375 | + SIGCHLD : constant Interrupt_ID := |
376 | + System.OS_Interface.SIGCHLD; -- 4.3BSD's/POSIX name for SIGCLD | | 376 | + System.OS_Interface.SIGCHLD; -- 4.3BSD's/POSIX name for SIGCLD |
377 | + | | 377 | + |
378 | + SIGCLD : constant Interrupt_ID := | | 378 | + SIGCLD : constant Interrupt_ID := |
379 | + System.OS_Interface.SIGCLD; -- child status change | | 379 | + System.OS_Interface.SIGCLD; -- child status change |
380 | + | | 380 | + |
381 | + SIGTTIN : constant Interrupt_ID := | | 381 | + SIGTTIN : constant Interrupt_ID := |
382 | + System.OS_Interface.SIGTTIN; -- background tty read attempted | | 382 | + System.OS_Interface.SIGTTIN; -- background tty read attempted |
383 | + | | 383 | + |
384 | + SIGTTOU : constant Interrupt_ID := | | 384 | + SIGTTOU : constant Interrupt_ID := |
385 | + System.OS_Interface.SIGTTOU; -- background tty write attempted | | 385 | + System.OS_Interface.SIGTTOU; -- background tty write attempted |
386 | + | | 386 | + |
387 | + SIGIO : constant Interrupt_ID := -- input/output possible, | | 387 | + SIGIO : constant Interrupt_ID := -- input/output possible, |
388 | + System.OS_Interface.SIGIO; -- SIGPOLL alias (Solaris) | | 388 | + System.OS_Interface.SIGIO; -- SIGPOLL alias (Solaris) |
389 | + | | 389 | + |
390 | + SIGXCPU : constant Interrupt_ID := | | 390 | + SIGXCPU : constant Interrupt_ID := |
391 | + System.OS_Interface.SIGXCPU; -- CPU time limit exceeded | | 391 | + System.OS_Interface.SIGXCPU; -- CPU time limit exceeded |
392 | + | | 392 | + |
393 | + SIGXFSZ : constant Interrupt_ID := | | 393 | + SIGXFSZ : constant Interrupt_ID := |
394 | + System.OS_Interface.SIGXFSZ; -- filesize limit exceeded | | 394 | + System.OS_Interface.SIGXFSZ; -- filesize limit exceeded |
395 | + | | 395 | + |
396 | + SIGVTALRM : constant Interrupt_ID := | | 396 | + SIGVTALRM : constant Interrupt_ID := |
397 | + System.OS_Interface.SIGVTALRM; -- virtual timer expired | | 397 | + System.OS_Interface.SIGVTALRM; -- virtual timer expired |
398 | + | | 398 | + |
399 | + SIGPROF : constant Interrupt_ID := | | 399 | + SIGPROF : constant Interrupt_ID := |
400 | + System.OS_Interface.SIGPROF; -- profiling timer expired | | 400 | + System.OS_Interface.SIGPROF; -- profiling timer expired |
401 | + | | 401 | + |
402 | + SIGWINCH : constant Interrupt_ID := | | 402 | + SIGWINCH : constant Interrupt_ID := |
403 | + System.OS_Interface.SIGWINCH; -- window size change | | 403 | + System.OS_Interface.SIGWINCH; -- window size change |
404 | + | | 404 | + |
405 | + SIGUSR1 : constant Interrupt_ID := | | 405 | + SIGUSR1 : constant Interrupt_ID := |
406 | + System.OS_Interface.SIGUSR1; -- user defined signal 1 | | 406 | + System.OS_Interface.SIGUSR1; -- user defined signal 1 |
407 | + | | 407 | + |
408 | + SIGUSR2 : constant Interrupt_ID := | | 408 | + SIGUSR2 : constant Interrupt_ID := |
409 | + System.OS_Interface.SIGUSR2; -- user defined signal 2 | | 409 | + System.OS_Interface.SIGUSR2; -- user defined signal 2 |
410 | + | | 410 | + |
411 | +end Ada.Interrupts.Names; | | 411 | +end Ada.Interrupts.Names; |
412 | --- gcc/ada/adaint.c.orig | | 412 | --- gcc/ada/adaint.c.orig |
413 | +++ gcc/ada/adaint.c | | 413 | +++ gcc/ada/adaint.c |
414 | @@ -27,6 +27,7 @@ | | 414 | @@ -27,6 +27,7 @@ |
415 | * GNAT was originally developed by the GNAT team at New York University. * | | 415 | * GNAT was originally developed by the GNAT team at New York University. * |
416 | * Extensive contributions were provided by Ada Core Technologies Inc. * | | 416 | * Extensive contributions were provided by Ada Core Technologies Inc. * |
417 | * * | | 417 | * * |
418 | + * Copyright (C) 2010 John Marino <www.dragonlace.net> * | | 418 | + * Copyright (C) 2010 John Marino <www.dragonlace.net> * |
419 | ****************************************************************************/ | | 419 | ****************************************************************************/ |
420 | | | 420 | |
421 | /* This file contains those routines named by Import pragmas in | | 421 | /* This file contains those routines named by Import pragmas in |
422 | @@ -400,7 +401,11 @@ | | 422 | @@ -400,7 +401,11 @@ |
423 | __gnat_current_time | | 423 | __gnat_current_time |
424 | (void) | | 424 | (void) |
425 | { | | 425 | { |
426 | +#if defined(__NetBSD__) && (__NetBSD__ > 5) | | 426 | +#if defined(__NetBSD__) && (__NetBSD__ > 5) |
427 | + time_t res = __time50 (NULL); | | 427 | + time_t res = __time50 (NULL); |
428 | +#else | | 428 | +#else |
429 | time_t res = time (NULL); | | 429 | time_t res = time (NULL); |
430 | +#endif | | 430 | +#endif |
431 | return (OS_Time) res; | | 431 | return (OS_Time) res; |
432 | } | | 432 | } |
433 | | | 433 | |
434 | @@ -1047,6 +1052,7 @@ | | 434 | @@ -1047,6 +1052,7 @@ |
435 | strcpy (path, "GNAT-XXXXXX"); | | 435 | strcpy (path, "GNAT-XXXXXX"); |
436 | | | 436 | |
437 | #if (defined (__FreeBSD__) || defined (__NetBSD__) || defined (__OpenBSD__) \ | | 437 | #if (defined (__FreeBSD__) || defined (__NetBSD__) || defined (__OpenBSD__) \ |
438 | + || defined (__DragonFly__) \ | | 438 | + || defined (__DragonFly__) \ |
439 | || defined (linux) || defined(__GLIBC__)) && !defined (__vxworks) | | 439 | || defined (linux) || defined(__GLIBC__)) && !defined (__vxworks) |
440 | return mkstemp (path); | | 440 | return mkstemp (path); |
441 | #elif defined (__Lynx__) | | 441 | #elif defined (__Lynx__) |
442 | @@ -1195,7 +1201,49 @@ | | 442 | @@ -1195,7 +1201,49 @@ |
443 | free (pname); | | 443 | free (pname); |
444 | } | | 444 | } |
445 | | | 445 | |
446 | +#elif defined (__ANDROID__) | | 446 | +#elif defined (__ANDROID__) |
447 | + | | 447 | + |
448 | + /* | | 448 | + /* |
449 | + * ext2 /ext3/ext4/fat16/fat32 have no path limits | | 449 | + * ext2 /ext3/ext4/fat16/fat32 have no path limits |
450 | + * /data/local/tmp normally requires rooted devices, if it even exists | | 450 | + * /data/local/tmp normally requires rooted devices, if it even exists |
451 | + * /sdcard is the standard location for external storage. Nativeactivity | | 451 | + * /sdcard is the standard location for external storage. Nativeactivity |
452 | + * manifest needs to authorize its use, otherwise it might not have the | | 452 | + * manifest needs to authorize its use, otherwise it might not have the |
453 | + * proper permissions. | | 453 | + * proper permissions. |
454 | + */ | | 454 | + */ |
455 | + | | 455 | + |
456 | + int testfd; | | 456 | + int testfd; |
457 | + char *datadir = getenv ("ANDROID_DATA"); | | 457 | + char *datadir = getenv ("ANDROID_DATA"); |
458 | + | | 458 | + |
459 | + if (datadir == NULL) | | 459 | + if (datadir == NULL) |
460 | + strcpy (tmp_filename, "/data/local/tmp/gnat-XXXXXX"); | | 460 | + strcpy (tmp_filename, "/data/local/tmp/gnat-XXXXXX"); |
461 | + else | | 461 | + else |
462 | + sprintf (tmp_filename, "%s/local/tmp/gnat-XXXXXX", datadir); | | 462 | + sprintf (tmp_filename, "%s/local/tmp/gnat-XXXXXX", datadir); |
463 | + | | 463 | + |
464 | + testfd = mkstemp (tmp_filename); | | 464 | + testfd = mkstemp (tmp_filename); |
465 | + if (testfd != -1) | | 465 | + if (testfd != -1) |
466 | + { | | 466 | + { |
467 | + close (testfd); | | 467 | + close (testfd); |
468 | + return; | | 468 | + return; |
469 | + } | | 469 | + } |
470 | + | | 470 | + |
471 | + char *sdcard = getenv ("EXTERNAL_STORAGE"); | | 471 | + char *sdcard = getenv ("EXTERNAL_STORAGE"); |
472 | + | | 472 | + |
473 | + if (sdcard == NULL) | | 473 | + if (sdcard == NULL) |
474 | + strcpy (tmp_filename, "/sdcard/gnat-XXXXXX"); | | 474 | + strcpy (tmp_filename, "/sdcard/gnat-XXXXXX"); |
475 | + else | | 475 | + else |
476 | + sprintf (tmp_filename, "%s/gnat-XXXXXX", sdcard); | | 476 | + sprintf (tmp_filename, "%s/gnat-XXXXXX", sdcard); |
477 | + | | 477 | + |
478 | + testfd = mkstemp (tmp_filename); | | 478 | + testfd = mkstemp (tmp_filename); |
479 | + if (testfd != -1) | | 479 | + if (testfd != -1) |
480 | + { | | 480 | + { |
481 | + close (testfd); | | 481 | + close (testfd); |
482 | + return; | | 482 | + return; |
483 | + } | | 483 | + } |
484 | + | | 484 | + |
485 | + tmpnam (tmp_filename); | | 485 | + tmpnam (tmp_filename); |
486 | + | | 486 | + |
487 | #elif defined (linux) || defined (__FreeBSD__) || defined (__NetBSD__) \ | | 487 | #elif defined (linux) || defined (__FreeBSD__) || defined (__NetBSD__) \ |
488 | + || defined (__DragonFly__) \ | | 488 | + || defined (__DragonFly__) \ |
489 | || defined (__OpenBSD__) || defined(__GLIBC__) | | 489 | || defined (__OpenBSD__) || defined(__GLIBC__) |
490 | #define MAX_SAFE_PATH 1000 | | 490 | #define MAX_SAFE_PATH 1000 |
491 | char *tmpdir = getenv ("TMPDIR"); | | 491 | char *tmpdir = getenv ("TMPDIR"); |
492 | @@ -1617,9 +1665,12 @@ | | 492 | @@ -1617,9 +1665,12 @@ |
493 | /* Set access time to now in local time. */ | | 493 | /* Set access time to now in local time. */ |
494 | t = time ((time_t) 0); | | 494 | t = time ((time_t) 0); |
495 | utimbuf.actime = mktime (localtime (&t)); | | 495 | utimbuf.actime = mktime (localtime (&t)); |
496 | - | | 496 | - |
497 | +#if defined(__NetBSD__) && (__NetBSD__ > 5) | | 497 | +#if defined(__NetBSD__) && (__NetBSD__ > 5) |
498 | + __utime50 (name, &utimbuf); | | 498 | + __utime50 (name, &utimbuf); |
499 | +#else | | 499 | +#else |
500 | utime (name, &utimbuf); | | 500 | utime (name, &utimbuf); |
501 | #endif | | 501 | #endif |
502 | +#endif | | 502 | +#endif |
503 | } | | 503 | } |
504 | | | 504 | |
505 | /* Get the list of installed standard libraries from the | | 505 | /* Get the list of installed standard libraries from the |
506 | @@ -2384,6 +2435,8 @@ | | 506 | @@ -2384,6 +2435,8 @@ |
507 | int cores = 1; | | 507 | int cores = 1; |
508 | | | 508 | |
509 | #if defined (linux) || defined (sun) || defined (AIX) \ | | 509 | #if defined (linux) || defined (sun) || defined (AIX) \ |
510 | + || defined (__FreeBSD__) || defined (__DragonFly__) \ | | 510 | + || defined (__FreeBSD__) || defined (__DragonFly__) \ |
511 | + || defined (__OpenBSD__) || defined (__NetBSD__) \ | | 511 | + || defined (__OpenBSD__) || defined (__NetBSD__) \ |
512 | || (defined (__alpha__) && defined (_osf_)) || defined (__APPLE__) | | 512 | || (defined (__alpha__) && defined (_osf_)) || defined (__APPLE__) |
513 | cores = (int) sysconf (_SC_NPROCESSORS_ONLN); | | 513 | cores = (int) sysconf (_SC_NPROCESSORS_ONLN); |
514 | | | 514 | |
515 | @@ -3421,25 +3474,214 @@ | | 515 | @@ -3421,25 +3474,214 @@ |
516 | } | | 516 | } |
517 | #endif | | 517 | #endif |
518 | | | 518 | |
519 | -#if defined (IS_CROSS) \ | | 519 | -#if defined (IS_CROSS) \ |
520 | - || (! ((defined (sparc) || defined (i386)) && defined (sun) \ | | 520 | - || (! ((defined (sparc) || defined (i386)) && defined (sun) \ |
521 | - && defined (__SVR4)) \ | | 521 | - && defined (__SVR4)) \ |
522 | - && ! (defined (linux) && (defined (i386) || defined (__x86_64__))) \ | | 522 | - && ! (defined (linux) && (defined (i386) || defined (__x86_64__))) \ |
523 | - && ! (defined (linux) && defined (__ia64__)) \ | | 523 | - && ! (defined (linux) && defined (__ia64__)) \ |
524 | - && ! (defined (linux) && defined (powerpc)) \ | | 524 | - && ! (defined (linux) && defined (powerpc)) \ |
525 | - && ! defined (__FreeBSD__) \ | | 525 | - && ! defined (__FreeBSD__) \ |
526 | - && ! defined (__Lynx__) \ | | 526 | - && ! defined (__Lynx__) \ |
527 | - && ! defined (__hpux__) \ | | 527 | - && ! defined (__hpux__) \ |
528 | - && ! defined (__APPLE__) \ | | 528 | - && ! defined (__APPLE__) \ |
529 | - && ! defined (_AIX) \ | | 529 | - && ! defined (_AIX) \ |
530 | - && ! (defined (__alpha__) && defined (__osf__)) \ | | 530 | - && ! (defined (__alpha__) && defined (__osf__)) \ |
531 | - && ! defined (VMS) \ | | 531 | - && ! defined (VMS) \ |
532 | - && ! defined (__MINGW32__) \ | | 532 | - && ! defined (__MINGW32__) \ |
533 | - && ! (defined (__mips) && defined (__sgi))) | | 533 | - && ! (defined (__mips) && defined (__sgi))) |
534 | - | | 534 | - |
535 | -/* Dummy function to satisfy g-trasym.o. See the preprocessor conditional | | 535 | -/* Dummy function to satisfy g-trasym.o. See the preprocessor conditional |
536 | - just above for a list of native platforms that provide a non-dummy | | 536 | - just above for a list of native platforms that provide a non-dummy |
537 | - version of this procedure in libaddr2line.a. */ | | 537 | - version of this procedure in libaddr2line.a. */ |
538 | +/* run-time symbolic traceback support */ | | 538 | +/* run-time symbolic traceback support */ |
539 | +#if defined (__DragonFly__) \ | | 539 | +#if defined (__DragonFly__) \ |
540 | + || defined (__FreeBSD__) \ | | 540 | + || defined (__FreeBSD__) \ |
541 | + || defined (__OpenBSD__) \ | | 541 | + || defined (__OpenBSD__) \ |
542 | + || defined (__NetBSD__) \ | | 542 | + || defined (__NetBSD__) \ |
543 | + || (defined (__sun__) && defined (__i386__) && defined (__SVR4)) | | 543 | + || (defined (__sun__) && defined (__i386__) && defined (__SVR4)) |
544 | + | | 544 | + |
545 | +/* The above platforms use the external program /usr/bin/addr2line */ | | 545 | +/* The above platforms use the external program /usr/bin/addr2line */ |
546 | +#define EXTERNAL_SYMTRACE | | 546 | +#define EXTERNAL_SYMTRACE |
547 | + | | 547 | + |
548 | +#elif defined (VMS) \ | | 548 | +#elif defined (VMS) \ |
549 | + || defined (_AIX) \ | | 549 | + || defined (_AIX) \ |
550 | + || defined (__Lynx__) \ | | 550 | + || defined (__Lynx__) \ |
551 | + || defined (__hpux__) \ | | 551 | + || defined (__hpux__) \ |
552 | + || defined (__APPLE__) \ | | 552 | + || defined (__APPLE__) \ |
553 | + || defined (__MINGW32__) \ | | 553 | + || defined (__MINGW32__) \ |
554 | + || (defined (__mips) && defined (__sgi)) \ | | 554 | + || (defined (__mips) && defined (__sgi)) \ |
555 | + || (defined (__alpha__) && defined (__osf__)) \ | | 555 | + || (defined (__alpha__) && defined (__osf__)) \ |
556 | + || (defined (linux) && defined (i386)) \ | | 556 | + || (defined (linux) && defined (i386)) \ |
557 | + || (defined (linux) && defined (powerpc)) \ | | 557 | + || (defined (linux) && defined (powerpc)) \ |
558 | + || (defined (linux) && defined (__ia64__)) \ | | 558 | + || (defined (linux) && defined (__ia64__)) \ |
559 | + || (defined (linux) && defined (__x86_64__)) \ | | 559 | + || (defined (linux) && defined (__x86_64__)) \ |
560 | + || (defined (__SVR4) && defined (__sun__) && defined (sparc)) | | 560 | + || (defined (__SVR4) && defined (__sun__) && defined (sparc)) |
561 | + | | 561 | + |
562 | +/* The above platforms use the system library libaddr2line.a */ | | 562 | +/* The above platforms use the system library libaddr2line.a */ |
563 | +#define NATIVE_SYMTRACE | | 563 | +#define NATIVE_SYMTRACE |
564 | +#endif | | 564 | +#endif |
565 | + | | 565 | + |
566 | +#if defined (EXTERNAL_SYMTRACE) && !defined (IS_CROSS) | | 566 | +#if defined (EXTERNAL_SYMTRACE) && !defined (IS_CROSS) |
567 | + | | 567 | + |
568 | +/* | | 568 | +/* |
569 | + Copyright (C) 1999 by Juergen Pfeifer <juergen.pfeifer@gmx.net> | | 569 | + Copyright (C) 1999 by Juergen Pfeifer <juergen.pfeifer@gmx.net> |
570 | + Ada for Linux Team (ALT) | | 570 | + Ada for Linux Team (ALT) |
571 | + Heavily modified by John Marino <http://www.dragonlace.net> | | 571 | + Heavily modified by John Marino <http://www.dragonlace.net> |
572 | + | | 572 | + |
573 | + Permission is hereby granted, free of charge, to any person obtaining a | | 573 | + Permission is hereby granted, free of charge, to any person obtaining a |
574 | + copy of this software and associated documentation files (the | | 574 | + copy of this software and associated documentation files (the |
575 | + "Software"), to deal in the Software without restriction, including | | 575 | + "Software"), to deal in the Software without restriction, including |
576 | + without limitation the rights to use, copy, modify, merge, publish, | | 576 | + without limitation the rights to use, copy, modify, merge, publish, |
577 | + distribute, distribute with modifications, sublicense, and/or sell | | 577 | + distribute, distribute with modifications, sublicense, and/or sell |
578 | + copies of the Software, and to permit persons to whom the Software is | | 578 | + copies of the Software, and to permit persons to whom the Software is |
579 | + furnished to do so, subject to the following conditions: | | 579 | + furnished to do so, subject to the following conditions: |
580 | + | | 580 | + |
581 | + The above copyright notice and this permission notice shall be included | | 581 | + The above copyright notice and this permission notice shall be included |
582 | + in all copies or substantial portions of the Software. | | 582 | + in all copies or substantial portions of the Software. |
583 | + | | 583 | + |
584 | + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | | 584 | + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
585 | + OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | | 585 | + OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
586 | + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | | 586 | + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
587 | + IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, | | 587 | + IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
588 | + DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR | | 588 | + DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR |
589 | + OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR | | 589 | + OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR |
590 | + THE USE OR OTHER DEALINGS IN THE SOFTWARE. | | 590 | + THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
591 | + | | 591 | + |
592 | + Except as contained in this notice, the name(s) of the above copyright | | 592 | + Except as contained in this notice, the name(s) of the above copyright |
593 | + holders shall not be used in advertising or otherwise to promote the | | 593 | + holders shall not be used in advertising or otherwise to promote the |
594 | + sale, use or other dealings in this Software without prior written | | 594 | + sale, use or other dealings in this Software without prior written |
595 | + authorization. | | 595 | + authorization. |
596 | +*/ | | 596 | +*/ |
597 | + | | 597 | + |
598 | +#include <sys/types.h> | | 598 | +#include <sys/types.h> |
599 | +#include <stdlib.h> | | 599 | +#include <stdlib.h> |
600 | +#include <unistd.h> | | 600 | +#include <unistd.h> |
601 | +#include <string.h> | | 601 | +#include <string.h> |
602 | +#include <signal.h> | | 602 | +#include <signal.h> |
603 | + | | 603 | + |
604 | +#define CLOSE_SENDPIPE close(sendpipe[0]); close(sendpipe[1]) | | 604 | +#define CLOSE_SENDPIPE close(sendpipe[0]); close(sendpipe[1]) |
605 | +#define CLOSE_READPIPE close(readpipe[0]); close(readpipe[1]) | | 605 | +#define CLOSE_READPIPE close(readpipe[0]); close(readpipe[1]) |
606 | +#define DUP2CLOSE(oldfd, newfd) dup2(oldfd, newfd); close(oldfd); | | 606 | +#define DUP2CLOSE(oldfd, newfd) dup2(oldfd, newfd); close(oldfd); |
607 | +#define RESTSIG sigaction(SIGPIPE,&oact,NULL) | | 607 | +#define RESTSIG sigaction(SIGPIPE,&oact,NULL) |
608 | + | | 608 | + |
609 | +#define MAX_LINE 1024 | | 609 | +#define MAX_LINE 1024 |
610 | +#define PARENT_READ readpipe[0] | | 610 | +#define PARENT_READ readpipe[0] |
611 | +#define CHILD_WRITE readpipe[1] | | 611 | +#define CHILD_WRITE readpipe[1] |
612 | +#define CHILD_READ sendpipe[0] | | 612 | +#define CHILD_READ sendpipe[0] |
613 | +#define PARENT_WRITE sendpipe[1] | | 613 | +#define PARENT_WRITE sendpipe[1] |
614 | + | | 614 | + |
615 | +#if defined (__sun__) | | 615 | +#if defined (__sun__) |
616 | +#define ADDR2LINE_PROG "/usr/gnu/bin/addr2line" | | 616 | +#define ADDR2LINE_PROG "/usr/gnu/bin/addr2line" |
617 | +#else | | 617 | +#else |
618 | +#define ADDR2LINE_PROG "/usr/bin/addr2line" | | 618 | +#define ADDR2LINE_PROG "/usr/bin/addr2line" |
619 | +#endif | | 619 | +#endif |
620 | + | | 620 | + |
621 | +void | | 621 | +void |
622 | +convert_addresses (const char *file_name, | | 622 | +convert_addresses (const char *file_name, |
623 | + void *addrs, | | 623 | + void *addrs, |
624 | + int n_addr, | | 624 | + int n_addr, |
625 | + void *buf, | | 625 | + void *buf, |
626 | + int *len) | | 626 | + int *len) |
627 | +{ | | 627 | +{ |
628 | + int max_len = *len; | | 628 | + int max_len = *len; |
629 | + pid_t childpid; | | 629 | + pid_t childpid; |
630 | + | | 630 | + |
631 | + struct sigaction act, oact; | | 631 | + struct sigaction act, oact; |
632 | + | | 632 | + |
633 | + int sendpipe[2] = {-1,-1}, /* parent -> child */ | | 633 | + int sendpipe[2] = {-1,-1}, /* parent -> child */ |
634 | + readpipe[2] = {-1,-1}; /* parent <- child */ | | 634 | + readpipe[2] = {-1,-1}; /* parent <- child */ |
635 | + | | 635 | + |
636 | + *len = 0; | | 636 | + *len = 0; |
637 | + act.sa_handler = SIG_IGN; | | 637 | + act.sa_handler = SIG_IGN; |
638 | + sigemptyset(&act.sa_mask); | | 638 | + sigemptyset(&act.sa_mask); |
639 | + act.sa_flags = 0; | | 639 | + act.sa_flags = 0; |
640 | + if (sigaction(SIGPIPE,&act,&oact) < 0) | | 640 | + if (sigaction(SIGPIPE,&act,&oact) < 0) |
641 | + return; | | 641 | + return; |
642 | + | | 642 | + |
643 | + if (pipe(sendpipe) < 0) { RESTSIG; return; } | | 643 | + if (pipe(sendpipe) < 0) { RESTSIG; return; } |
644 | + if (pipe(readpipe) < 0) { CLOSE_SENDPIPE; RESTSIG; return; } | | 644 | + if (pipe(readpipe) < 0) { CLOSE_SENDPIPE; RESTSIG; return; } |
645 | + if ((childpid = fork()) < 0) { | | 645 | + if ((childpid = fork()) < 0) { |
646 | + CLOSE_READPIPE; | | 646 | + CLOSE_READPIPE; |
647 | + CLOSE_SENDPIPE; | | 647 | + CLOSE_SENDPIPE; |
648 | + RESTSIG; | | 648 | + RESTSIG; |
649 | + return; | | 649 | + return; |
650 | + } | | 650 | + } |
651 | + | | 651 | + |
652 | + if (childpid == 0) { /* child process */ | | 652 | + if (childpid == 0) { /* child process */ |
653 | + close(PARENT_WRITE); | | 653 | + close(PARENT_WRITE); |
654 | + close(PARENT_READ); | | 654 | + close(PARENT_READ); |
655 | + if ((CHILD_READ != STDIN_FILENO) && (CHILD_WRITE != STDOUT_FILENO)) { | | 655 | + if ((CHILD_READ != STDIN_FILENO) && (CHILD_WRITE != STDOUT_FILENO)) { |
656 | + if ((CHILD_READ == STDOUT_FILENO) && (CHILD_WRITE == STDIN_FILENO)) { | | 656 | + if ((CHILD_READ == STDOUT_FILENO) && (CHILD_WRITE == STDIN_FILENO)) { |
657 | + const int temp_fd = dup(CHILD_WRITE); | | 657 | + const int temp_fd = dup(CHILD_WRITE); |
658 | + close (CHILD_WRITE); | | 658 | + close (CHILD_WRITE); |
659 | + DUP2CLOSE (CHILD_READ, STDIN_FILENO); | | 659 | + DUP2CLOSE (CHILD_READ, STDIN_FILENO); |
660 | + DUP2CLOSE (temp_fd, STDOUT_FILENO); | | 660 | + DUP2CLOSE (temp_fd, STDOUT_FILENO); |
661 | + } | | 661 | + } |
662 | + else if ((CHILD_READ == STDIN_FILENO) && (CHILD_WRITE > 1)) { | | 662 | + else if ((CHILD_READ == STDIN_FILENO) && (CHILD_WRITE > 1)) { |
663 | + DUP2CLOSE (CHILD_WRITE, STDOUT_FILENO); | | 663 | + DUP2CLOSE (CHILD_WRITE, STDOUT_FILENO); |
664 | + } | | 664 | + } |
665 | + else if ((CHILD_READ > 1) && (CHILD_WRITE == STDOUT_FILENO)) { | | 665 | + else if ((CHILD_READ > 1) && (CHILD_WRITE == STDOUT_FILENO)) { |
666 | + DUP2CLOSE (CHILD_READ, STDIN_FILENO); | | 666 | + DUP2CLOSE (CHILD_READ, STDIN_FILENO); |
667 | + } | | 667 | + } |
668 | + else if ((CHILD_READ > 1) && (CHILD_WRITE == STDIN_FILENO)) { | | 668 | + else if ((CHILD_READ > 1) && (CHILD_WRITE == STDIN_FILENO)) { |
669 | + DUP2CLOSE (CHILD_WRITE, STDOUT_FILENO); | | 669 | + DUP2CLOSE (CHILD_WRITE, STDOUT_FILENO); |
670 | + DUP2CLOSE (CHILD_READ, STDIN_FILENO); | | 670 | + DUP2CLOSE (CHILD_READ, STDIN_FILENO); |
671 | + } | | 671 | + } |
672 | + else { | | 672 | + else { |
673 | + /* CHILD_READ >= 1 and CHILD_WRITE > 1 */ | | 673 | + /* CHILD_READ >= 1 and CHILD_WRITE > 1 */ |
674 | + DUP2CLOSE (CHILD_READ, STDIN_FILENO); | | 674 | + DUP2CLOSE (CHILD_READ, STDIN_FILENO); |
675 | + DUP2CLOSE (CHILD_WRITE, STDOUT_FILENO); | | 675 | + DUP2CLOSE (CHILD_WRITE, STDOUT_FILENO); |
676 | + } | | 676 | + } |
677 | + } | | 677 | + } |
678 | + /* As pointed out by Florian Weimer to JP, it is a security threat to call | | 678 | + /* As pointed out by Florian Weimer to JP, it is a security threat to call |
679 | + the script with a user defined environment and using the path. That | | 679 | + the script with a user defined environment and using the path. That |
680 | + would be Trojans pleasure. Therefore the absolute path to addr2line | | 680 | + would be Trojans pleasure. Therefore the absolute path to addr2line |
681 | + and an empty environment is used. That should be safe. | | 681 | + and an empty environment is used. That should be safe. |
682 | + */ | | 682 | + */ |
683 | + char *const argv[] = { "addr2line", | | 683 | + char *const argv[] = { "addr2line", |
684 | + "-e", file_name, | | 684 | + "-e", file_name, |
685 | + "--demangle=gnat", | | 685 | + "--demangle=gnat", |
686 | + "--functions", | | 686 | + "--functions", |
687 | + "--basenames", | | 687 | + "--basenames", |
688 | + NULL }; | | 688 | + NULL }; |
689 | + char *const envp[] = { NULL }; | | 689 | + char *const envp[] = { NULL }; |
690 | + if (execve(ADDR2LINE_PROG, argv, envp) < 0) { | | 690 | + if (execve(ADDR2LINE_PROG, argv, envp) < 0) { |
691 | + close (CHILD_WRITE); | | 691 | + close (CHILD_WRITE); |
692 | + close (CHILD_READ); | | 692 | + close (CHILD_READ); |
693 | + RESTSIG; | | 693 | + RESTSIG; |
694 | + exit (1); | | 694 | + exit (1); |
695 | + } | | 695 | + } |
696 | + } | | 696 | + } |
697 | + | | 697 | + |
698 | + /* Below this line is parent process */ | | 698 | + /* Below this line is parent process */ |
699 | + int i, n; | | 699 | + int i, n; |
700 | + char hex[16]; | | 700 | + char hex[16]; |
701 | + char line[MAX_LINE + 1]; | | 701 | + char line[MAX_LINE + 1]; |
702 | + char *p; | | 702 | + char *p; |
703 | + char *s = buf; | | 703 | + char *s = buf; |
704 | + long *trace_address = addrs; | | 704 | + long *trace_address = addrs; |
705 | + | | 705 | + |
706 | + close(CHILD_WRITE); | | 706 | + close(CHILD_WRITE); |
707 | + close(CHILD_READ); | | 707 | + close(CHILD_READ); |
708 | + | | 708 | + |
709 | + for(i=0; i < n_addr; i++) { | | 709 | + for(i=0; i < n_addr; i++) { |
710 | + snprintf(hex,sizeof(hex),"%#lx\n",*trace_address); | | 710 | + snprintf(hex,sizeof(hex),"%#lx\n",*trace_address); |
711 | + write(PARENT_WRITE,hex,strlen(hex)); | | 711 | + write(PARENT_WRITE,hex,strlen(hex)); |
712 | + n = read(PARENT_READ,line,MAX_LINE); | | 712 | + n = read(PARENT_READ,line,MAX_LINE); |
713 | + if (n<=0) | | 713 | + if (n<=0) |
714 | + break; | | 714 | + break; |
715 | + | | 715 | + |
716 | + line[n]=0; | | 716 | + line[n]=0; |
717 | + /* We have approx. 16 additional chars for "%#lx in " clause. | | 717 | + /* We have approx. 16 additional chars for "%#lx in " clause. |
718 | + We use this info to prevent a buffer overrun. */ | | 718 | + We use this info to prevent a buffer overrun. */ |
719 | + if (n + 16 + (*len) > max_len) | | 719 | + if (n + 16 + (*len) > max_len) |
720 | + break; | | 720 | + break; |
721 | + | | 721 | + |
722 | + p = strchr(line,'\n'); | | 722 | + p = strchr(line,'\n'); |
723 | + if (p) { | | 723 | + if (p) { |
724 | + if (*(p+1)) { | | 724 | + if (*(p+1)) { |
725 | + *p = 0; | | 725 | + *p = 0; |
726 | + *len += snprintf(s, (max_len - (*len)), "%#lx in %s at %s", | | 726 | + *len += snprintf(s, (max_len - (*len)), "%#lx in %s at %s", |
727 | + *trace_address, line, p+1); | | 727 | + *trace_address, line, p+1); |
728 | + } | | 728 | + } |
729 | + else { | | 729 | + else { |
730 | + *len += snprintf(s, (max_len - (*len)), "%#lx at %s", | | 730 | + *len += snprintf(s, (max_len - (*len)), "%#lx at %s", |
731 | + *trace_address, line); | | 731 | + *trace_address, line); |
732 | + } | | 732 | + } |
733 | + s = buf + (*len); | | 733 | + s = buf + (*len); |
734 | + } | | 734 | + } |
735 | + trace_address += 1; | | 735 | + trace_address += 1; |
736 | + } | | 736 | + } |
737 | + close (PARENT_WRITE); | | 737 | + close (PARENT_WRITE); |
738 | + close (PARENT_READ); | | 738 | + close (PARENT_READ); |
739 | + RESTSIG; | | 739 | + RESTSIG; |
740 | +} | | 740 | +} |
741 | + | | 741 | + |
742 | +#elif defined (IS_CROSS) || !defined (NATIVE_SYMTRACE) | | 742 | +#elif defined (IS_CROSS) || !defined (NATIVE_SYMTRACE) |
743 | + | | 743 | + |
744 | +/* run-time symbolic traceback support | | 744 | +/* run-time symbolic traceback support |
745 | + Dummy function to satisfy g-trasym.o. */ | | 745 | + Dummy function to satisfy g-trasym.o. */ |
746 | | | 746 | |
747 | void | | 747 | void |
748 | convert_addresses (const char *file_name ATTRIBUTE_UNUSED, | | 748 | convert_addresses (const char *file_name ATTRIBUTE_UNUSED, |
749 | @@ -3686,3 +3928,110 @@ | | 749 | @@ -3686,3 +3928,110 @@ |
750 | return (void *) syscall (__NR_gettid); | | 750 | return (void *) syscall (__NR_gettid); |
751 | } | | 751 | } |
752 | #endif | | 752 | #endif |
753 | + | | 753 | + |
754 | + | | 754 | + |
755 | + | | 755 | + |
756 | + | | 756 | + |
757 | +#ifdef MARINO_DISABLED_THIS | | 757 | +#ifdef MARINO_DISABLED_THIS |
758 | +/* JRM 31 OCT 2010: For some reason, gnatmake wouldn't function correct when | | 758 | +/* JRM 31 OCT 2010: For some reason, gnatmake wouldn't function correct when |
759 | + strcpy or sprintf & friends were replaced. I had to back out the patches. | | 759 | + strcpy or sprintf & friends were replaced. I had to back out the patches. |
760 | + I'll leave the BSD routines here in case we ever want to try again. */ | | 760 | + I'll leave the BSD routines here in case we ever want to try again. */ |
761 | + | | 761 | + |
762 | + | | 762 | + |
763 | +/* | | 763 | +/* |
764 | + * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com> | | 764 | + * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com> |
765 | + * | | 765 | + * |
766 | + * Permission to use, copy, modify, and distribute this software for any | | 766 | + * Permission to use, copy, modify, and distribute this software for any |
767 | + * purpose with or without fee is hereby granted, provided that the above | | 767 | + * purpose with or without fee is hereby granted, provided that the above |
768 | + * copyright notice and this permission notice appear in all copies. | | 768 | + * copyright notice and this permission notice appear in all copies. |
769 | + * | | 769 | + * |
770 | + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | | 770 | + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
771 | + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | | 771 | + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
772 | + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | | 772 | + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
773 | + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | | 773 | + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
774 | + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | | 774 | + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
775 | + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | | 775 | + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
776 | + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | | 776 | + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
777 | + */ | | 777 | + */ |
778 | + | | 778 | + |
779 | +/* | | 779 | +/* |
780 | + * original function name: strlcpy | | 780 | + * original function name: strlcpy |
781 | + * Copy src to string dst of size siz. At most siz-1 characters | | 781 | + * Copy src to string dst of size siz. At most siz-1 characters |
782 | + * will be copied. Always NUL terminates (unless siz == 0). | | 782 | + * will be copied. Always NUL terminates (unless siz == 0). |
783 | + * Returns strlen(src); if retval >= siz, truncation occurred. | | 783 | + * Returns strlen(src); if retval >= siz, truncation occurred. |
784 | + * | | 784 | + * |
785 | + * $OpenBSD: strlcpy.c,v 1.11 2006/05/05 15:27:38 millert Exp $ | | 785 | + * OpenBSD: strlcpy.c,v 1.11 2006/05/05 15:27:38 millert Exp |
786 | + * $FreeBSD: src/lib/libc/string/strlcpy.c,v 1.10 2008/10/19 delphij Exp $ | | 786 | + * FreeBSD: src/lib/libc/string/strlcpy.c,v 1.10 2008/10/19 delphij Exp |
787 | + * $DragonFly: src/lib/libc/string/strlcpy.c,v 1.4 2005/09/18 asmodai Exp $ | | 787 | + * DragonFly: src/lib/libc/string/strlcpy.c,v 1.4 2005/09/18 asmodai Exp |
788 | + */ | | 788 | + */ |
789 | + | | 789 | + |
790 | +size_t | | 790 | +size_t |
791 | +bsd_strlcpy(char *dst, const char *src, size_t siz) | | 791 | +bsd_strlcpy(char *dst, const char *src, size_t siz) |
792 | +{ | | 792 | +{ |
793 | + char *d = dst; | | 793 | + char *d = dst; |
794 | + const char *s = src; | | 794 | + const char *s = src; |
795 | + size_t n = siz; | | 795 | + size_t n = siz; |
796 | + | | 796 | + |
797 | + /* Copy as many bytes as will fit */ | | 797 | + /* Copy as many bytes as will fit */ |
798 | + if (n != 0) { | | 798 | + if (n != 0) { |
799 | + while (--n != 0) { | | 799 | + while (--n != 0) { |
800 | + if ((*d++ = *s++) == '\0') | | 800 | + if ((*d++ = *s++) == '\0') |
801 | + break; | | 801 | + break; |
802 | + } | | 802 | + } |
803 | + } | | 803 | + } |
804 | + | | 804 | + |
805 | + /* Not enough room in dst, add NUL and traverse rest of src */ | | 805 | + /* Not enough room in dst, add NUL and traverse rest of src */ |
806 | + if (n == 0) { | | 806 | + if (n == 0) { |
807 | + if (siz != 0) | | 807 | + if (siz != 0) |
808 | + *d = '\0'; /* NUL-terminate dst */ | | 808 | + *d = '\0'; /* NUL-terminate dst */ |
809 | + while (*s++) | | 809 | + while (*s++) |
810 | + ; | | 810 | + ; |
811 | + } | | 811 | + } |
812 | + | | 812 | + |
813 | + return(s - src - 1); /* count does not include NUL */ | | 813 | + return(s - src - 1); /* count does not include NUL */ |
814 | +} | | 814 | +} |
815 | + | | 815 | + |
816 | + | | 816 | + |
817 | + | | 817 | + |
818 | +/* | | 818 | +/* |
819 | + * Original function name: strlcat | | 819 | + * Original function name: strlcat |
820 | + * Appends src to string dst of size siz (unlike strncat, siz is the | | 820 | + * Appends src to string dst of size siz (unlike strncat, siz is the |
821 | + * full size of dst, not space left). At most siz-1 characters | | 821 | + * full size of dst, not space left). At most siz-1 characters |
822 | + * will be copied. Always NUL terminates (unless siz <= strlen(dst)). | | 822 | + * will be copied. Always NUL terminates (unless siz <= strlen(dst)). |
823 | + * Returns strlen(src) + MIN(siz, strlen(initial dst)). | | 823 | + * Returns strlen(src) + MIN(siz, strlen(initial dst)). |
824 | + * If retval >= siz, truncation occurred. | | 824 | + * If retval >= siz, truncation occurred. |
825 | + * | | 825 | + * |
826 | + * $OpenBSD: strlcat.c,v 1.13 2005/08/08 08:05:37 espie Exp $ | | 826 | + * OpenBSD: strlcat.c,v 1.13 2005/08/08 08:05:37 espie Exp |
827 | + * $FreeBSD: src/lib/libc/string/strlcat.c,v 1.11 2009/01/12 delphij Exp $ | | 827 | + * FreeBSD: src/lib/libc/string/strlcat.c,v 1.11 2009/01/12 delphij Exp |
828 | + * $DragonFly: src/lib/libc/string/strlcat.c,v 1.4 2004/12/18 asmodai Exp $ | | 828 | + * DragonFly: src/lib/libc/string/strlcat.c,v 1.4 2004/12/18 asmodai Exp |
829 | + */ | | 829 | + */ |
830 | + | | 830 | + |
831 | +size_t | | 831 | +size_t |
832 | +bsd_strlcat(char *dst, const char *src, size_t siz) | | 832 | +bsd_strlcat(char *dst, const char *src, size_t siz) |
833 | +{ | | 833 | +{ |
834 | + char *d = dst; | | 834 | + char *d = dst; |
835 | + const char *s = src; | | 835 | + const char *s = src; |
836 | + size_t n = siz; | | 836 | + size_t n = siz; |
837 | + size_t dlen; | | 837 | + size_t dlen; |
838 | + | | 838 | + |
839 | + /* Find the end of dst and adjust bytes left but don't go past end */ | | 839 | + /* Find the end of dst and adjust bytes left but don't go past end */ |
840 | + while (n-- != 0 && *d != '\0') | | 840 | + while (n-- != 0 && *d != '\0') |
841 | + d++; | | 841 | + d++; |
842 | + dlen = d - dst; | | 842 | + dlen = d - dst; |
843 | + n = siz - dlen; | | 843 | + n = siz - dlen; |
844 | + | | 844 | + |
845 | + if (n == 0) | | 845 | + if (n == 0) |
846 | + return(dlen + strlen(s)); | | 846 | + return(dlen + strlen(s)); |
847 | + while (*s != '\0') { | | 847 | + while (*s != '\0') { |
848 | + if (n != 1) { | | 848 | + if (n != 1) { |
849 | + *d++ = *s; | | 849 | + *d++ = *s; |
850 | + n--; | | 850 | + n--; |
851 | + } | | 851 | + } |
852 | + s++; | | 852 | + s++; |
853 | + } | | 853 | + } |
854 | + *d = '\0'; | | 854 | + *d = '\0'; |
855 | + | | 855 | + |
856 | + return(dlen + (s - src)); /* count does not include NUL */ | | 856 | + return(dlen + (s - src)); /* count does not include NUL */ |
857 | +} | | 857 | +} |
858 | +#endif | | 858 | +#endif |
859 | + | | 859 | + |
860 | --- gcc/ada/cio.c.orig | | 860 | --- gcc/ada/cio.c.orig |
861 | +++ gcc/ada/cio.c | | 861 | +++ gcc/ada/cio.c |
862 | @@ -27,6 +27,7 @@ | | 862 | @@ -27,6 +27,7 @@ |
863 | * GNAT was originally developed by the GNAT team at New York University. * | | 863 | * GNAT was originally developed by the GNAT team at New York University. * |
864 | * Extensive contributions were provided by Ada Core Technologies Inc. * | | 864 | * Extensive contributions were provided by Ada Core Technologies Inc. * |
865 | * * | | 865 | * * |
866 | + * Copyright (C) 2011 John Marino <www.dragonlace.net> * | | 866 | + * Copyright (C) 2011 John Marino <www.dragonlace.net> * |
867 | ****************************************************************************/ | | 867 | ****************************************************************************/ |
868 | | | 868 | |
869 | #ifdef IN_RTS | | 869 | #ifdef IN_RTS |
870 | @@ -42,7 +43,8 @@ | | 870 | @@ -42,7 +43,8 @@ |
871 | | | 871 | |
872 | /* Don't use macros on GNU/Linux since they cause incompatible changes between | | 872 | /* Don't use macros on GNU/Linux since they cause incompatible changes between |
873 | glibc 2.0 and 2.1 */ | | 873 | glibc 2.0 and 2.1 */ |
874 | -#ifdef linux | | 874 | -#ifdef linux |
875 | +/* Android is The exception because it uses the BIONIC library */ | | 875 | +/* Android is The exception because it uses the BIONIC library */ |
876 | +#if defined(linux) && !defined(__ANDROID__) | | 876 | +#if defined(linux) && !defined(__ANDROID__) |
877 | #undef putchar | | 877 | #undef putchar |
878 | #undef getchar | | 878 | #undef getchar |
879 | #undef fputc | | 879 | #undef fputc |
880 | --- gcc/ada/cstreams.c.orig | | 880 | --- gcc/ada/cstreams.c.orig |
881 | +++ gcc/ada/cstreams.c | | 881 | +++ gcc/ada/cstreams.c |
882 | @@ -27,6 +27,7 @@ | | 882 | @@ -27,6 +27,7 @@ |
883 | * GNAT was originally developed by the GNAT team at New York University. * | | 883 | * GNAT was originally developed by the GNAT team at New York University. * |
884 | * Extensive contributions were provided by Ada Core Technologies Inc. * | | 884 | * Extensive contributions were provided by Ada Core Technologies Inc. * |
885 | * * | | 885 | * * |
886 | + * Copyright (C) 2010 John Marino <draco@marino.st> * | | 886 | + * Copyright (C) 2010 John Marino <draco@marino.st> * |
887 | ****************************************************************************/ | | 887 | ****************************************************************************/ |
888 | | | 888 | |
889 | /* Routines required for implementing routines in Interfaces.C.Streams */ | | 889 | /* Routines required for implementing routines in Interfaces.C.Streams */ |
890 | @@ -50,9 +51,10 @@ | | 890 | @@ -50,9 +51,10 @@ |
891 | #include <unixlib.h> | | 891 | #include <unixlib.h> |
892 | #endif | | 892 | #endif |
893 | | | 893 | |
894 | -#ifdef linux | | 894 | -#ifdef linux |
895 | +#if defined(linux) && !defined(__ANDROID__) | | 895 | +#if defined(linux) && !defined(__ANDROID__) |
896 | /* Don't use macros on GNU/Linux since they cause incompatible changes between | | 896 | /* Don't use macros on GNU/Linux since they cause incompatible changes between |
897 | glibc 2.0 and 2.1 */ | | 897 | glibc 2.0 and 2.1 */ |
898 | +/* Android is The exception because it uses the BIONIC library */ | | 898 | +/* Android is The exception because it uses the BIONIC library */ |
899 | | | 899 | |
900 | #ifdef stderr | | 900 | #ifdef stderr |
901 | # undef stderr | | 901 | # undef stderr |
902 | @@ -173,7 +175,9 @@ | | 902 | @@ -173,7 +175,9 @@ |
903 | *p = '\\'; | | 903 | *p = '\\'; |
904 | } | | 904 | } |
905 | | | 905 | |
906 | -#elif defined (sgi) || defined (__FreeBSD__) | | 906 | -#elif defined (sgi) || defined (__FreeBSD__) |
907 | +#elif defined (sgi) || defined (__FreeBSD__) \ | | 907 | +#elif defined (sgi) || defined (__FreeBSD__) \ |
908 | + || defined (__DragonFly__) \ | | 908 | + || defined (__DragonFly__) \ |
909 | + || defined (__OpenBSD__) | | 909 | + || defined (__OpenBSD__) |
910 | | | 910 | |
911 | /* Use realpath function which resolves links and references to . and .. | | 911 | /* Use realpath function which resolves links and references to . and .. |
912 | on those Unix systems that support it. Note that GNU/Linux provides it but | | 912 | on those Unix systems that support it. Note that GNU/Linux provides it but |
913 | --- gcc/ada/env.c.orig | | 913 | --- gcc/ada/env.c.orig |
914 | +++ gcc/ada/env.c | | 914 | +++ gcc/ada/env.c |
915 | @@ -27,6 +27,7 @@ | | 915 | @@ -27,6 +27,7 @@ |
916 | * GNAT was originally developed by the GNAT team at New York University. * | | 916 | * GNAT was originally developed by the GNAT team at New York University. * |
917 | * Extensive contributions were provided by Ada Core Technologies Inc. * | | 917 | * Extensive contributions were provided by Ada Core Technologies Inc. * |
918 | * * | | 918 | * * |
919 | + * Copyright (C) 2010 John Marino <draco@marino.st> * | | 919 | + * Copyright (C) 2010 John Marino <draco@marino.st> * |
920 | ****************************************************************************/ | | 920 | ****************************************************************************/ |
921 | | | 921 | |
922 | /* Tru64 UNIX V4.0F <stdlib.h> declares unsetenv() only if AES_SOURCE (which | | 922 | /* Tru64 UNIX V4.0F <stdlib.h> declares unsetenv() only if AES_SOURCE (which |
923 | @@ -172,7 +173,8 @@ | | 923 | @@ -172,7 +173,8 @@ |
924 | LIB$SIGNAL (status); | | 924 | LIB$SIGNAL (status); |
925 | } | | 925 | } |
926 | | | 926 | |
927 | -#elif (defined (__vxworks) && defined (__RTP__)) || defined (__APPLE__) | | 927 | -#elif (defined (__vxworks) && defined (__RTP__)) || defined (__APPLE__) |
928 | +#elif (defined (__vxworks) && defined (__RTP__)) || defined (__APPLE__) \ | | 928 | +#elif (defined (__vxworks) && defined (__RTP__)) || defined (__APPLE__) \ |
929 | + || defined (__OpenBSD__) | | 929 | + || defined (__OpenBSD__) |
930 | setenv (name, value, 1); | | 930 | setenv (name, value, 1); |
931 | | | 931 | |
932 | #else | | 932 | #else |
933 | @@ -299,6 +301,7 @@ | | 933 | @@ -299,6 +301,7 @@ |
934 | } | | 934 | } |
935 | #elif defined (__MINGW32__) || defined (__FreeBSD__) || defined (__APPLE__) \ | | 935 | #elif defined (__MINGW32__) || defined (__FreeBSD__) || defined (__APPLE__) \ |
936 | || (defined (__vxworks) && defined (__RTP__)) || defined (__CYGWIN__) \ | | 936 | || (defined (__vxworks) && defined (__RTP__)) || defined (__CYGWIN__) \ |
937 | + || defined (__DragonFly__) \ | | 937 | + || defined (__DragonFly__) \ |
938 | || defined (__NetBSD__) || defined (__OpenBSD__) || defined (__rtems__) | | 938 | || defined (__NetBSD__) || defined (__OpenBSD__) || defined (__rtems__) |
939 | /* On Windows, FreeBSD and MacOS there is no function to clean all the | | 939 | /* On Windows, FreeBSD and MacOS there is no function to clean all the |
940 | environment but there is a "clean" way to unset a variable. So go | | 940 | environment but there is a "clean" way to unset a variable. So go |
941 | --- gcc/ada/errno.c.orig | | 941 | --- gcc/ada/errno.c.orig |
942 | +++ gcc/ada/errno.c | | 942 | +++ gcc/ada/errno.c |
943 | @@ -27,6 +27,7 @@ | | 943 | @@ -27,6 +27,7 @@ |
944 | * GNAT was originally developed by the GNAT team at New York University. * | | 944 | * GNAT was originally developed by the GNAT team at New York University. * |
945 | * Extensive contributions were provided by Ada Core Technologies Inc. * | | 945 | * Extensive contributions were provided by Ada Core Technologies Inc. * |
946 | * * | | 946 | * * |
947 | + * Copyright (C) 2011 John Marino <www.dragonlace.net> * | | 947 | + * Copyright (C) 2011 John Marino <www.dragonlace.net> * |
948 | ****************************************************************************/ | | 948 | ****************************************************************************/ |
949 | | | 949 | |
950 | /* This file provides access to the C-language errno to the Ada interface | | 950 | /* This file provides access to the C-language errno to the Ada interface |
951 | @@ -39,6 +40,7 @@ | | 951 | @@ -39,6 +40,7 @@ |
952 | #define _REENTRANT | | 952 | #define _REENTRANT |
953 | #define _THREAD_SAFE | | 953 | #define _THREAD_SAFE |
954 | #define _SGI_MP_SOURCE | | 954 | #define _SGI_MP_SOURCE |
955 | +#define GNAT_SET_ERRNO | | 955 | +#define GNAT_SET_ERRNO |
956 | | | 956 | |
957 | #ifdef MaRTE | | 957 | #ifdef MaRTE |
958 | | | 958 | |
959 | @@ -52,6 +54,17 @@ | | 959 | @@ -52,6 +54,17 @@ |
960 | | | 960 | |
961 | #endif | | 961 | #endif |
962 | | | 962 | |
963 | +#ifdef __ANDROID__ | | 963 | +#ifdef __ANDROID__ |
964 | + | | 964 | + |
965 | +/* The ANDROID errno.h file also defines __set_errno as an external variable | | 965 | +/* The ANDROID errno.h file also defines __set_errno as an external variable |
966 | + for use with syscalls. It should not be referenced directly, but we are | | 966 | + for use with syscalls. It should not be referenced directly, but we are |
967 | + going to do it anyway because the alternative solution is to rename all | | 967 | + going to do it anyway because the alternative solution is to rename all |
968 | + uses of __set_errno in GNAT. */ | | 968 | + uses of __set_errno in GNAT. */ |
969 | + | | 969 | + |
970 | +#undef GNAT_SET_ERRNO | | 970 | +#undef GNAT_SET_ERRNO |
971 | +#endif | | 971 | +#endif |
972 | + | | 972 | + |
973 | + | | 973 | + |
974 | #include <errno.h> | | 974 | #include <errno.h> |
975 | int | | 975 | int |
976 | __get_errno(void) | | 976 | __get_errno(void) |
977 | @@ -59,8 +72,10 @@ | | 977 | @@ -59,8 +72,10 @@ |
978 | return errno; | | 978 | return errno; |
979 | } | | 979 | } |
980 | | | 980 | |
981 | +#ifdef GNAT_SET_ERRNO | | 981 | +#ifdef GNAT_SET_ERRNO |
982 | void | | 982 | void |
983 | __set_errno(int err) | | 983 | __set_errno(int err) |
984 | { | | 984 | { |
985 | errno = err; | | 985 | errno = err; |
986 | } | | 986 | } |
987 | +#endif | | 987 | +#endif |
988 | --- gcc/ada/g-comlin.adb.orig | | 988 | --- gcc/ada/g-comlin.adb.orig |
989 | +++ gcc/ada/g-comlin.adb | | 989 | +++ gcc/ada/g-comlin.adb |
990 | @@ -27,6 +27,7 @@ | | 990 | @@ -27,6 +27,7 @@ |
991 | -- GNAT was originally developed by the GNAT team at New York University. -- | | 991 | -- GNAT was originally developed by the GNAT team at New York University. -- |
992 | -- Extensive contributions were provided by Ada Core Technologies Inc. -- | | 992 | -- Extensive contributions were provided by Ada Core Technologies Inc. -- |
993 | -- -- | | 993 | -- -- |
994 | +-- Copyright (C) 2010 John Marino <draco@marino.st> -- | | 994 | +-- Copyright (C) 2010 John Marino <draco@marino.st> -- |
995 | ------------------------------------------------------------------------------ | | 995 | ------------------------------------------------------------------------------ |
996 | | | 996 | |
997 | with Ada.Characters.Handling; use Ada.Characters.Handling; | | 997 | with Ada.Characters.Handling; use Ada.Characters.Handling; |
998 | @@ -512,6 +513,7 @@ | | 998 | @@ -512,6 +513,7 @@ |
999 | begin | | 999 | begin |
1000 | Index_In_Switches := 0; | | 1000 | Index_In_Switches := 0; |
1001 | Switch_Length := 0; | | 1001 | Switch_Length := 0; |
1002 | + Param := Parameter_None; | | 1002 | + Param := Parameter_None; |
1003 | | | 1003 | |
1004 | -- Remove all leading spaces first to make sure that Index points | | 1004 | -- Remove all leading spaces first to make sure that Index points |
1005 | -- at the start of the first switch. | | 1005 | -- at the start of the first switch. |
1006 | --- gcc/ada/g-expect.adb.orig | | 1006 | --- gcc/ada/g-expect.adb.orig |
1007 | +++ gcc/ada/g-expect.adb | | 1007 | +++ gcc/ada/g-expect.adb |
1008 | @@ -29,6 +29,7 @@ | | 1008 | @@ -29,6 +29,7 @@ |
1009 | -- GNAT was originally developed by the GNAT team at New York University. -- | | 1009 | -- GNAT was originally developed by the GNAT team at New York University. -- |
1010 | -- Extensive contributions were provided by Ada Core Technologies Inc. -- | | 1010 | -- Extensive contributions were provided by Ada Core Technologies Inc. -- |
1011 | -- -- | | 1011 | -- -- |
1012 | +-- Copyright (C) 2010 John Marino <draco@marino.st> -- | | 1012 | +-- Copyright (C) 2010 John Marino <draco@marino.st> -- |
1013 | ------------------------------------------------------------------------------ | | 1013 | ------------------------------------------------------------------------------ |
1014 | | | 1014 | |
1015 | with System; use System; | | 1015 | with System; use System; |
1016 | @@ -1333,15 +1334,21 @@ | | 1016 | @@ -1333,15 +1334,21 @@ |
1017 | | | 1017 | |
1018 | -- The following commands are not executed on Unix systems, and are only | | 1018 | -- The following commands are not executed on Unix systems, and are only |
1019 | -- required for Windows systems. We are now in the parent process. | | 1019 | -- required for Windows systems. We are now in the parent process. |
1020 | + -- Although the if-statement is redundant, it's here so the compiler | | 1020 | + -- Although the if-statement is redundant, it's here so the compiler |
1021 | + -- doesn't complain about uninitialized variables. | | 1021 | + -- doesn't complain about uninitialized variables. |
1022 | | | 1022 | |
1023 | - -- Restore the old descriptors | | 1023 | - -- Restore the old descriptors |
1024 | + if No_Fork_On_Target then | | 1024 | + if No_Fork_On_Target then |
1025 | + | | 1025 | + |
1026 | + -- Restore the old descriptors | | 1026 | + -- Restore the old descriptors |
1027 | + | | 1027 | + |
1028 | + Dup2 (Input, GNAT.OS_Lib.Standin); | | 1028 | + Dup2 (Input, GNAT.OS_Lib.Standin); |
1029 | + Dup2 (Output, GNAT.OS_Lib.Standout); | | 1029 | + Dup2 (Output, GNAT.OS_Lib.Standout); |
1030 | + Dup2 (Error, GNAT.OS_Lib.Standerr); | | 1030 | + Dup2 (Error, GNAT.OS_Lib.Standerr); |
1031 | + Close (Input); | | 1031 | + Close (Input); |
1032 | + Close (Output); | | 1032 | + Close (Output); |
1033 | + Close (Error); | | 1033 | + Close (Error); |
1034 | + end if; | | 1034 | + end if; |
1035 | | | 1035 | |
1036 | - Dup2 (Input, GNAT.OS_Lib.Standin); | | 1036 | - Dup2 (Input, GNAT.OS_Lib.Standin); |
1037 | - Dup2 (Output, GNAT.OS_Lib.Standout); | | 1037 | - Dup2 (Output, GNAT.OS_Lib.Standout); |
1038 | - Dup2 (Error, GNAT.OS_Lib.Standerr); | | 1038 | - Dup2 (Error, GNAT.OS_Lib.Standerr); |
1039 | - Close (Input); | | 1039 | - Close (Input); |
1040 | - Close (Output); | | 1040 | - Close (Output); |
1041 | - Close (Error); | | 1041 | - Close (Error); |
1042 | end Set_Up_Child_Communications; | | 1042 | end Set_Up_Child_Communications; |
1043 | | | 1043 | |
1044 | --------------------------- | | 1044 | --------------------------- |
1045 | --- /dev/null | | 1045 | --- /dev/null |
1046 | +++ gcc/ada/g-socthi-bsd.adb | | 1046 | +++ gcc/ada/g-socthi-bsd.adb |
1047 | @@ -0,0 +1,379 @@ | | 1047 | @@ -0,0 +1,379 @@ |
1048 | +------------------------------------------------------------------------------ | | 1048 | +------------------------------------------------------------------------------ |
1049 | +-- -- | | 1049 | +-- -- |
1050 | +-- GNAT COMPILER COMPONENTS -- | | 1050 | +-- GNAT COMPILER COMPONENTS -- |
1051 | +-- -- | | 1051 | +-- -- |
1052 | +-- G N A T . S O C K E T S . T H I N -- | | 1052 | +-- G N A T . S O C K E T S . T H I N -- |
1053 | +-- -- | | 1053 | +-- -- |
1054 | +-- B o d y -- | | 1054 | +-- B o d y -- |
1055 | +-- -- | | 1055 | +-- -- |
1056 | +-- Copyright (C) 2001-2009, AdaCore -- | | 1056 | +-- Copyright (C) 2001-2009, AdaCore -- |
1057 | +-- -- | | 1057 | +-- -- |
1058 | +-- GNAT is free software; you can redistribute it and/or modify it under -- | | 1058 | +-- GNAT is free software; you can redistribute it and/or modify it under -- |
1059 | +-- terms of the GNU General Public License as published by the Free Soft- -- | | 1059 | +-- terms of the GNU General Public License as published by the Free Soft- -- |
1060 | +-- ware Foundation; either version 2, or (at your option) any later ver- -- | | 1060 | +-- ware Foundation; either version 2, or (at your option) any later ver- -- |
1061 | +-- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- | | 1061 | +-- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- |
1062 | +-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- | | 1062 | +-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- |
1063 | +-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- | | 1063 | +-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- |
1064 | +-- for more details. You should have received a copy of the GNU General -- | | 1064 | +-- for more details. You should have received a copy of the GNU General -- |
1065 | +-- Public License distributed with GNAT; see file COPYING. If not, write -- | | 1065 | +-- Public License distributed with GNAT; see file COPYING. If not, write -- |
1066 | +-- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, -- | | 1066 | +-- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, -- |
1067 | +-- Boston, MA 02110-1301, USA. -- | | 1067 | +-- Boston, MA 02110-1301, USA. -- |
1068 | +-- -- | | 1068 | +-- -- |
1069 | +-- As a special exception, if other files instantiate generics from this -- | | 1069 | +-- As a special exception, if other files instantiate generics from this -- |
1070 | +-- unit, or you link this unit with other files to produce an executable, -- | | 1070 | +-- unit, or you link this unit with other files to produce an executable, -- |
1071 | +-- this unit does not by itself cause the resulting executable to be -- | | 1071 | +-- this unit does not by itself cause the resulting executable to be -- |
1072 | +-- covered by the GNU General Public License. This exception does not -- | | 1072 | +-- covered by the GNU General Public License. This exception does not -- |
1073 | +-- however invalidate any other reasons why the executable file might be -- | | 1073 | +-- however invalidate any other reasons why the executable file might be -- |
1074 | +-- covered by the GNU Public License. -- | | 1074 | +-- covered by the GNU Public License. -- |
1075 | +-- -- | | 1075 | +-- -- |
1076 | +-- GNAT was originally developed by the GNAT team at New York University. -- | | 1076 | +-- GNAT was originally developed by the GNAT team at New York University. -- |
1077 | +-- Extensive contributions were provided by Ada Core Technologies Inc. -- | | 1077 | +-- Extensive contributions were provided by Ada Core Technologies Inc. -- |
1078 | +-- -- | | 1078 | +-- -- |
1079 | +-- Copyright (C) 2010 John Marino <draco@marino.st> -- | | 1079 | +-- Copyright (C) 2010 John Marino <draco@marino.st> -- |
1080 | +------------------------------------------------------------------------------ | | 1080 | +------------------------------------------------------------------------------ |
1081 | + | | 1081 | + |
1082 | +-- This package provides a target dependent thin interface to the sockets | | 1082 | +-- This package provides a target dependent thin interface to the sockets |
1083 | +-- layer for use by the GNAT.Sockets package (g-socket.ads). This package | | 1083 | +-- layer for use by the GNAT.Sockets package (g-socket.ads). This package |
1084 | +-- should not be directly with'ed by an applications program. | | 1084 | +-- should not be directly with'ed by an applications program. |
1085 | + | | 1085 | + |
1086 | +-- This is the *BSD version which uses fcntl rather than ioctl | | 1086 | +-- This is the *BSD version which uses fcntl rather than ioctl |
1087 | +-- The constant SCON.Thread_Blocking_IO is always true (for all platforms, not | | 1087 | +-- The constant SCON.Thread_Blocking_IO is always true (for all platforms, not |
1088 | +-- just *BSD), so this binding is significantly simpler than the standard | | 1088 | +-- just *BSD), so this binding is significantly simpler than the standard |
1089 | +-- one it replaces. | | 1089 | +-- one it replaces. |
1090 | + | | 1090 | + |
1091 | +with GNAT.OS_Lib; use GNAT.OS_Lib; | | 1091 | +with GNAT.OS_Lib; use GNAT.OS_Lib; |
1092 | + | | 1092 | + |
1093 | +with Interfaces.C; use Interfaces.C; | | 1093 | +with Interfaces.C; use Interfaces.C; |
1094 | + | | 1094 | + |
1095 | +package body GNAT.Sockets.Thin is | | 1095 | +package body GNAT.Sockets.Thin is |
1096 | + | | 1096 | + |
1097 | + Unknown_System_Error : constant C.Strings.chars_ptr := | | 1097 | + Unknown_System_Error : constant C.Strings.chars_ptr := |
1098 | + C.Strings.New_String ("Unknown system error"); | | 1098 | + C.Strings.New_String ("Unknown system error"); |
1099 | + | | 1099 | + |
1100 | + function Syscall_Accept | | 1100 | + function Syscall_Accept |
1101 | + (S : C.int; | | 1101 | + (S : C.int; |
1102 | + Addr : System.Address; | | 1102 | + Addr : System.Address; |
1103 | + Addrlen : not null access C.int) return C.int; | | 1103 | + Addrlen : not null access C.int) return C.int; |
1104 | + pragma Import (C, Syscall_Accept, "accept"); | | 1104 | + pragma Import (C, Syscall_Accept, "accept"); |
1105 | + -- The accept() function accepts a connection on a socket. An incoming | | 1105 | + -- The accept() function accepts a connection on a socket. An incoming |
1106 | + -- connection is acknowledged and associated with an immediately created | | 1106 | + -- connection is acknowledged and associated with an immediately created |
1107 | + -- socket. The original socket is returned to the listening state. | | 1107 | + -- socket. The original socket is returned to the listening state. |
1108 | + | | 1108 | + |
1109 | + function Syscall_Connect | | 1109 | + function Syscall_Connect |
1110 | + (S : C.int; | | 1110 | + (S : C.int; |
1111 | + Name : System.Address; | | 1111 | + Name : System.Address; |
1112 | + Namelen : C.int) return C.int; | | 1112 | + Namelen : C.int) return C.int; |
1113 | + pragma Import (C, Syscall_Connect, "connect"); | | 1113 | + pragma Import (C, Syscall_Connect, "connect"); |
1114 | + -- The connect() system call initiates a connection on a socket. If the | | 1114 | + -- The connect() system call initiates a connection on a socket. If the |
1115 | + -- parameter S is of type SOCK_DGRAM then connect() permanently specifies | | 1115 | + -- parameter S is of type SOCK_DGRAM then connect() permanently specifies |
1116 | + -- the peer to which datagrams are to be sent. If S is type SOCK_STREAM | | 1116 | + -- the peer to which datagrams are to be sent. If S is type SOCK_STREAM |
1117 | + -- then connect() attempts to make a connection with another socket, which | | 1117 | + -- then connect() attempts to make a connection with another socket, which |
1118 | + -- is identified by the parameter Name. | | 1118 | + -- is identified by the parameter Name. |
1119 | + | | 1119 | + |
1120 | + function Syscall_Recv | | 1120 | + function Syscall_Recv |
1121 | + (S : C.int; | | 1121 | + (S : C.int; |
1122 | + Msg : System.Address; | | 1122 | + Msg : System.Address; |
1123 | + Len : C.int; | | 1123 | + Len : C.int; |
1124 | + Flags : C.int) return C.int; | | 1124 | + Flags : C.int) return C.int; |
1125 | + pragma Import (C, Syscall_Recv, "recv"); | | 1125 | + pragma Import (C, Syscall_Recv, "recv"); |
1126 | + -- The recv() function receives a message from a socket. The call can be | | 1126 | + -- The recv() function receives a message from a socket. The call can be |
1127 | + -- used on a connection mode socket or a bound, connectionless socket. If | | 1127 | + -- used on a connection mode socket or a bound, connectionless socket. If |
1128 | + -- no messages are available at the socket, the recv() call waits for a | | 1128 | + -- no messages are available at the socket, the recv() call waits for a |
1129 | + -- message to arrive unless the socket is non-blocking. If a socket is | | 1129 | + -- message to arrive unless the socket is non-blocking. If a socket is |
1130 | + -- non-blocking, the call returns a -1 and ERRNO is set to EWOULDBLOCK. | | 1130 | + -- non-blocking, the call returns a -1 and ERRNO is set to EWOULDBLOCK. |
1131 | + | | 1131 | + |
1132 | + function Syscall_Recvfrom | | 1132 | + function Syscall_Recvfrom |
1133 | + (S : C.int; | | 1133 | + (S : C.int; |
1134 | + Msg : System.Address; | | 1134 | + Msg : System.Address; |
1135 | + Len : C.int; | | 1135 | + Len : C.int; |
1136 | + Flags : C.int; | | 1136 | + Flags : C.int; |
1137 | + From : System.Address; | | 1137 | + From : System.Address; |
1138 | + Fromlen : not null access C.int) return C.int; | | 1138 | + Fromlen : not null access C.int) return C.int; |
1139 | + pragma Import (C, Syscall_Recvfrom, "recvfrom"); | | 1139 | + pragma Import (C, Syscall_Recvfrom, "recvfrom"); |
1140 | + -- The recvfrom() system call receives a message from a socket and captures | | 1140 | + -- The recvfrom() system call receives a message from a socket and captures |
1141 | + -- the address from which the data was sent. It can be used to receive | | 1141 | + -- the address from which the data was sent. It can be used to receive |
1142 | + -- data on an unconnected socket as well. If no messages are available, | | 1142 | + -- data on an unconnected socket as well. If no messages are available, |
1143 | + -- the call waits for a message to arrive on blocking sockets. For | | 1143 | + -- the call waits for a message to arrive on blocking sockets. For |
1144 | + -- non-blocking sockets without messages, -1 is returned and ERRNO is set | | 1144 | + -- non-blocking sockets without messages, -1 is returned and ERRNO is set |
1145 | + -- to EAGAIN or EWOULDBLOCK. | | 1145 | + -- to EAGAIN or EWOULDBLOCK. |
1146 | + | | 1146 | + |
1147 | + function Syscall_Recvmsg | | 1147 | + function Syscall_Recvmsg |
1148 | + (S : C.int; | | 1148 | + (S : C.int; |
1149 | + Msg : System.Address; | | 1149 | + Msg : System.Address; |
1150 | + Flags : C.int) return System.CRTL.ssize_t; | | 1150 | + Flags : C.int) return System.CRTL.ssize_t; |
1151 | + pragma Import (C, Syscall_Recvmsg, "recvmsg"); | | 1151 | + pragma Import (C, Syscall_Recvmsg, "recvmsg"); |
1152 | + -- The recvmsg call receives a message from a socket, and can be used to | | 1152 | + -- The recvmsg call receives a message from a socket, and can be used to |
1153 | + -- receive data on an unconnected socket as well. If no messages are | | 1153 | + -- receive data on an unconnected socket as well. If no messages are |
1154 | + -- available, the call waits for a message to arrive on blocking sockets. | | 1154 | + -- available, the call waits for a message to arrive on blocking sockets. |
1155 | + -- For non-blocking sockets without messages, -1 is returned and ERRNO is | | 1155 | + -- For non-blocking sockets without messages, -1 is returned and ERRNO is |
1156 | + -- set to EAGAIN or EWOULDBLOCK. | | 1156 | + -- set to EAGAIN or EWOULDBLOCK. |
1157 | + | | 1157 | + |
1158 | + function Syscall_Sendmsg | | 1158 | + function Syscall_Sendmsg |
1159 | + (S : C.int; | | 1159 | + (S : C.int; |
1160 | + Msg : System.Address; | | 1160 | + Msg : System.Address; |
1161 | + Flags : C.int) return System.CRTL.ssize_t; | | 1161 | + Flags : C.int) return System.CRTL.ssize_t; |
1162 | + pragma Import (C, Syscall_Sendmsg, "sendmsg"); | | 1162 | + pragma Import (C, Syscall_Sendmsg, "sendmsg"); |
1163 | + -- The sendmsg() function sends a message to a socket, and can be used with | | 1163 | + -- The sendmsg() function sends a message to a socket, and can be used with |
1164 | + -- unconnected sockets as well (the msg is ignored in this case). The | | 1164 | + -- unconnected sockets as well (the msg is ignored in this case). The |
1165 | + -- function returns the number of bytes sent when successful, otherwise it | | 1165 | + -- function returns the number of bytes sent when successful, otherwise it |
1166 | + -- returns -1 and ERRNO is set (many possible values). | | 1166 | + -- returns -1 and ERRNO is set (many possible values). |
1167 | + | | 1167 | + |
1168 | + function Syscall_Sendto | | 1168 | + function Syscall_Sendto |
1169 | + (S : C.int; | | 1169 | + (S : C.int; |
1170 | + Msg : System.Address; | | 1170 | + Msg : System.Address; |
1171 | + Len : C.int; | | 1171 | + Len : C.int; |
1172 | + Flags : C.int; | | 1172 | + Flags : C.int; |
1173 | + To : System.Address; | | 1173 | + To : System.Address; |
1174 | + Tolen : C.int) return C.int; | | 1174 | + Tolen : C.int) return C.int; |
1175 | + pragma Import (C, Syscall_Sendto, "sendto"); | | 1175 | + pragma Import (C, Syscall_Sendto, "sendto"); |
1176 | + -- The sendto() function only works for connected sockets and it initiates | | 1176 | + -- The sendto() function only works for connected sockets and it initiates |
1177 | + -- the transmission of a message. A successful call returns the numbers of | | 1177 | + -- the transmission of a message. A successful call returns the numbers of |
1178 | + -- bytes sent, and a failure returns a -1 and ERRNO is set. | | 1178 | + -- bytes sent, and a failure returns a -1 and ERRNO is set. |
1179 | + | | 1179 | + |
1180 | + function Syscall_Socket | | 1180 | + function Syscall_Socket |
1181 | + (Domain : C.int; | | 1181 | + (Domain : C.int; |
1182 | + Typ : C.int; | | 1182 | + Typ : C.int; |
1183 | + Protocol : C.int) return C.int; | | 1183 | + Protocol : C.int) return C.int; |
1184 | + pragma Import (C, Syscall_Socket, "socket"); | | 1184 | + pragma Import (C, Syscall_Socket, "socket"); |
1185 | + -- The socket() function is used to create an unbound socket and returns a | | 1185 | + -- The socket() function is used to create an unbound socket and returns a |
1186 | + -- file descriptor that can be used with other socket functions. Upon | | 1186 | + -- file descriptor that can be used with other socket functions. Upon |
1187 | + -- failure, a -1 is returned and ERRNO is set. | | 1187 | + -- failure, a -1 is returned and ERRNO is set. |
1188 | + | | 1188 | + |
1189 | + procedure Disable_SIGPIPE (S : C.int); | | 1189 | + procedure Disable_SIGPIPE (S : C.int); |
1190 | + pragma Import (C, Disable_SIGPIPE, "__gnat_disable_sigpipe"); | | 1190 | + pragma Import (C, Disable_SIGPIPE, "__gnat_disable_sigpipe"); |
1191 | + | | 1191 | + |
1192 | + procedure Disable_All_SIGPIPEs; | | 1192 | + procedure Disable_All_SIGPIPEs; |
1193 | + pragma Import (C, Disable_All_SIGPIPEs, "__gnat_disable_all_sigpipes"); | | 1193 | + pragma Import (C, Disable_All_SIGPIPEs, "__gnat_disable_all_sigpipes"); |
1194 | + -- Sets the process to ignore all SIGPIPE signals on platforms that | | 1194 | + -- Sets the process to ignore all SIGPIPE signals on platforms that |
1195 | + -- don't support Disable_SIGPIPE for particular streams. | | 1195 | + -- don't support Disable_SIGPIPE for particular streams. |
1196 | + | | 1196 | + |
1197 | + function C_Fcntl | | 1197 | + function C_Fcntl |
1198 | + (Fd : C.int; | | 1198 | + (Fd : C.int; |
1199 | + Cmd : C.int; | | 1199 | + Cmd : C.int; |
1200 | + Val : C.int) return C.int; | | 1200 | + Val : C.int) return C.int; |
1201 | + pragma Import (C, C_Fcntl, "fcntl"); | | 1201 | + pragma Import (C, C_Fcntl, "fcntl"); |
1202 | + -- The ioctl of 64-bit DragonFlyBSD, OpenBSD, and NetBSD does not support | | 1202 | + -- The ioctl of 64-bit DragonFlyBSD, OpenBSD, and NetBSD does not support |
1203 | + -- setting a socket in non-blocking mode. fcntl must be used instead. | | 1203 | + -- setting a socket in non-blocking mode. fcntl must be used instead. |
1204 | + | | 1204 | + |
1205 | + -------------- | | 1205 | + -------------- |
1206 | + -- C_Accept -- | | 1206 | + -- C_Accept -- |
1207 | + -------------- | | 1207 | + -------------- |
1208 | + | | 1208 | + |
1209 | + function C_Accept | | 1209 | + function C_Accept |
1210 | + (S : C.int; | | 1210 | + (S : C.int; |
1211 | + Addr : System.Address; | | 1211 | + Addr : System.Address; |
1212 | + Addrlen : not null access C.int) return C.int | | 1212 | + Addrlen : not null access C.int) return C.int |
1213 | + is | | 1213 | + is |
1214 | + Res : constant C.int := Syscall_Accept (S, Addr, Addrlen); | | 1214 | + Res : constant C.int := Syscall_Accept (S, Addr, Addrlen); |
1215 | + begin | | 1215 | + begin |
1216 | + | | 1216 | + |
1217 | + Disable_SIGPIPE (Res); | | 1217 | + Disable_SIGPIPE (Res); |
1218 | + return Res; | | 1218 | + return Res; |
1219 | + | | 1219 | + |
1220 | + end C_Accept; | | 1220 | + end C_Accept; |
1221 | + | | 1221 | + |
1222 | + --------------- | | 1222 | + --------------- |
1223 | + -- C_Connect -- | | 1223 | + -- C_Connect -- |
1224 | + --------------- | | 1224 | + --------------- |
1225 | + | | 1225 | + |
1226 | + function C_Connect | | 1226 | + function C_Connect |
1227 | + (S : C.int; | | 1227 | + (S : C.int; |
1228 | + Name : System.Address; | | 1228 | + Name : System.Address; |
1229 | + Namelen : C.int) return C.int | | 1229 | + Namelen : C.int) return C.int |
1230 | + is | | 1230 | + is |
1231 | + begin | | 1231 | + begin |
1232 | + | | 1232 | + |
1233 | + return Syscall_Connect (S, Name, Namelen); | | 1233 | + return Syscall_Connect (S, Name, Namelen); |
1234 | + | | 1234 | + |
1235 | + end C_Connect; | | 1235 | + end C_Connect; |
1236 | + | | 1236 | + |
1237 | + ------------------ | | 1237 | + ------------------ |
1238 | + -- Socket_Ioctl -- | | 1238 | + -- Socket_Ioctl -- |
1239 | + ------------------ | | 1239 | + ------------------ |
1240 | + | | 1240 | + |
1241 | + function Socket_Ioctl | | 1241 | + function Socket_Ioctl |
1242 | + (S : C.int; | | 1242 | + (S : C.int; |
1243 | + Req : C.int; | | 1243 | + Req : C.int; |
1244 | + Arg : access C.int) return C.int | | 1244 | + Arg : access C.int) return C.int |
1245 | + is | | 1245 | + is |
1246 | + -- Currently all requests are of the FIONBIO type, so always calc flags | | 1246 | + -- Currently all requests are of the FIONBIO type, so always calc flags |
1247 | + use Interfaces; | | 1247 | + use Interfaces; |
1248 | + flags : constant Unsigned_32 := | | 1248 | + flags : constant Unsigned_32 := |
1249 | + Unsigned_32 (C_Fcntl (S, SOSC.F_GETFL, 0)); | | 1249 | + Unsigned_32 (C_Fcntl (S, SOSC.F_GETFL, 0)); |
1250 | + nonblock : constant Unsigned_32 := Unsigned_32 (SOSC.FNDELAY); | | 1250 | + nonblock : constant Unsigned_32 := Unsigned_32 (SOSC.FNDELAY); |
1251 | + enabled : constant Boolean := Arg.all = 1; | | 1251 | + enabled : constant Boolean := Arg.all = 1; |
1252 | + newval : C.int; | | 1252 | + newval : C.int; |
1253 | + begin | | 1253 | + begin |
1254 | + if Req = SOSC.FIONBIO then | | 1254 | + if Req = SOSC.FIONBIO then |
1255 | + if enabled then | | 1255 | + if enabled then |
1256 | + newval := C.int (flags or nonblock); | | 1256 | + newval := C.int (flags or nonblock); |
1257 | + elsif (flags and nonblock) > 0 then | | 1257 | + elsif (flags and nonblock) > 0 then |
1258 | + newval := C.int (flags - nonblock); | | 1258 | + newval := C.int (flags - nonblock); |
1259 | + else | | 1259 | + else |
1260 | + newval := C.int (flags); | | 1260 | + newval := C.int (flags); |
1261 | + end if; | | 1261 | + end if; |
1262 | + return C_Fcntl (Fd => S, Cmd => SOSC.F_SETFL, Val => newval); | | 1262 | + return C_Fcntl (Fd => S, Cmd => SOSC.F_SETFL, Val => newval); |
1263 | + else | | 1263 | + else |
1264 | + return C_Ioctl (Fd => S, Req => Req, Arg => Arg); | | 1264 | + return C_Ioctl (Fd => S, Req => Req, Arg => Arg); |
1265 | + end if; | | 1265 | + end if; |
1266 | + end Socket_Ioctl; | | 1266 | + end Socket_Ioctl; |
1267 | + | | 1267 | + |
1268 | + ------------ | | 1268 | + ------------ |
1269 | + -- C_Recv -- | | 1269 | + -- C_Recv -- |
1270 | + ------------ | | 1270 | + ------------ |
1271 | + | | 1271 | + |
1272 | + function C_Recv | | 1272 | + function C_Recv |
1273 | + (S : C.int; | | 1273 | + (S : C.int; |
1274 | + Msg : System.Address; | | 1274 | + Msg : System.Address; |
1275 | + Len : C.int; | | 1275 | + Len : C.int; |
1276 | + Flags : C.int) return C.int | | 1276 | + Flags : C.int) return C.int |
1277 | + is | | 1277 | + is |
1278 | + begin | | 1278 | + begin |
1279 | + | | 1279 | + |
1280 | + return Syscall_Recv (S, Msg, Len, Flags); | | 1280 | + return Syscall_Recv (S, Msg, Len, Flags); |
1281 | + | | 1281 | + |
1282 | + end C_Recv; | | 1282 | + end C_Recv; |
1283 | + | | 1283 | + |
1284 | + ---------------- | | 1284 | + ---------------- |
1285 | + -- C_Recvfrom -- | | 1285 | + -- C_Recvfrom -- |
1286 | + ---------------- | | 1286 | + ---------------- |
1287 | + | | 1287 | + |
1288 | + function C_Recvfrom | | 1288 | + function C_Recvfrom |
1289 | + (S : C.int; | | 1289 | + (S : C.int; |
1290 | + Msg : System.Address; | | 1290 | + Msg : System.Address; |
1291 | + Len : C.int; | | 1291 | + Len : C.int; |
1292 | + Flags : C.int; | | 1292 | + Flags : C.int; |
1293 | + From : System.Address; | | 1293 | + From : System.Address; |
1294 | + Fromlen : not null access C.int) return C.int | | 1294 | + Fromlen : not null access C.int) return C.int |
1295 | + is | | 1295 | + is |
1296 | + begin | | 1296 | + begin |
1297 | + | | 1297 | + |
1298 | + return Syscall_Recvfrom (S, Msg, Len, Flags, From, Fromlen); | | 1298 | + return Syscall_Recvfrom (S, Msg, Len, Flags, From, Fromlen); |
1299 | + | | 1299 | + |
1300 | + end C_Recvfrom; | | 1300 | + end C_Recvfrom; |
1301 | + | | 1301 | + |
1302 | + --------------- | | 1302 | + --------------- |
1303 | + -- C_Recvmsg -- | | 1303 | + -- C_Recvmsg -- |
1304 | + --------------- | | 1304 | + --------------- |
1305 | + | | 1305 | + |
1306 | + function C_Recvmsg | | 1306 | + function C_Recvmsg |
1307 | + (S : C.int; | | 1307 | + (S : C.int; |
1308 | + Msg : System.Address; | | 1308 | + Msg : System.Address; |
1309 | + Flags : C.int) return System.CRTL.ssize_t | | 1309 | + Flags : C.int) return System.CRTL.ssize_t |
1310 | + is | | 1310 | + is |
1311 | + begin | | 1311 | + begin |
1312 | + | | 1312 | + |
1313 | + return Syscall_Recvmsg (S, Msg, Flags); | | 1313 | + return Syscall_Recvmsg (S, Msg, Flags); |
1314 | + | | 1314 | + |
1315 | + end C_Recvmsg; | | 1315 | + end C_Recvmsg; |
1316 | + | | 1316 | + |
1317 | + --------------- | | 1317 | + --------------- |
1318 | + -- C_Sendmsg -- | | 1318 | + -- C_Sendmsg -- |
1319 | + --------------- | | 1319 | + --------------- |
1320 | + | | 1320 | + |
1321 | + function C_Sendmsg | | 1321 | + function C_Sendmsg |
1322 | + (S : C.int; | | 1322 | + (S : C.int; |
1323 | + Msg : System.Address; | | 1323 | + Msg : System.Address; |
1324 | + Flags : C.int) return System.CRTL.ssize_t | | 1324 | + Flags : C.int) return System.CRTL.ssize_t |
1325 | + is | | 1325 | + is |
1326 | + begin | | 1326 | + begin |
1327 | + | | 1327 | + |
1328 | + return Syscall_Sendmsg (S, Msg, Flags); | | 1328 | + return Syscall_Sendmsg (S, Msg, Flags); |
1329 | + | | 1329 | + |
1330 | + end C_Sendmsg; | | 1330 | + end C_Sendmsg; |
1331 | + | | 1331 | + |
1332 | + -------------- | | 1332 | + -------------- |
1333 | + -- C_Sendto -- | | 1333 | + -- C_Sendto -- |
1334 | + -------------- | | 1334 | + -------------- |
1335 | + | | 1335 | + |
1336 | + function C_Sendto | | 1336 | + function C_Sendto |
1337 | + (S : C.int; | | 1337 | + (S : C.int; |
1338 | + Msg : System.Address; | | 1338 | + Msg : System.Address; |
1339 | + Len : C.int; | | 1339 | + Len : C.int; |
1340 | + Flags : C.int; | | 1340 | + Flags : C.int; |
1341 | + To : System.Address; | | 1341 | + To : System.Address; |
1342 | + Tolen : C.int) return C.int | | 1342 | + Tolen : C.int) return C.int |
1343 | + is | | 1343 | + is |
1344 | + begin | | 1344 | + begin |
1345 | + | | 1345 | + |
1346 | + return Syscall_Sendto (S, Msg, Len, Flags, To, Tolen); | | 1346 | + return Syscall_Sendto (S, Msg, Len, Flags, To, Tolen); |
1347 | + | | 1347 | + |
1348 | + end C_Sendto; | | 1348 | + end C_Sendto; |
1349 | + | | 1349 | + |
1350 | + -------------- | | 1350 | + -------------- |
1351 | + -- C_Socket -- | | 1351 | + -- C_Socket -- |
1352 | + -------------- | | 1352 | + -------------- |
1353 | + | | 1353 | + |
1354 | + function C_Socket | | 1354 | + function C_Socket |
1355 | + (Domain : C.int; | | 1355 | + (Domain : C.int; |
1356 | + Typ : C.int; | | 1356 | + Typ : C.int; |
1357 | + Protocol : C.int) return C.int | | 1357 | + Protocol : C.int) return C.int |
1358 | + is | | 1358 | + is |
1359 | + Res : constant C.int := Syscall_Socket (Domain, Typ, Protocol); | | 1359 | + Res : constant C.int := Syscall_Socket (Domain, Typ, Protocol); |
1360 | + begin | | 1360 | + begin |
1361 | + | | 1361 | + |
1362 | + Disable_SIGPIPE (Res); | | 1362 | + Disable_SIGPIPE (Res); |
1363 | + return Res; | | 1363 | + return Res; |
1364 | + | | 1364 | + |
1365 | + end C_Socket; | | 1365 | + end C_Socket; |
1366 | + | | 1366 | + |
1367 | + -------------- | | 1367 | + -------------- |
1368 | + -- Finalize -- | | 1368 | + -- Finalize -- |
1369 | + -------------- | | 1369 | + -------------- |
1370 | + | | 1370 | + |
1371 | + procedure Finalize is | | 1371 | + procedure Finalize is |
1372 | + begin | | 1372 | + begin |
1373 | + null; | | 1373 | + null; |
1374 | + end Finalize; | | 1374 | + end Finalize; |
1375 | + | | 1375 | + |
1376 | + ------------------------- | | 1376 | + ------------------------- |
1377 | + -- Host_Error_Messages -- | | 1377 | + -- Host_Error_Messages -- |
1378 | + ------------------------- | | 1378 | + ------------------------- |
1379 | + | | 1379 | + |
1380 | + package body Host_Error_Messages is separate; | | 1380 | + package body Host_Error_Messages is separate; |
1381 | + | | 1381 | + |
1382 | + ---------------- | | 1382 | + ---------------- |
1383 | + -- Initialize -- | | 1383 | + -- Initialize -- |
1384 | + ---------------- | | 1384 | + ---------------- |
1385 | + | | 1385 | + |
1386 | + procedure Initialize is | | 1386 | + procedure Initialize is |
1387 | + begin | | 1387 | + begin |
1388 | + Disable_All_SIGPIPEs; | | 1388 | + Disable_All_SIGPIPEs; |
1389 | + end Initialize; | | 1389 | + end Initialize; |
1390 | + | | 1390 | + |
1391 | + -------------------- | | 1391 | + -------------------- |
1392 | + -- Signalling_Fds -- | | 1392 | + -- Signalling_Fds -- |
1393 | + -------------------- | | 1393 | + -------------------- |
1394 | + | | 1394 | + |
1395 | + package body Signalling_Fds is | | 1395 | + package body Signalling_Fds is |
1396 | + | | 1396 | + |
1397 | + -- In this default implementation, we use a C version of these | | 1397 | + -- In this default implementation, we use a C version of these |
1398 | + -- subprograms provided by socket.c. | | 1398 | + -- subprograms provided by socket.c. |
1399 | + | | 1399 | + |
1400 | + function C_Create (Fds : not null access Fd_Pair) return C.int; | | 1400 | + function C_Create (Fds : not null access Fd_Pair) return C.int; |
1401 | + function C_Read (Rsig : C.int) return C.int; | | 1401 | + function C_Read (Rsig : C.int) return C.int; |
1402 | + function C_Write (Wsig : C.int) return C.int; | | 1402 | + function C_Write (Wsig : C.int) return C.int; |
1403 | + procedure C_Close (Sig : C.int); | | 1403 | + procedure C_Close (Sig : C.int); |
1404 | + | | 1404 | + |
1405 | + pragma Import (C, C_Create, "__gnat_create_signalling_fds"); | | 1405 | + pragma Import (C, C_Create, "__gnat_create_signalling_fds"); |
1406 | + pragma Import (C, C_Read, "__gnat_read_signalling_fd"); | | 1406 | + pragma Import (C, C_Read, "__gnat_read_signalling_fd"); |
1407 | + pragma Import (C, C_Write, "__gnat_write_signalling_fd"); | | 1407 | + pragma Import (C, C_Write, "__gnat_write_signalling_fd"); |
1408 | + pragma Import (C, C_Close, "__gnat_close_signalling_fd"); | | 1408 | + pragma Import (C, C_Close, "__gnat_close_signalling_fd"); |
1409 | + | | 1409 | + |
1410 | + function Create | | 1410 | + function Create |
1411 | + (Fds : not null access Fd_Pair) return C.int renames C_Create; | | 1411 | + (Fds : not null access Fd_Pair) return C.int renames C_Create; |
1412 | + function Read (Rsig : C.int) return C.int renames C_Read; | | 1412 | + function Read (Rsig : C.int) return C.int renames C_Read; |
1413 | + function Write (Wsig : C.int) return C.int renames C_Write; | | 1413 | + function Write (Wsig : C.int) return C.int renames C_Write; |
1414 | + procedure Close (Sig : C.int) renames C_Close; | | 1414 | + procedure Close (Sig : C.int) renames C_Close; |
1415 | + | | 1415 | + |
1416 | + end Signalling_Fds; | | 1416 | + end Signalling_Fds; |
1417 | + | | 1417 | + |
1418 | + -------------------------- | | 1418 | + -------------------------- |
1419 | + -- Socket_Error_Message -- | | 1419 | + -- Socket_Error_Message -- |
1420 | + -------------------------- | | 1420 | + -------------------------- |
1421 | + | | 1421 | + |
1422 | + function Socket_Error_Message | | 1422 | + function Socket_Error_Message |
1423 | + (Errno : Integer) return C.Strings.chars_ptr | | 1423 | + (Errno : Integer) return C.Strings.chars_ptr |
1424 | + is separate; | | 1424 | + is separate; |
1425 | + | | 1425 | + |
1426 | +end GNAT.Sockets.Thin; | | 1426 | +end GNAT.Sockets.Thin; |
1427 | --- /dev/null | | 1427 | --- /dev/null |
1428 | +++ gcc/ada/g-socthi-netbsd.adb | | 1428 | +++ gcc/ada/g-socthi-netbsd.adb |
1429 | @@ -0,0 +1,381 @@ | | 1429 | @@ -0,0 +1,381 @@ |
1430 | +------------------------------------------------------------------------------ | | 1430 | +------------------------------------------------------------------------------ |
1431 | +-- -- | | 1431 | +-- -- |
1432 | +-- GNAT COMPILER COMPONENTS -- | | 1432 | +-- GNAT COMPILER COMPONENTS -- |
1433 | +-- -- | | 1433 | +-- -- |
1434 | +-- G N A T . S O C K E T S . T H I N -- | | 1434 | +-- G N A T . S O C K E T S . T H I N -- |
1435 | +-- -- | | 1435 | +-- -- |
1436 | +-- B o d y -- | | 1436 | +-- B o d y -- |
1437 | +-- -- | | 1437 | +-- -- |
1438 | +-- Copyright (C) 2001-2009, AdaCore -- | | 1438 | +-- Copyright (C) 2001-2009, AdaCore -- |
1439 | +-- -- | | 1439 | +-- -- |
1440 | +-- GNAT is free software; you can redistribute it and/or modify it under -- | | 1440 | +-- GNAT is free software; you can redistribute it and/or modify it under -- |
1441 | +-- terms of the GNU General Public License as published by the Free Soft- -- | | 1441 | +-- terms of the GNU General Public License as published by the Free Soft- -- |
1442 | +-- ware Foundation; either version 2, or (at your option) any later ver- -- | | 1442 | +-- ware Foundation; either version 2, or (at your option) any later ver- -- |
1443 | +-- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- | | 1443 | +-- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- |
1444 | +-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- | | 1444 | +-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- |
1445 | +-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- | | 1445 | +-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- |
1446 | +-- for more details. You should have received a copy of the GNU General -- | | 1446 | +-- for more details. You should have received a copy of the GNU General -- |
1447 | +-- Public License distributed with GNAT; see file COPYING. If not, write -- | | 1447 | +-- Public License distributed with GNAT; see file COPYING. If not, write -- |
1448 | +-- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, -- | | 1448 | +-- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, -- |
1449 | +-- Boston, MA 02110-1301, USA. -- | | 1449 | +-- Boston, MA 02110-1301, USA. -- |
1450 | +-- -- | | 1450 | +-- -- |
1451 | +-- As a special exception, if other files instantiate generics from this -- | | 1451 | +-- As a special exception, if other files instantiate generics from this -- |
1452 | +-- unit, or you link this unit with other files to produce an executable, -- | | 1452 | +-- unit, or you link this unit with other files to produce an executable, -- |
1453 | +-- this unit does not by itself cause the resulting executable to be -- | | 1453 | +-- this unit does not by itself cause the resulting executable to be -- |
1454 | +-- covered by the GNU General Public License. This exception does not -- | | 1454 | +-- covered by the GNU General Public License. This exception does not -- |
1455 | +-- however invalidate any other reasons why the executable file might be -- | | 1455 | +-- however invalidate any other reasons why the executable file might be -- |
1456 | +-- covered by the GNU Public License. -- | | 1456 | +-- covered by the GNU Public License. -- |
1457 | +-- -- | | 1457 | +-- -- |
1458 | +-- GNAT was originally developed by the GNAT team at New York University. -- | | 1458 | +-- GNAT was originally developed by the GNAT team at New York University. -- |
1459 | +-- Extensive contributions were provided by Ada Core Technologies Inc. -- | | 1459 | +-- Extensive contributions were provided by Ada Core Technologies Inc. -- |
1460 | +-- -- | | 1460 | +-- -- |
1461 | +-- Copyright (C) 2010, 2011 John Marino <www.dragonlace.net> -- | | 1461 | +-- Copyright (C) 2010, 2011 John Marino <www.dragonlace.net> -- |
1462 | +------------------------------------------------------------------------------ | | 1462 | +------------------------------------------------------------------------------ |
1463 | + | | 1463 | + |
1464 | +-- This package provides a target dependent thin interface to the sockets | | 1464 | +-- This package provides a target dependent thin interface to the sockets |
1465 | +-- layer for use by the GNAT.Sockets package (g-socket.ads). This package | | 1465 | +-- layer for use by the GNAT.Sockets package (g-socket.ads). This package |
1466 | +-- should not be directly with'ed by an applications program. | | 1466 | +-- should not be directly with'ed by an applications program. |
1467 | + | | 1467 | + |
1468 | +-- This is the NetBSD version which uses fcntl rather than ioctl | | 1468 | +-- This is the NetBSD version which uses fcntl rather than ioctl |
1469 | +-- The constant SCON.Thread_Blocking_IO is always true (for all platforms, not | | 1469 | +-- The constant SCON.Thread_Blocking_IO is always true (for all platforms, not |
1470 | +-- just *BSD), so this binding is significantly simpler than the standard | | 1470 | +-- just *BSD), so this binding is significantly simpler than the standard |
1471 | +-- one it replaces. | | 1471 | +-- one it replaces. |
1472 | +-- NetBSD uses binary compatibility functions that are forcing the use of | | 1472 | +-- NetBSD uses binary compatibility functions that are forcing the use of |
1473 | +-- their own files rather than sharing the *BSD versions. | | 1473 | +-- their own files rather than sharing the *BSD versions. |
1474 | + | | 1474 | + |
1475 | +with GNAT.OS_Lib; use GNAT.OS_Lib; | | 1475 | +with GNAT.OS_Lib; use GNAT.OS_Lib; |
1476 | + | | 1476 | + |
1477 | +with Interfaces.C; use Interfaces.C; | | 1477 | +with Interfaces.C; use Interfaces.C; |
1478 | + | | 1478 | + |
1479 | +package body GNAT.Sockets.Thin is | | 1479 | +package body GNAT.Sockets.Thin is |
1480 | + | | 1480 | + |
1481 | + Unknown_System_Error : constant C.Strings.chars_ptr := | | 1481 | + Unknown_System_Error : constant C.Strings.chars_ptr := |
1482 | + C.Strings.New_String ("Unknown system error"); | | 1482 | + C.Strings.New_String ("Unknown system error"); |
1483 | + | | 1483 | + |
1484 | + function Syscall_Accept | | 1484 | + function Syscall_Accept |
1485 | + (S : C.int; | | 1485 | + (S : C.int; |
1486 | + Addr : System.Address; | | 1486 | + Addr : System.Address; |
1487 | + Addrlen : not null access C.int) return C.int; | | 1487 | + Addrlen : not null access C.int) return C.int; |
1488 | + pragma Import (C, Syscall_Accept, "accept"); | | 1488 | + pragma Import (C, Syscall_Accept, "accept"); |
1489 | + -- The accept() function accepts a connection on a socket. An incoming | | 1489 | + -- The accept() function accepts a connection on a socket. An incoming |
1490 | + -- connection is acknowledged and associated with an immediately created | | 1490 | + -- connection is acknowledged and associated with an immediately created |
1491 | + -- socket. The original socket is returned to the listening state. | | 1491 | + -- socket. The original socket is returned to the listening state. |
1492 | + | | 1492 | + |
1493 | + function Syscall_Connect | | 1493 | + function Syscall_Connect |
1494 | + (S : C.int; | | 1494 | + (S : C.int; |
1495 | + Name : System.Address; | | 1495 | + Name : System.Address; |
1496 | + Namelen : C.int) return C.int; | | 1496 | + Namelen : C.int) return C.int; |
1497 | + pragma Import (C, Syscall_Connect, "connect"); | | 1497 | + pragma Import (C, Syscall_Connect, "connect"); |
1498 | + -- The connect() system call initiates a connection on a socket. If the | | 1498 | + -- The connect() system call initiates a connection on a socket. If the |
1499 | + -- parameter S is of type SOCK_DGRAM then connect() permanently specifies | | 1499 | + -- parameter S is of type SOCK_DGRAM then connect() permanently specifies |
1500 | + -- the peer to which datagrams are to be sent. If S is type SOCK_STREAM | | 1500 | + -- the peer to which datagrams are to be sent. If S is type SOCK_STREAM |
1501 | + -- then connect() attempts to make a connection with another socket, which | | 1501 | + -- then connect() attempts to make a connection with another socket, which |
1502 | + -- is identified by the parameter Name. | | 1502 | + -- is identified by the parameter Name. |
1503 | + | | 1503 | + |
1504 | + function Syscall_Recv | | 1504 | + function Syscall_Recv |
1505 | + (S : C.int; | | 1505 | + (S : C.int; |
1506 | + Msg : System.Address; | | 1506 | + Msg : System.Address; |
1507 | + Len : C.int; | | 1507 | + Len : C.int; |
1508 | + Flags : C.int) return C.int; | | 1508 | + Flags : C.int) return C.int; |
1509 | + pragma Import (C, Syscall_Recv, "recv"); | | 1509 | + pragma Import (C, Syscall_Recv, "recv"); |
1510 | + -- The recv() function receives a message from a socket. The call can be | | 1510 | + -- The recv() function receives a message from a socket. The call can be |
1511 | + -- used on a connection mode socket or a bound, connectionless socket. If | | 1511 | + -- used on a connection mode socket or a bound, connectionless socket. If |
1512 | + -- no messages are available at the socket, the recv() call waits for a | | 1512 | + -- no messages are available at the socket, the recv() call waits for a |
1513 | + -- message to arrive unless the socket is non-blocking. If a socket is | | 1513 | + -- message to arrive unless the socket is non-blocking. If a socket is |
1514 | + -- non-blocking, the call returns a -1 and ERRNO is set to EWOULDBLOCK. | | 1514 | + -- non-blocking, the call returns a -1 and ERRNO is set to EWOULDBLOCK. |
1515 | + | | 1515 | + |
1516 | + function Syscall_Recvfrom | | 1516 | + function Syscall_Recvfrom |
1517 | + (S : C.int; | | 1517 | + (S : C.int; |
1518 | + Msg : System.Address; | | 1518 | + Msg : System.Address; |
1519 | + Len : C.int; | | 1519 | + Len : C.int; |
1520 | + Flags : C.int; | | 1520 | + Flags : C.int; |
1521 | + From : System.Address; | | 1521 | + From : System.Address; |
1522 | + Fromlen : not null access C.int) return C.int; | | 1522 | + Fromlen : not null access C.int) return C.int; |
1523 | + pragma Import (C, Syscall_Recvfrom, "recvfrom"); | | 1523 | + pragma Import (C, Syscall_Recvfrom, "recvfrom"); |
1524 | + -- The recvfrom() system call receives a message from a socket and captures | | 1524 | + -- The recvfrom() system call receives a message from a socket and captures |
1525 | + -- the address from which the data was sent. It can be used to receive | | 1525 | + -- the address from which the data was sent. It can be used to receive |
1526 | + -- data on an unconnected socket as well. If no messages are available, | | 1526 | + -- data on an unconnected socket as well. If no messages are available, |
1527 | + -- the call waits for a message to arrive on blocking sockets. For | | 1527 | + -- the call waits for a message to arrive on blocking sockets. For |
1528 | + -- non-blocking sockets without messages, -1 is returned and ERRNO is set | | 1528 | + -- non-blocking sockets without messages, -1 is returned and ERRNO is set |
1529 | + -- to EAGAIN or EWOULDBLOCK. | | 1529 | + -- to EAGAIN or EWOULDBLOCK. |
1530 | + | | 1530 | + |
1531 | + function Syscall_Recvmsg | | 1531 | + function Syscall_Recvmsg |
1532 | + (S : C.int; | | 1532 | + (S : C.int; |
1533 | + Msg : System.Address; | | 1533 | + Msg : System.Address; |
1534 | + Flags : C.int) return System.CRTL.ssize_t; | | 1534 | + Flags : C.int) return System.CRTL.ssize_t; |
1535 | + pragma Import (C, Syscall_Recvmsg, "recvmsg"); | | 1535 | + pragma Import (C, Syscall_Recvmsg, "recvmsg"); |
1536 | + -- The recvmsg call receives a message from a socket, and can be used to | | 1536 | + -- The recvmsg call receives a message from a socket, and can be used to |
1537 | + -- receive data on an unconnected socket as well. If no messages are | | 1537 | + -- receive data on an unconnected socket as well. If no messages are |
1538 | + -- available, the call waits for a message to arrive on blocking sockets. | | 1538 | + -- available, the call waits for a message to arrive on blocking sockets. |
1539 | + -- For non-blocking sockets without messages, -1 is returned and ERRNO is | | 1539 | + -- For non-blocking sockets without messages, -1 is returned and ERRNO is |
1540 | + -- set to EAGAIN or EWOULDBLOCK. | | 1540 | + -- set to EAGAIN or EWOULDBLOCK. |
1541 | + | | 1541 | + |
1542 | + function Syscall_Sendmsg | | 1542 | + function Syscall_Sendmsg |
1543 | + (S : C.int; | | 1543 | + (S : C.int; |
1544 | + Msg : System.Address; | | 1544 | + Msg : System.Address; |
1545 | + Flags : C.int) return System.CRTL.ssize_t; | | 1545 | + Flags : C.int) return System.CRTL.ssize_t; |
1546 | + pragma Import (C, Syscall_Sendmsg, "sendmsg"); | | 1546 | + pragma Import (C, Syscall_Sendmsg, "sendmsg"); |
1547 | + -- The sendmsg() function sends a message to a socket, and can be used with | | 1547 | + -- The sendmsg() function sends a message to a socket, and can be used with |
1548 | + -- unconnected sockets as well (the msg is ignored in this case). The | | 1548 | + -- unconnected sockets as well (the msg is ignored in this case). The |
1549 | + -- function returns the number of bytes sent when successful, otherwise it | | 1549 | + -- function returns the number of bytes sent when successful, otherwise it |
1550 | + -- returns -1 and ERRNO is set (many possible values). | | 1550 | + -- returns -1 and ERRNO is set (many possible values). |
1551 | + | | 1551 | + |
1552 | + function Syscall_Sendto | | 1552 | + function Syscall_Sendto |
1553 | + (S : C.int; | | 1553 | + (S : C.int; |
1554 | + Msg : System.Address; | | 1554 | + Msg : System.Address; |
1555 | + Len : C.int; | | 1555 | + Len : C.int; |
1556 | + Flags : C.int; | | 1556 | + Flags : C.int; |
1557 | + To : System.Address; | | 1557 | + To : System.Address; |
1558 | + Tolen : C.int) return C.int; | | 1558 | + Tolen : C.int) return C.int; |
1559 | + pragma Import (C, Syscall_Sendto, "sendto"); | | 1559 | + pragma Import (C, Syscall_Sendto, "sendto"); |
1560 | + -- The sendto() function only works for connected sockets and it initiates | | 1560 | + -- The sendto() function only works for connected sockets and it initiates |
1561 | + -- the transmission of a message. A successful call returns the numbers of | | 1561 | + -- the transmission of a message. A successful call returns the numbers of |
1562 | + -- bytes sent, and a failure returns a -1 and ERRNO is set. | | 1562 | + -- bytes sent, and a failure returns a -1 and ERRNO is set. |
1563 | + | | 1563 | + |
1564 | + function Syscall_Socket | | 1564 | + function Syscall_Socket |
1565 | + (Domain : C.int; | | 1565 | + (Domain : C.int; |
1566 | + Typ : C.int; | | 1566 | + Typ : C.int; |
1567 | + Protocol : C.int) return C.int; | | 1567 | + Protocol : C.int) return C.int; |
1568 | + pragma Import (C, Syscall_Socket, "__socket30"); | | 1568 | + pragma Import (C, Syscall_Socket, "__socket30"); |
1569 | + -- The socket() function is used to create an unbound socket and returns a | | 1569 | + -- The socket() function is used to create an unbound socket and returns a |
1570 | + -- file descriptor that can be used with other socket functions. Upon | | 1570 | + -- file descriptor that can be used with other socket functions. Upon |
1571 | + -- failure, a -1 is returned and ERRNO is set. | | 1571 | + -- failure, a -1 is returned and ERRNO is set. |
1572 | + | | 1572 | + |
1573 | + procedure Disable_SIGPIPE (S : C.int); | | 1573 | + procedure Disable_SIGPIPE (S : C.int); |
1574 | + pragma Import (C, Disable_SIGPIPE, "__gnat_disable_sigpipe"); | | 1574 | + pragma Import (C, Disable_SIGPIPE, "__gnat_disable_sigpipe"); |
1575 | + | | 1575 | + |
1576 | + procedure Disable_All_SIGPIPEs; | | 1576 | + procedure Disable_All_SIGPIPEs; |
1577 | + pragma Import (C, Disable_All_SIGPIPEs, "__gnat_disable_all_sigpipes"); | | 1577 | + pragma Import (C, Disable_All_SIGPIPEs, "__gnat_disable_all_sigpipes"); |
1578 | + -- Sets the process to ignore all SIGPIPE signals on platforms that | | 1578 | + -- Sets the process to ignore all SIGPIPE signals on platforms that |
1579 | + -- don't support Disable_SIGPIPE for particular streams. | | 1579 | + -- don't support Disable_SIGPIPE for particular streams. |
1580 | + | | 1580 | + |
1581 | + function C_Fcntl | | 1581 | + function C_Fcntl |
1582 | + (Fd : C.int; | | 1582 | + (Fd : C.int; |
1583 | + Cmd : C.int; | | 1583 | + Cmd : C.int; |
1584 | + Val : C.int) return C.int; | | 1584 | + Val : C.int) return C.int; |
1585 | + pragma Import (C, C_Fcntl, "fcntl"); | | 1585 | + pragma Import (C, C_Fcntl, "fcntl"); |
1586 | + -- The ioctl of 64-bit DragonFlyBSD, OpenBSD, and NetBSD does not support | | 1586 | + -- The ioctl of 64-bit DragonFlyBSD, OpenBSD, and NetBSD does not support |
1587 | + -- setting a socket in non-blocking mode. fcntl must be used instead. | | 1587 | + -- setting a socket in non-blocking mode. fcntl must be used instead. |
1588 | + | | 1588 | + |
1589 | + -------------- | | 1589 | + -------------- |
1590 | + -- C_Accept -- | | 1590 | + -- C_Accept -- |
1591 | + -------------- | | 1591 | + -------------- |
1592 | + | | 1592 | + |
1593 | + function C_Accept | | 1593 | + function C_Accept |
1594 | + (S : C.int; | | 1594 | + (S : C.int; |
1595 | + Addr : System.Address; | | 1595 | + Addr : System.Address; |
1596 | + Addrlen : not null access C.int) return C.int | | 1596 | + Addrlen : not null access C.int) return C.int |
1597 | + is | | 1597 | + is |
1598 | + Res : constant C.int := Syscall_Accept (S, Addr, Addrlen); | | 1598 | + Res : constant C.int := Syscall_Accept (S, Addr, Addrlen); |
1599 | + begin | | 1599 | + begin |
1600 | + | | 1600 | + |
1601 | + Disable_SIGPIPE (Res); | | 1601 | + Disable_SIGPIPE (Res); |
1602 | + return Res; | | 1602 | + return Res; |
1603 | + | | 1603 | + |
1604 | + end C_Accept; | | 1604 | + end C_Accept; |
1605 | + | | 1605 | + |
1606 | + --------------- | | 1606 | + --------------- |
1607 | + -- C_Connect -- | | 1607 | + -- C_Connect -- |
1608 | + --------------- | | 1608 | + --------------- |
1609 | + | | 1609 | + |
1610 | + function C_Connect | | 1610 | + function C_Connect |
1611 | + (S : C.int; | | 1611 | + (S : C.int; |
1612 | + Name : System.Address; | | 1612 | + Name : System.Address; |
1613 | + Namelen : C.int) return C.int | | 1613 | + Namelen : C.int) return C.int |
1614 | + is | | 1614 | + is |
1615 | + begin | | 1615 | + begin |
1616 | + | | 1616 | + |
1617 | + return Syscall_Connect (S, Name, Namelen); | | 1617 | + return Syscall_Connect (S, Name, Namelen); |
1618 | + | | 1618 | + |
1619 | + end C_Connect; | | 1619 | + end C_Connect; |
1620 | + | | 1620 | + |
1621 | + ------------------ | | 1621 | + ------------------ |
1622 | + -- Socket_Ioctl -- | | 1622 | + -- Socket_Ioctl -- |
1623 | + ------------------ | | 1623 | + ------------------ |
1624 | + | | 1624 | + |
1625 | + function Socket_Ioctl | | 1625 | + function Socket_Ioctl |
1626 | + (S : C.int; | | 1626 | + (S : C.int; |
1627 | + Req : C.int; | | 1627 | + Req : C.int; |
1628 | + Arg : access C.int) return C.int | | 1628 | + Arg : access C.int) return C.int |
1629 | + is | | 1629 | + is |
1630 | + -- Currently all requests are of the FIONBIO type, so always calc flags | | 1630 | + -- Currently all requests are of the FIONBIO type, so always calc flags |
1631 | + use Interfaces; | | 1631 | + use Interfaces; |
1632 | + flags : constant Unsigned_32 := | | 1632 | + flags : constant Unsigned_32 := |
1633 | + Unsigned_32 (C_Fcntl (S, SOSC.F_GETFL, 0)); | | 1633 | + Unsigned_32 (C_Fcntl (S, SOSC.F_GETFL, 0)); |
1634 | + nonblock : constant Unsigned_32 := Unsigned_32 (SOSC.FNDELAY); | | 1634 | + nonblock : constant Unsigned_32 := Unsigned_32 (SOSC.FNDELAY); |
1635 | + enabled : constant Boolean := Arg.all = 1; | | 1635 | + enabled : constant Boolean := Arg.all = 1; |
1636 | + newval : C.int; | | 1636 | + newval : C.int; |
1637 | + begin | | 1637 | + begin |
1638 | + if Req = SOSC.FIONBIO then | | 1638 | + if Req = SOSC.FIONBIO then |
1639 | + if enabled then | | 1639 | + if enabled then |
1640 | + newval := C.int (flags or nonblock); | | 1640 | + newval := C.int (flags or nonblock); |
1641 | + elsif (flags and nonblock) > 0 then | | 1641 | + elsif (flags and nonblock) > 0 then |
1642 | + newval := C.int (flags - nonblock); | | 1642 | + newval := C.int (flags - nonblock); |
1643 | + else | | 1643 | + else |
1644 | + newval := C.int (flags); | | 1644 | + newval := C.int (flags); |
1645 | + end if; | | 1645 | + end if; |
1646 | + return C_Fcntl (Fd => S, Cmd => SOSC.F_SETFL, Val => newval); | | 1646 | + return C_Fcntl (Fd => S, Cmd => SOSC.F_SETFL, Val => newval); |
1647 | + else | | 1647 | + else |
1648 | + return C_Ioctl (Fd => S, Req => Req, Arg => Arg); | | 1648 | + return C_Ioctl (Fd => S, Req => Req, Arg => Arg); |
1649 | + end if; | | 1649 | + end if; |
1650 | + end Socket_Ioctl; | | 1650 | + end Socket_Ioctl; |
1651 | + | | 1651 | + |
1652 | + ------------ | | 1652 | + ------------ |
1653 | + -- C_Recv -- | | 1653 | + -- C_Recv -- |
1654 | + ------------ | | 1654 | + ------------ |
1655 | + | | 1655 | + |
1656 | + function C_Recv | | 1656 | + function C_Recv |
1657 | + (S : C.int; | | 1657 | + (S : C.int; |
1658 | + Msg : System.Address; | | 1658 | + Msg : System.Address; |
1659 | + Len : C.int; | | 1659 | + Len : C.int; |
1660 | + Flags : C.int) return C.int | | 1660 | + Flags : C.int) return C.int |
1661 | + is | | 1661 | + is |
1662 | + begin | | 1662 | + begin |
1663 | + | | 1663 | + |
1664 | + return Syscall_Recv (S, Msg, Len, Flags); | | 1664 | + return Syscall_Recv (S, Msg, Len, Flags); |
1665 | + | | 1665 | + |
1666 | + end C_Recv; | | 1666 | + end C_Recv; |
1667 | + | | 1667 | + |
1668 | + ---------------- | | 1668 | + ---------------- |
1669 | + -- C_Recvfrom -- | | 1669 | + -- C_Recvfrom -- |
1670 | + ---------------- | | 1670 | + ---------------- |
1671 | + | | 1671 | + |
1672 | + function C_Recvfrom | | 1672 | + function C_Recvfrom |
1673 | + (S : C.int; | | 1673 | + (S : C.int; |
1674 | + Msg : System.Address; | | 1674 | + Msg : System.Address; |
1675 | + Len : C.int; | | 1675 | + Len : C.int; |
1676 | + Flags : C.int; | | 1676 | + Flags : C.int; |
1677 | + From : System.Address; | | 1677 | + From : System.Address; |
1678 | + Fromlen : not null access C.int) return C.int | | 1678 | + Fromlen : not null access C.int) return C.int |
1679 | + is | | 1679 | + is |
1680 | + begin | | 1680 | + begin |
1681 | + | | 1681 | + |
1682 | + return Syscall_Recvfrom (S, Msg, Len, Flags, From, Fromlen); | | 1682 | + return Syscall_Recvfrom (S, Msg, Len, Flags, From, Fromlen); |
1683 | + | | 1683 | + |
1684 | + end C_Recvfrom; | | 1684 | + end C_Recvfrom; |
1685 | + | | 1685 | + |
1686 | + --------------- | | 1686 | + --------------- |
1687 | + -- C_Recvmsg -- | | 1687 | + -- C_Recvmsg -- |
1688 | + --------------- | | 1688 | + --------------- |
1689 | + | | 1689 | + |
1690 | + function C_Recvmsg | | 1690 | + function C_Recvmsg |
1691 | + (S : C.int; | | 1691 | + (S : C.int; |
1692 | + Msg : System.Address; | | 1692 | + Msg : System.Address; |
1693 | + Flags : C.int) return System.CRTL.ssize_t | | 1693 | + Flags : C.int) return System.CRTL.ssize_t |
1694 | + is | | 1694 | + is |
1695 | + begin | | 1695 | + begin |
1696 | + | | 1696 | + |
1697 | + return Syscall_Recvmsg (S, Msg, Flags); | | 1697 | + return Syscall_Recvmsg (S, Msg, Flags); |
1698 | + | | 1698 | + |
1699 | + end C_Recvmsg; | | 1699 | + end C_Recvmsg; |
1700 | + | | 1700 | + |
1701 | + --------------- | | 1701 | + --------------- |
1702 | + -- C_Sendmsg -- | | 1702 | + -- C_Sendmsg -- |
1703 | + --------------- | | 1703 | + --------------- |
1704 | + | | 1704 | + |
1705 | + function C_Sendmsg | | 1705 | + function C_Sendmsg |
1706 | + (S : C.int; | | 1706 | + (S : C.int; |
1707 | + Msg : System.Address; | | 1707 | + Msg : System.Address; |
1708 | + Flags : C.int) return System.CRTL.ssize_t | | 1708 | + Flags : C.int) return System.CRTL.ssize_t |
1709 | + is | | 1709 | + is |
1710 | + begin | | 1710 | + begin |
1711 | + | | 1711 | + |
1712 | + return Syscall_Sendmsg (S, Msg, Flags); | | 1712 | + return Syscall_Sendmsg (S, Msg, Flags); |
1713 | + | | 1713 | + |
1714 | + end C_Sendmsg; | | 1714 | + end C_Sendmsg; |
1715 | + | | 1715 | + |
1716 | + -------------- | | 1716 | + -------------- |
1717 | + -- C_Sendto -- | | 1717 | + -- C_Sendto -- |
1718 | + -------------- | | 1718 | + -------------- |
1719 | + | | 1719 | + |
1720 | + function C_Sendto | | 1720 | + function C_Sendto |
1721 | + (S : C.int; | | 1721 | + (S : C.int; |
1722 | + Msg : System.Address; | | 1722 | + Msg : System.Address; |
1723 | + Len : C.int; | | 1723 | + Len : C.int; |
1724 | + Flags : C.int; | | 1724 | + Flags : C.int; |
1725 | + To : System.Address; | | 1725 | + To : System.Address; |
1726 | + Tolen : C.int) return C.int | | 1726 | + Tolen : C.int) return C.int |
1727 | + is | | 1727 | + is |
1728 | + begin | | 1728 | + begin |
1729 | + | | 1729 | + |
1730 | + return Syscall_Sendto (S, Msg, Len, Flags, To, Tolen); | | 1730 | + return Syscall_Sendto (S, Msg, Len, Flags, To, Tolen); |
1731 | + | | 1731 | + |
1732 | + end C_Sendto; | | 1732 | + end C_Sendto; |
1733 | + | | 1733 | + |
1734 | + -------------- | | 1734 | + -------------- |
1735 | + -- C_Socket -- | | 1735 | + -- C_Socket -- |
1736 | + -------------- | | 1736 | + -------------- |
1737 | + | | 1737 | + |
1738 | + function C_Socket | | 1738 | + function C_Socket |
1739 | + (Domain : C.int; | | 1739 | + (Domain : C.int; |
1740 | + Typ : C.int; | | 1740 | + Typ : C.int; |
1741 | + Protocol : C.int) return C.int | | 1741 | + Protocol : C.int) return C.int |
1742 | + is | | 1742 | + is |
1743 | + Res : constant C.int := Syscall_Socket (Domain, Typ, Protocol); | | 1743 | + Res : constant C.int := Syscall_Socket (Domain, Typ, Protocol); |
1744 | + begin | | 1744 | + begin |
1745 | + | | 1745 | + |
1746 | + Disable_SIGPIPE (Res); | | 1746 | + Disable_SIGPIPE (Res); |
1747 | + return Res; | | 1747 | + return Res; |
1748 | + | | 1748 | + |
1749 | + end C_Socket; | | 1749 | + end C_Socket; |
1750 | + | | 1750 | + |
1751 | + -------------- | | 1751 | + -------------- |
1752 | + -- Finalize -- | | 1752 | + -- Finalize -- |
1753 | + -------------- | | 1753 | + -------------- |
1754 | + | | 1754 | + |
1755 | + procedure Finalize is | | 1755 | + procedure Finalize is |
1756 | + begin | | 1756 | + begin |
1757 | + null; | | 1757 | + null; |
1758 | + end Finalize; | | 1758 | + end Finalize; |
1759 | + | | 1759 | + |
1760 | + ------------------------- | | 1760 | + ------------------------- |
1761 | + -- Host_Error_Messages -- | | 1761 | + -- Host_Error_Messages -- |
1762 | + ------------------------- | | 1762 | + ------------------------- |
1763 | + | | 1763 | + |
1764 | + package body Host_Error_Messages is separate; | | 1764 | + package body Host_Error_Messages is separate; |
1765 | + | | 1765 | + |
1766 | + ---------------- | | 1766 | + ---------------- |
1767 | + -- Initialize -- | | 1767 | + -- Initialize -- |
1768 | + ---------------- | | 1768 | + ---------------- |
1769 | + | | 1769 | + |
1770 | + procedure Initialize is | | 1770 | + procedure Initialize is |
1771 | + begin | | 1771 | + begin |
1772 | + Disable_All_SIGPIPEs; | | 1772 | + Disable_All_SIGPIPEs; |
1773 | + end Initialize; | | 1773 | + end Initialize; |
1774 | + | | 1774 | + |
1775 | + -------------------- | | 1775 | + -------------------- |
1776 | + -- Signalling_Fds -- | | 1776 | + -- Signalling_Fds -- |
1777 | + -------------------- | | 1777 | + -------------------- |
1778 | + | | 1778 | + |
1779 | + package body Signalling_Fds is | | 1779 | + package body Signalling_Fds is |
1780 | + | | 1780 | + |
1781 | + -- In this default implementation, we use a C version of these | | 1781 | + -- In this default implementation, we use a C version of these |
1782 | + -- subprograms provided by socket.c. | | 1782 | + -- subprograms provided by socket.c. |
1783 | + | | 1783 | + |
1784 | + function C_Create (Fds : not null access Fd_Pair) return C.int; | | 1784 | + function C_Create (Fds : not null access Fd_Pair) return C.int; |
1785 | + function C_Read (Rsig : C.int) return C.int; | | 1785 | + function C_Read (Rsig : C.int) return C.int; |
1786 | + function C_Write (Wsig : C.int) return C.int; | | 1786 | + function C_Write (Wsig : C.int) return C.int; |
1787 | + procedure C_Close (Sig : C.int); | | 1787 | + procedure C_Close (Sig : C.int); |
1788 | + | | 1788 | + |
1789 | + pragma Import (C, C_Create, "__gnat_create_signalling_fds"); | | 1789 | + pragma Import (C, C_Create, "__gnat_create_signalling_fds"); |
1790 | + pragma Import (C, C_Read, "__gnat_read_signalling_fd"); | | 1790 | + pragma Import (C, C_Read, "__gnat_read_signalling_fd"); |
1791 | + pragma Import (C, C_Write, "__gnat_write_signalling_fd"); | | 1791 | + pragma Import (C, C_Write, "__gnat_write_signalling_fd"); |
1792 | + pragma Import (C, C_Close, "__gnat_close_signalling_fd"); | | 1792 | + pragma Import (C, C_Close, "__gnat_close_signalling_fd"); |
1793 | + | | 1793 | + |
1794 | + function Create | | 1794 | + function Create |
1795 | + (Fds : not null access Fd_Pair) return C.int renames C_Create; | | 1795 | + (Fds : not null access Fd_Pair) return C.int renames C_Create; |
1796 | + function Read (Rsig : C.int) return C.int renames C_Read; | | 1796 | + function Read (Rsig : C.int) return C.int renames C_Read; |
1797 | + function Write (Wsig : C.int) return C.int renames C_Write; | | 1797 | + function Write (Wsig : C.int) return C.int renames C_Write; |
1798 | + procedure Close (Sig : C.int) renames C_Close; | | 1798 | + procedure Close (Sig : C.int) renames C_Close; |
1799 | + | | 1799 | + |
1800 | + end Signalling_Fds; | | 1800 | + end Signalling_Fds; |
1801 | + | | 1801 | + |
1802 | + -------------------------- | | 1802 | + -------------------------- |
1803 | + -- Socket_Error_Message -- | | 1803 | + -- Socket_Error_Message -- |
1804 | + -------------------------- | | 1804 | + -------------------------- |
1805 | + | | 1805 | + |
1806 | + function Socket_Error_Message | | 1806 | + function Socket_Error_Message |
1807 | + (Errno : Integer) return C.Strings.chars_ptr | | 1807 | + (Errno : Integer) return C.Strings.chars_ptr |
1808 | + is separate; | | 1808 | + is separate; |
1809 | + | | 1809 | + |
1810 | +end GNAT.Sockets.Thin; | | 1810 | +end GNAT.Sockets.Thin; |
1811 | --- /dev/null | | 1811 | --- /dev/null |
1812 | +++ gcc/ada/g-socthi-netbsd6.ads | | 1812 | +++ gcc/ada/g-socthi-netbsd6.ads |
1813 | @@ -0,0 +1,263 @@ | | 1813 | @@ -0,0 +1,263 @@ |
1814 | +------------------------------------------------------------------------------ | | 1814 | +------------------------------------------------------------------------------ |
1815 | +-- -- | | 1815 | +-- -- |
1816 | +-- GNAT COMPILER COMPONENTS -- | | 1816 | +-- GNAT COMPILER COMPONENTS -- |
1817 | +-- -- | | 1817 | +-- -- |
1818 | +-- G N A T . S O C K E T S . T H I N -- | | 1818 | +-- G N A T . S O C K E T S . T H I N -- |
1819 | +-- -- | | 1819 | +-- -- |
1820 | +-- S p e c -- | | 1820 | +-- S p e c -- |
1821 | +-- -- | | 1821 | +-- -- |
1822 | +-- Copyright (C) 2001-2009, AdaCore -- | | 1822 | +-- Copyright (C) 2001-2009, AdaCore -- |
1823 | +-- -- | | 1823 | +-- -- |
1824 | +-- GNAT is free software; you can redistribute it and/or modify it under -- | | 1824 | +-- GNAT is free software; you can redistribute it and/or modify it under -- |
1825 | +-- terms of the GNU General Public License as published by the Free Soft- -- | | 1825 | +-- terms of the GNU General Public License as published by the Free Soft- -- |
1826 | +-- ware Foundation; either version 2, or (at your option) any later ver- -- | | 1826 | +-- ware Foundation; either version 2, or (at your option) any later ver- -- |
1827 | +-- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- | | 1827 | +-- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- |
1828 | +-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- | | 1828 | +-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- |
1829 | +-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- | | 1829 | +-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- |
1830 | +-- for more details. You should have received a copy of the GNU General -- | | 1830 | +-- for more details. You should have received a copy of the GNU General -- |
1831 | +-- Public License distributed with GNAT; see file COPYING. If not, write -- | | 1831 | +-- Public License distributed with GNAT; see file COPYING. If not, write -- |
1832 | +-- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, -- | | 1832 | +-- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, -- |
1833 | +-- Boston, MA 02110-1301, USA. -- | | 1833 | +-- Boston, MA 02110-1301, USA. -- |
1834 | +-- -- | | 1834 | +-- -- |
1835 | +-- As a special exception, if other files instantiate generics from this -- | | 1835 | +-- As a special exception, if other files instantiate generics from this -- |
1836 | +-- unit, or you link this unit with other files to produce an executable, -- | | 1836 | +-- unit, or you link this unit with other files to produce an executable, -- |
1837 | +-- this unit does not by itself cause the resulting executable to be -- | | 1837 | +-- this unit does not by itself cause the resulting executable to be -- |
1838 | +-- covered by the GNU General Public License. This exception does not -- | | 1838 | +-- covered by the GNU General Public License. This exception does not -- |
1839 | +-- however invalidate any other reasons why the executable file might be -- | | 1839 | +-- however invalidate any other reasons why the executable file might be -- |
1840 | +-- covered by the GNU Public License. -- | | 1840 | +-- covered by the GNU Public License. -- |
1841 | +-- -- | | 1841 | +-- -- |
1842 | +-- GNAT was originally developed by the GNAT team at New York University. -- | | 1842 | +-- GNAT was originally developed by the GNAT team at New York University. -- |
1843 | +-- Extensive contributions were provided by Ada Core Technologies Inc. -- | | 1843 | +-- Extensive contributions were provided by Ada Core Technologies Inc. -- |
1844 | +-- -- | | 1844 | +-- -- |
1845 | +-- Copyright (C) 2011 John Marino <www.dragonlace.net> -- | | 1845 | +-- Copyright (C) 2011 John Marino <www.dragonlace.net> -- |
1846 | +------------------------------------------------------------------------------ | | 1846 | +------------------------------------------------------------------------------ |
1847 | + | | 1847 | + |
1848 | +-- This package provides a target dependent thin interface to the sockets | | 1848 | +-- This package provides a target dependent thin interface to the sockets |
1849 | +-- layer for use by the GNAT.Sockets package (g-socket.ads). This package | | 1849 | +-- layer for use by the GNAT.Sockets package (g-socket.ads). This package |
1850 | +-- should not be directly with'ed by an applications program. | | 1850 | +-- should not be directly with'ed by an applications program. |
1851 | + | | 1851 | + |
1852 | +-- This is the NetBSD 6+ version | | 1852 | +-- This is the NetBSD 6+ version |
1853 | + | | 1853 | + |
1854 | +with Interfaces.C.Strings; | | 1854 | +with Interfaces.C.Strings; |
1855 | + | | 1855 | + |
1856 | +with GNAT.OS_Lib; | | 1856 | +with GNAT.OS_Lib; |
1857 | +with GNAT.Sockets.Thin_Common; | | 1857 | +with GNAT.Sockets.Thin_Common; |
1858 | + | | 1858 | + |
1859 | +with System; | | 1859 | +with System; |
1860 | +with System.CRTL; | | 1860 | +with System.CRTL; |
1861 | + | | 1861 | + |
1862 | +package GNAT.Sockets.Thin is | | 1862 | +package GNAT.Sockets.Thin is |
1863 | + | | 1863 | + |
1864 | + -- This package is intended for hosts implementing BSD sockets with a | | 1864 | + -- This package is intended for hosts implementing BSD sockets with a |
1865 | + -- standard interface. It will be used as a default for all the platforms | | 1865 | + -- standard interface. It will be used as a default for all the platforms |
1866 | + -- that do not have a specific version of this file. | | 1866 | + -- that do not have a specific version of this file. |
1867 | + | | 1867 | + |
1868 | + use Thin_Common; | | 1868 | + use Thin_Common; |
1869 | + | | 1869 | + |
1870 | + package C renames Interfaces.C; | | 1870 | + package C renames Interfaces.C; |
1871 | + | | 1871 | + |
1872 | + use type System.CRTL.ssize_t; | | 1872 | + use type System.CRTL.ssize_t; |
1873 | + | | 1873 | + |
1874 | + function Socket_Errno return Integer renames GNAT.OS_Lib.Errno; | | 1874 | + function Socket_Errno return Integer renames GNAT.OS_Lib.Errno; |
1875 | + -- Returns last socket error number | | 1875 | + -- Returns last socket error number |
1876 | + | | 1876 | + |
1877 | + function Socket_Error_Message (Errno : Integer) return C.Strings.chars_ptr; | | 1877 | + function Socket_Error_Message (Errno : Integer) return C.Strings.chars_ptr; |
1878 | + -- Returns the error message string for the error number Errno. If Errno is | | 1878 | + -- Returns the error message string for the error number Errno. If Errno is |
1879 | + -- not known, returns "Unknown system error". | | 1879 | + -- not known, returns "Unknown system error". |
1880 | + | | 1880 | + |
1881 | + function Host_Errno return Integer; | | 1881 | + function Host_Errno return Integer; |
1882 | + pragma Import (C, Host_Errno, "__gnat_get_h_errno"); | | 1882 | + pragma Import (C, Host_Errno, "__gnat_get_h_errno"); |
1883 | + -- Returns last host error number | | 1883 | + -- Returns last host error number |
1884 | + | | 1884 | + |
1885 | + package Host_Error_Messages is | | 1885 | + package Host_Error_Messages is |
1886 | + | | 1886 | + |
1887 | + function Host_Error_Message | | 1887 | + function Host_Error_Message |
1888 | + (H_Errno : Integer) return C.Strings.chars_ptr; | | 1888 | + (H_Errno : Integer) return C.Strings.chars_ptr; |
1889 | + -- Returns the error message string for the host error number H_Errno. | | 1889 | + -- Returns the error message string for the host error number H_Errno. |
1890 | + -- If H_Errno is not known, returns "Unknown system error". | | 1890 | + -- If H_Errno is not known, returns "Unknown system error". |
1891 | + | | 1891 | + |
1892 | + end Host_Error_Messages; | | 1892 | + end Host_Error_Messages; |
1893 | + | | 1893 | + |
1894 | + -------------------------------- | | 1894 | + -------------------------------- |
1895 | + -- Standard library functions -- | | 1895 | + -- Standard library functions -- |
1896 | + -------------------------------- | | 1896 | + -------------------------------- |
1897 | + | | 1897 | + |
1898 | + function C_Accept | | 1898 | + function C_Accept |
1899 | + (S : C.int; | | 1899 | + (S : C.int; |
1900 | + Addr : System.Address; | | 1900 | + Addr : System.Address; |
1901 | + Addrlen : not null access C.int) return C.int; | | 1901 | + Addrlen : not null access C.int) return C.int; |
1902 | + | | 1902 | + |
1903 | + function C_Bind | | 1903 | + function C_Bind |
1904 | + (S : C.int; | | 1904 | + (S : C.int; |
1905 | + Name : System.Address; | | 1905 | + Name : System.Address; |
1906 | + Namelen : C.int) return C.int; | | 1906 | + Namelen : C.int) return C.int; |
1907 | + | | 1907 | + |
1908 | + function C_Close | | 1908 | + function C_Close |
1909 | + (Fd : C.int) return C.int; | | 1909 | + (Fd : C.int) return C.int; |
1910 | + | | 1910 | + |
1911 | + function C_Connect | | 1911 | + function C_Connect |
1912 | + (S : C.int; | | 1912 | + (S : C.int; |
1913 | + Name : System.Address; | | 1913 | + Name : System.Address; |
1914 | + Namelen : C.int) return C.int; | | 1914 | + Namelen : C.int) return C.int; |
1915 | + | | 1915 | + |
1916 | + function C_Gethostname | | 1916 | + function C_Gethostname |
1917 | + (Name : System.Address; | | 1917 | + (Name : System.Address; |
1918 | + Namelen : C.int) return C.int; | | 1918 | + Namelen : C.int) return C.int; |
1919 | + | | 1919 | + |
1920 | + function C_Getpeername | | 1920 | + function C_Getpeername |
1921 | + (S : C.int; | | 1921 | + (S : C.int; |
1922 | + Name : System.Address; | | 1922 | + Name : System.Address; |
1923 | + Namelen : not null access C.int) return C.int; | | 1923 | + Namelen : not null access C.int) return C.int; |
1924 | + | | 1924 | + |
1925 | + function C_Getsockname | | 1925 | + function C_Getsockname |
1926 | + (S : C.int; | | 1926 | + (S : C.int; |
1927 | + Name : System.Address; | | 1927 | + Name : System.Address; |
1928 | + Namelen : not null access C.int) return C.int; | | 1928 | + Namelen : not null access C.int) return C.int; |
1929 | + | | 1929 | + |
1930 | + function C_Getsockopt | | 1930 | + function C_Getsockopt |
1931 | + (S : C.int; | | 1931 | + (S : C.int; |
1932 | + Level : C.int; | | 1932 | + Level : C.int; |
1933 | + Optname : C.int; | | 1933 | + Optname : C.int; |
1934 | + Optval : System.Address; | | 1934 | + Optval : System.Address; |
1935 | + Optlen : not null access C.int) return C.int; | | 1935 | + Optlen : not null access C.int) return C.int; |
1936 | + | | 1936 | + |
1937 | + function Socket_Ioctl | | 1937 | + function Socket_Ioctl |
1938 | + (S : C.int; | | 1938 | + (S : C.int; |
1939 | + Req : C.int; | | 1939 | + Req : C.int; |
1940 | + Arg : access C.int) return C.int; | | 1940 | + Arg : access C.int) return C.int; |
1941 | + | | 1941 | + |
1942 | + function C_Listen | | 1942 | + function C_Listen |
1943 | + (S : C.int; | | 1943 | + (S : C.int; |
1944 | + Backlog : C.int) return C.int; | | 1944 | + Backlog : C.int) return C.int; |
1945 | + | | 1945 | + |
1946 | + function C_Recv | | 1946 | + function C_Recv |
1947 | + (S : C.int; | | 1947 | + (S : C.int; |
1948 | + Msg : System.Address; | | 1948 | + Msg : System.Address; |
1949 | + Len : C.int; | | 1949 | + Len : C.int; |
1950 | + Flags : C.int) return C.int; | | 1950 | + Flags : C.int) return C.int; |
1951 | + | | 1951 | + |
1952 | + function C_Recvfrom | | 1952 | + function C_Recvfrom |
1953 | + (S : C.int; | | 1953 | + (S : C.int; |
1954 | + Msg : System.Address; | | 1954 | + Msg : System.Address; |
1955 | + Len : C.int; | | 1955 | + Len : C.int; |
1956 | + Flags : C.int; | | 1956 | + Flags : C.int; |
1957 | + From : System.Address; | | 1957 | + From : System.Address; |
1958 | + Fromlen : not null access C.int) return C.int; | | 1958 | + Fromlen : not null access C.int) return C.int; |
1959 | + | | 1959 | + |
1960 | + function C_Recvmsg | | 1960 | + function C_Recvmsg |
1961 | + (S : C.int; | | 1961 | + (S : C.int; |
1962 | + Msg : System.Address; | | 1962 | + Msg : System.Address; |
1963 | + Flags : C.int) return System.CRTL.ssize_t; | | 1963 | + Flags : C.int) return System.CRTL.ssize_t; |
1964 | + | | 1964 | + |
1965 | + function C_Select | | 1965 | + function C_Select |
1966 | + (Nfds : C.int; | | 1966 | + (Nfds : C.int; |
1967 | + Readfds : access Fd_Set; | | 1967 | + Readfds : access Fd_Set; |
1968 | + Writefds : access Fd_Set; | | 1968 | + Writefds : access Fd_Set; |
1969 | + Exceptfds : access Fd_Set; | | 1969 | + Exceptfds : access Fd_Set; |
1970 | + Timeout : Timeval_Access) return C.int; | | 1970 | + Timeout : Timeval_Access) return C.int; |
1971 | + | | 1971 | + |
1972 | + function C_Sendmsg | | 1972 | + function C_Sendmsg |
1973 | + (S : C.int; | | 1973 | + (S : C.int; |
1974 | + Msg : System.Address; | | 1974 | + Msg : System.Address; |
1975 | + Flags : C.int) return System.CRTL.ssize_t; | | 1975 | + Flags : C.int) return System.CRTL.ssize_t; |
1976 | + | | 1976 | + |
1977 | + function C_Sendto | | 1977 | + function C_Sendto |
1978 | + (S : C.int; | | 1978 | + (S : C.int; |
1979 | + Msg : System.Address; | | 1979 | + Msg : System.Address; |
1980 | + Len : C.int; | | 1980 | + Len : C.int; |
1981 | + Flags : C.int; | | 1981 | + Flags : C.int; |
1982 | + To : System.Address; | | 1982 | + To : System.Address; |
1983 | + Tolen : C.int) return C.int; | | 1983 | + Tolen : C.int) return C.int; |
1984 | + | | 1984 | + |
1985 | + function C_Setsockopt | | 1985 | + function C_Setsockopt |
1986 | + (S : C.int; | | 1986 | + (S : C.int; |
1987 | + Level : C.int; | | 1987 | + Level : C.int; |
1988 | + Optname : C.int; | | 1988 | + Optname : C.int; |
1989 | + Optval : System.Address; | | 1989 | + Optval : System.Address; |
1990 | + Optlen : C.int) return C.int; | | 1990 | + Optlen : C.int) return C.int; |
1991 | + | | 1991 | + |
1992 | + function C_Shutdown | | 1992 | + function C_Shutdown |
1993 | + (S : C.int; | | 1993 | + (S : C.int; |
1994 | + How : C.int) return C.int; | | 1994 | + How : C.int) return C.int; |
1995 | + | | 1995 | + |
1996 | + function C_Socket | | 1996 | + function C_Socket |
1997 | + (Domain : C.int; | | 1997 | + (Domain : C.int; |
1998 | + Typ : C.int; | | 1998 | + Typ : C.int; |
1999 | + Protocol : C.int) return C.int; | | 1999 | + Protocol : C.int) return C.int; |
2000 | + | | 2000 | + |
2001 | + function C_System | | 2001 | + function C_System |
2002 | + (Command : System.Address) return C.int; | | 2002 | + (Command : System.Address) return C.int; |
2003 | + | | 2003 | + |
2004 | + ------------------------------------------------------- | | 2004 | + ------------------------------------------------------- |
2005 | + -- Signalling file descriptors for selector abortion -- | | 2005 | + -- Signalling file descriptors for selector abortion -- |
2006 | + ------------------------------------------------------- | | 2006 | + ------------------------------------------------------- |
2007 | + | | 2007 | + |
2008 | + package Signalling_Fds is | | 2008 | + package Signalling_Fds is |
2009 | + | | 2009 | + |
2010 | + function Create (Fds : not null access Fd_Pair) return C.int; | | 2010 | + function Create (Fds : not null access Fd_Pair) return C.int; |
2011 | + pragma Convention (C, Create); | | 2011 | + pragma Convention (C, Create); |
2012 | + -- Create a pair of connected descriptors suitable for use with C_Select | | 2012 | + -- Create a pair of connected descriptors suitable for use with C_Select |
2013 | + -- (used for signalling in Selector objects). | | 2013 | + -- (used for signalling in Selector objects). |
2014 | + | | 2014 | + |
2015 | + function Read (Rsig : C.int) return C.int; | | 2015 | + function Read (Rsig : C.int) return C.int; |
2016 | + pragma Convention (C, Read); | | 2016 | + pragma Convention (C, Read); |
2017 | + -- Read one byte of data from rsig, the read end of a pair of signalling | | 2017 | + -- Read one byte of data from rsig, the read end of a pair of signalling |
2018 | + -- fds created by Create_Signalling_Fds. | | 2018 | + -- fds created by Create_Signalling_Fds. |
2019 | + | | 2019 | + |
2020 | + function Write (Wsig : C.int) return C.int; | | 2020 | + function Write (Wsig : C.int) return C.int; |
2021 | + pragma Convention (C, Write); | | 2021 | + pragma Convention (C, Write); |
2022 | + -- Write one byte of data to wsig, the write end of a pair of signalling | | 2022 | + -- Write one byte of data to wsig, the write end of a pair of signalling |
2023 | + -- fds created by Create_Signalling_Fds. | | 2023 | + -- fds created by Create_Signalling_Fds. |
2024 | + | | 2024 | + |
2025 | + procedure Close (Sig : C.int); | | 2025 | + procedure Close (Sig : C.int); |
2026 | + pragma Convention (C, Close); | | 2026 | + pragma Convention (C, Close); |
2027 | + -- Close one end of a pair of signalling fds (ignoring any error) | | 2027 | + -- Close one end of a pair of signalling fds (ignoring any error) |
2028 | + | | 2028 | + |
2029 | + end Signalling_Fds; | | 2029 | + end Signalling_Fds; |
2030 | + | | 2030 | + |
2031 | + ------------------------------------------- | | 2031 | + ------------------------------------------- |
2032 | + -- Nonreentrant network databases access -- | | 2032 | + -- Nonreentrant network databases access -- |
2033 | + ------------------------------------------- | | 2033 | + ------------------------------------------- |
2034 | + | | 2034 | + |
2035 | + -- The following are used only on systems that have nonreentrant | | 2035 | + -- The following are used only on systems that have nonreentrant |
2036 | + -- getXXXbyYYY functions, and do NOT have corresponding getXXXbyYYY_ | | 2036 | + -- getXXXbyYYY functions, and do NOT have corresponding getXXXbyYYY_ |
2037 | + -- functions. Currently, LynxOS is the only such system. | | 2037 | + -- functions. Currently, LynxOS is the only such system. |
2038 | + | | 2038 | + |
2039 | + function Nonreentrant_Gethostbyname | | 2039 | + function Nonreentrant_Gethostbyname |
2040 | + (Name : C.char_array) return Hostent_Access; | | 2040 | + (Name : C.char_array) return Hostent_Access; |
2041 | + | | 2041 | + |
2042 | + function Nonreentrant_Gethostbyaddr | | 2042 | + function Nonreentrant_Gethostbyaddr |
2043 | + (Addr : System.Address; | | 2043 | + (Addr : System.Address; |
2044 | + Addr_Len : C.int; | | 2044 | + Addr_Len : C.int; |
2045 | + Addr_Type : C.int) return Hostent_Access; | | 2045 | + Addr_Type : C.int) return Hostent_Access; |
2046 | + | | 2046 | + |
2047 | + function Nonreentrant_Getservbyname | | 2047 | + function Nonreentrant_Getservbyname |
2048 | + (Name : C.char_array; | | 2048 | + (Name : C.char_array; |
2049 | + Proto : C.char_array) return Servent_Access; | | 2049 | + Proto : C.char_array) return Servent_Access; |
2050 | + | | 2050 | + |
2051 | + function Nonreentrant_Getservbyport | | 2051 | + function Nonreentrant_Getservbyport |
2052 | + (Port : C.int; | | 2052 | + (Port : C.int; |
2053 | + Proto : C.char_array) return Servent_Access; | | 2053 | + Proto : C.char_array) return Servent_Access; |
2054 | + | | 2054 | + |
2055 | + procedure Initialize; | | 2055 | + procedure Initialize; |
2056 | + procedure Finalize; | | 2056 | + procedure Finalize; |
2057 | + | | 2057 | + |
2058 | +private | | 2058 | +private |
2059 | + pragma Import (C, C_Bind, "bind"); | | 2059 | + pragma Import (C, C_Bind, "bind"); |
2060 | + pragma Import (C, C_Close, "close"); | | 2060 | + pragma Import (C, C_Close, "close"); |
2061 | + pragma Import (C, C_Gethostname, "gethostname"); | | 2061 | + pragma Import (C, C_Gethostname, "gethostname"); |
2062 | + pragma Import (C, C_Getpeername, "getpeername"); | | 2062 | + pragma Import (C, C_Getpeername, "getpeername"); |
2063 | + pragma Import (C, C_Getsockname, "getsockname"); | | 2063 | + pragma Import (C, C_Getsockname, "getsockname"); |
2064 | + pragma Import (C, C_Getsockopt, "getsockopt"); | | 2064 | + pragma Import (C, C_Getsockopt, "getsockopt"); |
2065 | + pragma Import (C, C_Listen, "listen"); | | 2065 | + pragma Import (C, C_Listen, "listen"); |
2066 | + pragma Import (C, C_Select, "__select50"); | | 2066 | + pragma Import (C, C_Select, "__select50"); |
2067 | + pragma Import (C, C_Setsockopt, "setsockopt"); | | 2067 | + pragma Import (C, C_Setsockopt, "setsockopt"); |
2068 | + pragma Import (C, C_Shutdown, "shutdown"); | | 2068 | + pragma Import (C, C_Shutdown, "shutdown"); |
2069 | + pragma Import (C, C_System, "system"); | | 2069 | + pragma Import (C, C_System, "system"); |
2070 | + | | 2070 | + |
2071 | + pragma Import (C, Nonreentrant_Gethostbyname, "gethostbyname"); | | 2071 | + pragma Import (C, Nonreentrant_Gethostbyname, "gethostbyname"); |
2072 | + pragma Import (C, Nonreentrant_Gethostbyaddr, "gethostbyaddr"); | | 2072 | + pragma Import (C, Nonreentrant_Gethostbyaddr, "gethostbyaddr"); |
2073 | + pragma Import (C, Nonreentrant_Getservbyname, "getservbyname"); | | 2073 | + pragma Import (C, Nonreentrant_Getservbyname, "getservbyname"); |
2074 | + pragma Import (C, Nonreentrant_Getservbyport, "getservbyport"); | | 2074 | + pragma Import (C, Nonreentrant_Getservbyport, "getservbyport"); |
2075 | + | | 2075 | + |
2076 | +end GNAT.Sockets.Thin; | | 2076 | +end GNAT.Sockets.Thin; |
2077 | --- /dev/null | | 2077 | --- /dev/null |
2078 | +++ gcc/ada/g-trasym-bsd.adb | | 2078 | +++ gcc/ada/g-trasym-bsd.adb |
2079 | @@ -0,0 +1,150 @@ | | 2079 | @@ -0,0 +1,150 @@ |
2080 | +------------------------------------------------------------------------------ | | 2080 | +------------------------------------------------------------------------------ |
2081 | +-- -- | | 2081 | +-- -- |
2082 | +-- GNAT RUN-TIME COMPONENTS -- | | 2082 | +-- GNAT RUN-TIME COMPONENTS -- |
2083 | +-- -- | | 2083 | +-- -- |
2084 | +-- G N A T . T R A C E B A C K . S Y M B O L I C -- | | 2084 | +-- G N A T . T R A C E B A C K . S Y M B O L I C -- |
2085 | +-- -- | | 2085 | +-- -- |
2086 | +-- B o d y -- | | 2086 | +-- B o d y -- |
2087 | +-- -- | | 2087 | +-- -- |
2088 | +-- Copyright (C) 1999-2009, AdaCore -- | | 2088 | +-- Copyright (C) 1999-2009, AdaCore -- |
2089 | +-- -- | | 2089 | +-- -- |
2090 | +-- GNAT is free software; you can redistribute it and/or modify it under -- | | 2090 | +-- GNAT is free software; you can redistribute it and/or modify it under -- |
2091 | +-- terms of the GNU General Public License as published by the Free Soft- -- | | 2091 | +-- terms of the GNU General Public License as published by the Free Soft- -- |
2092 | +-- ware Foundation; either version 2, or (at your option) any later ver- -- | | 2092 | +-- ware Foundation; either version 2, or (at your option) any later ver- -- |
2093 | +-- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- | | 2093 | +-- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- |
2094 | +-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- | | 2094 | +-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- |
2095 | +-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- | | 2095 | +-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- |
2096 | +-- for more details. You should have received a copy of the GNU General -- | | 2096 | +-- for more details. You should have received a copy of the GNU General -- |
2097 | +-- Public License distributed with GNAT; see file COPYING. If not, write -- | | 2097 | +-- Public License distributed with GNAT; see file COPYING. If not, write -- |
2098 | +-- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, -- | | 2098 | +-- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, -- |
2099 | +-- Boston, MA 02110-1301, USA. -- | | 2099 | +-- Boston, MA 02110-1301, USA. -- |
2100 | +-- -- | | 2100 | +-- -- |
2101 | +-- As a special exception, if other files instantiate generics from this -- | | 2101 | +-- As a special exception, if other files instantiate generics from this -- |
2102 | +-- unit, or you link this unit with other files to produce an executable, -- | | 2102 | +-- unit, or you link this unit with other files to produce an executable, -- |
2103 | +-- this unit does not by itself cause the resulting executable to be -- | | 2103 | +-- this unit does not by itself cause the resulting executable to be -- |
2104 | +-- covered by the GNU General Public License. This exception does not -- | | 2104 | +-- covered by the GNU General Public License. This exception does not -- |
2105 | +-- however invalidate any other reasons why the executable file might be -- | | 2105 | +-- however invalidate any other reasons why the executable file might be -- |
2106 | +-- covered by the GNU Public License. -- | | 2106 | +-- covered by the GNU Public License. -- |
2107 | +-- -- | | 2107 | +-- -- |
2108 | +-- GNAT was originally developed by the GNAT team at New York University. -- | | 2108 | +-- GNAT was originally developed by the GNAT team at New York University. -- |
2109 | +-- Extensive contributions were provided by Ada Core Technologies Inc. -- | | 2109 | +-- Extensive contributions were provided by Ada Core Technologies Inc. -- |
2110 | +-- -- | | 2110 | +-- -- |
2111 | +------------------------------------------------------------------------------ | | 2111 | +------------------------------------------------------------------------------ |
2112 | + | | 2112 | + |
2113 | +-- Run-time symbolic traceback support | | 2113 | +-- Run-time symbolic traceback support |
2114 | +-- This file is based on the work by Juergen Pfiefer which is still used | | 2114 | +-- This file is based on the work by Juergen Pfiefer which is still used |
2115 | +-- today to provide symbolic traceback support for gnu/kFreeBSD. | | 2115 | +-- today to provide symbolic traceback support for gnu/kFreeBSD. |
2116 | +-- Incorporated in GNAT-AUX by John Marino <http://www.dragonlace.net> | | 2116 | +-- Incorporated in GNAT-AUX by John Marino <http://www.dragonlace.net> |
2117 | + | | 2117 | + |
2118 | +with System.Soft_Links; | | 2118 | +with System.Soft_Links; |
2119 | +with Ada.Exceptions.Traceback; use Ada.Exceptions.Traceback; | | 2119 | +with Ada.Exceptions.Traceback; use Ada.Exceptions.Traceback; |
2120 | + | | 2120 | + |
2121 | +package body GNAT.Traceback.Symbolic is | | 2121 | +package body GNAT.Traceback.Symbolic is |
2122 | + | | 2122 | + |
2123 | + package TSL renames System.Soft_Links; | | 2123 | + package TSL renames System.Soft_Links; |
2124 | + | | 2124 | + |
2125 | + -- To perform the raw addresses to symbolic form translation we rely on a | | 2125 | + -- To perform the raw addresses to symbolic form translation we rely on a |
2126 | + -- libaddr2line symbolizer which examines debug info from a provided | | 2126 | + -- libaddr2line symbolizer which examines debug info from a provided |
2127 | + -- executable file name, and an absolute path is needed to ensure the file | | 2127 | + -- executable file name, and an absolute path is needed to ensure the file |
2128 | + -- is always found. This is "__gnat_locate_exec_on_path (gnat_argv [0])" | | 2128 | + -- is always found. This is "__gnat_locate_exec_on_path (gnat_argv [0])" |
2129 | + -- for our executable file, a fairly heavy operation so we cache the | | 2129 | + -- for our executable file, a fairly heavy operation so we cache the |
2130 | + -- result. | | 2130 | + -- result. |
2131 | + | | 2131 | + |
2132 | + Exename : System.Address; | | 2132 | + Exename : System.Address; |
2133 | + -- Pointer to the name of the executable file to be used on all | | 2133 | + -- Pointer to the name of the executable file to be used on all |
2134 | + -- invocations of the libaddr2line symbolization service. | | 2134 | + -- invocations of the libaddr2line symbolization service. |
2135 | + | | 2135 | + |
2136 | + Exename_Resolved : Boolean := False; | | 2136 | + Exename_Resolved : Boolean := False; |
2137 | + -- Flag to indicate whether we have performed the executable file name | | 2137 | + -- Flag to indicate whether we have performed the executable file name |
2138 | + -- resolution already. Relying on a not null Exename for this purpose | | 2138 | + -- resolution already. Relying on a not null Exename for this purpose |
2139 | + -- would be potentially inefficient as this is what we will get if the | | 2139 | + -- would be potentially inefficient as this is what we will get if the |
2140 | + -- resolution attempt fails. | | 2140 | + -- resolution attempt fails. |
2141 | + | | 2141 | + |
2142 | + ------------------------ | | 2142 | + ------------------------ |
2143 | + -- Symbolic_Traceback -- | | 2143 | + -- Symbolic_Traceback -- |
2144 | + ------------------------ | | 2144 | + ------------------------ |
2145 | + | | 2145 | + |
2146 | + function Symbolic_Traceback (Traceback : Tracebacks_Array) return String is | | 2146 | + function Symbolic_Traceback (Traceback : Tracebacks_Array) return String is |
2147 | + | | 2147 | + |
2148 | + procedure convert_addresses | | 2148 | + procedure convert_addresses |
2149 | + (filename : System.Address; | | 2149 | + (filename : System.Address; |
2150 | + addrs : System.Address; | | 2150 | + addrs : System.Address; |
2151 | + n_addrs : Integer; | | 2151 | + n_addrs : Integer; |
2152 | + buf : System.Address; | | 2152 | + buf : System.Address; |
2153 | + len : System.Address); | | 2153 | + len : System.Address); |
2154 | + pragma Import (C, convert_addresses, "convert_addresses"); | | 2154 | + pragma Import (C, convert_addresses, "convert_addresses"); |
2155 | + -- This is the procedure version of the Ada-aware addr2line. It places | | 2155 | + -- This is the procedure version of the Ada-aware addr2line. It places |
2156 | + -- in BUF a string representing the symbolic translation of the N_ADDRS | | 2156 | + -- in BUF a string representing the symbolic translation of the N_ADDRS |
2157 | + -- raw addresses provided in ADDRS, looked up in debug information from | | 2157 | + -- raw addresses provided in ADDRS, looked up in debug information from |
2158 | + -- FILENAME. LEN points to an integer which contains the size of the | | 2158 | + -- FILENAME. LEN points to an integer which contains the size of the |
2159 | + -- BUF buffer at input and the result length at output. | | 2159 | + -- BUF buffer at input and the result length at output. |
2160 | + -- | | 2160 | + -- |
2161 | + -- Note that this procedure is *not* thread-safe. | | 2161 | + -- Note that this procedure is *not* thread-safe. |
2162 | + | | 2162 | + |
2163 | + type Argv_Array is array (0 .. 0) of System.Address; | | 2163 | + type Argv_Array is array (0 .. 0) of System.Address; |
2164 | + gnat_argv : access Argv_Array; | | 2164 | + gnat_argv : access Argv_Array; |
2165 | + pragma Import (C, gnat_argv, "gnat_argv"); | | 2165 | + pragma Import (C, gnat_argv, "gnat_argv"); |
2166 | + | | 2166 | + |
2167 | + function locate_exec_on_path | | 2167 | + function locate_exec_on_path |
2168 | + (c_exename : System.Address) return System.Address; | | 2168 | + (c_exename : System.Address) return System.Address; |
2169 | + pragma Import (C, locate_exec_on_path, "__gnat_locate_exec_on_path"); | | 2169 | + pragma Import (C, locate_exec_on_path, "__gnat_locate_exec_on_path"); |
2170 | + | | 2170 | + |
2171 | + B_Size : constant Integer := 256 * Traceback'Length; | | 2171 | + B_Size : constant Integer := 256 * Traceback'Length; |
2172 | + Len : Integer := B_Size; | | 2172 | + Len : Integer := B_Size; |
2173 | + Res : String (1 .. B_Size); | | 2173 | + Res : String (1 .. B_Size); |
2174 | + | | 2174 | + |
2175 | + use type System.Address; | | 2175 | + use type System.Address; |
2176 | + | | 2176 | + |
2177 | + begin | | 2177 | + begin |
2178 | + -- The symbolic translation of an empty set of addresses is an empty | | 2178 | + -- The symbolic translation of an empty set of addresses is an empty |
2179 | + -- string. | | 2179 | + -- string. |
2180 | + | | 2180 | + |
2181 | + if Traceback'Length = 0 then | | 2181 | + if Traceback'Length = 0 then |
2182 | + return ""; | | 2182 | + return ""; |
2183 | + end if; | | 2183 | + end if; |
2184 | + | | 2184 | + |
2185 | + -- If our input set of raw addresses is not empty, resort to the | | 2185 | + -- If our input set of raw addresses is not empty, resort to the |
2186 | + -- libaddr2line service to symbolize it all. | | 2186 | + -- libaddr2line service to symbolize it all. |
2187 | + | | 2187 | + |
2188 | + -- Compute, cache and provide the absolute path to our executable file | | 2188 | + -- Compute, cache and provide the absolute path to our executable file |
2189 | + -- name as the binary file where the relevant debug information is to be | | 2189 | + -- name as the binary file where the relevant debug information is to be |
2190 | + -- found. If the executable file name resolution fails, we have no | | 2190 | + -- found. If the executable file name resolution fails, we have no |
2191 | + -- sensible basis to invoke the symbolizer at all. | | 2191 | + -- sensible basis to invoke the symbolizer at all. |
2192 | + | | 2192 | + |
2193 | + -- Protect all this against concurrent accesses explicitly, as the | | 2193 | + -- Protect all this against concurrent accesses explicitly, as the |
2194 | + -- underlying services are potentially thread unsafe. | | 2194 | + -- underlying services are potentially thread unsafe. |
2195 | + | | 2195 | + |
2196 | + TSL.Lock_Task.all; | | 2196 | + TSL.Lock_Task.all; |
2197 | + | | 2197 | + |
2198 | + if not Exename_Resolved then | | 2198 | + if not Exename_Resolved then |
2199 | + Exename := locate_exec_on_path (gnat_argv (0)); | | 2199 | + Exename := locate_exec_on_path (gnat_argv (0)); |
2200 | + Exename_Resolved := True; | | 2200 | + Exename_Resolved := True; |
2201 | + end if; | | 2201 | + end if; |
2202 | + | | 2202 | + |
2203 | + if Exename /= System.Null_Address then | | 2203 | + if Exename /= System.Null_Address then |
2204 | + Len := Res'Length; | | 2204 | + Len := Res'Length; |
2205 | + convert_addresses | | 2205 | + convert_addresses |
2206 | + (Exename, Traceback'Address, Traceback'Length, | | 2206 | + (Exename, Traceback'Address, Traceback'Length, |
2207 | + Res (1)'Address, Len'Address); | | 2207 | + Res (1)'Address, Len'Address); |
2208 | + end if; | | 2208 | + end if; |
2209 | + | | 2209 | + |
2210 | + TSL.Unlock_Task.all; | | 2210 | + TSL.Unlock_Task.all; |
2211 | + | | 2211 | + |
2212 | + -- Return what the addr2line symbolizer has produced if we have called | | 2212 | + -- Return what the addr2line symbolizer has produced if we have called |
2213 | + -- it (the executable name resolution succeeded), or an empty string | | 2213 | + -- it (the executable name resolution succeeded), or an empty string |
2214 | + -- otherwise. | | 2214 | + -- otherwise. |
2215 | + | | 2215 | + |
2216 | + if Exename /= System.Null_Address then | | 2216 | + if Exename /= System.Null_Address then |
2217 | + return Res (1 .. Len); | | 2217 | + return Res (1 .. Len); |
2218 | + else | | 2218 | + else |
2219 | + return ""; | | 2219 | + return ""; |
2220 | + end if; | | 2220 | + end if; |
2221 | + | | 2221 | + |
2222 | + end Symbolic_Traceback; | | 2222 | + end Symbolic_Traceback; |
2223 | + | | 2223 | + |
2224 | + function Symbolic_Traceback (E : Exception_Occurrence) return String is | | 2224 | + function Symbolic_Traceback (E : Exception_Occurrence) return String is |
2225 | + begin | | 2225 | + begin |
2226 | + return Symbolic_Traceback (Tracebacks (E)); | | 2226 | + return Symbolic_Traceback (Tracebacks (E)); |
2227 | + end Symbolic_Traceback; | | 2227 | + end Symbolic_Traceback; |
2228 | + | | 2228 | + |
2229 | +end GNAT.Traceback.Symbolic; | | 2229 | +end GNAT.Traceback.Symbolic; |
2230 | --- gcc/ada/gnatchop.adb.orig | | 2230 | --- gcc/ada/gnatchop.adb.orig |
2231 | +++ gcc/ada/gnatchop.adb | | 2231 | +++ gcc/ada/gnatchop.adb |
2232 | @@ -21,6 +21,7 @@ | | 2232 | @@ -21,6 +21,7 @@ |
2233 | -- GNAT was originally developed by the GNAT team at New York University. -- | | 2233 | -- GNAT was originally developed by the GNAT team at New York University. -- |
2234 | -- Extensive contributions were provided by Ada Core Technologies Inc. -- | | 2234 | -- Extensive contributions were provided by Ada Core Technologies Inc. -- |
2235 | -- -- | | 2235 | -- -- |
2236 | +-- Copyright (C) 2010 John Marino <draco@marino.st> -- | | 2236 | +-- Copyright (C) 2010 John Marino <draco@marino.st> -- |
2237 | ------------------------------------------------------------------------------ | | 2237 | ------------------------------------------------------------------------------ |
2238 | | | 2238 | |
2239 | with Ada.Characters.Conversions; use Ada.Characters.Conversions; | | 2239 | with Ada.Characters.Conversions; use Ada.Characters.Conversions; |
2240 | @@ -45,7 +46,7 @@ | | 2240 | @@ -45,7 +46,7 @@ |
2241 | Config_File_Name : constant String_Access := new String'("gnat.adc"); | | 2241 | Config_File_Name : constant String_Access := new String'("gnat.adc"); |
2242 | -- The name of the file holding the GNAT configuration pragmas | | 2242 | -- The name of the file holding the GNAT configuration pragmas |
2243 | | | 2243 | |
2244 | - Gcc : String_Access := new String'("gcc"); | | 2244 | - Gcc : String_Access := new String'("gcc"); |
2245 | + Gcc : String_Access := new String'("gnatgcc"); | | 2245 | + Gcc : String_Access := new String'("gnatgcc"); |
2246 | -- May be modified by switch --GCC= | | 2246 | -- May be modified by switch --GCC= |
2247 | | | 2247 | |
2248 | Gcc_Set : Boolean := False; | | 2248 | Gcc_Set : Boolean := False; |
2249 | --- gcc/ada/gnatlink.adb.orig | | 2249 | --- gcc/ada/gnatlink.adb.orig |
2250 | +++ gcc/ada/gnatlink.adb | | 2250 | +++ gcc/ada/gnatlink.adb |
2251 | @@ -21,6 +21,7 @@ | | 2251 | @@ -21,6 +21,7 @@ |
2252 | -- GNAT was originally developed by the GNAT team at New York University. -- | | 2252 | -- GNAT was originally developed by the GNAT team at New York University. -- |
2253 | -- Extensive contributions were provided by Ada Core Technologies Inc. -- | | 2253 | -- Extensive contributions were provided by Ada Core Technologies Inc. -- |
2254 | -- -- | | 2254 | -- -- |
2255 | +-- Copyright (C) 2010 John Marino <draco@marino.st> -- | | 2255 | +-- Copyright (C) 2010 John Marino <draco@marino.st> -- |
2256 | ------------------------------------------------------------------------------ | | 2256 | ------------------------------------------------------------------------------ |
2257 | | | 2257 | |
2258 | -- Gnatlink usage: please consult the gnat documentation | | 2258 | -- Gnatlink usage: please consult the gnat documentation |
2259 | @@ -137,7 +138,7 @@ | | 2259 | @@ -137,7 +138,7 @@ |
2260 | -- This table collects the arguments to be passed to compile the binder | | 2260 | -- This table collects the arguments to be passed to compile the binder |
2261 | -- generated file. | | 2261 | -- generated file. |
2262 | | | 2262 | |
2263 | - Gcc : String_Access := Program_Name ("gcc", "gnatlink"); | | 2263 | - Gcc : String_Access := Program_Name ("gcc", "gnatlink"); |
2264 | + Gcc : String_Access := Program_Name ("gnatgcc", "gnatlink"); | | 2264 | + Gcc : String_Access := Program_Name ("gnatgcc", "gnatlink"); |
2265 | | | 2265 | |
2266 | Read_Mode : constant String := "r" & ASCII.NUL; | | 2266 | Read_Mode : constant String := "r" & ASCII.NUL; |
2267 | | | 2267 | |
2268 | --- gcc/ada/gnatvsn.ads.orig | | 2268 | --- gcc/ada/gnatvsn.ads.orig |
2269 | +++ gcc/ada/gnatvsn.ads | | 2269 | +++ gcc/ada/gnatvsn.ads |
2270 | @@ -27,6 +27,7 @@ | | 2270 | @@ -27,6 +27,7 @@ |
2271 | -- GNAT was originally developed by the GNAT team at New York University. -- | | 2271 | -- GNAT was originally developed by the GNAT team at New York University. -- |
2272 | -- Extensive contributions were provided by Ada Core Technologies Inc. -- | | 2272 | -- Extensive contributions were provided by Ada Core Technologies Inc. -- |
2273 | -- -- | | 2273 | -- -- |
2274 | +-- Copyright (C) 2010 John Marino <draco@marino.st> -- | | 2274 | +-- Copyright (C) 2010 John Marino <draco@marino.st> -- |
2275 | ------------------------------------------------------------------------------ | | 2275 | ------------------------------------------------------------------------------ |
2276 | | | 2276 | |
2277 | -- This package spec holds version information for the GNAT tools. | | 2277 | -- This package spec holds version information for the GNAT tools. |
2278 | @@ -34,7 +35,7 @@ | | 2278 | @@ -34,7 +35,7 @@ |
2279 | | | 2279 | |
2280 | package Gnatvsn is | | 2280 | package Gnatvsn is |
2281 | | | 2281 | |
2282 | - Gnat_Static_Version_String : constant String := "GNU Ada"; | | 2282 | - Gnat_Static_Version_String : constant String := "GNU Ada"; |
2283 | + Gnat_Static_Version_String : constant String := "GNAT AUX"; | | 2283 | + Gnat_Static_Version_String : constant String := "GNAT AUX"; |
2284 | -- Static string identifying this version, that can be used as an argument | | 2284 | -- Static string identifying this version, that can be used as an argument |
2285 | -- to e.g. pragma Ident. | | 2285 | -- to e.g. pragma Ident. |
2286 | | | 2286 | |
2287 | --- gcc/ada/gsocket.h.orig | | 2287 | --- gcc/ada/gsocket.h.orig |
2288 | +++ gcc/ada/gsocket.h | | 2288 | +++ gcc/ada/gsocket.h |
2289 | @@ -27,6 +27,7 @@ | | 2289 | @@ -27,6 +27,7 @@ |
2290 | * GNAT was originally developed by the GNAT team at New York University. * | | 2290 | * GNAT was originally developed by the GNAT team at New York University. * |
2291 | * Extensive contributions were provided by Ada Core Technologies Inc. * | | 2291 | * Extensive contributions were provided by Ada Core Technologies Inc. * |
2292 | * * | | 2292 | * * |
2293 | + * Copyright (C) 2010 John Marino <draco@marino.st> * | | 2293 | + * Copyright (C) 2010 John Marino <draco@marino.st> * |
2294 | ****************************************************************************/ | | 2294 | ****************************************************************************/ |
2295 | | | 2295 | |
2296 | #if defined(__nucleus__) || defined(VTHREADS) | | 2296 | #if defined(__nucleus__) || defined(VTHREADS) |
2297 | @@ -194,7 +195,14 @@ | | 2297 | @@ -194,7 +195,14 @@ |
2298 | #include <netdb.h> | | 2298 | #include <netdb.h> |
2299 | #endif | | 2299 | #endif |
2300 | | | 2300 | |
2301 | +#if defined(__ANDROID__) | | 2301 | +#if defined(__ANDROID__) |
2302 | +#include <sys/select.h> | | 2302 | +#include <sys/select.h> |
2303 | +#endif | | 2303 | +#endif |
2304 | + | | 2304 | + |
2305 | #if defined (_AIX) || defined (__FreeBSD__) || defined (__hpux__) || \ | | 2305 | #if defined (_AIX) || defined (__FreeBSD__) || defined (__hpux__) || \ |
2306 | + defined (__OpenBSD__) || \ | | 2306 | + defined (__OpenBSD__) || \ |
2307 | + defined (__NetBSD__) || \ | | 2307 | + defined (__NetBSD__) || \ |
2308 | + defined (__DragonFly__) || \ | | 2308 | + defined (__DragonFly__) || \ |
2309 | defined (__osf__) || defined (_WIN32) || defined (__APPLE__) | | 2309 | defined (__osf__) || defined (_WIN32) || defined (__APPLE__) |
2310 | # define HAVE_THREAD_SAFE_GETxxxBYyyy 1 | | 2310 | # define HAVE_THREAD_SAFE_GETxxxBYyyy 1 |
2311 | | | 2311 | |
2312 | @@ -227,7 +235,13 @@ | | 2312 | @@ -227,7 +235,13 @@ |
2313 | # endif | | 2313 | # endif |
2314 | #endif | | 2314 | #endif |
2315 | | | 2315 | |
2316 | -#if defined (__FreeBSD__) || defined (__vxworks) || defined(__rtems__) | | 2316 | -#if defined (__FreeBSD__) || defined (__vxworks) || defined(__rtems__) |
2317 | +#if defined (__FreeBSD__) \ | | 2317 | +#if defined (__FreeBSD__) \ |
2318 | + || defined (__DragonFly__) \ | | 2318 | + || defined (__DragonFly__) \ |
2319 | + || defined (__OpenBSD__) \ | | 2319 | + || defined (__OpenBSD__) \ |
2320 | + || defined (__NetBSD__) \ | | 2320 | + || defined (__NetBSD__) \ |
2321 | + || defined (__ANDROID__) \ | | 2321 | + || defined (__ANDROID__) \ |
2322 | + || defined (__vxworks) \ | | 2322 | + || defined (__vxworks) \ |
2323 | + || defined(__rtems__) | | 2323 | + || defined(__rtems__) |
2324 | # define Has_Sockaddr_Len 1 | | 2324 | # define Has_Sockaddr_Len 1 |
2325 | #else | | 2325 | #else |
2326 | # define Has_Sockaddr_Len 0 | | 2326 | # define Has_Sockaddr_Len 0 |
2327 | --- gcc/ada/init.c.orig | | 2327 | --- gcc/ada/init.c.orig |
2328 | +++ gcc/ada/init.c | | 2328 | +++ gcc/ada/init.c |
2329 | @@ -27,6 +27,7 @@ | | 2329 | @@ -27,6 +27,7 @@ |
2330 | * GNAT was originally developed by the GNAT team at New York University. * | | 2330 | * GNAT was originally developed by the GNAT team at New York University. * |
2331 | * Extensive contributions were provided by Ada Core Technologies Inc. * | | 2331 | * Extensive contributions were provided by Ada Core Technologies Inc. * |
2332 | * * | | 2332 | * * |
2333 | + * Copyright (C) 2010, 2011 John Marino <www.dragonlace.net> * | | 2333 | + * Copyright (C) 2010, 2011 John Marino <www.dragonlace.net> * |
2334 | ****************************************************************************/ | | 2334 | ****************************************************************************/ |
2335 | | | 2335 | |
2336 | /* This unit contains initialization circuits that are system dependent. | | 2336 | /* This unit contains initialization circuits that are system dependent. |
2337 | @@ -519,7 +520,7 @@ | | 2337 | @@ -519,7 +520,7 @@ |
2338 | /* GNU/Linux Section */ | | 2338 | /* GNU/Linux Section */ |
2339 | /*********************/ | | 2339 | /*********************/ |
2340 | | | 2340 | |
2341 | -#elif defined (linux) | | 2341 | -#elif defined (linux) |
2342 | +#elif defined (linux) && !defined(__ANDROID__) | | 2342 | +#elif defined (linux) && !defined(__ANDROID__) |
2343 | | | 2343 | |
2344 | #include <signal.h> | | 2344 | #include <signal.h> |
2345 | | | 2345 | |
2346 | @@ -1724,7 +1725,7 @@ | | 2346 | @@ -1724,7 +1725,7 @@ |
2347 | /* FreeBSD Section */ | | 2347 | /* FreeBSD Section */ |
2348 | /*******************/ | | 2348 | /*******************/ |
2349 | | | 2349 | |
2350 | -#elif defined (__FreeBSD__) | | 2350 | -#elif defined (__FreeBSD__) |
2351 | +#elif defined (__FreeBSD__) || defined (__DragonFly__) | | 2351 | +#elif defined (__FreeBSD__) || defined (__DragonFly__) |
2352 | | | 2352 | |
2353 | #include <signal.h> | | 2353 | #include <signal.h> |
2354 | #include <sys/ucontext.h> | | 2354 | #include <sys/ucontext.h> |
2355 | @@ -1769,7 +1770,7 @@ | | 2355 | @@ -1769,7 +1770,7 @@ |
2356 | } | | 2356 | } |
2357 | | | 2357 | |
2358 | void | | 2358 | void |
2359 | -__gnat_install_handler () | | 2359 | -__gnat_install_handler () |
2360 | +__gnat_install_handler (void) | | 2360 | +__gnat_install_handler (void) |
2361 | { | | 2361 | { |
2362 | struct sigaction act; | | 2362 | struct sigaction act; |
2363 | | | 2363 | |
2364 | @@ -1791,6 +1792,77 @@ | | 2364 | @@ -1791,6 +1792,77 @@ |
2365 | } | | 2365 | } |
2366 | | | 2366 | |
2367 | /*******************/ | | 2367 | /*******************/ |
2368 | +/* Android Section */ | | 2368 | +/* Android Section */ |
2369 | +/*******************/ | | 2369 | +/*******************/ |
2370 | + | | 2370 | + |
2371 | +#elif defined(__ANDROID__) | | 2371 | +#elif defined(__ANDROID__) |
2372 | + | | 2372 | + |
2373 | +#include <signal.h> | | 2373 | +#include <signal.h> |
2374 | + | | 2374 | + |
2375 | +static void | | 2375 | +static void |
2376 | +__gnat_error_handler (int sig, | | 2376 | +__gnat_error_handler (int sig, |
2377 | + struct siginfo *si ATTRIBUTE_UNUSED, | | 2377 | + struct siginfo *si ATTRIBUTE_UNUSED, |
2378 | + void *ucontext ATTRIBUTE_UNUSED) | | 2378 | + void *ucontext ATTRIBUTE_UNUSED) |
2379 | +{ | | 2379 | +{ |
2380 | + struct Exception_Data *exception; | | 2380 | + struct Exception_Data *exception; |
2381 | + const char *msg; | | 2381 | + const char *msg; |
2382 | + | | 2382 | + |
2383 | + switch (sig) | | 2383 | + switch (sig) |
2384 | + { | | 2384 | + { |
2385 | + case SIGFPE: | | 2385 | + case SIGFPE: |
2386 | + exception = &constraint_error; | | 2386 | + exception = &constraint_error; |
2387 | + msg = "SIGFPE"; | | 2387 | + msg = "SIGFPE"; |
2388 | + break; | | 2388 | + break; |
2389 | + | | 2389 | + |
2390 | + case SIGILL: | | 2390 | + case SIGILL: |
2391 | + exception = &constraint_error; | | 2391 | + exception = &constraint_error; |
2392 | + msg = "SIGILL"; | | 2392 | + msg = "SIGILL"; |
2393 | + break; | | 2393 | + break; |
2394 | + | | 2394 | + |
2395 | + case SIGSEGV: | | 2395 | + case SIGSEGV: |
2396 | + exception = &storage_error; | | 2396 | + exception = &storage_error; |
2397 | + msg = "stack overflow or erroneous memory access"; | | 2397 | + msg = "stack overflow or erroneous memory access"; |
2398 | + break; | | 2398 | + break; |
2399 | + | | 2399 | + |
2400 | + case SIGBUS: | | 2400 | + case SIGBUS: |
2401 | + exception = &constraint_error; | | 2401 | + exception = &constraint_error; |
2402 | + msg = "SIGBUS"; | | 2402 | + msg = "SIGBUS"; |
2403 | + break; | | 2403 | + break; |
2404 | + | | 2404 | + |
2405 | + default: | | 2405 | + default: |
2406 | + exception = &program_error; | | 2406 | + exception = &program_error; |
2407 | + msg = "unhandled signal"; | | 2407 | + msg = "unhandled signal"; |
2408 | + } | | 2408 | + } |
2409 | + | | 2409 | + |
2410 | + Raise_From_Signal_Handler (exception, msg); | | 2410 | + Raise_From_Signal_Handler (exception, msg); |
2411 | +} | | 2411 | +} |
2412 | + | | 2412 | + |
2413 | +void | | 2413 | +void |
2414 | +__gnat_install_handler (void) | | 2414 | +__gnat_install_handler (void) |
2415 | +{ | | 2415 | +{ |
2416 | + struct sigaction act; | | 2416 | + struct sigaction act; |
2417 | + | | 2417 | + |
2418 | + act.sa_sigaction = __gnat_error_handler; | | 2418 | + act.sa_sigaction = __gnat_error_handler; |
2419 | + act.sa_flags = SA_NODEFER | SA_RESTART | SA_SIGINFO; | | 2419 | + act.sa_flags = SA_NODEFER | SA_RESTART | SA_SIGINFO; |
2420 | + sigemptyset (&act.sa_mask); | | 2420 | + sigemptyset (&act.sa_mask); |
2421 | + | | 2421 | + |
2422 | + /* Do not install handlers if interrupt state is "System". */ | | 2422 | + /* Do not install handlers if interrupt state is "System". */ |
2423 | + if (__gnat_get_interrupt_state (SIGABRT) != 's') | | 2423 | + if (__gnat_get_interrupt_state (SIGABRT) != 's') |
2424 | + sigaction (SIGABRT, &act, NULL); | | 2424 | + sigaction (SIGABRT, &act, NULL); |
2425 | + if (__gnat_get_interrupt_state (SIGFPE) != 's') | | 2425 | + if (__gnat_get_interrupt_state (SIGFPE) != 's') |
2426 | + sigaction (SIGFPE, &act, NULL); | | 2426 | + sigaction (SIGFPE, &act, NULL); |
2427 | + if (__gnat_get_interrupt_state (SIGILL) != 's') | | 2427 | + if (__gnat_get_interrupt_state (SIGILL) != 's') |
2428 | + sigaction (SIGILL, &act, NULL); | | 2428 | + sigaction (SIGILL, &act, NULL); |
2429 | + if (__gnat_get_interrupt_state (SIGBUS) != 's') | | 2429 | + if (__gnat_get_interrupt_state (SIGBUS) != 's') |
2430 | + sigaction (SIGBUS, &act, NULL); | | 2430 | + sigaction (SIGBUS, &act, NULL); |
2431 | + if (__gnat_get_interrupt_state (SIGSEGV) != 's') | | 2431 | + if (__gnat_get_interrupt_state (SIGSEGV) != 's') |
2432 | + sigaction (SIGSEGV, &act, NULL); | | 2432 | + sigaction (SIGSEGV, &act, NULL); |
2433 | + | | 2433 | + |
2434 | + __gnat_handler_installed = 1; | | 2434 | + __gnat_handler_installed = 1; |
2435 | +} | | 2435 | +} |
2436 | + | | 2436 | + |
2437 | + | | 2437 | + |
2438 | +/*******************/ | | 2438 | +/*******************/ |
2439 | /* VxWorks Section */ | | 2439 | /* VxWorks Section */ |
2440 | /*******************/ | | 2440 | /*******************/ |
2441 | | | 2441 | |
2442 | @@ -2320,6 +2392,7 @@ | | 2442 | @@ -2341,6 +2413,7 @@ |
2443 | | | 2443 | |
2444 | #if defined (_WIN32) || defined (__INTERIX) \ | | 2444 | #if defined (_WIN32) || defined (__INTERIX) \ |
2445 | || defined (__Lynx__) || defined(__NetBSD__) || defined(__FreeBSD__) \ | | 2445 | || defined (__Lynx__) || defined(__NetBSD__) || defined(__FreeBSD__) \ |
2446 | + || defined (__DragonFly__) \ | | 2446 | + || defined (__DragonFly__) \ |
2447 | || defined (__OpenBSD__) | | 2447 | || defined (__OpenBSD__) |
2448 | | | 2448 | |
2449 | #define HAVE_GNAT_INIT_FLOAT | | 2449 | #define HAVE_GNAT_INIT_FLOAT |
2450 | --- gcc/ada/initialize.c.orig | | 2450 | --- gcc/ada/initialize.c.orig |
2451 | +++ gcc/ada/initialize.c | | 2451 | +++ gcc/ada/initialize.c |
2452 | @@ -27,6 +27,7 @@ | | 2452 | @@ -27,6 +27,7 @@ |
2453 | * GNAT was originally developed by the GNAT team at New York University. * | | 2453 | * GNAT was originally developed by the GNAT team at New York University. * |
2454 | * Extensive contributions were provided by Ada Core Technologies Inc. * | | 2454 | * Extensive contributions were provided by Ada Core Technologies Inc. * |
2455 | * * | | 2455 | * * |
2456 | + * Copyright (C) 2010 John Marino <draco@marino.st> * | | 2456 | + * Copyright (C) 2010 John Marino <draco@marino.st> * |
2457 | ****************************************************************************/ | | 2457 | ****************************************************************************/ |
2458 | | | 2458 | |
2459 | /* This unit provides default implementation for __gnat_initialize () | | 2459 | /* This unit provides default implementation for __gnat_initialize () |
2460 | @@ -255,6 +256,7 @@ | | 2460 | @@ -255,6 +256,7 @@ |
2461 | /******************************************/ | | 2461 | /******************************************/ |
2462 | | | 2462 | |
2463 | #elif defined (__Lynx__) || defined (__FreeBSD__) || defined(__NetBSD__) \ | | 2463 | #elif defined (__Lynx__) || defined (__FreeBSD__) || defined(__NetBSD__) \ |
2464 | + || defined (__DragonFly__) \ | | 2464 | + || defined (__DragonFly__) \ |
2465 | || defined (__OpenBSD__) | | 2465 | || defined (__OpenBSD__) |
2466 | | | 2466 | |
2467 | extern void __gnat_init_float (void); | | 2467 | extern void __gnat_init_float (void); |
2468 | --- gcc/ada/link.c.orig | | 2468 | --- gcc/ada/link.c.orig |
2469 | +++ gcc/ada/link.c | | 2469 | +++ gcc/ada/link.c |
2470 | @@ -27,6 +27,7 @@ | | 2470 | @@ -27,6 +27,7 @@ |
2471 | * GNAT was originally developed by the GNAT team at New York University. * | | 2471 | * GNAT was originally developed by the GNAT team at New York University. * |
2472 | * Extensive contributions were provided by Ada Core Technologies Inc. * | | 2472 | * Extensive contributions were provided by Ada Core Technologies Inc. * |
2473 | * * | | 2473 | * * |
2474 | + * Copyright (C) 2010, 2011 John Marino <www.dragonlace.net> * | | 2474 | + * Copyright (C) 2010, 2011 John Marino <www.dragonlace.net> * |
2475 | ****************************************************************************/ | | 2475 | ****************************************************************************/ |
2476 | | | 2476 | |
2477 | /* This file contains host-specific parameters describing the behavior */ | | 2477 | /* This file contains host-specific parameters describing the behavior */ |
2478 | @@ -187,7 +188,10 @@ | | 2478 | @@ -187,7 +188,10 @@ |
2479 | const char *__gnat_default_libgcc_subdir = "lib"; | | 2479 | const char *__gnat_default_libgcc_subdir = "lib"; |
2480 | #endif | | 2480 | #endif |
2481 | | | 2481 | |
2482 | -#elif defined (__FreeBSD__) | | 2482 | -#elif defined (__FreeBSD__) |
2483 | +#elif defined (__FreeBSD__) \ | | 2483 | +#elif defined (__FreeBSD__) \ |
2484 | + || defined (__OpenBSD__) \ | | 2484 | + || defined (__OpenBSD__) \ |
2485 | + || defined (__NetBSD__) \ | | 2485 | + || defined (__NetBSD__) \ |
2486 | + || defined (__DragonFly__) | | 2486 | + || defined (__DragonFly__) |
2487 | const char *__gnat_object_file_option = ""; | | 2487 | const char *__gnat_object_file_option = ""; |
2488 | const char *__gnat_run_path_option = "-Wl,-rpath,"; | | 2488 | const char *__gnat_run_path_option = "-Wl,-rpath,"; |
2489 | char __gnat_shared_libgnat_default = STATIC; | | 2489 | char __gnat_shared_libgnat_default = STATIC; |
2490 | --- gcc/ada/make.adb.orig | | 2490 | --- gcc/ada/make.adb.orig |
2491 | +++ gcc/ada/make.adb | | 2491 | +++ gcc/ada/make.adb |
2492 | @@ -21,6 +21,7 @@ | | 2492 | @@ -21,6 +21,7 @@ |
2493 | -- GNAT was originally developed by the GNAT team at New York University. -- | | 2493 | -- GNAT was originally developed by the GNAT team at New York University. -- |
2494 | -- Extensive contributions were provided by Ada Core Technologies Inc. -- | | 2494 | -- Extensive contributions were provided by Ada Core Technologies Inc. -- |
2495 | -- -- | | 2495 | -- -- |
2496 | +-- Copyright (C) 2010 John Marino <draco@marino.st> -- | | 2496 | +-- Copyright (C) 2010 John Marino <draco@marino.st> -- |
2497 | ------------------------------------------------------------------------------ | | 2497 | ------------------------------------------------------------------------------ |
2498 | | | 2498 | |
2499 | with ALI; use ALI; | | 2499 | with ALI; use ALI; |
2500 | @@ -652,7 +653,7 @@ | | 2500 | @@ -652,7 +653,7 @@ |
2501 | -- Compiler, Binder & Linker Data and Subprograms -- | | 2501 | -- Compiler, Binder & Linker Data and Subprograms -- |
2502 | ---------------------------------------------------- | | 2502 | ---------------------------------------------------- |
2503 | | | 2503 | |
2504 | - Gcc : String_Access := Program_Name ("gcc", "gnatmake"); | | 2504 | - Gcc : String_Access := Program_Name ("gcc", "gnatmake"); |
2505 | + Gcc : String_Access := Program_Name ("gnatgcc", "gnatmake"); | | 2505 | + Gcc : String_Access := Program_Name ("gnatgcc", "gnatmake"); |
2506 | Gnatbind : String_Access := Program_Name ("gnatbind", "gnatmake"); | | 2506 | Gnatbind : String_Access := Program_Name ("gnatbind", "gnatmake"); |
2507 | Gnatlink : String_Access := Program_Name ("gnatlink", "gnatmake"); | | 2507 | Gnatlink : String_Access := Program_Name ("gnatlink", "gnatmake"); |
2508 | -- Default compiler, binder, linker programs | | 2508 | -- Default compiler, binder, linker programs |
2509 | --- gcc/ada/mlib-prj.adb.orig | | 2509 | --- gcc/ada/mlib-prj.adb.orig |
2510 | +++ gcc/ada/mlib-prj.adb | | 2510 | +++ gcc/ada/mlib-prj.adb |
2511 | @@ -341,6 +341,11 @@ | | 2511 | @@ -341,6 +341,11 @@ |
2512 | | | 2512 | |
2513 | Foreign_Sources : Boolean; | | 2513 | Foreign_Sources : Boolean; |
2514 | | | 2514 | |
2515 | + Rpath_Disabled : Boolean := False; | | 2515 | + Rpath_Disabled : Boolean := False; |
2516 | + -- If -R is passed through the library options for the linker, it will | | 2516 | + -- If -R is passed through the library options for the linker, it will |
2517 | + -- prevent the implemented libraries portion of the rpath switch from | | 2517 | + -- prevent the implemented libraries portion of the rpath switch from |
2518 | + -- being built, even if the linker is capable of supporting rpath. | | 2518 | + -- being built, even if the linker is capable of supporting rpath. |
2519 | + | | 2519 | + |
2520 | Rpath : String_Access := null; | | 2520 | Rpath : String_Access := null; |
2521 | -- Allocated only if Path Option is supported | | 2521 | -- Allocated only if Path Option is supported |
2522 | | | 2522 | |
2523 | @@ -790,7 +795,7 @@ | | 2523 | @@ -790,7 +795,7 @@ |
2524 | Opts.Table (Opts.Last) := | | 2524 | Opts.Table (Opts.Last) := |
2525 | new String'("-L" & Name_Buffer (1 .. Name_Len)); | | 2525 | new String'("-L" & Name_Buffer (1 .. Name_Len)); |
2526 | | | 2526 | |
2527 | - if Path_Option /= null then | | 2527 | - if Path_Option /= null then |
2528 | + if not Rpath_Disabled and then Path_Option /= null then | | 2528 | + if not Rpath_Disabled and then Path_Option /= null then |
2529 | Add_Rpath (Name_Buffer (1 .. Name_Len)); | | 2529 | Add_Rpath (Name_Buffer (1 .. Name_Len)); |
2530 | end if; | | 2530 | end if; |
2531 | | | 2531 | |
2532 | @@ -1285,6 +1290,9 @@ | | 2532 | @@ -1285,6 +1290,9 @@ |
2533 | Opts.Increment_Last; | | 2533 | Opts.Increment_Last; |
2534 | Opts.Table (Opts.Last) := | | 2534 | Opts.Table (Opts.Last) := |
2535 | new String'(Name_Buffer (1 .. Name_Len)); | | 2535 | new String'(Name_Buffer (1 .. Name_Len)); |
2536 | + if Name_Len = 2 and then Name_Buffer (1 .. 2) = "-R" then | | 2536 | + if Name_Len = 2 and then Name_Buffer (1 .. 2) = "-R" then |
2537 | + Rpath_Disabled := True; | | 2537 | + Rpath_Disabled := True; |
2538 | + end if; | | 2538 | + end if; |
2539 | end if; | | 2539 | end if; |
2540 | | | 2540 | |
2541 | Current := Element.Next; | | 2541 | Current := Element.Next; |
2542 | --- gcc/ada/mlib-utl.adb.orig | | 2542 | --- gcc/ada/mlib-utl.adb.orig |
2543 | +++ gcc/ada/mlib-utl.adb | | 2543 | +++ gcc/ada/mlib-utl.adb |
2544 | @@ -21,6 +21,7 @@ | | 2544 | @@ -21,6 +21,7 @@ |
2545 | -- GNAT was originally developed by the GNAT team at New York University. -- | | 2545 | -- GNAT was originally developed by the GNAT team at New York University. -- |
2546 | -- Extensive contributions were provided by Ada Core Technologies Inc. -- | | 2546 | -- Extensive contributions were provided by Ada Core Technologies Inc. -- |
2547 | -- -- | | 2547 | -- -- |
2548 | +-- Copyright (C) 2010 John Marino <draco@marino.st> -- | | 2548 | +-- Copyright (C) 2010 John Marino <draco@marino.st> -- |
2549 | ------------------------------------------------------------------------------ | | 2549 | ------------------------------------------------------------------------------ |
2550 | | | 2550 | |
2551 | with MLib.Fil; use MLib.Fil; | | 2551 | with MLib.Fil; use MLib.Fil; |
2552 | @@ -412,7 +413,7 @@ | | 2552 | @@ -412,7 +413,7 @@ |
2553 | if Driver_Name = No_Name then | | 2553 | if Driver_Name = No_Name then |
2554 | if Gcc_Exec = null then | | 2554 | if Gcc_Exec = null then |
2555 | if Gcc_Name = null then | | 2555 | if Gcc_Name = null then |
2556 | - Gcc_Name := Osint.Program_Name ("gcc", "gnatmake"); | | 2556 | - Gcc_Name := Osint.Program_Name ("gcc", "gnatmake"); |
2557 | + Gcc_Name := Osint.Program_Name ("gnatgcc", "gnatmake"); | | 2557 | + Gcc_Name := Osint.Program_Name ("gnatgcc", "gnatmake"); |
2558 | end if; | | 2558 | end if; |
2559 | | | 2559 | |
2560 | Gcc_Exec := Locate_Exec_On_Path (Gcc_Name.all); | | 2560 | Gcc_Exec := Locate_Exec_On_Path (Gcc_Name.all); |
2561 | --- gcc/ada/prj-makr.adb.orig | | 2561 | --- gcc/ada/prj-makr.adb.orig |
2562 | +++ gcc/ada/prj-makr.adb | | 2562 | +++ gcc/ada/prj-makr.adb |
2563 | @@ -21,6 +21,7 @@ | | 2563 | @@ -21,6 +21,7 @@ |
2564 | -- GNAT was originally developed by the GNAT team at New York University. -- | | 2564 | -- GNAT was originally developed by the GNAT team at New York University. -- |
2565 | -- Extensive contributions were provided by Ada Core Technologies Inc. -- | | 2565 | -- Extensive contributions were provided by Ada Core Technologies Inc. -- |
2566 | -- -- | | 2566 | -- -- |
2567 | +-- Copyright (C) 2010 John Marino <draco@marino.st> -- | | 2567 | +-- Copyright (C) 2010 John Marino <draco@marino.st> -- |
2568 | ------------------------------------------------------------------------------ | | 2568 | ------------------------------------------------------------------------------ |
2569 | | | 2569 | |
2570 | with Csets; | | 2570 | with Csets; |
2571 | @@ -110,7 +111,7 @@ | | 2571 | @@ -110,7 +111,7 @@ |
2572 | | | 2572 | |
2573 | procedure Dup2 (Old_Fd, New_Fd : File_Descriptor); | | 2573 | procedure Dup2 (Old_Fd, New_Fd : File_Descriptor); |
2574 | | | 2574 | |
2575 | - Gcc : constant String := "gcc"; | | 2575 | - Gcc : constant String := "gcc"; |
2576 | + Gcc : constant String := "gnatgcc"; | | 2576 | + Gcc : constant String := "gnatgcc"; |
2577 | Gcc_Path : String_Access := null; | | 2577 | Gcc_Path : String_Access := null; |
2578 | | | 2578 | |
2579 | Non_Empty_Node : constant Project_Node_Id := 1; | | 2579 | Non_Empty_Node : constant Project_Node_Id := 1; |
2580 | --- gcc/ada/s-fileio.adb.orig | | 2580 | --- gcc/ada/s-fileio.adb.orig |
2581 | +++ gcc/ada/s-fileio.adb | | 2581 | +++ gcc/ada/s-fileio.adb |
2582 | @@ -231,7 +231,7 @@ | | 2582 | @@ -231,7 +231,7 @@ |
2583 | Close_Status : int := 0; | | 2583 | Close_Status : int := 0; |
2584 | Dup_Strm : Boolean := False; | | 2584 | Dup_Strm : Boolean := False; |
2585 | File : AFCB_Ptr renames File_Ptr.all; | | 2585 | File : AFCB_Ptr renames File_Ptr.all; |
2586 | - Errno : Integer; | | 2586 | - Errno : Integer; |
2587 | + Errno : Integer := 0; | | 2587 | + Errno : Integer := 0; |
2588 | | | 2588 | |
2589 | begin | | 2589 | begin |
2590 | -- Take a task lock, to protect the global data value Open_Files | | 2590 | -- Take a task lock, to protect the global data value Open_Files |
2591 | --- /dev/null | | 2591 | --- /dev/null |
2592 | +++ gcc/ada/s-osinte-android.ads | | 2592 | +++ gcc/ada/s-osinte-android.ads |
2593 | @@ -0,0 +1,566 @@ | | 2593 | @@ -0,0 +1,566 @@ |
2594 | +------------------------------------------------------------------------------ | | 2594 | +------------------------------------------------------------------------------ |
2595 | +-- -- | | 2595 | +-- -- |
2596 | +-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS -- | | 2596 | +-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS -- |
2597 | +-- -- | | 2597 | +-- -- |
2598 | +-- S Y S T E M . O S _ I N T E R F A C E -- | | 2598 | +-- S Y S T E M . O S _ I N T E R F A C E -- |
2599 | +-- -- | | 2599 | +-- -- |
2600 | +-- S p e c -- | | 2600 | +-- S p e c -- |
2601 | +-- -- | | 2601 | +-- -- |
2602 | +-- Copyright (C) 1991-1994, Florida State University -- | | 2602 | +-- Copyright (C) 1991-1994, Florida State University -- |
2603 | +-- Copyright (C) 1995-2010, Free Software Foundation, Inc. -- | | 2603 | +-- Copyright (C) 1995-2010, Free Software Foundation, Inc. -- |
2604 | +-- -- | | 2604 | +-- -- |
2605 | +-- GNARL is free software; you can redistribute it and/or modify it under -- | | 2605 | +-- GNARL is free software; you can redistribute it and/or modify it under -- |
2606 | +-- terms of the GNU General Public License as published by the Free Soft- -- | | 2606 | +-- terms of the GNU General Public License as published by the Free Soft- -- |
2607 | +-- ware Foundation; either version 2, or (at your option) any later ver- -- | | 2607 | +-- ware Foundation; either version 2, or (at your option) any later ver- -- |
2608 | +-- sion. GNARL is distributed in the hope that it will be useful, but WITH- -- | | 2608 | +-- sion. GNARL is distributed in the hope that it will be useful, but WITH- -- |
2609 | +-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- | | 2609 | +-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- |
2610 | +-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- | | 2610 | +-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- |
2611 | +-- for more details. You should have received a copy of the GNU General -- | | 2611 | +-- for more details. You should have received a copy of the GNU General -- |
2612 | +-- Public License distributed with GNARL; see file COPYING. If not, write -- | | 2612 | +-- Public License distributed with GNARL; see file COPYING. If not, write -- |
2613 | +-- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, -- | | 2613 | +-- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, -- |
2614 | +-- Boston, MA 02110-1301, USA. -- | | 2614 | +-- Boston, MA 02110-1301, USA. -- |
2615 | +-- -- | | 2615 | +-- -- |
2616 | +-- As a special exception, if other files instantiate generics from this -- | | 2616 | +-- As a special exception, if other files instantiate generics from this -- |
2617 | +-- unit, or you link this unit with other files to produce an executable, -- | | 2617 | +-- unit, or you link this unit with other files to produce an executable, -- |
2618 | +-- this unit does not by itself cause the resulting executable to be -- | | 2618 | +-- this unit does not by itself cause the resulting executable to be -- |
2619 | +-- covered by the GNU General Public License. This exception does not -- | | 2619 | +-- covered by the GNU General Public License. This exception does not -- |
2620 | +-- however invalidate any other reasons why the executable file might be -- | | 2620 | +-- however invalidate any other reasons why the executable file might be -- |
2621 | +-- covered by the GNU Public License. -- | | 2621 | +-- covered by the GNU Public License. -- |
2622 | +-- -- | | 2622 | +-- -- |
2623 | +-- GNARL was developed by the GNARL team at Florida State University. -- | | 2623 | +-- GNARL was developed by the GNARL team at Florida State University. -- |
2624 | +-- Extensive contributions were provided by Ada Core Technologies, Inc. -- | | 2624 | +-- Extensive contributions were provided by Ada Core Technologies, Inc. -- |
2625 | +-- -- | | 2625 | +-- -- |
2626 | +------------------------------------------------------------------------------ | | 2626 | +------------------------------------------------------------------------------ |
2627 | + | | 2627 | + |
2628 | +-- This is a GNU/Linux (GNU/LinuxThreads) version of this package | | 2628 | +-- This is a GNU/Linux (GNU/LinuxThreads) version of this package |
2629 | + | | 2629 | + |
2630 | +-- This package encapsulates all direct interfaces to OS services | | 2630 | +-- This package encapsulates all direct interfaces to OS services |
2631 | +-- that are needed by the tasking run-time (libgnarl). | | 2631 | +-- that are needed by the tasking run-time (libgnarl). |
2632 | + | | 2632 | + |
2633 | +-- PLEASE DO NOT add any with-clauses to this package or remove the pragma | | 2633 | +-- PLEASE DO NOT add any with-clauses to this package or remove the pragma |
2634 | +-- Preelaborate. This package is designed to be a bottom-level (leaf) package. | | 2634 | +-- Preelaborate. This package is designed to be a bottom-level (leaf) package. |
2635 | + | | 2635 | + |
2636 | +with Ada.Unchecked_Conversion; | | 2636 | +with Ada.Unchecked_Conversion; |
2637 | +with Interfaces.C; | | 2637 | +with Interfaces.C; |
2638 | +with System.Linux; | | 2638 | +with System.Linux; |
2639 | + | | 2639 | + |
2640 | +package System.OS_Interface is | | 2640 | +package System.OS_Interface is |
2641 | + pragma Preelaborate; | | 2641 | + pragma Preelaborate; |
2642 | + | | 2642 | + |
2643 | + subtype int is Interfaces.C.int; | | 2643 | + subtype int is Interfaces.C.int; |
2644 | + subtype char is Interfaces.C.char; | | 2644 | + subtype char is Interfaces.C.char; |
2645 | + subtype short is Interfaces.C.short; | | 2645 | + subtype short is Interfaces.C.short; |
2646 | + subtype long is Interfaces.C.long; | | 2646 | + subtype long is Interfaces.C.long; |
2647 | + subtype unsigned is Interfaces.C.unsigned; | | 2647 | + subtype unsigned is Interfaces.C.unsigned; |
2648 | + subtype unsigned_short is Interfaces.C.unsigned_short; | | 2648 | + subtype unsigned_short is Interfaces.C.unsigned_short; |
2649 | + subtype unsigned_long is Interfaces.C.unsigned_long; | | 2649 | + subtype unsigned_long is Interfaces.C.unsigned_long; |
2650 | + subtype unsigned_char is Interfaces.C.unsigned_char; | | 2650 | + subtype unsigned_char is Interfaces.C.unsigned_char; |
2651 | + subtype plain_char is Interfaces.C.plain_char; | | 2651 | + subtype plain_char is Interfaces.C.plain_char; |
2652 | + subtype size_t is Interfaces.C.size_t; | | 2652 | + subtype size_t is Interfaces.C.size_t; |
2653 | + | | 2653 | + |
2654 | + ----------- | | 2654 | + ----------- |
2655 | + -- Errno -- | | 2655 | + -- Errno -- |
2656 | + ----------- | | 2656 | + ----------- |
2657 | + | | 2657 | + |
2658 | + function errno return int; | | 2658 | + function errno return int; |
2659 | + pragma Import (C, errno, "__get_errno"); | | 2659 | + pragma Import (C, errno, "__get_errno"); |
2660 | + | | 2660 | + |
2661 | + EAGAIN : constant := System.Linux.EAGAIN; | | 2661 | + EAGAIN : constant := System.Linux.EAGAIN; |
2662 | + EINTR : constant := System.Linux.EINTR; | | 2662 | + EINTR : constant := System.Linux.EINTR; |
2663 | + EINVAL : constant := System.Linux.EINVAL; | | 2663 | + EINVAL : constant := System.Linux.EINVAL; |
2664 | + ENOMEM : constant := System.Linux.ENOMEM; | | 2664 | + ENOMEM : constant := System.Linux.ENOMEM; |
2665 | + EPERM : constant := System.Linux.EPERM; | | 2665 | + EPERM : constant := System.Linux.EPERM; |
2666 | + ETIMEDOUT : constant := System.Linux.ETIMEDOUT; | | 2666 | + ETIMEDOUT : constant := System.Linux.ETIMEDOUT; |
2667 | + | | 2667 | + |
2668 | + ------------- | | 2668 | + ------------- |
2669 | + -- Signals -- | | 2669 | + -- Signals -- |
2670 | + ------------- | | 2670 | + ------------- |
2671 | + | | 2671 | + |
2672 | + Max_Interrupt : constant := 63; | | 2672 | + Max_Interrupt : constant := 63; |
2673 | + type Signal is new int range 0 .. Max_Interrupt; | | 2673 | + type Signal is new int range 0 .. Max_Interrupt; |
2674 | + for Signal'Size use int'Size; | | 2674 | + for Signal'Size use int'Size; |
2675 | + | | 2675 | + |
2676 | + SIGHUP : constant := System.Linux.SIGHUP; | | 2676 | + SIGHUP : constant := System.Linux.SIGHUP; |
2677 | + SIGINT : constant := System.Linux.SIGINT; | | 2677 | + SIGINT : constant := System.Linux.SIGINT; |
2678 | + SIGQUIT : constant := System.Linux.SIGQUIT; | | 2678 | + SIGQUIT : constant := System.Linux.SIGQUIT; |
2679 | + SIGILL : constant := System.Linux.SIGILL; | | 2679 | + SIGILL : constant := System.Linux.SIGILL; |
2680 | + SIGTRAP : constant := System.Linux.SIGTRAP; | | 2680 | + SIGTRAP : constant := System.Linux.SIGTRAP; |
2681 | + SIGIOT : constant := System.Linux.SIGIOT; | | 2681 | + SIGIOT : constant := System.Linux.SIGIOT; |
2682 | + SIGABRT : constant := System.Linux.SIGABRT; | | 2682 | + SIGABRT : constant := System.Linux.SIGABRT; |
2683 | + SIGFPE : constant := System.Linux.SIGFPE; | | 2683 | + SIGFPE : constant := System.Linux.SIGFPE; |
2684 | + SIGKILL : constant := System.Linux.SIGKILL; | | 2684 | + SIGKILL : constant := System.Linux.SIGKILL; |
2685 | + SIGBUS : constant := System.Linux.SIGBUS; | | 2685 | + SIGBUS : constant := System.Linux.SIGBUS; |
2686 | + SIGSEGV : constant := System.Linux.SIGSEGV; | | 2686 | + SIGSEGV : constant := System.Linux.SIGSEGV; |
2687 | + SIGPIPE : constant := System.Linux.SIGPIPE; | | 2687 | + SIGPIPE : constant := System.Linux.SIGPIPE; |
2688 | + SIGALRM : constant := System.Linux.SIGALRM; | | 2688 | + SIGALRM : constant := System.Linux.SIGALRM; |
2689 | + SIGTERM : constant := System.Linux.SIGTERM; | | 2689 | + SIGTERM : constant := System.Linux.SIGTERM; |
2690 | + SIGUSR1 : constant := System.Linux.SIGUSR1; | | 2690 | + SIGUSR1 : constant := System.Linux.SIGUSR1; |
2691 | + SIGUSR2 : constant := System.Linux.SIGUSR2; | | 2691 | + SIGUSR2 : constant := System.Linux.SIGUSR2; |
2692 | + SIGCLD : constant := System.Linux.SIGCLD; | | 2692 | + SIGCLD : constant := System.Linux.SIGCLD; |
2693 | + SIGCHLD : constant := System.Linux.SIGCHLD; | | 2693 | + SIGCHLD : constant := System.Linux.SIGCHLD; |
2694 | + SIGPWR : constant := System.Linux.SIGPWR; | | 2694 | + SIGPWR : constant := System.Linux.SIGPWR; |
2695 | + SIGWINCH : constant := System.Linux.SIGWINCH; | | 2695 | + SIGWINCH : constant := System.Linux.SIGWINCH; |
2696 | + SIGURG : constant := System.Linux.SIGURG; | | 2696 | + SIGURG : constant := System.Linux.SIGURG; |
2697 | + SIGPOLL : constant := System.Linux.SIGPOLL; | | 2697 | + SIGPOLL : constant := System.Linux.SIGPOLL; |
2698 | + SIGIO : constant := System.Linux.SIGIO; | | 2698 | + SIGIO : constant := System.Linux.SIGIO; |
2699 | + SIGLOST : constant := System.Linux.SIGLOST; | | 2699 | + SIGLOST : constant := System.Linux.SIGLOST; |
2700 | + SIGSTOP : constant := System.Linux.SIGSTOP; | | 2700 | + SIGSTOP : constant := System.Linux.SIGSTOP; |
2701 | + SIGTSTP : constant := System.Linux.SIGTSTP; | | 2701 | + SIGTSTP : constant := System.Linux.SIGTSTP; |
2702 | + SIGCONT : constant := System.Linux.SIGCONT; | | 2702 | + SIGCONT : constant := System.Linux.SIGCONT; |
2703 | + SIGTTIN : constant := System.Linux.SIGTTIN; | | 2703 | + SIGTTIN : constant := System.Linux.SIGTTIN; |
2704 | + SIGTTOU : constant := System.Linux.SIGTTOU; | | 2704 | + SIGTTOU : constant := System.Linux.SIGTTOU; |
2705 | + SIGVTALRM : constant := System.Linux.SIGVTALRM; | | 2705 | + SIGVTALRM : constant := System.Linux.SIGVTALRM; |
2706 | + SIGPROF : constant := System.Linux.SIGPROF; | | 2706 | + SIGPROF : constant := System.Linux.SIGPROF; |
2707 | + SIGXCPU : constant := System.Linux.SIGXCPU; | | 2707 | + SIGXCPU : constant := System.Linux.SIGXCPU; |
2708 | + SIGXFSZ : constant := System.Linux.SIGXFSZ; | | 2708 | + SIGXFSZ : constant := System.Linux.SIGXFSZ; |
2709 | + SIGUNUSED : constant := System.Linux.SIGUNUSED; | | 2709 | + SIGUNUSED : constant := System.Linux.SIGUNUSED; |
2710 | + SIGSTKFLT : constant := System.Linux.SIGSTKFLT; | | 2710 | + SIGSTKFLT : constant := System.Linux.SIGSTKFLT; |
2711 | + SIGLTHRRES : constant := System.Linux.SIGLTHRRES; | | 2711 | + SIGLTHRRES : constant := System.Linux.SIGLTHRRES; |
2712 | + SIGLTHRCAN : constant := System.Linux.SIGLTHRCAN; | | 2712 | + SIGLTHRCAN : constant := System.Linux.SIGLTHRCAN; |
2713 | + SIGLTHRDBG : constant := System.Linux.SIGLTHRDBG; | | 2713 | + SIGLTHRDBG : constant := System.Linux.SIGLTHRDBG; |
2714 | + | | 2714 | + |
2715 | + SIGADAABORT : constant := SIGABRT; | | 2715 | + SIGADAABORT : constant := SIGABRT; |
2716 | + -- Change this if you want to use another signal for task abort. | | 2716 | + -- Change this if you want to use another signal for task abort. |
2717 | + -- SIGTERM might be a good one. | | 2717 | + -- SIGTERM might be a good one. |
2718 | + | | 2718 | + |
2719 | + type Signal_Set is array (Natural range <>) of Signal; | | 2719 | + type Signal_Set is array (Natural range <>) of Signal; |
2720 | + | | 2720 | + |
2721 | + Unmasked : constant Signal_Set := ( | | 2721 | + Unmasked : constant Signal_Set := ( |
2722 | + SIGTRAP, | | 2722 | + SIGTRAP, |
2723 | + -- To enable debugging on multithreaded applications, mark SIGTRAP to | | 2723 | + -- To enable debugging on multithreaded applications, mark SIGTRAP to |
2724 | + -- be kept unmasked. | | 2724 | + -- be kept unmasked. |
2725 | + | | 2725 | + |
2726 | + SIGBUS, | | 2726 | + SIGBUS, |
2727 | + | | 2727 | + |
2728 | + SIGTTIN, SIGTTOU, SIGTSTP, | | 2728 | + SIGTTIN, SIGTTOU, SIGTSTP, |
2729 | + -- Keep these three signals unmasked so that background processes | | 2729 | + -- Keep these three signals unmasked so that background processes |
2730 | + -- and IO behaves as normal "C" applications | | 2730 | + -- and IO behaves as normal "C" applications |
2731 | + | | 2731 | + |
2732 | + SIGPROF, | | 2732 | + SIGPROF, |
2733 | + -- To avoid confusing the profiler | | 2733 | + -- To avoid confusing the profiler |
2734 | + | | 2734 | + |
2735 | + SIGKILL, SIGSTOP, | | 2735 | + SIGKILL, SIGSTOP, |
2736 | + -- These two signals actually cannot be masked; | | 2736 | + -- These two signals actually cannot be masked; |
2737 | + -- POSIX simply won't allow it. | | 2737 | + -- POSIX simply won't allow it. |
2738 | + | | 2738 | + |
2739 | + SIGLTHRRES, SIGLTHRCAN, SIGLTHRDBG); | | 2739 | + SIGLTHRRES, SIGLTHRCAN, SIGLTHRDBG); |
2740 | + -- These three signals are used by GNU/LinuxThreads starting from | | 2740 | + -- These three signals are used by GNU/LinuxThreads starting from |
2741 | + -- glibc 2.1 (future 2.2). | | 2741 | + -- glibc 2.1 (future 2.2). |
2742 | + | | 2742 | + |
2743 | + Reserved : constant Signal_Set := | | 2743 | + Reserved : constant Signal_Set := |
2744 | + -- I am not sure why the following two signals are reserved. | | 2744 | + -- I am not sure why the following two signals are reserved. |
2745 | + -- I guess they are not supported by this version of GNU/Linux. | | 2745 | + -- I guess they are not supported by this version of GNU/Linux. |
2746 | + (SIGVTALRM, SIGUNUSED); | | 2746 | + (SIGVTALRM, SIGUNUSED); |
2747 | + | | 2747 | + |
2748 | + type sigset_t is private; | | 2748 | + type sigset_t is private; |
2749 | + | | 2749 | + |
2750 | + function sigaddset (set : access sigset_t; sig : Signal) return int; | | 2750 | + function sigaddset (set : access sigset_t; sig : Signal) return int; |
2751 | + pragma Import (C, sigaddset, "sigaddset"); | | 2751 | + pragma Import (C, sigaddset, "sigaddset"); |
2752 | + | | 2752 | + |
2753 | + function sigdelset (set : access sigset_t; sig : Signal) return int; | | 2753 | + function sigdelset (set : access sigset_t; sig : Signal) return int; |
2754 | + pragma Import (C, sigdelset, "sigdelset"); | | 2754 | + pragma Import (C, sigdelset, "sigdelset"); |
2755 | + | | 2755 | + |
2756 | + function sigfillset (set : access sigset_t) return int; | | 2756 | + function sigfillset (set : access sigset_t) return int; |
2757 | + pragma Import (C, sigfillset, "sigfillset"); | | 2757 | + pragma Import (C, sigfillset, "sigfillset"); |
2758 | + | | 2758 | + |
2759 | + function sigismember (set : access sigset_t; sig : Signal) return int; | | 2759 | + function sigismember (set : access sigset_t; sig : Signal) return int; |
2760 | + pragma Import (C, sigismember, "sigismember"); | | 2760 | + pragma Import (C, sigismember, "sigismember"); |
2761 | + | | 2761 | + |
2762 | + function sigemptyset (set : access sigset_t) return int; | | 2762 | + function sigemptyset (set : access sigset_t) return int; |
2763 | + pragma Import (C, sigemptyset, "sigemptyset"); | | 2763 | + pragma Import (C, sigemptyset, "sigemptyset"); |
2764 | + | | 2764 | + |
2765 | + type union_type_3 is new String (1 .. 116); | | 2765 | + type union_type_3 is new String (1 .. 116); |
2766 | + type siginfo_t is record | | 2766 | + type siginfo_t is record |
2767 | + si_signo : int; | | 2767 | + si_signo : int; |
2768 | + si_code : int; | | 2768 | + si_code : int; |
2769 | + si_errno : int; | | 2769 | + si_errno : int; |
2770 | + X_data : union_type_3; | | 2770 | + X_data : union_type_3; |
2771 | + end record; | | 2771 | + end record; |
2772 | + pragma Convention (C, siginfo_t); | | 2772 | + pragma Convention (C, siginfo_t); |
2773 | + | | 2773 | + |
2774 | + type struct_sigaction is record | | 2774 | + type struct_sigaction is record |
2775 | + sa_handler : System.Address; | | 2775 | + sa_handler : System.Address; |
2776 | + sa_mask : sigset_t; | | 2776 | + sa_mask : sigset_t; |
2777 | + sa_flags : Interfaces.C.unsigned_long; | | 2777 | + sa_flags : Interfaces.C.unsigned_long; |
2778 | + sa_restorer : System.Address; | | 2778 | + sa_restorer : System.Address; |
2779 | + end record; | | 2779 | + end record; |
2780 | + pragma Convention (C, struct_sigaction); | | 2780 | + pragma Convention (C, struct_sigaction); |
2781 | + | | 2781 | + |
2782 | + type struct_sigaction_ptr is access all struct_sigaction; | | 2782 | + type struct_sigaction_ptr is access all struct_sigaction; |
2783 | + | | 2783 | + |
2784 | + type Machine_State is record | | 2784 | + type Machine_State is record |
2785 | + eip : unsigned_long; | | 2785 | + eip : unsigned_long; |
2786 | + ebx : unsigned_long; | | 2786 | + ebx : unsigned_long; |
2787 | + esp : unsigned_long; | | 2787 | + esp : unsigned_long; |
2788 | + ebp : unsigned_long; | | 2788 | + ebp : unsigned_long; |
2789 | + esi : unsigned_long; | | 2789 | + esi : unsigned_long; |
2790 | + edi : unsigned_long; | | 2790 | + edi : unsigned_long; |
2791 | + end record; | | 2791 | + end record; |
2792 | + type Machine_State_Ptr is access all Machine_State; | | 2792 | + type Machine_State_Ptr is access all Machine_State; |
2793 | + | | 2793 | + |
2794 | + SA_SIGINFO : constant := System.Linux.SA_SIGINFO; | | 2794 | + SA_SIGINFO : constant := System.Linux.SA_SIGINFO; |
2795 | + SA_ONSTACK : constant := System.Linux.SA_ONSTACK; | | 2795 | + SA_ONSTACK : constant := System.Linux.SA_ONSTACK; |
2796 | + | | 2796 | + |
2797 | + SIG_BLOCK : constant := 0; | | 2797 | + SIG_BLOCK : constant := 0; |
2798 | + SIG_UNBLOCK : constant := 1; | | 2798 | + SIG_UNBLOCK : constant := 1; |
2799 | + SIG_SETMASK : constant := 2; | | 2799 | + SIG_SETMASK : constant := 2; |
2800 | + | | 2800 | + |
2801 | + SIG_DFL : constant := 0; | | 2801 | + SIG_DFL : constant := 0; |
2802 | + SIG_IGN : constant := 1; | | 2802 | + SIG_IGN : constant := 1; |
2803 | + | | 2803 | + |
2804 | + function sigaction | | 2804 | + function sigaction |
2805 | + (sig : Signal; | | 2805 | + (sig : Signal; |
2806 | + act : struct_sigaction_ptr; | | 2806 | + act : struct_sigaction_ptr; |
2807 | + oact : struct_sigaction_ptr) return int; | | 2807 | + oact : struct_sigaction_ptr) return int; |
2808 | + pragma Import (C, sigaction, "sigaction"); | | 2808 | + pragma Import (C, sigaction, "sigaction"); |
2809 | + | | 2809 | + |
2810 | + ---------- | | 2810 | + ---------- |
2811 | + -- Time -- | | 2811 | + -- Time -- |
2812 | + ---------- | | 2812 | + ---------- |
2813 | + | | 2813 | + |
2814 | + type timespec is private; | | 2814 | + type timespec is private; |
2815 | + | | 2815 | + |
2816 | + function To_Duration (TS : timespec) return Duration; | | 2816 | + function To_Duration (TS : timespec) return Duration; |
2817 | + pragma Inline (To_Duration); | | 2817 | + pragma Inline (To_Duration); |
2818 | + | | 2818 | + |
2819 | + function To_Timespec (D : Duration) return timespec; | | 2819 | + function To_Timespec (D : Duration) return timespec; |
2820 | + pragma Inline (To_Timespec); | | 2820 | + pragma Inline (To_Timespec); |
2821 | + | | 2821 | + |
2822 | + function sysconf (name : int) return long; | | 2822 | + function sysconf (name : int) return long; |
2823 | + pragma Import (C, sysconf); | | 2823 | + pragma Import (C, sysconf); |
2824 | + | | 2824 | + |
2825 | + SC_CLK_TCK : constant := 2; | | 2825 | + SC_CLK_TCK : constant := 2; |
2826 | + SC_NPROCESSORS_ONLN : constant := 84; | | 2826 | + SC_NPROCESSORS_ONLN : constant := 84; |
2827 | + | | 2827 | + |
2828 | + ------------------------- | | 2828 | + ------------------------- |
2829 | + -- Priority Scheduling -- | | 2829 | + -- Priority Scheduling -- |
2830 | + ------------------------- | | 2830 | + ------------------------- |
2831 | + | | 2831 | + |
2832 | + SCHED_OTHER : constant := 0; | | 2832 | + SCHED_OTHER : constant := 0; |
2833 | + SCHED_FIFO : constant := 1; | | 2833 | + SCHED_FIFO : constant := 1; |
2834 | + SCHED_RR : constant := 2; | | 2834 | + SCHED_RR : constant := 2; |
2835 | + | | 2835 | + |
2836 | + function To_Target_Priority | | 2836 | + function To_Target_Priority |
2837 | + (Prio : System.Any_Priority) return Interfaces.C.int; | | 2837 | + (Prio : System.Any_Priority) return Interfaces.C.int; |
2838 | + -- Maps System.Any_Priority to a POSIX priority | | 2838 | + -- Maps System.Any_Priority to a POSIX priority |
2839 | + | | 2839 | + |
2840 | + ------------- | | 2840 | + ------------- |
2841 | + -- Process -- | | 2841 | + -- Process -- |
2842 | + ------------- | | 2842 | + ------------- |
2843 | + | | 2843 | + |
2844 | + type pid_t is private; | | 2844 | + type pid_t is private; |
2845 | + | | 2845 | + |
2846 | + function kill (pid : pid_t; sig : Signal) return int; | | 2846 | + function kill (pid : pid_t; sig : Signal) return int; |
2847 | + pragma Import (C, kill, "kill"); | | 2847 | + pragma Import (C, kill, "kill"); |
2848 | + | | 2848 | + |
2849 | + function getpid return pid_t; | | 2849 | + function getpid return pid_t; |
2850 | + pragma Import (C, getpid, "getpid"); | | 2850 | + pragma Import (C, getpid, "getpid"); |
2851 | + | | 2851 | + |
2852 | + ------------- | | 2852 | + ------------- |
2853 | + -- Threads -- | | 2853 | + -- Threads -- |
2854 | + ------------- | | 2854 | + ------------- |
2855 | + | | 2855 | + |
2856 | + type Thread_Body is access | | 2856 | + type Thread_Body is access |
2857 | + function (arg : System.Address) return System.Address; | | 2857 | + function (arg : System.Address) return System.Address; |
2858 | + pragma Convention (C, Thread_Body); | | 2858 | + pragma Convention (C, Thread_Body); |
2859 | + | | 2859 | + |
2860 | + function Thread_Body_Access is new | | 2860 | + function Thread_Body_Access is new |
2861 | + Ada.Unchecked_Conversion (System.Address, Thread_Body); | | 2861 | + Ada.Unchecked_Conversion (System.Address, Thread_Body); |
2862 | + | | 2862 | + |
2863 | + type pthread_t is new unsigned_long; | | 2863 | + type pthread_t is new unsigned_long; |
2864 | + subtype Thread_Id is pthread_t; | | 2864 | + subtype Thread_Id is pthread_t; |
2865 | + | | 2865 | + |
2866 | + function To_pthread_t is new Ada.Unchecked_Conversion | | 2866 | + function To_pthread_t is new Ada.Unchecked_Conversion |
2867 | + (unsigned_long, pthread_t); | | 2867 | + (unsigned_long, pthread_t); |
2868 | + | | 2868 | + |
2869 | + type pthread_mutex_t is limited private; | | 2869 | + type pthread_mutex_t is limited private; |
2870 | + type pthread_cond_t is limited private; | | 2870 | + type pthread_cond_t is limited private; |
2871 | + type pthread_attr_t is limited private; | | 2871 | + type pthread_attr_t is limited private; |
2872 | + type pthread_mutexattr_t is limited private; | | 2872 | + type pthread_mutexattr_t is limited private; |
2873 | + type pthread_condattr_t is limited private; | | 2873 | + type pthread_condattr_t is limited private; |
2874 | + type pthread_key_t is private; | | 2874 | + type pthread_key_t is private; |
2875 | + | | 2875 | + |
2876 | + PTHREAD_CREATE_DETACHED : constant := 1; | | 2876 | + PTHREAD_CREATE_DETACHED : constant := 1; |
2877 | + | | 2877 | + |
2878 | + ----------- | | 2878 | + ----------- |
2879 | + -- Stack -- | | 2879 | + -- Stack -- |
2880 | + ----------- | | 2880 | + ----------- |
2881 | + | | 2881 | + |
2882 | + type stack_t is record | | 2882 | + type stack_t is record |
2883 | + ss_sp : System.Address; | | 2883 | + ss_sp : System.Address; |
2884 | + ss_flags : int; | | 2884 | + ss_flags : int; |
2885 | + ss_size : size_t; | | 2885 | + ss_size : size_t; |
2886 | + end record; | | 2886 | + end record; |
2887 | + pragma Convention (C, stack_t); | | 2887 | + pragma Convention (C, stack_t); |
2888 | + | | 2888 | + |
2889 | + function sigaltstack | | 2889 | + function sigaltstack |
2890 | + (ss : not null access stack_t; | | 2890 | + (ss : not null access stack_t; |
2891 | + oss : access stack_t) return int; | | 2891 | + oss : access stack_t) return int; |
2892 | + pragma Import (C, sigaltstack, "sigaltstack"); | | 2892 | + pragma Import (C, sigaltstack, "sigaltstack"); |
2893 | + | | 2893 | + |
2894 | + Alternate_Stack : aliased System.Address; | | 2894 | + Alternate_Stack : aliased System.Address; |
2895 | + pragma Import (C, Alternate_Stack, "__gnat_alternate_stack"); | | 2895 | + pragma Import (C, Alternate_Stack, "__gnat_alternate_stack"); |
2896 | + -- The alternate signal stack for stack overflows | | 2896 | + -- The alternate signal stack for stack overflows |
2897 | + | | 2897 | + |
2898 | + Alternate_Stack_Size : constant := 16 * 1024; | | 2898 | + Alternate_Stack_Size : constant := 16 * 1024; |
2899 | + -- This must be in keeping with init.c:__gnat_alternate_stack | | 2899 | + -- This must be in keeping with init.c:__gnat_alternate_stack |
2900 | + | | 2900 | + |
2901 | + function Get_Stack_Base (thread : pthread_t) return Address; | | 2901 | + function Get_Stack_Base (thread : pthread_t) return Address; |
2902 | + pragma Inline (Get_Stack_Base); | | 2902 | + pragma Inline (Get_Stack_Base); |
2903 | + -- This is a dummy procedure to share some GNULLI files | | 2903 | + -- This is a dummy procedure to share some GNULLI files |
2904 | + | | 2904 | + |
2905 | + --------------------------------------- | | 2905 | + --------------------------------------- |
2906 | + -- Nonstandard Thread Initialization -- | | 2906 | + -- Nonstandard Thread Initialization -- |
2907 | + --------------------------------------- | | 2907 | + --------------------------------------- |
2908 | + | | 2908 | + |
2909 | + procedure pthread_init; | | 2909 | + procedure pthread_init; |
2910 | + pragma Inline (pthread_init); | | 2910 | + pragma Inline (pthread_init); |
2911 | + -- This is a dummy procedure to share some GNULLI files | | 2911 | + -- This is a dummy procedure to share some GNULLI files |
2912 | + | | 2912 | + |
2913 | + ------------------------- | | 2913 | + ------------------------- |
2914 | + -- POSIX.1c Section 3 -- | | 2914 | + -- POSIX.1c Section 3 -- |
2915 | + ------------------------- | | 2915 | + ------------------------- |
2916 | + | | 2916 | + |
2917 | + function sigwait (set : access sigset_t; sig : access Signal) return int; | | 2917 | + function sigwait (set : access sigset_t; sig : access Signal) return int; |
2918 | + pragma Import (C, sigwait, "sigwait"); | | 2918 | + pragma Import (C, sigwait, "sigwait"); |
2919 | + | | 2919 | + |
2920 | + function pthread_kill (thread : pthread_t; sig : Signal) return int; | | 2920 | + function pthread_kill (thread : pthread_t; sig : Signal) return int; |
2921 | + pragma Import (C, pthread_kill, "pthread_kill"); | | 2921 | + pragma Import (C, pthread_kill, "pthread_kill"); |
2922 | + | | 2922 | + |
2923 | + function pthread_sigmask | | 2923 | + function pthread_sigmask |
2924 | + (how : int; | | 2924 | + (how : int; |
2925 | + set : access sigset_t; | | 2925 | + set : access sigset_t; |
2926 | + oset : access sigset_t) return int; | | 2926 | + oset : access sigset_t) return int; |
2927 | + pragma Import (C, pthread_sigmask, "pthread_sigmask"); | | 2927 | + pragma Import (C, pthread_sigmask, "pthread_sigmask"); |
2928 | + | | 2928 | + |
2929 | + -------------------------- | | 2929 | + -------------------------- |
2930 | + -- POSIX.1c Section 11 -- | | 2930 | + -- POSIX.1c Section 11 -- |
2931 | + -------------------------- | | 2931 | + -------------------------- |
2932 | + | | 2932 | + |
2933 | + function pthread_mutexattr_init | | 2933 | + function pthread_mutexattr_init |
2934 | + (attr : access pthread_mutexattr_t) return int; | | 2934 | + (attr : access pthread_mutexattr_t) return int; |
2935 | + pragma Import (C, pthread_mutexattr_init, "pthread_mutexattr_init"); | | 2935 | + pragma Import (C, pthread_mutexattr_init, "pthread_mutexattr_init"); |
2936 | + | | 2936 | + |
2937 | + function pthread_mutexattr_destroy | | 2937 | + function pthread_mutexattr_destroy |
2938 | + (attr : access pthread_mutexattr_t) return int; | | 2938 | + (attr : access pthread_mutexattr_t) return int; |
2939 | + pragma Import (C, pthread_mutexattr_destroy, "pthread_mutexattr_destroy"); | | 2939 | + pragma Import (C, pthread_mutexattr_destroy, "pthread_mutexattr_destroy"); |
2940 | + | | 2940 | + |
2941 | + function pthread_mutex_init | | 2941 | + function pthread_mutex_init |
2942 | + (mutex : access pthread_mutex_t; | | 2942 | + (mutex : access pthread_mutex_t; |
2943 | + attr : access pthread_mutexattr_t) return int; | | 2943 | + attr : access pthread_mutexattr_t) return int; |
2944 | + pragma Import (C, pthread_mutex_init, "pthread_mutex_init"); | | 2944 | + pragma Import (C, pthread_mutex_init, "pthread_mutex_init"); |
2945 | + | | 2945 | + |
2946 | + function pthread_mutex_destroy (mutex : access pthread_mutex_t) return int; | | 2946 | + function pthread_mutex_destroy (mutex : access pthread_mutex_t) return int; |
2947 | + pragma Import (C, pthread_mutex_destroy, "pthread_mutex_destroy"); | | 2947 | + pragma Import (C, pthread_mutex_destroy, "pthread_mutex_destroy"); |
2948 | + | | 2948 | + |
2949 | + function pthread_mutex_lock (mutex : access pthread_mutex_t) return int; | | 2949 | + function pthread_mutex_lock (mutex : access pthread_mutex_t) return int; |
2950 | + pragma Import (C, pthread_mutex_lock, "pthread_mutex_lock"); | | 2950 | + pragma Import (C, pthread_mutex_lock, "pthread_mutex_lock"); |
2951 | + | | 2951 | + |
2952 | + function pthread_mutex_unlock (mutex : access pthread_mutex_t) return int; | | 2952 | + function pthread_mutex_unlock (mutex : access pthread_mutex_t) return int; |
2953 | + pragma Import (C, pthread_mutex_unlock, "pthread_mutex_unlock"); | | 2953 | + pragma Import (C, pthread_mutex_unlock, "pthread_mutex_unlock"); |
2954 | + | | 2954 | + |
2955 | + function pthread_condattr_init | | 2955 | + function pthread_condattr_init |
2956 | + (attr : access pthread_condattr_t) return int; | | 2956 | + (attr : access pthread_condattr_t) return int; |
2957 | + pragma Import (C, pthread_condattr_init, "pthread_condattr_init"); | | 2957 | + pragma Import (C, pthread_condattr_init, "pthread_condattr_init"); |
2958 | + | | 2958 | + |
2959 | + function pthread_condattr_destroy | | 2959 | + function pthread_condattr_destroy |
2960 | + (attr : access pthread_condattr_t) return int; | | 2960 | + (attr : access pthread_condattr_t) return int; |
2961 | + pragma Import (C, pthread_condattr_destroy, "pthread_condattr_destroy"); | | 2961 | + pragma Import (C, pthread_condattr_destroy, "pthread_condattr_destroy"); |
2962 | + | | 2962 | + |
2963 | + function pthread_cond_init | | 2963 | + function pthread_cond_init |
2964 | + (cond : access pthread_cond_t; | | 2964 | + (cond : access pthread_cond_t; |
2965 | + attr : access pthread_condattr_t) return int; | | 2965 | + attr : access pthread_condattr_t) return int; |
2966 | + pragma Import (C, pthread_cond_init, "pthread_cond_init"); | | 2966 | + pragma Import (C, pthread_cond_init, "pthread_cond_init"); |
2967 | + | | 2967 | + |
2968 | + function pthread_cond_destroy (cond : access pthread_cond_t) return int; | | 2968 | + function pthread_cond_destroy (cond : access pthread_cond_t) return int; |
2969 | + pragma Import (C, pthread_cond_destroy, "pthread_cond_destroy"); | | 2969 | + pragma Import (C, pthread_cond_destroy, "pthread_cond_destroy"); |
2970 | + | | 2970 | + |
2971 | + function pthread_cond_signal (cond : access pthread_cond_t) return int; | | 2971 | + function pthread_cond_signal (cond : access pthread_cond_t) return int; |
2972 | + pragma Import (C, pthread_cond_signal, "pthread_cond_signal"); | | 2972 | + pragma Import (C, pthread_cond_signal, "pthread_cond_signal"); |
2973 | + | | 2973 | + |
2974 | + function pthread_cond_wait | | 2974 | + function pthread_cond_wait |
2975 | + (cond : access pthread_cond_t; | | 2975 | + (cond : access pthread_cond_t; |
2976 | + mutex : access pthread_mutex_t) return int; | | 2976 | + mutex : access pthread_mutex_t) return int; |
2977 | + pragma Import (C, pthread_cond_wait, "pthread_cond_wait"); | | 2977 | + pragma Import (C, pthread_cond_wait, "pthread_cond_wait"); |
2978 | + | | 2978 | + |
2979 | + function pthread_cond_timedwait | | 2979 | + function pthread_cond_timedwait |
2980 | + (cond : access pthread_cond_t; | | 2980 | + (cond : access pthread_cond_t; |
2981 | + mutex : access pthread_mutex_t; | | 2981 | + mutex : access pthread_mutex_t; |
2982 | + abstime : access timespec) return int; | | 2982 | + abstime : access timespec) return int; |
2983 | + pragma Import (C, pthread_cond_timedwait, "pthread_cond_timedwait"); | | 2983 | + pragma Import (C, pthread_cond_timedwait, "pthread_cond_timedwait"); |
2984 | + | | 2984 | + |
2985 | + -------------------------- | | 2985 | + -------------------------- |
2986 | + -- POSIX.1c Section 13 -- | | 2986 | + -- POSIX.1c Section 13 -- |
2987 | + -------------------------- | | 2987 | + -------------------------- |
2988 | + | | 2988 | + |
2989 | + type struct_sched_param is record | | 2989 | + type struct_sched_param is record |
2990 | + sched_priority : int; -- scheduling priority | | 2990 | + sched_priority : int; -- scheduling priority |
2991 | + end record; | | 2991 | + end record; |
2992 | + pragma Convention (C, struct_sched_param); | | 2992 | + pragma Convention (C, struct_sched_param); |
2993 | + | | 2993 | + |
2994 | + function pthread_setschedparam | | 2994 | + function pthread_setschedparam |
2995 | + (thread : pthread_t; | | 2995 | + (thread : pthread_t; |
2996 | + policy : int; | | 2996 | + policy : int; |
2997 | + param : access struct_sched_param) return int; | | 2997 | + param : access struct_sched_param) return int; |
2998 | + pragma Import (C, pthread_setschedparam, "pthread_setschedparam"); | | 2998 | + pragma Import (C, pthread_setschedparam, "pthread_setschedparam"); |
2999 | + | | 2999 | + |
3000 | + function pthread_attr_setschedpolicy | | 3000 | + function pthread_attr_setschedpolicy |
3001 | + (attr : access pthread_attr_t; | | 3001 | + (attr : access pthread_attr_t; |
3002 | + policy : int) return int; | | 3002 | + policy : int) return int; |
3003 | + pragma Import | | 3003 | + pragma Import |
3004 | + (C, pthread_attr_setschedpolicy, "pthread_attr_setschedpolicy"); | | 3004 | + (C, pthread_attr_setschedpolicy, "pthread_attr_setschedpolicy"); |
3005 | + | | 3005 | + |
3006 | + function sched_yield return int; | | 3006 | + function sched_yield return int; |
3007 | + pragma Import (C, sched_yield, "sched_yield"); | | 3007 | + pragma Import (C, sched_yield, "sched_yield"); |
3008 | + | | 3008 | + |
3009 | + --------------------------- | | 3009 | + --------------------------- |
3010 | + -- P1003.1c - Section 16 -- | | 3010 | + -- P1003.1c - Section 16 -- |
3011 | + --------------------------- | | 3011 | + --------------------------- |
3012 | + | | 3012 | + |
3013 | + function pthread_attr_init | | 3013 | + function pthread_attr_init |
3014 | + (attributes : access pthread_attr_t) return int; | | 3014 | + (attributes : access pthread_attr_t) return int; |
3015 | + pragma Import (C, pthread_attr_init, "pthread_attr_init"); | | 3015 | + pragma Import (C, pthread_attr_init, "pthread_attr_init"); |
3016 | + | | 3016 | + |
3017 | + function pthread_attr_destroy | | 3017 | + function pthread_attr_destroy |
3018 | + (attributes : access pthread_attr_t) return int; | | 3018 | + (attributes : access pthread_attr_t) return int; |
3019 | + pragma Import (C, pthread_attr_destroy, "pthread_attr_destroy"); | | 3019 | + pragma Import (C, pthread_attr_destroy, "pthread_attr_destroy"); |
3020 | + | | 3020 | + |
3021 | + function pthread_attr_setdetachstate | | 3021 | + function pthread_attr_setdetachstate |
3022 | + (attr : access pthread_attr_t; | | 3022 | + (attr : access pthread_attr_t; |
3023 | + detachstate : int) return int; | | 3023 | + detachstate : int) return int; |
3024 | + pragma Import | | 3024 | + pragma Import |
3025 | + (C, pthread_attr_setdetachstate, "pthread_attr_setdetachstate"); | | 3025 | + (C, pthread_attr_setdetachstate, "pthread_attr_setdetachstate"); |
3026 | + | | 3026 | + |
3027 | + function pthread_attr_setstacksize | | 3027 | + function pthread_attr_setstacksize |
3028 | + (attr : access pthread_attr_t; | | 3028 | + (attr : access pthread_attr_t; |
3029 | + stacksize : size_t) return int; | | 3029 | + stacksize : size_t) return int; |
3030 | + pragma Import (C, pthread_attr_setstacksize, "pthread_attr_setstacksize"); | | 3030 | + pragma Import (C, pthread_attr_setstacksize, "pthread_attr_setstacksize"); |
3031 | + | | 3031 | + |
3032 | + function pthread_create | | 3032 | + function pthread_create |
3033 | + (thread : access pthread_t; | | 3033 | + (thread : access pthread_t; |
3034 | + attributes : access pthread_attr_t; | | 3034 | + attributes : access pthread_attr_t; |
3035 | + start_routine : Thread_Body; | | 3035 | + start_routine : Thread_Body; |
3036 | + arg : System.Address) return int; | | 3036 | + arg : System.Address) return int; |
3037 | + pragma Import (C, pthread_create, "pthread_create"); | | 3037 | + pragma Import (C, pthread_create, "pthread_create"); |
3038 | + | | 3038 | + |
3039 | + procedure pthread_exit (status : System.Address); | | 3039 | + procedure pthread_exit (status : System.Address); |
3040 | + pragma Import (C, pthread_exit, "pthread_exit"); | | 3040 | + pragma Import (C, pthread_exit, "pthread_exit"); |
3041 | + | | 3041 | + |
3042 | + function pthread_self return pthread_t; | | 3042 | + function pthread_self return pthread_t; |
3043 | + pragma Import (C, pthread_self, "pthread_self"); | | 3043 | + pragma Import (C, pthread_self, "pthread_self"); |
3044 | + | | 3044 | + |
3045 | + function lwp_self return System.Address; | | 3045 | + function lwp_self return System.Address; |
3046 | + pragma Import (C, lwp_self, "__gnat_lwp_self"); | | 3046 | + pragma Import (C, lwp_self, "__gnat_lwp_self"); |
3047 | + | | 3047 | + |
3048 | + -------------------------- | | 3048 | + -------------------------- |
3049 | + -- POSIX.1c Section 17 -- | | 3049 | + -- POSIX.1c Section 17 -- |
3050 | + -------------------------- | | 3050 | + -------------------------- |
3051 | + | | 3051 | + |
3052 | + function pthread_setspecific | | 3052 | + function pthread_setspecific |
3053 | + (key : pthread_key_t; | | 3053 | + (key : pthread_key_t; |
3054 | + value : System.Address) return int; | | 3054 | + value : System.Address) return int; |
3055 | + pragma Import (C, pthread_setspecific, "pthread_setspecific"); | | 3055 | + pragma Import (C, pthread_setspecific, "pthread_setspecific"); |
3056 | + | | 3056 | + |
3057 | + function pthread_getspecific (key : pthread_key_t) return System.Address; | | 3057 | + function pthread_getspecific (key : pthread_key_t) return System.Address; |
3058 | + pragma Import (C, pthread_getspecific, "pthread_getspecific"); | | 3058 | + pragma Import (C, pthread_getspecific, "pthread_getspecific"); |
3059 | + | | 3059 | + |
3060 | + type destructor_pointer is access procedure (arg : System.Address); | | 3060 | + type destructor_pointer is access procedure (arg : System.Address); |
3061 | + pragma Convention (C, destructor_pointer); | | 3061 | + pragma Convention (C, destructor_pointer); |
3062 | + | | 3062 | + |
3063 | + function pthread_key_create | | 3063 | + function pthread_key_create |
3064 | + (key : access pthread_key_t; | | 3064 | + (key : access pthread_key_t; |
3065 | + destructor : destructor_pointer) return int; | | 3065 | + destructor : destructor_pointer) return int; |
3066 | + pragma Import (C, pthread_key_create, "pthread_key_create"); | | 3066 | + pragma Import (C, pthread_key_create, "pthread_key_create"); |
3067 | + | | 3067 | + |
3068 | + CPU_SETSIZE : constant := 1_024; | | 3068 | + CPU_SETSIZE : constant := 1_024; |
3069 | + | | 3069 | + |
3070 | + type bit_field is array (1 .. CPU_SETSIZE) of Boolean; | | 3070 | + type bit_field is array (1 .. CPU_SETSIZE) of Boolean; |
3071 | + for bit_field'Size use CPU_SETSIZE; | | 3071 | + for bit_field'Size use CPU_SETSIZE; |
3072 | + pragma Pack (bit_field); | | 3072 | + pragma Pack (bit_field); |
3073 | + pragma Convention (C, bit_field); | | 3073 | + pragma Convention (C, bit_field); |
3074 | + | | 3074 | + |
3075 | + type cpu_set_t is record | | 3075 | + type cpu_set_t is record |
3076 | + bits : bit_field; | | 3076 | + bits : bit_field; |
3077 | + end record; | | 3077 | + end record; |
3078 | + pragma Convention (C, cpu_set_t); | | 3078 | + pragma Convention (C, cpu_set_t); |
3079 | + | | 3079 | + |
3080 | + function pthread_setaffinity_np | | 3080 | + function pthread_setaffinity_np |
3081 | + (thread : pthread_t; | | 3081 | + (thread : pthread_t; |
3082 | + cpusetsize : size_t; | | 3082 | + cpusetsize : size_t; |
3083 | + cpuset : access cpu_set_t) return int; | | 3083 | + cpuset : access cpu_set_t) return int; |
3084 | + pragma Import (C, pthread_setaffinity_np, "pthread_setaffinity_np"); | | 3084 | + pragma Import (C, pthread_setaffinity_np, "pthread_setaffinity_np"); |
3085 | + pragma Weak_External (pthread_setaffinity_np); | | 3085 | + pragma Weak_External (pthread_setaffinity_np); |
3086 | + -- Use a weak symbol because this function may be available or not, | | 3086 | + -- Use a weak symbol because this function may be available or not, |
3087 | + -- depending on the version of the system. | | 3087 | + -- depending on the version of the system. |
3088 | + | | 3088 | + |
3089 | + function pthread_attr_setaffinity_np | | 3089 | + function pthread_attr_setaffinity_np |
3090 | + (attr : access pthread_attr_t; | | 3090 | + (attr : access pthread_attr_t; |
3091 | + cpusetsize : size_t; | | 3091 | + cpusetsize : size_t; |
3092 | + cpuset : access cpu_set_t) return int; | | 3092 | + cpuset : access cpu_set_t) return int; |
3093 | + pragma Import (C, pthread_attr_setaffinity_np, | | 3093 | + pragma Import (C, pthread_attr_setaffinity_np, |
3094 | + "pthread_attr_setaffinity_np"); | | 3094 | + "pthread_attr_setaffinity_np"); |
3095 | + pragma Weak_External (pthread_attr_setaffinity_np); | | 3095 | + pragma Weak_External (pthread_attr_setaffinity_np); |
3096 | + -- Use a weak symbol because this function may be available or not, | | 3096 | + -- Use a weak symbol because this function may be available or not, |
3097 | + -- depending on the version of the system. | | 3097 | + -- depending on the version of the system. |
3098 | + | | 3098 | + |
3099 | +private | | 3099 | +private |
3100 | + | | 3100 | + |
3101 | + type sigset_t is array (0 .. 127) of unsigned_char; | | 3101 | + type sigset_t is array (0 .. 127) of unsigned_char; |
3102 | + pragma Convention (C, sigset_t); | | 3102 | + pragma Convention (C, sigset_t); |
3103 | + for sigset_t'Alignment use Interfaces.C.unsigned_long'Alignment; | | 3103 | + for sigset_t'Alignment use Interfaces.C.unsigned_long'Alignment; |
3104 | + | | 3104 | + |
3105 | + pragma Warnings (Off); | | 3105 | + pragma Warnings (Off); |
3106 | + for struct_sigaction use record | | 3106 | + for struct_sigaction use record |
3107 | + sa_handler at Linux.sa_handler_pos range 0 .. Standard'Address_Size - 1; | | 3107 | + sa_handler at Linux.sa_handler_pos range 0 .. Standard'Address_Size - 1; |
3108 | + sa_mask at Linux.sa_mask_pos range 0 .. 1023; | | 3108 | + sa_mask at Linux.sa_mask_pos range 0 .. 1023; |
3109 | + sa_flags at Linux.sa_flags_pos range 0 .. Standard'Address_Size - 1; | | 3109 | + sa_flags at Linux.sa_flags_pos range 0 .. Standard'Address_Size - 1; |
3110 | + end record; | | 3110 | + end record; |
3111 | + -- We intentionally leave sa_restorer unspecified and let the compiler | | 3111 | + -- We intentionally leave sa_restorer unspecified and let the compiler |
3112 | + -- append it after the last field, so disable corresponding warning. | | 3112 | + -- append it after the last field, so disable corresponding warning. |
3113 | + pragma Warnings (On); | | 3113 | + pragma Warnings (On); |
3114 | + | | 3114 | + |
3115 | + type pid_t is new int; | | 3115 | + type pid_t is new int; |
3116 | + | | 3116 | + |
3117 | + type time_t is new long; | | 3117 | + type time_t is new long; |
3118 | + | | 3118 | + |
3119 | + type timespec is record | | 3119 | + type timespec is record |
3120 | + tv_sec : time_t; | | 3120 | + tv_sec : time_t; |
3121 | + tv_nsec : long; | | 3121 | + tv_nsec : long; |
3122 | + end record; | | 3122 | + end record; |
3123 | + pragma Convention (C, timespec); | | 3123 | + pragma Convention (C, timespec); |
3124 | + | | 3124 | + |
3125 | + type pthread_attr_t is record | | 3125 | + type pthread_attr_t is record |
3126 | + detachstate : int; | | 3126 | + detachstate : int; |
3127 | + schedpolicy : int; | | 3127 | + schedpolicy : int; |
3128 | + schedparam : struct_sched_param; | | 3128 | + schedparam : struct_sched_param; |
3129 | + inheritsched : int; | | 3129 | + inheritsched : int; |
3130 | + scope : int; | | 3130 | + scope : int; |
3131 | + guardsize : size_t; | | 3131 | + guardsize : size_t; |
3132 | + stackaddr_set : int; | | 3132 | + stackaddr_set : int; |
3133 | + stackaddr : System.Address; | | 3133 | + stackaddr : System.Address; |
3134 | + stacksize : size_t; | | 3134 | + stacksize : size_t; |
3135 | + end record; | | 3135 | + end record; |
3136 | + pragma Convention (C, pthread_attr_t); | | 3136 | + pragma Convention (C, pthread_attr_t); |
3137 | + | | 3137 | + |
3138 | + type pthread_condattr_t is record | | 3138 | + type pthread_condattr_t is record |
3139 | + dummy : int; | | 3139 | + dummy : int; |
3140 | + end record; | | 3140 | + end record; |
3141 | + pragma Convention (C, pthread_condattr_t); | | 3141 | + pragma Convention (C, pthread_condattr_t); |
3142 | + | | 3142 | + |
3143 | + type pthread_mutexattr_t is record | | 3143 | + type pthread_mutexattr_t is record |
3144 | + mutexkind : int; | | 3144 | + mutexkind : int; |
3145 | + end record; | | 3145 | + end record; |
3146 | + pragma Convention (C, pthread_mutexattr_t); | | 3146 | + pragma Convention (C, pthread_mutexattr_t); |
3147 | + | | 3147 | + |
3148 | + type pthread_mutex_t is new System.Linux.pthread_mutex_t; | | 3148 | + type pthread_mutex_t is new System.Linux.pthread_mutex_t; |
3149 | + | | 3149 | + |
3150 | + type unsigned_long_long_t is mod 2 ** 64; | | 3150 | + type unsigned_long_long_t is mod 2 ** 64; |
3151 | + -- Interfaces.C.Extensions isn't preelaborated so cannot be with-ed | | 3151 | + -- Interfaces.C.Extensions isn't preelaborated so cannot be with-ed |
3152 | + | | 3152 | + |
3153 | + type pthread_cond_t is array (0 .. 47) of unsigned_char; | | 3153 | + type pthread_cond_t is array (0 .. 47) of unsigned_char; |
3154 | + pragma Convention (C, pthread_cond_t); | | 3154 | + pragma Convention (C, pthread_cond_t); |
3155 | + for pthread_cond_t'Alignment use unsigned_long_long_t'Alignment; | | 3155 | + for pthread_cond_t'Alignment use unsigned_long_long_t'Alignment; |
3156 | + | | 3156 | + |
3157 | + type pthread_key_t is new unsigned; | | 3157 | + type pthread_key_t is new unsigned; |
3158 | + | | 3158 | + |
3159 | +end System.OS_Interface; | | 3159 | +end System.OS_Interface; |
3160 | --- /dev/null | | 3160 | --- /dev/null |
3161 | +++ gcc/ada/s-osinte-dragonfly.adb | | 3161 | +++ gcc/ada/s-osinte-dragonfly.adb |
3162 | @@ -0,0 +1,117 @@ | | 3162 | @@ -0,0 +1,117 @@ |
3163 | +------------------------------------------------------------------------------ | | 3163 | +------------------------------------------------------------------------------ |
3164 | +-- -- | | 3164 | +-- -- |
3165 | +-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS -- | | 3165 | +-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS -- |
3166 | +-- -- | | 3166 | +-- -- |
3167 | +-- S Y S T E M . O S _ I N T E R F A C E -- | | 3167 | +-- S Y S T E M . O S _ I N T E R F A C E -- |
3168 | +-- -- | | 3168 | +-- -- |
3169 | +-- B o d y -- | | 3169 | +-- B o d y -- |
3170 | +-- -- | | 3170 | +-- -- |
3171 | +-- Copyright (C) 1991-2009, Free Software Foundation, Inc. -- | | 3171 | +-- Copyright (C) 1991-2009, Free Software Foundation, Inc. -- |
3172 | +-- -- | | 3172 | +-- -- |
3173 | +-- GNARL is free software; you can redistribute it and/or modify it under -- | | 3173 | +-- GNARL is free software; you can redistribute it and/or modify it under -- |
3174 | +-- terms of the GNU General Public License as published by the Free Soft- -- | | 3174 | +-- terms of the GNU General Public License as published by the Free Soft- -- |
3175 | +-- ware Foundation; either version 3, or (at your option) any later ver- -- | | 3175 | +-- ware Foundation; either version 3, or (at your option) any later ver- -- |
3176 | +-- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- | | 3176 | +-- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- |
3177 | +-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- | | 3177 | +-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- |
3178 | +-- or FITNESS FOR A PARTICULAR PURPOSE. -- | | 3178 | +-- or FITNESS FOR A PARTICULAR PURPOSE. -- |
3179 | +-- -- | | 3179 | +-- -- |
3180 | +-- As a special exception under Section 7 of GPL version 3, you are granted -- | | 3180 | +-- As a special exception under Section 7 of GPL version 3, you are granted -- |
3181 | +-- additional permissions described in the GCC Runtime Library Exception, -- | | 3181 | +-- additional permissions described in the GCC Runtime Library Exception, -- |
3182 | +-- version 3.1, as published by the Free Software Foundation. -- | | 3182 | +-- version 3.1, as published by the Free Software Foundation. -- |
3183 | +-- -- | | 3183 | +-- -- |
3184 | +-- You should have received a copy of the GNU General Public License and -- | | 3184 | +-- You should have received a copy of the GNU General Public License and -- |
3185 | +-- a copy of the GCC Runtime Library Exception along with this program; -- | | 3185 | +-- a copy of the GCC Runtime Library Exception along with this program; -- |
3186 | +-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- | | 3186 | +-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- |
3187 | +-- <http://www.gnu.org/licenses/>. -- | | 3187 | +-- <http://www.gnu.org/licenses/>. -- |
3188 | +-- -- | | 3188 | +-- -- |
3189 | +-- GNARL was developed by the GNARL team at Florida State University. It is -- | | 3189 | +-- GNARL was developed by the GNARL team at Florida State University. It is -- |
3190 | +-- now maintained by Ada Core Technologies Inc. in cooperation with Florida -- | | 3190 | +-- now maintained by Ada Core Technologies Inc. in cooperation with Florida -- |
3191 | +-- State University (http://www.gnat.com). -- | | 3191 | +-- State University (http://www.gnat.com). -- |
3192 | +-- -- | | 3192 | +-- -- |
3193 | +-- Copyright (C) 2010 John Marino <draco@marino.st> -- | | 3193 | +-- Copyright (C) 2010 John Marino <draco@marino.st> -- |
3194 | +------------------------------------------------------------------------------ | | 3194 | +------------------------------------------------------------------------------ |
3195 | + | | 3195 | + |
3196 | +-- This is the DragonFly THREADS version of this package | | 3196 | +-- This is the DragonFly THREADS version of this package |
3197 | + | | 3197 | + |
3198 | +with Interfaces.C; use Interfaces.C; | | 3198 | +with Interfaces.C; use Interfaces.C; |
3199 | + | | 3199 | + |
3200 | +package body System.OS_Interface is | | 3200 | +package body System.OS_Interface is |
3201 | + | | 3201 | + |
3202 | + ----------- | | 3202 | + ----------- |
3203 | + -- Errno -- | | 3203 | + -- Errno -- |
3204 | + ----------- | | 3204 | + ----------- |
3205 | + | | 3205 | + |
3206 | + function Errno return int is | | 3206 | + function Errno return int is |
3207 | + type int_ptr is access all int; | | 3207 | + type int_ptr is access all int; |
3208 | + | | 3208 | + |
3209 | + function internal_errno return int_ptr; | | 3209 | + function internal_errno return int_ptr; |
3210 | + pragma Import (C, internal_errno, "__get_errno"); | | 3210 | + pragma Import (C, internal_errno, "__get_errno"); |
3211 | + | | 3211 | + |
3212 | + begin | | 3212 | + begin |
3213 | + return (internal_errno.all); | | 3213 | + return (internal_errno.all); |
3214 | + end Errno; | | 3214 | + end Errno; |
3215 | + | | 3215 | + |
3216 | + -------------------- | | 3216 | + -------------------- |
3217 | + -- Get_Stack_Base -- | | 3217 | + -- Get_Stack_Base -- |
3218 | + -------------------- | | 3218 | + -------------------- |
3219 | + | | 3219 | + |
3220 | + function Get_Stack_Base (thread : pthread_t) return Address is | | 3220 | + function Get_Stack_Base (thread : pthread_t) return Address is |
3221 | + pragma Unreferenced (thread); | | 3221 | + pragma Unreferenced (thread); |
3222 | + begin | | 3222 | + begin |
3223 | + return Null_Address; | | 3223 | + return Null_Address; |
3224 | + end Get_Stack_Base; | | 3224 | + end Get_Stack_Base; |
3225 | + | | 3225 | + |
3226 | + ------------------ | | 3226 | + ------------------ |
3227 | + -- pthread_init -- | | 3227 | + -- pthread_init -- |
3228 | + ------------------ | | 3228 | + ------------------ |
3229 | + | | 3229 | + |
3230 | + procedure pthread_init is | | 3230 | + procedure pthread_init is |
3231 | + begin | | 3231 | + begin |
3232 | + null; | | 3232 | + null; |
3233 | + end pthread_init; | | 3233 | + end pthread_init; |
3234 | + | | 3234 | + |
3235 | + ----------------- | | 3235 | + ----------------- |
3236 | + -- To_Duration -- | | 3236 | + -- To_Duration -- |
3237 | + ----------------- | | 3237 | + ----------------- |
3238 | + | | 3238 | + |
3239 | + function To_Duration (TS : timespec) return Duration is | | 3239 | + function To_Duration (TS : timespec) return Duration is |
3240 | + begin | | 3240 | + begin |
3241 | + return Duration (TS.tv_sec) + Duration (TS.tv_nsec) / 10#1#E9; | | 3241 | + return Duration (TS.tv_sec) + Duration (TS.tv_nsec) / 10#1#E9; |
3242 | + end To_Duration; | | 3242 | + end To_Duration; |
3243 | + | | 3243 | + |
3244 | + ------------------------ | | 3244 | + ------------------------ |
3245 | + -- To_Target_Priority -- | | 3245 | + -- To_Target_Priority -- |
3246 | + ------------------------ | | 3246 | + ------------------------ |
3247 | + | | 3247 | + |
3248 | + function To_Target_Priority | | 3248 | + function To_Target_Priority |
3249 | + (Prio : System.Any_Priority) return Interfaces.C.int | | 3249 | + (Prio : System.Any_Priority) return Interfaces.C.int |
3250 | + is | | 3250 | + is |
3251 | + begin | | 3251 | + begin |
3252 | + return Interfaces.C.int (Prio); | | 3252 | + return Interfaces.C.int (Prio); |
3253 | + end To_Target_Priority; | | 3253 | + end To_Target_Priority; |
3254 | + | | 3254 | + |
3255 | + ----------------- | | 3255 | + ----------------- |
3256 | + -- To_Timespec -- | | 3256 | + -- To_Timespec -- |
3257 | + ----------------- | | 3257 | + ----------------- |
3258 | + | | 3258 | + |
3259 | + function To_Timespec (D : Duration) return timespec is | | 3259 | + function To_Timespec (D : Duration) return timespec is |
3260 | + S : time_t; | | 3260 | + S : time_t; |
3261 | + F : Duration; | | 3261 | + F : Duration; |
3262 | + | | 3262 | + |
3263 | + begin | | 3263 | + begin |
3264 | + S := time_t (Long_Long_Integer (D)); | | 3264 | + S := time_t (Long_Long_Integer (D)); |
3265 | + F := D - Duration (S); | | 3265 | + F := D - Duration (S); |
3266 | + | | 3266 | + |
3267 | + -- If F has negative value due to a round-up, adjust for positive F | | 3267 | + -- If F has negative value due to a round-up, adjust for positive F |
3268 | + -- value. | | 3268 | + -- value. |
3269 | + | | 3269 | + |
3270 | + if F < 0.0 then | | 3270 | + if F < 0.0 then |
3271 | + S := S - 1; | | 3271 | + S := S - 1; |
3272 | + F := F + 1.0; | | 3272 | + F := F + 1.0; |
3273 | + end if; | | 3273 | + end if; |
3274 | + | | 3274 | + |
3275 | + return timespec'(tv_sec => S, | | 3275 | + return timespec'(tv_sec => S, |
3276 | + tv_nsec => long (Long_Long_Integer (F * 10#1#E9))); | | 3276 | + tv_nsec => long (Long_Long_Integer (F * 10#1#E9))); |
3277 | + end To_Timespec; | | 3277 | + end To_Timespec; |
3278 | + | | 3278 | + |
3279 | +end System.OS_Interface; | | 3279 | +end System.OS_Interface; |
3280 | --- /dev/null | | 3280 | --- /dev/null |
3281 | +++ gcc/ada/s-osinte-dragonfly.ads | | 3281 | +++ gcc/ada/s-osinte-dragonfly.ads |
3282 | @@ -0,0 +1,648 @@ | | 3282 | @@ -0,0 +1,648 @@ |
3283 | +------------------------------------------------------------------------------ | | 3283 | +------------------------------------------------------------------------------ |
3284 | +-- -- | | 3284 | +-- -- |
3285 | +-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS -- | | 3285 | +-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS -- |
3286 | +-- -- | | 3286 | +-- -- |
3287 | +-- S Y S T E M . O S _ I N T E R F A C E -- | | 3287 | +-- S Y S T E M . O S _ I N T E R F A C E -- |
3288 | +-- -- | | 3288 | +-- -- |
3289 | +-- S p e c -- | | 3289 | +-- S p e c -- |
3290 | +-- -- | | 3290 | +-- -- |
3291 | +-- Copyright (C) 1991-1994, Florida State University -- | | 3291 | +-- Copyright (C) 1991-1994, Florida State University -- |
3292 | +-- Copyright (C) 1995-2009, Free Software Foundation, Inc. -- | | 3292 | +-- Copyright (C) 1995-2009, Free Software Foundation, Inc. -- |
3293 | +-- -- | | 3293 | +-- -- |
3294 | +-- GNARL is free software; you can redistribute it and/or modify it under -- | | 3294 | +-- GNARL is free software; you can redistribute it and/or modify it under -- |
3295 | +-- terms of the GNU General Public License as published by the Free Soft- -- | | 3295 | +-- terms of the GNU General Public License as published by the Free Soft- -- |
3296 | +-- ware Foundation; either version 2, or (at your option) any later ver- -- | | 3296 | +-- ware Foundation; either version 2, or (at your option) any later ver- -- |
3297 | +-- sion. GNARL is distributed in the hope that it will be useful, but WITH- -- | | 3297 | +-- sion. GNARL is distributed in the hope that it will be useful, but WITH- -- |
3298 | +-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- | | 3298 | +-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- |
3299 | +-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- | | 3299 | +-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- |
3300 | +-- for more details. You should have received a copy of the GNU General -- | | 3300 | +-- for more details. You should have received a copy of the GNU General -- |
3301 | +-- Public License distributed with GNARL; see file COPYING. If not, write -- | | 3301 | +-- Public License distributed with GNARL; see file COPYING. If not, write -- |
3302 | +-- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, -- | | 3302 | +-- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, -- |
3303 | +-- Boston, MA 02110-1301, USA. -- | | 3303 | +-- Boston, MA 02110-1301, USA. -- |
3304 | +-- -- | | 3304 | +-- -- |
3305 | +-- As a special exception, if other files instantiate generics from this -- | | 3305 | +-- As a special exception, if other files instantiate generics from this -- |
3306 | +-- unit, or you link this unit with other files to produce an executable, -- | | 3306 | +-- unit, or you link this unit with other files to produce an executable, -- |
3307 | +-- this unit does not by itself cause the resulting executable to be -- | | 3307 | +-- this unit does not by itself cause the resulting executable to be -- |
3308 | +-- covered by the GNU General Public License. This exception does not -- | | 3308 | +-- covered by the GNU General Public License. This exception does not -- |
3309 | +-- however invalidate any other reasons why the executable file might be -- | | 3309 | +-- however invalidate any other reasons why the executable file might be -- |
3310 | +-- covered by the GNU Public License. -- | | 3310 | +-- covered by the GNU Public License. -- |
3311 | +-- -- | | 3311 | +-- -- |
3312 | +-- GNARL was developed by the GNARL team at Florida State University. It is -- | | 3312 | +-- GNARL was developed by the GNARL team at Florida State University. It is -- |
3313 | +-- now maintained by Ada Core Technologies Inc. in cooperation with Florida -- | | 3313 | +-- now maintained by Ada Core Technologies Inc. in cooperation with Florida -- |
3314 | +-- State University (http://www.gnat.com). -- | | 3314 | +-- State University (http://www.gnat.com). -- |
3315 | +-- -- | | 3315 | +-- -- |
3316 | +-- Copyright (C) 2010 John Marino <draco@marino.st> -- | | 3316 | +-- Copyright (C) 2010 John Marino <draco@marino.st> -- |
3317 | +------------------------------------------------------------------------------ | | 3317 | +------------------------------------------------------------------------------ |
3318 | + | | 3318 | + |
3319 | +-- This is the DragonFly BSD PTHREADS version of this package | | 3319 | +-- This is the DragonFly BSD PTHREADS version of this package |
3320 | + | | 3320 | + |
3321 | +-- This package encapsulates all direct interfaces to OS services | | 3321 | +-- This package encapsulates all direct interfaces to OS services |
3322 | +-- that are needed by the tasking run-time (libgnarl). | | 3322 | +-- that are needed by the tasking run-time (libgnarl). |
3323 | + | | 3323 | + |
3324 | +-- PLEASE DO NOT add any with-clauses to this package or remove the pragma | | 3324 | +-- PLEASE DO NOT add any with-clauses to this package or remove the pragma |
3325 | +-- Preelaborate. This package is designed to be a bottom-level (leaf) package. | | 3325 | +-- Preelaborate. This package is designed to be a bottom-level (leaf) package. |
3326 | + | | 3326 | + |
3327 | +with Ada.Unchecked_Conversion; | | 3327 | +with Ada.Unchecked_Conversion; |
3328 | + | | 3328 | + |
3329 | +with Interfaces.C; | | 3329 | +with Interfaces.C; |
3330 | + | | 3330 | + |
3331 | +package System.OS_Interface is | | 3331 | +package System.OS_Interface is |
3332 | + pragma Preelaborate; | | 3332 | + pragma Preelaborate; |
3333 | + | | 3333 | + |
3334 | + pragma Linker_Options ("-pthread"); | | 3334 | + pragma Linker_Options ("-pthread"); |
3335 | + | | 3335 | + |
3336 | + subtype int is Interfaces.C.int; | | 3336 | + subtype int is Interfaces.C.int; |
3337 | + subtype short is Interfaces.C.short; | | 3337 | + subtype short is Interfaces.C.short; |
3338 | + subtype long is Interfaces.C.long; | | 3338 | + subtype long is Interfaces.C.long; |
3339 | + subtype unsigned is Interfaces.C.unsigned; | | 3339 | + subtype unsigned is Interfaces.C.unsigned; |
3340 | + subtype unsigned_short is Interfaces.C.unsigned_short; | | 3340 | + subtype unsigned_short is Interfaces.C.unsigned_short; |
3341 | + subtype unsigned_long is Interfaces.C.unsigned_long; | | 3341 | + subtype unsigned_long is Interfaces.C.unsigned_long; |
3342 | + subtype unsigned_char is Interfaces.C.unsigned_char; | | 3342 | + subtype unsigned_char is Interfaces.C.unsigned_char; |
3343 | + subtype plain_char is Interfaces.C.plain_char; | | 3343 | + subtype plain_char is Interfaces.C.plain_char; |
3344 | + subtype size_t is Interfaces.C.size_t; | | 3344 | + subtype size_t is Interfaces.C.size_t; |
3345 | + | | 3345 | + |
3346 | + ----------- | | 3346 | + ----------- |
3347 | + -- Errno -- | | 3347 | + -- Errno -- |
3348 | + ----------- | | 3348 | + ----------- |
3349 | + | | 3349 | + |
3350 | + function Errno return int; | | 3350 | + function Errno return int; |
3351 | + pragma Inline (Errno); | | 3351 | + pragma Inline (Errno); |
3352 | + | | 3352 | + |
3353 | + EAGAIN : constant := 35; | | 3353 | + EAGAIN : constant := 35; |
3354 | + EINTR : constant := 4; | | 3354 | + EINTR : constant := 4; |
3355 | + EINVAL : constant := 22; | | 3355 | + EINVAL : constant := 22; |
3356 | + ENOMEM : constant := 12; | | 3356 | + ENOMEM : constant := 12; |
3357 | + ETIMEDOUT : constant := 60; | | 3357 | + ETIMEDOUT : constant := 60; |
3358 | + | | 3358 | + |
3359 | + ------------- | | 3359 | + ------------- |
3360 | + -- Signals -- | | 3360 | + -- Signals -- |
3361 | + ------------- | | 3361 | + ------------- |
3362 | + | | 3362 | + |
3363 | + Max_Interrupt : constant := 31; | | 3363 | + Max_Interrupt : constant := 31; |
3364 | + type Signal is new int range 0 .. Max_Interrupt; | | 3364 | + type Signal is new int range 0 .. Max_Interrupt; |
3365 | + for Signal'Size use int'Size; | | 3365 | + for Signal'Size use int'Size; |
3366 | + | | 3366 | + |
3367 | + SIGHUP : constant := 1; -- hangup | | 3367 | + SIGHUP : constant := 1; -- hangup |
3368 | + SIGINT : constant := 2; -- interrupt (rubout) | | 3368 | + SIGINT : constant := 2; -- interrupt (rubout) |
3369 | + SIGQUIT : constant := 3; -- quit (ASCD FS) | | 3369 | + SIGQUIT : constant := 3; -- quit (ASCD FS) |
3370 | + SIGILL : constant := 4; -- illegal instruction (not reset) | | 3370 | + SIGILL : constant := 4; -- illegal instruction (not reset) |
3371 | + SIGTRAP : constant := 5; -- trace trap (not reset) | | 3371 | + SIGTRAP : constant := 5; -- trace trap (not reset) |
3372 | + SIGIOT : constant := 6; -- IOT instruction | | 3372 | + SIGIOT : constant := 6; -- IOT instruction |
3373 | + SIGABRT : constant := 6; -- used by abort, replace SIGIOT in the future | | 3373 | + SIGABRT : constant := 6; -- used by abort, replace SIGIOT in the future |
3374 | + SIGEMT : constant := 7; -- EMT instruction | | 3374 | + SIGEMT : constant := 7; -- EMT instruction |
3375 | + SIGFPE : constant := 8; -- floating point exception | | 3375 | + SIGFPE : constant := 8; -- floating point exception |
3376 | + SIGKILL : constant := 9; -- kill (cannot be caught or ignored) | | 3376 | + SIGKILL : constant := 9; -- kill (cannot be caught or ignored) |
3377 | + SIGBUS : constant := 10; -- bus error | | 3377 | + SIGBUS : constant := 10; -- bus error |
3378 | + SIGSEGV : constant := 11; -- segmentation violation | | 3378 | + SIGSEGV : constant := 11; -- segmentation violation |
3379 | + SIGSYS : constant := 12; -- bad argument to system call | | 3379 | + SIGSYS : constant := 12; -- bad argument to system call |
3380 | + SIGPIPE : constant := 13; -- write on a pipe with no one to read it | | 3380 | + SIGPIPE : constant := 13; -- write on a pipe with no one to read it |
3381 | + SIGALRM : constant := 14; -- alarm clock | | 3381 | + SIGALRM : constant := 14; -- alarm clock |
3382 | + SIGTERM : constant := 15; -- software termination signal from kill | | 3382 | + SIGTERM : constant := 15; -- software termination signal from kill |
3383 | + SIGURG : constant := 16; -- urgent condition on IO channel | | 3383 | + SIGURG : constant := 16; -- urgent condition on IO channel |
3384 | + SIGSTOP : constant := 17; -- stop (cannot be caught or ignored) | | 3384 | + SIGSTOP : constant := 17; -- stop (cannot be caught or ignored) |
3385 | + SIGTSTP : constant := 18; -- user stop requested from tty | | 3385 | + SIGTSTP : constant := 18; -- user stop requested from tty |
3386 | + SIGCONT : constant := 19; -- stopped process has been continued | | 3386 | + SIGCONT : constant := 19; -- stopped process has been continued |
3387 | + SIGCLD : constant := 20; -- alias for SIGCHLD | | 3387 | + SIGCLD : constant := 20; -- alias for SIGCHLD |
3388 | + SIGCHLD : constant := 20; -- child status change | | 3388 | + SIGCHLD : constant := 20; -- child status change |
3389 | + SIGTTIN : constant := 21; -- background tty read attempted | | 3389 | + SIGTTIN : constant := 21; -- background tty read attempted |
3390 | + SIGTTOU : constant := 22; -- background tty write attempted | | 3390 | + SIGTTOU : constant := 22; -- background tty write attempted |
3391 | + SIGIO : constant := 23; -- I/O possible (Solaris SIGPOLL alias) | | 3391 | + SIGIO : constant := 23; -- I/O possible (Solaris SIGPOLL alias) |
3392 | + SIGXCPU : constant := 24; -- CPU time limit exceeded | | 3392 | + SIGXCPU : constant := 24; -- CPU time limit exceeded |
3393 | + SIGXFSZ : constant := 25; -- filesize limit exceeded | | 3393 | + SIGXFSZ : constant := 25; -- filesize limit exceeded |
3394 | + SIGVTALRM : constant := 26; -- virtual timer expired | | 3394 | + SIGVTALRM : constant := 26; -- virtual timer expired |
3395 | + SIGPROF : constant := 27; -- profiling timer expired | | 3395 | + SIGPROF : constant := 27; -- profiling timer expired |
3396 | + SIGWINCH : constant := 28; -- window size change | | 3396 | + SIGWINCH : constant := 28; -- window size change |
3397 | + SIGINFO : constant := 29; -- information request (BSD) | | 3397 | + SIGINFO : constant := 29; -- information request (BSD) |
3398 | + SIGUSR1 : constant := 30; -- user defined signal 1 | | 3398 | + SIGUSR1 : constant := 30; -- user defined signal 1 |
3399 | + SIGUSR2 : constant := 31; -- user defined signal 2 | | 3399 | + SIGUSR2 : constant := 31; -- user defined signal 2 |
3400 | + | | 3400 | + |
3401 | + SIGADAABORT : constant := SIGABRT; | | 3401 | + SIGADAABORT : constant := SIGABRT; |
3402 | + -- Change this if you want to use another signal for task abort. | | 3402 | + -- Change this if you want to use another signal for task abort. |
3403 | + -- SIGTERM might be a good one. | | 3403 | + -- SIGTERM might be a good one. |
3404 | + | | 3404 | + |
3405 | + type Signal_Set is array (Natural range <>) of Signal; | | 3405 | + type Signal_Set is array (Natural range <>) of Signal; |
3406 | + | | 3406 | + |
3407 | + -- Interrupts that must be unmasked at all times. DragonFlyBSD | | 3407 | + -- Interrupts that must be unmasked at all times. DragonFlyBSD |
3408 | + -- pthreads will not allow an application to mask out any | | 3408 | + -- pthreads will not allow an application to mask out any |
3409 | + -- interrupt needed by the threads library. | | 3409 | + -- interrupt needed by the threads library. |
3410 | + Unmasked : constant Signal_Set := | | 3410 | + Unmasked : constant Signal_Set := |
3411 | + (SIGTRAP, SIGBUS, SIGTTIN, SIGTTOU, SIGTSTP); | | 3411 | + (SIGTRAP, SIGBUS, SIGTTIN, SIGTTOU, SIGTSTP); |
3412 | + | | 3412 | + |
3413 | + -- DragonFlyBSD will uses SIGPROF for timing. Do not allow a | | 3413 | + -- DragonFlyBSD will uses SIGPROF for timing. Do not allow a |
3414 | + -- handler to attach to this signal. | | 3414 | + -- handler to attach to this signal. |
3415 | + Reserved : constant Signal_Set := (0 .. 0 => SIGPROF); | | 3415 | + Reserved : constant Signal_Set := (0 .. 0 => SIGPROF); |
3416 | + | | 3416 | + |
3417 | + type sigset_t is private; | | 3417 | + type sigset_t is private; |
3418 | + | | 3418 | + |
3419 | + function sigaddset | | 3419 | + function sigaddset |
3420 | + (set : access sigset_t; | | 3420 | + (set : access sigset_t; |
3421 | + sig : Signal) return int; | | 3421 | + sig : Signal) return int; |
3422 | + pragma Import (C, sigaddset, "sigaddset"); | | 3422 | + pragma Import (C, sigaddset, "sigaddset"); |
3423 | + | | 3423 | + |
3424 | + function sigdelset | | 3424 | + function sigdelset |
3425 | + (set : access sigset_t; | | 3425 | + (set : access sigset_t; |
3426 | + sig : Signal) return int; | | 3426 | + sig : Signal) return int; |
3427 | + pragma Import (C, sigdelset, "sigdelset"); | | 3427 | + pragma Import (C, sigdelset, "sigdelset"); |
3428 | + | | 3428 | + |
3429 | + function sigfillset (set : access sigset_t) return int; | | 3429 | + function sigfillset (set : access sigset_t) return int; |
3430 | + pragma Import (C, sigfillset, "sigfillset"); | | 3430 | + pragma Import (C, sigfillset, "sigfillset"); |
3431 | + | | 3431 | + |
3432 | + function sigismember | | 3432 | + function sigismember |
3433 | + (set : access sigset_t; | | 3433 | + (set : access sigset_t; |
3434 | + sig : Signal) return int; | | 3434 | + sig : Signal) return int; |
3435 | + pragma Import (C, sigismember, "sigismember"); | | 3435 | + pragma Import (C, sigismember, "sigismember"); |
3436 | + | | 3436 | + |
3437 | + function sigemptyset (set : access sigset_t) return int; | | 3437 | + function sigemptyset (set : access sigset_t) return int; |
3438 | + pragma Import (C, sigemptyset, "sigemptyset"); | | 3438 | + pragma Import (C, sigemptyset, "sigemptyset"); |
3439 | + | | 3439 | + |
3440 | + -- sigcontext is architecture dependent, so define it private | | 3440 | + -- sigcontext is architecture dependent, so define it private |
3441 | + type struct_sigcontext is private; | | 3441 | + type struct_sigcontext is private; |