Back to index

glibc  2.9
q_neg.c
Go to the documentation of this file.
00001 /* Software floating-point emulation.
00002    Return !a
00003    Copyright (C) 1997, 1999, 2000 Free Software Foundation, Inc.
00004    This file is part of the GNU C Library.
00005    Contributed by Richard Henderson (rth@cygnus.com) and
00006                 Jakub Jelinek (jj@ultra.linux.cz).
00007 
00008    The GNU C Library is free software; you can redistribute it and/or
00009    modify it under the terms of the GNU Lesser General Public
00010    License as published by the Free Software Foundation; either
00011    version 2.1 of the License, or (at your option) any later version.
00012 
00013    The GNU C Library is distributed in the hope that it will be useful,
00014    but WITHOUT ANY WARRANTY; without even the implied warranty of
00015    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016    Lesser General Public License for more details.
00017 
00018    You should have received a copy of the GNU Lesser General Public
00019    License along with the GNU C Library; if not, write to the Free
00020    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00021    02111-1307 USA.  */
00022 
00023 #include "soft-fp.h"
00024 #include "quad.h"
00025 
00026 long double _q_neg(const long double a)
00027 {
00028   FP_DECL_EX;
00029   long double c = a;
00030   
00031 #if (__BYTE_ORDER == __BIG_ENDIAN)
00032   ((UWtype *)&c)[0] ^= (((UWtype)1) << (W_TYPE_SIZE - 1));
00033 #elif (__BYTE_ORDER == __LITTLE_ENDIAN) && (W_TYPE_SIZE == 64)
00034   ((UWtype *)&c)[1] ^= (((UWtype)1) << (W_TYPE_SIZE - 1));
00035 #elif (__BYTE_ORDER == __LITTLE_ENDIAN) && (W_TYPE_SIZE == 32)
00036   ((UWtype *)&c)[3] ^= (((UWtype)1) << (W_TYPE_SIZE - 1));
00037 #else
00038   FP_DECL_Q(A); FP_DECL_Q(C);
00039 
00040   FP_UNPACK_Q(A, a);
00041   FP_NEG_Q(C, A);
00042   FP_PACK_Q(c, C);
00043 #endif
00044   FP_CLEAR_EXCEPTIONS;
00045   FP_HANDLE_EXCEPTIONS;
00046   return c;
00047 }