aboutsummaryrefslogtreecommitdiff
path: root/lib/libc/gen/confstr.c
diff options
context:
space:
mode:
authorGarrett Wollman <wollman@FreeBSD.org>2002-07-15 22:21:33 +0000
committerGarrett Wollman <wollman@FreeBSD.org>2002-07-15 22:21:33 +0000
commit603a6e79d816d21d57d45f7cb0cc1a2022183d5b (patch)
tree38abef9fc8162894f0df269e919284aeb7c7b573 /lib/libc/gen/confstr.c
parent476d84ff75b53950a57731b1f55ba1226a630a1d (diff)
downloadsrc-603a6e79d816d21d57d45f7cb0cc1a2022183d5b.tar.gz
src-603a6e79d816d21d57d45f7cb0cc1a2022183d5b.zip
Support POSIX/SUS ``programming environment'' mistake in confstr().
Notes
Notes: svn path=/head/; revision=100149
Diffstat (limited to 'lib/libc/gen/confstr.c')
-rw-r--r--lib/libc/gen/confstr.c63
1 files changed, 62 insertions, 1 deletions
diff --git a/lib/libc/gen/confstr.c b/lib/libc/gen/confstr.c
index ad2e5a0959c3..592a3eff2ecf 100644
--- a/lib/libc/gen/confstr.c
+++ b/lib/libc/gen/confstr.c
@@ -40,20 +40,81 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <errno.h>
+#include <limits.h>
#include <paths.h>
-#include <unistd.h>
#include <string.h>
+#include <unistd.h>
+
size_t
confstr(int name, char *buf, size_t len)
{
const char *p;
+ const char UPE[] = "unsupported programming environment";
switch (name) {
case _CS_PATH:
p = _PATH_STDPATH;
goto docopy;
+ /*
+ * POSIX/SUS ``Programming Environments'' stuff
+ *
+ * We don't support more than one programming environment
+ * on any platform (yet), so we just return the empty
+ * string for the environment we are compiled for,
+ * and the string "unsupported programming environment"
+ * for anything else. (The Standard says that if these
+ * values are used on a system which does not support
+ * this environment -- determined via sysconf() -- then
+ * the value we return is unspecified. So, we return
+ * something which will cause obvious breakage.)
+ *
+ * Note that the _V6_LP64_OFF64 is actually an *I*LP64
+ * environment; FreeBSD's LP64 architectures use the
+ * _V6_LPBIG_OFFBIG environment instead.
+ */
+ case _CS_POSIX_V6_ILP32_OFF32_CFLAGS:
+ case _CS_POSIX_V6_ILP32_OFF32_LDFLAGS:
+ case _CS_POSIX_V6_ILP32_OFF32_LIBS:
+ case _CS_POSIX_V6_LP64_OFF64_CFLAGS:
+ case _CS_POSIX_V6_LP64_OFF64_LDFLAGS:
+ case _CS_POSIX_V6_LP64_OFF64_LIBS:
+ /*
+ * These six environments are never supported.
+ */
+ p = UPE;
+ goto docopy;
+
+ case _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS:
+ case _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS:
+ case _CS_POSIX_V6_ILP32_OFFBIG_LIBS:
+ if (sizeof(long) * CHAR_BIT == 32 &&
+ sizeof(off_t) > sizeof(long))
+ p = "";
+ else
+ p = UPE;
+ goto docopy;
+
+ case _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS:
+ case _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS:
+ case _CS_POSIX_V6_LPBIG_OFFBIG_LIBS:
+ if (sizeof(long) * CHAR_BIT >= 64 &&
+ sizeof(void *) * CHAR_BIT >= 64 &&
+ sizeof(int) * CHAR_BIT >= 32 &&
+ sizeof(off_t) >= sizeof(long))
+ p = "";
+ else
+ p = UPE;
+ goto docopy;
+
+ case _CS_POSIX_V6_WIDTH_RESTRICTED_ENVS:
+ if (sizeof(long) * CHAR_BIT >= 64)
+ p = "_V6_LPBIG_OFFBIG";
+ else
+ p = "_V6_ILP32_OFFBIG";
+ goto docopy;
+
docopy:
if (len != 0 && buf != NULL)
strlcpy(buf, p, len);