/* Copyright (C) 1992,95,97,99,2000 Free Software Foundation, Inc.
   This file is part of the GNU C Library.
   Contributed by Brendan Kehoe (brendan@zen.org).

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

#include <sysdeps/unix/sysdep.h>
#include <asm/errno.h>

#ifndef _MAP_SYSDEP_H_
#define _MAP_SYSDEP_H_

#ifdef __ASSEMBLER__

#ifdef NO_UNDERSCORES
# define ASM_ify(a)	a
#else
# define ASM_ify(a)	_##a
#endif

#define ENTRY(name) \
	.text;					\
    	.global ASM_ify(name);			\
ASM_ify(name):


/*
 * Note that while it's better structurally, going back to call __syscall_error
 * can make things confusing if you're debugging---it looks like it's jumping
 * backwards into the previous fn.
 */

/*
 * ETI WvH: goto syscall error routine if return value != 0!
 */
#define PSEUDO(name, syscall_name, args) 		\
ENTRY(name)						\
	.i0	 mv.32    r39 16@SYS_ify(syscall_name);	\
	.i0	 trap;					\
							\
	.i0	 mv.32    r30 16@(-EMAXERRNO);		\
	.i0	 cle.u32  p2  r32 r30;			\
	;						\
	.i0 (p2) bra r63;				\
	;						\
	;						\
	.i0	 sethi.32 r61 hi(ASM_ify(__syscall_error));	\
	.i0	 dincr.32 r61 lo(ASM_ify(__syscall_error));	\
	;						\
	.i0	 bra      r61;				\
	;						\
	;

#undef PSEUDO_END
#define PSEUDO_END(sym)

#undef END
#define END(sym)

#define ret

#endif	/* __ASSEMBLER */

#endif	/* _MAP_SYSDEP_H_ */
