From c72186fe0866cee88677b864ea43b36981a0d83f Mon Sep 17 00:00:00 2001 From: Igor Putovny Date: Thu, 30 May 2024 12:27:54 +0200 Subject: [PATCH] Backport SKIP_BACK with type control from v3 --- lib/birdlib.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/birdlib.h b/lib/birdlib.h index c1090417a..3460389bf 100644 --- a/lib/birdlib.h +++ b/lib/birdlib.h @@ -19,7 +19,7 @@ struct align_probe { char x; long int y; }; #define OFFSETOF(s, i) ((size_t) &((s *)0)->i) -#define SKIP_BACK(s, i, p) ((s *)((char *)p - OFFSETOF(s, i))) +#define SKIP_BACK(s, i, p) ({ s *_ptr = ((s *)((char *)p - OFFSETOF(s, i))); SAME_TYPE(&_ptr->i, p); _ptr; }) #define BIRD_ALIGN(s, a) (((s)+a-1)&~(a-1)) #define CPU_STRUCT_ALIGN (sizeof(struct align_probe)) -- 2.47.2