Imported Upstream version 6.10.0.49

Former-commit-id: 1d6753294b2993e1fbf92de9366bb9544db4189b
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2020-01-16 16:38:04 +00:00
parent d94e79959b
commit 468663ddbb
48518 changed files with 2789335 additions and 61176 deletions

541
external/bdwgc/extra/AmigaOS.c vendored Normal file

File diff suppressed because it is too large Load Diff

167
external/bdwgc/extra/MacOS.c vendored Normal file
View File

@@ -0,0 +1,167 @@
/*
MacOS.c
Some routines for the Macintosh OS port of the Hans-J. Boehm, Alan J. Demers
garbage collector.
<Revision History>
11/22/94 pcb StripAddress the temporary memory handle for 24-bit mode.
11/30/94 pcb Tracking all memory usage so we can deallocate it all at once.
02/10/96 pcb Added routine to perform a final collection when
unloading shared library.
by Patrick C. Beard.
*/
/* Boehm, February 15, 1996 2:55 pm PST */
#include <Resources.h>
#include <Memory.h>
#include <LowMem.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define GC_BUILD
#include "gc.h"
#include "private/gc_priv.h"
/* use 'CODE' resource 0 to get exact location of the beginning of global space. */
typedef struct {
unsigned long aboveA5;
unsigned long belowA5;
unsigned long JTSize;
unsigned long JTOffset;
} *CodeZeroPtr, **CodeZeroHandle;
void* GC_MacGetDataStart(void)
{
CodeZeroHandle code0 = (CodeZeroHandle)GetResource('CODE', 0);
if (code0) {
long belowA5Size = (**code0).belowA5;
ReleaseResource((Handle)code0);
return (LMGetCurrentA5() - belowA5Size);
}
fprintf(stderr, "Couldn't load the jump table.");
exit(-1);
return 0;
}
#ifdef USE_TEMPORARY_MEMORY
/* track the use of temporary memory so it can be freed all at once. */
typedef struct TemporaryMemoryBlock TemporaryMemoryBlock, **TemporaryMemoryHandle;
struct TemporaryMemoryBlock {
TemporaryMemoryHandle nextBlock;
char data[];
};
static TemporaryMemoryHandle theTemporaryMemory = NULL;
void GC_MacFreeTemporaryMemory(void);
Ptr GC_MacTemporaryNewPtr(size_t size, Boolean clearMemory)
{
# if !defined(SHARED_LIBRARY_BUILD)
static Boolean firstTime = true;
# endif
OSErr result;
TemporaryMemoryHandle tempMemBlock;
Ptr tempPtr = nil;
tempMemBlock = (TemporaryMemoryHandle)TempNewHandle(size + sizeof(TemporaryMemoryBlock), &result);
if (tempMemBlock && result == noErr) {
HLockHi((Handle)tempMemBlock);
tempPtr = (**tempMemBlock).data;
if (clearMemory) memset(tempPtr, 0, size);
tempPtr = StripAddress(tempPtr);
/* keep track of the allocated blocks. */
(**tempMemBlock).nextBlock = theTemporaryMemory;
theTemporaryMemory = tempMemBlock;
}
# if !defined(SHARED_LIBRARY_BUILD)
/* install an exit routine to clean up the memory used at the end. */
if (firstTime) {
atexit(&GC_MacFreeTemporaryMemory);
firstTime = false;
}
# endif
return tempPtr;
}
extern word GC_fo_entries;
static void perform_final_collection(void)
{
unsigned i;
word last_fo_entries = 0;
/* adjust the stack bottom, because CFM calls us from another stack
location. */
GC_stackbottom = (ptr_t)&i;
/* try to collect and finalize everything in sight */
for (i = 0; i < 2 || GC_fo_entries < last_fo_entries; i++) {
last_fo_entries = GC_fo_entries;
GC_gcollect();
}
}
void GC_MacFreeTemporaryMemory(void)
{
# if defined(SHARED_LIBRARY_BUILD)
/* if possible, collect all memory, and invoke all finalizers. */
perform_final_collection();
# endif
if (theTemporaryMemory != NULL) {
# if !defined(SHARED_LIBRARY_BUILD)
long totalMemoryUsed = 0;
# endif
TemporaryMemoryHandle tempMemBlock = theTemporaryMemory;
while (tempMemBlock != NULL) {
TemporaryMemoryHandle nextBlock = (**tempMemBlock).nextBlock;
# if !defined(SHARED_LIBRARY_BUILD)
totalMemoryUsed += GetHandleSize((Handle)tempMemBlock);
# endif
DisposeHandle((Handle)tempMemBlock);
tempMemBlock = nextBlock;
}
theTemporaryMemory = NULL;
# if !defined(SHARED_LIBRARY_BUILD)
if (GC_print_stats) {
fprintf(stdout, "[total memory used: %ld bytes.]\n",
totalMemoryUsed);
fprintf(stdout, "[total collections: %lu]\n",
(unsigned long)GC_gc_no);
}
# endif
}
}
#endif /* USE_TEMPORARY_MEMORY */
#if __option(far_data)
void* GC_MacGetDataEnd(void)
{
CodeZeroHandle code0 = (CodeZeroHandle)GetResource('CODE', 0);
if (code0) {
long aboveA5Size = (**code0).aboveA5;
ReleaseResource((Handle)code0);
return (LMGetCurrentA5() + aboveA5Size);
}
fprintf(stderr, "Couldn't load the jump table.");
exit(-1);
return 0;
}
#endif /* __option(far_data) */

