1 /* 2 * The Spread Toolkit. 3 * 4 * The contents of this file are subject to the Spread Open-Source 5 * License, Version 1.0 (the ``License''); you may not use 6 * this file except in compliance with the License. You may obtain a 7 * copy of the License at: 8 * 9 * http://www.spread.org/license/ 10 * 11 * or in the file ``license.txt'' found in this distribution. 12 * 13 * Software distributed under the License is distributed on an AS IS basis, 14 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 15 * for the specific language governing rights and limitations under the 16 * License. 17 * 18 * The Creators of Spread are: 19 * Yair Amir, Michal Miskin-Amir, Jonathan Stanton. 20 * 21 * Copyright (C) 1993-2004 Spread Concepts LLC <spread@spreadconcepts.com> 22 * 23 * All Rights Reserved. 24 * 25 * Major Contributor(s): 26 * --------------- 27 * Cristina Nita-Rotaru crisn@cs.purdue.edu - group communication security. 28 * Theo Schlossnagle jesus@omniti.com - Perl, skiplists, autoconf. 29 * Dan Schoenblum dansch@cnds.jhu.edu - Java interface. 30 * John Schultz jschultz@cnds.jhu.edu - contribution to process group membership. 31 * 32 */ 33 34 #ifndef INC_ARCH 35 #define INC_ARCH 36 37 /* 38 * Each record in this file represents an architecture. 39 * Each record contains the following fields: 40 * 41 * #define INTSIZE{16,32,64} 42 * #define ARCH_SCATTER_{CONTROL,ACCRIGHTS,NONE} 43 * #define ARCH_ENDIAN{0x00000000,0x80000080} 44 * #define LOC_INLINE { __inline__ or blank } 45 * #define ARCH_SCATTER_SIZE { sys dependent variable } 46 * #define HAVE_GOOD_VARGS ( exists if true ) 47 * #define HAVE_LRAND48 ( exists if true ) 48 * #define HAVE_STDINT_H ( exists if true --currently glibc2.1 needs it ) 49 * typedef {sys dependent type} sockopt_len_t; 50 * #define ERR_TIMEDOUT EAGAIN 51 * #define sock_errno { errno or WSAGetLastError() for windows } 52 * #define sock_strerror { strerror or sock_strerror for windows } 53 * #define sock_set_errno { sock_unix_set_errno or WSASetLastError for windows } 54 */ 55 56 #undef INTSIZE32 57 #undef INTSIZE64 58 #undef INTSIZE16 59 60 61 #ifndef ARCH_PC_WIN95 62 /* If we aren't using windows... we can use autoconf */ 63 64 #include "config.h" 65 66 67 #ifdef WORDS_BIGENDIAN 68 #define ARCH_ENDIAN 0x00000000 69 #else 70 #define ARCH_ENDIAN 0x80000080 71 #endif 72 73 #define LOC_INLINE inline 74 75 /* Need to add special cases, SUNOS gets 64, IRIX gets 512 */ 76 #ifdef MSG_MAXIOVLEN 77 #define ARCH_SCATTER_SIZE MSG_MAXIOVLEN 78 #else 79 #define ARCH_SCATTER_SIZE 1024 80 #endif 81 82 #define HAVE_GOOD_VARGS 83 84 #ifndef ERR_TIMEDOUT 85 #define ERR_TIMEDOUT ETIMEDOUT 86 #endif 87 88 #ifndef RAND_MAX 89 #define RAND_MAX 2147483647 90 #endif 91 92 #define sock_errno errno 93 #define sock_strerror strerror 94 #define sock_set_errno(a) (errno = (a)) 95 96 #ifndef byte 97 #define byte u_int8_t 98 #endif 99 100 #ifndef int16 101 #define int16 int16_t 102 #endif 103 104 #ifndef int16u 105 #define int16u u_int16_t 106 #endif 107 108 #ifndef int32 109 #define int32 int32_t 110 #endif 111 112 #ifndef int32u 113 #define int32u u_int32_t 114 #endif 115 116 #else 117 /* We are using windows... */ 118 #define INTSIZE32 119 #define ARCH_SCATTER_NONE 120 #define ARCH_ENDIAN 0x80000080 121 #define LOC_INLINE 122 typedef unsigned long sockopt_len_t; 123 typedef unsigned long socklen_t; 124 #define BADCLOCK 125 #define HAVE_GOOD_VARGS 126 /* This size is for packing several messages into one packet */ 127 #define ARCH_SCATTER_SIZE 64 128 #define ERR_TIMEDOUT EAGAIN 129 #define sock_errno WSAGetLastError() 130 #define sock_strerror sock_strerror 131 #define sock_set_errno WSASetLastError 132 #define MAXPATHLEN _MAX_PATH 133 #define snprintf _snprintf 134 #define alloca _alloca 135 /* Sockets are not file descriptors on windows so they need a special close function. */ 136 #define close closesocket 137 /* Windows defines a default size of 64. However, the size of fd_set array for select 138 * can be raised by defining a larger constant before including windows.h winsock.h 139 */ 140 #define FD_SETSIZE 1024 141 /* System location of spread.conf file */ 142 #define SPREAD_ETCDIR "/etc" 143 /* Use winsock constants since we are dealing with sockets 144 * Note: If we ever need file IO with errno's we will have conflicts 145 * since the WSA version and the basic E versions may not have the same 146 * number. Right now we don't need the E versions for windows so we just 147 * use the WSA versions. 148 */ 149 #undef EINTR 150 #undef EAGAIN 151 #undef EWOULDBLOCK 152 #undef EINPROGRESS 153 #define EWOULDBLOCK WSAEWOULDBLOCK 154 #define EINTR WSAEINTR 155 #define EAGAIN WSAEWOULDBLOCK 156 #define EINPROGRESS WSAEINPROGRESS 157 158 /* Windows does not define MAXHOSTNAMELEN, so we define it here to a reasonable host name limit */ 159 #define MAXHOSTNAMELEN 128 160 161 /* byte is already defined as a typedef to unsigned char on Windows XP (and probably earlier) so do not define 162 * #ifndef byte 163 * #define byte unsigned char 164 * #endif 165 */ 166 167 #ifndef int16 168 #define int16 short 169 #endif 170 171 #ifndef int16u 172 #define int16u unsigned short 173 #endif 174 175 #ifndef int32 176 #define int32 int 177 #endif 178 179 #ifndef int32u 180 #define int32u unsigned int 181 #endif 182 183 #ifndef UINT32_MAX 184 #define UINT32_MAX UINT_MAX 185 #endif 186 #ifndef INT32_MAX 187 #define INT32_MAX INT_MAX 188 #endif 189 190 /* Declare functions from arch.c */ 191 char *sock_strerror(int err); 192 193 #endif /* ARCH_PC_WIN95 */ 194 195 /* Pick which rand version to use */ 196 #ifdef HAVE_LRAND48 197 #define get_rand lrand48 198 #else 199 #define get_rand rand 200 #endif 201 202 /* Useful CPP macros to make strings from #defines */ 203 #define Q(x) # x 204 #define QQ(x) Q(x) 205 206 207 #define ENDIAN_TYPE 0x80000080 208 209 #define Get_endian( type ) ( (type) & ENDIAN_TYPE ) 210 #define Set_endian( type ) ( ( (type) & ~ENDIAN_TYPE )| ARCH_ENDIAN ) 211 #define Same_endian( type ) ( ( (type) & ENDIAN_TYPE ) == ARCH_ENDIAN ) 212 #define Clear_endian( type ) ( (type) & ~ENDIAN_TYPE ) 213 214 #define Flip_int16( type ) ( ( ((type) >> 8) & 0x00ff) | ( ((type) << 8) & 0xff00) ) 215 216 #define Flip_int32( type ) ( ( ((type) >>24) & 0x000000ff) | ( ((type) >> 8) & 0x0000ff00) | ( ((type) << 8) & 0x00ff0000) | ( ((type) <<24) & 0xff000000) ) 217 218 #define channel int 219 #define mailbox int 220 221 typedef struct dummy_membership_id { 222 int32 proc_id; 223 int32 time; 224 } membership_id; 225 226 typedef struct dummy_group_id { 227 membership_id memb_id; 228 int32 index; 229 } group_id; 230 231 /* 232 * General Useful Types 233 */ 234 235 typedef short bool; 236 #ifndef TRUE 237 #define TRUE 1 238 #endif 239 #ifndef FALSE 240 #define FALSE 0 241 #endif 242 243 #endif /* INC_ARCH */ 244