Home | History | Annotate | Line # | Download | only in i386
      1       1.1  mrg /*
      2  1.1.1.11  mrg  * Copyright (C) 2007-2024 Free Software Foundation, Inc.
      3       1.1  mrg  *
      4       1.1  mrg  * This file is free software; you can redistribute it and/or modify it
      5       1.1  mrg  * under the terms of the GNU General Public License as published by the
      6       1.1  mrg  * Free Software Foundation; either version 3, or (at your option) any
      7       1.1  mrg  * later version.
      8       1.1  mrg  *
      9       1.1  mrg  * This file is distributed in the hope that it will be useful, but
     10       1.1  mrg  * WITHOUT ANY WARRANTY; without even the implied warranty of
     11       1.1  mrg  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     12       1.1  mrg  * General Public License for more details.
     13       1.1  mrg  *
     14       1.1  mrg  * Under Section 7 of GPL version 3, you are granted additional
     15       1.1  mrg  * permissions described in the GCC Runtime Library Exception, version
     16       1.1  mrg  * 3.1, as published by the Free Software Foundation.
     17       1.1  mrg  *
     18       1.1  mrg  * You should have received a copy of the GNU General Public License and
     19       1.1  mrg  * a copy of the GCC Runtime Library Exception along with this program;
     20       1.1  mrg  * see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
     21       1.1  mrg  * <http://www.gnu.org/licenses/>.
     22       1.1  mrg  */
     23       1.1  mrg 
     24   1.1.1.2  mrg #ifndef _SOFT_FLOAT
     25       1.1  mrg #if __PREC == 32
     26       1.1  mrg  #define X87CW		(0 << 8)	/* Single precision (24 bits) */
     27       1.1  mrg #elif __PREC == 64
     28       1.1  mrg  #define X87CW		(2 << 8)	/* Double precision (53 bits) */
     29       1.1  mrg #elif __PREC == 80
     30       1.1  mrg  #define X87CW		(3 << 8)	/* Extended precision (64 bits) */
     31       1.1  mrg #else
     32       1.1  mrg  #error "Wrong precision requested."
     33       1.1  mrg #endif
     34       1.1  mrg 
     35       1.1  mrg #define X87CW_PCMASK	(3 << 8)
     36       1.1  mrg 
     37       1.1  mrg static void __attribute__((constructor))
     38       1.1  mrg set_precision (void)
     39       1.1  mrg {
     40       1.1  mrg   unsigned short int cwd;
     41       1.1  mrg 
     42   1.1.1.8  mrg   asm volatile ("fnstcw\t%0" : "=m" (cwd));
     43       1.1  mrg 
     44       1.1  mrg   cwd &= ~X87CW_PCMASK;
     45       1.1  mrg   cwd |= X87CW;
     46       1.1  mrg 
     47       1.1  mrg   asm volatile ("fldcw\t%0" : : "m" (cwd));
     48       1.1  mrg }
     49   1.1.1.2  mrg #endif
     50