View File

@@ -0,0 +1,27 @@
/*
MacOS_config.h
Configuration flags for Macintosh development systems.
<Revision History>
11/16/95 pcb Updated compilation flags to reflect latest 4.6 Makefile.
by Patrick C. Beard.
*/
/* Boehm, November 17, 1995 12:10 pm PST */
#ifdef __MWERKS__
/* for CodeWarrior Pro with Metrowerks Standard Library (MSL). */
/* #define MSL_USE_PRECOMPILED_HEADERS 0 */
#include <ansi_prefix.mac.h>
#endif /* __MWERKS__ */
/* these are defined again in gc_priv.h. */
#undef TRUE
#undef FALSE
#define ALL_INTERIOR_POINTERS /* follows interior pointers. */
/* #define DONT_ADD_BYTE_AT_END */ /* no padding. */
/* #define SMALL_CONFIG */ /* whether to use a smaller heap. */
#define USE_TEMPORARY_MEMORY /* use Macintosh temporary memory. */

View File

@@ -0,0 +1,9 @@
/*
dataend.c
A hack to get the extent of global data for the Macintosh.
by Patrick C. Beard.
*/
long __dataend;

View File

@@ -0,0 +1,9 @@
/*
datastart.c
A hack to get the extent of global data for the Macintosh.
by Patrick C. Beard.
*/
long __datastart;

92
external/bdwgc/extra/gc.c vendored Normal file
View File

