[uClibc-cvs] uClibc/libc/sysdeps/linux/frv/bits elf-fdpic.h, NONE, 1.1 endian.h, NONE, 1.1 fcntl.h, NONE, 1.1 kernel_stat.h, NONE, 1.1 kernel_types.h, NONE, 1.1 mman.h, NONE, 1.1 setjmp.h, NONE, 1.1 stackinfo.h, NONE, 1.1 syscalls.h, NONE, 1.1 wordsize.h, NONE, 1.1

Erik Andersen andersen at uclibc.org
Wed Feb 18 08:04:53 UTC 2004


Update of /var/cvs/uClibc/libc/sysdeps/linux/frv/bits
In directory nail:/tmp/cvs-serv7699/libc/sysdeps/linux/frv/bits

Added Files:
	elf-fdpic.h endian.h fcntl.h kernel_stat.h kernel_types.h 
	mman.h setjmp.h stackinfo.h syscalls.h wordsize.h 
Log Message:
Alexandre Oliva writes:

This patch adds code to uClibc to support a new ABI designed for the
FR-V architecture, that enables text segments of executables and
shared libraries to be shared by multiple processes on an OS such as
uClinux, that can run on FR-V processors without an MMU.

Patches for binutils and GCC have just been posted in the
corresponding mailing lists.  The binutils patch was approved,
but there's one additional patch pending review, that I posted
this week.  An updated GCC patch will be posted to
gcc-patches at gcc.gnu.org as soon as I complete testing (I used a
known-good compiler to test the uClibc patch below).

Since the existing dynamic loader code didn't support independent
relocation of segments, it required changes that were somewhat
extensive.  I've added a number of new machine-specific macros to try
to keep the platform and ABI-specific details outside the generic
code.  I hope this is not a problem.



--- NEW FILE: kernel_stat.h ---
#ifndef _BITS_STAT_STRUCT_H
#define _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 
 * 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 char	__pad2[6];
	unsigned short	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. */
	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 */

--- NEW FILE: mman.h ---
/* Definitions for POSIX memory map interface.  Linux/frv 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
#endif

--- NEW FILE: fcntl.h ---
/* O_*, F_*, FD_* bit values for Linux.
   Copyright (C) 1995, 1996, 1997, 1998, 2000 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	_FCNTL_H
# error "Never use <bits/fcntl.h> directly; include <fcntl.h> instead."
#endif


#include <sys/types.h>

/* open/fcntl - O_SYNC is only implemented on blocks devices and on files
   located on an ext2 file system */
#define O_ACCMODE	   0003
#define O_RDONLY	     00
#define O_WRONLY	     01
#define O_RDWR		     02
#define O_CREAT		   0100	/* not fcntl */
#define O_EXCL		   0200	/* not fcntl */
#define O_NOCTTY	   0400	/* not fcntl */
#define O_TRUNC		  01000	/* not fcntl */
#define O_APPEND	  02000
#define O_NONBLOCK	  04000
#define O_NDELAY	O_NONBLOCK
#define O_SYNC		 010000
#define O_FSYNC		 O_SYNC
#define O_ASYNC		 020000

#ifdef __USE_GNU
# 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_STREAMING	04000000/* streaming access */
#endif

/* For now Linux has synchronisity options for data and read operations.
   We define the symbols here but let them do the same as O_SYNC since
   this is a superset.  */
#if defined __USE_POSIX199309 || defined __USE_UNIX98
# define O_DSYNC	O_SYNC	/* Synchronize data.  */
# define O_RSYNC	O_SYNC	/* Synchronize read operations.  */
#endif

#ifdef __USE_LARGEFILE64
# define O_LARGEFILE	0100000
#endif

