mirror of
https://github.com/isc-projects/bind9.git
synced 2026-06-09 01:12:07 -04:00
Use isc int types to be able to build with old VS
This commit is contained in:
parent
b1e2ecbc03
commit
28e0b2c4c4
4 changed files with 18 additions and 16 deletions
|
|
@ -12,6 +12,7 @@
|
|||
#include <config.h>
|
||||
|
||||
#include <isc/util.h>
|
||||
#include <isc/types.h>
|
||||
|
||||
#include "entropy_private.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
#include <stdlib.h>
|
||||
|
||||
#include <isc/lang.h>
|
||||
#include <isc/types.h>
|
||||
|
||||
/*! \file isc/random.h
|
||||
* \brief Implements wrapper around a non-cryptographically secure
|
||||
|
|
@ -24,19 +25,19 @@
|
|||
|
||||
ISC_LANG_BEGINDECLS
|
||||
|
||||
uint8_t
|
||||
isc_uint8_t
|
||||
isc_random8(void);
|
||||
/*!<
|
||||
* \brief Returns a single 8-bit random value.
|
||||
*/
|
||||
|
||||
uint16_t
|
||||
isc_uint16_t
|
||||
isc_random16(void);
|
||||
/*!<
|
||||
* \brief Returns a single 16-bit random value.
|
||||
*/
|
||||
|
||||
uint32_t
|
||||
isc_uint32_t
|
||||
isc_random32(void);
|
||||
/*!<
|
||||
* \brief Returns a single 32-bit random value.
|
||||
|
|
@ -48,8 +49,8 @@ isc_random_buf(void *buf, size_t buflen);
|
|||
* \brief Fills the region buf of length buflen with random data.
|
||||
*/
|
||||
|
||||
uint32_t
|
||||
isc_random_uniform(uint32_t upper_bound);
|
||||
isc_uint32_t
|
||||
isc_random_uniform(isc_uint32_t upper_bound);
|
||||
/*!<
|
||||
* \brief Will return a single 32-bit value, uniformly distributed but
|
||||
* less than upper_bound. This is recommended over
|
||||
|
|
|
|||
|
|
@ -69,21 +69,21 @@ isc_random_initialize(void) {
|
|||
isc_entropy_get(seed, sizeof(seed));
|
||||
}
|
||||
|
||||
uint8_t
|
||||
isc_uint8_t
|
||||
isc_random8(void) {
|
||||
RUNTIME_CHECK(isc_once_do(&isc_random_once,
|
||||
isc_random_initialize) == ISC_R_SUCCESS);
|
||||
return (next() & 0xff);
|
||||
}
|
||||
|
||||
uint16_t
|
||||
isc_uint16_t
|
||||
isc_random16(void) {
|
||||
RUNTIME_CHECK(isc_once_do(&isc_random_once,
|
||||
isc_random_initialize) == ISC_R_SUCCESS);
|
||||
return (next() & 0xffff);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
isc_uint32_t
|
||||
isc_random32(void) {
|
||||
RUNTIME_CHECK(isc_once_do(&isc_random_once,
|
||||
isc_random_initialize) == ISC_R_SUCCESS);
|
||||
|
|
@ -99,7 +99,7 @@ isc_random_buf(void *buf, size_t buflen) {
|
|||
isc_random_initialize) == ISC_R_SUCCESS);
|
||||
|
||||
int i;
|
||||
uint32_t r;
|
||||
isc_uint32_t r;
|
||||
|
||||
for (i = 0; i + sizeof(r) <= buflen; i += sizeof(r)) {
|
||||
r = next();
|
||||
|
|
@ -114,10 +114,10 @@ isc_random_buf(void *buf, size_t buflen) {
|
|||
return;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
isc_uint32_t
|
||||
isc_random_uniform(uint32_t upper_bound) {
|
||||
/* Copy of arc4random_uniform from OpenBSD */
|
||||
uint32_t r, min;
|
||||
isc_uint32_t r, min;
|
||||
|
||||
RUNTIME_CHECK(isc_once_do(&isc_random_once,
|
||||
isc_random_initialize) == ISC_R_SUCCESS);
|
||||
|
|
|
|||
|
|
@ -63,19 +63,19 @@ static pthread_mutex_t _mutex = PTHREAD_MUTEX_INITIALIZER;
|
|||
#define _UNLOCK() pthread_mutex_unlock(&_mutex)
|
||||
#endif /* defined(_WIN32) || defined(_WIN64) */
|
||||
|
||||
static inline uint32_t rotl(const uint32_t x, int k) {
|
||||
static inline isc_uint32_t rotl(const isc_uint32_t x, int k) {
|
||||
return (x << k) | (x >> (32 - k));
|
||||
}
|
||||
|
||||
static uint32_t seed[4];
|
||||
static isc_uint32_t seed[4];
|
||||
|
||||
static inline uint32_t
|
||||
static inline isc_uint32_t
|
||||
next(void) {
|
||||
_LOCK();
|
||||
|
||||
const uint32_t result_starstar = rotl(seed[0] * 5, 7) * 9;
|
||||
const isc_uint32_t result_starstar = rotl(seed[0] * 5, 7) * 9;
|
||||
|
||||
const uint32_t t = seed[1] << 9;
|
||||
const isc_uint32_t t = seed[1] << 9;
|
||||
|
||||
seed[2] ^= seed[0];
|
||||
seed[3] ^= seed[1];
|
||||
|
|
|
|||
Loading…
Reference in a new issue