mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-02 01:44:06 -04:00
Got it to compile under VC
This commit is contained in:
parent
818cf9d7a5
commit
fb46c04ad6
@ -2,10 +2,10 @@
|
||||
license as well as the LGPL, in spite of the comments below. See
|
||||
http://www.malloc.de . */
|
||||
|
||||
#include "dtoolbase.h"
|
||||
|
||||
#if defined(USE_MEMORY_PTMALLOC2) && !defined(linux)
|
||||
#define USE_DL_PREFIX 1
|
||||
#define __STDC__ 1
|
||||
#define MREMAP_MAYMOVE 1 /* terrible hack--drose */
|
||||
|
||||
/* Malloc implementation for multiple threads without lock contention.
|
||||
Copyright (C) 1996,1997,1998,1999,2000,01,02 Free Software Foundation, Inc.
|
||||
@ -238,14 +238,6 @@
|
||||
probably don't want to touch unless you are extending or adapting malloc.
|
||||
*/
|
||||
|
||||
/*
|
||||
WIN32 sets up defaults for MS environment and compilers.
|
||||
Otherwise defaults are for unix.
|
||||
*/
|
||||
|
||||
/* #define WIN32 */
|
||||
|
||||
|
||||
/*************************** thread-m.h ******************************/
|
||||
|
||||
|
||||
@ -2248,7 +2240,7 @@ struct malloc_chunk {
|
||||
};
|
||||
|
||||
|
||||
/*typedef struct malloc_chunk* mchunkptr;*/
|
||||
typedef struct malloc_chunk* mchunkptr;
|
||||
|
||||
/*
|
||||
malloc_chunk details:
|
||||
@ -2868,7 +2860,7 @@ struct malloc_par {
|
||||
char* sbrk_base;
|
||||
};
|
||||
|
||||
/*typedef struct malloc_state *mstate;*/
|
||||
typedef struct malloc_state *mstate;
|
||||
|
||||
/* There are several instances of this struct ("arenas") in this
|
||||
malloc. If you are adapting this malloc in a way that does NOT use
|
||||
@ -5320,9 +5312,6 @@ mremap_chunk(p, new_size) mchunkptr p; size_t new_size;
|
||||
/* Note the extra SIZE_SZ overhead as in mmap_chunk(). */
|
||||
new_size = (new_size + offset + SIZE_SZ + page_mask) & ~page_mask;
|
||||
|
||||
#ifndef MREMAP_MAYMOVE
|
||||
#define MREMAP_MAYMOVE 1 /* terrible hack--drose */
|
||||
#endif
|
||||
cp = (char *)mremap((char *)p - offset, size + offset, new_size,
|
||||
MREMAP_MAYMOVE);
|
||||
|
||||
@ -7830,6 +7819,9 @@ sbrk_exit:
|
||||
static void *mmap (void *ptr, long size, long prot, long type, long handle, long arg) {
|
||||
static long g_pagesize;
|
||||
static long g_regionsize;
|
||||
DWORD alloc=MEM_RESERVE|MEM_TOP_DOWN;
|
||||
DWORD ntprot=0;
|
||||
long rounding=0;
|
||||
#ifdef TRACE
|
||||
printf ("mmap %p %d %d %d\n", ptr, size, prot, type);
|
||||
#endif
|
||||
@ -7844,8 +7836,6 @@ static void *mmap (void *ptr, long size, long prot, long type, long handle, long
|
||||
assert ((unsigned) ptr % g_pagesize == 0);
|
||||
assert (size % g_pagesize == 0);
|
||||
/* Allocate this */
|
||||
DWORD alloc=MEM_RESERVE|MEM_TOP_DOWN, ntprot=0;
|
||||
long rounding=0;
|
||||
if(!(type & MAP_NORESERVE)) alloc|=MEM_COMMIT;
|
||||
if((prot & (PROT_READ|PROT_WRITE))==(PROT_READ|PROT_WRITE)) ntprot|=PAGE_READWRITE;
|
||||
else if(prot & PROT_READ) ntprot|=PAGE_READONLY;
|
||||
@ -7865,7 +7855,8 @@ static void *mmap (void *ptr, long size, long prot, long type, long handle, long
|
||||
{ /* prot==PROT_NONE also appears to be a euphemism for free */
|
||||
MEMORY_BASIC_INFORMATION mbi;
|
||||
DWORD read=0;
|
||||
for(char *p=((char *)ptr)+read; read<size && VirtualQuery(p, &mbi, sizeof(mbi)); read+=mbi.RegionSize)
|
||||
char *p;
|
||||
for(p=((char *)ptr)+read; read<size && VirtualQuery(p, &mbi, sizeof(mbi)); read+=mbi.RegionSize)
|
||||
{
|
||||
if(mbi.State & MEM_COMMIT)
|
||||
{
|
||||
@ -7905,7 +7896,7 @@ static void *mmap (void *ptr, long size, long prot, long type, long handle, long
|
||||
#ifdef TRACE
|
||||
printf ("%s %p %d %d %d\n", (type & MAP_NORESERVE) ? "Reserve" : "Commit", ptr, size, prot, type);
|
||||
#endif
|
||||
mmap_exit:
|
||||
mmap_exit:
|
||||
/* Release spin lock */
|
||||
slrelease (&g_sl);
|
||||
return ptr;
|
||||
@ -7933,7 +7924,7 @@ static long munmap (void *ptr, long size) {
|
||||
#ifdef TRACE
|
||||
printf ("Release %p %d\n", ptr, size);
|
||||
#endif
|
||||
munmap_exit:
|
||||
munmap_exit:
|
||||
/* Release spin lock */
|
||||
/* slrelease (&g_sl); */
|
||||
return rc;
|
||||
@ -7943,6 +7934,7 @@ static int mprotect(const void *addr, long len, int prot)
|
||||
{
|
||||
static long g_pagesize;
|
||||
static long g_regionsize;
|
||||
DWORD ntprot=0, oldntprot=0;
|
||||
int rc = -1;
|
||||
#ifdef TRACE
|
||||
printf ("mprotect %p %d %d\n", addr, len, prot);
|
||||
@ -7958,7 +7950,6 @@ static int mprotect(const void *addr, long len, int prot)
|
||||
assert ((unsigned) addr % g_pagesize == 0);
|
||||
assert (len% g_pagesize == 0);
|
||||
|
||||
DWORD ntprot=0, oldntprot=0;
|
||||
if((prot & (PROT_READ|PROT_WRITE))==(PROT_READ|PROT_WRITE)) ntprot|=PAGE_READWRITE;
|
||||
else if(prot & PROT_READ) ntprot|=PAGE_READONLY;
|
||||
else if(prot & PROT_WRITE) ntprot|=PAGE_READWRITE;
|
||||
@ -7984,7 +7975,8 @@ static int mprotect(const void *addr, long len, int prot)
|
||||
{ /* prot==PROT_NONE also appears to be a euphemism for free */
|
||||
MEMORY_BASIC_INFORMATION mbi;
|
||||
DWORD read=0;
|
||||
for(char *p=((char *)addr)+read; read<len && VirtualQuery(p, &mbi, sizeof(mbi)); read+=mbi.RegionSize)
|
||||
char *p;
|
||||
for(p=((char *)addr)+read; read<len && VirtualQuery(p, &mbi, sizeof(mbi)); read+=mbi.RegionSize)
|
||||
{
|
||||
if(mbi.State & MEM_COMMIT)
|
||||
{
|
||||
@ -8003,7 +7995,7 @@ static int mprotect(const void *addr, long len, int prot)
|
||||
#ifdef TRACE
|
||||
printf ("Protect %p %d %d\n", addr, len, prot);
|
||||
#endif
|
||||
mprotect_exit:
|
||||
mprotect_exit:
|
||||
/* Release spin lock */
|
||||
/* slrelease (&g_sl); */
|
||||
return rc;
|
||||
@ -8220,5 +8212,4 @@ History:
|
||||
|
||||
*/
|
||||
|
||||
#endif // USE_MEMORY_PTMALLOC2
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user