| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
#ifndef LIB_INCLUDED |
| 25 |
#define LIB_INCLUDED |
| 26 |
|
| 27 |
#include <stddef.h> |
| 28 |
#include <string.h> |
| 29 |
#include <stdlib.h> |
| 30 |
|
| 31 |
#ifndef OS_INCLUDED |
| 32 |
# include "os.h" |
| 33 |
#endif |
| 34 |
|
| 35 |
|
| 36 |
#ifndef OS_UCHAR_DEFINED |
| 37 |
typedef unsigned char uchar; |
| 38 |
#endif |
| 39 |
|
| 40 |
#ifndef OS_USHORT_DEFINED |
| 41 |
typedef unsigned short ushort; |
| 42 |
#endif |
| 43 |
|
| 44 |
#ifndef OS_UINT_DEFINED |
| 45 |
typedef unsigned int uint; |
| 46 |
#endif |
| 47 |
|
| 48 |
#ifndef OS_ULONG_DEFINED |
| 49 |
typedef unsigned long ulong; |
| 50 |
#endif |
| 51 |
|
| 52 |
|
| 53 |
typedef unsigned char ub1; |
| 54 |
typedef signed char sb1; |
| 55 |
typedef char b1; |
| 56 |
typedef unsigned int ub2; |
| 57 |
typedef signed int sb2; |
| 58 |
typedef int b2; |
| 59 |
typedef unsigned long ub4; |
| 60 |
typedef signed long sb4; |
| 61 |
typedef long b4; |
| 62 |
typedef int eword; |
| 63 |
|
| 64 |
|
| 65 |
#define UB4MAXVAL 0xffffffffUL |
| 66 |
#define UB2MAXVAL 0xffffU |
| 67 |
#define UB1MAXVAL 0xffU |
| 68 |
#define SB4MAXVAL 0x7fffffffL |
| 69 |
#define SB2MAXVAL 0x7fff |
| 70 |
#define SB1MAXVAL 0x7f |
| 71 |
#define SB4MINVAL (-(0x7fffffff)-1) |
| 72 |
#define SB2MINVAL (-(0x7fff)-1) |
| 73 |
#define SB1MINVAL (-(0x7f)-1) |
| 74 |
|
| 75 |
|
| 76 |
#define CLRSTRUCT(x) memset(&(x), 0, (size_t)sizeof(x)) |
| 77 |
#define CPSTRUCT(dst,src) memcpy(&(dst), &(src), (size_t)sizeof(dst)) |
| 78 |
|
| 79 |
|
| 80 |
#ifndef TRUE |
| 81 |
# define TRUE 1 |
| 82 |
#endif |
| 83 |
#ifndef FALSE |
| 84 |
# define FALSE 0 |
| 85 |
#endif |
| 86 |
|
| 87 |
|
| 88 |
#define bit(va, bt) ((va) & (bt)) |
| 89 |
#define bis(va, bt) ((va) |= (bt)) |
| 90 |
#define bic(va, bt) ((va) &= ~(bt)) |
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
#ifdef OSANSI |
| 101 |
# define noreg volatile |
| 102 |
# define NOREG(arglist) |
| 103 |
#else |
| 104 |
# define noreg |
| 105 |
# define NOREG(arglist) osnoreg arglist ; |
| 106 |
#endif |
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
#ifdef LINT |
| 113 |
# ifndef NOTREACHED |
| 114 |
# define NOTREACHED return |
| 115 |
# endif |
| 116 |
# ifndef NOTREACHEDV |
| 117 |
# define NOTREACHEDV(t) return((t)0) |
| 118 |
# endif |
| 119 |
# ifndef VARUSED |
| 120 |
# define VARUSED(v) varused(v) |
| 121 |
# endif |
| 122 |
void varused(); |
| 123 |
#else |
| 124 |
# ifndef NOTREACHED |
| 125 |
# define NOTREACHED |
| 126 |
# endif |
| 127 |
# ifndef NOTREACHEDV |
| 128 |
# define NOTREACHEDV(t) |
| 129 |
# endif |
| 130 |
# ifndef VARUSED |
| 131 |
# define VARUSED(v) |
| 132 |
# endif |
| 133 |
#endif |
| 134 |
|
| 135 |
|
| 136 |
#ifdef DEBUG |
| 137 |
# define IF_DEBUG(x) x |
| 138 |
#else |
| 139 |
# define IF_DEBUG(x) |
| 140 |
#endif |
| 141 |
|
| 142 |
#ifndef offsetof |
| 143 |
# define offsetof(s_name, m_name) (size_t)&(((s_name *)0)->m_name) |
| 144 |
#endif |
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
|
| 149 |
|
| 150 |
#define t_isspace(c) \ |
| 151 |
(((unsigned char)(c)) <= 127 && isspace((unsigned char)(c))) |
| 152 |
|
| 153 |
#endif |