Andrew Eggenberger, le mar. 29 oct. 2019 00:30:17 -0500, a ecrit: > Here's a really quick implementation just to get some feedback.
That's already a beginning. The implementation shouldn't go in the platform-generic stdlib/ files, but in sysdeps/mach/hurd/ > @@ -24,8 +24,11 @@ > int > getentropy (void *buffer, size_t length) > { > - __set_errno (ENOSYS); > - return -1; > + size_t bytes_read; > + bytes_read = getrandom(buffer, length, 0); > + if (bytes_read != length){ Getrandom is allowed not to return the proper length. Getentropy should have a loop around it. The ./sysdeps/unix/sysv/linux/getentropy.c version might actually be used as such. > ssize_t > getrandom (void *buffer, size_t length, unsigned int flags) > { > - __set_errno (ENOSYS); > - return -1; > -} > + FILE * random_source; > + if (flags & GRND_RANDOM){ > + random_source = fopen("/dev/random", "r"); > + return fread(buffer, 1, length, random_source); Rather use open/read, there is no need for buffering. Also remember to close it. You can factorize the open/read/close calls by only setting a char* variable in the if. Samuel