Пример #1
0
/*
 * The feraiseexcept() function shall attempt to raise the supported
 * floating-point exceptions represented by the argument excepts. The order
 * in which these floating-point exceptions are raised is unspecified. 
 */
int
feraiseexcept(int excepts)
{
#ifndef lint
	_DIAGASSERT((except & ~FE_ALL_EXCEPT) == 0);
#endif
#ifdef __SOFTFP__
	excepts &= fpgetsticky();

	if (excepts) {
		siginfo_t info;
		memset(&info, 0, sizeof info);
		info.si_signo = SIGFPE;
		info.si_pid = getpid();
		info.si_uid = geteuid();
		if (excepts & FE_UNDERFLOW)
			info.si_code = FPE_FLTUND;
		else if (excepts & FE_OVERFLOW)
			info.si_code = FPE_FLTOVF;
		else if (excepts & FE_DIVBYZERO)
			info.si_code = FPE_FLTDIV;
		else if (excepts & FE_INVALID)
			info.si_code = FPE_FLTINV;
		else if (excepts & FE_INEXACT)
			info.si_code = FPE_FLTRES;
		sigqueueinfo(getpid(), &info);
	}
#else
	int fpscr = armreg_fpscr_read();
	fpscr = (fpscr & ~VFP_FPSCR_ESUM) | __SHIFTIN(excepts, VFP_FPSCR_ESUM);
	armreg_fpscr_write(fpscr);
#endif
	return 0;
}
Пример #2
0
long long
__aeabi_ldiv0(long long result)
{
#ifdef _KERNEL
#else
	siginfo_t info;
	
	memset(&info, 0, sizeof info);
	info.si_signo = SIGFPE;
	info.si_pid = getpid();
	info.si_uid = geteuid();
	info.si_code = FPE_INTDIV;
	sigqueueinfo(getpid(), &info);
#endif
	return result;
}
Пример #3
0
int
__aeabi_idiv0(int result)
{
/* MINIX: LSC: Changed || to &&. */
#if !defined(_KERNEL) && !defined(_STANDALONE)
#if !defined(__minix) /* LSC: No sigqueueinfo on Minix. */
	siginfo_t info;
	
	memset(&info, 0, sizeof info);
	info.si_signo = SIGFPE;
	info.si_pid = getpid();
	info.si_uid = geteuid();
	info.si_code = FPE_INTDIV;
	sigqueueinfo(getpid(), &info);
#else
	/* LSC: So just trigger the signal. */
	raise(SIGFPE);
#endif /* !defined(__minix) */
#endif
	return result;
}