public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* Problem with malloc on PA
@ 2001-04-25 14:29 Matthew Wilcox
  2001-04-25 15:30 ` Roland McGrath
  2001-04-25 15:42 ` Ulrich Drepper
  0 siblings, 2 replies; 6+ messages in thread
From: Matthew Wilcox @ 2001-04-25 14:29 UTC (permalink / raw)
  To: libc-alpha

The PA-RISC architecture requires a lock to be 16-byte aligned.  So we
add __attribute__((aligned (16))) to our lock type and that aligns it
to a 16-byte offset within the struct.  But if the struct isn't 16-byte
aligned, this loses.

malloc() currently returns pointers which are 8-byte aligned.  Would it
be possible to change it so that they're 16-byte aligned?  I took a quick
look at the code, and I saw MALLOC_ALIGN_MASK, but I'm not sure exactly
what effects simply changing this would have.  I suspect I would want
to change MALLOC_ALIGNMENT as well, but not SIZE_SZ?

help greatly appreciated.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Problem with malloc on PA
  2001-04-25 14:29 Problem with malloc on PA Matthew Wilcox
@ 2001-04-25 15:30 ` Roland McGrath
  2001-04-25 15:42 ` Ulrich Drepper
  1 sibling, 0 replies; 6+ messages in thread
From: Roland McGrath @ 2001-04-25 15:30 UTC (permalink / raw)
  To: Matthew Wilcox; +Cc: libc-alpha

> The PA-RISC architecture requires a lock to be 16-byte aligned.  So we
> add __attribute__((aligned (16))) to our lock type and that aligns it
> to a 16-byte offset within the struct.  But if the struct isn't 16-byte
> aligned, this loses.

That sure confer the 16-byte alignment requirement onto the containing struct.
Then you can replace malloc(sizeof(struct foo)) with
memalign(__alignof(struct foo), sizefo(struct foo)).

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Problem with malloc on PA
  2001-04-25 14:29 Problem with malloc on PA Matthew Wilcox
  2001-04-25 15:30 ` Roland McGrath
@ 2001-04-25 15:42 ` Ulrich Drepper
  2001-04-25 16:41   ` Matthew Wilcox
  1 sibling, 1 reply; 6+ messages in thread
From: Ulrich Drepper @ 2001-04-25 15:42 UTC (permalink / raw)
  To: Matthew Wilcox; +Cc: libc-alpha

willy@ldl.fc.hp.com (Matthew Wilcox) writes:

> malloc() currently returns pointers which are 8-byte aligned.  Would it
> be possible to change it so that they're 16-byte aligned?

Not in general, but for PA, yes.

> I took a quick look at the code, and I saw MALLOC_ALIGN_MASK, but
> I'm not sure exactly what effects simply changing this would have.
> I suspect I would want to change MALLOC_ALIGNMENT as well, but not
> SIZE_SZ?

What type does gcc return __alignof__(type) == 16 for?  We should be
able to define

  #define MALLOC_ALIGNMENT MAX(SIZE_SZ + SIZE_SZ, __alignof__(type))

The rest should then fall into place.

-- 
---------------.                          ,-.   1325 Chesapeake Terrace
Ulrich Drepper  \    ,-------------------'   \  Sunnyvale, CA 94089 USA
Red Hat          `--' drepper at redhat.com   `------------------------

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Problem with malloc on PA
  2001-04-25 15:42 ` Ulrich Drepper
@ 2001-04-25 16:41   ` Matthew Wilcox
  2001-04-25 17:04     ` Ulrich Drepper
  0 siblings, 1 reply; 6+ messages in thread
From: Matthew Wilcox @ 2001-04-25 16:41 UTC (permalink / raw)
  To: Ulrich Drepper; +Cc: Matthew Wilcox, libc-alpha

On Wed, Apr 25, 2001 at 03:38:26PM -0700, Ulrich Drepper wrote:
> Not in general, but for PA, yes.

Great!

> What type does gcc return __alignof__(type) == 16 for?  We should be
> able to define
> 
>   #define MALLOC_ALIGNMENT MAX(SIZE_SZ + SIZE_SZ, __alignof__(type))
> 
> The rest should then fall into place.

_lt_spinlock_t in our tree, see my other mail.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Problem with malloc on PA
  2001-04-25 16:41   ` Matthew Wilcox
@ 2001-04-25 17:04     ` Ulrich Drepper
  2001-04-25 17:06       ` Matthew Wilcox
  0 siblings, 1 reply; 6+ messages in thread
From: Ulrich Drepper @ 2001-04-25 17:04 UTC (permalink / raw)
  To: Matthew Wilcox; +Cc: libc-alpha

willy@ldl.fc.hp.com (Matthew Wilcox) writes:

> _lt_spinlock_t in our tree, see my other mail.

I generally available type.  From the above I assume there is none and
this is an issue with the locking hardware support.  In this case
we'll do something else.  We allow MALLOC_ALIGNMENT to be defined on
the compiler command line and only use the default if it isn't.  The
PA Makefiles will then define it as 16.  I'll make this change now.

-- 
---------------.                          ,-.   1325 Chesapeake Terrace
Ulrich Drepper  \    ,-------------------'   \  Sunnyvale, CA 94089 USA
Red Hat          `--' drepper at redhat.com   `------------------------

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Problem with malloc on PA
  2001-04-25 17:04     ` Ulrich Drepper
@ 2001-04-25 17:06       ` Matthew Wilcox
  0 siblings, 0 replies; 6+ messages in thread
From: Matthew Wilcox @ 2001-04-25 17:06 UTC (permalink / raw)
  To: Ulrich Drepper; +Cc: Matthew Wilcox, libc-alpha

On Wed, Apr 25, 2001 at 05:00:27PM -0700, Ulrich Drepper wrote:
> willy@ldl.fc.hp.com (Matthew Wilcox) writes:
> 
> > _lt_spinlock_t in our tree, see my other mail.
> 
> I generally available type.  From the above I assume there is none and
> this is an issue with the locking hardware support.  In this case
> we'll do something else.  We allow MALLOC_ALIGNMENT to be defined on
> the compiler command line and only use the default if it isn't.  The
> PA Makefiles will then define it as 16.  I'll make this change now.

The other patch would make _lt_spinlock_t a generally available type.
For all other architectures, it would be an int, for PA, a 16-byte-aligned
int.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2001-04-25 17:06 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-04-25 14:29 Problem with malloc on PA Matthew Wilcox
2001-04-25 15:30 ` Roland McGrath
2001-04-25 15:42 ` Ulrich Drepper
2001-04-25 16:41   ` Matthew Wilcox
2001-04-25 17:04     ` Ulrich Drepper
2001-04-25 17:06       ` Matthew Wilcox

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).