diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2017-02-21 12:05:07 +0000 |
---|---|---|
committer | Laurent Bercot <ska-skaware@skarnet.org> | 2017-02-21 12:05:07 +0000 |
commit | 49d8fa1058aaf23c29e074b2314492ae40d2f557 (patch) | |
tree | 393f884d5a99f984e992a0f35f1b02ac43536217 /src/librandom | |
parent | fdffefb8032922ce7ffe4c00816072a8ff2148fc (diff) | |
download | skalibs-49d8fa1058aaf23c29e074b2314492ae40d2f557.tar.xz |
Types change: big pass on libstddjb and libunixonacid
libdatastruct still missing, library still not functional
Diffstat (limited to 'src/librandom')
-rw-r--r-- | src/librandom/random_name.c | 1 | ||||
-rw-r--r-- | src/librandom/random_string.c | 2 | ||||
-rw-r--r-- | src/librandom/random_uint32.c | 2 | ||||
-rw-r--r-- | src/librandom/random_unsort.c | 10 | ||||
-rw-r--r-- | src/librandom/surf.c | 11 | ||||
-rw-r--r-- | src/librandom/surf_init.c | 2 |
6 files changed, 14 insertions, 14 deletions
diff --git a/src/librandom/random_name.c b/src/librandom/random_name.c index f972e93..1c8eb04 100644 --- a/src/librandom/random_name.c +++ b/src/librandom/random_name.c @@ -2,6 +2,7 @@ /* MT-unsafe */ +#include <sys/types.h> #include <skalibs/random.h> void random_name (char *s, size_t n) diff --git a/src/librandom/random_string.c b/src/librandom/random_string.c index 5053824..cd2a0aa 100644 --- a/src/librandom/random_string.c +++ b/src/librandom/random_string.c @@ -31,7 +31,7 @@ void random_string (char *s, size_t n) { while (n) { - register int r = getrandom(s, n, 0) ; + int r = getrandom(s, n, 0) ; if (r >= 0) { s += r ; diff --git a/src/librandom/random_uint32.c b/src/librandom/random_uint32.c index a2144f1..26c0968 100644 --- a/src/librandom/random_uint32.c +++ b/src/librandom/random_uint32.c @@ -29,7 +29,7 @@ uint32_t random_uint32 (uint32_t n) { char tmp[4] ; random_string(tmp, 4) ; - uint32_unpack(tmp, &x) ; + uint32_unpack_big(tmp, &x) ; if (x >= min) break ; } return x % n ; diff --git a/src/librandom/random_unsort.c b/src/librandom/random_unsort.c index 98a4b09..4596136 100644 --- a/src/librandom/random_unsort.c +++ b/src/librandom/random_unsort.c @@ -1,7 +1,7 @@ /* ISC license. */ #include <stdint.h> -#include <skalibs/bytestr.h> +#include <string.h> #include <skalibs/random.h> void random_unsort (char *s, size_t n, size_t chunksize) @@ -9,9 +9,9 @@ void random_unsort (char *s, size_t n, size_t chunksize) char tmp[chunksize] ; while (n--) { - register uint32_t i = random_uint32(n+1) ; - byte_copy(tmp, chunksize, s + i * chunksize) ; - byte_copy(s + i * chunksize, chunksize, s + n * chunksize) ; - byte_copy(s + n * chunksize, chunksize, tmp) ; + uint32_t i = random_uint32(n+1) ; + memcpy(tmp, s + i * chunksize, chunksize) ; + memcpy(s + i * chunksize, s + n * chunksize, chunksize) ; + memcpy(s + n * chunksize, tmp, chunksize) ; } } diff --git a/src/librandom/surf.c b/src/librandom/surf.c index fe5346e..1b68fc2 100644 --- a/src/librandom/surf.c +++ b/src/librandom/surf.c @@ -1,9 +1,8 @@ /* ISC license. */ -#include <sys/types.h> #include <stdint.h> +#include <string.h> #include <skalibs/uint32.h> -#include <skalibs/bytestr.h> #include <skalibs/surf.h> #define ROTATE(x, b) (((x) << (b)) | ((x) >> (32 - (b)))) @@ -38,19 +37,19 @@ static void surfit (SURFSchedule *ctx) void surf (SURFSchedule *ctx, char *s, size_t n) { { - register size_t i = 32 - ctx->pos ; + size_t i = 32 - ctx->pos ; if (n < i) i = n ; - byte_copy(s, i, ctx->out + ctx->pos) ; + memcpy(s, ctx->out + ctx->pos, i) ; s += i ; n -= i ; ctx->pos += i ; } while (n > 32) { surfit(ctx) ; - byte_copy(s, 32, ctx->out) ; + memcpy(s, ctx->out, 32) ; s += 32 ; n -= 32 ; } if (!n) return ; surfit(ctx) ; - byte_copy(s, n, ctx->out) ; + memcpy(s, ctx->out, n) ; ctx->pos = n ; } diff --git a/src/librandom/surf_init.c b/src/librandom/surf_init.c index d1d9b3c..53abdcc 100644 --- a/src/librandom/surf_init.c +++ b/src/librandom/surf_init.c @@ -6,7 +6,7 @@ void surf_init (SURFSchedule *ctx, char const *s) { SURFSchedule zero = SURFSCHEDULE_ZERO ; - register unsigned int i = 4 ; + unsigned int i = 4 ; *ctx = zero ; for (; i < 12 ; i++) uint32_unpack(s + (i<<2) - 16, ctx->in + i) ; for (i = 0 ; i < 32 ; i++) uint32_unpack(s + 32 + (i<<2), ctx->seed + i) ; |