login
Header Space

 
 

Re: Improved Swapping Method In sort.c

Score:
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Soumyadip Das Mahapatra <dip_kernel@...>
Cc: <linux-kernel@...>
Date: Wednesday, April 30, 2008 - 1:33 pm

On Wednesday 2008-04-30 19:09, Soumyadip Das Mahapatra wrote:


That proposal looks like buggy.

19:32 yaguchi:/dev/shm > cat ui.c 
#include <stdint.h>
#include <stdio.h>

static void u32_swap(void *a, void *b)
{
        *(uint32_t *)b ^= *(uint32_t *)a 
                        ^= *(uint32_t *)b
                        ^= *(uint32_t *)a;
}

int main(void)
{
        uint32_t x = 5, y = 7;
        printf("%u %u\n", x, y);
        u32_swap(&x, &y);
        printf("%u %u\n", x, y);
}
19:32 yaguchi:/dev/shm > ./a.out 
5 7
7 0

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Improved Swapping Method In sort.c, Soumyadip Das Mahapatra, (Wed Apr 30, 1:09 pm)
Re: Improved Swapping Method In sort.c, H. Peter Anvin, (Fri May 2, 1:05 am)
Re: Improved Swapping Method In sort.c, David Newall, (Wed Apr 30, 2:46 pm)
Re: Improved Swapping Method In sort.c, Jan Engelhardt, (Wed Apr 30, 1:33 pm)
Re: Improved Swapping Method In sort.c, Sami Farin, (Wed Apr 30, 2:03 pm)
Re: Improved Swapping Method In sort.c, Jan Engelhardt, (Wed Apr 30, 1:30 pm)
speck-geostationary