summaryrefslogtreecommitdiff
path: root/public/gcsdk/gcsteamdefines.h
diff options
context:
space:
mode:
authorFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
committerFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
commit3bf9df6b2785fa6d951086978a3e66f49427166a (patch)
tree2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /public/gcsdk/gcsteamdefines.h
downloadarchived-source-engine-2018-hl2-src-master.tar.xz
archived-source-engine-2018-hl2-src-master.zip
Diffstat (limited to 'public/gcsdk/gcsteamdefines.h')
-rw-r--r--public/gcsdk/gcsteamdefines.h48
1 files changed, 48 insertions, 0 deletions
diff --git a/public/gcsdk/gcsteamdefines.h b/public/gcsdk/gcsteamdefines.h
new file mode 100644
index 0000000..be9fb29
--- /dev/null
+++ b/public/gcsdk/gcsteamdefines.h
@@ -0,0 +1,48 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose: Defines a bunch of stuff that would be defined in Steam, but
+// isn't in Source.
+//
+//=============================================================================
+
+#ifndef GCSTEAMDEFINES_H
+#define GCSTEAMDEFINES_H
+#ifdef _WIN32
+#pragma once
+#endif
+
+#include "tier0/memalloc.h"
+
+// steam defines some things that games don't
+#ifndef STEAM
+#define PvAlloc(x) malloc(x)
+#define PvRealloc(x, y) realloc(x, y)
+#define FreePv(x) free(x)
+
+// auto-lock class for read-write locks
+template< class T >
+class CRWLockAutoWrite
+{
+ T &m_RWLock;
+public:
+ CRWLockAutoWrite( T &RWLock ) : m_RWLock( RWLock )
+ {
+ m_RWLock.LockForWrite();
+ }
+
+ ~CRWLockAutoWrite()
+ {
+ m_RWLock.UnlockWrite();
+ }
+};
+
+#define AUTO_LOCK_WRITE( mutex ) CRWLockAutoWrite<CThreadRWLock> UNIQUE_ID( mutex )
+#define AUTO_LOCK_SPIN_WRITE( mutex ) CRWLockAutoWrite<CThreadSpinRWLock> UNIQUE_ID( mutex )
+
+inline void *MemAlloc_AllocAligned( size_t size, size_t align, bool bCanFail ) { return MemAlloc_AllocAligned( size, align ); }
+inline void MemAlloc_FreeAligned( void *pMemBlock, bool bOperatorNew ) { MemAlloc_FreeAligned( pMemBlock ); }
+
+#endif
+
+
+#endif // GCSTEAMDEFINES_H \ No newline at end of file