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: Wed, 24 Jun 2009 01:07:58 +0200 Message-ID: <86zlby35wx.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> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1245798658 9667 80.91.229.12 (23 Jun 2009 23:10:58 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 23 Jun 2009 23:10:58 +0000 (UTC) To: bug-guile@gnu.org Original-X-From: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Wed Jun 24 01:10:51 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 1MJF8d-0006zc-D8 for guile-bugs@m.gmane.org; Wed, 24 Jun 2009 01:10:51 +0200 Original-Received: from localhost ([127.0.0.1]:52192 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MJF8c-00043K-Ff for guile-bugs@m.gmane.org; Tue, 23 Jun 2009 19:10:50 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MJF8Y-00041x-EF for bug-guile@gnu.org; Tue, 23 Jun 2009 19:10:46 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MJF8T-0003uD-Lv for bug-guile@gnu.org; Tue, 23 Jun 2009 19:10:46 -0400 Original-Received: from [199.232.76.173] (port=55446 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MJF8T-0003uA-DL for bug-guile@gnu.org; Tue, 23 Jun 2009 19:10:41 -0400 Original-Received: from main.gmane.org ([80.91.229.2]:54408 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 1MJF8S-0000MA-Lz for bug-guile@gnu.org; Tue, 23 Jun 2009 19:10:41 -0400 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1MJF8P-0002K2-7b for bug-guile@gnu.org; Tue, 23 Jun 2009 23:10:37 +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 ; Tue, 23 Jun 2009 23:10:37 +0000 Original-Received: from ludo by reverse-83.fdn.fr with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 23 Jun 2009 23:10:37 +0000 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 251 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: 6 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: i486-pc-linux-gnu User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.91 (gnu/linux) Cancel-Lock: sha1:GLZJu4PPUrF4aq605lMLtRaTL0o= 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:4244 Archived-At: --=-=-= Hello, "Bill Schottstaedt" writes: > This is trickier than I thought -- it's not the GC after all. In my configure > script for Snd, autoconf defines _FILE_OFFSET_BITS to 64 if large files are implemented. > The config.h "include" precedes everything else. When scm_getc is called > within guile, it thinks sizeof(scm_t_port) is 92. Everything is fine until > my skip comment procedure is called (with this 92 byte struct) -- it > thinks the scm_t_port size is 104, and fields like rw_active (in scm_getc > which is apparently expanded inline) are not where it expects them to be! > If I undef _FILE_OFFSET_BITS, both agree on the struct size, and there > is no problem. Ouch! That's a good illustration of the harm that can be done by exposing data structures. 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? Thanks, Ludo'. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename*=us-ascii''%2c%2cport-off64-t.diff Content-Description: The patch diff --git a/libguile/fports.c b/libguile/fports.c index de788c9..53d1140 100644 --- a/libguile/fports.c +++ b/libguile/fports.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1995,1996,1997,1998,1999,2000,2001, 2002, 2003, 2004, 2006, 2007, 2008 Free Software Foundation, Inc. +/* Copyright (C) 1995,1996,1997,1998,1999,2000,2001, 2002, 2003, 2004, 2006, 2007, 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 @@ -671,8 +671,8 @@ fport_seek_or_seek64 (SCM port, off_t_or_off64_t offset, int whence) fport_seek already. */ #if GUILE_USE_64_CALLS && HAVE_STAT64 && SIZEOF_OFF_T != SIZEOF_OFF64_T -static off_t -fport_seek (SCM port, off_t offset, int whence) +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) @@ -696,7 +696,7 @@ scm_i_fport_seek (SCM port, SCM offset, int how) } static void -fport_truncate (SCM port, off_t length) +fport_truncate (SCM port, scm_t_off length) { scm_t_fport *fp = SCM_FSTREAM (port); diff --git a/libguile/gen-scmconfig.c b/libguile/gen-scmconfig.c index 85ebfae..9715973 100644 --- a/libguile/gen-scmconfig.c +++ b/libguile/gen-scmconfig.c @@ -400,6 +400,22 @@ main (int argc, char *argv[]) pf ("#define SCM_HAVE_READDIR64_R 0 /* 0 or 1 */\n"); #endif + /* Arrange so that we have a file offset type that reflects the one + used when compiling Guile, regardless of the application's + `_FILE_OFFSET_BITS' says. + + Note that we can't define `scm_t_off' in terms of `off_t' or + `off64_t' because they may or may not be available depending on + how the application that uses Guile is compiled. */ + +#if defined GUILE_USE_64_CALLS && defined HAVE_STAT64 + pf ("typedef scm_t_int64 scm_t_off;\n"); +#elif SIZEOF_OFF_T == SIZEOF_INT + pf ("typedef int scm_t_off;\n"); +#else + pf ("typedef long int scm_t_off;\n"); +#endif + #if USE_DLL_IMPORT pf ("\n"); pf ("/* Define some additional CPP macros on Win32 platforms. */\n"); diff --git a/libguile/ports.c b/libguile/ports.c index 248e0a4..1b7c9a5 100644 --- a/libguile/ports.c +++ b/libguile/ports.c @@ -222,15 +222,14 @@ scm_set_port_close (scm_t_bits tc, int (*close) (SCM)) } void -scm_set_port_seek (scm_t_bits tc, off_t (*seek) (SCM port, - off_t OFFSET, - int WHENCE)) +scm_set_port_seek (scm_t_bits tc, + scm_t_off (*seek) (SCM, scm_t_off, int)) { scm_ptobs[SCM_TC2PTOBNUM (tc)].seek = seek; } void -scm_set_port_truncate (scm_t_bits tc, void (*truncate) (SCM port, off_t length)) +scm_set_port_truncate (scm_t_bits tc, void (*truncate) (SCM, scm_t_off)) { scm_ptobs[SCM_TC2PTOBNUM (tc)].truncate = truncate; } diff --git a/libguile/ports.h b/libguile/ports.h index 64a0a89..48ed770 100644 --- a/libguile/ports.h +++ b/libguile/ports.h @@ -29,8 +29,6 @@ #include "libguile/struct.h" #include "libguile/threads.h" -/* Not sure if this is a good idea. We need it for off_t. */ -#include @@ -70,7 +68,7 @@ typedef struct unsigned char *read_buf; /* buffer start. */ const unsigned char *read_pos;/* the next unread char. */ unsigned char *read_end; /* pointer to last buffered char + 1. */ - off_t read_buf_size; /* size of the buffer. */ + scm_t_off read_buf_size; /* size of the buffer. */ /* when chars are put back into the buffer, e.g., using peek-char or unread-string, the read-buffer pointers are switched to cbuf. @@ -79,7 +77,7 @@ typedef struct unsigned char *saved_read_buf; const unsigned char *saved_read_pos; unsigned char *saved_read_end; - off_t saved_read_buf_size; + scm_t_off saved_read_buf_size; /* write requests are saved into this buffer at write_pos until it reaches write_buf + write_buf_size, then the ptob flush is @@ -88,7 +86,7 @@ typedef struct unsigned char *write_buf; /* buffer start. */ unsigned char *write_pos; /* pointer to last buffered char + 1. */ unsigned char *write_end; /* pointer to end of buffer + 1. */ - off_t write_buf_size; /* size of the buffer. */ + scm_t_off write_buf_size; /* size of the buffer. */ unsigned char shortbuf; /* buffer for "unbuffered" streams. */ @@ -185,8 +183,8 @@ typedef struct scm_t_ptob_descriptor int (*fill_input) (SCM port); int (*input_waiting) (SCM port); - off_t (*seek) (SCM port, off_t OFFSET, int WHENCE); - void (*truncate) (SCM port, off_t length); + scm_t_off (*seek) (SCM port, scm_t_off OFFSET, int WHENCE); + void (*truncate) (SCM port, scm_t_off length); } scm_t_ptob_descriptor; @@ -224,12 +222,12 @@ SCM_API void scm_set_port_end_input (scm_t_bits tc, void (*end_input) (SCM port, int offset)); SCM_API void scm_set_port_seek (scm_t_bits tc, - off_t (*seek) (SCM port, - off_t OFFSET, + scm_t_off (*seek) (SCM port, + scm_t_off OFFSET, int WHENCE)); SCM_API void scm_set_port_truncate (scm_t_bits tc, void (*truncate) (SCM port, - off_t length)); + scm_t_off length)); SCM_API void scm_set_port_input_waiting (scm_t_bits tc, int (*input_waiting) (SCM)); SCM_API SCM scm_char_ready_p (SCM port); size_t scm_take_from_input_buffers (SCM port, char *dest, size_t read_len); diff --git a/libguile/r6rs-ports.c b/libguile/r6rs-ports.c index d77c214..4b6a251 100644 --- a/libguile/r6rs-ports.c +++ b/libguile/r6rs-ports.c @@ -125,8 +125,8 @@ bip_fill_input (SCM port) return result; } -static off_t -bip_seek (SCM port, off_t offset, int whence) +static scm_t_off +bip_seek (SCM port, scm_t_off offset, int whence) #define FUNC_NAME "bip_seek" { off_t c_result = 0; @@ -217,8 +217,8 @@ cbp_mark (SCM port) return SCM_BOOL_F; } -static off_t -cbp_seek (SCM port, off_t offset, int whence) +static scm_t_off +cbp_seek (SCM port, scm_t_off offset, int whence) #define FUNC_NAME "cbp_seek" { SCM result; @@ -885,8 +885,8 @@ bop_write (SCM port, const void *data, size_t size) buf->len = (buf->len > buf->pos) ? buf->len : buf->pos; } -static off_t -bop_seek (SCM port, off_t offset, int whence) +static scm_t_off +bop_seek (SCM port, scm_t_off offset, int whence) #define FUNC_NAME "bop_seek" { scm_t_bop_buffer *buf; diff --git a/libguile/strports.c b/libguile/strports.c index 3f8a22e..4f816f2 100644 --- a/libguile/strports.c +++ b/libguile/strports.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1995,1996,1998,1999,2000,2001,2002, 2003, 2005, 2006 Free Software Foundation, Inc. +/* Copyright (C) 1995,1996,1998,1999,2000,2001,2002, 2003, 2005, 2006, 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 @@ -199,8 +199,8 @@ st_end_input (SCM port, int offset) pt->rw_active = SCM_PORT_NEITHER; } -static off_t -st_seek (SCM port, off_t offset, int whence) +static scm_t_off +st_seek (SCM port, scm_t_off offset, int whence) { scm_t_port *pt = SCM_PTAB_ENTRY (port); off_t target; @@ -272,7 +272,7 @@ st_seek (SCM port, off_t offset, int whence) } static void -st_truncate (SCM port, off_t length) +st_truncate (SCM port, scm_t_off length) { scm_t_port *pt = SCM_PTAB_ENTRY (port); --=-=-=--