[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] Use __builtin_ffs instead of libc provided ffs in vm_map.c
From: |
Samuel Thibault |
Subject: |
Re: [PATCH] Use __builtin_ffs instead of libc provided ffs in vm_map.c |
Date: |
Thu, 15 Dec 2022 17:12:48 +0100 |
User-agent: |
NeoMutt/20170609 (1.8.3) |
Applied, thanks!
Flavio Cruz, le mer. 14 déc. 2022 02:35:47 -0500, a ecrit:
> We already this built in in other places and this will move us closer to
> being able to build the kernel without libc.
> ---
> Makefile.am | 4 ++--
> vm/vm_map.c | 4 ++--
> 2 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/Makefile.am b/Makefile.am
> index 684344e2..33f770f6 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -167,13 +167,13 @@ gnumach_o_LINK = $(LD) $(LDFLAGS) -u _start -r -o $@
> noinst_PROGRAMS += \
> gnumach.o
>
> -# This is the list of routines we decide is OK to steal from the C library.
> +# This is the list of routines we decide is OK to steal from the C library
> or libgcc.
> clib_routines := htonl htons ntohl ntohs \
> udivdi3 __udivdi3 __udivmoddi4 __umoddi3 \
> __divdi3 __moddi3 \
> __rel_iplt_start __rel_iplt_end \
> __rela_iplt_start __rela_iplt_end \
> - __ffsdi2 ffs \
> + __ffsdi2 \
> _START _start etext _edata end _end # actually ld magic, not
> libc.
> gnumach-undef: gnumach.$(OBJEXT)
> $(NM_V) $(NM) -u $< | sed 's/ *U *//' | sort -u > $@
> diff --git a/vm/vm_map.c b/vm/vm_map.c
> index ceeb91ee..4200a239 100644
> --- a/vm/vm_map.c
> +++ b/vm/vm_map.c
> @@ -685,10 +685,10 @@ vm_map_find_entry_anywhere(struct vm_map *map,
> if (((mask + 1) & mask) != 0) {
> /* We have high bits in addition to the low bits */
>
> - int first0 = ffs(~mask); /* First zero after low
> bits */
> + int first0 = __builtin_ffs(~mask); /* First zero
> after low bits */
> vm_offset_t lowmask = (1UL << (first0-1)) - 1; /* low
> bits */
> vm_offset_t himask = mask - lowmask; /* high
> bits */
> - int second1 = ffs(himask); /* First one after low
> bits */
> + int second1 = __builtin_ffs(himask); /* First one
> after low bits */
>
> max = 1UL << (second1-1);
>
> --
> 2.37.2
>
>