From dev-return-14218-apmail-apr-dev-archive=apr.apache.org@apr.apache.org Wed May 18 17:22:28 2005 Return-Path: Delivered-To: apmail-apr-dev-archive@www.apache.org Received: (qmail 21036 invoked from network); 18 May 2005 17:22:28 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 18 May 2005 17:22:28 -0000 Received: (qmail 6882 invoked by uid 500); 18 May 2005 16:37:31 -0000 Delivered-To: apmail-apr-dev-archive@apr.apache.org Received: (qmail 6829 invoked by uid 500); 18 May 2005 16:37:29 -0000 Mailing-List: contact dev-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Id: Delivered-To: mailing list dev@apr.apache.org Received: (qmail 6775 invoked by uid 99); 18 May 2005 16:37:29 -0000 X-ASF-Spam-Status: No, hits=0.1 required=10.0 tests=HTML_40_50,HTML_MESSAGE X-Spam-Check-By: apache.org Received-SPF: neutral (hermes.apache.org: local policy) Received: from fallback-mx1.atl.registeredsite.com (HELO fallback-mx1.atl.registeredsite.com) (64.224.219.95) by apache.org (qpsmtpd/0.28) with ESMTP; Wed, 18 May 2005 09:37:26 -0700 Received: from mail9.atl.registeredsite.com (mail9.atl.registeredsite.com [64.224.219.83]) by fallback-mx1.atl.registeredsite.com (8.12.11/8.12.11) with ESMTP id j4IGPD90005760 for ; Wed, 18 May 2005 16:25:13 GMT Received: from mail.pacificdataworks.com (mail.pacificdataworks.com [216.247.106.90]) by mail9.atl.registeredsite.com (8.12.11/8.12.8) with ESMTP id j4IGOg4c003202; Wed, 18 May 2005 16:24:43 GMT Received: from dv670x2.pacificdataworks.com [216.247.106.90] by mail.pacificdataworks.com with ESMTP (SMTPD32-6.06) id AC3589F600F6; Wed, 18 May 2005 12:24:21 -0400 Message-Id: <6.0.3.0.2.20050518091640.02a57480@mail.pacificdataworks.com> X-Sender: abinstock@mail.pacificdataworks.com X-Mailer: QUALCOMM Windows Eudora Version 6.0.3.0 Date: Wed, 18 May 2005 09:24:39 -0700 To: "William A. Rowe, Jr." , Joe Orton From: Andrew Binstock Subject: Re: LP64/P64 model API issue #2 Cc: dev@apr.apache.org In-Reply-To: <6.2.1.2.2.20050518023918.04b1d790@pop3.rowe-clan.net> References: <6.2.1.2.2.20050516133724.07370a90@pop3.rowe-clan.net> <20050517140136.GB5421@redhat.com> <6.2.1.2.2.20050518023918.04b1d790@pop3.rowe-clan.net> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="=====================_1157625156==.ALT" X-Virus-Checked: Checked X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N --=====================_1157625156==.ALT Content-Type: text/plain; charset="us-ascii"; format=flowed Quick note re: > It's embodied by the patch below - the delta of two pointer > offsets result in a size_t (by definition). On LP64/P64, the > sizeof(int) < sizeof(size_t). That's not the definition of size_t. The delta of two pointers you're referring to is ptrdiff_t. size_t is an unsigned integral type that holds the value of a sizeof operation. The relationship you mention need not be true on a 64-bit platform. ---Andrew Binstock >>> re >>> At 12:41 AM 5/18/2005, William A. Rowe, Jr. wrote: >At 09:01 AM 5/17/2005, Joe Orton wrote: > >On Mon, May 16, 2005 at 01:39:20PM -0500, William Rowe wrote: > >> Issue #1; How to manipulate nelts in apr_table_entry? > >> > >> We can preserve the existing behavior of nelts, defining it as > >> a simple int. A few casts are required out of the result of some > >> pointer arithmetic. > > > >Can you explain what casts are needed exactly, and why? > >It's embodied by the patch below - the delta of two pointer >offsets result in a size_t (by definition). On LP64/P64, the >sizeof(int) < sizeof(size_t). > >Author: wrowe >Date: Mon May 16 14:49:49 2005 >New Revision: 170468 > >URL: http://svn.apache.org/viewcvs?rev=170468&view=rev >Log: > > We play pointer math with local 'i', so it must be apr_size_t. > > Until we decide otherwise, cast the pointer math result back to an > int for a nelts result. > >Modified: > apr/apr/trunk/tables/apr_tables.c > >Modified: apr/apr/trunk/tables/apr_tables.c >URL: >http://svn.apache.org/viewcvs/apr/apr/trunk/tables/apr_tables.c?rev=170468&r1=170467&r2=170468&view=diff >============================================================================== >--- apr/apr/trunk/tables/apr_tables.c (original) >+++ apr/apr/trunk/tables/apr_tables.c Mon May 16 14:49:49 2005 >@@ -970,7 +970,7 @@ > */ > apr_table_entry_t **values_tmp = > (apr_table_entry_t **)apr_palloc(pool, n * > sizeof(apr_table_entry_t*)); >- int i; >+ apr_size_t i; > int blocksize; > > /* First pass: sort pairs of elements (blocksize=1) */ >@@ -1156,7 +1156,7 @@ > *dst++ = *src; > } > } while (++src < last_elt); >- t->a.nelts -= (last_elt - dst); >+ t->a.nelts -= (int)(last_elt - dst); > } > > table_reindex(t); Pacific Data Works LLC Technology White Papers www.pacificdataworks.com --=====================_1157625156==.ALT Content-Type: text/html; charset="us-ascii" Quick note re:

