summaryrefslogtreecommitdiff
path: root/klibc/include/arch
diff options
context:
space:
mode:
Diffstat (limited to 'klibc/include/arch')
-rw-r--r--klibc/include/arch/alpha/klibc/archsetjmp.h33
-rw-r--r--klibc/include/arch/alpha/klibc/archsignal.h13
-rw-r--r--klibc/include/arch/alpha/klibc/archstat.h26
-rw-r--r--klibc/include/arch/alpha/klibc/archsys.h53
-rw-r--r--klibc/include/arch/alpha/machine/asm.h44
-rw-r--r--klibc/include/arch/arm/klibc/archsetjmp.h14
-rw-r--r--klibc/include/arch/arm/klibc/archsignal.h13
-rw-r--r--klibc/include/arch/arm/klibc/archstat.h45
-rw-r--r--klibc/include/arch/arm/klibc/archsys.h12
-rw-r--r--klibc/include/arch/cris/klibc/archsetjmp.h24
-rw-r--r--klibc/include/arch/cris/klibc/archsignal.h13
-rw-r--r--klibc/include/arch/cris/klibc/archstat.h37
-rw-r--r--klibc/include/arch/cris/klibc/archsys.h12
-rw-r--r--klibc/include/arch/i386/klibc/archsetjmp.h19
-rw-r--r--klibc/include/arch/i386/klibc/archsignal.h13
-rw-r--r--klibc/include/arch/i386/klibc/archstat.h37
-rw-r--r--klibc/include/arch/i386/klibc/archsys.h12
-rw-r--r--klibc/include/arch/i386/klibc/diverr.h16
-rw-r--r--klibc/include/arch/i386/sys/io.h126
-rw-r--r--klibc/include/arch/i386/sys/vm86.h41
-rw-r--r--klibc/include/arch/ia64/klibc/archsetjmp.h17
-rw-r--r--klibc/include/arch/ia64/klibc/archsignal.h31
-rw-r--r--klibc/include/arch/ia64/klibc/archstat.h24
-rw-r--r--klibc/include/arch/ia64/klibc/archsys.h218
-rw-r--r--klibc/include/arch/m68k/klibc/archsignal.h13
-rw-r--r--klibc/include/arch/m68k/klibc/archstat.h37
-rw-r--r--klibc/include/arch/m68k/klibc/archsys.h12
-rw-r--r--klibc/include/arch/mips/klibc/archfcntl.h87
-rw-r--r--klibc/include/arch/mips/klibc/archsetjmp.h39
-rw-r--r--klibc/include/arch/mips/klibc/archsignal.h13
-rw-r--r--klibc/include/arch/mips/klibc/archstat.h39
-rw-r--r--klibc/include/arch/mips/klibc/archsys.h12
-rw-r--r--klibc/include/arch/mips/machine/asm.h11
-rw-r--r--klibc/include/arch/mips/sgidefs.h20
-rw-r--r--klibc/include/arch/mips/spaces.h1
-rw-r--r--klibc/include/arch/mips64/klibc/archsignal.h13
-rw-r--r--klibc/include/arch/mips64/klibc/archstat.h33
-rw-r--r--klibc/include/arch/mips64/klibc/archsys.h12
-rw-r--r--klibc/include/arch/parisc/klibc/archsignal.h24
-rw-r--r--klibc/include/arch/parisc/klibc/archstat.h27
-rw-r--r--klibc/include/arch/parisc/klibc/archsys.h12
-rw-r--r--klibc/include/arch/ppc/klibc/archsetjmp.h36
-rw-r--r--klibc/include/arch/ppc/klibc/archsignal.h13
-rw-r--r--klibc/include/arch/ppc/klibc/archstat.h28
-rw-r--r--klibc/include/arch/ppc/klibc/archsys.h61
-rw-r--r--klibc/include/arch/ppc64/klibc/archsetjmp.h36
-rw-r--r--klibc/include/arch/ppc64/klibc/archsignal.h13
-rw-r--r--klibc/include/arch/ppc64/klibc/archstat.h25
-rw-r--r--klibc/include/arch/ppc64/klibc/archsys.h52
-rw-r--r--klibc/include/arch/s390/klibc/archsetjmp.h15
-rw-r--r--klibc/include/arch/s390/klibc/archsignal.h13
-rw-r--r--klibc/include/arch/s390/klibc/archstat.h31
-rw-r--r--klibc/include/arch/s390/klibc/archsys.h41
-rw-r--r--klibc/include/arch/s390x/klibc/archsetjmp.h15
-rw-r--r--klibc/include/arch/s390x/klibc/archsignal.h13
-rw-r--r--klibc/include/arch/s390x/klibc/archstat.h24
-rw-r--r--klibc/include/arch/s390x/klibc/archsys.h41
-rw-r--r--klibc/include/arch/sh/klibc/archsetjmp.h22
-rw-r--r--klibc/include/arch/sh/klibc/archsignal.h13
-rw-r--r--klibc/include/arch/sh/klibc/archstat.h45
-rw-r--r--klibc/include/arch/sh/klibc/archsys.h12
-rw-r--r--klibc/include/arch/sparc/klibc/archsetjmp.h16
-rw-r--r--klibc/include/arch/sparc/klibc/archsignal.h13
-rw-r--r--klibc/include/arch/sparc/klibc/archstat.h35
-rw-r--r--klibc/include/arch/sparc/klibc/archsys.h10
-rw-r--r--klibc/include/arch/sparc/machine/asm.h192
-rw-r--r--klibc/include/arch/sparc/machine/frame.h138
-rw-r--r--klibc/include/arch/sparc/machine/trap.h141
-rw-r--r--klibc/include/arch/sparc64/klibc/archsetjmp.h16
-rw-r--r--klibc/include/arch/sparc64/klibc/archsignal.h13
-rw-r--r--klibc/include/arch/sparc64/klibc/archstat.h22
-rw-r--r--klibc/include/arch/sparc64/klibc/archsys.h10
-rw-r--r--klibc/include/arch/x86_64/klibc/archsetjmp.h21
-rw-r--r--klibc/include/arch/x86_64/klibc/archsignal.h13
-rw-r--r--klibc/include/arch/x86_64/klibc/archstat.h26
-rw-r--r--klibc/include/arch/x86_64/klibc/archsys.h109
-rw-r--r--klibc/include/arch/x86_64/sys/io.h126
77 files changed, 2748 insertions, 0 deletions
diff --git a/klibc/include/arch/alpha/klibc/archsetjmp.h b/klibc/include/arch/alpha/klibc/archsetjmp.h
new file mode 100644
index 0000000000..9dc570a6f5
--- /dev/null
+++ b/klibc/include/arch/alpha/klibc/archsetjmp.h
@@ -0,0 +1,33 @@
+/*
+ * arch/alpha/include/klibc/archsetjmp.h
+ */
+
+#ifndef _KLIBC_ARCHSETJMP_H
+#define _KLIBC_ARCHSETJMP_H
+
+struct __jmp_buf {
+ unsigned long __s0;
+ unsigned long __s1;
+ unsigned long __s2;
+ unsigned long __s3;
+ unsigned long __s4;
+ unsigned long __s5;
+ unsigned long __fp;
+ unsigned long __ra;
+ unsigned long __gp;
+ unsigned long __sp;
+
+ unsigned long __f2;
+ unsigned long __f3;
+ unsigned long __f4;
+ unsigned long __f5;
+ unsigned long __f6;
+ unsigned long __f7;
+ unsigned long __f8;
+ unsigned long __f9;
+};
+
+/* Must be an array so it will decay to a pointer when a function is called */
+typedef struct __jmp_buf jmp_buf[1];
+
+#endif /* _KLIBC_ARCHSETJMP_H */
diff --git a/klibc/include/arch/alpha/klibc/archsignal.h b/klibc/include/arch/alpha/klibc/archsignal.h
new file mode 100644
index 0000000000..b870a05131
--- /dev/null
+++ b/klibc/include/arch/alpha/klibc/archsignal.h
@@ -0,0 +1,13 @@
+/*
+ * arch/alpha/include/klibc/archsignal.h
+ *
+ * Architecture-specific signal definitions
+ *
+ */
+
+#ifndef _KLIBC_ARCHSIGNAL_H
+#define _KLIBC_ARCHSIGNAL_H
+
+/* No special stuff for this architecture */
+
+#endif
diff --git a/klibc/include/arch/alpha/klibc/archstat.h b/klibc/include/arch/alpha/klibc/archstat.h
new file mode 100644
index 0000000000..23302d737d
--- /dev/null
+++ b/klibc/include/arch/alpha/klibc/archstat.h
@@ -0,0 +1,26 @@
+#ifndef _KLIBC_ARCHSTAT_H
+#define _KLIBC_ARCHSTAT_H
+
+#define _STATBUF_ST_NSEC
+
+struct stat {
+ unsigned long st_dev;
+ unsigned long st_ino;
+ unsigned long st_rdev;
+ long st_size;
+ unsigned long st_blocks;
+
+ unsigned int st_mode;
+ unsigned int st_uid;
+ unsigned int st_gid;
+ unsigned int st_blksize;
+ unsigned int st_nlink;
+ unsigned int __pad0;
+
+ struct timespec st_atim;
+ struct timespec st_mtim;
+ struct timespec st_ctim;
+ long __unused[3];
+};
+
+#endif
diff --git a/klibc/include/arch/alpha/klibc/archsys.h b/klibc/include/arch/alpha/klibc/archsys.h
new file mode 100644
index 0000000000..16ed658987
--- /dev/null
+++ b/klibc/include/arch/alpha/klibc/archsys.h
@@ -0,0 +1,53 @@
+/*
+ * arch/alpha/include/klibc/archsys.h
+ *
+ * Architecture-specific syscall definitions
+ */
+
+#ifndef _KLIBC_ARCHSYS_H
+#define _KLIBC_ARCHSYS_H
+
+/* Alpha has some bizarre Tru64-derived system calls which return two
+ different values in $0 and $20(!), respectively. The standard
+ macros can't deal with these; even the ones that give the right
+ return value have the wrong clobbers. */
+
+#define _syscall0_dual0(type, name) \
+type name(void) \
+{ \
+ long _sc_ret, _sc_err; \
+ { \
+ register long _sc_0 __asm__("$0"); \
+ register long _sc_19 __asm__("$19"); \
+ register long _sc_20 __asm__("$20"); \
+ \
+ _sc_0 = __NR_##name; \
+ __asm__("callsys" \
+ : "=r"(_sc_0), "=r"(_sc_19), "=r" (_sc_20) \
+ : "0"(_sc_0) \
+ : _syscall_clobbers); \
+ _sc_ret = _sc_0, _sc_err = _sc_19; (void)(_sc_20); \
+ } \
+ _syscall_return(type); \
+}
+
+#define _syscall0_dual1(type, name) \
+type name(void) \
+{ \
+ long _sc_ret, _sc_err; \
+ { \
+ register long _sc_0 __asm__("$0"); \
+ register long _sc_19 __asm__("$19"); \
+ register long _sc_20 __asm__("$20"); \
+ \
+ _sc_0 = __NR_##name; \
+ __asm__("callsys" \
+ : "=r"(_sc_0), "=r"(_sc_19), "=r" (_sc_20) \
+ : "0"(_sc_0) \
+ : _syscall_clobbers); \
+ _sc_ret = _sc_20, _sc_err = _sc_19; (void)(_sc_0); \
+ } \
+ _syscall_return(type); \
+}
+
+#endif /* _KLIBC_ARCHSYS_H */
diff --git a/klibc/include/arch/alpha/machine/asm.h b/klibc/include/arch/alpha/machine/asm.h
new file mode 100644
index 0000000000..e22db90412
--- /dev/null
+++ b/klibc/include/arch/alpha/machine/asm.h
@@ -0,0 +1,44 @@
+/*
+ * machine/asm.h
+ */
+
+#ifndef _MACHINE_ASM_H
+#define _MACHINE_ASM_H
+
+/* Standard aliases for Alpha register names */
+
+#define v0 $0
+#define t0 $1
+#define t1 $2
+#define t2 $3
+#define t3 $4
+#define t4 $5
+#define t5 $6
+#define t6 $7
+#define t7 $8
+#define s0 $9
+#define s1 $10
+#define s2 $11
+#define s3 $12
+#define s4 $13
+#define s5 $14
+#define fp $15
+#define a0 $16
+#define a1 $17
+#define a2 $18
+#define a3 $19
+#define a4 $20
+#define a5 $21
+#define t8 $22
+#define t9 $23
+#define t10 $24
+#define t11 $25
+#define ra $26
+#define t12 $27 /* t12 and pv are both used for $27 */
+#define pv $27 /* t12 and pv are both used for $27 */
+#define at $28
+#define gp $29
+#define sp $30
+#define zero $31
+
+#endif /* _MACHINE_ASM_H */
diff --git a/klibc/include/arch/arm/klibc/archsetjmp.h b/klibc/include/arch/arm/klibc/archsetjmp.h
new file mode 100644
index 0000000000..c956b50a90
--- /dev/null
+++ b/klibc/include/arch/arm/klibc/archsetjmp.h
@@ -0,0 +1,14 @@
+/*
+ * arch/i386/include/klibc/archsetjmp.h
+ */
+
+#ifndef _KLIBC_ARCHSETJMP_H
+#define _KLIBC_ARCHSETJMP_H
+
+struct __jmp_buf {
+ unsigned int regs[10];
+};
+
+typedef struct __jmp_buf jmp_buf[1];
+
+#endif /* _SETJMP_H */
diff --git a/klibc/include/arch/arm/klibc/archsignal.h b/klibc/include/arch/arm/klibc/archsignal.h
new file mode 100644
index 0000000000..77685e62f0
--- /dev/null
+++ b/klibc/include/arch/arm/klibc/archsignal.h
@@ -0,0 +1,13 @@
+/*
+ * arch/arm/include/klibc/archsignal.h
+ *
+ * Architecture-specific signal definitions
+ *
+ */
+
+#ifndef _KLIBC_ARCHSIGNAL_H
+#define _KLIBC_ARCHSIGNAL_H
+
+/* No special stuff for this architecture */
+
+#endif
diff --git a/klibc/include/arch/arm/klibc/archstat.h b/klibc/include/arch/arm/klibc/archstat.h
new file mode 100644
index 0000000000..42b1409f67
--- /dev/null
+++ b/klibc/include/arch/arm/klibc/archstat.h
@@ -0,0 +1,45 @@
+#ifndef _KLIBC_ARCHSTAT_H
+#define _KLIBC_ARCHSTAT_H
+
+#include <endian.h>
+
+#define _STATBUF_ST_NSEC
+
+/* This matches struct stat64 in glibc2.1, hence the absolutely
+ * insane amounts of padding around dev_t's.
+ * Note: The kernel zero's the padded region because glibc might read them
+ * in the hope that the kernel has stretched to using larger sizes.
+ */
+struct stat {
+ unsigned long long st_dev;
+ unsigned char __pad0[4];
+
+ unsigned long __st_ino;
+ unsigned int st_mode;
+ unsigned int st_nlink;
+
+ unsigned long st_uid;
+ unsigned long st_gid;
+
+ unsigned long long st_rdev;
+ unsigned char __pad3[4];
+
+ long long st_size;
+ unsigned long st_blksize;
+
+#if __BYTE_ORDER == __BIG_ENDIAN
+ unsigned long __pad4; /* Future possible st_blocks hi bits */
+ unsigned long st_blocks; /* Number 512-byte blocks allocated. */
+#else /* Must be little */
+ unsigned long st_blocks; /* Number 512-byte blocks allocated. */
+ unsigned long __pad4; /* Future possible st_blocks hi bits */
+#endif
+
+ struct timespec st_atim;
+ struct timespec st_mtim;
+ struct timespec st_ctim;
+
+ unsigned long long st_ino;
+};
+
+#endif
diff --git a/klibc/include/arch/arm/klibc/archsys.h b/klibc/include/arch/arm/klibc/archsys.h
new file mode 100644
index 0000000000..dfdc70a6de
--- /dev/null
+++ b/klibc/include/arch/arm/klibc/archsys.h
@@ -0,0 +1,12 @@
+/*
+ * arch/cris/include/klibc/archsys.h
+ *
+ * Architecture-specific syscall definitions
+ */
+
+#ifndef _KLIBC_ARCHSYS_H
+#define _KLIBC_ARCHSYS_H
+
+/* No special syscall definitions for this architecture */
+
+#endif /* _KLIBC_ARCHSYS_H */
diff --git a/klibc/include/arch/cris/klibc/archsetjmp.h b/klibc/include/arch/cris/klibc/archsetjmp.h
new file mode 100644
index 0000000000..8d20800609
--- /dev/null
+++ b/klibc/include/arch/cris/klibc/archsetjmp.h
@@ -0,0 +1,24 @@
+/*
+ * arch/cris/include/klibc/archsetjmp.h
+ */
+
+#ifndef _KLIBC_ARCHSETJMP_H
+#define _KLIBC_ARCHSETJMP_H
+
+struct __jmp_buf {
+ unsigned long __r0;
+ unsigned long __r1;
+ unsigned long __r2;
+ unsigned long __r3;
+ unsigned long __r4;
+ unsigned long __r5;
+ unsigned long __r6;
+ unsigned long __r7;
+ unsigned long __r8;
+ unsigned long __sp;
+ unsigned long __srp;
+};
+
+typedef struct __jmp_buf jmp_buf[1];
+
+#endif /* _KLIBC_ARCHSETJMP_H */
diff --git a/klibc/include/arch/cris/klibc/archsignal.h b/klibc/include/arch/cris/klibc/archsignal.h
new file mode 100644
index 0000000000..73b2e196c9
--- /dev/null
+++ b/klibc/include/arch/cris/klibc/archsignal.h
@@ -0,0 +1,13 @@
+/*
+ * arch/cris/include/klibc/archsignal.h
+ *
+ * Architecture-specific signal definitions
+ *
+ */
+
+#ifndef _KLIBC_ARCHSIGNAL_H
+#define _KLIBC_ARCHSIGNAL_H
+
+/* No special stuff for this architecture */
+
+#endif
diff --git a/klibc/include/arch/cris/klibc/archstat.h b/klibc/include/arch/cris/klibc/archstat.h
new file mode 100644
index 0000000000..154820755f
--- /dev/null
+++ b/klibc/include/arch/cris/klibc/archstat.h
@@ -0,0 +1,37 @@
+#ifndef _KLIBC_ARCHSTAT_H
+#define _KLIBC_ARCHSTAT_H
+
+#define _STATBUF_ST_NSEC
+
+/* This matches struct stat64 in glibc2.1, hence the absolutely
+ * insane amounts of padding around dev_t's.
+ */
+struct stat {
+ unsigned long long st_dev;
+ unsigned char __pad0[4];
+
+ unsigned long __st_ino;
+
+ unsigned int st_mode;
+ unsigned int st_nlink;
+
+ unsigned long st_uid;
+ unsigned long st_gid;
+
+ unsigned long long st_rdev;
+ unsigned char __pad3[4];
+
+ long long st_size;
+ unsigned long st_blksize;
+
+ unsigned long st_blocks; /* Number 512-byte blocks allocated. */
+ unsigned long __pad4; /* future possible st_blocks high bits */
+
+ struct timespec st_atim;
+ struct timespec st_mtim;
+ struct timespec st_ctim;
+
+ unsigned long long st_ino;
+};
+
+#endif
diff --git a/klibc/include/arch/cris/klibc/archsys.h b/klibc/include/arch/cris/klibc/archsys.h
new file mode 100644
index 0000000000..dfdc70a6de
--- /dev/null
+++ b/klibc/include/arch/cris/klibc/archsys.h
@@ -0,0 +1,12 @@
+/*
+ * arch/cris/include/klibc/archsys.h
+ *
+ * Architecture-specific syscall definitions
+ */
+
+#ifndef _KLIBC_ARCHSYS_H
+#define _KLIBC_ARCHSYS_H
+
+/* No special syscall definitions for this architecture */
+
+#endif /* _KLIBC_ARCHSYS_H */
diff --git a/klibc/include/arch/i386/klibc/archsetjmp.h b/klibc/include/arch/i386/klibc/archsetjmp.h
new file mode 100644
index 0000000000..db04314b8c
--- /dev/null
+++ b/klibc/include/arch/i386/klibc/archsetjmp.h
@@ -0,0 +1,19 @@
+/*
+ * arch/i386/include/klibc/archsetjmp.h
+ */
+
+#ifndef _KLIBC_ARCHSETJMP_H
+#define _KLIBC_ARCHSETJMP_H
+
+struct __jmp_buf {
+ unsigned int __ebx;
+ unsigned int __esp;
+ unsigned int __ebp;
+ unsigned int __esi;
+ unsigned int __edi;
+ unsigned int __eip;
+};
+
+typedef struct __jmp_buf jmp_buf[1];
+
+#endif /* _SETJMP_H */
diff --git a/klibc/include/arch/i386/klibc/archsignal.h b/klibc/include/arch/i386/klibc/archsignal.h
new file mode 100644
index 0000000000..b092ba6d3a
--- /dev/null
+++ b/klibc/include/arch/i386/klibc/archsignal.h
@@ -0,0 +1,13 @@
+/*
+ * arch/i386/include/klibc/archsignal.h
+ *
+ * Architecture-specific signal definitions
+ *
+ */
+
+#ifndef _KLIBC_ARCHSIGNAL_H
+#define _KLIBC_ARCHSIGNAL_H
+
+/* No special stuff for this architecture */
+
+#endif
diff --git a/klibc/include/arch/i386/klibc/archstat.h b/klibc/include/arch/i386/klibc/archstat.h
new file mode 100644
index 0000000000..154820755f
--- /dev/null
+++ b/klibc/include/arch/i386/klibc/archstat.h
@@ -0,0 +1,37 @@
+#ifndef _KLIBC_ARCHSTAT_H
+#define _KLIBC_ARCHSTAT_H
+
+#define _STATBUF_ST_NSEC
+
+/* This matches struct stat64 in glibc2.1, hence the absolutely
+ * insane amounts of padding around dev_t's.
+ */
+struct stat {
+ unsigned long long st_dev;
+ unsigned char __pad0[4];
+
+ unsigned long __st_ino;
+
+ unsigned int st_mode;
+ unsigned int st_nlink;
+
+ unsigned long st_uid;
+ unsigned long st_gid;
+
+ unsigned long long st_rdev;
+ unsigned char __pad3[4];
+
+ long long st_size;
+ unsigned long st_blksize;
+
+ unsigned long st_blocks; /* Number 512-byte blocks allocated. */
+ unsigned long __pad4; /* future possible st_blocks high bits */
+
+ struct timespec st_atim;
+ struct timespec st_mtim;
+ struct timespec st_ctim;
+
+ unsigned long long st_ino;
+};
+
+#endif
diff --git a/klibc/include/arch/i386/klibc/archsys.h b/klibc/include/arch/i386/klibc/archsys.h
new file mode 100644
index 0000000000..dfdc70a6de
--- /dev/null
+++ b/klibc/include/arch/i386/klibc/archsys.h
@@ -0,0 +1,12 @@
+/*
+ * arch/cris/include/klibc/archsys.h
+ *
+ * Architecture-specific syscall definitions
+ */
+
+#ifndef _KLIBC_ARCHSYS_H
+#define _KLIBC_ARCHSYS_H
+
+/* No special syscall definitions for this architecture */
+
+#endif /* _KLIBC_ARCHSYS_H */
diff --git a/klibc/include/arch/i386/klibc/diverr.h b/klibc/include/arch/i386/klibc/diverr.h
new file mode 100644
index 0000000000..410aba06d3
--- /dev/null
+++ b/klibc/include/arch/i386/klibc/diverr.h
@@ -0,0 +1,16 @@
+/*
+ * arch/i386/include/klibc/diverr.h
+ */
+
+#ifndef _KLIBC_DIVERR_H
+#define _KLIBC_DIVERR_H
+
+#include <signal.h>
+
+static __inline__ void
+__divide_error(void)
+{
+ asm volatile("divl %0" :: "rm" (0) : "eax", "edx");
+}
+
+#endif /* _KLIBC_DIVERR_H */
diff --git a/klibc/include/arch/i386/sys/io.h b/klibc/include/arch/i386/sys/io.h
new file mode 100644
index 0000000000..b051464dfc
--- /dev/null
+++ b/klibc/include/arch/i386/sys/io.h
@@ -0,0 +1,126 @@
+#ident "$Id: io.h,v 1.2 2004/01/25 07:49:39 hpa Exp $"
+/* ----------------------------------------------------------------------- *
+ *
+ * Copyright 2004 H. Peter Anvin - All Rights Reserved
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall
+ * be included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * ----------------------------------------------------------------------- */
+
+/*
+ * sys/io.h for the i386 architecture
+ *
+ * Basic I/O macros
+ */
+
+#ifndef _SYS_IO_H
+#define _SYS_IO_H 1
+
+/* I/O-related system calls */
+
+int iopl(int);
+int ioperm(unsigned long, unsigned long, int);
+
+/* Basic I/O macros */
+
+static __inline__ void
+outb(unsigned char __v, unsigned short __p)
+{
+ asm volatile("outb %0,%1" : : "a" (__v), "dN" (__p));
+}
+
+static __inline__ void
+outw(unsigned short __v, unsigned short __p)
+{
+ asm volatile("outw %0,%1" : : "a" (__v), "dN" (__p));
+}
+
+static __inline__ void
+outl(unsigned int __v, unsigned short __p)
+{
+ asm volatile("outl %0,%1" : : "a" (__v), "dN" (__p));
+}
+
+static __inline__ unsigned char
+inb(unsigned short __p)
+{
+ unsigned char __v;
+ asm volatile("inb %1,%0" : "=a" (__v) : "dN" (__p));
+ return __v;
+}
+
+static __inline__ unsigned short
+inw(unsigned short __p)
+{
+ unsigned short __v;
+ asm volatile("inw %1,%0" : "=a" (__v) : "dN" (__p));
+ return __v;
+}
+
+static __inline__ unsigned int
+inl(unsigned short __p)
+{
+ unsigned int __v;
+ asm volatile("inl %1,%0" : "=a" (__v) : "dN" (__p));
+ return __v;
+}
+
+/* String I/O macros */
+
+static __inline__ void
+outsb (unsigned short __p, const void *__d, unsigned long __n)
+{
+ asm volatile("cld; rep; outsb" : "+S" (__d), "+c" (__n) : "d" (__p));
+}
+
+static __inline__ void
+outsw (unsigned short __p, const void *__d, unsigned long __n)
+{
+ asm volatile("cld; rep; outsw" : "+S" (__d), "+c" (__n) : "d" (__p));
+}
+
+static __inline__ void
+outsl (unsigned short __p, const void *__d, unsigned long __n)
+{
+ asm volatile("cld; rep; outsl" : "+S" (__d), "+c" (__n) : "d" (__p));
+}
+
+
+static __inline__ void
+insb (unsigned short __p, void *__d, unsigned long __n)
+{
+ asm volatile("cld; rep; insb" : "+D" (__d), "+c" (__n) : "d" (__p));
+}
+
+static __inline__ void
+insw (unsigned short __p, void *__d, unsigned long __n)
+{
+ asm volatile("cld; rep; insw" : "+D" (__d), "+c" (__n) : "d" (__p));
+}
+
+static __inline__ void
+insl (unsigned short __p, void *__d, unsigned long __n)
+{
+ asm volatile("cld; rep; insl" : "+D" (__d), "+c" (__n) : "d" (__p));
+}
+
+#endif /* _SYS_IO_H */
diff --git a/klibc/include/arch/i386/sys/vm86.h b/klibc/include/arch/i386/sys/vm86.h
new file mode 100644
index 0000000000..d3272393dc
--- /dev/null
+++ b/klibc/include/arch/i386/sys/vm86.h
@@ -0,0 +1,41 @@
+#ident "$Id: vm86.h,v 1.1 2004/01/25 01:34:28 hpa Exp $"
+/* ----------------------------------------------------------------------- *
+ *
+ * Copyright 2004 H. Peter Anvin - All Rights Reserved
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall
+ * be included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * ----------------------------------------------------------------------- */
+
+/*
+ * sys/vm86.h for i386
+ */
+
+#ifndef _SYS_VM86_H
+#define _SYS_VM86_H 1
+
+#include <asm/vm86.h>
+
+/* Actual system call */
+int vm86(struct vm86_struct *);
+
+#endif
diff --git a/klibc/include/arch/ia64/klibc/archsetjmp.h b/klibc/include/arch/ia64/klibc/archsetjmp.h
new file mode 100644
index 0000000000..bd639c0b00
--- /dev/null
+++ b/klibc/include/arch/ia64/klibc/archsetjmp.h
@@ -0,0 +1,17 @@
+/*
+ * arch/ia64/include/klibc/archsetjmp.h
+ *
+ * Code borrowed from the FreeBSD kernel.
+ *
+ */
+
+#ifndef _KLIBC_ARCHSETJMP_H
+#define _KLIBC_ARCHSETJMP_H
+
+/* User code must not depend on the internal representation of jmp_buf. */
+#define _JBLEN 0x200
+
+/* guaranteed 128-bit alignment! */
+typedef char jmp_buf[_JBLEN] __attribute__ ((aligned (16)));
+
+#endif
diff --git a/klibc/include/arch/ia64/klibc/archsignal.h b/klibc/include/arch/ia64/klibc/archsignal.h
new file mode 100644
index 0000000000..5b01f19bc2
--- /dev/null
+++ b/klibc/include/arch/ia64/klibc/archsignal.h
@@ -0,0 +1,31 @@
+/*
+ * arch/ia64/include/klibc/archsignal.h
+ *
+ * Architecture-specific signal definitions.
+ *
+ */
+
+#ifndef _KLIBC_ARCHSIGNAL_H
+#define _KLIBC_ARCHSIGNAL_H
+
+#define _NSIG 64
+#define _NSIG_BPW 64
+#define _NSIG_WORDS (_NSIG / _NSIG_BPW)
+
+typedef struct {
+ unsigned long sig[_NSIG_WORDS];
+} sigset_t;
+
+struct sigaction {
+ union {
+ __sighandler_t _sa_handler;
+ void (*_sa_sigaction)(int, struct siginfo *, void *);
+ } _u;
+ sigset_t sa_mask;
+ int sa_flags;
+};
+
+#define sa_handler _u._sa_handler
+#define sa_sigaction _u._sa_sigaction
+
+#endif
diff --git a/klibc/include/arch/ia64/klibc/archstat.h b/klibc/include/arch/ia64/klibc/archstat.h
new file mode 100644
index 0000000000..9475c0b797
--- /dev/null
+++ b/klibc/include/arch/ia64/klibc/archstat.h
@@ -0,0 +1,24 @@
+#ifndef _KLIBC_ARCHSTAT_H
+#define _KLIBC_ARCHSTAT_H
+
+#define _STATBUF_ST_NSEC
+
+struct stat {
+ unsigned long st_dev;
+ unsigned long st_ino;
+ unsigned long st_nlink;
+ unsigned int st_mode;
+ unsigned int st_uid;
+ unsigned int st_gid;
+ unsigned int __pad0;
+ unsigned long st_rdev;
+ unsigned long st_size;
+ struct timespec st_atim;
+ struct timespec st_mtim;
+ struct timespec st_ctim;
+ unsigned long st_blksize;
+ long st_blocks;
+ unsigned long __unused[3];
+};
+
+#endif
diff --git a/klibc/include/arch/ia64/klibc/archsys.h b/klibc/include/arch/ia64/klibc/archsys.h
new file mode 100644
index 0000000000..4c795a43ca
--- /dev/null
+++ b/klibc/include/arch/ia64/klibc/archsys.h
@@ -0,0 +1,218 @@
+/*
+ * arch/ia64/include/klibc/archsys.h
+ *
+ * Architecture-specific syscall definitions
+ */
+
+#ifndef _KLIBC_ARCHSYS_H
+#define _KLIBC_ARCHSYS_H
+
+#define __IA64_BREAK "break 0x100000;;\n\t"
+
+#define _syscall0(type,name) \
+type \
+name (void) \
+{ \
+ register long _r8 asm ("r8"); \
+ register long _r10 asm ("r10"); \
+ register long _r15 asm ("r15") = __NR_##name; \
+ long _retval; \
+ __asm __volatile (__IA64_BREAK \
+ : "=r" (_r8), "=r" (_r10), "=r" (_r15) \
+ : "2" (_r15) ASM_ARGS_0 \
+ : "memory" ASM_CLOBBERS_0); \
+ _retval = _r8; \
+ if (_r10 == -1) { \
+ errno = (_retval); \
+ _retval = -1; \
+ } \
+ return (type)_retval; \
+}
+
+#define _syscall1(type,name,type1,arg1) \
+type \
+name (type1 arg1) \
+{ \
+ register long _r8 asm ("r8"); \
+ register long _r10 asm ("r10"); \
+ register long _r15 asm ("r15") = __NR_##name; \
+ long _retval; \
+ LOAD_ARGS_1(arg1); \
+ __asm __volatile (__IA64_BREAK \
+ : "=r" (_r8), "=r" (_r10), "=r" (_r15), \
+ ASM_OUTARGS_1 \
+ : "2" (_r15) ASM_ARGS_1 \
+ : "memory" ASM_CLOBBERS_1); \
+ _retval = _r8; \
+ if (_r10 == -1) { \
+ errno = (_retval); \
+ _retval = -1; \
+ } \
+ return (type)_retval; \
+}
+
+#define _syscall2(type,name,type1,arg1,type2,arg2) \
+type \
+name (type1 arg1, type2 arg2) \
+{ \
+ register long _r8 asm ("r8"); \
+ register long _r10 asm ("r10"); \
+ register long _r15 asm ("r15") = __NR_##name; \
+ long _retval; \
+ LOAD_ARGS_2(arg1, arg2); \
+ __asm __volatile (__IA64_BREAK \
+ : "=r" (_r8), "=r" (_r10), "=r" (_r15), \
+ ASM_OUTARGS_2 \
+ : "2" (_r15) ASM_ARGS_2 \
+ : "memory" ASM_CLOBBERS_2); \
+ _retval = _r8; \
+ if (_r10 == -1) { \
+ errno = (_retval); \
+ _retval = -1; \
+ } \
+ return (type)_retval; \
+}
+
+#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
+type \
+name (type1 arg1, type2 arg2, type3 arg3) \
+{ \
+ register long _r8 asm ("r8"); \
+ register long _r10 asm ("r10"); \
+ register long _r15 asm ("r15") = __NR_##name; \
+ long _retval; \
+ LOAD_ARGS_3(arg1, arg2, arg3); \
+ __asm __volatile (__IA64_BREAK \
+ : "=r" (_r8), "=r" (_r10), "=r" (_r15), \
+ ASM_OUTARGS_3 \
+ : "2" (_r15) ASM_ARGS_3 \
+ : "memory" ASM_CLOBBERS_3); \
+ _retval = _r8; \
+ if (_r10 == -1) { \
+ errno = (_retval); \
+ _retval = -1; \
+ } \
+ return (type)_retval; \
+}
+
+#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
+type \
+name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
+{ \
+ register long _r8 asm ("r8"); \
+ register long _r10 asm ("r10"); \
+ register long _r15 asm ("r15") = __NR_##name; \
+ long _retval; \
+ LOAD_ARGS_4(arg1, arg2, arg3, arg4); \
+ __asm __volatile (__IA64_BREAK \
+ : "=r" (_r8), "=r" (_r10), "=r" (_r15), \
+ ASM_OUTARGS_4 \
+ : "2" (_r15) ASM_ARGS_4 \
+ : "memory" ASM_CLOBBERS_4); \
+ _retval = _r8; \
+ if (_r10 == -1) { \
+ errno = (_retval); \
+ _retval = -1; \
+ } \
+ return (type)_retval; \
+}
+
+#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5) \
+type \
+name (type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5) \
+{ \
+ register long _r8 asm ("r8"); \
+ register long _r10 asm ("r10"); \
+ register long _r15 asm ("r15") = __NR_##name; \
+ long _retval; \
+ LOAD_ARGS_5(arg1, arg2, arg3, arg4, arg5); \
+ __asm __volatile (__IA64_BREAK \
+ : "=r" (_r8), "=r" (_r10), "=r" (_r15), \
+ ASM_OUTARGS_5 \
+ : "2" (_r15) ASM_ARGS_5 \
+ : "memory" ASM_CLOBBERS_5); \
+ _retval = _r8; \
+ if (_r10 == -1) { \
+ errno = (_retval); \
+ _retval = -1; \
+ } \
+ return (type)_retval; \
+}
+
+#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5,type6,arg6) \
+type \
+name (type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5, type6 arg6) \
+{ \
+ register long _r8 asm ("r8"); \
+ register long _r10 asm ("r10"); \
+ register long _r15 asm ("r15") = __NR_##name; \
+ long _retval; \
+ LOAD_ARGS_6(arg1, arg2, arg3, arg4, arg5, arg6); \
+ __asm __volatile (__IA64_BREAK \
+ : "=r" (_r8), "=r" (_r10), "=r" (_r15), \
+ ASM_OUTARGS_6 \
+ : "2" (_r15) ASM_ARGS_6 \
+ : "memory" ASM_CLOBBERS_6); \
+ _retval = _r8; \
+ if (_r10 == -1) { \
+ errno = (_retval); \
+ _retval = -1; \
+ } \
+ return (type)_retval; \
+}
+
+
+#define LOAD_ARGS_0() do { } while (0)
+#define LOAD_ARGS_1(out0) \
+ register long _out0 asm ("out0") = (long) (out0); \
+ LOAD_ARGS_0 ()
+#define LOAD_ARGS_2(out0, out1) \
+ register long _out1 asm ("out1") = (long) (out1); \
+ LOAD_ARGS_1 (out0)
+#define LOAD_ARGS_3(out0, out1, out2) \
+ register long _out2 asm ("out2") = (long) (out2); \
+ LOAD_ARGS_2 (out0, out1)
+#define LOAD_ARGS_4(out0, out1, out2, out3) \
+ register long _out3 asm ("out3") = (long) (out3); \
+ LOAD_ARGS_3 (out0, out1, out2)
+#define LOAD_ARGS_5(out0, out1, out2, out3, out4) \
+ register long _out4 asm ("out4") = (long) (out4); \
+ LOAD_ARGS_4 (out0, out1, out2, out3)
+#define LOAD_ARGS_6(out0, out1, out2, out3, out4, out5) \
+ register long _out5 asm ("out5") = (long) (out5); \
+ LOAD_ARGS_5 (out0, out1, out2, out3, out4)
+
+#define ASM_OUTARGS_1 "=r" (_out0)
+#define ASM_OUTARGS_2 ASM_OUTARGS_1, "=r" (_out1)
+#define ASM_OUTARGS_3 ASM_OUTARGS_2, "=r" (_out2)
+#define ASM_OUTARGS_4 ASM_OUTARGS_3, "=r" (_out3)
+#define ASM_OUTARGS_5 ASM_OUTARGS_4, "=r" (_out4)
+#define ASM_OUTARGS_6 ASM_OUTARGS_5, "=r" (_out5)
+
+#define ASM_ARGS_0
+#define ASM_ARGS_1 ASM_ARGS_0, "3" (_out0)
+#define ASM_ARGS_2 ASM_ARGS_1, "4" (_out1)
+#define ASM_ARGS_3 ASM_ARGS_2, "5" (_out2)
+#define ASM_ARGS_4 ASM_ARGS_3, "6" (_out3)
+#define ASM_ARGS_5 ASM_ARGS_4, "7" (_out4)
+#define ASM_ARGS_6 ASM_ARGS_5, "8" (_out5)
+
+#define ASM_CLOBBERS_0 ASM_CLOBBERS_1, "out0"
+#define ASM_CLOBBERS_1 ASM_CLOBBERS_2, "out1"
+#define ASM_CLOBBERS_2 ASM_CLOBBERS_3, "out2"
+#define ASM_CLOBBERS_3 ASM_CLOBBERS_4, "out3"
+#define ASM_CLOBBERS_4 ASM_CLOBBERS_5, "out4"
+#define ASM_CLOBBERS_5 ASM_CLOBBERS_6, "out5"
+#define ASM_CLOBBERS_6 , "out6", "out7", \
+ /* Non-stacked integer registers, minus r8, r10, r15. */ \
+ "r2", "r3", "r9", "r11", "r12", "r13", "r14", "r16", "r17", "r18", \
+ "r19", "r20", "r21", "r22", "r23", "r24", "r25", "r26", "r27", \
+ "r28", "r29", "r30", "r31", \
+ /* Predicate registers. */ \
+ "p6", "p7", "p8", "p9", "p10", "p11", "p12", "p13", "p14", "p15", \
+ /* Non-rotating fp registers. */ \
+ "f6", "f7", "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15", \
+ /* Branch registers. */ \
+ "b6", "b7"
+
+#endif /* _KLIBC_ARCHSYS_H */
diff --git a/klibc/include/arch/m68k/klibc/archsignal.h b/klibc/include/arch/m68k/klibc/archsignal.h
new file mode 100644
index 0000000000..714527f6b0
--- /dev/null
+++ b/klibc/include/arch/m68k/klibc/archsignal.h
@@ -0,0 +1,13 @@
+/*
+ * arch/m68k/include/klibc/archsignal.h
+ *
+ * Architecture-specific signal definitions
+ *
+ */
+
+#ifndef _KLIBC_ARCHSIGNAL_H
+#define _KLIBC_ARCHSIGNAL_H
+
+/* No special stuff for this architecture */
+
+#endif
diff --git a/klibc/include/arch/m68k/klibc/archstat.h b/klibc/include/arch/m68k/klibc/archstat.h
new file mode 100644
index 0000000000..9c0a05da09
--- /dev/null
+++ b/klibc/include/arch/m68k/klibc/archstat.h
@@ -0,0 +1,37 @@
+#ifndef _KLIBC_ARCHSTAT_H
+#define _KLIBC_ARCHSTAT_H
+
+#define _STATBUF_ST_NSEC
+
+/* This matches struct stat64 in glibc2.1, hence the absolutely
+ * insane amounts of padding around dev_t's.
+ */
+struct stat {
+ unsigned long long st_dev;
+ unsigned char __pad1[2];
+
+ unsigned long __st_ino;
+
+ unsigned int st_mode;
+ unsigned int st_nlink;
+
+ unsigned long st_uid;
+ unsigned long st_gid;
+
+ unsigned long long st_rdev;
+ unsigned char __pad3[2];
+
+ long long st_size;
+ unsigned long st_blksize;
+
+ unsigned long __pad4; /* future possible st_blocks high bits */
+ unsigned long st_blocks; /* Number 512-byte blocks allocated. */
+
+ struct timespec st_atim;
+ struct timespec st_mtim;
+ struct timespec st_ctim;
+
+ unsigned long long st_ino;
+};
+
+#endif
diff --git a/klibc/include/arch/m68k/klibc/archsys.h b/klibc/include/arch/m68k/klibc/archsys.h
new file mode 100644
index 0000000000..8f6bed8e94
--- /dev/null
+++ b/klibc/include/arch/m68k/klibc/archsys.h
@@ -0,0 +1,12 @@
+/*
+ * arch/m68k/include/klibc/archsys.h
+ *
+ * Architecture-specific syscall definitions
+ */
+
+#ifndef _KLIBC_ARCHSYS_H
+#define _KLIBC_ARCHSYS_H
+
+/* No special syscall definitions for this architecture */
+
+#endif /* _KLIBC_ARCHSYS_H */
diff --git a/klibc/include/arch/mips/klibc/archfcntl.h b/klibc/include/arch/mips/klibc/archfcntl.h
new file mode 100644
index 0000000000..54462ea69f
--- /dev/null
+++ b/klibc/include/arch/mips/klibc/archfcntl.h
@@ -0,0 +1,87 @@
+/*
+ * arch/mips/include/klibc/archfcntl.h
+ *
+ * On MIPS, <asm/fcntl.h> isn't usable (compiling struct stat with
+ * the correct definitions doesn't "just work"), so we need to provide
+ * our own definitions.
+ */
+
+#ifndef _KLIBC_ARCHFCNTL_H
+#define _KLIBC_ARCHFCNTL_H
+
+#ifdef _ASM_FCNTL_H /* We were too late! */
+# error "<asm/fcntl.h> included before <klibc/archfcntl.h>"
+#endif
+#define _ASM_FCNTL_H /* Keep <asm/fcntl.h> from getting included */
+
+#define O_ACCMODE 0x0003
+#define O_RDONLY 0x0000
+#define O_WRONLY 0x0001
+#define O_RDWR 0x0002
+#define O_APPEND 0x0008
+#define O_SYNC 0x0010
+#define O_NONBLOCK 0x0080
+#define O_CREAT 0x0100
+#define O_TRUNC 0x0200
+#define O_EXCL 0x0400
+#define O_NOCTTY 0x0800
+#define FASYNC 0x1000
+#define O_LARGEFILE 0x2000
+#define O_DIRECT 0x8000
+#define O_DIRECTORY 0x10000
+#define O_NOFOLLOW 0x20000
+#define O_NOATIME 0x40000
+
+#define O_NDELAY O_NONBLOCK
+
+#define F_DUPFD 0
+#define F_GETFD 1
+#define F_SETFD 2
+#define F_GETFL 3
+#define F_SETFL 4
+#define F_GETLK 14
+#define F_SETLK 6
+#define F_SETLKW 7
+
+#define F_SETOWN 24
+#define F_GETOWN 23
+#define F_SETSIG 10
+#define F_GETSIG 11
+
+#define F_GETLK64 33
+#define F_SETLK64 34
+#define F_SETLKW64 35
+
+#define FD_CLOEXEC 1
+
+#define F_RDLCK 0
+#define F_WRLCK 1
+#define F_UNLCK 2
+
+#define F_EXLCK 4
+#define F_SHLCK 8
+
+#define F_INPROGRESS 16
+
+#define LOCK_SH 1
+#define LOCK_EX 2
+#define LOCK_NB 4
+#define LOCK_UN 8
+
+#define LOCK_MAND 32
+#define LOCK_READ 64
+#define LOCK_WRITE 128
+#define LOCK_RW 192
+
+typedef struct flock {
+ short l_type;
+ short l_whence;
+ loff_t l_start;
+ loff_t l_len;
+ pid_t l_pid;
+} flock_t;
+
+#define F_LINUX_SPECIFIC_BASE 1024
+
+#endif /* _KLIBC_ARCHFCNTL_H */
+
diff --git a/klibc/include/arch/mips/klibc/archsetjmp.h b/klibc/include/arch/mips/klibc/archsetjmp.h
new file mode 100644
index 0000000000..40e5be2736
--- /dev/null
+++ b/klibc/include/arch/mips/klibc/archsetjmp.h
@@ -0,0 +1,39 @@
+/*
+ * arch/mips/include/klibc/archsetjmp.h
+ */
+
+#ifndef _KLIBC_ARCHSETJMP_H
+#define _KLIBC_ARCHSETJMP_H
+
+struct __jmp_buf {
+ unsigned long __s0;
+ unsigned long __s1;
+ unsigned long __s2;
+ unsigned long __s3;
+ unsigned long __s4;
+ unsigned long __s5;
+ unsigned long __s6;
+ unsigned long __s7;
+ unsigned long __gp;
+ unsigned long __sp;
+ unsigned long __s8;
+ unsigned long __ra;
+ unsigned long __f20;
+ unsigned long __f21;
+ unsigned long __f22;
+ unsigned long __f23;
+ unsigned long __f24;
+ unsigned long __f25;
+ unsigned long __f26;
+ unsigned long __f27;
+ unsigned long __f28;
+ unsigned long __f29;
+ unsigned long __f30;
+ unsigned long __f31;
+ unsigned long __fcr31;
+ unsigned long __unused;
+} __attribute__((aligned(8)));
+
+typedef struct __jmp_buf jmp_buf[1];
+
+#endif /* _KLIBC_ARCHSETJMP_H */
diff --git a/klibc/include/arch/mips/klibc/archsignal.h b/klibc/include/arch/mips/klibc/archsignal.h
new file mode 100644
index 0000000000..3b72908636
--- /dev/null
+++ b/klibc/include/arch/mips/klibc/archsignal.h
@@ -0,0 +1,13 @@
+/*
+ * arch/mips/include/klibc/archsignal.h
+ *
+ * Architecture-specific signal definitions
+ *
+ */
+
+#ifndef _KLIBC_ARCHSIGNAL_H
+#define _KLIBC_ARCHSIGNAL_H
+
+/* No special stuff for this architecture */
+
+#endif
diff --git a/klibc/include/arch/mips/klibc/archstat.h b/klibc/include/arch/mips/klibc/archstat.h
new file mode 100644
index 0000000000..612bbfa85b
--- /dev/null
+++ b/klibc/include/arch/mips/klibc/archstat.h
@@ -0,0 +1,39 @@
+#ifndef _KLIBC_ARCHSTAT_H
+#define _KLIBC_ARCHSTAT_H
+
+#define _STATBUF_ST_NSEC
+
+/*
+ * This matches struct stat64 in glibc2.1, hence the absolutely insane
+ * amounts of padding around dev_t's. The memory layout is the same as of
+ * struct stat of the 64-bit kernel.
+ */
+
+struct stat {
+ unsigned long st_dev;
+ unsigned long st_pad0[3]; /* Reserved for st_dev expansion */
+
+ unsigned long long st_ino;
+
+ mode_t st_mode;
+ nlink_t st_nlink;
+
+ uid_t st_uid;
+ gid_t st_gid;
+
+ unsigned long st_rdev;
+ unsigned long st_pad1[3]; /* Reserved for st_rdev expansion */
+
+ long long st_size;
+
+ struct timespec st_atim;
+ struct timespec st_mtim;
+ struct timespec st_ctim;
+
+ unsigned long st_blksize;
+ unsigned long st_pad2;
+
+ long long st_blocks;
+};
+
+#endif
diff --git a/klibc/include/arch/mips/klibc/archsys.h b/klibc/include/arch/mips/klibc/archsys.h
new file mode 100644
index 0000000000..f696cdfaa7
--- /dev/null
+++ b/klibc/include/arch/mips/klibc/archsys.h
@@ -0,0 +1,12 @@
+/*
+ * arch/mips/include/klibc/archsys.h
+ *
+ * Architecture-specific syscall definitions
+ */
+
+#ifndef _KLIBC_ARCHSYS_H
+#define _KLIBC_ARCHSYS_H
+
+/* No special syscall definitions for this architecture */
+
+#endif /* _KLIBC_ARCHSYS_H */
diff --git a/klibc/include/arch/mips/machine/asm.h b/klibc/include/arch/mips/machine/asm.h
new file mode 100644
index 0000000000..e5239a6cef
--- /dev/null
+++ b/klibc/include/arch/mips/machine/asm.h
@@ -0,0 +1,11 @@
+/*
+ * arch/mips/include/machine/asm.h
+ */
+
+#ifndef _MACHINE_ASM_H
+#define _MACHINE_ASM_H
+
+#include <asm/regdef.h>
+#include <asm/asm.h>
+
+#endif /* _MACHINE_ASM_H */
diff --git a/klibc/include/arch/mips/sgidefs.h b/klibc/include/arch/mips/sgidefs.h
new file mode 100644
index 0000000000..eb103ace2c
--- /dev/null
+++ b/klibc/include/arch/mips/sgidefs.h
@@ -0,0 +1,20 @@
+/*
+ * arch/mips/include/sgidefs.h
+ */
+
+/* Some ABI constants */
+
+#ifndef _SGIDEFS_H
+#define _SGIDEFS_H
+
+#define _MIPS_ISA_MIPS1 1
+#define _MIPS_ISA_MIPS2 2
+#define _MIPS_ISA_MIPS3 3
+#define _MIPS_ISA_MIPS4 4
+#define _MIPS_ISA_MIPS5 5
+
+#define _MIPS_SIM_ABI32 1
+#define _MIPS_SIM_NABI32 2
+#define _MIPS_SIM_ABI64 3
+
+#endif /* _SGIDEFS_H */
diff --git a/klibc/include/arch/mips/spaces.h b/klibc/include/arch/mips/spaces.h
new file mode 100644
index 0000000000..b5f530b753
--- /dev/null
+++ b/klibc/include/arch/mips/spaces.h
@@ -0,0 +1 @@
+/* Included by <asm/page.h> but not actually needed */
diff --git a/klibc/include/arch/mips64/klibc/archsignal.h b/klibc/include/arch/mips64/klibc/archsignal.h
new file mode 100644
index 0000000000..56b0fd323e
--- /dev/null
+++ b/klibc/include/arch/mips64/klibc/archsignal.h
@@ -0,0 +1,13 @@
+/*
+ * arch/mips64/include/klibc/archsignal.h
+ *
+ * Architecture-specific signal definitions
+ *
+ */
+
+#ifndef _KLIBC_ARCHSIGNAL_H
+#define _KLIBC_ARCHSIGNAL_H
+
+/* No special stuff for this architecture */
+
+#endif
diff --git a/klibc/include/arch/mips64/klibc/archstat.h b/klibc/include/arch/mips64/klibc/archstat.h
new file mode 100644
index 0000000000..d237e3a3e8
--- /dev/null
+++ b/klibc/include/arch/mips64/klibc/archstat.h
@@ -0,0 +1,33 @@
+#ifndef _KLIBC_ARCHSTAT_H
+#define _KLIBC_ARCHSTAT_H
+
+#define _STATBUF_ST_NSEC
+
+struct stat {
+ unsigned int st_dev;
+ unsigned int st_pad0[3]; /* Reserved for st_dev expansion */
+
+ unsigned long st_ino;
+
+ mode_t st_mode;
+ nlink_t st_nlink;
+
+ uid_t st_uid;
+ gid_t st_gid;
+
+ unsigned int st_rdev;
+ unsigned int st_pad1[3]; /* Reserved for st_rdev expansion */
+
+ off_t st_size;
+
+ struct timespec st_atim;
+ struct timespec st_mtim;
+ struct timespec st_ctim;
+
+ unsigned int st_blksize;
+ unsigned int st_pad2;
+
+ unsigned long st_blocks;
+};
+
+#endif
diff --git a/klibc/include/arch/mips64/klibc/archsys.h b/klibc/include/arch/mips64/klibc/archsys.h
new file mode 100644
index 0000000000..81e5106e16
--- /dev/null
+++ b/klibc/include/arch/mips64/klibc/archsys.h
@@ -0,0 +1,12 @@
+/*
+ * arch/mips64/include/klibc/archsys.h
+ *
+ * Architecture-specific syscall definitions
+ */
+
+#ifndef _KLIBC_ARCHSYS_H
+#define _KLIBC_ARCHSYS_H
+
+/* No special syscall definitions for this architecture */
+
+#endif /* _KLIBC_ARCHSYS_H */
diff --git a/klibc/include/arch/parisc/klibc/archsignal.h b/klibc/include/arch/parisc/klibc/archsignal.h
new file mode 100644
index 0000000000..3190e8528e
--- /dev/null
+++ b/klibc/include/arch/parisc/klibc/archsignal.h
@@ -0,0 +1,24 @@
+/*
+ * arch/parisc/include/klibc/archsignal.h
+ *
+ * Architecture-specific signal definitions
+ *
+ */
+
+#ifndef _KLIBC_ARCHSIGNAL_H
+#define _KLIBC_ARCHSIGNAL_H
+
+#define _NSIG 64
+#define _NSIG_SZ (_NSIG / LONG_BIT)
+
+typedef struct {
+ unsigned long sig[_NSIG_SZ];
+} sigset_t;
+
+struct sigaction {
+ __sighandler_t sa_handler;
+ unsigned long sa_flags;
+ sigset_t sa_mask;
+};
+
+#endif
diff --git a/klibc/include/arch/parisc/klibc/archstat.h b/klibc/include/arch/parisc/klibc/archstat.h
new file mode 100644
index 0000000000..7d28f459ee
--- /dev/null
+++ b/klibc/include/arch/parisc/klibc/archstat.h
@@ -0,0 +1,27 @@
+#ifndef _KLIBC_ARCHSTAT_H
+#define _KLIBC_ARCHSTAT_H
+
+#define _STATBUF_ST_NSEC
+
+struct stat {
+ unsigned long long st_dev;
+ unsigned int __pad1;
+
+ unsigned int __st_ino; /* Not actually filled in */
+ unsigned int st_mode;
+ unsigned int st_nlink;
+ unsigned int st_uid;
+ unsigned int st_gid;
+ unsigned long long st_rdev;
+ unsigned int __pad2;
+ signed long long st_size;
+ signed int st_blksize;
+
+ signed long long st_blocks;
+ struct timespec st_atim;
+ struct timespec st_mtim;
+ struct timespec st_ctim;
+ unsigned long long st_ino;
+};
+
+#endif
diff --git a/klibc/include/arch/parisc/klibc/archsys.h b/klibc/include/arch/parisc/klibc/archsys.h
new file mode 100644
index 0000000000..5013ba8794
--- /dev/null
+++ b/klibc/include/arch/parisc/klibc/archsys.h
@@ -0,0 +1,12 @@
+/*
+ * arch/parisc/include/klibc/archsys.h
+ *
+ * Architecture-specific syscall definitions
+ */
+
+#ifndef _KLIBC_ARCHSYS_H
+#define _KLIBC_ARCHSYS_H
+
+/* No special syscall definitions for this architecture */
+
+#endif /* _KLIBC_ARCHSYS_H */
diff --git a/klibc/include/arch/ppc/klibc/archsetjmp.h b/klibc/include/arch/ppc/klibc/archsetjmp.h
new file mode 100644
index 0000000000..53e2fccc3b
--- /dev/null
+++ b/klibc/include/arch/ppc/klibc/archsetjmp.h
@@ -0,0 +1,36 @@
+/*
+ * arch/ppc/include/klibc/archsetjmp.h
+ */
+
+#ifndef _KLIBC_ARCHSETJMP_H
+#define _KLIBC_ARCHSETJMP_H
+
+struct __jmp_buf {
+ unsigned long __r2;
+ unsigned long __sp;
+ unsigned long __lr;
+ unsigned long __cr;
+ unsigned long __r13;
+ unsigned long __r14;
+ unsigned long __r15;
+ unsigned long __r16;
+ unsigned long __r17;
+ unsigned long __r18;
+ unsigned long __r19;
+ unsigned long __r20;
+ unsigned long __r21;
+ unsigned long __r22;
+ unsigned long __r23;
+ unsigned long __r24;
+ unsigned long __r25;
+ unsigned long __r26;
+ unsigned long __r27;
+ unsigned long __r28;
+ unsigned long __r29;
+ unsigned long __r30;
+ unsigned long __r31;
+};
+
+typedef struct __jmp_buf jmp_buf[1];
+
+#endif /* _SETJMP_H */
diff --git a/klibc/include/arch/ppc/klibc/archsignal.h b/klibc/include/arch/ppc/klibc/archsignal.h
new file mode 100644
index 0000000000..567a547ef9
--- /dev/null
+++ b/klibc/include/arch/ppc/klibc/archsignal.h
@@ -0,0 +1,13 @@
+/*
+ * arch/ppc/include/klibc/archsignal.h
+ *
+ * Architecture-specific signal definitions
+ *
+ */
+
+#ifndef _KLIBC_ARCHSIGNAL_H
+#define _KLIBC_ARCHSIGNAL_H
+
+/* No special stuff for this architecture */
+
+#endif
diff --git a/klibc/include/arch/ppc/klibc/archstat.h b/klibc/include/arch/ppc/klibc/archstat.h
new file mode 100644
index 0000000000..1d0487b47f
--- /dev/null
+++ b/klibc/include/arch/ppc/klibc/archstat.h
@@ -0,0 +1,28 @@
+#ifndef _KLIBC_ARCHSTAT_H
+#define _KLIBC_ARCHSTAT_H
+
+#define _STATBUF_ST_NSEC
+
+/* This matches struct stat64 in glibc2.1.
+ */
+struct stat {
+ unsigned long long st_dev; /* Device. */
+ unsigned long long st_ino; /* File serial number. */
+ unsigned int st_mode; /* File mode. */
+ unsigned int st_nlink; /* Link count. */
+ unsigned int st_uid; /* User ID of the file's owner. */
+ unsigned int st_gid; /* Group ID of the file's group. */
+ unsigned long long st_rdev; /* Device number, if device. */
+ unsigned short int __pad2;
+ long long st_size; /* Size of file, in bytes. */
+ long st_blksize; /* Optimal block size for I/O. */
+
+ long long st_blocks; /* Number 512-byte blocks allocated. */
+ struct timespec st_atim; /* Time of last access. */
+ struct timespec st_mtim; /* Time of last modification. */
+ struct timespec st_ctim; /* Time of last status change. */
+ unsigned long int __unused4;
+ unsigned long int __unused5;
+};
+
+#endif
diff --git a/klibc/include/arch/ppc/klibc/archsys.h b/klibc/include/arch/ppc/klibc/archsys.h
new file mode 100644
index 0000000000..17a28859e5
--- /dev/null
+++ b/klibc/include/arch/ppc/klibc/archsys.h
@@ -0,0 +1,61 @@
+/*
+ * arch/ppc/include/klibc/archsys.h
+ *
+ * Architecture-specific syscall definitions
+ */
+
+#ifndef _KLIBC_ARCHSYS_H
+#define _KLIBC_ARCHSYS_H
+
+/* PowerPC seems to lack _syscall6() in its headers */
+/* This seems to work on both 32- and 64-bit ppc */
+
+#ifndef _syscall6
+
+#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
+ type5,arg5,type6,arg6) \
+type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5,type6 arg6) \
+{ \
+ unsigned long __sc_ret, __sc_err; \
+ { \
+ register unsigned long __sc_0 __asm__ ("r0"); \
+ register unsigned long __sc_3 __asm__ ("r3"); \
+ register unsigned long __sc_4 __asm__ ("r4"); \
+ register unsigned long __sc_5 __asm__ ("r5"); \
+ register unsigned long __sc_6 __asm__ ("r6"); \
+ register unsigned long __sc_7 __asm__ ("r7"); \
+ register unsigned long __sc_8 __asm__ ("r8"); \
+ \
+ __sc_3 = (unsigned long) (arg1); \
+ __sc_4 = (unsigned long) (arg2); \
+ __sc_5 = (unsigned long) (arg3); \
+ __sc_6 = (unsigned long) (arg4); \
+ __sc_7 = (unsigned long) (arg5); \
+ __sc_8 = (unsigned long) (arg6); \
+ __sc_0 = __NR_##name; \
+ __asm__ __volatile__ \
+ ("sc \n\t" \
+ "mfcr %1 " \
+ : "+r" (__sc_3), \
+ "+r" (__sc_0), \
+ "+r" (__sc_4), \
+ "+r" (__sc_5), \
+ "+r" (__sc_6), \
+ "+r" (__sc_7), \
+ "+r" (__sc_8) \
+ : : "cr0", "ctr", "memory", \
+ "r9", "r10", "r11", "r12"); \
+ __sc_ret = __sc_3; \
+ __sc_err = __sc_0; \
+ } \
+ if (__sc_err & 0x10000000) \
+ { \
+ errno = (int)__sc_ret; \
+ __sc_ret = -1; \
+ } \
+ return (type)__sc_ret; \
+}
+
+#endif /* _syscall6() missing */
+
+#endif /* _KLIBC_ARCHSYS_H */
diff --git a/klibc/include/arch/ppc64/klibc/archsetjmp.h b/klibc/include/arch/ppc64/klibc/archsetjmp.h
new file mode 100644
index 0000000000..006a2e27be
--- /dev/null
+++ b/klibc/include/arch/ppc64/klibc/archsetjmp.h
@@ -0,0 +1,36 @@
+/*
+ * arch/ppc64/include/klibc/archsetjmp.h
+ */
+
+#ifndef _KLIBC_ARCHSETJMP_H
+#define _KLIBC_ARCHSETJMP_H
+
+struct __jmp_buf {
+ unsigned long __r2;
+ unsigned long __sp;
+ unsigned long __lr;
+ unsigned long __cr;
+ unsigned long __r13;
+ unsigned long __r14;
+ unsigned long __r15;
+ unsigned long __r16;
+ unsigned long __r17;
+ unsigned long __r18;
+ unsigned long __r19;
+ unsigned long __r20;
+ unsigned long __r21;
+ unsigned long __r22;
+ unsigned long __r23;
+ unsigned long __r24;
+ unsigned long __r25;
+ unsigned long __r26;
+ unsigned long __r27;
+ unsigned long __r28;
+ unsigned long __r29;
+ unsigned long __r30;
+ unsigned long __r31;
+};
+
+typedef struct __jmp_buf jmp_buf[1];
+
+#endif /* _SETJMP_H */
diff --git a/klibc/include/arch/ppc64/klibc/archsignal.h b/klibc/include/arch/ppc64/klibc/archsignal.h
new file mode 100644
index 0000000000..8452f6e4bc
--- /dev/null
+++ b/klibc/include/arch/ppc64/klibc/archsignal.h
@@ -0,0 +1,13 @@
+/*
+ * arch/ppc64/include/klibc/archsignal.h
+ *
+ * Architecture-specific signal definitions
+ *
+ */
+
+#ifndef _KLIBC_ARCHSIGNAL_H
+#define _KLIBC_ARCHSIGNAL_H
+
+/* No special stuff for this architecture */
+
+#endif
diff --git a/klibc/include/arch/ppc64/klibc/archstat.h b/klibc/include/arch/ppc64/klibc/archstat.h
new file mode 100644
index 0000000000..71f4748690
--- /dev/null
+++ b/klibc/include/arch/ppc64/klibc/archstat.h
@@ -0,0 +1,25 @@
+#ifndef _KLIBC_ARCHSTAT_H
+#define _KLIBC_ARCHSTAT_H
+
+#define _STATBUF_ST_NSEC
+
+struct stat {
+ unsigned long st_dev;
+ ino_t st_ino;
+ nlink_t st_nlink;
+ mode_t st_mode;
+ uid_t st_uid;
+ gid_t st_gid;
+ unsigned long st_rdev;
+ off_t st_size;
+ unsigned long st_blksize;
+ unsigned long st_blocks;
+ struct timespec st_atim; /* Time of last access. */
+ struct timespec st_mtim; /* Time of last modification. */
+ struct timespec st_ctim; /* Time of last status change. */
+ unsigned long __unused4;
+ unsigned long __unused5;
+ unsigned long __unused6;
+};
+
+#endif
diff --git a/klibc/include/arch/ppc64/klibc/archsys.h b/klibc/include/arch/ppc64/klibc/archsys.h
new file mode 100644
index 0000000000..4f81fee00d
--- /dev/null
+++ b/klibc/include/arch/ppc64/klibc/archsys.h
@@ -0,0 +1,52 @@
+/*
+ * arch/ppc64/include/klibc/archsys.h
+ *
+ * Architecture-specific syscall definitions
+ */
+
+#ifndef _KLIBC_ARCHSYS_H
+#define _KLIBC_ARCHSYS_H
+
+#ifndef _syscall6
+
+#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
+ type5,arg5,type6,arg6) \
+type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5,type6 arg6) \
+{ \
+ unsigned long __sc_ret, __sc_err; \
+ { \
+ register unsigned long __sc_0 __asm__ ("r0"); \
+ register unsigned long __sc_3 __asm__ ("r3"); \
+ register unsigned long __sc_4 __asm__ ("r4"); \
+ register unsigned long __sc_5 __asm__ ("r5"); \
+ register unsigned long __sc_6 __asm__ ("r6"); \
+ register unsigned long __sc_7 __asm__ ("r7"); \
+ register unsigned long __sc_8 __asm__ ("r8"); \
+ \
+ __sc_3 = (unsigned long) (arg1); \
+ __sc_4 = (unsigned long) (arg2); \
+ __sc_5 = (unsigned long) (arg3); \
+ __sc_6 = (unsigned long) (arg4); \
+ __sc_7 = (unsigned long) (arg5); \
+ __sc_8 = (unsigned long) (arg6); \
+ __sc_0 = __NR_##name; \
+ __asm__ __volatile__ \
+ ("sc \n\t" \
+ "mfcr %1 " \
+ : "=&r" (__sc_3), "=&r" (__sc_0) \
+ : "0" (__sc_3), "1" (__sc_0), \
+ "r" (__sc_4), \
+ "r" (__sc_5), \
+ "r" (__sc_6), \
+ "r" (__sc_7), \
+ "r" (__sc_8) \
+ : __syscall_clobbers); \
+ __sc_ret = __sc_3; \
+ __sc_err = __sc_0; \
+ } \
+ __syscall_return (type); \
+}
+
+#endif /* _syscall6() missing */
+
+#endif /* _KLIBC_ARCHSYS_H */
diff --git a/klibc/include/arch/s390/klibc/archsetjmp.h b/klibc/include/arch/s390/klibc/archsetjmp.h
new file mode 100644
index 0000000000..11a641ed5a
--- /dev/null
+++ b/klibc/include/arch/s390/klibc/archsetjmp.h
@@ -0,0 +1,15 @@
+/*
+ * arch/s390/include/klibc/archsetjmp.h
+ */
+
+#ifndef _KLIBC_ARCHSETJMP_H
+#define _KLIBC_ARCHSETJMP_H
+
+struct __jmp_buf {
+ uint32_t __gregs[10]; /* general registers r6-r15 */
+ uint64_t __fpregs[2]; /* fp registers f4 and f6 */
+};
+
+typedef struct __jmp_buf jmp_buf[1];
+
+#endif /* _SETJMP_H */
diff --git a/klibc/include/arch/s390/klibc/archsignal.h b/klibc/include/arch/s390/klibc/archsignal.h
new file mode 100644
index 0000000000..1f8de28b4b
--- /dev/null
+++ b/klibc/include/arch/s390/klibc/archsignal.h
@@ -0,0 +1,13 @@
+/*
+ * arch/s390/include/klibc/archsignal.h
+ *
+ * Architecture-specific signal definitions
+ *
+ */
+
+#ifndef _KLIBC_ARCHSIGNAL_H
+#define _KLIBC_ARCHSIGNAL_H
+
+/* No special stuff for this architecture */
+
+#endif
diff --git a/klibc/include/arch/s390/klibc/archstat.h b/klibc/include/arch/s390/klibc/archstat.h
new file mode 100644
index 0000000000..866c3d4f4c
--- /dev/null
+++ b/klibc/include/arch/s390/klibc/archstat.h
@@ -0,0 +1,31 @@
+#ifndef _KLIBC_ARCHSTAT_H
+#define _KLIBC_ARCHSTAT_H
+
+#define _STATBUF_ST_NSEC
+
+/* This matches struct stat64 in glibc2.1, hence the absolutely
+ * insane amounts of padding around dev_t's.
+ */
+struct stat {
+ unsigned long long st_dev;
+ unsigned int __pad1;
+#define STAT64_HAS_BROKEN_ST_INO 1
+ unsigned long __st_ino;
+ unsigned int st_mode;
+ unsigned int st_nlink;
+ unsigned long st_uid;
+ unsigned long st_gid;
+ unsigned long long st_rdev;
+ unsigned int __pad3;
+ long long st_size;
+ unsigned long st_blksize;
+ unsigned char __pad4[4];
+ unsigned long __pad5; /* future possible st_blocks high bits */
+ unsigned long st_blocks; /* Number 512-byte blocks allocated. */
+ struct timespec st_atim;
+ struct timespec st_mtim;
+ struct timespec st_ctim;
+ unsigned long long st_ino;
+};
+
+#endif
diff --git a/klibc/include/arch/s390/klibc/archsys.h b/klibc/include/arch/s390/klibc/archsys.h
new file mode 100644
index 0000000000..1cd0948f3c
--- /dev/null
+++ b/klibc/include/arch/s390/klibc/archsys.h
@@ -0,0 +1,41 @@
+/*
+ * arch/s390/include/klibc/archsys.h
+ *
+ * Architecture-specific syscall definitions
+ */
+
+#ifndef _KLIBC_ARCHSYS_H
+#define _KLIBC_ARCHSYS_H
+
+/* S/390 only has five syscall parameters, and uses a structure for
+ 6-argument syscalls. */
+
+#ifndef _syscall6
+
+#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,\
+ type4,arg4,type5,arg5,type6,arg6) \
+type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \
+ type5 arg5, type6 arg6) { \
+ unsigned long __arg[6] = { \
+ (unsigned long) arg1, \
+ (unsigned long) arg2, \
+ (unsigned long) arg3, \
+ (unsigned long) arg4, \
+ (unsigned long) arg5, \
+ (unsigned long) arg6 \
+ }; \
+ register void *__argp asm("2") = &__arg; \
+ long __res; \
+ __asm__ __volatile__ ( \
+ " svc %b1\n" \
+ " lr %0,2" \
+ : "=d" (__res) \
+ : "i" (__NR_##name), \
+ "d" (__argp) \
+ : _svc_clobber); \
+ __syscall_return(type, __res); \
+}
+
+#endif /* _syscall6() missing */
+
+#endif /* _KLIBC_ARCHSYS_H */
diff --git a/klibc/include/arch/s390x/klibc/archsetjmp.h b/klibc/include/arch/s390x/klibc/archsetjmp.h
new file mode 100644
index 0000000000..dd3ed0d47c
--- /dev/null
+++ b/klibc/include/arch/s390x/klibc/archsetjmp.h
@@ -0,0 +1,15 @@
+/*
+ * arch/s390x/include/klibc/archsetjmp.h
+ */
+
+#ifndef _KLIBC_ARCHSETJMP_H
+#define _KLIBC_ARCHSETJMP_H
+
+struct __jmp_buf {
+ uint64_t __gregs[10]; /* general registers r6-r15 */
+ uint64_t __fpregs[4]; /* fp registers f1, f3, f5, f7 */
+};
+
+typedef struct __jmp_buf jmp_buf[1];
+
+#endif /* _SETJMP_H */
diff --git a/klibc/include/arch/s390x/klibc/archsignal.h b/klibc/include/arch/s390x/klibc/archsignal.h
new file mode 100644
index 0000000000..08c9a0073a
--- /dev/null
+++ b/klibc/include/arch/s390x/klibc/archsignal.h
@@ -0,0 +1,13 @@
+/*
+ * arch/s390x/include/klibc/archsignal.h
+ *
+ * Architecture-specific signal definitions
+ *
+ */
+
+#ifndef _KLIBC_ARCHSIGNAL_H
+#define _KLIBC_ARCHSIGNAL_H
+
+/* No special stuff for this architecture */
+
+#endif
diff --git a/klibc/include/arch/s390x/klibc/archstat.h b/klibc/include/arch/s390x/klibc/archstat.h
new file mode 100644
index 0000000000..0de73cb2b6
--- /dev/null
+++ b/klibc/include/arch/s390x/klibc/archstat.h
@@ -0,0 +1,24 @@
+#ifndef _KLIBC_ARCHSTAT_H
+#define _KLIBC_ARCHSTAT_H
+
+#define _STATBUF_ST_NSEC
+
+struct stat {
+ unsigned long st_dev;
+ unsigned long st_ino;
+ unsigned long st_nlink;
+ unsigned int st_mode;
+ unsigned int st_uid;
+ unsigned int st_gid;
+ unsigned int __pad1;
+ unsigned long st_rdev;
+ unsigned long st_size;
+ struct timespec st_atim;
+ struct timespec st_mtim;
+ struct timespec st_ctim;
+ unsigned long st_blksize;
+ long st_blocks;
+ unsigned long __unused[3];
+};
+
+#endif
diff --git a/klibc/include/arch/s390x/klibc/archsys.h b/klibc/include/arch/s390x/klibc/archsys.h
new file mode 100644
index 0000000000..15f7113bb4
--- /dev/null
+++ b/klibc/include/arch/s390x/klibc/archsys.h
@@ -0,0 +1,41 @@
+/*
+ * arch/s390x/include/klibc/archsys.h
+ *
+ * Architecture-specific syscall definitions
+ */
+
+#ifndef _KLIBC_ARCHSYS_H
+#define _KLIBC_ARCHSYS_H
+
+/* S/390X only has five syscall parameters, and uses a structure for
+ 6-argument syscalls. */
+
+#ifndef _syscall6
+
+#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,\
+ type4,arg4,type5,arg5,type6,arg6) \
+type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \
+ type5 arg5, type6 arg6) { \
+ unsigned long __arg[6] = { \
+ (unsigned long) arg1, \
+ (unsigned long) arg2, \
+ (unsigned long) arg3, \
+ (unsigned long) arg4, \
+ (unsigned long) arg5, \
+ (unsigned long) arg6 \
+ }; \
+ register void *__argp asm("2") = &__arg; \
+ long __res; \
+ __asm__ __volatile__ ( \
+ " svc %b1\n" \
+ " lgr %0,2" \
+ : "=d" (__res) \
+ : "i" (__NR_##name), \
+ "d" (__argp) \
+ : _svc_clobber); \
+ __syscall_return(type, __res); \
+}
+
+#endif /* _syscall6() missing */
+
+#endif /* _KLIBC_ARCHSYS_H */
diff --git a/klibc/include/arch/sh/klibc/archsetjmp.h b/klibc/include/arch/sh/klibc/archsetjmp.h
new file mode 100644
index 0000000000..28dd932fbc
--- /dev/null
+++ b/klibc/include/arch/sh/klibc/archsetjmp.h
@@ -0,0 +1,22 @@
+/*
+ * arch/sh/include/klibc/archsetjmp.h
+ */
+
+#ifndef _KLIBC_ARCHSETJMP_H
+#define _KLIBC_ARCHSETJMP_H
+
+struct __jmp_buf {
+ unsigned long r8;
+ unsigned long r9;
+ unsigned long r10;
+ unsigned long r11;
+ unsigned long r12;
+ unsigned long r13;
+ unsigned long r14;
+ unsigned long r15;
+ unsigned long pr;
+};
+
+typedef struct __jmp_buf jmp_buf[1];
+
+#endif /* _KLIBC_ARCHSETJMP_H */
diff --git a/klibc/include/arch/sh/klibc/archsignal.h b/klibc/include/arch/sh/klibc/archsignal.h
new file mode 100644
index 0000000000..6c4e5976ad
--- /dev/null
+++ b/klibc/include/arch/sh/klibc/archsignal.h
@@ -0,0 +1,13 @@
+/*
+ * arch/sh/include/klibc/archsignal.h
+ *
+ * Architecture-specific signal definitions
+ *
+ */
+
+#ifndef _KLIBC_ARCHSIGNAL_H
+#define _KLIBC_ARCHSIGNAL_H
+
+/* No special stuff for this architecture */
+
+#endif
diff --git a/klibc/include/arch/sh/klibc/archstat.h b/klibc/include/arch/sh/klibc/archstat.h
new file mode 100644
index 0000000000..73caceb593
--- /dev/null
+++ b/klibc/include/arch/sh/klibc/archstat.h
@@ -0,0 +1,45 @@
+#ifndef _KLIBC_ARCHSTAT_H
+#define _KLIBC_ARCHSTAT_H
+
+#include <endian.h>
+
+#define _STATBUF_ST_NSEC
+
+/* This matches struct stat64 in glibc2.1, hence the absolutely
+ * insane amounts of padding around dev_t's.
+ */
+struct stat64 {
+ unsigned long long st_dev;
+ unsigned char __pad0[4];
+
+ unsigned long st_ino;
+ unsigned int st_mode;
+ unsigned int st_nlink;
+
+ unsigned long st_uid;
+ unsigned long st_gid;
+
+ unsigned long long st_rdev;
+ unsigned char __pad3[4];
+
+ long long st_size;
+ unsigned long st_blksize;
+
+#if __BYTE_ORDER == __BIG_ENDIAN
+ unsigned long __pad4; /* Future possible st_blocks hi bits */
+ unsigned long st_blocks; /* Number 512-byte blocks allocated. */
+#else /* Must be little */
+ unsigned long st_blocks; /* Number 512-byte blocks allocated. */
+ unsigned long __pad4; /* Future possible st_blocks hi bits */
+#endif
+
+ struct timespec st_atim;
+ struct timespec st_mtim;
+ struct timespec st_ctim;
+
+ unsigned long __unused1;
+ unsigned long __unused2;
+};
+
+#endif
+
diff --git a/klibc/include/arch/sh/klibc/archsys.h b/klibc/include/arch/sh/klibc/archsys.h
new file mode 100644
index 0000000000..5f8050a536
--- /dev/null
+++ b/klibc/include/arch/sh/klibc/archsys.h
@@ -0,0 +1,12 @@
+/*
+ * arch/sh/include/klibc/archsys.h
+ *
+ * Architecture-specific syscall definitions
+ */
+
+#ifndef _KLIBC_ARCHSYS_H
+#define _KLIBC_ARCHSYS_H
+
+/* No special syscall definitions for this architecture */
+
+#endif /* _KLIBC_ARCHSYS_H */
diff --git a/klibc/include/arch/sparc/klibc/archsetjmp.h b/klibc/include/arch/sparc/klibc/archsetjmp.h
new file mode 100644
index 0000000000..92c1c74c9d
--- /dev/null
+++ b/klibc/include/arch/sparc/klibc/archsetjmp.h
@@ -0,0 +1,16 @@
+/*
+ * arch/sparc/include/klibc/archsetjmp.h
+ */
+
+#ifndef _KLIBC_ARCHSETJMP_H
+#define _KLIBC_ARCHSETJMP_H
+
+struct __jmp_buf {
+ unsigned long __sp;
+ unsigned long __fp;
+ unsigned long __pc;
+};
+
+typedef struct __jmp_buf jmp_buf[1];
+
+#endif /* _SETJMP_H */
diff --git a/klibc/include/arch/sparc/klibc/archsignal.h b/klibc/include/arch/sparc/klibc/archsignal.h
new file mode 100644
index 0000000000..6af3709033
--- /dev/null
+++ b/klibc/include/arch/sparc/klibc/archsignal.h
@@ -0,0 +1,13 @@
+/*
+ * arch/sparc/include/klibc/archsignal.h
+ *
+ * Architecture-specific signal definitions
+ *
+ */
+
+#ifndef _KLIBC_ARCHSIGNAL_H
+#define _KLIBC_ARCHSIGNAL_H
+
+/* No special stuff for this architecture */
+
+#endif
diff --git a/klibc/include/arch/sparc/klibc/archstat.h b/klibc/include/arch/sparc/klibc/archstat.h
new file mode 100644
index 0000000000..0ff68785e5
--- /dev/null
+++ b/klibc/include/arch/sparc/klibc/archstat.h
@@ -0,0 +1,35 @@
+#ifndef _KLIBC_ARCHSTAT_H
+#define _KLIBC_ARCHSTAT_H
+
+#define _STATBUF_ST_NSEC
+
+struct stat {
+ unsigned long long st_dev;
+
+ unsigned long long st_ino;
+
+ unsigned int st_mode;
+ unsigned int st_nlink;
+
+ unsigned int st_uid;
+ unsigned int st_gid;
+
+ unsigned long long st_rdev;
+
+ unsigned char __pad3[8];
+
+ long long st_size;
+ unsigned int st_blksize;
+
+ unsigned char __pad4[8];
+ unsigned int st_blocks;
+
+ struct timespec st_atim;
+ struct timespec st_mtim;
+ struct timespec st_ctim;
+
+ unsigned int __unused4;
+ unsigned int __unused5;
+};
+
+#endif
diff --git a/klibc/include/arch/sparc/klibc/archsys.h b/klibc/include/arch/sparc/klibc/archsys.h
new file mode 100644
index 0000000000..20de8a8b44
--- /dev/null
+++ b/klibc/include/arch/sparc/klibc/archsys.h
@@ -0,0 +1,10 @@
+/*
+ * arch/sparc/include/klibc/archsys.h
+ *
+ * Architecture-specific syscall definitions
+ */
+
+#ifndef _KLIBC_ARCHSYS_H
+#define _KLIBC_ARCHSYS_H
+
+#endif /* _KLIBC_ARCHSYS_H */
diff --git a/klibc/include/arch/sparc/machine/asm.h b/klibc/include/arch/sparc/machine/asm.h
new file mode 100644
index 0000000000..b622bd8cf1
--- /dev/null
+++ b/klibc/include/arch/sparc/machine/asm.h
@@ -0,0 +1,192 @@
+/* $NetBSD: asm.h,v 1.14 2002/07/20 08:37:30 mrg Exp $ */
+
+/*
+ * Copyright (c) 1994 Allen Briggs
+ * All rights reserved.
+ *
+ * Gleaned from locore.s and sun3 asm.h which had the following copyrights:
+ * locore.s:
+ * Copyright (c) 1988 University of Utah.
+ * Copyright (c) 1982, 1990 The Regents of the University of California.
+ * sun3/include/asm.h:
+ * Copyright (c) 1993 Adam Glass
+ * Copyright (c) 1990 The Regents of the University of California.
+ *
+ * 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.
+ */
+
+#ifndef _ASM_H_
+#define _ASM_H_
+
+/* Pull in CCFSZ, CC64FSZ, and BIAS from frame.h */
+#ifndef _LOCORE
+#define _LOCORE
+#endif
+#include <machine/frame.h>
+
+#ifdef __ELF__
+#define _C_LABEL(name) name
+#else
+#ifdef __STDC__
+#define _C_LABEL(name) _ ## name
+#else
+#define _C_LABEL(name) _/**/name
+#endif
+#endif
+#define _ASM_LABEL(name) name
+
+#ifdef PIC
+/*
+ * PIC_PROLOGUE() is akin to the compiler generated function prologue for
+ * PIC code. It leaves the address of the Global Offset Table in DEST,
+ * clobbering register TMP in the process.
+ *
+ * We can use two code sequences. We can read the %pc or use the call
+ * instruction that saves the pc in %o7. Call requires the branch unit and
+ * IEU1, and clobbers %o7 which needs to be restored. This instruction
+ * sequence takes about 4 cycles due to instruction interdependence. Reading
+ * the pc takes 4 cycles to dispatch and is always dispatched alone. That
+ * sequence takes 7 cycles.
+ */
+#ifdef __arch64__
+#define PIC_PROLOGUE(dest,tmp) \
+ mov %o7, tmp; \
+ sethi %hi(_GLOBAL_OFFSET_TABLE_-4),dest; \
+ call 0f; \
+ or dest,%lo(_GLOBAL_OFFSET_TABLE_+4),dest; \
+0: \
+ add dest,%o7,dest; \
+ mov tmp, %o7
+#else
+#define PIC_PROLOGUE(dest,tmp) \
+ mov %o7,tmp; 3: call 4f; nop; 4: \
+ sethi %hi(_C_LABEL(_GLOBAL_OFFSET_TABLE_)-(3b-.)),dest; \
+ or dest,%lo(_C_LABEL(_GLOBAL_OFFSET_TABLE_)-(3b-.)),dest; \
+ add dest,%o7,dest; mov tmp,%o7
+#endif
+
+/*
+ * PICCY_SET() does the equivalent of a `set var, %dest' instruction in
+ * a PIC-like way, but without involving the Global Offset Table. This
+ * only works for VARs defined in the same file *and* in the text segment.
+ */
+#ifdef __arch64__
+#define PICCY_SET(var,dest,tmp) \
+ 3: rd %pc, tmp; add tmp,(var-3b),dest
+#else
+#define PICCY_SET(var,dest,tmp) \
+ mov %o7,tmp; 3: call 4f; nop; 4: \
+ add %o7,(var-3b),dest; mov tmp,%o7
+#endif
+#else
+#define PIC_PROLOGUE(dest,tmp)
+#define PICCY_OFFSET(var,dest,tmp)
+#endif
+
+#define FTYPE(x) .type x,@function
+#define OTYPE(x) .type x,@object
+
+#define _ENTRY(name) \
+ .align 4; .globl name; .proc 1; FTYPE(name); name:
+
+#ifdef GPROF
+/* see _MCOUNT_ENTRY in profile.h */
+#ifdef __ELF__
+#ifdef __arch64__
+#define _PROF_PROLOGUE \
+ .data; .align 8; 1: .uaword 0; .uaword 0; \
+ .text; save %sp,-CC64FSZ,%sp; sethi %hi(1b),%o0; call _mcount; \
+ or %o0,%lo(1b),%o0; restore
+#else
+#define _PROF_PROLOGUE \
+ .data; .align 4; 1: .long 0; \
+ .text; save %sp,-96,%sp; sethi %hi(1b),%o0; call _mcount; \
+ or %o0,%lo(1b),%o0; restore
+#endif
+#else
+#ifdef __arch64__
+#define _PROF_PROLOGUE \
+ .data; .align 8; 1: .uaword 0; .uaword 0; \
+ .text; save %sp,-CC64FSZ,%sp; sethi %hi(1b),%o0; call mcount; \
+ or %o0,%lo(1b),%o0; restore
+#else
+#define _PROF_PROLOGUE \
+ .data; .align 4; 1: .long 0; \
+ .text; save %sp,-96,%sp; sethi %hi(1b),%o0; call mcount; \
+ or %o0,%lo(1b),%o0; restore
+#endif
+#endif
+#else
+#define _PROF_PROLOGUE
+#endif
+
+#define ENTRY(name) _ENTRY(_C_LABEL(name)); _PROF_PROLOGUE
+#define ENTRY_NOPROFILE(name) _ENTRY(_C_LABEL(name))
+#define ASENTRY(name) _ENTRY(_ASM_LABEL(name)); _PROF_PROLOGUE
+#define FUNC(name) ASENTRY(name)
+#define RODATA(name) .align 4; .text; .globl _C_LABEL(name); \
+ OTYPE(_C_LABEL(name)); _C_LABEL(name):
+
+
+#define ASMSTR .asciz
+
+#define RCSID(name) .asciz name
+
+#ifdef __ELF__
+#define WEAK_ALIAS(alias,sym) \
+ .weak alias; \
+ alias = sym
+#endif
+
+/*
+ * WARN_REFERENCES: create a warning if the specified symbol is referenced.
+ */
+#ifdef __ELF__
+#ifdef __STDC__
+#define WARN_REFERENCES(_sym,_msg) \
+ .section .gnu.warning. ## _sym ; .ascii _msg ; .text
+#else
+#define WARN_REFERENCES(_sym,_msg) \
+ .section .gnu.warning./**/_sym ; .ascii _msg ; .text
+#endif /* __STDC__ */
+#else
+#ifdef __STDC__
+#define __STRING(x) #x
+#define WARN_REFERENCES(sym,msg) \
+ .stabs msg ## ,30,0,0,0 ; \
+ .stabs __STRING(_ ## sym) ## ,1,0,0,0
+#else
+#define __STRING(x) "x"
+#define WARN_REFERENCES(sym,msg) \
+ .stabs msg,30,0,0,0 ; \
+ .stabs __STRING(_/**/sym),1,0,0,0
+#endif /* __STDC__ */
+#endif /* __ELF__ */
+
+#endif /* _ASM_H_ */
diff --git a/klibc/include/arch/sparc/machine/frame.h b/klibc/include/arch/sparc/machine/frame.h
new file mode 100644
index 0000000000..b09175c7f4
--- /dev/null
+++ b/klibc/include/arch/sparc/machine/frame.h
@@ -0,0 +1,138 @@
+/* $NetBSD: frame.h,v 1.4 2001/12/04 00:05:05 darrenr 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. 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.
+ *
+ * @(#)frame.h 8.1 (Berkeley) 6/11/93
+ */
+
+#if defined(_KERNEL_OPT)
+#include "opt_sparc_arch.h"
+#endif
+
+/*
+ * Sparc stack frame format.
+ *
+ * Note that the contents of each stack frame may be held only in
+ * machine register windows. In order to get an accurate picture
+ * of the frame, you must first force the kernel to write any such
+ * windows to the stack.
+ */
+#ifndef _LOCORE
+#ifndef SUN4U
+struct frame {
+ int32_t fr_local[8]; /* space to save locals (%l0..%l7) */
+ int32_t fr_arg[6]; /* space to save arguments (%i0..%i5) */
+ struct frame *fr_fp; /* space to save frame pointer (%i6) */
+ int32_t fr_pc; /* space to save return pc (%i7) */
+ /*
+ * SunOS reserves another 8 words here; this is pointless
+ * but we do it for compatibility.
+ */
+ int32_t fr_xxx; /* `structure return pointer' (unused) */
+ int32_t fr_argd[6]; /* `arg dump area' (lunacy) */
+ int32_t fr_argx[1]; /* arg extension (args 7..n; variable size) */
+};
+#else
+struct frame32 {
+ int32_t fr_local[8]; /* space to save locals (%l0..%l7) */
+ int32_t fr_arg[6]; /* space to save arguments (%i0..%i5) */
+ u_int32_t fr_fp; /* space to save frame pointer (%i6) */
+ u_int32_t fr_pc; /* space to save return pc (%i7) */
+ /*
+ * SunOS reserves another 8 words here; this is pointless
+ * but we do it for compatibility.
+ */
+ int32_t fr_xxx; /* `structure return pointer' (unused) */
+ int32_t fr_argd[6]; /* `arg dump area' (lunacy) */
+ int32_t fr_argx[1]; /* arg extension (args 7..n; variable size) */
+};
+#endif
+#endif
+
+/*
+ * CCFSZ (C Compiler Frame SiZe) is the size of a stack frame required if
+ * a function is to call C code. It should be just 64, but Sun defined
+ * their frame with space to hold arguments 0 through 5 (plus some junk),
+ * and varargs routines (such as kprintf) demand this, and gcc uses this
+ * area at times anyway.
+ */
+#define CCFSZ 96
+
+/*
+ * Sparc v9 stack frame format.
+ *
+ * Note that the contents of each stack frame may be held only in
+ * machine register windows. In order to get an accurate picture
+ * of the frame, you must first force the kernel to write any such
+ * windows to the stack.
+ *
+ * V9 frames have an odd bias, so you can tall a v9 frame from
+ * a v8 frame by testing the stack pointer's lsb.
+ */
+#if !defined(_LOCORE) && !defined(_LIBC)
+struct frame64 {
+ int64_t fr_local[8]; /* space to save locals (%l0..%l7) */
+ int64_t fr_arg[6]; /* space to save arguments (%i0..%i5) */
+ u_int64_t fr_fp; /* space to save frame pointer (%i6) */
+ u_int64_t fr_pc; /* space to save return pc (%i7) */
+ /*
+ * SVR4 reserves a bunch of extra stuff.
+ */
+ int64_t fr_argd[6]; /* `register save area' (lunacy) */
+ int64_t fr_argx[0]; /* arg extension (args 7..n; variable size) */
+};
+
+#define v9next_frame(f) ((struct frame64*)(f->fr_fp+BIAS))
+#endif
+
+/*
+ * CC64FSZ (C Compiler 64-bit Frame SiZe) is the size of a stack frame used
+ * by the compiler in 64-bit mode. It is (16)*8; space for 8 ins, 8 outs.
+ */
+#define CC64FSZ 176
+
+/*
+ * v9 stacks all have a bias of 2047 added to the %sp and %fp, so you can easily
+ * detect it by testing the register for an odd value. Why 2K-1 I don't know.
+ */
+#define BIAS (2048-1)
+
diff --git a/klibc/include/arch/sparc/machine/trap.h b/klibc/include/arch/sparc/machine/trap.h
new file mode 100644
index 0000000000..42c3ef6ae2
--- /dev/null
+++ b/klibc/include/arch/sparc/machine/trap.h
@@ -0,0 +1,141 @@
+/* $NetBSD: trap.h,v 1.11 1999/01/20 00:15:08 pk 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. 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.
+ *
+ * @(#)trap.h 8.1 (Berkeley) 6/11/93
+ */
+/*
+ * Sun4m support by Aaron Brown, Harvard University.
+ * Changes Copyright (c) 1995 The President and Fellows of Harvard College.
+ * All rights reserved.
+ */
+
+#ifndef _MACHINE_TRAP_H
+#define _MACHINE_TRAP_H
+
+/* trap vec (pri) description */
+#define T_RESET 0x00 /* (1) not actually vectored; jumps to 0 */
+#define T_TEXTFAULT 0x01 /* (2) address fault during instr fetch */
+#define T_ILLINST 0x02 /* (3) illegal instruction */
+#define T_PRIVINST 0x03 /* (4) privileged instruction */
+#define T_FPDISABLED 0x04 /* (5) fp instr while fp disabled */
+#define T_WINOF 0x05 /* (6) register window overflow */
+#define T_WINUF 0x06 /* (7) register window underflow */
+#define T_ALIGN 0x07 /* (8) address not properly aligned */
+#define T_FPE 0x08 /* (9) floating point exception */
+#define T_DATAFAULT 0x09 /* (10) address fault during data fetch */
+#define T_TAGOF 0x0a /* (11) tag overflow */
+/* 0x0b unused */
+/* 0x0c unused */
+/* 0x0d unused */
+/* 0x0e unused */
+/* 0x0f unused */
+/* 0x10 unused */
+#define T_L1INT 0x11 /* (27) level 1 interrupt */
+#define T_L2INT 0x12 /* (26) level 2 interrupt */
+#define T_L3INT 0x13 /* (25) level 3 interrupt */
+#define T_L4INT 0x14 /* (24) level 4 interrupt */
+#define T_L5INT 0x15 /* (23) level 5 interrupt */
+#define T_L6INT 0x16 /* (22) level 6 interrupt */
+#define T_L7INT 0x17 /* (21) level 7 interrupt */
+#define T_L8INT 0x18 /* (20) level 8 interrupt */
+#define T_L9INT 0x19 /* (19) level 9 interrupt */
+#define T_L10INT 0x1a /* (18) level 10 interrupt */
+#define T_L11INT 0x1b /* (17) level 11 interrupt */
+#define T_L12INT 0x1c /* (16) level 12 interrupt */
+#define T_L13INT 0x1d /* (15) level 13 interrupt */
+#define T_L14INT 0x1e /* (14) level 14 interrupt */
+#define T_L15INT 0x1f /* (13) level 15 interrupt */
+/* 0x20 unused */
+/* through 0x23 unused */
+#define T_CPDISABLED 0x24 /* (5) coprocessor instr while disabled */
+#define T_UNIMPLFLUSH 0x25 /* Unimplemented FLUSH */
+/* through 0x27 unused */
+#define T_CPEXCEPTION 0x28 /* (9) coprocessor exception */
+/* 0x29 unused */
+#define T_IDIV0 0x2a /* divide by zero (from hw [su]div instr) */
+#define T_STOREBUFFAULT 0x2b /* SuperSPARC: Store buffer copy-back fault */
+/* 0x2c unused */
+/* through 0x7f unused */
+
+/* beginning of `user' vectors (from trap instructions) - all priority 12 */
+#define T_SUN_SYSCALL 0x80 /* system call */
+#define T_BREAKPOINT 0x81 /* breakpoint `instruction' */
+#define T_DIV0 0x82 /* division routine was handed 0 */
+#define T_FLUSHWIN 0x83 /* flush windows */
+#define T_CLEANWIN 0x84 /* provide clean windows */
+#define T_RANGECHECK 0x85 /* ? */
+#define T_FIXALIGN 0x86 /* fix up unaligned accesses */
+#define T_INTOF 0x87 /* integer overflow ? */
+#define T_SVR4_SYSCALL 0x88 /* SVR4 system call */
+#define T_BSD_SYSCALL 0x89 /* BSD system call */
+#define T_KGDB_EXEC 0x8a /* for kernel gdb */
+
+/* 0x8b..0xff are currently unallocated, except the following */
+#define T_SVR4_GETCC 0xa0
+#define T_SVR4_SETCC 0xa1
+#define T_SVR4_GETPSR 0xa2
+#define T_SVR4_SETPSR 0xa3
+#define T_SVR4_GETHRTIME 0xa4
+#define T_SVR4_GETHRVTIME 0xa5
+#define T_SVR4_GETHRESTIME 0xa7
+
+
+#ifdef _KERNEL /* pseudo traps for locore.s */
+#define T_RWRET -1 /* need first user window for trap return */
+#define T_AST -2 /* no-op, just needed reschedule or profile */
+#endif
+
+/* flags to system call (flags in %g1 along with syscall number) */
+#define SYSCALL_G2RFLAG 0x400 /* on success, return to %g2 rather than npc */
+#define SYSCALL_G7RFLAG 0x800 /* use %g7 as above (deprecated) */
+
+/*
+ * `software trap' macros to keep people happy (sparc v8 manual says not
+ * to set the upper bits).
+ */
+#define ST_BREAKPOINT (T_BREAKPOINT & 0x7f)
+#define ST_DIV0 (T_DIV0 & 0x7f)
+#define ST_FLUSHWIN (T_FLUSHWIN & 0x7f)
+#define ST_SYSCALL (T_SUN_SYSCALL & 0x7f)
+
+#endif /* _MACHINE_TRAP_H_ */
diff --git a/klibc/include/arch/sparc64/klibc/archsetjmp.h b/klibc/include/arch/sparc64/klibc/archsetjmp.h
new file mode 100644
index 0000000000..022a31e542
--- /dev/null
+++ b/klibc/include/arch/sparc64/klibc/archsetjmp.h
@@ -0,0 +1,16 @@
+/*
+ * arch/sparc64/include/klibc/archsetjmp.h
+ */
+
+#ifndef _KLIBC_ARCHSETJMP_H
+#define _KLIBC_ARCHSETJMP_H
+
+struct __jmp_buf {
+ unsigned long __sp;
+ unsigned long __fp;
+ unsigned long __pc;
+};
+
+typedef struct __jmp_buf jmp_buf[1];
+
+#endif /* _SETJMP_H */
diff --git a/klibc/include/arch/sparc64/klibc/archsignal.h b/klibc/include/arch/sparc64/klibc/archsignal.h
new file mode 100644
index 0000000000..f81bd668bb
--- /dev/null
+++ b/klibc/include/arch/sparc64/klibc/archsignal.h
@@ -0,0 +1,13 @@
+/*
+ * arch/sparc64/include/klibc/archsignal.h
+ *
+ * Architecture-specific signal definitions
+ *
+ */
+
+#ifndef _KLIBC_ARCHSIGNAL_H
+#define _KLIBC_ARCHSIGNAL_H
+
+/* No special stuff for this architecture */
+
+#endif
diff --git a/klibc/include/arch/sparc64/klibc/archstat.h b/klibc/include/arch/sparc64/klibc/archstat.h
new file mode 100644
index 0000000000..c22905d30c
--- /dev/null
+++ b/klibc/include/arch/sparc64/klibc/archstat.h
@@ -0,0 +1,22 @@
+#ifndef _KLIBC_ARCHSTAT_H
+#define _KLIBC_ARCHSTAT_H
+
+/* No nsec fields?! */
+struct stat {
+ unsigned st_dev;
+ ino_t st_ino;
+ mode_t st_mode;
+ short st_nlink;
+ uid_t st_uid;
+ gid_t st_gid;
+ unsigned st_rdev;
+ off_t st_size;
+ time_t st_atime;
+ time_t st_mtime;
+ time_t st_ctime;
+ off_t st_blksize;
+ off_t st_blocks;
+ unsigned long __unused4[2];
+};
+
+#endif
diff --git a/klibc/include/arch/sparc64/klibc/archsys.h b/klibc/include/arch/sparc64/klibc/archsys.h
new file mode 100644
index 0000000000..6a3a7b25bc
--- /dev/null
+++ b/klibc/include/arch/sparc64/klibc/archsys.h
@@ -0,0 +1,10 @@
+/*
+ * arch/sparc64/include/klibc/archsys.h
+ *
+ * Architecture-specific syscall definitions
+ */
+
+#ifndef _KLIBC_ARCHSYS_H
+#define _KLIBC_ARCHSYS_H
+
+#endif /* _KLIBC_ARCHSYS_H */
diff --git a/klibc/include/arch/x86_64/klibc/archsetjmp.h b/klibc/include/arch/x86_64/klibc/archsetjmp.h
new file mode 100644
index 0000000000..90d0a0d263
--- /dev/null
+++ b/klibc/include/arch/x86_64/klibc/archsetjmp.h
@@ -0,0 +1,21 @@
+/*
+ * arch/x86_64/include/klibc/archsetjmp.h
+ */
+
+#ifndef _KLIBC_ARCHSETJMP_H
+#define _KLIBC_ARCHSETJMP_H
+
+struct __jmp_buf {
+ unsigned long __rbx;
+ unsigned long __rsp;
+ unsigned long __rbp;
+ unsigned long __r12;
+ unsigned long __r13;
+ unsigned long __r14;
+ unsigned long __r15;
+ unsigned long __rip;
+};
+
+typedef struct __jmp_buf jmp_buf[1];
+
+#endif /* _SETJMP_H */
diff --git a/klibc/include/arch/x86_64/klibc/archsignal.h b/klibc/include/arch/x86_64/klibc/archsignal.h
new file mode 100644
index 0000000000..74e82e1dd0
--- /dev/null
+++ b/klibc/include/arch/x86_64/klibc/archsignal.h
@@ -0,0 +1,13 @@
+/*
+ * arch/x86_64/include/klibc/archsignal.h
+ *
+ * Architecture-specific signal definitions
+ *
+ */
+
+#ifndef _KLIBC_ARCHSIGNAL_H
+#define _KLIBC_ARCHSIGNAL_H
+
+/* No special stuff for this architecture */
+
+#endif
diff --git a/klibc/include/arch/x86_64/klibc/archstat.h b/klibc/include/arch/x86_64/klibc/archstat.h
new file mode 100644
index 0000000000..53e141daea
--- /dev/null
+++ b/klibc/include/arch/x86_64/klibc/archstat.h
@@ -0,0 +1,26 @@
+#ifndef _KLIBC_ARCHSTAT_H
+#define _KLIBC_ARCHSTAT_H
+
+#define _STATBUF_ST_NSEC
+
+struct stat {
+ unsigned long st_dev;
+ unsigned long st_ino;
+ unsigned long st_nlink;
+
+ unsigned int st_mode;
+ unsigned int st_uid;
+ unsigned int st_gid;
+ unsigned int __pad0;
+ unsigned long st_rdev;
+ long st_size;
+ long st_blksize;
+ long st_blocks; /* Number 512-byte blocks allocated. */
+
+ struct timespec st_atim;
+ struct timespec st_mtim;
+ struct timespec st_ctim;
+ long __unused[3];
+};
+
+#endif
diff --git a/klibc/include/arch/x86_64/klibc/archsys.h b/klibc/include/arch/x86_64/klibc/archsys.h
new file mode 100644
index 0000000000..2ec72cd397
--- /dev/null
+++ b/klibc/include/arch/x86_64/klibc/archsys.h
@@ -0,0 +1,109 @@
+/*
+ * arch/x86_64/include/klibc/archsys.h
+ *
+ * Architecture-specific syscall definitions
+ */
+
+#ifndef _KLIBC_ARCHSYS_H
+#define _KLIBC_ARCHSYS_H
+
+/* The x86-64 syscall headers are needlessly inefficient */
+
+#undef _syscall0
+#undef _syscall1
+#undef _syscall2
+#undef _syscall3
+#undef _syscall4
+#undef _syscall5
+#undef _syscall6
+
+#define _syscall0(type,name) \
+type name (void) \
+{ \
+long __res; \
+__asm__ volatile (__syscall \
+ : "=a" (__res) \
+ : "0" (__NR_##name) \
+ : __syscall_clobber); \
+__syscall_return(type,__res); \
+}
+
+#define _syscall1(type,name,type1,arg1) \
+type name (type1 arg1) \
+{ \
+long __res; \
+__asm__ volatile (__syscall \
+ : "=a" (__res) \
+ : "0" (__NR_##name),"D" (arg1) \
+ : __syscall_clobber); \
+__syscall_return(type,__res); \
+}
+
+#define _syscall2(type,name,type1,arg1,type2,arg2) \
+type name (type1 arg1,type2 arg2) \
+{ \
+long __res; \
+__asm__ volatile (__syscall \
+ : "=a" (__res) \
+ : "0" (__NR_##name),"D" (arg1),"S" (arg2) \
+ : __syscall_clobber); \
+__syscall_return(type,__res); \
+}
+
+#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
+type name (type1 arg1,type2 arg2,type3 arg3) \
+{ \
+long __res; \
+__asm__ volatile (__syscall \
+ : "=a" (__res) \
+ : "0" (__NR_##name),"D" (arg1),"S" (arg2), \
+ "d" (arg3) \
+ : __syscall_clobber); \
+__syscall_return(type,__res); \
+}
+
+#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
+type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4) \
+{ \
+long __res; \
+register type4 __r10 asm("%r10") = arg4; \
+__asm__ volatile (__syscall \
+ : "=a" (__res) \
+ : "0" (__NR_##name),"D" (arg1),"S" (arg2), \
+ "d" (arg3),"r" (__r10) \
+ : __syscall_clobber); \
+__syscall_return(type,__res); \
+}
+
+#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
+ type5,arg5) \
+type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \
+{ \
+long __res; \
+register type4 __r10 asm("%r10") = arg4; \
+register type5 __r8 asm("%r8") = arg5; \
+__asm__ volatile (__syscall \
+ : "=a" (__res) \
+ : "0" (__NR_##name),"D" (arg1),"S" (arg2), \
+ "d" (arg3),"r" (__r10),"r" (__r8) \
+ : __syscall_clobber); \
+__syscall_return(type,__res); \
+}
+
+#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
+ type5,arg5,type6,arg6) \
+type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5,type6 arg6) \
+{ \
+long __res; \
+register type4 __r10 asm("%r10") = arg4; \
+register type5 __r8 asm("%r8") = arg5; \
+register type6 __r9 asm("%r9") = arg6; \
+__asm__ volatile (__syscall \
+ : "=a" (__res) \
+ : "0" (__NR_##name),"D" (arg1),"S" (arg2), \
+ "d" (arg3),"r" (__r10),"r" (__r8), "r" (__r9) \
+ : __syscall_clobber); \
+__syscall_return(type,__res); \
+}
+
+#endif /* _KLIBC_ARCHSYS_H */
diff --git a/klibc/include/arch/x86_64/sys/io.h b/klibc/include/arch/x86_64/sys/io.h
new file mode 100644
index 0000000000..4a0ae44985
--- /dev/null
+++ b/klibc/include/arch/x86_64/sys/io.h
@@ -0,0 +1,126 @@
+#ident "$Id: io.h,v 1.1 2004/01/25 01:34:29 hpa Exp $"
+/* ----------------------------------------------------------------------- *
+ *
+ * Copyright 2004 H. Peter Anvin - All Rights Reserved
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall
+ * be included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * ----------------------------------------------------------------------- */
+
+/*
+ * sys/io.h for the i386 architecture
+ *
+ * Basic I/O macros
+ */
+
+#ifndef _SYS_IO_H
+#define _SYS_IO_H 1
+
+/* I/O-related system calls */
+
+int iopl(int);
+int ioperm(unsigned long, unsigned long, int);
+
+/* Basic I/O macros */
+
+static __inline__ void
+outb(unsigned char __v, unsigned short __p)
+{
+ asm volatile("outb %0,%1" : : "a" (__v), "dN" (__p));
+}
+
+static __inline__ void
+outw(unsigned short __v, unsigned short __p)
+{
+ asm volatile("outw %0,%1" : : "a" (__v), "dN" (__p));
+}
+
+static __inline__ void
+outl(unsigned int __v, unsigned short __p)
+{
+ asm volatile("outl %0,%1" : : "a" (__v), "dN" (__p));
+}
+
+static __inline__ unsigned char
+inb(unsigned short __p)
+{
+ unsigned char __v;
+ asm volatile("inb %1,%0" : "=a" (__v) : "dN" (__p));
+ return v;
+}
+
+static __inline__ unsigned short
+inw(unsigned short __p)
+{
+ unsigned short __v;
+ asm volatile("inw %1,%0" : "=a" (__v) : "dN" (__p));
+ return v;
+}
+
+static __inline__ unsigned int
+inl(unsigned short __p)
+{
+ unsigned int __v;
+ asm volatile("inl %1,%0" : "=a" (__v) : "dN" (__p));
+ return v;
+}
+
+/* String I/O macros */
+
+static __inline__ void
+outsb (unsigned short __p, const void *__d, unsigned long __n)
+{
+ asm volatile("cld; rep; outsb" : "+S" (__d), "+c" (__n) : "d" (__p));
+}
+
+static __inline__ void
+outsw (unsigned short __p, const void *__d, unsigned long __n)
+{
+ asm volatile("cld; rep; outsw" : "+S" (__d), "+c" (__n) : "d" (__p));
+}
+
+static __inline__ void
+outsl (unsigned short __p, const void *__d, unsigned long __n)
+{
+ asm volatile("cld; rep; outsl" : "+S" (__d), "+c" (__n) : "d" (__p));
+}
+
+
+static __inline__ void
+insb (unsigned short __p, void *__d, unsigned long __n)
+{
+ asm volatile("cld; rep; insb" : "+D" (__d), "+c" (__n) : "d" (__p));
+}
+
+static __inline__ void
+insw (unsigned short __p, void *__d, unsigned long __n)
+{
+ asm volatile("cld; rep; insw" : "+D" (__d), "+c" (__n) : "d" (__p));
+}
+
+static __inline__ void
+insl (unsigned short __p, void *__d, unsigned long __n)
+{
+ asm volatile("cld; rep; insl" : "+D" (__d), "+c" (__n) : "d" (__p));
+}
+
+#endif /* _SYS_IO_H */