ZooKeeper
  1. ZooKeeper
  2. ZOOKEEPER-1635

ZooKeeper C client doesn't compile on 64 bit Windows

    Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Invalid
    • Affects Version/s: None
    • Fix Version/s: 3.5.0
    • Component/s: None
    • Labels:
      None
    • Environment:

      Windows x64 systems.

      Description

      x64 target does not support _asm inline (See: http://msdn.microsoft.com/en-us/library/4ks26t93(v=vs.80).aspx)

      The proposal is to use native windows function which still valid for i386 and x64 architecture.

      In order to avoid any potential break, a compilation directive has been added. But, the best should be the removal of the asm part.

      -----------
      sample code
      -----------

      int32_t fetch_and_add(volatile int32_t* operand, int incr)
      {
      #ifndef WIN32
      int32_t result;
      asm _volatile_(
      "lock xaddl %0,%1\n"
      : "=r"(result), "=m"(*(int *)operand)
      : "0"(incr)
      : "memory");
      return result;
      #else

      #ifdef WIN32_NOASM
      InterlockedExchangeAdd(operand, incr);
      return *operand;
      #else
      volatile int32_t result;
      _asm

      { mov eax, operand; //eax = v; mov ebx, incr; // ebx = i; mov ecx, 0x0; // ecx = 0; lock xadd dword ptr [eax], ecx; lock xadd dword ptr [eax], ebx; mov result, ecx; // result = ebx; }

      return result;*/
      #endif

      #endif
      }

        Activity

        Tomas Gutierrez created issue -
        Tomas Gutierrez made changes -
        Field Original Value New Value
        Description x64 target does not support _asm inline (See: http://msdn.microsoft.com/en-us/library/4ks26t93(v=vs.80).aspx)

        The proposal is to use native windows function which still valid for i386 and x64 architecture.

        In order to avoid any potential break, a compilation directive has been added. But, the best should be the removal of the asm part.
        x64 target does not support _asm inline (See: http://msdn.microsoft.com/en-us/library/4ks26t93(v=vs.80).aspx)

        The proposal is to use native windows function which still valid for i386 and x64 architecture.

        In order to avoid any potential break, a compilation directive has been added. But, the best should be the removal of the asm part.


        -----------
        sample code
        -----------


        int32_t fetch_and_add(volatile int32_t* operand, int incr)
        {
        #ifndef WIN32
            int32_t result;
            asm __volatile__(
                 "lock xaddl %0,%1\n"
                 : "=r"(result), "=m"(*(int *)operand)
                 : "0"(incr)
                 : "memory");
           return result;
        #else

        #ifdef WIN32_NOASM
                        InterlockedExchangeAdd(operand, incr);
                        return *operand;
        #else
            volatile int32_t result;
            _asm
            {
                mov eax, operand; //eax = v;
               mov ebx, incr; // ebx = i;
                mov ecx, 0x0; // ecx = 0;
                lock xadd dword ptr [eax], ecx;
               lock xadd dword ptr [eax], ebx;
                mov result, ecx; // result = ebx;
             }
             return result;*/
        #endif

        #endif
        }
        Tomas Gutierrez made changes -
        Fix Version/s 3.5.0 [ 12316644 ]
        Michi Mutsuzaki made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Invalid [ 6 ]
        Michi Mutsuzaki made changes -
        Summary Support x64 architecture for Windows ZooKeeper C client doesn't compile on 64 bit Windows

          People

          • Assignee:
            Unassigned
            Reporter:
            Tomas Gutierrez
          • Votes:
            10 Vote for this issue
            Watchers:
            8 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development