Skip to content

Commit

Permalink
Remove cond-expand on gauche.sys.threads
Browse files Browse the repository at this point in the history
Now that we always have thread support, we no longer need those
cond-expands.
  • Loading branch information
shirok committed Nov 22, 2023
1 parent 3f19f85 commit d1114a2
Show file tree
Hide file tree
Showing 5 changed files with 234 additions and 287 deletions.
4 changes: 1 addition & 3 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,7 @@ AS_CASE(["$host"],
GAUCHE_THREAD_TYPE=pthreads
],
[*-*-mingw*], [
AS_IF([test $GAUCHE_THREAD_TYPE = "pthreads"],
[ AC_MSG_ERROR([pthread can't be used on Windows. Use --enable-threads=win32 to enable threads]) ],
[ GAUCHE_THREAD_TYPE=win32 ])
GAUCHE_THREAD_TYPE=win32
],
[
AC_MSG_ERROR([Can't determine thread subsystem type on $host])
Expand Down
10 changes: 3 additions & 7 deletions lib/control/pmap.scm
Original file line number Diff line number Diff line change
Expand Up @@ -296,13 +296,9 @@

(define default-mapper
(make-parameter
(cond-expand
[gauche.sys.threads
(if (= 1 (sys-available-processors))
(sequential-mapper)
(make-static-mapper))]
[else
(sequential-mapper)])))
(if (= 1 (sys-available-processors))
(sequential-mapper)
(make-static-mapper))))

;;;
;;; High-level API
Expand Down
46 changes: 14 additions & 32 deletions libsrc/gauche/process.scm
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,10 @@
))
(select-module gauche.process)

;; Delay-load gauche.charconv
(autoload gauche.charconv
wrap-with-input-conversion wrap-with-output-conversion)
(autoload gauche.uvector
write-uvector)
;; Delay-load to avoid circular dependency
(autoload gauche.charconv wrap-with-input-conversion wrap-with-output-conversion)
(autoload gauche.uvector write-uvector)
(autoload gauche.threads make-thread thread-start!)

;; Avoid build dependency issue
(autoload srfi.19
Expand Down Expand Up @@ -429,33 +428,16 @@
(values iomap toclose ipipes opipes tmpfiles))

;; Set up source of << and <<< redirection, used inside %setup-iomap.
;; We don't want to depend on gauche.threads at compile time, so we split
;; this part to be evaluated at runtime.
;; Returns updated iomap, toclose, and tmpfiles.
(without-precompiling
(define (%setup-<< fd do-file dir arg iomap toclose tmpfiles)
(define (write-arg o)
(unwind-protect
(cond [(eq? dir '<<<) (write arg o)]
[(string? arg) (display arg o)]
[else (write-uvector arg o)])
(close-output-port o)))
(cond-expand
[gauche.sys.threads
(receive (in out) (sys-pipe)
(thread-start! (make-thread (cut write-arg out)))
(values (acons fd in iomap) (cons in toclose) tmpfiles))]
[else
;; If we can't use threads, we fall back to using temporary
;; files. It has some drawbacks: (1) If we 'exec'-ing
;; (not forking), we don't have chance to remove them, and
;; (2) On Windows we won't be able to remove temp file unless
;; we wait the child process to complete. We'll do our best
;; anyway.
(receive (out nam) (sys-mkstemp (%temp-path-prefix))
(write-arg out)
(do-file '< fd nam)
(values iomap toclose (cons nam tmpfiles)))])))
(define (%setup-<< fd do-file dir arg iomap toclose tmpfiles)
(define (write-arg o)
(unwind-protect
(cond [(eq? dir '<<<) (write arg o)]
[(string? arg) (display arg o)]
[else (write-uvector arg o)])
(close-output-port o)))
(receive (in out) (sys-pipe)
(thread-start! (make-thread (cut write-arg out)))
(values (acons fd in iomap) (cons in toclose) tmpfiles)))

(define (%ensure-mask mask)
(cond
Expand Down
Loading

0 comments on commit d1114a2

Please sign in to comment.