Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 16 Jun 2011 08:12:26 -0700
From:      Garrett Cooper <yanegomi@gmail.com>
To:        Bruce Evans <brde@optusnet.com.au>
Cc:        svn-src-head@freebsd.org, svn-src-all@freebsd.org, Tai-hwa Liang <avatar@mmlab.cse.yzu.edu.tw>, src-committers@freebsd.org
Subject:   Re: svn commit: r223139 - head/lib/libstand
Message-ID:  <BANLkTinpp95JyEp8sVR7uL-sAWor-69mCA@mail.gmail.com>
In-Reply-To: <20110616235239.D1926@besplex.bde.org>
References:  <201106160714.p5G7Etfx017112@svn.freebsd.org> <BANLkTi=X0_SBLAQ6t7amTLv7jF6_oXAV4Q@mail.gmail.com> <BANLkTimG4svFzv1QPiKQcC7QdChLica9xA@mail.gmail.com> <20110616180803.D1005@besplex.bde.org> <11061619555315.44181@www.mmlab.cse.yzu.edu.tw> <20110616235239.D1926@besplex.bde.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, Jun 16, 2011 at 7:06 AM, Bruce Evans <brde@optusnet.com.au> wrote:
> On Thu, 16 Jun 2011, Tai-hwa Liang wrote:
>
>> On Thu, 16 Jun 2011, Bruce Evans wrote:
>>
>>> On Thu, 16 Jun 2011, Garrett Cooper wrote:
>>>>
>>>> And you need to add #include <stdint.h> to stand.h in order to get
>>>> uintmax_t. Here's a proper patch for amd64..
>>>
>>> This would add namespace pollution. =A0stand.h doesn't use anything in
>>> <stdint.h>. =A0It depends on normal namespace pollution in an XXX secti=
on
>>> in <sys/types.h> for the declaration of uintptr_t. =A0It and other head=
ers
>>> should use __uintptr_t instead. =A0Strangely, <sys/types.h> declares
>>> uintptr_t but not uintmax_t.
>>
>> =A0What about casting to __uintmax_t instead?
>>
>> Index: zalloc.c
>> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
>> --- zalloc.c =A0 =A0(revision 223146)
>> +++ zalloc.c =A0 =A0(working copy)
>> @@ -154,7 +154,7 @@
>> =A0 =A0if ((char *)ptr < (char *)mp->mp_Base ||
>> =A0 =A0 =A0 =A0(char *)ptr + bytes > (char *)mp->mp_End ||
>> =A0 =A0 =A0 =A0((iaddr_t)ptr & MEMNODE_SIZE_MASK) !=3D 0)
>> - =A0 =A0 =A0 panic("zfree(%p,%ju): wild pointer", ptr, bytes);
>> + =A0 =A0 =A0 panic("zfree(%p,%ju): wild pointer", ptr, (__uintmax_t)byt=
es);
>> ...
>
> zalloc.c is not the (header) implementation, so it should not use the
> implementation detail (anything beginning with __).
>
> The latest tinderbox errors for this are hard to understand. =A0For amd64
> they say:
>
>> /src/lib/libstand/zalloc.c: In function 'zfree':
>> /src/lib/libstand/zalloc.c:157: warning: format '%ju' expects type
>> 'uintmax_t', but argument 3 has type 'iaddr_t'
>
> but amd64 seems to be just like sparc64 -- both seem to declare all the
> types as `unsigned long' at the lowest level. =A0I would expect all 64-bi=
t
> arches to do this, although this is logically wrong (it makes the largest
> integral type uintmax_t logically smaller than the standard bogus type
> unsigned long long). =A0This logic error is partly intentional (it detect=
s
> different type mismatches than uintmax_t =3D `unsigned long long' combine=
d
> with uint64_t =3D `unsigned long' would).

    My second patch when applied gets one past tinderbox on powerpc..
waiting for powerpc64 and sparc64 to complete. Namespace pollution is
one thing, but stdint.h isn't that bad IMHO -- I just find it funny
that iaddr_t had to be typedef'ed to uintptr_t in the first place.
Thanks!
-Garrett



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?BANLkTinpp95JyEp8sVR7uL-sAWor-69mCA>