diff options
author | Calvin <calvin@cmpct.info> | 2018-06-07 14:34:27 +0300 |
---|---|---|
committer | Jan Vorlicek <janvorli@microsoft.com> | 2018-06-07 14:34:27 +0300 |
commit | e5449ef453c71aa4918d18f6635b870d8bbd3cae (patch) | |
tree | 9338f0085cae140a7bf17b2d44173b923f4c8957 /src/libraries/Native/Unix/System.Native/pal_random.c | |
parent | d99f09a3c9c4752dbabe4333b94b8ecab62704bd (diff) |
AIX support for System.Native/PAL (dotnet/corefx#30012)
* AIX support for System.Native/PAL
Somewhat incomplete, but at least on Mono version, gets it compiling,
so work on it can be done; as I believe the nopped out functions aren't
hooked up to Mono's BCL yet. For now, if merged, would let me get back
to working on a patch for UnicodeEncoding ;)
See mono/corefxdotnet/corefx#69 for the description.
This is for Mono, as CoreCLR doesn't run under AIX or i.
* make some of the suggested changes
* fix networking.c, defines in io
* fix errenous define, stupid me
* Forgot to include where AIX deviates from the rest of the world on poll
* Handle F_DUPFD_CLOEXEC properly
* fix possible bug there; be defensive; and explain why
* Don't make AIX change the PAL_POLL* values
These need to be the same on all platforms. Currently, it seems
that pal_io.c doesn't actually use these values (yet?) so I've
disabled the check there. pal_console is the only consumer of a
definition there, but it's not built for Mono and thus AIX yet, so
I haven't touched it.
Useful dump of AIX poll values:
POLLIN = 0x0001, /* non-urgent readable data available */
POLLPRI = 0x0004, /* urgent readable data available */
POLLOUT = 0x0002, /* data can be written without blocked */
POLLERR = 0x4000, /* an error occurred */
POLLHUP = 0x2000, /* the file descriptor hung up */
POLLNVAL = 0x8000, /* the requested events were invalid */
And of finding the users of these definitions within the directory
"srcNative/Unix/System.Native":
$ grep -R POLL | grep -v EPOLL
pal_console.cpp: struct pollfd fd = { .fd = STDIN_FILENO, .events = POLLIN };
pal_io.c:// HACK: AIX values are different; this file doesn't actually use POLL* yet, so
pal_io.c:c_static_assert(PAL_POLLIN == POLLIN);
pal_io.c:c_static_assert(PAL_POLLPRI == POLLPRI);
pal_io.c:c_static_assert(PAL_POLLOUT == POLLOUT);
pal_io.c:c_static_assert(PAL_POLLERR == POLLERR);
pal_io.c:c_static_assert(PAL_POLLHUP == POLLHUP);
pal_io.c:c_static_assert(PAL_POLLNVAL == POLLNVAL);
pal_io.h: PAL_POLLIN = 0x0001, /* non-urgent readable data available */
pal_io.h: PAL_POLLPRI = 0x0002, /* urgent readable data available */
pal_io.h: PAL_POLLOUT = 0x0004, /* data can be written without blocked */
pal_io.h: PAL_POLLERR = 0x0008, /* an error occurred */
pal_io.h: PAL_POLLHUP = 0x0010, /* the file descriptor hung up */
pal_io.h: PAL_POLLNVAL = 0x0020, /* the requested events were invalid */
* We actually /do/ need to translate PollEvents after all
stupid me, I didn't notice
* fix ConvertDirent's fallback case to use proper if brace style
* don't make it a TODO as this requires more work later; consistent ifdef
* Initial attempt at CMake detection for things
* Add the CMake checks to pal_config too
* remove my stupid typo
* consistent ifdef/if
* check for poll function
the #else case on pal_networking hasn't changed because it's a stub
for now. when it becomes a real boy someday, it'll get an #elif for
`HAVE_POLL`.
* change func check to incl check for poll; mono does this too
Commit migrated from https://github.com/dotnet/corefx/commit/eedd1c2784fd1c597428187985df00567bc00f86
Diffstat (limited to 'src/libraries/Native/Unix/System.Native/pal_random.c')
-rw-r--r-- | src/libraries/Native/Unix/System.Native/pal_random.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/libraries/Native/Unix/System.Native/pal_random.c b/src/libraries/Native/Unix/System.Native/pal_random.c index a46896e8771..979df55000e 100644 --- a/src/libraries/Native/Unix/System.Native/pal_random.c +++ b/src/libraries/Native/Unix/System.Native/pal_random.c @@ -40,7 +40,12 @@ void SystemNative_GetNonCryptographicallySecureRandomBytes(uint8_t* buffer, int3 do { +#if HAVE_O_CLOEXEC fd = open("/dev/urandom", O_RDONLY, O_CLOEXEC); +#else + fd = open("/dev/urandom", O_RDONLY); + fcntl(fd, F_SETFD, FD_CLOEXEC); +#endif } while ((fd == -1) && (errno == EINTR)); |