dnl Process this file with autoconf to produce a configure script.
AC_INIT([MIT/GNU Scheme microcode], [15.1], [bug-mit-scheme@gnu.org], [mit-scheme])
-AC_REVISION([$Id: configure.ac,v 1.61 2008/09/27 03:59:05 cph Exp $])
+AC_REVISION([$Id: configure.ac,v 1.62 2009/03/21 07:09:08 riastradh Exp $])
AC_CONFIG_SRCDIR([boot.c])
AC_CONFIG_HEADERS([config.h])
AC_PROG_MAKE_SET
AC_FUNC_WAIT3
AC_CHECK_FUNCS([ctermid])
AC_CHECK_FUNCS([dup2])
-AC_CHECK_FUNCS([fcntl fegetround fesetround floor fpathconf frexp ftruncate])
+AC_CHECK_FUNCS([fcntl fdatasync fegetround fesetround floor fpathconf frexp])
+AC_CHECK_FUNCS([fsync fsync_range ftruncate])
AC_CHECK_FUNCS([getcwd gethostbyname gethostname getlogin getpagesize getpgrp])
AC_CHECK_FUNCS([getpt gettimeofday getwd grantpt])
AC_CHECK_FUNCS([kill])
AC_CHECK_FUNCS([rename rmdir])
AC_CHECK_FUNCS([select setitimer setpgrp setpgrp2 shmat sigaction])
AC_CHECK_FUNCS([sighold socket statfs strchr strerror strstr strtol])
-AC_CHECK_FUNCS([strtoul symlink sysconf])
+AC_CHECK_FUNCS([strtoul symlink sync_file_range sysconf])
AC_CHECK_FUNCS([times truncate])
AC_CHECK_FUNCS([uname utime])
AC_CHECK_FUNCS([waitpid])
/* -*-C-*-
-$Id: ntfile.c,v 1.19 2008/01/30 20:02:14 cph Exp $
+$Id: ntfile.c,v 1.20 2009/03/21 07:09:08 riastradh Exp $
Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
NT_error_api_call ((GetLastError ()), apicall_SetFilePointer);
return (NT_open_handle (hFile));
}
+
+Tchannel
+OS_open_exclusive_output_file (const char * filename)
+{
+ error_unimplemented_primitive ();
+ return (0);
+}
\f
static Tchannel
make_load_channel (HANDLE handle)
/* -*-C-*-
-$Id: ntio.c,v 1.37 2008/03/09 20:24:24 cph Exp $
+$Id: ntio.c,v 1.38 2009/03/21 07:09:08 riastradh Exp $
Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
{
return (CHANNEL_TYPE (channel));
}
+
+void
+OS_channel_synchronize (Tchannel channel)
+{
+}
\f
static void
generic_channel_close (Tchannel channel, int errorp)
/* -*-C-*-
-$Id: os2file.c,v 1.8 2008/01/30 20:02:16 cph Exp $
+$Id: os2file.c,v 1.9 2009/03/21 07:09:08 riastradh Exp $
Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
transaction_commit ();
return (channel);
}
+
+Tchannel
+OS_open_exclusive_output_file (const char * filename)
+{
+ error_unimplemented_primitive ();
+ return (0);
+}
\f
static Tchannel
open_file_noerror (const char * filename, ULONG attr, ULONG flags,
/* -*-C-*-
-$Id: os2io.c,v 1.15 2008/03/09 20:24:27 cph Exp $
+$Id: os2io.c,v 1.16 2009/03/21 07:09:08 riastradh Exp $
Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
{
(CHANNEL_NONBLOCKING (channel)) = 0;
}
+
+void
+OS_channel_synchronize (Tchannel channel)
+{
+}
\f
size_t
OS_channel_read_load_file (Tchannel channel, void * buffer, size_t nbytes)
/* -*-C-*-
-$Id: osfile.h,v 1.10 2008/01/30 20:02:17 cph Exp $
+$Id: osfile.h,v 1.11 2009/03/21 07:09:09 riastradh Exp $
Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
extern Tchannel OS_open_input_file (const char * filename);
extern Tchannel OS_open_output_file (const char * filename);
+extern Tchannel OS_open_exclusive_output_file (const char * filename);
extern Tchannel OS_open_io_file (const char * filename);
extern Tchannel OS_open_append_file (const char * filename);
extern Tchannel OS_open_load_file (const char * filename);
/* -*-C-*-
-$Id: osio.h,v 1.25 2008/03/09 20:24:30 cph Exp $
+$Id: osio.h,v 1.26 2009/03/21 07:09:09 riastradh Exp $
Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
extern void OS_channel_close (Tchannel channel);
extern void OS_channel_close_noerror (Tchannel channel);
extern void OS_channel_close_on_abort (Tchannel channel);
+extern void OS_channel_synchronize (Tchannel channel);
extern enum channel_type OS_channel_type (Tchannel channel);
extern size_t OS_channel_read_load_file
(Tchannel channel, void * buffer, size_t nbytes);
/* -*-C-*-
-$Id: prosfile.c,v 1.16 2008/01/30 20:02:19 cph Exp $
+$Id: prosfile.c,v 1.17 2009/03/21 07:09:09 riastradh Exp $
Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
If the file exists, it is rewritten.")
NEW_OPEN_FILE_PRIMITIVE (OS_open_output_file)
+/* Really this should just return #F or something, I think, since the
+ possibility of the file's existence is so common a case to worry
+ about. Doing so requires more changes to the runtime, though. */
+
+DEFINE_PRIMITIVE ("NEW-FILE-OPEN-EXCLUSIVE-OUTPUT-CHANNEL",
+ Prim_new_file_open_exclusive_output_channel, 2, 2,
+ "Open an output file called FILENAME.\n\
+The channel number is saved in the cdr of WEAK-PAPIR.\n\
+If the file exists, an error is signalled.")
+ NEW_OPEN_FILE_PRIMITIVE (OS_open_exclusive_output_file)
+
DEFINE_PRIMITIVE ("NEW-FILE-OPEN-IO-CHANNEL", Prim_new_file_open_io_channel,
2, 2,
"Open a file called FILENAME.\n\
If the file exists, it is rewritten.")
OPEN_FILE_PRIMITIVE (OS_open_output_file)
+DEFINE_PRIMITIVE ("FILE-OPEN-EXCLUSIVE-OUTPUT-CHANNEL",
+ Prim_file_open_exclusive_output_channel, 2, 2,
+ "Open an output file called FILENAME, returning a channel number.\n\
+If the file exists, an error is signalled.")
+ OPEN_FILE_PRIMITIVE (OS_open_exclusive_output_file)
+
DEFINE_PRIMITIVE ("FILE-OPEN-IO-CHANNEL", Prim_file_open_io_channel, 1, 1,
"Open a file called FILENAME, returning a channel number.\n\
The file is opened for both input and output.\n\
/* -*-C-*-
-$Id: prosio.c,v 1.30 2008/01/30 20:02:19 cph Exp $
+$Id: prosio.c,v 1.31 2009/03/21 07:09:09 riastradh Exp $
Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
}
PRIMITIVE_RETURN (UNSPECIFIC);
}
+
+DEFINE_PRIMITIVE ("CHANNEL-SYNCHRONIZE", Prim_channel_synchronize, 1, 1,
+ "(CHANNEL)\n\
+Synchronize CHANNEL with any permanent storage associated with it,\n\
+forcing any buffered data to be written permanently.")
+{
+ PRIMITIVE_HEADER (1);
+ OS_channel_synchronize (arg_channel (1));
+ PRIMITIVE_RETURN (UNSPECIFIC);
+}
\f
DEFINE_PRIMITIVE ("CHANNEL-TABLE", Prim_channel_table, 0, 0,
"Return a vector of all channels in the channel table.")
/* -*-C-*-
-$Id: syscall.h,v 1.23 2008/01/30 20:02:21 cph Exp $
+$Id: syscall.h,v 1.24 2009/03/21 07:09:09 riastradh Exp $
Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
syscall_close,
syscall_connect,
syscall_fcntl_GETFL,
+ syscall_fcntl_FULLFSYNC,
syscall_fcntl_SETFL,
+ syscall_fdatasync,
syscall_fork,
syscall_fstat,
+ syscall_fstatfs,
+ syscall_fsync,
+ syscall_fsync_range,
syscall_ftruncate,
syscall_getcwd,
syscall_gethostname,
syscall_listen,
syscall_localtime,
syscall_lseek,
+ syscall_lstat,
syscall_malloc,
syscall_mkdir,
+ syscall_mktime,
syscall_open,
syscall_opendir,
syscall_pause,
syscall_select,
syscall_setitimer,
syscall_setpgid,
+ syscall_setsockopt,
syscall_shutdown,
syscall_sighold,
syscall_sigprocmask,
syscall_sigsuspend,
syscall_sleep,
syscall_socket,
+ syscall_stat,
+ syscall_statfs,
syscall_symlink,
+ syscall_sync_file_range,
syscall_tcdrain,
syscall_tcflush,
syscall_tcgetpgrp,
syscall_utime,
syscall_vfork,
syscall_write,
- syscall_stat,
- syscall_lstat,
- syscall_mktime,
- syscall_dld,
- syscall_statfs,
- syscall_fstatfs,
- syscall_setsockopt
};
\f
enum syserr_names
/* -*-C-*-
-$Id: ux.h,v 1.89 2009/03/08 00:02:09 riastradh Exp $
+$Id: ux.h,v 1.90 2009/03/21 07:09:09 riastradh Exp $
Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
#define UX_ctime ctime
#define UX_dup dup
#define UX_fcntl fcntl
+#define UX_fdatasync fdatasync
#define UX_free free
#define UX_fstat fstat
#define UX_fstatfs fstatfs
+#define UX_fsync fsync
+#define UX_fsync_range fsync_range
#define UX_ftruncate ftruncate
#define UX_getegid getegid
#define UX_getenv getenv
#define UX_stat stat
#define UX_statfs statfs
#define UX_symlink symlink
+#define UX_sync_file_range sync_file_range
#define UX_system system
#define UX_time time
#define UX_times times
/* -*-C-*-
-$Id: uxfile.c,v 1.17 2008/01/30 20:02:22 cph Exp $
+$Id: uxfile.c,v 1.18 2009/03/21 07:09:09 riastradh Exp $
Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
DEFUN_OPEN_FILE (OS_open_input_file, O_RDONLY)
DEFUN_OPEN_FILE (OS_open_output_file, (O_WRONLY | O_CREAT | O_TRUNC))
+DEFUN_OPEN_FILE (OS_open_exclusive_output_file, (O_WRONLY | O_CREAT | O_EXCL))
DEFUN_OPEN_FILE (OS_open_io_file, (O_RDWR | O_CREAT))
#ifdef O_APPEND
/* -*-C-*-
-$Id: uxio.c,v 1.60 2008/03/09 20:24:32 cph Exp $
+$Id: uxio.c,v 1.61 2009/03/21 07:09:09 riastradh Exp $
Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
(*cp) = (channel);
transaction_record_action (tat_abort, channel_close_on_abort_1, cp);
}
+
+/* This pile of kludgerosity makes the best effort it can to truly
+ force everything out to disk on Linux, NetBSD, and Darwin. */
+
+void
+OS_channel_synchronize (Tchannel channel)
+{
+ int fd = (CHANNEL_DESCRIPTOR (channel));
+#ifdef HAVE_FDATASYNC
+ STD_VOID_SYSTEM_CALL (syscall_fdatasync, (UX_fdatasync (fd)));
+#endif /* HAVE_FDATASYNC */
+#ifdef HAVE_FSYNC_RANGE
+ STD_VOID_SYSTEM_CALL
+ (syscall_fsync_range,
+ (UX_fsync_range (fd, (FFILESYNC | FDISKSYNC), 0, 0)));
+#endif /* HAVE_FSYNC_RANGE */
+#ifdef HAVE_SYNC_FILE_RANGE
+ STD_VOID_SYSTEM_CALL
+ (syscall_sync_file_range,
+ (UX_sync_file_range
+ (fd, 0, 0,
+ (SYNC_FILE_RANGE_WAIT_BEFORE
+ | SYNC_FILE_RANGE_WRITE
+ | SYNC_FILE_RANGE_WAIT_AFTER))));
+#endif /* HAVE_SYNC_FILE_RANGE */
+#ifdef HAVE_FSYNC
+ STD_VOID_SYSTEM_CALL (syscall_fsync, (UX_fsync (fd)));
+#endif /* HAVE_FSYNC */
+#ifdef F_FULLFSYNC
+ STD_VOID_SYSTEM_CALL
+ (syscall_fcntl_FULLFSYNC, (UX_fcntl (fd, F_FULLFSYNC, 0)));
+#endif /* F_FULLFSYNC */
+}
\f
enum channel_type
OS_channel_type (Tchannel channel)
/* -*-C-*-
-$Id: uxtop.c,v 1.39 2008/01/30 20:02:22 cph Exp $
+$Id: uxtop.c,v 1.40 2009/03/21 07:09:09 riastradh Exp $
Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
"close",
"connect",
"fcntl-getfl",
+ "fcntl-fullfsync",
"fcntl-setfl",
+ "fdatasync",
"fork",
"fstat",
+ "fstatfs",
+ "fsync",
+ "fsync_range",
"ftruncate",
"getcwd",
"gethostname",
"listen",
"localtime",
"lseek",
+ "lstat",
"malloc",
"mkdir",
+ "mktime",
"open",
"opendir",
"pause",
"select",
"setitimer",
"setpgid",
+ "setsockopt",
"shutdown",
"sighold",
"sigprocmask",
"sigsuspend",
"sleep",
"socket",
+ "stat",
+ "statfs",
"symlink",
+ "sync_file_range",
"tcdrain",
"tcflush",
"tcgetpgrp",
"utime",
"vfork",
"write",
- "stat",
- "lstat",
- "mktime",
- "dynamic-load",
- "statfs",
- "fstatfs",
- "setsockopt"
};
void
#| -*-Scheme-*-
-$Id: fileio.scm,v 1.38 2008/07/11 05:26:42 cph Exp $
+$Id: fileio.scm,v 1.39 2009/03/21 07:09:09 riastradh Exp $
Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
(port/set-line-ending port (file-line-ending pathname))
port))
+(define (open-exclusive-output-file filename)
+ (let* ((pathname (merge-pathnames filename))
+ (channel (file-open-exclusive-output-channel (->namestring pathname)))
+ (port (make-generic-i/o-port channel #f output-file-type pathname)))
+ (set-channel-port! channel port)
+ (port/set-line-ending port (file-line-ending pathname))
+ port))
+
(define (open-i/o-file filename)
(let* ((pathname (merge-pathnames filename))
(channel (file-open-io-channel (->namestring pathname)))
(port/set-line-ending port 'BINARY)
port))
+(define (open-exclusive-binary-output-file filename)
+ (let* ((pathname (merge-pathnames filename))
+ (channel (file-open-exclusive-output-channel (->namestring pathname)))
+ (port (make-generic-i/o-port channel #f output-file-type pathname)))
+ (set-channel-port! channel port)
+ (port/set-coding port 'BINARY)
+ (port/set-line-ending port 'BINARY)
+ port))
+
(define (open-binary-i/o-file filename)
(let* ((pathname (merge-pathnames filename))
(channel (file-open-io-channel (->namestring pathname)))
(define call-with-output-file
(make-call-with-file open-output-file))
+(define call-with-exclusive-output-file
+ (make-call-with-file open-exclusive-output-file))
+
(define call-with-binary-output-file
(make-call-with-file open-binary-output-file))
+(define call-with-exclusive-binary-output-file
+ (make-call-with-file open-exclusive-binary-output-file))
+
(define call-with-append-file
(make-call-with-file (lambda (filename) (open-output-file filename #t))))
(define with-output-to-file
(make-with-output-to-file call-with-output-file))
+(define with-output-to-exclusive-file
+ (make-with-output-to-file call-with-exclusive-output-file))
+
(define with-output-to-binary-file
- (make-with-output-to-file call-with-binary-output-file))
\ No newline at end of file
+ (make-with-output-to-file call-with-binary-output-file))
+
+(define with-output-to-exclusive-binary-file
+ (make-with-output-to-file call-with-exclusive-binary-output-file))
\ No newline at end of file
#| -*-Scheme-*-
-$Id: io.scm,v 14.88 2008/01/30 20:02:31 cph Exp $
+$Id: io.scm,v 14.89 2009/03/21 07:09:09 riastradh Exp $
Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
(ucode-primitive channel-descriptor 1)
(ucode-primitive channel-nonblocking 1)
(ucode-primitive channel-read 4)
+ (ucode-primitive channel-synchronize 1)
(ucode-primitive channel-write 4)
(ucode-primitive file-length-new 1)
(ucode-primitive file-position 1)
(or (descriptor->channel descriptor)
(make-channel descriptor)))
descriptors))))))
+
+(define (channel-synchronize channel)
+ ((ucode-primitive channel-synchronize 1) (channel-descriptor channel)))
\f
;;;; File Primitives
-(define (file-open primitive filename)
+(define (file-open primitive operator filename)
(let ((channel (open-channel (lambda (p) (primitive filename p)))))
(if (or (channel-type=directory? channel)
(channel-type=unknown? channel))
(begin
(channel-close channel)
- (error:bad-range-argument filename primitive)))
- channel))
+ (file-open primitive
+ operator
+ (error:file-operation filename
+ "open"
+ "file"
+ (if (channel-type=directory? channel)
+ "Is a directory"
+ "Unknown file type")
+ operator
+ (list filename))))
+ channel)))
(define (file-open-input-channel filename)
- (file-open (ucode-primitive new-file-open-input-channel 2) filename))
+ (file-open (ucode-primitive new-file-open-input-channel 2)
+ file-open-input-channel
+ filename))
(define (file-open-output-channel filename)
- (file-open (ucode-primitive new-file-open-output-channel 2) filename))
+ (file-open (ucode-primitive new-file-open-output-channel 2)
+ file-open-output-channel
+ filename))
+
+(define (file-open-exclusive-output-channel filename)
+ (file-open (ucode-primitive new-file-open-exclusive-output-channel 2)
+ file-open-exclusive-output-channel
+ filename))
(define (file-open-io-channel filename)
- (file-open (ucode-primitive new-file-open-io-channel 2) filename))
+ (file-open (ucode-primitive new-file-open-io-channel 2)
+ file-open-io-channel
+ filename))
(define (file-open-append-channel filename)
- (file-open (ucode-primitive new-file-open-append-channel 2) filename))
+ (file-open (ucode-primitive new-file-open-append-channel 2)
+ file-open-append-channel
+ filename))
(define (channel-file-length channel)
((ucode-primitive file-length-new 1) (channel-descriptor channel)))
#| -*-Scheme-*-
-$Id: runtime.pkg,v 14.689 2009/02/18 07:57:41 riastradh Exp $
+$Id: runtime.pkg,v 14.690 2009/03/21 07:09:09 riastradh Exp $
Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
call-with-binary-append-file
call-with-binary-input-file
call-with-binary-output-file
+ call-with-exclusive-binary-output-file
+ call-with-exclusive-output-file
call-with-input-file
call-with-output-file
open-binary-i/o-file
open-binary-input-file
open-binary-output-file
+ open-exclusive-binary-output-file
+ open-exclusive-output-file
open-i/o-file
open-input-file
open-output-file
with-input-from-binary-file
with-input-from-file
with-output-to-binary-file
+ with-output-to-exclusive-binary-file
+ with-output-to-exclusive-file
with-output-to-file)
(initialization (initialize-package!)))
channel-port
channel-read
channel-read-block
+ channel-synchronize
channel-table
channel-type
channel-type=directory?
error:not-directory-channel
error:not-dld-handle
file-open-append-channel
+ file-open-exclusive-output-channel
file-open-input-channel
file-open-io-channel
file-open-output-channel