// $Id$
-/* tab:4
+/*
* IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. By
* downloading, copying, installing or using the software you agree to
* this license. If you do not agree to this license, do not download,
#define READ_FLAG(port, flag) ((port) & (flag))
/* Enables interrupts. */
-inline void __nesc_enable_interrupt() {
+inline void __nesc_enable_interrupt() @safe() {
sei();
}
/* Disables all interrupts. */
-inline void __nesc_disable_interrupt() {
+inline void __nesc_disable_interrupt() @safe() {
cli();
}
/* Saves current interrupt mask state and disables interrupts. */
inline __nesc_atomic_t
-__nesc_atomic_start(void) @spontaneous()
+__nesc_atomic_start(void) @spontaneous() @safe()
{
__nesc_atomic_t result = SREG;
__nesc_disable_interrupt();
/* Restores interrupt mask to original state. */
inline void
-__nesc_atomic_end(__nesc_atomic_t original_SREG) @spontaneous()
+__nesc_atomic_end(__nesc_atomic_t original_SREG) @spontaneous() @safe()
{
asm volatile("" : : : "memory"); /* ensure atomic section effect visibility */
SREG = original_SREG;
};
/* Combine function. */
-mcu_power_t mcombine(mcu_power_t m1, mcu_power_t m2) {
+mcu_power_t mcombine(mcu_power_t m1, mcu_power_t m2) @safe() {
return (m1 < m2)? m1: m2;
}
-#endif //_H_atmega128hardware_H
+/* 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() {
+ float f;
+ memcpy(&f, source, sizeof(float));
+ return f;
+}
+inline float __nesc_hton_afloat(void *COUNT(sizeof(float)) target, float value) @safe() {
+ memcpy(target, &value, sizeof(float));
+ return value;
+}
+#endif //_H_atmega128hardware_H