GLAST/LAT > DAQ and FSW > FSW > Doxygen Index > PBI / V0-0-7

Constituent: test_endianness     Tag: mv2304


Interface   Data Structures   File List   Data Fields   Globals  

test_endianness.c File Reference

Program to test the macros in PBI/Endianness.h. More...

#include <stdio.h>
#include "PBI/Endianness.h"

Include dependency graph for test_endianness.c:

Include dependency graph

Data Structures

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.


Detailed Description

Program to test the macros in PBI/Endianness.h.

Author:
JJRussell - russell@slac.stanford.edu
   CVS $Id: test_endianness.c,v 1.2 2004/02/17 01:30:09 russell 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 Documentation

#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

#define TEST_MISSION
 

Value:

"\n"                                                    \
"\n"                                                                         \
" Test Endianness\n"                                                         \
" ---------------\n"                                                         \
" As with many tests in PBI, the simple ability to correctly compile the\n"  \
" test is 90% of proving the test passes.\n"                                 \
"\n"                                                                         \
" If this test did not compile correctly the include file PBI/Endianness.h\n"\
" could not determine the endianness of the machine. The only recurse here\n"\
" is to examine the file and see what criteria it is using and why that\n"   \
" criteria fails for this machine. Of course, there is the little matter\n"  \
" that if the compilation of this test fails, you would not be reading\n"    \
" this message.\n"                                                           \
"\n"                                                                         \
" If PBI/Endianness.h did make a determination, this program can check if\n" \
" that determination is correct by interpreting a 4 byte integer both as\n"  \
" an integer and as 4 element character array. On little endian machines\n"  \
" the zero'th element of the array will match the low byte of the integer,\n"\
" the next element will match the next lowest byte and so forth. On a big\n" \
" endian machine, the zero'th element of the array will match the high\n"    \
" byte of the integer. In this way the endianness determination can be\n"    \
" confirmed.\n"
Symbol representing the string stating the mission of this test. It is purely here to make the code read nicer.


Function Documentation

int main int  argc,
char **  argv
 

Standard main entry point for Unix platforms. It merely calls the testing routine test_endianness ().

Return values:
0,if successful
-1,if unsuccessful
This program takes no arguments.

Here is the call graph for this function:

int test_endianness void   ) 
 

The test program itself and also the entry point for running this test on VxWork's platforms.

Return values:
0,if successful
-1,if unsucceful


Generated on Tue Mar 15 23:41:23 2005 by doxygen 1.3.3