xref: /netbsd/lib/libc/arch/x86_64/stdlib/labs.S (revision adeb86dd)
1*adeb86ddSuebayasi/*	$NetBSD: labs.S,v 1.3 2014/05/22 15:01:56 uebayasi Exp $	*/
210f59d7bSfvdl
310f59d7bSfvdl/*
410f59d7bSfvdl * Written by Frank van der Linden (fvdl@wasabisystems.com)
510f59d7bSfvdl * Public Domain.
610f59d7bSfvdl */
710f59d7bSfvdl
810f59d7bSfvdl#include <machine/asm.h>
910f59d7bSfvdl
1010f59d7bSfvdl#if defined(LIBC_SCCS)
11*adeb86ddSuebayasi	RCSID("$NetBSD: labs.S,v 1.3 2014/05/22 15:01:56 uebayasi Exp $")
1210f59d7bSfvdl#endif
1310f59d7bSfvdl
14e796a34cSmatt#ifdef WEAK_ALIAS
15e796a34cSmattWEAK_ALIAS(imaxabs, _llabs)
16e796a34cSmattWEAK_ALIAS(llabs, _llabs)
17e796a34cSmattWEAK_ALIAS(labs, _labs)
18e796a34cSmatt#endif
19e796a34cSmatt
20e796a34cSmatt#ifdef WEAK_ALIAS
21e796a34cSmattENTRY(_llabs)
22e796a34cSmattENTRY(_labs)
23e796a34cSmatt#else
2410f59d7bSfvdlENTRY(llabs)
2510f59d7bSfvdlENTRY(labs)
26e796a34cSmatt#endif
2710f59d7bSfvdl        movq    %rdi,%rax
2810f59d7bSfvdl        testq   %rax,%rax
2910f59d7bSfvdl        jns     1f
3010f59d7bSfvdl        negq    %rax
3110f59d7bSfvdl1:      ret
32*adeb86ddSuebayasi#ifdef WEAK_ALIAS
33*adeb86ddSuebayasiEND(_llabs)
34*adeb86ddSuebayasiEND(_labs)
35*adeb86ddSuebayasi#else
36*adeb86ddSuebayasiEND(llabs)
37*adeb86ddSuebayasiEND(labs)
38*adeb86ddSuebayasi#endif
39