From: Jakub Jelinek <jakub@redhat.com>
To: Ulrich Drepper <drepper@redhat.com>, Roland McGrath <roland@redhat.com>
Cc: Glibc hackers <libc-hacker@sources.redhat.com>
Subject: Re: [PATCH] Use extern inline wrappers instead of macros for some checking functions
Date: Thu, 10 Mar 2005 13:23:00 -0000 [thread overview]
Message-ID: <20050310132258.GZ4777@sunsite.mff.cuni.cz> (raw)
In-Reply-To: <20050309190657.GW4777@sunsite.mff.cuni.cz>
On Wed, Mar 09, 2005 at 08:06:57PM +0100, Jakub Jelinek wrote:
> This patch:
> a) fixes getwd, pread and pread64 that were broken before
> b) starts using extern inline wrappers instead of macros for those checking
> routines that have no GCC builtins. Although programs using say
> somestruct->read (buf, 1, 2, 3);
> without #undef read or using (somestruct->read) (buf, 1, 2, 3);
> are broken, there are simply too many of them.
> The wrappers for routines that have checking builtins in GCC
> (like memcpy, strcpy or e.g. printf) should stay as is, so that warnings
> about them are reported on the place where the bug occurs instead of
> always in say bits/string3.h.
> c) improves test coverage of these functions
> Tested with GCC 4.0-RH with:
> -#if _FORTIFY_SOURCE > 0 && __GNUC_PREREQ (4, 1) && __OPTIMIZE__ > 0
> +#if _FORTIFY_SOURCE > 0 && (__GNUC_PREREQ (4, 1) || (defined __GNUC_RH_RELEASE__ && __GNUC_PREREQ (4, 0))) && __OPTIMIZE__ > 0
> so that tst-chk{2,3} actually test something.
Roland asked off-line if I could use __typeof for the __*_alias prototypes.
Unfortunately, it seems I can't.
With
extern ssize_t __read_chk (int __fd, void *__buf, size_t __nbytes,
size_t __buflen) __wur;
extern __typeof (read) __read_alias __asm__ ("read") __wur;
extern __always_inline __wur ssize_t
read (int __fd, void *__buf, size_t __nbytes)
{
if (__bos0 (__buf) != (size_t) -1
&& (!__builtin_constant_p (__nbytes) || __nbytes > __bos0 (__buf)))
return __read_chk (__fd, __buf, __nbytes, __bos0 (__buf));
return __read_alias (__fd, __buf, __nbytes);
}
All GCCs I have tried (3.2.3-RH, 3.3.4-RH, 3.4.3-RH, 4.0 branch) treat
__typeof (read) as a "call" and thus this triggers a warning in
all those compilers:
/usr/include/unistd.h:312: warning: 'read' declared inline after being called
/usr/include/unistd.h:312: warning: previous declaration of 'read' was here
So I'll just post an __always_inline patch on top of this one.
Jakub
next prev parent reply other threads:[~2005-03-10 13:23 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-03-09 19:07 Jakub Jelinek
2005-03-10 13:23 ` Jakub Jelinek [this message]
2005-03-19 0:12 ` Ulrich Drepper
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=20050310132258.GZ4777@sunsite.mff.cuni.cz \
--to=jakub@redhat.com \
--cc=drepper@redhat.com \
--cc=libc-hacker@sources.redhat.com \
--cc=roland@redhat.com \
/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).