From cdf278b6057cacffcbf1940bd8fed63cb23c9242 Mon Sep 17 00:00:00 2001 From: idgay Date: Sat, 20 Sep 2008 00:10:18 +0000 Subject: [PATCH] nx_float support --- tos/chips/atm128/atm128hardware.h | 7 ++++++- tos/chips/msp430/msp430hardware.h | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/tos/chips/atm128/atm128hardware.h b/tos/chips/atm128/atm128hardware.h index 32c1c8e3..b412d90f 100644 --- a/tos/chips/atm128/atm128hardware.h +++ b/tos/chips/atm128/atm128hardware.h @@ -135,7 +135,12 @@ mcu_power_t mcombine(mcu_power_t m1, mcu_power_t m2) @safe() { return (m1 < m2)? m1: m2; } -/* Floating-point network-type support */ +/* Floating-point network-type support. + These functions must convert to/from a 32-bit big-endian integer that follows + the layout of Java's java.lang.float.floatToRawIntBits method. + Conveniently, for the AVR family, this is a straight byte copy... +*/ + typedef float nx_float __attribute__((nx_base_be(afloat))); inline float __nesc_ntoh_afloat(const void *COUNT(sizeof(float)) source) @safe() { diff --git a/tos/chips/msp430/msp430hardware.h b/tos/chips/msp430/msp430hardware.h index 829f2bd8..ac18b26c 100644 --- a/tos/chips/msp430/msp430hardware.h +++ b/tos/chips/msp430/msp430hardware.h @@ -239,7 +239,12 @@ void __nesc_atomic_end(__nesc_atomic_t reenable_interrupts) @spontaneous() @safe } #endif -/* Floating-point network-type support */ +/* Floating-point network-type support. + These functions must convert to/from a 32-bit big-endian integer that follows + the layout of Java's java.lang.float.floatToRawIntBits method. + Conveniently, for the MSP430 family, this is a straight byte copy... +*/ + typedef float nx_float __attribute__((nx_base_be(afloat))); inline float __nesc_ntoh_afloat(const void *COUNT(sizeof(float)) source) @safe() { -- 2.39.2