xref: /dflybsd-src/contrib/gcc-8.0/include/environ.h (revision 38fd149817dfbff97799f62fcb70be98c4e32523)
1*38fd1498Szrj /* Declare the environ system variable.
2*38fd1498Szrj    Copyright (C) 2015-2018 Free Software Foundation, Inc.
3*38fd1498Szrj 
4*38fd1498Szrj This file is part of the libiberty library.
5*38fd1498Szrj Libiberty is free software; you can redistribute it and/or
6*38fd1498Szrj modify it under the terms of the GNU Library General Public
7*38fd1498Szrj License as published by the Free Software Foundation; either
8*38fd1498Szrj version 2 of the License, or (at your option) any later version.
9*38fd1498Szrj 
10*38fd1498Szrj Libiberty is distributed in the hope that it will be useful,
11*38fd1498Szrj but WITHOUT ANY WARRANTY; without even the implied warranty of
12*38fd1498Szrj MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13*38fd1498Szrj Library General Public License for more details.
14*38fd1498Szrj 
15*38fd1498Szrj You should have received a copy of the GNU Library General Public
16*38fd1498Szrj License along with libiberty; see the file COPYING.LIB.  If not,
17*38fd1498Szrj write to the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
18*38fd1498Szrj Boston, MA 02110-1301, USA.  */
19*38fd1498Szrj 
20*38fd1498Szrj /* On OSX, the environ variable can be used directly in the code of an
21*38fd1498Szrj    executable, but cannot be used in the code of a shared library (such as
22*38fd1498Szrj    GCC's liblto_plugin, which links in libiberty code).  Instead, the
23*38fd1498Szrj    function _NSGetEnviron can be called to get the address of environ.  */
24*38fd1498Szrj 
25*38fd1498Szrj #ifndef HAVE_ENVIRON_DECL
26*38fd1498Szrj #  ifdef __APPLE__
27*38fd1498Szrj #     include <crt_externs.h>
28*38fd1498Szrj #     define environ (*_NSGetEnviron ())
29*38fd1498Szrj #  else
30*38fd1498Szrj #    ifndef environ
31*38fd1498Szrj extern char **environ;
32*38fd1498Szrj #    endif
33*38fd1498Szrj #  endif
34*38fd1498Szrj #  define HAVE_ENVIRON_DECL
35*38fd1498Szrj #endif
36