seekdir/telldir: fixed prototypes

The position used by seekdir(3) and telldir(3) is of type 'long', not of
type 'off_t'.

Signed-off-by: Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
readdir: fixed build

lib/readdir.c:10:3: error: implicit declaration of function readdir_r [-Werror=implicit-function-declaration]
   if (readdir_r(d,&tmp,&ld)) return 0;
readdir: major fixes and improvements

Depending whether getdents(2) or getdents64(2) were called, the
internal __dirstream buffer contains objects of different types:

--- fs/readdir.c ---
struct linux_dirent {
        unsigned long   d_ino;
        unsigned long   d_off;
        unsigned short  d_reclen;
        char            d_name[1];
};

SYSCALL_DEFINE3(getdents, unsigned int, fd,
                struct linux_dirent __user *, dirent, unsigned int, count)

--- include/linux/dirent.h ---
struct linux_dirent64 {
        u64             d_ino;
        s64             d_off;
        unsigned short  d_reclen;
        unsigned char   d_type;
        char            d_name[0];
};

SYSCALL_DEFINE3(getdents64, unsigned int, fd,
                struct linux_dirent64 __user *, dirent, unsigned int, count)

Existing code mixed casts between these types and even with userspace
types which causes problems when 'long' is not a 64 bit type.

The patch:

* uses correct datatypes in readdir*(3), telldir() and seekdir()

* adds a flag telling whether getdents(2) or getdents64(2) were used
  to fill dir ents buffer

* fixes prototypes of getdents64(2) and getdents(2)

* adds testsuite programs
Fixed SMP build

'make -j' fails usually because $(OBJDIR) was not created yet when
compiling files.

This patch adds a $(OBJDIR)/.dirstamp target which is added as a
dependency for object files and executes an 'mkdir'.

Ditto for $(PICODIR)
Define and use $(STRIP) makefile variable

This increases readability and makes it easier to turn off stripping
of debug symbols.
use $(XCFLAGS) in every rule compiling a .c or .S file
Build some files without stack-protector
Sanity checks for syscall availability

Catch the case when syscall(2) is not implemented for the actual arch
instead of jumping to the next function and executing the wrong code
Workaround PPC build issues

Fixes https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=182118 and
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27054
Security fix for proper $PATH

Removed '.' from the default $PATH.
Enhanced __stack_chk_fail

* modified __stack_chk_fail() to trigger a segfault by accessing
  address 0x0. Every system with an MMU known by me, segfaults
  by dereferencing a NULL pointer.

* added hack to compile stack_smash_handler2 with
  '--fno-omit-frame-pointer'.
makefile: removed duplicate rule

building stackgap was solved better by previous patches
Use stdout instead of stderr in testsuite

This patches uses stdout instead stderr when giving out normal status
messages in the testsuite.
Support for dynamic PAGE_SIZE

This patch adds support for dynamic PAGE_SIZE values. It
is a little bit invasive in several aspects:

* it modifies the startup code. We need to know the position of
  the elf-info auxilary table which is located after 'environ'.
  We can not use 'environ' directly because it might be modified
  by the application.

  Hence, an additional __elfinfo variable is placed into .bss and
  filled in the startup code. Depending on platform, this adds
  4-8 instructions and an additional pointer to .bss.

  I tested only the i386 and x86_64 modifications; it would be
  nice when people with corresponding hardware would test the
  other ones. I am especially uncertain regarding the parisc
  changes.

  The elf-info stuff (which might be interesting e.g. for dynamic
  linking or sysconf(_SC_CLK_TCK)) can be enabled without the
  dynamic pagesize too.

* it removes the 'PAGE_SIZE' macro from <sys/shm.h>; this will
  break compilation of existing userspace application which are
  using this deprecated macro

* I added a new internal 'dietpagesize.h' header which defines

  | __DIET_PAGE_SIZE
  | __DIET_PAGE_SHIFT

  macros. These return either builtin constants (when
  WANT_DYN_PAGESIZE is not selected), or values derived from
  __libc_getpagesize().

  Every usage of PAGE_SIZE in dietlibc code was replaced by these
  macros.

* due to the previous point, the internal 'struct __dirstream'
  was modified. I replaced

  | getdents64(d->fd,(struct dirent64*)d->buf, sizeof (d->buf)-1);

  with

  | getdents64(d->fd,(struct dirent64*)d->buf,  __DIRSTREAM_BUF_SIZE-1);

  literally but I am not sure where the '-1' is coming from.
  There is one hunk, where this '-1' is missing so I think the
  '-1' should be removed from all calls to getdents64().

* changes affect the *alloc() functions too; on x86_64 around 64
  bytes were added to .text of alloc.o

* the new testprogramm requires a 'getconf' binary which returns
  the correct values for PAGE_SIZE and CLK_TCK

Patch seems to work fine on i386, x86_64, ppc and ppc64.  Things
went a little bit complicated with linux 2.6.25; previous kernels
exported a elf_addr_t type in <linux/elf.h> which is used in the
auxilary elf-info table. Now, this is not available anymore and I
use a type derived from __WORD_SIZE.
Fixes/enhancements for INF/NAN handling in printf()

This patch adds support for uppercase 'F' and 'G' printf format
specifiers.  It fixes handling of -INF values in __dtostr() too;
previously, there was

| unsigned int i;
| if ((i=isinf(d))) return copystring(buf,maxlen,i>0?"inf":"-inf");
                                                 ~~~
which evaluated to true everytime. The copystring() function
worked for 3-letter words only but not for '-inf'.

The last argument of __dtostr() was changed from a boolean flag to
a bitmask. Bit 0 encodes 'g' or 'f', and bit 1 lower-/uppercase.
There should be probably added some macros for them; for now,
these values are used directly.

Please note that this might affect other applications (liblowfat?)
too which are using __dtostr().

'isinf(3)' is a builtin with gcc 4.3 and does not give a hint
about the signess of the infinity anymore. Hence, this patch uses
a more portable way where needed.
Fixes/enhancements in str?time() functions

This patch changes the used format for %x and %X specifiers in
strptime(3) to match these specified by SUSv2.  It adds support
for '%F' in strftime(3) too.
Fixes for -Werror-no-implicit-functions

Some fixes for issues preventing builds with
'-Werror-implicit-function-declaration'.
__noreturn__ annotation for abort(3)

SUSv2 says about abort(3):

  The abort() function shall not return.

Hence, an '__attribute__((__noreturn__))' should be added to the
abort(3) declaration.
Several testsuite fixes/enhancments

* test/getmntent.c: I removed the checks which called endmntent()
  multiple times resp. with a NULL pointer.  Behavior in first
  case is undefined and latter causes a segfault (I could not
  find documentation that this is allowed).  Hence, it does not
  make sense to test this.

* test/stdlib/tst-malloc.c: test 'malloc(0)' only, when
  WANT_MALLOC_ZERO is set

* test/time/tst-strftime.c: the '%Zu' printf format specifier is
  bogus (from libc5 ages). I replaced it with the '%zu' one.

  Please note, that this test still fails because it uses glibc
  specific features.

* test/time/tst-strptime.c: removed tests which set a non-C
  locale. Broken usage of 'strptime()' result was fixed too.
  This test should succeed now.

* test/math.c: this test was added while working on the '%F/%G'
  patch and verifies the isinf() + isnan() functions.

* fixes lot of broken printf() format specifiers

* fixes tests using isinf(); the math.c test checks the dietlibc
  implementation of isinf() (which differs between positive and
  negative inf). All other tests use boolean retval only and test
  for the signess of the values
minor cleanups in stackgap.c