checkpoint. more conversion to automake.

This commit is contained in:
crs 2002-06-19 11:23:49 +00:00
parent f85457c49f
commit 9c7e863d77
31 changed files with 328 additions and 270 deletions

View File

@ -3,64 +3,70 @@
#include "common.h"
#if defined(CONFIG_PLATFORM_LINUX)
//
// pick types of particular sizes
//
#include <stdint.h>
typedef int8_t SInt8;
typedef int16_t SInt16;
typedef int32_t SInt32;
typedef int64_t SInt64;
typedef uint8_t UInt8;
typedef uint16_t UInt16;
typedef uint32_t UInt32;
typedef uint64_t UInt64;
#endif // CONFIG_PLATFORM_LINUX
#if defined(CONFIG_PLATFORM_SOLARIS)
#include <inttypes.h>
typedef int8_t SInt8;
typedef int16_t SInt16;
typedef int32_t SInt32;
typedef int64_t SInt64;
typedef uint8_t UInt8;
typedef uint16_t UInt16;
typedef uint32_t UInt32;
typedef uint64_t UInt64;
#endif // CONFIG_PLATFORM_SOLARIS
#if defined(CONFIG_PLATFORM_WIN32)
// use VC++ extensions if available
#if defined(_MSC_VER)
typedef signed __int8 SInt8;
typedef signed __int16 SInt16;
typedef signed __int32 SInt32;
typedef signed __int64 SInt64;
typedef unsigned __int8 UInt8;
typedef unsigned __int16 UInt16;
typedef unsigned __int32 UInt32;
typedef unsigned __int64 UInt64;
#else
typedef signed char SInt8;
typedef short SInt16;
typedef int SInt32;
typedef long long SInt64;
typedef unsigned char UInt8;
typedef unsigned short UInt16;
typedef unsigned int UInt32;
typedef unsigned long long UInt64;
#if !defined(TYPE_OF_SIZE_1)
# if SIZEOF_CHAR == 1
# define TYPE_OF_SIZE_1 char
# endif
#endif
#endif // CONFIG_PLATFORM_WIN32
#if !defined(TYPE_OF_SIZE_2)
# if SIZEOF_INT == 2
# define TYPE_OF_SIZE_2 int
# else
# define TYPE_OF_SIZE_2 short
# endif
#endif
#if !defined(TYPE_OF_SIZE_4)
# if SIZEOF_INT == 4
# define TYPE_OF_SIZE_4 int
# else
# define TYPE_OF_SIZE_4 long
# endif
#endif
//
// verify existence of required types
//
#if !defined(TYPE_OF_SIZE_1)
# error No 1 byte integer type
#endif
#if !defined(TYPE_OF_SIZE_2)
# error No 2 byte integer type
#endif
#if !defined(TYPE_OF_SIZE_4)
# error No 4 byte integer type
#endif
//
// make typedefs
//
// except for SInt8 and UInt8 these types are only guaranteed to be
// at least as big as indicated (in bits). that is, they may be
// larger than indicated.
//
typedef signed TYPE_OF_SIZE_1 SInt8;
typedef signed TYPE_OF_SIZE_2 SInt16;
typedef signed TYPE_OF_SIZE_4 SInt32;
typedef unsigned TYPE_OF_SIZE_1 UInt8;
typedef unsigned TYPE_OF_SIZE_2 UInt16;
typedef unsigned TYPE_OF_SIZE_4 UInt32;
//
// clean up
//
#undef TYPE_OF_SIZE_1
#undef TYPE_OF_SIZE_2
#undef TYPE_OF_SIZE_4
#endif

View File

@ -3,7 +3,7 @@
#include <cstdlib>
#include <cstring>
#if defined(CONFIG_PLATFORM_WIN32)
#if WINDOWS_LIKE
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#define vsnprintf _vsnprintf
@ -42,6 +42,13 @@ static const int g_prioritySuffixLength = 2;
static const int g_priorityPad = g_maxPriorityLength +
g_prioritySuffixLength;
// platform newline sequence
#if WINDOWS_LIKE
static const char* g_newline = "\r\n";
#else
static const char* g_newline = "\n";
#endif
// minimum length of a newline sequence
static const int g_newlineLength = 2;
@ -226,17 +233,13 @@ CLog::output(int priority, char* msg)
}
// put a newline at the end
#if defined(CONFIG_PLATFORM_WIN32)
strcat(msg + g_priorityPad, "\r\n");
#else
strcat(msg + g_priorityPad, "\n");
#endif
strcat(msg + g_priorityPad, g_newline);
// print it
CHoldLock lock(s_lock);
if (s_outputter == NULL ||
!s_outputter(priority, msg + g_maxPriorityLength - n)) {
#if defined(CONFIG_PLATFORM_WIN32)
#if WINDOWS_LIKE
openConsole();
#endif
fprintf(stderr, "%s", msg + g_maxPriorityLength - n);
@ -268,7 +271,7 @@ CLog::vsprint(int pad, char* buffer, int len, const char* fmt, va_list args)
return buffer;
}
#if defined(CONFIG_PLATFORM_WIN32)
#if WINDOWS_LIKE
static DWORD s_thread = 0;

