Porting Lagoon to AMD 64 Avatar

From LagoonWiki

Jump to: navigation, search

Notes for changing the source to compile on 64 bit:

In: externalPackages/tnl/tnlTypes.h

Find
 #include <stdlib.h>
Insert below it:
 #include <inttypes.h>

In: externalPackages/tnl/netStringTable.cpp

Find:
 if(mNodeList[i] && !(U32(mNodeList[i]) & 1))
Replace with:
 if(mNodeList[i] && !(uintptr_t(mNodeList[i]) & 1))
Find:
 walk = StringTableEntryId(mNodeList[walk >> 1]); 
Replace with:
 walk = StringTableEntryId((uintptr_t)mNodeList[walk >> 1]);
Find:
 TNLAssert((U32(node) & 1) == 0, "Free list entry in node chain!!!"); 
Replace with:
 TNLAssert((uintptr_t(node) & 1) == 0, "Free list entry in node chain!!!");
Find:
 mNodeListFreeEntry = (StringTableEntryId) mNodeList[mNodeListFreeEntry >> 1];
Replace with:
 mNodeListFreeEntry = (uintptr_t)mNodeList[mNodeListFreeEntry >> 1];
Find:
 if(((StringTableEntryId) theNode) & 1 || theNode == NULL)
Replace with:
 if(((uintptr_t)theNode) & 1 || theNode == NULL)

In: code/defines.mak:

Find:
 INCDIR += $(IPATH_OPT)$(NOMADS_HOME)/externalPackages/devil/lagoon/include
Replace with:
 #INCDIR += $(IPATH_OPT)$(NOMADS_HOME)/externalPackages/devil/lagoon/include

In: code/inc/kernel/nipcserver.h

Find:
 #include "kernel/ndefdllclass.h"
Insert below it:
 #include <inttypes.h>

In: code/src/kernel/nipcserver.cc

Find:
 outClientId = (int) nd->GetPtr();
Replace with:
 outClientId = (uintptr_t)nd->GetPtr();

In: code/inc/kernel/nipcminiserver.h

Find:
 #ifndef N_NODE_H
 #include "util/nnode.h"
 #endif
Insert below it:
 #include <inttypes.h>

In: code/src/kernel/nipcminiserver.cc

Find:
 n_printf("client %d: connection accepted.\n", (int) this);
Replace with:
 n_printf("client %d: connection accepted.\n", (uintptr_t)this);

In: code/inc/gfx/ntexturearray.h

Find:
 #ifndef N_GFXSERVER_H
 #include "gfx/ngfxserver.h"
 #endif
Insert below it:
 #include <inttypes.h>
Find:
 int t0,t1;
 if (this->ref_texarray[i].isvalid())  t0 = int(this->ref_texarray[i].get());
 else                                  t0 = 0;
 if (other->ref_texarray[i].isvalid()) t1 = int(other->ref_texarray[i].get());
 else                                  t1 = 0;
 int d = t1-t0;
 if (d != 0) return d;
Replace with:
 uintptr_t t0,t1;
 if (this->ref_texarray[i].isvalid())  t0 = uintptr_t(this->ref_texarray[i].get());
 else                                  t0 = 0;
 if (other->ref_texarray[i].isvalid()) t1 = uintptr_t(other->ref_texarray[i].get());
 else                                  t1 = 0;
 uintptr_t d = t1-t0;
 if (d != 0) return (int)d;

In: code/inc/opcode/OPC_AABBTree.h

Find:
 #ifndef __OPC_AABBTREE_H__
 #define __OPC_AABBTREE_H__
Insert below it:
 #include <inttypes.h>

In: code/src/opcode/OPC_AABBTree.cc

Find:
 mPos = udword(&Pool[Count+0])|1;
 #ifndef OPC_NO_NEG_VANILLA_TREE
 mNeg = udword(&Pool[Count+1])|1;
 
Replace with:
 mPos = int(uintptr_t(&Pool[Count+0]))|1;
 #ifndef OPC_NO_NEG_VANILLA_TREE
 mNeg = int(uintptr_t(&Pool[Count+1]))|1;
Find:
 mPos = (udword)PosNeg;
Replace with:
 mPos = int((uintptr_t)PosNeg);

In: code/inc/opcode/OPC_HybridModel.h

Find:
 #ifndef __OPC_HYBRIDMODEL_H__
 #define __OPC_HYBRIDMODEL_H__
Insert below it:
 #include <inttypes.h>

In: code/src/opcode/OPC_HybridModel.cc

Find:
 udword Index = (udword(current->GetPrimitives()) - udword(Data->mBase))/sizeof(udword);
Replace with:
 udword Index = (udword(uintptr_t(current->GetPrimitives())) - udword(uintptr_t(Data->mBase)))/sizeof(udword);

In: code/inc/opcode/OPC_OptimizedTree.h

Find:
 #ifndef __OPC_OPTIMIZEDTREE_H__
 #define __OPC_OPTIMIZEDTREE_H__
Insert below it:
 #include <inttypes.h>

In: code/src/opcode/OPC_OptimizedTree.cc

Find:
 linear[box_id].mData = (udword)&linear[PosID];
Replace with:
 linear[box_id].mData = (udword)uintptr_t(&linear[PosID]);
Find:
 linear[box_id].mPosData = (udword)&linear[PosID];