> It's embodied by the patch below - the delta of two pointer
> offsets result in a size_t (by definition).  On LP64/P64, the
> sizeof(int) < sizeof(size_t).

That's not the definition of size_t. The delta of
two pointers you're referring to is ptrdiff_t.

size_t is an unsigned integral type that holds the value
of a sizeof operation. The relationship you mention
need not be true on a 64-bit platform.

---Andrew Binstock

>>> re >>>

At 12:41 AM 5/18/2005, William A. Rowe, Jr. wrote:

At 09:01 AM 5/17/2005, Joe Orton wrote:
>On Mon, May 16, 2005 at 01:39:20PM -0500, William Rowe wrote:
>> Issue  #1; How to manipulate nelts in apr_table_entry?
>>
>> We can preserve the existing behavior of nelts, defining it as
>> a simple int.  A few casts are required out of the result of some
>> pointer arithmetic.
>
>Can you explain what casts are needed exactly, and why?

It's embodied by the patch below - the delta of two pointer
offsets result in a size_t (by definition).  On LP64/P64, the
sizeof(int) < sizeof(size_t).

Author: wrowe
Date: Mon May 16 14:49:49 2005
New Revision: 170468

URL: http://svn.apache.org/viewcvs?rev=170468&view=rev
Log:

  We play pointer math with local 'i', so it must be apr_size_t.

  Until we decide otherwise, cast the pointer math result back to an
  int for a nelts result.

Modified:
    apr/apr/trunk/tables/apr_tables.c

Modified: apr/apr/trunk/tables/apr_tables.c
URL: http://svn.apache.org/viewcvs/apr/apr/trunk/tables/apr_tables.c?rev=170468&r1=170467&r2=170468&view=diff
==============================================================================
--- apr/apr/trunk/tables/apr_tables.c (original)
+++ apr/apr/trunk/tables/apr_tables.c Mon May 16 14:49:49 2005
@@ -970,7 +970,7 @@
      */
     apr_table_entry_t **values_tmp =
         (apr_table_entry_t **)apr_palloc(pool, n * sizeof(apr_table_entry_t*));
-    int i;
+    apr_size_t i;
     int blocksize;
 
     /* First pass: sort pairs of elements (blocksize=1) */
@@ -1156,7 +1156,7 @@
                 *dst++ = *src;
             }
         } while (++src < last_elt);
-        t->a.nelts -= (last_elt - dst);
+        t->a.nelts -= (int)(last_elt - dst);
     }
 
     table_reindex(t);


Pacific Data Works LLC
Technology White Papers
www.pacificdataworks.com

--=====================_1157625156==.ALT--