From 6ef670c379cfd7a76da9fbb7d6a632568bfc249f Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Thu, 3 Jan 2019 14:45:23 -0500 Subject: [PATCH] freebsd_network: Consolidate and unify SMP-related definitions. Previously I implemented "curcpu" as ipro1000 used it, independent of all the other SMP functions, as an optimization. Now, iflib wants to use these functions all together, so they have to produce consistent results. --- src/libs/compat/freebsd_network/Jamfile | 1 - .../compat/freebsd_network/compat/sys/param.h | 3 --- .../compat/freebsd_network/compat/sys/pcpu.h | 3 +-- .../compat/freebsd_network/compat/sys/smp.h | 7 +++++-- src/libs/compat/freebsd_network/pcpu.cpp | 18 ------------------ 5 files changed, 6 insertions(+), 26 deletions(-) delete mode 100644 src/libs/compat/freebsd_network/pcpu.cpp diff --git a/src/libs/compat/freebsd_network/Jamfile b/src/libs/compat/freebsd_network/Jamfile index 7280b5919b..2914d4e8f3 100644 --- a/src/libs/compat/freebsd_network/Jamfile +++ b/src/libs/compat/freebsd_network/Jamfile @@ -41,7 +41,6 @@ KernelStaticLibrary libfreebsd_network.a : mbuf.c mii.c mutex.c - pcpu.cpp priv.cpp smp.c subr_autoconf.cpp diff --git a/src/libs/compat/freebsd_network/compat/sys/param.h b/src/libs/compat/freebsd_network/compat/sys/param.h index 5d5ed02b0f..d955744be7 100644 --- a/src/libs/compat/freebsd_network/compat/sys/param.h +++ b/src/libs/compat/freebsd_network/compat/sys/param.h @@ -68,9 +68,6 @@ #error Need definition of CACHE_LINE_SIZE for this arch! #endif -/* defined in platform_kernel_args.h as SMP_MAX_CPUS */ -#define MAXCPU 64 /* SMP_MAX_CPUS */ - /* Macros for counting and rounding. */ #ifndef howmany #define howmany(x, y) (((x)+((y)-1))/(y)) diff --git a/src/libs/compat/freebsd_network/compat/sys/pcpu.h b/src/libs/compat/freebsd_network/compat/sys/pcpu.h index 9900e8e5f2..a10975a5e5 100644 --- a/src/libs/compat/freebsd_network/compat/sys/pcpu.h +++ b/src/libs/compat/freebsd_network/compat/sys/pcpu.h @@ -7,12 +7,11 @@ #include +#include struct thread; -int get_curcpu(); -#define curcpu (get_curcpu()) #define curthread ((struct thread*)NULL) /* NOTE: Dereferencing curthread will crash, which is intentional. There is no FreeBSD compatible struct thread and Haiku's should not be used as it diff --git a/src/libs/compat/freebsd_network/compat/sys/smp.h b/src/libs/compat/freebsd_network/compat/sys/smp.h index 62a79e5d7f..eff700817c 100644 --- a/src/libs/compat/freebsd_network/compat/sys/smp.h +++ b/src/libs/compat/freebsd_network/compat/sys/smp.h @@ -1,5 +1,5 @@ /* - * Copyright 2014 Haiku Inc. All rights reserved. + * Copyright 2014-2019, Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. */ #ifndef _FBSD_COMPAT_SYS_SMP_H_ @@ -20,7 +20,7 @@ static inline int cpu_next(int i) { i++; - if (i > mp_maxid) + if (i > (int)mp_maxid) i = 0; return i; } @@ -28,5 +28,8 @@ cpu_next(int i) #define CPU_FIRST() cpu_first() #define CPU_NEXT(i) cpu_next((i)) +#define MAXCPU 1 +#define curcpu 0 + #endif diff --git a/src/libs/compat/freebsd_network/pcpu.cpp b/src/libs/compat/freebsd_network/pcpu.cpp deleted file mode 100644 index 5a6bf7bd3c..0000000000 --- a/src/libs/compat/freebsd_network/pcpu.cpp +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright 2018, Haiku, Inc. All rights reserved. - * Distributed under the terms of the MIT License. - */ - -#include -#include - -extern "C" { -#include -}; - - -int32_t -get_curcpu() -{ - return smp_get_current_cpu(); -}