/* Values for the second argument to `fcntl'.  */
#define F_DUPFD		0	/* Duplicate file descriptor.  */
#define F_GETFD		1	/* Get file descriptor flags.  */
#define F_SETFD		2	/* Set file descriptor flags.  */
#define F_GETFL		3	/* Get file status flags.  */
#define F_SETFL		4	/* Set file status flags.  */
#ifndef __USE_FILE_OFFSET64
# define F_GETLK	5	/* Get record locking info.  */
# define F_SETLK	6	/* Set record locking info (non-blocking).  */
# define F_SETLKW	7	/* Set record locking info (blocking).  */
#else
# define F_GETLK	F_GETLK64  /* Get record locking info.  */
# define F_SETLK	F_SETLK64  /* Set record locking info (non-blocking).*/
# define F_SETLKW	F_SETLKW64 /* Set record locking info (blocking).  */
#endif
#define F_GETLK64	12	/* Get record locking info.  */
#define F_SETLK64	13	/* Set record locking info (non-blocking).  */
#define F_SETLKW64	14	/* Set record locking info (blocking).  */

#if defined __USE_BSD || defined __USE_XOPEN2K
# define F_SETOWN	8	/* Get owner of socket (receiver of SIGIO).  */
# define F_GETOWN	9	/* Set owner of socket (receiver of SIGIO).  */
#endif

#ifdef __USE_GNU
# define F_SETSIG	10	/* Set number of signal to be sent.  */
# define F_GETSIG	11	/* Get number of signal to be sent.  */
#endif

/* For F_[GET|SET]FL.  */
#define FD_CLOEXEC	1	/* actually anything with low bit set goes */

/* For posix fcntl() and `l_type' field of a `struct flock' for lockf().  */
#define F_RDLCK		0	/* Read lock.  */
#define F_WRLCK		1	/* Write lock.  */
#define F_UNLCK		2	/* Remove lock.  */

/* For old implementation of bsd flock().  */
#define F_EXLCK		4	/* or 3 */
#define F_SHLCK		8	/* or 4 */

#ifdef __USE_BSD
/* Operations for bsd flock(), also used by the kernel implementation.  */
# define LOCK_SH	1	/* shared lock */
# define LOCK_EX	2	/* exclusive lock */
# define LOCK_NB	4	/* or'd with one of the above to prevent
				   blocking */
# define LOCK_UN	8	/* remove lock */
#endif

struct flock
  {
    short int l_type;	/* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK.  */
    short int l_whence;	/* Where `l_start' is relative to (like `lseek').  */
#ifndef __USE_FILE_OFFSET64
    __off_t l_start;	/* Offset where the lock begins.  */
    __off_t l_len;	/* Size of the locked area; zero means until EOF.  */
#else
    __off64_t l_start;	/* Offset where the lock begins.  */
    __off64_t l_len;	/* Size of the locked area; zero means until EOF.  */
#endif
    __pid_t l_pid;	/* Process holding the lock.  */
  };

#ifdef __USE_LARGEFILE64
struct flock64
  {
    short int l_type;	/* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK.  */
    short int l_whence;	/* Where `l_start' is relative to (like `lseek').  */
    __off64_t l_start;	/* Offset where the lock begins.  */
    __off64_t l_len;	/* Size of the locked area; zero means until EOF.  */
    __pid_t l_pid;	/* Process holding the lock.  */
  };
#endif

/* Define some more compatibility macros to be backward compatible with
   BSD systems which did not managed to hide these kernel macros.  */
#ifdef	__USE_BSD
# define FAPPEND	O_APPEND
# define FFSYNC		O_FSYNC
# define FASYNC		O_ASYNC
# define FNONBLOCK	O_NONBLOCK
# define FNDELAY	O_NDELAY
#endif /* Use BSD.  */

/* Advise to `posix_fadvise'.  */
#ifdef __USE_XOPEN2K
# define POSIX_FADV_NORMAL	0 /* No further special treatment.  */
# define POSIX_FADV_RANDOM	1 /* Expect random page references.  */
# define POSIX_FADV_SEQUENTIAL	2 /* Expect sequential page references.  */
# define POSIX_FADV_WILLNEED	3 /* Will need these pages.  */
# define POSIX_FADV_DONTNEED	4 /* Don't need these pages.  */
# define POSIX_FADV_NOREUSE	5 /* Data will be accessed once.  */
#endif

--- NEW FILE: stackinfo.h ---
/* Copyright (C) 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.  */

/* This file contains a bit of information about the stack allocation
   of the processor.  */

