Annotation of embedaddon/ntp/include/ntp_types.h, revision 1.1.1.1

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

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>