@@ -0,0 +1,92 @@
/*
* Copyright (c) 1994 by Xerox Corporation. All rights reserved.
* Copyright (c) 1996 by Silicon Graphics. All rights reserved.
* Copyright (c) 1998 by Fergus Henderson. All rights reserved.
* Copyright (c) 2000-2009 by Hewlett-Packard Development Company.
* All rights reserved.
*
* THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
* OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
*
* Permission is hereby granted to use or copy this program
* for any purpose, provided the above notices are retained on all copies.
* Permission to modify the code and to distribute modified code is granted,
* provided the above notices are retained, and a notice that the code was
* modified is included with the above copyright notice.
*/
/* This file could be used for the following purposes: */
/* - get the complete GC as a single link object file (module); */
/* - enable more compiler optimizations. */
/* Tip: to get the highest level of compiler optimizations, the typical */
/* compiler options (GCC) to use are: */
/* -O3 -fno-strict-aliasing -march=native -Wall -fprofile-generate/use */
/* Warning: GCC for Linux (for C++ clients only): Use -fexceptions both */
/* for GC and the client otherwise GC_thread_exit_proc() is not */
/* guaranteed to be invoked (see the comments in pthread_start.c). */
#ifndef __cplusplus
/* static is desirable here for more efficient linkage. */
/* TODO: Enable this in case of the compilation as C++ code. */
# define GC_INNER STATIC
# define GC_EXTERN GC_INNER
/* STATIC is defined in gcconfig.h. */
#endif
/* Small files go first... */
#include "../backgraph.c"
#include "../blacklst.c"
#include "../checksums.c"
#include "../gcj_mlc.c"
#include "../headers.c"
#include "../new_hblk.c"
#include "../obj_map.c"
#include "../ptr_chck.c"
#include "gc_inline.h"
#include "../allchblk.c"
#include "../alloc.c"
#include "../dbg_mlc.c"
#include "../finalize.c"
#include "../fnlz_mlc.c"
#include "../malloc.c"
#include "../mallocx.c"
#include "../mark.c"
#include "../mark_rts.c"
#include "../reclaim.c"
#include "../typd_mlc.c"
#include "../misc.c"
#include "../os_dep.c"
#include "../thread_local_alloc.c"
/* Unity specific includes */
#include "../heapsections.c"
#include "../vector_mlc.c"
/* Most platform-specific files go here... */
#include "../darwin_stop_world.c"
#include "../dyn_load.c"
#include "../gc_dlopen.c"
#include "../mach_dep.c"
#include "../pthread_stop_world.c"
#include "../pthread_support.c"
#include "../specific.c"
#include "../win32_threads.c"
#ifndef GC_PTHREAD_START_STANDALONE
# include "../pthread_start.c"
#endif
/* Restore pthread calls redirection (if altered in */
/* pthread_stop_world.c, pthread_support.c or win32_threads.c). */
/* This is only useful if directly included from application */
/* (instead of linking gc). */
#ifndef GC_NO_THREAD_REDIRECTS
# define GC_PTHREAD_REDIRECTS_ONLY
# include "gc_pthread_redirects.h"
#endif
/* The files from "extra" folder are not included. */

View File

@@ -0,0 +1,48 @@
#if defined(__ANDROID__)
#include <signal.h>
#define SIGMAX 64
static void (*wrapped_signal_handlers[SIGMAX]) (int, siginfo_t *, void *);
static void signal_handler(int signum, siginfo_t* siginfo, void* sigcontext)
{
if (wrapped_signal_handlers[signum])
wrapped_signal_handlers[signum](signum, siginfo, sigcontext);
}
extern int __real_sigaction(int signum, const struct sigaction *action, struct sigaction *old_action);
__attribute__((used)) int __wrap_sigaction(int signum, const struct sigaction *action, struct sigaction *old_action)
{
struct sigaction wrapper_action_data;
struct sigaction* wrapper_action = NULL;
if (signum >= SIGMAX)
return __real_sigaction(signum, action, old_action);
// patch sig action with our thumb compiled dispatcher
if (action)
{
wrapper_action = &wrapper_action_data;
memcpy(wrapper_action, action, sizeof(*action));
wrapper_action->sa_sigaction = signal_handler;
}
// install handler (abort on error)
if (__real_sigaction(signum, wrapper_action, old_action) == -1)
return -1;
// hide any previously installed wrapper
if (old_action && old_action->sa_sigaction == signal_handler)
old_action->sa_sigaction = wrapped_signal_handlers[signum];
// add action to dispatch table
if (action)
wrapped_signal_handlers[signum] = action->sa_sigaction;
return 0;
}
#undef SIGMAX
#endif /* __ANDROID__ */

389
external/bdwgc/extra/msvc_dbg.c vendored Normal file
View File

