my-endian.cc File Reference

#include "my-endian.h"

Include dependency graph for my-endian.cc:

Go to the source code of this file.

Functions

int IsLittleEndian (void)
u_4bytes rotate4 (u_4bytes In)
unsigned short swap2 (u_2bytes In)
void ToOtherEndian (TEntry *e)


Function Documentation

int IsLittleEndian void   ) 
 

Definition at line 26 of file my-endian.cc.

Referenced by main().

00026                          {
00027     static const unsigned long long_number = 1;
00028     return *(const unsigned char *)&long_number;
00029 }

u_4bytes rotate4 u_4bytes  In  ) 
 

Definition at line 14 of file my-endian.cc.

References swap2().

Referenced by ToOtherEndian().

00014                               {
00015     u_4bytes Out;
00016 
00017     ((u_2bytes*)&Out)[0] = swap2(((u_2bytes*)&In)[1]);
00018     ((u_2bytes*)&Out)[1] = swap2(((u_2bytes*)&In)[0]);
00019 
00020     return Out;
00021 }

Here is the call graph for this function:

unsigned short swap2 u_2bytes  In  ) 
 

Definition at line 4 of file my-endian.cc.

Referenced by rotate4(), and ToOtherEndian().

00004                                   {
00005     u_2bytes Out;
00006 
00007     ((char*)&(Out))[0] = ((char*)&(In))[1];
00008     ((char*)&(Out))[1] = ((char*)&(In))[0];
00009 
00010     return Out;
00011 }

void ToOtherEndian TEntry e  ) 
 

Definition at line 32 of file my-endian.cc.

References head, rotate4(), swap2(), tail, and url.

Referenced by main().

00032                               {
00033 
00034     /* unroll this loop if you want to enumerate u_4bytes members of TEntry_v2 */
00035     u_4bytes *p;
00036     for (p = &(e -> head.event_duration); p <= &(e -> url); p++)
00037         *p = rotate4(*p);
00038 
00039     e -> tail.status = swap2(e -> tail.status);
00040     
00041     if (sizeof(method_t) == 2)
00042         e -> tail.method = swap2(e -> tail.method);
00043     else
00044     if (sizeof(method_t) == 4)
00045         e -> tail.method = rotate4(e -> tail.method);
00046 
00047     if (sizeof(protocol_t) == 2)
00048         e -> tail.protocol = swap2(e -> tail.protocol);
00049     else
00050     if (sizeof(protocol_t) == 4)
00051         e -> tail.protocol = rotate4(e -> tail.protocol);
00052 }

Here is the call graph for this function:


Generated on Tue Mar 6 16:55:04 2007 for ns2 Network Simulator 2.29 by  doxygen 1.4.6