summaryrefslogtreecommitdiff
path: root/libc/sysdeps/linux/h8300/bits
diff options
context:
space:
mode:
Diffstat (limited to 'libc/sysdeps/linux/h8300/bits')
-rw-r--r--libc/sysdeps/linux/h8300/bits/atomicity.h79
-rw-r--r--libc/sysdeps/linux/h8300/bits/huge_val.h75
-rw-r--r--libc/sysdeps/linux/h8300/bits/kernel_stat.h5
-rw-r--r--libc/sysdeps/linux/h8300/bits/kernel_types.h24
-rw-r--r--libc/sysdeps/linux/h8300/bits/mman.h20
-rw-r--r--libc/sysdeps/linux/h8300/bits/resource.h204
-rw-r--r--libc/sysdeps/linux/h8300/bits/setjmp.h42
-rw-r--r--libc/sysdeps/linux/h8300/bits/sigcontextinfo.h26
-rw-r--r--libc/sysdeps/linux/h8300/bits/stackinfo.h28
-rw-r--r--libc/sysdeps/linux/h8300/bits/syscalls.h156
-rw-r--r--libc/sysdeps/linux/h8300/bits/wordsize.h20
11 files changed, 316 insertions, 363 deletions
diff --git a/libc/sysdeps/linux/h8300/bits/atomicity.h b/libc/sysdeps/linux/h8300/bits/atomicity.h
new file mode 100644
index 000000000..a4fcc1524
--- /dev/null
+++ b/libc/sysdeps/linux/h8300/bits/atomicity.h
@@ -0,0 +1,79 @@
+/* Low-level functions for atomic operations. H8/300 version.
+ Copyright (C) 1997, 2000, 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _ATOMICITY_H
+#define _ATOMICITY_H 1
+
+#include <inttypes.h>
+
+
+static inline uint32_t
+__attribute__ ((unused))
+exchange_and_add (volatile uint32_t *mem, uint32_t val)
+{
+ uint32_t result;
+ __asm__ __volatile__ ("stc ccr,@-sp\n\t"
+ "orc #0x80,ccr\n\t"
+ "mov.l %1,er1\n\t"
+ "mov.l %0,%1\n\t"
+ "add.l er1,%0\n\t"
+ "ldc @sp+,ccr"
+ : "=r" (result), "=m" (*mem)
+ : "0" (val), "1" (*mem)
+ : "er1");
+ return result;
+}
+
+static inline void
+__attribute__ ((unused))
+atomic_add (volatile uint32_t *mem, int val)
+{
+ __asm__ __volatile__ ("stc ccr,@-sp\n\t"
+ "orc #0x80,ccr\n\t"
+ "mov.l %0,er0\n\t"
+ "add %1,er0\n\t"
+ "mov.l er0,%0\n\t"
+ "ldc @sp+,ccr"
+ : "=m" (*mem)
+ : "r" (val), "0" (*mem)
+ : "er0");
+}
+
+static inline int
+__attribute__ ((unused))
+compare_and_swap (volatile long int *p, long int oldval, long int newval)
+{
+ int ret = 0;
+
+ __asm__ __volatile__ ("stc ccr,@-sp\n\t"
+ "orc #0x80,ccr\n\t"
+ "mov.l %1,er0\n\t"
+ "cmp.l %2,er0\n\t"
+ "bne 1f\n\t"
+ "mov.l %3,%1\n\t"
+ "inc.l #1,%0\n"
+ "1:\n\t"
+ "ldc @sp+,ccr"
+ : "=r"(ret),"=m"(*p)
+ : "r"(oldval),"r"(newval),"0"(ret),"1"(*p)
+ : "er0");
+ return ret;
+}
+
+#endif /* atomicity.h */
diff --git a/libc/sysdeps/linux/h8300/bits/huge_val.h b/libc/sysdeps/linux/h8300/bits/huge_val.h
deleted file mode 100644
index 822b82930..000000000
--- a/libc/sysdeps/linux/h8300/bits/huge_val.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/* `HUGE_VAL' constants for m68k (where it is infinity).
- Used by <stdlib.h> and <math.h> functions for overflow.
- Copyright (C) 1992, 1995, 1996, 1997 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with the GNU C Library; see the file COPYING.LIB. If not,
- write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA. */
-
-#ifndef _MATH_H
-# error "Never use <bits/huge_val.h> directly; include <math.h> instead."
-#endif
-
-
-#include <features.h>
-#include <sys/cdefs.h>
-
-/* IEEE positive infinity (-HUGE_VAL is negative infinity). */
-
-#ifdef __GNUC__
-
-# define HUGE_VAL \
- (__extension__ \
- ((union { unsigned long long __l; double __d; }) \
- { __l: 0x7ff0000000000000ULL }).__d)
-
-#else /* not GCC */
-
-static union { unsigned char __c[8]; double __d; } __huge_val =
- { { 0x7f, 0xf0, 0, 0, 0, 0, 0, 0 } };
-# define HUGE_VAL (__huge_val.__d)
-
-#endif /* GCC. */
-
-
-/* ISO C 9X extensions: (float) HUGE_VALF and (long double) HUGE_VALL. */
-
-#ifdef __USE_ISOC9X
-
-# ifdef __GNUC__
-
-# define HUGE_VALF \
- (__extension__ \
- ((union { unsigned long __l; float __f; }) \
- { __l: 0x7f800000UL }).__f)
-
-# define HUGE_VALL \
- (__extension__ \
- ((union { unsigned long __l[3]; long double __ld; }) \
- { __l: { 0x7fff0000UL, 0x80000000UL, 0UL } }).__ld)
-
-# else /* not GCC */
-
-static union { unsigned char __c[4]; float __f; } __huge_valf =
- { { 0x7f, 0x80, 0, 0 } };
-# define HUGE_VALF (__huge_valf.__f)
-
-static union { unsigned char __c[12]; long double __ld; } __huge_vall =
- { { 0x7f, 0xff, 0, 0, 0x80, 0, 0, 0, 0, 0, 0, 0 } };
-# define HUGE_VALL (__huge_vall.__ld)
-
-# endif /* GCC. */
-
-#endif /* __USE_ISOC9X. */
diff --git a/libc/sysdeps/linux/h8300/bits/kernel_stat.h b/libc/sysdeps/linux/h8300/bits/kernel_stat.h
index 3d2805e7f..c227a30d0 100644
--- a/libc/sysdeps/linux/h8300/bits/kernel_stat.h
+++ b/libc/sysdeps/linux/h8300/bits/kernel_stat.h
@@ -38,13 +38,12 @@ struct kernel_stat64 {
unsigned int st_nlink;
unsigned long st_uid;
unsigned long st_gid;
- unsigned char __pad2[6];
unsigned short st_rdev;
- unsigned char __pad3[2];
+ unsigned char __pad3[10];
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. */
+ unsigned long __pad4; /* future possible st_blocks high bits */
unsigned long st_atime;
unsigned long __pad5;
unsigned long st_mtime;
diff --git a/libc/sysdeps/linux/h8300/bits/kernel_types.h b/libc/sysdeps/linux/h8300/bits/kernel_types.h
index ad0c08271..057067560 100644
--- a/libc/sysdeps/linux/h8300/bits/kernel_types.h
+++ b/libc/sysdeps/linux/h8300/bits/kernel_types.h
@@ -1,11 +1,11 @@
-/* Note that we use the exact same include guard #define names
- * as asm/posix_types.h. This will avoid gratuitous conflicts
- * with the posix_types.h kernel header, and will ensure that
- * our private content, and not the kernel header, will win.
- * -Erik
- */
-#ifndef __ARCH_H8300_POSIX_TYPES_H
-#define __ARCH_H8300_POSIX_TYPES_H
+#ifndef _BITS_KERNEL_TYPES_H
+#define _BITS_KERNEL_TYPES_H
+
+/* Sigh. We need to carefully wrap this one... No guarantees
+ * that the asm/posix_types.h kernel header is working. Many
+ * arches have broken headers that introduce tons of gratuitous
+ * conflicts with uClibc's namespace. See bits/kernel_types.h
+ * for i386, arm, etc for examples... */
typedef unsigned short __kernel_dev_t;
typedef unsigned long __kernel_ino_t;
@@ -28,14 +28,10 @@ typedef unsigned short __kernel_uid16_t;
typedef unsigned short __kernel_gid16_t;
typedef unsigned int __kernel_uid32_t;
typedef unsigned int __kernel_gid32_t;
-
typedef unsigned short __kernel_old_uid_t;
typedef unsigned short __kernel_old_gid_t;
-typedef __kernel_dev_t __kernel_old_dev_t;
-
-#ifdef __GNUC__
typedef long long __kernel_loff_t;
-#endif
+typedef __kernel_dev_t __kernel_old_dev_t;
typedef struct {
#ifdef __USE_ALL
@@ -45,4 +41,4 @@ typedef struct {
#endif
} __kernel_fsid_t;
-#endif /* __ARCH_H8300_POSIX_TYPES_H */
+#endif /* _BITS_KERNEL_TYPES_H */
diff --git a/libc/sysdeps/linux/h8300/bits/mman.h b/libc/sysdeps/linux/h8300/bits/mman.h
index 4bf232029..34f14ee5b 100644
--- a/libc/sysdeps/linux/h8300/bits/mman.h
+++ b/libc/sysdeps/linux/h8300/bits/mman.h
@@ -1,5 +1,5 @@
-/* Definitions for BSD-style memory management.
- Copyright (C) 1994-1998,2000,01 Free Software Foundation, Inc.
+/* Definitions for POSIX memory map interface. Linux/m68k version.
+ Copyright (C) 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -17,23 +17,23 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
-/* These are the bits used by 4.4 BSD and its derivatives. On systems
- (such as GNU) where these facilities are not system services but can be
- emulated in the C library, these are the definitions we emulate. */
-
#ifndef _SYS_MMAN_H
# error "Never use <bits/mman.h> directly; include <sys/mman.h> instead."
#endif
+/* The following definitions basically come from the kernel headers.
+ But the kernel header is not namespace clean. */
+
+
/* Protections are chosen from these bits, OR'd together. The
implementation does not necessarily support PROT_EXEC or PROT_WRITE
without PROT_READ. The only guarantees are that no writing will be
allowed without PROT_WRITE and no access will be allowed for PROT_NONE. */
-#define PROT_NONE 0x00 /* No access. */
-#define PROT_READ 0x01 /* Pages can be read. */
-#define PROT_WRITE 0x02 /* Pages can be written. */
-#define PROT_EXEC 0x04 /* Pages can be executed. */
+#define PROT_READ 0x1 /* Page can be read. */
+#define PROT_WRITE 0x2 /* Page can be written. */
+#define PROT_EXEC 0x4 /* Page can be executed. */
+#define PROT_NONE 0x0 /* Page can not be accessed. */
/* Sharing types (must choose one and only one of these). */
#define MAP_SHARED 0x01 /* Share changes. */
diff --git a/libc/sysdeps/linux/h8300/bits/resource.h b/libc/sysdeps/linux/h8300/bits/resource.h
deleted file mode 100644
index 50c659389..000000000
--- a/libc/sysdeps/linux/h8300/bits/resource.h
+++ /dev/null
@@ -1,204 +0,0 @@
-/* Bit values & structures for resource limits. Linux version.
- Copyright (C) 1994, 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with the GNU C Library; see the file COPYING.LIB. If not,
- write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA. */
-
-#ifndef _SYS_RESOURCE_H
-# error "Never use <bits/resource.h> directly; include <sys/resource.h> instead."
-#endif
-
-#include <bits/types.h>
-
-/* Transmute defines to enumerations. The macro re-definitions are
- necessary because some programs want to test for operating system
- features with #ifdef RUSAGE_SELF. In ISO C the reflexive
- definition is a no-op. */
-
-/* Kinds of resource limit. */
-enum __rlimit_resource
-{
- /* Per-process CPU limit, in seconds. */
- RLIMIT_CPU = 0,
-#define RLIMIT_CPU RLIMIT_CPU
-
- /* Largest file that can be created, in bytes. */
- RLIMIT_FSIZE = 1,
-#define RLIMIT_FSIZE RLIMIT_FSIZE
-
- /* Maximum size of data segment, in bytes. */
- RLIMIT_DATA = 2,
-#define RLIMIT_DATA RLIMIT_DATA
-
- /* Maximum size of stack segment, in bytes. */
- RLIMIT_STACK = 3,
-#define RLIMIT_STACK RLIMIT_STACK
-
- /* Largest core file that can be created, in bytes. */
- RLIMIT_CORE = 4,
-#define RLIMIT_CORE RLIMIT_CORE
-
- /* Largest resident set size, in bytes.
- This affects swapping; processes that are exceeding their
- resident set size will be more likely to have physical memory
- taken from them. */
- RLIMIT_RSS = 5,
-#define RLIMIT_RSS RLIMIT_RSS
-
- /* Number of open files. */
- RLIMIT_NOFILE = 7,
- RLIMIT_OFILE = RLIMIT_NOFILE, /* BSD name for same. */
-#define RLIMIT_NOFILE RLIMIT_NOFILE
-#define RLIMIT_OFILE RLIMIT_OFILE
-
- /* Address space limit (?) */
- RLIMIT_AS = 9,
-#define RLIMIT_AS RLIMIT_AS
-
- /* Number of processes. */
- RLIMIT_NPROC = 6,
-#define RLIMIT_NPROC RLIMIT_NPROC
-
- /* Locked-in-memory address space. */
- RLIMIT_MEMLOCK = 8,
-#define RLIMIT_MEMLOCK RLIMIT_MEMLOCK
-
- RLIM_NLIMITS = 10
-#define RLIMIT_NLIMITS RLIMIT_NLIMITS
-#define RLIM_NLIMITS RLIM_NLIMITS
-};
-
-/* Value to indicate that there is no limit. */
-#ifndef __USE_FILE_OFFSET64
-# define RLIM_INFINITY ((long int)(~0UL >> 1))
-#else
-# define RLIM_INFINITY 0x7fffffffffffffffLL
-#endif
-
-#ifdef __USE_LARGEFILE64
-# define RLIM64_INFINITY 0x7fffffffffffffffLL
-#endif
-
-/* We can represent all limits. */
-#define RLIM_SAVED_MAX RLIM_INFINITY
-#define RLIM_SAVED_CUR RLIM_INFINITY
-
-
-/* Type for resource quantity measurement. */
-#ifndef __USE_FILE_OFFSET64
-typedef __rlim_t rlim_t;
-#else
-typedef __rlim64_t rlim_t;
-#endif
-#ifdef __USE_LARGEFILE64
-typedef __rlim64_t rlim64_t;
-#endif
-
-struct rlimit
- {
- /* The current (soft) limit. */
- rlim_t rlim_cur;
- /* The hard limit. */
- rlim_t rlim_max;
- };
-
-#ifdef __USE_LARGEFILE64
-struct rlimit64
- {
- /* The current (soft) limit. */
- rlim64_t rlim_cur;
- /* The hard limit. */
- rlim64_t rlim_max;
- };
-#endif
-
-/* Whose usage statistics do you want? */
-enum __rusage_who
-{
- /* The calling process. */
- RUSAGE_SELF = 0,
-#define RUSAGE_SELF RUSAGE_SELF
-
- /* All of its terminated child processes. */
- RUSAGE_CHILDREN = -1,
-#define RUSAGE_CHILDREN RUSAGE_CHILDREN
-
- /* Both. */
- RUSAGE_BOTH = -2
-#define RUSAGE_BOTH RUSAGE_BOTH
-};
-
-#define __need_timeval
-#include <bits/time.h> /* For `struct timeval'. */
-
-/* Structure which says how much of each resource has been used. */
-struct rusage
- {
- /* Total amount of user time used. */
- struct timeval ru_utime;
- /* Total amount of system time used. */
- struct timeval ru_stime;
- /* Maximum resident set size (in kilobytes). */
- long int ru_maxrss;
- /* Amount of sharing of text segment memory
- with other processes (kilobyte-seconds). */
- long int ru_ixrss;
- /* Amount of data segment memory used (kilobyte-seconds). */
- long int ru_idrss;
- /* Amount of stack memory used (kilobyte-seconds). */
- long int ru_isrss;
- /* Number of soft page faults (i.e. those serviced by reclaiming
- a page from the list of pages awaiting reallocation. */
- long int ru_minflt;
- /* Number of hard page faults (i.e. those that required I/O). */
- long int ru_majflt;
- /* Number of times a process was swapped out of physical memory. */
- long int ru_nswap;
- /* Number of input operations via the file system. Note: This
- and `ru_oublock' do not include operations with the cache. */
- long int ru_inblock;
- /* Number of output operations via the file system. */
- long int ru_oublock;
- /* Number of IPC messages sent. */
- long int ru_msgsnd;
- /* Number of IPC messages received. */
- long int ru_msgrcv;
- /* Number of signals delivered. */
- long int ru_nsignals;
- /* Number of voluntary context switches, i.e. because the process
- gave up the process before it had to (usually to wait for some
- resource to be available). */
- long int ru_nvcsw;
- /* Number of involuntary context switches, i.e. a higher priority process
- became runnable or the current process used up its time slice. */
- long int ru_nivcsw;
- };
-
-/* Priority limits. */
-#define PRIO_MIN -20 /* Minimum priority a process can have. */
-#define PRIO_MAX 20 /* Maximum priority a process can have. */
-
-/* The type of the WHICH argument to `getpriority' and `setpriority',
- indicating what flavor of entity the WHO argument specifies. */
-enum __priority_which
-{
- PRIO_PROCESS = 0, /* WHO is a process ID. */
-#define PRIO_PROCESS PRIO_PROCESS
- PRIO_PGRP = 1, /* WHO is a process group ID. */
-#define PRIO_PGRP PRIO_PGRP
- PRIO_USER = 2 /* WHO is a user ID. */
-#define PRIO_USER PRIO_USER
-};
diff --git a/libc/sysdeps/linux/h8300/bits/setjmp.h b/libc/sysdeps/linux/h8300/bits/setjmp.h
index 78f9c83fb..024861440 100644
--- a/libc/sysdeps/linux/h8300/bits/setjmp.h
+++ b/libc/sysdeps/linux/h8300/bits/setjmp.h
@@ -1,43 +1,27 @@
-/* Copyright (C) 1997, 1998 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with the GNU C Library; see the file COPYING.LIB. If not,
- write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA. */
-
-/* Define the machine-dependent type `jmp_buf'. H8/300H version. */
+/* Copyright (C) 2004, Yoshinori Sato <ysato@users.sourceforge.jp> */
+/* Define the machine-dependent type `jmp_buf'. H8/300 version. */
#ifndef _SETJMP_H
# error "Never include <bits/setjmp.h> directly; use <setjmp.h> instead."
#endif
-#include <signal.h>
+#ifndef _ASM
typedef struct
{
- /* er1-er5 */
- long int __regs[5];
-
- /* er6 */
- int *__fp;
- /* sp */
- int *__sp;
- /* pc */
- void *__pc;
+ unsigned long __regs[4]; /* save er4 - er7(sp) */
+ unsigned long __pc; /* the return address */
} __jmp_buf[1];
+#endif /* _ASM */
+
+#define JB_REGS 0
+#define JB_PC 16
+#define JB_SIZE 20
+
+
/* Test if longjmp to JMPBUF would unwind the frame
containing a local variable at ADDRESS. */
#define _JMPBUF_UNWINDS(jmpbuf, address) \
- ((void *) (address) < (void *) (jmpbuf)->__sp)
+ ((void *) (address) < (void *) (jmpbuf)->__regs[3])
diff --git a/libc/sysdeps/linux/h8300/bits/sigcontextinfo.h b/libc/sysdeps/linux/h8300/bits/sigcontextinfo.h
new file mode 100644
index 000000000..b7e08cfc9
--- /dev/null
+++ b/libc/sysdeps/linux/h8300/bits/sigcontextinfo.h
@@ -0,0 +1,26 @@
+/* Copyright (C) 1998, 1999, 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>, 1998.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#define SIGCONTEXT int _code, struct sigcontext *
+#define SIGCONTEXT_EXTRA_ARGS _code,
+#define GET_PC(ctx) ((void *) (ctx)->sc_pc)
+#define GET_FRAME(ctx) ((void *) __builtin_frame_address (1))
+#define GET_STACK(ctx) ((void *) (ctx)->sc_usp)
+#define CALL_SIGHANDLER(handler, signo, ctx) \
+ (handler)((signo), SIGCONTEXT_EXTRA_ARGS (ctx))
diff --git a/libc/sysdeps/linux/h8300/bits/stackinfo.h b/libc/sysdeps/linux/h8300/bits/stackinfo.h
new file mode 100644
index 000000000..89a77d932
--- /dev/null
+++ b/libc/sysdeps/linux/h8300/bits/stackinfo.h
@@ -0,0 +1,28 @@
+/* Copyright (C) 1999 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* This file contains a bit of information about the stack allocation
+ of the processor. */
+
+#ifndef _STACKINFO_H
+#define _STACKINFO_H 1
+
+/* On h8300 the stack grows down. */
+#define _STACK_GROWS_DOWN 1
+
+#endif /* stackinfo.h */
diff --git a/libc/sysdeps/linux/h8300/bits/syscalls.h b/libc/sysdeps/linux/h8300/bits/syscalls.h
index 62541b873..b734a6251 100644
--- a/libc/sysdeps/linux/h8300/bits/syscalls.h
+++ b/libc/sysdeps/linux/h8300/bits/syscalls.h
@@ -1,19 +1,157 @@
-#ifndef _BITS_SYSCALLS_H
-#define _BITS_SYSCALLS_H
+/* Unlike the asm/unistd.h kernel header file (which this is partly based on),
+ * this file must be able to cope with PIC and non-PIC code. For some arches
+ * there is no difference. For x86 (which has far too few registers) there is
+ * a difference. Regardless, including asm/unistd.h is hereby officially
+ * forbidden. Don't do it. It is bad for you.
+ */
#ifndef _SYSCALL_H
# error "Never use <bits/syscalls.h> directly; include <sys/syscall.h> instead."
#endif
-#include <features.h>
-
-/* Do something very evil for now. Until we create our own syscall
- * macros, short circuit bits/sysnum.h and use asm/unistd.h instead */
-#include <asm/unistd.h>
-
/* This includes the `__NR_<name>' syscall numbers taken from the Linux kernel
* header files. It also defines the traditional `SYS_<name>' macros for older
* programs. */
#include <bits/sysnum.h>
-#endif /* _BITS_SYSCALLS_H */
+
+#define __syscall_return(type, res) \
+do { \
+ if ((unsigned long)(res) >= (unsigned long)(-125)) { \
+ /* avoid using res which is declared to be in register d0; \
+ errno might expand to a function call and clobber it. */ \
+ int __err = -(res); \
+ errno = __err; \
+ res = -1; \
+ } \
+ return (type) (res); \
+} while (0)
+
+#define _syscall0(type, name) \
+type name(void) \
+{ \
+ register long __res __asm__("er0"); \
+ __asm__ __volatile__ ("mov.l %1,er0\n\t" \
+ "trapa #0\n\t" \
+ : "=r" (__res) \
+ : "ir" (__NR_##name) \
+ : "cc"); \
+ if ((unsigned long)(__res) >= (unsigned long)(-125)) { \
+ errno = -__res; \
+ __res = -1; \
+ } \
+ return (type)__res; \
+}
+
+#define _syscall1(type, name, atype, a) \
+type name(atype a) \
+{ \
+ register long __res __asm__("er0"); \
+ __asm__ __volatile__ ("mov.l %2, er1\n\t" \
+ "mov.l %1, er0\n\t" \
+ "trapa #0\n\t" \
+ : "=r" (__res) \
+ : "ir" (__NR_##name), \
+ "g" ((long)a) \
+ : "cc", "er1"); \
+ if ((unsigned long)(__res) >= (unsigned long)(-125)) { \
+ errno = -__res; \
+ __res = -1; \
+ } \
+ return (type)__res; \
+}
+
+#define _syscall2(type, name, atype, a, btype, b) \
+type name(atype a, btype b) \
+{ \
+ register long __res __asm__("er0"); \
+ __asm__ __volatile__ ("mov.l %3, er2\n\t" \
+ "mov.l %2, er1\n\t" \
+ "mov.l %1, er0\n\t" \
+ "trapa #0\n\t" \
+ : "=r" (__res) \
+ : "ir" (__NR_##name), \
+ "g" ((long)a), \
+ "g" ((long)b) \
+ : "cc", "er1", "er2"); \
+ if ((unsigned long)(__res) >= (unsigned long)(-125)) { \
+ errno = -__res; \
+ __res = -1; \
+ } \
+ return (type)__res; \
+}
+
+#define _syscall3(type, name, atype, a, btype, b, ctype, c) \
+type name(atype a, btype b, ctype c) \
+{ \
+ register long __res __asm__("er0"); \
+ __asm__ __volatile__ ("mov.l %4, er3\n\t" \
+ "mov.l %3, er2\n\t" \
+ "mov.l %2, er1\n\t" \
+ "mov.l %1, er0\n\t" \
+ "trapa #0\n\t" \
+ : "=r" (__res) \
+ : "ir" (__NR_##name), \
+ "g" ((long)a), \
+ "g" ((long)b), \
+ "g" ((long)c) \
+ : "cc", "er1", "er2", "er3"); \
+ if ((unsigned long)(__res) >= (unsigned long)(-125)) { \
+ errno = -__res; \
+ __res = -1; \
+ } \
+ return (type)__res; \
+}
+
+#define _syscall4(type, name, atype, a, btype, b, ctype, c, dtype, d) \
+type name(atype a, btype b, ctype c, dtype d) \
+{ \
+ register long __res __asm__("er0"); \
+ __asm__ __volatile__ ("mov.l %5, er4\n\t" \
+ "mov.l %4, er3\n\t" \
+ "mov.l %3, er2\n\t" \
+ "mov.l %2, er1\n\t" \
+ "mov.l %1, er0\n\t" \
+ "trapa #0\n\t" \
+ : "=r" (__res) \
+ : "ir" (__NR_##name), \
+ "g" ((long)a), \
+ "g" ((long)b), \
+ "g" ((long)c), \
+ "g" ((long)d) \
+ : "cc", "er1", "er2", "er3", "er4"); \
+ if ((unsigned long)(__res) >= (unsigned long)(-125)) { \
+ errno = -__res; \
+ __res = -1; \
+ } \
+ return (type)__res; \
+}
+
+#define _syscall5(type, name, atype, a, btype, b, ctype, c, dtype, d, etype, e) \
+type name(atype a, btype b, ctype c, dtype d, etype e) \
+{ \
+ register long __res __asm__("er0"); \
+ __asm__ __volatile__ ( \
+ "mov.l er5,@-sp\n\t" \
+ "mov.l %5, er4\n\t" \
+ "mov.l %4, er3\n\t" \
+ "mov.l %3, er2\n\t" \
+ "mov.l %2, er1\n\t" \
+ "mov.l %1, er0\n\t" \
+ "mov.l %6, er5\n\t" \
+ "trapa #0\n\t" \
+ "mov.l @sp+,er5\n\t" \
+ : "=r" (__res) \
+ : "ir" (__NR_##name), \
+ "g" ((long)a), \
+ "g" ((long)b), \
+ "g" ((long)c), \
+ "g" ((long)d), \
+ "m" ((long)e) \
+ : "cc", "er1", "er2", "er3", "er4"); \
+ if ((unsigned long)(__res) >= (unsigned long)(-125)) { \
+ errno = -__res; \
+ __res = -1; \
+ } \
+ return (type)__res; \
+}
diff --git a/libc/sysdeps/linux/h8300/bits/wordsize.h b/libc/sysdeps/linux/h8300/bits/wordsize.h
index ba643b60a..b47eee944 100644
--- a/libc/sysdeps/linux/h8300/bits/wordsize.h
+++ b/libc/sysdeps/linux/h8300/bits/wordsize.h
@@ -1,19 +1 @@
-/* Copyright (C) 1999 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA. */
-
-#define __WORDSIZE 32
+#define __WORDSIZE 32