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/Makefile.linux
+++ b/Makefile.linux
@@ -37,7 +37,7 @@ ARCH ?= $(shell sh $(SRCDIR)/config-arch.sh)
 
 # options
 
-C_COMPILER_OPTIONS ?= -fno-strict-aliasing -fwrapv -DHAVE_CHICKEN_CONFIG_H
+C_COMPILER_OPTIONS ?= -fno-strict-aliasing -fwrapv -DHAVE_CHICKEN_CONFIG_H -D_GNU_SOURCE -fPIC
 ifdef DEBUGBUILD
 C_COMPILER_OPTIMIZATION_OPTIONS ?= -g -Wall -Wno-unused
 else
diff --git a/posixunix.scm b/posixunix.scm
index 9b23846..a597993 100644
--- a/posixunix.scm
+++ b/posixunix.scm
@@ -310,7 +310,6 @@ static C_TLS sigset_t C_sigset;
 
 #define C_ctime(n)          (C_secs = (n), ctime(&C_secs))
 
-#if defined(__SVR4) || defined(C_MACOSX)
 /* Seen here: http://lists.samba.org/archive/samba-technical/2002-November/025571.html */
 
 static time_t C_timegm(struct tm *t)
@@ -340,9 +339,6 @@ static time_t C_timegm(struct tm *t)
     }
   return (tl - (tb - tl));
 }
-#else
-#define C_timegm timegm
-#endif
 
 #define cpy_tmvec_to_tmstc08(ptm, v) \
     (memset((ptm), 0, sizeof(struct tm)), \
@@ -379,8 +375,6 @@ static time_t C_timegm(struct tm *t)
 #define C_tm_get_08(v)  cpy_tmstc08_to_tmvec( (v), &C_tm )
 #define C_tm_get_9(v)   cpy_tmstc9_to_tmvec( (v), &C_tm )
 
-#if !defined(C_GNU_ENV) || defined(__CYGWIN__) || defined(__uClinux__)
-
 static struct tm *
 C_tm_set( C_word v )
 {
@@ -395,26 +389,6 @@ C_tm_get( C_word v )
   return v;
 }
 
-#else
-
-static struct tm *
-C_tm_set( C_word v )
-{
-  C_tm_set_08( v );
-  C_tm_set_9( v );
-  return &C_tm;
-}
-
-static C_word
-C_tm_get( C_word v )
-{
-  C_tm_get_08( v );
-  C_tm_get_9( v );
-  return v;
-}
-
-#endif
-
 #define C_asctime(v)    (asctime(C_tm_set(v)))
 #define C_a_mktime(ptr, c, v)  C_flonum(ptr, mktime(C_tm_set(v)))
 #define C_a_timegm(ptr, c, v)  C_flonum(ptr, C_timegm(C_tm_set(v)))
@@ -1665,13 +1639,7 @@ EOF
 
 (define local-timezone-abbreviation
   (foreign-lambda* c-string ()
-   "\n#if !defined(__CYGWIN__) && !defined(__SVR4) && !defined(__uClinux__) && !defined(__hpux__)\n"
-   "time_t clock = time(NULL);"
-   "struct tm *ltm = C_localtime(&clock);"
-   "char *z = ltm ? (char *)ltm->tm_zone : 0;"
-   "\n#else\n"
    "char *z = (daylight ? tzname[1] : tzname[0]);"
-   "\n#endif\n"
    "C_return(z);") )
 
 
diff --git a/runtime.c b/runtime.c
index 41a2f9d..433182c 100644
--- a/runtime.c
+++ b/runtime.c
@@ -7919,10 +7919,7 @@ void C_ccall C_decode_seconds(C_word c, C_word closure, C_word k, C_word secs, C
 		  C_fix(tmt->tm_mday), C_fix(tmt->tm_mon), C_fix(tmt->tm_year),
 		  C_fix(tmt->tm_wday), C_fix(tmt->tm_yday),
 		  tmt->tm_isdst > 0 ? C_SCHEME_TRUE : C_SCHEME_FALSE,
-#ifdef C_GNU_ENV
-                  /* negative for west of UTC, but we want positive */
-		  C_fix(-tmt->tm_gmtoff)
-#elif defined(__CYGWIN__) || defined(__MINGW32__) || defined(_WIN32) || defined(__WINNT__)
+#if defined(__CYGWIN__) || defined(__MINGW32__) || defined(_WIN32) || defined(__WINNT__)
                   C_fix(mode == C_SCHEME_FALSE ? _timezone : 0) /* does not account for DST */
 #else
                   C_fix(mode == C_SCHEME_FALSE ? timezone : 0)  /* does not account for DST */
-- 
1.6.0.4

