aros/libcall.h: Don't let AROS_CALL and AROS_LVO_CALL depend on __AROS_CPU_SPECIFIC_LC
[AROS.git] / compiler / arossupport / writefloat.c
blob84e3353ac8ad8fb52c2fa8990761b0c6557f0f26
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Write a big endian floating point (32bit) from a streamhook
6 Lang: english
7 */
9 #include <proto/dos.h>
11 /******************************************************************************
13 NAME */
14 #include <stdio.h>
15 #include <aros/bigendianio.h>
16 #include <proto/alib.h>
18 BOOL WriteFloat (
20 /* SYNOPSIS */
21 struct Hook * hook,
22 FLOAT data,
23 void * stream)
25 /* FUNCTION
26 Writes one big endian 32bit floating point value to a streamhook.
28 INPUTS
29 hook - Write to this streamhook
30 data - Data to be written
31 stream - Stream passed to streamhook
33 RESULT
34 The function returns TRUE on success and FALSE otherwise.
35 See IoErr() for the reason in case of an error.
37 NOTES
38 This function writes big endian values to a file even on little
39 endian machines.
41 EXAMPLE
43 BUGS
45 SEE ALSO
46 ReadByte(), ReadWord(), ReadLong(), ReadFloat(), ReadDouble(),
47 ReadString(), ReadStruct(), WriteByte(), WriteWord(), WriteLong(),
48 WriteFloat(), WriteDouble(), WriteString(), WriteStruct()
50 HISTORY
52 ******************************************************************************/
54 UBYTE * ptr;
55 struct BEIOM_Write wr = { BEIO_WRITE, };
57 #if AROS_BIG_ENDIAN
58 ptr = (UBYTE *)&data;
59 # define NEXT ++
60 #else
61 ptr = ((UBYTE *)&data) + 3;
62 # define NEXT --
63 #endif
65 #define WRITE_ONE_BYTE \
66 wr.Data = *ptr NEXT; \
67 if (CallHookA (hook, stream, &wr) == EOF) \
68 return FALSE
70 WRITE_ONE_BYTE;
71 WRITE_ONE_BYTE;
72 WRITE_ONE_BYTE;
73 WRITE_ONE_BYTE;
75 return TRUE;
76 } /* WriteFloat */