__stdio_WRITE: make code more readable. No code changes

Pulled assignments out of ifs.
do {...} while (1); is a weird method of writing "loop forever",
thus rewrote it.
No code changes: objdump output is the same.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
buildsys: do not add empty obj to archives

Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
ldso:sh: fix compiler warning due to unused-but-set-variable

gcc 4.6.x raises useful warnings due to unused-but-set-variable,
This patch fixes the following one by using properly preprocessor
guard

In file included from ldso/libdl/libdl.c:129:0:
./ldso/ldso/sh/elfinterp.c: In function '_dl_do_reloc':
./ldso/ldso/sh/elfinterp.c:163:22: warning: variable 'tls_tpnt' set but not used [-Wunused-but-set-variable]

Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>
ldso: remove duplicated assignment with TLS symbol

The tpnt field is already set, so not needed to assign it again.

Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>
microblaze: add sys/user.h

A microblaze-specific sys/user.h is needed for (e.g.) strace,
so use this version from glibc.

Signed-off-by: Steve Bennett <steveb@workware.net.au>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
librt: add posix_spawn support

Signed-off-by: Ismael Luceno <ismael.luceno@gmail.com>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
stdio: prevent retries on fclose/fflush after write errors

Some test results:

The longer patch posted at Sun 14:46:24 +0100 made my target system
unbootable.  I did not attempt to troubleshoot it, as we are focusing
our efforts on the shorter patch now.

The shorter patch posted at Mon 01:50:27 +0100 is a good start, but it
didn't completely fix the problem for me.  I am posting an updated
version with a few changes at the end of this message; the patched
uClibc 0.9.32.1 tree passes both of my test cases.

My changes:

1) Need to break out of the loop on "hard" errors.  Otherwise the
library call never returns:

open("/dev/null", O_RDONLY)             = 4
dup2(4, 1)                              = 1
write(1, "hello world\n", 12)           = -1 EBADF (Bad file descriptor)
write(1, "hello world\n", 12)           = -1 EBADF (Bad file descriptor)
write(1, "hello world\n", 12)           = -1 EBADF (Bad file descriptor)
write(1, "hello world\n", 12)           = -1 EBADF (Bad file descriptor)
...

2) Move all of the error handling logic back into the "else" clause.  In
particular, I believe we do not want to be checking errno unless
__WRITE() had indicated a failure, since the value may be undefined:

        if (errno == EINTR
         || errno == EAGAIN
         /* do we have other "soft" errors? */
        ) {

3) Whitespace/indentation consistency.

-- 8< --

From: Denys Vlasenko <vda.linux@googlemail.com>

Currently, uclibc retains buffered data on stdio write errors,
and subsequent fclose and fflush will try to write it out again
(in most cases, in vain).

Which results in something like this:

On Wednesday 26 January 2011 13:21, Baruch Siach wrote:
> Hi busybox list,
>
> I'm running the following command under strace (thanks Rob):
>
> echo 56 > /sys/class/gpio/export
>
> and I see the following output:
>
> write(1, "56\n", 3)                     = -1 EBUSY (Device or resource busy)
> write(1, "5", 1)                        = 1
>
> The first EBUSY is OK, since GPIO 56 is already requested. But the second
> write() attempt seems strange, and leads to an unwanted outcome. GPIO 5 gets
> exported.

This patch prevents that.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
ldso: use ELF_xxx()/ElfW() helpers

They expand into the same code, but using the ELF_xxx()/ElfW() macros
makes it much easier to spot similarities between code bases.

Acked-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Acked-by: Carmelo Amoroso <carmelo.amoroso@st.com>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>