aboutsummaryrefslogtreecommitdiff
path: root/stand
diff options
context:
space:
mode:
authorWarner Losh <imp@FreeBSD.org>2022-09-16 15:08:37 +0000
committerWarner Losh <imp@FreeBSD.org>2022-09-16 15:18:56 +0000
commit8b19d28d68a396b0263e3c13a559a31f70eb3b1d (patch)
tree1fbf870858619e4f9e080bb0adcf45608cd26cba /stand
parent4c670b53a0007739a0fc84ea4bc24a5895953aae (diff)
downloadsrc-8b19d28d68a396b0263e3c13a559a31f70eb3b1d.tar.gz
src-8b19d28d68a396b0263e3c13a559a31f70eb3b1d.zip
stand: Create MOD_ALIGN macro and use it everywhere
To further reduce the differences between the different MOD_xxx macros, use MOD_ALIGN to do the proper alignment for the given use. Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D36570
Diffstat (limited to 'stand')
-rw-r--r--stand/common/metadata.c7
-rw-r--r--stand/efi/loader/bootinfo.c9
-rw-r--r--stand/i386/libi386/bootinfo32.c7
-rw-r--r--stand/i386/libi386/bootinfo64.c7
-rw-r--r--stand/userboot/userboot/bootinfo32.c7
-rw-r--r--stand/userboot/userboot/bootinfo64.c7
6 files changed, 25 insertions, 19 deletions
diff --git a/stand/common/metadata.c b/stand/common/metadata.c
index a9c81added02..cb92537d1ce2 100644
--- a/stand/common/metadata.c
+++ b/stand/common/metadata.c
@@ -111,6 +111,7 @@ md_copyenv(vm_offset_t addr)
static int align;
+#define MOD_ALIGN(l) roundup(l, align)
#define COPY32(v, a, c) { \
uint32_t x = (v); \
if (c) \
@@ -123,7 +124,7 @@ static int align;
COPY32(strlen(s) + 1, a, c) \
if (c) \
archsw.arch_copyin(s, a, strlen(s) + 1);\
- a += roundup(strlen(s) + 1, align); \
+ a += MOD_ALIGN(strlen(s) + 1); \
}
#define MOD_NAME(a, s, c) MOD_STR(MODINFO_NAME, a, s, c)
@@ -135,7 +136,7 @@ static int align;
COPY32(sizeof(s), a, c); \
if (c) \
archsw.arch_copyin(&s, a, sizeof(s)); \
- a += roundup(sizeof(s), align); \
+ a += MOD_ALIGN(sizeof(s)); \
}
#define MOD_ADDR(a, s, c) MOD_VAR(MODINFO_ADDR, a, s, c)
@@ -146,7 +147,7 @@ static int align;
COPY32(mm->md_size, a, c); \
if (c) \
archsw.arch_copyin(mm->md_data, a, mm->md_size);\
- a += roundup(mm->md_size, align); \
+ a += MOD_ALIGN(mm->md_size); \
}
#define MOD_END(a, c) { \
diff --git a/stand/efi/loader/bootinfo.c b/stand/efi/loader/bootinfo.c
index 06b131aac521..c3184a1e84d5 100644
--- a/stand/efi/loader/bootinfo.c
+++ b/stand/efi/loader/bootinfo.c
@@ -180,6 +180,7 @@ bi_copyenv(vm_offset_t start)
* MOD_SIZE sizeof(size_t) module size
* MOD_METADATA (variable) type-specific metadata
*/
+#define MOD_ALIGN(l) roundup(l, sizeof(u_long))
#define COPY32(v, a, c) { \
uint32_t x = (v); \
if (c) \
@@ -192,7 +193,7 @@ bi_copyenv(vm_offset_t start)
COPY32(strlen(s) + 1, a, c); \
if (c) \
archsw.arch_copyin(s, a, strlen(s) + 1); \
- a += roundup(strlen(s) + 1, sizeof(u_long)); \
+ a += MOD_ALIGN(strlen(s) + 1); \
}
#define MOD_NAME(a, s, c) MOD_STR(MODINFO_NAME, a, s, c)
@@ -204,7 +205,7 @@ bi_copyenv(vm_offset_t start)
COPY32(sizeof(s), a, c); \
if (c) \
archsw.arch_copyin(&s, a, sizeof(s)); \
- a += roundup(sizeof(s), sizeof(u_long)); \
+ a += MOD_ALIGN(sizeof(s)); \
}
#define MOD_ADDR(a, s, c) MOD_VAR(MODINFO_ADDR, a, s, c)
@@ -214,8 +215,8 @@ bi_copyenv(vm_offset_t start)
COPY32(MODINFO_METADATA | mm->md_type, a, c); \
COPY32(mm->md_size, a, c); \
if (c) \
- archsw.arch_copyin(mm->md_data, a, mm->md_size); \
- a += roundup(mm->md_size, sizeof(u_long)); \
+ archsw.arch_copyin(mm->md_data, a, mm->md_size); \
+ a += MOD_ALIGN(mm->md_size); \
}
#define MOD_END(a, c) { \
diff --git a/stand/i386/libi386/bootinfo32.c b/stand/i386/libi386/bootinfo32.c
index dd919d0fad93..207fe9a3fde8 100644
--- a/stand/i386/libi386/bootinfo32.c
+++ b/stand/i386/libi386/bootinfo32.c
@@ -59,6 +59,7 @@ static struct bootinfo bi;
* MOD_SIZE sizeof(size_t) module size
* MOD_METADATA (variable) type-specific metadata
*/
+#define MOD_ALIGN(l) roundup(l, sizeof(u_long))
#define COPY32(v, a, c) { \
uint32_t x = (v); \
if (c) \
@@ -71,7 +72,7 @@ static struct bootinfo bi;
COPY32(strlen(s) + 1, a, c); \
if (c) \
archsw.arch_copyin(s, a, strlen(s) + 1); \
- a += roundup(strlen(s) + 1, sizeof(u_long));\
+ a += MOD_ALIGN(strlen(s) + 1); \
}
#define MOD_NAME(a, s, c) MOD_STR(MODINFO_NAME, a, s, c)
@@ -83,7 +84,7 @@ static struct bootinfo bi;
COPY32(sizeof(s), a, c); \
if (c) \
archsw.arch_copyin(&s, a, sizeof(s)); \
- a += roundup(sizeof(s), sizeof(u_long)); \
+ a += MOD_ALIGN(sizeof(s)); \
}
#define MOD_ADDR(a, s, c) MOD_VAR(MODINFO_ADDR, a, s, c)
@@ -94,7 +95,7 @@ static struct bootinfo bi;
COPY32(mm->md_size, a, c); \
if (c) \
archsw.arch_copyin(mm->md_data, a, mm->md_size); \
- a += roundup(mm->md_size, sizeof(u_long));\
+ a += MOD_ALIGN(mm->md_size); \
}
#define MOD_END(a, c) { \
diff --git a/stand/i386/libi386/bootinfo64.c b/stand/i386/libi386/bootinfo64.c
index 1e06c229ec30..e088c27347be 100644
--- a/stand/i386/libi386/bootinfo64.c
+++ b/stand/i386/libi386/bootinfo64.c
@@ -60,6 +60,7 @@ __FBSDID("$FreeBSD$");
* MOD_SIZE sizeof(size_t) module size
* MOD_METADATA (variable) type-specific metadata
*/
+#define MOD_ALIGN(l) roundup(l, sizeof(uint64_t))
#define COPY32(v, a, c) { \
uint32_t x = (v); \
if (c) \
@@ -72,7 +73,7 @@ __FBSDID("$FreeBSD$");
COPY32(strlen(s) + 1, a, c); \
if (c) \
archsw.arch_copyin(s, a, strlen(s) + 1); \
- a += roundup(strlen(s) + 1, sizeof(uint64_t));\
+ a += MOD_ALIGN(strlen(s) + 1); \
}
#define MOD_NAME(a, s, c) MOD_STR(MODINFO_NAME, a, s, c)
@@ -84,7 +85,7 @@ __FBSDID("$FreeBSD$");
COPY32(sizeof(s), a, c); \
if (c) \
archsw.arch_copyin(&s, a, sizeof(s)); \
- a += roundup(sizeof(s), sizeof(uint64_t)); \
+ a += MOD_ALIGN(sizeof(s)); \
}
#define MOD_ADDR(a, s, c) MOD_VAR(MODINFO_ADDR, a, s, c)
@@ -95,7 +96,7 @@ __FBSDID("$FreeBSD$");
COPY32(mm->md_size, a, c); \
if (c) \
archsw.arch_copyin(mm->md_data, a, mm->md_size); \
- a += roundup(mm->md_size, sizeof(uint64_t));\
+ a += MOD_ALIGN(mm->md_size); \
}
#define MOD_END(a, c) { \
diff --git a/stand/userboot/userboot/bootinfo32.c b/stand/userboot/userboot/bootinfo32.c
index 26376709e899..bd2729927349 100644
--- a/stand/userboot/userboot/bootinfo32.c
+++ b/stand/userboot/userboot/bootinfo32.c
@@ -58,6 +58,7 @@ static struct bootinfo bi;
* MOD_SIZE sizeof(size_t) module size
* MOD_METADATA (variable) type-specific metadata
*/
+#define MOD_ALIGN(l) roundup(l, sizeof(uint32_t))
#define COPY32(v, a, c) { \
uint32_t x = (v); \
if (c) \
@@ -70,7 +71,7 @@ static struct bootinfo bi;
COPY32(strlen(s) + 1, a, c); \
if (c) \
archsw.arch_copyin(s, a, strlen(s) + 1);\
- a += roundup(strlen(s) + 1, sizeof(uint32_t));\
+ a += MOD_ALIGN(strlen(s) + 1); \
}
#define MOD_NAME(a, s, c) MOD_STR(MODINFO_NAME, a, s, c)
@@ -82,7 +83,7 @@ static struct bootinfo bi;
COPY32(sizeof(s), a, c); \
if (c) \
archsw.arch_copyin(&s, a, sizeof(s)); \
- a += roundup(sizeof(s), sizeof(uint32_t)); \
+ a += MOD_ALIGN(sizeof(s)); \
}
#define MOD_ADDR(a, s, c) MOD_VAR(MODINFO_ADDR, a, s, c)
@@ -93,7 +94,7 @@ static struct bootinfo bi;
COPY32(mm->md_size, a, c); \
if (c) \
archsw.arch_copyin(mm->md_data, a, mm->md_size);\
- a += roundup(mm->md_size, sizeof(uint32_t));\
+ a += MOD_ALIGN(mm->md_size); \
}
#define MOD_END(a, c) { \
diff --git a/stand/userboot/userboot/bootinfo64.c b/stand/userboot/userboot/bootinfo64.c
index f2713adf5513..5fffb04d8d75 100644
--- a/stand/userboot/userboot/bootinfo64.c
+++ b/stand/userboot/userboot/bootinfo64.c
@@ -55,6 +55,7 @@ __FBSDID("$FreeBSD$");
* MOD_SIZE sizeof(size_t) module size
* MOD_METADATA (variable) type-specific metadata
*/
+#define MOD_ALIGN(l) roundup(l, sizeof(uint64_t))
#define COPY32(v, a, c) { \
uint32_t x = (v); \
if (c) \
@@ -67,7 +68,7 @@ __FBSDID("$FreeBSD$");
COPY32(strlen(s) + 1, a, c); \
if (c) \
archsw.arch_copyin(s, a, strlen(s) + 1);\
- a += roundup(strlen(s) + 1, sizeof(uint64_t));\
+ a += MOD_ALIGN(strlen(s) + 1); \
}
#define MOD_NAME(a, s, c) MOD_STR(MODINFO_NAME, a, s, c)
@@ -79,7 +80,7 @@ __FBSDID("$FreeBSD$");
COPY32(sizeof(s), a, c); \
if (c) \
archsw.arch_copyin(&s, a, sizeof(s)); \
- a += roundup(sizeof(s), sizeof(uint64_t)); \
+ a += MOD_ALIGN(sizeof(s)); \
}
#define MOD_ADDR(a, s, c) MOD_VAR(MODINFO_ADDR, a, s, c)
@@ -90,7 +91,7 @@ __FBSDID("$FreeBSD$");
COPY32(mm->md_size, a, c); \
if (c) \
archsw.arch_copyin(mm->md_data, a, mm->md_size);\
- a += roundup(mm->md_size, sizeof(uint64_t));\
+ a += MOD_ALIGN(mm->md_size); \
}
#define MOD_END(a, c) { \