]> git.saurik.com Git - apple/libc.git/blobdiff - gen/isnan.c
Libc-594.1.4.tar.gz
[apple/libc.git] / gen / isnan.c
index bce7a533db8e4e1bfa8f6caac42027b4432a621d..43ce009b0e5396f23286c644d1a9770962a3702b 100644 (file)
@@ -1,83 +1,32 @@
 /*
- * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 1999, 2008 Apple Inc. All rights reserved.
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
-/* @(#)s_isnan.c 5.1 93/09/24 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice 
- * is preserved.
- * ====================================================
- */
-
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: s_isnan.c,v 1.8 1995/05/10 20:47:36 jtc Exp $";
-#endif
-
-/*
- * isnan(x) returns 1 is x is nan, else 0;
- * no branching!
- */
-
-#include <sys/types.h>
-
-typedef union
-{
-  double value;
-  struct
-  {
-#if defined(__BIG_ENDIAN__)
-    u_int32_t msw;
-    u_int32_t lsw;
-#else
-    u_int32_t lsw;
-    u_int32_t msw;
-#endif
-  } parts;
-} ieee_double_shape_type;
-/* Get two 32 bit ints from a double.  */
-
-#define EXTRACT_WORDS(ix0,ix1,d)                               \
-do {                                                           \
-  ieee_double_shape_type ew_u;                                 \
-  ew_u.value = (d);                                            \
-  (ix0) = ew_u.parts.msw;                                      \
-  (ix1) = ew_u.parts.lsw;                                      \
-} while (0)
 
+#include <math.h>
 
-#ifdef __STDC__
-       int isnan(double x)
-#else
-       int isnan(x)
-       double x;
-#endif
+/* 3BSD compatibility function */
+#undef isnan
+int
+isnan(double d)
 {
-       int32_t hx,lx;
-       EXTRACT_WORDS(hx,lx,x);
-       hx &= 0x7fffffff;
-       hx |= (u_int32_t)(lx|(-lx))>>31;        
-       hx = 0x7ff00000 - hx;
-       return (int)((u_int32_t)(hx))>>31;
+    return __inline_isnand(d);
 }