diff options
author | Mattias Andrée <maandree@kth.se> | 2021-09-16 18:10:26 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2021-09-16 18:10:26 +0200 |
commit | 76c910e166d2b1887c5d355df4efec47ec0ce3bd (patch) | |
tree | b5761449486d6cadf6d4e00bd96a92fb5d7890cc /libhaiku.c | |
parent | Merge branch 'rewrite' (diff) | |
download | libhaiku-76c910e166d2b1887c5d355df4efec47ec0ce3bd.tar.gz libhaiku-76c910e166d2b1887c5d355df4efec47ec0ce3bd.tar.bz2 libhaiku-76c910e166d2b1887c5d355df4efec47ec0ce3bd.tar.xz |
Improve makefile, fix warnings, and fix libhaiku_perror linking2.0.1
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'libhaiku.c')
-rw-r--r-- | libhaiku.c | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -31,12 +31,14 @@ static int random_int(int n) { static int initialised = 0; - double r, ri; + double r; + int ri; if (!initialised) { srand((unsigned)time(NULL)); initialised = 1; } - r = (double)rand() * (double)n / ((double)RAND_MAX + 1.0); + ri = rand(); + r = (double)ri * (double)n / ((double)RAND_MAX + (double)1); ri = ((int)r) % n; return ri < 0 ? (ri + n) : ri; } @@ -307,4 +309,4 @@ libhaiku_perror2(const char *prefix, int errnum) * @param prefix Unless `NULL` or empty, each line will be prefixed * by the specified string followed by a colon and a space */ -extern void libhaiku_perror(const char *prefix); +extern inline void libhaiku_perror(const char *prefix); |