xref: /netbsd/lib/libc/arch/powerpc/sys/cerror.S (revision c4a72b64)
1/*	$NetBSD: cerror.S,v 1.6 2002/07/30 06:07:59 matt Exp $	*/
2
3#include <machine/asm.h>
4#include "SYS.h"
5
6#ifndef _REENTRANT
7	.globl	_C_LABEL(errno)
8#endif
9
10ENTRY(__cerror)
11#ifdef _REENTRANT
12	mflr	%r0
13	stwu	%r1,-16(%r1)		# allocate new stack frame
14	stw	%r0,20(%r1)
15	stw	%r31,8(%r1)
16	mr	%r31,%r3		# stash away in callee-saved register
17	bl	PIC_PLT(_C_LABEL(__errno))
18	stw	%r31,0(%r3)
19	lwz	%r0,20(%r1)
20	lwz	%r31,8(%r1)
21	mtlr	%r0
22	la	%r1,16(%r1)
23#else
24#ifdef PIC
25	mflr	%r10
26	bl	_GLOBAL_OFFSET_TABLE_@local-4
27	mflr	%r4
28	lwz	%r4,_C_LABEL(errno)@got(%r4)
29	stw	%r3,0(%r4)
30	mtlr	%r10
31#else
32	lis	%r4,_C_LABEL(errno)@ha
33	stw	%r3,_C_LABEL(errno)@l(%r4)
34#endif /* PIC */
35#endif /* _REENTRANT */
36	li	%r3,-1
37	li	%r4,-1
38	blr
39