View File

@ -1,8 +1,8 @@
#ifndef CLOG_H
#define CLOG_H
#include "BasicTypes.h"
#include <cstdarg>
#include "common.h"
#include <stdarg.h>
class CLog {
public:
@ -67,7 +67,7 @@ private:
static void output(int priority, char* msg);
static char* vsprint(int pad, char*, int len, const char*, va_list);
static int nprint(const char*, va_list);
#if defined(CONFIG_PLATFORM_WIN32)
#if WINDOWS_LIKE
static void openConsole();
#endif

View File

@ -110,21 +110,7 @@ CStopwatch::operator double() const
return getTime();
}
#if defined(CONFIG_PLATFORM_UNIX)
#include <sys/time.h>
double
CStopwatch::getClock() const
{
struct timeval t;
gettimeofday(&t, NULL);
return (double)t.tv_sec + 1.0e-6 * (double)t.tv_usec;
}
#endif // CONFIG_PLATFORM_UNIX
#if defined(CONFIG_PLATFORM_WIN32)
#if WINDOWS_LIKE
// avoid getting a lot a crap from mmsystem.h that we don't need
#define MMNODRV // Installable driver support
@ -198,4 +184,28 @@ CStopwatch::getClock() const
}
}
#endif // CONFIG_PLATFORM_WIN32
#elif UNIX_LIKE
#if TIME_WITH_SYS_TIME
# include <sys/time.h>
# include <time.h>
#else
# if HAVE_SYS_TIME_H
# include <sys/time.h>
# else
# include <time.h>
# endif
#endif
#if HAVE_UNISTD_H
# include <unistd.h>
#endif
double
CStopwatch::getClock() const
{
struct timeval t;
gettimeofday(&t, NULL);
return (double)t.tv_sec + 1.0e-6 * (double)t.tv_usec;
}
#endif // UNIX_LIKE

View File

@ -2,7 +2,7 @@
#include <cerrno>
// win32 wants a const char* argument to std::exception c'tor
#if defined(CONFIG_PLATFORM_WIN32)
#if WINDOWS_LIKE
#define STDEXCEPTARG ""
#endif

View File

@ -1,53 +1,58 @@
#ifndef COMMON_H
#define COMMON_H
#if defined(__linux__)
#define CONFIG_PLATFORM_LINUX
#define CONFIG_PLATFORM_UNIX
#define CONFIG_TYPES_X11
#define CONFIG_PTHREADS
#elif defined(__sun__)
#define CONFIG_PLATFORM_SOLARIS
#define CONFIG_PLATFORM_UNIX
#define CONFIG_TYPES_X11
#define CONFIG_PTHREADS
#elif defined(_WIN32)
#define CONFIG_PLATFORM_WIN32
#if (_MSC_VER >= 1200)
// work around for statement scoping bug
#define for if (false) { } else for
// turn off bonehead warnings
#pragma warning(disable: 4786) // identifier truncated in debug info
#pragma warning(disable: 4514) // unreferenced inline function removed
// this one's a little too aggressive
#pragma warning(disable: 4127) // conditional expression is constant
// emitted incorrectly under release build in some circumstances
#if defined(NDEBUG)
#pragma warning(disable: 4702) // unreachable code
#pragma warning(disable: 4701) // local variable maybe used uninitialized
#if HAVE_CONFIG_H
# include "config.h"
#endif
#endif // (_MSC_VER >= 1200)
// check if win32 platform
#if defined(_WIN32) || HAVE_WINDOWS_H
# define WINDOWS_LIKE 1
#else
// VC++ specific
# if (_MSC_VER >= 1200)
// work around for statement scoping bug
# define for if (false) { } else for
#error unsupported platform
// turn off bonehead warnings
# pragma warning(disable: 4786) // identifier truncated in debug info
# pragma warning(disable: 4514) // unreferenced inline function removed
// this one's a little too aggressive
# pragma warning(disable: 4127) // conditional expression is constant
// emitted incorrectly under release build in some circumstances
# if defined(NDEBUG)
# pragma warning(disable: 4702) // unreachable code
# pragma warning(disable: 4701) // variable maybe used uninitialized
# endif
# endif // (_MSC_VER >= 1200)
// VC++ has built-in sized types
# if defined(_MSC_VER)
# define TYPE_OF_SIZE_1 __int8
# define TYPE_OF_SIZE_2 __int16
# define TYPE_OF_SIZE_4 __int32
# else
# define SIZE_OF_CHAR 1
# define SIZE_OF_SHORT 2
# define SIZE_OF_INT 4
# define SIZE_OF_LONG 4
# endif
#endif // defined(_WIN32) || HAVE_WINDOWS_H
// unix-like if not like anything else
#if (!defined(WINDOWS_LIKE) || WINDOWS_LIKE == 0)
# define UNIX_LIKE 1
#endif
// define NULL
#ifndef NULL
#define NULL 0
#endif
#include <cassert>
// make assert available since we use it a lot
#include <assert.h>
#endif

