diff mbox series

[kvm-unit-tests,v6,03/11] lib: Define unlikely()/likely() macros in libcflat.h

Message ID 20240411172944.23089-4-vsntk18@gmail.com (mailing list archive)
State New, archived
Headers show
Series Add #VC exception handling for AMD SEV-ES | expand

Commit Message

Vasant Karasulli April 11, 2024, 5:29 p.m. UTC
From: Vasant Karasulli <vkarasulli@suse.de>

So that they can be shared across testcases and lib/.
Linux's x86 instruction decoder refrences them.

Signed-off-by: Varad Gautam <varad.gautam@suse.com>
Signed-off-by: Vasant Karasulli <vkarasulli@suse.de>
---
 lib/libcflat.h | 3 +++
 x86/kvmclock.c | 4 ----
 2 files changed, 3 insertions(+), 4 deletions(-)

--
2.34.1

Comments

Andrew Jones April 12, 2024, 6:31 a.m. UTC | #1
On Thu, Apr 11, 2024 at 07:29:36PM +0200, vsntk18@gmail.com wrote:
> From: Vasant Karasulli <vkarasulli@suse.de>
> 
> So that they can be shared across testcases and lib/.
> Linux's x86 instruction decoder refrences them.
> 
> Signed-off-by: Varad Gautam <varad.gautam@suse.com>
> Signed-off-by: Vasant Karasulli <vkarasulli@suse.de>
> ---
>  lib/libcflat.h | 3 +++
>  x86/kvmclock.c | 4 ----
>  2 files changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/lib/libcflat.h b/lib/libcflat.h
> index 700f4352..283da08a 100644
> --- a/lib/libcflat.h
> +++ b/lib/libcflat.h
> @@ -167,4 +167,7 @@ extern void setup_vm(void);
>  #define SZ_1G			(1 << 30)
>  #define SZ_2G			(1ul << 31)
> 
> +#define unlikely(x)	__builtin_expect(!!(x), 0)
> +#define likely(x)	__builtin_expect(!!(x), 1)

Please put these in lib/linux/compiler.h

Thanks,
drew

> +
>  #endif
> diff --git a/x86/kvmclock.c b/x86/kvmclock.c
> index f9f21032..487c12af 100644
> --- a/x86/kvmclock.c
> +++ b/x86/kvmclock.c
> @@ -5,10 +5,6 @@
>  #include "kvmclock.h"
>  #include "asm/barrier.h"
> 
> -#define unlikely(x)	__builtin_expect(!!(x), 0)
> -#define likely(x)	__builtin_expect(!!(x), 1)
> -
> -
>  struct pvclock_vcpu_time_info __attribute__((aligned(4))) hv_clock[MAX_CPU];
>  struct pvclock_wall_clock wall_clock;
>  static unsigned char valid_flags = 0;
> --
> 2.34.1
>
diff mbox series

Patch

diff --git a/lib/libcflat.h b/lib/libcflat.h
index 700f4352..283da08a 100644
--- a/lib/libcflat.h
+++ b/lib/libcflat.h
@@ -167,4 +167,7 @@  extern void setup_vm(void);
 #define SZ_1G			(1 << 30)
 #define SZ_2G			(1ul << 31)

+#define unlikely(x)	__builtin_expect(!!(x), 0)
+#define likely(x)	__builtin_expect(!!(x), 1)
+
 #endif
diff --git a/x86/kvmclock.c b/x86/kvmclock.c
index f9f21032..487c12af 100644
--- a/x86/kvmclock.c
+++ b/x86/kvmclock.c
@@ -5,10 +5,6 @@ 
 #include "kvmclock.h"
 #include "asm/barrier.h"

-#define unlikely(x)	__builtin_expect(!!(x), 0)
-#define likely(x)	__builtin_expect(!!(x), 1)
-
-
 struct pvclock_vcpu_time_info __attribute__((aligned(4))) hv_clock[MAX_CPU];
 struct pvclock_wall_clock wall_clock;
 static unsigned char valid_flags = 0;