summaryrefslogtreecommitdiff
path: root/libc/sysdeps/linux/metag/sysdep.h
blob: 8750641b6d7599a6ae3cb66f390e62dbd8e314ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*
 * Assembler macros for Meta.
 *
 * Licensed under LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
 */

#include <common/sysdep.h>

#include <features.h>
#include <libc-internal.h>

#ifdef	__ASSEMBLER__

#ifdef SHARED
#define PLTJMP(_x)	_x##@PLT
#else
#define PLTJMP(_x)	_x
#endif

#undef	PSEUDO_END
#define	PSEUDO_END(name)						\
  SYSCALL_ERROR_HANDLER							\
  END (name)

#if defined NOT_IN_libc
# define SYSCALL_ERROR __local_syscall_error
# ifdef RTLD_PRIVATE_ERRNO
#  define SYSCALL_ERROR_HANDLER					\
__local_syscall_error:						\
       NEG	D0Re0, D0Re0;					\
       ADDT	D1Re0, CPC1, #HI(_rtld_errno);			\
       ADD	D1Re0, D1Re0, #LO(_rtld_errno) + 4;		\
       SETD	[D1Re0], D0Re0;					\
       NEG	D0Re0, #0x1;					\
       MOV	PC, D1RtP;
# else
#  define SYSCALL_ERROR_HANDLER					\
__local_syscall_error:						\
	MOV	D1Re0, D1RtP;					\
	SETL	[A0StP++], D0Re0, D1Re0;			\
	CALLR	D1RtP, PLTJMP(___errno_location);		\
	GETD	D1Re0, [A0StP+#-8];				\
	NEG	D1Re0, D1Re0;					\
	SETD	[D0Re0], D1Re0;					\
	NEG	D0Re0, #0x1;					\
	GETD	D1RtP, [A0StP+#-4];				\
	SUB	A0StP, A0StP, #0x8;				\
	MOV	PC, D1RtP;
# endif
#else
# define SYSCALL_ERROR_HANDLER	/* Nothing here; code in sysdep.S is used.  */
# define SYSCALL_ERROR ___syscall_error
#endif

#endif /* __ASSEMBLER __*/