View File

@ -1,14 +1,12 @@
#include "stdpre.h"
#if !defined(CONFIG_PLATFORM_LINUX)
#if defined(HAVE_ISTREAM)
#include <istream>
#else
// some versions of libstdc++ don't have <istream>
// FIXME -- only include iostream for versions that don't have istream
#include <iostream>
#endif
#include "stdpost.h"
#if defined(CONFIG_PLATFORM_WIN32) && defined(_MSC_VER)
#if defined(_MSC_VER)
// istream has no overloads for __int* types
inline
std::istream& operator>>(std::istream& s, SInt8& i)

View File

@ -1,9 +1,7 @@
#include "stdpre.h"
#if !defined(CONFIG_PLATFORM_LINUX)
#if defined(HAVE_OSTREAM)
#include <ostream>
#else
// some versions of libstdc++ don't have <ostream>
// FIXME -- only include iostream for versions that don't have ostream
#include <iostream>
#endif
#include "stdpost.h"

View File

@ -402,9 +402,9 @@ CClient::runSession(void*)
}
// FIXME -- use factory to create screen
#if defined(CONFIG_PLATFORM_WIN32)
#if WINDOWS_LIKE
#include "CMSWindowsSecondaryScreen.h"
#elif defined(CONFIG_PLATFORM_UNIX)
#elif UNIX_LIKE
#include "CXWindowsSecondaryScreen.h"
#endif
void
@ -426,9 +426,9 @@ CClient::openSecondaryScreen()
// open screen
log((CLOG_DEBUG1 "creating secondary screen"));
#if defined(CONFIG_PLATFORM_WIN32)
#if WINDOWS_LIKE
m_screen = new CMSWindowsSecondaryScreen;
#elif defined(CONFIG_PLATFORM_UNIX)
#elif UNIX_LIKE
m_screen = new CXWindowsSecondaryScreen;
#endif
log((CLOG_DEBUG1 "opening secondary screen"));

View File

@ -4,12 +4,20 @@
#include "CXWindowsUtil.h"
#include "CThread.h"
#include "CLog.h"
#include <X11/X.h>
#include <X11/Xutil.h>
#define XK_MISCELLANY
#define XK_XKB_KEYS
#include <X11/keysymdef.h>
#include <X11/extensions/XTest.h>
#if defined(X_DISPLAY_MISSING)
# error X11 is required to build synergy
#else
# include <X11/X.h>
# include <X11/Xutil.h>
# define XK_MISCELLANY
# define XK_XKB_KEYS
# include <X11/keysymdef.h>
# if defined(HAVE_X11_EXTENSIONS_XTEST_H)
# include <X11/extensions/XTest.h>
# else
# error The XTest extension is required to build synergy
# endif
#endif
//
// CXWindowsSecondaryScreen

View File

