Aymeric Vincent | 11 Nov 12:25 2014

compiler_rt missing support for 80-bit floats?


while trying to compile libuhd on NetBSD, I stumbled upon an undefined
reference to __trunctfxf2 at link time of the first example program.

This function truncates a 128bit float to 80 bits. Digging around, I
found out that we have three implementations of the softfloat emulation
in the tree. The one given with gcc is not used.

This leaves us with src/lib/libc/softfloat which seems to lack the alias
required for this function. I enclose a patch which adds it there but I
don't know if it's still used on any platform, probably depends on the
gcc version being used. It's clearly not used on amd64, even on the
netbsd-7 branch.

So, the implementation we currently use is provided by compiler_rt in
src/sys/external/bsd/compiler_rt/dist/lib/builtins but also lacks the
implementation of this function.

Could someone with experience on floating point and/or compiler_rt
please tell if it's a simple matter of adding the 80-bit case to
fp_trunc_impl.inc and add stub C files, or if there is a deeper reason
for dropping 80bit support?


(the following patch is for reference only if someone else is interested
 for another platform/gcc combination, I couldn't test it)
(Continue reading)

Aymeric Vincent | 11 Nov 12:00 2014

login(1) vs "dialout ttys"


while looking at usr.bin/login/login.c, I noticed the following strange

	if (tty[sizeof("tty")-1] == 'd')
		syslog(LOG_INFO, "DIALUP %s, %s", tty, pwd->pw_name);

The intent seems obvious (if the name contains a 'd' in a position which
would agree with "ttyd", syslog that we have a dialup login) but it
seems to be a sloppy test which is furthermore incoherent with the
current naming of our devices.  (It can't currently lead to an out of
bounds access because ttyname(3) returns a static PATH_MAX-length array)

After a quick look around, ttys(5) mentions ttyd0 as a dialout device in
its examples section, and the MAKEDEV.conf of the vax seems to avoid
ttyd in its enumeration of ttys, but on the other hand quite a handful
of ports use tty[a-d] as usual serial ports and logins on ttyd would
spam syslog uselessly.

Out of curiosity, I'm also interested to know if /dev/dtyxx is the new
incarnation of /dev/ttydxx or if they serve different purposes.

Also, checking with cvs annotate dug up a very old PR which induced the
removal of the test but the test was added back a few months later as a
merge of 4.4lite.


(Continue reading)

Masao Uebayashi | 7 Nov 05:15 2014

Macro to define absolute symbol

I want to define absolute symbols in ELF files, using as(1) '.equiv' directive,
as done in _KERNEL_OPT_* symbols in kernel build.  Could anyone look and
complete this, including the !__STDC__ part and cdefs_aout.h?

My use-case is to define COHERENCY_UNIT for linker script.

Index: sys/sys/cdefs_elf.h
RCS file: /cvsroot/src/sys/sys/cdefs_elf.h,v
retrieving revision 1.46
diff -p -u -r1.46 cdefs_elf.h
--- sys/sys/cdefs_elf.h	26 Aug 2014 09:03:17 -0000	1.46
+++ sys/sys/cdefs_elf.h	7 Nov 2014 04:06:50 -0000
 <at>  <at>  -130,6 +130,16  <at>  <at> 

+#if __STDC__
+#define	__SYMVAL(sym, val)						\
+	__asm(".globl	" #sym);					\
+	__asm(".equiv	" #sym ", " __STRING(val))
+#define	__SYMVAL(sym, val)						\
+	__asm(".globl	sym");						\
+	__asm(".equiv	sym, " __STRING(val))
 #define	__IDSTRING(_n,_s)		__SECTIONSTRING(.ident,_s)

 #define	__RCSID(_s)			__IDSTRING(rcsid,_s)
(Continue reading)

Marc Balmer | 14 Oct 08:33 2014

Binary packages on NetBSD: Importing pkg(8) from FreeBSD?

[This has also been posted to pkgsrc-users <at> netbsd.org]

FreeBSD has now by default pkg(8) (formerly called pkgng) as the default manager for _binary_ packages.  It
replaces the old pkg_* tools.  pkg(8) is a manager for binary packages _only_; to produce the binary
packages the FreeBSD ports system is used almost unaltered.  pkg(8) has been designed to be a modern binary
package manager that can among other things properly deal with update situations, properly resolve
dependencies and in general allows systems to be managed with binary packages easily.

pkg(8) is not part of the base system, the base system only contains a way to bootstrap pkg(8).  pkg(8) itself
resides in the FreeBSD ports tree.

I think pkg(8) would be a good thing for NetBSD to have, too.  pkg(8) is properly designed and allows for
different binary package formats (at least in theory), so it could probably be feasible to add a pkg(8)
backend that handles binary packages produced using pkgsrc.

afaict, the following steps would be needed:

- Tell the upstream developers about our plans (the pkgsrc backend should become part of the upstream code,
if possible)
- Import the pkg(8) bootstrap mechanism into NetBSD base (src/external).
- Extend pkg(8) to deal with pkgsrc-produced binary packages.
- Import pkg(8) into pkgsrc.
- Coordinate local changes with the upstream developers.

As pkg(8) "only" deals with binary packages, this would be complimentary to the existing pkg_* tools that
come with pkgsrc, i.e. it's use would be optional.

Is anyone besides me interested in such work and would be able/willing to spend some amount of time on this?

- mbalmer
(Continue reading)

Edward Tomasz Napierała | 30 Sep 13:19 2014

Re: FreeBSD got a new automounter

Just FYI, I'll happily help you with porting the automounter.  Userland
part should be trivial; I don't think it contains any system-specific
code, apart from autofs ioctls.  The kernel part is not complicated either,
but will need someone who knows NetBSD VFS.

Steffen Nurpmeso | 29 Sep 15:05 2014

snprintf(3) behaviour regarding large "n"

Hello NetBSD,

i recently had a hard time because NetBSD was the only operating
system that fails to pass the testsuite (S/MIME function
verification, and only this test!) of the S-nail mailer
i maintain.

Short: the problem is that i use snprintf(3) with a "size_t n"
argument of UI32_MAX (is EQ to UINT32_MAX).
Well, looking at POSIX this is even somewhat correct (but then it
should be EOVERFLOW for conformance), but it is (a) neither
documented in the manual nor (b) would a halfway sane person do it
like that -- :) --, though i'd agree that i should have used
SIZE_MAX to indicate what i had in mind ("buffer _is_ large
enough"), not at last because there is an error defined for when
_the return value_ would exceed INT_MAX (also EOVERFLOW).

The patch has not been compile tested (regarding availability of
INT_MAX), sorry (very small resources here).

James K. Lowden | 19 Sep 21:38 2014

fcntl & cmsg

unix(4) contains an "interesting" sentence:

	     "The received descriptor is a duplicate of the sender's
descriptor, as if it were created with a call to dup(2).  Per-process
descriptor flags, set with fcntl(2), are not passed to a receiver."

because fcntl(2) doesn't define "per-process" descriptor flags.  Does
the sentence mean "any flag set with fcntl", or are some flags
per-process?  If the latter, is the reader supposed to be able to
determine which flags are per-process from the context?  

McKusick distinguishes between a "file entry" describing an open file,
and a descriptor, which is an index into an array of references to file
entries.  The descriptor array -- and hence each descriptor -- is
unique to each process, whereas many references to the file entry may
be created by fork() and dup(), and via unix domain sockets.  

But fcntl(2) says it "provides for control over descriptors" when in
fact sometimes it updates or interrogates the file entry.  Examples
include F_SETLK and (afaict) F_SETOWN.  fcntl(2) does mention "flags
associated with the file descriptor", which I'm willing to believe are
"per-process".   They are:

*  the close-on-exec flag via F_SETFD
*  the O_NONBLOCK, O_APPEND, and O_ASYNC flags via F_SETFL

(Can anyone explain why close-on-exec isn't just another option for
F_SETFL?  I see that dup(2) preserves the F_SETFL flags but not
close-on-exec. Interesting choice....)

(Continue reading)

Jens Mehler | 18 Sep 14:05 2014

Cross building NetBSD userland

Hi Folks I hope this is the correct list.

After resolving several issues with my GCC port and finally being able
to build the kernel as intended I started porting the userland for the
Eco32 processor.

I use the following commands
                export MKGCCMDS=no
                export MKBINUTILS=no
                export MKGDB=no
                export MKSTATICLIB=yes
                ./build.sh -T ./obj/tooldir -u -U -m eco32 release

The build starts and finally ends with:
obj ===> lib
obj ===> lib/csu
obj ===> lib/../external/gpl3/gcc/lib/libgcc
obj ===> lib/../external/gpl3/gcc/lib/libgcc/libgcc
nbmake: "/hdd/home/okarin/eco32/netbsd/usr/src/share/mk/bsd.files.mk"
line 110: Wrong number of words (1) in .for substitution list with 2 vars
nbmake: Fatal errors encountered -- cannot continue
nbmake: stopped in

I wonder what I am missing.
Is there some kind of guide to get the userland compiled for the first
time ?

With best regards,
(Continue reading)

Emmanuel Dreyfus | 15 Sep 06:35 2014

strtoll question


Consider the program below and its output. Am I using strtoll() wrongly,
or is this a bug? (this is netbsd-7 branch)

$ cat /tmp/x.c
#include <stdio.h>
#include <errno.h>
#include <sys/types.h>

        const char *ptr = "999999999999999";
        char *endp;
        long long int res;

        errno = 0;
        res = strtoll(ptr, &endp, 0);
        printf("errno = %d\n", errno);
        printf("*endp = 0x%02x\n", *endp);
        printf("str %s\n", ptr);
        printf("num %lld\n", res);

        return 0;

$ cc -o /tmp/x /tmp/x.c 
$ /tmp/x
errno = 0
(Continue reading)

Thomas Klausner | 23 Aug 22:22 2014

FreeBSD got a new automounter

Something to borrow?


Emmanuel Dreyfus | 22 Aug 11:59 2014

check memory mapping


Is there a way for a process to check whether a given address in mmeory 
is accessible, without triggering a signal?

There is mincore(), but it jus says wether it is already in resident
memory, not if accessing the address will swap it in or cause a SIGSEGV.


Emmanuel Dreyfus
manu <at> netbsd.org