chicken-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Chicken-hackers] [PATCH 5/8] Add chicken.file.posix module


From: Evan Hanson
Subject: [Chicken-hackers] [PATCH 5/8] Add chicken.file.posix module
Date: Thu, 2 Mar 2017 21:50:41 +1300

This module simply reexports the low-level file-related values from
posix (mostly having to do with file descriptors).

It also adds a stub for `file-control` and the various various fcntl/*
values on Windows so that the posix module's export list can be the same
across all platforms.
---
 README                |  1 +
 chicken-install.scm   |  1 +
 defaults.make         |  4 ++--
 distribution/manifest |  2 ++
 posix.scm             | 16 ++++++++++++++++
 posixwin.scm          | 10 ++++++++--
 rules.make            |  7 +++++--
 7 files changed, 35 insertions(+), 6 deletions(-)

diff --git a/README b/README
index 32142132..623d868a 100644
--- a/README
+++ b/README
@@ -283,6 +283,7 @@
        |   |       |-- chicken.eval.import.so
        |   |       |-- chicken.expand.import.so
        |   |       |-- chicken.file.import.so
+       |   |       |-- chicken.file.posix.import.so
        |   |       |-- chicken.files.import.so
        |   |       |-- chicken.fixnum.import.so
        |   |       |-- chicken.flonum.import.so
diff --git a/chicken-install.scm b/chicken-install.scm
index 8d53bf5c..c07a3cfe 100644
--- a/chicken-install.scm
+++ b/chicken-install.scm
@@ -52,6 +52,7 @@
       "chicken.eval.import.so"
       "chicken.expand.import.so"
       "chicken.file.import.so"
+      "chicken.file.posix.import.so"
       "chicken.files.import.so"
       "chicken.fixnum.import.so"
       "chicken.flonum.import.so"
diff --git a/defaults.make b/defaults.make
index b70a90c2..e535a9d2 100644
--- a/defaults.make
+++ b/defaults.make
@@ -265,8 +265,8 @@ CHICKEN_PROGRAM_OPTIONS += $(if $(PROFILE_OBJECTS),-profile)
 
 PRIMITIVE_IMPORT_LIBRARIES = chicken chicken.csi chicken.foreign
 DYNAMIC_IMPORT_LIBRARIES = setup-api setup-download srfi-4
-DYNAMIC_CHICKEN_IMPORT_LIBRARIES = bitwise errno fixnum flonum format \
-       gc io keyword locative memory posix pretty-print random time
+DYNAMIC_CHICKEN_IMPORT_LIBRARIES = bitwise errno file.posix fixnum flonum \
+       format gc io keyword locative memory posix pretty-print random time
 DYNAMIC_CHICKEN_COMPILER_IMPORT_LIBRARIES = user-pass
 DYNAMIC_CHICKEN_UNIT_IMPORT_LIBRARIES = continuation data-structures \
        eval expand file files internal irregex lolevel pathname port \
diff --git a/distribution/manifest b/distribution/manifest
index 917099c7..5ec76b9a 100644
--- a/distribution/manifest
+++ b/distribution/manifest
@@ -281,6 +281,8 @@ chicken.expand.import.scm
 chicken.expand.import.c
 chicken.file.import.scm
 chicken.file.import.c
+chicken.file.posix.import.scm
+chicken.file.posix.import.c
 chicken.files.import.scm
 chicken.files.import.c
 chicken.fixnum.import.scm
diff --git a/posix.scm b/posix.scm
index 6e4ffad4..bf4fb8c4 100644
--- a/posix.scm
+++ b/posix.scm
@@ -87,3 +87,19 @@
 (define errno/srch _esrch)
 (define errno/wouldblock _ewouldblock)
 (define errno/xdev _exdev))
+
+(module chicken.file.posix
+  (duplicate-fileno fcntl/dupfd fcntl/getfd fcntl/getfl fcntl/setfd
+   fcntl/setfl file-access-time file-change-time file-close file-control
+   file-creation-mode file-link file-lock file-lock/blocking
+   file-mkstemp file-open file-owner file-permissions file-position
+   file-read file-select file-size file-stat file-test-lock
+   file-truncate file-unlock file-write fileno/stderr fileno/stdin
+   fileno/stdout open-input-file* open-output-file* open/append
+   open/binary open/creat open/excl open/fsync open/noctty open/nonblock
+   open/rdonly open/rdwr open/read open/sync open/text open/trunc
+   open/write open/wronly perm/irgrp perm/iroth perm/irusr perm/irwxg
+   perm/irwxo perm/irwxu perm/isgid perm/isuid perm/isvtx perm/iwgrp
+   perm/iwoth perm/iwusr perm/ixgrp perm/ixoth perm/ixusr port->fileno
+   seek/cur seek/end seek/set set-file-position!)
+(import chicken chicken.posix))
diff --git a/posixwin.scm b/posixwin.scm
index 62790932..c42b5f6e 100644
--- a/posixwin.scm
+++ b/posixwin.scm
@@ -634,9 +634,9 @@ EOF
    current-effective-user-name get-environment-variables
    current-group-id current-process-id current-user-id current-user-name
    delete-directory directory directory? duplicate-fileno
-   #;fcntl/dupfd #;fcntl/getfd #;fcntl/getfl #;fcntl/setfd #;fcntl/setfl
+   fcntl/dupfd fcntl/getfd fcntl/getfl fcntl/setfd fcntl/setfl
    fifo? file-access-time file-change-time
-   file-creation-mode file-close #;file-control file-execute-access?
+   file-creation-mode file-close file-control file-execute-access?
    file-link file-lock file-lock/blocking file-mkstemp
    file-modification-time file-open file-owner file-permissions
    file-position set-file-position! file-read file-read-access?
@@ -1330,6 +1330,7 @@ EOF
 (define-unimplemented current-effective-user-name)
 (define-unimplemented current-group-id)
 (define-unimplemented current-user-id)
+(define-unimplemented file-control)
 (define-unimplemented file-link)
 (define-unimplemented file-lock)
 (define-unimplemented file-lock/blocking)
@@ -1359,6 +1360,11 @@ EOF
 
 (define (fifo? _) #f)
 
+(define fcntl/dupfd 0)
+(define fcntl/getfd 0)
+(define fcntl/setfd 0)
+(define fcntl/getfl 0)
+(define fcntl/setfl 0)
 (define open/fsync 0)
 (define open/noctty 0)
 (define open/nonblock 0)
diff --git a/rules.make b/rules.make
index 6f572a96..c5ce7542 100644
--- a/rules.make
+++ b/rules.make
@@ -520,6 +520,7 @@ $(foreach lib, $(filter-out chicken,$(COMPILER_OBJECTS_1)),\
 # special cases for modules not corresponding directly to units
 $(eval $(call 
declare-emitted-import-lib-dependency,chicken.posix,$(POSIXFILE)))
 $(eval $(call 
declare-emitted-import-lib-dependency,chicken.errno,$(POSIXFILE)))
+$(eval $(call 
declare-emitted-import-lib-dependency,chicken.file.posix,$(POSIXFILE)))
 $(eval $(call declare-emitted-import-lib-dependency,chicken.bitwise,library))
 $(eval $(call declare-emitted-import-lib-dependency,chicken.fixnum,library))
 $(eval $(call declare-emitted-import-lib-dependency,chicken.flonum,library))
@@ -804,13 +805,15 @@ 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)/posix.scm $(SRCDIR)posixunix.scm 
$(SRCDIR)posix-common.scm $(SRCDIR)common-declarations.scm
+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.file.posix \
        -emit-import-library chicken.posix
-posixwin.c: $(SRCDIR)/posix.scm $(SRCDIR)posixwin.scm 
$(SRCDIR)posix-common.scm $(SRCDIR)common-declarations.scm
+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.file.posix \
        -emit-import-library chicken.posix
 irregex.c: $(SRCDIR)irregex.scm $(SRCDIR)irregex-core.scm 
$(SRCDIR)irregex-utils.scm $(SRCDIR)common-declarations.scm
        $(bootstrap-lib) -emit-import-library chicken.irregex
-- 
2.11.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]