Skip to content

Commit

Permalink
workaround gcc4.x 'local static variable' guarding (hlds is single th…
Browse files Browse the repository at this point in the history
…read so this is ok)
  • Loading branch information
jkivilin committed Dec 3, 2011
1 parent 1dead9b commit 4051d8b
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Makefile
Expand Up @@ -8,15 +8,15 @@ ifeq ($(OSTYPE),win32)
CPP = /usr/bin/i586-mingw32msvc-gcc
AR = /usr/bin/i586-mingw32msvc-ar rc
RANLIB = /usr/bin/i586-mingw32msvc-ranlib
LINKFLAGS = -mdll -lwsock32 -lstdc++ -Xlinker --add-stdcall-alias -s
LINKFLAGS = -mdll -lwsock32 -Xlinker --add-stdcall-alias -s
DLLEND = .dll
ZLIB_OSFLAGS =
else
CPP = gcc-4.2 -m32
AR = ar rc
RANLIB = ranlib
ARCHFLAG = -fPIC
LINKFLAGS = -fPIC -shared -ldl -lstdc++ -s
LINKFLAGS = -fPIC -shared -ldl -s
DLLEND = _i386.so
ZLIB_OSFLAGS = -DNO_UNDERLINE
endif
Expand Down
29 changes: 29 additions & 0 deletions h_export.cpp
Expand Up @@ -37,3 +37,32 @@ void WINAPI GiveFnptrsToDll( enginefuncs_t* pengfuncsFromEngine, globalvars_t *p
gpGlobals = pGlobals;
}

#ifdef __GNUC__
/* workaround gcc4.x 'local static variable' guarding (hlds is single thread so this is ok) */
namespace __cxxabiv1
{
/* guard variables */

/* The ABI requires a 64-bit type. */
__extension__ typedef int __guard __attribute__((mode (__DI__)));

extern "C" int __cxa_guard_acquire (__guard *);
extern "C" void __cxa_guard_release (__guard *);
extern "C" void __cxa_guard_abort (__guard *);

extern "C" int __cxa_guard_acquire (__guard *g)
{
return !*(char *)(g);
}

extern "C" void __cxa_guard_release (__guard *g)
{
*(char *)g = 1;
}

extern "C" void __cxa_guard_abort (__guard *)
{
}
}
#endif

0 comments on commit 4051d8b

Please sign in to comment.