auto import from //branches/cupcake/...@126645
diff --git a/libc/include/stdio.h b/libc/include/stdio.h
index b3b0adf..79e526b 100644
--- a/libc/include/stdio.h
+++ b/libc/include/stdio.h
@@ -41,6 +41,16 @@
 #include <sys/cdefs.h>
 #include <sys/_types.h>
 
+/* va_list and size_t must be defined by stdio.h according to Posix */
+#define __need___va_list
+#include <stdarg.h>
+
+/* note that this forces stddef.h to *only* define size_t */
+#define __need_size_t
+#include <stddef.h>
+
+#include <stddef.h>
+
 #if __BSD_VISIBLE || __POSIX_VISIBLE || __XPG_VISIBLE
 #include <sys/types.h>	/* XXX should be removed */
 #endif
diff --git a/libc/include/stdlib.h b/libc/include/stdlib.h
index a821e03..acfe694 100644
--- a/libc/include/stdlib.h
+++ b/libc/include/stdlib.h
@@ -29,6 +29,13 @@
 #define _STDLIB_H_
 
 #include <sys/cdefs.h>
+
+/* wchar_t is required in stdlib.h according to POSIX.
+ * note that defining __need_wchar_t prevents stddef.h
+ * to define all other symbols it does normally */
+#define __need_wchar_t
+#include <stddef.h>
+
 #include <stddef.h>
 #include <string.h>
 #include <alloca.h>
diff --git a/libc/include/sys/android/atomics.h b/libc/include/sys/android/atomics.h
deleted file mode 100644
index 75017b9..0000000
--- a/libc/include/sys/android/atomics.h
+++ /dev/null
@@ -1 +0,0 @@
-#include <sys/atomics.h>
\ No newline at end of file
diff --git a/libc/include/sys/android/tls.h b/libc/include/sys/android/tls.h
deleted file mode 100644
index 274ac35..0000000
--- a/libc/include/sys/android/tls.h
+++ /dev/null
@@ -1 +0,0 @@
-#include <sys/tls.h>
diff --git a/libc/include/sys/stat.h b/libc/include/sys/stat.h
index 7ab0f82..5e6363f 100644
--- a/libc/include/sys/stat.h
+++ b/libc/include/sys/stat.h
@@ -77,6 +77,10 @@
 extern int    mknod(const char *, mode_t, dev_t);
 extern mode_t umask(mode_t);
 
+#define  stat64    stat
+#define  fstat64   fstat
+#define  lstat64   lstat
+
 static __inline__ int mkfifo(const char *__p, mode_t __m)
 {
   return mknod(__p, (__m & ~S_IFMT) | S_IFIFO, (dev_t)0);
diff --git a/libc/include/sys/tls.h b/libc/include/sys/tls.h
deleted file mode 100644
index da34344..0000000
--- a/libc/include/sys/tls.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-#ifndef _SYS_TLS_H
-#define _SYS_TLS_H
-
-#include <sys/cdefs.h>
-
-__BEGIN_DECLS
-
-/** WARNING WARNING WARNING
- **
- ** This header file is *NOT* part of the public Bionic ABI/API
- ** and should not be used/included by user-serviceable parts of
- ** the system (e.g. applications).
- **
- ** It is only provided here for the benefit of the system dynamic
- ** linker and the OpenGL sub-system (which needs to access the
- ** pre-allocated slot directly for performance reason).
- **/
-
-/* maximum number of elements in the TLS array */
-#define BIONIC_TLS_SLOTS            64
-
-/* note that slot 0, called TLS_SLOT_SELF must point to itself.
- * this is required to implement thread-local storage with the x86
- * Linux kernel, that reads the TLS from fs:[0], where 'fs' is a
- * thread-specific segment descriptor...
- */
-
-/* Well known TLS slots */
-#define TLS_SLOT_SELF               0
-#define TLS_SLOT_THREAD_ID          1
-#define TLS_SLOT_ERRNO              2
-
-#define TLS_SLOT_OPENGL_API         3
-#define TLS_SLOT_OPENGL             4
-
-/* small technical note: it is not possible to call pthread_setspecific
- * on keys that are <= TLS_SLOT_MAX_WELL_KNOWN, which is why it is set to
- * TLS_SLOT_ERRNO.
- *
- * later slots like TLS_SLOT_OPENGL are pre-allocated through the use of
- * TLS_DEFAULT_ALLOC_MAP. this means that there is no need to use
- * pthread_key_create() to initialize them. on the other hand, there is
- * no destructor associated to them (we might need to implement this later)
- */
-#define TLS_SLOT_MAX_WELL_KNOWN     TLS_SLOT_ERRNO
-
-#define TLS_DEFAULT_ALLOC_MAP       0x0000001F
-
-/* set the Thread Local Storage, must contain at least BIONIC_TLS_SLOTS pointers */
-extern void __init_tls(void**  tls, void*  thread_info);
-
-/* syscall only, do not call directly */
-extern int __set_tls(void *ptr);
-
-/* get the TLS */
-#ifdef __arm__
-#  define __get_tls() ( *((volatile void **) 0xffff0ff0) )
-#else
-extern void*  __get_tls( void );
-#endif
-
-/* return the stack base and size, used by our malloc debugger */
-extern void*  __get_stack_base(int  *p_stack_size);
-
-__END_DECLS
-
-#endif /* _SYS_TLS_H */
diff --git a/libc/include/wchar.h b/libc/include/wchar.h
index 3dadc98..e2feb60 100644
--- a/libc/include/wchar.h
+++ b/libc/include/wchar.h
@@ -30,11 +30,17 @@
 
 #include <sys/cdefs.h>
 #include <stdio.h>
+
+/* wchar_t is required in stdlib.h according to POSIX */
+#define __need___wchar_t
 #include <stddef.h>
+
 #include <stdarg.h>
 #include <time.h>
 #include <malloc.h>
 
+#include <stddef.h>
+
 /* IMPORTANT: Any code that relies on wide character support is essentially
  *            non-portable and/or broken. the only reason this header exist
  *            is because I'm really a nice guy. However, I'm not nice enough
@@ -44,11 +50,6 @@
 
 __BEGIN_DECLS
 
-#ifndef __cplusplus
-/* wchar_t is a builtin keyword of g++ */
-typedef unsigned char            wchar_t;
-#endif
-
 typedef int                     wint_t;
 typedef struct { int  dummy; }  mbstate_t;