2003-08-11 22:40:21 +02:00
|
|
|
/* Copyright 2003 Roger Dingledine */
|
|
|
|
/* See LICENSE for licensing information */
|
|
|
|
/* $Id$ */
|
|
|
|
|
2004-05-01 22:46:28 +02:00
|
|
|
/*****
|
|
|
|
* torint.h: Header file to define uint32_t and friends.
|
|
|
|
*****/
|
|
|
|
|
2003-08-11 22:40:21 +02:00
|
|
|
#ifndef __TORINT_H
|
|
|
|
#define __TORINT_H
|
|
|
|
|
2003-08-11 23:16:13 +02:00
|
|
|
#include "orconfig.h"
|
|
|
|
|
2004-05-01 22:46:28 +02:00
|
|
|
|
2003-08-11 22:40:21 +02:00
|
|
|
#ifdef HAVE_STDINT_H
|
|
|
|
#include <stdint.h>
|
2003-08-11 22:50:30 +02:00
|
|
|
#endif
|
|
|
|
#ifdef HAVE_SYS_TYPES_H
|
|
|
|
#include <sys/types.h>
|
2003-08-11 23:16:13 +02:00
|
|
|
#endif
|
|
|
|
|
2003-08-11 22:40:21 +02:00
|
|
|
|
2003-08-12 01:21:51 +02:00
|
|
|
#if (SIZEOF_INT8_T != 0)
|
|
|
|
#define HAVE_INT8_T
|
|
|
|
#endif
|
|
|
|
#if (SIZEOF_INT16_T != 0)
|
|
|
|
#define HAVE_INT16_T
|
|
|
|
#endif
|
|
|
|
#if (SIZEOF_INT32_T != 0)
|
|
|
|
#define HAVE_INT32_T
|
|
|
|
#endif
|
|
|
|
#if (SIZEOF_INT64_T != 0)
|
|
|
|
#define HAVE_INT64_T
|
|
|
|
#endif
|
|
|
|
#if (SIZEOF_UINT8_T != 0)
|
|
|
|
#define HAVE_UINT8_T
|
|
|
|
#endif
|
|
|
|
#if (SIZEOF_UINT16_T != 0)
|
|
|
|
#define HAVE_UINT16_T
|
|
|
|
#endif
|
|
|
|
#if (SIZEOF_UINT32_T != 0)
|
|
|
|
#define HAVE_UINT32_T
|
|
|
|
#endif
|
|
|
|
#if (SIZEOF_UINT64_T != 0)
|
|
|
|
#define HAVE_UINT64_T
|
|
|
|
#endif
|
2004-05-05 22:26:35 +02:00
|
|
|
#if (SIZEOF_INTPTR_T != 0)
|
|
|
|
#define HAVE_INTPTR_T
|
|
|
|
#endif
|
|
|
|
#if (SIZEOF_UINTPTR_T != 0)
|
|
|
|
#define HAVE_UINTPTR_T
|
|
|
|
#endif
|
2003-08-12 01:21:51 +02:00
|
|
|
|
2003-08-11 22:40:21 +02:00
|
|
|
#if (SIZEOF_CHAR == 1)
|
2003-08-11 23:16:13 +02:00
|
|
|
#ifndef HAVE_INT8_T
|
2003-08-11 22:40:21 +02:00
|
|
|
typedef signed char int8_t;
|
2003-08-11 23:16:13 +02:00
|
|
|
#define HAVE_INT8_T
|
|
|
|
#endif
|
|
|
|
#ifndef HAVE_UINT8_T
|
|
|
|
typedef unsigned char uint8_t;
|
|
|
|
#define HAVE_UINT8_T
|
2003-08-11 22:40:21 +02:00
|
|
|
#endif
|
2003-08-11 22:50:30 +02:00
|
|
|
#endif
|
2003-08-11 22:40:21 +02:00
|
|
|
|
2003-12-17 22:14:13 +01:00
|
|
|
#if (SIZEOF_SHORT == 2)
|
2003-08-11 22:50:30 +02:00
|
|
|
#ifndef HAVE_INT16_T
|
2003-08-11 22:40:21 +02:00
|
|
|
typedef signed short int16_t;
|
2003-08-11 23:16:13 +02:00
|
|
|
#define HAVE_INT16_T
|
2003-08-11 22:40:21 +02:00
|
|
|
#endif
|
2003-08-11 23:16:13 +02:00
|
|
|
#ifndef HAVE_UINT16_T
|
|
|
|
typedef unsigned short uint16_t;
|
|
|
|
#define HAVE_UINT16_T
|
2003-08-11 22:50:30 +02:00
|
|
|
#endif
|
2003-08-11 23:16:13 +02:00
|
|
|
#endif
|
|
|
|
|
2003-08-11 22:40:21 +02:00
|
|
|
|
2003-12-17 22:14:13 +01:00
|
|
|
#if (SIZEOF_INT == 2)
|
2003-08-11 23:16:13 +02:00
|
|
|
#ifndef HAVE_INT16_T
|
|
|
|
typedef signed int int16_t;
|
|
|
|
#define HAVE_INT16_T
|
|
|
|
#endif
|
|
|
|
#ifndef HAVE_UINT16_T
|
|
|
|
typedef unsigned int uint16_t;
|
|
|
|
#define HAVE_UINT16_T
|
|
|
|
#endif
|
|
|
|
#elif (SIZEOF_INT == 4)
|
2003-08-11 22:50:30 +02:00
|
|
|
#ifndef HAVE_INT32_T
|
2003-08-11 22:40:21 +02:00
|
|
|
typedef signed int int32_t;
|
2003-08-11 23:16:13 +02:00
|
|
|
#define HAVE_INT32_T
|
2003-08-11 22:40:21 +02:00
|
|
|
#endif
|
2003-08-11 23:16:13 +02:00
|
|
|
#ifndef HAVE_UINT32_T
|
|
|
|
typedef unsigned int uint32_t;
|
|
|
|
#define HAVE_UINT32_T
|
2003-08-11 22:50:30 +02:00
|
|
|
#endif
|
2003-08-11 23:16:13 +02:00
|
|
|
#endif
|
|
|
|
|
2003-08-11 22:40:21 +02:00
|
|
|
|
2003-08-11 23:16:13 +02:00
|
|
|
#if (SIZEOF_LONG == 4)
|
|
|
|
#ifndef HAVE_INT32_T
|
|
|
|
typedef signed long int32_t;
|
|
|
|
#define HAVE_INT32_T
|
|
|
|
#endif
|
|
|
|
#ifndef HAVE_UINT32_T
|
|
|
|
typedef unsigned long uint32_t;
|
|
|
|
#define HAVE_UINT32_T
|
|
|
|
#endif
|
|
|
|
#elif (SIZEOF_LONG == 8)
|
2003-08-11 22:50:30 +02:00
|
|
|
#ifndef HAVE_INT64_T
|
2003-08-11 22:40:21 +02:00
|
|
|
typedef signed long int64_t;
|
2003-08-11 23:16:13 +02:00
|
|
|
#define HAVE_INT64_T
|
|
|
|
#endif
|
|
|
|
#ifndef HAVE_UINT32_T
|
|
|
|
typedef unsigned long uint64_t;
|
|
|
|
#define HAVE_UINT32_T
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if (SIZEOF_LONG_LONG == 8)
|
|
|
|
#ifndef HAVE_INT64_T
|
2003-08-11 22:40:21 +02:00
|
|
|
typedef signed long long int64_t;
|
2003-08-11 23:16:13 +02:00
|
|
|
#define HAVE_INT64_T
|
|
|
|
#endif
|
|
|
|
#ifndef HAVE_UINT64_T
|
|
|
|
typedef unsigned long long uint64_t;
|
|
|
|
#define HAVE_UINT64_T
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if (SIZEOF___INT64 == 8)
|
|
|
|
#ifndef HAVE_INT64_T
|
2003-08-11 22:40:21 +02:00
|
|
|
typedef signed __int64 int64_t;
|
2003-08-11 23:16:13 +02:00
|
|
|
#define HAVE_INT64_T
|
|
|
|
#endif
|
|
|
|
#ifndef HAVE_UINT64_T
|
|
|
|
typedef unsigned __int64 uint64_t;
|
|
|
|
#define HAVE_UINT64_T
|
2003-08-11 22:40:21 +02:00
|
|
|
#endif
|
2003-08-11 22:50:30 +02:00
|
|
|
#endif
|
2003-08-11 22:40:21 +02:00
|
|
|
|
2004-05-05 22:26:35 +02:00
|
|
|
#if (SIZEOF_VOID_P > 4 && SIZEOF_VOID_P <= 8)
|
|
|
|
#ifndef HAVE_INTPTR_T
|
|
|
|
typedef int64_t intptr_t;
|
|
|
|
#endif
|
|
|
|
#ifndef HAVE_UINTPTR_T
|
|
|
|
typedef uint64_t uintptr_t;
|
|
|
|
#endif
|
|
|
|
#elif (SIZEOF_VOID_P > 2 && SIZEOF_VOID_P <= 4)
|
|
|
|
#ifndef HAVE_INTPTR_T
|
|
|
|
typedef int32_t intptr_t;
|
|
|
|
#endif
|
|
|
|
#ifndef HAVE_UINTPTR_T
|
|
|
|
typedef uint32_t uintptr_t;
|
|
|
|
#endif
|
|
|
|
#else
|
|
|
|
#error "void * is either >8 bytes or <= 2. In either case, I am confused."
|
|
|
|
#endif
|
2003-08-11 23:16:13 +02:00
|
|
|
|
|
|
|
#ifndef HAVE_INT8_T
|
|
|
|
#error "Missing type int8_t"
|
|
|
|
#endif
|
|
|
|
#ifndef HAVE_UINT8_T
|
|
|
|
#error "Missing type uint8_t"
|
|
|
|
#endif
|
|
|
|
#ifndef HAVE_INT16_T
|
|
|
|
#error "Missing type int16_t"
|
|
|
|
#endif
|
|
|
|
#ifndef HAVE_UINT16_T
|
|
|
|
#error "Missing type uint16_t"
|
|
|
|
#endif
|
|
|
|
#ifndef HAVE_INT32_T
|
|
|
|
#error "Missing type int32_t"
|
|
|
|
#endif
|
|
|
|
#ifndef HAVE_UINT32_T
|
|
|
|
#error "Missing type uint32_t"
|
|
|
|
#endif
|
|
|
|
#ifndef HAVE_INT64_T
|
|
|
|
#error "Missing type int64_t"
|
|
|
|
#endif
|
|
|
|
#ifndef HAVE_UINT64_T
|
|
|
|
#error "Missing type uint64_t"
|
|
|
|
#endif
|
2003-08-11 22:40:21 +02:00
|
|
|
|
|
|
|
#endif /* __TORINT_H */
|
2004-04-06 05:44:36 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
Local Variables:
|
|
|
|
mode:c
|
|
|
|
indent-tabs-mode:nil
|
|
|
|
c-basic-offset:2
|
|
|
|
End:
|
|
|
|
*/
|