Merge pull request #10 from tropicaaal/refactor/tropical-dev

fix: implement many POSIX stubs over required winapi calls
This commit is contained in:
DecalOverdose 2026-03-03 12:04:46 +04:00 committed by GitHub
commit 61a8953fe4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
26 changed files with 765 additions and 156 deletions

1
.gitignore vendored
View file

@ -1,3 +1,4 @@
# .gitignore
build/
.cache/
.idea/

View file

@ -6,6 +6,7 @@ project(MinecraftConsoles C CXX)
# Set target arch type if empty. Visual studio solution generator provides it.
################################################################################
set(CMAKE_VS_PLATFORM_NAME "Linux")
set(CMAKE_CXX_STANDARD 11)
################################################################################
# Global configuration types

View file

@ -104,13 +104,6 @@
#define MINECRAFT_LANGUAGE_LATINAMERICANSPANISH 0x13
#define MINECRAFT_LANGUAGE_GREEK 0x14
#if defined(__linux__)
#define __debugbreak()
#define __int32 int
typedef unsigned long ULONG;
inline void InitializeCriticalSectionAndSpinCount(CRITICAL_SECTION CriticalSection, ULONG SpinCount) {}
#endif // __linux__
/* Match these
const int XC_LANGUAGE_ENGLISH =1;

View file

@ -2,7 +2,7 @@
class Mob;
class Options;
using namespace std;
#include "../../Minecraft.World/SoundTypes.h"
#include "../../../Minecraft.World/SoundTypes.h"
enum eMUSICFILES
{

View file

@ -1,7 +1,7 @@
#pragma once
using namespace std;
#pragma message("LevelGenerationOptions.h ")
// #pragma message("LevelGenerationOptions.h ")
#include "GameRuleDefinition.h"
#include "../../../Minecraft.World/StructureFeature.h"

View file

@ -1,6 +1,6 @@
#pragma once
#pragma message("UIStructs.h")
// #pragma message("UIStructs.h")
#include "UIEnums.h"

View file

@ -4,7 +4,9 @@
#include "OffsettedRenderList.h"
#include "../Minecraft.World/JavaIntHash.h"
#include "../Minecraft.World/Level.h"
#ifndef __linux__
#include <xmcore.h>
#endif // __linux__
#ifdef __PS3__
#include "C4JSpursJob.h"
#endif

View file

@ -0,0 +1,697 @@
#ifndef LINUXSTUBS_H
#define LINUXSTUBS_H
#pragma once
#include <cstdint>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cerrno>
#include <atomic>
#include <climits>
#include <cfloat>
#include <pthread.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <dirent.h>
#include <fnmatch.h>
#include <time.h>
#include <stdio.h>
#include <sys/time.h>
#define TRUE true
#define FALSE false
#define RtlZeroMemory(Destination,Length) memset((Destination),0,(Length))
#define ZeroMemory RtlZeroMemory
#define WINAPI
#define _vsnprintf_s vsnprintf;
typedef unsigned int DWORD;
typedef const char *LPCSTR;
typedef bool BOOL;
typedef BOOL *PBOOL;
typedef BOOL *LPBOOL;
typedef void* LPVOID;
typedef wchar_t WCHAR;
typedef unsigned char BYTE;
typedef BYTE* PBYTE;
typedef const wchar_t* LPCWSTR;
typedef unsigned long long ULONGLONG;
typedef int HRESULT;
typedef unsigned int UINT;
typedef void* HANDLE;
typedef int INT;
typedef long* PLONG;
typedef unsigned int* LPDWORD;
typedef const void* LPCVOID;
typedef char CHAR;
typedef void* PVOID;
typedef uintptr_t ULONG_PTR;
typedef long LONG;
typedef long LONG64, *PLONG64;
typedef void VOID;
typedef ULONGLONG PlayerUID;
typedef DWORD WORD;
typedef DWORD* PDWORD;
typedef struct {
DWORD LowPart;
LONG HighPart;
long long QuadPart;
} LARGE_INTEGER;
typedef long long LONGLONG;
typedef size_t SIZE_T;
typedef std::wstring LPWSTR;
typedef unsigned char boolean; // java brainrot
#define __debugbreak()
#define __int32 int
#define CONST const
typedef int64_t __int64;
typedef uint64_t __uint64;
typedef unsigned long ULONG;
// typedef unsigned char byte;
typedef short SHORT;
typedef float FLOAT;
#define ERROR_SUCCESS 0L
#define ERROR_IO_PENDING 997L // dderror
#define ERROR_CANCELLED 1223L
//#define S_OK ((HRESULT)0x00000000L)
#define S_FALSE ((HRESULT)0x00000001L)
#define PAGE_READWRITE 0x04
#define MEM_LARGE_PAGES 0x20000000
#define MAXULONG_PTR ((ULONG_PTR)~0UL)
#define MAX_PATH 260
#define GENERIC_READ 0x80000000UL
#define GENERIC_WRITE 0x40000000UL
#define GENERIC_EXECUTE 0x20000000UL
#define GENERIC_ALL 0x10000000UL
#define FILE_SHARE_READ 0x00000001
#define FILE_SHARE_WRITE 0x00000002
#define FILE_SHARE_DELETE 0x00000004
#define CREATE_NEW 1
#define CREATE_ALWAYS 2
#define OPEN_EXISTING 3
#define OPEN_ALWAYS 4
#define TRUNCATE_EXISTING 5
#define FILE_ATTRIBUTE_READONLY 0x00000001
#define FILE_ATTRIBUTE_HIDDEN 0x00000002
#define FILE_ATTRIBUTE_SYSTEM 0x00000004
#define FILE_ATTRIBUTE_DIRECTORY 0x00000010
#define FILE_ATTRIBUTE_ARCHIVE 0x00000020
#define FILE_ATTRIBUTE_NORMAL 0x00000080
#define FILE_ATTRIBUTE_TEMPORARY 0x00000100
#define INVALID_FILE_ATTRIBUTES ((DWORD)-1)
#define INVALID_FILE_SIZE ((DWORD)-1)
#define INVALID_SET_FILE_POINTER ((DWORD)-1)
#define FILE_BEGIN SEEK_SET
#define FILE_CURRENT SEEK_CUR
#define FILE_END SEEK_END
#define INVALID_HANDLE_VALUE ((HANDLE)(ULONG_PTR)-1)
// https://learn.microsoft.com/en-us/windows/win32/api/minwinbase/ns-minwinbase-filetime
typedef struct _FILETIME {
DWORD dwLowDateTime;
DWORD dwHighDateTime;
} FILETIME, *PFILETIME, *LPFILETIME;
typedef struct _MEMORYSTATUS {
DWORD dwLength;
DWORD dwMemoryLoad;
SIZE_T dwTotalPhys;
SIZE_T dwAvailPhys;
SIZE_T dwTotalPageFile;
SIZE_T dwAvailPageFile;
SIZE_T dwTotalVirtual;
SIZE_T dwAvailVirtual;
} MEMORYSTATUS, *LPMEMORYSTATUS;
typedef struct _WIN32_FIND_DATAA {
DWORD dwFileAttributes;
FILETIME ftCreationTime;
FILETIME ftLastAccessTime;
FILETIME ftLastWriteTime;
DWORD nFileSizeHigh;
DWORD nFileSizeLow;
DWORD dwReserved0;
DWORD dwReserved1;
char cFileName[MAX_PATH];
char cAlternateFileName[14];
} WIN32_FIND_DATAA, *PWIN32_FIND_DATAA, *LPWIN32_FIND_DATAA;
typedef WIN32_FIND_DATAA WIN32_FIND_DATA;
typedef PWIN32_FIND_DATAA PWIN32_FIND_DATA;
typedef LPWIN32_FIND_DATAA LPWIN32_FIND_DATA;
typedef struct _WIN32_FILE_ATTRIBUTE_DATA {
DWORD dwFileAttributes;
FILETIME ftCreationTime;
FILETIME ftLastAccessTime;
FILETIME ftLastWriteTime;
DWORD nFileSizeHigh;
DWORD nFileSizeLow;
} WIN32_FILE_ATTRIBUTE_DATA, *LPWIN32_FILE_ATTRIBUTE_DATA;
typedef enum _GET_FILEEX_INFO_LEVELS {
GetFileExInfoStandard,
GetFileExMaxInfoLevel
} GET_FILEEX_INFO_LEVELS;
typedef VOID* XMEMCOMPRESSION_CONTEXT;
typedef VOID* XMEMDECOMPRESSION_CONTEXT;
// internal search state for FindFirstFile/FindNextFile
typedef struct _LINUXSTUBS_FIND_HANDLE {
DIR *dir;
char dirpath[MAX_PATH];
char pattern[MAX_PATH];
} _LINUXSTUBS_FIND_HANDLE;
// https://learn.microsoft.com/en-us/windows/win32/api/minwinbase/ns-minwinbase-systemtime
typedef struct _SYSTEMTIME {
WORD wYear;
WORD wMonth;
WORD wDayOfWeek;
WORD wDay;
WORD wHour;
WORD wMinute;
WORD wSecond;
WORD wMilliseconds;
} SYSTEMTIME, *PSYSTEMTIME, *LPSYSTEMTIME;
#define TLS_OUT_OF_INDEXES ((DWORD)0xFFFFFFFF)
typedef pthread_mutex_t RTL_CRITICAL_SECTION;
typedef pthread_mutex_t* PRTL_CRITICAL_SECTION;
typedef RTL_CRITICAL_SECTION CRITICAL_SECTION;
typedef PRTL_CRITICAL_SECTION PCRITICAL_SECTION;
typedef PRTL_CRITICAL_SECTION LPCRITICAL_SECTION;
static inline void InitializeCriticalSection(PRTL_CRITICAL_SECTION CriticalSection)
{
pthread_mutexattr_t attr;
pthread_mutexattr_init(&attr);
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
pthread_mutex_init(CriticalSection, &attr);
pthread_mutexattr_destroy(&attr);
}
static inline void InitializeCriticalSectionAndSpinCount(PRTL_CRITICAL_SECTION CriticalSection, ULONG SpinCount)
{
// no spin count required because we use a recursive mutex
InitializeCriticalSection(CriticalSection);
}
static inline void DeleteCriticalSection(PRTL_CRITICAL_SECTION CriticalSection)
{
pthread_mutex_destroy(CriticalSection);
}
static inline void EnterCriticalSection(PRTL_CRITICAL_SECTION CriticalSection)
{
pthread_mutex_lock(CriticalSection);
}
static inline void LeaveCriticalSection(PRTL_CRITICAL_SECTION CriticalSection)
{
pthread_mutex_unlock(CriticalSection);
}
static inline ULONG TryEnterCriticalSection(PRTL_CRITICAL_SECTION CriticalSection)
{
return pthread_mutex_trylock(CriticalSection) == 0;
}
// https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-tlsalloc
static inline DWORD TlsAlloc(VOID)
{
pthread_key_t key;
if (pthread_key_create(&key, NULL) == 0)
return key;
return TLS_OUT_OF_INDEXES;
}
// https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-tlsfree
static inline BOOL TlsFree(DWORD dwTlsIndex)
{
return pthread_key_delete(dwTlsIndex) == 0;
}
// https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-tlsgetvalue
static inline LPVOID TlsGetValue(DWORD dwTlsIndex)
{
return pthread_getspecific(dwTlsIndex);
}
// https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-tlssetvalue
static inline BOOL TlsSetValue(DWORD dwTlsIndex, LPVOID lpTlsValue)
{
return pthread_setspecific(dwTlsIndex, lpTlsValue) == 0;
}
// https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-globalmemorystatus
static inline VOID GlobalMemoryStatus(LPMEMORYSTATUS lpBuffer)
{
// TODO: Parse /proc/meminfo and set lpBuffer based on that. Probably will also need another
// different codepath for macOS too.
}
static inline DWORD GetLastError(VOID)
{
return errno;
}
static inline VOID Sleep(DWORD dwMilliseconds)
{
struct timespec ts;
ts.tv_nsec = (dwMilliseconds * 1000000) % 1000000000;
ts.tv_sec = dwMilliseconds / 1000;
int ret;
do {
ret = nanosleep(&ts, &ts);
} while (ret == -1 && errno == EINTR);
}
static inline LONG64 InterlockedCompareExchangeRelease64(
LONG64 volatile *Destination,
LONG64 Exchange,
LONG64 Comperand)
{
LONG64 expected = Comperand;
__atomic_compare_exchange_n(Destination, &expected, Exchange, false, __ATOMIC_RELEASE, __ATOMIC_RELAXED);
return expected;
}
// internal helper: convert time_t to FILETIME (100ns intervals since 1601-01-01)
static inline FILETIME _TimeToFileTime(time_t t)
{
const ULONGLONG EPOCH_DIFF = 11644473600ULL;
ULONGLONG val = ((ULONGLONG)t + EPOCH_DIFF) * 10000000ULL;
FILETIME ft;
ft.dwLowDateTime = (DWORD)(val & 0xFFFFFFFF);
ft.dwHighDateTime = (DWORD)(val >> 32);
return ft;
}
// internal helper: fill WIN32_FIND_DATAA from stat + name
static inline void _FillFindData(const char *name, const struct stat *st, WIN32_FIND_DATAA *out)
{
memset(out, 0, sizeof(*out));
out->dwFileAttributes = S_ISDIR(st->st_mode) ? FILE_ATTRIBUTE_DIRECTORY : FILE_ATTRIBUTE_NORMAL;
if (!(st->st_mode & S_IWUSR)) out->dwFileAttributes |= FILE_ATTRIBUTE_READONLY;
if (name[0] == '.') out->dwFileAttributes |= FILE_ATTRIBUTE_HIDDEN;
out->ftCreationTime = _TimeToFileTime(st->st_mtime);
out->ftLastAccessTime = _TimeToFileTime(st->st_atime);
out->ftLastWriteTime = _TimeToFileTime(st->st_mtime);
out->nFileSizeHigh = (DWORD)((st->st_size >> 32) & 0xFFFFFFFF);
out->nFileSizeLow = (DWORD)(st->st_size & 0xFFFFFFFF);
strncpy(out->cFileName, name, MAX_PATH - 1);
}
static inline HANDLE CreateFileA(const char *lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode,
void *lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile)
{
int flags = 0;
if ((dwDesiredAccess & GENERIC_READ) && (dwDesiredAccess & GENERIC_WRITE)) flags = O_RDWR;
else if (dwDesiredAccess & GENERIC_WRITE) flags = O_WRONLY;
else flags = O_RDONLY;
switch (dwCreationDisposition)
{
case CREATE_NEW: flags |= O_CREAT | O_EXCL; break;
case CREATE_ALWAYS: flags |= O_CREAT | O_TRUNC; break;
case OPEN_EXISTING: break;
case OPEN_ALWAYS: flags |= O_CREAT; break;
case TRUNCATE_EXISTING: flags |= O_TRUNC; break;
}
int fd = open(lpFileName, flags, 0644);
return fd == -1 ? INVALID_HANDLE_VALUE : (HANDLE)(intptr_t)fd;
}
static inline HANDLE CreateFile(const char *lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode,
void *lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile)
{
return CreateFileA(lpFileName, dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile);
}
static inline BOOL CloseHandle(HANDLE hObject)
{
if (hObject == INVALID_HANDLE_VALUE) return FALSE;
return close((int)(intptr_t)hObject) == 0;
}
static inline DWORD GetFileSize(HANDLE hFile, DWORD *lpFileSizeHigh)
{
struct stat st{};
if (fstat((int)(intptr_t)hFile, &st) != 0) { if (lpFileSizeHigh) *lpFileSizeHigh = 0; return INVALID_FILE_SIZE; }
if (lpFileSizeHigh) *lpFileSizeHigh = (DWORD)((st.st_size >> 32) & 0xFFFFFFFF);
return (DWORD)(st.st_size & 0xFFFFFFFF);
}
static inline BOOL GetFileSizeEx(HANDLE hFile, LARGE_INTEGER *lpFileSize)
{
struct stat st{};
if (fstat((int)(intptr_t)hFile, &st) != 0) return FALSE;
if (lpFileSize) { lpFileSize->QuadPart = st.st_size; lpFileSize->LowPart = (DWORD)(st.st_size & 0xFFFFFFFF); lpFileSize->HighPart = (LONG)(st.st_size >> 32); }
return TRUE;
}
static inline BOOL ReadFile(HANDLE hFile, void *lpBuffer, DWORD nNumberOfBytesToRead, DWORD *lpNumberOfBytesRead, void *lpOverlapped)
{
ssize_t n = read((int)(intptr_t)hFile, lpBuffer, nNumberOfBytesToRead);
if (lpNumberOfBytesRead) *lpNumberOfBytesRead = n >= 0 ? (DWORD)n : 0;
return n >= 0;
}
static inline BOOL WriteFile(HANDLE hFile, const void *lpBuffer, DWORD nNumberOfBytesToWrite, DWORD *lpNumberOfBytesWritten, void *lpOverlapped)
{
ssize_t n = write((int)(intptr_t)hFile, lpBuffer, nNumberOfBytesToWrite);
if (lpNumberOfBytesWritten) *lpNumberOfBytesWritten = n >= 0 ? (DWORD)n : 0;
return n >= 0;
}
static inline DWORD SetFilePointer(HANDLE hFile, LONG lDistanceToMove, LONG *lpDistanceToMoveHigh, DWORD dwMoveMethod)
{
off_t offset = lDistanceToMove;
if (lpDistanceToMoveHigh) offset |= ((off_t)*lpDistanceToMoveHigh << 32);
off_t result = lseek((int)(intptr_t)hFile, offset, dwMoveMethod);
if (result == (off_t)-1) { if (lpDistanceToMoveHigh) *lpDistanceToMoveHigh = -1; return INVALID_SET_FILE_POINTER; }
if (lpDistanceToMoveHigh) *lpDistanceToMoveHigh = (LONG)(result >> 32);
return (DWORD)(result & 0xFFFFFFFF);
}
static inline DWORD GetFileAttributesA(const char *lpFileName)
{
struct stat st{};
if (stat(lpFileName, &st) != 0) return INVALID_FILE_ATTRIBUTES;
DWORD attrs = S_ISDIR(st.st_mode) ? FILE_ATTRIBUTE_DIRECTORY : FILE_ATTRIBUTE_NORMAL;
if (!(st.st_mode & S_IWUSR)) attrs |= FILE_ATTRIBUTE_READONLY;
const char *base = strrchr(lpFileName, '/'); base = base ? base + 1 : lpFileName;
if (base[0] == '.') attrs |= FILE_ATTRIBUTE_HIDDEN;
return attrs;
}
static inline DWORD GetFileAttributes(const char *lpFileName)
{
return GetFileAttributesA(lpFileName);
}
static inline BOOL GetFileAttributesExA(const char *lpFileName, GET_FILEEX_INFO_LEVELS fInfoLevelId, void *lpFileInformation)
{
if (fInfoLevelId != GetFileExInfoStandard || !lpFileInformation) return FALSE;
struct stat st{};
if (stat(lpFileName, &st) != 0) return FALSE;
WIN32_FILE_ATTRIBUTE_DATA *out = (WIN32_FILE_ATTRIBUTE_DATA *)lpFileInformation;
out->dwFileAttributes = GetFileAttributesA(lpFileName);
out->ftCreationTime = _TimeToFileTime(st.st_mtime);
out->ftLastAccessTime = _TimeToFileTime(st.st_atime);
out->ftLastWriteTime = _TimeToFileTime(st.st_mtime);
out->nFileSizeHigh = (DWORD)((st.st_size >> 32) & 0xFFFFFFFF);
out->nFileSizeLow = (DWORD)(st.st_size & 0xFFFFFFFF);
return TRUE;
}
static inline BOOL GetFileAttributesEx(const char *lpFileName, GET_FILEEX_INFO_LEVELS fInfoLevelId, void *lpFileInformation)
{
return GetFileAttributesExA(lpFileName, fInfoLevelId, lpFileInformation);
}
static inline BOOL CreateDirectoryA(const char *lpPathName, void *lpSecurityAttributes)
{
return mkdir(lpPathName, 0755) == 0;
}
static inline BOOL CreateDirectory(const char *lpPathName, void *lpSecurityAttributes)
{
return CreateDirectoryA(lpPathName, lpSecurityAttributes);
}
static inline BOOL DeleteFileA(const char *lpFileName)
{
return unlink(lpFileName) == 0;
}
static inline BOOL DeleteFile(const char *lpFileName)
{
return DeleteFileA(lpFileName);
}
static inline BOOL MoveFileA(const char *lpExistingFileName, const char *lpNewFileName)
{
return rename(lpExistingFileName, lpNewFileName) == 0;
}
static inline BOOL MoveFile(const char *lpExistingFileName, const char *lpNewFileName)
{
return MoveFileA(lpExistingFileName, lpNewFileName);
}
// https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-findfirstfilea
static inline HANDLE FindFirstFileA(const char *lpFileName, WIN32_FIND_DATAA *lpFindFileData)
{
if (!lpFileName || !lpFindFileData) return INVALID_HANDLE_VALUE;
char dirpath[MAX_PATH], pattern[MAX_PATH];
const char *sep = strrchr(lpFileName, '/');
if (sep)
{
size_t len = sep - lpFileName;
if (len >= MAX_PATH) return INVALID_HANDLE_VALUE;
strncpy(dirpath, lpFileName, len); dirpath[len] = '\0';
strncpy(pattern, sep + 1, MAX_PATH - 1);
}
else
{
strncpy(dirpath, ".", MAX_PATH - 1);
strncpy(pattern, lpFileName, MAX_PATH - 1);
}
DIR *dir = opendir(dirpath);
if (!dir) return INVALID_HANDLE_VALUE;
_LINUXSTUBS_FIND_HANDLE *fh = (_LINUXSTUBS_FIND_HANDLE *)malloc(sizeof(_LINUXSTUBS_FIND_HANDLE));
if (!fh) { closedir(dir); return INVALID_HANDLE_VALUE; }
fh->dir = dir;
strncpy(fh->dirpath, dirpath, MAX_PATH - 1);
strncpy(fh->pattern, pattern, MAX_PATH - 1);
struct dirent *ent;
while ((ent = readdir(fh->dir)) != NULL)
{
if (strcmp(ent->d_name, ".") == 0 || strcmp(ent->d_name, "..") == 0) continue;
if (fnmatch(fh->pattern, ent->d_name, 0) == 0)
{
char fullpath[MAX_PATH * 2];
snprintf(fullpath, sizeof(fullpath), "%s/%s", fh->dirpath, ent->d_name);
struct stat st{};
if (stat(fullpath, &st) == 0) _FillFindData(ent->d_name, &st, lpFindFileData);
else { memset(lpFindFileData, 0, sizeof(*lpFindFileData)); strncpy(lpFindFileData->cFileName, ent->d_name, MAX_PATH - 1); }
return (HANDLE)fh;
}
}
closedir(fh->dir); free(fh);
return INVALID_HANDLE_VALUE;
}
static inline HANDLE FindFirstFile(const char *lpFileName, WIN32_FIND_DATAA *lpFindFileData)
{
return FindFirstFileA(lpFileName, lpFindFileData);
}
// https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-findnextfilea
static inline BOOL FindNextFileA(HANDLE hFindFile, WIN32_FIND_DATAA *lpFindFileData)
{
if (hFindFile == INVALID_HANDLE_VALUE || !lpFindFileData) return FALSE;
_LINUXSTUBS_FIND_HANDLE *fh = (_LINUXSTUBS_FIND_HANDLE *)hFindFile;
struct dirent *ent;
while ((ent = readdir(fh->dir)) != NULL)
{
if (strcmp(ent->d_name, ".") == 0 || strcmp(ent->d_name, "..") == 0) continue;
if (fnmatch(fh->pattern, ent->d_name, 0) == 0)
{
char fullpath[MAX_PATH * 2];
snprintf(fullpath, sizeof(fullpath), "%s/%s", fh->dirpath, ent->d_name);
struct stat st{};
if (stat(fullpath, &st) == 0) _FillFindData(ent->d_name, &st, lpFindFileData);
else { memset(lpFindFileData, 0, sizeof(*lpFindFileData)); strncpy(lpFindFileData->cFileName, ent->d_name, MAX_PATH - 1); }
return TRUE;
}
}
return FALSE;
}
static inline BOOL FindNextFile(HANDLE hFindFile, WIN32_FIND_DATAA *lpFindFileData)
{
return FindNextFileA(hFindFile, lpFindFileData);
}
// https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-findclose
static inline BOOL FindClose(HANDLE hFindFile)
{
if (hFindFile == INVALID_HANDLE_VALUE) return FALSE;
_LINUXSTUBS_FIND_HANDLE *fh = (_LINUXSTUBS_FIND_HANDLE *)hFindFile;
closedir(fh->dir); free(fh);
return TRUE;
}
// internal helper: convert FILETIME (100ns since 1601) to time_t (seconds since 1970)
static inline time_t _FileTimeToTimeT(const FILETIME& ft)
{
ULONGLONG val = ((ULONGLONG)ft.dwHighDateTime << 32) | ft.dwLowDateTime;
const ULONGLONG EPOCH_DIFF = 116444736000000000ULL; // 100ns intervals between 1601-01-01 and 1970-01-01
return (time_t)((val - EPOCH_DIFF) / 10000000ULL);
}
// internal helper: read the current wall clock into a timespec
static inline void _CurrentTimeSpec(struct timespec *ts)
{
#ifdef CLOCK_REALTIME
clock_gettime(CLOCK_REALTIME, ts);
#else
struct timeval tv;
gettimeofday(&tv, NULL);
ts->tv_sec = tv.tv_sec;
ts->tv_nsec = tv.tv_usec * 1000;
#endif
}
// internal helper: fill SYSTEMTIME from a broken-down tm + nanosecond remainder
static inline void _FillSystemTime(const struct tm *tm, long tv_nsec, LPSYSTEMTIME lpSystemTime)
{
lpSystemTime->wYear = tm->tm_year + 1900;
lpSystemTime->wMonth = tm->tm_mon + 1;
lpSystemTime->wDayOfWeek = tm->tm_wday; // 0 = Sunday
lpSystemTime->wDay = tm->tm_mday;
lpSystemTime->wHour = tm->tm_hour;
lpSystemTime->wMinute = tm->tm_min;
lpSystemTime->wSecond = tm->tm_sec;
lpSystemTime->wMilliseconds = (WORD)(tv_nsec / 1000000); // ns to ms
}
// https://learn.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-getsystemtime
static inline VOID GetSystemTime(LPSYSTEMTIME lpSystemTime)
{
struct timespec ts; _CurrentTimeSpec(&ts);
struct tm tm; gmtime_r(&ts.tv_sec, &tm); // UTC
_FillSystemTime(&tm, ts.tv_nsec, lpSystemTime);
}
// https://learn.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-getlocaltime
static inline VOID GetLocalTime(LPSYSTEMTIME lpSystemTime)
{
struct timespec ts; _CurrentTimeSpec(&ts);
struct tm tm; localtime_r(&ts.tv_sec, &tm); // local time
_FillSystemTime(&tm, ts.tv_nsec, lpSystemTime);
}
// https://learn.microsoft.com/en-us/windows/win32/api/timezoneapi/nf-timezoneapi-systemtimetofiletime
static inline BOOL SystemTimeToFileTime(const SYSTEMTIME *lpSystemTime, LPFILETIME lpFileTime)
{
struct tm tm = {};
tm.tm_year = lpSystemTime->wYear - 1900;
tm.tm_mon = lpSystemTime->wMonth - 1;
tm.tm_mday = lpSystemTime->wDay;
tm.tm_hour = lpSystemTime->wHour;
tm.tm_min = lpSystemTime->wMinute;
tm.tm_sec = lpSystemTime->wSecond;
time_t t = timegm(&tm);
if (t == (time_t)-1) return FALSE;
ULONGLONG ft = ((ULONGLONG)t + 11644473600ULL) * 10000000ULL;
ft += lpSystemTime->wMilliseconds * 10000ULL;
lpFileTime->dwLowDateTime = (DWORD)(ft & 0xFFFFFFFF);
lpFileTime->dwHighDateTime = (DWORD)(ft >> 32);
return TRUE;
}
// https://learn.microsoft.com/en-us/windows/win32/api/timezoneapi/nf-timezoneapi-filetimetosystemtime
static inline BOOL FileTimeToSystemTime(const FILETIME *lpFileTime, LPSYSTEMTIME lpSystemTime)
{
ULONGLONG ft = ((ULONGLONG)lpFileTime->dwHighDateTime << 32) | lpFileTime->dwLowDateTime;
time_t t = _FileTimeToTimeT(*lpFileTime);
long remainder_ns = (long)((ft % 10000000ULL) * 100);
struct tm tm; gmtime_r(&t, &tm); // UTC
_FillSystemTime(&tm, remainder_ns, lpSystemTime);
return TRUE;
}
static inline DWORD GetTickCount()
{
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
// milliseconds
return (long long)ts.tv_sec * 1000 + (long long)ts.tv_nsec / 1000000;
}
static inline BOOL QueryPerformanceFrequency(LARGE_INTEGER *lpFrequency)
{
// nanoseconds
lpFrequency->QuadPart = 1000000000;
return false;
}
static inline BOOL QueryPerformanceCounter(LARGE_INTEGER *lpPerformanceCount)
{
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
// nanoseconds
lpPerformanceCount->QuadPart = ((long long)ts.tv_sec * 1000000000) + (long long)ts.tv_nsec;
return true;
}
// https://learn.microsoft.com/en-us/windows/win32/api/debugapi/nf-debugapi-outputdebugstringa
static inline VOID OutputDebugStringA(LPCSTR lpOutputString)
{
if (!lpOutputString) return;
fputs(lpOutputString, stderr);
}
// https://learn.microsoft.com/en-us/windows/win32/api/debugapi/nf-debugapi-outputdebugstringw
static inline VOID OutputDebugStringW(LPCWSTR lpOutputString)
{
if (!lpOutputString) return;
fprintf(stderr, "%ls", lpOutputString);
}
static inline VOID OutputDebugString(LPCSTR lpOutputString)
{
return OutputDebugStringA(lpOutputString);
}
typedef struct {
pthread_mutex_t mutex;
pthread_cond_t cond;
int signaled;
int manual_reset;
} Event;
HANDLE CreateEvent(int manual_reset, int initial_state) {
Event* ev = (Event*)malloc(sizeof(Event));
pthread_mutex_init(&ev->mutex, NULL);
pthread_cond_init(&ev->cond, NULL);
ev->signaled = initial_state;
ev->manual_reset = manual_reset;
return (HANDLE)ev;
}
#endif // LINUXSTUBS_H

View file

@ -42,7 +42,7 @@ typedef long long int int64;
#define XDEVICE_PORT1 1
#define XDEVICE_PORT2 2
#define XDEVICE_PORT3 3
#define XUSER_MAX_COUNT 4
// #define XUSER_MAX_COUNT 4
#define XUSER_INDEX_NONE 0x000000FE
#define XBX_CLR_DEFAULT 0xFF000000
@ -157,8 +157,8 @@ FORCEINLINE void XBX_SetStorageDeviceId( DWORD idx ) {}
FORCEINLINE const char *XBX_GetLanguageString() { return ""; }
FORCEINLINE bool XBX_IsLocalized() { return false; }
#define XCONTENT_MAX_DISPLAYNAME_LENGTH 128
#define XCONTENT_MAX_FILENAME_LENGTH 42
// #define XCONTENT_MAX_DISPLAYNAME_LENGTH 128
// #define XCONTENT_MAX_FILENAME_LENGTH 42
#define XBX_INVALID_STORAGE_ID ((DWORD) -1)
#define XBX_STORAGE_DECLINED ((DWORD) -2)

View file

@ -1,6 +1,7 @@
#include "stdafx.h"
#include "PS3LeaderboardManager.h"
#include "../../../Minecraft.World/x64headers/extraX64.h"
#include "base64.h"

View file

@ -1,7 +1,6 @@
#pragma once
#include "../../Common/Leaderboards/LeaderboardManager.h"
#include "../../../Minecraft.World/x64headers/extraX64.h"
#include "PS3/Passphrase/ps3__np_conf.h"

View file

@ -7,7 +7,11 @@
#ifndef _SOCIAL_MANAGER_H
#define _SOCIAL_MANAGER_H
#ifndef __linux__
#include <xsocialpost.h>
#endif // __linux__#ifndef __linux__
#include <xsocialpost.h>
#endif // __linux__
#define MAX_SOCIALPOST_CAPTION 60
#define MAX_SOCIALPOST_DESC 100

View file

@ -8,7 +8,7 @@
#define IggyVersion "1.2.30"
#define IggyFlashVersion "9,1,2,30"
#include "rrcore.h" // base data types, macros
#include "rrCore.h" // base data types, macros
RADDEFSTART

View file

@ -7,7 +7,9 @@
#ifndef _SOCIAL_MANAGER_H
#define _SOCIAL_MANAGER_H
#ifndef __linux__
#include <xsocialpost.h>
#endif // __linux__
#define MAX_SOCIALPOST_CAPTION 60
#define MAX_SOCIALPOST_DESC 100

View file

@ -54,6 +54,15 @@
#include "PSVitaTypes.h"
#include "PSVitaStubs.h"
#include "PSVitaMaths.h"
#elif defined __linux__
#define AUTO_VAR(_var, _val) auto _var = _val
#include <stdio.h>
#include <stdlib.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include "Linux/LinuxStubs.h"
#include "Linux/xbox_valve.h"
#else
#define AUTO_VAR(_var, _val) auto _var = _val
#include <unordered_map>
@ -109,7 +118,7 @@ typedef XUID GameSessionUID;
#include "../Minecraft.Client/xbox/network/extra.h"
#else
#include "extraX64.h"
#include "../Minecraft.World/x64headers/extraX64.h"
#endif
#ifdef __PS3__
@ -149,7 +158,7 @@ typedef XUID GameSessionUID;
#endif
#include "../Minecraft.World/Definitions.h"
#include "../Minecraft.World/class.h"
#include "../Minecraft.World/Class.h"
#include "../Minecraft.World/ArrayWithLength.h"
#include "../Minecraft.World/SharedConstants.h"
#include "../Minecraft.World/Random.h"
@ -178,6 +187,12 @@ typedef XUID GameSessionUID;
#include "Windows64/4JLibs/inc/4J_Profile.h"
#include "Windows64/4JLibs/inc/4J_Render.h"
#include "Windows64/4JLibs/inc/4J_Storage.h"
#elif defined __linux__
// draw the rest of the owl
#include "Windows64/4JLibs/inc/4J_Input.h"
#include "Windows64/4JLibs/inc/4J_Profile.h"
#include "Windows64/4JLibs/inc/4J_Render.h"
#include "Windows64/4JLibs/inc/4J_Storage.h"
#elif defined __PSVITA__
#include "PSVita/4JLibs/inc/4J_Input.h"
#include "PSVita/4JLibs/inc/4J_Profile.h"
@ -211,7 +226,7 @@ typedef XUID GameSessionUID;
#include "Common/UI/UIEnums.h"
#include "Common/UI/UIStructs.h"
// #ifdef _XBOX
#include "Common/App_defines.h"
#include "Common/App_Defines.h"
#include "Common/App_enums.h"
#include "Common/Tutorial/TutorialEnum.h"
#include "Common/App_structs.h"
@ -280,18 +295,19 @@ typedef XUID GameSessionUID;
#include "Windows64/Iggy/gdraw/gdraw_d3d11.h"
#include "Windows64/Windows64_UIController.h"
#elif defined __linux__
// #include "Windows64/Sentient/MinecraftTelemetry.h"
// FIXME: Make Linux/ versions of all of these
// #include "Windows64/Sentient/MinecraftTelemetry.h" // conflicts with Common/Telemetry/TelemetryManager.h, no idea whats up with that
#include "Windows64Media/strings.h"
// #include "Windows64/Windows64_App.h"
// #include "Windows64/Sentient/DynamicConfigurations.h"
// #include "Windows64/Sentient/SentientTelemetryCommon.h"
// #include "Windows64/GameConfig/Minecraft.spa.h"
// #include "Windows64/XML/ATGXmlParser.h"
// #include "Windows64/Social/SocialManager.h"
// #include "Common/Audio/SoundEngine.h"
// #include "Windows64/Iggy/include/iggy.h"
// #include "Windows64/Iggy/gdraw/gdraw_d3d11.h"
// #include "Windows64/Windows64_UIController.h"
#include "Windows64/Windows64_App.h"
#include "Windows64/Sentient/DynamicConfigurations.h"
#include "Windows64/Sentient/SentientTelemetryCommon.h"
#include "Windows64/GameConfig/Minecraft.spa.h"
#include "Windows64/XML/ATGXmlParser.h"
#include "Windows64/Social/SocialManager.h"
#include "Common/Audio/SoundEngine.h"
#include "Windows64/Iggy/include/iggy.h"
#include "Windows64/Iggy/gdraw/gdraw_d3d11.h"
#include "Windows64/Windows64_UIController.h"
#elif defined __PSVITA__
#include "PSVita/PSVita_App.h"
#include "PSVitaMedia/strings.h" // TODO - create PSVita-specific version of this

View file

@ -2,7 +2,7 @@
#include "net.minecraft.world.level.levelgen.h"
#include "net.minecraft.world.level.h"
#include "net.minecraft.world.level.storage.h"
#include "dimension.h"
#include "Dimension.h"
#include "BiomeSource.h"
#include "FixedBiomeSource.h"
#include "OldChunkStorage.h"

View file

@ -3,7 +3,6 @@
#include "InputOutputStream.h"
#include "PacketListener.h"
#include "GameEventPacket.h"
#include "../Minecraft.Client/PS3Media/strings.h"
const int GameEventPacket::NO_RESPAWN_BED_AVAILABLE = 0;

View file

@ -65,7 +65,7 @@ File OldChunkStorage::getFile(int x, int z)
wchar_t xRadix36[64];
wchar_t zRadix36[64];
#if ( defined __PS3__ || defined __ORBIS__ || defined __PSVITA__ )
#if ( defined __PS3__ || defined __ORBIS__ || defined __PSVITA__ || defined __linux__ )
assert(0); // need a gcc verison of _itow ?
#else
_itow(x,xRadix36,36);

View file

@ -1,7 +1,7 @@
#include "stdafx.h"
#include "net.minecraft.world.entity.h"
#include "net.minecraft.world.level.pathfinder.h"
#include "path.h"
#include "Path.h"
Path::~Path()
{

View file

@ -407,7 +407,7 @@ void SparseDataStorage::addNewPlane(int y)
// Attempt to update the data & count atomically. This command will Only succeed if the data stored at
// dataAndCount is equal to lastDataAndCount, and will return the value present just before the write took place
__int64 lastDataAndCount2 = InterlockedCompareExchangeRelease64( &dataAndCount, newDataAndCount, lastDataAndCount );
__int64 lastDataAndCount2 = InterlockedCompareExchangeRelease64( (LONG64 *)&dataAndCount, newDataAndCount, lastDataAndCount );
if( lastDataAndCount2 == lastDataAndCount )
{
@ -485,7 +485,7 @@ void SparseDataStorage::updateDataAndCount(__int64 newDataAndCount)
// Attempt to update the data & count atomically. This command will Only succeed if the data stored at
// dataAndCount is equal to lastDataAndCount, and will return the value present just before the write took place
__int64 lastDataAndCount2 = InterlockedCompareExchangeRelease64( &dataAndCount, newDataAndCount, lastDataAndCount );
__int64 lastDataAndCount2 = InterlockedCompareExchangeRelease64( (LONG64 *)&dataAndCount, newDataAndCount, lastDataAndCount );
if( lastDataAndCount2 == lastDataAndCount )
{
@ -564,7 +564,7 @@ int SparseDataStorage::compress()
// Attempt to update the data & count atomically. This command will Only succeed if the data stored at
// dataAndCount is equal to lastDataAndCount, and will return the value present just before the write took place
__int64 lastDataAndCount2 = InterlockedCompareExchangeRelease64( &dataAndCount, newDataAndCount, lastDataAndCount );
__int64 lastDataAndCount2 = InterlockedCompareExchangeRelease64( (LONG64 *)&dataAndCount, newDataAndCount, lastDataAndCount );
if( lastDataAndCount2 != lastDataAndCount )
{

View file

@ -1,5 +1,7 @@
#pragma once
#ifndef __linux__
#include "xmcore.h"
#endif // __linux__
// 4J added - Storage for data (ie the extra per tile storage). Data is normally stored as 4-bits per tile, in a DataLayer class of 16384 bytes ( 128 x 16 x 16 x 0.5 )
// This class provides more economical storage for such data by taking into consideration that it is quite common for large parts of the data to be very compressible (ie zero).

View file

@ -413,7 +413,7 @@ void SparseLightStorage::addNewPlane(int y)
// Attempt to update the data & count atomically. This command will Only succeed if the data stored at
// dataAndCount is equal to lastDataAndCount, and will return the value present just before the write took place
__int64 lastDataAndCount2 = InterlockedCompareExchangeRelease64( &dataAndCount, newDataAndCount, lastDataAndCount );
__int64 lastDataAndCount2 = InterlockedCompareExchangeRelease64( (LONG64 *)&dataAndCount, newDataAndCount, lastDataAndCount );
if( lastDataAndCount2 == lastDataAndCount )
{
@ -491,7 +491,7 @@ void SparseLightStorage::updateDataAndCount(__int64 newDataAndCount)
// Attempt to update the data & count atomically. This command will Only succeed if the data stored at
// dataAndCount is equal to lastDataAndCount, and will return the value present just before the write took place
__int64 lastDataAndCount2 = InterlockedCompareExchangeRelease64( &dataAndCount, newDataAndCount, lastDataAndCount );
__int64 lastDataAndCount2 = InterlockedCompareExchangeRelease64( (LONG64 *)&dataAndCount, newDataAndCount, lastDataAndCount );
if( lastDataAndCount2 == lastDataAndCount )
{
@ -581,7 +581,7 @@ int SparseLightStorage::compress()
// Attempt to update the data & count atomically. This command will Only succeed if the data stored at
// dataAndCount is equal to lastDataAndCount, and will return the value present just before the write took place
__int64 lastDataAndCount2 = InterlockedCompareExchangeRelease64( &dataAndCount, newDataAndCount, lastDataAndCount );
__int64 lastDataAndCount2 = InterlockedCompareExchangeRelease64( (LONG64 *)&dataAndCount, newDataAndCount, lastDataAndCount );
if( lastDataAndCount2 != lastDataAndCount )
{

View file

@ -1,7 +1,7 @@
#include "stdafx.h"
#include "WoodSlabTile.h"
#include "woodtile.h"
#include "treetile.h"
#include "WoodTile.h"
#include "TreeTile.h"
#include "net.minecraft.world.level.h"
#include "net.minecraft.world.level.biome.h"
#include "net.minecraft.world.item.h"

View file

@ -1,66 +0,0 @@
#ifndef WLINUX_H
#define WLINUX_H
#pragma once
#include <cstdint>
#include <cstring>
#include <string>
#define TRUE true
#define FALSE false
#define RtlZeroMemory(Destination,Length) memset((Destination),0,(Length))
#define ZeroMemory RtlZeroMemory
#define WINAPI
typedef unsigned int DWORD;
typedef const char *LPCSTR;
typedef bool BOOL;
typedef void* LPVOID;
typedef char WCHAR;
typedef unsigned char BYTE;
typedef BYTE* PBYTE;
typedef const wchar_t* LPCWSTR;
typedef unsigned long long ULONGLONG;
typedef int HRESULT;
typedef unsigned int UINT;
typedef void* HANDLE;
typedef int INT;
typedef long* PLONG;
typedef unsigned int* LPDWORD;
typedef const void* LPCVOID;
typedef char CHAR;
typedef void* PVOID;
typedef unsigned long* ULONG_PTR;
typedef long LONG;
typedef void VOID;
typedef ULONGLONG PlayerUID;
typedef DWORD WORD;
typedef struct {
DWORD LowPart;
long long QuadPart;
LONG HighPart;
} LARGE_INTEGER;
typedef long long LONGLONG;
typedef size_t SIZE_T;
typedef std::wstring LPWSTR;
typedef unsigned char boolean; // java brainrot
// https://learn.microsoft.com/en-us/windows/win32/api/minwinbase/ns-minwinbase-filetime
typedef struct _FILETIME {
DWORD dwLowDateTime;
DWORD dwHighDateTime;
} FILETIME, *PFILETIME, *LPFILETIME;
#define FILE_BEGIN SEEK_SET
typedef short SHORT;
typedef VOID* XMEMCOMPRESSION_CONTEXT;
typedef VOID* XMEMDECOMPRESSION_CONTEXT;
typedef float FLOAT;
#include "../x64headers/extraX64.h"
#endif // WLINUX_H

View file

@ -9,12 +9,8 @@
#define AUTO_VAR(_var, _val) auto _var = _val
#endif
typedef unsigned __int64;
typedef unsigned __uint64;
#if defined( __linux__ )
#include "linux/wlinux.h"
#include "linux/xbox_valve.h"
#if ( defined _XBOX || defined _WINDOWS64 || defined _DURANGO )
typedef unsigned __int64 __uint64;
#endif
#ifdef _WINDOWS64
@ -98,6 +94,9 @@ typedef XUID GameSessionUID;
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include "../Minecraft.Client/Linux/LinuxStubs.h"
#include "../Minecraft.Client/Linux/xbox_valve.h"
#else
#include <unordered_map>
#include <unordered_set>
@ -126,11 +125,6 @@ typedef XUID GameSessionUID;
#include <assert.h>
#endif
#if defined(__linux__)
#else
#include "../Minecraft.Client/Xbox/Network/extra.h"
#endif
#include "Definitions.h"
#include "Class.h"
#include "Exceptions.h"
@ -183,6 +177,7 @@ void MemSect(int sect);
#include "../Minecraft.Client/PSVita/4JLibs/inc/4J_Storage.h"
#include "../Minecraft.Client/PSVita/4JLibs/inc/4J_Input.h"
#elif defined __linux__
// FIXME: Port 4JLibs to POSIX
#include "../Minecraft.Client/Windows64/4JLibs/inc/4J_Profile.h"
#include "../Minecraft.Client/Windows64/4JLibs/inc/4J_Render.h"
#include "../Minecraft.Client/Windows64/4JLibs/inc/4J_Storage.h"
@ -246,6 +241,7 @@ void MemSect(int sect);
#include "../Minecraft.Client/PSVita/Sentient/SentientManager.h"
#include "../Minecraft.Client/PSVita/Sentient/MinecraftTelemetry.h"
#elif defined(__linux__)
// FIXME: Move and port to ../Minecraft.Client/Linux
#include "../Minecraft.Client/Windows64/Windows64_App.h"
#include "../Minecraft.Client/Windows64Media/strings.h"
#include "../Minecraft.Client/Windows64/Sentient/SentientTelemetryCommon.h"

View file

@ -23,44 +23,6 @@ const int XUSER_MAX_COUNT = 4;
const int MINECRAFT_NET_MAX_PLAYERS = 8;
#endif
#if defined(__linux__)
typedef struct _RTL_CRITICAL_SECTION {
// //
// // The following field is used for blocking when there is contention for
// // the resource
// //
//
union {
ULONG_PTR RawEvent[4];
} Synchronization;
//
// //
// // The following three fields control entering and exiting the critical
// // section for the resource
// //
//
LONG LockCount;
LONG RecursionCount;
HANDLE OwningThread;
} RTL_CRITICAL_SECTION, *PRTL_CRITICAL_SECTION;
typedef RTL_CRITICAL_SECTION CRITICAL_SECTION;
inline void DeleteCriticalSection(CRITICAL_SECTION* stubEnterCS)
{
}
inline void EnterCriticalSection(CRITICAL_SECTION* stubEnterCS)
{
}
inline void LeaveCriticalSection( CRITICAL_SECTION* stubEnterCS)
{
}
#endif // __linux__
#ifdef __ORBIS__
#include <net.h>
#include <np/np_npid.h>