Deleted Added
full compact
rand.c (174541) rand.c (241046)
1/*-
2 * Copyright (c) 1990, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 19 unchanged lines hidden (view full) ---

28 *
29 * Posix rand_r function added May 1999 by Wes Peters <wes@softweyr.com>.
30 */
31
32#if defined(LIBC_SCCS) && !defined(lint)
33static char sccsid[] = "@(#)rand.c 8.1 (Berkeley) 6/14/93";
34#endif /* LIBC_SCCS and not lint */
35#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1990, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 19 unchanged lines hidden (view full) ---

28 *
29 * Posix rand_r function added May 1999 by Wes Peters <wes@softweyr.com>.
30 */
31
32#if defined(LIBC_SCCS) && !defined(lint)
33static char sccsid[] = "@(#)rand.c 8.1 (Berkeley) 6/14/93";
34#endif /* LIBC_SCCS and not lint */
35#include <sys/cdefs.h>
36__FBSDID("$FreeBSD: head/lib/libc/stdlib/rand.c 174541 2007-12-11 20:39:32Z ache $");
36__FBSDID("$FreeBSD: head/lib/libc/stdlib/rand.c 241046 2012-09-29 11:54:34Z jilles $");
37
38#include "namespace.h"
39#include <sys/time.h> /* for sranddev() */
40#include <sys/types.h>
41#include <fcntl.h> /* for sranddev() */
42#include <stdlib.h>
43#include <unistd.h> /* for sranddev() */
44#include "un-namespace.h"

--- 71 unchanged lines hidden (view full) ---

116 * secure random(4) interface.
117 */
118void
119sranddev()
120{
121 int fd, done;
122
123 done = 0;
37
38#include "namespace.h"
39#include <sys/time.h> /* for sranddev() */
40#include <sys/types.h>
41#include <fcntl.h> /* for sranddev() */
42#include <stdlib.h>
43#include <unistd.h> /* for sranddev() */
44#include "un-namespace.h"

--- 71 unchanged lines hidden (view full) ---

116 * secure random(4) interface.
117 */
118void
119sranddev()
120{
121 int fd, done;
122
123 done = 0;
124 fd = _open("/dev/random", O_RDONLY, 0);
124 fd = _open("/dev/random", O_RDONLY | O_CLOEXEC, 0);
125 if (fd >= 0) {
126 if (_read(fd, (void *) &next, sizeof(next)) == sizeof(next))
127 done = 1;
128 _close(fd);
129 }
130
131 if (!done) {
132 struct timeval tv;

--- 36 unchanged lines hidden ---
125 if (fd >= 0) {
126 if (_read(fd, (void *) &next, sizeof(next)) == sizeof(next))
127 done = 1;
128 _close(fd);
129 }
130
131 if (!done) {
132 struct timeval tv;

--- 36 unchanged lines hidden ---