~ chicken-core (chicken-5) 18d75b95174dce22dd835836c5a288e94de6a7ff
commit 18d75b95174dce22dd835836c5a288e94de6a7ff Author: Evan Hanson <evhan@foldling.org> AuthorDate: Fri Feb 24 13:39:36 2017 +1300 Commit: Evan Hanson <evhan@foldling.org> CommitDate: Thu Mar 2 16:37:28 2017 +1300 Add posix.scm file that wraps platform-specific posix implementations This inverts the way the posix unit is organised by having one outer file (posix.scm) that includes a platform-specific implementation file (either posixunix.scm or posixwin.scm), depending on what feature flag is passed. diff --git a/distribution/manifest b/distribution/manifest index 8904266b..917099c7 100644 --- a/distribution/manifest +++ b/distribution/manifest @@ -99,6 +99,7 @@ lfa2.scm mini-srfi-1.scm pathname.c pathname.scm +posix.scm posixunix.scm posixwin.scm posix-common.scm diff --git a/posix.scm b/posix.scm new file mode 100644 index 00000000..c844366a --- /dev/null +++ b/posix.scm @@ -0,0 +1,46 @@ +;;;; posix.scm - Platform-specific routines +; +; Copyright (c) 2008-2017, The CHICKEN Team +; Copyright (c) 2000-2007, Felix L. Winkelmann +; All rights reserved. +; +; Redistribution and use in source and binary forms, with or without +; modification, are permitted provided that the following conditions are +; met: +; +; Redistributions of source code must retain the above copyright +; notice, this list of conditions and the following disclaimer. +; +; Redistributions in binary form must reproduce the above copyright +; notice, this list of conditions and the following disclaimer in the +; documentation and/or other materials provided with the distribution. +; +; Neither the name of the author nor the names of its contributors may +; be used to endorse or promote products derived from this software +; without specific prior written permission. +; +; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +; HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +; INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +; BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +; OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +; ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR +; TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE +; USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH +; DAMAGE. + + +(declare + (unit posix) + (uses scheduler irregex pathname extras files port lolevel) + (disable-interrupts) + (not inline ##sys#interrupt-hook ##sys#user-interrupt-hook)) + +(cond-expand + (platform-unix + (include "posixunix.scm")) + (platform-windows + (include "posixwin.scm"))) diff --git a/posixunix.scm b/posixunix.scm index 3119b547..1e177374 100644 --- a/posixunix.scm +++ b/posixunix.scm @@ -25,12 +25,6 @@ ; POSSIBILITY OF SUCH DAMAGE. -(declare - (unit posix) - (uses scheduler irregex pathname extras files port lolevel) - (disable-interrupts) - (not inline ##sys#interrupt-hook ##sys#user-interrupt-hook)) - ;; these are not available on Windows (define-foreign-variable _stat_st_blksize unsigned-int "C_statbuf.st_blksize") diff --git a/posixwin.scm b/posixwin.scm index 14ec70cf..11103166 100644 --- a/posixwin.scm +++ b/posixwin.scm @@ -61,11 +61,7 @@ (declare - (unit posix) - (uses scheduler data-structures irregex extras pathname files port lolevel) - (disable-interrupts) - (hide quote-arg-string) - (not inline ##sys#interrupt-hook ##sys#user-interrupt-hook) + (uses data-structures) (foreign-declare #<<EOF #ifndef WIN32_LEAN_AND_MEAN # define WIN32_LEAN_AND_MEAN diff --git a/rules.make b/rules.make index 630df061..6f572a96 100644 --- a/rules.make +++ b/rules.make @@ -804,12 +804,12 @@ extras.c: $(SRCDIR)extras.scm $(SRCDIR)common-declarations.scm -emit-import-library chicken.io \ -emit-import-library chicken.pretty-print \ -emit-import-library chicken.random -posixunix.c: $(SRCDIR)posixunix.scm $(SRCDIR)posix-common.scm $(SRCDIR)common-declarations.scm - $(bootstrap-lib) \ +posixunix.c: $(SRCDIR)/posix.scm $(SRCDIR)posixunix.scm $(SRCDIR)posix-common.scm $(SRCDIR)common-declarations.scm + $(bootstrap-lib) -feature platform-unix \ -emit-import-library chicken.errno \ -emit-import-library chicken.posix -posixwin.c: $(SRCDIR)posixwin.scm $(SRCDIR)posix-common.scm $(SRCDIR)common-declarations.scm - $(bootstrap-lib) \ +posixwin.c: $(SRCDIR)/posix.scm $(SRCDIR)posixwin.scm $(SRCDIR)posix-common.scm $(SRCDIR)common-declarations.scm + $(bootstrap-lib) -feature platform-windows \ -emit-import-library chicken.errno \ -emit-import-library chicken.posix irregex.c: $(SRCDIR)irregex.scm $(SRCDIR)irregex-core.scm $(SRCDIR)irregex-utils.scm $(SRCDIR)common-declarations.scmTrap