lkml.org 
[lkml]   [2015]   [Apr]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] lib/sort: Add 64 bit swap function
Hi Rasmus,

On 04/27/2015 09:45 AM, Rasmus Villemoes wrote:
> On Mon, Apr 27 2015, Daniel Wagner <daniel.wagner@bmw-carit.de> wrote:
>
>> static int cmp_32(const void *a, const void *b)
>> {
>> return (int) (*(u32 *)a - *(u32 *)b);
>> }
>>
>> static int cmp_64(const void *a, const void *b)
>> {
>> return (int) (*(u64 *)a - *(u64 *)b);
>> }
>>
>
> Please [1] don't [2] do [3] this [4].
>
> [1] acbbe6fbb240a927ee1f5994f04d31267d422215 kcmp: fix standard comparison bug
>
> [2] ef17af2a817db97d42dd2ec0a425231748e23dbc fs: nfsd: Fix signedness bug in compare_blob
>
> [3] ddbc22e27e672b6b180757ea1d7f8481dbb88128 fs/hfs/catalog.c: fix comparison bug in hfs_cat_keycmp
>
> [4] 72392ed0eb6fde96826cb9d66bd4f50a7ba61450 kernfs: Fix kernfs_name_compare
>
> (sorry for not actually looking at the patch - this just triggered one
> of my pet peeves).

Thanks for the pointers. I see, even the simplest stuff is not that
simple. I'll keep an eye open for this one :)

In this case though it is not so bad. You are looking at test code. I
used that one to test the performance of the patch not the correctness
since there is the boot-time regression test for the sorting.

The main part of this path is a new u64 swap function:

+static void u64_swap(void *a, void *b, int size)
+{
+ u64 t = *(u64 *)a;
+ *(u64 *)a = *(u64 *)b;
+ *(u64 *)b = t;
+}
+

cheers,
daniel


\
 
 \ /
  Last update: 2015-04-27 12:21    [W:0.025 / U:1.112 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site