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