1.1 --- a/sourcemm/metamod_oslink.cpp Sun Nov 25 01:22:41 2007 +0000
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,101 +0,0 @@
1.4 -/**
1.5 - * vim: set ts=4 :
1.6 - * ======================================================
1.7 - * Metamod:Source
1.8 - * Copyright (C) 2004-2007 AlliedModders LLC and authors.
1.9 - * All rights reserved.
1.10 - * ======================================================
1.11 - *
1.12 - * This software is provided 'as-is', without any express or implied warranty.
1.13 - * In no event will the authors be held liable for any damages arising from
1.14 - * the use of this software.
1.15 - *
1.16 - * Permission is granted to anyone to use this software for any purpose,
1.17 - * including commercial applications, and to alter it and redistribute it
1.18 - * freely, subject to the following restrictions:
1.19 - *
1.20 - * 1. The origin of this software must not be misrepresented; you must not
1.21 - * claim that you wrote the original software. If you use this software in a
1.22 - * product, an acknowledgment in the product documentation would be
1.23 - * appreciated but is not required.
1.24 - * 2. Altered source versions must be plainly marked as such, and must not be
1.25 - * misrepresented as being the original software.
1.26 - * 3. This notice may not be removed or altered from any source distribution.
1.27 - *
1.28 - * Version: $Id$
1.29 - */
1.30 -
1.31 -#include "metamod_oslink.h"
1.32 -#include <malloc.h>
1.33 -#ifdef __linux
1.34 -#include <errno.h>
1.35 -#include <stdio.h>
1.36 -#endif
1.37 -
1.38 -#if defined __WIN32__ || defined _WIN32 || defined WIN32
1.39 -const char *dlerror()
1.40 -{
1.41 - static char buf[1024];
1.42 - FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
1.43 - NULL, GetLastError(),
1.44 - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
1.45 - (LPTSTR) &buf, 0, NULL);
1.46 - return buf;
1.47 -}
1.48 -#endif
1.49 -
1.50 -#if defined __linux__
1.51 -int GetLastError()
1.52 -{
1.53 - return errno;
1.54 -}
1.55 -
1.56 -extern "C" void __cxa_guard_acquire(void)
1.57 -{
1.58 -}
1.59 -
1.60 -extern "C" void __cxa_guard_release(void)
1.61 -{
1.62 -}
1.63 -#endif
1.64 -
1.65 -bool GetFileOfAddress(void *pAddr, char *buffer, size_t maxlength)
1.66 -{
1.67 -#if defined WIN32 || defined _WIN32
1.68 - MEMORY_BASIC_INFORMATION mem;
1.69 - if (!VirtualQuery(pAddr, &mem, sizeof(mem)))
1.70 - return false;
1.71 - if (mem.AllocationBase == NULL)
1.72 - return false;
1.73 - HMODULE dll = (HMODULE)mem.AllocationBase;
1.74 - GetModuleFileName(dll, (LPTSTR)buffer, maxlength);
1.75 -#elif defined __linux__
1.76 - Dl_info info;
1.77 - if (!dladdr(pAddr, &info))
1.78 - return false;
1.79 - if (!info.dli_fbase || !info.dli_fname)
1.80 - return false;
1.81 - const char *dllpath = info.dli_fname;
1.82 - snprintf(buffer, maxlength, "%s", dllpath);
1.83 -#endif
1.84 - return true;
1.85 -}
1.86 -
1.87 -#if defined __GNUC__ && (__GNUC__ == 3 || __GNUC__ == 4)
1.88 -void * operator new(size_t size) {
1.89 - return malloc(size);
1.90 -}
1.91 -
1.92 -void * operator new[](size_t size) {
1.93 - return malloc(size);
1.94 -}
1.95 -
1.96 -void operator delete(void * ptr) {
1.97 - free(ptr);
1.98 -}
1.99 -
1.100 -void operator delete[](void * ptr) {
1.101 - free(ptr);
1.102 -}
1.103 -#endif
1.104 -