Replace with:
 linear[box_id].mPosData = (udword)uintptr_t(&linear[PosID]);
Find:
 linear[box_id].mNegData = (udword)&linear[NegID];
Replace with:
 linear[box_id].mNegData = (udword)uintptr_t(&linear[NegID]);
Find:
 Data = udword(&mNodes[Nb]);				\
Replace with:
 Data = udword(uintptr_t(&mNodes[Nb]));		\
Find:
 udword Nb = (Data - udword(Nodes))/Nodes[i].GetNodeSize();	\
Replace with:
 udword Nb = (Data - udword(uintptr_t(Nodes)))/Nodes[i].GetNodeSize();	\


In: externalPackages/tnl/tnlTypes.h

Find
 #include <stdlib.h>
Insert below it:
 #include <inttypes.h>

In: externalPackages/tnl/netStringTable.cpp

Find:
 if(mNodeList[i] && !(U32(mNodeList[i]) & 1))
Replace with:
 if(mNodeList[i] && !(uintptr_t(mNodeList[i]) & 1))
Find:
 walk = StringTableEntryId(mNodeList[walk >> 1]); 
Replace with:
 walk = StringTableEntryId((uintptr_t)mNodeList[walk >> 1]);
Find:
 TNLAssert((U32(node) & 1) == 0, "Free list entry in node chain!!!"); 
Replace with:
 TNLAssert((uintptr_t(node) & 1) == 0, "Free list entry in node chain!!!");
Find:
 mNodeListFreeEntry = (StringTableEntryId) mNodeList[mNodeListFreeEntry >> 1];
Replace with:
 mNodeListFreeEntry = (uintptr_t)mNodeList[mNodeListFreeEntry >> 1];
Find:
 if(((StringTableEntryId) theNode) & 1 || theNode == NULL)
Replace with:
 if(((uintptr_t)theNode) & 1 || theNode == NULL)

In: code/defines.mak:

Find:
 INCDIR += $(IPATH_OPT)$(NOMADS_HOME)/externalPackages/devil/lagoon/include
Replace with:
 #INCDIR += $(IPATH_OPT)$(NOMADS_HOME)/externalPackages/devil/lagoon/include

In: code/inc/kernel/nipcserver.h

Find:
 #include "kernel/ndefdllclass.h"
Insert below it:
 #include <inttypes.h>

In: code/src/kernel/nipcserver.cc

Find:
 outClientId = (int) nd->GetPtr();
Replace with:
 outClientId = (uintptr_t)nd->GetPtr();

In: code/inc/kernel/nipcminiserver.h

Find:
 #ifndef N_NODE_H
 #include "util/nnode.h"
 #endif
Insert below it:
 #include <inttypes.h>

In: code/src/kernel/nipcminiserver.cc

Find:
 n_printf("client %d: connection accepted.\n", (int) this);
Replace with:
 n_printf("client %d: connection accepted.\n", (uintptr_t)this);

In: code/inc/gfx/ntexturearray.h

Find:
 #ifndef N_GFXSERVER_H
 #include "gfx/ngfxserver.h"
 #endif
Insert below it:
 #include <inttypes.h>
Find:
 int t0,t1;
 if (this->ref_texarray[i].isvalid())  t0 = int(this->ref_texarray[i].get());
 else                                  t0 = 0;
 if (other->ref_texarray[i].isvalid()) t1 = int(other->ref_texarray[i].get());
 else                                  t1 = 0;
 int d = t1-t0;
 if (d != 0) return d;
Replace with:
 uintptr_t t0,t1;
 if (this->ref_texarray[i].isvalid())  t0 = uintptr_t(this->ref_texarray[i].get());
 else                                  t0 = 0;
 if (other->ref_texarray[i].isvalid()) t1 = uintptr_t(other->ref_texarray[i].get());
 else                                  t1 = 0;
 uintptr_t d = t1-t0;
 if (d != 0) return (int)d;

In: code/inc/opcode/OPC_AABBTree.h

Find:
 #ifndef __OPC_AABBTREE_H__
 #define __OPC_AABBTREE_H__
Insert below it:
 #include <inttypes.h>

In: code/src/opcode/OPC_AABBTree.cc

Find:
 mPos = udword(&Pool[Count+0])|1;
 #ifndef OPC_NO_NEG_VANILLA_TREE
 mNeg = udword(&Pool[Count+1])|1;
 
Replace with:
 mPos = int(uintptr_t(&Pool[Count+0]))|1;
 #ifndef OPC_NO_NEG_VANILLA_TREE
 mNeg = int(uintptr_t(&Pool[Count+1]))|1;
Find:
 mPos = (udword)PosNeg;
Replace with:
 mPos = int((uintptr_t)PosNeg);

In: code/inc/opcode/OPC_HybridModel.h

Find:
 #ifndef __OPC_HYBRIDMODEL_H__
 #define __OPC_HYBRIDMODEL_H__
Insert below it:
 #include <inttypes.h>

In: code/src/opcode/OPC_SweepAndPrune.cc

Find:
 if(element)	element = (SAP_Element*)(udword(element) + delta);
Replace with:
 if(element)	element = (SAP_Element*)(uintptr_t(element) + delta);
Find:
 udword Delta = udword(NewElems) - udword(mElementPool);
Replace with:
 udword Delta = udword(uintptr_t(NewElems - mElementPool));
Personal tools