Return-Path: Mailing-List: contact dev-help@apr.apache.org; run by ezmlm Delivered-To: mailing list dev@apr.apache.org Received: (qmail 86498 invoked from network); 22 Jan 2001 10:36:42 -0000 Received: from test.webdav.org (HELO kurgan.lyra.org) (198.144.203.199) by h31.sny.collab.net with SMTP; 22 Jan 2001 10:36:42 -0000 Received: (from gstein@localhost) by kurgan.lyra.org (8.9.3/8.9.3) id CAA15854 for dev@apr.apache.org; Mon, 22 Jan 2001 02:37:04 -0800 X-Authentication-Warning: kurgan.lyra.org: gstein set sender to gstein@lyra.org using -f Date: Mon, 22 Jan 2001 02:37:04 -0800 From: Greg Stein To: dev@apr.apache.org Subject: extending finfo (was: Re: apr_stat) Message-ID: <20010122023704.E704@lyra.org> Mail-Followup-To: dev@apr.apache.org References: <200101200434.UAA15178@scv2.apple.com> <200101201432.JAA13302@devsys.jaguNET.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2i In-Reply-To: <200101201432.JAA13302@devsys.jaguNET.com>; from jim@jaguNET.com on Sat, Jan 20, 2001 at 09:32:39AM -0500 X-URL: http://www.lyra.org/greg/ X-Spam-Rating: h31.sny.collab.net 1.6.2 0/1000/N On Sat, Jan 20, 2001 at 09:32:39AM -0500, Jim Jagielski wrote: > Wilfredo Sanchez wrote: > > > Well since it's a public type, we are screwed on binary compatibity if > > > we wait for those decisions until later. Love reading that sys/stat.h > > > header :-/ I'm actually interested in any feedback from Fred or Brian, > > > if there are other things we should have our eyes on. > > > > You can pad the structure with some reserved field space. We do that > > with device driver API, and it's saved us a few times. > > +1 on this. reserved is your friend :) Actually, "reserved" can be troublesome because it might not be enough space, the alignments of the fields could off (e.g. reserve a long, want a short), we may reserve too much, etc. Microsoft actually handled this very well. You pass the size of your structure (as a param, or as the first field of the structure). Based on the size of the structure, APR can determine what the app was compiled against and what it can accept. For example, let's say we ship 1.0 with: struct foo { int a; int b; }; Some app (call it A1) compiles against that, and passes sizeof(struct foo) to the call (let's say it is 8 bytes). In V2, we extend the structure: struct foo { int a; int b; char *c; long d; }; A1 is still passing 8, so APR knows it was built against the V1 structure and just fills in "a" and "b". Along comes A2 and it passes 16 for the size. APR fills in all four fields. In our apr_stat case, note that the size of the structure also tells APR whether/how to interpret the "wanted" bits and whether to even *bother* with fetching the data for "c" and "d". Cheers, -g -- Greg Stein, http://www.lyra.org/