From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: ludo@gnu.org (Ludovic =?iso-8859-1?Q?Court=E8s?=) Newsgroups: gmane.lisp.guile.bugs Subject: Re: guile 1.9.0 scm_read_hash_extend gc trouble Date: Sun, 28 Jun 2009 01:42:10 +0200 Message-ID: <878wjdqm5p.fsf@gnu.org> References: <20090621120823.M97037@ccrma.Stanford.EDU> <873a9tr46q.fsf@arudy.ossau.uklinux.net> <87skhtpolb.fsf@arudy.ossau.uklinux.net> <20090622171923.M95660@ccrma.Stanford.EDU> <87bpof7sw3.fsf@arudy.ossau.uklinux.net> <20090623191142.M93181@ccrma.Stanford.EDU> <86zlby35wx.fsf@gnu.org> <8763eh4a3k.fsf@arudy.ossau.uklinux.net> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1246146168 10074 80.91.229.12 (27 Jun 2009 23:42:48 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 27 Jun 2009 23:42:48 +0000 (UTC) To: bug-guile@gnu.org Original-X-From: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Sun Jun 28 01:42:41 2009 Return-path: Envelope-to: guile-bugs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1MKhXb-0000bn-QC for guile-bugs@m.gmane.org; Sun, 28 Jun 2009 01:42:40 +0200 Original-Received: from localhost ([127.0.0.1]:39930 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MKhXb-0001nk-6Z for guile-bugs@m.gmane.org; Sat, 27 Jun 2009 19:42:39 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MKhXX-0001kt-ER for bug-guile@gnu.org; Sat, 27 Jun 2009 19:42:35 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MKhXS-0001X9-1e for bug-guile@gnu.org; Sat, 27 Jun 2009 19:42:34 -0400 Original-Received: from [199.232.76.173] (port=49577 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MKhXR-0001Ww-VR for bug-guile@gnu.org; Sat, 27 Jun 2009 19:42:29 -0400 Original-Received: from main.gmane.org ([80.91.229.2]:50912 helo=ciao.gmane.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1MKhXR-0005VA-9T for bug-guile@gnu.org; Sat, 27 Jun 2009 19:42:29 -0400 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1MKhXN-0004ur-RM for bug-guile@gnu.org; Sat, 27 Jun 2009 23:42:25 +0000 Original-Received: from reverse-83.fdn.fr ([80.67.176.83]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 27 Jun 2009 23:42:25 +0000 Original-Received: from ludo by reverse-83.fdn.fr with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 27 Jun 2009 23:42:25 +0000 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 191 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: reverse-83.fdn.fr X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 10 Messidor an 217 de la =?iso-8859-1?Q?R=E9volution?= X-PGP-Key-ID: 0xEA52ECF4 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 821D 815D 902A 7EAB 5CEE D120 7FBA 3D4F EB1F 5364 X-OS: x86_64-unknown-linux-gnu User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux) Cancel-Lock: sha1:eyn4gqgdoKzrJvSO5I6vsExTwoc= X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: bug-guile@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Bug reports for GUILE, GNU's Ubiquitous Extension Language" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Errors-To: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.bugs:4252 Archived-At: --=-=-= Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Hi, Neil Jerram writes: > ludo@gnu.org (Ludovic Courtès) writes: > >> The attached patch adds a new `scm_t_off' type, whose definition does >> not depend on the application's `_FILE_OFFSET_BITS' value. Can you >> confirm that it allows you to build Guile with 32-bit offsets and Snd >> with 64-bit offsets (or vice versa)? >> >> Neil: Does this sound like the right approach? > > Yes, this looks great. (In case it makes a difference, I've reviewed > the master commit, not the patch that you put in email.) Perfect, thank you! > Also I think it means that we can delete some code that was needed to > handle the possibility that off_t might be 32-bit on a platform that > also supports large files. > > - In scm_seek (), the "if (SCM_OPFPORTP (fd_port))" block is now not > needed, because the following more general "if (SCM_OPPORTP > (fd_port))" case will handle 64-bit correctly. > > - Therefore scm_i_fport_seek () can be removed. > > - The "#if GUILE_USE_64_CALLS && HAVE_STAT64 && SIZEOF_OFF_T != > SIZEOF_OFF64_T" implementation of fport_seek () can be removed, > because fport_seek () is now always identical to > fport_seek_or_seek64 (). > > - Plus the same things again but for "truncate" instead of "seek". Also: - `scm_t_off' and `off_t_or_off64_t' are now identical, so the latter could be removed. > Would you agree? Yes. What do you think of the attached patch? On my GNU/Linux machine where 64-bit offsets are used, I see this: --8<---------------cut here---------------start------------->8--- scheme@(guile-user)> (open-input-file "/dev/zero") $1 = # scheme@(guile-user)> (seek $1 (expt 2 33) SEEK_SET) $2 = 0 --8<---------------cut here---------------end--------------->8--- I can't think of a better test case, though. Thanks, Ludo'. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename*=us-ascii''%2c%2cscm_t_off-again.diff Content-Description: The patch diff --git a/libguile/fports.c b/libguile/fports.c index f6e0556..cfb8b25 100644 --- a/libguile/fports.c +++ b/libguile/fports.c @@ -610,8 +610,8 @@ fport_fill_input (SCM port) } } -static off_t_or_off64_t -fport_seek_or_seek64 (SCM port, off_t_or_off64_t offset, int whence) +static scm_t_off +fport_seek (SCM port, scm_t_off offset, int whence) { scm_t_port *pt = SCM_PTAB_ENTRY (port); scm_t_fport *fp = SCM_FSTREAM (port); @@ -662,39 +662,6 @@ fport_seek_or_seek64 (SCM port, off_t_or_off64_t offset, int whence) return result; } -/* If we've got largefile and off_t isn't already off64_t then - fport_seek_or_seek64 needs a range checking wrapper to be fport_seek in - the port descriptor. - - Otherwise if no largefile, or off_t is the same as off64_t (which is the - case on NetBSD apparently), then fport_seek_or_seek64 is right to be - fport_seek already. */ - -#if GUILE_USE_64_CALLS && HAVE_STAT64 && SIZEOF_OFF_T != SIZEOF_OFF64_T -static scm_t_off -fport_seek (SCM port, scm_t_off offset, int whence) -{ - off64_t rv = fport_seek_or_seek64 (port, (off64_t) offset, whence); - if (rv > OFF_T_MAX || rv < OFF_T_MIN) - { - errno = EOVERFLOW; - scm_syserror ("fport_seek"); - } - return (scm_t_off) rv; - -} -#else -#define fport_seek fport_seek_or_seek64 -#endif - -/* `how' has been validated and is one of SEEK_SET, SEEK_CUR or SEEK_END */ -SCM -scm_i_fport_seek (SCM port, SCM offset, int how) -{ - return scm_from_off_t_or_off64_t - (fport_seek_or_seek64 (port, scm_to_off_t_or_off64_t (offset), how)); -} - static void fport_truncate (SCM port, scm_t_off length) { @@ -704,13 +671,6 @@ fport_truncate (SCM port, scm_t_off length) scm_syserror ("ftruncate"); } -int -scm_i_fport_truncate (SCM port, SCM length) -{ - scm_t_fport *fp = SCM_FSTREAM (port); - return ftruncate_or_ftruncate64 (fp->fdes, scm_to_off_t_or_off64_t (length)); -} - /* helper for fport_write: try to write data, using multiple system calls if required. */ #define FUNC_NAME "write_all" diff --git a/libguile/fports.h b/libguile/fports.h index 2687504..cbef0f8 100644 --- a/libguile/fports.h +++ b/libguile/fports.h @@ -3,7 +3,7 @@ #ifndef SCM_FPORTS_H #define SCM_FPORTS_H -/* Copyright (C) 1995,1996,1997,1998,1999,2000,2001, 2006, 2008 Free Software Foundation, Inc. +/* Copyright (C) 1995,1996,1997,1998,1999,2000,2001, 2006, 2008, 2009 Free Software Foundation, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License @@ -59,8 +59,6 @@ SCM_INTERNAL void scm_init_fports (void); /* internal functions */ SCM_INTERNAL SCM scm_i_fdes_to_port (int fdes, long mode_bits, SCM name); -SCM_INTERNAL int scm_i_fport_truncate (SCM, SCM); -SCM_INTERNAL SCM scm_i_fport_seek (SCM, SCM, int); #endif /* SCM_FPORTS_H */ diff --git a/libguile/ports.c b/libguile/ports.c index 98207b0..627fd3f 100644 --- a/libguile/ports.c +++ b/libguile/ports.c @@ -1390,12 +1390,7 @@ SCM_DEFINE (scm_seek, "seek", 3, 0, 0, if (how != SEEK_SET && how != SEEK_CUR && how != SEEK_END) SCM_OUT_OF_RANGE (3, whence); - if (SCM_OPFPORTP (fd_port)) - { - /* go direct to fport code to allow 64-bit offsets */ - return scm_i_fport_seek (fd_port, offset, how); - } - else if (SCM_OPPORTP (fd_port)) + if (SCM_OPPORTP (fd_port)) { scm_t_ptob_descriptor *ptob = scm_ptobs + SCM_PTOBNUM (fd_port); off_t_or_off64_t off = scm_to_off_t_or_off64_t (offset); @@ -1488,11 +1483,6 @@ SCM_DEFINE (scm_truncate_file, "truncate-file", 1, 1, 0, SCM_SYSCALL (rv = ftruncate_or_ftruncate64 (scm_to_int (object), c_length)); } - else if (SCM_OPOUTFPORTP (object)) - { - /* go direct to fport code to allow 64-bit offsets */ - rv = scm_i_fport_truncate (object, length); - } else if (SCM_OPOUTPORTP (object)) { off_t_or_off64_t c_length = scm_to_off_t_or_off64_t (length); --=-=-=--