@ -15,9 +15,9 @@
#include <cstring>
// platform dependent name of a daemon
#if defined(CONFIG_PLATFORM_WIN32)
#if WINDOWS_LIKE
#define DAEMON_NAME "Synergy Client"
#elif defined(CONFIG_PLATFORM_UNIX)
#elif UNIX_LIKE
#define DAEMON_NAME "synergy"
#endif
@ -176,7 +176,7 @@ static
void
help()
{
#if defined(CONFIG_PLATFORM_WIN32)
#if WINDOWS_LIKE
# define PLATFORM_ARGS \
" [--install]" \
@ -326,7 +326,7 @@ parse(int argc, const char** argv)
bye(0);
}
#if defined(CONFIG_PLATFORM_WIN32)
#if WINDOWS_LIKE
else if (isArg(i, argc, argv, NULL, "--install")) {
s_install = true;
if (s_uninstall) {
@ -338,7 +338,7 @@ parse(int argc, const char** argv)
}
#endif
#if defined(CONFIG_PLATFORM_WIN32)
#if WINDOWS_LIKE
else if (isArg(i, argc, argv, NULL, "--uninstall")) {
s_uninstall = true;
if (s_install) {
@ -404,7 +404,7 @@ parse(int argc, const char** argv)
// increase default filter level for daemon. the user must
// explicitly request another level for a daemon.
if (s_daemon && s_logFilter == NULL) {
#if defined(CONFIG_PLATFORM_WIN32)
#if WINDOWS_LIKE
if (CPlatform::isWindows95Family()) {
// windows 95 has no place for logging so avoid showing
// the log console window.
@ -430,7 +430,7 @@ parse(int argc, const char** argv)
// platform dependent entry points
//
#if defined(CONFIG_PLATFORM_WIN32)
#if WINDOWS_LIKE
#include "CMSWindowsScreen.h"
@ -605,7 +605,7 @@ WinMain(HINSTANCE instance, HINSTANCE, LPSTR, int)
return result;
}
#elif defined(CONFIG_PLATFORM_UNIX)
#elif UNIX_LIKE
static
int

View File

@ -1,6 +1,6 @@
dnl Process this file with autoconf to produce a configure script.
AC_INIT(base/IInterface.h)
AC_INIT(base/common.h)
AM_CONFIG_HEADER(config.h)
AC_CONFIG_AUX_DIR(config)
AM_INIT_AUTOMAKE(synergy, 0.5)
@ -17,13 +17,13 @@ ACX_PTHREAD(,AC_MSG_ERROR(You must have pthreads to compile synergy))
dnl checks for header files
AC_HEADER_STDC
AC_HEADER_TIME
AC_CHECK_HEADERS([unistd.h sys/time.h])
AC_CHECK_HEADERS([istream ostream])
AC_CHECK_HEADERS([windows.h])
AC_PATH_X
if test "$no_x" = yes; then
AC_MSG_ERROR(You must have X Windows to compile synergy)
fi
AC_PATH_XTRA
AC_CHECK_HEADERS(sys/time.h)
dnl AC_HEADER_TIME
AC_CHECK_HEADERS([X11/extensions/XTest.h])
dnl checks for types
dnl AC_TYPE_SIZE_T
@ -32,7 +32,13 @@ dnl checks for structures
AC_STRUCT_TM
dnl checks for compiler characteristics
AC_CHECK_SIZEOF(char, 1)
AC_CHECK_SIZEOF(short, 2)
AC_CHECK_SIZEOF(int, 2)
AC_CHECK_SIZEOF(long, 4)
dnl should check for bool
dnl should require template support
dnl should require exception support
dnl checks for library functions
dnl AC_TYPE_SIGNAL

View File

@ -7,7 +7,7 @@
CCondVarBase::CCondVarBase(CMutex* mutex) :
m_mutex(mutex)
#if defined(CONFIG_PLATFORM_WIN32)
#if WINDOWS_LIKE
, m_waitCountMutex()
#endif
{
@ -45,7 +45,7 @@ CCondVarBase::getMutex() const
return m_mutex;
}
#if defined(CONFIG_PTHREADS)
#if HAVE_PTHREAD
#include "CThread.h"
#include <pthread.h>
@ -169,9 +169,9 @@ CCondVarBase::wait(CStopwatch& timer, double timeout) const
}
}
#endif // CONFIG_PTHREADS
#endif // HAVE_PTHREAD
#if defined(CONFIG_PLATFORM_WIN32)
#if WINDOWS_LIKE
#include "CLock.h"
#include "CThreadRep.h"
@ -312,4 +312,4 @@ CCondVarBase::wait(CStopwatch& timer, double timeout) const
result == WAIT_OBJECT_0 + 1);
}
#endif // CONFIG_PLATFORM_WIN32
#endif // WINDOWS_LIKE

View File

@ -56,7 +56,7 @@ private:
CMutex* m_mutex;
void* m_cond;
#if defined(CONFIG_PLATFORM_WIN32)
#if WINDOWS_LIKE
enum { kSignal, kBroadcast };
mutable UInt32 m_waitCount;
CMutex m_waitCountMutex;

View File

@ -26,7 +26,7 @@ CMutex::operator=(const CMutex&)
return *this;
}
#if defined(CONFIG_PTHREADS)
#if HAVE_PTHREAD
#include <pthread.h>
#include <cerrno>
@ -98,9 +98,9 @@ CMutex::unlock() const
}
}
#endif // CONFIG_PTHREADS
#endif // HAVE_PTHREAD
#if defined(CONFIG_PLATFORM_WIN32)
#if WINDOWS_LIKE
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
@ -133,4 +133,4 @@ CMutex::unlock() const
LeaveCriticalSection(reinterpret_cast<CRITICAL_SECTION*>(m_mutex));
}
#endif // CONFIG_PLATFORM_WIN32
#endif // WINDOWS_LIKE

View File

