bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 1/2 gnumach] cpu_number: Inline widely used simple function


From: Samuel Thibault
Subject: Re: [PATCH 1/2 gnumach] cpu_number: Inline widely used simple function
Date: Sun, 24 Sep 2023 14:43:10 +0200
User-agent: NeoMutt/20170609 (1.8.3)

Applied, thanks!

Damien Zammit, le dim. 24 sept. 2023 10:34:49 +0000, a ecrit:
> TESTED: on uniprocessor and smp, both behaved as normal.
> 
> ---
>  i386/Makefrag_x86.am   |  1 -
>  i386/i386/cpu_number.c | 30 ------------------------------
>  i386/i386/cpu_number.h | 10 ++++++++--
>  kern/ast.h             |  1 -
>  kern/processor.h       |  3 ++-
>  kern/thread.h          |  3 ++-
>  6 files changed, 12 insertions(+), 36 deletions(-)
>  delete mode 100644 i386/i386/cpu_number.c
> 
> diff --git a/i386/Makefrag_x86.am b/i386/Makefrag_x86.am
> index 46c1d38b..272de023 100644
> --- a/i386/Makefrag_x86.am
> +++ b/i386/Makefrag_x86.am
> @@ -18,7 +18,6 @@ libkernel_a_SOURCES += \
>       i386/i386/ast_check.c \
>       i386/i386/ast_types.h \
>       i386/i386/cpu.h \
> -     i386/i386/cpu_number.c \
>       i386/i386/cpu_number.h \
>       i386/i386/db_disasm.c \
>       i386/i386/db_interface.c \
> diff --git a/i386/i386/cpu_number.c b/i386/i386/cpu_number.c
> deleted file mode 100644
> index ef19e11f..00000000
> --- a/i386/i386/cpu_number.c
> +++ /dev/null
> @@ -1,30 +0,0 @@
> -/*
> - * Copyright (c) 2022 Free Software Foundation, Inc.
> - *
> - * This program is free software: you can redistribute it and/or modify
> - * it under the terms of the GNU General Public License as published by
> - * the Free Software Foundation, either version 2 of the License, or
> - * (at your option) any later version.
> - *
> - * This program is distributed in the hope that it will be useful,
> - * but WITHOUT ANY WARRANTY; without even the implied warranty of
> - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> - * GNU General Public License for more details.
> - *
> - * You should have received a copy of the GNU General Public License
> - * along with this program.  If not, see <http://www.gnu.org/licenses/>.
> - */
> -
> -#include <i386/cpu_number.h>
> -#include <i386/apic.h>
> -#include <i386/smp.h>
> -#include <i386/cpu.h>
> -#include <i386/mp_desc.h>
> -#include <kern/printf.h>
> -
> -#if NCPUS > 1
> -int cpu_number(void)
> -{
> -     return cpu_id_lut[apic_get_current_cpu()];
> -}
> -#endif
> diff --git a/i386/i386/cpu_number.h b/i386/i386/cpu_number.h
> index 479a847a..8357be84 100644
> --- a/i386/i386/cpu_number.h
> +++ b/i386/i386/cpu_number.h
> @@ -64,8 +64,14 @@
>       popl    %esi            ;\
>  
>  #ifndef __ASSEMBLER__
> -#include "kern/cpu_number.h"
> -int cpu_number(void);
> +#include <kern/cpu_number.h>
> +#include <i386/apic.h>
> +
> +static inline int cpu_number(void)
> +{
> +     return cpu_id_lut[apic_get_current_cpu()];
> +}
> +
>  #endif
>  
>  #else        /* NCPUS == 1 */
> diff --git a/kern/ast.h b/kern/ast.h
> index c8cbd04f..aded1677 100644
> --- a/kern/ast.h
> +++ b/kern/ast.h
> @@ -40,7 +40,6 @@
>   *   a set of reasons for an AST, and passing this set to ast_taken.
>   */
>  
> -#include "cpu_number.h"
>  #include <kern/kern_types.h>
>  #include <kern/macros.h>
>  #include <machine/ast.h>
> diff --git a/kern/processor.h b/kern/processor.h
> index 17b784a3..79386627 100644
> --- a/kern/processor.h
> +++ b/kern/processor.h
> @@ -41,7 +41,6 @@
>  #include <mach/kern_return.h>
>  #include <mach/port.h>
>  #include <mach/processor_info.h>
> -#include <kern/cpu_number.h>
>  #include <kern/lock.h>
>  #include <kern/queue.h>
>  #include <kern/sched.h>
> @@ -112,6 +111,8 @@ struct processor {
>  typedef struct processor Processor;
>  extern struct processor      processor_array[NCPUS];
>  
> +#include <kern/cpu_number.h>
> +
>  /*
>   *   Chain of all processor sets.
>   */
> diff --git a/kern/thread.h b/kern/thread.h
> index 8547464d..bf07828a 100644
> --- a/kern/thread.h
> +++ b/kern/thread.h
> @@ -42,7 +42,6 @@
>  #include <mach/port.h>
>  #include <mach/vm_prot.h>
>  #include <kern/ast.h>
> -#include <kern/cpu_number.h>
>  #include <kern/mach_clock.h>
>  #include <kern/queue.h>
>  #include <kern/pc_sample.h>
> @@ -235,6 +234,8 @@ struct thread {
>  #endif
>  };
>  
> +#include <kern/cpu_number.h>
> +
>  /* typedef of thread_t is in kern/kern_types.h */
>  typedef struct thread_shuttle        *thread_shuttle_t;
>  #define THREAD_NULL          ((thread_t) 0)
> -- 
> 2.40.1
> 
> 
> 

-- 
Samuel
---
Pour une évaluation indépendante, transparente et rigoureuse !
Je soutiens la Commission d'Évaluation de l'Inria.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]