From fd0072e77cd28d52e00ea77542ba6d11018889b5 Mon Sep 17 00:00:00 2001 From: Daniel Genrich Date: Sun, 17 Aug 2008 17:08:00 +0000 Subject: Win64: please check my changes if you ran across them ;) But should be fine since no additional crashes were reported! --- intern/guardedalloc/BLO_sys_types.h | 112 ++++++++++++++++++++++++++++++++++ intern/guardedalloc/intern/mallocn.c | 12 ++-- intern/guardedalloc/intern/mmap_win.c | 2 +- intern/guardedalloc/mmap_win.h | 4 +- intern/opennl/superlu/BLO_sys_types.h | 112 ++++++++++++++++++++++++++++++++++ intern/opennl/superlu/smemory.c | 10 +-- 6 files changed, 241 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..17fa99308e0 --- /dev/null +++ b/intern/guardedalloc/BLO_sys_types.h @@ -0,0 +1,112 @@ +/** + * $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 + +#ifdef FREE_WINDOWS +typedef unsigned char uint8_t; +typedef unsigned int uint32_t; +#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; + +#ifdef _WIN64 +typedef __int64 intptr_t; +typedef unsigned __int64 uintptr_t; +#else +typedef long intptr_t; +typedef unsigned long uintptr_t; +#endif + +#elif defined(__linux__) + + /* Linux-i386, Linux-Alpha, Linux-ppc */ +#include + +#elif defined (__APPLE__) + +#include + +#else + + /* FreeBSD, Irix, Solaris */ +#include + +#endif /* ifdef platform for types */ + +#ifdef _WIN32 +#define htonl(x) correctByteOrder(x) +#define ntohl(x) correctByteOrder(x) +#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/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/superlu/BLO_sys_types.h b/intern/opennl/superlu/BLO_sys_types.h new file mode 100644 index 00000000000..17fa99308e0 --- /dev/null +++ b/intern/opennl/superlu/BLO_sys_types.h @@ -0,0 +1,112 @@ +/** + * $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 + +#ifdef FREE_WINDOWS +typedef unsigned char uint8_t; +typedef unsigned int uint32_t; +#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; + +#ifdef _WIN64 +typedef __int64 intptr_t; +typedef unsigned __int64 uintptr_t; +#else +typedef long intptr_t; +typedef unsigned long uintptr_t; +#endif + +#elif defined(__linux__) + + /* Linux-i386, Linux-Alpha, Linux-ppc */ +#include + +#elif defined (__APPLE__) + +#include + +#else + + /* FreeBSD, Irix, Solaris */ +#include + +#endif /* ifdef platform for types */ + +#ifdef _WIN32 +#define htonl(x) correctByteOrder(x) +#define ntohl(x) correctByteOrder(x) +#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 9f6109002b158e4285d7c88ffc573f2cd4ac62ce Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Sun, 17 Aug 2008 22:28:30 +0000 Subject: Fix compile problem in MSVC after Win64 patch --- intern/guardedalloc/BLO_sys_types.h | 16 +++++++++++++++- intern/opennl/superlu/BLO_sys_types.h | 16 +++++++++++++++- 2 files changed, 30 insertions(+), 2 deletions(-) (limited to 'intern') diff --git a/intern/guardedalloc/BLO_sys_types.h b/intern/guardedalloc/BLO_sys_types.h index 17fa99308e0..4d3ffbe023d 100644 --- a/intern/guardedalloc/BLO_sys_types.h +++ b/intern/guardedalloc/BLO_sys_types.h @@ -69,13 +69,23 @@ 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; -typedef unsigned __int64 uintptr_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__) @@ -94,8 +104,12 @@ typedef unsigned long uintptr_t; #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__) diff --git a/intern/opennl/superlu/BLO_sys_types.h b/intern/opennl/superlu/BLO_sys_types.h index 17fa99308e0..4d3ffbe023d 100644 --- a/intern/opennl/superlu/BLO_sys_types.h +++ b/intern/opennl/superlu/BLO_sys_types.h @@ -69,13 +69,23 @@ 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; -typedef unsigned __int64 uintptr_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__) @@ -94,8 +104,12 @@ typedef unsigned long uintptr_t; #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__) -- cgit v1.2.3 From ed9a0fe7e940f6eaa306e7ca9876b98a3251d4a2 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Sun, 17 Aug 2008 22:32:40 +0000 Subject: Update MSVC project files after Win64 patch --- intern/guardedalloc/make/msvc_7_0/guardedalloc.vcproj | 3 +++ intern/opennl/make/msvc_7_0/opennl.vcproj | 3 +++ 2 files changed, 6 insertions(+) (limited to 'intern') 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/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 + + -- cgit v1.2.3 From f876fd66b4bced68e4771f051186023d142cfa5e Mon Sep 17 00:00:00 2001 From: Daniel Genrich Date: Mon, 18 Aug 2008 10:37:15 +0000 Subject: Fixing compile errors on mingw/cygwin (reported by aligorith) --- intern/guardedalloc/BLO_sys_types.h | 4 ++++ intern/opennl/superlu/BLO_sys_types.h | 4 ++++ 2 files changed, 8 insertions(+) (limited to 'intern') diff --git a/intern/guardedalloc/BLO_sys_types.h b/intern/guardedalloc/BLO_sys_types.h index 4d3ffbe023d..953b2ebad46 100644 --- a/intern/guardedalloc/BLO_sys_types.h +++ b/intern/guardedalloc/BLO_sys_types.h @@ -96,6 +96,10 @@ typedef unsigned long uintptr_t; #include +#elif defined(FREE_WINDOWS) + +#include + #else /* FreeBSD, Irix, Solaris */ diff --git a/intern/opennl/superlu/BLO_sys_types.h b/intern/opennl/superlu/BLO_sys_types.h index 4d3ffbe023d..953b2ebad46 100644 --- a/intern/opennl/superlu/BLO_sys_types.h +++ b/intern/opennl/superlu/BLO_sys_types.h @@ -96,6 +96,10 @@ typedef unsigned long uintptr_t; #include +#elif defined(FREE_WINDOWS) + +#include + #else /* FreeBSD, Irix, Solaris */ -- cgit v1.2.3 From a84d346939d2da10abc70c9e5670828f66f26437 Mon Sep 17 00:00:00 2001 From: Daniel Genrich Date: Mon, 18 Aug 2008 10:48:37 +0000 Subject: #2: Fixing compile errors on mingw/cygwin (reported by aligorith) --- intern/guardedalloc/BLO_sys_types.h | 5 ----- intern/opennl/superlu/BLO_sys_types.h | 5 ----- 2 files changed, 10 deletions(-) (limited to 'intern') diff --git a/intern/guardedalloc/BLO_sys_types.h b/intern/guardedalloc/BLO_sys_types.h index 953b2ebad46..5ed3117c890 100644 --- a/intern/guardedalloc/BLO_sys_types.h +++ b/intern/guardedalloc/BLO_sys_types.h @@ -48,11 +48,6 @@ #ifdef __cplusplus extern "C" { #endif - -#ifdef FREE_WINDOWS -typedef unsigned char uint8_t; -typedef unsigned int uint32_t; -#endif #if defined(_WIN32) && !defined(FREE_WINDOWS) diff --git a/intern/opennl/superlu/BLO_sys_types.h b/intern/opennl/superlu/BLO_sys_types.h index 953b2ebad46..5ed3117c890 100644 --- a/intern/opennl/superlu/BLO_sys_types.h +++ b/intern/opennl/superlu/BLO_sys_types.h @@ -48,11 +48,6 @@ #ifdef __cplusplus extern "C" { #endif - -#ifdef FREE_WINDOWS -typedef unsigned char uint8_t; -typedef unsigned int uint32_t; -#endif #if defined(_WIN32) && !defined(FREE_WINDOWS) -- cgit v1.2.3