1 /* Copyright (C) 1991,1996,1997,2000-2004,2009 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, write to the Free
16 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
24 #include "../version.h"
26 /* If BUF is not NULL and LEN > 0, fill in at most LEN - 1 bytes
27 of BUF with the value corresponding to NAME and zero-terminate BUF.
28 Return the number of bytes required to hold NAME's entire value. */
30 confstr (name, buf, len)
35 const char *string = "";
36 size_t string_len = 1;
42 static const char cs_path[] = CS_PATH;
44 string_len = sizeof (cs_path);
48 /* eglibc: We share code in confstr.inc with cross-getconf.c. */
49 #include "confstr.inc"
52 case _CS_XBS5_ILP32_OFF32_CFLAGS:
53 case _CS_POSIX_V6_ILP32_OFF32_CFLAGS:
54 case _CS_POSIX_V7_ILP32_OFF32_CFLAGS:
55 #ifdef __ILP32_OFF32_CFLAGS
56 # if _POSIX_V7_ILP32_OFF32 == -1
57 # error "__ILP32_OFF32_CFLAGS should not be defined"
58 # elif !defined _POSIX_V7_ILP32_OFF32
59 if (__sysconf (_SC_V7_ILP32_OFF32) < 0)
62 string = __ILP32_OFF32_CFLAGS;
63 string_len = sizeof (__ILP32_OFF32_CFLAGS);
67 case _CS_XBS5_ILP32_OFFBIG_CFLAGS:
68 case _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS:
69 case _CS_POSIX_V7_ILP32_OFFBIG_CFLAGS:
70 #ifdef __ILP32_OFFBIG_CFLAGS
71 # if _POSIX_V7_ILP32_OFFBIG == -1
72 # error "__ILP32_OFFBIG_CFLAGS should not be defined"
73 # elif !defined _POSIX_V7_ILP32_OFFBIG
74 if (__sysconf (_SC_V7_ILP32_OFFBIG) < 0)
77 string = __ILP32_OFFBIG_CFLAGS;
78 string_len = sizeof (__ILP32_OFFBIG_CFLAGS);
82 case _CS_XBS5_LP64_OFF64_CFLAGS:
83 case _CS_POSIX_V6_LP64_OFF64_CFLAGS:
84 case _CS_POSIX_V7_LP64_OFF64_CFLAGS:
85 #ifdef __LP64_OFF64_CFLAGS
86 # if _POSIX_V7_LP64_OFF64 == -1
87 # error "__LP64_OFF64_CFLAGS should not be defined"
88 # elif !defined _POSIX_V7_LP64_OFF64
89 if (__sysconf (_SC_V7_LP64_OFF64) < 0)
92 string = __LP64_OFF64_CFLAGS;
93 string_len = sizeof (__LP64_OFF64_CFLAGS);
97 case _CS_XBS5_ILP32_OFF32_LDFLAGS:
98 case _CS_POSIX_V6_ILP32_OFF32_LDFLAGS:
99 case _CS_POSIX_V7_ILP32_OFF32_LDFLAGS:
100 #ifdef __ILP32_OFF32_LDFLAGS
101 # if _POSIX_V7_ILP32_OFF32 == -1
102 # error "__ILP32_OFF32_LDFLAGS should not be defined"
103 # elif !defined _POSIX_V7_ILP32_OFF32
104 if (__sysconf (_SC_V7_ILP32_OFF32) < 0)
107 string = __ILP32_OFF32_LDFLAGS;
108 string_len = sizeof (__ILP32_OFF32_LDFLAGS);
112 case _CS_XBS5_ILP32_OFFBIG_LDFLAGS:
113 case _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS:
114 case _CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS:
115 #ifdef __ILP32_OFFBIG_LDFLAGS
116 # if _POSIX_V7_ILP32_OFFBIG == -1
117 # error "__ILP32_OFFBIG_LDFLAGS should not be defined"
118 # elif !defined _POSIX_V7_ILP32_OFFBIG
119 if (__sysconf (_SC_V7_ILP32_OFFBIG) < 0)
122 string = __ILP32_OFFBIG_LDFLAGS;
123 string_len = sizeof (__ILP32_OFFBIG_LDFLAGS);
127 case _CS_XBS5_LP64_OFF64_LDFLAGS:
128 case _CS_POSIX_V6_LP64_OFF64_LDFLAGS:
129 case _CS_POSIX_V7_LP64_OFF64_LDFLAGS:
130 #ifdef __LP64_OFF64_LDFLAGS
131 # if _POSIX_V7_LP64_OFF64 == -1
132 # error "__LP64_OFF64_LDFLAGS should not be defined"
133 # elif !defined _POSIX_V7_LP64_OFF64
134 if (__sysconf (_SC_V7_LP64_OFF64) < 0)
137 string = __LP64_OFF64_LDFLAGS;
138 string_len = sizeof (__LP64_OFF64_LDFLAGS);
143 case _CS_LFS_LINTFLAGS:
144 #if _POSIX_V6_ILP32_OFF32 == 1 && _POSIX_V6_ILP32_OFFBIG == 1
145 # define __LFS_CFLAGS "-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
146 /* Signal that we want the new ABI. */
147 string = __LFS_CFLAGS;
148 string_len = sizeof (__LFS_CFLAGS);
152 case _CS_LFS_LDFLAGS:
154 /* No special libraries or linker flags needed. */
157 case _CS_LFS64_CFLAGS:
158 case _CS_LFS64_LINTFLAGS:
159 #define __LFS64_CFLAGS "-D_LARGEFILE64_SOURCE"
160 string = __LFS64_CFLAGS;
161 string_len = sizeof (__LFS64_CFLAGS);
164 case _CS_LFS64_LDFLAGS:
166 /* No special libraries or linker flags needed. */
169 case _CS_XBS5_ILP32_OFF32_LIBS:
170 case _CS_XBS5_ILP32_OFF32_LINTFLAGS:
171 case _CS_XBS5_ILP32_OFFBIG_LIBS:
172 case _CS_XBS5_ILP32_OFFBIG_LINTFLAGS:
173 case _CS_XBS5_LP64_OFF64_LIBS:
174 case _CS_XBS5_LP64_OFF64_LINTFLAGS:
175 case _CS_XBS5_LPBIG_OFFBIG_CFLAGS:
176 case _CS_XBS5_LPBIG_OFFBIG_LDFLAGS:
177 case _CS_XBS5_LPBIG_OFFBIG_LIBS:
178 case _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS:
180 case _CS_POSIX_V6_ILP32_OFF32_LIBS:
181 case _CS_POSIX_V6_ILP32_OFF32_LINTFLAGS:
182 case _CS_POSIX_V6_ILP32_OFFBIG_LIBS:
183 case _CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS:
184 case _CS_POSIX_V6_LP64_OFF64_LIBS:
185 case _CS_POSIX_V6_LP64_OFF64_LINTFLAGS:
186 case _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS:
187 case _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS:
188 case _CS_POSIX_V6_LPBIG_OFFBIG_LIBS:
189 case _CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS:
191 case _CS_POSIX_V7_ILP32_OFF32_LIBS:
192 case _CS_POSIX_V7_ILP32_OFF32_LINTFLAGS:
193 case _CS_POSIX_V7_ILP32_OFFBIG_LIBS:
194 case _CS_POSIX_V7_ILP32_OFFBIG_LINTFLAGS:
195 case _CS_POSIX_V7_LP64_OFF64_LIBS:
196 case _CS_POSIX_V7_LP64_OFF64_LINTFLAGS:
197 case _CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS:
198 case _CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS:
199 case _CS_POSIX_V7_LPBIG_OFFBIG_LIBS:
200 case _CS_POSIX_V7_LPBIG_OFFBIG_LINTFLAGS:
201 /* GNU libc does not require special actions to use LFS functions. */
204 case _CS_GNU_LIBC_VERSION:
205 string = "glibc " VERSION;
206 string_len = sizeof ("glibc " VERSION);
209 case _CS_GNU_LIBPTHREAD_VERSION:
210 #ifdef LIBPTHREAD_VERSION
211 string = LIBPTHREAD_VERSION;
212 string_len = sizeof LIBPTHREAD_VERSION;
215 /* No thread library. */
216 __set_errno (EINVAL);
221 __set_errno (EINVAL);
225 if (len > 0 && buf != NULL)
227 if (string_len <= len)
228 memcpy (buf, string, string_len);
231 memcpy (buf, string, len - 1);
237 libc_hidden_def (confstr)