On Thursday 26 February 2009 08:57:41 pm Rob Landley wrote:
> On Thursday 26 February 2009 02:16:02 Bernhard Reutner-Fischer wrote:
> > On Wed, Feb 25, 2009 at 01:38:39PM -0600, Rob Landley wrote:
> > >On Wednesday 25 February 2009 12:35:54 Bernhard Reutner-Fischer wrote:
> > >> On Tue, Feb 24, 2009 at 12:27:34AM +0000, [email protected] wrote:
> > >> > /* Special exit function which only terminates the current thread. */
> > >> >-extern void __exit_thread (int val) __attribute__ ((noreturn));
> > >> >+extern void __exit_thread (int val) __attribute__ ((__noreturn__));
> > >>
> > >> This should rather be attribute_noreturn
> > >
> > >*shrug* I just made it consistent with all the other declarations in the
> > >file. Is there documentation on this somewhere?
> >
> > libc-symbols.h
>
> That's documentation, is it? I'd previously believed that "This file is
> part of the GNU C Library" at the top of those sort of files meant it
> had been blindly copied from glibc, and not necessarily indicative of
> uClibc's coding style.
>
> Rummage, rummage...
>
> I don't understand your recommendation. include/unistd.h doesn't
> #include libc-symbols.h. Nothing does, it only gets included because
> the uClibc build goes:
>
> CFLAGS := -include $(top_builddir)include/libc-symbols.h
>
> in Rules.mak. This means after the build, when unistd.h gets
> installed in /usr/include, how the heck are programs that #include
> it supposed to get a definition of attribute_noreturn (which would
> be polluting the user symbol space anyway)?
>
> Let me check the current source:
>
> $ find include | grep -v .svn | xargs grep noreturn
> include/libc-symbols.h:# define attribute_noreturn __attribute__
> ((__noreturn__))
> include/libc-symbols.h:# define attribute_noreturn
> include/unistd.h:extern void _exit (int __status) __attribute__
> ((__noreturn__));
> include/unistd.h:extern void __exit_thread (int val) __attribute__
> ((__noreturn__));
> include/setjmp.h: __THROW __attribute__ ((__noreturn__));
> include/setjmp.h: __THROW __attribute__ ((__noreturn__));
> include/setjmp.h: __THROW __attribute__ ((__noreturn__));
> include/stdlib.h:extern void abort (void) __THROW __attribute__
> ((__noreturn__));
> include/stdlib.h:extern void exit (int __status) __THROW __attribute__
> ((__noreturn__));
> include/stdlib.h:extern void _Exit (int __status) __THROW __attribute__
> ((__noreturn__));
> include/err.h: __attribute__ ((__noreturn__, __format__ (__printf__, 2,
> 3)));
> include/err.h: __attribute__ ((__noreturn__, __format__ (__printf__, 2,
> 0)));
> include/err.h: __attribute__ ((__noreturn__, __format__ (__printf__, 2,
> 3)));
> include/err.h: __attribute__ ((__noreturn__, __format__ (__printf__, 2,
> 0)));
>
> So there are exactly two instances in the headers of attribute_noreturn,
> both are the #defines you pointed two in libc-symbols.h. Every other
> instance is __attribute__ ((__noreturn__)).
>
> Out of curiosity, let's see what happens if I make the change, make clean,
> make defconfig, make...
>
> CC libc/sysdeps/linux/common/fstat.os
> libc/sysdeps/linux/common/fstat.c:43: error: '__EI_fstat64' aliased to
> undefined symbol '__GI_fstat64'
> make: *** [libc/sysdeps/linux/common/fstat.os] Error 1
>
> Current svn doesn't build a defconfig on Ubuntu 8.10 x86_64 is what happens.
> (Try with 2.6.29-rc5 kernel headers? Nope, that's not it, it's the .config.)
>
> Ok, so which config symbol controls that...
> ./libc/sysdeps/linux/common/.fstat.os.dep:libc/sysdeps/linux/common/fstat.os:
> libc/sysdeps/linux/common/fstat.c \
>
> .fstat.os.dep? Right, not the bug I'm looking for, so put a bit #if 0/#endif
> around the entire contents of that file. Do it _again_ when lstat.c breaks
> the same way. Do it _again_ for stat.c...
Reproduced.
Oh no. There is a particularly nasty hack around aliases, hidden symbols and
such.
When I see something like *this*, I know it can't be good:
/* need to hide the 64bit prototype or the strong_alias()
* will fail when __NR_stat64 doesnt exist */
#define stat64 __hidestat64
#include <sys/syscall.h>
#include <unistd.h>
...
And it indeed broke with libc_hidden_proto() removal.
Please try this patch. It worked for me (two .config's tested),
and it makes this stuff _simpler_.
--
vda
diff -d -urpN uClibc.8/include/libc-symbols.h uClibc.9/include/libc-symbols.h
--- uClibc.8/include/libc-symbols.h 2009-02-16 15:03:57.000000000 +0100
+++ uClibc.9/include/libc-symbols.h 2009-02-27 23:41:18.000000000 +0100
@@ -177,6 +177,12 @@
# define strong_alias(name, aliasname) _strong_alias(name, aliasname)
# define _strong_alias(name, aliasname) \
extern __typeof (name) aliasname __attribute__ ((alias (#name)));
+/* Same, but does not check for type match. Use sparingly.
+ Example: strong_alias(stat,stat64) may fail, this one works: */
+# define strong_alias_untyped(name, aliasname) \
+ _strong_alias_untyped(name, aliasname)
+# define _strong_alias_untyped(name, aliasname) \
+ extern __typeof (aliasname) aliasname __attribute__ ((alias (#name)));
/* This comes between the return type and function name in
a function definition to make that definition weak. */
diff -d -urpN uClibc.8/libc/sysdeps/linux/common/fstat.c uClibc.9/libc/sysdeps/linux/common/fstat.c
--- uClibc.8/libc/sysdeps/linux/common/fstat.c 2009-02-16 15:04:58.000000000 +0100
+++ uClibc.9/libc/sysdeps/linux/common/fstat.c 2009-02-27 23:02:40.000000000 +0100
@@ -7,19 +7,11 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-/* need to hide the 64bit prototype or the strong_alias()
- * will fail when __NR_fstat64 doesnt exist */
-#define fstat64 __hidefstat64
-
#include <sys/syscall.h>
#include <unistd.h>
#include <sys/stat.h>
#include "xstatconv.h"
-#undef fstat64
-
-/* libc_hidden_proto(fstat) */
-
#define __NR___syscall_fstat __NR_fstat
static __inline__ _syscall2(int, __syscall_fstat, int, fd, struct kernel_stat *, buf)
@@ -37,8 +29,6 @@ int fstat(int fd, struct stat *buf)
libc_hidden_def(fstat)
#if ! defined __NR_fstat64 && defined __UCLIBC_HAS_LFS__
-extern __typeof(fstat) fstat64;
-/* libc_hidden_proto(fstat64) */
-strong_alias(fstat,fstat64)
+strong_alias_untyped(fstat,fstat64)
libc_hidden_def(fstat64)
#endif
diff -d -urpN uClibc.8/libc/sysdeps/linux/common/getdents64.c uClibc.9/libc/sysdeps/linux/common/getdents64.c
--- uClibc.8/libc/sysdeps/linux/common/getdents64.c 2009-02-16 15:04:58.000000000 +0100
+++ uClibc.9/libc/sysdeps/linux/common/getdents64.c 2009-02-27 23:18:24.000000000 +0100
@@ -20,9 +20,6 @@
#if defined __UCLIBC_HAS_LFS__ && defined __NR_getdents64
-/* Experimentally off - libc_hidden_proto(memcpy) */
-/* libc_hidden_proto(lseek64) */
-
# ifndef offsetof
# define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
# endif
@@ -36,7 +33,6 @@ struct kernel_dirent64
char d_name[256];
};
-
# define __NR___syscall_getdents64 __NR_getdents64
static __inline__ _syscall3(int, __syscall_getdents64, int, fd, unsigned char *, dirp, size_t, count)
@@ -102,4 +98,4 @@ ssize_t __getdents64 (int fd, char *buf,
attribute_hidden strong_alias(__getdents64,__getdents)
#endif
-#endif /* __UCLIBC_HAS_LFS__ */
+#endif
diff -d -urpN uClibc.8/libc/sysdeps/linux/common/getdents.c uClibc.9/libc/sysdeps/linux/common/getdents.c
--- uClibc.8/libc/sysdeps/linux/common/getdents.c 2009-02-16 15:04:58.000000000 +0100
+++ uClibc.9/libc/sysdeps/linux/common/getdents.c 2009-02-27 23:42:14.000000000 +0100
@@ -18,6 +18,11 @@
#include <bits/kernel_types.h>
#include <bits/kernel-features.h>
+#if !(defined __UCLIBC_HAS_LFS__ && defined __NR_getdents64 && __WORDSIZE == 64)
+/* If the condition above is met, __getdents is defined as an alias
+ * for __getdents64 (see getdents64.c). Otherwise...
+ */
+
/* With newer versions of linux, the getdents syscall returns d_type
* information after the name field.
*
@@ -42,7 +47,8 @@ ssize_t __getdents (int fd, char *buf, s
#define __NR___syscall_getdents __NR_getdents
static __always_inline _syscall3(int, __syscall_getdents, int, fd, unsigned char *, kdirp, size_t, count)
-#ifdef __ASSUME_GETDENTS32_D_TYPE
+#if defined __ASSUME_GETDENTS32_D_TYPE
+
ssize_t __getdents (int fd, char *buf, size_t nbytes)
{
ssize_t retval;
@@ -72,9 +78,6 @@ ssize_t __getdents (int fd, char *buf, s
#elif ! defined __UCLIBC_HAS_LFS__ || ! defined __NR_getdents64
-/* Experimentally off - libc_hidden_proto(memcpy) */
-/* libc_hidden_proto(lseek) */
-
ssize_t __getdents (int fd, char *buf, size_t nbytes)
{
struct dirent *dp;
@@ -136,8 +139,6 @@ attribute_hidden strong_alias(__getdents
#elif __WORDSIZE == 32
-/* Experimentally off - libc_hidden_proto(memmove) */
-
extern __typeof(__getdents) __getdents64 attribute_hidden;
ssize_t __getdents (int fd, char *buf, size_t nbytes)
{
@@ -165,3 +166,5 @@ ssize_t __getdents (int fd, char *buf, s
}
#endif
+
+#endif
diff -d -urpN uClibc.8/libc/sysdeps/linux/common/lstat.c uClibc.9/libc/sysdeps/linux/common/lstat.c
--- uClibc.8/libc/sysdeps/linux/common/lstat.c 2009-02-16 15:04:58.000000000 +0100
+++ uClibc.9/libc/sysdeps/linux/common/lstat.c 2009-02-27 23:02:00.000000000 +0100
@@ -7,19 +7,11 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-/* need to hide the 64bit prototype or the strong_alias()
- * will fail when __NR_lstat64 doesnt exist */
-#define lstat64 __hidelstat64
-
#include <sys/syscall.h>
#include <unistd.h>
#include <sys/stat.h>
#include "xstatconv.h"
-#undef lstat64
-
-/* libc_hidden_proto(lstat) */
-
#define __NR___syscall_lstat __NR_lstat
static __inline__ _syscall2(int, __syscall_lstat,
const char *, file_name, struct kernel_stat *, buf)
@@ -38,8 +30,6 @@ int lstat(const char *file_name, struct
libc_hidden_def(lstat)
#if ! defined __NR_lstat64 && defined __UCLIBC_HAS_LFS__
-extern __typeof(lstat) lstat64;
-/* libc_hidden_proto(lstat64) */
-strong_alias(lstat,lstat64)
+strong_alias_untyped(lstat,lstat64)
libc_hidden_def(lstat64)
#endif
diff -d -urpN uClibc.8/libc/sysdeps/linux/common/posix_fadvise.c uClibc.9/libc/sysdeps/linux/common/posix_fadvise.c
--- uClibc.8/libc/sysdeps/linux/common/posix_fadvise.c 2009-02-16 15:04:58.000000000 +0100
+++ uClibc.9/libc/sysdeps/linux/common/posix_fadvise.c 2009-02-27 23:01:37.000000000 +0100
@@ -8,15 +8,9 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-/* need to hide the 64bit prototype or the strong_alias()
- * will fail when __NR_fadvise64_64 doesnt exist */
-#define posix_fadvise64 __hideposix_fadvise64
-
#include <sys/syscall.h>
#include <fcntl.h>
-#undef posix_fadvise64
-
#ifdef __NR_fadvise64
#define __NR_posix_fadvise __NR_fadvise64
/* get rid of following conditional when
@@ -49,7 +43,6 @@ int posix_fadvise(int fd, off_t offset,
#endif
#if defined __UCLIBC_HAS_LFS__ && (!defined __NR_fadvise64_64 || !defined _syscall6)
-extern __typeof(posix_fadvise) posix_fadvise64;
strong_alias(posix_fadvise,posix_fadvise64)
#endif
diff -d -urpN uClibc.8/libc/sysdeps/linux/common/sendfile.c uClibc.9/libc/sysdeps/linux/common/sendfile.c
--- uClibc.8/libc/sysdeps/linux/common/sendfile.c 2009-02-16 15:04:58.000000000 +0100
+++ uClibc.9/libc/sysdeps/linux/common/sendfile.c 2009-02-27 23:02:13.000000000 +0100
@@ -7,16 +7,10 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-/* need to hide the 64bit prototype or the strong_alias()
- * will fail when __NR_sendfile64 doesnt exist */
-#define sendfile64 __hidesendfile64
-
#include <sys/syscall.h>
#include <unistd.h>
#include <sys/sendfile.h>
-#undef sendfile64
-
#ifdef __NR_sendfile
_syscall4(ssize_t, sendfile, int, out_fd, int, in_fd, __off_t *, offset,
diff -d -urpN uClibc.8/libc/sysdeps/linux/common/stat.c uClibc.9/libc/sysdeps/linux/common/stat.c
--- uClibc.8/libc/sysdeps/linux/common/stat.c 2009-02-16 15:04:58.000000000 +0100
+++ uClibc.9/libc/sysdeps/linux/common/stat.c 2009-02-27 23:01:50.000000000 +0100
@@ -7,19 +7,11 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-/* need to hide the 64bit prototype or the strong_alias()
- * will fail when __NR_stat64 doesnt exist */
-#define stat64 __hidestat64
-
#include <sys/syscall.h>
#include <unistd.h>
#include <sys/stat.h>
#include "xstatconv.h"
-#undef stat64
-
-/* libc_hidden_proto(stat) */
-
#define __NR___syscall_stat __NR_stat
#undef stat
static __inline__ _syscall2(int, __syscall_stat,
@@ -39,8 +31,6 @@ int stat(const char *file_name, struct s
libc_hidden_def(stat)
#if ! defined __NR_stat64 && defined __UCLIBC_HAS_LFS__
-extern __typeof(stat) stat64;
-/* libc_hidden_proto(stat64) */
-strong_alias(stat,stat64)
+strong_alias_untyped(stat,stat64)
libc_hidden_def(stat64)
#endif
_______________________________________________
uClibc mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/uclibc