From patchwork Mon May 18 07:32:05 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshinori Sato X-Patchwork-Id: 473291 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from silver.osuosl.org (silver.osuosl.org [140.211.166.136]) by ozlabs.org (Postfix) with ESMTP id A34851401B5 for ; Mon, 18 May 2015 17:53:28 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 8C80232D02; Mon, 18 May 2015 07:53:27 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ued80ax8o-qN; Mon, 18 May 2015 07:53:12 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by silver.osuosl.org (Postfix) with ESMTP id 02DA732BD6; Mon, 18 May 2015 07:52:56 +0000 (UTC) X-Original-To: uclibc@lists.busybox.net Delivered-To: uclibc@osuosl.org Received: from silver.osuosl.org (silver.osuosl.org [140.211.166.136]) by ash.osuosl.org (Postfix) with ESMTP id B93D31C22AD for ; Mon, 18 May 2015 07:52:51 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id B549D32BAD for ; Mon, 18 May 2015 07:52:51 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ZVurO14tLbh9 for ; Mon, 18 May 2015 07:52:47 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail1.asahi-net.or.jp (mail1.asahi-net.or.jp [202.224.39.197]) by silver.osuosl.org (Postfix) with ESMTP id 5A75D311EE for ; Mon, 18 May 2015 07:52:47 +0000 (UTC) Received: from sa76r4 (y081184.ppp.asahi-net.or.jp [118.243.81.184]) by mail1.asahi-net.or.jp (Postfix) with ESMTP id E35D6AE598; Mon, 18 May 2015 16:32:18 +0900 (JST) Received: from localhost (localhost [127.0.0.1]) by sa76r4 (Postfix) with ESMTP id A419FA05; Mon, 18 May 2015 16:32:18 +0900 (JST) X-Virus-Scanned: Debian amavisd-new at sa76r4.localdomain Received: from sa76r4 ([127.0.0.1]) by localhost (sa76r4.localdomain [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 3sIFi3SU7NBx; Mon, 18 May 2015 16:32:18 +0900 (JST) Received: by sa76r4 (Postfix, from userid 1000) id 85D3DE622; Mon, 18 May 2015 16:32:18 +0900 (JST) From: Yoshinori Sato To: uclibc@uclibc.org Subject: [PATCH 4/6] h8300: headers update Date: Mon, 18 May 2015 16:32:05 +0900 Message-Id: <1431934327-1278-5-git-send-email-ysato@users.sourceforge.jp> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1431934327-1278-1-git-send-email-ysato@users.sourceforge.jp> References: <1431934327-1278-1-git-send-email-ysato@users.sourceforge.jp> X-BeenThere: uclibc@uclibc.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "Discussion and development of uClibc \(the embedded C library\)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: uclibc-bounces@uclibc.org Sender: "uClibc" - wire up new kernel Signed-off-by: Yoshinori Sato --- libc/sysdeps/linux/h8300/bits/fcntl.h | 14 +- libc/sysdeps/linux/h8300/bits/kernel_stat.h | 4 +- libc/sysdeps/linux/h8300/bits/kernel_types.h | 13 ++ libc/sysdeps/linux/h8300/bits/syscalls.h | 214 +++++++-------------- .../linux/h8300/bits/uClibc_arch_features.h | 2 +- 5 files changed, 99 insertions(+), 148 deletions(-) diff --git a/libc/sysdeps/linux/h8300/bits/fcntl.h b/libc/sysdeps/linux/h8300/bits/fcntl.h index 45deec4..08b6327 100644 --- a/libc/sysdeps/linux/h8300/bits/fcntl.h +++ b/libc/sysdeps/linux/h8300/bits/fcntl.h @@ -13,8 +13,9 @@ 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, see - . */ + 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 _FCNTL_H # error "Never use directly; include instead." @@ -22,6 +23,9 @@ #include +#ifdef __USE_GNU +# include +#endif /* open/fcntl - O_SYNC is only implemented on blocks devices and on files located on an ext2 file system */ @@ -42,8 +46,10 @@ #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_NOFOLLOW 0400000 /* Do not follow links. */ +# define O_NOATIME 01000000 /* Do not set atime. */ +# define O_CLOEXEC 02000000 /* Set close_on_exec. */ #endif /* For now Linux has synchronisity options for data and read operations. @@ -93,8 +99,6 @@ # 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. */ diff --git a/libc/sysdeps/linux/h8300/bits/kernel_stat.h b/libc/sysdeps/linux/h8300/bits/kernel_stat.h index 5f6c8ae..ea97b21 100644 --- a/libc/sysdeps/linux/h8300/bits/kernel_stat.h +++ b/libc/sysdeps/linux/h8300/bits/kernel_stat.h @@ -1,5 +1,5 @@ -#ifndef _BITS_STAT_STRUCT_H -#define _BITS_STAT_STRUCT_H +#ifndef _H8300_BITS_STAT_STRUCT_H +#define _H8300_BITS_STAT_STRUCT_H /* This file provides whatever this particular arch's kernel thinks * struct kernel_stat should look like... It turns out each arch has a diff --git a/libc/sysdeps/linux/h8300/bits/kernel_types.h b/libc/sysdeps/linux/h8300/bits/kernel_types.h index 4cfd1bf..7e76891 100644 --- a/libc/sysdeps/linux/h8300/bits/kernel_types.h +++ b/libc/sysdeps/linux/h8300/bits/kernel_types.h @@ -35,6 +35,18 @@ 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 int val[2]; @@ -42,5 +54,6 @@ typedef struct { int __val[2]; #endif } __kernel_fsid_t; +#define __kernel_fsid_t __kernel_fsid_t #endif /* _BITS_KERNEL_TYPES_H */ diff --git a/libc/sysdeps/linux/h8300/bits/syscalls.h b/libc/sysdeps/linux/h8300/bits/syscalls.h index 5867ed6..b43795f 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 directly; include 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 -#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 b76b861..fb430ae 100644 --- a/libc/sysdeps/linux/h8300/bits/uClibc_arch_features.h +++ b/libc/sysdeps/linux/h8300/bits/uClibc_arch_features.h @@ -43,6 +43,6 @@ #define __UCLIBC_HAVE_SIGNED_ZERO__ /* only weird assemblers generally need this */ -#undef __UCLIBC_ASM_LINE_SEP__ +#define __UCLIBC_ASM_LINE_SEP__ ! #endif /* _BITS_UCLIBC_ARCH_FEATURES_H */