Comment: | Make of_random() a function
When arc4random() is unavailable, either random() or rand() is used and |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
c1fe4b2b772d5ccfda3f9c825cdf694e |
User & Date: | js on 2020-07-12 09:49:35 |
Other Links: | manifest | tags |
2020-07-12
| ||
10:00 | Add support for getrandom() check-in: ba1135b0b2 user: js tags: trunk | |
09:49 | Make of_random() a function check-in: c1fe4b2b77 user: js tags: trunk | |
2020-07-11
| ||
21:07 | .travis.yml: Re-add devkitPro builds using Docker check-in: 28e2425585 user: js tags: trunk | |
Modified configure.ac from [aca5876c18] to [989ef7fcda].
︙ | ︙ | |||
897 898 899 900 901 902 903 | ]) AS_IF([test x"$enable_static" = x"yes" -o x"$enable_shared" = x"no"], [ AC_SUBST(ENCODINGS_A, "encodings.a") AC_SUBST(ENCODINGS_ENCODINGS_A, "encodings/encodings.a") ]) ]) | < < < | < < < | 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 | ]) AS_IF([test x"$enable_static" = x"yes" -o x"$enable_shared" = x"no"], [ AC_SUBST(ENCODINGS_A, "encodings.a") AC_SUBST(ENCODINGS_ENCODINGS_A, "encodings/encodings.a") ]) ]) AC_CHECK_FUNCS(arc4random random, break) AS_IF([test x"$host_os" != x"morphos"], [ AC_CHECK_LIB(dl, dlopen, LIBS="$LIBS -ldl") ]) AC_CHECK_HEADERS_ONCE(dlfcn.h) case "$host_os" in netbsd*) |
︙ | ︙ |
Modified src/OFObject.h from [0775955f65] to [89cb21ae56].
︙ | ︙ | |||
28 29 30 31 32 33 34 35 | #endif #include <stddef.h> #include <stdint.h> #include <stdbool.h> #include <limits.h> #include "macros.h" | > | | 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | #endif #include <stddef.h> #include <stdint.h> #include <stdbool.h> #include <limits.h> #include "block.h" #include "macros.h" #include "once.h" /* * Some versions of MinGW require <winsock2.h> to be included before * <windows.h>. Do this here to make sure this is always done in the correct * order, even if another header includes just <windows.h>. */ #ifdef __MINGW32__ |
︙ | ︙ | |||
1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 | extern void *_Null_unspecified objc_autoreleasePoolPush(void); extern void objc_autoreleasePoolPop(void *_Null_unspecified pool); #endif extern id of_alloc_object(Class class_, size_t extraSize, size_t extraAlignment, void *_Nullable *_Nullable extra); extern void OF_NO_RETURN_FUNC of_method_not_found(id self, SEL _cmd); extern uint32_t of_hash_seed; #ifdef __cplusplus } #endif OF_ASSUME_NONNULL_END #ifdef __OBJC__ # import "OFObject+KeyValueCoding.h" # import "OFObject+Serialization.h" #endif #endif | > > | 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 | extern void *_Null_unspecified objc_autoreleasePoolPush(void); extern void objc_autoreleasePoolPop(void *_Null_unspecified pool); #endif extern id of_alloc_object(Class class_, size_t extraSize, size_t extraAlignment, void *_Nullable *_Nullable extra); extern void OF_NO_RETURN_FUNC of_method_not_found(id self, SEL _cmd); extern uint32_t of_hash_seed; /* This does *NOT* provide cryptographically secure randomness! */ extern uint32_t of_random(void); #ifdef __cplusplus } #endif OF_ASSUME_NONNULL_END #ifdef __OBJC__ # import "OFObject+KeyValueCoding.h" # import "OFObject+Serialization.h" #endif #endif |
Modified src/OFObject.m from [d6b3535b02] to [54579841e3].
︙ | ︙ | |||
99 100 101 102 103 104 105 106 107 108 109 110 111 112 | #define PRE_MEM(mem) ((struct pre_mem *)(void *)((char *)mem - PRE_MEM_ALIGN)) static struct { Class isa; } allocFailedException; uint32_t of_hash_seed; static const char * typeEncodingForSelector(Class class, SEL selector) { Method method; if ((method = class_getInstanceMethod(class, selector)) == NULL) | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 | #define PRE_MEM(mem) ((struct pre_mem *)(void *)((char *)mem - PRE_MEM_ALIGN)) static struct { Class isa; } allocFailedException; uint32_t of_hash_seed; #ifndef HAVE_ARC4RANDOM static void initRandom(void) { struct timeval tv; # ifdef HAVE_RANDOM gettimeofday(&tv, NULL); srandom((unsigned)(tv.tv_sec ^ tv.tv_usec)); # else gettimeofday(&tv, NULL); srand((unsigned)(tv.tv_sec ^ tv.tv_usec)); # endif } #endif uint32_t of_random(void) { #ifdef HAVE_ARC4RANDOM return arc4random(); #else static of_once_t onceControl; of_once(&onceControl, initRandom); # ifdef HAVE_RANDOM return (((uint32_t)(random()) << 16) | ((uint32_t)(random()) & 0xFFFF)); # else return (((uint32_t)(rand()) << 16) | ((uint32_t)(rand()) & 0xFFFF)); # endif #endif } static const char * typeEncodingForSelector(Class class, SEL selector) { Method method; if ((method = class_getInstanceMethod(class, selector)) == NULL) |
︙ | ︙ |
Modified src/macros.h from [975aa82042] to [41e131467f].
︙ | ︙ | |||
894 895 896 897 898 899 900 | } static OF_INLINE char of_ascii_tolower(char c) { return (c >= 'A' && c <= 'Z' ? 'a' + (c - 'A') : c); } | < < < < < < < < < < < < < < < < < < < < < | 894 895 896 897 898 899 900 901 | } static OF_INLINE char of_ascii_tolower(char c) { return (c >= 'A' && c <= 'Z' ? 'a' + (c - 'A') : c); } #endif |
Modified src/objfw-defs.h.in from [f12fccebb9] to [4530c4317b].
1 2 3 4 5 6 | #undef INFINITY #undef LLONG_MAX #undef LLONG_MIN #undef OF_APPLE_RUNTIME #undef OF_BIG_ENDIAN #undef OF_FLOAT_BIG_ENDIAN | < | 1 2 3 4 5 6 7 8 9 10 11 12 13 | #undef INFINITY #undef LLONG_MAX #undef LLONG_MIN #undef OF_APPLE_RUNTIME #undef OF_BIG_ENDIAN #undef OF_FLOAT_BIG_ENDIAN #undef OF_HAVE_ATOMIC_BUILTINS #undef OF_HAVE_ATOMIC_OPS #undef OF_HAVE_BUILTIN_BSWAP16 #undef OF_HAVE_BUILTIN_BSWAP32 #undef OF_HAVE_BUILTIN_BSWAP64 #undef OF_HAVE_CHMOD #undef OF_HAVE_CHOWN |
︙ | ︙ | |||
27 28 29 30 31 32 33 | #undef OF_HAVE_OSATOMIC_64 #undef OF_HAVE_PIPE #undef OF_HAVE_PLEDGE #undef OF_HAVE_PLUGINS #undef OF_HAVE_PROCESSES #undef OF_HAVE_PTHREADS #undef OF_HAVE_PTHREAD_SPINLOCKS | < | 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | #undef OF_HAVE_OSATOMIC_64 #undef OF_HAVE_PIPE #undef OF_HAVE_PLEDGE #undef OF_HAVE_PLUGINS #undef OF_HAVE_PROCESSES #undef OF_HAVE_PTHREADS #undef OF_HAVE_PTHREAD_SPINLOCKS #undef OF_HAVE_RECURSIVE_PTHREAD_MUTEXES #undef OF_HAVE_SCHED_YIELD #undef OF_HAVE_SOCKETS #undef OF_HAVE_STDNORETURN #undef OF_HAVE_SYMLINK #undef OF_HAVE_SYNC_BUILTINS #undef OF_HAVE_SYS_SOCKET_H |
︙ | ︙ |