Remove __ELF__ conditionals
[platform/upstream/glibc.git] / sysdeps / i386 / fpu / s_frexp.S
1 /* ix87 specific frexp implementation for double.
2    Copyright (C) 1997, 2000, 2005, 2012 Free Software Foundation, Inc.
3    This file is part of the GNU C Library.
4    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
5
6    The GNU C Library is free software; you can redistribute it and/or
7    modify it under the terms of the GNU Lesser General Public
8    License as published by the Free Software Foundation; either
9    version 2.1 of the License, or (at your option) any later version.
10
11    The GNU C Library is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14    Lesser General Public License for more details.
15
16    You should have received a copy of the GNU Lesser General Public
17    License along with the GNU C Library; if not, write to the Free
18    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19    02111-1307 USA.  */
20
21 #include <machine/asm.h>
22 #include "bp-sym.h"
23 #include "bp-asm.h"
24
25         .section .rodata
26
27         .align ALIGNARG(4)
28         ASM_TYPE_DIRECTIVE(two54,@object)
29 two54:  .byte 0, 0, 0, 0, 0, 0, 0x50, 0x43
30         ASM_SIZE_DIRECTIVE(two54)
31
32 #ifdef PIC
33 #define MO(op) op##@GOTOFF(%edx)
34 #else
35 #define MO(op) op
36 #endif
37
38 #define PARMS   LINKAGE         /* no space for saved regs */
39 #define VAL0    PARMS
40 #define VAL1    VAL0+4
41 #define EXPP    VAL1+4
42
43         .text
44 ENTRY (BP_SYM (__frexp))
45         ENTER
46
47         movl    VAL0(%esp), %ecx
48         movl    VAL1(%esp), %eax
49         movl    %eax, %edx
50         andl    $0x7fffffff, %eax
51         orl     %eax, %ecx
52         jz      1f
53         xorl    %ecx, %ecx
54         cmpl    $0x7ff00000, %eax
55         jae     1f
56
57         cmpl    $0x00100000, %eax
58         jae     2f
59
60         fldl    VAL0(%esp)
61 #ifdef  PIC
62         LOAD_PIC_REG (dx)
63 #endif
64         fmull   MO(two54)
65         movl    $-54, %ecx
66         fstpl   VAL0(%esp)
67         fwait
68         movl    VAL1(%esp), %eax
69         movl    %eax, %edx
70         andl    $0x7fffffff, %eax
71
72 2:      shrl    $20, %eax
73         andl    $0x800fffff, %edx
74         subl    $1022, %eax
75         orl     $0x3fe00000, %edx
76         addl    %eax, %ecx
77         movl    %edx, VAL1(%esp)
78
79         /* Store %ecx in the variable pointed to by the second argument,
80            get the factor from the stack and return.  */
81 1:      movl    EXPP(%esp), %eax
82         CHECK_BOUNDS_BOTH_WIDE (%eax, EXPP(%esp), $4)
83         fldl    VAL0(%esp)
84         movl    %ecx, (%eax)
85
86         LEAVE
87         ret
88 END (BP_SYM (__frexp))
89 weak_alias (BP_SYM (__frexp), BP_SYM (frexp))