Back to index

glibc  2.9
qp_cmpe.c
Go to the documentation of this file.
00001 /* Software floating-point emulation.
00002    Compare (*a) and (*b), return float condition code.
00003    Signal exception (unless masked) if unordered.
00004    Copyright (C) 1997,1999 Free Software Foundation, Inc.
00005    This file is part of the GNU C Library.
00006    Contributed by Richard Henderson (rth@cygnus.com) and
00007                 Jakub Jelinek (jj@ultra.linux.cz).
00008 
00009    The GNU C Library is free software; you can redistribute it and/or
00010    modify it under the terms of the GNU Lesser General Public
00011    License as published by the Free Software Foundation; either
00012    version 2.1 of the License, or (at your option) any later version.
00013 
00014    The GNU C Library is distributed in the hope that it will be useful,
00015    but WITHOUT ANY WARRANTY; without even the implied warranty of
00016    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017    Lesser General Public License for more details.
00018 
00019    You should have received a copy of the GNU Lesser General Public
00020    License along with the GNU C Library; if not, write to the Free
00021    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00022    02111-1307 USA.  */
00023 
00024 #include "soft-fp.h"
00025 #include "quad.h"
00026 
00027 int _Qp_cmpe(const long double *a, const long double *b)
00028 {
00029   FP_DECL_EX;
00030   FP_DECL_Q(A); FP_DECL_Q(B);
00031   int r;
00032 
00033   FP_INIT_ROUNDMODE;
00034   FP_UNPACK_RAW_QP(A, a);
00035   FP_UNPACK_RAW_QP(B, b);
00036   FP_CMP_Q(r, B, A, 3);
00037   if (r == -1) r = 2;
00038   if (r == 3)
00039     FP_SET_EXCEPTION(FP_EX_INVALID);
00040   QP_HANDLE_EXCEPTIONS(
00041        __asm (
00042 "      ldd [%0], %%f52\n"
00043 "      ldd [%0+8], %%f54\n"
00044 "      ldd [%1], %%f56\n"
00045 "      ldd [%1+8], %%f58\n"
00046 "      fcmpeq %%fcc3, %%f52, %%f56\n"
00047 "      " : : "r" (a), "r" (b) : QP_CLOBBER_CC);
00048        _FPU_GETCW(_fcw);
00049        r = ((_fcw >> 36) & 3));
00050 
00051   return r;
00052 }