Do the Windows oldnames workaround through the C++ GNULIB_NAMESPACE.
[gnulib.git] / lib / sys_random.in.h
bloba8469cf5cc81bf1c4b473b4dca64a5511c653437
1 /* Substitute for <sys/random.h>.
2 Copyright (C) 2020 Free Software Foundation, Inc.
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2, or (at your option)
7 any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, see <https://www.gnu.org/licenses/>. */
17 # if __GNUC__ >= 3
18 @PRAGMA_SYSTEM_HEADER@
19 # endif
20 @PRAGMA_COLUMNS@
22 #ifndef _@GUARD_PREFIX@_SYS_RANDOM_H
24 #if @HAVE_SYS_RANDOM_H@
26 /* On uClibc, <sys/random.h> assumes prior inclusion of <stddef.h>. */
27 # if defined __UCLIBC__
28 # include <stddef.h>
29 # endif
30 /* On Mac OS X 10.5, <sys/random.h> assumes prior inclusion of <sys/types.h>.
31 On Max OS X 10.13, <sys/random.h> assumes prior inclusion of a file that
32 includes <Availability.h>, such as <stdlib.h> or <unistd.h>. */
33 # if defined __APPLE__ && defined __MACH__ /* Mac OS X */
34 # include <sys/types.h>
35 # include <stdlib.h>
36 # endif
38 /* The include_next requires a split double-inclusion guard. */
39 # @INCLUDE_NEXT@ @NEXT_SYS_RANDOM_H@
41 #endif
43 #ifndef _@GUARD_PREFIX@_SYS_RANDOM_H
44 #define _@GUARD_PREFIX@_SYS_RANDOM_H
46 #include <sys/types.h>
48 /* Define the GRND_* constants. */
49 #ifndef GRND_NONBLOCK
50 # define GRND_NONBLOCK 1
51 # define GRND_RANDOM 2
52 #endif
54 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
56 /* The definition of _GL_ARG_NONNULL is copied here. */
58 /* The definition of _GL_WARN_ON_USE is copied here. */
61 /* Declare overridden functions. */
64 #if @GNULIB_GETRANDOM@
65 /* Fill a buffer with random bytes. */
66 # if @REPLACE_GETRANDOM@
67 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
68 # undef getrandom
69 # define getrandom rpl_getrandom
70 # endif
71 _GL_FUNCDECL_RPL (getrandom, ssize_t,
72 (void *buffer, size_t length, unsigned int flags)
73 _GL_ARG_NONNULL ((1)));
74 _GL_CXXALIAS_RPL (getrandom, ssize_t,
75 (void *buffer, size_t length, unsigned int flags));
76 # else
77 # if !@HAVE_GETRANDOM@
78 _GL_FUNCDECL_SYS (getrandom, ssize_t,
79 (void *buffer, size_t length, unsigned int flags)
80 _GL_ARG_NONNULL ((1)));
81 # endif
82 _GL_CXXALIAS_SYS (getrandom, ssize_t,
83 (void *buffer, size_t length, unsigned int flags));
84 # endif
85 _GL_CXXALIASWARN (getrandom);
86 #elif defined GNULIB_POSIXCHECK
87 # undef getrandom
88 # if HAVE_RAW_DECL_GETRANDOM
89 _GL_WARN_ON_USE (getrandom, "getrandom is unportable - "
90 "use gnulib module getrandom for portability");
91 # endif
92 #endif
95 #endif /* _@GUARD_PREFIX@_SYS_RANDOM_H */
96 #endif /* _@GUARD_PREFIX@_SYS_RANDOM_H */