@@ -0,0 +1,389 @@
/*
Copyright (c) 2004 Andrei Polushin
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#if !defined(_M_AMD64) && defined(_MSC_VER)
/* X86_64 is currently missing some meachine-dependent code below. */
#define GC_BUILD
#include "private/msvc_dbg.h"
#include "gc.h"
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#pragma pack(push, 8)
#include <imagehlp.h>
#pragma pack(pop)
#pragma comment(lib, "dbghelp.lib")
#pragma optimize("gy", off)
typedef GC_word word;
#define GC_ULONG_PTR word
#ifdef _WIN64
typedef GC_ULONG_PTR ULONG_ADDR;
#else
typedef ULONG ULONG_ADDR;
#endif
static HANDLE GetSymHandle(void)
{
static HANDLE symHandle = NULL;
if (!symHandle) {
BOOL bRet = SymInitialize(symHandle = GetCurrentProcess(), NULL, FALSE);
if (bRet) {
DWORD dwOptions = SymGetOptions();
dwOptions &= ~SYMOPT_UNDNAME;
dwOptions |= SYMOPT_LOAD_LINES;
SymSetOptions(dwOptions);
}
}
return symHandle;
}
static void* CALLBACK FunctionTableAccess(HANDLE hProcess,
ULONG_ADDR dwAddrBase)
{
return SymFunctionTableAccess(hProcess, dwAddrBase);
}
static ULONG_ADDR CALLBACK GetModuleBase(HANDLE hProcess, ULONG_ADDR dwAddress)
{
MEMORY_BASIC_INFORMATION memoryInfo;
ULONG_ADDR dwAddrBase = SymGetModuleBase(hProcess, dwAddress);
if (dwAddrBase) {
return dwAddrBase;
}
if (VirtualQueryEx(hProcess, (void*)(GC_ULONG_PTR)dwAddress, &memoryInfo,
sizeof(memoryInfo))) {
char filePath[_MAX_PATH];
char curDir[_MAX_PATH];
char exePath[_MAX_PATH];
DWORD size = GetModuleFileNameA((HINSTANCE)memoryInfo.AllocationBase,
filePath, sizeof(filePath));
/* Save and restore current directory around SymLoadModule, see KB */
/* article Q189780. */
GetCurrentDirectoryA(sizeof(curDir), curDir);
GetModuleFileNameA(NULL, exePath, sizeof(exePath));
#if defined(_MSC_VER) && _MSC_VER == 1200
/* use strcat for VC6 */
strcat(exePath, "\\..");
#else
strcat_s(exePath, sizeof(exePath), "\\..");
#endif /* _MSC_VER >= 1200 */
SetCurrentDirectoryA(exePath);
#ifdef _DEBUG
GetCurrentDirectoryA(sizeof(exePath), exePath);
#endif
SymLoadModule(hProcess, NULL, size ? filePath : NULL, NULL,
(ULONG_ADDR)(GC_ULONG_PTR)memoryInfo.AllocationBase, 0);
SetCurrentDirectoryA(curDir);
}
return (ULONG_ADDR)(GC_ULONG_PTR)memoryInfo.AllocationBase;
}
static ULONG_ADDR CheckAddress(void* address)
{
ULONG_ADDR dwAddress = (ULONG_ADDR)(GC_ULONG_PTR)address;
GetModuleBase(GetSymHandle(), dwAddress);
return dwAddress;
}
size_t GetStackFrames(size_t skip, void* frames[], size_t maxFrames)
{
HANDLE hProcess = GetSymHandle();
HANDLE hThread = GetCurrentThread();
CONTEXT context;
context.ContextFlags = CONTEXT_FULL;
if (!GetThreadContext(hThread, &context)) {
return 0;
}
/* GetThreadContext might return invalid context for the current thread. */
#if defined(_M_IX86)
__asm mov context.Ebp, ebp
#endif
return GetStackFramesFromContext(hProcess, hThread, &context, skip + 1,
frames, maxFrames);
}
size_t GetStackFramesFromContext(HANDLE hProcess, HANDLE hThread,
CONTEXT* context, size_t skip,
void* frames[], size_t maxFrames)
{
size_t frameIndex;
DWORD machineType;
STACKFRAME stackFrame = { 0 };
stackFrame.AddrPC.Mode = AddrModeFlat;
#if defined(_M_IX86)
machineType = IMAGE_FILE_MACHINE_I386;
stackFrame.AddrPC.Offset = context->Eip;
stackFrame.AddrStack.Mode = AddrModeFlat;
stackFrame.AddrStack.Offset = context->Esp;
stackFrame.AddrFrame.Mode = AddrModeFlat;
stackFrame.AddrFrame.Offset = context->Ebp;
#elif defined(_M_MRX000)
machineType = IMAGE_FILE_MACHINE_R4000;
stackFrame.AddrPC.Offset = context->Fir;
#elif defined(_M_ALPHA)
machineType = IMAGE_FILE_MACHINE_ALPHA;
stackFrame.AddrPC.Offset = (unsigned long)context->Fir;
#elif defined(_M_PPC)
machineType = IMAGE_FILE_MACHINE_POWERPC;
stackFrame.AddrPC.Offset = context->Iar;
#elif defined(_M_IA64)
machineType = IMAGE_FILE_MACHINE_IA64;
stackFrame.AddrPC.Offset = context->StIIP;
#elif defined(_M_ALPHA64)
machineType = IMAGE_FILE_MACHINE_ALPHA64;
stackFrame.AddrPC.Offset = context->Fir;
#elif !defined(CPPCHECK)
# error Unknown CPU
#endif
for (frameIndex = 0; frameIndex < maxFrames; ) {
BOOL bRet = StackWalk(machineType, hProcess, hThread, &stackFrame,
&context, NULL, FunctionTableAccess, GetModuleBase, NULL);
if (!bRet) {
break;
}
if (skip) {
skip--;
} else {
frames[frameIndex++] = (void*)(GC_ULONG_PTR)stackFrame.AddrPC.Offset;
}
}
return frameIndex;
}
size_t GetModuleNameFromAddress(void* address, char* moduleName, size_t size)
{
if (size) *moduleName = 0;
{
const char* sourceName;
IMAGEHLP_MODULE moduleInfo = { sizeof (moduleInfo) };
if (!SymGetModuleInfo(GetSymHandle(), CheckAddress(address),
&moduleInfo)) {
return 0;
}
sourceName = strrchr(moduleInfo.ImageName, '\\');
if (sourceName) {
sourceName++;
} else {
sourceName = moduleInfo.ImageName;
}
if (size) {
strncpy(moduleName, sourceName, size)[size - 1] = 0;
}
return strlen(sourceName);
}
}
size_t GetModuleNameFromStack(size_t skip, char* moduleName, size_t size)
{
void* address = NULL;
GetStackFrames(skip + 1, &address, 1);
if (address) {
return GetModuleNameFromAddress(address, moduleName, size);
}
return 0;
}
size_t GetSymbolNameFromAddress(void* address, char* symbolName, size_t size,
size_t* offsetBytes)
{
if (size) *symbolName = 0;
if (offsetBytes) *offsetBytes = 0;
__try {
ULONG_ADDR dwOffset = 0;
union {
IMAGEHLP_SYMBOL sym;
char symNameBuffer[sizeof(IMAGEHLP_SYMBOL) + MAX_SYM_NAME];
} u;
u.sym.SizeOfStruct = sizeof(u.sym);
u.sym.MaxNameLength = sizeof(u.symNameBuffer) - sizeof(u.sym);
if (!SymGetSymFromAddr(GetSymHandle(), CheckAddress(address), &dwOffset,
&u.sym)) {
return 0;
} else {
const char* sourceName = u.sym.Name;
char undName[1024];
if (UnDecorateSymbolName(u.sym.Name, undName, sizeof(undName),
UNDNAME_NO_MS_KEYWORDS | UNDNAME_NO_ACCESS_SPECIFIERS)) {
sourceName = undName;
} else if (SymUnDName(&u.sym, undName, sizeof(undName))) {
sourceName = undName;
}
if (offsetBytes) {
*offsetBytes = dwOffset;
}
if (size) {
strncpy(symbolName, sourceName, size)[size - 1] = 0;
}
return strlen(sourceName);
}
} __except (EXCEPTION_EXECUTE_HANDLER) {
SetLastError(GetExceptionCode());
}
return 0;
}
size_t GetSymbolNameFromStack(size_t skip, char* symbolName, size_t size,
size_t* offsetBytes)
{
void* address = NULL;
GetStackFrames(skip + 1, &address, 1);
if (address) {
return GetSymbolNameFromAddress(address, symbolName, size, offsetBytes);
}
return 0;
}
size_t GetFileLineFromAddress(void* address, char* fileName, size_t size,
size_t* lineNumber, size_t* offsetBytes)
{
if (size) *fileName = 0;
if (lineNumber) *lineNumber = 0;
if (offsetBytes) *offsetBytes = 0;
{
char* sourceName;
IMAGEHLP_LINE line = { sizeof (line) };
GC_ULONG_PTR dwOffset = 0;
if (!SymGetLineFromAddr(GetSymHandle(), CheckAddress(address), &dwOffset,
&line)) {
return 0;
}
if (lineNumber) {
*lineNumber = line.LineNumber;
}
if (offsetBytes) {
*offsetBytes = dwOffset;
}
sourceName = line.FileName;
/* TODO: resolve relative filenames, found in 'source directories' */
/* registered with MSVC IDE. */
if (size) {
strncpy(fileName, sourceName, size)[size - 1] = 0;
}
return strlen(sourceName);
}
}
size_t GetFileLineFromStack(size_t skip, char* fileName, size_t size,
size_t* lineNumber, size_t* offsetBytes)
{
void* address = NULL;
GetStackFrames(skip + 1, &address, 1);
if (address) {
return GetFileLineFromAddress(address, fileName, size, lineNumber,
offsetBytes);
}
return 0;
}
size_t GetDescriptionFromAddress(void* address, const char* format,
char* buffer, size_t size)
{
char*const begin = buffer;
char*const end = buffer + size;
size_t line_number = 0;
if (size) {
*buffer = 0;
}
buffer += GetFileLineFromAddress(address, buffer, size, &line_number, NULL);
size = (GC_ULONG_PTR)end < (GC_ULONG_PTR)buffer ? 0 : end - buffer;
if (line_number) {
char str[128];
wsprintf(str, "(%d) : ", (int)line_number);
if (size) {
strncpy(buffer, str, size)[size - 1] = 0;
}
buffer += strlen(str);
size = (GC_ULONG_PTR)end < (GC_ULONG_PTR)buffer ? 0 : end - buffer;
}
if (size) {
strncpy(buffer, "at ", size)[size - 1] = 0;
}
buffer += strlen("at ");
size = (GC_ULONG_PTR)end < (GC_ULONG_PTR)buffer ? 0 : end - buffer;
buffer += GetSymbolNameFromAddress(address, buffer, size, NULL);
size = (GC_ULONG_PTR)end < (GC_ULONG_PTR)buffer ? 0 : end - buffer;
if (size) {
strncpy(buffer, " in ", size)[size - 1] = 0;
}
buffer += strlen(" in ");
size = (GC_ULONG_PTR)end < (GC_ULONG_PTR)buffer ? 0 : end - buffer;
buffer += GetModuleNameFromAddress(address, buffer, size);
return buffer - begin;
}
size_t GetDescriptionFromStack(void* const frames[], size_t count,
const char* format, char* description[],
size_t size)
{
char*const begin = (char*)description;
char*const end = begin + size;
char* buffer = begin + (count + 1) * sizeof(char*);
size_t i;
(void)format;
for (i = 0; i < count; ++i) {
if (size)
description[i] = buffer;
size = (GC_ULONG_PTR)end < (GC_ULONG_PTR)buffer ? 0 : end - buffer;
buffer += 1 + GetDescriptionFromAddress(frames[i], NULL, buffer, size);
}
if (size)
description[count] = NULL;
return buffer - begin;
}
/* Compatibility with <execinfo.h> */
int backtrace(void* addresses[], int count)
{
return GetStackFrames(1, addresses, count);
}
char** backtrace_symbols(void*const* addresses, int count)
{
size_t size = GetDescriptionFromStack(addresses, count, NULL, NULL, 0);
char** symbols = (char**)malloc(size);
if (symbols != NULL)
GetDescriptionFromStack(addresses, count, NULL, symbols, size);
return symbols;
}
#else
extern int GC_quiet;
/* ANSI C does not allow translation units to be empty. */
#endif /* _M_AMD64 */

