GLAST / LAT > DAQ and FSW > FSW > Doxygen Index> PBI / V0-1-2 > test_endianness / mv2304
#include <stdio.h>
#include <PBI/Endianness.h>
Classes | |
union | U |
A union used to reference an integer both as a 32 bit integer and as an array of 4 bytes. More... | |
Defines | |
#define | ENDIANNESS_NAME_LITTLE "LITTLE" |
Defines a string describing the endianness of the little endian machines. | |
#define | ENDIANNESS_NAME_BIG "BIG" |
Defines a string describing the endianness of the big endian machines. | |
#define | ENDIANNESS_NAME_UNKNOWN "UNKNOWN" |
Defines a string when the endianness of the machine cannot be determined. | |
#define | ENDIANNESS_NAME ENDIANNESS_NAME_UNKOWN |
Defines a string describing the endianness of the machine. | |
#define | TEST_MISSION |
Symbol representing the string stating the mission of this test. It is purely here to make the code read nicer. | |
Functions | |
int | main (int argc, char **argv) |
Standard main entry point for Unix platforms. It merely calls the testing routine test_endianness (). | |
int | test_endianness (void) |
The test program itself and also the entry point for running this test on VxWork's platforms. |
CVS $Id: test_endianness.c,v 1.3 2011/03/24 20:50:58 apw Exp $
As with many tests in PBI, the simple ability to correctly compile the test is 90% of proving the test passes.
If this test did not compile correctly the include file PBI/Endianness.h could not determine the endianness of the machine. The only recourse here is to examine the file and see what criteria it is using and why that criteria fails for this machine. Of course, there is the little matter that if the compilation of this test fails, you would not be reading this message.
If PBI/Endianness.h did make a determination, this program can check if that determination is correct by interpreting a 4 byte integer both as an integer and as 4 element character array. On little endian machines the zero'th element of the array will match the low byte of the integer, the next element will match the next lowest byte and so forth. On a big endian machine, the zero'th element of the array will match the high byte of the integer. In this way the endianness determination can be confirmed."
To run the program type
On Unix platforms: $ test_endianness On VxWorks > test_endianness ()
The program returns 0 if successful, else -1.
#define ENDIANNESS_NAME ENDIANNESS_NAME_UNKOWN |
Defines a string describing the endianness of the machine.
Defines a string describing the endianness of the machine as determined by the macros ins PBI/Endianness.h. This will be one of the previously defined symbols, i.e. ENDIANNESS_NAME_LITTLE, ENDIANNESS_NAME_BIG or ENDIANNESS_NAME_UNKNOWN
Referenced by test_endianness().
int main | ( | int | argc, | |
char ** | argv | |||
) |
Standard main entry point for Unix platforms. It merely calls the testing routine test_endianness ().
0,if | successful | |
-1,if | unsuccessful |
References test_endianness().
int test_endianness | ( | void | ) |
The test program itself and also the entry point for running this test on VxWork's platforms.
0,if | successful | |
-1,if | unsucceful |
References ENDIANNESS, ENDIANNESS_K_BIG, ENDIANNESS_K_LITTLE, ENDIANNESS_K_UNKNOWN, ENDIANNESS_NAME, ENDIANNESS_NAME_BIG, ENDIANNESS_NAME_LITTLE, ENDIANNESS_NAME_UNKNOWN, TEST_MISSION, U::uc, and U::ui.
Referenced by main().