1
0
mirror of https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git synced 2025-07-18 11:19:10 +00:00

Remove global Windows.h include

This is the beginning of efforts to reduce the scope of Windows.h. I have
shuttled it into hsWindows.h (again) and fixed the compilation of the
major apps. There is still some scope work that needs to be done, and the
Max plugin has not yet been addressed.
This commit is contained in:
2012-11-17 16:11:17 -05:00
parent 5de87cdaca
commit 7785c9c85e
71 changed files with 223 additions and 151 deletions

View File

@ -83,6 +83,7 @@ set(CoreLib_HEADERS
hsTemplates.h
hsThread.h
hsWide.h
hsWindows.h
pcSmallRect.h
plFileUtils.h
plGeneric.h

View File

@ -40,6 +40,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
*==LICENSE==*/
#include "HeadSpin.h"
#include "hsWindows.h"
#ifdef _MSC_VER
# include <crtdbg.h>

View File

@ -46,6 +46,17 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
# define HS_DEBUGGING
#endif // defined(_DEBUG) || defined(UNIX_DENUG)
//======================================
// Some standard includes
//======================================
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <stdarg.h>
#include <stdint.h>
//======================================
// Winblows Hacks
//======================================
@ -61,67 +72,21 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
# pragma warning( disable : 4305 4503 4018 4786 4284 4800)
# endif // _MSC_VER
// Terrible hacks for MinGW because they don't have a reasonable
// default for the Windows version. We cheat and say it's XP.
# ifdef __MINGW32__
# undef _WIN32_WINNT
# define _WIN32_WINNT 0x501
# undef _WIN32_IE
# define _WIN32_IE 0x400
# endif
// Windows.h includes winsock.h (winsocks 1), so we need to manually include winsock2
// and tell Windows.h to only bring in modern headers
# include <WinSock2.h>
# include <ws2tcpip.h>
# define WIN32_LEAN_AND_MEAN
# ifndef NOMINMAX
# define NOMINMAX // Needed to prevent NxMath conflicts
# endif
# include <Windows.h>
// This needs to be after #include <windows.h>, since it also includes windows.h
# ifdef USE_VLD
# include <vld.h>
# endif
#endif // HS_BUILD_FOR_WIN32
//======================================
// We don't want the Windows.h min/max!
//======================================
#ifdef max
# undef max
#endif
#ifdef min
# undef min
#endif
//======================================
// Some standard includes
//======================================
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <stdarg.h>
#include <stdint.h>
//======================================
// Just some fun typedefs...
//======================================
#ifdef HS_BUILD_FOR_WIN32
// Kind of nasty looking forward declarations, but this is Win32.... it'll never change!
// If you want to argue: would you rather pull in the entire Windows.h? Windows 8 makes it
// even more bloated than before!
struct HWND__; typedef struct HWND__ *HWND;
struct HINSTANCE__; typedef struct HINSTANCE__ *HINSTANCE;
typedef HWND hsWindowHndl;
typedef HINSTANCE hsWindowInst;
typedef HINSTANCE HMODULE;
typedef long HRESULT;
#else
typedef int32_t* hsWindowHndl;
typedef int32_t* hsWindowInst;
#endif // HS_BUILD_FOR_WIN32
//======================================
// Basic macros
//======================================
@ -547,31 +512,16 @@ void DebugMsg(const char fmt[], ...);
/*****************************************************************************
*
* Atomic Operations
* FIXME: Replace with std::atomic when VS2012 supports WinXP
*
***/
// *value += increment; return original value of *value; thread safe
inline long AtomicAdd(long* value, long increment)
{
#ifdef HS_BUILD_FOR_WIN32
return InterlockedExchangeAdd(value, increment);
#ifdef _MSC_VER
# define AtomicAdd(value, increment) InterlockedExchangeAdd(value, increment)
# define AtomicSet(value, set) InterlockedExchange(value, set)
#elif __GNUC__
return __sync_fetch_and_add(value, increment);
#else
# error "No Atomic Set support on this architecture"
# define AtomicAdd(value, increment) __sync_fetch_and_add(value, increment)
# define AtomicSet(value, set) __sync_lock_test_and_set(value, set)
#endif
}
// *value = value; return original value of *value; thread safe
inline long AtomicSet(long* value, long set)
{
#ifdef HS_BUILD_FOR_WIN32
return InterlockedExchange(value, set);
#elif __GNUC__
return __sync_lock_test_and_set(value, set);
#else
# error "No Atomic Set support on this architecture"
#endif
}
#endif

View File

@ -60,10 +60,11 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#ifdef HS_BUILD_FOR_WIN32
typedef CRITICAL_SECTION CritSectHandle;
# include "hsWindows.h"
typedef CRITICAL_SECTION CritSectHandle;
#elif HS_BUILD_FOR_UNIX
# include <pthread.h>
typedef pthread_mutex_t CritSectHandle;
# include <pthread.h>
typedef pthread_mutex_t CritSectHandle;
#else
# error "CCritSect: Not implemented on this platform"
#endif

View File

@ -41,6 +41,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
*==LICENSE==*/
#include "hsFiles.h"
#include "HeadSpin.h"
#include "hsWindows.h"
#if HS_BUILD_FOR_WIN32

View File

@ -46,8 +46,9 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
typedef uint32_t hsMilliseconds;
#ifdef HS_BUILD_FOR_UNIX
#ifdef HS_BUILD_FOR_WIN32
# include "hsWindows.h"
#elif defined(HS_BUILD_FOR_UNIX)
#include <pthread.h>
#include <semaphore.h>
// We can't wait with a timeout with semas

View File

@ -0,0 +1,75 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef _hsWindows_inc_
#define _hsWindows_inc_
/** \file hsWindows.h
* \brief Pulls in Windows core headers
*
* This file pulls in the core Windows headers and Winsock2. It is separate from
* HeadSpin.h to improve build times and to facillitate adding precompiled headers.
* You should avoid including this header from other headers!
*/
#ifdef HS_BUILD_FOR_WIN32
// Terrible hacks for MinGW because they don't have a reasonable
// default for the Windows version. We cheat and say it's XP.
# ifdef __MINGW32__
# undef _WIN32_WINNT
# define _WIN32_WINNT 0x501
# undef _WIN32_IE
# define _WIN32_IE 0x400
# endif
# define NOMINMAX
# define WIN32_LEAN_AND_MEAN
# include <Windows.h>
# include <ws2tcpip.h> // Pulls in WinSock 2 for us
// This needs to be after #include <windows.h>, since it also includes windows.h
# ifdef USE_VLD
# include <vld.h>
# endif // USE_VLD
#endif // HS_BUILD_FOR_WIN32
#endif // _hsWindows_inc_

View File

@ -51,6 +51,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
//////////////////////////////////////////////////////////////////////////////
#include "HeadSpin.h"
#include "hsWindows.h"
#include "hsStlUtils.h"
#include "plFileUtils.h"
#include "hsFiles.h"