aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2011-09-24 18:21:58 -0700
committerAlon Zakai <alonzakai@gmail.com>2011-09-24 18:21:58 -0700
commit2f11f2e15392069a3c4a72fef2358fbf722b4e0e (patch)
tree7aadb70939ccfa84575b44e0ee714d891666efc7
parentec318d92f2c5f645eab561efc461941405071131 (diff)
start to include system headers (tests broken)
-rwxr-xr-xemscripten.py2
-rw-r--r--system/include/_ansi.h133
-rw-r--r--system/include/_syslist.h40
-rw-r--r--system/include/alloca.h21
-rw-r--r--system/include/ar.h69
-rw-r--r--system/include/argz.h33
-rw-r--r--system/include/assert.h46
-rw-r--r--system/include/complex.h124
-rw-r--r--system/include/ctype.h113
-rw-r--r--system/include/dirent.h15
-rw-r--r--system/include/envlock.h15
-rw-r--r--system/include/envz.h16
-rw-r--r--system/include/errno.h11
-rw-r--r--system/include/fastmath.h13
-rw-r--r--system/include/fcntl.h1
-rw-r--r--system/include/fnmatch.h55
-rw-r--r--system/include/getopt.h190
-rw-r--r--system/include/glob.h89
-rw-r--r--system/include/grp.h94
-rw-r--r--system/include/iconv.h62
-rw-r--r--system/include/ieeefp.h256
-rw-r--r--system/include/inttypes.h290
-rw-r--r--system/include/langinfo.h316
-rw-r--r--system/include/libgen.h23
-rw-r--r--system/include/limits.h146
-rw-r--r--system/include/locale.h65
-rw-r--r--system/include/malloc.h169
-rw-r--r--system/include/math.h580
-rw-r--r--system/include/newlib.h2
-rw-r--r--system/include/paths.h7
-rw-r--r--system/include/process.h44
-rw-r--r--system/include/pthread.h359
-rw-r--r--system/include/pwd.h78
-rw-r--r--system/include/readme.txt3
-rw-r--r--system/include/reent.h183
-rw-r--r--system/include/regdef.h7
-rw-r--r--system/include/regex.h102
-rw-r--r--system/include/sched.h97
-rw-r--r--system/include/search.h59
-rw-r--r--system/include/setjmp.h20
-rw-r--r--system/include/signal.h30
-rw-r--r--system/include/stdarg.h50
-rw-r--r--system/include/stddef.h64
-rw-r--r--system/include/stdint.h493
-rw-r--r--system/include/stdio.h685
-rw-r--r--system/include/stdlib.h226
-rw-r--r--system/include/string.h104
-rw-r--r--system/include/strings.h35
-rw-r--r--system/include/tar.h39
-rw-r--r--system/include/termios.h7
-rw-r--r--system/include/time.h261
-rw-r--r--system/include/unctrl.h46
-rw-r--r--system/include/unistd.h6
-rw-r--r--system/include/utime.h12
-rw-r--r--system/include/utmp.h8
-rw-r--r--system/include/wchar.h192
-rw-r--r--system/include/wctype.h47
-rw-r--r--system/include/wordexp.h53
-rw-r--r--tests/runner.py2
-rwxr-xr-xtools/emmaken.py2
-rw-r--r--tools/shared.py4
61 files changed, 6311 insertions, 3 deletions
diff --git a/emscripten.py b/emscripten.py
index 40a09904..ecfb04fc 100755
--- a/emscripten.py
+++ b/emscripten.py
@@ -101,7 +101,7 @@ def compile_malloc():
"""
src = path_from_root('src', 'dlmalloc.c')
includes = '-I' + path_from_root('src', 'include')
- command = [shared.CLANG, '-c', '-g', '-emit-llvm', '-m32'] + shared.COMPILER_OPTS + ['-o-', includes, src]
+ command = [shared.CLANG, '-c', '-g', '-emit-llvm'] + shared.COMPILER_OPTS + ['-o-', includes, src]
with get_temp_file('.bc') as out: ret = subprocess.call(command, stdout=out)
if ret != 0: raise RuntimeError('Could not compile dlmalloc.')
return out.name
diff --git a/system/include/_ansi.h b/system/include/_ansi.h
new file mode 100644
index 00000000..e584ec38
--- /dev/null
+++ b/system/include/_ansi.h
@@ -0,0 +1,133 @@
+/* Provide support for both ANSI and non-ANSI environments. */
+
+/* Some ANSI environments are "broken" in the sense that __STDC__ cannot be
+ relied upon to have it's intended meaning. Therefore we must use our own
+ concoction: _HAVE_STDC. Always use _HAVE_STDC instead of __STDC__ in newlib
+ sources!
+
+ To get a strict ANSI C environment, define macro __STRICT_ANSI__. This will
+ "comment out" the non-ANSI parts of the ANSI header files (non-ANSI header
+ files aren't affected). */
+
+#ifndef _ANSIDECL_H_
+#define _ANSIDECL_H_
+
+#include <newlib.h>
+#include <sys/config.h>
+
+/* First try to figure out whether we really are in an ANSI C environment. */
+/* FIXME: This probably needs some work. Perhaps sys/config.h can be
+ prevailed upon to give us a clue. */
+
+#ifdef __STDC__
+#define _HAVE_STDC
+#endif
+
+/* ISO C++. */
+
+#ifdef __cplusplus
+#if !(defined(_BEGIN_STD_C) && defined(_END_STD_C))
+#ifdef _HAVE_STD_CXX
+#define _BEGIN_STD_C namespace std { extern "C" {
+#define _END_STD_C } }
+#else
+#define _BEGIN_STD_C extern "C" {
+#define _END_STD_C }
+#endif
+#if defined(__GNUC__) && \
+ ( (__GNUC__ >= 4) || \
+ ( (__GNUC__ >= 3) && defined(__GNUC_MINOR__) && (__GNUC_MINOR__ >= 3) ) )
+#define _NOTHROW __attribute__ ((nothrow))
+#else
+#define _NOTHROW throw()
+#endif
+#endif
+#else
+#define _BEGIN_STD_C
+#define _END_STD_C
+#define _NOTHROW
+#endif
+
+#ifdef _HAVE_STDC
+#define _PTR void *
+#define _AND ,
+#define _NOARGS void
+#define _CONST const
+#define _VOLATILE volatile
+#define _SIGNED signed
+#define _DOTS , ...
+#define _VOID void
+#ifdef __CYGWIN__
+#define _EXFUN_NOTHROW(name, proto) __cdecl name proto _NOTHROW
+#define _EXFUN(name, proto) __cdecl name proto
+#define _EXPARM(name, proto) (* __cdecl name) proto
+#define _EXFNPTR(name, proto) (__cdecl * name) proto
+#else
+#define _EXFUN_NOTHROW(name, proto) name proto _NOTHROW
+#define _EXFUN(name, proto) name proto
+#define _EXPARM(name, proto) (* name) proto
+#define _EXFNPTR(name, proto) (* name) proto
+#endif
+#define _DEFUN(name, arglist, args) name(args)
+#define _DEFUN_VOID(name) name(_NOARGS)
+#define _CAST_VOID (void)
+#ifndef _LONG_DOUBLE
+#define _LONG_DOUBLE long double
+#endif
+#ifndef _LONG_LONG_TYPE
+#define _LONG_LONG_TYPE long long
+#endif
+#ifndef _PARAMS
+#define _PARAMS(paramlist) paramlist
+#endif
+#else
+#define _PTR char *
+#define _AND ;
+#define _NOARGS
+#define _CONST
+#define _VOLATILE
+#define _SIGNED
+#define _DOTS
+#define _VOID void
+#define _EXFUN(name, proto) name()
+#define _EXFUN_NOTHROW(name, proto) name()
+#define _DEFUN(name, arglist, args) name arglist args;
+#define _DEFUN_VOID(name) name()
+#define _CAST_VOID
+#define _LONG_DOUBLE double
+#define _LONG_LONG_TYPE long
+#ifndef _PARAMS
+#define _PARAMS(paramlist) ()
+#endif
+#endif
+
+/* Support gcc's __attribute__ facility. */
+
+#ifdef __GNUC__
+#define _ATTRIBUTE(attrs) __attribute__ (attrs)
+#else
+#define _ATTRIBUTE(attrs)
+#endif
+
+/* The traditional meaning of 'extern inline' for GCC is not
+ to emit the function body unless the address is explicitly
+ taken. However this behaviour is changing to match the C99
+ standard, which uses 'extern inline' to indicate that the
+ function body *must* be emitted. If we are using GCC, but do
+ not have the new behaviour, we need to use extern inline; if
+ we are using a new GCC with the C99-compatible behaviour, or
+ a non-GCC compiler (which we will have to hope is C99, since
+ there is no other way to achieve the effect of omitting the
+ function if it isn't referenced) we just use plain 'inline',
+ which c99 defines to mean more-or-less the same as the Gnu C
+ 'extern inline'. */
+#if defined(__GNUC__) && !defined(__GNUC_STDC_INLINE__)
+/* We're using GCC, but without the new C99-compatible behaviour. */
+#define _ELIDABLE_INLINE extern __inline__ _ATTRIBUTE ((__always_inline__))
+#else
+/* We're using GCC in C99 mode, or an unknown compiler which
+ we just have to hope obeys the C99 semantics of inline. */
+#define _ELIDABLE_INLINE __inline__
+#endif
+
+#endif /* _ANSIDECL_H_ */
diff --git a/system/include/_syslist.h b/system/include/_syslist.h
new file mode 100644
index 00000000..271644ef
--- /dev/null
+++ b/system/include/_syslist.h
@@ -0,0 +1,40 @@
+/* internal use only -- mapping of "system calls" for libraries that lose
+ and only provide C names, so that we end up in violation of ANSI */
+#ifndef __SYSLIST_H
+#define __SYSLIST_H
+
+#ifdef MISSING_SYSCALL_NAMES
+#define _close close
+#define _execve execve
+#define _fcntl fcntl
+#define _fork fork
+#define _fstat fstat
+#define _getpid getpid
+#define _gettimeofday gettimeofday
+#define _isatty isatty
+#define _kill kill
+#define _link link
+#define _lseek lseek
+#define _mkdir mkdir
+#define _open open
+#define _read read
+#define _sbrk sbrk
+#define _stat stat
+#define _times times
+#define _unlink unlink
+#define _wait wait
+#define _write write
+#endif /* MISSING_SYSCALL_NAMES */
+
+#if defined MISSING_SYSCALL_NAMES || !defined HAVE_OPENDIR
+/* If the system call interface is missing opendir, readdir, and
+ closedir, there is an implementation of these functions in
+ libc/posix that is implemented using open, getdents, and close.
+ Note, these functions are currently not in the libc/syscalls
+ directory. */
+#define _opendir opendir
+#define _readdir readdir
+#define _closedir closedir
+#endif /* MISSING_SYSCALL_NAMES || !HAVE_OPENDIR */
+
+#endif /* !__SYSLIST_H_ */
diff --git a/system/include/alloca.h b/system/include/alloca.h
new file mode 100644
index 00000000..2ea0fd9b
--- /dev/null
+++ b/system/include/alloca.h
@@ -0,0 +1,21 @@
+/* libc/include/alloca.h - Allocate memory on stack */
+
+/* Written 2000 by Werner Almesberger */
+/* Rearranged for general inclusion by stdlib.h.
+ 2001, Corinna Vinschen <vinschen@redhat.com> */
+
+#ifndef _NEWLIB_ALLOCA_H
+#define _NEWLIB_ALLOCA_H
+
+#include "_ansi.h"
+#include <sys/reent.h>
+
+#undef alloca
+
+#ifdef __GNUC__
+#define alloca(size) __builtin_alloca(size)
+#else
+void * _EXFUN(alloca,(size_t));
+#endif
+
+#endif
diff --git a/system/include/ar.h b/system/include/ar.h
new file mode 100644
index 00000000..ac2e4ca9
--- /dev/null
+++ b/system/include/ar.h
@@ -0,0 +1,69 @@
+/* $NetBSD: ar.h,v 1.4 1994/10/26 00:55:43 cgd Exp $ */
+
+/*-
+ * Copyright (c) 1991, 1993
+ * The Regents of the University of California. All rights reserved.
+ * (c) UNIX System Laboratories, Inc.
+ * All or some portions of this file are derived from material licensed
+ * to the University of California by American Telephone and Telegraph
+ * Co. or Unix System Laboratories, Inc. and are reproduced herein with
+ * the permission of UNIX System Laboratories, Inc.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Hugh Smith at The University of Guelph.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
+ *
+ * @(#)ar.h 8.2 (Berkeley) 1/21/94
+ */
+
+#ifndef _AR_H_
+#define _AR_H_
+
+/* Pre-4BSD archives had these magic numbers in them. */
+#define OARMAG1 0177555
+#define OARMAG2 0177545
+
+#define ARMAG "!<arch>\n" /* ar "magic number" */
+#define SARMAG 8 /* strlen(ARMAG); */
+
+#define AR_EFMT1 "#1/" /* extended format #1 */
+
+struct ar_hdr {
+ char ar_name[16]; /* name */
+ char ar_date[12]; /* modification time */
+ char ar_uid[6]; /* user id */
+ char ar_gid[6]; /* group id */
+ char ar_mode[8]; /* octal file permissions */
+ char ar_size[10]; /* size in bytes */
+#define ARFMAG "`\n"
+ char ar_fmag[2]; /* consistency check */
+};
+
+#endif /* !_AR_H_ */
diff --git a/system/include/argz.h b/system/include/argz.h
new file mode 100644
index 00000000..02c9adbf
--- /dev/null
+++ b/system/include/argz.h
@@ -0,0 +1,33 @@
+/* Copyright (C) 2002 by Red Hat, Incorporated. All rights reserved.
+ *
+ * Permission to use, copy, modify, and distribute this software
+ * is freely granted, provided that this notice is preserved.
+ */
+
+#ifndef _ARGZ_H_
+#define _ARGZ_H_
+
+#include <errno.h>
+#include <sys/types.h>
+
+#include "_ansi.h"
+
+_BEGIN_STD_C
+
+/* The newlib implementation of these functions assumes that sizeof(char) == 1. */
+error_t argz_create (char *const argv[], char **argz, size_t *argz_len);
+error_t argz_create_sep (const char *string, int sep, char **argz, size_t *argz_len);
+size_t argz_count (const char *argz, size_t argz_len);
+void argz_extract (char *argz, size_t argz_len, char **argv);
+void argz_stringify (char *argz, size_t argz_len, int sep);
+error_t argz_add (char **argz, size_t *argz_len, const char *str);
+error_t argz_add_sep (char **argz, size_t *argz_len, const char *str, int sep);
+error_t argz_append (char **argz, size_t *argz_len, const char *buf, size_t buf_len);
+error_t argz_delete (char **argz, size_t *argz_len, char *entry);
+error_t argz_insert (char **argz, size_t *argz_len, char *before, const char *entry);
+char * argz_next (char *argz, size_t argz_len, const char *entry);
+error_t argz_replace (char **argz, size_t *argz_len, const char *str, const char *with, unsigned *replace_count);
+
+_END_STD_C
+
+#endif /* _ARGZ_H_ */
diff --git a/system/include/assert.h b/system/include/assert.h
new file mode 100644
index 00000000..e542b214
--- /dev/null
+++ b/system/include/assert.h
@@ -0,0 +1,46 @@
+/*
+ assert.h
+*/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "_ansi.h"
+
+#undef assert
+
+#ifdef NDEBUG /* required by ANSI standard */
+# define assert(__e) ((void)0)
+#else
+# define assert(__e) ((__e) ? (void)0 : __assert_func (__FILE__, __LINE__, \
+ __ASSERT_FUNC, #__e))
+
+# ifndef __ASSERT_FUNC
+ /* Use g++'s demangled names in C++. */
+# if defined __cplusplus && defined __GNUC__
+# define __ASSERT_FUNC __PRETTY_FUNCTION__
+
+ /* C99 requires the use of __func__. */
+# elif __STDC_VERSION__ >= 199901L
+# define __ASSERT_FUNC __func__
+
+ /* Older versions of gcc don't have __func__ but can use __FUNCTION__. */
+# elif __GNUC__ >= 2
+# define __ASSERT_FUNC __FUNCTION__
+
+ /* failed to detect __func__ support. */
+# else
+# define __ASSERT_FUNC ((char *) 0)
+# endif
+# endif /* !__ASSERT_FUNC */
+#endif /* !NDEBUG */
+
+void _EXFUN(__assert, (const char *, int, const char *)
+ _ATTRIBUTE ((__noreturn__)));
+void _EXFUN(__assert_func, (const char *, int, const char *, const char *)
+ _ATTRIBUTE ((__noreturn__)));
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/system/include/complex.h b/system/include/complex.h
new file mode 100644
index 00000000..d5ce5f87
--- /dev/null
+++ b/system/include/complex.h
@@ -0,0 +1,124 @@
+/* $NetBSD: complex.h,v 1.3 2010/09/15 16:11:30 christos Exp $ */
+
+/*
+ * Written by Matthias Drochner.
+ * Public domain.
+ */
+
+#ifndef _COMPLEX_H
+#define _COMPLEX_H
+
+#define complex _Complex
+#define _Complex_I 1.0fi
+#define I _Complex_I
+
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+
+/* 7.3.5 Trigonometric functions */
+/* 7.3.5.1 The cacos functions */
+double complex cacos(double complex);
+float complex cacosf(float complex);
+
+/* 7.3.5.2 The casin functions */
+double complex casin(double complex);
+float complex casinf(float complex);
+
+/* 7.3.5.1 The catan functions */
+double complex catan(double complex);
+float complex catanf(float complex);
+
+/* 7.3.5.1 The ccos functions */
+double complex ccos(double complex);
+float complex ccosf(float complex);
+
+/* 7.3.5.1 The csin functions */
+double complex csin(double complex);
+float complex csinf(float complex);
+
+/* 7.3.5.1 The ctan functions */
+double complex ctan(double complex);
+float complex ctanf(float complex);
+
+/* 7.3.6 Hyperbolic functions */
+/* 7.3.6.1 The cacosh functions */
+double complex cacosh(double complex);
+float complex cacoshf(float complex);
+
+/* 7.3.6.2 The casinh functions */
+double complex casinh(double complex);
+float complex casinhf(float complex);
+
+/* 7.3.6.3 The catanh functions */
+double complex catanh(double complex);
+float complex catanhf(float complex);
+
+/* 7.3.6.4 The ccosh functions */
+double complex ccosh(double complex);
+float complex ccoshf(float complex);
+
+/* 7.3.6.5 The csinh functions */
+double complex csinh(double complex);
+float complex csinhf(float complex);
+
+/* 7.3.6.6 The ctanh functions */
+double complex ctanh(double complex);
+float complex ctanhf(float complex);
+
+/* 7.3.7 Exponential and logarithmic functions */
+/* 7.3.7.1 The cexp functions */
+double complex cexp(double complex);
+float complex cexpf(float complex);
+
+/* 7.3.7.2 The clog functions */
+double complex clog(double complex);
+float complex clogf(float complex);
+
+/* 7.3.8 Power and absolute-value functions */
+/* 7.3.8.1 The cabs functions */
+/*#ifndef __LIBM0_SOURCE__
+/* avoid conflict with historical cabs(struct complex) */
+/* double cabs(double complex) __RENAME(__c99_cabs);
+ float cabsf(float complex) __RENAME(__c99_cabsf);
+ #endif
+*/
+double cabs(double complex) ;
+float cabsf(float complex) ;
+
+/* 7.3.8.2 The cpow functions */
+double complex cpow(double complex, double complex);
+float complex cpowf(float complex, float complex);
+
+/* 7.3.8.3 The csqrt functions */
+double complex csqrt(double complex);
+float complex csqrtf(float complex);
+
+/* 7.3.9 Manipulation functions */
+/* 7.3.9.1 The carg functions */
+double carg(double complex);
+float cargf(float complex);
+
+/* 7.3.9.2 The cimag functions */
+double cimag(double complex);
+float cimagf(float complex);
+/*long double cimagl(long double complex); */
+
+/* 7.3.9.3 The conj functions */
+double complex conj(double complex);
+float complex conjf(float complex);
+/*long double complex conjl(long double complex); */
+
+/* 7.3.9.4 The cproj functions */
+double complex cproj(double complex);
+float complex cprojf(float complex);
+/*long double complex cprojl(long double complex); */
+
+/* 7.3.9.5 The creal functions */
+double creal(double complex);
+float crealf(float complex);
+/*long double creall(long double complex); */
+
+__END_DECLS
+
+#endif /* ! _COMPLEX_H */
diff --git a/system/include/ctype.h b/system/include/ctype.h
new file mode 100644
index 00000000..56ad5abb
--- /dev/null
+++ b/system/include/ctype.h
@@ -0,0 +1,113 @@
+#ifndef _CTYPE_H_
+#define _CTYPE_H_
+
+#include "_ansi.h"
+
+_BEGIN_STD_C
+
+int _EXFUN(isalnum, (int __c));
+int _EXFUN(isalpha, (int __c));
+int _EXFUN(iscntrl, (int __c));
+int _EXFUN(isdigit, (int __c));
+int _EXFUN(isgraph, (int __c));
+int _EXFUN(islower, (int __c));
+int _EXFUN(isprint, (int __c));
+int _EXFUN(ispunct, (int __c));
+int _EXFUN(isspace, (int __c));
+int _EXFUN(isupper, (int __c));
+int _EXFUN(isxdigit,(int __c));
+int _EXFUN(tolower, (int __c));
+int _EXFUN(toupper, (int __c));
+
+#if !defined(__STRICT_ANSI__) || defined(__cplusplus) || __STDC_VERSION__ >= 199901L
+int _EXFUN(isblank, (int __c));
+#endif
+
+#ifndef __STRICT_ANSI__
+int _EXFUN(isascii, (int __c));
+int _EXFUN(toascii, (int __c));
+#define _tolower(__c) ((unsigned char)(__c) - 'A' + 'a')
+#define _toupper(__c) ((unsigned char)(__c) - 'a' + 'A')
+#endif
+
+#define _U 01
+#define _L 02
+#define _N 04
+#define _S 010
+#define _P 020
+#define _C 040
+#define _X 0100
+#define _B 0200
+
+#ifndef _MB_CAPABLE
+_CONST
+#endif
+extern __IMPORT char *__ctype_ptr__;
+
+#ifndef __cplusplus
+/* These macros are intentionally written in a manner that will trigger
+ a gcc -Wall warning if the user mistakenly passes a 'char' instead
+ of an int containing an 'unsigned char'. Note that the sizeof will
+ always be 1, which is what we want for mapping EOF to __ctype_ptr__[0];
+ the use of a raw index inside the sizeof triggers the gcc warning if
+ __c was of type char, and sizeof masks side effects of the extra __c.
+ Meanwhile, the real index to __ctype_ptr__+1 must be cast to int,
+ since isalpha(0x100000001LL) must equal isalpha(1), rather than being
+ an out-of-bounds reference on a 64-bit machine. */
+#define __ctype_lookup(__c) ((__ctype_ptr__+sizeof(""[__c]))[(int)(__c)])
+
+#define isalpha(__c) (__ctype_lookup(__c)&(_U|_L))
+#define isupper(__c) ((__ctype_lookup(__c)&(_U|_L))==_U)
+#define islower(__c) ((__ctype_lookup(__c)&(_U|_L))==_L)
+#define isdigit(__c) (__ctype_lookup(__c)&_N)
+#define isxdigit(__c) (__ctype_lookup(__c)&(_X|_N))
+#define isspace(__c) (__ctype_lookup(__c)&_S)
+#define ispunct(__c) (__ctype_lookup(__c)&_P)
+#define isalnum(__c) (__ctype_lookup(__c)&(_U|_L|_N))
+#define isprint(__c) (__ctype_lookup(__c)&(_P|_U|_L|_N|_B))
+#define isgraph(__c) (__ctype_lookup(__c)&(_P|_U|_L|_N))
+#define iscntrl(__c) (__ctype_lookup(__c)&_C)
+
+#if defined(__GNUC__) && \
+ (!defined(__STRICT_ANSI__) || __STDC_VERSION__ >= 199901L)
+#define isblank(__c) \
+ __extension__ ({ __typeof__ (__c) __x = (__c); \
+ (__ctype_lookup(__x)&_B) || (int) (__x) == '\t';})
+#endif
+
+
+/* Non-gcc versions will get the library versions, and will be
+ slightly slower. These macros are not NLS-aware so they are
+ disabled if the system supports the extended character sets. */
+# if defined(__GNUC__)
+# if !defined (_MB_EXTENDED_CHARSET