Go Back   EQEmulator Home > EQEmulator Forums > Development > Development::Server Code Submissions

Reply
 
Thread Tools Display Modes
  #1  
Old 06-10-2009, 08:35 PM
gaeorn
Developer
 
Join Date: Apr 2009
Location: USA
Posts: 478
Default

This patch fixes assembler errors on some 64bit systems.

Code:
Index: common/crc32.cpp
===================================================================
--- common/crc32.cpp    (revision 1)
+++ common/crc32.cpp    (working copy)
@@ -112,6 +112,14 @@
 #undef i386    //darwin seems to think we are generating PIC, and we clobber ebx
 #endif

+/* Some 64bit systems do not like the i386 assembly code below. However, some 64bit
+   systems do work with the assembly code below. We #undef i386 to be on the safe
+   side if we are compiling 64bit. */
+
+#ifdef __x86_64__
+#undef i386
+#endif
+
 uint32 CRC32::Update(const int8* buf, uint32 bufsize, uint32 crc32) {
 #if defined(WIN32)
        // Register use:
Reply With Quote
  #2  
Old 06-10-2009, 08:42 PM
gaeorn
Developer
 
Join Date: Apr 2009
Location: USA
Posts: 478
Default

I did a whole pile of type casts where MakeAnyLenString was being used with %lu in the format string. This patch is over 400 lines long so rather than post it here, it can be retrieved at:
Code:
svn diff -c 8 https://www.tsahosting.net/svn/eqemu64/trunk/
Reply With Quote
  #3  
Old 06-10-2009, 08:50 PM
gaeorn
Developer
 
Join Date: Apr 2009
Location: USA
Posts: 478
Default

The following patch removes the optimize flag (-O) when building common/patches/SoF.o. There is a bug in gcc that causes stringstreams not to work if optimized under 64bit.

Without this patch to the makefile, zone will segfault when a SoF client tries to enter the game (post char select). I also patch the makefile for world since the same object file is linked into world.

Code:
Index: world/makefile
===================================================================
--- world/makefile      (revision 27)
+++ world/makefile      (working copy)
@@ -21,6 +21,8 @@
 MYSQL_FLAGS=$(shell mysql_config --cflags)
 MYSQL_LIB=$(shell mysql_config --libs)

+SOFCOPTS=$(WFLAGS) -g -pthread -pipe -I../common/SocketLib \
+  -DFX -D_GNU_SOURCE -DINVERSEXY -DWORLD $(DFLAGS) $(MYSQL_FLAGS) $(PERL_FLAGS)
 COPTS=$(WFLAGS) -g -O -pthread -pipe -I../common/SocketLib \
   -DFX -D_GNU_SOURCE -DINVERSEXY -DWORLD $(DFLAGS) $(MYSQL_FLAGS) $(PERL_FLAGS)
 LINKOPTS=$(COPTS) -rdynamic -L. -lstdc++ -lm -lz -ldl \
@@ -33,6 +35,9 @@

 include makefile.common

+../common/patches/SoF.o: ../common/patches/SoF.cpp
+        $(CC) $(NOLINK) $(SOFCOPTS) $< $(OUT)$@
+
 .depend depend:
        for f in $(SF); \
        do \
Index: zone/makefile
===================================================================
--- zone/makefile       (revision 27)
+++ zone/makefile       (working copy)
@@ -18,6 +18,7 @@
 PERL_LIB=$(shell perl -MExtUtils::Embed -e ldopts)
 DFLAGS+=-DEMBPERL -DEMBPERL_PLUGIN -DHAS_UNION_SEMUN
 WFLAGS=-fpermissive -Wall -Wuninitialized -Wwrite-strings -Wcast-qual -Wno-deprecated  -Wcomment -Wcast-align
+SOFCOPTS=$(WFLAGS) -g -pthread -pipe -D_GNU_SOURCE -DINVERSEXY -DFX -DZONE $(DFLAGS) $(MYSQL_FLAGS) $(PERL_FLAGS)
 COPTS=$(WFLAGS) -O -g -pthread -pipe -D_GNU_SOURCE -DINVERSEXY -DFX -DZONE $(DFLAGS) $(MYSQL_FLAGS) $(PERL_FLAGS)
 LINKOPTS=$(COPTS) -rdynamic -L. -lstdc++ -ldl $(MYSQL_LIB) $(PERL_LIB)

@@ -27,6 +28,9 @@

 include makefile.common

+../common/patches/SoF.o: ../common/patches/SoF.cpp
+        $(CC) $(NOLINK) $(SOFCOPTS) $< $(OUT)$@
+
 .depend depend:
        for f in $(SF); \
        do \
Reply With Quote
  #4  
Old 06-10-2009, 08:52 PM
gaeorn
Developer
 
Join Date: Apr 2009
Location: USA
Posts: 478
Default

I needed to add this header include to ucs/clientlist.cpp to compile on my system. I do not know if this is a 64bit problem or just my version of gcc.

Code:
Index: ucs/clientlist.cpp
===================================================================
--- ucs/clientlist.cpp  (revision 37)
+++ ucs/clientlist.cpp  (revision 38)
@@ -31,6 +31,7 @@
 #include "../common/EmuTCPServer.h"
 #include <list>
 #include <vector>
+#include <algorithm>
 #include <string>
 #include <cstdlib>
Reply With Quote
  #5  
Old 06-10-2009, 09:51 PM
gaeorn
Developer
 
Join Date: Apr 2009
Location: USA
Posts: 478
Default

Just realized I hadn't given credit to ndnet for his work on the patch that fixed the missing augments. He is the one who found that fix.
Reply With Quote
  #6  
Old 06-15-2009, 02:00 AM
KLS
Administrator
 
Join Date: Sep 2006
Posts: 1,348
Default

I'll try to get to this stuff in the next few days, sorry I almost forgot about it.
Reply With Quote
  #7  
Old 06-15-2009, 02:35 AM
gaeorn
Developer
 
Join Date: Apr 2009
Location: USA
Posts: 478
Default

No worries. I just figured they could be done one at a time as time permits. Thanks.
Reply With Quote
  #8  
Old 06-17-2009, 08:22 PM
gaeorn
Developer
 
Join Date: Apr 2009
Location: USA
Posts: 478
Default

Quote:
Originally Posted by gaeorn View Post
I needed to add this header include to ucs/clientlist.cpp to compile on my system. I do not know if this is a 64bit problem or just my version of gcc.

Code:
Index: ucs/clientlist.cpp
===================================================================
--- ucs/clientlist.cpp  (revision 37)
+++ ucs/clientlist.cpp  (revision 38)
@@ -31,6 +31,7 @@
 #include "../common/EmuTCPServer.h"
 #include <list>
 #include <vector>
+#include <algorithm>
 #include <string>
 #include <cstdlib>
You can ignore this patch as Derision already updated the SVN with a fix.
Reply With Quote
  #9  
Old 06-18-2009, 12:58 AM
KLS
Administrator
 
Join Date: Sep 2006
Posts: 1,348
Default

I was gonna commit some of this tonight but I ran into some issues; not entirely your fault.

Some comments:

There is no va_copy() on windows.
I also don't believe socklen_t is defined type on windows, though I didn't look into it further.
Reply With Quote
  #10  
Old 06-18-2009, 01:23 AM
gaeorn
Developer
 
Join Date: Apr 2009
Location: USA
Posts: 478
Default

The va_copy() probably could be replaced with a memcpy. The socklen_t could be inside an #ifdef.

Feel free to do whatever you think is best. And fyi, I know C much better than I know C++, so if there are better ways of doing things, change it
Reply With Quote
  #11  
Old 06-18-2009, 01:45 AM
gaeorn
Developer
 
Join Date: Apr 2009
Location: USA
Posts: 478
Default

Quote:
Originally Posted by KLS View Post
There is no va_copy() on windows.
This should work for windows:

va_list apcopy = ap;

From what I was reading, va_copy is just the following define in most cases:

#define va_copy(d,s) ((d) = (s))
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 05:45 AM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3