Date: Sat, 28 Jul 2018 13:16:45 -0700 From: Conrad Meyer <cem@freebsd.org> To: Konstantin Belousov <kostikbel@gmail.com> Cc: src-committers <src-committers@freebsd.org>, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r336835 - head/lib/libc/gen Message-ID: <CAG6CVpVEhyutDe7DL7ECVbKi=JpbD%2BAD8d633=eLX6-VbD4i9g@mail.gmail.com> In-Reply-To: <20180728200611.GA40119@kib.kiev.ua> References: <201807281908.w6SJ80qo089859@repo.freebsd.org> <20180728200611.GA40119@kib.kiev.ua>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sat, Jul 28, 2018 at 1:06 PM, Konstantin Belousov <kostikbel@gmail.com> wrote: > On Sat, Jul 28, 2018 at 07:08:00PM +0000, Conrad Meyer wrote: >> For unclear reasons, POSIX' definition of these routines spells NULL a= s >> "(char *)0." This is needlessly unclear. One guess might be that POS= IX >> targets more exotic computer architectures than FreeBSD does. Fortuna= tely, >> there is no such problem on any reasonable platform for FreeBSD to sup= port. >> Spell NULL as NULL. > > The reasons are quite clear. Unclear here refers to the lack of documentation, not the absense of a possible explanation. > Practically NULL has to be defined as '0' > or '0L' at best, for C and esp. C++ rules of the pointers automatic > casts to work. This means that NULL cannot be used in vararg lists where > the pointer is expected. This is not true on FreeBSD. NULL is (void*)0 in all C code, and the special nullptr value in C++. Yes, this is a stronger definition than the C standard guarantees. This is because the C standard permits much more exotic architectures than FreeBSD actually runs on. > In other words, the (char *)0 part of the pre-commit text was correct, > while after-commit use of NULL only works on machines where pointers > have the same representation as ints or longs. I believe this encompasses all architectures FreeBSD supports =E2=80=94 eve= n ignoring our sys/_null.h definition of NULL as (void *)0 or nullptr. Best, Conrad
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAG6CVpVEhyutDe7DL7ECVbKi=JpbD%2BAD8d633=eLX6-VbD4i9g>