mirror of
https://github.com/ValveSoftware/GameNetworkingSockets.git
synced 2026-05-29 16:20:34 +00:00
MinGW build fixes
These changes compile and link, but they probably crash or something right now. We need to get a unit test or three into the repo so we can vet changes like this. Signed-off-by: Steven Noonan <steven@valvesoftware.com>
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
typedef unsigned char uint8;
|
||||
#endif
|
||||
|
||||
#if defined( __GNUC__ ) && !defined(POSIX)
|
||||
#if defined( __GNUC__ ) && !defined(_WIN32) && !defined(POSIX)
|
||||
#if __GNUC__ < 4
|
||||
#error "Steamworks requires GCC 4.X (4.2 or 4.4 have been tested)"
|
||||
#endif
|
||||
@@ -36,7 +36,7 @@ typedef unsigned char uint8;
|
||||
typedef unsigned char uint8;
|
||||
typedef signed char int8;
|
||||
|
||||
#if defined( _WIN32 )
|
||||
#if defined( _WIN32 ) && !defined( GNU_COMPILER )
|
||||
|
||||
typedef __int16 int16;
|
||||
typedef unsigned __int16 uint16;
|
||||
|
||||
+10
-5
@@ -6,6 +6,11 @@
|
||||
// on compile-time defines, which in turn pulls in other odd dependencies
|
||||
|
||||
#if defined(_WIN32)
|
||||
#ifdef __MINGW32__
|
||||
// x86intrin.h gets included by MinGW's winnt.h, so defining this avoids
|
||||
// redefinition of AES-NI intrinsics below
|
||||
#define _X86INTRIN_H_INCLUDED
|
||||
#endif
|
||||
#include "winlite.h"
|
||||
#elif defined(POSIX)
|
||||
#include <sys/types.h>
|
||||
@@ -399,10 +404,10 @@ void DispatchOpenSSLErrors( const char * contextMessage )
|
||||
#include <emmintrin.h>
|
||||
// stupid: can't use wmmintrin.h on gcc/clang, requires AESNI codegen to be globally enabled!
|
||||
#if defined(__clang__) || defined(__GNUC__)
|
||||
static FORCEINLINE __m128i _mm_aesenc_si128( __m128i a, __m128i b ) { asm( "aesenc %1, %0" : "+x"(a) : "x"(b) ); return a; }
|
||||
static FORCEINLINE __m128i _mm_aesenclast_si128( __m128i a, __m128i b ) { asm( "aesenclast %1, %0" : "+x"(a) : "x"(b) ); return a; }
|
||||
static FORCEINLINE __m128i _mm_aesdec_si128( __m128i a, __m128i b ) { asm( "aesdec %1, %0" : "+x"(a) : "x"(b) ); return a; }
|
||||
static FORCEINLINE __m128i _mm_aesdeclast_si128( __m128i a, __m128i b ) { asm( "aesdeclast %1, %0" : "+x"(a) : "x"(b) ); return a; }
|
||||
static FORCEINLINE __attribute__((gnu_inline)) __m128i _mm_aesenc_si128( __m128i a, __m128i b ) { asm( "aesenc %1, %0" : "+x"(a) : "x"(b) ); return a; }
|
||||
static FORCEINLINE __attribute__((gnu_inline)) __m128i _mm_aesenclast_si128( __m128i a, __m128i b ) { asm( "aesenclast %1, %0" : "+x"(a) : "x"(b) ); return a; }
|
||||
static FORCEINLINE __attribute__((gnu_inline)) __m128i _mm_aesdec_si128( __m128i a, __m128i b ) { asm( "aesdec %1, %0" : "+x"(a) : "x"(b) ); return a; }
|
||||
static FORCEINLINE __attribute__((gnu_inline)) __m128i _mm_aesdeclast_si128( __m128i a, __m128i b ) { asm( "aesdeclast %1, %0" : "+x"(a) : "x"(b) ); return a; }
|
||||
#else
|
||||
#include <wmmintrin.h>
|
||||
#endif
|
||||
@@ -3082,7 +3087,7 @@ bool CCrypto::GenerateRandomBlock( void *pvDest, int cubDest )
|
||||
// NOTE: assume that this cannot fail. MS has baked this function name into
|
||||
// static CRT runtime libraries for years; changing the export would break
|
||||
// millions of applications. Available from Windows XP onward. -henryg
|
||||
typedef BYTE ( NTAPI *PfnRtlGenRandom_t )( __out_bcount( RandomBufferLength ) PVOID RandomBuffer, __in ULONG RandomBufferLength );
|
||||
typedef BYTE ( NTAPI *PfnRtlGenRandom_t )( PVOID RandomBuffer, ULONG RandomBufferLength );
|
||||
static PfnRtlGenRandom_t s_pfnRtlGenRandom;
|
||||
if ( !s_pfnRtlGenRandom )
|
||||
{
|
||||
|
||||
+24
-13
@@ -24,7 +24,6 @@ dependencies += [
|
||||
incdirs = include_directories('.', '../include', 'common', 'public')
|
||||
|
||||
flags_common = [
|
||||
'-fstack-protector-strong',
|
||||
'-fno-strict-aliasing',
|
||||
]
|
||||
|
||||
@@ -47,6 +46,8 @@ warn_flags_cxx = [
|
||||
|
||||
cpp_flags = [
|
||||
'-DSTEAMNETWORKINGSOCKETS_OPENSOURCE',
|
||||
'-DSTEAMDATAGRAMLIB_FOREXPORT',
|
||||
'-DSTATIC_TIER0',
|
||||
|
||||
# needed for ed25519-donna
|
||||
'-DENABLE_CRYPTO_25519',
|
||||
@@ -55,6 +56,28 @@ cpp_flags = [
|
||||
'-DCRYPTO_DISABLE_ENCRYPT_WITH_PASSWORD',
|
||||
]
|
||||
|
||||
target_os = target_machine.system()
|
||||
|
||||
if target_os == 'linux'
|
||||
cpp_flags += ['-DPOSIX', '-DLINUX']
|
||||
elif target_os == 'darwin'
|
||||
cpp_flags += ['-DPOSIX', '-DOSX']
|
||||
elif target_os == 'windows'
|
||||
cpp_flags += ['-D_WIN32', '-DWIN32', '-D__STDC_FORMAT_MACROS=1', '-D__USE_MINGW_ANSI_STDIO=0']
|
||||
flags_common += [
|
||||
'-fno-stack-protector',
|
||||
]
|
||||
dependencies += [
|
||||
c_compiler.find_library('ws2_32'),
|
||||
]
|
||||
else
|
||||
error('Could not identify your target operating system')
|
||||
endif
|
||||
|
||||
if target_os != 'windows'
|
||||
flags_common += [ '-fstack-protector-strong' ]
|
||||
endif
|
||||
|
||||
c_flags = []
|
||||
foreach arg : warn_flags_c + flags_common + warn_flags_common
|
||||
if c_compiler.has_argument(arg)
|
||||
@@ -70,18 +93,6 @@ foreach arg : warn_flags_cxx + flags_common + warn_flags_common
|
||||
endif
|
||||
endforeach
|
||||
|
||||
target_os = target_machine.system()
|
||||
|
||||
if target_os == 'linux'
|
||||
cpp_flags += ['-DPOSIX', '-DLINUX']
|
||||
elif target_os == 'darwin'
|
||||
cpp_flags += ['-DPOSIX', '-DOSX']
|
||||
elif target_os == 'windows'
|
||||
cpp_flags += ['-D_WIN32']
|
||||
else
|
||||
error('Could not identify your target operating system')
|
||||
endif
|
||||
|
||||
target_compiler = c_compiler.get_id()
|
||||
if target_compiler == 'gcc' or target_compiler == 'clang'
|
||||
cpp_flags += ['-DGNUC', '-DGNU_COMPILER']
|
||||
|
||||
@@ -143,7 +143,9 @@
|
||||
|
||||
// Tag the end of functions using printf-style format strings with this (consumed by GCC).
|
||||
// Note that for methods the 'this' pointer counts as the first argument in argument numbering.
|
||||
#ifdef COMPILER_GCC
|
||||
#ifdef __MINGW32__
|
||||
#define FMTFUNCTION( fmtargnumber, firstvarargnumber ) __attribute__ (( format( __MINGW_PRINTF_FORMAT, fmtargnumber, firstvarargnumber )))
|
||||
#elif defined(COMPILER_GCC)
|
||||
#define FMTFUNCTION( fmtargnumber, firstvarargnumber ) __attribute__ (( format( __printf__, fmtargnumber, firstvarargnumber )))
|
||||
#else
|
||||
#define FMTFUNCTION( fmtargnumber, firstvarargnumber )
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "minbase_identify.h"
|
||||
#include "minbase_common_errors.h"
|
||||
#include "errno.h"
|
||||
#include "winlite.h"
|
||||
|
||||
ECommonError TranslateCommonErrno()
|
||||
{
|
||||
|
||||
@@ -176,6 +176,10 @@
|
||||
#define DLL_GLOBAL_IMPORT extern PLAT_DECL_IMPORT
|
||||
#endif
|
||||
|
||||
#ifdef FASTCALL
|
||||
#undef FASTCALL
|
||||
#endif
|
||||
|
||||
// Used for standard calling conventions
|
||||
#if defined(_WIN32)
|
||||
#define STDCALL __stdcall
|
||||
|
||||
@@ -240,6 +240,7 @@ extern "C++" // templates cannot be declared to have 'C' linkage
|
||||
template <typename T, size_t N>
|
||||
char (*RtlpNumberOf( UNALIGNED T (&)[N] ))[N];
|
||||
|
||||
#ifndef RTL_NUMBER_OF_V2
|
||||
#ifdef _PREFAST_
|
||||
// The +0 is so that we can go:
|
||||
// size = ARRAYSIZE(array) * sizeof(array[0]) without triggering a /analyze
|
||||
@@ -248,6 +249,7 @@ char (*RtlpNumberOf( UNALIGNED T (&)[N] ))[N];
|
||||
#else
|
||||
#define RTL_NUMBER_OF_V2(A) (sizeof(*RtlpNumberOf(A)))
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#elif defined(LINUX)
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ typedef unsigned int uint;
|
||||
typedef float float32;
|
||||
typedef double float64;
|
||||
|
||||
#if defined( _WIN32 )
|
||||
#if defined( _WIN32 ) && !defined(GNU_COMPILER)
|
||||
|
||||
typedef __int16 int16;
|
||||
typedef unsigned __int16 uint16;
|
||||
@@ -75,7 +75,7 @@ typedef uint32 uint32_t;
|
||||
// NOTE: int64_t must match the compiler stdint.h definition
|
||||
// and so may not match the Steam int64. Mixing the two is
|
||||
// error-prone so always use the Steam non-_t types in Steam code.
|
||||
#if defined(COMPILER_GCC) && defined(PLATFORM_64BITS) && !defined(OSX) && !(defined(IOS) || defined(TVOS))
|
||||
#if 0 && defined(COMPILER_GCC) && defined(PLATFORM_64BITS) && !defined(OSX) && !(defined(IOS) || defined(TVOS))
|
||||
#define INT64_DIFFERENT_FROM_INT64_T 1
|
||||
typedef long int int64_t;
|
||||
typedef unsigned long int uint64_t;
|
||||
|
||||
@@ -402,7 +402,7 @@ I CUtlLinkedList<T,I>::AllocInternal( bool multilist )
|
||||
|
||||
if ( elem == InvalidIndex() )
|
||||
{
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32) && !defined(GNU_COMPILER)
|
||||
Error("%s overflow!\n", typeid(*this).raw_name());
|
||||
#else
|
||||
#if ( !defined(_PS3) || defined(_DEBUG) )
|
||||
|
||||
@@ -11,6 +11,10 @@
|
||||
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#ifdef __MINGW32__
|
||||
// for __MINGW_PRINTF_FORMAT
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
#include <limits.h>
|
||||
#include <stdarg.h>
|
||||
@@ -163,6 +167,9 @@ extern void V_MakeAbsolutePath( OUT_Z_CAP(outLen) char *pOut, int outLen, const
|
||||
#define _wcsnicmp wcsncasecmp
|
||||
#endif
|
||||
#define _wcschr wcschr
|
||||
#ifdef TEXT
|
||||
#undef TEXT
|
||||
#endif
|
||||
#define TEXT(str) str
|
||||
|
||||
#endif // POSIX
|
||||
|
||||
@@ -27,7 +27,9 @@
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#ifndef NOMINMAX
|
||||
#define NOMINMAX
|
||||
#endif
|
||||
#define NOSERVICE
|
||||
#define NOMCX
|
||||
#define NOIME
|
||||
|
||||
@@ -201,7 +201,7 @@ void PrintCertInfo( const CMsgSteamDatagramCertificateSigned &msgSigned, std::st
|
||||
|
||||
if ( pszJSONIndent )
|
||||
{
|
||||
V_sprintf_safe( szTemp, "%s\"key_id\": %llu,\n", pszJSONIndent, CalculatePublicKeyID( pubKey ) );
|
||||
V_sprintf_safe( szTemp, "%s\"key_id\": %" PRIu64 ",\n", pszJSONIndent, CalculatePublicKeyID( pubKey ) );
|
||||
sOutResult += szTemp;
|
||||
if ( !sDataCenterIDs.empty() )
|
||||
{
|
||||
@@ -217,7 +217,7 @@ void PrintCertInfo( const CMsgSteamDatagramCertificateSigned &msgSigned, std::st
|
||||
}
|
||||
else
|
||||
{
|
||||
V_sprintf_safe( szTemp, "Public key ID. . : %llu\n", CalculatePublicKeyID( pubKey ) );
|
||||
V_sprintf_safe( szTemp, "Public key ID. . : %" PRIu64 "\n", CalculatePublicKeyID( pubKey ) );
|
||||
sOutResult += szTemp;
|
||||
V_sprintf_safe( szTemp, "Created. . . . . : %s\n", szTimeCreated );
|
||||
sOutResult += szTemp;
|
||||
|
||||
@@ -1068,7 +1068,7 @@ static void SteamDatagramThreadProc()
|
||||
// we need to take priority above normal threads and wake up immediately
|
||||
// to process the packet. We should be asleep most of the time waiting
|
||||
// for packets to arrive.
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32) && !defined(GNU_COMPILER)
|
||||
DbgVerify( SetThreadPriority( GetCurrentThread(), THREAD_PRIORITY_HIGHEST ) );
|
||||
|
||||
typedef struct tagTHREADNAME_INFO
|
||||
|
||||
@@ -582,7 +582,7 @@ bool V_IsAbsolutePath( const char *pStr )
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
static __success( return != 0 ) DWORD ConvertWideToUTF8( __in_z const wchar_t *pwszNullTerm, __out_ecount_part_z_opt( nMaxOut, return ) char *pchOut, __in DWORD nMaxOut )
|
||||
static DWORD ConvertWideToUTF8( const wchar_t *pwszNullTerm, char *pchOut, DWORD nMaxOut )
|
||||
{
|
||||
if ( !pchOut )
|
||||
return WideCharToMultiByte( CP_UTF8, 0, pwszNullTerm, -1, NULL, 0, NULL, NULL );
|
||||
|
||||
Reference in New Issue
Block a user