Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

ind_types.c File Reference


Detailed Description

Endian-ness checking, swapping routines, and other functions for achieving cross-platform compatibility.

Header
/u/nn/cvsroot/lissom/src/ind_types.c,v 1.21 2003/01/11 06:50:43 jbednar Exp

Definition in file ind_types.c.

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <ctype.h>
#include "ind_types.h"

Include dependency graph for ind_types.c:

Include dependency graph

Go to the source code of this file.

Defines

#define CHECK_TYPE(typename, expectedsize)
 Verify that the platform-independent types have appropriate values for this architecture.

#define WARN_MISSING(typename)   if (warn_if_missing) printf("Note: no %s type defined.\n",#typename)
#define swap_endian_proc(type)
 Family of procedures to swap endian-ness for values of different types.


Typedefs

typedef int endtype
 Type on which to test endian-ness.


Functions

int check_ind_types (int warn_if_missing)
int endianness (void)
 Returns 0 for little-endian, 1 for big-endian, and -1 for unknown.


Define Documentation

#define CHECK_TYPE typename,
expectedsize   
 

Value:

if (sizeof(typename) != expectedsize) {                       \
  printf("Warning -- problem with ind_types: sizeof(%3s)=%d, not %d.\n"   \
         ,#typename,int(sizeof(typename)),int(expectedsize));   \
  errors++;                                                      \
}
Verify that the platform-independent types have appropriate values for this architecture.

Definition at line 32 of file ind_types.c.

#define swap_endian_proc type   
 

Value:

type type ## _swap_endian(type num)       \
{                                         \
  unsigned i;                             \
  union {                                 \
    type num;                             \
    char c[sizeof(type)];                 \
  } in,out;                               \
                                          \
  in.num = num;                           \
  for (i=0; i < sizeof(type); i++)        \
    out.c[i] = in.c[sizeof(type)-1-i];    \
  return out.num;                         \
}
Family of procedures to swap endian-ness for values of different types.

Definition at line 138 of file ind_types.c.


Function Documentation

int endianness void   
 

Returns 0 for little-endian, 1 for big-endian, and -1 for unknown.

Many compilers (e.g. GCC) define a compile-time constant for endianness, but this routine allows it to be checked, and should work on most ordinary architectures

Definition at line 92 of file ind_types.c.

References endtype.


Generated on Mon Jan 20 02:36:06 2003 for RF-LISSOM by doxygen1.3-rc2