Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.3 KiB

  1. //====== Copyright (c), Valve Corporation, All rights reserved. =======
  2. //
  3. // Purpose: Defines a bunch of stuff that would be defined in Steam, but
  4. // isn't in Source.
  5. //
  6. //=============================================================================
  7. #ifndef GCSTEAMDEFINES_H
  8. #define GCSTEAMDEFINES_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "tier0/memalloc.h"
  13. // steam defines some things that games don't
  14. #ifndef STEAM
  15. #define PvAlloc(x) malloc(x)
  16. #define PvRealloc(x, y) realloc(x, y)
  17. #define FreePv(x) free(x)
  18. #ifdef _DEBUG
  19. #define DbgVerify(x) Assert(x)
  20. #else
  21. #define DbgVerify(x) (x)
  22. #endif
  23. // auto-lock class for read-write locks
  24. template< class T >
  25. class CRWLockAutoWrite
  26. {
  27. T &m_RWLock;
  28. public:
  29. CRWLockAutoWrite( T &RWLock ) : m_RWLock( RWLock )
  30. {
  31. m_RWLock.LockForWrite();
  32. }
  33. ~CRWLockAutoWrite()
  34. {
  35. m_RWLock.UnlockWrite();
  36. }
  37. };
  38. #define AUTO_LOCK_WRITE( mutex ) CRWLockAutoWrite<CThreadRWLock> UNIQUE_ID( mutex )
  39. #define AUTO_LOCK_SPIN_WRITE( mutex ) CRWLockAutoWrite<CThreadSpinRWLock> UNIQUE_ID( mutex )
  40. //inline void *MemAlloc_AllocAligned( size_t size, size_t align, bool bCanFail ) { return MemAlloc_AllocAligned( size, align ); }
  41. inline void MemAlloc_FreeAligned( void *pMemBlock, bool bOperatorNew ) { MemAlloc_FreeAligned( pMemBlock ); }
  42. #endif
  43. #endif // GCSTEAMDEFINES_H