From 4d5659d61818f8f297bbdc176a4cf5c4fcf96c68 Mon Sep 17 00:00:00 2001
From: felix <felix@call-with-current-continuation.org>
Date: Tue, 21 Feb 2012 11:14:59 +0100
Subject: [PATCH] applied patch by 'Sergey' for musl support
---
Makefile.linux | 2 +-
posixunix.scm | 32 --------------------------------
runtime.c | 5 +----
3 files changed, 2 insertions(+), 37 deletions(-)
diff --git a/Makefile.linux b/Makefile.linux
index 6e5116a..6114b81 100644
a
|
b
|
ARCH ?= $(shell sh $(SRCDIR)/config-arch.sh) |
37 | 37 | |
38 | 38 | # options |
39 | 39 | |
40 | | C_COMPILER_OPTIONS ?= -fno-strict-aliasing -fwrapv -DHAVE_CHICKEN_CONFIG_H |
| 40 | C_COMPILER_OPTIONS ?= -fno-strict-aliasing -fwrapv -DHAVE_CHICKEN_CONFIG_H -D_GNU_SOURCE -fPIC |
41 | 41 | ifdef DEBUGBUILD |
42 | 42 | C_COMPILER_OPTIMIZATION_OPTIONS ?= -g -Wall -Wno-unused |
43 | 43 | else |
diff --git a/posixunix.scm b/posixunix.scm
index 9b23846..a597993 100644
a
|
b
|
static C_TLS sigset_t C_sigset; |
310 | 310 | |
311 | 311 | #define C_ctime(n) (C_secs = (n), ctime(&C_secs)) |
312 | 312 | |
313 | | #if defined(__SVR4) || defined(C_MACOSX) |
314 | 313 | /* Seen here: http://lists.samba.org/archive/samba-technical/2002-November/025571.html */ |
315 | 314 | |
316 | 315 | static time_t C_timegm(struct tm *t) |
… |
… |
static time_t C_timegm(struct tm *t) |
340 | 339 | } |
341 | 340 | return (tl - (tb - tl)); |
342 | 341 | } |
343 | | #else |
344 | | #define C_timegm timegm |
345 | | #endif |
346 | 342 | |
347 | 343 | #define cpy_tmvec_to_tmstc08(ptm, v) \ |
348 | 344 | (memset((ptm), 0, sizeof(struct tm)), \ |
… |
… |
static time_t C_timegm(struct tm *t) |
379 | 375 | #define C_tm_get_08(v) cpy_tmstc08_to_tmvec( (v), &C_tm ) |
380 | 376 | #define C_tm_get_9(v) cpy_tmstc9_to_tmvec( (v), &C_tm ) |
381 | 377 | |
382 | | #if !defined(C_GNU_ENV) || defined(__CYGWIN__) || defined(__uClinux__) |
383 | | |
384 | 378 | static struct tm * |
385 | 379 | C_tm_set( C_word v ) |
386 | 380 | { |
… |
… |
C_tm_get( C_word v ) |
395 | 389 | return v; |
396 | 390 | } |
397 | 391 | |
398 | | #else |
399 | | |
400 | | static struct tm * |
401 | | C_tm_set( C_word v ) |
402 | | { |
403 | | C_tm_set_08( v ); |
404 | | C_tm_set_9( v ); |
405 | | return &C_tm; |
406 | | } |
407 | | |
408 | | static C_word |
409 | | C_tm_get( C_word v ) |
410 | | { |
411 | | C_tm_get_08( v ); |
412 | | C_tm_get_9( v ); |
413 | | return v; |
414 | | } |
415 | | |
416 | | #endif |
417 | | |
418 | 392 | #define C_asctime(v) (asctime(C_tm_set(v))) |
419 | 393 | #define C_a_mktime(ptr, c, v) C_flonum(ptr, mktime(C_tm_set(v))) |
420 | 394 | #define C_a_timegm(ptr, c, v) C_flonum(ptr, C_timegm(C_tm_set(v))) |
… |
… |
EOF |
1665 | 1639 | |
1666 | 1640 | (define local-timezone-abbreviation |
1667 | 1641 | (foreign-lambda* c-string () |
1668 | | "\n#if !defined(__CYGWIN__) && !defined(__SVR4) && !defined(__uClinux__) && !defined(__hpux__)\n" |
1669 | | "time_t clock = time(NULL);" |
1670 | | "struct tm *ltm = C_localtime(&clock);" |
1671 | | "char *z = ltm ? (char *)ltm->tm_zone : 0;" |
1672 | | "\n#else\n" |
1673 | 1642 | "char *z = (daylight ? tzname[1] : tzname[0]);" |
1674 | | "\n#endif\n" |
1675 | 1643 | "C_return(z);") ) |
1676 | 1644 | |
1677 | 1645 | |
diff --git a/runtime.c b/runtime.c
index 41a2f9d..433182c 100644
a
|
b
|
void C_ccall C_decode_seconds(C_word c, C_word closure, C_word k, C_word secs, C |
7919 | 7919 | C_fix(tmt->tm_mday), C_fix(tmt->tm_mon), C_fix(tmt->tm_year), |
7920 | 7920 | C_fix(tmt->tm_wday), C_fix(tmt->tm_yday), |
7921 | 7921 | tmt->tm_isdst > 0 ? C_SCHEME_TRUE : C_SCHEME_FALSE, |
7922 | | #ifdef C_GNU_ENV |
7923 | | /* negative for west of UTC, but we want positive */ |
7924 | | C_fix(-tmt->tm_gmtoff) |
7925 | | #elif defined(__CYGWIN__) || defined(__MINGW32__) || defined(_WIN32) || defined(__WINNT__) |
| 7922 | #if defined(__CYGWIN__) || defined(__MINGW32__) || defined(_WIN32) || defined(__WINNT__) |
7926 | 7923 | C_fix(mode == C_SCHEME_FALSE ? _timezone : 0) /* does not account for DST */ |
7927 | 7924 | #else |
7928 | 7925 | C_fix(mode == C_SCHEME_FALSE ? timezone : 0) /* does not account for DST */ |