Print this page
11210 libm should be cstyle(1ONBLD) clean


  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.
  25  */
  26 
  27 /*
  28  * Copyright 2011, Richard Lowe
  29  */
  30 
  31 /* Functions in this file are duplicated in locallibm.il.  Keep them in sync */
  32 
  33 #ifndef _LIBM_INLINES_H
  34 #define _LIBM_INLINES_H
  35 
  36 #ifdef __GNUC__
  37 
  38 #ifdef __cplusplus
  39 extern "C" {
  40 #endif
  41 
  42 #include <sys/types.h>
  43 #include <sys/ieeefp.h>
  44 
  45 #define _LO_WORD(x)     ((uint32_t *)&x)[0]
  46 #define _HI_WORD(x)     ((uint32_t *)&x)[1]
  47 #define _HIER_WORD(x)   ((uint32_t *)&x)[2]
  48 
  49 extern __GNU_INLINE double
  50 __inline_sqrt(double a)
  51 {
  52         double ret;
  53 
  54         __asm__ __volatile__("fsqrt\n\t" : "=t" (ret) : "0" (a) : "cc");
  55         return (ret);
  56 }
  57 


 244 
 245         return (ret);
 246 }
 247 
 248 extern __GNU_INLINE int
 249 isnanf(float f)
 250 {
 251         __asm__ __volatile__(
 252             "andl $0x7fffffff,%0\n\t"
 253             "negl %0\n\t"
 254             "addl $0x7f800000,%0\n\t"
 255             "shrl $31,%0\n\t"
 256             : "+r" (f)
 257             :
 258             : "cc");
 259 
 260         return (f);
 261 }
 262 
 263 extern __GNU_INLINE double
 264 rint(double a) {

 265     return (__inline_rint(a));
 266 }
 267 
 268 extern __GNU_INLINE double
 269 scalbn(double d, int n)
 270 {
 271         double dummy;
 272 
 273         __asm__ __volatile__(
 274             "fildl %2\n\t"      /* Convert N to extended */
 275             "fxch\n\t"
 276             "fscale\n\t"
 277             : "+t" (d), "=u" (dummy)
 278             : "m" (n)
 279             : "cc");
 280 
 281         return (d);
 282 }
 283 
 284 extern __GNU_INLINE int


 328             "jmp   1f\n\t"
 329             "2:\n\t"                    /* note that %0 = 0 from before */
 330             "cmpl  $0x80000000,%1\n\t"  /* what is first half of significand? */
 331             "jnz   3f\n\t"              /* jump if not equal to 0x80000000 */
 332             "testl $0xffffffff,%2\n\t"  /* is second half of significand 0? */
 333             "jnz   3f\n\t"              /* jump if not equal to 0 */
 334             "jmp   1f\n\t"
 335             "3:\n\t"
 336             "movl  $1,%0\n\t"
 337             "1:\n\t"
 338             : "+&r" (ret)
 339             : "r" (_HI_WORD(ld)), "r" (_LO_WORD(ld))
 340             : "cc");
 341 
 342         return (ret);
 343 }
 344 
 345 #ifdef __cplusplus
 346 }
 347 #endif
 348 
 349 #endif  /* __GNUC__ */
 350 
 351 #endif /* _LIBM_INLINES_H */


  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.
  25  */
  26 
  27 /*
  28  * Copyright 2011, Richard Lowe
  29  */
  30 
  31 /* Functions in this file are duplicated in locallibm.il.  Keep them in sync */
  32 
  33 #ifndef _LIBM_INLINES_H
  34 #define _LIBM_INLINES_H
  35 
  36 #ifdef __GNUC__

  37 #ifdef __cplusplus
  38 extern "C" {
  39 #endif
  40 
  41 #include <sys/types.h>
  42 #include <sys/ieeefp.h>
  43 
  44 #define _LO_WORD(x)     ((uint32_t *)&x)[0]
  45 #define _HI_WORD(x)     ((uint32_t *)&x)[1]
  46 #define _HIER_WORD(x)   ((uint32_t *)&x)[2]
  47 
  48 extern __GNU_INLINE double
  49 __inline_sqrt(double a)
  50 {
  51         double ret;
  52 
  53         __asm__ __volatile__("fsqrt\n\t" : "=t" (ret) : "0" (a) : "cc");
  54         return (ret);
  55 }
  56 


 243 
 244         return (ret);
 245 }
 246 
 247 extern __GNU_INLINE int
 248 isnanf(float f)
 249 {
 250         __asm__ __volatile__(
 251             "andl $0x7fffffff,%0\n\t"
 252             "negl %0\n\t"
 253             "addl $0x7f800000,%0\n\t"
 254             "shrl $31,%0\n\t"
 255             : "+r" (f)
 256             :
 257             : "cc");
 258 
 259         return (f);
 260 }
 261 
 262 extern __GNU_INLINE double
 263 rint(double a)
 264 {
 265         return (__inline_rint(a));
 266 }
 267 
 268 extern __GNU_INLINE double
 269 scalbn(double d, int n)
 270 {
 271         double dummy;
 272 
 273         __asm__ __volatile__(
 274             "fildl %2\n\t"      /* Convert N to extended */
 275             "fxch\n\t"
 276             "fscale\n\t"
 277             : "+t" (d), "=u" (dummy)
 278             : "m" (n)
 279             : "cc");
 280 
 281         return (d);
 282 }
 283 
 284 extern __GNU_INLINE int


 328             "jmp   1f\n\t"
 329             "2:\n\t"                    /* note that %0 = 0 from before */
 330             "cmpl  $0x80000000,%1\n\t"  /* what is first half of significand? */
 331             "jnz   3f\n\t"              /* jump if not equal to 0x80000000 */
 332             "testl $0xffffffff,%2\n\t"  /* is second half of significand 0? */
 333             "jnz   3f\n\t"              /* jump if not equal to 0 */
 334             "jmp   1f\n\t"
 335             "3:\n\t"
 336             "movl  $1,%0\n\t"
 337             "1:\n\t"
 338             : "+&r" (ret)
 339             : "r" (_HI_WORD(ld)), "r" (_LO_WORD(ld))
 340             : "cc");
 341 
 342         return (ret);
 343 }
 344 
 345 #ifdef __cplusplus
 346 }
 347 #endif

 348 #endif  /* __GNUC__ */

 349 #endif /* _LIBM_INLINES_H */