Solene Rapenne <[email protected]> writes:

> On Wed, Jan 01, 2020 at 07:00:45PM +0200, Timo Myyrä wrote:
>
>> Hi,
>> 
>> Here's an attempt to update sbcl to latest version.
>> Before adding the new patch I got consistent test failures in inpure timer 
>> test
>> "(:WITH-TIMEOUT :MANY-AT-THE-SAME-TIME".
>> 
>> After adding the patch to unix.lisp the tests have passed twice on amd64.
>> Does this look OK, does the tests work on other platforms?
>> 
>> Timo
>> 
>
> I'm ok and will commit it if maintainer is ok too

Heres revised diff with upstream backports. I still think we're better off
waiting next release so we don't have to include these patches but it can't hurt
to test these to see they indeed fix the issue.

Tested clisp bootstrapped on amd64 and tests passed.

timo

Index: Makefile
===================================================================
RCS file: /cvs/ports/lang/sbcl/Makefile,v
retrieving revision 1.43
diff -u -p -u -p -r1.43 Makefile
--- Makefile    16 Sep 2019 06:24:18 -0000      1.43
+++ Makefile    2 Jan 2020 18:04:39 -0000
@@ -6,7 +6,7 @@ USE_WXNEEDED =          Yes
 
 COMMENT=               compiler and runtime system for ANSI Common Lisp
 
-V =                    1.5.5
+V =                    2.0.0
 DISTNAME=              sbcl-${V}-source
 PKGNAME=               sbcl-${V}
 WRKDIST=               ${WRKDIR}/sbcl-${V}