@ -99,7 +99,7 @@ CThread::wait(double timeout) const
return currentRep->wait(m_rep, timeout);
}
#if defined(CONFIG_PLATFORM_WIN32)
#if WINDOWS_LIKE
bool
CThread::waitForEvent(double timeout)
{

View File

@ -105,7 +105,7 @@ public:
// (cancellation point)
bool wait(double timeout = -1.0) const;
#if defined(CONFIG_PLATFORM_WIN32)
#if WINDOWS_LIKE
// wait for a message in the queue. returns true if a message
// is available.
// (cancellation point)

View File

@ -6,40 +6,34 @@
#include "CLog.h"
#include "IJob.h"
#if defined(CONFIG_PTHREADS)
#include <signal.h>
#define SIGWAKEUP SIGUSR1
#endif
#if HAVE_PTHREAD
# include <signal.h>
# define SIGWAKEUP SIGUSR1
#elif WINDOWS_LIKE
# if !defined(_MT)
# error multithreading compile option is required
# endif
# include <process.h>
#else
#error unsupported platform for multithreading
#if defined(CONFIG_PLATFORM_WIN32)
# if !defined(_MT)
# error multithreading compile option is required
# endif
#include <process.h>
#endif
// FIXME -- temporary exception type
class XThreadUnavailable { };
#if defined(CONFIG_PLATFORM_UNIX) && !defined(NDEBUG)
#include <cstdlib>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
static void threadDebug(int)
{
if (fork() == 0) abort();
else { wait(0); exit(1); }
}
#endif
//
// CThreadRep
//
CMutex* CThreadRep::s_mutex = NULL;
CThreadRep* CThreadRep::s_head = NULL;
#if defined(CONFIG_PTHREADS)
#if HAVE_PTHREAD
pthread_t CThreadRep::s_signalThread;
#endif
@ -55,10 +49,10 @@ CThreadRep::CThreadRep() :
// initialize stuff
init();
#if defined(CONFIG_PTHREADS)
#if HAVE_PTHREAD
// get main thread id
m_thread = pthread_self();
#elif defined(CONFIG_PLATFORM_WIN32)
#elif WINDOWS_LIKE
// get main thread id
m_thread = NULL;
m_id = GetCurrentThreadId();
@ -94,7 +88,7 @@ CThreadRep::CThreadRep(IJob* job, void* userData) :
CLock lock(s_mutex);
// start the thread. throw if it doesn't start.
#if defined(CONFIG_PTHREADS)
#if HAVE_PTHREAD
// mask some signals in all threads except the main thread
sigset_t sigset, oldsigset;
sigemptyset(&sigset);
@ -106,7 +100,7 @@ CThreadRep::CThreadRep(IJob* job, void* userData) :
if (status != 0) {
throw XThreadUnavailable();
}
#elif defined(CONFIG_PLATFORM_WIN32)
#elif WINDOWS_LIKE
unsigned int id;
m_thread = reinterpret_cast<HANDLE>(_beginthreadex(NULL, 0,
threadFunc, (void*)this, 0, &id));
@ -151,7 +145,7 @@ CThreadRep::initThreads()
if (s_mutex == NULL) {
s_mutex = new CMutex;
#if defined(CONFIG_PTHREADS)
#if HAVE_PTHREAD
// install SIGWAKEUP handler
struct sigaction act;
sigemptyset(&act.sa_mask);
@ -162,18 +156,11 @@ CThreadRep::initThreads()
# endif
act.sa_handler = &threadCancel;
sigaction(SIGWAKEUP, &act, NULL);
# ifndef NDEBUG
act.sa_handler = &threadDebug;
sigaction(SIGSEGV, &act, NULL);
# endif
// set signal mask
sigset_t sigset;
sigemptyset(&sigset);
sigaddset(&sigset, SIGWAKEUP);
# ifndef NDEBUG
sigaddset(&sigset, SIGSEGV);
# endif
pthread_sigmask(SIG_UNBLOCK, &sigset, NULL);
sigemptyset(&sigset);
sigaddset(&sigset, SIGPIPE);
@ -196,7 +183,7 @@ CThreadRep::initThreads()
sigaddset(&sigset, SIGTERM);
pthread_sigmask(SIG_UNBLOCK, &sigset, NULL);
}
#endif
#endif // HAVE_PTHREAD
}
}
@ -251,9 +238,9 @@ CThreadRep::getCurrentThreadRep()
{
assert(s_mutex != NULL);
#if defined(CONFIG_PTHREADS)
#if HAVE_PTHREAD
const pthread_t thread = pthread_self();
#elif defined(CONFIG_PLATFORM_WIN32)
#elif WINDOWS_LIKE
const DWORD id = GetCurrentThreadId();
#endif
@ -263,11 +250,11 @@ CThreadRep::getCurrentThreadRep()
// search
CThreadRep* scan = s_head;
while (scan != NULL) {
#if defined(CONFIG_PTHREADS)
#if HAVE_PTHREAD
if (scan->m_thread == thread) {
break;
}
#elif defined(CONFIG_PLATFORM_WIN32)
#elif WINDOWS_LIKE
if (scan->m_id == id) {
break;
}
@ -326,10 +313,19 @@ CThreadRep::doThreadFunc()
m_result = result;
}
#if defined(CONFIG_PTHREADS)
#if HAVE_PTHREAD
#include "CStopwatch.h"
#include <sys/time.h>
#if TIME_WITH_SYS_TIME
# include <sys/time.h>
# include <time.h>
#else
# if HAVE_SYS_TIME_H
# include <sys/time.h>
# else
# include <time.h>
# endif
#endif
void
CThreadRep::init()
@ -492,7 +488,9 @@ CThreadRep::threadSignalHandler(void* vrep)
}
}
#elif defined(CONFIG_PLATFORM_WIN32)
#endif // HAVE_PTHREAD
#if WINDOWS_LIKE
void
CThreadRep::init()
@ -713,4 +711,4 @@ CThreadRep::threadFunc(void* arg)
return 0;
}
#endif
#endif // WINDOWS_LIKE

