diff options
Diffstat (limited to 'libc/sysdeps/linux/h8300')
26 files changed, 301 insertions, 502 deletions
diff --git a/libc/sysdeps/linux/h8300/Makefile b/libc/sysdeps/linux/h8300/Makefile index 2ab4ee6f0..552462392 100644 --- a/libc/sysdeps/linux/h8300/Makefile +++ b/libc/sysdeps/linux/h8300/Makefile @@ -1,65 +1,13 @@ # Makefile for uClibc # -# Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org> +# Copyright (C) 2015 Yoshinori Sato +# +# Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball. # -# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. - -TOPDIR=../../../../ -include $(TOPDIR)Rules.mak -ifeq ($(DOPIC),y) -# is this not provided by gcc ? -ASFLAGS+=-D__PIC__ -endif - -#FIXME -- this arch should include its own crti.S and crtn.S -UCLIBC_CTOR_DTOR=n - -CRT_SRC := crt0.S -CRT_OBJ := crt0.o crt1.o -CTOR_TARGETS := $(TOPDIR)lib/crti.o $(TOPDIR)lib/crtn.o - -SSRC := __longjmp.S bsd-_setjmp.S bsd-setjmp.S clone.S setjmp.S vfork.S -SOBJ := $(patsubst %.S,%.o, $(SSRC)) - -CSRC := ptrace.c brk.c -COBJ := $(patsubst %.c,%.o, $(CSRC)) - -OBJS := $(SOBJ) $(COBJ) - -OBJ_LIST := ../../../obj.sysdeps.$(TARGET_ARCH) - -all: $(OBJ_LIST) $(CTOR_TARGETS) - -$(OBJ_LIST): $(OBJS) $(CRT_OBJ) - $(STRIPTOOL) -x -R .note -R .comment $^ - $(INSTALL) -d $(TOPDIR)lib/ - cp $(CRT_OBJ) $(TOPDIR)lib/ - echo $(patsubst %, sysdeps/linux/$(TARGET_ARCH)/%, $(OBJS)) > $@ - -$(CRT_OBJ): $(CRT_SRC) - $(CC) $(ASFLAGS) -DL_$* $< -c -o $*.o - -$(SOBJ): %.o : %.S - $(CC) $(ASFLAGS) -c $< -o $@ - -$(COBJ): %.o : %.c - $(CC) $(CFLAGS) -c $< -o $@ - -ifeq ($(UCLIBC_CTOR_DTOR),y) -$(TOPDIR)lib/crti.o: crti.S - $(INSTALL) -d $(TOPDIR)lib/ - $(CC) $(ASFLAGS) $(SSP_DISABLE_FLAGS) -c $< -o $@ - -$(TOPDIR)lib/crtn.o: crtn.S - $(INSTALL) -d $(TOPDIR)lib/ - $(CC) $(ASFLAGS) $(SSP_DISABLE_FLAGS) -c $< -o $@ -else -$(CTOR_TARGETS): - $(INSTALL) -d $(TOPDIR)lib/ - $(AR) $(ARFLAGS) $@ -endif - -headers: -clean: - $(RM) *.o *~ core +top_srcdir=../../../../ +top_builddir=../../../../ +all: objs +include $(top_builddir)Rules.mak +include Makefile.arch +include $(top_srcdir)Makerules diff --git a/libc/sysdeps/linux/h8300/Makefile.arch b/libc/sysdeps/linux/h8300/Makefile.arch new file mode 100644 index 000000000..371d3dd49 --- /dev/null +++ b/libc/sysdeps/linux/h8300/Makefile.arch @@ -0,0 +1,10 @@ +# Makefile for uClibc +# +# Copyright (C) 2015 Yoshinori Sato +# +# Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball. +# + +CSRC-y := brk.c ptrace.c + +SSRC-y := __longjmp.S bsd-_setjmp.S bsd-setjmp.S clone.S setjmp.S vfork.S diff --git a/libc/sysdeps/linux/h8300/__longjmp.S b/libc/sysdeps/linux/h8300/__longjmp.S index 5cffa3e5f..bcb098510 100644 --- a/libc/sysdeps/linux/h8300/__longjmp.S +++ b/libc/sysdeps/linux/h8300/__longjmp.S @@ -4,10 +4,10 @@ .h8300h #endif .text - -.global ___longjmp -___longjmp: +.global __longjmp + +__longjmp: mov.l er1,er1 bne 1f sub.l er1,er1 @@ -20,3 +20,5 @@ ___longjmp: mov.l @er0+,er3 ; return PC adds #4,sp ; adjust return stack jmp @er3 + +libc_hidden_def(__longjmp) diff --git a/libc/sysdeps/linux/h8300/bits/byteswap.h b/libc/sysdeps/linux/h8300/bits/byteswap.h index dc56467f2..08ca99f83 100644 --- a/libc/sysdeps/linux/h8300/bits/byteswap.h +++ b/libc/sysdeps/linux/h8300/bits/byteswap.h @@ -14,54 +14,13 @@ 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. */ + see <http://www.gnu.org/licenses/>. */ -#if !defined _BYTESWAP_H && !defined _NETINET_IN_H -# error "Never use <bits/byteswap.h> directly; include <byteswap.h> instead." -#endif - -/* Swap bytes in 16 bit value. We don't provide an assembler version - because GCC is smart enough to generate optimal assembler output, and - this allows for better cse. */ -#define __bswap_16(x) \ - ((((x) >> 8) & 0xff) | (((x) & 0xff) << 8)) +#ifndef _ASM_BITS_BYTESWAP_H +#define _ASM_BITS_BYTESWAP_H 1 -/* Swap bytes in 32 bit value. */ -#define __bswap_constant_32(x) \ - ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) | \ - (((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24)) +#define __bswap_non_constant_32(x) __builtin_bswap32(x) -#if defined __GNUC__ && __GNUC__ >= 2 -# define __bswap_32(x) \ - __extension__ \ - ({ unsigned int __v; \ - if (__builtin_constant_p (x)) \ - __v = __bswap_constant_32 (x); \ - else \ - __asm__ __volatile__ ("mov.l %0,er0\n\t" \ - "mov.b r0l,r1h\n\t" \ - "mov.b r0h,r1l\n\t" \ - "mov.w r1,e1\n\t" \ - "mov.w e0,r0\n\t" \ - "mov.b r0l,r1h\n\t" \ - "mov.b r0h,r1l\n\t" \ - "mov.l er1,%0" \ - : "=d" (__v) \ - : "0" (x): "er0","er1"); \ - __v; }) -#else -# define __bswap_32(x) __bswap_constant_32 (x) #endif -#if defined __GNUC__ && __GNUC__ >= 2 -/* Swap bytes in 64 bit value. */ -# define __bswap_64(x) \ - __extension__ \ - ({ union { unsigned long long int __ll; \ - unsigned long int __l[2]; } __v, __r; \ - __v.__ll = (x); \ - __r.__l[0] = __bswap_32 (__v.__l[1]); \ - __r.__l[1] = __bswap_32 (__v.__l[0]); \ - __r.__ll; }) -#endif +#include <bits/byteswap-common.h> diff --git a/libc/sysdeps/linux/h8300/bits/fcntl.h b/libc/sysdeps/linux/h8300/bits/fcntl.h index 87d193923..c167ee23c 100644 --- a/libc/sysdeps/linux/h8300/bits/fcntl.h +++ b/libc/sysdeps/linux/h8300/bits/fcntl.h @@ -13,9 +13,8 @@ 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. */ + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ #ifndef _FCNTL_H # error "Never use <bits/fcntl.h> directly; include <fcntl.h> instead." @@ -23,6 +22,9 @@ #include <sys/types.h> +#ifdef __USE_GNU +# include <bits/uio.h> +#endif /* open/fcntl - O_SYNC is only implemented on blocks devices and on files located on an ext2 file system */ @@ -42,10 +44,12 @@ #define O_ASYNC 020000 #ifdef __USE_GNU -# define O_DIRECTORY 040000 /* Must be a directory. */ -# define O_NOFOLLOW 0100000 /* Do not follow links. */ -# define O_DIRECT 0200000 /* Direct disk access. */ -# define O_STREAMING 04000000/* streaming access */ +# define O_DIRECT 040000 /* Direct disk access. */ +# define O_DIRECTORY 0200000 /* Must be a directory. */ +# define O_NOFOLLOW 0400000 /* Do not follow links. */ +# define O_NOATIME 01000000 /* Do not set atime. */ +# define O_CLOEXEC 02000000 /* Set close_on_exec. */ +# define O_PATH 010000000 /* Resolve pathname but do not open file. */ #endif /* For now Linux has synchronisity options for data and read operations. @@ -95,6 +99,8 @@ # define F_NOTIFY 1026 /* Request notfications on a directory. */ # define F_DUPFD_CLOEXEC 1030 /* Duplicate file descriptor with close-on-exit set on new fd. */ +# define F_SETPIPE_SZ 1031 /* Set pipe page size array. */ +# define F_GETPIPE_SZ 1032 /* Get pipe page size array. */ #endif /* For F_[GET|SET]FL. */ @@ -182,7 +188,7 @@ struct flock64 #endif -#ifdef __USE_GNU +#if defined __USE_GNU && defined __UCLIBC_LINUX_SPECIFIC__ /* Flags for SYNC_FILE_RANGE. */ # define SYNC_FILE_RANGE_WAIT_BEFORE 1 /* Wait upon writeout of all pages in the range before performing the @@ -205,7 +211,7 @@ struct flock64 __BEGIN_DECLS -#ifdef __USE_GNU +#if defined __USE_GNU && defined __UCLIBC_LINUX_SPECIFIC__ /* Provide kernel hint to read ahead. */ extern ssize_t readahead (int __fd, __off64_t __offset, size_t __count) diff --git a/libc/sysdeps/linux/h8300/bits/kernel_stat.h b/libc/sysdeps/linux/h8300/bits/kernel_stat.h deleted file mode 100644 index 9468292e5..000000000 --- a/libc/sysdeps/linux/h8300/bits/kernel_stat.h +++ /dev/null @@ -1,61 +0,0 @@ -#ifndef _BITS_STAT_STRUCT_H -#define _BITS_STAT_STRUCT_H - -#ifndef _LIBC -#error bits/kernel_stat.h is for internal uClibc use only! -#endif - -/* This file provides whatever this particular arch's kernel thinks - * struct kernel_stat should look like... It turns out each arch has a - * different opinion on the subject... */ - -struct kernel_stat { - unsigned short st_dev; - unsigned short __pad1; - unsigned long st_ino; - unsigned short st_mode; - unsigned short st_nlink; - unsigned short st_uid; - unsigned short st_gid; - unsigned short st_rdev; - unsigned short __pad2; - unsigned long st_size; - unsigned long st_blksize; - unsigned long st_blocks; - unsigned long st_atime; - unsigned long __unused1; - unsigned long st_mtime; - unsigned long __unused2; - unsigned long st_ctime; - unsigned long __unused3; - unsigned long __unused4; - unsigned long __unused5; -}; - -struct kernel_stat64 { - unsigned char __pad0[6]; - unsigned short st_dev; - unsigned char __pad1[2]; -#define _HAVE_STAT64___ST_INO - unsigned long __st_ino; - unsigned int st_mode; - unsigned int st_nlink; - unsigned long st_uid; - unsigned long st_gid; - unsigned short st_rdev; - unsigned char __pad3[10]; - 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 */ - unsigned long st_atime; - unsigned long __pad5; - unsigned long st_mtime; - unsigned long __pad6; - unsigned long st_ctime; - unsigned long __pad7; /* will be high 32 bits of ctime someday */ - unsigned long long st_ino; -}; - -#endif /* _BITS_STAT_STRUCT_H */ - diff --git a/libc/sysdeps/linux/h8300/bits/kernel_types.h b/libc/sysdeps/linux/h8300/bits/kernel_types.h index 057067560..312cf2955 100644 --- a/libc/sysdeps/linux/h8300/bits/kernel_types.h +++ b/libc/sysdeps/linux/h8300/bits/kernel_types.h @@ -1,5 +1,5 @@ -#ifndef _BITS_KERNEL_TYPES_H -#define _BITS_KERNEL_TYPES_H +#ifndef __ASM_GENERIC_POSIX_TYPES_H +#define __ASM_GENERIC_POSIX_TYPES_H /* Sigh. We need to carefully wrap this one... No guarantees * that the asm/posix_types.h kernel header is working. Many @@ -16,9 +16,9 @@ typedef int __kernel_pid_t; typedef unsigned short __kernel_ipc_pid_t; typedef unsigned short __kernel_uid_t; typedef unsigned short __kernel_gid_t; -typedef unsigned int __kernel_size_t; -typedef int __kernel_ssize_t; -typedef int __kernel_ptrdiff_t; +typedef unsigned long __kernel_size_t; +typedef long __kernel_ssize_t; +typedef long __kernel_ptrdiff_t; typedef long __kernel_time_t; typedef long __kernel_suseconds_t; typedef long __kernel_clock_t; @@ -32,6 +32,20 @@ typedef unsigned short __kernel_old_uid_t; typedef unsigned short __kernel_old_gid_t; typedef long long __kernel_loff_t; typedef __kernel_dev_t __kernel_old_dev_t; +typedef long __kernel_long_t; +typedef unsigned long __kernel_ulong_t; + +#define __kernel_long_t __kernel_long_t +#define __kernel_ino_t __kernel_ino_t +#define __kernel_mode_t __kernel_mode_t +#define __kernel_pid_t __kernel_pid_t +#define __kernel_ipc_pid_t __kernel_ipc_pid_t +#define __kernel_uid_t __kernel_uid_t +#define __kernel_susecond_t __kernel_susecond_t +#define __kernel_daddr_t __kernel_daddr_t +#define __kernel_uid32_t __kernel_uid32_t +#define __kernel_old_uid_t __kernel_old_uid_t +#define __kernel_old_dev_t __kernel_old_dev_t typedef struct { #ifdef __USE_ALL @@ -40,5 +54,6 @@ typedef struct { int __val[2]; #endif } __kernel_fsid_t; +#define __kernel_fsid_t __kernel_fsid_t -#endif /* _BITS_KERNEL_TYPES_H */ +#endif /* __ASM_GENERIC_POSIX_TYPES_H */ diff --git a/libc/sysdeps/linux/h8300/bits/mman.h b/libc/sysdeps/linux/h8300/bits/mman.h deleted file mode 100644 index 7f644b99b..000000000 --- a/libc/sysdeps/linux/h8300/bits/mman.h +++ /dev/null @@ -1,76 +0,0 @@ -/* 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 - 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 _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_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. */ -#define MAP_PRIVATE 0x02 /* Changes are private. */ -#ifdef __USE_MISC -# define MAP_TYPE 0x0f /* Mask for type of mapping. */ -#endif - -/* Other flags. */ -#define MAP_FIXED 0x10 /* Interpret addr exactly. */ -#ifdef __USE_MISC -# define MAP_FILE 0 -# define MAP_ANONYMOUS 0x20 /* Don't use a file. */ -# define MAP_ANON MAP_ANONYMOUS -#endif - -/* These are Linux-specific. */ -#ifdef __USE_MISC -# define MAP_GROWSDOWN 0x0100 /* Stack-like segment. */ -# define MAP_DENYWRITE 0x0800 /* ETXTBSY */ -# define MAP_EXECUTABLE 0x1000 /* Mark it as an executable. */ -# define MAP_LOCKED 0x2000 /* Lock the mapping. */ -# define MAP_NORESERVE 0x4000 /* Don't check for reservations. */ -#endif - -/* Flags to `msync'. */ -#define MS_ASYNC 1 /* Sync memory asynchronously. */ -#define MS_SYNC 4 /* Synchronous memory sync. */ -#define MS_INVALIDATE 2 /* Invalidate the caches. */ - -/* Flags for `mlockall'. */ -#define MCL_CURRENT 1 /* Lock all currently mapped pages. */ -#define MCL_FUTURE 2 /* Lock all additions to address - space. */ - -/* Flags for `mremap'. */ -#ifdef __USE_GNU -# define MREMAP_MAYMOVE 1 -# define MREMAP_FIXED 2 -#endif diff --git a/libc/sysdeps/linux/h8300/bits/setjmp.h b/libc/sysdeps/linux/h8300/bits/setjmp.h index 15f8d8445..67e1bc89d 100644 --- a/libc/sysdeps/linux/h8300/bits/setjmp.h +++ b/libc/sysdeps/linux/h8300/bits/setjmp.h @@ -9,24 +9,10 @@ # error "Never include <bits/setjmp.h> directly; use <setjmp.h> instead." #endif -#ifndef _ASM - typedef struct { 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)->__regs[3]) - #endif /* bits/setjmp.h */ diff --git a/libc/sysdeps/linux/h8300/bits/sigcontextinfo.h b/libc/sysdeps/linux/h8300/bits/sigcontextinfo.h index b7e08cfc9..851c21d04 100644 --- a/libc/sysdeps/linux/h8300/bits/sigcontextinfo.h +++ b/libc/sysdeps/linux/h8300/bits/sigcontextinfo.h @@ -13,9 +13,8 @@ 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. */ + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ #define SIGCONTEXT int _code, struct sigcontext * #define SIGCONTEXT_EXTRA_ARGS _code, diff --git a/libc/sysdeps/linux/h8300/bits/stackinfo.h b/libc/sysdeps/linux/h8300/bits/stackinfo.h index 89a77d932..689011b10 100644 --- a/libc/sysdeps/linux/h8300/bits/stackinfo.h +++ b/libc/sysdeps/linux/h8300/bits/stackinfo.h @@ -12,9 +12,8 @@ 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. */ + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ /* This file contains a bit of information about the stack allocation of the processor. */ diff --git a/libc/sysdeps/linux/h8300/bits/syscalls.h b/libc/sysdeps/linux/h8300/bits/syscalls.h index 5867ed608..b43795f2e 100644 --- a/libc/sysdeps/linux/h8300/bits/syscalls.h +++ b/libc/sysdeps/linux/h8300/bits/syscalls.h @@ -1,151 +1,85 @@ -/* 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 _BITS_SYSCALLS_H +#define _BITS_SYSCALLS_H #ifndef _SYSCALL_H # error "Never use <bits/syscalls.h> directly; include <sys/syscall.h> instead." #endif -#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) +#ifndef __ASSEMBLER__ -#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; \ -} +#include <errno.h> -#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 ASMFMT_0 +#define ASMFMT_1 , "g"(er1) +#define ASMFMT_2 , "g"(er1), "g"(er2) +#define ASMFMT_3 , "g"(er1), "g"(er2), "g"(er3) +#define ASMFMT_4 , "g"(er1), "g"(er2), "g"(er3), "g"(er4) +#define ASMFMT_5 , "g"(er1), "g"(er2), "g"(er3), "g"(er4), "g"(er5) +#define ASMFMT_6 , "g"(er1), "g"(er2), "g"(er3), "g"(er4), "m"(er5), "m"(er6) -#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 SUBSTITUTE_ARGS_0() do {} while(0); +#define SUBSTITUTE_ARGS_1(arg1) \ + register long int er1 __asm__("er1") = (long int)arg1; +#define SUBSTITUTE_ARGS_2(arg1, arg2) \ + register long int er1 __asm__("er1") = (long int)arg1; \ + register long int er2 __asm__("er2") = (long int)arg2; +#define SUBSTITUTE_ARGS_3(arg1, arg2, arg3) \ + register long int er1 __asm__("er1") = (long int)arg1; \ + register long int er2 __asm__("er2") = (long int)arg2; \ + register long int er3 __asm__("er3") = (long int)arg3; +#define SUBSTITUTE_ARGS_4(arg1, arg2, arg3, arg4) \ + register long int er1 __asm__("er1") = (long int)arg1; \ + register long int er2 __asm__("er2") = (long int)arg2; \ + register long int er3 __asm__("er3") = (long int)arg3; \ + register long int er4 __asm__("er4") = (long int)arg4; +#define SUBSTITUTE_ARGS_5(arg1, arg2, arg3, arg4, arg5) \ + register long int er1 __asm__("er1") = (long int)arg1; \ + register long int er2 __asm__("er2") = (long int)arg2; \ + register long int er3 __asm__("er3") = (long int)arg3; \ + register long int er4 __asm__("er4") = (long int)arg4; \ + register long int er5 __asm__("er5") = (long int)arg5; +#define SUBSTITUTE_ARGS_6(arg1, arg2, arg3, arg4, arg5, arg6) \ + register long int er1 __asm__("er1") = (long int)arg1; \ + register long int er2 __asm__("er2") = (long int)arg2; \ + register long int er3 __asm__("er3") = (long int)arg3; \ + register long int er4 __asm__("er4") = (long int)arg4; \ + long int er5 = (long int)arg5; \ + long int er6 = (long int)arg6; -#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 LOAD_ARGS_0 +#define LOAD_ARGS_1 +#define LOAD_ARGS_2 +#define LOAD_ARGS_3 +#define LOAD_ARGS_4 +#define LOAD_ARGS_5 +#define LOAD_ARGS_6 "mov.l er5,@-sp\n\tmov.l %6,er5\n\t" \ + "mov.l er6,@-sp\n\tmov.l %7,er6\n\t" -#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 RESTORE_ARGS_0 +#define RESTORE_ARGS_1 +#define RESTORE_ARGS_2 +#define RESTORE_ARGS_3 +#define RESTORE_ARGS_4 +#define RESTORE_ARGS_5 +#define RESTORE_ARGS_6 "mov.l @sp+,er6\n\tmov.l @sp+,er5" -#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; \ -} +/* The _NCS variant allows non-constant syscall numbers. */ +#define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \ +(__extension__ \ + ({ \ + register long int er0 __asm__ ("er0"); \ + SUBSTITUTE_ARGS_##nr(args) \ + __asm__ __volatile__ ( \ + LOAD_ARGS_##nr \ + "mov.l %1,er0\n\t" \ + "trapa #0\n\t" \ + RESTORE_ARGS_##nr \ + : "=r" (er0) \ + : "ir" (name) ASMFMT_##nr \ + : "memory" \ + ); \ + (int) er0; \ + }) \ +) +#endif /* __ASSEMBLER__ */ +#endif /* _BITS_SYSCALLS_H */ diff --git a/libc/sysdeps/linux/h8300/bits/uClibc_arch_features.h b/libc/sysdeps/linux/h8300/bits/uClibc_arch_features.h index b0d032d30..6047d1482 100644 --- a/libc/sysdeps/linux/h8300/bits/uClibc_arch_features.h +++ b/libc/sysdeps/linux/h8300/bits/uClibc_arch_features.h @@ -12,28 +12,31 @@ /* can your target use syscall6() for mmap ? */ #define __UCLIBC_MMAP_HAS_6_ARGS__ -/* does your target use syscall4() for truncate64 ? (32bit arches only) */ -#undef __UCLIBC_MMAP_HAS_6_ARGS__ +/* does your target align 64bit values in register pairs ? (32bit arches only) */ +#undef __UCLIBC_SYSCALL_ALIGN_64BIT__ /* does your target have a broken create_module() ? */ #undef __UCLIBC_BROKEN_CREATE_MODULE__ +/* does your target have to worry about older [gs]etrlimit() ? */ +#undef __UCLIBC_HANDLE_OLDER_RLIMIT__ + /* does your target have an asm .set ? */ #define __UCLIBC_HAVE_ASM_SET_DIRECTIVE__ -/* define if target doesn't like .global */ -#undef __UCLIBC_ASM_GLOBAL_DIRECTIVE__ - /* define if target supports .weak */ #define __UCLIBC_HAVE_ASM_WEAK_DIRECTIVE__ /* define if target supports .weakext */ #undef __UCLIBC_HAVE_ASM_WEAKEXT_DIRECTIVE__ -/* needed probably only for ppc64 */ -#undef __UCLIBC_HAVE_ASM_GLOBAL_DOT_NAME__ +/* define if target supports CFI pseudo ops */ +#undef __UCLIBC_HAVE_ASM_CFI_DIRECTIVES__ /* define if target supports IEEE signed zero floats */ #define __UCLIBC_HAVE_SIGNED_ZERO__ +/* only weird assemblers generally need this */ +#define __UCLIBC_ASM_LINE_SEP__ ! + #endif /* _BITS_UCLIBC_ARCH_FEATURES_H */ diff --git a/libc/sysdeps/linux/h8300/brk.c b/libc/sysdeps/linux/h8300/brk.c index 9eab66060..b33781374 100644 --- a/libc/sysdeps/linux/h8300/brk.c +++ b/libc/sysdeps/linux/h8300/brk.c @@ -12,7 +12,6 @@ /* This must be initialized data because commons can't have aliases. */ void *__curbrk attribute_hidden = 0; -libc_hidden_proto(brk) int brk (void *addr) { void *newbrk; diff --git a/libc/sysdeps/linux/h8300/bsd-_setjmp.S b/libc/sysdeps/linux/h8300/bsd-_setjmp.S index e315058a7..766d9cc91 100644 --- a/libc/sysdeps/linux/h8300/bsd-_setjmp.S +++ b/libc/sysdeps/linux/h8300/bsd-_setjmp.S @@ -1,8 +1,6 @@ -/* BSD `_setjmp' entry point to `sigsetjmp (..., 0)'. H8/300 version. */ +/* BSD `_setjmp' entry point to `sigsetjmp (..., 0)'. H8/300 version. */ -#define _ASM -#define _SETJMP_H -#include <bits/setjmp.h> +#include <jmpbuf-offsets.h> #ifdef __H8300S__ .h8300s @@ -10,10 +8,10 @@ .h8300h #endif .text - -.global __setjmp -__setjmp: +.global _setjmp + +_setjmp: add.l #JB_SIZE,er0 mov.l @sp,er1 ; return PC mov.l er1,@-er0 @@ -25,3 +23,5 @@ __setjmp: sub.l er0,er0 mov.l er0,@(JB_SIZE:16,er1) rts + + .end diff --git a/libc/sysdeps/linux/h8300/bsd-setjmp.S b/libc/sysdeps/linux/h8300/bsd-setjmp.S index 9c3535503..77c810fe0 100644 --- a/libc/sysdeps/linux/h8300/bsd-setjmp.S +++ b/libc/sysdeps/linux/h8300/bsd-setjmp.S @@ -1,8 +1,6 @@ -/* BSD `_setjmp' entry point to `sigsetjmp (..., 1)'. H8/300 version. */ +/* BSD `_setjmp' entry point to `sigsetjmp (..., 1)'. H8/300 version. */ -#define _ASM -#define _SETJMP_H -#include <bits/setjmp.h> +#include <jmpbuf-offsets.h> #ifdef __H8300S__ .h8300s @@ -10,10 +8,10 @@ .h8300h #endif .text - -.global _setjmp -_setjmp: +.global setjmp + +setjmp: add.l #JB_SIZE,er0 mov.l @sp,er1 ; return PC mov.l er1,@-er0 @@ -23,8 +21,9 @@ _setjmp: mov.l er4,@-er0 sub.l er0,er0 #if !defined(__PIC__) - jmp @___sigjmp_save + jmp @__sigjmp_save #else - mov.l @(___sigjmp_save@GOTOFF,er5),er1 + mov.l @(__sigjmp_save@GOTOFF,er5),er1 jmp @er3 #endif + .end diff --git a/libc/sysdeps/linux/h8300/clone.S b/libc/sysdeps/linux/h8300/clone.S index 554a29703..a00eba4cb 100644 --- a/libc/sysdeps/linux/h8300/clone.S +++ b/libc/sysdeps/linux/h8300/clone.S @@ -1,5 +1,4 @@ -/* Adapted from glibc */ -/* Copyright (C) 1996, 1997 Free Software Foundation, Inc. */ +/* Copyright 2015 Yoshinori Sato <ysato@users.sourceforge.jp> */ /* clone is even more special than fork as it mucks with stacks and invokes a function in the right context after its all over. */ @@ -8,7 +7,8 @@ #include <bits/errno.h> #include <sys/syscall.h> -/* int _clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg); */ +/* int _clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg + void *parent_tidptr, void *tls, void *child_tidptr) */ #ifdef __H8300H__ .h8300h @@ -18,8 +18,8 @@ #endif .text -.globl _clone -_clone: +.globl clone +clone: /* Sanity check arguments. */ mov.l #-EINVAL,er3 mov.l er0,er0 /* no NULL function pointers */ @@ -31,13 +31,25 @@ _clone: mov.l @(4:16,sp),er3 mov.l er3,@-er1 - /* Do the system call */ + /* setup argument */ mov.l er0,er3 /* er3 = child entry */ - mov.l er1,er0 - mov.l er2,er1 /* er1 = flags */ - mov.l er0,er2 /* er2 = child sp */ - mov.l #__NR_clone,r0 + sub.l #20,sp + mov.l er2,@sp /* flags */ + mov.l er1,@(4,sp) /* new sp */ + mov.l sp,er1 + mov.l @(20+8,sp),er0 + mov.l er0,@er1 /* parent tid */ + adds #4,er1 + mov.l @(20+16,sp),er0 + mov.l er0,@er1 /* child tid */ + adds #4,er1 + mov.l @(20+12,sp),er0 + mov.l er0,@er1 /* tls */ + /* do the system call */ + mov.l sp,er1 + mov.l #__NR_clone,er0 trapa #0 + add.l #20,sp mov.l er0,er0 bmi __syscall_error beq thread_start @@ -62,7 +74,9 @@ __syscall_error: thread_start: mov.l @sp+,er0 /* restore args */ - jsr @er3 + jsr @er3 mov.l er0,er1 mov.l #__NR_exit,er0 trapa #0 + + .end diff --git a/libc/sysdeps/linux/h8300/crt0.S b/libc/sysdeps/linux/h8300/crt1.S index ebdca18e5..847872ad7 100644 --- a/libc/sysdeps/linux/h8300/crt0.S +++ b/libc/sysdeps/linux/h8300/crt1.S @@ -14,8 +14,7 @@ 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., 675 Mass Ave, -Cambridge, MA 02139, USA. */ +not, see <http://www.gnu.org/licenses/>. */ #include <features.h> @@ -29,17 +28,39 @@ Cambridge, MA 02139, USA. */ #else .h8300h #endif +/* +void __uClibc_main(int (*main)(int, char **, char **), int argc, + char **argv, void (*app_init)(void), void (*app_fini)(void), + void (*rtld_fini)(void),void *stack_end attribute_unused) +*/ .text _start: /* put here so that references to _start work with elf-PIC */ - mov.l @(0,sp),er0 /* argc */ - mov.l @(4,sp),er1 /* argv */ - mov.l @(8,sp),er2 /* envp */ + mov.l @sp+,er1 /* argc */ + mov.l @sp+,er2 /* argv */ + add.l #4,sp + #if !defined(__PIC__) - jsr @___uClibc_main + mov.l sp, @-sp + sub.l er0,er0 + mov.l er0,@-sp + mov.l #_fini,er0 + mov.l er0,@-sp + mov.l #_init,er0 + mov.l er0,@-sp + mov.l #main,er0 + jsr @__uClibc_main #else - mov.l @(___uClibc_main@GOTOFF,er5),er3 + mov.l sp, @-sp + sub.l er0,er0 + mov.l er0,@-sp + mov.l @(_fini@GOTOFF,er5),er0 + mov.l er0,@-sp + mov.l @(_init@GOTOFF,er5),er0 + mov.l er0,@-sp + mov.l @(main@GOTOFF,er5),er0 + mov.l @(__uClibc_main@GOTOFF,er5),er3 jsr @er3 #endif @@ -62,9 +83,9 @@ empty_func: /* Define a symbol for the first piece of initialized data. */ .data - .globl __data_start -__data_start: + .globl _data_start +_data_start: .long 0 .weak data_start - data_start = __data_start + data_start = _data_start diff --git a/libc/sysdeps/linux/h8300/crti.S b/libc/sysdeps/linux/h8300/crti.S index 270df276e..cc6afe902 100644 --- a/libc/sysdeps/linux/h8300/crti.S +++ b/libc/sysdeps/linux/h8300/crti.S @@ -10,8 +10,8 @@ .section .init ; #NO_APP .align 1 - .global __init -__init: + .global _init +_init: mov.l er6,@-er7 mov.l er7,er6 ; #APP @@ -20,8 +20,8 @@ __init: .section .fini ; #NO_APP .align 1 - .global __fini -__fini: + .global _fini +_fini: mov.l er6,@-er7 mov.l er7,er6 ; #APP diff --git a/libc/sysdeps/linux/h8300/crtn.S b/libc/sysdeps/linux/h8300/crtn.S index 89e321868..a390704a6 100644 --- a/libc/sysdeps/linux/h8300/crtn.S +++ b/libc/sysdeps/linux/h8300/crtn.S @@ -10,21 +10,19 @@ .section .init ; #NO_APP .align 1 - .global __init + .global _init ; #NO_APP mov.l @er7+,er6 rts - .size __init, .-__init ; #APP .section .fini ; #NO_APP .align 1 - .global __fini + .global _fini ; #NO_APP mov.l @er7+,er6 rts - .size __fini, .-__fini ; #APP .end diff --git a/libc/sysdeps/linux/h8300/jmpbuf-offsets.h b/libc/sysdeps/linux/h8300/jmpbuf-offsets.h new file mode 100644 index 000000000..8351f599e --- /dev/null +++ b/libc/sysdeps/linux/h8300/jmpbuf-offsets.h @@ -0,0 +1,9 @@ +/* + * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org> + * + * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. + */ + +#define JB_REGS 0 +#define JB_PC 16 +#define JB_SIZE 20 diff --git a/libc/sysdeps/linux/h8300/jmpbuf-unwind.h b/libc/sysdeps/linux/h8300/jmpbuf-unwind.h new file mode 100644 index 000000000..fe3f758a2 --- /dev/null +++ b/libc/sysdeps/linux/h8300/jmpbuf-unwind.h @@ -0,0 +1,12 @@ +/* + * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org> + * + * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. + */ + +#include <setjmp.h> + +/* Test if longjmp to JMPBUF would unwind the frame + containing a local variable at ADDRESS. */ +#define _JMPBUF_UNWINDS(jmpbuf, address) \ + ((void *) (address) < (void *) (jmpbuf)->__regs[3]) diff --git a/libc/sysdeps/linux/h8300/setjmp.S b/libc/sysdeps/linux/h8300/setjmp.S index 5e487674b..0b8f052ce 100644 --- a/libc/sysdeps/linux/h8300/setjmp.S +++ b/libc/sysdeps/linux/h8300/setjmp.S @@ -1,6 +1,4 @@ -#define _ASM -#define _SETJMP_H -#include <bits/setjmp.h> +#include <jmpbuf-offsets.h> #ifdef __H8300S__ .h8300s @@ -9,9 +7,9 @@ #endif .text -.global ___sigsetjmp +.global __sigsetjmp -___sigsetjmp: +__sigsetjmp: add.l #JB_SIZE,er0 mov.l @sp,er1 ; return PC mov.l er1,@-er0 diff --git a/libc/sysdeps/linux/h8300/sys/procfs.h b/libc/sysdeps/linux/h8300/sys/procfs.h index 27abf8ef5..1722bf0f2 100644 --- a/libc/sysdeps/linux/h8300/sys/procfs.h +++ b/libc/sysdeps/linux/h8300/sys/procfs.h @@ -12,9 +12,8 @@ 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. */ + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ #ifndef _SYS_PROCFS_H #define _SYS_PROCFS_H 1 diff --git a/libc/sysdeps/linux/h8300/sys/ucontext.h b/libc/sysdeps/linux/h8300/sys/ucontext.h index ffc9ea024..4ee82850f 100644 --- a/libc/sysdeps/linux/h8300/sys/ucontext.h +++ b/libc/sysdeps/linux/h8300/sys/ucontext.h @@ -12,9 +12,8 @@ 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. */ + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ /* H8/300 compliant context switching support. */ diff --git a/libc/sysdeps/linux/h8300/vfork.S b/libc/sysdeps/linux/h8300/vfork.S index 35c04e559..24370df3a 100644 --- a/libc/sysdeps/linux/h8300/vfork.S +++ b/libc/sysdeps/linux/h8300/vfork.S @@ -1,9 +1,6 @@ +/* Copyright 2002, 2015 Yoshinori Sato <ysato@users.sourceforge.jp> */ -#include <asm/unistd.h> - -#ifndef __NR_vfork -#define __NR_vfork __NR_fork /* uClinux-2.0 only has fork which is vfork */ -#endif +#include <sys/syscall.h> #ifdef __H8300S__ .h8300s @@ -12,30 +9,60 @@ #endif .text .align 2 - .globl _errno - .globl ___vfork - .hidden ___vfork - .type ___vfork,@function -___vfork: + .globl __vfork + .hidden __vfork + .type __vfork,@function +__vfork: +#ifdef __NR_vfork mov.l @sp+, er1 sub.l er0,er0 mov.b #__NR_vfork,r0l trapa #0 + mov.l #-4096, er2 cmp.l er0,er2 bcs fix_errno - jmp @er1 /* don't return, just jmp directly */ + jmp @er1 /* don't return, just jmp directly */ fix_errno: neg.l er0 -#if !defined(__PIC__) +# if !defined(__PIC__) mov.l er0,@_errno -#else +# else mov.l @(_errno@GOTOFF,er5),er2 mov.l er0,@er2 -#endif +# endif sub.l er0,er0 dec.l #1,er0 - jmp @er1 /* don't return, just jmp directly */ + jmp @er1 /* don't return, just jmp directly */ +#else + mov.l @sp+,er2 /* er2 = return address */ + mov.l #vfork_args,er1 + sub.l er0,er0 + mov.b #__NR_clone,r0l + trapa #0 + mov.l #-4096,er1 + cmp.l er0,er1 + bcc done + neg.l er0 +# if !defined(__PIC__) + mov.l er0,@errno +# else + mov.l @(errno@GOTOFF,er5),er1 + mov.l er0,@er1 +# endif + sub.l er0,er0 + dec.l #1,er0 +done: + jmp @er2 + +vfork_args: + .long 0x00004111 /* CLONE_VFORK | CLONE_VM | SIGCHLD */ + .long 0 + .long 0 + .long 0 + .long 0 +#endif weak_alias(__vfork,vfork) -libc_hidden_weak(vfork) +libc_hidden_def(vfork) + .end |
