binutils-gdb/sim/erc32/float.c
Tom Tromey 81e6e8ae40 Do not use old-style definitions in sim
This changes all the non-generated (hand-written) code in sim to use
"new" (post-K&R) style function definitions.

2021-04-08  Tom Tromey  <tom@tromey.com>

	* bpf.c (bpf_def_model_init): Use new-style declaration.

sim/common/ChangeLog
2021-04-08  Tom Tromey  <tom@tromey.com>

	* cgen-utils.c (RORQI, ROLQI, RORHI, ROLHI, RORSI, ROLSI): Use
	new-style declaration.

sim/erc32/ChangeLog
2021-04-08  Tom Tromey  <tom@tromey.com>

	* sis.c (run_sim, main): Use new-style declaration.
	* interf.c (run_sim, sim_open, sim_close, sim_load)
	(sim_create_inferior, sim_store_register, sim_fetch_register)
	(sim_info, sim_stop_reason, flush_windows, sim_do_command): Use
	new-style declaration.
	* help.c (usage, gen_help): Use new-style declaration.
	* func.c (batch, set_regi, set_rega, disp_reg, limcalc)
	(reset_stat, show_stat, init_bpt, int_handler, init_signals)
	(disp_fpu, disp_regs, disp_ctrl, disp_mem, dis_mem, event)
	(init_event, set_int, advance_time, now, wait_for_irq, check_bpt)
	(reset_all, sys_reset, sys_halt): Use new-style declaration.
	* float.c (get_accex, clear_accex, set_fsr): Use new-style
	declaration.
	* exec.c (sub_cc, add_cc, log_cc, dispatch_instruction, fpexec)
	(chk_asi, execute_trap, check_interrupts, init_regs): Use
	new-style declaration.
	* erc32.c (init_sim, reset, decode_ersr, mecparerror)
	(error_mode, decode_memcfg, decode_wcr, decode_mcr, sim_halt)
	(close_port, exit_sim, mec_reset, mec_intack, chk_irq, mec_irq)
	(set_sfsr, mec_read, mec_write, init_stdio, restore_stdio)
	(port_init, read_uart, write_uart, flush_uart, uarta_tx)
	(uartb_tx, uart_rx, uart_intr, uart_irq_start, wdog_intr)
	(wdog_start, rtc_intr, rtc_start, rtc_counter_read)
	(rtc_scaler_set, rtc_reload_set, gpt_intr, gpt_start)
	(gpt_counter_read, gpt_scaler_set, gpt_reload_set, timer_ctrl)
	(memory_read, memory_write, get_mem_ptr, sis_memory_write)
	(sis_memory_read): Use new-style declaration.

sim/frv/ChangeLog
2021-04-08  Tom Tromey  <tom@tromey.com>

	* sim-if.c (sim_open, frv_sim_close, sim_create_inferior): Use
	new-style declaration.

sim/h8300/ChangeLog
2021-04-08  Tom Tromey  <tom@tromey.com>

	* compile.c (cmdline_location): Use new-style declaration.

sim/iq2000/ChangeLog
2021-04-08  Tom Tromey  <tom@tromey.com>

	* sim-if.c (sim_open, sim_create_inferior): Use new-style
	declaration.
	* iq2000.c (fetch_str): Use new-style declaration.

sim/lm32/ChangeLog
2021-04-08  Tom Tromey  <tom@tromey.com>

	* sim-if.c (sim_open, sim_create_inferior): Use new-style
	declaration.

sim/m32r/ChangeLog
2021-04-08  Tom Tromey  <tom@tromey.com>

	* sim-if.c (sim_open, sim_create_inferior): Use new-style
	declaration.
2021-04-08 14:34:42 -06:00

84 lines
2.1 KiB
C

/* This file is part of SIS (SPARC instruction simulator)
Copyright (C) 1995-2021 Free Software Foundation, Inc.
Contributed by Jiri Gaisler, European Space Agency
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* This file implements the interface between the host and the simulated
FPU. IEEE trap handling is done as follows:
1. In the host, all IEEE traps are masked
2. After each simulated FPU instruction, check if any exception
occured by reading the exception bits from the host FPU status
register (get_accex()).
3. Propagate any exceptions to the simulated FSR.
4. Clear host exception bits.
*/
#include "config.h"
#include "sis.h"
#include <fenv.h>
/* This routine should return the accrued exceptions */
int
get_accex(void)
{
int fexc, accx;
fexc = fetestexcept (FE_ALL_EXCEPT);
accx = 0;
if (fexc & FE_INEXACT)
accx |= 1;
if (fexc & FE_DIVBYZERO)
accx |= 2;
if (fexc & FE_UNDERFLOW)
accx |= 4;
if (fexc & FE_OVERFLOW)
accx |= 8;
if (fexc & FE_INVALID)
accx |= 0x10;
return accx;
}
/* How to clear the accrued exceptions */
void
clear_accex(void)
{
feclearexcept (FE_ALL_EXCEPT);
}
/* How to map SPARC FSR onto the host */
void
set_fsr(uint32 fsr)
{
int fround;
fsr >>= 30;
switch (fsr) {
case 0:
fround = FE_TONEAREST;
break;
case 1:
fround = FE_TOWARDZERO;
break;
case 2:
fround = FE_UPWARD;
break;
case 3:
fround = FE_DOWNWARD;
break;
}
fesetround (fround);
}