<div dir="ltr">+1<br><div><br></div><div>From a POSIX perspective, I think Eshan's modifications make it more correct for RTEMS but his patch and test are out of sync with master so there needs to be resolution to move this forward.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Aug 12, 2020 at 2:07 PM Gedare Bloom <<a href="mailto:gedare@rtems.org">gedare@rtems.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Chris, Christian, Sebastian:<br>
<br>
I think it would be best if one of you may have insight on this touching libbsd.<br>
<br>
On Wed, Aug 12, 2020 at 11:13 AM Joel Sherrill <<a href="mailto:joel@rtems.org" target="_blank">joel@rtems.org</a>> wrote:<br>
><br>
><br>
> It appears that confstr is already added (with no ifdefs on RTEMS) to libbsd. We discussed that some of these cases make no sense for RTEMS and should just return the UPE (unsupported programming environment" string. We also do not have a "standard path" so shouldn't return one.<br>
><br>
> But the second patch with a test is not merged. And is not in sync with what is in confstr.c right now. There is also a spelling error.<br>
><br>
> Can someone please comment on whether the unmodified BSD version of this is what we want or whether Eshan should update his patch against 6-freebsd-12 to disable the cases that don't make sense.<br>
><br>
> Either way, we will need a new round of tests.<br>
><br>
> --joel<br>
><br>
><br>
> On Mon, Jul 13, 2020 at 1:10 PM Eshan dhawan <<a href="mailto:eshandhawan51@gmail.com" target="_blank">eshandhawan51@gmail.com</a>> wrote:<br>
>><br>
>> File added to LIBBSD<br>
>><br>
>> Closes #3373<br>
>> Signed-off-by: Eshan dhawan <<a href="mailto:eshandhawan51@gmail.com" target="_blank">eshandhawan51@gmail.com</a>><br>
>> ---<br>
>> freebsd/lib/libc/gen/confstr.c | 127 +++++++++++++++++++++++++++++++++<br>
>> libbsd.py | 1 +<br>
>> 2 files changed, 128 insertions(+)<br>
>> create mode 100644 freebsd/lib/libc/gen/confstr.c<br>
>><br>
>> diff --git a/freebsd/lib/libc/gen/confstr.c b/freebsd/lib/libc/gen/confstr.c<br>
>> new file mode 100644<br>
>> index 00000000..653f581b<br>
>> --- /dev/null<br>
>> +++ b/freebsd/lib/libc/gen/confstr.c<br>
>> @@ -0,0 +1,127 @@<br>
>> +/*-<br>
>> + * SPDX-License-Identifier: BSD-3-Clause<br>
>> + *<br>
>> + * Copyright (c) 1993<br>
>> + * The Regents of the University of California. All rights reserved.<br>
>> + *<br>
>> + * Redistribution and use in source and binary forms, with or without<br>
>> + * modification, are permitted provided that the following conditions<br>
>> + * are met:<br>
>> + * 1. Redistributions of source code must retain the above copyright<br>
>> + * notice, this list of conditions and the following disclaimer.<br>
>> + * 2. Redistributions in binary form must reproduce the above copyright<br>
>> + * notice, this list of conditions and the following disclaimer in the<br>
>> + * documentation and/or other materials provided with the distribution.<br>
>> + * 3. Neither the name of the University nor the names of its contributors<br>
>> + * may be used to endorse or promote products derived from this software<br>
>> + * without specific prior written permission.<br>
>> + *<br>
>> + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND<br>
>> + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE<br>
>> + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE<br>
>> + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE<br>
>> + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL<br>
>> + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS<br>
>> + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)<br>
>> + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT<br>
>> + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY<br>
>> + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF<br>
>> + * SUCH DAMAGE.<br>
>> + */<br>
>> +<br>
>> +#include <sys/cdefs.h><br>
>> +__SCCSID("@(#)confstr.c 8.1 (Berkeley) 6/4/93");<br>
>> +__FBSDID("$FreeBSD$");<br>
>> +<br>
>> +#include <sys/param.h><br>
>> +<br>
>> +#include <errno.h><br>
>> +#include <limits.h><br>
>> +#include <paths.h><br>
>> +#include <string.h><br>
>> +#include <unistd.h><br>
>> +<br>
>> +<br>
>> +size_t<br>
>> +confstr(int name, char *buf, size_t len)<br>
>> +{<br>
>> + const char *p;<br>
>> + const char UPE[] = "unsupported programming environment";<br>
>> +<br>
>> + switch (name) {<br>
>> +#ifndef __rtems__<br>
>> + case _CS_PATH:<br>
>> + p = _PATH_STDPATH;<br>
>> + goto docopy;<br>
>> +#endif<br>
>> + /*<br>
>> + * POSIX/SUS ``Programming Environments'' stuff<br>
>> + *<br>
>> + * We don't support more than one programming environment<br>
>> + * on any platform (yet), so we just return the empty<br>
>> + * string for the environment we are compiled for,<br>
>> + * and the string "unsupported programming environment"<br>
>> + * for anything else. (The Standard says that if these<br>
>> + * values are used on a system which does not support<br>
>> + * this environment -- determined via sysconf() -- then<br>
>> + * the value we return is unspecified. So, we return<br>
>> + * something which will cause obvious breakage.)<br>
>> + */<br>
>> + case _CS_POSIX_V6_ILP32_OFF32_CFLAGS:<br>
>> + case _CS_POSIX_V6_ILP32_OFF32_LDFLAGS:<br>
>> + case _CS_POSIX_V6_ILP32_OFF32_LIBS:<br>
>> + case _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS:<br>
>> + case _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS:<br>
>> + case _CS_POSIX_V6_LPBIG_OFFBIG_LIBS:<br>
>> + /*<br>
>> + * These two environments are never supported.<br>
>> + */<br>
>> + p = UPE;<br>
>> + goto docopy;<br>
>> +<br>
>> + case _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS:<br>
>> + case _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS:<br>
>> + case _CS_POSIX_V6_ILP32_OFFBIG_LIBS:<br>
>> +#ifndef __rtems__<br>
>> + if (sizeof(long) * CHAR_BIT == 32 &&<br>
>> + sizeof(off_t) > sizeof(long))<br>
>> + p = "";<br>
>> + else<br>
>> +#endif<br>
>> + p = UPE;<br>
>> + goto docopy;<br>
>> +<br>
>> + case _CS_POSIX_V6_LP64_OFF64_CFLAGS:<br>
>> + case _CS_POSIX_V6_LP64_OFF64_LDFLAGS:<br>
>> + case _CS_POSIX_V6_LP64_OFF64_LIBS:<br>
>> +#ifndef __rtems__<br>
>> + if (sizeof(long) * CHAR_BIT >= 64 &&<br>
>> + sizeof(void *) * CHAR_BIT >= 64 &&<br>
>> + sizeof(int) * CHAR_BIT >= 32 &&<br>
>> + sizeof(off_t) >= sizeof(long))<br>
>> + p = "";<br>
>> + else<br>
>> +#endif<br>
>> + p = UPE;<br>
>> + goto docopy;<br>
>> +#ifndef __rtems__<br>
>> + case _CS_POSIX_V6_WIDTH_RESTRICTED_ENVS:<br>
>> + /* XXX - should have more complete coverage */<br>
>> + if (sizeof(long) * CHAR_BIT >= 64)<br>
>> + p = "_POSIX_V6_LP64_OFF64";<br>
>> + else<br>
>> + p = "_POSIX_V6_ILP32_OFFBIG";<br>
>> + goto docopy;<br>
>> +#endif<br>
>> +<br>
>> +docopy:<br>
>> + if (len != 0 && buf != NULL)<br>
>> + strlcpy(buf, p, len);<br>
>> + return (strlen(p) + 1);<br>
>> +<br>
>> + default:<br>
>> + errno = EINVAL;<br>
>> + return (0);<br>
>> + }<br>
>> + /* NOTREACHED */<br>
>> +}<br>
>> diff --git a/libbsd.py b/libbsd.py<br>
>> index 812674a6..9beba660 100644<br>
>> --- a/libbsd.py<br>
>> +++ b/libbsd.py<br>
>> @@ -2952,6 +2952,7 @@ class user_space(builder.Module):<br>
>> 'lib/libc/gen/getdomainname.c',<br>
>> 'lib/libc/gen/gethostname.c',<br>
>> 'lib/libc/gen/sethostname.c',<br>
>> + 'lib/libc/gen/confstr.c',<br>
>> 'lib/libc/inet/inet_addr.c',<br>
>> 'lib/libc/inet/inet_cidr_ntop.c',<br>
>> 'lib/libc/inet/inet_cidr_pton.c',<br>
>> --<br>
>> 2.17.1<br>
>><br>
</blockquote></div>