NetBSD-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: getconf LONG_BIT in NetBSD





On 5/20/24 00:47, Valery Ushakov wrote:
On Sun, May 19, 2024 at 22:08:27 +0200, Ramiro Aceves wrote:

I see that "getconf LONG_BIT" works in other systems such as  Linux and
FreeBSD but in NetBSD I have tried it and it does not work:

netbsd-nuc$ getconf LONG_BIT
getconf: LONG_BIT: unknown variable


I read this on limits (3) man page about LONG_BIT:

    XSI Limits
      Also the X/Open System Interface Extension (XSI) specifies few limits.
In NetBSD these are limited to LONG_BIT (the number of bits in long),
WORD_BIT (the number of bits in a “word”), and few limits related to float
and double.

How can I get the value of the LONG_BIT variable?

Pedantically speaking, LONG_BIT is not a "conf" variable, so the
question is where you draw the line for getconf(1)?  What should be
returned for LONG_BIT on a system that can run both 32-bit and 64-bit
code (amd64/i386, sparc64/sparc, etc).

Thanks UWE for the explanation.
I have a Debian and a FreeBSD installation along with NetBSD in the same computer and both return 64 bits for the LONG_INT variable.


Looking a bit closer at the Open Group text for getconf(1) and
friends, I think they intend this kind of stuff to be onbtained via
POSIX_V7_WIDTH_RESTRICTED_ENVS getconf/confstr() and getconf -v
argument.

https://pubs.opengroup.org/onlinepubs/9699919799/utilities/getconf.html
https://pubs.opengroup.org/onlinepubs/9699919799/utilities/c99.html#tag_20_11_13_04

We don't support getconf -v and it seems a bit clunky and posixy
anyway.  What's wrong with doing it the autoconf way by running the
compiler you are going to use? :)


The configure.ac script that has the "getconf LONG_BIT" belongs to this program:

https://www.sm5bsz.com/linuxdsp/archive/lir05-02.zip

This software works for Windows (MinGW) and Linux. I have been trying to compile it also in FreeBSD and NetBSD. I have had preliminary compiling success in both OS. Once $BITS variable is obtained is used many times to do conditional programing along the script.


AC_PREREQ(2.50)
AC_INIT(xmain.c)
AC_MSG_CHECKING([OS])
AC_CONFIG_FILES([Makefile])
AC_CONFIG_FILES([ft245.c])
BITS=`(getconf LONG_BIT)`  <<<<------------Here
AC_SUBST(BITS)
#setterm -term linux -back white
#setterm -term linux -fore black
OS=`uname`
AC_SUBST(OS, "${OS}")
MACHINE=$(uname -m)
CPU="CPU_INTEL"
if test "$MACHINE" = "armv5l"; then
  CPU="CPU_ARM"
fi
if test "$MACHINE" = "armv6l"; then
  CPU="CPU_ARM"
fi
if test "$MACHINE" = "armv7l"; then
  CPU="CPU_ARM"
fi
if test "$MACHINE" = "aarch64"; then
  CPU="CPU_ARM"
fi
if test "$MACHINE" = "evbarm"; then <<<<<---- Added for NetBSD in the RPi
  CPU="CPU_ARM"
fi
if test "$MACHINE" = "armv8l"; then
...
...
...

Regards.
Ramiro.


-uwe




Home | Main Index | Thread Index | Old Index