[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Minios-devel] [UNIKRAFT PATCH] arch/arm: Copy atomic.h from Arm64 to Arm32
Hi Simon, looks good, thanks. -- Felipe Reviewed-by: Felipe Huici <felipe.huici@xxxxxxxxx> On 07.02.20, 00:20, "Minios-devel on behalf of Simon Kuenzer" <minios-devel-bounces@xxxxxxxxxxxxxxxxxxxx on behalf of simon.kuenzer@xxxxxxxxx> wrote: Copies atomic.h from Arm64 to Arm32. The functions implemented in this header are implemented based on GCC builtins. The architecture does not matter for those functions, so the header works on both architectures. As long as we did not start restructuring arch/ and plat/, copying the header is the most feasible option. Longer-term, the header could become generic. Signed-off-by: Simon Kuenzer <simon.kuenzer@xxxxxxxxx> --- arch/arm/arm/include/uk/asm/atomic.h | 67 ++++++++++++++++++---------- 1 file changed, 44 insertions(+), 23 deletions(-) diff --git a/arch/arm/arm/include/uk/asm/atomic.h b/arch/arm/arm/include/uk/asm/atomic.h index 93ac9867..7319d663 100644 --- a/arch/arm/arm/include/uk/asm/atomic.h +++ b/arch/arm/arm/include/uk/asm/atomic.h @@ -3,7 +3,13 @@ * Port from Mini-OS: include/arm/os.h */ /* - * Copyright (c) 2009 Citrix Systems, Inc. All rights reserved. + * Authors: Karim Allah Ahmed <karim.allah.ahmed@xxxxxxxxx> + * Thomas Leonard <talex5@xxxxxxxxx> + * Wei Chen <Wei.Chen@xxxxxxx> + * + * Copyright (c) 2014 Karim Allah Ahmed + * Copyright (c) 2014 Thomas Leonard + * Copyright (c) 2018, Arm Ltd., All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -32,33 +38,48 @@ #endif /** - * ukarch_ffsl - find first (lowest) set bit in word. + * ukarch_ffs - find first (lowest) set bit in word. * @word: The word to search * - * Undefined if no bit exists, so code should check against 0 first. + * Returns one plus the index of the least significant 1-bit of x, or + * if x is zero, returns zero. + * ffs(1)=0, ffs(0x8000000)=31 */ -static inline unsigned long ukarch_ffsl(unsigned long word) +static inline unsigned int ukarch_ffs(unsigned int x) { - int clz; + return __builtin_ffs(x) - 1; +} - /* xxxxx10000 = word - * xxxxx01111 = word - 1 - * 0000011111 = word ^ (word - 1) - * 4 = 31 - clz(word ^ (word - 1)) - */ +/** + * ukarch_fls - find last (highest) set bit in word. + * @word: The word to search + * + * Undefined if no bit exists, so code should check against 0 first. + * fls(1)=0, fls(0x8000000)=31 + */ +static inline unsigned int ukarch_fls(unsigned int x) +{ + return sizeof(x) * 8 - __builtin_clz(x) - 1; +} - __asm__("sub r0, %[word], #1\n" - "eor r0, r0, %[word]\n" - "clz %[clz], r0\n" - : - /* Outputs: */ - [clz] "=r"(clz) - : - /* Inputs: */ - [word] "r"(word) - : - /* Clobbers: */ - "r0"); +/** + * ukarch_ffsl - find first (lowest) set bit in word. + * @word: The word to search + * + * Undefined if no bit exists, so code should check against 0 first. + */ +static inline unsigned long ukarch_ffsl(unsigned long x) +{ + return __builtin_ffsl(x) - 1; +} - return 31 - clz; +/** + * ukarch_flsl - find last (highest) set bit in word. + * @word: The word to search + * + * Undefined if no bit exists, so code should check against 0 first. + */ +static inline unsigned long ukarch_flsl(unsigned long x) +{ + return sizeof(x) * 8 - __builtin_clzl(x) - 1; } -- 2.20.1 _______________________________________________ Minios-devel mailing list Minios-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/minios-devel _______________________________________________ Minios-devel mailing list Minios-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/minios-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |