View Single Post
  #11  
Old 03-14-2010, 05:09 PM
snorkle
Fire Beetle
 
Join Date: Oct 2009
Posts: 3
Default

I had to make some changes to get the old VZTZ source to work in Linux. I'm not sure what revision their source was based on but I ended up scrapping it for 8.0. Here's one of the things I had to change to get it to work with newer gcc versions:

Code:
vztzfebsource-read-only/common$ svn diff crc32.cpp
Index: crc32.cpp
===================================================================
--- crc32.cpp   (revision 7)
+++ 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:
@@ -167,8 +175,8 @@
 #elif defined(i386)
        register uint32  val __asm ( "ax" );
        val = crc32;
-
 __asm __volatile (
+       "push   %%ebx\n"
        "xorl   %%ebx, %%ebx\n"
        "movl   %1, %%esi\n"
        "movl   %2, %%ecx\n"
@@ -232,9 +240,10 @@
        "xorb   2(%%esi), %%bl\n"
        "xorl   (%%edi,%%ebx,4), %%eax\n"
    "2:\n"
+       "pop  %%ebx\n"
        :
        : "a" (val), "g" (buf), "g" (bufsize)
-       : "bx", "cx", "dx", "si", "di"
+       : "cx", "dx", "si", "di"
    );

    return val;

Last edited by gaeorn; 03-29-2010 at 02:16 AM.. Reason: add code tags around code block
Reply With Quote