View File

@ -1,11 +1,11 @@
#ifndef CTHREADREP_H
#define CTHREADREP_H
#include "BasicTypes.h"
#include "common.h"
#if defined(CONFIG_PTHREADS)
#if HAVE_PTHREAD
#include <pthread.h>
#elif defined(CONFIG_PLATFORM_WIN32)
#elif WINDOWS_LIKE
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#endif
@ -43,7 +43,7 @@ public:
// wait for thread to exit or for current thread to cancel
bool wait(CThreadRep*, double timeout);
#if defined(CONFIG_PLATFORM_WIN32)
#if WINDOWS_LIKE
// wait for a message on the queue
bool waitForEvent(double timeout);
#endif
@ -62,9 +62,9 @@ public:
// get the current cancellable state
bool isCancellable() const;
#if defined(CONFIG_PTHREADS)
#if HAVE_PTHREAD
bool isExited() const;
#elif defined(CONFIG_PLATFORM_WIN32)
#elif WINDOWS_LIKE
HANDLE getExitEvent() const;
HANDLE getCancelEvent() const;
#endif
@ -88,11 +88,11 @@ private:
static CThreadRep* find();
// thread functions
#if defined(CONFIG_PTHREADS)
#if HAVE_PTHREAD
static void* threadFunc(void* arg);
static void threadCancel(int);
static void* threadSignalHandler(void*);
#elif defined(CONFIG_PLATFORM_WIN32)
#elif WINDOWS_LIKE
static unsigned int __stdcall threadFunc(void* arg);
#endif
void doThreadFunc();
@ -108,22 +108,21 @@ private:
CThreadRep* m_prev;
CThreadRep* m_next;
SInt32 m_refCount;
int m_refCount;
IJob* m_job;
void* m_userData;
void* m_result;
bool m_cancellable;
bool m_cancelling;
UInt32 m_signals;
#if defined(CONFIG_PTHREADS)
#if HAVE_PTHREAD
pthread_t m_thread;
bool m_exit;
bool m_cancel;
static pthread_t s_signalThread;
#endif
#if defined(CONFIG_PLATFORM_WIN32)
#if WINDOWS_LIKE
HANDLE m_thread;
DWORD m_id;
HANDLE m_exit;

View File

