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.
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user