This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: getentropy for <unistd.h>


On 12/28/2016 06:02 PM, Zack Weinberg wrote:
On Wed, Dec 28, 2016 at 1:50 AM, Florian Weimer <fweimer@redhat.com> wrote:
It's not in 4.3BSD either, and if __USE_MISC is intended to be restricted to
those definitions (or those of similar vintage), then __USE_MISC would not
be correct.

If __USE_MISC is free to involve, pretty much like __USE_GNU, then this is
not a problem.  But it's not clear to me if this is the intent.

It seems to me that the *useful* distinction between __USE_MISC and
__USE_GNU nowadays is: __USE_MISC is for non-standardized features
that are visible by default, __USE_GNU is for non-standardized
features that are only visible when requested with -D_GNU_SOURCE.

So the decision to make when choosing between the two is "should this
be visible by default?" I would personally tend to err on the side of
"no" when adding new things to core headers like unistd.h.

At least we should treat getentropy and explicit_bzero in an identical fashion.

What about this patch?

Florian
getentropy: Declare it in <unistd.h> for __USE_MISC

2016-12-29  Florian Weimer  <fweimer@redhat.com>

	* posix/unistd.h (getentropy): Declare for __USE_MISC, not just
	__USE_GNU.

diff --git a/posix/unistd.h b/posix/unistd.h
index 70b10c6..a8c9aa9 100644
--- a/posix/unistd.h
+++ b/posix/unistd.h
@@ -1157,7 +1157,7 @@ extern int pthread_atfork (void (*__prepare) (void),
 			   void (*__child) (void)) __THROW;
 #endif
 
-#ifdef __USE_GNU
+#ifdef __USE_MISC
 /* Write LENGTH bytes of randomness starting at BUFFER.  Return 0 on
    success or -1 on error.  */
 int getentropy (void *__buffer, size_t __length) __wur;

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]