179
external/bdwgc/extra/pcr_interface.c vendored Normal file
View File

@@ -0,0 +1,179 @@
/*
* Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved.
*
* THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
* OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
*
* Permission is hereby granted to use or copy this program
* for any purpose, provided the above notices are retained on all copies.
* Permission to modify the code and to distribute modified code is granted,
* provided the above notices are retained, and a notice that the code was
* modified is included with the above copyright notice.
*/
# include "private/gc_priv.h"
# ifdef PCR
/*
* We wrap all of the allocator functions to avoid questions of
* compatibility between the prototyped and nonprototyped versions of the f
*/
# include "config/PCR_StdTypes.h"
# include "mm/PCR_MM.h"
# include <errno.h>
# define MY_MAGIC 17L
# define MY_DEBUGMAGIC 42L
void * GC_AllocProc(size_t size, PCR_Bool ptrFree, PCR_Bool clear )
{
if (ptrFree) {
void * result = (void *)GC_malloc_atomic(size);
if (clear && result != 0) BZERO(result, size);
return(result);
} else {
return((void *)GC_malloc(size));
}
}
void * GC_DebugAllocProc(size_t size, PCR_Bool ptrFree, PCR_Bool clear )
{
if (ptrFree) {
void * result = (void *)GC_debug_malloc_atomic(size, __FILE__,
__LINE__);
if (clear && result != 0) BZERO(result, size);
return(result);
} else {
return((void *)GC_debug_malloc(size, __FILE__, __LINE__));
}
}
# define GC_ReallocProc GC_realloc
void * GC_DebugReallocProc(void * old_object, size_t new_size_in_bytes)
{
return(GC_debug_realloc(old_object, new_size_in_bytes, __FILE__, __LINE__));
}
# define GC_FreeProc GC_free
# define GC_DebugFreeProc GC_debug_free
typedef struct {
PCR_ERes (*ed_proc)(void *p, size_t size, PCR_Any data);
GC_bool ed_pointerfree;
PCR_ERes ed_fail_code;
PCR_Any ed_client_data;
} enumerate_data;
void GC_enumerate_block(struct hblk *h, enumerate_data * ed)
{
hdr * hhdr;
size_t sz;
ptr_t p;
ptr_t lim;
word descr;
# if !defined(CPPCHECK)
# error This code was updated without testing.
# error and its precursor was clearly broken.
# endif
hhdr = HDR(h);
descr = hhdr -> hb_descr;
sz = (size_t)hhdr->hb_sz;
if (descr != 0 && ed -> ed_pointerfree
|| descr == 0 && !(ed -> ed_pointerfree)) return;
lim = (ptr_t)(h+1) - sz;
p = (ptr_t)h;
do {
if (PCR_ERes_IsErr(ed -> ed_fail_code)) return;
ed -> ed_fail_code =
(*(ed -> ed_proc))(p, sz, ed -> ed_client_data);
p+= sz;
} while ((word)p <= (word)lim);
}
struct PCR_MM_ProcsRep * GC_old_allocator = 0;
PCR_ERes GC_EnumerateProc(
PCR_Bool ptrFree,
PCR_ERes (*proc)(void *p, size_t size, PCR_Any data),
PCR_Any data
)
{
enumerate_data ed;
ed.ed_proc = proc;
ed.ed_pointerfree = ptrFree;
ed.ed_fail_code = PCR_ERes_okay;
ed.ed_client_data = data;
GC_apply_to_all_blocks(GC_enumerate_block, &ed);
if (ed.ed_fail_code != PCR_ERes_okay) {
return(ed.ed_fail_code);
} else {
/* Also enumerate objects allocated by my predecessors */
return((*(GC_old_allocator->mmp_enumerate))(ptrFree, proc, data));
}
}
void GC_DummyFreeProc(void *p) {}
void GC_DummyShutdownProc(void) {}
struct PCR_MM_ProcsRep GC_Rep = {
MY_MAGIC,
GC_AllocProc,
GC_ReallocProc,
GC_DummyFreeProc, /* mmp_free */
GC_FreeProc, /* mmp_unsafeFree */
GC_EnumerateProc,
GC_DummyShutdownProc /* mmp_shutdown */
};
struct PCR_MM_ProcsRep GC_DebugRep = {
MY_DEBUGMAGIC,
GC_DebugAllocProc,
GC_DebugReallocProc,
GC_DummyFreeProc, /* mmp_free */
GC_DebugFreeProc, /* mmp_unsafeFree */
GC_EnumerateProc,
GC_DummyShutdownProc /* mmp_shutdown */
};
GC_bool GC_use_debug = 0;
void GC_pcr_install()
{
PCR_MM_Install((GC_use_debug? &GC_DebugRep : &GC_Rep), &GC_old_allocator);
}
PCR_ERes
PCR_GC_Setup(void)
{
return PCR_ERes_okay;
}
PCR_ERes
PCR_GC_Run(void)
{
if( !PCR_Base_TestPCRArg("-nogc") ) {
GC_quiet = ( PCR_Base_TestPCRArg("-gctrace") ? 0 : 1 );
GC_use_debug = (GC_bool)PCR_Base_TestPCRArg("-debug_alloc");
GC_init();
if( !PCR_Base_TestPCRArg("-nogc_incremental") ) {
/*
* awful hack to test whether VD is implemented ...
*/
if( PCR_VD_Start( 0, NIL, 0) != PCR_ERes_FromErr(ENOSYS) ) {
GC_enable_incremental();
}
}
}
return PCR_ERes_okay;
}
void GC_push_thread_structures(void)
{
/* PCR doesn't work unless static roots are pushed. Can't get here. */
ABORT("In GC_push_thread_structures()");
}
# endif

