Homesource Forums

Homeworld Source Editing Talk
It is currently Mon Sep 25, 2017 10:52 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Gcc v4
PostPosted: Mon Nov 13, 2006 7:09 am 
Offline
coder

Joined: Tue Nov 07, 2006 4:40 am
Posts: 236
Hi.

I'm not sure if it is relevant here or elsewhere, but after looking at the various forums I've elected to put it here. :)

I've read the threads about the work involved in updating the code to work with the later, more stringent versions of GCC. I've had a look at some of the code and acknowledge that it is going to be a lage task. :)

With that in mind I wondered if there was anything I could do which could help the process without breaking anything that's already in place. I've some experience with ASM from years ago and I've looked at the sections of the source which fail to compile in GCC v4.1. I've modified a few functions in a handfull of files which now compiles correctly in v4 but more importantly also still compiles (without errors) and works in the currently required v3 of GCC. It still needs a few comments to say what changes I've made, but I'd be happy to post the diffs here or mail the changes to whoever wants to have a look at them.

Aunxx.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 13, 2006 1:07 pm 
Offline
coder
User avatar

Joined: Wed Oct 04, 2006 8:13 pm
Posts: 94
Location: UTC -0500
sure, post the diffs here if not too large (or post them somewhere else, maybe pastebin http://www.google.com/search?&q=pastebin ).
lmop may give you commit access, not sure.

currently, I'm not aware of anyone, besides you, fixing some code for gcc4

_________________
http://againsttcpa.com/what-is-tcpa.html
http://google.com/search?q=c+programming+faq
http://research.att.com/~bs
acronyms.ch, neworder.box.sk


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 14, 2006 6:51 am 
Offline
coder

Joined: Tue Nov 07, 2006 4:40 am
Posts: 236
Hi.

This is only tested on a couple of Linux boxes, and the game continues to run in the limited tests I tried. GCC v3 stops giving errors, and it compiles with GCC v4. This doesn't mean that the game runs after compiling with v4, just that less of it fails. :D
Still more to do, but it's keeping me out of the pub. :)

Code:
Index: rgl/asm.c
===================================================================
--- rgl/asm.c   (revision 248)
+++ rgl/asm.c   (working copy)
@@ -606,6 +606,7 @@
 void asm_cliptest(
     GLuint n, GLfloat* d, GLubyte* clipmask, GLubyte* ormask, GLubyte* andmask)
 {
+   static char * Local_clip_table = (char*) clip_table; // Needs to be defined locally for GCC v4
 #if defined (_MSC_VER)
     _asm
     {
@@ -783,7 +784,7 @@
         "    movb %%ah, (%%esi)\n"
         :
         : "m" (ormask), "m" (andmask), "m" (n), "m" (clipmask), "m" (d),
-          "m" (clip_table)
+          "m" (Local_clip_table)
         : "eax", "ecx", "edx", "edi", "esi" );
 #endif
 }
@@ -1296,6 +1297,7 @@
     static int n __attribute__ ((aligned (16)));
     static __m128 Zero __attribute__ ((aligned (16)));
     static float* m __attribute__ ((aligned (16)));
+    const static char * Local_Mask =  (char *) Mask; // Needs to be defined locally for GCC v4
 #endif
 
     n = (count + 3) & (~3);
@@ -1457,7 +1459,7 @@
         "    jnz     xmmproject_start\n"
         :
         : "S" (m), "c" (n), "a" (source), "d" (dest),
-          "m" (Mask) );
+          "m" (Local_Mask) );
 #endif
 }

Code:
Index: SDL/font.c
===================================================================
--- SDL/font.c  (revision 248)
+++ SDL/font.c  (working copy)
@@ -849,7 +849,7 @@
 
         if (header->character[index] != NULL)
         {
-            (ubyte *)header->character[index] += (udword)fileHeader;//fix up character pointer
+               header->character[index] = (udword)fileHeader + (ubyte *)header->character[index];
 #ifdef ENDIAN_BIG
                        header->character[index]->width   = LittleShort( header->character[index]->width );
                        header->character[index]->height  = LittleShort( header->character[index]->height );

Code:
Index: Game/KNITransform.c
===================================================================
--- Game/KNITransform.c (revision 248)
+++ Game/KNITransform.c (working copy)
@@ -284,6 +284,7 @@
     static float* mat0;
     static float* mat1;
 
+    static char * Local_Mask;
     static MM_ALIGN16_PRE __m128 nextX MM_ALIGN16_POST;
 
     //matrices
@@ -296,6 +297,7 @@
     mat0 = (float*)mat;
     mat1 = (float*)per;
 
+    Local_Mask = (char*) Mask;
     _mm_prefetch((char*)m0, 0);
 
     //vectorize nVerts
@@ -698,7 +700,7 @@
         : "m" (m0), "m" (mat0), "m" (m1), "m" (mat1),
           "m" (n), "m" (source), "m" (dest),
           "m" (nextX),
-          "m" (Mask)
+          "m" (Local_Mask)
           : "eax", "edx", "ecx", "edi", "esi" );
 #endif
 }