#ifndef _STACKINFO_H
#define _STACKINFO_H	1

/* On FRV the stack grows down.  */
#define _STACK_GROWS_DOWN	1

#endif	/* stackinfo.h */

--- NEW FILE: elf-fdpic.h ---
/* Copyright 2003 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
Library 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; see the file COPYING.LIB.  If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA.  */

#ifndef _BITS_ELF_FDPIC_H
#define _BITS_ELF_FDPIC_H

/* These data structures are described in the FDPIC ABI extension.
   The kernel passes a process a memory map, such that for every LOAD
   segment there is an elf32_fdpic_loadseg entry.  A pointer to an
   elf32_fdpic_loadmap is passed in GR8 at start-up, and a pointer to
   an additional such map is passed in GR9 for the interpreter, when
   there is one.  */

#include <elf.h>

/* This data structure represents a PT_LOAD segment.  */
struct elf32_fdpic_loadseg
{
  /* Core address to which the segment is mapped.  */
  Elf32_Addr addr;
  /* VMA recorded in the program header.  */
  Elf32_Addr p_vaddr;
  /* Size of this segment in memory.  */
  Elf32_Word p_memsz;
};

struct elf32_fdpic_loadmap {
  /* Protocol version number, must be zero.  */
  Elf32_Half version;
  /* Number of segments in this map.  */
  Elf32_Half nsegs;
  /* The actual memory map.  */
  struct elf32_fdpic_loadseg segs[/*nsegs*/];
};

struct elf32_fdpic_loadaddr {
  struct elf32_fdpic_loadmap *map;
  void *got_value;
};

/* Map a pointer's VMA to its corresponding address according to the
   load map.  */
inline static void *
__reloc_pointer (void *p,
		 const struct elf32_fdpic_loadmap *map)
{
  int c;

#if 0
  if (map->version != 0)
    /* Crash.  */
    ((void(*)())0)();
#endif

  /* No special provision is made for NULL.  We don't want NULL
     addresses to go through relocation, so they shouldn't be in
     .rofixup sections, and, if they're present in dynamic
     relocations, they shall be mapped to the NULL address without
     undergoing relocations.  */

  for (c = 0;
       /* Take advantage of the fact that the loadmap is ordered by
	  virtual addresses.  In general there will only be 2 entries,
	  so it's not profitable to do a binary search.  */
       c < map->nsegs && p >= (void*)map->segs[c].p_vaddr;
       c++)
    {
      /* This should be computed as part of the pointer comparison
	 above, but we want to use the carry in the comparison, so we
	 can't convert it to an integer type beforehand.  */
      unsigned long offset = p - (void*)map->segs[c].p_vaddr;
      /* We explicitly refrain from checking for one-past-the-end.
	 Zero-sized objects aren't legal, and it's expected that array
	 addresses will be relocated before the addend that would make
	 it one-past-the-end is added.  This gives us a reasonable speed
	 up, and we couldn't possibly disambiguate all cases anyway.  */
      if (offset < map->segs[c].p_memsz)
	return (char*)map->segs[c].addr + offset;
    }
	     
  /* We might want to crash instead.  */
  return (void*)-1;
}

# define __RELOC_POINTER(ptr, loadaddr) \
  (__reloc_pointer ((void*)(ptr), \
		    (loadaddr).map))

#endif /* _BITS_ELF_FDPIC_H */

--- NEW FILE: endian.h ---
/* frv is little-endian.  */

#ifndef _ENDIAN_H
# error "Never use <bits/endian.h> directly; include <endian.h> instead."
#endif

#define __BYTE_ORDER __BIG_ENDIAN

--- NEW FILE: wordsize.h ---
/* 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

--- NEW FILE: kernel_types.h ---
/* 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 _ASM_POSIX_TYPES_H
#define _ASM_POSIX_TYPES_H

typedef unsigned short	__kernel_dev_t;
typedef unsigned long	__kernel_ino_t;
typedef unsigned short	__kernel_mode_t;
typedef unsigned short	__kernel_nlink_t;
typedef long		__kernel_off_t;
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 long		__kernel_time_t;
typedef long		__kernel_suseconds_t;
typedef long		__kernel_clock_t;
typedef int		__kernel_daddr_t;
typedef char *		__kernel_caddr_t;
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 long long	__kernel_loff_t;

typedef struct {
#ifdef __USE_ALL
	int val[2];
#else
	int __val[2];
#endif
} __kernel_fsid_t;

#endif /* _ASM_POSIX_TYPES_H */

