Changeset View
Changeset View
Standalone View
Standalone View
sys/sys/random.h
Show All 31 Lines | |||||
#define _SYS_RANDOM_H_ | #define _SYS_RANDOM_H_ | ||||
#include <sys/types.h> | #include <sys/types.h> | ||||
#ifdef _KERNEL | #ifdef _KERNEL | ||||
struct uio; | struct uio; | ||||
/* | |||||
* In the loadable random world, there are set of dangling pointers left in the | |||||
* core kernel: | |||||
* * read_random, read_random_uio, is_random_seeded are function pointers, | |||||
* rather than functions. | |||||
* * p_random_alg_context is a true pointer in loadable random kernels. | |||||
* | |||||
* These are initialized at SI_SUB_RANDOM:SI_ORDER_SECOND during boot. The | |||||
* read-type pointers are initialized by random_alg_context_init() in | |||||
* randomdev.c and p_random_alg_context in the algorithm, e.g., fortuna.c's | |||||
* random_fortuna_init_alg(). The nice thing about function pointers is they | |||||
* have a similar calling convention to ordinary functions. | |||||
* | |||||
* (In !loadable, the read_random, etc, routines are just plain functions; | |||||
* p_random_alg_context is a macro for the public visibility | |||||
* &random_alg_context.) | |||||
*/ | |||||
#if defined(RANDOM_LOADABLE) | |||||
extern void (*_read_random)(void *, u_int); | |||||
extern int (*_read_random_uio)(struct uio *, bool); | |||||
extern bool (*_is_random_seeded)(void); | |||||
#define read_random(a, b) (*_read_random)(a, b) | |||||
#define read_random_uio(a, b) (*_read_random_uio)(a, b) | |||||
#define is_random_seeded() (*_is_random_seeded)() | |||||
#else | |||||
void read_random(void *, u_int); | void read_random(void *, u_int); | ||||
int read_random_uio(struct uio *, bool); | int read_random_uio(struct uio *, bool); | ||||
bool is_random_seeded(void); | bool is_random_seeded(void); | ||||
#endif | |||||
markm: Can those #undefs above not be reworked to here somehow? | |||||
cemAuthorUnsubmitted Done Inline ActionsNo, unfortunately. The idea is that these are the standard definitions everyone gets -- so "read_random(9)" just works regardless of LOADABLE. The undefs in randomdev were an implementation detail for that file only. But I think it may be possible to avoid them, so I'll give it a shot. cem: No, unfortunately. The idea is that these are the standard definitions everyone gets -- so… | |||||
/* | /* | ||||
* Note: if you add or remove members of random_entropy_source, remember to | * Note: if you add or remove members of random_entropy_source, remember to | ||||
* also update the strings in the static array random_source_descr[] in | * also update the strings in the static array random_source_descr[] in | ||||
* random_harvestq.c. | * random_harvestq.c. | ||||
*/ | */ | ||||
enum random_entropy_source { | enum random_entropy_source { | ||||
RANDOM_START = 0, | RANDOM_START = 0, | ||||
▲ Show 20 Lines • Show All 90 Lines • Show Last 20 Lines |
Can those #undefs above not be reworked to here somehow?