From 10d59e720827660ab73801165c3c0925a27c5101 Mon Sep 17 00:00:00 2001 From: Ian Thompson Date: Mon, 9 Jun 2008 14:04:19 +0000 Subject: Merged from trunk svn merge -r14988:15170 https://svn.blender.org/svnroot/bf-blender/trunk/blender --- intern/bsp/SConscript | 2 +- intern/guardedalloc/intern/mmap_win.c | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) (limited to 'intern') diff --git a/intern/bsp/SConscript b/intern/bsp/SConscript index e363fd1d4c3..88d2529ae59 100644 --- a/intern/bsp/SConscript +++ b/intern/bsp/SConscript @@ -8,5 +8,5 @@ incs = 'intern ../container ../moto/include ../memutil' if (env['OURPLATFORM'] == 'win32-mingw'): env.BlenderLib ('blender_BSP', sources, Split(incs), [], libtype=['common','intern'], priority=[26,26] ) else: - env.BlenderLib ('blender_BSP', sources, Split(incs), [], libtype='core', priority=15 ) + env.BlenderLib ('blender_BSP', sources, Split(incs), [], libtype='core', priority=26 ) diff --git a/intern/guardedalloc/intern/mmap_win.c b/intern/guardedalloc/intern/mmap_win.c index cc31cf5174e..436c99344a7 100644 --- a/intern/guardedalloc/intern/mmap_win.c +++ b/intern/guardedalloc/intern/mmap_win.c @@ -200,7 +200,6 @@ static void mmap_remlink(volatile mmapListBase *listbase, void *vlink) static void *mmap_findlink(volatile mmapListBase *listbase, void *ptr) { - MemMap *mmap_ptr = (MemMap*)ptr; MemMap *mm; if (ptr == 0) return NULL; -- cgit v1.2.3 From d124d3c5cdfdc9d470a4734281396b97c4d3afb5 Mon Sep 17 00:00:00 2001 From: Maxime Curioni Date: Sat, 12 Jul 2008 04:02:08 +0000 Subject: soc-2008-mxcurioni: first part of the Freestyle Python implementation. A new Freestyle module is added. The following modules are implemented: BinaryPredicate0D, BinaryPredicate1D, Id, Interface0D, Interface1D. I added a Convert module to help in the creation of Python objects for Freestyle's data structures. I also added a missing file for guarded_alloc needed for compilation on Windows. --- intern/guardedalloc/intern/mmap_win.c | 260 ++++++++++++++++++++++++++++++++++ intern/guardedalloc/mmap_win.h | 51 +++++++ 2 files changed, 311 insertions(+) create mode 100644 intern/guardedalloc/intern/mmap_win.c create mode 100644 intern/guardedalloc/mmap_win.h (limited to 'intern') diff --git a/intern/guardedalloc/intern/mmap_win.c b/intern/guardedalloc/intern/mmap_win.c new file mode 100644 index 00000000000..436c99344a7 --- /dev/null +++ b/intern/guardedalloc/intern/mmap_win.c @@ -0,0 +1,260 @@ +/** + * $Id: $ + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2008 Blender Foundation. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): Andrea Weikert. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#if defined(WIN32) + +#include +#include +#include +#include +#include + +#include "mmap_win.h" + +#ifndef FILE_MAP_EXECUTE +//not defined in earlier versions of the Platform SDK (before February 2003) +#define FILE_MAP_EXECUTE 0x0020 +#endif + +/* --------------------------------------------------------------------- */ +/* local storage definitions */ +/* --------------------------------------------------------------------- */ +/* all memory mapped chunks are put in linked lists */ +typedef struct mmapLink +{ + struct mmapLink *next,*prev; +} mmapLink; + +typedef struct mmapListBase +{ + void *first, *last; +} mmapListBase; + +typedef struct MemMap { + struct MemMap *next,*prev; + void *mmap; + HANDLE fhandle; + HANDLE maphandle; +} MemMap; + +/* --------------------------------------------------------------------- */ +/* local functions */ +/* --------------------------------------------------------------------- */ + +static void mmap_addtail(volatile mmapListBase *listbase, void *vlink); +static void mmap_remlink(volatile mmapListBase *listbase, void *vlink); +static void *mmap_findlink(volatile mmapListBase *listbase, void *ptr); + +static int mmap_get_prot_flags (int flags); +static int mmap_get_access_flags (int flags); + +/* --------------------------------------------------------------------- */ +/* vars */ +/* --------------------------------------------------------------------- */ +volatile static struct mmapListBase _mmapbase; +volatile static struct mmapListBase *mmapbase = &_mmapbase; + + +/* --------------------------------------------------------------------- */ +/* implementation */ +/* --------------------------------------------------------------------- */ + +/* mmap for windows */ +void *mmap(void *start, size_t len, int prot, int flags, int fd, off_t offset) +{ + HANDLE fhandle = INVALID_HANDLE_VALUE; + HANDLE maphandle; + int prot_flags = mmap_get_prot_flags(prot); + int access_flags = mmap_get_access_flags(prot); + MemMap *mm = NULL; + void *ptr = NULL; + + if ( flags & MAP_FIXED ) { + return MAP_FAILED; + } + + /* + if ( fd == -1 ) { + _set_errno( EBADF ); + return MAP_FAILED; + } + */ + + if ( fd != -1 ) { + fhandle = (HANDLE) _get_osfhandle (fd); + } + if ( fhandle == INVALID_HANDLE_VALUE ) { + if (!(flags & MAP_ANONYMOUS)) { + errno = EBADF; + return MAP_FAILED; + } + } else { + if ( !DuplicateHandle( GetCurrentProcess(), fhandle, GetCurrentProcess(), + &fhandle, 0, FALSE, DUPLICATE_SAME_ACCESS ) ) { + return MAP_FAILED; + } + } + + maphandle = CreateFileMapping(fhandle, NULL, prot_flags, 0, len, NULL); + if ( maphandle == 0 ) { + errno = EBADF; + return MAP_FAILED; + } + + ptr = MapViewOfFile(maphandle, access_flags, 0, offset, 0); + if ( ptr == NULL ) { + DWORD dwLastErr = GetLastError(); + if ( dwLastErr == ERROR_MAPPED_ALIGNMENT ) + errno=EINVAL; + else + errno=EACCES; + CloseHandle(maphandle); + return MAP_FAILED; + } + + mm= (MemMap *)malloc(sizeof(MemMap)); + if (!mm) { + errno=ENOMEM; + } + mm->fhandle = fhandle; + mm->maphandle = maphandle; + mm->mmap = ptr; + mmap_addtail(mmapbase, mm); + + return ptr; +} + +/* munmap for windows */ +long munmap(void *ptr, long size) +{ + MemMap *mm = mmap_findlink(mmapbase, ptr); + if (!mm) { + errno=EINVAL; + return -1; + } + UnmapViewOfFile( mm->mmap ); + CloseHandle( mm->maphandle ); + CloseHandle( mm->fhandle); + mmap_remlink(mmapbase, mm); + return 0; +} + +/* --------------------------------------------------------------------- */ +/* local functions */ +/* --------------------------------------------------------------------- */ + +static void mmap_addtail(volatile mmapListBase *listbase, void *vlink) +{ + struct mmapLink *link= vlink; + + if (link == 0) return; + if (listbase == 0) return; + + link->next = 0; + link->prev = listbase->last; + + if (listbase->last) ((struct mmapLink *)listbase->last)->next = link; + if (listbase->first == 0) listbase->first = link; + listbase->last = link; +} + +static void mmap_remlink(volatile mmapListBase *listbase, void *vlink) +{ + struct mmapLink *link= vlink; + + if (link == 0) return; + if (listbase == 0) return; + + if (link->next) link->next->prev = link->prev; + if (link->prev) link->prev->next = link->next; + + if (listbase->last == link) listbase->last = link->prev; + if (listbase->first == link) listbase->first = link->next; +} + +static void *mmap_findlink(volatile mmapListBase *listbase, void *ptr) +{ + MemMap *mm; + + if (ptr == 0) return NULL; + if (listbase == 0) return NULL; + + mm = (MemMap *)listbase->first; + while (mm) { + if (mm->mmap == ptr) { + return mm; + } + mm = mm->next; + } + return NULL; +} + +static int mmap_get_prot_flags (int flags) +{ + int prot = PAGE_NOACCESS; + + if ( ( flags & PROT_READ ) == PROT_READ ) { + if ( ( flags & PROT_WRITE ) == PROT_WRITE ) { + prot = (flags & PROT_EXEC) ? PAGE_EXECUTE_READWRITE : PAGE_READWRITE; + } else { + prot = (flags & PROT_EXEC) ? PAGE_EXECUTE_READ : PAGE_READONLY; + } + } else if ( ( flags & PROT_WRITE ) == PROT_WRITE ) { + prot = (flags & PROT_EXEC) ? PAGE_EXECUTE_READ : PAGE_WRITECOPY; + } else if ( ( flags & PROT_EXEC ) == PROT_EXEC ) { + prot = PAGE_EXECUTE_READ; + } + return prot; +} + +static int mmap_get_access_flags (int flags) +{ + int access = 0; + + if ( ( flags & PROT_READ ) == PROT_READ ) { + if ( ( flags & PROT_WRITE ) == PROT_WRITE ) { + access = FILE_MAP_WRITE; + } else { + access = (flags & PROT_EXEC) ? FILE_MAP_EXECUTE : FILE_MAP_READ; + } + } else if ( ( flags & PROT_WRITE ) == PROT_WRITE ) { + access = FILE_MAP_COPY; + } else if ( ( flags & PROT_EXEC ) == PROT_EXEC ) { + access = FILE_MAP_EXECUTE; + } + return access; +} + + +#endif // WIN32 + + + + + diff --git a/intern/guardedalloc/mmap_win.h b/intern/guardedalloc/mmap_win.h new file mode 100644 index 00000000000..53af86e1f66 --- /dev/null +++ b/intern/guardedalloc/mmap_win.h @@ -0,0 +1,51 @@ +/** + * $Id: $ + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2008 Blender Foundation. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): Andrea Weikert. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#ifndef MMAP_WIN_H +#define MMAP_WIN_H + +#define PROT_NONE 0 +#define PROT_READ 1 +#define PROT_WRITE 2 +#define PROT_EXEC 4 + +#define MAP_FILE 0 +#define MAP_SHARED 1 +#define MAP_PRIVATE 2 +#define MAP_TYPE 0xF +#define MAP_FIXED 0x10 +#define MAP_ANONYMOUS 0x20 +#define MAP_ANON MAP_ANONYMOUS + +#define MAP_FAILED ((void *)-1) + +void *mmap(void *start, size_t len, int prot, int flags, int fd, off_t offset); +long munmap(void *ptr, long size); + +#endif \ No newline at end of file -- cgit v1.2.3 From 8398730043faeb9af860ca7a408a5a4ba49b46f1 Mon Sep 17 00:00:00 2001 From: Maxime Curioni Date: Sat, 12 Jul 2008 05:02:47 +0000 Subject: soc-2008-mxcurioni: merge with trunk - rev 15540 --- intern/ghost/intern/GHOST_SystemWin32.cpp | 9 +++++++++ intern/moto/include/GEN_Map.h | 18 ++++++++++++++++++ 2 files changed, 27 insertions(+) (limited to 'intern') diff --git a/intern/ghost/intern/GHOST_SystemWin32.cpp b/intern/ghost/intern/GHOST_SystemWin32.cpp index 82a76b3c706..293f8fc1661 100644 --- a/intern/ghost/intern/GHOST_SystemWin32.cpp +++ b/intern/ghost/intern/GHOST_SystemWin32.cpp @@ -302,6 +302,15 @@ GHOST_TSuccess GHOST_SystemWin32::init() { GHOST_TSuccess success = GHOST_System::init(); + /* Disable scaling on high DPI displays on Vista */ + HMODULE user32 = ::LoadLibraryA("user32.dll"); + typedef BOOL (WINAPI * LPFNSETPROCESSDPIAWARE)(); + LPFNSETPROCESSDPIAWARE SetProcessDPIAware = + (LPFNSETPROCESSDPIAWARE)GetProcAddress(user32, "SetProcessDPIAware"); + if (SetProcessDPIAware) + SetProcessDPIAware(); + FreeLibrary(user32); + // Determine whether this system has a high frequency performance counter. */ m_hasPerformanceCounter = ::QueryPerformanceFrequency((LARGE_INTEGER*)&m_freq) == TRUE; if (m_hasPerformanceCounter) { diff --git a/intern/moto/include/GEN_Map.h b/intern/moto/include/GEN_Map.h index db3335d6110..9f56924419e 100644 --- a/intern/moto/include/GEN_Map.h +++ b/intern/moto/include/GEN_Map.h @@ -82,6 +82,24 @@ public: } return 0; } + + Key* getKey(int index) { + int count=0; + for (int i=0;im_key; + } + bucket = bucket->m_next; + count++; + } + } + return 0; + } void clear() { for (int i = 0; i < m_num_buckets; ++i) { -- cgit v1.2.3 From f042a468fdd0f06ca41c022c9ed6ac59d35ff143 Mon Sep 17 00:00:00 2001 From: Ian Thompson Date: Fri, 18 Jul 2008 23:35:34 +0000 Subject: Merged 15170:15635 from trunk (no conflicts or even merges) --- intern/bsp/intern/BSP_CSGMesh.cpp | 2 +- intern/container/CTR_TaggedIndex.h | 16 ++++++++++++++++ intern/decimation/intern/LOD_ManMesh2.cpp | 6 +++--- intern/elbeem/intern/solver_init.cpp | 2 +- intern/ghost/intern/GHOST_SystemWin32.cpp | 17 +++++++++++++++++ intern/ghost/intern/GHOST_SystemX11.cpp | 8 ++++---- intern/ghost/intern/GHOST_WindowWin32.cpp | 8 ++++++++ intern/iksolver/intern/IK_QTask.h | 2 +- intern/moto/include/GEN_Map.h | 18 ++++++++++++++++++ intern/moto/include/MT_random.h | 6 +++--- intern/moto/intern/MT_random.cpp | 10 +++++----- 11 files changed, 77 insertions(+), 18 deletions(-) (limited to 'intern') diff --git a/intern/bsp/intern/BSP_CSGMesh.cpp b/intern/bsp/intern/BSP_CSGMesh.cpp index 553f39a4642..ca7795b3cf5 100644 --- a/intern/bsp/intern/BSP_CSGMesh.cpp +++ b/intern/bsp/intern/BSP_CSGMesh.cpp @@ -197,7 +197,7 @@ BuildEdges( for (int vert = 0; vert < vertex_num; ++vert) { - BSP_FaceInd fi(f_it - f_it_begin); + BSP_FaceInd fi(size_t (f_it - f_it_begin)); InsertEdge(prev_vi,face.m_verts[vert],fi,dummy); prev_vi = face.m_verts[vert]; } diff --git a/intern/container/CTR_TaggedIndex.h b/intern/container/CTR_TaggedIndex.h index 7a7bd85e890..68d2536c879 100644 --- a/intern/container/CTR_TaggedIndex.h +++ b/intern/container/CTR_TaggedIndex.h @@ -93,6 +93,16 @@ public: } +#if defined(_WIN64) + CTR_TaggedIndex( + const unsigned __int64 val + ) : + m_val ( ((unsigned __int64)val & index_mask) + | ( (empty_tag << tag_shift) + & (~index_mask) ) ) { + } +#endif + CTR_TaggedIndex( const CTR_TaggedIndex &my_index ): @@ -124,6 +134,12 @@ public: return (long int)(m_val & index_mask); } +#if defined(_WIN64) + operator unsigned __int64 () const { + return (unsigned __int64)(m_val & index_mask); + } +#endif + bool IsEmpty( ) const { diff --git a/intern/decimation/intern/LOD_ManMesh2.cpp b/intern/decimation/intern/LOD_ManMesh2.cpp index eeb497bb09e..2fe49b36583 100644 --- a/intern/decimation/intern/LOD_ManMesh2.cpp +++ b/intern/decimation/intern/LOD_ManMesh2.cpp @@ -477,7 +477,7 @@ DeleteVertex( return; } - LOD_VertexInd last = LOD_VertexInd(verts.end() - verts.begin() - 1); + LOD_VertexInd last = LOD_VertexInd(size_t(verts.end() - verts.begin() - 1)); if (!(last == v)) { @@ -533,7 +533,7 @@ DeleteEdge( return; } - LOD_EdgeInd last = LOD_EdgeInd(edges.end() - edges.begin() - 1); + LOD_EdgeInd last = LOD_EdgeInd(size_t(edges.end() - edges.begin() - 1)); if (!(last == e)) { vector e_verts; @@ -573,7 +573,7 @@ DeleteFace( return; } - LOD_FaceInd last = LOD_FaceInd(faces.end() - faces.begin() - 1); + LOD_FaceInd last = LOD_FaceInd(size_t (faces.end() - faces.begin() - 1)); if (!(last == f)) { diff --git a/intern/elbeem/intern/solver_init.cpp b/intern/elbeem/intern/solver_init.cpp index c953d2f47da..a873f3c6987 100644 --- a/intern/elbeem/intern/solver_init.cpp +++ b/intern/elbeem/intern/solver_init.cpp @@ -694,7 +694,7 @@ bool LbmFsgrSolver::initializeSolverMemory() double maxDefaultMemChunk = 2.*1024.*1024.*1024.; //std::cerr<<" memEstFine "<< memEstFine <<" maxWin:" < maxWinMemChunk) { + if(sizeof(void *)==4 && memEstFine>maxWinMemChunk) { memBlockAllocProblem = true; } #endif // WIN32 diff --git a/intern/ghost/intern/GHOST_SystemWin32.cpp b/intern/ghost/intern/GHOST_SystemWin32.cpp index 82a76b3c706..f5c7c08ebfe 100644 --- a/intern/ghost/intern/GHOST_SystemWin32.cpp +++ b/intern/ghost/intern/GHOST_SystemWin32.cpp @@ -42,6 +42,14 @@ #include "GHOST_SystemWin32.h" +// win64 doesn't define GWL_USERDATA +#ifdef WIN32 +#ifndef GWL_USERDATA +#define GWL_USERDATA GWLP_USERDATA +#define GWL_WNDPROC GWLP_WNDPROC +#endif +#endif + /* * According to the docs the mouse wheel message is supported from windows 98 * upwards. Leaving WINVER at default value, the WM_MOUSEWHEEL message and the @@ -302,6 +310,15 @@ GHOST_TSuccess GHOST_SystemWin32::init() { GHOST_TSuccess success = GHOST_System::init(); + /* Disable scaling on high DPI displays on Vista */ + HMODULE user32 = ::LoadLibraryA("user32.dll"); + typedef BOOL (WINAPI * LPFNSETPROCESSDPIAWARE)(); + LPFNSETPROCESSDPIAWARE SetProcessDPIAware = + (LPFNSETPROCESSDPIAWARE)GetProcAddress(user32, "SetProcessDPIAware"); + if (SetProcessDPIAware) + SetProcessDPIAware(); + FreeLibrary(user32); + // Determine whether this system has a high frequency performance counter. */ m_hasPerformanceCounter = ::QueryPerformanceFrequency((LARGE_INTEGER*)&m_freq) == TRUE; if (m_hasPerformanceCounter) { diff --git a/intern/ghost/intern/GHOST_SystemX11.cpp b/intern/ghost/intern/GHOST_SystemX11.cpp index ff1bf51bbb5..3003e0b8b14 100644 --- a/intern/ghost/intern/GHOST_SystemX11.cpp +++ b/intern/ghost/intern/GHOST_SystemX11.cpp @@ -488,12 +488,12 @@ GHOST_SystemX11::processEvent(XEvent *xe) data.changed = 1; data.delta = xcme.data.s[8] - data.time; data.time = xcme.data.s[8]; - data.tx = xcme.data.s[2]; - data.ty = xcme.data.s[3]; - data.tz = xcme.data.s[4]; + data.tx = xcme.data.s[2] >> 2; + data.ty = xcme.data.s[3] >> 2; + data.tz = xcme.data.s[4] >> 2; data.rx = xcme.data.s[5]; data.ry = xcme.data.s[6]; - data.rz = xcme.data.s[7]; + data.rz =-xcme.data.s[7]; g_event = new GHOST_EventNDOF(getMilliSeconds(), GHOST_kEventNDOFMotion, window, data); diff --git a/intern/ghost/intern/GHOST_WindowWin32.cpp b/intern/ghost/intern/GHOST_WindowWin32.cpp index 905b2f7ac63..fef58d071a4 100644 --- a/intern/ghost/intern/GHOST_WindowWin32.cpp +++ b/intern/ghost/intern/GHOST_WindowWin32.cpp @@ -48,6 +48,14 @@ #define M_PI 3.1415926536 #endif +// win64 doesn't define GWL_USERDATA +#ifdef WIN32 +#ifndef GWL_USERDATA +#define GWL_USERDATA GWLP_USERDATA +#define GWL_WNDPROC GWLP_WNDPROC +#endif +#endif + LPCSTR GHOST_WindowWin32::s_windowClassName = "GHOST_WindowClass"; const int GHOST_WindowWin32::s_maxTitleLength = 128; HGLRC GHOST_WindowWin32::s_firsthGLRc = NULL; diff --git a/intern/iksolver/intern/IK_QTask.h b/intern/iksolver/intern/IK_QTask.h index c291a0e7e50..4d469d737f8 100644 --- a/intern/iksolver/intern/IK_QTask.h +++ b/intern/iksolver/intern/IK_QTask.h @@ -74,7 +74,7 @@ public: virtual bool PositionTask() const { return false; } - virtual void Scale(float scale) {} + virtual void Scale(float) {} protected: int m_id; diff --git a/intern/moto/include/GEN_Map.h b/intern/moto/include/GEN_Map.h index db3335d6110..9f56924419e 100644 --- a/intern/moto/include/GEN_Map.h +++ b/intern/moto/include/GEN_Map.h @@ -82,6 +82,24 @@ public: } return 0; } + + Key* getKey(int index) { + int count=0; + for (int i=0;im_key; + } + bucket = bucket->m_next; + count++; + } + } + return 0; + } void clear() { for (int i = 0; i < m_num_buckets; ++i) { diff --git a/intern/moto/include/MT_random.h b/intern/moto/include/MT_random.h index d7da546cf03..3afe1dd1662 100644 --- a/intern/moto/include/MT_random.h +++ b/intern/moto/include/MT_random.h @@ -31,10 +31,10 @@ #include -#define MT_RAND_MAX ULONG_MAX +#define MT_RAND_MAX UINT_MAX -extern void MT_srand(unsigned long); -extern unsigned long MT_rand(); +extern void MT_srand(unsigned int); +extern unsigned int MT_rand(); #endif diff --git a/intern/moto/intern/MT_random.cpp b/intern/moto/intern/MT_random.cpp index 96cb394d3da..b8302e093ca 100644 --- a/intern/moto/intern/MT_random.cpp +++ b/intern/moto/intern/MT_random.cpp @@ -76,11 +76,11 @@ #define TEMPERING_SHIFT_T(y) (y << 15) #define TEMPERING_SHIFT_L(y) (y >> 18) -static unsigned long mt[N]; /* the array for the state vector */ +static unsigned int mt[N]; /* the array for the state vector */ static int mti = N+1; /* mti==N+1 means mt[N] is not initialized */ /* initializing the array with a NONZERO seed */ -void MT_srand(unsigned long seed) +void MT_srand(unsigned int seed) { /* setting initial seeds to mt[N] using */ /* the generator Line 25 of Table 1 in */ @@ -91,12 +91,12 @@ void MT_srand(unsigned long seed) mt[mti] = (69069 * mt[mti-1]) & 0xffffffff; } -unsigned long MT_rand() +unsigned int MT_rand() { - static unsigned long mag01[2] = { 0x0, MATRIX_A }; + static unsigned int mag01[2] = { 0x0, MATRIX_A }; /* mag01[x] = x * MATRIX_A for x=0,1 */ - unsigned long y; + unsigned int y; if (mti >= N) { /* generate N words at one time */ int kk; -- cgit v1.2.3 From 20af6c61e8d76764d29e800924963fd770ae5acd Mon Sep 17 00:00:00 2001 From: Ian Thompson Date: Tue, 22 Jul 2008 14:56:02 +0000 Subject: Bugfix: Pasting non-text data (or trying to retrieve non-text data from the clipboard) crashed blender on Windows. --- intern/ghost/intern/GHOST_SystemWin32.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'intern') diff --git a/intern/ghost/intern/GHOST_SystemWin32.cpp b/intern/ghost/intern/GHOST_SystemWin32.cpp index f5c7c08ebfe..0b42fb80295 100644 --- a/intern/ghost/intern/GHOST_SystemWin32.cpp +++ b/intern/ghost/intern/GHOST_SystemWin32.cpp @@ -919,6 +919,8 @@ GHOST_TUns8* GHOST_SystemWin32::getClipboard(int flag) const if ( OpenClipboard(NULL) ) { HANDLE hData = GetClipboardData( CF_TEXT ); + if (hData == NULL) + return NULL; buffer = (char*)GlobalLock( hData ); temp_buff = (char*) malloc(strlen(buffer)+1); -- cgit v1.2.3 From 6d0e840648b1349302ea20891598806beddb6714 Mon Sep 17 00:00:00 2001 From: Ian Thompson Date: Tue, 22 Jul 2008 15:31:22 +0000 Subject: Bug fix for the bug fix. Wasn't closing the clipboard before returning. Thanks b333rt for catching this. --- intern/ghost/intern/GHOST_SystemWin32.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'intern') diff --git a/intern/ghost/intern/GHOST_SystemWin32.cpp b/intern/ghost/intern/GHOST_SystemWin32.cpp index 0b42fb80295..7bc20d38739 100644 --- a/intern/ghost/intern/GHOST_SystemWin32.cpp +++ b/intern/ghost/intern/GHOST_SystemWin32.cpp @@ -917,10 +917,12 @@ GHOST_TUns8* GHOST_SystemWin32::getClipboard(int flag) const char *buffer; char *temp_buff; - if ( OpenClipboard(NULL) ) { + if ( IsClipboardFormatAvailable(CF_TEXT) && OpenClipboard(NULL) ) { HANDLE hData = GetClipboardData( CF_TEXT ); - if (hData == NULL) + if (hData == NULL) { + CloseClipboard(); return NULL; + } buffer = (char*)GlobalLock( hData ); temp_buff = (char*) malloc(strlen(buffer)+1); -- cgit v1.2.3 From ed972db1a3a2aa7f340e4382b4f0094681b34ed3 Mon Sep 17 00:00:00 2001 From: Ian Thompson Date: Sat, 9 Aug 2008 10:12:59 +0000 Subject: Merge from trunk: 15912:16031 --- intern/boolop/SConscript | 2 +- intern/boolop/intern/BOP_Interface.cpp | 2 +- intern/boolop/make/msvc_7_0/boolop.vcproj | 9 +++++++++ intern/bsp/SConscript | 2 +- 4 files changed, 12 insertions(+), 3 deletions(-) (limited to 'intern') diff --git a/intern/boolop/SConscript b/intern/boolop/SConscript index a3f3c0b6433..bec263f251f 100644 --- a/intern/boolop/SConscript +++ b/intern/boolop/SConscript @@ -8,7 +8,7 @@ incs += ' ../../source/blender/makesdna ../../intern/guardedalloc' incs += ' ../../source/blender/blenlib' if (env['OURPLATFORM'] == 'win32-mingw'): - env.BlenderLib ('blender_bop', sources, Split(incs) , [], libtype=['common','intern'], priority = [5,50] ) + env.BlenderLib ('blender_bop', sources, Split(incs) , [], libtype=['common','intern'], priority = [30,85] ) else: env.BlenderLib ('blender_bop', sources, Split(incs) , [], libtype='common', priority = 5 ) diff --git a/intern/boolop/intern/BOP_Interface.cpp b/intern/boolop/intern/BOP_Interface.cpp index 898ca708204..c6bcb4a74ce 100644 --- a/intern/boolop/intern/BOP_Interface.cpp +++ b/intern/boolop/intern/BOP_Interface.cpp @@ -37,7 +37,7 @@ #include "BOP_Chrono.h" #if defined(BOP_ORIG_MERGE) && defined(BOP_NEW_MERGE) -#include "../../source/blender/blenkernel/BKE_global.h" +#include "../../../source/blender/blenkernel/BKE_global.h" #endif BoolOpState BOP_intersectionBoolOp(BOP_Mesh* meshC, diff --git a/intern/boolop/make/msvc_7_0/boolop.vcproj b/intern/boolop/make/msvc_7_0/boolop.vcproj index 7ae417e42d5..6e6d6abeb43 100644 --- a/intern/boolop/make/msvc_7_0/boolop.vcproj +++ b/intern/boolop/make/msvc_7_0/boolop.vcproj @@ -278,6 +278,9 @@ ECHO Done + + @@ -330,9 +333,15 @@ ECHO Done + + + + diff --git a/intern/bsp/SConscript b/intern/bsp/SConscript index 88d2529ae59..39f278625a9 100644 --- a/intern/bsp/SConscript +++ b/intern/bsp/SConscript @@ -6,7 +6,7 @@ sources = env.Glob('intern/*.cpp') incs = 'intern ../container ../moto/include ../memutil' if (env['OURPLATFORM'] == 'win32-mingw'): - env.BlenderLib ('blender_BSP', sources, Split(incs), [], libtype=['common','intern'], priority=[26,26] ) + env.BlenderLib ('blender_BSP', sources, Split(incs), [], libtype=['common','intern'], priority=[26,69] ) else: env.BlenderLib ('blender_BSP', sources, Split(incs), [], libtype='core', priority=26 ) -- cgit v1.2.3 From 3bab89cc1c51e80e15efb4f5d751940ac06001a4 Mon Sep 17 00:00:00 2001 From: Ian Thompson Date: Sat, 30 Aug 2008 14:32:16 +0000 Subject: Merge from trunk 16122-16307 --- intern/guardedalloc/BLO_sys_types.h | 125 +++++++++++++++++++++ intern/guardedalloc/intern/mallocn.c | 12 +- intern/guardedalloc/intern/mmap_win.c | 2 +- .../guardedalloc/make/msvc_7_0/guardedalloc.vcproj | 3 + intern/guardedalloc/mmap_win.h | 4 +- intern/opennl/make/msvc_7_0/opennl.vcproj | 3 + intern/opennl/superlu/BLO_sys_types.h | 125 +++++++++++++++++++++ intern/opennl/superlu/smemory.c | 10 +- 8 files changed, 273 insertions(+), 11 deletions(-) create mode 100644 intern/guardedalloc/BLO_sys_types.h create mode 100644 intern/opennl/superlu/BLO_sys_types.h (limited to 'intern') diff --git a/intern/guardedalloc/BLO_sys_types.h b/intern/guardedalloc/BLO_sys_types.h new file mode 100644 index 00000000000..5ed3117c890 --- /dev/null +++ b/intern/guardedalloc/BLO_sys_types.h @@ -0,0 +1,125 @@ +/** + * $Id$ + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + * A platform-independent definition of [u]intXX_t + * Plus the accompanying header include for htonl/ntohl + * + * This file includes to define [u]intXX_t types, where + * XX can be 8, 16, 32 or 64. Unfortunately, not all systems have this + * file. + * - Windows uses __intXX compiler-builtin types. These are signed, + * so we have to flip the signs. + * For these rogue platforms, we make the typedefs ourselves. + * + */ + +/* +// DG: original BLO_sys_types.h is in source/blender/blenkernel +// but is not allowed be accessed here because of bad-level-call +*/ + +#ifndef BLO_SYS_TYPES_H +#define BLO_SYS_TYPES_H + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(_WIN32) && !defined(FREE_WINDOWS) + +/* The __intXX are built-in types of the visual complier! So we don't + * need to include anything else here. */ + +typedef signed __int8 int8_t; +typedef signed __int16 int16_t; +typedef signed __int32 int32_t; +typedef signed __int64 int64_t; + +typedef unsigned __int8 uint8_t; +typedef unsigned __int16 uint16_t; +typedef unsigned __int32 uint32_t; +typedef unsigned __int64 uint64_t; + +#ifndef _INTPTR_T_DEFINED +#ifdef _WIN64 +typedef __int64 intptr_t; +#else +typedef long intptr_t; +#endif +#define _INTPTR_T_DEFINED +#endif + +#ifndef _UINTPTR_T_DEFINED +#ifdef _WIN64 +typedef unsigned __int64 uintptr_t; +#else +typedef unsigned long uintptr_t; +#endif +#define _UINTPTR_T_DEFINED +#endif + +#elif defined(__linux__) + + /* Linux-i386, Linux-Alpha, Linux-ppc */ +#include + +#elif defined (__APPLE__) + +#include + +#elif defined(FREE_WINDOWS) + +#include + +#else + + /* FreeBSD, Irix, Solaris */ +#include + +#endif /* ifdef platform for types */ + +#ifdef _WIN32 +#ifndef htonl +#define htonl(x) correctByteOrder(x) +#endif +#ifndef ntohl +#define ntohl(x) correctByteOrder(x) +#endif +#elif defined (__FreeBSD__) || defined (__OpenBSD__) +#include +#elif defined (__APPLE__) +#include +#else /* irix sun linux */ +#include +#endif /* ifdef platform for htonl/ntohl */ + +#ifdef __cplusplus +} +#endif + +#endif /* eof */ + diff --git a/intern/guardedalloc/intern/mallocn.c b/intern/guardedalloc/intern/mallocn.c index 25f2fd8d269..a36549d0cc7 100644 --- a/intern/guardedalloc/intern/mallocn.c +++ b/intern/guardedalloc/intern/mallocn.c @@ -49,6 +49,8 @@ #include "MEM_guardedalloc.h" +#include "BLO_sys_types.h" // needed for intptr_t + /* --------------------------------------------------------------------- */ /* Data definition */ /* --------------------------------------------------------------------- */ @@ -112,7 +114,7 @@ static const char *check_memlist(MemHead *memh); volatile int totblock= 0; -volatile unsigned long mem_in_use= 0, mmap_in_use= 0; +volatile uintptr_t mem_in_use= 0, mmap_in_use= 0; static volatile struct localListBase _membase; static volatile struct localListBase *membase = &_membase; @@ -335,7 +337,7 @@ void *MEM_mapallocN(unsigned int len, const char *str) /* Memory statistics print */ typedef struct MemPrintBlock { const char *name; - unsigned long len; + uintptr_t len; int items; } MemPrintBlock; @@ -485,14 +487,14 @@ short MEM_freeN(void *vmemh) /* anders compileertie niet meer */ return(-1); } - if(sizeof(long)==8) { - if (((long) memh) & 0x7) { + if(sizeof(intptr_t)==8) { + if (((intptr_t) memh) & 0x7) { MemorY_ErroR("free","attempt to free illegal pointer"); return(-1); } } else { - if (((long) memh) & 0x3) { + if (((intptr_t) memh) & 0x3) { MemorY_ErroR("free","attempt to free illegal pointer"); return(-1); } diff --git a/intern/guardedalloc/intern/mmap_win.c b/intern/guardedalloc/intern/mmap_win.c index 436c99344a7..642cc16296e 100644 --- a/intern/guardedalloc/intern/mmap_win.c +++ b/intern/guardedalloc/intern/mmap_win.c @@ -151,7 +151,7 @@ void *mmap(void *start, size_t len, int prot, int flags, int fd, off_t offset) } /* munmap for windows */ -long munmap(void *ptr, long size) +intptr_t munmap(void *ptr, intptr_t size) { MemMap *mm = mmap_findlink(mmapbase, ptr); if (!mm) { diff --git a/intern/guardedalloc/make/msvc_7_0/guardedalloc.vcproj b/intern/guardedalloc/make/msvc_7_0/guardedalloc.vcproj index 40e88511d5d..974acef4e70 100644 --- a/intern/guardedalloc/make/msvc_7_0/guardedalloc.vcproj +++ b/intern/guardedalloc/make/msvc_7_0/guardedalloc.vcproj @@ -261,6 +261,9 @@ ECHO Done + + diff --git a/intern/guardedalloc/mmap_win.h b/intern/guardedalloc/mmap_win.h index f83a2d64b18..443c3b6f4ce 100644 --- a/intern/guardedalloc/mmap_win.h +++ b/intern/guardedalloc/mmap_win.h @@ -45,8 +45,10 @@ #define MAP_FAILED ((void *)-1) +#include "BLO_sys_types.h" // needed for intptr_t + void *mmap(void *start, size_t len, int prot, int flags, int fd, off_t offset); -long munmap(void *ptr, long size); +intptr_t munmap(void *ptr, intptr_t size); #endif diff --git a/intern/opennl/make/msvc_7_0/opennl.vcproj b/intern/opennl/make/msvc_7_0/opennl.vcproj index ec999b0c252..d302a2508ab 100644 --- a/intern/opennl/make/msvc_7_0/opennl.vcproj +++ b/intern/opennl/make/msvc_7_0/opennl.vcproj @@ -715,6 +715,9 @@ ECHO Done + + diff --git a/intern/opennl/superlu/BLO_sys_types.h b/intern/opennl/superlu/BLO_sys_types.h new file mode 100644 index 00000000000..5ed3117c890 --- /dev/null +++ b/intern/opennl/superlu/BLO_sys_types.h @@ -0,0 +1,125 @@ +/** + * $Id$ + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + * A platform-independent definition of [u]intXX_t + * Plus the accompanying header include for htonl/ntohl + * + * This file includes to define [u]intXX_t types, where + * XX can be 8, 16, 32 or 64. Unfortunately, not all systems have this + * file. + * - Windows uses __intXX compiler-builtin types. These are signed, + * so we have to flip the signs. + * For these rogue platforms, we make the typedefs ourselves. + * + */ + +/* +// DG: original BLO_sys_types.h is in source/blender/blenkernel +// but is not allowed be accessed here because of bad-level-call +*/ + +#ifndef BLO_SYS_TYPES_H +#define BLO_SYS_TYPES_H + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(_WIN32) && !defined(FREE_WINDOWS) + +/* The __intXX are built-in types of the visual complier! So we don't + * need to include anything else here. */ + +typedef signed __int8 int8_t; +typedef signed __int16 int16_t; +typedef signed __int32 int32_t; +typedef signed __int64 int64_t; + +typedef unsigned __int8 uint8_t; +typedef unsigned __int16 uint16_t; +typedef unsigned __int32 uint32_t; +typedef unsigned __int64 uint64_t; + +#ifndef _INTPTR_T_DEFINED +#ifdef _WIN64 +typedef __int64 intptr_t; +#else +typedef long intptr_t; +#endif +#define _INTPTR_T_DEFINED +#endif + +#ifndef _UINTPTR_T_DEFINED +#ifdef _WIN64 +typedef unsigned __int64 uintptr_t; +#else +typedef unsigned long uintptr_t; +#endif +#define _UINTPTR_T_DEFINED +#endif + +#elif defined(__linux__) + + /* Linux-i386, Linux-Alpha, Linux-ppc */ +#include + +#elif defined (__APPLE__) + +#include + +#elif defined(FREE_WINDOWS) + +#include + +#else + + /* FreeBSD, Irix, Solaris */ +#include + +#endif /* ifdef platform for types */ + +#ifdef _WIN32 +#ifndef htonl +#define htonl(x) correctByteOrder(x) +#endif +#ifndef ntohl +#define ntohl(x) correctByteOrder(x) +#endif +#elif defined (__FreeBSD__) || defined (__OpenBSD__) +#include +#elif defined (__APPLE__) +#include +#else /* irix sun linux */ +#include +#endif /* ifdef platform for htonl/ntohl */ + +#ifdef __cplusplus +} +#endif + +#endif /* eof */ + diff --git a/intern/opennl/superlu/smemory.c b/intern/opennl/superlu/smemory.c index 79da748671a..7eefb900673 100644 --- a/intern/opennl/superlu/smemory.c +++ b/intern/opennl/superlu/smemory.c @@ -8,6 +8,8 @@ */ #include "ssp_defs.h" +#include "BLO_sys_types.h" // needed for intptr_t + /* Constants */ #define NO_MEMTYPE 4 /* 0: lusup; 1: ucol; @@ -49,8 +51,8 @@ static int no_expand; /* Macros to manipulate stack */ #define StackFull(x) ( x + stack.used >= stack.size ) -#define NotDoubleAlign(addr) ( (long int)addr & 7 ) -#define DoubleAlign(addr) ( ((long int)addr + 7) & ~7L ) +#define NotDoubleAlign(addr) ( (intptr_t)addr & 7 ) +#define DoubleAlign(addr) ( ((intptr_t)addr + 7) & ~7L ) #define TempSpace(m, w) ( (2*w + 4 + NO_MARKER) * m * sizeof(int) + \ (w + 1) * m * sizeof(float) ) #define Reduce(alpha) ((alpha + 1) / 2) /* i.e. (alpha-1)/2 + 1 */ @@ -611,8 +613,8 @@ sStackCompress(GlobalLU_t *Glu) last = (char*)usub + xusub[ndim] * iword; fragment = (char*) (((char*)stack.array + stack.top1) - last); - stack.used -= (long int) fragment; - stack.top1 -= (long int) fragment; + stack.used -= (intptr_t) fragment; + stack.top1 -= (intptr_t) fragment; Glu->ucol = ucol; Glu->lsub = lsub; -- cgit v1.2.3 From 33ac84e888ee3e3217f15f955e1b389a9c4bb230 Mon Sep 17 00:00:00 2001 From: Daniel Genrich Date: Wed, 3 Sep 2008 00:00:32 +0000 Subject: Compile fixes (reported by broken) --- intern/opennl/superlu/BLO_sys_types.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'intern') diff --git a/intern/opennl/superlu/BLO_sys_types.h b/intern/opennl/superlu/BLO_sys_types.h index 5ed3117c890..411a8582f96 100644 --- a/intern/opennl/superlu/BLO_sys_types.h +++ b/intern/opennl/superlu/BLO_sys_types.h @@ -54,6 +54,7 @@ extern "C" { /* The __intXX are built-in types of the visual complier! So we don't * need to include anything else here. */ + typedef signed __int8 int8_t; typedef signed __int16 int16_t; typedef signed __int32 int32_t; @@ -102,6 +103,7 @@ typedef unsigned long uintptr_t; #endif /* ifdef platform for types */ + #ifdef _WIN32 #ifndef htonl #define htonl(x) correctByteOrder(x) -- cgit v1.2.3 From cb89decfdcf5e6b2f26376d416633f4ccf0c532d Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 4 Sep 2008 20:51:28 +0000 Subject: Merge of first part of changes from the apricot branch, especially the features that are needed to run the game. Compile tested with scons, make, but not cmake, that seems to have an issue not related to these changes. The changes include: * GLSL support in the viewport and game engine, enable in the game menu in textured draw mode. * Synced and merged part of the duplicated blender and gameengine/ gameplayer drawing code. * Further refactoring of game engine drawing code, especially mesh storage changed a lot. * Optimizations in game engine armatures to avoid recomputations. * A python function to get the framerate estimate in game. * An option take object color into account in materials. * An option to restrict shadow casters to a lamp's layers. * Increase from 10 to 18 texture slots for materials, lamps, word. An extra texture slot shows up once the last slot is used. * Memory limit for undo, not enabled by default yet because it needs the .B.blend to be changed. * Multiple undo for image painting. * An offset for dupligroups, so not all objects in a group have to be at the origin. --- intern/guardedalloc/MEM_guardedalloc.h | 10 ++++++++-- intern/guardedalloc/intern/mallocn.c | 21 +++++++++++++++++---- intern/memutil/MEM_Allocator.h | 1 + intern/memutil/MEM_CacheLimiter.h | 12 ++++++------ intern/memutil/intern/MEM_CacheLimiterC-Api.cpp | 8 ++++---- intern/moto/include/GEN_Map.h | 13 +++++++++++++ intern/moto/include/MT_Matrix4x4.h | 1 + intern/moto/include/MT_Matrix4x4.inl | 14 +++++++------- 8 files changed, 57 insertions(+), 23 deletions(-) (limited to 'intern') diff --git a/intern/guardedalloc/MEM_guardedalloc.h b/intern/guardedalloc/MEM_guardedalloc.h index d004e7952cc..1d4c753802b 100644 --- a/intern/guardedalloc/MEM_guardedalloc.h +++ b/intern/guardedalloc/MEM_guardedalloc.h @@ -58,8 +58,8 @@ #ifndef MEM_MALLOCN_H #define MEM_MALLOCN_H -/* Needed for FILE* */ -#include "stdio.h" +#include "stdio.h" /* needed for FILE* */ +#include "BLO_sys_types.h" /* needed for uintptr_t */ #ifdef __cplusplus extern "C" { @@ -123,6 +123,12 @@ extern "C" { /** Attempt to enforce OSX (or other OS's) to have malloc and stack nonzero */ void MEM_set_memory_debug(void); + /* Memory usage stats + * - MEM_get_memory_in_use is all memory + * - MEM_get_mapped_memory_in_use is a subset of all memory */ + uintptr_t MEM_get_memory_in_use(void); + uintptr_t MEM_get_mapped_memory_in_use(void); + int MEM_get_memory_blocks_in_use(void); #ifdef __cplusplus } diff --git a/intern/guardedalloc/intern/mallocn.c b/intern/guardedalloc/intern/mallocn.c index a36549d0cc7..7bdca7339fc 100644 --- a/intern/guardedalloc/intern/mallocn.c +++ b/intern/guardedalloc/intern/mallocn.c @@ -49,8 +49,6 @@ #include "MEM_guardedalloc.h" -#include "BLO_sys_types.h" // needed for intptr_t - /* --------------------------------------------------------------------- */ /* Data definition */ /* --------------------------------------------------------------------- */ @@ -113,8 +111,8 @@ static const char *check_memlist(MemHead *memh); /* --------------------------------------------------------------------- */ -volatile int totblock= 0; -volatile uintptr_t mem_in_use= 0, mmap_in_use= 0; +static volatile int totblock= 0; +static volatile uintptr_t mem_in_use= 0, mmap_in_use= 0; static volatile struct localListBase _membase; static volatile struct localListBase *membase = &_membase; @@ -698,4 +696,19 @@ static const char *check_memlist(MemHead *memh) return(name); } +uintptr_t MEM_get_memory_in_use(void) +{ + return mem_in_use; +} + +uintptr_t MEM_get_mapped_memory_in_use(void) +{ + return mmap_in_use; +} + +int MEM_get_memory_blocks_in_use(void) +{ + return totblock; +} + /* eof */ diff --git a/intern/memutil/MEM_Allocator.h b/intern/memutil/MEM_Allocator.h index d5ae94cc6b8..b2c3c5e82e2 100644 --- a/intern/memutil/MEM_Allocator.h +++ b/intern/memutil/MEM_Allocator.h @@ -25,6 +25,7 @@ #define __MEM_Allocator_h_included__ 1 #include "guardedalloc/MEM_guardedalloc.h" +#include "guardedalloc/BLO_sys_types.h" #ifdef _MSC_VER #if _MSC_VER < 1300 // 1200 == VC++ 6.0 according to boost diff --git a/intern/memutil/MEM_CacheLimiter.h b/intern/memutil/MEM_CacheLimiter.h index cada06ae523..43149efc977 100644 --- a/intern/memutil/MEM_CacheLimiter.h +++ b/intern/memutil/MEM_CacheLimiter.h @@ -61,11 +61,8 @@ class MEM_CacheLimiter; #ifndef __MEM_cache_limiter_c_api_h_included__ extern "C" { - extern void MEM_CacheLimiter_set_maximum(int m); - extern int MEM_CacheLimiter_get_maximum(); - // this is rather _ugly_! - extern int mem_in_use; - extern int mmap_in_use; + extern void MEM_CacheLimiter_set_maximum(intptr_t m); + extern intptr_t MEM_CacheLimiter_get_maximum(); }; #endif @@ -141,7 +138,10 @@ public: delete handle; } void enforce_limits() { - int max = MEM_CacheLimiter_get_maximum(); + intptr_t max = MEM_CacheLimiter_get_maximum(); + intptr_t mem_in_use= MEM_get_memory_in_use(); + intptr_t mmap_in_use= MEM_get_mapped_memory_in_use(); + if (max == 0) { return; } diff --git a/intern/memutil/intern/MEM_CacheLimiterC-Api.cpp b/intern/memutil/intern/MEM_CacheLimiterC-Api.cpp index 4cf0ef305d4..d998c9a3e80 100644 --- a/intern/memutil/intern/MEM_CacheLimiterC-Api.cpp +++ b/intern/memutil/intern/MEM_CacheLimiterC-Api.cpp @@ -27,18 +27,18 @@ #include "MEM_CacheLimiter.h" #include "MEM_CacheLimiterC-Api.h" -static int & get_max() +static intptr_t & get_max() { - static int m = 32*1024*1024; + static intptr_t m = 32*1024*1024; return m; } -void MEM_CacheLimiter_set_maximum(int m) +void MEM_CacheLimiter_set_maximum(intptr_t m) { get_max() = m; } -int MEM_CacheLimiter_get_maximum() +intptr_t MEM_CacheLimiter_get_maximum() { return get_max(); } diff --git a/intern/moto/include/GEN_Map.h b/intern/moto/include/GEN_Map.h index 9f56924419e..d85e9af175b 100644 --- a/intern/moto/include/GEN_Map.h +++ b/intern/moto/include/GEN_Map.h @@ -50,6 +50,19 @@ public: m_buckets[i] = 0; } } + + GEN_Map(const GEN_Map& map) + { + m_num_buckets = map.m_num_buckets; + m_buckets = new Entry *[m_num_buckets]; + + for (int i = 0; i < m_num_buckets; ++i) { + m_buckets[i] = 0; + + for(Entry *entry = map.m_buckets[i]; entry; entry=entry->m_next) + insert(entry->m_key, entry->m_value); + } + } int size() { int count=0; diff --git a/intern/moto/include/MT_Matrix4x4.h b/intern/moto/include/MT_Matrix4x4.h index 823541347b7..b4ee84a718b 100644 --- a/intern/moto/include/MT_Matrix4x4.h +++ b/intern/moto/include/MT_Matrix4x4.h @@ -212,6 +212,7 @@ public: MT_Matrix4x4 transposed() const; void transpose(); + MT_Matrix4x4 inverse() const; void invert(); protected: diff --git a/intern/moto/include/MT_Matrix4x4.inl b/intern/moto/include/MT_Matrix4x4.inl index a2aa893a6b3..074bd6e4b05 100644 --- a/intern/moto/include/MT_Matrix4x4.inl +++ b/intern/moto/include/MT_Matrix4x4.inl @@ -52,14 +52,14 @@ GEN_INLINE void MT_Matrix4x4::invert() { } } -/* We do things slightly different here, because the invert() modifies - * the buffer itself. This makes it impossible to make this op right - * away. Like other, still missing facilities, I will repair this - * later. */ -/* GEN_INLINE T_Matrix4x4 MT_Matrix4x4::inverse() const */ -/* { */ -/* } */ +GEN_INLINE MT_Matrix4x4 MT_Matrix4x4::inverse() const +{ + MT_Matrix4x4 invmat = *this; + + invmat.invert(); + return invmat; +} GEN_INLINE MT_Matrix4x4& MT_Matrix4x4::operator*=(const MT_Matrix4x4& m) { -- cgit v1.2.3