mirror of
https://github.com/torvalds/linux.git
synced 2026-01-24 23:16:46 +00:00
scripts/sorttable: Make compare_extable() into two functions
Instead of having the compare_extable() part of the sorttable.h header
where it get's defined twice, since it is a very simple function, just
define it twice in sorttable.c, and then it can use the proper read
functions for the word size and endianess and the Elf_Addr macro can be
removed from sorttable.h.
Also add a micro optimization. Instead of:
if (a < b)
return -1;
if (a > b)
return 1;
return 0;
That can be shorten to:
if (a < b)
return -1;
return a > b;
Cc: bpf <bpf@vger.kernel.org>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Masahiro Yamada <masahiroy@kernel.org>
Cc: Nathan Chancellor <nathan@kernel.org>
Cc: Nicolas Schier <nicolas@fjasle.eu>
Cc: Zheng Yejian <zhengyejian1@huawei.com>
Cc: Martin Kelly <martin.kelly@crowdstrike.com>
Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Link: https://lore.kernel.org/20250105162344.945299671@goodmis.org
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
This commit is contained in:
committed by
Steven Rostedt (Google)
parent
66990c0033
commit
7ffc0d0819
@@ -173,6 +173,26 @@ static inline unsigned int get_secindex(unsigned int shndx,
|
||||
return r(&symtab_shndx_start[sym_offs]);
|
||||
}
|
||||
|
||||
static int compare_extable_32(const void *a, const void *b)
|
||||
{
|
||||
Elf32_Addr av = r(a);
|
||||
Elf32_Addr bv = r(b);
|
||||
|
||||
if (av < bv)
|
||||
return -1;
|
||||
return av > bv;
|
||||
}
|
||||
|
||||
static int compare_extable_64(const void *a, const void *b)
|
||||
{
|
||||
Elf64_Addr av = r8(a);
|
||||
Elf64_Addr bv = r8(b);
|
||||
|
||||
if (av < bv)
|
||||
return -1;
|
||||
return av > bv;
|
||||
}
|
||||
|
||||
/* 32 bit and 64 bit are very similar */
|
||||
#include "sorttable.h"
|
||||
#define SORTTABLE_64
|
||||
|
||||
Reference in New Issue
Block a user