summaryrefslogtreecommitdiff
path: root/usr
diff options
context:
space:
mode:
authorToomas Soome <tsoome@me.com>2022-01-26 23:44:14 +0200
committerToomas Soome <tsoome@me.com>2022-05-18 18:31:03 +0300
commit6328d71e9dd97ed4dfdf9425b5dc7b9deb6f579a (patch)
treead1b674d7d8ede447f3d8cc77043af88c0e7dff6 /usr
parentb602cbcd64fbbebf696bd7c8e03367bdfa19805d (diff)
downloadillumos-joyent-6328d71e9dd97ed4dfdf9425b5dc7b9deb6f579a.tar.gz
14454 sys/debug.h: CTASSERT should use _Static_assert
Reviewed by: Robert Mustacchi <rm@fingolfin.org> Reviewed by: Patrick Mooney <pmooney@pfmooney.com> Approved by: Dan McDonald <danmcd@mnx.io>
Diffstat (limited to 'usr')
-rw-r--r--usr/src/boot/common/bootstrap.h6
-rw-r--r--usr/src/uts/common/io/mlxcx/mlxcx_endint.h10
-rw-r--r--usr/src/uts/common/sys/debug.h5
-rw-r--r--usr/src/uts/i86pc/vm/hat_i86.c8
4 files changed, 10 insertions, 19 deletions
diff --git a/usr/src/boot/common/bootstrap.h b/usr/src/boot/common/bootstrap.h
index 689905ae68..f176973897 100644
--- a/usr/src/boot/common/bootstrap.h
+++ b/usr/src/boot/common/bootstrap.h
@@ -409,10 +409,6 @@ int nvstore_set_var_from_string(void *, const char *, const char *,
const char *);
int nvstore_unset_var(void *, const char *);
-#ifndef CTASSERT /* Allow lint to override */
-#define CTASSERT(x) _CTASSERT(x, __LINE__)
-#define _CTASSERT(x, y) __CTASSERT(x, y)
-#define __CTASSERT(x, y) typedef char __assert ## y[(x) ? 1 : -1]
-#endif
+#define CTASSERT(x) _Static_assert(x, "compile-time assertion failed")
#endif /* !_BOOTSTRAP_H_ */
diff --git a/usr/src/uts/common/io/mlxcx/mlxcx_endint.h b/usr/src/uts/common/io/mlxcx/mlxcx_endint.h
index 4ad69173c0..acc8f4216c 100644
--- a/usr/src/uts/common/io/mlxcx/mlxcx_endint.h
+++ b/usr/src/uts/common/io/mlxcx/mlxcx_endint.h
@@ -36,12 +36,10 @@
* gain a little bit of type safety when dealing with endian-swapped bitfields.
*/
-#pragma pack(1)
-typedef struct { uint16_t be_val; } uint16be_t;
-typedef struct { uint8_t be_val[3]; } uint24be_t;
-typedef struct { uint32_t be_val; } uint32be_t;
-typedef struct { uint64_t be_val; } uint64be_t;
-#pragma pack()
+typedef struct { uint16_t be_val; } __packed uint16be_t;
+typedef struct { uint8_t be_val[3]; } __packed uint24be_t;
+typedef struct { uint32_t be_val; } __packed uint32be_t;
+typedef struct { uint64_t be_val; } __packed uint64be_t;
static inline uint16_t
from_be16(uint16be_t v)
diff --git a/usr/src/uts/common/sys/debug.h b/usr/src/uts/common/sys/debug.h
index 9c91905af2..0c1625455a 100644
--- a/usr/src/uts/common/sys/debug.h
+++ b/usr/src/uts/common/sys/debug.h
@@ -133,10 +133,7 @@ _NOTE(CONSTCOND) } while (0)
/*
* Compile-time assertion. The condition 'x' must be constant.
*/
-#define CTASSERT(x) _CTASSERT(x, __LINE__)
-#define _CTASSERT(x, y) __CTASSERT(x, y)
-#define __CTASSERT(x, y) \
- typedef char __compile_time_assertion__ ## y [(x) ? 1 : -1] __unused
+#define CTASSERT(x) _Static_assert(x, "compile-time assertion failed")
#if defined(_KERNEL) || defined(_FAKE_KERNEL)
diff --git a/usr/src/uts/i86pc/vm/hat_i86.c b/usr/src/uts/i86pc/vm/hat_i86.c
index 1558af9482..76a6a0575c 100644
--- a/usr/src/uts/i86pc/vm/hat_i86.c
+++ b/usr/src/uts/i86pc/vm/hat_i86.c
@@ -1140,8 +1140,8 @@ hat_pcp_setup(struct cpu *cpu)
*/
hati_cpu_punchin(cpu, (uintptr_t)&kdi_idt, PROT_READ);
- CTASSERT(((uintptr_t)&kpti_tramp_start % MMU_PAGESIZE) == 0);
- CTASSERT(((uintptr_t)&kpti_tramp_end % MMU_PAGESIZE) == 0);
+ VERIFY0((uintptr_t)&kpti_tramp_start % MMU_PAGESIZE);
+ VERIFY0((uintptr_t)&kpti_tramp_end % MMU_PAGESIZE);
for (va = (uintptr_t)&kpti_tramp_start;
va < (uintptr_t)&kpti_tramp_end; va += MMU_PAGESIZE) {
hati_cpu_punchin(cpu, va, PROT_READ | PROT_EXEC);
@@ -1175,8 +1175,8 @@ hat_pcp_setup(struct cpu *cpu)
}
}
- CTASSERT(((uintptr_t)&kdi_isr_start % MMU_PAGESIZE) == 0);
- CTASSERT(((uintptr_t)&kdi_isr_end % MMU_PAGESIZE) == 0);
+ VERIFY0((uintptr_t)&kdi_isr_start % MMU_PAGESIZE);
+ VERIFY0((uintptr_t)&kdi_isr_end % MMU_PAGESIZE);
for (va = (uintptr_t)&kdi_isr_start;
va < (uintptr_t)&kdi_isr_end; va += MMU_PAGESIZE) {
hati_cpu_punchin(cpu, va, PROT_READ | PROT_EXEC);