Index: distinfo
===================================================================
RCS file: /cvs/ports/lang/sbcl/distinfo,v
retrieving revision 1.18
diff -u -p -u -p -r1.18 distinfo
--- distinfo    16 Sep 2019 06:24:18 -0000      1.18
+++ distinfo    2 Jan 2020 18:04:39 -0000
@@ -1,2 +1,2 @@
-SHA256 (sbcl-1.5.5-source.tar.bz2) = 
y0f65qhvDFxXQxYE+05fEcioI/lM4SjVaLh3D8W8quI=
-SIZE (sbcl-1.5.5-source.tar.bz2) = 6351480
+SHA256 (sbcl-2.0.0-source.tar.bz2) = 
kDaSVoBdQ3yCq5vauaQQB29XgQpQuysijeTmyJJpL88=
+SIZE (sbcl-2.0.0-source.tar.bz2) = 6457217
Index: patches/patch-src_code_unix_lisp
===================================================================
RCS file: patches/patch-src_code_unix_lisp
diff -N patches/patch-src_code_unix_lisp
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_code_unix_lisp    2 Jan 2020 18:04:39 -0000
@@ -0,0 +1,47 @@
+$OpenBSD$
+
+backport commit 92e98d3cbfdef83ce8411b2fb43ddfe0e3272d9e
+
+Index: src/code/unix.lisp
+--- src/code/unix.lisp.orig
++++ src/code/unix.lisp
+@@ -1051,36 +1051,18 @@ avoiding atexit(3) hooks, etc. Otherwise exit(2) is ca
+ #-win32
+ (progn
+ 
+-  #-sb-fluid (declaim (inline get-time-of-day))
++  (declaim (inline get-time-of-day))
+   (defun get-time-of-day ()
+     "Return the number of seconds and microseconds since the beginning of
+ the UNIX epoch (January 1st 1970.)"
+-    #+(or darwin netbsd)
+     (with-alien ((tv (struct timeval)))
+-      ;; CLH: FIXME! This seems to be a MacOS bug, but on x86-64/darwin,
+-      ;; gettimeofday occasionally fails. passing in a null pointer for the
+-      ;; timezone struct seems to work around the problem. NS notes: Darwin
+-      ;; manpage says the timezone is not used anymore in their implementation
+-      ;; at all.
+-      (syscall* ("sb_gettimeofday" (* (struct timeval))
+-                                (* (struct timezone)))
++      (syscall* ("sb_gettimeofday" (* (struct timeval)))
+                 (values (slot tv 'tv-sec)
+                         (slot tv 'tv-usec))
+-                (addr tv)
+-                nil))
+-    #-(or darwin netbsd)
+-    (with-alien ((tv (struct timeval))
+-                 (tz (struct timezone)))
+-      (syscall* ("sb_gettimeofday" (* (struct timeval))
+-                                (* (struct timezone)))
+-                (values (slot tv 'tv-sec)
+-                        (slot tv 'tv-usec))
+-                (addr tv)
+-                (addr tz))))
++                (addr tv))))
+ 
+   (declaim (inline system-internal-run-time
+                    system-real-time-values))
+-
+   (defun system-real-time-values ()
+     (multiple-value-bind (sec usec) (get-time-of-day)
+       (declare (type unsigned-byte sec) (type (unsigned-byte 31) usec))
Index: patches/patch-src_runtime_GNUmakefile
===================================================================
RCS file: /cvs/ports/lang/sbcl/patches/patch-src_runtime_GNUmakefile,v
retrieving revision 1.8
diff -u -p -u -p -r1.8 patch-src_runtime_GNUmakefile
--- patches/patch-src_runtime_GNUmakefile       8 Mar 2018 15:17:39 -0000       
1.8
+++ patches/patch-src_runtime_GNUmakefile       2 Jan 2020 18:04:39 -0000
@@ -2,7 +2,7 @@ $OpenBSD: patch-src_runtime_GNUmakefile,
 Index: src/runtime/GNUmakefile
 --- src/runtime/GNUmakefile.orig
 +++ src/runtime/GNUmakefile
-@@ -30,7 +30,7 @@ __LDFLAGS__ =
+@@ -34,7 +34,7 @@ __LDFLAGS__ =
  
  include ../../output/prefix.def
  
Index: patches/patch-src_runtime_gc-common_c
===================================================================
RCS file: /cvs/ports/lang/sbcl/patches/patch-src_runtime_gc-common_c,v
retrieving revision 1.2
diff -u -p -u -p -r1.2 patch-src_runtime_gc-common_c
--- patches/patch-src_runtime_gc-common_c       8 Mar 2018 15:17:39 -0000       
1.2
+++ patches/patch-src_runtime_gc-common_c       2 Jan 2020 18:04:39 -0000
@@ -5,7 +5,7 @@ clang only has it as builtin
 Index: src/runtime/gc-common.c
 --- src/runtime/gc-common.c.orig
 +++ src/runtime/gc-common.c
-@@ -55,6 +55,8 @@
+@@ -57,6 +57,8 @@
  #define LONG_FLOAT_SIZE 3
  #endif
  
Index: patches/patch-src_runtime_wrap_c
===================================================================
RCS file: patches/patch-src_runtime_wrap_c
diff -N patches/patch-src_runtime_wrap_c
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_runtime_wrap_c    2 Jan 2020 18:04:39 -0000
@@ -0,0 +1,48 @@
+$OpenBSD$
+
+backport commit 92e98d3cbfdef83ce8411b2fb43ddfe0e3272d9e
+
+Index: src/runtime/wrap.c
+--- src/runtime/wrap.c.orig
++++ src/runtime/wrap.c
+@@ -443,28 +443,6 @@ int sb_select(int top_fd, DWORD *read_set, DWORD *writ
+     }
+     return polling_write;
+ }
+-
+-/*
+- * Windows doesn't have gettimeofday(), and we need it for the compiler,
+- * for serve-event, and for a couple other things. We don't need a timezone
+- * yet, however, and the closest we can easily get to a timeval is the
+- * seconds part. So that's what we do.
+- */
+-#define UNIX_EPOCH_FILETIME 116444736000000000ULL
+-
+-int sb_gettimeofday(long *timeval, long *timezone)
+-{
+-    FILETIME ft;
+-    ULARGE_INTEGER uft;
+-    GetSystemTimeAsFileTime(&ft);
+-    uft.LowPart = ft.dwLowDateTime;
+-    uft.HighPart = ft.dwHighDateTime;
+-    uft.QuadPart -= UNIX_EPOCH_FILETIME;
+-    timeval[0] = uft.QuadPart / 10000000;
+-    timeval[1] = (uft.QuadPart % 10000000)/10;
+-
+-    return 0;
+-}
+ #endif
+ 
+ 
+@@ -551,9 +529,9 @@ int sb_getrusage(int who, struct rusage *rusage)
+         return getrusage(who, rusage);
+ }
+ 
+-int sb_gettimeofday(struct timeval *tp, void *tzp)
++int sb_gettimeofday(struct timeval *tp)
+ {
+-        return gettimeofday(tp, tzp);
++        return gettimeofday(tp, NULL);
+ }
+ 
+ #ifndef LISP_FEATURE_DARWIN /* reimplements nanosleep in darwin-os.c  */
Index: patches/patch-tests_compiler_impure_lisp
===================================================================
RCS file: patches/patch-tests_compiler_impure_lisp
diff -N patches/patch-tests_compiler_impure_lisp
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-tests_compiler_impure_lisp    2 Jan 2020 18:04:39 -0000
@@ -0,0 +1,17 @@
+$OpenBSD$
+
+backport commit d013944f19bae8084a871c79c4b5a8fd1c87d8f0
+
+Index: tests/compiler.impure.lisp
+--- tests/compiler.impure.lisp.orig
++++ tests/compiler.impure.lisp
+@@ -2458,7 +2458,8 @@
+     (assert (equal type1 (sb-kernel:%simple-fun-type g)))
+     (assert (equal type0 (sb-kernel:%simple-fun-type h)))))
+ 
+-(test-util:with-test (:name :bug-308921)
++(test-util:with-test (:name :bug-308921
++                      :broken-on :sbcl)
+   (let ((*check-consistency* t))
+     (ctu:file-compile
+      `((let ((exported-symbols-alist
Index: patches/patch-tests_timer_impure_lisp
===================================================================
RCS file: patches/patch-tests_timer_impure_lisp
diff -N patches/patch-tests_timer_impure_lisp
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-tests_timer_impure_lisp       2 Jan 2020 18:04:39 -0000
@@ -0,0 +1,31 @@
+$OpenBSD$
+
+backport commit d013944f19bae8084a871c79c4b5a8fd1c87d8f0
+
+Index: tests/timer.impure.lisp
+--- tests/timer.impure.lisp.orig
++++ tests/timer.impure.lisp
+@@ -194,9 +194,6 @@
+             (sb-ext:with-timeout 2
+               (sleep 2))))))
+ 
+-(defun wait-for-threads (threads)
+-  (loop while (some #'sb-thread:thread-alive-p threads) do (sleep 0.01)))
+-
+ (with-test (:name (:with-timeout :many-at-the-same-time)
+                   :skipped-on (not :sb-thread)
+                   :broken-on :win32)
+@@ -209,11 +206,10 @@
+                                   (sleep 5)
+                                   (setf ok nil)
+                                   (format t "~%not ok~%"))
+-                              (timeout ()
+-                                )))))))
++                              (timeout ())))))))
+       (assert (not (raises-timeout-p
+                     (sb-ext:with-timeout 20
+-                      (wait-for-threads threads)))))
++                      (mapc #'sb-thread:join-thread threads)))))
+       (assert ok))))
+ 
+ ;;; FIXME: Since timeouts do not work on Windows this would loop
Index: pkg/PLIST
===================================================================
RCS file: /cvs/ports/lang/sbcl/pkg/PLIST,v
retrieving revision 1.12
diff -u -p -u -p -r1.12 PLIST
--- pkg/PLIST   13 May 2019 12:58:58 -0000      1.12
+++ pkg/PLIST   2 Jan 2020 18:04:39 -0000
@@ -50,3 +50,4 @@ share/doc/sbcl/BUGS
 share/doc/sbcl/COPYING
 share/doc/sbcl/CREDITS
 share/doc/sbcl/NEWS
+share/doc/sbcl/html/

Reply via email to