• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright (c) 2020, Google Inc.
2  *
3  * Permission to use, copy, modify, and/or distribute this software for any
4  * purpose with or without fee is hereby granted, provided that the above
5  * copyright notice and this permission notice appear in all copies.
6  *
7  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
10  * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
12  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
13  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
14 
15 #ifndef OPENSSL_HEADER_CRYPTO_RAND_GETRANDOM_FILLIN_H
16 #define OPENSSL_HEADER_CRYPTO_RAND_GETRANDOM_FILLIN_H
17 
18 #include <openssl/base.h>
19 
20 
21 #if defined(OPENSSL_LINUX)
22 
23 #include <sys/syscall.h>
24 
25 #if defined(OPENSSL_X86_64)
26 #define EXPECTED_NR_getrandom 318
27 #elif defined(OPENSSL_X86)
28 #define EXPECTED_NR_getrandom 355
29 #elif defined(OPENSSL_AARCH64)
30 #define EXPECTED_NR_getrandom 278
31 #elif defined(OPENSSL_ARM)
32 #define EXPECTED_NR_getrandom 384
33 #elif defined(OPENSSL_PPC64LE)
34 #define EXPECTED_NR_getrandom 359
35 #endif
36 
37 #if defined(EXPECTED_NR_getrandom)
38 #define USE_NR_getrandom
39 
40 #if defined(__NR_getrandom)
41 
42 #if __NR_getrandom != EXPECTED_NR_getrandom
43 #error "system call number for getrandom is not the expected value"
44 #endif
45 
46 #else  // __NR_getrandom
47 
48 #define __NR_getrandom EXPECTED_NR_getrandom
49 
50 #endif  // __NR_getrandom
51 
52 #endif  // EXPECTED_NR_getrandom
53 
54 #if !defined(GRND_NONBLOCK)
55 #define GRND_NONBLOCK 1
56 #endif
57 #if !defined(GRND_RANDOM)
58 #define GRND_RANDOM 2
59 #endif
60 
61 #endif  // OPENSSL_LINUX
62 
63 
64 #endif  // OPENSSL_HEADER_CRYPTO_RAND_GETRANDOM_FILLIN_H
65