@ -37,7 +37,7 @@ struct protoent FAR * (PASCAL FAR *CNetwork::getprotobyname)(const char FAR * na
int (PASCAL FAR *CNetwork::getsockerror)(void);
int (PASCAL FAR *CNetwork::gethosterror)(void);
#if defined(CONFIG_PLATFORM_WIN32)
#if WINDOWS_LIKE
int (PASCAL FAR *CNetwork::select)(int nfds, fd_set FAR *readfds, fd_set FAR *writefds, fd_set FAR *exceptfds, const struct timeval FAR *timeout);
int (PASCAL FAR *CNetwork::WSACleanup)(void);
@ -297,7 +297,7 @@ CNetwork::write2(Socket s, const void FAR* buf, size_t len)
#endif
#if defined(CONFIG_PLATFORM_UNIX)
#if UNIX_LIKE
#include <unistd.h>
#include <sys/ioctl.h>

View File

@ -3,21 +3,23 @@
#include "BasicTypes.h"
#if defined(CONFIG_PLATFORM_WIN32)
// declare no functions in winsock2
# define INCL_WINSOCK_API_PROTOTYPES 0
# define INCL_WINSOCK_API_TYPEDEFS 0
# include <winsock2.h>
#if WINDOWS_LIKE
// declare no functions in winsock2
# define INCL_WINSOCK_API_PROTOTYPES 0
# define INCL_WINSOCK_API_TYPEDEFS 0
# include <winsock2.h>
typedef int ssize_t;
# if !defined(SOL_TCP)
# define SOL_TCP IPPROTO_TCP
# endif
# if !defined(SOL_TCP)
# define SOL_TCP IPPROTO_TCP
# endif
#else
# define FAR
# define PASCAL
# undef FAR
# undef PASCAL
# define FAR
# define PASCAL
#endif
#if defined(CONFIG_PLATFORM_UNIX)
#if UNIX_LIKE
# include <sys/types.h>
# include <sys/poll.h>
# include <sys/socket.h>
@ -31,7 +33,7 @@ typedef int ssize_t;
class CNetwork {
public:
#if defined(CONFIG_PLATFORM_WIN32)
#if WINDOWS_LIKE
typedef SOCKET Socket;
typedef struct sockaddr Address;
typedef int AddressLength;
@ -48,7 +50,7 @@ public:
kPOLLERR = 4,
kPOLLNVAL = 8
};
#elif defined(CONFIG_PLATFORM_UNIX)
#elif UNIX_LIKE
typedef int Socket;
typedef struct sockaddr Address;
typedef socklen_t AddressLength;
@ -80,9 +82,9 @@ public:
// getsockerror() constants
enum {
#if defined(CONFIG_PLATFORM_WIN32)
#if WINDOWS_LIKE
kEADDRINUSE = WSAEADDRINUSE,
#elif defined(CONFIG_PLATFORM_UNIX)
#elif UNIX_LIKE
kEADDRINUSE = EADDRINUSE,
#endif
kNone = 0
@ -90,12 +92,12 @@ public:
// gethosterror() constants
enum {
#if defined(CONFIG_PLATFORM_WIN32)
#if WINDOWS_LIKE
kHOST_NOT_FOUND = WSAHOST_NOT_FOUND,
kNO_DATA = WSANO_DATA,
kNO_RECOVERY = WSANO_RECOVERY,
kTRY_AGAIN = WSATRY_AGAIN,
#elif defined(CONFIG_PLATFORM_UNIX)
#elif UNIX_LIKE
kHOST_NOT_FOUND = HOST_NOT_FOUND,
kNO_DATA = NO_DATA,
kNO_RECOVERY = NO_RECOVERY,
@ -137,7 +139,7 @@ public:
static int (PASCAL FAR *getsockerror)(void);
static int (PASCAL FAR *gethosterror)(void);
#if defined(CONFIG_PLATFORM_WIN32)
#if WINDOWS_LIKE
private:
static void init2(HMODULE);
static int PASCAL FAR poll2(PollEntry[], int nfds, int timeout);

View File

@ -1,11 +1,15 @@
#include "common.h"
#if defined(CONFIG_PLATFORM_WIN32)
#if WINDOWS_LIKE
#include "CWin32Platform.cpp"
#elif defined(CONFIG_PLATFORM_UNIX)
#elif UNIX_LIKE
#include "CUnixPlatform.cpp"
#else
#error Unsupported platform
#endif

View File

@ -3,16 +3,20 @@
#include "common.h"
#if defined(CONFIG_PLATFORM_WIN32)
#if WINDOWS_LIKE
#include "CWin32Platform.h"
typedef CWin32Platform CPlatform;
#elif defined(CONFIG_PLATFORM_UNIX)
#elif UNIX_LIKE
#include "CUnixPlatform.h"
typedef CUnixPlatform CPlatform;
#else
#error Unsupported platform
#endif
#endif

View File

@ -5,7 +5,11 @@
#include "ClipboardTypes.h"
#include "stdmap.h"
#include "stdlist.h"
#include <X11/Xlib.h>
#if defined(X_DISPLAY_MISSING)
# error X11 is required to build synergy
#else
# include <X11/Xlib.h>
#endif
class CXWindowsClipboard : public IClipboard {
public:

View File

@ -3,7 +3,11 @@
#include "ClipboardTypes.h"
#include "CMutex.h"
#include <X11/Xlib.h>
#if defined(X_DISPLAY_MISSING)
# error X11 is required to build synergy
#else
# include <X11/Xlib.h>
#endif
class IClipboard;
class CXWindowsClipboard;

View File

@ -3,7 +3,11 @@
#include "CString.h"
#include "BasicTypes.h"
#include <X11/Xlib.h>
#if defined(X_DISPLAY_MISSING)
# error X11 is required to build synergy
#else
# include <X11/Xlib.h>
#endif
class CXWindowsUtil {
public:

View File

@ -1353,9 +1353,9 @@ CServer::updatePrimaryClipboard(ClipboardID id)
}
// FIXME -- use factory to create screen
#if defined(CONFIG_PLATFORM_WIN32)
#if WINDOWS_LIKE
#include "CMSWindowsPrimaryScreen.h"
#elif defined(CONFIG_PLATFORM_UNIX)
#elif UNIX_LIKE
#include "CXWindowsPrimaryScreen.h"
#endif
void
@ -1377,9 +1377,9 @@ CServer::openPrimaryScreen()
// open screen
log((CLOG_DEBUG1 "creating primary screen"));
#if defined(CONFIG_PLATFORM_WIN32)
#if WINDOWS_LIKE
m_primary = new CMSWindowsPrimaryScreen;
#elif defined(CONFIG_PLATFORM_UNIX)
#elif UNIX_LIKE
m_primary = new CXWindowsPrimaryScreen;
#endif
log((CLOG_DEBUG1 "opening primary screen"));

View File

@ -2,18 +2,19 @@
#define CSYNERGYHOOK_H
#include "BasicTypes.h"
#if WINDOWS_LIKE
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#else
#error CSynergyHook is a win32 specific file
#endif
#if defined(CONFIG_PLATFORM_WIN32)
#if defined(SYNRGYHK_EXPORTS)
#define CSYNERGYHOOK_API __declspec(dllexport)
#else
#define CSYNERGYHOOK_API __declspec(dllimport)
#endif
#else
#define CSYNERGYHOOK_API
#endif
#define SYNERGY_MSG_MARK WM_APP + 0x0011 // mark id; <unused>
#define SYNERGY_MSG_KEY WM_APP + 0x0012 // vk code; key data

View File

@ -5,10 +5,14 @@
#include "CThread.h"
#include "CLog.h"
#include "CStopwatch.h"
#include <X11/X.h>
#include <X11/Xutil.h>
#define XK_MISCELLANY
#include <X11/keysymdef.h>
#if defined(X_DISPLAY_MISSING)
# error X11 is required to build synergy
#else
# include <X11/X.h>
# include <X11/Xutil.h>
# define XK_MISCELLANY
# include <X11/keysymdef.h>
#endif
//
// CXWindowsPrimaryScreen

View File

@ -14,16 +14,16 @@
#include <cstring>
// platform dependent name of a daemon
#if defined(CONFIG_PLATFORM_WIN32)
#if WINDOWS_LIKE
#define DAEMON_NAME "Synergy Server"
#elif defined(CONFIG_PLATFORM_UNIX)
#elif UNIX_LIKE
#define DAEMON_NAME "synergyd"
#endif
// configuration file name
#if defined(CONFIG_PLATFORM_WIN32)
#if WINDOWS_LIKE
#define CONFIG_NAME "synergy.sgc"
#elif defined(CONFIG_PLATFORM_UNIX)
#elif UNIX_LIKE
#define CONFIG_NAME "synergy.conf"
#endif
@ -34,7 +34,7 @@
static const char* pname = NULL;
static bool s_restartable = true;
static bool s_daemon = true;
#if defined(CONFIG_PLATFORM_WIN32)
#if WINDOWS_LIKE
static bool s_install = false;
static bool s_uninstall = false;
#endif
@ -209,7 +209,7 @@ static
void
help()
{
#if defined(CONFIG_PLATFORM_WIN32)
#if WINDOWS_LIKE
# define PLATFORM_ARGS \
" {--daemon|--no-daemon}" \
@ -398,7 +398,7 @@ parse(int argc, const char** argv)
bye(0);
}
#if defined(CONFIG_PLATFORM_WIN32)
#if WINDOWS_LIKE
else if (isArg(i, argc, argv, NULL, "--install")) {
s_install = true;
if (s_uninstall) {
@ -410,7 +410,7 @@ parse(int argc, const char** argv)
}
#endif
#if defined(CONFIG_PLATFORM_WIN32)
#if WINDOWS_LIKE
else if (isArg(i, argc, argv, NULL, "--uninstall")) {
s_uninstall = true;
if (s_install) {
@ -450,7 +450,7 @@ parse(int argc, const char** argv)
// increase default filter level for daemon. the user must
// explicitly request another level for a daemon.
if (s_daemon && s_logFilter == NULL) {
#if defined(CONFIG_PLATFORM_WIN32)
#if WINDOWS_LIKE
if (CPlatform::isWindows95Family()) {
// windows 95 has no place for logging so avoid showing
// the log console window.
@ -541,7 +541,7 @@ loadConfig()
// platform dependent entry points
//
#if defined(CONFIG_PLATFORM_WIN32)
#if WINDOWS_LIKE
#include "CMSWindowsScreen.h"
@ -726,7 +726,7 @@ WinMain(HINSTANCE instance, HINSTANCE, LPSTR, int)
return result;
}
#elif defined(CONFIG_PLATFORM_UNIX)
#elif UNIX_LIKE
static
int

View File

@ -3,7 +3,7 @@
#include "BasicTypes.h"
#include "XIO.h"
#include <cstdarg>
#include <stdarg.h>
class IInputStream;
class IOutputStream;