diff options
author | Ton Roosendaal <ton@blender.org> | 2007-04-28 20:15:00 +0400 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2007-04-28 20:15:00 +0400 |
commit | 42057481fbb0c7ed3de21a9c72707aab72d1b48c (patch) | |
tree | 3ecc62efb7fa2b61e35c61d4c90e1f32b9e76391 /source/blender/blenlib | |
parent | 6bb16e0c86c553697f6cade8c6e1cd166f993d2c (diff) |
Part 2 of 64 bits fixing; the files.
The good news; previously written 64 bits are still valid! All fixes
appeared to be possible in code, no versioning patches needed. :)
That also removes the I AM STUPID 64 bits ban from the code.
The bad news:
I couldn't get a 64 bits Blender running here (ghost-mac issues... it
has to be recoded using Quartz to be able to run 64 bits). So what I
have tested was:
32 bits binary:
- Appending/linking data from 64 bits file.
- Reading 64 bits chained library-linked files (file -> file -> etc)
- Linking 32 bits files with 64 bits files
This has to be tested for 64 bits too. Will drop in IRC now to help.
Note: part 3 is fixing memory issues for addressing > 4 GB data. A first
start has been made for a blenlib API function.
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r-- | source/blender/blenlib/BLI_blenlib.h | 9 | ||||
-rw-r--r-- | source/blender/blenlib/intern/util.c | 47 |
2 files changed, 55 insertions, 1 deletions
diff --git a/source/blender/blenlib/BLI_blenlib.h b/source/blender/blenlib/BLI_blenlib.h index ad2dbc52d69..6e51d171461 100644 --- a/source/blender/blenlib/BLI_blenlib.h +++ b/source/blender/blenlib/BLI_blenlib.h @@ -1,4 +1,4 @@ -/** +/* * $Id$ * * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** @@ -362,6 +362,13 @@ int BLI_strcasecmp(const char *s1, const char *s2); int BLI_strncasecmp(const char *s1, const char *s2, int n); void BLI_timestr(double time, char *str); +/** + * Trick to address 32 GB with an int (only for malloced pointers) + */ +int BLI_int_from_pointer(void *poin); +void *BLI_pointer_from_int(int val); + + #define PRNTSUB(type,arg) printf(#arg ": %" #type " ", arg) #ifndef PRINT diff --git a/source/blender/blenlib/intern/util.c b/source/blender/blenlib/intern/util.c index 2aa1b852ed3..83e110101dc 100644 --- a/source/blender/blenlib/intern/util.c +++ b/source/blender/blenlib/intern/util.c @@ -1508,4 +1508,51 @@ void BLI_timestr(double time, char *str) str[11]=0; } +/* ************** 64 bits magic, trick to support up to 32 gig of address space *************** */ +/* only works for malloced pointers (8 aligned) */ + +#ifdef __LP64__ + +#if defined(WIN32) && !defined(FREE_WINDOWS) +#define PMASK 0x07FFFFFFFFi64 +#else +#define PMASK 0x07FFFFFFFFll +#endif + + +int BLI_int_from_pointer(void *poin) +{ + long lval= (long)poin; + + return (int)(lval>>3); +} + +void *BLI_pointer_from_int(int val) +{ + static int firsttime= 1; + static long basevalue= 0; + + if(firsttime) { + void *poin= malloc(10000); + basevalue= (long)poin; + basevalue &= ~PMASK; + printf("base: %d pointer %p\n", basevalue, poin); /* debug */ + firsttime= 0; + free(poin); + } + return basevalue | (((long)val)<<3); +} + +#else + +int BLI_int_from_pointer(void *poin) +{ + return (int)poin; +} +void *BLI_pointer_from_int(int val) +{ + return (void *)val; +} + +#endif |