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