Mark symbols in offload tables with force_output in read_offload_tables
[official-gcc.git] / gcc / ada / g-binenv.adb
blob13e414d46fa6b362c1ebe12fa40a216efbf050e0
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
4 -- --
5 -- G N A T . B I N D _ E N V I R O N M E N T --
6 -- --
7 -- B o d y --
8 -- --
9 -- Copyright (C) 2015, Free Software Foundation, Inc. --
10 -- --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. --
17 -- --
18 -- As a special exception under Section 7 of GPL version 3, you are granted --
19 -- additional permissions described in the GCC Runtime Library Exception, --
20 -- version 3.1, as published by the Free Software Foundation. --
21 -- --
22 -- You should have received a copy of the GNU General Public License and --
23 -- a copy of the GCC Runtime Library Exception along with this program; --
24 -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
25 -- <http://www.gnu.org/licenses/>. --
26 -- --
27 -- GNARL was developed by the GNARL team at Florida State University. --
28 -- Extensive contributions were provided by AdaCore. --
29 -- --
30 ------------------------------------------------------------------------------
32 with System;
34 package body GNAT.Bind_Environment is
36 ---------
37 -- Get --
38 ---------
40 function Get (Key : String) return String is
41 use type System.Address;
43 Bind_Env_Addr : System.Address;
44 pragma Import (C, Bind_Env_Addr, "__gl_bind_env_addr");
45 -- Variable provided by init.c/s-init.ads, and initialized by
46 -- the binder generated file.
48 Bind_Env : String (Positive);
49 for Bind_Env'Address use Bind_Env_Addr;
50 pragma Import (Ada, Bind_Env);
51 -- Import Bind_Env string from binder file. Note that we import
52 -- it here as a string with maximum boundaries. The "real" end
53 -- of the string is indicated by a NUL byte.
55 Index, KLen, VLen : Integer;
57 begin
58 if Bind_Env_Addr = System.Null_Address then
59 return "";
60 end if;
62 Index := Bind_Env'First;
63 loop
64 -- Index points to key length
66 VLen := 0;
67 KLen := Character'Pos (Bind_Env (Index));
68 exit when KLen = 0;
70 Index := Index + KLen + 1;
72 -- Index points to value length
74 VLen := Character'Pos (Bind_Env (Index));
75 exit when Bind_Env (Index - KLen .. Index - 1) = Key;
77 Index := Index + VLen + 1;
78 end loop;
80 return Bind_Env (Index + 1 .. Index + VLen);
81 end Get;
83 end GNAT.Bind_Environment;