From carmelo at uclibc.org Tue Apr 1 09:07:08 2008 From: carmelo at uclibc.org (carmelo at uclibc.org) Date: Tue, 1 Apr 2008 09:07:08 -0700 (PDT) Subject: svn commit: trunk/uClibc/libc/sysdeps/linux/common Message-ID: <20080401160708.CD0F93C544@busybox.net> Author: carmelo Date: 2008-04-01 09:07:06 -0700 (Tue, 01 Apr 2008) New Revision: 21613 Log: Fix remap_file_pages prototype and use mman.h header Modified: trunk/uClibc/libc/sysdeps/linux/common/remap_file_pages.c Changeset: Modified: trunk/uClibc/libc/sysdeps/linux/common/remap_file_pages.c =================================================================== --- trunk/uClibc/libc/sysdeps/linux/common/remap_file_pages.c 2008-04-01 15:29:03 UTC (rev 21612) +++ trunk/uClibc/libc/sysdeps/linux/common/remap_file_pages.c 2008-04-01 16:07:06 UTC (rev 21613) @@ -5,12 +5,12 @@ * * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. */ - +#include #include #ifdef __NR_remap_file_pages -_syscall5(int, remap_file_pages, unsigned long, start, unsigned long, size, - unsigned long, prot, unsigned long, pgoff, unsigned long, flags); +_syscall5(int, remap_file_pages, void *, __start, size_t, __size, + int, __prot, size_t, __pgoff, int, __flags); #endif From bugs at busybox.net Tue Apr 1 09:26:26 2008 From: bugs at busybox.net (bugs at busybox.net) Date: Tue, 1 Apr 2008 09:26:26 -0700 Subject: [uClibc 0002714]: sprintf should not pull in most of stdio.h code Message-ID: The following issue has been SUBMITTED. ====================================================================== http://busybox.net/bugs/view.php?id=2714 ====================================================================== Reported By: vda Assigned To: uClibc ====================================================================== Project: uClibc Issue ID: 2714 Category: Stdio Reproducibility: always Severity: minor Priority: normal Status: assigned ====================================================================== Date Submitted: 04-01-2008 09:26 PDT Last Modified: 04-01-2008 09:26 PDT ====================================================================== Summary: sprintf should not pull in most of stdio.h code Description: Use of [v]s[n]printf functions does not require application to necessarily pull in the whole of stdio.h machinery. Only formatting routines are needed. Currently I observe +12k growth when I add a sprintf(dummy_buf, "%d", some_var) to the program which otherwise does not use stdio.h. For one, seek and write functions ideally should not appear. ====================================================================== Issue History Date Modified Username Field Change ====================================================================== 04-01-08 09:26 vda New Issue 04-01-08 09:26 vda Status new => assigned 04-01-08 09:26 vda Assigned To => uClibc ====================================================================== From bugs at busybox.net Tue Apr 1 11:13:40 2008 From: bugs at busybox.net (bugs at busybox.net) Date: Tue, 1 Apr 2008 11:13:40 -0700 Subject: [uClibc 0002714]: sprintf should not pull in most of stdio.h code Message-ID: A NOTE has been added to this issue. ====================================================================== http://busybox.net/bugs/view.php?id=2714 ====================================================================== Reported By: vda Assigned To: uClibc ====================================================================== Project: uClibc Issue ID: 2714 Category: Stdio Reproducibility: always Severity: minor Priority: normal Status: assigned ====================================================================== Date Submitted: 04-01-2008 09:26 PDT Last Modified: 04-01-2008 11:13 PDT ====================================================================== Summary: sprintf should not pull in most of stdio.h code Description: Use of [v]s[n]printf functions does not require application to necessarily pull in the whole of stdio.h machinery. Only formatting routines are needed. Currently I observe +12k growth when I add a sprintf(dummy_buf, "%d", some_var) to the program which otherwise does not use stdio.h. For one, seek and write functions ideally should not appear. ====================================================================== ---------------------------------------------------------------------- vda - 04-01-08 11:13 ---------------------------------------------------------------------- Since I have a good test case, I can provide more info (link map rules!). seeks are pulled in because of __UCLIBC_HAS_STDIO_AUTO_RW_TRANSITION__ here: #ifdef __UCLIBC_HAS_WCHAR__ int attribute_hidden __stdio_trans2w_o(FILE * __restrict stream, int oflag) #else int attribute_hidden __stdio_trans2w(FILE * __restrict stream) #endif { ... if (__STDIO_STREAM_IS_READING(stream)) { if (!__FEOF_UNLOCKED(stream)) { #ifdef __UCLIBC_HAS_STDIO_AUTO_RW_TRANSITION__ /* Need to seek to correct position if we have buffered * read data or ungots. If appending, we might as well * seek to the end. * * NOTE: If the OS does not handle append files correctly, * this is insufficient since we would need to seek to * the end even if not reading.*/ if (((__STDIO_STREAM_BUFFER_RAVAIL(stream)) || (stream->__modeflags & __FLAG_UNGOT)) && fseek(stream, 0L, ... which is pulled in because of STDIO_STREAM_TRANS_TO_WRITE here: int VFPRINTF (FILE * __restrict stream, register const FMT_TYPE * __restrict format, va_list arg) { ... if #ifdef L_vfprintf (!__STDIO_STREAM_IS_NARROW_WRITING(stream) && __STDIO_STREAM_TRANS_TO_WRITE(stream, __FLAG_NARROW)) #else (!__STDIO_STREAM_IS_WIDE_WRITING(stream) && __STDIO_STREAM_TRANS_TO_WRITE(stream, __FLAG_WIDE)) #endif Issue History Date Modified Username Field Change ====================================================================== 04-01-08 09:26 vda New Issue 04-01-08 09:26 vda Status new => assigned 04-01-08 09:26 vda Assigned To => uClibc 04-01-08 11:13 vda Note Added: 0006274 ====================================================================== From bugs at busybox.net Tue Apr 1 12:04:27 2008 From: bugs at busybox.net (bugs at busybox.net) Date: Tue, 1 Apr 2008 12:04:27 -0700 Subject: [uClibc 0002714]: sprintf should not pull in most of stdio.h code Message-ID: <89d832fc42bf44223c0012fe719cfc35@bugs.uclibc.org> A NOTE has been added to this issue. ====================================================================== http://busybox.net/bugs/view.php?id=2714 ====================================================================== Reported By: vda Assigned To: uClibc ====================================================================== Project: uClibc Issue ID: 2714 Category: Stdio Reproducibility: always Severity: minor Priority: normal Status: assigned ====================================================================== Date Submitted: 04-01-2008 09:26 PDT Last Modified: 04-01-2008 12:04 PDT ====================================================================== Summary: sprintf should not pull in most of stdio.h code Description: Use of [v]s[n]printf functions does not require application to necessarily pull in the whole of stdio.h machinery. Only formatting routines are needed. Currently I observe +12k growth when I add a sprintf(dummy_buf, "%d", some_var) to the program which otherwise does not use stdio.h. For one, seek and write functions ideally should not appear. ====================================================================== ---------------------------------------------------------------------- vda - 04-01-08 11:13 ---------------------------------------------------------------------- Since I have a good test case, I can provide more info (link map rules!). seeks are pulled in because of __UCLIBC_HAS_STDIO_AUTO_RW_TRANSITION__ here: #ifdef __UCLIBC_HAS_WCHAR__ int attribute_hidden __stdio_trans2w_o(FILE * __restrict stream, int oflag) #else int attribute_hidden __stdio_trans2w(FILE * __restrict stream) #endif { ... if (__STDIO_STREAM_IS_READING(stream)) { if (!__FEOF_UNLOCKED(stream)) { #ifdef __UCLIBC_HAS_STDIO_AUTO_RW_TRANSITION__ /* Need to seek to correct position if we have buffered * read data or ungots. If appending, we might as well * seek to the end. * * NOTE: If the OS does not handle append files correctly, * this is insufficient since we would need to seek to * the end even if not reading.*/ if (((__STDIO_STREAM_BUFFER_RAVAIL(stream)) || (stream->__modeflags & __FLAG_UNGOT)) && fseek(stream, 0L, ... which is pulled in because of STDIO_STREAM_TRANS_TO_WRITE here: int VFPRINTF (FILE * __restrict stream, register const FMT_TYPE * __restrict format, va_list arg) { ... if #ifdef L_vfprintf (!__STDIO_STREAM_IS_NARROW_WRITING(stream) && __STDIO_STREAM_TRANS_TO_WRITE(stream, __FLAG_NARROW)) #else (!__STDIO_STREAM_IS_WIDE_WRITING(stream) && __STDIO_STREAM_TRANS_TO_WRITE(stream, __FLAG_WIDE)) #endif ---------------------------------------------------------------------- vda - 04-01-08 12:04 ---------------------------------------------------------------------- Seems like it can be improved in _vfprintf.c / old_vfprintf.c by factoring out "the core" of vprintf() into separate function (say, "vprintf_internal_unlocked()"), so that: * vprintf() does locking and __STDIO_STREAM_TRANS_TO_WRITE thing, then calls vprintf_internal_unlocked(); * vsnprintf, vdprintf.c, vasprintf.c all use vprintf_internal_unlocked() directly [and do not need to set up fake locking now] Issue History Date Modified Username Field Change ====================================================================== 04-01-08 09:26 vda New Issue 04-01-08 09:26 vda Status new => assigned 04-01-08 09:26 vda Assigned To => uClibc 04-01-08 11:13 vda Note Added: 0006274 04-01-08 12:04 vda Note Added: 0006284 ====================================================================== From bugs at busybox.net Tue Apr 1 14:50:33 2008 From: bugs at busybox.net (bugs at busybox.net) Date: Tue, 1 Apr 2008 14:50:33 -0700 Subject: [uClibc 0002714]: sprintf should not pull in most of stdio.h code Message-ID: <897e00b905ed6e72d4e53b7cbd5ca726@bugs.uclibc.org> A NOTE has been added to this issue. ====================================================================== http://busybox.net/bugs/view.php?id=2714 ====================================================================== Reported By: vda Assigned To: uClibc ====================================================================== Project: uClibc Issue ID: 2714 Category: Stdio Reproducibility: always Severity: minor Priority: normal Status: assigned ====================================================================== Date Submitted: 04-01-2008 09:26 PDT Last Modified: 04-01-2008 14:50 PDT ====================================================================== Summary: sprintf should not pull in most of stdio.h code Description: Use of [v]s[n]printf functions does not require application to necessarily pull in the whole of stdio.h machinery. Only formatting routines are needed. Currently I observe +12k growth when I add a sprintf(dummy_buf, "%d", some_var) to the program which otherwise does not use stdio.h. For one, seek and write functions ideally should not appear. ====================================================================== ---------------------------------------------------------------------- vda - 04-01-08 11:13 ---------------------------------------------------------------------- Since I have a good test case, I can provide more info (link map rules!). seeks are pulled in because of __UCLIBC_HAS_STDIO_AUTO_RW_TRANSITION__ here: #ifdef __UCLIBC_HAS_WCHAR__ int attribute_hidden __stdio_trans2w_o(FILE * __restrict stream, int oflag) #else int attribute_hidden __stdio_trans2w(FILE * __restrict stream) #endif { ... if (__STDIO_STREAM_IS_READING(stream)) { if (!__FEOF_UNLOCKED(stream)) { #ifdef __UCLIBC_HAS_STDIO_AUTO_RW_TRANSITION__ /* Need to seek to correct position if we have buffered * read data or ungots. If appending, we might as well * seek to the end. * * NOTE: If the OS does not handle append files correctly, * this is insufficient since we would need to seek to * the end even if not reading.*/ if (((__STDIO_STREAM_BUFFER_RAVAIL(stream)) || (stream->__modeflags & __FLAG_UNGOT)) && fseek(stream, 0L, ... which is pulled in because of STDIO_STREAM_TRANS_TO_WRITE here: int VFPRINTF (FILE * __restrict stream, register const FMT_TYPE * __restrict format, va_list arg) { ... if #ifdef L_vfprintf (!__STDIO_STREAM_IS_NARROW_WRITING(stream) && __STDIO_STREAM_TRANS_TO_WRITE(stream, __FLAG_NARROW)) #else (!__STDIO_STREAM_IS_WIDE_WRITING(stream) && __STDIO_STREAM_TRANS_TO_WRITE(stream, __FLAG_WIDE)) #endif ---------------------------------------------------------------------- vda - 04-01-08 12:04 ---------------------------------------------------------------------- Seems like it can be improved in _vfprintf.c / old_vfprintf.c by factoring out "the core" of vprintf() into separate function (say, "vprintf_internal_unlocked()"), so that: * vprintf() does locking and __STDIO_STREAM_TRANS_TO_WRITE thing, then calls vprintf_internal_unlocked(); * vsnprintf, vdprintf.c, vasprintf.c all use vprintf_internal_unlocked() directly [and do not need to set up fake locking now] ---------------------------------------------------------------------- vda - 04-01-08 14:50 ---------------------------------------------------------------------- 2.patch implements this solution. 3.patch removes unneeded initialization of locking. If you are going to apply it, take a look at vsnprintf.c's comment about __bufputc - it seems to be bogus, AFAICS __bufputc initialization has nothing to do with __user_locking. (I did grep around). Didn't look yet whether it works with old_vfprintf.c. Issue History Date Modified Username Field Change ====================================================================== 04-01-08 09:26 vda New Issue 04-01-08 09:26 vda Status new => assigned 04-01-08 09:26 vda Assigned To => uClibc 04-01-08 11:13 vda Note Added: 0006274 04-01-08 12:04 vda Note Added: 0006284 04-01-08 14:46 vda File Added: 2.patch 04-01-08 14:46 vda File Added: 3.patch 04-01-08 14:50 vda Note Added: 0006294 ====================================================================== From bugs at busybox.net Tue Apr 1 15:22:04 2008 From: bugs at busybox.net (bugs at busybox.net) Date: Tue, 1 Apr 2008 15:22:04 -0700 Subject: [uClibc 0002714]: sprintf should not pull in most of stdio.h code Message-ID: A NOTE has been added to this issue. ====================================================================== http://busybox.net/bugs/view.php?id=2714 ====================================================================== Reported By: vda Assigned To: uClibc ====================================================================== Project: uClibc Issue ID: 2714 Category: Stdio Reproducibility: always Severity: minor Priority: normal Status: assigned ====================================================================== Date Submitted: 04-01-2008 09:26 PDT Last Modified: 04-01-2008 15:22 PDT ====================================================================== Summary: sprintf should not pull in most of stdio.h code Description: Use of [v]s[n]printf functions does not require application to necessarily pull in the whole of stdio.h machinery. Only formatting routines are needed. Currently I observe +12k growth when I add a sprintf(dummy_buf, "%d", some_var) to the program which otherwise does not use stdio.h. For one, seek and write functions ideally should not appear. ====================================================================== ---------------------------------------------------------------------- vda - 04-01-08 11:13 ---------------------------------------------------------------------- Since I have a good test case, I can provide more info (link map rules!). seeks are pulled in because of __UCLIBC_HAS_STDIO_AUTO_RW_TRANSITION__ here: #ifdef __UCLIBC_HAS_WCHAR__ int attribute_hidden __stdio_trans2w_o(FILE * __restrict stream, int oflag) #else int attribute_hidden __stdio_trans2w(FILE * __restrict stream) #endif { ... if (__STDIO_STREAM_IS_READING(stream)) { if (!__FEOF_UNLOCKED(stream)) { #ifdef __UCLIBC_HAS_STDIO_AUTO_RW_TRANSITION__ /* Need to seek to correct position if we have buffered * read data or ungots. If appending, we might as well * seek to the end. * * NOTE: If the OS does not handle append files correctly, * this is insufficient since we would need to seek to * the end even if not reading.*/ if (((__STDIO_STREAM_BUFFER_RAVAIL(stream)) || (stream->__modeflags & __FLAG_UNGOT)) && fseek(stream, 0L, ... which is pulled in because of STDIO_STREAM_TRANS_TO_WRITE here: int VFPRINTF (FILE * __restrict stream, register const FMT_TYPE * __restrict format, va_list arg) { ... if #ifdef L_vfprintf (!__STDIO_STREAM_IS_NARROW_WRITING(stream) && __STDIO_STREAM_TRANS_TO_WRITE(stream, __FLAG_NARROW)) #else (!__STDIO_STREAM_IS_WIDE_WRITING(stream) && __STDIO_STREAM_TRANS_TO_WRITE(stream, __FLAG_WIDE)) #endif ---------------------------------------------------------------------- vda - 04-01-08 12:04 ---------------------------------------------------------------------- Seems like it can be improved in _vfprintf.c / old_vfprintf.c by factoring out "the core" of vprintf() into separate function (say, "vprintf_internal_unlocked()"), so that: * vprintf() does locking and __STDIO_STREAM_TRANS_TO_WRITE thing, then calls vprintf_internal_unlocked(); * vsnprintf, vdprintf.c, vasprintf.c all use vprintf_internal_unlocked() directly [and do not need to set up fake locking now] ---------------------------------------------------------------------- vda - 04-01-08 14:50 ---------------------------------------------------------------------- 2.patch implements this solution. 3.patch removes unneeded initialization of locking. If you are going to apply it, take a look at vsnprintf.c's comment about __bufputc - it seems to be bogus, AFAICS __bufputc initialization has nothing to do with __user_locking. (I did grep around). Didn't look yet whether it works with old_vfprintf.c. ---------------------------------------------------------------------- vda - 04-01-08 15:22 ---------------------------------------------------------------------- These patches save http://busybox.net/bugs/view.php?id=115#400 bytes compared to unpatched uclibc. Next target can be removing __stdio_fwrite + __stdio_WRITE, as they should not be needed for sprintf too - projected to save http://busybox.net/bugs/view.php?id=23#300 bytes. Issue History Date Modified Username Field Change ====================================================================== 04-01-08 09:26 vda New Issue 04-01-08 09:26 vda Status new => assigned 04-01-08 09:26 vda Assigned To => uClibc 04-01-08 11:13 vda Note Added: 0006274 04-01-08 12:04 vda Note Added: 0006284 04-01-08 14:46 vda File Added: 2.patch 04-01-08 14:46 vda File Added: 3.patch 04-01-08 14:50 vda Note Added: 0006294 04-01-08 15:22 vda Note Added: 0006304 ====================================================================== From bugs at busybox.net Wed Apr 2 01:38:22 2008 From: bugs at busybox.net (bugs at busybox.net) Date: Wed, 2 Apr 2008 01:38:22 -0700 Subject: [uClibc 0002264]: pthread issues with 0.9.29 Message-ID: <0e78a16bd8a7dad3763e28fba8667cf9@bugs.uclibc.org> A NOTE has been added to this issue. ====================================================================== http://busybox.net/bugs/view.php?id=2264 ====================================================================== Reported By: kannappan Assigned To: uClibc ====================================================================== Project: uClibc Issue ID: 2264 Category: Posix Threads Reproducibility: always Severity: major Priority: normal Status: feedback ====================================================================== Date Submitted: 02-20-2008 03:29 PST Last Modified: 04-02-2008 01:38 PDT ====================================================================== Summary: pthread issues with 0.9.29 Description: I am using uclibc0.9.29, binutils 2.18 for ARM926T I am facing problems executing applications which uses pthread. when including pthread library my application crashes giving message "segmentation fault". But the same is working with glibc . When I debugged using strace It gave following error message # strace ./run_loop execve("./run_loop", ["./run_loop"], [/* 16 vars */]) = -1 ENOEXEC (Exec format error) write(2, "strace: exec: Exec format error\n", 32strace: exec: Exec format error ) = 32 exit(1) = ? Process 738 detached ====================================================================== ---------------------------------------------------------------------- carmelo73 - 02-20-08 04:40 ---------------------------------------------------------------------- From bugs at busybox.net Thu Apr 3 09:51:34 2008 From: bugs at busybox.net (bugs at busybox.net) Date: Thu, 3 Apr 2008 09:51:34 -0700 Subject: [uClibc 0002264]: pthread issues with 0.9.29 Message-ID: <6e39498dc70d5a1255fb44fc7e617e54@busybox.net> A NOTE has been added to this issue. ====================================================================== http://busybox.net/bugs/view.php?id=2264 ====================================================================== Reported By: kannappan Assigned To: uClibc ====================================================================== Project: uClibc Issue ID: 2264 Category: Posix Threads Reproducibility: always Severity: major Priority: normal Status: feedback ====================================================================== Date Submitted: 02-20-2008 03:29 PST Last Modified: 04-03-2008 09:51 PDT ====================================================================== Summary: pthread issues with 0.9.29 Description: I am using uclibc0.9.29, binutils 2.18 for ARM926T I am facing problems executing applications which uses pthread. when including pthread library my application crashes giving message "segmentation fault". But the same is working with glibc . When I debugged using strace It gave following error message # strace ./run_loop execve("./run_loop", ["./run_loop"], [/* 16 vars */]) = -1 ENOEXEC (Exec format error) write(2, "strace: exec: Exec format error\n", 32strace: exec: Exec format error ) = 32 exit(1) = ? Process 738 detached ====================================================================== ---------------------------------------------------------------------- carmelo73 - 02-20-08 04:40 ---------------------------------------------------------------------- From aldot at uclibc.org Fri Apr 4 03:04:42 2008 From: aldot at uclibc.org (aldot at uclibc.org) Date: Fri, 4 Apr 2008 03:04:42 -0700 (PDT) Subject: svn commit: trunk/uClibc/libm/i386 Message-ID: <20080404100442.8CEEB3C3CE@busybox.net> Author: aldot Date: 2008-04-04 03:04:41 -0700 (Fri, 04 Apr 2008) New Revision: 21634 Log: - use a 16bit value for fnstsw as required by newer binutils. Modified: trunk/uClibc/libm/i386/ftestexcept.c Changeset: Modified: trunk/uClibc/libm/i386/ftestexcept.c =================================================================== --- trunk/uClibc/libm/i386/ftestexcept.c 2008-04-04 07:24:15 UTC (rev 21633) +++ trunk/uClibc/libm/i386/ftestexcept.c 2008-04-04 10:04:41 UTC (rev 21634) @@ -24,7 +24,7 @@ int fetestexcept (int excepts) { - int temp; + short temp; int xtemp = 0; /* Get current exceptions. */ From bugs at busybox.net Fri Apr 4 12:08:31 2008 From: bugs at busybox.net (bugs at busybox.net) Date: Fri, 4 Apr 2008 12:08:31 -0700 Subject: [uClibc 0002834]: libc_pthread_init() causes segfault Message-ID: The following issue has been SUBMITTED. ====================================================================== http://busybox.net/bugs/view.php?id=2834 ====================================================================== Reported By: hank_le Assigned To: uClibc ====================================================================== Project: uClibc Issue ID: 2834 Category: Posix Threads Reproducibility: always Severity: major Priority: normal Status: assigned ====================================================================== Date Submitted: 04-04-2008 12:08 PDT Last Modified: 04-04-2008 12:08 PDT ====================================================================== Summary: libc_pthread_init() causes segfault Description: Initializing programs that link to libpthread segfault. Simple "Hello World" program segfaults when linked against libpthread, yet runs fine without. Attached pthread_test.c won't run. ====================================================================== Issue History Date Modified Username Field Change ====================================================================== 04-04-08 12:08 hank_le New Issue 04-04-08 12:08 hank_le Status new => assigned 04-04-08 12:08 hank_le Assigned To => uClibc 04-04-08 12:08 hank_le File Added: pthread_test.c ====================================================================== From bugs at busybox.net Sun Apr 6 23:30:49 2008 From: bugs at busybox.net (bugs at busybox.net) Date: Sun, 6 Apr 2008 23:30:49 -0700 Subject: [uClibc 0002264]: pthread issues with 0.9.29 Message-ID: <0b1c1ee16d6e143c8211920da846d5f3@bugs.uclibc.org> A NOTE has been added to this issue. ====================================================================== http://busybox.net/bugs/view.php?id=2264 ====================================================================== Reported By: kannappan Assigned To: uClibc ====================================================================== Project: uClibc Issue ID: 2264 Category: Posix Threads Reproducibility: always Severity: major Priority: normal Status: feedback ====================================================================== Date Submitted: 02-20-2008 03:29 PST Last Modified: 04-06-2008 23:30 PDT ====================================================================== Summary: pthread issues with 0.9.29 Description: I am using uclibc0.9.29, binutils 2.18 for ARM926T I am facing problems executing applications which uses pthread. when including pthread library my application crashes giving message "segmentation fault". But the same is working with glibc . When I debugged using strace It gave following error message # strace ./run_loop execve("./run_loop", ["./run_loop"], [/* 16 vars */]) = -1 ENOEXEC (Exec format error) write(2, "strace: exec: Exec format error\n", 32strace: exec: Exec format error ) = 32 exit(1) = ? Process 738 detached ====================================================================== ---------------------------------------------------------------------- carmelo73 - 02-20-08 04:40 ---------------------------------------------------------------------- From bugs at busybox.net Mon Apr 7 13:02:56 2008 From: bugs at busybox.net (bugs at busybox.net) Date: Mon, 7 Apr 2008 13:02:56 -0700 Subject: [uClibc 0002264]: pthread issues with 0.9.29 Message-ID: A NOTE has been added to this issue. ====================================================================== http://busybox.net/bugs/view.php?id=2264 ====================================================================== Reported By: kannappan Assigned To: uClibc ====================================================================== Project: uClibc Issue ID: 2264 Category: Posix Threads Reproducibility: always Severity: major Priority: normal Status: feedback ====================================================================== Date Submitted: 02-20-2008 03:29 PST Last Modified: 04-07-2008 13:02 PDT ====================================================================== Summary: pthread issues with 0.9.29 Description: I am using uclibc0.9.29, binutils 2.18 for ARM926T I am facing problems executing applications which uses pthread. when including pthread library my application crashes giving message "segmentation fault". But the same is working with glibc . When I debugged using strace It gave following error message # strace ./run_loop execve("./run_loop", ["./run_loop"], [/* 16 vars */]) = -1 ENOEXEC (Exec format error) write(2, "strace: exec: Exec format error\n", 32strace: exec: Exec format error ) = 32 exit(1) = ? Process 738 detached ====================================================================== ---------------------------------------------------------------------- carmelo73 - 02-20-08 04:40 ---------------------------------------------------------------------- From carmelo at uclibc.org Tue Apr 8 03:21:16 2008 From: carmelo at uclibc.org (carmelo at uclibc.org) Date: Tue, 8 Apr 2008 03:21:16 -0700 (PDT) Subject: svn commit: branches/uClibc-nptl/ldso/include Message-ID: <20080408102116.BF1093C2F0@busybox.net> Author: carmelo Date: 2008-04-08 03:21:16 -0700 (Tue, 08 Apr 2008) New Revision: 21669 Log: Change one missing inline to __always_inline Modified: branches/uClibc-nptl/ldso/include/dl-syscall.h Changeset: Modified: branches/uClibc-nptl/ldso/include/dl-syscall.h =================================================================== --- branches/uClibc-nptl/ldso/include/dl-syscall.h 2008-04-08 04:28:18 UTC (rev 21668) +++ branches/uClibc-nptl/ldso/include/dl-syscall.h 2008-04-08 10:21:16 UTC (rev 21669) @@ -127,7 +127,7 @@ #ifdef __UCLIBC_HAS_SSP__ # include # define __NR__dl_gettimeofday __NR_gettimeofday -static inline _syscall2(int, _dl_gettimeofday, struct timeval *, tv, +static __always_inline _syscall2(int, _dl_gettimeofday, struct timeval *, tv, # ifdef __USE_BSD struct timezone *, tz); # else From bugs at busybox.net Tue Apr 8 17:54:30 2008 From: bugs at busybox.net (bugs at busybox.net) Date: Tue, 8 Apr 2008 17:54:30 -0700 Subject: [uClibc 0002714]: sprintf should not pull in most of stdio.h code Message-ID: <1af11462d4605f2a05e8446233e96460@busybox.net> A NOTE has been added to this issue. ====================================================================== http://busybox.net/bugs/view.php?id=2714 ====================================================================== Reported By: vda Assigned To: uClibc ====================================================================== Project: uClibc Issue ID: 2714 Category: Stdio Reproducibility: always Severity: minor Priority: normal Status: assigned ====================================================================== Date Submitted: 04-01-2008 09:26 PDT Last Modified: 04-08-2008 17:54 PDT ====================================================================== Summary: sprintf should not pull in most of stdio.h code Description: Use of [v]s[n]printf functions does not require application to necessarily pull in the whole of stdio.h machinery. Only formatting routines are needed. Currently I observe +12k growth when I add a sprintf(dummy_buf, "%d", some_var) to the program which otherwise does not use stdio.h. For one, seek and write functions ideally should not appear. ====================================================================== ---------------------------------------------------------------------- vda - 04-01-08 11:13 ---------------------------------------------------------------------- Since I have a good test case, I can provide more info (link map rules!). seeks are pulled in because of __UCLIBC_HAS_STDIO_AUTO_RW_TRANSITION__ here: #ifdef __UCLIBC_HAS_WCHAR__ int attribute_hidden __stdio_trans2w_o(FILE * __restrict stream, int oflag) #else int attribute_hidden __stdio_trans2w(FILE * __restrict stream) #endif { ... if (__STDIO_STREAM_IS_READING(stream)) { if (!__FEOF_UNLOCKED(stream)) { #ifdef __UCLIBC_HAS_STDIO_AUTO_RW_TRANSITION__ /* Need to seek to correct position if we have buffered * read data or ungots. If appending, we might as well * seek to the end. * * NOTE: If the OS does not handle append files correctly, * this is insufficient since we would need to seek to * the end even if not reading.*/ if (((__STDIO_STREAM_BUFFER_RAVAIL(stream)) || (stream->__modeflags & __FLAG_UNGOT)) && fseek(stream, 0L, ... which is pulled in because of STDIO_STREAM_TRANS_TO_WRITE here: int VFPRINTF (FILE * __restrict stream, register const FMT_TYPE * __restrict format, va_list arg) { ... if #ifdef L_vfprintf (!__STDIO_STREAM_IS_NARROW_WRITING(stream) && __STDIO_STREAM_TRANS_TO_WRITE(stream, __FLAG_NARROW)) #else (!__STDIO_STREAM_IS_WIDE_WRITING(stream) && __STDIO_STREAM_TRANS_TO_WRITE(stream, __FLAG_WIDE)) #endif ---------------------------------------------------------------------- vda - 04-01-08 12:04 ---------------------------------------------------------------------- Seems like it can be improved in _vfprintf.c / old_vfprintf.c by factoring out "the core" of vprintf() into separate function (say, "vprintf_internal_unlocked()"), so that: * vprintf() does locking and __STDIO_STREAM_TRANS_TO_WRITE thing, then calls vprintf_internal_unlocked(); * vsnprintf, vdprintf.c, vasprintf.c all use vprintf_internal_unlocked() directly [and do not need to set up fake locking now] ---------------------------------------------------------------------- vda - 04-01-08 14:50 ---------------------------------------------------------------------- 2.patch implements this solution. 3.patch removes unneeded initialization of locking. If you are going to apply it, take a look at vsnprintf.c's comment about __bufputc - it seems to be bogus, AFAICS __bufputc initialization has nothing to do with __user_locking. (I did grep around). Didn't look yet whether it works with old_vfprintf.c. ---------------------------------------------------------------------- vda - 04-01-08 15:22 ---------------------------------------------------------------------- These patches save http://busybox.net/bugs/view.php?id=115#400 bytes compared to unpatched uclibc. Next target can be removing __stdio_fwrite + __stdio_WRITE, as they should not be needed for sprintf too - projected to save http://busybox.net/bugs/view.php?id=23#300 bytes. ---------------------------------------------------------------------- vda - 04-08-08 17:54 ---------------------------------------------------------------------- v2 of patches should be more correct wrt old_vsprintf (it is just left untouched now) Issue History Date Modified Username Field Change ====================================================================== 04-01-08 09:26 vda New Issue 04-01-08 09:26 vda Status new => assigned 04-01-08 09:26 vda Assigned To => uClibc 04-01-08 11:13 vda Note Added: 0006274 04-01-08 12:04 vda Note Added: 0006284 04-01-08 14:46 vda File Added: 2.patch 04-01-08 14:46 vda File Added: 3.patch 04-01-08 14:50 vda Note Added: 0006294 04-01-08 15:22 vda Note Added: 0006304 04-08-08 17:53 vda File Added: v2_2.patch 04-08-08 17:53 vda File Added: v2_3.patch 04-08-08 17:54 vda Note Added: 0006454 ====================================================================== From bugs at busybox.net Tue Apr 8 23:22:43 2008 From: bugs at busybox.net (bugs at busybox.net) Date: Tue, 8 Apr 2008 23:22:43 -0700 Subject: [uClibc 0002544]: Can't make a target system for X86_64 Message-ID: <3a1f6bac8e059be995060e8473d9a586@bugs.uclibc.org> A NOTE has been added to this issue. ====================================================================== http://busybox.net/bugs/view.php?id=2544 ====================================================================== Reported By: kickinz1 Assigned To: uClibc ====================================================================== Project: uClibc Issue ID: 2544 Category: Architecture Specific Reproducibility: always Severity: major Priority: normal Status: assigned ====================================================================== Date Submitted: 03-12-2008 10:21 PDT Last Modified: 04-08-2008 23:22 PDT ====================================================================== Summary: Can't make a target system for X86_64 Description: If I choose to make a x86_64 target, I can't achieve to have a working system. It can't compile uclibc 0.9.29. throwing the following error message: CC libc/stdlib/strtol_l.os In file included from ../../libc/stdlib/strtol_l.c:8: ../../libc/stdlib/stdlib.c:346: error: conflicting types for 'strtoll_l' ../../include/stdlib.h:266: error: previous declaration of 'strtoll_l' was here ../../libc/stdlib/stdlib.c:347: error: conflicting types for 'strtoll_l' ../../include/stdlib.h:266: error: previous declaration of 'strtoll_l' was here ../../libc/stdlib/stdlib.c:348: error: conflicting types for 'strtoll_l' ../../include/stdlib.h:266: error: previous declaration of 'strtoll_l' was here make: *** [../../libc/stdlib/strtol_l.os ====================================================================== ---------------------------------------------------------------------- khem - 04-08-08 23:22 ---------------------------------------------------------------------- Can you disable locale and try? (UCLIBC_HAS_LOCALE and UCLIBC_HAS_XLOCALE) Issue History Date Modified Username Field Change ====================================================================== 03-12-08 10:21 kickinz1 New Issue 03-12-08 10:21 kickinz1 Status new => assigned 03-12-08 10:21 kickinz1 Assigned To => uClibc 03-27-08 08:35 Graol Note Added: 0006114 03-27-08 08:40 Graol Note Edited: 0006114 03-27-08 08:57 Graol Note Deleted: 0006114 04-08-08 23:22 khem Note Added: 0006464 ====================================================================== From bugs at busybox.net Tue Apr 8 23:30:46 2008 From: bugs at busybox.net (bugs at busybox.net) Date: Tue, 8 Apr 2008 23:30:46 -0700 Subject: [uClibc 0002074]: poll() does not work on Linux 2.0.40 Message-ID: A NOTE has been added to this issue. ====================================================================== http://busybox.net/bugs/view.php?id=2074 ====================================================================== Reported By: michael_d Assigned To: uClibc ====================================================================== Project: uClibc Issue ID: 2074 Category: Other Reproducibility: always Severity: minor Priority: normal Status: assigned ====================================================================== Date Submitted: 02-07-2008 19:49 PST Last Modified: 04-08-2008 23:30 PDT ====================================================================== Summary: poll() does not work on Linux 2.0.40 Description: When compiled for Linux 2.0.40, the poll() function will not work, always returning ENOSYS. While that kernel does not implement the poll syscall, there is a complete emulation within uClibc's source, which works fine but is not normally compiled in. The problem is that this kernel's defines __NR_poll, even though it does not implement the syscall. uClibc blindly assumes that the call will work if its number is defined, and discards the emulation to save space. To fix this, the library needs to check for the presence of the header, rather than just seeing if the syscall number is defined. I've worked around this locally by editing to remove __NR_poll. (Note that fixes for issues http://busybox.net/bugs/view.php?id=1874 and http://busybox.net/bugs/view.php?id=2064 must be applied before compilation of uClibc is possible on this platform.) ====================================================================== ---------------------------------------------------------------------- vapier - 02-15-08 15:39 ---------------------------------------------------------------------- please see the FAQ: http://uclibc.org/FAQ.html#upstream_versions in other words, please post a patch that addresses the issue for you ---------------------------------------------------------------------- michael_d - 03-13-08 05:18 ---------------------------------------------------------------------- I've uploaded a patch, which checks whether the kernel headers include . If that header is not present, it's unlikely the kernel really supports the syscall. ---------------------------------------------------------------------- vapier - 03-21-08 00:02 ---------------------------------------------------------------------- erm, no, lets not do that ... just add a check via KERNEL_VERSION() and LINUX_VERSION_CODE ---------------------------------------------------------------------- khem - 04-08-08 23:30 ---------------------------------------------------------------------- kernel should not export NR_poll if it does not implement the syscall. So fix in the kernel headers what you did is right thing to do. Nothing is needed to be done in uclibc in my opinion. Issue History Date Modified Username Field Change ====================================================================== 02-07-08 19:49 michael_d New Issue 02-07-08 19:49 michael_d Status new => assigned 02-07-08 19:49 michael_d Assigned To => uClibc 02-15-08 15:39 vapier Note Added: 0004924 03-13-08 05:15 michael_d File Added: uClibc-0.9.29-pollfix.diff 03-13-08 05:18 michael_d Note Added: 0005704 03-21-08 00:02 vapier Note Added: 0005824 04-08-08 23:30 khem Note Added: 0006474 ====================================================================== From bugs at busybox.net Wed Apr 9 00:07:39 2008 From: bugs at busybox.net (bugs at busybox.net) Date: Wed, 9 Apr 2008 00:07:39 -0700 Subject: [uClibc 0002454]: Fixing ARM EABI support bug in syscall() Message-ID: <4c0ecfbbdfbc323153dad65441c470e3@bugs.uclibc.org> A NOTE has been added to this issue. ====================================================================== http://busybox.net/bugs/view.php?id=2454 ====================================================================== Reported By: Joe Lin Assigned To: uClibc ====================================================================== Project: uClibc Issue ID: 2454 Category: Architecture Specific Reproducibility: always Severity: major Priority: normal Status: assigned ====================================================================== Date Submitted: 03-06-2008 04:12 PST Last Modified: 04-09-2008 00:07 PDT ====================================================================== Summary: Fixing ARM EABI support bug in syscall() Description: When making an EABI syscall() system call, the library does not correctly pass requesting system number to the Linux kernel. For example, the ping facility in Busybox will issue a syscall() to get monotonic time (see monotonic_us() in libbb/time.c). The syscall() in syscall-eabi.S passes R7 value verbatim. But the kernel (see linux's vector_swi routine in arch/arm/kernel/entry-common.S) expects R7 a number without __NR_SYSCALL_BASE. This bug caused a Segmentation Fault. Below is the patch. -------------------------------------------------------------- diff -Naurd uClibc-0.9.29/libc/sysdeps/linux/arm/syscall-eabi.S uClibc-0.9.29-p1/libc/sysdeps/linux/arm/syscall-eabi.S --- uClibc-0.9.29/libc/sysdeps/linux/arm/syscall-eabi.S 2006-02-11 12:29:52.000000000 +0800 +++ uClibc-0.9.29-p1/libc/sysdeps/linux/arm/syscall-eabi.S 2008-03-06 19:53:15.000000000 +0800 @@ -29,7 +29,7 @@ syscall: mov ip, sp stmfd sp!, {r4, r5, r6, r7} - mov r7, r0 + sub r7, r0, #SYS_SYSCALL_BASE mov r0, r1 mov r1, r2 mov r2, r3 -------------------------------------------------------------- ====================================================================== ---------------------------------------------------------------------- khem - 04-09-08 00:07 ---------------------------------------------------------------------- is your kernel compiled with AEABI ? Are you compiling uclibc also with EABI turned on in toolchain ? Issue History Date Modified Username Field Change ====================================================================== 03-06-08 04:12 Joe Lin New Issue 03-06-08 04:12 Joe Lin Status new => assigned 03-06-08 04:12 Joe Lin Assigned To => uClibc 04-09-08 00:07 khem Note Added: 0006484 ====================================================================== From vda at uclibc.org Wed Apr 9 12:51:18 2008 From: vda at uclibc.org (vda at uclibc.org) Date: Wed, 9 Apr 2008 12:51:18 -0700 (PDT) Subject: svn commit: trunk/uClibc/libc/stdio Message-ID: <20080409195118.C07513C515@busybox.net> Author: vda Date: 2008-04-09 12:51:18 -0700 (Wed, 09 Apr 2008) New Revision: 21683 Log: Factor out the core of vprintf() into separate function vprintf_internal, so that: * vprintf() does locking and __STDIO_STREAM_TRANS_TO_WRITE thing, then calls vprintf_internal * vsnprintf, vdprintf.c, vasprintf.c use vprintf_internal directly This makes sprintf faster (since it doesn't do any locking) and stops it from pulling in fseek in static compile. Added: trunk/uClibc/libc/stdio/_vfprintf_internal.c trunk/uClibc/libc/stdio/_vfwprintf_internal.c Modified: trunk/uClibc/libc/stdio/Makefile.in trunk/uClibc/libc/stdio/_stdio.h trunk/uClibc/libc/stdio/_vfprintf.c trunk/uClibc/libc/stdio/vasprintf.c trunk/uClibc/libc/stdio/vdprintf.c trunk/uClibc/libc/stdio/vsnprintf.c trunk/uClibc/libc/stdio/vswprintf.c Changeset: Modified: trunk/uClibc/libc/stdio/Makefile.in =================================================================== --- trunk/uClibc/libc/stdio/Makefile.in 2008-04-09 11:38:48 UTC (rev 21682) +++ trunk/uClibc/libc/stdio/Makefile.in 2008-04-09 19:51:18 UTC (rev 21683) @@ -59,6 +59,7 @@ ifneq ($(USE_OLD_VFPRINTF),y) VF_CSRC := \ vfprintf.c \ + _vfprintf_internal.c \ _ppfs_init.c _ppfs_prepargs.c _ppfs_setargs.c _ppfs_parsespec.c \ register_printf_function.c parse_printf_format.c CSRC += $(VF_CSRC) @@ -77,7 +78,7 @@ CUSRC += fgetwc.c getwchar.c fgetws.c fputwc.c putwchar.c fputws.c # getwc (fgetwc alias) getwc_unlocked (fgetwc_unlocked alias) # putwc (fputwc alias) putwc_unlocked (fputwc_unlocked alias) -CSRC += vfwprintf.c +CSRC += vfwprintf.c _vfwprintf_internal.c CSRC += wscanf.c swscanf.c fwscanf.c vwscanf.c vswscanf.c vfwscanf.c endif Modified: trunk/uClibc/libc/stdio/_stdio.h =================================================================== --- trunk/uClibc/libc/stdio/_stdio.h 2008-04-09 11:38:48 UTC (rev 21682) +++ trunk/uClibc/libc/stdio/_stdio.h 2008-04-09 19:51:18 UTC (rev 21683) @@ -15,6 +15,7 @@ #include #include #include +#include #include #ifdef __UCLIBC_HAS_WCHAR__ #include @@ -431,6 +432,18 @@ #endif /**********************************************************************/ + +extern int _vfprintf_internal (FILE * __restrict stream, + register const char * __restrict format, + va_list arg) attribute_hidden; + +#ifdef __UCLIBC_HAS_WCHAR__ +extern int _vfwprintf_internal (FILE * __restrict stream, + register const wchar_t * __restrict format, + va_list arg) attribute_hidden; +#endif + +/**********************************************************************/ /* Only use the macro below if you know fp is a valid FILE for a valid fd. * This is _not_ true for custom streams! */ #define __FILENO_UNLOCKED(fp) ((fp)->__filedes) Modified: trunk/uClibc/libc/stdio/_vfprintf.c =================================================================== --- trunk/uClibc/libc/stdio/_vfprintf.c 2008-04-09 11:38:48 UTC (rev 21682) +++ trunk/uClibc/libc/stdio/_vfprintf.c 2008-04-09 19:51:18 UTC (rev 21683) @@ -1198,7 +1198,7 @@ #endif /**********************************************************************/ -#if defined(L_vfprintf) || defined(L_vfwprintf) +#if defined(L__vfprintf_internal) || defined(L__vfwprintf_internal) /* We only support ascii digits (or their USC equivalent codes) in * precision and width settings in *printf (wide) format strings. @@ -1207,14 +1207,15 @@ static size_t _charpad(FILE * __restrict stream, int padchar, size_t numpad); -#ifdef L_vfprintf +#ifdef L__vfprintf_internal -#define VFPRINTF vfprintf +#define VFPRINTF_internal _vfprintf_internal #define FMT_TYPE char #define OUTNSTR _outnstr #define STRLEN strlen #define _PPFS_init _ppfs_init -#define OUTPUT(F,S) fputs_unlocked(S,F) +/* Pulls in fseek: #define OUTPUT(F,S) fputs_unlocked(S,F) */ +#define OUTPUT(F,S) __stdio_fwrite((const unsigned char *)(S),strlen(S),(F)) /* #define _outnstr(stream, string, len) __stdio_fwrite(string, len, stream) */ #define _outnstr(stream, string, len) ((len > 0) ? __stdio_fwrite(string, len, stream) : 0) #define FP_OUT _fp_out_narrow @@ -1239,14 +1240,16 @@ #endif /* __STDIO_PRINTF_FLOAT */ -#else /* L_vfprintf */ +#else /* L__vfprintf_internal */ -#define VFPRINTF vfwprintf +#define VFPRINTF_internal _vfwprintf_internal #define FMT_TYPE wchar_t #define OUTNSTR _outnwcs #define STRLEN wcslen #define _PPFS_init _ppwfs_init +/* Pulls in fseek: */ #define OUTPUT(F,S) fputws(S,F) +/* TODO: #define OUTPUT(F,S) _wstdio_fwrite((S),wcslen(S),(F)) */ #define _outnwcs(stream, wstring, len) _wstdio_fwrite(wstring, len, stream) #define FP_OUT _fp_out_wide @@ -1417,8 +1420,9 @@ return 0; } -#endif /* L_vfprintf */ +#endif /* L__vfprintf_internal */ + static size_t _charpad(FILE * __restrict stream, int padchar, size_t numpad) { size_t todo = numpad; @@ -1439,12 +1443,12 @@ register ppfs_t *ppfs, int *count) { static const char spec_base[] = SPEC_BASE; -#ifdef L_vfprintf +#ifdef L__vfprintf_internal static const char prefix[] = "+\0-\0 \0000x\0000X"; /* 0 2 4 6 9 11*/ -#else /* L_vfprintf */ +#else /* L__vfprintf_internal */ static const wchar_t prefix[] = L"+\0-\0 \0000x\0000X"; -#endif /* L_vfprintf */ +#endif /* L__vfprintf_internal */ enum { PREFIX_PLUS = 0, PREFIX_MINUS = 2, @@ -1465,7 +1469,7 @@ mbstate_t mbstate; #endif /* __UCLIBC_HAS_WCHAR__ */ size_t slen; -#ifdef L_vfprintf +#ifdef L__vfprintf_internal #define SLEN slen #else size_t SLEN; @@ -1532,7 +1536,7 @@ alphacase = __UIM_LOWER; #ifdef __UCLIBC_MJN3_ONLY__ -#ifdef L_vfprintf +#ifdef L__vfprintf_internal #warning CONSIDER: Should we ignore these flags if stub locale? What about custom specs? #endif #endif /* __UCLIBC_MJN3_ONLY__ */ @@ -1560,7 +1564,7 @@ padchar = ppfs->info.pad; } #ifdef __UCLIBC_MJN3_ONLY__ -#ifdef L_vfprintf +#ifdef L__vfprintf_internal #warning CONSIDER: If using outdigits and/or grouping, how should we interpret precision? #endif #endif /* __UCLIBC_MJN3_ONLY__ */ @@ -1580,7 +1584,7 @@ } } slen = (char *)(buf + sizeof(buf) - 1) - s; -#ifdef L_vfwprintf +#ifdef L__vfwprintf_internal { const char *q = s; mbstate.__mask = 0; /* Initialize the mbstate. */ @@ -1605,13 +1609,13 @@ } if (ppfs->conv_num == CONV_p) {/* null pointer */ s = "(nil)"; -#ifdef L_vfwprintf +#ifdef L__vfwprintf_internal SLEN = #endif slen = 5; numfill = 0; } else if (numfill == 0) { /* if precision 0, no output */ -#ifdef L_vfwprintf +#ifdef L__vfwprintf_internal SLEN = #endif slen = 0; @@ -1637,7 +1641,7 @@ return -1; /* TODO -- try to continue? */ #endif /* __STDIO_PRINTF_FLOAT */ } else if (ppfs->conv_num <= CONV_S) { /* wide char or string */ -#ifdef L_vfprintf +#ifdef L__vfprintf_internal #ifdef __UCLIBC_HAS_WCHAR__ mbstate.__mask = 0; /* Initialize the mbstate. */ @@ -1692,7 +1696,7 @@ slen = 1; } -#else /* L_vfprintf */ +#else /* L__vfprintf_internal */ if (ppfs->conv_num == CONV_S) { /* wide string */ ws = *((wchar_t **) (*argptr)); @@ -1713,7 +1717,7 @@ if (ppfs->conv_num == CONV_s) { /* string */ #ifdef __UCLIBC_MJN3_ONLY__ -#warning TODO: Fix %s for vfwprintf... output upto illegal sequence? +#warning TODO: Fix %s for _vfwprintf_internal... output upto illegal sequence? #endif /* __UCLIBC_MJN3_ONLY__ */ s = *((char **) (*argptr)); if (s) { @@ -1746,7 +1750,7 @@ goto CHAR_CASE; } -#endif /* L_vfprintf */ +#endif /* L__vfprintf_internal */ #ifdef __UCLIBC_HAS_PRINTF_M_SPEC__ } else if (ppfs->conv_num == CONV_m) { @@ -1778,7 +1782,7 @@ } #ifdef __UCLIBC_MJN3_ONLY__ -#ifdef L_vfprintf +#ifdef L__vfprintf_internal #warning CONSIDER: If using outdigits and/or grouping, how should we pad? #endif #endif /* __UCLIBC_MJN3_ONLY__ */ @@ -1805,11 +1809,12 @@ numpad = 0; } OUTPUT(stream, prefix + prefix_num); + if (_charpad(stream, '0', numfill) != numfill) { return -1; } -#ifdef L_vfprintf +#ifdef L__vfprintf_internal #ifdef __UCLIBC_HAS_WCHAR__ if (!ws) { @@ -1836,7 +1841,7 @@ } #endif /* __UCLIBC_HAS_WCHAR__ */ -#else /* L_vfprintf */ +#else /* L__vfprintf_internal */ if (!ws) { assert(s); @@ -1849,7 +1854,7 @@ } } -#endif /* L_vfprintf */ +#endif /* L__vfprintf_internal */ if (_charpad(stream, ' ', numpad) != numpad) { return -1; } @@ -1860,35 +1865,21 @@ libc_hidden_proto(fprintf) -libc_hidden_proto(VFPRINTF) -int VFPRINTF (FILE * __restrict stream, +int VFPRINTF_internal (FILE * __restrict stream, register const FMT_TYPE * __restrict format, va_list arg) { ppfs_t ppfs; int count, r; register const FMT_TYPE *s; - __STDIO_AUTO_THREADLOCK_VAR; - __STDIO_AUTO_THREADLOCK(stream); - count = 0; s = format; - if -#ifdef L_vfprintf - (!__STDIO_STREAM_IS_NARROW_WRITING(stream) - && __STDIO_STREAM_TRANS_TO_WRITE(stream, __FLAG_NARROW)) -#else - (!__STDIO_STREAM_IS_WIDE_WRITING(stream) - && __STDIO_STREAM_TRANS_TO_WRITE(stream, __FLAG_WIDE)) -#endif - { - count = -1; - } else if (_PPFS_init(&ppfs, format) < 0) { /* Bad format string. */ + if (_PPFS_init(&ppfs, format) < 0) { /* Bad format string. */ OUTNSTR(stream, (const unsigned char *) ppfs.fmtpos, STRLEN((const FMT_TYPE *)(ppfs.fmtpos))); -#if defined(L_vfprintf) && !defined(NDEBUG) +#if defined(L__vfprintf_internal) && !defined(NDEBUG) fprintf(stderr,"\nIMbS: \"%s\"\n\n", format); #endif count = -1; @@ -1930,14 +1921,66 @@ va_end(ppfs.arg); /* Need to clean up after va_copy! */ } -/* #if defined(L_vfprintf) && defined(__UCLIBC_HAS_WCHAR__) */ +/* #if defined(L__vfprintf_internal) && defined(__UCLIBC_HAS_WCHAR__) */ /* DONE: */ /* #endif */ + return count; +} +#endif /* defined(L__vfprintf_internal) || defined(L__vfwprintf_internal) */ + + +/**********************************************************************/ +#if defined(L_vfprintf) || defined(L_vfwprintf) + +/* This is just a wrapper around VFPRINTF_internal. + * Factoring out vfprintf internals allows: + * (1) vdprintf and vsnprintf don't need to setup fake locking, + * (2) __STDIO_STREAM_TRANS_TO_WRITE is not used in vfprintf internals, + * and thus fseek etc is not pulled in by vdprintf and vsnprintf. + * + * In order to not pull in fseek through fputs, OUTPUT() macro + * is using __stdio_fwrite (TODO: do the same for wide functions). + */ +#ifdef L_vfprintf +#define VFPRINTF vfprintf +#define VFPRINTF_internal _vfprintf_internal +#define FMT_TYPE char +#else +#define VFPRINTF vfwprintf +#define VFPRINTF_internal _vfwprintf_internal +#define FMT_TYPE wchar_t +#endif + +libc_hidden_proto(VFPRINTF) +int VFPRINTF (FILE * __restrict stream, + register const FMT_TYPE * __restrict format, + va_list arg) +{ + int count; + __STDIO_AUTO_THREADLOCK_VAR; + + __STDIO_AUTO_THREADLOCK(stream); + + if +#ifdef L_vfprintf + (!__STDIO_STREAM_IS_NARROW_WRITING(stream) + && __STDIO_STREAM_TRANS_TO_WRITE(stream, __FLAG_NARROW)) +#else + (!__STDIO_STREAM_IS_WIDE_WRITING(stream) + && __STDIO_STREAM_TRANS_TO_WRITE(stream, __FLAG_WIDE)) +#endif + { + count = -1; + } else { + count = VFPRINTF_internal(stream, format, arg); + } + __STDIO_AUTO_THREADUNLOCK(stream); return count; } libc_hidden_def(VFPRINTF) -#endif +#endif /* defined(L_vfprintf) || defined(L_vfwprintf) */ + /**********************************************************************/ Added: trunk/uClibc/libc/stdio/_vfprintf_internal.c =================================================================== --- trunk/uClibc/libc/stdio/_vfprintf_internal.c (rev 0) +++ trunk/uClibc/libc/stdio/_vfprintf_internal.c 2008-04-09 19:51:18 UTC (rev 21683) @@ -0,0 +1,9 @@ +/* Copyright (C) 2004 Manuel Novoa III + * Copyright (C) 2000-2006 Erik Andersen + * + * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. + * + * Dedicated to Toni. See uClibc/DEDICATION.mjn3 for details. + */ +#define L__vfprintf_internal +#include "_vfprintf.c" Added: trunk/uClibc/libc/stdio/_vfwprintf_internal.c =================================================================== --- trunk/uClibc/libc/stdio/_vfwprintf_internal.c (rev 0) +++ trunk/uClibc/libc/stdio/_vfwprintf_internal.c 2008-04-09 19:51:18 UTC (rev 21683) @@ -0,0 +1,9 @@ +/* Copyright (C) 2004 Manuel Novoa III + * Copyright (C) 2000-2006 Erik Andersen + * + * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. + * + * Dedicated to Toni. See uClibc/DEDICATION.mjn3 for details. + */ +#define L__vfwprintf_internal +#include "_vfprintf.c" Modified: trunk/uClibc/libc/stdio/vasprintf.c =================================================================== --- trunk/uClibc/libc/stdio/vasprintf.c 2008-04-09 11:38:48 UTC (rev 21682) +++ trunk/uClibc/libc/stdio/vasprintf.c 2008-04-09 19:51:18 UTC (rev 21683) @@ -57,7 +57,7 @@ #else /* __UCLIBC_HAS_GLIBC_CUSTOM_STREAMS__ */ - /* This implementation actually calls the printf machinery twice, but only + /* This implementation actually calls the printf machinery twice, but * only does one malloc. This can be a problem though when custom printf * specs or the %m specifier are involved because the results of the * second call might be different from the first. */ Modified: trunk/uClibc/libc/stdio/vdprintf.c =================================================================== --- trunk/uClibc/libc/stdio/vdprintf.c 2008-04-09 11:38:48 UTC (rev 21682) +++ trunk/uClibc/libc/stdio/vdprintf.c 2008-04-09 19:51:18 UTC (rev 21683) @@ -11,7 +11,6 @@ #include "_stdio.h" #include -libc_hidden_proto(vfprintf) libc_hidden_proto(fflush_unlocked) libc_hidden_proto(vdprintf) @@ -54,7 +53,7 @@ #endif f.__nextopen = NULL; - rv = vfprintf(&f, format, arg); + rv = _vfprintf_internal(&f, format, arg); #ifdef __STDIO_BUFFERS /* If not buffering, then fflush is unnecessary. */ @@ -67,5 +66,4 @@ return rv; } -libc_hidden_def(vdprintf) #endif Modified: trunk/uClibc/libc/stdio/vsnprintf.c =================================================================== --- trunk/uClibc/libc/stdio/vsnprintf.c 2008-04-09 11:38:48 UTC (rev 21682) +++ trunk/uClibc/libc/stdio/vsnprintf.c 2008-04-09 19:51:18 UTC (rev 21683) @@ -10,8 +10,6 @@ libc_hidden_proto(vsnprintf) -libc_hidden_proto(vfprintf) - #ifdef __UCLIBC_MJN3_ONLY__ #warning WISHLIST: Implement vsnprintf for non-buffered and no custom stream case. #endif /* __UCLIBC_MJN3_ONLY__ */ @@ -61,7 +59,7 @@ __STDIO_STREAM_DISABLE_GETC(&f); __STDIO_STREAM_ENABLE_PUTC(&f); - rv = vfprintf(&f, format, arg); + rv = _vfprintf_internal(&f, format, arg); if (size) { if (f.__bufpos == f.__bufend) { --f.__bufpos; @@ -203,7 +201,7 @@ #endif f.__nextopen = NULL; - rv = vfprintf(&f, format, arg); + rv = _vfprintf_internal(&f, format, arg); return rv; } Modified: trunk/uClibc/libc/stdio/vswprintf.c =================================================================== --- trunk/uClibc/libc/stdio/vswprintf.c 2008-04-09 11:38:48 UTC (rev 21682) +++ trunk/uClibc/libc/stdio/vswprintf.c 2008-04-09 19:51:18 UTC (rev 21683) @@ -11,8 +11,6 @@ libc_hidden_proto(vswprintf) -libc_hidden_proto(vfwprintf) - #ifndef __STDIO_BUFFERS #warning Skipping vswprintf since no buffering! #else /* __STDIO_BUFFERS */ @@ -56,7 +54,7 @@ __STDIO_STREAM_DISABLE_GETC(&f); __STDIO_STREAM_DISABLE_PUTC(&f); - rv = vfwprintf(&f, format, arg); + rv = _vfwprintf_internal(&f, format, arg); /* NOTE: Return behaviour differs from snprintf... */ if (f.__bufpos == f.__bufend) { From vda at uclibc.org Wed Apr 9 12:52:13 2008 From: vda at uclibc.org (vda at uclibc.org) Date: Wed, 9 Apr 2008 12:52:13 -0700 (PDT) Subject: svn commit: trunk/uClibc/libc/stdio Message-ID: <20080409195213.68D553C517@busybox.net> Author: vda Date: 2008-04-09 12:52:13 -0700 (Wed, 09 Apr 2008) New Revision: 21684 Log: Remove vestigial locking init from sprintf routines. Modified: trunk/uClibc/libc/stdio/vdprintf.c trunk/uClibc/libc/stdio/vsnprintf.c trunk/uClibc/libc/stdio/vswprintf.c Changeset: Modified: trunk/uClibc/libc/stdio/vdprintf.c =================================================================== --- trunk/uClibc/libc/stdio/vdprintf.c 2008-04-09 19:51:18 UTC (rev 21683) +++ trunk/uClibc/libc/stdio/vdprintf.c 2008-04-09 19:52:13 UTC (rev 21684) @@ -47,6 +47,8 @@ __INIT_MBSTATE(&(f.__state)); #endif /* __STDIO_MBSTATE */ +/* _vfprintf_internal doesn't do any locking, locking init is here + * only because of fflush_unlocked. TODO? */ #ifdef __UCLIBC_HAS_THREADS__ f.__user_locking = 1; /* Set user locking. */ __stdio_init_mutex(&f.__lock); Modified: trunk/uClibc/libc/stdio/vsnprintf.c =================================================================== --- trunk/uClibc/libc/stdio/vsnprintf.c 2008-04-09 19:51:18 UTC (rev 21683) +++ trunk/uClibc/libc/stdio/vsnprintf.c 2008-04-09 19:52:13 UTC (rev 21684) @@ -41,16 +41,13 @@ __INIT_MBSTATE(&(f.__state)); #endif /* __STDIO_MBSTATE */ -#ifdef __UCLIBC_HAS_THREADS__ - f.__user_locking = 1; /* Set user locking. */ - __stdio_init_mutex(&f.__lock); -#endif f.__nextopen = NULL; if (size > SIZE_MAX - (size_t) buf) { size = SIZE_MAX - (size_t) buf; } +/* TODO: this comment seems to be wrong */ /* Set these last since __bufputc initialization depends on * __user_locking and only gets set if user locking is on. */ f.__bufstart = (unsigned char *) buf; @@ -195,10 +192,6 @@ __INIT_MBSTATE(&(f.__state)); #endif /* __STDIO_MBSTATE */ -#ifdef __UCLIBC_HAS_THREADS__ - f.__user_locking = 1; /* Set user locking. */ - __stdio_init_mutex(&f.__lock); -#endif f.__nextopen = NULL; rv = _vfprintf_internal(&f, format, arg); Modified: trunk/uClibc/libc/stdio/vswprintf.c =================================================================== --- trunk/uClibc/libc/stdio/vswprintf.c 2008-04-09 19:51:18 UTC (rev 21683) +++ trunk/uClibc/libc/stdio/vswprintf.c 2008-04-09 19:52:13 UTC (rev 21684) @@ -38,10 +38,6 @@ __INIT_MBSTATE(&(f.__state)); #endif /* __STDIO_MBSTATE */ -#ifdef __UCLIBC_HAS_THREADS__ - f.__user_locking = 1; /* Set user locking. */ - __stdio_init_mutex(&f.__lock); -#endif f.__nextopen = NULL; if (size > ((SIZE_MAX - (size_t) buf)/sizeof(wchar_t))) { From bugs at busybox.net Wed Apr 9 12:52:36 2008 From: bugs at busybox.net (bugs at busybox.net) Date: Wed, 9 Apr 2008 12:52:36 -0700 Subject: [uClibc 0002714]: sprintf should not pull in most of stdio.h code Message-ID: <3907c93c665a6206aff9caecd50341fc@busybox.net> The following issue has been CLOSED ====================================================================== http://busybox.net/bugs/view.php?id=2714 ====================================================================== Reported By: vda Assigned To: uClibc ====================================================================== Project: uClibc Issue ID: 2714 Category: Stdio Reproducibility: always Severity: minor Priority: normal Status: closed Resolution: open Fixed in Version: ====================================================================== Date Submitted: 04-01-2008 09:26 PDT Last Modified: 04-09-2008 12:52 PDT ====================================================================== Summary: sprintf should not pull in most of stdio.h code Description: Use of [v]s[n]printf functions does not require application to necessarily pull in the whole of stdio.h machinery. Only formatting routines are needed. Currently I observe +12k growth when I add a sprintf(dummy_buf, "%d", some_var) to the program which otherwise does not use stdio.h. For one, seek and write functions ideally should not appear. ====================================================================== ---------------------------------------------------------------------- vda - 04-01-08 11:13 ---------------------------------------------------------------------- Since I have a good test case, I can provide more info (link map rules!). seeks are pulled in because of __UCLIBC_HAS_STDIO_AUTO_RW_TRANSITION__ here: #ifdef __UCLIBC_HAS_WCHAR__ int attribute_hidden __stdio_trans2w_o(FILE * __restrict stream, int oflag) #else int attribute_hidden __stdio_trans2w(FILE * __restrict stream) #endif { ... if (__STDIO_STREAM_IS_READING(stream)) { if (!__FEOF_UNLOCKED(stream)) { #ifdef __UCLIBC_HAS_STDIO_AUTO_RW_TRANSITION__ /* Need to seek to correct position if we have buffered * read data or ungots. If appending, we might as well * seek to the end. * * NOTE: If the OS does not handle append files correctly, * this is insufficient since we would need to seek to * the end even if not reading.*/ if (((__STDIO_STREAM_BUFFER_RAVAIL(stream)) || (stream->__modeflags & __FLAG_UNGOT)) && fseek(stream, 0L, ... which is pulled in because of STDIO_STREAM_TRANS_TO_WRITE here: int VFPRINTF (FILE * __restrict stream, register const FMT_TYPE * __restrict format, va_list arg) { ... if #ifdef L_vfprintf (!__STDIO_STREAM_IS_NARROW_WRITING(stream) && __STDIO_STREAM_TRANS_TO_WRITE(stream, __FLAG_NARROW)) #else (!__STDIO_STREAM_IS_WIDE_WRITING(stream) && __STDIO_STREAM_TRANS_TO_WRITE(stream, __FLAG_WIDE)) #endif ---------------------------------------------------------------------- vda - 04-01-08 12:04 ---------------------------------------------------------------------- Seems like it can be improved in _vfprintf.c / old_vfprintf.c by factoring out "the core" of vprintf() into separate function (say, "vprintf_internal_unlocked()"), so that: * vprintf() does locking and __STDIO_STREAM_TRANS_TO_WRITE thing, then calls vprintf_internal_unlocked(); * vsnprintf, vdprintf.c, vasprintf.c all use vprintf_internal_unlocked() directly [and do not need to set up fake locking now] ---------------------------------------------------------------------- vda - 04-01-08 14:50 ---------------------------------------------------------------------- 2.patch implements this solution. 3.patch removes unneeded initialization of locking. If you are going to apply it, take a look at vsnprintf.c's comment about __bufputc - it seems to be bogus, AFAICS __bufputc initialization has nothing to do with __user_locking. (I did grep around). Didn't look yet whether it works with old_vfprintf.c. ---------------------------------------------------------------------- vda - 04-01-08 15:22 ---------------------------------------------------------------------- These patches save http://busybox.net/bugs/view.php?id=115#400 bytes compared to unpatched uclibc. Next target can be removing __stdio_fwrite + __stdio_WRITE, as they should not be needed for sprintf too - projected to save http://busybox.net/bugs/view.php?id=23#300 bytes. ---------------------------------------------------------------------- vda - 04-08-08 17:54 ---------------------------------------------------------------------- v2 of patches should be more correct wrt old_vsprintf (it is just left untouched now) ---------------------------------------------------------------------- vda - 04-09-08 12:52 ---------------------------------------------------------------------- Applied as revisions 21683 and 21684. Issue History Date Modified Username Field Change ====================================================================== 04-01-08 09:26 vda New Issue 04-01-08 09:26 vda Status new => assigned 04-01-08 09:26 vda Assigned To => uClibc 04-01-08 11:13 vda Note Added: 0006274 04-01-08 12:04 vda Note Added: 0006284 04-01-08 14:46 vda File Added: 2.patch 04-01-08 14:46 vda File Added: 3.patch 04-01-08 14:50 vda Note Added: 0006294 04-01-08 15:22 vda Note Added: 0006304 04-08-08 17:53 vda File Added: v2_2.patch 04-08-08 17:53 vda File Added: v2_3.patch 04-08-08 17:54 vda Note Added: 0006454 04-09-08 12:52 vda Status assigned => closed 04-09-08 12:52 vda Note Added: 0006494 ====================================================================== From vda at uclibc.org Wed Apr 9 14:51:33 2008 From: vda at uclibc.org (vda at uclibc.org) Date: Wed, 9 Apr 2008 14:51:33 -0700 (PDT) Subject: svn commit: trunk/uClibc/libc/stdio Message-ID: <20080409215133.AB6243C51C@busybox.net> Author: vda Date: 2008-04-09 14:51:33 -0700 (Wed, 09 Apr 2008) New Revision: 21685 Log: restore erroneously removed hidden_def for vdprintf Modified: trunk/uClibc/libc/stdio/vdprintf.c Changeset: Modified: trunk/uClibc/libc/stdio/vdprintf.c =================================================================== --- trunk/uClibc/libc/stdio/vdprintf.c 2008-04-09 19:52:13 UTC (rev 21684) +++ trunk/uClibc/libc/stdio/vdprintf.c 2008-04-09 21:51:33 UTC (rev 21685) @@ -68,4 +68,5 @@ return rv; } +libc_hidden_def(vdprintf) #endif From vda at uclibc.org Wed Apr 9 15:22:28 2008 From: vda at uclibc.org (vda at uclibc.org) Date: Wed, 9 Apr 2008 15:22:28 -0700 (PDT) Subject: svn commit: trunk/uClibc/libc/stdio Message-ID: <20080409222228.EBE7A3C51A@busybox.net> Author: vda Date: 2008-04-09 15:22:28 -0700 (Wed, 09 Apr 2008) New Revision: 21686 Log: fix breakage in old_vfprintf case Modified: trunk/uClibc/libc/stdio/vdprintf.c trunk/uClibc/libc/stdio/vsnprintf.c trunk/uClibc/libc/stdio/vswprintf.c Changeset: Modified: trunk/uClibc/libc/stdio/vdprintf.c =================================================================== --- trunk/uClibc/libc/stdio/vdprintf.c 2008-04-09 21:51:33 UTC (rev 21685) +++ trunk/uClibc/libc/stdio/vdprintf.c 2008-04-09 22:22:28 UTC (rev 21686) @@ -11,6 +11,9 @@ #include "_stdio.h" #include +#ifdef __USE_OLD_VFPRINTF__ +libc_hidden_proto(vfprintf) +#endif libc_hidden_proto(fflush_unlocked) libc_hidden_proto(vdprintf) @@ -49,13 +52,17 @@ /* _vfprintf_internal doesn't do any locking, locking init is here * only because of fflush_unlocked. TODO? */ -#ifdef __UCLIBC_HAS_THREADS__ +#if (defined(__STDIO_BUFFERS) || defined(__USE_OLD_VFPRINTF__)) && defined(__UCLIBC_HAS_THREADS__) f.__user_locking = 1; /* Set user locking. */ __stdio_init_mutex(&f.__lock); #endif f.__nextopen = NULL; +#ifdef __USE_OLD_VFPRINTF__ + rv = vfprintf(&f, format, arg); +#else rv = _vfprintf_internal(&f, format, arg); +#endif #ifdef __STDIO_BUFFERS /* If not buffering, then fflush is unnecessary. */ Modified: trunk/uClibc/libc/stdio/vsnprintf.c =================================================================== --- trunk/uClibc/libc/stdio/vsnprintf.c 2008-04-09 21:51:33 UTC (rev 21685) +++ trunk/uClibc/libc/stdio/vsnprintf.c 2008-04-09 22:22:28 UTC (rev 21686) @@ -10,12 +10,18 @@ libc_hidden_proto(vsnprintf) +#ifdef __USE_OLD_VFPRINTF__ +libc_hidden_proto(vfprintf) +#endif + #ifdef __UCLIBC_MJN3_ONLY__ #warning WISHLIST: Implement vsnprintf for non-buffered and no custom stream case. #endif /* __UCLIBC_MJN3_ONLY__ */ #ifdef __STDIO_BUFFERS +/* NB: __USE_OLD_VFPRINTF__ is not defined in this case */ + int vsnprintf(char *__restrict buf, size_t size, const char * __restrict format, va_list arg) { Modified: trunk/uClibc/libc/stdio/vswprintf.c =================================================================== --- trunk/uClibc/libc/stdio/vswprintf.c 2008-04-09 21:51:33 UTC (rev 21685) +++ trunk/uClibc/libc/stdio/vswprintf.c 2008-04-09 22:22:28 UTC (rev 21686) @@ -11,6 +11,10 @@ libc_hidden_proto(vswprintf) +#ifdef __USE_OLD_VFPRINTF__ +libc_hidden_proto(vfwprintf) +#endif + #ifndef __STDIO_BUFFERS #warning Skipping vswprintf since no buffering! #else /* __STDIO_BUFFERS */ @@ -38,6 +42,10 @@ __INIT_MBSTATE(&(f.__state)); #endif /* __STDIO_MBSTATE */ +#if defined(__USE_OLD_VFPRINTF__) && defined(__UCLIBC_HAS_THREADS__) + f.__user_locking = 1; /* Set user locking. */ + __stdio_init_mutex(&f.__lock); +#endif f.__nextopen = NULL; if (size > ((SIZE_MAX - (size_t) buf)/sizeof(wchar_t))) { @@ -50,7 +58,11 @@ __STDIO_STREAM_DISABLE_GETC(&f); __STDIO_STREAM_DISABLE_PUTC(&f); +#ifdef __USE_OLD_VFPRINTF__ + rv = vfwprintf(&f, format, arg); +#else rv = _vfwprintf_internal(&f, format, arg); +#endif /* NOTE: Return behaviour differs from snprintf... */ if (f.__bufpos == f.__bufend) { From bugs at busybox.net Wed Apr 9 19:22:51 2008 From: bugs at busybox.net (bugs at busybox.net) Date: Wed, 9 Apr 2008 19:22:51 -0700 Subject: [uClibc 0002454]: Fixing ARM EABI support bug in syscall() Message-ID: <67c93786fe7b84f9a91c1c9b68365168@busybox.net> A NOTE has been added to this issue. ====================================================================== http://busybox.net/bugs/view.php?id=2454 ====================================================================== Reported By: Joe Lin Assigned To: uClibc ====================================================================== Project: uClibc Issue ID: 2454 Category: Architecture Specific Reproducibility: always Severity: major Priority: normal Status: assigned ====================================================================== Date Submitted: 03-06-2008 04:12 PST Last Modified: 04-09-2008 19:22 PDT ====================================================================== Summary: Fixing ARM EABI support bug in syscall() Description: When making an EABI syscall() system call, the library does not correctly pass requesting system number to the Linux kernel. For example, the ping facility in Busybox will issue a syscall() to get monotonic time (see monotonic_us() in libbb/time.c). The syscall() in syscall-eabi.S passes R7 value verbatim. But the kernel (see linux's vector_swi routine in arch/arm/kernel/entry-common.S) expects R7 a number without __NR_SYSCALL_BASE. This bug caused a Segmentation Fault. Below is the patch. -------------------------------------------------------------- diff -Naurd uClibc-0.9.29/libc/sysdeps/linux/arm/syscall-eabi.S uClibc-0.9.29-p1/libc/sysdeps/linux/arm/syscall-eabi.S --- uClibc-0.9.29/libc/sysdeps/linux/arm/syscall-eabi.S 2006-02-11 12:29:52.000000000 +0800 +++ uClibc-0.9.29-p1/libc/sysdeps/linux/arm/syscall-eabi.S 2008-03-06 19:53:15.000000000 +0800 @@ -29,7 +29,7 @@ syscall: mov ip, sp stmfd sp!, {r4, r5, r6, r7} - mov r7, r0 + sub r7, r0, #SYS_SYSCALL_BASE mov r0, r1 mov r1, r2 mov r2, r3 -------------------------------------------------------------- ====================================================================== ---------------------------------------------------------------------- khem - 04-09-08 00:07 ---------------------------------------------------------------------- is your kernel compiled with AEABI ? Are you compiling uclibc also with EABI turned on in toolchain ? ---------------------------------------------------------------------- Joe Lin - 04-09-08 19:22 ---------------------------------------------------------------------- Yes, I compiled both kernel and uClibc with EABI turned on. If uClibc was compiled in OABI, it would go through different path in kernel, which got no problem. If kernel was not compiled to process EABI executables, EABI programs would not work. Issue History Date Modified Username Field Change ====================================================================== 03-06-08 04:12 Joe Lin New Issue 03-06-08 04:12 Joe Lin Status new => assigned 03-06-08 04:12 Joe Lin Assigned To => uClibc 04-09-08 00:07 khem Note Added: 0006484 04-09-08 19:22 Joe Lin Note Added: 0006504 ====================================================================== From vda at uclibc.org Thu Apr 10 13:39:08 2008 From: vda at uclibc.org (vda at uclibc.org) Date: Thu, 10 Apr 2008 13:39:08 -0700 (PDT) Subject: svn commit: trunk/uClibc/libc/stdio Message-ID: <20080410203908.1AAD83C59B@busybox.net> Author: vda Date: 2008-04-10 13:39:07 -0700 (Thu, 10 Apr 2008) New Revision: 21693 Log: even more fixes for vda-made breakage in vXXXfprintf (pointed out by Peter S.Mazinger) Modified: trunk/uClibc/libc/stdio/_vfprintf.c trunk/uClibc/libc/stdio/vsnprintf.c trunk/uClibc/libc/stdio/vswprintf.c Changeset: Modified: trunk/uClibc/libc/stdio/_vfprintf.c =================================================================== --- trunk/uClibc/libc/stdio/_vfprintf.c 2008-04-10 19:59:20 UTC (rev 21692) +++ trunk/uClibc/libc/stdio/_vfprintf.c 2008-04-10 20:39:07 UTC (rev 21693) @@ -1866,7 +1866,7 @@ libc_hidden_proto(fprintf) int VFPRINTF_internal (FILE * __restrict stream, - register const FMT_TYPE * __restrict format, + const FMT_TYPE * __restrict format, va_list arg) { ppfs_t ppfs; @@ -1954,7 +1954,7 @@ libc_hidden_proto(VFPRINTF) int VFPRINTF (FILE * __restrict stream, - register const FMT_TYPE * __restrict format, + const FMT_TYPE * __restrict format, va_list arg) { int count; Modified: trunk/uClibc/libc/stdio/vsnprintf.c =================================================================== --- trunk/uClibc/libc/stdio/vsnprintf.c 2008-04-10 19:59:20 UTC (rev 21692) +++ trunk/uClibc/libc/stdio/vsnprintf.c 2008-04-10 20:39:07 UTC (rev 21693) @@ -19,9 +19,8 @@ #endif /* __UCLIBC_MJN3_ONLY__ */ #ifdef __STDIO_BUFFERS +/* NB: we can still have __USE_OLD_VFPRINTF__ defined in this case! */ -/* NB: __USE_OLD_VFPRINTF__ is not defined in this case */ - int vsnprintf(char *__restrict buf, size_t size, const char * __restrict format, va_list arg) { @@ -47,6 +46,10 @@ __INIT_MBSTATE(&(f.__state)); #endif /* __STDIO_MBSTATE */ +#if defined(__USE_OLD_VFPRINTF__) && defined(__UCLIBC_HAS_THREADS__) + f.__user_locking = 1; /* Set user locking. */ + __stdio_init_mutex(&f.__lock); +#endif f.__nextopen = NULL; if (size > SIZE_MAX - (size_t) buf) { @@ -62,7 +65,11 @@ __STDIO_STREAM_DISABLE_GETC(&f); __STDIO_STREAM_ENABLE_PUTC(&f); +#ifdef __USE_OLD_VFPRINTF__ + rv = vfprintf(&f, format, arg); +#else rv = _vfprintf_internal(&f, format, arg); +#endif if (size) { if (f.__bufpos == f.__bufend) { --f.__bufpos; Modified: trunk/uClibc/libc/stdio/vswprintf.c =================================================================== --- trunk/uClibc/libc/stdio/vswprintf.c 2008-04-10 19:59:20 UTC (rev 21692) +++ trunk/uClibc/libc/stdio/vswprintf.c 2008-04-10 20:39:07 UTC (rev 21693) @@ -11,9 +11,7 @@ libc_hidden_proto(vswprintf) -#ifdef __USE_OLD_VFPRINTF__ -libc_hidden_proto(vfwprintf) -#endif +/* NB: this file is not used if __USE_OLD_VFPRINTF__ */ #ifndef __STDIO_BUFFERS #warning Skipping vswprintf since no buffering! @@ -42,10 +40,6 @@ __INIT_MBSTATE(&(f.__state)); #endif /* __STDIO_MBSTATE */ -#if defined(__USE_OLD_VFPRINTF__) && defined(__UCLIBC_HAS_THREADS__) - f.__user_locking = 1; /* Set user locking. */ - __stdio_init_mutex(&f.__lock); -#endif f.__nextopen = NULL; if (size > ((SIZE_MAX - (size_t) buf)/sizeof(wchar_t))) { @@ -58,11 +52,7 @@ __STDIO_STREAM_DISABLE_GETC(&f); __STDIO_STREAM_DISABLE_PUTC(&f); -#ifdef __USE_OLD_VFPRINTF__ - rv = vfwprintf(&f, format, arg); -#else rv = _vfwprintf_internal(&f, format, arg); -#endif /* NOTE: Return behaviour differs from snprintf... */ if (f.__bufpos == f.__bufend) { From vda at uclibc.org Thu Apr 10 14:15:59 2008 From: vda at uclibc.org (vda at uclibc.org) Date: Thu, 10 Apr 2008 14:15:59 -0700 (PDT) Subject: svn commit: trunk/uClibc/libc/stdio Message-ID: <20080410211559.485693C5B0@busybox.net> Author: vda Date: 2008-04-10 14:15:59 -0700 (Thu, 10 Apr 2008) New Revision: 21697 Log: remove "register" from _vf[w]printf_internal declarations too Modified: trunk/uClibc/libc/stdio/_stdio.h Changeset: Modified: trunk/uClibc/libc/stdio/_stdio.h =================================================================== --- trunk/uClibc/libc/stdio/_stdio.h 2008-04-10 21:05:30 UTC (rev 21696) +++ trunk/uClibc/libc/stdio/_stdio.h 2008-04-10 21:15:59 UTC (rev 21697) @@ -434,12 +434,12 @@ /**********************************************************************/ extern int _vfprintf_internal (FILE * __restrict stream, - register const char * __restrict format, + const char * __restrict format, va_list arg) attribute_hidden; #ifdef __UCLIBC_HAS_WCHAR__ extern int _vfwprintf_internal (FILE * __restrict stream, - register const wchar_t * __restrict format, + const wchar_t * __restrict format, va_list arg) attribute_hidden; #endif From bugs at busybox.net Thu Apr 10 19:12:05 2008 From: bugs at busybox.net (bugs at busybox.net) Date: Thu, 10 Apr 2008 19:12:05 -0700 Subject: [uClibc 0002454]: Fixing ARM EABI support bug in syscall() Message-ID: <4fa66822df3305b668f2ea72dbb32999@busybox.net> A NOTE has been added to this issue. ====================================================================== http://busybox.net/bugs/view.php?id=2454 ====================================================================== Reported By: Joe Lin Assigned To: uClibc ====================================================================== Project: uClibc Issue ID: 2454 Category: Architecture Specific Reproducibility: always Severity: major Priority: normal Status: assigned ====================================================================== Date Submitted: 03-06-2008 04:12 PST Last Modified: 04-10-2008 19:12 PDT ====================================================================== Summary: Fixing ARM EABI support bug in syscall() Description: When making an EABI syscall() system call, the library does not correctly pass requesting system number to the Linux kernel. For example, the ping facility in Busybox will issue a syscall() to get monotonic time (see monotonic_us() in libbb/time.c). The syscall() in syscall-eabi.S passes R7 value verbatim. But the kernel (see linux's vector_swi routine in arch/arm/kernel/entry-common.S) expects R7 a number without __NR_SYSCALL_BASE. This bug caused a Segmentation Fault. Below is the patch. -------------------------------------------------------------- diff -Naurd uClibc-0.9.29/libc/sysdeps/linux/arm/syscall-eabi.S uClibc-0.9.29-p1/libc/sysdeps/linux/arm/syscall-eabi.S --- uClibc-0.9.29/libc/sysdeps/linux/arm/syscall-eabi.S 2006-02-11 12:29:52.000000000 +0800 +++ uClibc-0.9.29-p1/libc/sysdeps/linux/arm/syscall-eabi.S 2008-03-06 19:53:15.000000000 +0800 @@ -29,7 +29,7 @@ syscall: mov ip, sp stmfd sp!, {r4, r5, r6, r7} - mov r7, r0 + sub r7, r0, #SYS_SYSCALL_BASE mov r0, r1 mov r1, r2 mov r2, r3 -------------------------------------------------------------- ====================================================================== ---------------------------------------------------------------------- khem - 04-09-08 00:07 ---------------------------------------------------------------------- is your kernel compiled with AEABI ? Are you compiling uclibc also with EABI turned on in toolchain ? ---------------------------------------------------------------------- Joe Lin - 04-09-08 19:22 ---------------------------------------------------------------------- Yes, I compiled both kernel and uClibc with EABI turned on. If uClibc was compiled in OABI, it would go through different path in kernel, which got no problem. If kernel was not compiled to process EABI executables, EABI programs would not work. ---------------------------------------------------------------------- khem - 04-10-08 19:12 ---------------------------------------------------------------------- I do not get segmentation fault on using busybox applet ping. Issue History Date Modified Username Field Change ====================================================================== 03-06-08 04:12 Joe Lin New Issue 03-06-08 04:12 Joe Lin Status new => assigned 03-06-08 04:12 Joe Lin Assigned To => uClibc 04-09-08 00:07 khem Note Added: 0006484 04-09-08 19:22 Joe Lin Note Added: 0006504 04-10-08 19:12 khem Note Added: 0006554 ====================================================================== From bugs at busybox.net Fri Apr 11 01:43:57 2008 From: bugs at busybox.net (bugs at busybox.net) Date: Fri, 11 Apr 2008 01:43:57 -0700 Subject: [uClibc 0002894]: extra/scripts/gen_bits_syscall_h.sh dont catch all armspecifc syscalls Message-ID: The following issue has been SUBMITTED. ====================================================================== http://busybox.net/bugs/view.php?id=2894 ====================================================================== Reported By: woglinde Assigned To: uClibc ====================================================================== Project: uClibc Issue ID: 2894 Category: Architecture Specific Reproducibility: always Severity: minor Priority: normal Status: assigned ====================================================================== Date Submitted: 04-11-2008 01:43 PDT Last Modified: 04-11-2008 01:43 PDT ====================================================================== Summary: extra/scripts/gen_bits_syscall_h.sh dont catch all armspecifc syscalls Description: Hi, the gen_bits_syscall_h.sh did the right-thing for serval years. But Mr. RMK changed the unistd.h for arm in a way, that some arm-specific syscalls/swi(__ARM_NR_BASE) are now stripped out. They are seldom used but they are, especially in the cacao javavm. I used my small jedi-regexp and sed-knowledge and hope the attached patch fixes this and don't break any other arch. ====================================================================== Issue History Date Modified Username Field Change ====================================================================== 04-11-08 01:43 woglinde New Issue 04-11-08 01:43 woglinde Status new => assigned 04-11-08 01:43 woglinde Assigned To => uClibc 04-11-08 01:43 woglinde File Added: unistd_arm.patch ====================================================================== From vda at uclibc.org Fri Apr 11 18:34:05 2008 From: vda at uclibc.org (vda at uclibc.org) Date: Fri, 11 Apr 2008 18:34:05 -0700 (PDT) Subject: svn commit: trunk/uClibc: include include/rpc libc/inet libc/inet/ etc... Message-ID: <20080412013405.4E0A83C4B9@busybox.net> Author: vda Date: 2008-04-11 18:34:04 -0700 (Fri, 11 Apr 2008) New Revision: 21713 Log: Functions should be either exported in public .h files and marked with libc_hidden_proto/def(), or not be exported in .h files and be hidden (or even static if possible). We have five functions which violate this. Fixing: netdb.h: export ruserpass() rpc/rpc.h: export xdr_accepted_reply() and xdr_rejected_reply() make inet_ntoa_r static function (it is not exported in any .h file) make _time_tzset hidden function (it is not exported in any .h file) Modified: trunk/uClibc/include/netdb.h trunk/uClibc/include/rpc/rpc.h trunk/uClibc/libc/inet/addr.c trunk/uClibc/libc/inet/rpc/rexec.c trunk/uClibc/libc/inet/rpc/rpc_prot.c trunk/uClibc/libc/inet/rpc/ruserpass.c trunk/uClibc/libc/misc/time/time.c Changeset: Modified: trunk/uClibc/include/netdb.h =================================================================== --- trunk/uClibc/include/netdb.h 2008-04-11 21:32:09 UTC (rev 21712) +++ trunk/uClibc/include/netdb.h 2008-04-12 01:34:04 UTC (rev 21713) @@ -444,6 +444,11 @@ #endif /* misc */ +/* ruserpass - remote password check. + This function also exists in glibc but is undocumented */ +extern int ruserpass(const char *host, const char **aname, const char **apass); + + #ifdef __USE_BSD /* Call `rshd' at port RPORT on remote machine *AHOST to execute CMD. The local user is LOCUSER, on the remote machine the command is Modified: trunk/uClibc/include/rpc/rpc.h =================================================================== --- trunk/uClibc/include/rpc/rpc.h 2008-04-11 21:32:09 UTC (rev 21712) +++ trunk/uClibc/include/rpc/rpc.h 2008-04-12 01:34:04 UTC (rev 21713) @@ -105,6 +105,9 @@ extern int *__rpc_thread_svc_max_pollfd (void) __attribute__ ((__const__)); #define svc_max_pollfd (*__rpc_thread_svc_max_pollfd ()) +extern bool_t xdr_accepted_reply (XDR *xdrs, struct accepted_reply *ar); +extern bool_t xdr_rejected_reply (XDR *xdrs, struct rejected_reply *rr); + __END_DECLS #endif /* rpc/rpc.h */ Modified: trunk/uClibc/libc/inet/addr.c =================================================================== --- trunk/uClibc/libc/inet/addr.c 2008-04-11 21:32:09 UTC (rev 21712) +++ trunk/uClibc/libc/inet/addr.c 2008-04-12 01:34:04 UTC (rev 21713) @@ -122,9 +122,7 @@ #define INET_NTOA_MAX_LEN 16 /* max 12 digits + 3 '.'s + 1 nul */ -extern char *inet_ntoa_r(struct in_addr in, char buf[INET_NTOA_MAX_LEN]); -libc_hidden_proto(inet_ntoa_r) -char *inet_ntoa_r(struct in_addr in, char buf[INET_NTOA_MAX_LEN]) +static char *inet_ntoa_r(struct in_addr in, char buf[INET_NTOA_MAX_LEN]) { in_addr_t addr = ntohl(in.s_addr); int i; @@ -143,7 +141,6 @@ return p+1; } -libc_hidden_def(inet_ntoa_r) libc_hidden_proto(inet_ntoa) char *inet_ntoa(struct in_addr in) Modified: trunk/uClibc/libc/inet/rpc/rexec.c =================================================================== --- trunk/uClibc/libc/inet/rpc/rexec.c 2008-04-11 21:32:09 UTC (rev 21712) +++ trunk/uClibc/libc/inet/rpc/rexec.c 2008-04-12 01:34:04 UTC (rev 21713) @@ -61,14 +61,13 @@ libc_hidden_proto(connect) libc_hidden_proto(accept) libc_hidden_proto(listen) +libc_hidden_proto(ruserpass) #define SA_LEN(_x) __libc_sa_len((_x)->sa_family) extern int __libc_sa_len (sa_family_t __af) __THROW attribute_hidden; int rexecoptions; char ahostbuf[NI_MAXHOST] attribute_hidden; -extern int ruserpass(const char *host, const char **aname, const char **apass) attribute_hidden; -libc_hidden_proto(ruserpass) libc_hidden_proto(rexec_af) int Modified: trunk/uClibc/libc/inet/rpc/rpc_prot.c =================================================================== --- trunk/uClibc/libc/inet/rpc/rpc_prot.c 2008-04-11 21:32:09 UTC (rev 21712) +++ trunk/uClibc/libc/inet/rpc/rpc_prot.c 2008-04-12 01:34:04 UTC (rev 21713) @@ -89,7 +89,6 @@ /* * XDR the MSG_ACCEPTED part of a reply message union */ -extern bool_t xdr_accepted_reply (XDR *xdrs, struct accepted_reply *ar); libc_hidden_proto(xdr_accepted_reply) bool_t xdr_accepted_reply (XDR *xdrs, struct accepted_reply *ar) @@ -117,7 +116,6 @@ /* * XDR the MSG_DENIED part of a reply message union */ -extern bool_t xdr_rejected_reply (XDR *xdrs, struct rejected_reply *rr); libc_hidden_proto(xdr_rejected_reply) bool_t xdr_rejected_reply (XDR *xdrs, struct rejected_reply *rr) Modified: trunk/uClibc/libc/inet/rpc/ruserpass.c =================================================================== --- trunk/uClibc/libc/inet/rpc/ruserpass.c 2008-04-11 21:32:09 UTC (rev 21712) +++ trunk/uClibc/libc/inet/rpc/ruserpass.c 2008-04-12 01:34:04 UTC (rev 21713) @@ -115,8 +115,8 @@ }; - -extern int ruserpass(const char *host, const char **aname, const char **apass); +/* ruserpass - remote password check. + This function also exists in glibc but is undocumented */ libc_hidden_proto(ruserpass) int ruserpass(const char *host, const char **aname, const char **apass) { Modified: trunk/uClibc/libc/misc/time/time.c =================================================================== --- trunk/uClibc/libc/misc/time/time.c 2008-04-11 21:32:09 UTC (rev 21712) +++ trunk/uClibc/libc/misc/time/time.c 2008-04-12 01:34:04 UTC (rev 21713) @@ -202,8 +202,7 @@ ((defined(L_strftime) || defined(L_strftime_l)) && \ defined(__UCLIBC_HAS_XLOCALE__)) -void _time_tzset(int use_old_rules); -libc_hidden_proto(_time_tzset) +void _time_tzset(int use_old_rules) attribute_hidden; #ifndef L__time_mktime From bugs at busybox.net Sat Apr 12 17:15:13 2008 From: bugs at busybox.net (bugs at busybox.net) Date: Sat, 12 Apr 2008 17:15:13 -0700 Subject: [uClibc 0002074]: poll() does not work on Linux 2.0.40 Message-ID: <71b6892720fc8a905bfd35a594100e4f@bugs.uclibc.org> A NOTE has been added to this issue. ====================================================================== http://busybox.net/bugs/view.php?id=2074 ====================================================================== Reported By: michael_d Assigned To: uClibc ====================================================================== Project: uClibc Issue ID: 2074 Category: Other Reproducibility: always Severity: minor Priority: normal Status: assigned ====================================================================== Date Submitted: 02-07-2008 19:49 PST Last Modified: 04-12-2008 17:15 PDT ====================================================================== Summary: poll() does not work on Linux 2.0.40 Description: When compiled for Linux 2.0.40, the poll() function will not work, always returning ENOSYS. While that kernel does not implement the poll syscall, there is a complete emulation within uClibc's source, which works fine but is not normally compiled in. The problem is that this kernel's defines __NR_poll, even though it does not implement the syscall. uClibc blindly assumes that the call will work if its number is defined, and discards the emulation to save space. To fix this, the library needs to check for the presence of the header, rather than just seeing if the syscall number is defined. I've worked around this locally by editing to remove __NR_poll. (Note that fixes for issues http://busybox.net/bugs/view.php?id=1874 and http://busybox.net/bugs/view.php?id=2064 must be applied before compilation of uClibc is possible on this platform.) ====================================================================== ---------------------------------------------------------------------- vapier - 02-15-08 15:39 ---------------------------------------------------------------------- please see the FAQ: http://uclibc.org/FAQ.html#upstream_versions in other words, please post a patch that addresses the issue for you ---------------------------------------------------------------------- michael_d - 03-13-08 05:18 ---------------------------------------------------------------------- I've uploaded a patch, which checks whether the kernel headers include . If that header is not present, it's unlikely the kernel really supports the syscall. ---------------------------------------------------------------------- vapier - 03-21-08 00:02 ---------------------------------------------------------------------- erm, no, lets not do that ... just add a check via KERNEL_VERSION() and LINUX_VERSION_CODE ---------------------------------------------------------------------- khem - 04-08-08 23:30 ---------------------------------------------------------------------- kernel should not export NR_poll if it does not implement the syscall. So fix in the kernel headers what you did is right thing to do. Nothing is needed to be done in uclibc in my opinion. ---------------------------------------------------------------------- michael_d - 04-12-08 17:15 ---------------------------------------------------------------------- I dislike hardcoding things via the kernel version, since that assumes things do not get backported. Sure, it's unlikely with an old kernel, but a poll() "backport" for 2.0.* actually existed at one time in the form of the LiS patches. I've uploaded a new version, which compromises a little. I've created a central header , which holds information on which kernel headers are actually present. However, while this header could be generated with a little shell/find/sed magic, for know it's just faked using LINUX_VERSION_CODE, and only for headers of interest. (The header also covers , which while not needed for the immediate problem, will help with a solution to http://busybox.net/bugs/view.php?id=2084.) Issue History Date Modified Username Field Change ====================================================================== 02-07-08 19:49 michael_d New Issue 02-07-08 19:49 michael_d Status new => assigned 02-07-08 19:49 michael_d Assigned To => uClibc 02-15-08 15:39 vapier Note Added: 0004924 03-13-08 05:15 michael_d File Added: uClibc-0.9.29-pollfix.diff 03-13-08 05:18 michael_d Note Added: 0005704 03-21-08 00:02 vapier Note Added: 0005824 04-08-08 23:30 khem Note Added: 0006474 04-12-08 17:12 michael_d File Added: uClibc-0.9.29-pollfix2.diff 04-12-08 17:15 michael_d Note Added: 0006594 ====================================================================== From bugs at busybox.net Sun Apr 13 18:39:27 2008 From: bugs at busybox.net (bugs at busybox.net) Date: Sun, 13 Apr 2008 18:39:27 -0700 Subject: [uClibc 0002454]: Fixing ARM EABI support bug in syscall() Message-ID: <161b524a76b621889138b907c60b121b@busybox.net> A NOTE has been added to this issue. ====================================================================== http://busybox.net/bugs/view.php?id=2454 ====================================================================== Reported By: Joe Lin Assigned To: uClibc ====================================================================== Project: uClibc Issue ID: 2454 Category: Architecture Specific Reproducibility: always Severity: major Priority: normal Status: assigned ====================================================================== Date Submitted: 03-06-2008 04:12 PST Last Modified: 04-13-2008 18:39 PDT ====================================================================== Summary: Fixing ARM EABI support bug in syscall() Description: When making an EABI syscall() system call, the library does not correctly pass requesting system number to the Linux kernel. For example, the ping facility in Busybox will issue a syscall() to get monotonic time (see monotonic_us() in libbb/time.c). The syscall() in syscall-eabi.S passes R7 value verbatim. But the kernel (see linux's vector_swi routine in arch/arm/kernel/entry-common.S) expects R7 a number without __NR_SYSCALL_BASE. This bug caused a Segmentation Fault. Below is the patch. -------------------------------------------------------------- diff -Naurd uClibc-0.9.29/libc/sysdeps/linux/arm/syscall-eabi.S uClibc-0.9.29-p1/libc/sysdeps/linux/arm/syscall-eabi.S --- uClibc-0.9.29/libc/sysdeps/linux/arm/syscall-eabi.S 2006-02-11 12:29:52.000000000 +0800 +++ uClibc-0.9.29-p1/libc/sysdeps/linux/arm/syscall-eabi.S 2008-03-06 19:53:15.000000000 +0800 @@ -29,7 +29,7 @@ syscall: mov ip, sp stmfd sp!, {r4, r5, r6, r7} - mov r7, r0 + sub r7, r0, #SYS_SYSCALL_BASE mov r0, r1 mov r1, r2 mov r2, r3 -------------------------------------------------------------- ====================================================================== ---------------------------------------------------------------------- khem - 04-09-08 00:07 ---------------------------------------------------------------------- is your kernel compiled with AEABI ? Are you compiling uclibc also with EABI turned on in toolchain ? ---------------------------------------------------------------------- Joe Lin - 04-09-08 19:22 ---------------------------------------------------------------------- Yes, I compiled both kernel and uClibc with EABI turned on. If uClibc was compiled in OABI, it would go through different path in kernel, which got no problem. If kernel was not compiled to process EABI executables, EABI programs would not work. ---------------------------------------------------------------------- khem - 04-10-08 19:12 ---------------------------------------------------------------------- I do not get segmentation fault on using busybox applet ping. ---------------------------------------------------------------------- Joe Lin - 04-13-08 18:39 ---------------------------------------------------------------------- No segmentation fault? My code runs with the patch ok, which means it should get the fault if without the patch. I'll take a time to review the exact point of problem using my hardware ICE. For now I just can't remember where the instruction is in the arch/arm/kernel/entry-common.S. Will report the point then. Issue History Date Modified Username Field Change ====================================================================== 03-06-08 04:12 Joe Lin New Issue 03-06-08 04:12 Joe Lin Status new => assigned 03-06-08 04:12 Joe Lin Assigned To => uClibc 04-09-08 00:07 khem Note Added: 0006484 04-09-08 19:22 Joe Lin Note Added: 0006504 04-10-08 19:12 khem Note Added: 0006554 04-13-08 18:39 Joe Lin Note Added: 0006604 ====================================================================== From vda at uclibc.org Tue Apr 15 01:23:20 2008 From: vda at uclibc.org (vda at uclibc.org) Date: Tue, 15 Apr 2008 01:23:20 -0700 (PDT) Subject: svn commit: trunk/uClibc/libc/string/x86_64 Message-ID: <20080415082320.6978B3C535@busybox.net> Author: vda Date: 2008-04-15 01:23:19 -0700 (Tue, 15 Apr 2008) New Revision: 21736 Log: amd64 string ops: replace some instructions by smaller ones, e.g. testb $0xff, %cl -> testb %cl, %cl Modified: trunk/uClibc/libc/string/x86_64/memset.S trunk/uClibc/libc/string/x86_64/strcat.S trunk/uClibc/libc/string/x86_64/strcspn.S trunk/uClibc/libc/string/x86_64/strlen.S trunk/uClibc/libc/string/x86_64/strspn.S Changeset: Modified: trunk/uClibc/libc/string/x86_64/memset.S =================================================================== --- trunk/uClibc/libc/string/x86_64/memset.S 2008-04-15 01:17:50 UTC (rev 21735) +++ trunk/uClibc/libc/string/x86_64/memset.S 2008-04-15 08:23:19 UTC (rev 21736) @@ -53,15 +53,15 @@ imul %rax,%r8 #endif test $0x7,%edi /* Check for alignment. */ - je 2f + jz 2f .p2align 4 1: /* Align ptr to 8 byte. */ mov %sil,(%rcx) dec %rdx inc %rcx - test $0x7,%ecx - jne 1b + test $0x7,%cl + jnz 1b 2: /* Check for really large regions. */ mov %rdx,%rax @@ -107,7 +107,7 @@ jne 8b 9: #if BZERO_P - nop /* huh?? */ + /* nothing */ #else /* Load result (only if used as memset). */ mov %rdi,%rax /* start address of destination is result */ Modified: trunk/uClibc/libc/string/x86_64/strcat.S =================================================================== --- trunk/uClibc/libc/string/x86_64/strcat.S 2008-04-15 01:17:50 UTC (rev 21735) +++ trunk/uClibc/libc/string/x86_64/strcat.S 2008-04-15 08:23:19 UTC (rev 21736) @@ -103,7 +103,7 @@ the addition will not result in 0. */ jz 4b /* no NUL found => continue loop */ - .p2align 4 /* Align, it's a jump target. */ + .p2align 4 /* Align, it is a jump target. */ 3: subq $8,%rax /* correct pointer increment. */ testb %cl, %cl /* is first byte NUL? */ Modified: trunk/uClibc/libc/string/x86_64/strcspn.S =================================================================== --- trunk/uClibc/libc/string/x86_64/strcspn.S 2008-04-15 01:17:50 UTC (rev 21735) +++ trunk/uClibc/libc/string/x86_64/strcspn.S 2008-04-15 08:23:19 UTC (rev 21736) @@ -26,7 +26,6 @@ #include "_glibc_inc.h" /* Seems to be unrolled too much */ -/* (and why testb $0xff, %cl, not testb %cl, %cl?) */ /* BEWARE: `#ifdef strcspn' means that strcspn is redefined as `strpbrk' */ #define STRPBRK_P (defined strcspn) @@ -63,19 +62,19 @@ movb %cl, (%rsp,%rcx) /* set corresponding byte in skipset table */ movb 1(%rax), %cl /* get byte from skipset */ - testb $0xff, %cl /* is NUL char? */ + testb %cl, %cl /* is NUL char? */ jz L(1) /* yes => start compare loop */ movb %cl, (%rsp,%rcx) /* set corresponding byte in skipset table */ movb 2(%rax), %cl /* get byte from skipset */ - testb $0xff, %cl /* is NUL char? */ + testb %cl, %cl /* is NUL char? */ jz L(1) /* yes => start compare loop */ movb %cl, (%rsp,%rcx) /* set corresponding byte in skipset table */ movb 3(%rax), %cl /* get byte from skipset */ addq $4, %rax /* increment skipset pointer */ movb %cl, (%rsp,%rcx) /* set corresponding byte in skipset table */ - testb $0xff, %cl /* is NUL char? */ + testb %cl, %cl /* is NUL char? */ jnz L(2) /* no => process next dword from skipset */ L(1): leaq -4(%rdx), %rax /* prepare loop */ Modified: trunk/uClibc/libc/string/x86_64/strlen.S =================================================================== --- trunk/uClibc/libc/string/x86_64/strlen.S 2008-04-15 01:17:50 UTC (rev 21735) +++ trunk/uClibc/libc/string/x86_64/strlen.S 2008-04-15 08:23:19 UTC (rev 21736) @@ -98,7 +98,7 @@ the addition will not result in 0. */ jz 4b /* no NUL found => continue loop */ - .p2align 4 /* Align, it's a jump target. */ + .p2align 4 /* Align, it is a jump target. */ 3: subq $8,%rax /* correct pointer increment. */ testb %cl, %cl /* is first byte NUL? */ Modified: trunk/uClibc/libc/string/x86_64/strspn.S =================================================================== --- trunk/uClibc/libc/string/x86_64/strspn.S 2008-04-15 01:17:50 UTC (rev 21735) +++ trunk/uClibc/libc/string/x86_64/strspn.S 2008-04-15 08:23:19 UTC (rev 21736) @@ -57,19 +57,19 @@ movb %cl, (%rsp,%rcx) /* set corresponding byte in stopset table */ movb 1(%rax), %cl /* get byte from stopset */ - testb $0xff, %cl /* is NUL char? */ + testb %cl, %cl /* is NUL char? */ jz L(1) /* yes => start compare loop */ movb %cl, (%rsp,%rcx) /* set corresponding byte in stopset table */ movb 2(%rax), %cl /* get byte from stopset */ - testb $0xff, %cl /* is NUL char? */ + testb %cl, %cl /* is NUL char? */ jz L(1) /* yes => start compare loop */ movb %cl, (%rsp,%rcx) /* set corresponding byte in stopset table */ movb 3(%rax), %cl /* get byte from stopset */ addq $4, %rax /* increment stopset pointer */ movb %cl, (%rsp,%rcx) /* set corresponding byte in stopset table */ - testb $0xff, %cl /* is NUL char? */ + testb %cl, %cl /* is NUL char? */ jnz L(2) /* no => process next dword from stopset */ L(1): leaq -4(%rdx), %rax /* prepare loop */ From vda at uclibc.org Tue Apr 15 01:27:24 2008 From: vda at uclibc.org (vda at uclibc.org) Date: Tue, 15 Apr 2008 01:27:24 -0700 (PDT) Subject: svn commit: trunk/uClibc/libc/string/x86_64 Message-ID: <20080415082724.9BA673C54F@busybox.net> Author: vda Date: 2008-04-15 01:27:24 -0700 (Tue, 15 Apr 2008) New Revision: 21738 Log: amd64 string ops: use alignment more carefully, and comment it. By capping max padding to not be bigger than three next insns, we avoid having ridiculously big NOPs like this one: 53:66 66 66 66 2e 0f 1f nopw %cs:0x0(%rax,%rax,1) 5a:84 00 00 00 00 00 which was bigger than next three insns combined! Size changes: text data bss dec hex filename 102 0 0 102 66 x86_64/memcpy.o 102 0 0 102 66 x86_64.old/memcpy.o 90 0 0 90 5a x86_64/mempcpy.o 102 0 0 102 66 x86_64.old/mempcpy.o 210 0 0 210 d2 x86_64/memset.o 242 0 0 242 f2 x86_64.old/memset.o 213 0 0 213 d5 x86_64/stpcpy.o 220 0 0 220 dc x86_64.old/stpcpy.o 428 0 0 428 1ac x86_64/strcat.o 444 0 0 444 1bc x86_64.old/strcat.o 417 0 0 417 1a1 x86_64/strchr.o 418 0 0 418 1a2 x86_64.old/strchr.o 33 0 0 33 21 x86_64/strcmp.o 33 0 0 33 21 x86_64.old/strcmp.o 213 0 0 213 d5 x86_64/strcpy.o 220 0 0 220 dc x86_64.old/strcpy.o 135 0 0 135 87 x86_64/strcspn.o 151 0 0 151 97 x86_64.old/strcspn.o 225 0 0 225 e1 x86_64/strlen.o 233 0 0 233 e9 x86_64.old/strlen.o 140 0 0 140 8c x86_64/strpbrk.o 156 0 0 156 9c x86_64.old/strpbrk.o 135 0 0 135 87 x86_64/strspn.o 151 0 0 151 97 x86_64.old/strspn.o Also, a few files got their .text alignment relaxed from 16 to 8 bytes, which reduces padding at link time. Modified: trunk/uClibc/libc/string/x86_64/memcpy.S trunk/uClibc/libc/string/x86_64/memset.S trunk/uClibc/libc/string/x86_64/strcat.S trunk/uClibc/libc/string/x86_64/strchr.S trunk/uClibc/libc/string/x86_64/strcpy.S trunk/uClibc/libc/string/x86_64/strcspn.S trunk/uClibc/libc/string/x86_64/strlen.S trunk/uClibc/libc/string/x86_64/strspn.S Changeset: Modified: trunk/uClibc/libc/string/x86_64/memcpy.S =================================================================== --- trunk/uClibc/libc/string/x86_64/memcpy.S 2008-04-15 08:25:32 UTC (rev 21737) +++ trunk/uClibc/libc/string/x86_64/memcpy.S 2008-04-15 08:27:24 UTC (rev 21738) @@ -59,9 +59,9 @@ subq $32, %rcx js 2f - .p2align 4 + /* Next 3 insns are 11 bytes total, make sure we decode them in one go */ + .p2align 4,,11 3: - /* Now correct the loop counter. Please note that in the following code the flags are not changed anymore. */ subq $32, %rcx Modified: trunk/uClibc/libc/string/x86_64/memset.S =================================================================== --- trunk/uClibc/libc/string/x86_64/memset.S 2008-04-15 08:25:32 UTC (rev 21737) +++ trunk/uClibc/libc/string/x86_64/memset.S 2008-04-15 08:27:24 UTC (rev 21738) @@ -55,8 +55,10 @@ test $0x7,%edi /* Check for alignment. */ jz 2f - .p2align 4 -1: /* Align ptr to 8 byte. */ + /* Next 3 insns are 9 bytes total, make sure we decode them in one go */ + .p2align 4,,9 +1: + /* Align ptr to 8 byte. */ mov %sil,(%rcx) dec %rdx inc %rcx @@ -70,8 +72,10 @@ cmp LARGE, %rdx jae 11f - .p2align 4 -3: /* Fill 64 bytes. */ + /* Next 3 insns are 11 bytes total, make sure we decode them in one go */ + .p2align 4,,11 +3: + /* Fill 64 bytes. */ mov %r8,(%rcx) mov %r8,0x8(%rcx) mov %r8,0x10(%rcx) @@ -114,9 +118,11 @@ #endif retq - .p2align 4 -11: /* Fill 64 bytes without polluting the cache. */ - /* We could use movntdq %xmm0,(%rcx) here to further + /* Next 3 insns are 14 bytes total, make sure we decode them in one go */ + .p2align 4,,14 +11: + /* Fill 64 bytes without polluting the cache. */ + /* We could use movntdq %xmm0,(%rcx) here to further speed up for large cases but let's not use XMM registers. */ movnti %r8,(%rcx) movnti %r8,0x8(%rcx) Modified: trunk/uClibc/libc/string/x86_64/strcat.S =================================================================== --- trunk/uClibc/libc/string/x86_64/strcat.S 2008-04-15 08:25:32 UTC (rev 21737) +++ trunk/uClibc/libc/string/x86_64/strcat.S 2008-04-15 08:27:24 UTC (rev 21738) @@ -45,7 +45,9 @@ /* Now the source is aligned. Scan for NUL byte. */ - .p2align 4 + + /* Next 3 insns are 10 bytes total, make sure we decode them in one go */ + .p2align 4,,10 4: /* First unroll. */ movq (%rax), %rcx /* get double word (= 8 bytes) in question */ @@ -103,8 +105,11 @@ the addition will not result in 0. */ jz 4b /* no NUL found => continue loop */ - .p2align 4 /* Align, it is a jump target. */ -3: subq $8,%rax /* correct pointer increment. */ + /* Align, it is a jump target. */ + /* Next 3 insns are 8 bytes total, make sure we decode them in one go */ + .p2align 3,,8 +3: + subq $8,%rax /* correct pointer increment. */ testb %cl, %cl /* is first byte NUL? */ jz 2f /* yes => return */ @@ -160,7 +165,9 @@ /* Now the sources is aligned. Unfortunatly we cannot force to have both source and destination aligned, so ignore the alignment of the destination. */ - .p2align 4 + + /* Next 3 insns are 10 bytes total, make sure we decode them in one go */ + .p2align 4,,10 22: /* 1st unroll. */ movq (%rsi), %rax /* Read double word (8 bytes). */ @@ -237,7 +244,9 @@ /* Do the last few bytes. %rax contains the value to write. The loop is unrolled twice. */ - .p2align 4 + + /* Next 3 insns are 6 bytes total, make sure we decode them in one go */ + .p2align 3,,6 23: movb %al, (%rdx) /* 1st byte. */ testb %al, %al /* Is it NUL. */ Modified: trunk/uClibc/libc/string/x86_64/strchr.S =================================================================== --- trunk/uClibc/libc/string/x86_64/strchr.S 2008-04-15 08:25:32 UTC (rev 21737) +++ trunk/uClibc/libc/string/x86_64/strchr.S 2008-04-15 08:27:24 UTC (rev 21738) @@ -92,7 +92,8 @@ each of whose bytes is C. This turns each byte that is C into a zero. */ - .p2align 4 + /* Next 3 insns are 10 bytes total, make sure we decode them in one go */ + .p2align 4,,10 4: /* Main Loop is unrolled 4 times. */ /* First unroll. */ @@ -230,8 +231,11 @@ reversed. */ - .p2align 4 /* Align, it's a jump target. */ -3: movq %r9,%rdx /* move to %rdx so that we can access bytes */ + /* Align, it's a jump target. */ + /* Next 3 insns are 9 bytes total, make sure we decode them in one go */ + .p2align 4,,9 +3: + movq %r9,%rdx /* move to %rdx so that we can access bytes */ subq $8,%rax /* correct pointer increment. */ testb %cl, %cl /* is first byte C? */ jz 6f /* yes => return pointer */ @@ -281,7 +285,7 @@ incq %rax 6: - nop + /* nop - huh?? */ retq END (BP_SYM (strchr)) Modified: trunk/uClibc/libc/string/x86_64/strcpy.S =================================================================== --- trunk/uClibc/libc/string/x86_64/strcpy.S 2008-04-15 08:25:32 UTC (rev 21737) +++ trunk/uClibc/libc/string/x86_64/strcpy.S 2008-04-15 08:27:24 UTC (rev 21738) @@ -53,7 +53,9 @@ /* Now the sources is aligned. Unfortunatly we cannot force to have both source and destination aligned, so ignore the alignment of the destination. */ - .p2align 4 + + /* Next 3 insns are 10 bytes total, make sure we decode them in one go */ + .p2align 4,,10 1: /* 1st unroll. */ movq (%rsi), %rax /* Read double word (8 bytes). */ @@ -130,7 +132,9 @@ /* Do the last few bytes. %rax contains the value to write. The loop is unrolled twice. */ - .p2align 4 + + /* Next 3 insns are 6 bytes total, make sure we decode them in one go */ + .p2align 3,,6 3: /* Note that stpcpy needs to return with the value of the NUL byte. */ Modified: trunk/uClibc/libc/string/x86_64/strcspn.S =================================================================== --- trunk/uClibc/libc/string/x86_64/strcspn.S 2008-04-15 08:25:32 UTC (rev 21737) +++ trunk/uClibc/libc/string/x86_64/strcspn.S 2008-04-15 08:27:24 UTC (rev 21738) @@ -55,7 +55,9 @@ Although all the following instruction only modify %cl we always have a correct zero-extended 64-bit value in %rcx. */ - .p2align 4 + /* Next 3 insns are 6 bytes total, make sure we decode them in one go */ + .p2align 3,,6 + L(2): movb (%rax), %cl /* get byte from skipset */ testb %cl, %cl /* is NUL char? */ jz L(1) /* yes => start compare loop */ @@ -88,7 +90,13 @@ value in the table. But the value of NUL is NUL so the loop terminates for NUL in every case. */ - .p2align 4 + /* Next 3 insns are 9 bytes total. */ + /* .p2align 4,,9 would make sure we decode them in one go, */ + /* but it will also align entire function to 16 bytes, */ + /* potentially creating largish padding at link time. */ + /* We are aligning to 8 bytes instead: */ + .p2align 3,,8 + L(3): addq $4, %rax /* adjust pointer for full loop round */ movb (%rax), %cl /* get byte from string */ Modified: trunk/uClibc/libc/string/x86_64/strlen.S =================================================================== --- trunk/uClibc/libc/string/x86_64/strlen.S 2008-04-15 08:25:32 UTC (rev 21737) +++ trunk/uClibc/libc/string/x86_64/strlen.S 2008-04-15 08:27:24 UTC (rev 21738) @@ -40,8 +40,11 @@ 1: movq $0xfefefefefefefeff,%r8 /* Save magic. */ - .p2align 4 /* Align loop. */ -4: /* Main Loop is unrolled 4 times. */ + /* Align loop. */ + /* Next 3 insns are 10 bytes total, make sure we decode them in one go */ + .p2align 4,,10 +4: + /* Main Loop is unrolled 4 times. */ /* First unroll. */ movq (%rax), %rcx /* get double word (= 8 bytes) in question */ addq $8,%rax /* adjust pointer for next word */ @@ -98,8 +101,11 @@ the addition will not result in 0. */ jz 4b /* no NUL found => continue loop */ - .p2align 4 /* Align, it is a jump target. */ -3: subq $8,%rax /* correct pointer increment. */ + /* Align, it is a jump target. */ + /* Next 3 insns are 8 bytes total, make sure we decode them in one go */ + .p2align 3,,8 +3: + subq $8,%rax /* correct pointer increment. */ testb %cl, %cl /* is first byte NUL? */ jz 2f /* yes => return */ Modified: trunk/uClibc/libc/string/x86_64/strspn.S =================================================================== --- trunk/uClibc/libc/string/x86_64/strspn.S 2008-04-15 08:25:32 UTC (rev 21737) +++ trunk/uClibc/libc/string/x86_64/strspn.S 2008-04-15 08:27:24 UTC (rev 21738) @@ -50,8 +50,10 @@ Although all the following instruction only modify %cl we always have a correct zero-extended 64-bit value in %rcx. */ - .p2align 4 -L(2): movb (%rax), %cl /* get byte from stopset */ + /* Next 3 insns are 6 bytes total, make sure we decode them in one go */ + .p2align 3,,6 +L(2): + movb (%rax), %cl /* get byte from stopset */ testb %cl, %cl /* is NUL char? */ jz L(1) /* yes => start compare loop */ movb %cl, (%rsp,%rcx) /* set corresponding byte in stopset table */ @@ -83,8 +85,14 @@ value in the table. But the value of NUL is NUL so the loop terminates for NUL in every case. */ - .p2align 4 -L(3): addq $4, %rax /* adjust pointer for full loop round */ + /* Next 3 insns are 9 bytes total. */ + /* .p2align 4,,9 would make sure we decode them in one go, */ + /* but it will also align entire function to 16 bytes, */ + /* potentially creating largish padding at link time. */ + /* We are aligning to 8 bytes instead: */ + .p2align 3,,8 +L(3): + addq $4, %rax /* adjust pointer for full loop round */ movb (%rax), %cl /* get byte from string */ testb %cl, (%rsp,%rcx) /* is it contained in skipset? */ From bugs at busybox.net Tue Apr 15 22:14:14 2008 From: bugs at busybox.net (bugs at busybox.net) Date: Tue, 15 Apr 2008 22:14:14 -0700 Subject: [uClibc 0002544]: Can't make a target system for X86_64 Message-ID: <5ffb62d70e0e3da19d77d3d63c2b9633@bugs.busybox.net> A NOTE has been added to this issue. ====================================================================== http://busybox.net/bugs/view.php?id=2544