39
external/bdwgc/extra/real_malloc.c vendored Normal file
View File

@@ -0,0 +1,39 @@
/*
* Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers
* Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved.
*
* THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
* OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
*
* Permission is hereby granted to use or copy this program
* for any purpose, provided the above notices are retained on all copies.
* Permission to modify the code and to distribute modified code is granted,
* provided the above notices are retained, and a notice that the code was
* modified is included with the above copyright notice.
*/
# ifdef HAVE_CONFIG_H
# include "config.h"
# endif
# ifdef PCR
/*
* This definition should go in its own file that includes no other
* header files. Otherwise, we risk not getting the underlying system
* malloc.
*/
# define PCR_NO_RENAME
# include <stdlib.h>
void * real_malloc(size_t size)
{
return(malloc(size));
}
# else
extern int GC_quiet;
/* ANSI C doesn't allow translation units to be empty. */
/* So we guarantee this one is nonempty. */
#endif /* PCR */

52
external/bdwgc/extra/symbian.cpp vendored Normal file
View File

@@ -0,0 +1,52 @@
#include <e32cmn.h>
#include <e32std.h>
#include <f32file.h>
#include <aknutils.h>
#include <stdlib.h>
#include <string.h>
extern "C" {
int GC_get_main_symbian_stack_base()
{
TThreadStackInfo aInfo;
TInt err = RThread().StackInfo(aInfo);
if ( !err )
{
return aInfo.iBase;
}
else
{
return 0;
}
}
char* GC_get_private_path_and_zero_file()
{
// always on c: drive
RFs fs;
fs.Connect();
fs.CreatePrivatePath( EDriveC );
TFileName path;
fs.PrivatePath( path );
fs.Close();
_LIT( KCDrive, "c:" );
path.Insert( 0, KCDrive );
//convert to char*, assume ascii
TBuf8<KMaxFileName> path8;
path8.Copy( path );
_LIT8( KZero8, "zero" );
path8.Append( KZero8 );
size_t size = path8.Length() + 1;
char* copyChar = (char*) malloc( size );
if (copyChar)
memcpy( copyChar, path8.PtrZ(), size );
return copyChar; // ownership passed
}
} /* extern "C" */

View File

@@ -0,0 +1,10 @@
// Symbian-specific file.
// INCLUDE FILES
#include "private/gcconfig.h"
extern "C" {
int winscw_data_end;
} /* extern "C" */

View File

@@ -0,0 +1,10 @@
// Symbian-specific file.
// INCLUDE FILES
#include "private/gcconfig.h"
extern "C" {
int winscw_data_start;
} /* extern "C" */

View File

@@ -0,0 +1,28 @@
// Symbian-specific file.
// INCLUDE FILES
#include <e32def.h>
#include "private/gcconfig.h"
#include "gc.h"
extern "C" {
void GC_init_global_static_roots()
{
ptr_t dataStart = NULL;
ptr_t dataEnd = NULL;
# if defined (__WINS__)
extern int winscw_data_start, winscw_data_end;
dataStart = ((ptr_t)&winscw_data_start);
dataEnd = ((ptr_t)&winscw_data_end);
# else
extern int Image$$RW$$Limit[], Image$$RW$$Base[];
dataStart = ((ptr_t)Image$$RW$$Base);
dataEnd = ((ptr_t)Image$$RW$$Limit);
# endif
GC_add_roots(dataStart, dataEnd);
}
} /* extern "C" */