From 1570432db3ccdade41067bf891364239355bd852 Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Mon, 11 Jun 2007 17:38:27 +0000 Subject: [PATCH] * cygwin.din (confstr): Export. * posix.sgml (confstr): Move to list of implemented SUSv3 functions. * sysconf.cc (confstr): Implement. * include/cygwin/version.h: Bump API minor number. --- winsup/cygwin/ChangeLog | 7 ++++ winsup/cygwin/cygwin.din | 1 + winsup/cygwin/include/cygwin/version.h | 3 +- winsup/cygwin/posix.sgml | 2 +- winsup/cygwin/sysconf.cc | 48 ++++++++++++++++++++++++++ 5 files changed, 59 insertions(+), 2 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 6dd0e0249..f974f7959 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,10 @@ +2007-06-11 Corinna Vinschen + + * cygwin.din (confstr): Export. + * posix.sgml (confstr): Move to list of implemented SUSv3 functions. + * sysconf.cc (confstr): Implement. + * include/cygwin/version.h: Bump API minor number. + 2007-06-05 Corinna Vinschen * ansi.sgml: Delete. diff --git a/winsup/cygwin/cygwin.din b/winsup/cygwin/cygwin.din index eb982f7be..2e64d2b6f 100644 --- a/winsup/cygwin/cygwin.din +++ b/winsup/cygwin/cygwin.din @@ -195,6 +195,7 @@ _close = close SIGFE closedir SIGFE _closedir = closedir SIGFE closelog SIGFE +confstr SIGFE connect = cygwin_connect SIGFE copysign NOSIGFE _copysign = copysign NOSIGFE diff --git a/winsup/cygwin/include/cygwin/version.h b/winsup/cygwin/include/cygwin/version.h index bbee7428e..49ad569ca 100644 --- a/winsup/cygwin/include/cygwin/version.h +++ b/winsup/cygwin/include/cygwin/version.h @@ -308,12 +308,13 @@ details. */ 166: Export sem_unlink. 167: Add st_birthtim to struct stat. 168: Export asnprintf, dprintf, _Exit, vasnprintf, vdprintf. + 169: Export confstr. */ /* Note that we forgot to bump the api for ualarm, strtoll, strtoull */ #define CYGWIN_VERSION_API_MAJOR 0 -#define CYGWIN_VERSION_API_MINOR 168 +#define CYGWIN_VERSION_API_MINOR 169 /* There is also a compatibity version number associated with the shared memory regions. It is incremented when incompatible diff --git a/winsup/cygwin/posix.sgml b/winsup/cygwin/posix.sgml index 5e9a60bbc..d236989f3 100644 --- a/winsup/cygwin/posix.sgml +++ b/winsup/cygwin/posix.sgml @@ -75,6 +75,7 @@ also ISO/IEC 9945:2003 and IEEE Std 1003.1-2001 (POSIX.1-2001). close closedir closelog + confstr connect copysign copysignf @@ -1070,7 +1071,6 @@ also ISO/IEC 9945:2003 and IEEE Std 1003.1-2001 (POSIX.1-2001). clog clogf clogl - confstr conj conjf conjl diff --git a/winsup/cygwin/sysconf.cc b/winsup/cygwin/sysconf.cc index 64f5bfaa1..dddf2c362 100644 --- a/winsup/cygwin/sysconf.cc +++ b/winsup/cygwin/sysconf.cc @@ -248,3 +248,51 @@ sysconf (int in) set_errno (EINVAL); return -1L; } + +#define ls(s) sizeof(s),s + +static struct +{ + size_t l; + const char *s; +} csa[] = +{ + {ls ("/bin:/usr/bin")}, /* _CS_PATH */ + {0, NULL}, /* _CS_POSIX_V6_ILP32_OFF32_CFLAGS */ + {0, NULL}, /* _CS_POSIX_V6_ILP32_OFF32_LDFLAGS */ + {0, NULL}, /* _CS_POSIX_V6_ILP32_OFF32_LIBS */ + {0, NULL}, /* _CS_POSIX_V6_ILP32_OFF32_LINTFLAGS */ + {ls ("")}, /* _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS */ + {ls ("")}, /* _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS */ + {ls ("")}, /* _CS_POSIX_V6_ILP32_OFFBIG_LIBS */ + {ls ("")}, /* _CS_XBS5_ILP32_OFFBIG_LINTFLAGS */ + {0, NULL}, /* _CS_POSIX_V6_LP64_OFF64_CFLAGS */ + {0, NULL}, /* _CS_POSIX_V6_LP64_OFF64_LDFLAGS */ + {0, NULL}, /* _CS_POSIX_V6_LP64_OFF64_LIBS */ + {0, NULL}, /* _CS_XBS5_LP64_OFF64_LINTFLAGS */ + {0, NULL}, /* _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS */ + {0, NULL}, /* _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS */ + {0, NULL}, /* _CS_POSIX_V6_LPBIG_OFFBIG_LIBS */ + {0, NULL}, /* _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS */ + {ls ("POSIX_V6_ILP32_OFFBIG")}, /* _CS_POSIX_V6_WIDTH_RESTRICTED_ENVS */ +}; + +#define CS_MIN _CS_PATH +#define CS_MAX _CS_POSIX_V6_WIDTH_RESTRICTED_ENVS + +extern "C" size_t +confstr (int in, char *buf, size_t len) +{ + if (in >= CS_MIN && in <= CS_MAX) + { + if (csa[in].l && len) + { + buf[0] = 0; + strncat (buf, csa[in].s, min (len, csa[in].l) - 1); + } + return csa[in].l; + } + /* Invalid option value. */ + set_errno (EINVAL); + return 0; +} -- 2.43.5