Hello,
I found an issue when running uClibc test "regex/testregex".
I launched tests using "uclibcng-testrunner.sh" script. And the script
printed that "testregex" had been passed successfully. But when I
opened "testregex.out" file I found, that many "testregex" sub-tests
failed.
This behavior is caused because test returns 0 exit code even when sub-
tests fail.
As a result we don't know was the "testregex" execution successful or
not though it is marked as "PASSED".
The problem was found when running tests on ARC HS38 with Linux 4.6.1.
It also was reproduced on ARMv5 with Linux 4.5.3.
--
Best regards,
Vlad Zakharov <Vladislav.Zakharov(a)synopsys.com>
Hi Waldemar,
On Mon, 2016-05-30 at 14:12 +0300, Alexey Brodkin wrote:
> Hello,
>
> On Thu, 2016-05-26 at 14:55 +0300, Alexey Brodkin wrote:
> >
> > Hello,
> >
> > On Mon, 2016-05-23 at 17:46 +0300, Alexey Brodkin wrote:
> > >
> > >
> > > This fixes util-linux building with uClibc.
> > > Patch is taken as it is from Buildroot:
> > > https://git.busybox.net/buildroot/plain/package/util-linux/0001-Fix-libmoun…
> > > 6f
> > > ea
> > > bf114623866568121f49712f5df
> > >
> > > Signed-off-by: Alexey Brodkin <abrodkin(a)synopsys.com>
> > > ---
> > > .../004-Fix-libmount-build-under-uClibc.patch | 153 +++++++++++++++++++++
> > > 1 file changed, 153 insertions(+)
> > > create mode 100644 package/utils/util-linux/patches/004-Fix-libmount-build-under-uClibc.patch
We are discussing one issue with "util-linux" package building.
The problem is in "util-linux" wants to use alloc modifier (either "%as"
or "%ms") in scanf().
Looks like uClibc still doesn't support neither "%ms" nor "%as" (this one
is obsolete glibc-specific so let's not bother with it anyways).
Now to work-around this missing requirement we used to use
an off-the-tree patch like this one in Buildroot:
https://git.busybox.net/buildroot/tree/package/util-linux/0001-Fix-libmount…
OpenWRT:
https://git.lede-project.org/?p=source.git;a=blob;f=package/utils/util-linu…
959bf0c8ce269e8039d4d05ef58e1d527;hb=8a7b28071fba84e297796c46d46e12b0967804e8
Gentoo:
https://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/sys-apps/util-linu…
ch?revision=1.2
The question to you is where do you think we should fix mentioned problem:
1) In uClibc-ng with addition of "%ms" support in scanf or
2) Try to upstream mentioned patch in "util-linux"?
Regards,
Alexey
When a 'hard' error occurs, fwrite reports that all data was written or
buffered even if that is not the case. It should report how much data
was actually written and buffered.
Signed-off-by: Jan Vangorp <jan.vangorp_ext(a)softathome.com>
---
libc/stdio/_WRITE.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/libc/stdio/_WRITE.c b/libc/stdio/_WRITE.c
index 113f0eb..f95bd1b 100644
--- a/libc/stdio/_WRITE.c
+++ b/libc/stdio/_WRITE.c
@@ -76,6 +76,7 @@ size_t attribute_hidden __stdio_WRITE(register FILE *stream,
*/
if (errno != EINTR && errno != EAGAIN) {
/* do we have other "soft" errors? */
+ bufsize -= todo;
break;
}
#ifdef __STDIO_BUFFERS
--
1.9.1
The man page for fopencookie prescribes that custom write functions
should return 0 on error (and should definitely not return a negative
value) [1].
However, the uClibc implementation expects a negative return value in
case of an error (libc/stdio/_WRITE.c). If the write function returns 0
on error, we drop into an infinite loop if the error persists.
This patch wraps the user supplied write function such that a 0 return
value is converted to -1. errno is first set to EAGAIN such that if the
custom write function does not set errno in case of error, this is
treated as a "soft" error.
Custom write functions that cater towards uClibc and _do_ return a
negative value are not affected.
If no custom write function is supplied, set errno to EINVAL such that
this condition is treated as a "hard" error. Previously the behaviour
depended on whether the last error before the write happened to be a "hard"
or a "soft" error.
[1] http://git.kernel.org/cgit/docs/man-pages/man-pages.git/tree/man3/fopencook…
Signed-off-by: Jan Vangorp <jan.vangorp_ext(a)softathome.com>
---
libc/stdio/_stdio.h | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/libc/stdio/_stdio.h b/libc/stdio/_stdio.h
index 310510d..727e331 100644
--- a/libc/stdio/_stdio.h
+++ b/libc/stdio/_stdio.h
@@ -110,6 +110,18 @@ do { \
cfile->__gcs.NAME(cfile->__cookie, ##ARGS); \
}
+#define __STDIO_STREAM_CUSTOM_WRITE_FUNC(S, ARGS...) \
+ if (__STDIO_STREAM_IS_CUSTOM((S))) { \
+ _IO_cookie_file_t *cfile = (_IO_cookie_file_t *) (S); \
+ if (cfile->__gcs.write == NULL) { \
+ __set_errno(EINVAL); \
+ return -1; \
+ } \
+ __set_errno(EAGAIN); \
+ ssize_t w = cfile->__gcs.write(cfile->__cookie, ##ARGS); \
+ return (w == 0 ? -1 : w); \
+ }
+
typedef struct {
struct __STDIO_FILE_STRUCT __fp;
void *__cookie;
@@ -121,6 +133,7 @@ typedef struct {
#undef __STDIO_STREAM_GLIBC_CUSTOM_FILEDES
#define __STDIO_STREAM_IS_CUSTOM(S) (0)
#define __STDIO_STREAM_CUSTOM_IO_FUNC(S, NAME, RC, ARGS...)
+#define __STDIO_STREAM_CUSTOM_WRITE_FUNC(S, ARGS...)
#endif /* __UCLIBC_HAS_GLIBC_CUSTOM_STREAMS__ */
@@ -135,7 +148,7 @@ static inline ssize_t __READ(FILE *stream, char *buf, size_t bufsize)
static inline ssize_t __WRITE(FILE *stream, const char *buf, size_t bufsize)
{
- __STDIO_STREAM_CUSTOM_IO_FUNC(stream, write, -1, buf, bufsize);
+ __STDIO_STREAM_CUSTOM_WRITE_FUNC(stream, buf, bufsize);
return write(stream->__filedes, buf, bufsize);
}
--
1.9.1
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "uClibc-ng - small C library for embedded systems".
The branch, master has been updated
via e1eceda87b2fa64ab17f3e32c81b9a97edc7cac7 (commit)
via 96f2821683ec41a28b5aa6ec92245e47dfee989b (commit)
via 568ceebf6adfc58c64a95133311268db626cdec2 (commit)
from 0f541b5c48b7b0df80e2aaa8fdbf653a8b8bcd03 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit e1eceda87b2fa64ab17f3e32c81b9a97edc7cac7
Author: Max Filippov <jcmvbkbc(a)gmail.com>
Date: Thu Jun 2 18:24:28 2016 +0300
tests: add %ms scanf format test
Signed-off-by: Max Filippov <jcmvbkbc(a)gmail.com>
commit 96f2821683ec41a28b5aa6ec92245e47dfee989b
Author: Jan Vangorp <jan.vangorp_ext(a)softathome.com>
Date: Thu Jun 9 00:00:49 2016 +0200
Fix return value of fwrite when a 'hard' error occurs
When a 'hard' error occurs, fwrite reports that all data was written or
buffered even if that is not the case. It should report how much data
was actually written and buffered.
Signed-off-by: Jan Vangorp <jan.vangorp_ext(a)softathome.com>
commit 568ceebf6adfc58c64a95133311268db626cdec2
Author: Jan Vangorp <jan.vangorp_ext(a)softathome.com>
Date: Thu Jun 9 00:00:18 2016 +0200
Fix infinite loop when fopencookie custom write returns 0 on error
The man page for fopencookie prescribes that custom write functions
should return 0 on error (and should definitely not return a negative
value) [1].
However, the uClibc implementation expects a negative return value in
case of an error (libc/stdio/_WRITE.c). If the write function returns 0
on error, we drop into an infinite loop if the error persists.
This patch wraps the user supplied write function such that a 0 return
value is converted to -1. errno is first set to EAGAIN such that if the
custom write function does not set errno in case of error, this is
treated as a "soft" error.
Custom write functions that cater towards uClibc and _do_ return a
negative value are not affected.
If no custom write function is supplied, set errno to EINVAL such that
this condition is treated as a "hard" error. Previously the behaviour
depended on whether the last error before the write happened to be a "hard"
or a "soft" error.
[1] http://git.kernel.org/cgit/docs/man-pages/man-pages.git/tree/man3/fopencook…
Signed-off-by: Jan Vangorp <jan.vangorp_ext(a)softathome.com>
-----------------------------------------------------------------------
Summary of changes:
libc/stdio/_WRITE.c | 1 +
libc/stdio/_stdio.h | 15 ++++++++++++++-
test/stdio/scanf_m.c | 17 ++++++++++-------
3 files changed, 25 insertions(+), 8 deletions(-)
diff --git a/libc/stdio/_WRITE.c b/libc/stdio/_WRITE.c
index 113f0eb..f95bd1b 100644
--- a/libc/stdio/_WRITE.c
+++ b/libc/stdio/_WRITE.c
@@ -76,6 +76,7 @@ size_t attribute_hidden __stdio_WRITE(register FILE *stream,
*/
if (errno != EINTR && errno != EAGAIN) {
/* do we have other "soft" errors? */
+ bufsize -= todo;
break;
}
#ifdef __STDIO_BUFFERS
diff --git a/libc/stdio/_stdio.h b/libc/stdio/_stdio.h
index 310510d..727e331 100644
--- a/libc/stdio/_stdio.h
+++ b/libc/stdio/_stdio.h
@@ -110,6 +110,18 @@ do { \
cfile->__gcs.NAME(cfile->__cookie, ##ARGS); \
}
+#define __STDIO_STREAM_CUSTOM_WRITE_FUNC(S, ARGS...) \
+ if (__STDIO_STREAM_IS_CUSTOM((S))) { \
+ _IO_cookie_file_t *cfile = (_IO_cookie_file_t *) (S); \
+ if (cfile->__gcs.write == NULL) { \
+ __set_errno(EINVAL); \
+ return -1; \
+ } \
+ __set_errno(EAGAIN); \
+ ssize_t w = cfile->__gcs.write(cfile->__cookie, ##ARGS); \
+ return (w == 0 ? -1 : w); \
+ }
+
typedef struct {
struct __STDIO_FILE_STRUCT __fp;
void *__cookie;
@@ -121,6 +133,7 @@ typedef struct {
#undef __STDIO_STREAM_GLIBC_CUSTOM_FILEDES
#define __STDIO_STREAM_IS_CUSTOM(S) (0)
#define __STDIO_STREAM_CUSTOM_IO_FUNC(S, NAME, RC, ARGS...)
+#define __STDIO_STREAM_CUSTOM_WRITE_FUNC(S, ARGS...)
#endif /* __UCLIBC_HAS_GLIBC_CUSTOM_STREAMS__ */
@@ -135,7 +148,7 @@ static inline ssize_t __READ(FILE *stream, char *buf, size_t bufsize)
static inline ssize_t __WRITE(FILE *stream, const char *buf, size_t bufsize)
{
- __STDIO_STREAM_CUSTOM_IO_FUNC(stream, write, -1, buf, bufsize);
+ __STDIO_STREAM_CUSTOM_WRITE_FUNC(stream, buf, bufsize);
return write(stream->__filedes, buf, bufsize);
}
diff --git a/test/stdio/scanf_m.c b/test/stdio/scanf_m.c
index 0ce78b6..e1dde27 100644
--- a/test/stdio/scanf_m.c
+++ b/test/stdio/scanf_m.c
@@ -5,20 +5,23 @@
int main(void)
{
const char *buf = "hello world";
- char *ps = NULL, *pc = NULL;
- char s[6], c;
+ char *ps = NULL, *pc = NULL, *ps2 = NULL;
+ char s[6], c, s2[5];
- /* Check that %[...]/%c work. */
- sscanf(buf, "%[a-z] %c", s, &c);
- /* Check that %m[...]/%mc work. */
- sscanf(buf, "%m[a-z] %mc", &ps, &pc);
+ /* Check that %[...]/%c/%s work. */
+ sscanf(buf, "%[a-z] %c %s", s, &c, s2);
+ /* Check that %m[...]/%mc/%ms work. */
+ sscanf(buf, "%m[a-z] %mc %ms", &ps, &pc, &ps2);
if (strcmp(ps, "hello") != 0 || *pc != 'w' ||
- strcmp(s, "hello") != 0 || c != 'w')
+ strcmp(ps2, "orld") != 0 ||
+ strcmp(s, "hello") != 0 || c != 'w' ||
+ strcmp(s2, "orld") != 0)
return 1;
free(ps);
free(pc);
+ free(ps2);
return 0;
}
hooks/post-receive
--
uClibc-ng - small C library for embedded systems
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "uClibc-ng - small C library for embedded systems".
The branch, master has been updated
via 0f541b5c48b7b0df80e2aaa8fdbf653a8b8bcd03 (commit)
via a75ca05cf77652bebb01edfb0bc48cd78eab95dc (commit)
via 1b49dc96d103e0151fee290d55cea55aa12c906d (commit)
from bf70f6f1face8e36030544a74e5ea04903df16cb (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 0f541b5c48b7b0df80e2aaa8fdbf653a8b8bcd03
Author: Waldemar Brodkorb <wbx(a)uclibc-ng.org>
Date: Sun Jun 12 11:41:23 2016 +0200
xtensa: use generic lowlevellock
Simplify and use generic lowlevellock.
Tested-by: Waldemar Brodkorb <wbx(a)uclibc-ng.org>
Signed-off-by: Leonid Lisovskiy <lly.dev(a)gmail.com>
commit a75ca05cf77652bebb01edfb0bc48cd78eab95dc
Author: Waldemar Brodkorb <wbx(a)uclibc-ng.org>
Date: Sun Jun 12 11:10:17 2016 +0200
metag: use generic lowlevellock
Simplify and use generic lowlevellock.
Tested-by: Waldemar Brodkorb <wbx(a)uclibc-ng.org>
Signed-off-by: Leonid Lisovskiy <lly.dev(a)gmail.com>
commit 1b49dc96d103e0151fee290d55cea55aa12c906d
Author: Waldemar Brodkorb <wbx(a)uclibc-ng.org>
Date: Sun Jun 12 01:15:47 2016 +0200
arc: use generic lowlevellock
Simplify and use generic lowlevellock.
Tested-by: Waldemar Brodkorb <wbx(a)uclibc-ng.org>
Signed-off-by: Leonid Lisovskiy <lly.dev(a)gmail.com>
-----------------------------------------------------------------------
Summary of changes:
.../nptl/sysdeps/unix/sysv/linux/arc/Makefile.arch | 4 +-
.../unix/sysv/linux/arc/libc-lowlevellock.c | 20 ---
.../sysdeps/unix/sysv/linux/arc/lowlevellock.c | 128 -------------------
.../sysdeps/unix/sysv/linux/metag/Makefile.arch | 5 +-
.../unix/sysv/linux/metag/libc-lowlevellock.c | 20 ---
.../sysdeps/unix/sysv/linux/metag/lowlevellock.c | 136 ---------------------
.../sysdeps/unix/sysv/linux/xtensa/lowlevellock.c | 132 --------------------
7 files changed, 4 insertions(+), 441 deletions(-)
delete mode 100644 libpthread/nptl/sysdeps/unix/sysv/linux/arc/libc-lowlevellock.c
delete mode 100644 libpthread/nptl/sysdeps/unix/sysv/linux/arc/lowlevellock.c
delete mode 100644 libpthread/nptl/sysdeps/unix/sysv/linux/metag/libc-lowlevellock.c
delete mode 100644 libpthread/nptl/sysdeps/unix/sysv/linux/metag/lowlevellock.c
delete mode 100644 libpthread/nptl/sysdeps/unix/sysv/linux/xtensa/lowlevellock.c
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/arc/Makefile.arch b/libpthread/nptl/sysdeps/unix/sysv/linux/arc/Makefile.arch
index 3b9db6a..468e646 100644
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/arc/Makefile.arch
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/arc/Makefile.arch
@@ -6,10 +6,10 @@
#
libpthread_linux_arch_SSRC =
-libpthread_linux_arch_CSRC = pthread_once.c lowlevellock.c \
+libpthread_linux_arch_CSRC = pthread_once.c \
pt-__syscall_rt_sigaction.c pt-__syscall_error.c
-libc_linux_arch_CSRC = fork.c libc-lowlevellock.c
+libc_linux_arch_CSRC = fork.c
libc_linux_arch_SSRC = clone.S vfork.S
libc_linux_arch_SSRC-OMIT = waitpid.S
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/arc/libc-lowlevellock.c b/libpthread/nptl/sysdeps/unix/sysv/linux/arc/libc-lowlevellock.c
deleted file mode 100644
index a38923a..0000000
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/arc/libc-lowlevellock.c
+++ /dev/null
@@ -1,20 +0,0 @@
-/* Copyright (C) 2003 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
- Contributed by Paul Mackerras <paulus(a)au.ibm.com>, 2003.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; see the file COPYING.LIB. If
- not, see <http://www.gnu.org/licenses/>. */
-
-/* No difference to lowlevellock.c, except we lose a couple of functions. */
-#include "lowlevellock.c"
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/arc/lowlevellock.c b/libpthread/nptl/sysdeps/unix/sysv/linux/arc/lowlevellock.c
deleted file mode 100644
index fd39fe9..0000000
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/arc/lowlevellock.c
+++ /dev/null
@@ -1,128 +0,0 @@
-/* low level locking for pthread library. Generic futex-using version.
- Copyright (C) 2003, 2007 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
- Contributed by Paul Mackerras <paulus(a)au.ibm.com>, 2003.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, see
- <http://www.gnu.org/licenses/>. */
-
-#include <errno.h>
-#include <sysdep.h>
-#include <lowlevellock.h>
-#include <sys/time.h>
-#include <tls.h>
-#include <tcb-offsets.h>
-
-void
-#ifndef IS_IN_libpthread
-weak_function
-#endif
-__lll_lock_wait_private (int *futex)
-{
- if (*futex == 2)
- lll_futex_wait (futex, 2, LLL_PRIVATE);
-
- while (atomic_exchange_acq (futex, 2) != 0)
- lll_futex_wait (futex, 2, LLL_PRIVATE);
-}
-
-
-/* These functions don't get included in libc.so */
-#ifdef IS_IN_libpthread
-void
-__lll_lock_wait (int *futex, int private)
-{
- if (*futex == 2)
- lll_futex_wait (futex, 2, private);
-
- while (atomic_exchange_acq (futex, 2) != 0)
- lll_futex_wait (futex, 2, private);
-}
-
-
-int
-__lll_timedlock_wait (int *futex, const struct timespec *abstime, int private)
-{
- /* Reject invalid timeouts. */
- if (abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000)
- return EINVAL;
-
- /* Try locking. */
- while (atomic_exchange_acq (futex, 2) != 0)
- {
- struct timeval tv;
-
- /* Get the current time. */
- (void) gettimeofday (&tv, NULL);
-
- /* Compute relative timeout. */
- struct timespec rt;
- rt.tv_sec = abstime->tv_sec - tv.tv_sec;
- rt.tv_nsec = abstime->tv_nsec - tv.tv_usec * 1000;
- if (rt.tv_nsec < 0)
- {
- rt.tv_nsec += 1000000000;
- --rt.tv_sec;
- }
-
- if (rt.tv_sec < 0)
- return ETIMEDOUT;
-
- /* Wait. */
- lll_futex_timed_wait (futex, 2, &rt, private);
- }
-
- return 0;
-}
-
-
-int
-__lll_timedwait_tid (int *tidp, const struct timespec *abstime)
-{
- int tid;
-
- if (abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000)
- return EINVAL;
-
- /* Repeat until thread terminated. */
- while ((tid = *tidp) != 0)
- {
- struct timeval tv;
- struct timespec rt;
-
- /* Get the current time. */
- (void) __gettimeofday (&tv, NULL);
-
- /* Compute relative timeout. */
- rt.tv_sec = abstime->tv_sec - tv.tv_sec;
- rt.tv_nsec = abstime->tv_nsec - tv.tv_usec * 1000;
- if (rt.tv_nsec < 0)
- {
- rt.tv_nsec += 1000000000;
- --rt.tv_sec;
- }
-
- /* Already timed out? */
- if (rt.tv_sec < 0)
- return ETIMEDOUT;
-
- /* Wait until thread terminates. The kernel so far does not use
- the private futex operations for this. */
- if (lll_futex_timed_wait (tidp, tid, &rt, LLL_SHARED) == -ETIMEDOUT)
- return ETIMEDOUT;
- }
-
- return 0;
-}
-#endif
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/metag/Makefile.arch b/libpthread/nptl/sysdeps/unix/sysv/linux/metag/Makefile.arch
index ddc7680..b38c375 100644
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/metag/Makefile.arch
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/metag/Makefile.arch
@@ -7,10 +7,9 @@
libpthread_linux_arch_SSRC =
libpthread_linux_arch_CSRC = pthread_once.c \
- pt-__syscall_rt_sigaction.c pt-__syscall_error.c \
- lowlevellock.c
+ pt-__syscall_rt_sigaction.c pt-__syscall_error.c
-libc_linux_arch_CSRC = fork.c libc-lowlevellock.c
+libc_linux_arch_CSRC = fork.c
libc_linux_arch_SSRC = clone.S vfork.S
libc_linux_arch_SSRC-OMIT = waitpid.S
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/metag/libc-lowlevellock.c b/libpthread/nptl/sysdeps/unix/sysv/linux/metag/libc-lowlevellock.c
deleted file mode 100644
index a38923a..0000000
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/metag/libc-lowlevellock.c
+++ /dev/null
@@ -1,20 +0,0 @@
-/* Copyright (C) 2003 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
- Contributed by Paul Mackerras <paulus(a)au.ibm.com>, 2003.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; see the file COPYING.LIB. If
- not, see <http://www.gnu.org/licenses/>. */
-
-/* No difference to lowlevellock.c, except we lose a couple of functions. */
-#include "lowlevellock.c"
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/metag/lowlevellock.c b/libpthread/nptl/sysdeps/unix/sysv/linux/metag/lowlevellock.c
deleted file mode 100644
index 977213c..0000000
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/metag/lowlevellock.c
+++ /dev/null
@@ -1,136 +0,0 @@
-/* low level locking for pthread library. Generic futex-using version.
- Copyright (C) 2003, 2005, 2007 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; see the file COPYING.LIB. If
- not, see <http://www.gnu.org/licenses/>. */
-
-#include <errno.h>
-#include <sysdep.h>
-#include <lowlevellock.h>
-#include <sys/time.h>
-#include <tls.h>
-
-void
-#ifndef IS_IN_libpthread
-weak_function
-#endif
-__lll_lock_wait_private (int *futex)
-{
- do
- {
- int oldval = atomic_compare_and_exchange_val_acq (futex, 2, 1);
- if (oldval != 0)
- lll_futex_wait (futex, 2, LLL_PRIVATE);
- }
- while (atomic_compare_and_exchange_bool_acq (futex, 2, 0) != 0);
-}
-
-
-/* These functions don't get included in libc.so */
-#ifdef IS_IN_libpthread
-void
-__lll_lock_wait (int *futex, int private)
-{
- do
- {
- int oldval = atomic_compare_and_exchange_val_acq (futex, 2, 1);
- if (oldval != 0)
- lll_futex_wait (futex, 2, private);
- }
- while (atomic_compare_and_exchange_bool_acq (futex, 2, 0) != 0);
-}
-
-
-int
-__lll_timedlock_wait (int *futex, const struct timespec *abstime, int private)
-{
- struct timespec rt;
-
- /* Reject invalid timeouts. */
- if (abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000)
- return EINVAL;
-
- /* Upgrade the lock. */
- if (atomic_exchange_acq (futex, 2) == 0)
- return 0;
-
- do
- {
- struct timeval tv;
-
- /* Get the current time. */
- (void) gettimeofday (&tv, NULL);
-
- /* Compute relative timeout. */
- rt.tv_sec = abstime->tv_sec - tv.tv_sec;
- rt.tv_nsec = abstime->tv_nsec - tv.tv_usec * 1000;
- if (rt.tv_nsec < 0)
- {
- rt.tv_nsec += 1000000000;
- --rt.tv_sec;
- }
-
- /* Already timed out? */
- if (rt.tv_sec < 0)
- return ETIMEDOUT;
-
- // XYZ: Lost the lock to check whether it was private.
- lll_futex_timed_wait (futex, 2, &rt, private);
- }
- while (atomic_compare_and_exchange_bool_acq (futex, 2, 0) != 0);
-
- return 0;
-}
-
-
-int
-__lll_timedwait_tid (int *tidp, const struct timespec *abstime)
-{
- int tid;
-
- if (abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000)
- return EINVAL;
-
- /* Repeat until thread terminated. */
- while ((tid = *tidp) != 0)
- {
- struct timeval tv;
- struct timespec rt;
-
- /* Get the current time. */
- (void) gettimeofday (&tv, NULL);
-
- /* Compute relative timeout. */
- rt.tv_sec = abstime->tv_sec - tv.tv_sec;
- rt.tv_nsec = abstime->tv_nsec - tv.tv_usec * 1000;
- if (rt.tv_nsec < 0)
- {
- rt.tv_nsec += 1000000000;
- --rt.tv_sec;
- }
-
- /* Already timed out? */
- if (rt.tv_sec < 0)
- return ETIMEDOUT;
-
- /* Wait until thread terminates. */
- // XYZ: Lost the lock to check whether it was private.
- if (lll_futex_timed_wait (tidp, tid, &rt, LLL_SHARED) == -ETIMEDOUT)
- return ETIMEDOUT;
- }
-
- return 0;
-}
-#endif
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/xtensa/lowlevellock.c b/libpthread/nptl/sysdeps/unix/sysv/linux/xtensa/lowlevellock.c
deleted file mode 100644
index 756f39f..0000000
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/xtensa/lowlevellock.c
+++ /dev/null
@@ -1,132 +0,0 @@
-/* low level locking for pthread library. Generic futex-using version.
- Copyright (C) 2003-2013 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library. If not, see
- <http://www.gnu.org/licenses/>. */
-
-#include <errno.h>
-#include <sysdep.h>
-#include <lowlevellock.h>
-#include <sys/time.h>
-
-void
-__lll_lock_wait_private (int *futex)
-{
- do
- {
- int oldval = atomic_compare_and_exchange_val_acq (futex, 2, 1);
- if (oldval != 0)
- lll_futex_wait (futex, 2, LLL_PRIVATE);
- }
- while (atomic_compare_and_exchange_bool_acq (futex, 2, 0) != 0);
-}
-
-
-/* These functions don't get included in libc.so */
-#ifdef IS_IN_libpthread
-void
-__lll_lock_wait (int *futex, int private)
-{
- do
- {
- int oldval = atomic_compare_and_exchange_val_acq (futex, 2, 1);
- if (oldval != 0)
- lll_futex_wait (futex, 2, private);
- }
- while (atomic_compare_and_exchange_bool_acq (futex, 2, 0) != 0);
-}
-
-
-int
-__lll_timedlock_wait (int *futex, const struct timespec *abstime, int private)
-{
- struct timespec rt;
-
- /* Reject invalid timeouts. */
- if (abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000)
- return EINVAL;
-
- /* Upgrade the lock. */
- if (atomic_exchange_acq (futex, 2) == 0)
- return 0;
-
- do
- {
- struct timeval tv;
-
- /* Get the current time. */
- (void) __gettimeofday (&tv, NULL);
-
- /* Compute relative timeout. */
- rt.tv_sec = abstime->tv_sec - tv.tv_sec;
- rt.tv_nsec = abstime->tv_nsec - tv.tv_usec * 1000;
- if (rt.tv_nsec < 0)
- {
- rt.tv_nsec += 1000000000;
- --rt.tv_sec;
- }
-
- /* Already timed out? */
- if (rt.tv_sec < 0)
- return ETIMEDOUT;
-
- // XYZ: Lost the lock to check whether it was private.
- lll_futex_timed_wait (futex, 2, &rt, private);
- }
- while (atomic_compare_and_exchange_bool_acq (futex, 2, 0) != 0);
-
- return 0;
-}
-
-
-int
-__lll_timedwait_tid (int *tidp, const struct timespec *abstime)
-{
- int tid;
-
- if (abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000)
- return EINVAL;
-
- /* Repeat until thread terminated. */
- while ((tid = *tidp) != 0)
- {
- struct timeval tv;
- struct timespec rt;
-
- /* Get the current time. */
- (void) __gettimeofday (&tv, NULL);
-
- /* Compute relative timeout. */
- rt.tv_sec = abstime->tv_sec - tv.tv_sec;
- rt.tv_nsec = abstime->tv_nsec - tv.tv_usec * 1000;
- if (rt.tv_nsec < 0)
- {
- rt.tv_nsec += 1000000000;
- --rt.tv_sec;
- }
-
- /* Already timed out? */
- if (rt.tv_sec < 0)
- return ETIMEDOUT;
-
- /* Wait until thread terminates. */
- // XYZ: Lost the lock to check whether it was private.
- if (lll_futex_timed_wait (tidp, tid, &rt, LLL_SHARED) == -ETIMEDOUT)
- return ETIMEDOUT;
- }
-
- return 0;
-}
-#endif
hooks/post-receive
--
uClibc-ng - small C library for embedded systems
mmap offset must be a multiple of the page size. It was hardcoded
to 4K, so mmap2 test failed on non-4K page size architectures.
Now we get page size using sysconf(_SC_PAGE_SIZE).
Build and run tests done on nsim arc hs38.
Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev(a)synopsys.com>
---
Resending due to previously sent one was discarded by mailing list.
test/mmap/mmap2.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/test/mmap/mmap2.c b/test/mmap/mmap2.c
index 8b94c61..1d5f5db 100644
--- a/test/mmap/mmap2.c
+++ b/test/mmap/mmap2.c
@@ -18,7 +18,7 @@
#define FATAL do { fprintf(stderr, "Error at line %d, file %s (%d) [%s]\n", \
__LINE__, __FILE__, errno, strerror(errno)); exit(1); } while(0)
-#define MAP_SIZE 4096UL
+#define MAP_SIZE sysconf(_SC_PAGESIZE)
#define MAP_MASK (MAP_SIZE - 1)
int main(int argc, char **argv) {
--
2.5.5
Hi Thomas,
Thomas Petazzoni wrote,
> Hello Waldemar,
>
> We discussed a while ago the problem of supporting the static + PIE
> scenario, which currently causes some build failures of the Go-based
> flannel package, due to Scrt1.o being missing.
>
> On IRC, you told me that Scrt1.o is properly produced by uClibc, and it
> looks like you suspected there was some issue in how Buildroot then
> packages the toolchain. So I looked at the build log of my toolchains,
> and here is what I found.
>
> If I looked at the build log of the br-arm-full toolchain (an uClibc-ng
> based toolchain for ARM, with all features enabled: C++, locales,
> threads, wchar, etc.), I do see Scrt1.o being built:
>
> AS lib/crt1.o
> AS lib/Scrt1.o
> AS lib/crti.o
> AS lib/crtn.o
>
> Then installed:
>
> install -m 644 ./lib/crt1.o ./lib/Scrt1.o ./lib/crti.o ./lib/crtn.o /opt/br-arm-full-2016.05-2-g5dabb45/usr/arm-buildroot-linux-uclibcgnueabi/sysroot/usr/lib//
>
> And it is properly present in the toolchain tarball:
>
> test@build:/opt$ tar tvf br-arm-full-2016.05-2-g5dabb45.tar.bz2 | grep crt
> -rw-r--r-- test/test 972 2016-06-01 14:27 br-arm-full-2016.05-2-g5dabb45/arm-buildroot-linux-uclibcgnueabi/sysroot/usr/lib/crtn.o
> -rw-r--r-- test/test 988 2016-06-01 14:27 br-arm-full-2016.05-2-g5dabb45/arm-buildroot-linux-uclibcgnueabi/sysroot/usr/lib/crti.o
> -rw-r--r-- test/test 1004 2016-06-01 14:27 br-arm-full-2016.05-2-g5dabb45/arm-buildroot-linux-uclibcgnueabi/sysroot/usr/lib/crt1.o
> -rw-r--r-- test/test 1080 2016-06-01 14:27 br-arm-full-2016.05-2-g5dabb45/arm-buildroot-linux-uclibcgnueabi/sysroot/usr/lib/Scrt1.o
> -rw-r--r-- test/test 1108 2016-06-01 14:31 br-arm-full-2016.05-2-g5dabb45/lib/gcc/arm-buildroot-linux-uclibcgnueabi/4.8.5/crtendS.o
> -rw-r--r-- test/test 1108 2016-06-01 14:31 br-arm-full-2016.05-2-g5dabb45/lib/gcc/arm-buildroot-linux-uclibcgnueabi/4.8.5/crtend.o
> -rw-r--r-- test/test 2528 2016-06-01 14:31 br-arm-full-2016.05-2-g5dabb45/lib/gcc/arm-buildroot-linux-uclibcgnueabi/4.8.5/crtbegin.o
> -rw-r--r-- test/test 2528 2016-06-01 14:31 br-arm-full-2016.05-2-g5dabb45/lib/gcc/arm-buildroot-linux-uclibcgnueabi/4.8.5/crtbeginT.o
> -rw-r--r-- test/test 2928 2016-06-01 14:31 br-arm-full-2016.05-2-g5dabb45/lib/gcc/arm-buildroot-linux-uclibcgnueabi/4.8.5/crtbeginS.o
>
> However, the flannel failures don't happen with br-arm-full, but only
> with br-arm-full-static, which is the same toolchain, but built with
> BR2_STATIC_LIBS=y. Due to this, uClibc is built with HAVE_SHARED
> disabled.
>
> And in this case, Scrt1.o is not built:
>
> AS lib/crt1.o
> AS lib/crti.o
> AS lib/crtn.o
>
> And it is not installed:
>
> install -m 644 ./lib/crt1.o ./lib/crti.o ./lib/crtn.o /opt/br-arm-full-static-2016.05-2-g5dabb45/usr/arm-buildroot-linux-uclibcgnueabi/sysroot/usr/lib//
>
> This explains why there is no Scrt1.o in the generated Buildroot
> toolchain.
>
> So I continue to believe that the problem is on uClibc's side, and not
> on Buildroot's side.
>
> It would be good if you could investigate why uClibc doesn't produce
> Scrt1.o when HAVE_SHARED is disabled.
At the moment Scrt1.o is only build under following condition:
ifeq ($(HAVE_SHARED)$(UCLIBC_FORMAT_SHARED_FLAT),y)
I tried to compile a simple hello world as static PIE for ARM and
this is not really straight forward. You need at least binutils 2.26
to use -W,--no-dynamic-linker otherwise PT_INTERP is added to the
resulting executable. After that I tried to run it in Qemu (system
and user level tried) and the binary fails to execute with a
segmentation fault.
So even if we add Scrt1.o somehow to the toolchains, the binaries
will not work on the target. Scrt1.o is just PIC version of crt1.c.
So the PIC assembly in uClibc-ng might be just broken.
Is it really required for flannel to work to use static PIE?
In my point of view it is some kind of security feature used on
Linux together with address space layout randomization.
I don't know flannel, but security related software as OpenSSH
does allow to build with and without PIE.
I am not if and when I can take a look at the startup code.
A short test for MIPS showed other problems and didn't compile my
hello world as static PIE.
best regards
Waldemar
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "uClibc-ng - small C library for embedded systems".
The branch, master has been updated
via bf70f6f1face8e36030544a74e5ea04903df16cb (commit)
via 4fee9155f396cb2bcfe707f78aa4332837520f93 (commit)
via 2e045f9867bfc62e64412bc039400d411da1d2d2 (commit)
from d80e49d7b6da04efac6ece21497d32b14abb089f (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit bf70f6f1face8e36030544a74e5ea04903df16cb
Author: Waldemar Brodkorb <wbx(a)uclibc-ng.org>
Date: Wed Jun 8 21:49:04 2016 +0200
test: add new mmap tests from glibc
Rename mmap2 test as this is a ARM specific test, only
execute on ARM systems. Add more new tests from glibc.
commit 4fee9155f396cb2bcfe707f78aa4332837520f93
Author: Waldemar Brodkorb <wbx(a)uclibc-ng.org>
Date: Tue Jun 7 04:14:23 2016 +0200
ssp: remove SSP legacy code
Nobody should use gcc 3.3 nowadays.
commit 2e045f9867bfc62e64412bc039400d411da1d2d2
Author: Waldemar Brodkorb <wbx(a)uclibc-ng.org>
Date: Tue Jun 7 03:54:20 2016 +0200
microblaze: remove unused dead code
These files are not used, no regression found while
running the testsuite.
-----------------------------------------------------------------------
Summary of changes:
extra/Configs/Config.in | 16 ----
ldso/ldso/ldso.c | 6 --
libc/misc/internals/__uClibc_main.c | 7 --
libc/sysdeps/linux/common/ssp.c | 27 +-----
libc/sysdeps/linux/microblaze/Makefile.arch | 5 +-
libc/sysdeps/linux/microblaze/crt0.S | 52 -----------
libc/sysdeps/linux/microblaze/fixdfsi.c | 85 -----------------
libc/sysdeps/linux/microblaze/floatlib.h | 140 ----------------------------
test/mmap/Makefile.in | 6 ++
test/mmap/{mmap2.c => mmap-arm.c} | 0
test/mmap/tst-mmap-eofsync.c | 106 +++++++++++++++++++++
test/mmap/tst-mmap-fflushsync.c | 99 ++++++++++++++++++++
test/mmap/tst-mmap-offend.c | 86 +++++++++++++++++
test/mmap/tst-mmap-setvbuf.c | 81 ++++++++++++++++
14 files changed, 380 insertions(+), 336 deletions(-)
delete mode 100644 libc/sysdeps/linux/microblaze/crt0.S
delete mode 100644 libc/sysdeps/linux/microblaze/fixdfsi.c
delete mode 100644 libc/sysdeps/linux/microblaze/floatlib.h
create mode 100644 test/mmap/Makefile.in
rename test/mmap/{mmap2.c => mmap-arm.c} (100%)
create mode 100644 test/mmap/tst-mmap-eofsync.c
create mode 100644 test/mmap/tst-mmap-fflushsync.c
create mode 100644 test/mmap/tst-mmap-offend.c
create mode 100644 test/mmap/tst-mmap-setvbuf.c
diff --git a/extra/Configs/Config.in b/extra/Configs/Config.in
index f3494db..a21bdac 100644
--- a/extra/Configs/Config.in
+++ b/extra/Configs/Config.in
@@ -2151,22 +2151,6 @@ config UCLIBC_HAS_SSP
Most people will answer N.
-config UCLIBC_HAS_SSP_COMPAT
- bool "Support for gcc-3.x propolice smashing stack protector"
- depends on UCLIBC_HAS_SSP
- help
- Add gcc-3.x propolice smashing stack protector to the library.
-
- This requires a patched version of GCC, supporting the
- -fstack-protector[-all] options, with the __guard and
- __stack_smash_handler functions removed from libgcc.
- These functions are added to ldso/libc instead.
-
- More information at:
- <http://www.research.ibm.com/trl/projects/security/ssp/>
-
- Most people will answer N.
-
config SSP_QUICK_CANARY
bool "Use simple guard values without accessing /dev/urandom"
depends on UCLIBC_HAS_SSP
diff --git a/ldso/ldso/ldso.c b/ldso/ldso/ldso.c
index 9f4e841..7bb6a34 100644
--- a/ldso/ldso/ldso.c
+++ b/ldso/ldso/ldso.c
@@ -120,9 +120,6 @@ static uintptr_t stack_chk_guard;
* in local thread area. */
uintptr_t __stack_chk_guard attribute_relro;
# endif
-# ifdef __UCLIBC_HAS_SSP_COMPAT__
-uintptr_t __guard attribute_relro;
-# endif
#endif
#ifdef __LDSO_SEARCH_INTERP_PATH__
@@ -1217,9 +1214,6 @@ of this helper program; chances are you did not intend to run this program.\n\
# else
__stack_chk_guard = stack_chk_guard;
# endif
-# ifdef __UCLIBC_HAS_SSP_COMPAT__
- __guard = stack_chk_guard;
-# endif
#endif
#ifdef __LDSO_PRELINK_SUPPORT__
diff --git a/libc/misc/internals/__uClibc_main.c b/libc/misc/internals/__uClibc_main.c
index 632a252..9bb81fc 100644
--- a/libc/misc/internals/__uClibc_main.c
+++ b/libc/misc/internals/__uClibc_main.c
@@ -61,10 +61,6 @@ static uintptr_t stack_chk_guard;
/* for gcc-4.1 non-TLS */
uintptr_t __stack_chk_guard attribute_relro;
# endif
-/* for gcc-3.x + Etoh ssp */
-# ifdef __UCLIBC_HAS_SSP_COMPAT__
-uintptr_t __guard attribute_relro;
-# endif
# endif
/*
@@ -274,9 +270,6 @@ void __uClibc_init(void)
# else
__stack_chk_guard = stack_chk_guard;
# endif
-# ifdef __UCLIBC_HAS_SSP_COMPAT__
- __guard = stack_chk_guard;
-# endif
# endif
#endif
diff --git a/libc/sysdeps/linux/common/ssp.c b/libc/sysdeps/linux/common/ssp.c
index 8dcc3dc..87e10c2 100644
--- a/libc/sysdeps/linux/common/ssp.c
+++ b/libc/sysdeps/linux/common/ssp.c
@@ -51,18 +51,11 @@ static void __cold do_msg(const char *msg1, const char *msg2, const char *msg3)
}
static void __cold attribute_noreturn
-#ifdef __UCLIBC_HAS_SSP_COMPAT__
-ssp_handler(char func[])
-#else
ssp_handler(void)
-#endif
{
pid_t pid;
static const char msg_ssd[] = "*** stack smashing detected ***: ";
static const char msg_terminated[] = " terminated";
-#ifdef __UCLIBC_HAS_SSP_COMPAT__
- static const char msg_ssa[] = ": stack smashing attack in function ";
-#endif
#ifdef __DODEBUG__
struct sigaction sa;
@@ -73,12 +66,7 @@ ssp_handler(void)
sigprocmask(SIG_BLOCK, &mask, NULL); /* except SSP_SIGTYPE */
#endif
-#ifdef __UCLIBC_HAS_SSP_COMPAT__
- if (func != NULL)
- do_msg(__uclibc_progname, msg_ssa, func);
- else
-#endif
- do_msg(msg_ssd, __uclibc_progname, msg_terminated);
+ do_msg(msg_ssd, __uclibc_progname, msg_terminated);
pid = getpid();
#ifdef __DODEBUG__
@@ -96,20 +84,7 @@ ssp_handler(void)
_exit(127);
}
-#ifdef __UCLIBC_HAS_SSP_COMPAT__
-void __stack_smash_handler(char func[], int damaged) attribute_noreturn __cold;
-void __stack_smash_handler(char func[], int damaged attribute_unused)
-{
- ssp_handler(func);
-}
-
-void __stack_chk_fail(void)
-{
- ssp_handler(NULL);
-}
-#else
strong_alias(ssp_handler,__stack_chk_fail)
-#endif
#ifdef __UCLIBC_HAS_FORTIFY__
/* should be redone when activated to use common code above.
diff --git a/libc/sysdeps/linux/microblaze/Makefile.arch b/libc/sysdeps/linux/microblaze/Makefile.arch
index 8f14fb9..6f1e9fb 100644
--- a/libc/sysdeps/linux/microblaze/Makefile.arch
+++ b/libc/sysdeps/linux/microblaze/Makefile.arch
@@ -5,8 +5,5 @@
#
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
-CSRC-y := clone.c fixdfsi.c
-
+CSRC-y := clone.c
SSRC-y := setjmp.S __longjmp.S vfork.S
-
-ARCH_HEADERS := floatlib.h
diff --git a/libc/sysdeps/linux/microblaze/crt0.S b/libc/sysdeps/linux/microblaze/crt0.S
deleted file mode 100644
index 6be1e4d..0000000
--- a/libc/sysdeps/linux/microblaze/crt0.S
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * libc/sysdeps/linux/microblaze/crt0.S -- Initial program entry point for linux/microblaze
- *
- * Copyright (C) 2003 John Williams <jwilliams(a)itee.uq.edu.au>
- * Copyright (C) 2001,2002 NEC Corporation
- * Copyright (C) 2001,2002 Miles Bader <miles(a)gnu.org>
- *
- * This file is subject to the terms and conditions of the GNU Lesser
- * General Public License. See the file COPYING.LIB in the main
- * directory of this archive for more details.
- *
- * Written by Miles Bader <miles(a)gnu.org>
- */
-
-#include <clinkage.h>
-
-/* Upon entry, the stack contains the following data:
- argc, argv[0], ..., argv[argc-1], 0, envp[0], ..., 0
-*/
-
- .text
-C_ENTRY(_start):
- lw r5, r0, r1 /* Arg 0: argc */
-
- addi r6, r1, 4 /* Arg 1: argv */
-
- /* Arg 2: envp */
- addi r3, r5, 1 /* skip argc elements to get envp start */
- /* ...plus the NULL at the end of argv */
- add r3, r3, r3 /* Make word offset */
- add r3, r3, r3
- add r7, r6, r3 /* add to argv to get offset */
-
- /* tail-call uclibc's startup routine */
- brid C_SYMBOL_NAME(__uClibc_main)
- nop
-
-
-/* Stick in a dummy reference to `main', so that if an application
- is linking when the `main' function is in a static library (.a)
- we can be sure that `main' actually gets linked in. */
-L_dummy_main_reference:
- .long C_SYMBOL_NAME(main)
-
-/* Define a symbol for the first piece of initialized data. */
- .data
- .globl __data_start
-__data_start:
- .long 0
- .weak data_start
- data_start = __data_start
-
diff --git a/libc/sysdeps/linux/microblaze/fixdfsi.c b/libc/sysdeps/linux/microblaze/fixdfsi.c
deleted file mode 100644
index 1611176..0000000
--- a/libc/sysdeps/linux/microblaze/fixdfsi.c
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
-** libgcc support for software floating point.
-** Copyright (C) 1991 by Pipeline Associates, Inc. All rights reserved.
-** Permission is granted to do *anything* you want with this file,
-** commercial or otherwise, provided this message remains intact. So there!
-** I would appreciate receiving any updates/patches/changes that anyone
-** makes, and am willing to be the repository for said changes (am I
-** making a big mistake?).
-
-Warning! Only single-precision is actually implemented. This file
-won't really be much use until double-precision is supported.
-
-However, once that is done, this file might eventually become a
-replacement for libgcc1.c. It might also make possible
-cross-compilation for an IEEE target machine from a non-IEEE
-host such as a VAX.
-
-If you'd like to work on completing this, please talk to rms(a)gnu.ai.mit.edu.
-
---> Double precision floating support added by James Carlson on 20 April 1998.
-
-**
-** Pat Wood
-** Pipeline Associates, Inc.
-** pipeline!phw(a)motown.com or
-** sun!pipeline!phw or
-** uunet!motown!pipeline!phw
-**
-** 05/01/91 -- V1.0 -- first release to gcc mailing lists
-** 05/04/91 -- V1.1 -- added float and double prototypes and return values
-** -- fixed problems with adding and subtracting zero
-** -- fixed rounding in truncdfsf2
-** -- fixed SWAP define and tested on 386
-*/
-
-/*
-** The following are routines that replace the libgcc soft floating point
-** routines that are called automatically when -msoft-float is selected.
-** The support single and double precision IEEE format, with provisions
-** for byte-swapped machines (tested on 386). Some of the double-precision
-** routines work at full precision, but most of the hard ones simply punt
-** and call the single precision routines, producing a loss of accuracy.
-** long long support is not assumed or included.
-** Overall accuracy is close to IEEE (actually 68882) for single-precision
-** arithmetic. I think there may still be a 1 in 1000 chance of a bit
-** being rounded the wrong way during a multiply. I'm not fussy enough to
-** bother with it, but if anyone is, knock yourself out.
-**
-** Efficiency has only been addressed where it was obvious that something
-** would make a big difference. Anyone who wants to do this right for
-** best speed should go in and rewrite in assembler.
-**
-** I have tested this only on a 68030 workstation and 386/ix integrated
-** in with -msoft-float.
-*/
-
-#include "floatlib.h"
-
-/* convert double to int */
-long
-__fixdfsi (double a1)
-{
- register union double_long dl1;
- register int exp;
- register long l;
-
- dl1.d = a1;
-
- if (!dl1.l.upper && !dl1.l.lower)
- return (0);
-
- exp = EXPD (dl1) - EXCESSD - 31;
- l = MANTD (dl1);
-
- if (exp > 0)
- return SIGND(dl1) ? (1<<31) : ((1ul<<31)-1);
-
- /* shift down until exp = 0 or l = 0 */
- if (exp < 0 && exp > -32 && l)
- l >>= -exp;
- else
- return (0);
-
- return (SIGND (dl1) ? -l : l);
-}
diff --git a/libc/sysdeps/linux/microblaze/floatlib.h b/libc/sysdeps/linux/microblaze/floatlib.h
deleted file mode 100644
index 817ba7d..0000000
--- a/libc/sysdeps/linux/microblaze/floatlib.h
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
-** libgcc support for software floating point.
-** Copyright (C) 1991 by Pipeline Associates, Inc. All rights reserved.
-** Permission is granted to do *anything* you want with this file,
-** commercial or otherwise, provided this message remains intact. So there!
-** I would appreciate receiving any updates/patches/changes that anyone
-** makes, and am willing to be the repository for said changes (am I
-** making a big mistake?).
-
-Warning! Only single-precision is actually implemented. This file
-won't really be much use until double-precision is supported.
-
-However, once that is done, this file might eventually become a
-replacement for libgcc1.c. It might also make possible
-cross-compilation for an IEEE target machine from a non-IEEE
-host such as a VAX.
-
-If you'd like to work on completing this, please talk to rms(a)gnu.ai.mit.edu.
-
---> Double precision floating support added by James Carlson on 20 April 1998.
-
-**
-** Pat Wood
-** Pipeline Associates, Inc.
-** pipeline!phw(a)motown.com or
-** sun!pipeline!phw or
-** uunet!motown!pipeline!phw
-**
-** 05/01/91 -- V1.0 -- first release to gcc mailing lists
-** 05/04/91 -- V1.1 -- added float and double prototypes and return values
-** -- fixed problems with adding and subtracting zero
-** -- fixed rounding in truncdfsf2
-** -- fixed SWAP define and tested on 386
-*/
-
-/*
-** The following are routines that replace the libgcc soft floating point
-** routines that are called automatically when -msoft-float is selected.
-** The support single and double precision IEEE format, with provisions
-** for byte-swapped machines (tested on 386). Some of the double-precision
-** routines work at full precision, but most of the hard ones simply punt
-** and call the single precision routines, producing a loss of accuracy.
-** long long support is not assumed or included.
-** Overall accuracy is close to IEEE (actually 68882) for single-precision
-** arithmetic. I think there may still be a 1 in 1000 chance of a bit
-** being rounded the wrong way during a multiply. I'm not fussy enough to
-** bother with it, but if anyone is, knock yourself out.
-**
-** Efficiency has only been addressed where it was obvious that something
-** would make a big difference. Anyone who wants to do this right for
-** best speed should go in and rewrite in assembler.
-**
-** I have tested this only on a 68030 workstation and 386/ix integrated
-** in with -msoft-float.
-*/
-
-#ifndef __FLOAT_LIB_H__
-#define __FLOAT_LIB_H__
-/* the following deal with IEEE single-precision numbers */
-#define EXCESS 126
-#define SIGNBIT 0x80000000
-#define HIDDEN (1 << 23)
-#define SIGN(fp) ((fp) & SIGNBIT)
-#define EXP(fp) (((fp) >> 23) & 0xFF)
-#define MANT(fp) (((fp) & 0x7FFFFF) | HIDDEN)
-#define PACK(s,e,m) ((s) | ((e) << 23) | (m))
-
-/* the following deal with IEEE double-precision numbers */
-#define EXCESSD 1022
-#define HIDDEND (1 << 20)
-#define EXPD(fp) (((fp.l.upper) >> 20) & 0x7FF)
-#define SIGND(fp) ((fp.l.upper) & SIGNBIT)
-#define MANTD(fp) (((((fp.l.upper) & 0xFFFFF) | HIDDEND) << 10) | \
- (fp.l.lower >> 22))
-#define HIDDEND_LL ((long long)1 << 52)
-#define MANTD_LL(fp) ((fp.ll & (HIDDEND_LL-1)) | HIDDEND_LL)
-#define PACKD_LL(s,e,m) (((long long)((s)+((e)<<20))<<32)|(m))
-
-/* define SWAP for 386/960 reverse-byte-order brain-damaged CPUs */
-union double_long {
- double d;
-#ifdef SWAP
- struct {
- unsigned long lower;
- long upper;
- } l;
-#else
- struct {
- long upper;
- unsigned long lower;
- } l;
-#endif
- long long ll;
-};
-
-union float_long
- {
- float f;
- long l;
- };
-
-#endif
-
-/* Functions defined in different files */
-
-float __addsf3 (float, float);
-float __subsf3 (float, float);
-long __cmpsf2 (float, float);
-float __mulsf3 (float, float);
-float __divsf3 (float, float);
-double __floatsidf (register long);
-double __floatdidf (register long long);
-float __floatsisf (register long );
-float __floatdisf (register long long );
-float __negsf2 (float);
-double __negdf2 (double);
-double __extendsfdf2 (float);
-float __truncdfsf2 (double);
-long __cmpdf2 (double, double);
-long __fixsfsi (float);
-long __fixdfsi (double);
-long long __fixdfdi (double);
-unsigned long __fixunsdfsi (double);
-unsigned long long __fixunsdfdi (double);
-double __adddf3 (double, double);
-double __subdf3 (double, double);
-double __muldf3 (double, double);
-double __divdf3 (double, double);
-int __gtdf2 (double, double);
-int __gedf2 (double, double);
-int __ltdf2 (double, double);
-int __ledf2 (double, double);
-int __eqdf2 (double, double);
-int __nedf2 (double, double);
-int __gtsf2 (float, float);
-int __gesf2 (float, float);
-int __ltsf2 (float, float);
-int __lesf2 (float, float);
-int __eqsf2 (float, float);
-int __nesf2 (float, float);
diff --git a/test/mmap/Makefile.in b/test/mmap/Makefile.in
new file mode 100644
index 0000000..7bb34ac
--- /dev/null
+++ b/test/mmap/Makefile.in
@@ -0,0 +1,6 @@
+# uClibc mmap tests
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+
+ifneq ($(TARGET_ARCH),arm)
+TESTS_DISABLED += mmap-arm
+endif
diff --git a/test/mmap/mmap2.c b/test/mmap/mmap-arm.c
similarity index 100%
rename from test/mmap/mmap2.c
rename to test/mmap/mmap-arm.c
diff --git a/test/mmap/tst-mmap-eofsync.c b/test/mmap/tst-mmap-eofsync.c
new file mode 100644
index 0000000..e8ef727
--- /dev/null
+++ b/test/mmap/tst-mmap-eofsync.c
@@ -0,0 +1,106 @@
+/* Test program for synchronization of stdio state with file after EOF. */
+
+#include <stdio.h>
+#include <error.h>
+#include <errno.h>
+
+static void do_prepare (void);
+#define PREPARE(argc, argv) do_prepare ()
+static int do_test (void);
+#define TEST_FUNCTION do_test ()
+#include <test-skeleton.c>
+
+static char *temp_file;
+static int temp_fd;
+
+static char text1[] = "Line the first\n";
+static char text2[] = "Line the second\n";
+
+static void
+do_prepare (void)
+{
+ temp_fd = create_temp_file ("tst-mmap-eofsync.", &temp_file);
+ if (temp_fd == -1)
+ error (1, errno, "cannot create temporary file");
+ else
+ {
+ ssize_t cc = write (temp_fd, text1, sizeof text1 - 1);
+ if (cc != sizeof text1 - 1)
+ error (1, errno, "cannot write to temporary file");
+ }
+}
+
+static int
+do_test (void)
+{
+ FILE *f;
+ char buf[128];
+ int result = 0;
+ int c;
+
+ f = fopen (temp_file, "rm");
+ if (f == NULL)
+ {
+ perror (temp_file);
+ return 1;
+ }
+
+ if (fgets (buf, sizeof buf, f) == NULL)
+ {
+ perror ("fgets");
+ return 1;
+ }
+
+ if (strcmp (buf, text1))
+ {
+ printf ("read \"%s\", expected \"%s\"\n", buf, text1);
+ result = 1;
+ }
+
+ printf ("feof = %d, ferror = %d immediately after fgets\n",
+ feof (f), ferror (f));
+
+#if 1
+ c = fgetc (f);
+ if (c == EOF)
+ printf ("fgetc -> EOF (feof = %d, ferror = %d)\n",
+ feof (f), ferror (f));
+ else
+ {
+ printf ("fgetc returned %o (feof = %d, ferror = %d)\n",
+ c, feof (f), ferror (f));
+ result = 1;
+ }
+#endif
+
+ c = write (temp_fd, text2, sizeof text2 - 1);
+ if (c == sizeof text2 - 1)
+ printf ("wrote more to file\n");
+ else
+ {
+ printf ("wrote %d != %zd (%m)\n", c, sizeof text2 - 1);
+ result = 1;
+ }
+
+ if (fgets (buf, sizeof buf, f) == NULL)
+ {
+ printf ("second fgets fails: feof = %d, ferror = %d (%m)\n",
+ feof (f), ferror (f));
+ clearerr (f);
+ if (fgets (buf, sizeof buf, f) == NULL)
+ {
+ printf ("retry fgets fails: feof = %d, ferror = %d (%m)\n",
+ feof (f), ferror (f));
+ result = 1;
+ }
+ }
+ if (result == 0 && strcmp (buf, text2))
+ {
+ printf ("second time read \"%s\", expected \"%s\"\n", buf, text2);
+ result = 1;
+ }
+
+ fclose (f);
+
+ return result;
+}
diff --git a/test/mmap/tst-mmap-fflushsync.c b/test/mmap/tst-mmap-fflushsync.c
new file mode 100644
index 0000000..24ae33c
--- /dev/null
+++ b/test/mmap/tst-mmap-fflushsync.c
@@ -0,0 +1,99 @@
+/* Test program for synchronization of stdio state with file after fflush. */
+
+#include <stdio.h>
+#include <error.h>
+#include <errno.h>
+
+static void do_prepare (void);
+#define PREPARE(argc, argv) do_prepare ()
+static int do_test (void);
+#define TEST_FUNCTION do_test ()
+#include <test-skeleton.c>
+
+static char *temp_file;
+static int temp_fd;
+
+static char text1[] = "Line the first\n";
+static char text2[] = "Line the second\n";
+
+static void
+do_prepare (void)
+{
+ temp_fd = create_temp_file ("tst-mmap-eofsync.", &temp_file);
+ if (temp_fd == -1)
+ error (1, errno, "cannot create temporary file");
+ else
+ {
+ ssize_t cc = write (temp_fd, text1, sizeof text1 - 1);
+ if (cc != sizeof text1 - 1)
+ error (1, errno, "cannot write to temporary file");
+ }
+}
+
+static int
+do_test (void)
+{
+ FILE *f;
+ char buf[128];
+ int result = 0;
+ int c;
+
+ f = fopen (temp_file, "rm");
+ if (f == NULL)
+ {
+ perror (temp_file);
+ return 1;
+ }
+
+ if (fgets (buf, sizeof buf, f) == NULL)
+ {
+ perror ("fgets");
+ return 1;
+ }
+
+ if (strcmp (buf, text1))
+ {
+ printf ("read \"%s\", expected \"%s\"\n", buf, text1);
+ result = 1;
+ }
+
+ printf ("feof = %d, ferror = %d immediately after fgets\n",
+ feof (f), ferror (f));
+
+ if (fflush (f) != 0)
+ {
+ printf ("fflush failed! %m\n");
+ result = 1;
+ }
+
+ c = write (temp_fd, text2, sizeof text2 - 1);
+ if (c == sizeof text2 - 1)
+ printf ("wrote more to file\n");
+ else
+ {
+ printf ("wrote %d != %zd (%m)\n", c, sizeof text2 - 1);
+ result = 1;
+ }
+
+ if (fgets (buf, sizeof buf, f) == NULL)
+ {
+ printf ("second fgets fails: feof = %d, ferror = %d (%m)\n",
+ feof (f), ferror (f));
+ clearerr (f);
+ if (fgets (buf, sizeof buf, f) == NULL)
+ {
+ printf ("retry fgets fails: feof = %d, ferror = %d (%m)\n",
+ feof (f), ferror (f));
+ result = 1;
+ }
+ }
+ if (result == 0 && strcmp (buf, text2))
+ {
+ printf ("second time read \"%s\", expected \"%s\"\n", buf, text2);
+ result = 1;
+ }
+
+ fclose (f);
+
+ return result;
+}
diff --git a/test/mmap/tst-mmap-offend.c b/test/mmap/tst-mmap-offend.c
new file mode 100644
index 0000000..19732e6
--- /dev/null
+++ b/test/mmap/tst-mmap-offend.c
@@ -0,0 +1,86 @@
+/* Test case for bug with mmap stdio read past end of file. */
+
+#include <stdio.h>
+#include <error.h>
+#include <errno.h>
+
+static void do_prepare (void);
+#define PREPARE(argc, argv) do_prepare ()
+static int do_test (void);
+#define TEST_FUNCTION do_test ()
+#include <test-skeleton.c>
+
+static char *temp_file;
+
+static const char text1[] = "hello\n";
+
+static void
+do_prepare (void)
+{
+ int temp_fd = create_temp_file ("tst-mmap-offend.", &temp_file);
+ if (temp_fd == -1)
+ error (1, errno, "cannot create temporary file");
+ else
+ {
+ ssize_t cc = write (temp_fd, text1, sizeof text1 - 1);
+ if (cc != sizeof text1 - 1)
+ error (1, errno, "cannot write to temporary file");
+ }
+ close (temp_fd);
+}
+
+static int
+do_test (void)
+{
+ unsigned char buffer[8192];
+ int result = 0;
+ FILE *f = fopen (temp_file, "rm");
+ size_t cc;
+
+ if (f == NULL)
+ {
+ perror (temp_file);
+ return 1;
+ }
+
+ cc = fread (buffer, 1, sizeof (buffer), f);
+ printf ("fread %zu: \"%.*s\"\n", cc, (int) cc, buffer);
+ if (cc != sizeof text1 - 1)
+ {
+ perror ("fread");
+ result = 1;
+ }
+
+ if (fseek (f, 2048, SEEK_SET) != 0)
+ {
+ perror ("fseek off end");
+ result = 1;
+ }
+
+ if (fread (buffer, 1, sizeof (buffer), f) != 0
+ || ferror (f) || !feof (f))
+ {
+ printf ("after fread error %d eof %d\n",
+ ferror (f), feof (f));
+ result = 1;
+ }
+
+ printf ("ftell %ld\n", ftell (f));
+
+ if (fseek (f, 0, SEEK_SET) != 0)
+ {
+ perror ("fseek rewind");
+ result = 1;
+ }
+
+ cc = fread (buffer, 1, sizeof (buffer), f);
+ printf ("fread after rewind %zu: \"%.*s\"\n", cc, (int) cc, buffer);
+ if (cc != sizeof text1 - 1)
+ {
+ perror ("fread after rewind");
+ result = 1;
+ }
+
+ fclose (f);
+ return result;
+}
diff --git a/test/mmap/tst-mmap-setvbuf.c b/test/mmap/tst-mmap-setvbuf.c
new file mode 100644
index 0000000..33d60b7
--- /dev/null
+++ b/test/mmap/tst-mmap-setvbuf.c
@@ -0,0 +1,81 @@
+/* Test setvbuf on readonly fopen (using mmap stdio).
+ Copyright (C) 2002-2016 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jakub Jelinek <jakub(a)redhat.com>, 2002.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+int main (void)
+{
+ char name[] = "/tmp/tst-mmap-setvbuf.XXXXXX";
+ char buf[4096];
+ const char * const test = "Let's see if mmap stdio works with setvbuf.\n";
+ char temp[strlen (test) + 1];
+ int fd = mkstemp (name);
+ FILE *f;
+
+ if (fd == -1)
+ {
+ printf ("%u: cannot open temporary file: %m\n", __LINE__);
+ exit (1);
+ }
+
+ f = fdopen (fd, "w");
+ if (f == NULL)
+ {
+ printf ("%u: cannot fdopen temporary file: %m\n", __LINE__);
+ exit (1);
+ }
+
+ fputs (test, f);
+ fclose (f);
+
+ f = fopen (name, "rm");
+ if (f == NULL)
+ {
+ printf ("%u: cannot fopen temporary file: %m\n", __LINE__);
+ exit (1);
+ }
+
+ if (setvbuf (f, buf, _IOFBF, sizeof buf))
+ {
+ printf ("%u: setvbuf failed: %m\n", __LINE__);
+ exit (1);
+ }
+
+ if (fread (temp, 1, strlen (test), f) != strlen (test))
+ {
+ printf ("%u: couldn't read the file back: %m\n", __LINE__);
+ exit (1);
+ }
+ temp [strlen (test)] = '\0';
+
+ if (strcmp (test, temp))
+ {
+ printf ("%u: read different string than was written:\n%s%s",
+ __LINE__, test, temp);
+ exit (1);
+ }
+
+ fclose (f);
+
+ unlink (name);
+ exit (0);
+}
hooks/post-receive
--
uClibc-ng - small C library for embedded systems