1 /*
2 * have_arc4random - Determine if we have the arc4random_buf() RNG
3 *
4 * Copyright (C) 2021 Landon Curt Noll
5 *
6 * Calc is open software; you can redistribute it and/or modify it under
7 * the terms of the version 2.1 of the GNU Lesser General Public License
8 * as published by the Free Software Foundation.
9 *
10 * Calc is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
13 * Public License for more details.
14 *
15 * A copy of version 2.1 of the GNU Lesser General Public License is
16 * distributed with calc under the filename COPYING-LGPL. You should have
17 * received a copy with calc; if not, write to Free Software Foundation, Inc.
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 *
20 * Under source code control: 2021/12/06 23:58:51
21 * File existed as early as: 2021
22 *
23 * chongo <was here> /\oo/\ http://www.isthe.com/chongo/
24 * Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
25 */
26
27 /*
28 * usage:
29 * have_arc4random
30 *
31 * Not all enviroments have the arc4random_buf() function,
32 * so this may not compile on your system.
33 *
34 * This prog outputs:
35 *
36 * HAVE_ARC4RANDOM
37 * defined ==> have arc4random_buf() call
38 * undefined ==> do not have arc4random_buf() call
39 */
40
41 #include "have_stdlib.h"
42 #if defined(HAVE_STDLIB_H)
43 #include <stdlib.h>
44 #endif
45 #include <stdio.h>
46
47
48 #include "banned.h" /* include after system header <> includes */
49
50
51 #define BUFLEN (32) /* length of the buffer to fill */
52
53
54 int
main(void)55 main(void)
56 {
57 #if defined(HAVE_NO_ARC4RANDOM)
58
59 printf("#undef HAVE_ARC4RANDOM /* no */\n");
60
61 #else /* HAVE_NO_ARC4RANDOM */
62
63 /* buffer for arc4random_buf() to fill */
64 static char buf[BUFLEN];
65
66 arc4random_buf(buf, BUFLEN);
67 printf("#define HAVE_ARC4RANDOM /* yes */\n");
68
69 #endif /* HAVE_NO_ARC4RANDOM */
70
71 /* exit(0); */
72 return 0;
73 }
74