added and modified bionic code to support SuperH architecture
modified: libc/Android.mk
new files: libc/arch-sh/bionic/*
new files: libc/arch-sh/include/*
diff --git a/libc/arch-sh/include/endian.h b/libc/arch-sh/include/endian.h
new file mode 100644
index 0000000..ad10164
--- /dev/null
+++ b/libc/arch-sh/include/endian.h
@@ -0,0 +1,39 @@
+/* $OpenBSD: endian.h,v 1.1.1.1 2006/10/06 21:02:55 miod Exp $ */
+/* $NetBSD: endian.h,v 1.4 2000/03/17 00:09:25 mycroft Exp $ */
+
+/* Written by Manuel Bouyer. Public domain */
+
+#ifndef _SH_ENDIAN_H_
+#define _SH_ENDIAN_H_
+
+#ifdef __GNUC__
+
+#define __swap64md __swap64gen
+
+#define __swap16md(x) ({ \
+ uint16_t rval; \
+ \
+ __asm volatile ("swap.b %1,%0" : "=r"(rval) : "r"(x)); \
+ \
+ rval; \
+})
+
+#define __swap32md(x) ({ \
+ uint32_t rval; \
+ \
+ __asm volatile ("swap.b %1,%0; swap.w %0,%0; swap.b %0,%0" \
+ : "=r"(rval) : "r"(x)); \
+ \
+ rval; \
+})
+
+#define MD_SWAP
+
+#endif /* __GNUC_ */
+
+#define _BYTE_ORDER _LITTLE_ENDIAN
+#include <sys/endian.h>
+
+#define __STRICT_ALIGNMENT
+
+#endif /* !_SH_ENDIAN_H_ */
diff --git a/libc/arch-sh/include/machine/_types.h b/libc/arch-sh/include/machine/_types.h
new file mode 100644
index 0000000..6f59e21
--- /dev/null
+++ b/libc/arch-sh/include/machine/_types.h
@@ -0,0 +1,126 @@
+/* $OpenBSD: _types.h,v 1.6 2008/07/21 20:50:55 martynas Exp $ */
+
+/*-
+ * Copyright (c) 1990, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * 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. 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.
+ *
+ * @(#)types.h 8.3 (Berkeley) 1/5/94
+ * @(#)ansi.h 8.2 (Berkeley) 1/4/94
+ */
+
+#ifndef _SH__TYPES_H_
+#define _SH__TYPES_H_
+
+#if defined(_KERNEL)
+typedef struct label_t {
+ int val[9];
+} label_t;
+#endif
+
+/* 7.18.1.1 Exact-width integer types */
+typedef __signed char __int8_t;
+typedef unsigned char __uint8_t;
+typedef short __int16_t;
+typedef unsigned short __uint16_t;
+typedef int __int32_t;
+typedef unsigned int __uint32_t;
+/* LONGLONG */
+typedef long long __int64_t;
+/* LONGLONG */
+typedef unsigned long long __uint64_t;
+
+/* 7.18.1.2 Minimum-width integer types */
+typedef __int8_t __int_least8_t;
+typedef __uint8_t __uint_least8_t;
+typedef __int16_t __int_least16_t;
+typedef __uint16_t __uint_least16_t;
+typedef __int32_t __int_least32_t;
+typedef __uint32_t __uint_least32_t;
+typedef __int64_t __int_least64_t;
+typedef __uint64_t __uint_least64_t;
+
+/* 7.18.1.3 Fastest minimum-width integer types */
+typedef __int32_t __int_fast8_t;
+typedef __uint32_t __uint_fast8_t;
+typedef __int32_t __int_fast16_t;
+typedef __uint32_t __uint_fast16_t;
+typedef __int32_t __int_fast32_t;
+typedef __uint32_t __uint_fast32_t;
+typedef __int64_t __int_fast64_t;
+typedef __uint64_t __uint_fast64_t;
+
+/* 7.18.1.4 Integer types capable of holding object pointers */
+typedef long __intptr_t;
+typedef unsigned long __uintptr_t;
+
+/* 7.18.1.5 Greatest-width integer types */
+typedef __int64_t __intmax_t;
+typedef __uint64_t __uintmax_t;
+
+/* Register size */
+typedef __uint32_t __register_t;
+
+/* VM system types */
+typedef unsigned long __vaddr_t;
+typedef unsigned long __paddr_t;
+typedef unsigned long __vsize_t;
+typedef unsigned long __psize_t;
+
+/* Standard system types */
+typedef int __clock_t;
+typedef int __clockid_t;
+typedef double __double_t;
+typedef float __float_t;
+typedef long long __off_t;
+typedef long __ptrdiff_t;
+#if 0
+/* cut it off for Android-SH */
+typedef unsigned long __size_t;
+#endif
+typedef long __ssize_t;
+typedef int __time_t;
+typedef int __timer_t;
+#if defined(__GNUC__) && __GNUC__ >= 3
+typedef __builtin_va_list __va_list;
+#else
+struct __va_list_tag;
+typedef struct __va_list_tag * __va_list;
+#endif
+
+/* Wide character support types */
+#ifndef __cplusplus
+typedef int __wchar_t;
+#endif
+typedef int __wint_t;
+typedef int __rune_t;
+typedef void * __wctrans_t;
+typedef void * __wctype_t;
+
+/* Feature test macros */
+#define __HAVE_GENERIC_SOFT_INTERRUPTS
+
+#endif /* _SH__TYPES_H_ */
diff --git a/libc/arch-sh/include/machine/asm.h b/libc/arch-sh/include/machine/asm.h
new file mode 100644
index 0000000..c659a9d
--- /dev/null
+++ b/libc/arch-sh/include/machine/asm.h
@@ -0,0 +1,217 @@
+/* $OpenBSD: asm.h,v 1.1.1.1 2006/10/06 21:02:55 miod Exp $ */
+/* $NetBSD: asm.h,v 1.25 2006/01/20 22:02:40 christos Exp $ */
+
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * William Jolitz.
+ *
+ * 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. 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.
+ *
+ * @(#)asm.h 5.5 (Berkeley) 5/7/91
+ */
+
+#ifndef _SH_ASM_H_
+#define _SH_ASM_H_
+
+#ifdef __ELF__
+# define _C_LABEL(x) x
+#else
+#ifdef __STDC__
+# define _C_LABEL(x) _ ## x
+#else
+# define _C_LABEL(x) _/**/x
+#endif
+#endif
+#define _ASM_LABEL(x) x
+
+#ifdef __STDC__
+# define __CONCAT(x,y) x ## y
+# define __STRING(x) #x
+#else
+# define __CONCAT(x,y) x/**/y
+# define __STRING(x) "x"
+#endif
+
+/* let kernels and others override entrypoint alignment */
+#ifndef _ALIGN_TEXT
+# define _ALIGN_TEXT .align 2
+#endif
+
+#ifdef __ELF__
+#define _ENTRY(x) \
+ .text ;\
+ _ALIGN_TEXT ;\
+ .globl x ;\
+ .type x,@function ;\
+ x:
+#else /* !__ELF__ */
+#define _ENTRY(x) \
+ .text ;\
+ _ALIGN_TEXT ;\
+ .globl x ;\
+ x:
+#endif /* !__ELF__ */
+
+#ifdef GPROF
+#define _PROF_PROLOGUE \
+ mov.l 1f,r1 ; \
+ mova 2f,r0 ; \
+ jmp @r1 ; \
+ nop ; \
+ .align 2 ; \
+1: .long __mcount ; \
+2:
+#else /* !GPROF */
+#define _PROF_PROLOGUE
+#endif /* !GPROF */
+
+#define ENTRY(y) _ENTRY(_C_LABEL(y)) _PROF_PROLOGUE
+#define NENTRY(y) _ENTRY(_C_LABEL(y))
+#define ASENTRY(y) _ENTRY(_ASM_LABEL(y)) _PROF_PROLOGUE
+
+#define SET_ENTRY_SIZE(y) \
+ .size _C_LABEL(y), . - _C_LABEL(y)
+
+#define SET_ASENTRY_SIZE(y) \
+ .size _ASM_LABEL(y), . - _ASM_LABEL(y)
+
+#ifdef __ELF__
+#define ALTENTRY(name) \
+ .globl _C_LABEL(name) ;\
+ .type _C_LABEL(name),@function ;\
+ _C_LABEL(name):
+#else
+#define ALTENTRY(name) \
+ .globl _C_LABEL(name) ;\
+ _C_LABEL(name):
+#endif
+
+
+/*
+ * Hide the gory details of PIC calls vs. normal calls. Use as in the
+ * following example:
+ *
+ * sts.l pr, @-sp
+ * PIC_PROLOGUE(.L_got, r0) ! saves old r12 on stack
+ * ...
+ * mov.l .L_function_1, r0
+ * 1: CALL r0 ! each call site needs a label
+ * nop
+ * ...
+ * mov.l .L_function_2, r0
+ * 2: CALL r0
+ * nop
+ * ...
+ * PIC_EPILOGUE ! restores r12 from stack
+ * lds.l @sp+, pr ! so call in right order
+ * rts
+ * nop
+ *
+ * .align 2
+ * .L_got:
+ * PIC_GOT_DATUM
+ * .L_function_1: ! if you call the same function twice
+ * CALL_DATUM(function, 1b) ! provide call datum for each call
+ * .L_function_2:
+ * CALL_DATUM(function, 2b)
+ */
+
+#ifdef PIC
+
+#define PIC_PLT(x) x@PLT
+#define PIC_GOT(x) x@GOT
+#define PIC_GOTOFF(x) x@GOTOFF
+
+#define PIC_PROLOGUE(got) \
+ mov.l r12, @-sp; \
+ PIC_PROLOGUE_NOSAVE(got)
+
+/*
+ * Functions that do non local jumps don't need to preserve r12,
+ * so we can shave off two instructions to save/restore it.
+ */
+#define PIC_PROLOGUE_NOSAVE(got) \
+ mov.l got, r12; \
+ mova got, r0; \
+ add r0, r12
+
+#define PIC_EPILOGUE \
+ mov.l @sp+, r12
+
+#define PIC_EPILOGUE_SLOT \
+ PIC_EPILOGUE
+
+#define PIC_GOT_DATUM \
+ .long _GLOBAL_OFFSET_TABLE_
+
+#define CALL bsrf
+#define JUMP braf
+
+#define CALL_DATUM(function, lpcs) \
+ .long PIC_PLT(function) - ((lpcs) + 4 - (.))
+
+/*
+ * This will result in text relocations in the shared library,
+ * unless the function is local or has hidden or protected visibility.
+ * Does not require PIC prologue.
+ */
+#define CALL_DATUM_LOCAL(function, lpcs) \
+ .long function - ((lpcs) + 4)
+
+#else /* !PIC */
+
+#define PIC_PROLOGUE(label)
+#define PIC_PROLOGUE_NOSAVE(label)
+#define PIC_EPILOGUE
+#define PIC_EPILOGUE_SLOT nop
+#define PIC_GOT_DATUM
+
+#define CALL jsr @
+#define JUMP jmp @
+
+#define CALL_DATUM(function, lpcs) \
+ .long function
+
+#define CALL_DATUM_LOCAL(function, lpcs) \
+ .long function
+
+#endif /* !PIC */
+
+
+#define ASMSTR .asciz
+
+#ifdef __ELF__
+#define WEAK_ALIAS(alias,sym) \
+ .weak _C_LABEL(alias); \
+ _C_LABEL(alias) = _C_LABEL(sym)
+#endif
+
+#define WARN_REFERENCES(_sym,_msg) \
+ .section .gnu.warning._sym; .ascii _msg; .previous
+
+#endif /* !_SH_ASM_H_ */
diff --git a/libc/arch-sh/include/machine/exec.h b/libc/arch-sh/include/machine/exec.h
new file mode 100644
index 0000000..48a9680
--- /dev/null
+++ b/libc/arch-sh/include/machine/exec.h
@@ -0,0 +1,35 @@
+/* $OpenBSD: exec.h,v 1.2 2006/11/10 20:34:06 drahn Exp $ */
+/* $NetBSD: elf_machdep.h,v 1.8 2002/04/28 17:10:34 uch Exp $ */
+
+#define __LDPGSZ 4096
+
+#define NATIVE_EXEC_ELF
+
+#define ARCH_ELFSIZE 32 /* MD native binary size */
+#define ELF_TARG_CLASS ELFCLASS32
+#ifdef __LITTLE_ENDIAN__
+#define ELF_TARG_DATA ELFDATA2LSB
+#else
+#define ELF_TARG_DATA ELFDATA2MSB
+#endif
+#define ELF_TARG_MACH EM_SH
+
+#define _KERN_DO_ELF
+#define _NLIST_DO_ELF
+
+/*
+ * SuperH ELF header flags.
+ */
+#define EF_SH_MACH_MASK 0x1f
+
+#define EF_SH_UNKNOWN 0x00
+#define EF_SH_SH1 0x01
+#define EF_SH_SH2 0x02
+#define EF_SH_SH3 0x03
+#define EF_SH_DSP 0x04
+#define EF_SH_SH3_DSP 0x05
+#define EF_SH_SH3E 0x08
+#define EF_SH_SH4 0x09
+
+#define EF_SH_HAS_DSP(x) ((x) & EF_SH_DSP)
+#define EF_SH_HAS_FP(x) ((x) & EF_SH_SH3E)
diff --git a/libc/arch-sh/include/machine/ieee.h b/libc/arch-sh/include/machine/ieee.h
new file mode 100644
index 0000000..7646f85
--- /dev/null
+++ b/libc/arch-sh/include/machine/ieee.h
@@ -0,0 +1,132 @@
+/* $OpenBSD: ieee.h,v 1.2 2006/11/10 20:29:36 otto Exp $ */
+
+/*
+ * Copyright (c) 1992, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This software was developed by the Computer Systems Engineering group
+ * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
+ * contributed to Berkeley.
+ *
+ * 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, Lawrence Berkeley Laboratory.
+ *
+ * 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. 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.
+ *
+ * @(#)ieee.h 8.1 (Berkeley) 6/11/93
+ */
+
+/*
+ * ieee.h defines the machine-dependent layout of the machine's IEEE
+ * floating point. It does *not* define (yet?) any of the rounding
+ * mode bits, exceptions, and so forth.
+ */
+
+/*
+ * Define the number of bits in each fraction and exponent.
+ *
+ * k k+1
+ * Note that 1.0 x 2 == 0.1 x 2 and that denorms are represented
+ *
+ * (-exp_bias+1)
+ * as fractions that look like 0.fffff x 2 . This means that
+ *
+ * -126
+ * the number 0.10000 x 2 , for instance, is the same as the normalized
+ *
+ * -127 -128
+ * float 1.0 x 2 . Thus, to represent 2 , we need one leading zero
+ *
+ * -129
+ * in the fraction; to represent 2 , we need two, and so on. This
+ *
+ * (-exp_bias-fracbits+1)
+ * implies that the smallest denormalized number is 2
+ *
+ * for whichever format we are talking about: for single precision, for
+ *
+ * -126 -149
+ * instance, we get .00000000000000000000001 x 2 , or 1.0 x 2 , and
+ *
+ * -149 == -127 - 23 + 1.
+ */
+#define SNG_EXPBITS 8
+#define SNG_FRACBITS 23
+
+#define DBL_EXPBITS 11
+#define DBL_FRACBITS 52
+
+#define EXT_EXPBITS 15
+#define EXT_FRACBITS 112
+
+struct ieee_single {
+ u_int sng_frac:23;
+ u_int sng_exp:8;
+ u_int sng_sign:1;
+};
+
+struct ieee_double {
+ u_int dbl_fracl;
+ u_int dbl_frach:20;
+ u_int dbl_exp:11;
+ u_int dbl_sign:1;
+};
+
+struct ieee_ext {
+ u_int ext_sign:1;
+ u_int ext_exp:15;
+ u_int ext_frach:16;
+ u_int ext_frachm;
+ u_int ext_fraclm;
+ u_int ext_fracl;
+};
+
+/*
+ * Floats whose exponent is in [1..INFNAN) (of whatever type) are
+ * `normal'. Floats whose exponent is INFNAN are either Inf or NaN.
+ * Floats whose exponent is zero are either zero (iff all fraction
+ * bits are zero) or subnormal values.
+ *
+ * A NaN is a `signalling NaN' if its QUIETNAN bit is clear in its
+ * high fraction; if the bit is set, it is a `quiet NaN'.
+ */
+#define SNG_EXP_INFNAN 255
+#define DBL_EXP_INFNAN 2047
+#define EXT_EXP_INFNAN 32767
+
+#if 0
+#define SNG_QUIETNAN (1 << 22)
+#define DBL_QUIETNAN (1 << 19)
+#define EXT_QUIETNAN (1 << 15)
+#endif
+
+/*
+ * Exponent biases.
+ */
+#define SNG_EXP_BIAS 127
+#define DBL_EXP_BIAS 1023
+#define EXT_EXP_BIAS 16383
diff --git a/libc/arch-sh/include/machine/internal_types.h b/libc/arch-sh/include/machine/internal_types.h
new file mode 100644
index 0000000..ea9b7c4
--- /dev/null
+++ b/libc/arch-sh/include/machine/internal_types.h
@@ -0,0 +1,6 @@
+/* $OpenBSD: internal_types.h,v 1.1.1.1 2006/10/06 21:02:55 miod Exp $ */
+/* Public domain */
+#ifndef _SH_INTERNAL_TYPES_H_
+#define _SH_INTERNAL_TYPES_H_
+
+#endif
diff --git a/libc/arch-sh/include/machine/kernel.h b/libc/arch-sh/include/machine/kernel.h
new file mode 100644
index 0000000..948021a
--- /dev/null
+++ b/libc/arch-sh/include/machine/kernel.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2009 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 _ARCH_SH_KERNEL_H
+#define _ARCH_SH_KERNEL_H
+
+/* this file contains kernel-specific definitions that were optimized out of
+ our processed kernel headers, but still useful nonetheless... */
+
+typedef unsigned long __kernel_blkcnt_t;
+typedef unsigned long __kernel_blksize_t;
+
+/* these aren't really defined by the kernel headers though... */
+typedef unsigned long __kernel_fsblkcnt_t;
+typedef unsigned long __kernel_fsfilcnt_t;
+typedef unsigned int __kernel_id_t;
+
+#endif /* _ARCH_SH_KERNEL_H */
diff --git a/libc/arch-sh/include/machine/limits.h b/libc/arch-sh/include/machine/limits.h
new file mode 100644
index 0000000..d602138
--- /dev/null
+++ b/libc/arch-sh/include/machine/limits.h
@@ -0,0 +1,60 @@
+/* $OpenBSD: limits.h,v 1.1.1.1 2006/10/06 21:02:55 miod Exp $ */
+/* $NetBSD: limits.h,v 1.1 1996/09/30 16:34:28 ws Exp $ */
+
+/*-
+ * Copyright (C) 1995, 1996 Wolfgang Solfrank.
+ * Copyright (C) 1995, 1996 TooLs GmbH.
+ * All rights reserved.
+ *
+ * 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 TooLs GmbH.
+ * 4. The name of TooLs GmbH may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``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 TOOLS GMBH 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 _SH_LIMITS_H_
+#define _SH_LIMITS_H_
+
+#include <sys/cdefs.h>
+
+#define MB_LEN_MAX 1 /* no multibyte characters */
+
+#ifndef SIZE_MAX
+#define SIZE_MAX UINT_MAX /* max value for a size_t */
+#endif
+#define SSIZE_MAX INT_MAX /* max value for a ssize_t */
+
+#if __BSD_VISIBLE
+#define SIZE_T_MAX UINT_MAX /* max value for a size_t (historic) */
+
+#define UQUAD_MAX 0xffffffffffffffffULL /* max unsigned quad */
+#define QUAD_MAX 0x7fffffffffffffffLL /* max signed quad */
+#define QUAD_MIN (-0x7fffffffffffffffLL-1) /* min signed quad */
+#endif /* __BSD_VISIBLE */
+
+#define LONGLONG_BIT 64
+#define LONGLONG_MIN (-9223372036854775807LL-1)
+#define LONGLONG_MAX 9223372036854775807LL
+#define ULONGLONG_MAX 18446744073709551615ULL
+
+#endif /* _SH_LIMITS_H_ */
diff --git a/libc/arch-sh/include/machine/setjmp.h b/libc/arch-sh/include/machine/setjmp.h
new file mode 100644
index 0000000..014ad3e
--- /dev/null
+++ b/libc/arch-sh/include/machine/setjmp.h
@@ -0,0 +1,7 @@
+/* $OpenBSD: setjmp.h,v 1.2 2007/03/02 06:11:54 miod Exp $ */
+/* $NetBSD: setjmp.h,v 1.3 2006/01/05 00:50:23 uwe Exp $ */
+
+/*
+ * machine/setjmp.h: machine dependent setjmp-related information.
+ */
+