Source: tdsystem.h


Annotated List
Files
Globals
Hierarchy
Index
/*
 *  $Id: tdsystem_h.html,v 1.6 2001/11/30 14:02:34 dreibh Exp $
 *
 * SCTP implementation according to RFC 2960.
 * Copyright (C) 1999-2001 by Thomas Dreibholz
 *
 * Realized in co-operation between Siemens AG
 * and University of Essen, Institute of Computer Networking Technology.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 * There are two mailinglists available at www.sctp.de which should be used for
 * any discussion related to this implementation.
 *
 * Contact: discussion@sctp.de
 *          dreibh@exp-math.uni-essen.de
 *
 * Purpose: System dependent definitions
 *
 */


#ifndef TDSYSTEM_H
#define TDSYSTEM_H

#ifdef HAVE_CONFIG_H
  #include <config.h>
#endif


// Use TransportInfo
#define USE_TRANSPORTINFO

// Use traffic shaper
// #define USE_TRAFFICSHAPER


// Disable all warning outputs. Not recommended!
// #define DISABLE_WARNINGS


// Some important definitions for usage of reentrant versions.
#ifndef _REENTRANT
 #define _REENTRANT
#endif
#ifndef _THREAD_SAFE
 #define _THREAD_SAFE
#endif

#define _GNU_SOURCE
#define USE_PTHREADS


// Use libefence for debugging
// #define USE_EFENCE


#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <iostream.h>
#include <string.h>
#include <math.h>


// In socket.cc: CMSG_NXTHDR: (__cmsg_nxthdr) is not found,
// if compiled with -O0 -> extern inline definition required.
#if !defined __USE_EXTERN_INLINES
 #define __USE_EXTERN_INLINES 1
#endif

#ifndef HAVE_SOCKLEN_T
 typedef int socklen_t;
 #define HAVE_SOCKLEN_T
#endif

#ifndef max
 #define max(a, b) ((a) < (b) ? (b) : (a))
#endif
#ifndef min
 #define min(a, b) ((a) > (b) ? (b) : (a))
#endif


// ###### Operating system definitions ######################################
#define OS_Linux   1
#define OS_FreeBSD 2
#define OS_Darwin  3

#ifdef LINUX
 #define SYSTEM OS_Linux
#endif
#ifdef FreeBSD
 #define SYSTEM OS_FreeBSD
#endif
#ifdef DARWIN
 #define SYSTEM OS_Darwin
 #define MAXDNAME 256
#endif
#ifndef SYSTEM
 #warning Variable SYSTEM with operating system name not defined! Use e.g. -DOS_Linux compiler option.
 #warning Trying Linux...
 #define SYSTEM OS_Linux
#endif


// ###### CPU defintions ####################################################
// Set correct number of CPU bits (32 or 64) here!
#if (SYSTEM == OS_Linux)
 #include <endian.h>
 #include <stdint.h>
 #define CPU_BYTEORDER __BYTE_ORDER
#elif (SYSTEM == OS_FreeBSD)
 #include <machine/endian.h>
 #include <sys/inttypes.h>
 #define CPU_BYTEORDER BYTE_ORDER
#elif (SYSTEM == OS_Darwin)
 #include <machine/endian.h>
 #include <stdint.h>
 #define CPU_BYTEORDER BYTE_ORDER
#endif

#if (defined __i386__) || (defined __i486__) || (defined __pentium__) || (defined __pentiumpro__)|| (defined __ppc__)
 #define CPU_BITS 32
#else
 #error "CPU_BITS is not set correctly! Check tdsystem.h!"
#endif

#if ((CPU_BYTEORDER != BIG_ENDIAN) && (CPU_BYTEORDER != LITTLE_ENDIAN))
 #error "CPU_BYTEORDER is not set correctly! Check tdsystem.h!"
#endif


// ###### Type definitions ##################################################
/**
  * Datatype for storing a signed char.
  */
typedef int8_t sbyte;

/**
  * Datatype for storing an unsigned char.
  */
typedef uint8_t ubyte;

/**
  * Datatype for storing an 8-bit integer.
  */
typedef int8_t int8;

/**
  * Datatype for storing a 8-bit cardinal.
  */
typedef uint8_t card8;

/**
  * Datatype for storing a 16-bit integer.
  */
typedef int16_t int16;

/**
  * Datatype for storing a 16-bit cardinal.
  */
typedef uint16_t card16;

/**
  * Datatype for storing a 32-bit intger.
  */
typedef int32_t int32;

/**
  * Datatype for storing a default-sized integer (32 bits minimum).
  */
#if defined (int_least32_t)
typedef int_least32_t integer;
#else
typedef int32 integer;
#endif

/**
  * Datatype for storing a 32-bit cardinal.
  */
typedef uint32_t card32;

/**
  * Datatype for storing an 64-bit integer.
  */
typedef int64_t int64;

/**
  * Datatype for storing a 64-bit cardinal.
  */
typedef uint64_t card64;

/**
  * Datatype for storing a default-sized cardinal (32 bits minimum).
  */
#if defined (uint_least32_t)
typedef uint_least32_t cardinal;
#else
typedef card32 cardinal;
#endif


#ifdef DMALLOC
#define USE_DMALLOC
#include <dmalloc.h>
#endif


// Include tools.h with libefence replacement for new and delete.
#include "tools.h"


#endif

Generated by: dreibh@kappes on Fri Nov 30 14:03:21 2001, using kdoc 2.0a53.