clean-temp: Document limitations.
[gnulib.git] / lib / sys_random.in.h
blob290fa3938e6803dae62e7b429f33e129bf12e60e
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 Mac OS X 10.5, <sys/random.h> assumes prior inclusion of <sys/types.h>.
27 On Max OS X 10.13, <sys/random.h> assumes prior inclusion of a file that
28 includes <Availability.h>, such as <stdlib.h> or <unistd.h>. */
29 # if defined __APPLE__ && defined __MACH__ /* Mac OS X */
30 # include <sys/types.h>
31 # include <stdlib.h>
32 # endif
34 /* The include_next requires a split double-inclusion guard. */
35 # @INCLUDE_NEXT@ @NEXT_SYS_RANDOM_H@
37 #endif
39 #ifndef _@GUARD_PREFIX@_SYS_RANDOM_H
40 #define _@GUARD_PREFIX@_SYS_RANDOM_H
42 #include <sys/types.h>
44 /* Define the GRND_* constants. */
45 #ifndef GRND_NONBLOCK
46 # define GRND_NONBLOCK 1
47 # define GRND_RANDOM 2
48 #endif
50 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
52 /* The definition of _GL_ARG_NONNULL is copied here. */
54 /* The definition of _GL_WARN_ON_USE is copied here. */
57 /* Declare overridden functions. */
60 #if @GNULIB_GETRANDOM@
61 /* Fill a buffer with random bytes. */
62 # if @REPLACE_GETRANDOM@
63 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
64 # undef getrandom
65 # define getrandom rpl_getrandom
66 # endif
67 _GL_FUNCDECL_RPL (getrandom, ssize_t,
68 (void *buffer, size_t length, unsigned int flags)
69 _GL_ARG_NONNULL ((1)));
70 _GL_CXXALIAS_RPL (getrandom, ssize_t,
71 (void *buffer, size_t length, unsigned int flags));
72 # else
73 # if !@HAVE_GETRANDOM@
74 _GL_FUNCDECL_SYS (getrandom, ssize_t,
75 (void *buffer, size_t length, unsigned int flags)
76 _GL_ARG_NONNULL ((1)));
77 # endif
78 _GL_CXXALIAS_SYS (getrandom, ssize_t,
79 (void *buffer, size_t length, unsigned int flags));
80 # endif
81 _GL_CXXALIASWARN (getrandom);
82 #elif defined GNULIB_POSIXCHECK
83 # undef getrandom
84 # if HAVE_RAW_DECL_GETRANDOM
85 _GL_WARN_ON_USE (getrandom, "getrandom is unportable - "
86 "use gnulib module getrandom for portability");
87 # endif
88 #endif
91 #endif /* _@GUARD_PREFIX@_SYS_RANDOM_H */
92 #endif /* _@GUARD_PREFIX@_SYS_RANDOM_H */