| 1 | /*
|
|---|
| 2 | * synergy -- mouse and keyboard sharing utility
|
|---|
| 3 | * Copyright (C) 2002 Chris Schoeneman
|
|---|
| 4 | *
|
|---|
| 5 | * This package is free software; you can redistribute it and/or
|
|---|
| 6 | * modify it under the terms of the GNU General Public License
|
|---|
| 7 | * found in the file COPYING that should have accompanied this file.
|
|---|
| 8 | *
|
|---|
| 9 | * This package is distributed in the hope that it will be useful,
|
|---|
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|---|
| 12 | * GNU General Public License for more details.
|
|---|
| 13 | */
|
|---|
| 14 |
|
|---|
| 15 | #ifndef COMMON_H
|
|---|
| 16 | #define COMMON_H
|
|---|
| 17 |
|
|---|
| 18 | // this file should be included, directly or indirectly by every other.
|
|---|
| 19 |
|
|---|
| 20 | #if HAVE_CONFIG_H
|
|---|
| 21 | # include "config.h"
|
|---|
| 22 |
|
|---|
| 23 | // don't use poll() on mac
|
|---|
| 24 | # if defined(__APPLE__)
|
|---|
| 25 | # undef HAVE_POLL
|
|---|
| 26 | # endif
|
|---|
| 27 | #else
|
|---|
| 28 | // we may not have run configure on win32
|
|---|
| 29 | # if defined(_WIN32)
|
|---|
| 30 | # define SYSAPI_WIN32 1
|
|---|
| 31 | # define WINAPI_MSWINDOWS 1
|
|---|
| 32 | # endif
|
|---|
| 33 |
|
|---|
| 34 | // we may not have run configure on ming32
|
|---|
| 35 | # if defined(__MINGW32__)
|
|---|
| 36 | # define SYSAPI_WIN32 1
|
|---|
| 37 | # define WINAPI_MSWINDOWS 1
|
|---|
| 38 | # define HAVE_CXX_BOOL 1
|
|---|
| 39 | # define HAVE_CXX_CASTS 1
|
|---|
| 40 | # define HAVE_CXX_EXCEPTIONS 1
|
|---|
| 41 | # define HAVE_CXX_MUTABLE 1
|
|---|
| 42 | # define HAVE_CXX_STDLIB 1
|
|---|
| 43 | # define HAVE_INTTYPES_H 1
|
|---|
| 44 | # define HAVE_ISTREAM 1
|
|---|
| 45 | # define HAVE_MEMORY_H 1
|
|---|
| 46 | # define HAVE_OSTREAM 1
|
|---|
| 47 | # include <sys/types.h>
|
|---|
| 48 | # define HAVE_SSTREAM 1
|
|---|
| 49 | # define HAVE_STDINT_H 1
|
|---|
| 50 | # define HAVE_STDLIB_H 1
|
|---|
| 51 | # define HAVE_STRINGS_H 1
|
|---|
| 52 | # define HAVE_STRING_H 1
|
|---|
| 53 | # define HAVE_SYS_STAT_H 1
|
|---|
| 54 | # define HAVE_SYS_TIME_H 1
|
|---|
| 55 | # define HAVE_SYS_TYPES_H 1
|
|---|
| 56 | # define HAVE_VSNPRINTF 1
|
|---|
| 57 | # define HAVE_WCHAR_H 1
|
|---|
| 58 | # define HAVE_LOCALE_H 1
|
|---|
| 59 |
|
|---|
| 60 | # define SIZEOF_CHAR 1
|
|---|
| 61 | # define SIZEOF_INT 4
|
|---|
| 62 | # define SIZEOF_LONG 4
|
|---|
| 63 | # define SIZEOF_SHORT 2
|
|---|
| 64 | # define STDC_HEADERS 1
|
|---|
| 65 | # define TIME_WITH_SYS_TIME 1
|
|---|
| 66 | # define X_DISPLAY_MISSING 1
|
|---|
| 67 | # endif
|
|---|
| 68 |
|
|---|
| 69 | // we may not have run configure on OS X
|
|---|
| 70 | # if defined(__APPLE__)
|
|---|
| 71 | # define SYSAPI_UNIX 1
|
|---|
| 72 | # define WINAPI_CARBON 1
|
|---|
| 73 |
|
|---|
| 74 | # define HAVE_CXX_BOOL 1
|
|---|
| 75 | # define HAVE_CXX_CASTS 1
|
|---|
| 76 | # define HAVE_CXX_EXCEPTIONS 1
|
|---|
| 77 | # define HAVE_CXX_MUTABLE 1
|
|---|
| 78 | # define HAVE_CXX_STDLIB 1
|
|---|
| 79 | # define HAVE_GETPWUID_R 1
|
|---|
| 80 | # define HAVE_GMTIME_R 1
|
|---|
| 81 | # define HAVE_INET_ATON 1
|
|---|
| 82 | # define HAVE_INTTYPES_H 1
|
|---|
| 83 | # define HAVE_ISTREAM 1
|
|---|
| 84 | # define HAVE_MEMORY_H 1
|
|---|
| 85 | # define HAVE_NANOSLEEP 1
|
|---|
| 86 | # define HAVE_OSTREAM 1
|
|---|
| 87 | # define HAVE_POSIX_SIGWAIT 1
|
|---|
| 88 | # define HAVE_PTHREAD 1
|
|---|
| 89 | # define HAVE_PTHREAD_SIGNAL 1
|
|---|
| 90 | # include <sys/types.h>
|
|---|
| 91 | # include <sys/socket.h>
|
|---|
| 92 | # if defined(_SOCKLEN_T)
|
|---|
| 93 | # define HAVE_SOCKLEN_T 1
|
|---|
| 94 | # endif
|
|---|
| 95 | # define HAVE_SSTREAM 1
|
|---|
| 96 | # define HAVE_STDINT_H 1
|
|---|
| 97 | # define HAVE_STDLIB_H 1
|
|---|
| 98 | # define HAVE_STRINGS_H 1
|
|---|
| 99 | # define HAVE_STRING_H 1
|
|---|
| 100 | # define HAVE_SYS_SELECT_H 1
|
|---|
| 101 | # define HAVE_SYS_SOCKET_H 1
|
|---|
| 102 | # define HAVE_SYS_STAT_H 1
|
|---|
| 103 | # define HAVE_SYS_TIME_H 1
|
|---|
| 104 | # define HAVE_SYS_TYPES_H 1
|
|---|
| 105 | # define HAVE_SYS_UTSNAME_H 1
|
|---|
| 106 | # define HAVE_UNISTD_H 1
|
|---|
| 107 | # define HAVE_VSNPRINTF 1
|
|---|
| 108 | /* disable this so we can build with the 10.2.8 SDK */
|
|---|
| 109 | /*# define HAVE_WCHAR_H 1*/
|
|---|
| 110 |
|
|---|
| 111 | # define SELECT_TYPE_ARG1 int
|
|---|
| 112 | # define SELECT_TYPE_ARG234 (fd_set *)
|
|---|
| 113 | # define SELECT_TYPE_ARG5 (struct timeval *)
|
|---|
| 114 | # define SIZEOF_CHAR 1
|
|---|
| 115 | # define SIZEOF_INT 4
|
|---|
| 116 | # define SIZEOF_LONG 4
|
|---|
| 117 | # define SIZEOF_SHORT 2
|
|---|
| 118 | # define STDC_HEADERS 1
|
|---|
| 119 | # define TIME_WITH_SYS_TIME 1
|
|---|
| 120 | # define X_DISPLAY_MISSING 1
|
|---|
| 121 | # endif
|
|---|
| 122 |
|
|---|
| 123 | # if defined(__OS2__)
|
|---|
| 124 | # define SYSAPI_UNIX 1
|
|---|
| 125 | # define WINAPI_PM 1
|
|---|
| 126 |
|
|---|
| 127 | # define HAVE_CXX_BOOL 1
|
|---|
| 128 | # define HAVE_CXX_CASTS 1
|
|---|
| 129 | # define HAVE_CXX_EXCEPTIONS 1
|
|---|
| 130 | # define HAVE_CXX_MUTABLE 1
|
|---|
| 131 | # define HAVE_CXX_STDLIB 1
|
|---|
| 132 | //# define HAVE_GETPWUID_R 1
|
|---|
| 133 | # define HAVE_GMTIME_R 1
|
|---|
| 134 | # define HAVE_INET_ATON 1
|
|---|
| 135 | # define HAVE_INTTYPES_H 1
|
|---|
| 136 | # define HAVE_ISTREAM 1
|
|---|
| 137 | # define HAVE_MEMORY_H 1
|
|---|
| 138 | # define HAVE_NANOSLEEP 1
|
|---|
| 139 | # define HAVE_OSTREAM 1
|
|---|
| 140 | # define HAVE_POSIX_SIGWAIT 1
|
|---|
| 141 | // we don't have pthreads, but we use the same header to reduce changes.
|
|---|
| 142 | # define HAVE_PTHREAD 1
|
|---|
| 143 | //# define HAVE_PTHREAD_SIGNAL 1
|
|---|
| 144 | # include <sys/types.h>
|
|---|
| 145 | # include <sys/socket.h>
|
|---|
| 146 | //# if defined(_SOCKLEN_T)
|
|---|
| 147 | //# define HAVE_SOCKLEN_T 1
|
|---|
| 148 | //# endif
|
|---|
| 149 | # define HAVE_SSTREAM 1
|
|---|
| 150 | # define HAVE_STDINT_H 1
|
|---|
| 151 | # define HAVE_STDLIB_H 1
|
|---|
| 152 | # define HAVE_STRINGS_H 1
|
|---|
| 153 | # define HAVE_STRING_H 1
|
|---|
| 154 | # define HAVE_SYS_SELECT_H 1
|
|---|
| 155 | # define HAVE_SYS_SOCKET_H 1
|
|---|
| 156 | # define HAVE_SYS_STAT_H 1
|
|---|
| 157 | # define HAVE_SYS_TIME_H 1
|
|---|
| 158 | # define HAVE_SYS_TYPES_H 1
|
|---|
| 159 | # define HAVE_SYS_UTSNAME_H 1
|
|---|
| 160 | # define HAVE_UNISTD_H 1
|
|---|
| 161 | # define HAVE_VSNPRINTF 1
|
|---|
| 162 | # define HAVE_WCHAR_H 1
|
|---|
| 163 | # define HAVE_LOCALE_H 1
|
|---|
| 164 |
|
|---|
| 165 | # define SELECT_TYPE_ARG1 int
|
|---|
| 166 | # define SELECT_TYPE_ARG234 (fd_set *)
|
|---|
| 167 | # define SELECT_TYPE_ARG5 (struct timeval *)
|
|---|
| 168 | # define SIZEOF_CHAR 1
|
|---|
| 169 | # define SIZEOF_INT 4
|
|---|
| 170 | # define SIZEOF_LONG 4
|
|---|
| 171 | # define SIZEOF_SHORT 2
|
|---|
| 172 | # define STDC_HEADERS 1
|
|---|
| 173 | # define TIME_WITH_SYS_TIME 1
|
|---|
| 174 | # define X_DISPLAY_MISSING 1
|
|---|
| 175 | # endif /* __OS2__ */
|
|---|
| 176 | #endif
|
|---|
| 177 |
|
|---|
| 178 | // VC++ specific
|
|---|
| 179 | #if (_MSC_VER >= 1200)
|
|---|
| 180 | // work around for statement scoping bug
|
|---|
| 181 | # define for if (false) { } else for
|
|---|
| 182 |
|
|---|
| 183 | // turn off bonehead warnings
|
|---|
| 184 | # pragma warning(disable: 4786) // identifier truncated in debug info
|
|---|
| 185 | # pragma warning(disable: 4514) // unreferenced inline function removed
|
|---|
| 186 |
|
|---|
| 187 | // this one's a little too aggressive
|
|---|
| 188 | # pragma warning(disable: 4127) // conditional expression is constant
|
|---|
| 189 |
|
|---|
| 190 | // emitted incorrectly under release build in some circumstances
|
|---|
| 191 | # if defined(NDEBUG)
|
|---|
| 192 | # pragma warning(disable: 4702) // unreachable code
|
|---|
| 193 | # pragma warning(disable: 4701) // variable maybe used uninitialized
|
|---|
| 194 | # endif
|
|---|
| 195 | #endif // (_MSC_VER >= 1200)
|
|---|
| 196 |
|
|---|
| 197 | // VC++ has built-in sized types
|
|---|
| 198 | #if defined(_MSC_VER)
|
|---|
| 199 | # include <wchar.h>
|
|---|
| 200 | # define TYPE_OF_SIZE_1 __int8
|
|---|
| 201 | # define TYPE_OF_SIZE_2 __int16
|
|---|
| 202 | # define TYPE_OF_SIZE_4 __int32
|
|---|
| 203 | #else
|
|---|
| 204 | # define SIZE_OF_CHAR 1
|
|---|
| 205 | # define SIZE_OF_SHORT 2
|
|---|
| 206 | # define SIZE_OF_INT 4
|
|---|
| 207 | # define SIZE_OF_LONG 4
|
|---|
| 208 | #endif
|
|---|
| 209 |
|
|---|
| 210 | // FIXME -- including fp.h from Carbon.h causes a undefined symbol error
|
|---|
| 211 | // on my build system. the symbol is scalb. since we don't need any
|
|---|
| 212 | // math functions we define __FP__, the include guard macro for fp.h, to
|
|---|
| 213 | // prevent fp.h from being included.
|
|---|
| 214 | #if defined(__APPLE__)
|
|---|
| 215 | #define __FP__
|
|---|
| 216 | #endif
|
|---|
| 217 |
|
|---|
| 218 | // define NULL
|
|---|
| 219 | #ifndef NULL
|
|---|
| 220 | #define NULL 0
|
|---|
| 221 | #endif
|
|---|
| 222 |
|
|---|
| 223 | // make assert available since we use it a lot
|
|---|
| 224 | #include <assert.h>
|
|---|
| 225 |
|
|---|
| 226 | #endif
|
|---|