title: Should 64bit Compare&Swap (CAS) work on a 32bit machine?  (or 64bit machine?)
body: <p>So I read that in a 32bit machine, one can use the <code>CAS</code> operation with aligned 64bit blocks.
  Similarly, in a 64bit machine, one can use the <code>CAS</code> operation with aligned 128bit blocks.</p>
  <p>I'm using a 32bit machine so I tried the following:</p>
  <pre><code>// sizeof(long long) is 8 bytes, so 64 bits
  long long y = 12;
  long long z = 12;
  long long x = 99;
  __sync_bool_compare_and_swap(&amp;y, z, x);
  </code></pre>
  <p>and the <code>CAS</code> succeeded changing the value of  <code>y</code> to <code>99</code>.</p>
  <p>But then I tried using a <code>char array[8];</code>(which size is 64 bits) instead of a <code>long long</code>. And I do:</p>
  <pre><code>char full[8] = {'0', '1', '2', '3', '4', '5', '6', '7'}; 
  char full2[8] = {'0', '1', '2', '3', '4', '5', '6', '7'};   
  char full3[8] = {'5', '8', '9', 'G', 'X', '5', '6', 'U'};
  __sync_bool_compare_and_swap(full, full2, full3);  
  </code></pre>
  <p>But in this case, the <code>CAS</code> fails although <code>full</code> and <code>full2</code> have exactly the same data. (I also checked that <code>full</code> and <code>full2</code> where correctly alligned)</p>
  <p>So the first time it seems that a <code>CAS</code> can be used to 64bit, but the second time it seems it can't. Any ideas why?</p>
  <h2><strong>EDIT</strong></h2>
  <h3>(How about 64bit machines?)</h3>
  <p>Ok, so the problem was that I was using <code>char *</code> in my <code>CAS</code> and these were only checked. So the solution was to cast to <code>long long</code> or to <code>uint64_t</code> which are 64bit values.</p>
  <p>But what should I do with a 64bit machine when I need to use 128bit value? <code>long long</code> is still 64bit in a 64bit machine and <code>uint128_t</code> doesn't seem to exist in C. <strong>So to which type should I cast?</strong> <code>double long</code> seems to be 128bit in my 64bit machine, but when doing the following:</p>
  <pre><code>  double long y = 32432143243214;
    double long z = 32432143243214;
  
    int x = __sync_bool_compare_and_swap(&amp;y, z, 1234321990);
  </code></pre>
  <p>I get this compile error
  <code> error: incompatible type for argument 1 of ‘__sync_bool_compare_and_swap’</code>.</p>