This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] Expand INTERNAL_SIZE_T macro.
- From: OndÅej BÃlka <neleai at seznam dot cz>
- To: Will Newton <will dot newton at linaro dot org>
- Cc: libc-alpha <libc-alpha at sourceware dot org>
- Date: Wed, 11 Dec 2013 21:12:12 +0100
- Subject: Re: [PATCH] Expand INTERNAL_SIZE_T macro.
- Authentication-results: sourceware.org; auth=none
- References: <20131209182119 dot GA4601 at domone dot podge> <CANu=DmhgUeGer7BKZaD0C8rCp+fssPa-kg2PcHgVBtKYYca4hw at mail dot gmail dot com>
On Tue, Dec 10, 2013 at 10:16:10AM +0000, Will Newton wrote:
> On 9 December 2013 18:21, OndÅej BÃlka <neleai@seznam.cz> wrote:
> > Hi,
> >
> > other malloc macro that causes bit of confusion is INTERNAL_SIZE_T.
> > We define it as size_t, only way this could be usable is user compiling
> > custom allocator.
> >
> > I am for dropping these as we then do not have to assume that change.
> >
> >
> > * malloc/hooks.c (mem2mem_check, top_check, free_check, realloc_check):
> > Change INTERNAL_SIZE_T to size_t.
> > * malloc/malloc.c (__malloc_assert, static, mremap_chunk,
> > __libc_malloc, __libc_realloc, __libc_calloc, _int_malloc, _int_free,
> > _int_realloc, _int_memalign, __malloc_trim, int_mallinfo): Likewise.
>
> This looks like a good cleanup to me, although I would be grateful if
> someone with more experience in this area could give their thoughts.
>
So does somebody else have comments?
> > - Changing default word sizes:
> > -
> > - INTERNAL_SIZE_T size_t
> > - MALLOC_ALIGNMENT MAX (2 * sizeof(INTERNAL_SIZE_T),
> > - __alignof__ (long double))
> > -
>
> Should the MALLOC_ALIGNMENT comment stay?
>
It duplicates a comment before MALLOC_ALIGNMENT definition, it is not needed here.
> >
> > #define REQUEST_OUT_OF_RANGE(req) \
> > ((unsigned long)(req) >= \
> > - (unsigned long)(INTERNAL_SIZE_T)(-2 * MINSIZE))
> > + (unsigned long)(size_t)(-2 * MINSIZE))
>
> I think these casts can go if we use size_t.
>
There are many other casts that can go away, that cleanup should be done
in separate patch.
> >
> > /* internal size_t must be no wider than pointer type */
> > - assert(sizeof(INTERNAL_SIZE_T) <= sizeof(char*));
> > + assert(sizeof(size_t) <= sizeof(char*));
>
> Should this use SIZE_SZ?
>
Yes, but this also belongs to separate patch. Also 2 * SIZE_SZ is in
most of places size of header so we should use HEADER_SZ or such.