Code:
Index: Game/Task.c
===================================================================
--- Game/Task.c (revision 248)
+++ Game/Task.c (working copy)
@@ -218,6 +218,7 @@
 ----------------------------------------------------------------------------*/
 taskhandle taskStart(taskfunction function, real32 period, udword flags)
 {
+    static char  * Local_taskData; // GCC v4 needs locally defined value
     static taskhandle handle = ERROR;
     taskdata *newTask;
     static void *taskFunctionContinueSave;
@@ -240,6 +241,7 @@
     handle = taskPointerAlloc();                            //alloc and save the
     taskData[handle] = newTask;                             //newest task pointer
 
+    Local_taskData= (char *)taskData;
 #if TASK_VERBOSE_LEVEL >= 2
     dbgMessagef("\ntaskStart: starting task at 0x%x at %d Hz, flags 0x%x using handle %d at 0x%x",
                function, 1.0f/period, flags, handle, taskData[handle]);
@@ -402,7 +404,7 @@
         :
         : "m" (taskESISave), "m" (taskEDISave), "m" (taskESPSave),
           "m" (taskEBPSave), "m" (taskEBXSave),
-          "m" (function), "m" (handle), "m" (taskData)
+          "m" (function), "m" (handle), "m" (Local_taskData)
 #if TASK_STACK_SAVE
           , "m" (taskESPSaveInitial)
 #endif
@@ -470,6 +472,8 @@
 static sdword tTicks, tLocalTicks;
 sdword taskExecuteAllPending(sdword ticks)
 {
+    static char * Local_taskData;
+    Local_taskData= (char *)taskData;
 #if TASK_STACK_SAVE
     static ubyte localStack[BIT8];
     static ubyte *currentESP;
@@ -780,7 +784,7 @@
                     "    movl %%eax, "TOF_Context_STR"+20(%%edx)\n"  /*ebp*/
 /*#endif*/
                     :
-                    : "m" (taskCurrentTask), "m" (taskData)
+                    : "m" (taskCurrentTask), "m" (Local_taskData)
                     : "eax", "edx" );
 #endif
 


I've just noticed that the diffs I've added here are for svn version 248. I believe that the files should still work with the latest version, but I'll check.

Aunxx


Top
 Profile  
 
PostPosted: Tue Nov 14, 2006 9:15 am 
Offline
coder

Joined: Tue Nov 07, 2006 4:40 am
Posts: 236
Hi,

I made the changes to the latest svn code, and it all still compiled.
I think I sorted most of the tricky stuff earlier and I've continued to modify the failing files in the same vein as before.

I also just removed the -fwriteable-strings to get past compiling the missions. Not very thorough but it allowed me to fully compile the homeworld binary using GCC v4.1

I've left it running and I intend to play a few missions to see if it's stable.

I'll see if I can break it over the next few hours. :)

Aunxx


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 14, 2006 11:56 am 
Offline
Site Admin
User avatar

Joined: Tue Dec 14, 2004 12:41 am
Posts: 326
Yay! :)

Also, post stuff like this here if you like.

If it gets too extensive I'll just copy any extra-long articles to a text file on homesource and link it back here.

But so far this is just fine as far as the forum goes.


Top
 Profile  
 
 Post subject: Uploaded
PostPosted: Thu Nov 16, 2006 12:14 pm 
Offline
coder

Joined: Tue Nov 07, 2006 4:40 am
Posts: 236
Hi.

I've uploaded the code, details are in

http://homesource.nekomimicon.net/sourceforum/viewtopic.php?t=120

Please let me know if it's broken anything and I'll probably suggest revering the code back and I'll look again. :)

Aunxx.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group