Add Linux compatibility for LoginServer
- Updated main.cpp with platform-specific code for Windows/Linux - Modified stdafx.h to include Linux headers and definitions - Updated signal_handler.cpp for cross-platform signal handling - Added Linux-compatible types and macros - Created CMakeLists.txt for Linux build system - Added build.sh script for automated building - Added loginserver.sh script for server management - Created comprehensive README_LINUX.md with deployment instructions - All changes maintain Windows compatibility using preprocessor directives
This commit is contained in:
@@ -11,7 +11,9 @@ void HookSignals(Condition * notifier)
|
||||
signal(SIGINT, OnSignal);
|
||||
signal(SIGTERM, OnSignal);
|
||||
signal(SIGABRT, OnSignal);
|
||||
#ifdef _WIN32
|
||||
signal(SIGBREAK, OnSignal);
|
||||
#endif
|
||||
}
|
||||
|
||||
void OnSignal(int s)
|
||||
@@ -21,7 +23,9 @@ void OnSignal(int s)
|
||||
case SIGINT:
|
||||
case SIGTERM:
|
||||
case SIGABRT:
|
||||
#ifdef _WIN32
|
||||
case SIGBREAK:
|
||||
#endif
|
||||
g_hNotifier->BeginSynchronized();
|
||||
g_hNotifier->Signal();
|
||||
g_hNotifier->EndSynchronized();
|
||||
@@ -36,5 +40,7 @@ void UnhookSignals()
|
||||
signal(SIGINT, 0);
|
||||
signal(SIGTERM, 0);
|
||||
signal(SIGABRT, 0);
|
||||
#ifdef _WIN32
|
||||
signal(SIGBREAK, 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
+50
-14
@@ -2,19 +2,49 @@
|
||||
|
||||
#include <queue>
|
||||
|
||||
#define VC_EXTRALEAN
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#ifdef _WIN32
|
||||
#define VC_EXTRALEAN
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
|
||||
#include <Windows.h>
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
#include <Windows.h>
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
|
||||
#define THREADCALL WINAPI
|
||||
#define STRCASECMP _stricmp
|
||||
#define THREADCALL WINAPI
|
||||
#define STRCASECMP _stricmp
|
||||
|
||||
#define I64FMT "%016I64X"
|
||||
#define I64FMTD "%I64u"
|
||||
#define SI64FMTD "%I64d"
|
||||
#define I64FMT "%016I64X"
|
||||
#define I64FMTD "%I64u"
|
||||
#define SI64FMTD "%I64d"
|
||||
#else
|
||||
// Linux includes
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <dirent.h>
|
||||
|
||||
#define THREADCALL
|
||||
#define STRCASECMP strcasecmp
|
||||
#define Sleep(ms) usleep((ms) * 1000)
|
||||
#define CreateDirectory(path, attr) mkdir(path, 0755)
|
||||
#define _snprintf snprintf
|
||||
|
||||
#define I64FMT "%016lX"
|
||||
#define I64FMTD "%lu"
|
||||
#define SI64FMTD "%ld"
|
||||
|
||||
// Windows types for Linux
|
||||
typedef int BOOL;
|
||||
typedef unsigned long DWORD;
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
#endif
|
||||
|
||||
#if defined(_DEBUG) || defined(DEBUG)
|
||||
# include <cassert>
|
||||
@@ -42,9 +72,11 @@
|
||||
# define TRACE
|
||||
#endif
|
||||
|
||||
// Ignore the warning "nonstandard extension used: enum '<enum name>' used in qualified name"
|
||||
// Sometimes it's necessary to avoid collisions, but aside from that, specifying the enumeration helps make code intent clearer.
|
||||
#pragma warning(disable: 4482)
|
||||
#ifdef _WIN32
|
||||
// Ignore the warning "nonstandard extension used: enum '<enum name>' used in qualified name"
|
||||
// Sometimes it's necessary to avoid collisions, but aside from that, specifying the enumeration helps make code intent clearer.
|
||||
#pragma warning(disable: 4482)
|
||||
#endif
|
||||
|
||||
#define STR(str) #str
|
||||
#define STRINGIFY(str) STR(str)
|
||||
@@ -65,7 +97,11 @@ protected:
|
||||
std::recursive_mutex& target;
|
||||
};
|
||||
|
||||
#define sleep(ms) Sleep(ms)
|
||||
#ifdef _WIN32
|
||||
#define sleep(ms) Sleep(ms)
|
||||
#else
|
||||
#define sleep(ms) usleep((ms) * 1000)
|
||||
#endif
|
||||
|
||||
#ifdef min
|
||||
#undef min
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#define INLINE __forceinline
|
||||
#ifdef _WIN32
|
||||
#define INLINE __forceinline
|
||||
#else
|
||||
#define INLINE inline __attribute__((always_inline))
|
||||
#endif
|
||||
|
||||
typedef int64_t int64;
|
||||
typedef int32_t int32;
|
||||
|
||||
Reference in New Issue
Block a user