public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/60092] posix_memalign not recognized to derive alias and alignment info
Date: Thu, 06 Feb 2014 13:18:00 -0000 [thread overview]
Message-ID: <bug-60092-4-3MlVN9hkXL@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-60092-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60092
--- Comment #7 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Jakub Jelinek from comment #6)
> (In reply to Marc Glisse from comment #4)
> > Hack: when the return value of posix_memalign is ignored, if the platform
> > supports it, replace with a call to aligned_alloc (C11), which has an easier
> > interface.
>
> The question is if posix_memalign is allowed to change errno. If it is,
> then making glibc contains say something like:
>
> extern int __REDIRECT_NTH (__posix_memalign_alias,
> (void ** __ptr, size_t __alignment, size_t
> __size),
> posix_memalign) __nonnull ((1)) __wur;
> extern void *__REDIRECT_NTH (__memalign_alias,
> (size_t __alignment, size_t __size),
> memalign) __attribute__ ((__malloc__,
> __alloc_size__ (2)));
>
> __extern_inline int
> posix_memalign (void **__ptr, size_t __alignment, size_t __size)
> {
> if (__builtin_constant_p (__alignment))
> {
> if (__alignment == 0
> || __alignment & (__alignment - 1)) != 0
> || __alignment % sizeof (void *))
> return EINVAL;
> void *__res = __memalign_alias (__alignment, __size);
> if (__res == NULL)
> return ENOMEM;
> *__ptr = __res;
> return 0;
> }
> return __posix_memalign_alias (__ptr, __alignment, __size);
> }
>
> But looking at glibc sources, even posix_memalign actually changes errno.
> Tbe problem with this inline version is that user aliasing bugs will trigger
> people more often, and that some hack will need to be find out for the
> EINVAL and ENOMEM values (because, stdlib.h is not supposed to include
> errno.h I guess, so it would need to be some __EINVAL/__ENOMEM value
> determined by configure or something).
According to the specification this is wrong. Note that changing errno
is hindering optimization. For example
int foo (int *p)
{
*p = 1;
malloc (4);
return *p;
}
cannot CSE *p because p may point to errno. (works for float *p and
works when using posix_memalign with my patch)
next prev parent reply other threads:[~2014-02-06 13:18 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-06 10:22 [Bug middle-end/60092] New: " rguenth at gcc dot gnu.org
2014-02-06 10:22 ` [Bug middle-end/60092] " rguenth at gcc dot gnu.org
2014-02-06 10:32 ` jakub at gcc dot gnu.org
2014-02-06 11:34 ` rguenth at gcc dot gnu.org
2014-02-06 12:51 ` glisse at gcc dot gnu.org
2014-02-06 13:13 ` jakub at gcc dot gnu.org
2014-02-06 13:18 ` rguenth at gcc dot gnu.org [this message]
2014-02-06 13:42 ` jakub at gcc dot gnu.org
2014-02-06 14:07 ` rguenther at suse dot de
2014-02-06 14:08 ` jakub at gcc dot gnu.org
2014-02-06 14:45 ` rguenth at gcc dot gnu.org
2014-02-06 14:53 ` jakub at gcc dot gnu.org
2014-02-06 15:03 ` rguenther at suse dot de
2014-02-07 9:34 ` rguenth at gcc dot gnu.org
2014-02-07 13:41 ` rguenth at gcc dot gnu.org
2014-02-12 10:01 ` burnus at gcc dot gnu.org
2014-02-12 10:18 ` jakub at gcc dot gnu.org
2014-02-12 13:36 ` rguenth at gcc dot gnu.org
2014-02-14 16:11 ` ro at gcc dot gnu.org
2014-02-14 16:14 ` jakub at gcc dot gnu.org
2014-02-14 16:40 ` ro at CeBiTec dot Uni-Bielefeld.DE
2014-02-15 9:59 ` rguenth at gcc dot gnu.org
2014-02-18 14:52 ` ro at CeBiTec dot Uni-Bielefeld.DE
2014-04-22 11:36 ` jakub at gcc dot gnu.org
2014-04-28 14:36 ` rguenth at gcc dot gnu.org
2014-06-03 13:48 ` rguenth at gcc dot gnu.org
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=bug-60092-4-3MlVN9hkXL@http.gcc.gnu.org/bugzilla/ \
--to=gcc-bugzilla@gcc.gnu.org \
--cc=gcc-bugs@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).