--- NEW FILE: syscalls.h ---
#ifndef _BITS_SYSCALLS_H
#define _BITS_SYSCALLS_H
#ifndef _SYSCALL_H
# error "Never use <bits/syscalls.h> directly; include <sys/syscall.h> instead."
#endif

/* 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>

#ifndef __set_errno
# define __set_errno(val) ((*__errno_location ()) = (val))
#endif
#ifndef SYS_ify
# define SYS_ify(syscall_name)  (__NR_##syscall_name)
#endif

#ifndef __ASSEMBLER__

/* user-visible error numbers are in the range -1 - -4095: see <asm-frv/errno.h> */
#define __syscall_return(type, res) \
do { \
        unsigned long __sr2 = (res);		    			    \
	if ((unsigned long)(__sr2) >= (unsigned long)(-4095)) {		    \
		__set_errno (-(__sr2));					    \
		__sr2 = -1; 						    \
	}								    \
	return (type) (__sr2); 						    \
} while (0)

/* XXX - _foo needs to be __foo, while __NR_bar could be _NR_bar. */

#define _syscall0(type,name) \
type name(void) \
{ \
register unsigned long __scnum __asm__ ("gr7") = (__NR_##name); 	    \
register unsigned long __sc0 __asm__ ("gr8");				    \
__asm__ __volatile__ ("tra	gr0,gr0"				    \
	: "=r" (__sc0) 							    \
	: "r" (__scnum)); 						    \
__syscall_return(type,__sc0); 						    \
}

#define _syscall1(type,name,type1,arg1) \
type name(type1 arg1) \
{ \
register unsigned long __scnum __asm__ ("gr7") = (__NR_##name);		    \
register unsigned long __sc0 __asm__ ("gr8") = (unsigned long) arg1;	    \
__asm__ __volatile__ ("tra	gr0,gr0"				    \
	: "+r" (__sc0) 							    \
	: "r" (__scnum));						    \
__syscall_return(type,__sc0);	 					    \
}

#define _syscall2(type,name,type1,arg1,type2,arg2) \
type name(type1 arg1,type2 arg2) \
{ \
register unsigned long __scnum __asm__ ("gr7") = (__NR_##name);		    \
register unsigned long __sc0 __asm__ ("gr8") = (unsigned long) arg1;	    \
register unsigned long __sc1 __asm__ ("gr9") = (unsigned long) arg2;	    \
__asm__ __volatile__ ("tra	gr0,gr0"				    \
	: "+r" (__sc0)	 						    \
	: "r" (__scnum), "r" (__sc1));					    \
__syscall_return(type,__sc0);	 					    \
}

#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
type name(type1 arg1,type2 arg2,type3 arg3) \
{ \
register unsigned long __scnum __asm__ ("gr7") = (__NR_##name);		    \
register unsigned long __sc0 __asm__ ("gr8") = (unsigned long) arg1;	    \
register unsigned long __sc1 __asm__ ("gr9") = (unsigned long) arg2;	    \
register unsigned long __sc2 __asm__ ("gr10") = (unsigned long) arg3;	    \
__asm__ __volatile__ ("tra	gr0,gr0"				    \
	: "+r" (__sc0)	 						    \
	: "r" (__scnum), "r" (__sc1), "r" (__sc2));			    \
__syscall_return(type,__sc0);	 					    \
}

#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
{ \
register unsigned long __scnum __asm__ ("gr7") = (__NR_##name);		    \
register unsigned long __sc0 __asm__ ("gr8") = (unsigned long) arg1;	    \
register unsigned long __sc1 __asm__ ("gr9") = (unsigned long) arg2;	    \
register unsigned long __sc2 __asm__ ("gr10") = (unsigned long) arg3;	    \
register unsigned long __sc3 __asm__ ("gr11") = (unsigned long) arg4;	    \
__asm__ __volatile__ ("tra	gr0,gr0"				    \
	: "+r" (__sc0)	 						    \
	: "r" (__scnum), "r" (__sc1), "r" (__sc2), "r" (__sc3));	    \
__syscall_return(type,__sc0);	 					    \
}

#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 unsigned long __scnum __asm__ ("gr7") = (__NR_##name);		    \
register unsigned long __sc0 __asm__ ("gr8") = (unsigned long) arg1;	    \
register unsigned long __sc1 __asm__ ("gr9") = (unsigned long) arg2;	    \
register unsigned long __sc2 __asm__ ("gr10") = (unsigned long) arg3;	    \
register unsigned long __sc3 __asm__ ("gr11") = (unsigned long) arg4;	    \
register unsigned long __sc4 __asm__ ("gr12") = (unsigned long) arg5;	    \
__asm__ __volatile__ ("tra	gr0,gr0"				    \
	: "+r" (__sc0)	 						    \
	: "r" (__scnum), "r" (__sc1), "r" (__sc2),		 	    \
	  "r" (__sc3), "r" (__sc4));					    \
__syscall_return(type,__sc0);	 					    \
}

#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 unsigned long __scnum __asm__ ("gr7") = (__NR_##name);		    \
register unsigned long __sc0 __asm__ ("gr8") = (unsigned long) arg1;	    \
register unsigned long __sc1 __asm__ ("gr9") = (unsigned long) arg2;	    \
register unsigned long __sc2 __asm__ ("gr10") = (unsigned long) arg3;	    \
register unsigned long __sc3 __asm__ ("gr11") = (unsigned long) arg4;	    \
register unsigned long __sc4 __asm__ ("gr12") = (unsigned long) arg5;	    \
register unsigned long __sc5 __asm__ ("gr13") = (unsigned long) arg6;	    \
__asm__ __volatile__ ("tra	gr0,gr0"				    \
	: "+r" (__sc0)	 						    \
	: "r" (__scnum), "r" (__sc1), "r" (__sc2),			    \
	  "r" (__sc3), "r" (__sc4), "r" (__sc5));			    \
__syscall_return(type,__sc0);	 					    \
}

#endif /* __ASSEMBLER__ */
#endif /* _BITS_SYSCALLS_H */

--- NEW FILE: setjmp.h ---
/* Copyright (C) 1999, 2000, 2003, 2004 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'.  FRV version. */

#ifndef _SETJMP_H
# error "Never include <bits/setjmp.h> directly; use <setjmp.h> instead."
#endif

#define	__SETJMP_NUM_INT	32		/* number of integer registers to save */
#define	__SETJMP_NUM_DBL	32		/* number of double registers to save */

#define	__SETJMP_INT(x)	(x)
#define	__SETJMP_DBL(x)	(__SETJMP_NUM_INT+(x))
#define	__SETJMP_LR	(__SETJMP_NUM_INT+__SETJMP_NUM_DBL)
#define __SETJMP_SP	(__SETJMP_LR+1)
#define __SETJMP_FP	(__SETJMP_SP+1)


#ifndef _ASM
typedef struct
/* Demand 64-bit alignment such that we can use std/ldd in
   setjmp/longjmp.  */
__attribute__((__aligned__(8)))
  {
    /* Callee-saved registers.  */
    unsigned long __ints[__SETJMP_NUM_INT];	/* integer registers */
    unsigned long __dbls[__SETJMP_NUM_DBL];	/* double registers */
    unsigned long __lr;				/* linkage register */
    unsigned long __sp;				/* stack pointer */
    unsigned long __fp;				/* frame pointer */
  } __jmp_buf[1];
#endif

/* Test if longjmp to JMPBUF would unwind the frame
   containing a local variable at ADDRESS.  */
#define _JMPBUF_UNWINDS(jmpbuf, address) \
  ((unsigned long) (address) < (jmpbuf)->__sp)




More information about the uClibc-cvs mailing list