trace_plugin/h_export.cpp
author Scott Ehlert <ds@alliedmods.net>
Thu Sep 26 15:56:37 2013 -0500 (2013-09-26)
changeset 280 622b9760d7ae
parent 0 d15304fcb7a7
permissions -rw-r--r--
Avoid linking to libstdc++ on Linux.
     1 // vi: set ts=4 sw=4 :
     2 // vim: set tw=75 :
     3 
     4 // h_export.cpp - main exported DLL functionality
     5 
     6 // From SDK dlls/h_export.cpp:
     7 
     8 /***
     9 *
    10 *	Copyright (c) 1999, 2000 Valve LLC. All rights reserved.
    11 *	
    12 *	This product contains software technology licensed from Id 
    13 *	Software, Inc. ("Id Technology").  Id Technology (c) 1996 Id Software, Inc. 
    14 *	All Rights Reserved.
    15 *
    16 *   Use, distribution, and modification of this source code and/or resulting
    17 *   object code is restricted to non-commercial enhancements to products from
    18 *   Valve LLC.  All other use, distribution, or modification is prohibited
    19 *   without written permission from Valve LLC.
    20 *
    21 ****/
    22 /*
    23 
    24 ===== h_export.cpp ========================================================
    25 
    26   Entity classes exported by Halflife.
    27 
    28 */
    29 
    30 #include <extdll.h>
    31 
    32 #include <h_export.h>
    33 #include <meta_api.h>
    34 
    35 //! Holds engine functionality callbacks
    36 enginefuncs_t g_engfuncs;
    37 globalvars_t  *gpGlobals;
    38 
    39 // Receive engine function table from engine.
    40 // This appears to be the _first_ DLL routine called by the engine, so we
    41 // do some setup operations here.
    42 void WINAPI GiveFnptrsToDll( enginefuncs_t* pengfuncsFromEngine, globalvars_t *pGlobals )
    43 {
    44 	memcpy(&g_engfuncs, pengfuncsFromEngine, sizeof(enginefuncs_t));
    45 	gpGlobals = pGlobals;
    46 	// NOTE!  Have to call logging function _after_ copying into g_engfuncs, so
    47 	// that g_engfuncs.pfnAlertMessage() can be resolved properly, heh. :)
    48 	UTIL_LogPrintf("[%s] dev: called: GiveFnptrsToDll\n", Plugin_info.logtag);
    49 }
    50 
    51 // Avoid linking to libstdc++
    52 #if defined(linux)
    53 extern "C" void __cxa_pure_virtual(void)
    54 {
    55 }
    56 
    57 void *operator new(size_t size)
    58 {
    59 	return malloc(size);
    60 }
    61 
    62 void *operator new[](size_t size)
    63 {
    64 	return malloc(size);
    65 }
    66 
    67 void operator delete(void *ptr)
    68 {
    69 	free(ptr);
    70 }
    71 
    72 void operator delete[](void * ptr)
    73 {
    74 	free(ptr);
    75 }
    76 #endif