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

ind_types.c File Reference

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

#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. More...

#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. More...


Typedefs

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


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. More...


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.16 2000/04/21 20:47:25 jbednar Exp

Definition in file ind_types.c.


Define Documentation

#define CHECK_TYPE( typename, expectedsize )
 

Initializer:

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

Definition at line 32 of file ind_types.c.

#define WARN_MISSING( typename )   if (warn_if_missing) printf("Note: no %s type defined.\n",#typename)
 

Definition at line 40 of file ind_types.c.

#define swap_endian_proc( type )
 

Initializer:

\
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.


Typedef Documentation

typedef int endtype
 

Type on which to test endian-ness.

Definition at line 20 of file ind_types.c.


Function Documentation

int check_ind_types ( int warn_if_missing )
 

Definition at line 43 of file ind_types.c.

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.

Referenced by binaryWeightsFileRead(), binaryWeightsFileWrite(), and printTokens().


Generated at Mon Aug 21 00:31:02 2000 for RF-LISSOM by doxygen1.2.1 written by Dimitri van Heesch, © 1997-2000