用于嵌入式Linux系统的标准C的库函数

源代码在线查看: strtoufix32.c

软件大小: 6528 K
上传用户: whyzhao
关键词: Linux 嵌入式 标准
下载地址: 免注册下载 普通下载 VIP

相关代码

				#ifdef __SPE__ 								#include 				#include 				#include 				#include 				#include 				#include "vfieeefp.h"								/*				 * Convert a string to a fixed-point 32-bit value.				 *				 * Ignores `locale' stuff.				 */				__uint32_t				_DEFUN (_strtoufix32_r, (rptr, nptr, endptr),					struct _reent *rptr _AND					_CONST char *nptr _AND					char **endptr)				{				  union double_union dbl;				  int exp, negexp;				  __uint32_t tmp, tmp2, result = 0;								  dbl.d = _strtod_r (rptr, nptr, endptr);								  /* treat NAN as domain error, +/- infinity as saturation */				  if (!finite(dbl.d))				    {				      if (isnan (dbl.d))					{					  rptr->_errno = EDOM;					  return 0;					}				      rptr->_errno = ERANGE;				      if (word0(dbl) & Sign_bit)					return 0;				      return ULONG_MAX;				    }								  /* check for normal saturation */				  if (dbl.d >= 1.0)				    {				      rptr->_errno = ERANGE;				      return ULONG_MAX;				    }				  else if (dbl.d < 0)				    {				      rptr->_errno = ERANGE;				      return 0;				    }								  /* otherwise we have normal positive number in range */								  /* strip off exponent */				  exp = ((word0(dbl) & Exp_mask) >> Exp_shift) - Bias;				  negexp = -exp;				  if (negexp > 32)				    return 0;				  word0(dbl) &= ~(Exp_mask | Sign_bit);				  /* add in implicit normalized bit */				  word0(dbl) |= Exp_msk1;				  /* shift so result is contained left-justified in word */				  tmp = word0(dbl) 				  tmp |= ((unsigned long)word1(dbl) >> (32 - Ebits));				  /* perform rounding */				  if (negexp > 1)				    {				      tmp2 = tmp + (1 				      result = (tmp2 >> (negexp - 1));				      /* if rounding causes carry, add carry bit in */				      if (tmp2 < tmp)					result += 1 				    }				  else				    {				      result = tmp + ((word1(dbl) & (1 				      /* if rounding causes carry, then saturation has occurred */				      if (result < tmp)					{					  rptr->_errno = ERANGE;					  return ULONG_MAX;					}				    }								  return result;				}								#ifndef _REENT_ONLY								__uint32_t				_DEFUN (strtoufix32, (s, ptr, base),					_CONST char *s _AND					char **ptr)				{				  return _strtoufix32_r (_REENT, s, ptr);				}								#endif								#endif /* __SPE__ */							

相关资源