ntp_types.h revision 1.1.1.2
1/* $NetBSD: ntp_types.h,v 1.1.1.2 2012/01/31 21:23:24 kardel Exp $ */ 2 3/* 4 * ntp_types.h - defines how int32 and u_int32 are treated. 5 * For 64 bit systems like the DEC Alpha, they have to be defined 6 * as int and u_int. 7 * For 32 bit systems, define them as long and u_long 8 */ 9#ifndef NTP_TYPES_H 10#define NTP_TYPES_H 11 12#include <sys/types.h> 13#include "ntp_machine.h" 14 15#ifndef TRUE 16# define TRUE 1 17#endif 18#ifndef FALSE 19# define FALSE 0 20#endif 21 22/* 23 * This is another naming conflict. 24 * On NetBSD for MAC the macro "mac" is defined as 1 25 * this is fun for us as a packet structure contains an 26 * optional "mac" member - severe confusion results 8-) 27 * As we hopefully do not have to rely on that macro we 28 * just undefine that. 29 */ 30#ifdef mac 31#undef mac 32#endif 33 34/* 35 * used to quiet compiler warnings 36 */ 37#ifndef UNUSED_ARG 38#define UNUSED_ARG(arg) ((void)(arg)) 39#endif 40 41/* 42 * COUNTOF(array) - size of array in elements 43 */ 44#define COUNTOF(arr) (sizeof(arr) / sizeof((arr)[0])) 45 46/* 47 * VMS DECC (v4.1), {u_char,u_short,u_long} are only in SOCKET.H, 48 * and u_int isn't defined anywhere 49 */ 50#if defined(VMS) 51#include <socket.h> 52typedef unsigned int u_int; 53/* 54 * Note: VMS DECC has long == int (even on __alpha), 55 * so the distinction below doesn't matter 56 */ 57#endif /* VMS */ 58 59#if (SIZEOF_INT == 4) 60# ifndef int32 61# define int32 int 62# ifndef INT32_MIN 63# define INT32_MIN INT_MIN 64# endif 65# ifndef INT32_MAX 66# define INT32_MAX INT_MAX 67# endif 68# endif 69# ifndef u_int32 70# define u_int32 unsigned int 71# ifndef U_INT32_MAX 72# define U_INT32_MAX UINT_MAX 73# endif 74# endif 75#else /* not sizeof(int) == 4 */ 76# if (SIZEOF_LONG == 4) 77# ifndef int32 78# define int32 long 79# ifndef INT32_MIN 80# define INT32_MIN LONG_MIN 81# endif 82# ifndef INT32_MAX 83# define INT32_MAX LONG_MAX 84# endif 85# endif 86# ifndef u_int32 87# define u_int32 unsigned long 88# ifndef U_INT32_MAX 89# define U_INT32_MAX ULONG_MAX 90# endif 91# endif 92# else /* not sizeof(long) == 4 */ 93# include "Bletch: what's 32 bits on this machine?" 94# endif /* not sizeof(long) == 4 */ 95#endif /* not sizeof(int) == 4 */ 96 97typedef u_char ntp_u_int8_t; 98typedef u_short ntp_u_int16_t; 99typedef u_int32 ntp_u_int32_t; 100 101typedef struct ntp_uint64_t { u_int32 val[2]; } ntp_uint64_t; 102 103typedef unsigned short associd_t; /* association ID */ 104typedef u_int32 keyid_t; /* cryptographic key ID */ 105typedef u_int32 tstamp_t; /* NTP seconds timestamp */ 106 107/* 108 * On Unix struct sock_timeval is equivalent to struct timeval. 109 * On Windows built with 64-bit time_t, sock_timeval.tv_sec is a long 110 * as required by Windows' socket() interface timeout argument, while 111 * timeval.tv_sec is time_t for the more common use as a UTC time 112 * within NTP. 113 */ 114#ifndef SYS_WINNT 115#define sock_timeval timeval 116#endif 117 118/* 119 * On Unix open() works for tty (serial) devices just fine, while on 120 * Windows refclock serial devices are opened using CreateFile, a lower 121 * level than the CRT-provided descriptors, because the C runtime lacks 122 * tty APIs. For refclocks which wish to use open() as well as or 123 * instead of refclock_open(), tty_open() is equivalent to open() on 124 * Unix and implemented in the Windows port similarly to 125 * refclock_open(). 126 */ 127#ifndef SYS_WINNT 128#define tty_open(f, a, m) open(f, a, m) 129#endif 130 131 132#endif /* NTP_TYPES_H */ 133