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
This commit is contained in:
parent
4c670b53a0
commit
8b19d28d68
@ -111,6 +111,7 @@ md_copyenv(vm_offset_t addr)
|
|||||||
|
|
||||||
static int align;
|
static int align;
|
||||||
|
|
||||||
|
#define MOD_ALIGN(l) roundup(l, align)
|
||||||
#define COPY32(v, a, c) { \
|
#define COPY32(v, a, c) { \
|
||||||
uint32_t x = (v); \
|
uint32_t x = (v); \
|
||||||
if (c) \
|
if (c) \
|
||||||
@ -123,7 +124,7 @@ static int align;
|
|||||||
COPY32(strlen(s) + 1, a, c) \
|
COPY32(strlen(s) + 1, a, c) \
|
||||||
if (c) \
|
if (c) \
|
||||||
archsw.arch_copyin(s, a, strlen(s) + 1);\
|
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)
|
#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); \
|
COPY32(sizeof(s), a, c); \
|
||||||
if (c) \
|
if (c) \
|
||||||
archsw.arch_copyin(&s, a, sizeof(s)); \
|
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)
|
#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); \
|
COPY32(mm->md_size, a, c); \
|
||||||
if (c) \
|
if (c) \
|
||||||
archsw.arch_copyin(mm->md_data, a, mm->md_size);\
|
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) { \
|
#define MOD_END(a, c) { \
|
||||||
|
@ -180,6 +180,7 @@ bi_copyenv(vm_offset_t start)
|
|||||||
* MOD_SIZE sizeof(size_t) module size
|
* MOD_SIZE sizeof(size_t) module size
|
||||||
* MOD_METADATA (variable) type-specific metadata
|
* MOD_METADATA (variable) type-specific metadata
|
||||||
*/
|
*/
|
||||||
|
#define MOD_ALIGN(l) roundup(l, sizeof(u_long))
|
||||||
#define COPY32(v, a, c) { \
|
#define COPY32(v, a, c) { \
|
||||||
uint32_t x = (v); \
|
uint32_t x = (v); \
|
||||||
if (c) \
|
if (c) \
|
||||||
@ -192,7 +193,7 @@ bi_copyenv(vm_offset_t start)
|
|||||||
COPY32(strlen(s) + 1, a, c); \
|
COPY32(strlen(s) + 1, a, c); \
|
||||||
if (c) \
|
if (c) \
|
||||||
archsw.arch_copyin(s, a, strlen(s) + 1); \
|
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)
|
#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); \
|
COPY32(sizeof(s), a, c); \
|
||||||
if (c) \
|
if (c) \
|
||||||
archsw.arch_copyin(&s, a, sizeof(s)); \
|
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)
|
#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(MODINFO_METADATA | mm->md_type, a, c); \
|
||||||
COPY32(mm->md_size, a, c); \
|
COPY32(mm->md_size, a, c); \
|
||||||
if (c) \
|
if (c) \
|
||||||
archsw.arch_copyin(mm->md_data, a, mm->md_size); \
|
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) { \
|
#define MOD_END(a, c) { \
|
||||||
|
@ -59,6 +59,7 @@ static struct bootinfo bi;
|
|||||||
* MOD_SIZE sizeof(size_t) module size
|
* MOD_SIZE sizeof(size_t) module size
|
||||||
* MOD_METADATA (variable) type-specific metadata
|
* MOD_METADATA (variable) type-specific metadata
|
||||||
*/
|
*/
|
||||||
|
#define MOD_ALIGN(l) roundup(l, sizeof(u_long))
|
||||||
#define COPY32(v, a, c) { \
|
#define COPY32(v, a, c) { \
|
||||||
uint32_t x = (v); \
|
uint32_t x = (v); \
|
||||||
if (c) \
|
if (c) \
|
||||||
@ -71,7 +72,7 @@ static struct bootinfo bi;
|
|||||||
COPY32(strlen(s) + 1, a, c); \
|
COPY32(strlen(s) + 1, a, c); \
|
||||||
if (c) \
|
if (c) \
|
||||||
archsw.arch_copyin(s, a, strlen(s) + 1); \
|
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)
|
#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); \
|
COPY32(sizeof(s), a, c); \
|
||||||
if (c) \
|
if (c) \
|
||||||
archsw.arch_copyin(&s, a, sizeof(s)); \
|
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)
|
#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); \
|
COPY32(mm->md_size, a, c); \
|
||||||
if (c) \
|
if (c) \
|
||||||
archsw.arch_copyin(mm->md_data, a, mm->md_size); \
|
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) { \
|
#define MOD_END(a, c) { \
|
||||||
|
@ -60,6 +60,7 @@ __FBSDID("$FreeBSD$");
|
|||||||
* MOD_SIZE sizeof(size_t) module size
|
* MOD_SIZE sizeof(size_t) module size
|
||||||
* MOD_METADATA (variable) type-specific metadata
|
* MOD_METADATA (variable) type-specific metadata
|
||||||
*/
|
*/
|
||||||
|
#define MOD_ALIGN(l) roundup(l, sizeof(uint64_t))
|
||||||
#define COPY32(v, a, c) { \
|
#define COPY32(v, a, c) { \
|
||||||
uint32_t x = (v); \
|
uint32_t x = (v); \
|
||||||
if (c) \
|
if (c) \
|
||||||
@ -72,7 +73,7 @@ __FBSDID("$FreeBSD$");
|
|||||||
COPY32(strlen(s) + 1, a, c); \
|
COPY32(strlen(s) + 1, a, c); \
|
||||||
if (c) \
|
if (c) \
|
||||||
archsw.arch_copyin(s, a, strlen(s) + 1); \
|
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)
|
#define MOD_NAME(a, s, c) MOD_STR(MODINFO_NAME, a, s, c)
|
||||||
@ -84,7 +85,7 @@ __FBSDID("$FreeBSD$");
|
|||||||
COPY32(sizeof(s), a, c); \
|
COPY32(sizeof(s), a, c); \
|
||||||
if (c) \
|
if (c) \
|
||||||
archsw.arch_copyin(&s, a, sizeof(s)); \
|
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)
|
#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); \
|
COPY32(mm->md_size, a, c); \
|
||||||
if (c) \
|
if (c) \
|
||||||
archsw.arch_copyin(mm->md_data, a, mm->md_size); \
|
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) { \
|
#define MOD_END(a, c) { \
|
||||||
|
@ -58,6 +58,7 @@ static struct bootinfo bi;
|
|||||||
* MOD_SIZE sizeof(size_t) module size
|
* MOD_SIZE sizeof(size_t) module size
|
||||||
* MOD_METADATA (variable) type-specific metadata
|
* MOD_METADATA (variable) type-specific metadata
|
||||||
*/
|
*/
|
||||||
|
#define MOD_ALIGN(l) roundup(l, sizeof(uint32_t))
|
||||||
#define COPY32(v, a, c) { \
|
#define COPY32(v, a, c) { \
|
||||||
uint32_t x = (v); \
|
uint32_t x = (v); \
|
||||||
if (c) \
|
if (c) \
|
||||||
@ -70,7 +71,7 @@ static struct bootinfo bi;
|
|||||||
COPY32(strlen(s) + 1, a, c); \
|
COPY32(strlen(s) + 1, a, c); \
|
||||||
if (c) \
|
if (c) \
|
||||||
archsw.arch_copyin(s, a, strlen(s) + 1);\
|
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)
|
#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); \
|
COPY32(sizeof(s), a, c); \
|
||||||
if (c) \
|
if (c) \
|
||||||
archsw.arch_copyin(&s, a, sizeof(s)); \
|
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)
|
#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); \
|
COPY32(mm->md_size, a, c); \
|
||||||
if (c) \
|
if (c) \
|
||||||
archsw.arch_copyin(mm->md_data, a, mm->md_size);\
|
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) { \
|
#define MOD_END(a, c) { \
|
||||||
|
@ -55,6 +55,7 @@ __FBSDID("$FreeBSD$");
|
|||||||
* MOD_SIZE sizeof(size_t) module size
|
* MOD_SIZE sizeof(size_t) module size
|
||||||
* MOD_METADATA (variable) type-specific metadata
|
* MOD_METADATA (variable) type-specific metadata
|
||||||
*/
|
*/
|
||||||
|
#define MOD_ALIGN(l) roundup(l, sizeof(uint64_t))
|
||||||
#define COPY32(v, a, c) { \
|
#define COPY32(v, a, c) { \
|
||||||
uint32_t x = (v); \
|
uint32_t x = (v); \
|
||||||
if (c) \
|
if (c) \
|
||||||
@ -67,7 +68,7 @@ __FBSDID("$FreeBSD$");
|
|||||||
COPY32(strlen(s) + 1, a, c); \
|
COPY32(strlen(s) + 1, a, c); \
|
||||||
if (c) \
|
if (c) \
|
||||||
archsw.arch_copyin(s, a, strlen(s) + 1);\
|
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)
|
#define MOD_NAME(a, s, c) MOD_STR(MODINFO_NAME, a, s, c)
|
||||||
@ -79,7 +80,7 @@ __FBSDID("$FreeBSD$");
|
|||||||
COPY32(sizeof(s), a, c); \
|
COPY32(sizeof(s), a, c); \
|
||||||
if (c) \
|
if (c) \
|
||||||
archsw.arch_copyin(&s, a, sizeof(s)); \
|
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)
|
#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); \
|
COPY32(mm->md_size, a, c); \
|
||||||
if (c) \
|
if (c) \
|
||||||
archsw.arch_copyin(mm->md_data, a, mm->md_size);\
|
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) { \
|
#define MOD_END(a, c) { \
|
||||||
|
Loading…
Reference in New Issue
Block a user