mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-05-19 05:39:18 +02:00
fix compilation under std=c89
There were few things that prevented successful compilation using c89 standard. (and other c* standards in case of gcc). Fix them in this small patch. Changes in 27/rand.c: - Use __GNU_SOURCE__ instead of __GNU_LIBRARY__ or else any of -std=c* options don't work with gcc - Add a check before using rand_r() as suggested in rand_r(3) - Move _WIN_32 definitions to "else" branch because it uses the most portable version
This commit is contained in:
parent
e7e6530c35
commit
f449bd157d
4 changed files with 19 additions and 17 deletions
1
AUTHORS
1
AUTHORS
|
@ -58,6 +58,7 @@ Thanks to the following people for patches and bug reports:
|
|||
* Stephen Lewis
|
||||
* Taylor Venable
|
||||
* Travis Cross
|
||||
* Vitaliy Mysak
|
||||
* Yuki Okumura
|
||||
|
||||
If you would prefer not to be listed, or are one of the users listed
|
||||
|
|
8
bignum.c
8
bignum.c
|
@ -772,10 +772,10 @@ sexp sexp_double_to_ratio (sexp ctx, double f) {
|
|||
return res;
|
||||
}
|
||||
|
||||
//
|
||||
// For conversion that does not introduce round-off error,
|
||||
// no matter what FLT_RADIX is.
|
||||
//
|
||||
/*
|
||||
* For conversion that does not introduce round-off error,
|
||||
* no matter what FLT_RADIX is.
|
||||
*/
|
||||
sexp sexp_double_to_ratio_2 (sexp ctx, double f) {
|
||||
int sign,i;
|
||||
sexp_gc_var3(res, whole, scale);
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
#define sexp_sizeof_random (sexp_sizeof_header + sizeof(sexp_random_t) + sizeof(sexp))
|
||||
|
||||
#ifdef __GNU_LIBRARY__
|
||||
#ifdef __GNU_SOURCE__
|
||||
|
||||
typedef struct random_data sexp_random_t;
|
||||
|
||||
|
@ -31,17 +31,7 @@ typedef struct random_data sexp_random_t;
|
|||
#define sexp_call_random(rs, dst) random_r(sexp_random_data(rs), &dst)
|
||||
#define sexp_seed_random(n, rs) srandom_r(n, sexp_random_data(rs))
|
||||
|
||||
#elif defined(_WIN32)
|
||||
|
||||
typedef unsigned int sexp_random_t;
|
||||
|
||||
/* FIXME: MSVC CRT has rand_s() for "cryptographically secure" random number
|
||||
* for WinXP or later. */
|
||||
#define sexp_random_init(rs, seed) (void)0
|
||||
#define sexp_call_random(rs, dst) ((dst) = rand())
|
||||
#define sexp_seed_random(n, rs) srand(n)
|
||||
|
||||
#else
|
||||
#elif _POSIX_C_SOURCE >= 1 || _XOPEN_SOURCE || _POSIX_SOURCE
|
||||
|
||||
typedef unsigned int sexp_random_t;
|
||||
|
||||
|
@ -50,6 +40,17 @@ typedef unsigned int sexp_random_t;
|
|||
#define sexp_call_random(rs, dst) ((dst) = rand_r(sexp_random_data(rs)))
|
||||
#define sexp_seed_random(n, rs) *sexp_random_data(rs) = (n)
|
||||
|
||||
#else
|
||||
|
||||
typedef unsigned int sexp_random_t;
|
||||
|
||||
#define sexp_random_init(rs, seed) (void)0
|
||||
|
||||
/* FIXME: MSVC CRT has rand_s() for "cryptographically secure" random number
|
||||
* for WinXP or later. */
|
||||
#define sexp_call_random(rs, dst) ((dst) = rand())
|
||||
#define sexp_seed_random(n, rs) srand(n)
|
||||
|
||||
#endif
|
||||
|
||||
sexp sexp_rs_random_integer (sexp ctx, sexp self, sexp_sint_t n, sexp rs, sexp bound) {
|
||||
|
|
2
sexp.c
2
sexp.c
|
@ -583,7 +583,7 @@ void sexp_init_context_globals (sexp ctx) {
|
|||
for (i=0; i<SEXP_NUM_CORE_TYPES; i++) {
|
||||
type = sexp_alloc_type(ctx, type, SEXP_TYPE);
|
||||
if (!type) {
|
||||
return; // TODO - fundamental OOM, what to do here?
|
||||
return; /* TODO - fundamental OOM, what to do here? */
|
||||
}
|
||||
memcpy(&(type->value), &(_sexp_type_specs[i]), sizeof(_sexp_type_specs[0]));
|
||||
vec[i] = type;
|
||||
|
|
Loading…
Add table
Reference in a new issue