Blame sysdeps/ieee754/flt-32/s_ceilf.c

Packit 6c4009
/* s_ceilf.c -- float version of s_ceil.c.
Packit 6c4009
 * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
Packit 6c4009
 */
Packit 6c4009
Packit 6c4009
/*
Packit 6c4009
 * ====================================================
Packit 6c4009
 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
Packit 6c4009
 *
Packit 6c4009
 * Developed at SunPro, a Sun Microsystems, Inc. business.
Packit 6c4009
 * Permission to use, copy, modify, and distribute this
Packit 6c4009
 * software is freely granted, provided that this notice
Packit 6c4009
 * is preserved.
Packit 6c4009
 * ====================================================
Packit 6c4009
 */
Packit 6c4009
Packit 6c4009
#include <math.h>
Packit 6c4009
#include <math_private.h>
Packit 6c4009
#include <libm-alias-float.h>
Packit Service 69fc78
#include <math-use-builtins.h>
Packit 6c4009
Packit 6c4009
float
Packit Service 6de65a
__ceilf(float x)
Packit 6c4009
{
Packit Service 69fc78
#if USE_CEILF_BUILTIN
Packit Service 69fc78
  return __builtin_ceilf (x);
Packit Service 69fc78
#else
Packit Service 69fc78
  /* Use generic implementation.  */
Packit Service 6de65a
	int32_t i0,j0;
Packit Service 6de65a
	uint32_t i;
Packit 6c4009
Packit Service 6de65a
	GET_FLOAT_WORD(i0,x);
Packit Service 6de65a
	j0 = ((i0>>23)&0xff)-0x7f;
Packit Service 6de65a
	if(j0<23) {
Packit Service 6de65a
	    if(j0<0) {
Packit Service 6de65a
		/* return 0*sign(x) if |x|<1 */
Packit Service 6de65a
		if(i0<0) {i0=0x80000000;}
Packit Service 6de65a
		else if(i0!=0) { i0=0x3f800000;}
Packit Service 6de65a
	    } else {
Packit Service 6de65a
		i = (0x007fffff)>>j0;
Packit Service 6de65a
		if((i0&i)==0) return x; /* x is integral */
Packit Service 6de65a
		if(i0>0) i0 += (0x00800000)>>j0;
Packit Service 6de65a
		i0 &= (~i);
Packit Service 6de65a
	    }
Packit Service 6de65a
	} else {
Packit Service 6de65a
	    if(__builtin_expect(j0==0x80, 0)) return x+x; /* inf or NaN */
Packit Service 6de65a
	    else return x;		/* x is integral */
Packit Service 54252c
	}
Packit Service 6de65a
	SET_FLOAT_WORD(x,i0);
Packit Service 6de65a
	return x;
Packit Service 69fc78
#endif /* ! USE_CEILF_BUILTIN  */
Packit 6c4009
}
Packit 6c4009
#ifndef __ceilf
Packit 6c4009
libm_alias_float (__ceil, ceil)
Packit 6c4009
#endif