svn commit: r298308 - in head/sys: amd64/amd64 amd64/linux amd64/linux32 i386/i386 i386/ibcs2 i386/linux x86/isa x86/x86
Pedro F. Giffuni
pfg at FreeBSD.org
Tue Apr 19 23:41:48 UTC 2016
Author: pfg
Date: Tue Apr 19 23:41:46 2016
New Revision: 298308
URL: https://svnweb.freebsd.org/changeset/base/298308
Log:
X86: use our nitems() macro when it is avaliable through param.h.
No functional change, only trivial cases are done in this sweep,
Discussed in: freebsd-current
Modified:
head/sys/amd64/amd64/amd64_mem.c
head/sys/amd64/amd64/machdep.c
head/sys/amd64/linux/linux_sysvec.c
head/sys/amd64/linux32/linux32_sysvec.c
head/sys/i386/i386/i686_mem.c
head/sys/i386/i386/machdep.c
head/sys/i386/ibcs2/ibcs2_sysvec.c
head/sys/i386/linux/linux_sysvec.c
head/sys/x86/isa/atpic.c
head/sys/x86/x86/identcpu.c
head/sys/x86/x86/local_apic.c
Modified: head/sys/amd64/amd64/amd64_mem.c
==============================================================================
--- head/sys/amd64/amd64/amd64_mem.c Tue Apr 19 23:37:24 2016 (r298307)
+++ head/sys/amd64/amd64/amd64_mem.c Tue Apr 19 23:41:46 2016 (r298308)
@@ -117,7 +117,7 @@ static int amd64_mtrrtomrt[] = {
MDF_WRITEBACK
};
-#define MTRRTOMRTLEN (sizeof(amd64_mtrrtomrt) / sizeof(amd64_mtrrtomrt[0]))
+#define MTRRTOMRTLEN nitems(amd64_mtrrtomrt)
static int
amd64_mtrr2mrt(int val)
Modified: head/sys/amd64/amd64/machdep.c
==============================================================================
--- head/sys/amd64/amd64/machdep.c Tue Apr 19 23:37:24 2016 (r298307)
+++ head/sys/amd64/amd64/machdep.c Tue Apr 19 23:41:46 2016 (r298308)
@@ -217,8 +217,8 @@ vm_paddr_t phys_avail[PHYSMAP_SIZE + 2];
vm_paddr_t dump_avail[PHYSMAP_SIZE + 2];
/* must be 2 less so 0 0 can signal end of chunks */
-#define PHYS_AVAIL_ARRAY_END ((sizeof(phys_avail) / sizeof(phys_avail[0])) - 2)
-#define DUMP_AVAIL_ARRAY_END ((sizeof(dump_avail) / sizeof(dump_avail[0])) - 2)
+#define PHYS_AVAIL_ARRAY_END (nitems(phys_avail) - 2)
+#define DUMP_AVAIL_ARRAY_END (nitems(dump_avail) - 2)
struct kva_md_info kmi;
Modified: head/sys/amd64/linux/linux_sysvec.c
==============================================================================
--- head/sys/amd64/linux/linux_sysvec.c Tue Apr 19 23:37:24 2016 (r298307)
+++ head/sys/amd64/linux/linux_sysvec.c Tue Apr 19 23:41:46 2016 (r298308)
@@ -186,7 +186,7 @@ static int _bsd_to_linux_trapcode[] = {
15 /* 30 T_RESERVED */
};
#define bsd_to_linux_trapcode(code) \
- ((code)<sizeof(_bsd_to_linux_trapcode)/sizeof(*_bsd_to_linux_trapcode)? \
+ ((code)<nitems(_bsd_to_linux_trapcode)? \
_bsd_to_linux_trapcode[(code)]: \
LINUX_T_UNKNOWN)
Modified: head/sys/amd64/linux32/linux32_sysvec.c
==============================================================================
--- head/sys/amd64/linux32/linux32_sysvec.c Tue Apr 19 23:37:24 2016 (r298307)
+++ head/sys/amd64/linux32/linux32_sysvec.c Tue Apr 19 23:41:46 2016 (r298308)
@@ -185,7 +185,7 @@ static int _bsd_to_linux_trapcode[] = {
15 /* 30 T_RESERVED */
};
#define bsd_to_linux_trapcode(code) \
- ((code)<sizeof(_bsd_to_linux_trapcode)/sizeof(*_bsd_to_linux_trapcode)? \
+ ((code)<nitems(_bsd_to_linux_trapcode)? \
_bsd_to_linux_trapcode[(code)]: \
LINUX_T_UNKNOWN)
Modified: head/sys/i386/i386/i686_mem.c
==============================================================================
--- head/sys/i386/i386/i686_mem.c Tue Apr 19 23:37:24 2016 (r298307)
+++ head/sys/i386/i386/i686_mem.c Tue Apr 19 23:41:46 2016 (r298308)
@@ -113,7 +113,7 @@ static int i686_mtrrtomrt[] = {
MDF_WRITEBACK
};
-#define MTRRTOMRTLEN (sizeof(i686_mtrrtomrt) / sizeof(i686_mtrrtomrt[0]))
+#define MTRRTOMRTLEN (nitems(i686_mtrrtomrt))
static int
i686_mtrr2mrt(int val)
Modified: head/sys/i386/i386/machdep.c
==============================================================================
--- head/sys/i386/i386/machdep.c Tue Apr 19 23:37:24 2016 (r298307)
+++ head/sys/i386/i386/machdep.c Tue Apr 19 23:41:46 2016 (r298308)
@@ -221,8 +221,8 @@ vm_paddr_t phys_avail[PHYSMAP_SIZE + 2];
vm_paddr_t dump_avail[PHYSMAP_SIZE + 2];
/* must be 2 less so 0 0 can signal end of chunks */
-#define PHYS_AVAIL_ARRAY_END ((sizeof(phys_avail) / sizeof(phys_avail[0])) - 2)
-#define DUMP_AVAIL_ARRAY_END ((sizeof(dump_avail) / sizeof(dump_avail[0])) - 2)
+#define PHYS_AVAIL_ARRAY_END (nitems(phys_avail) - 2)
+#define DUMP_AVAIL_ARRAY_END (nitems(dump_avail) - 2)
struct kva_md_info kmi;
@@ -2517,7 +2517,7 @@ init386(first)
/* make ldt memory segments */
ldt_segs[LUCODE_SEL].ssd_limit = atop(0 - 1);
ldt_segs[LUDATA_SEL].ssd_limit = atop(0 - 1);
- for (x = 0; x < sizeof ldt_segs / sizeof ldt_segs[0]; x++)
+ for (x = 0; x < nitems(ldt_segs); x++)
ssdtosd(&ldt_segs[x], &ldt[x].sd);
_default_ldt = GSEL(GLDT_SEL, SEL_KPL);
Modified: head/sys/i386/ibcs2/ibcs2_sysvec.c
==============================================================================
--- head/sys/i386/ibcs2/ibcs2_sysvec.c Tue Apr 19 23:37:24 2016 (r298307)
+++ head/sys/i386/ibcs2/ibcs2_sysvec.c Tue Apr 19 23:41:46 2016 (r298308)
@@ -57,7 +57,7 @@ extern struct sysent ibcs2_sysent[IBCS2_
static int ibcs2_fixup(register_t **, struct image_params *);
struct sysentvec ibcs2_svr3_sysvec = {
- .sv_size = sizeof (ibcs2_sysent) / sizeof (ibcs2_sysent[0]),
+ .sv_size = nitems(ibcs2_sysent),
.sv_table = ibcs2_sysent,
.sv_mask = 0xff,
.sv_sigsize = IBCS2_SIGTBLSZ,
Modified: head/sys/i386/linux/linux_sysvec.c
==============================================================================
--- head/sys/i386/linux/linux_sysvec.c Tue Apr 19 23:37:24 2016 (r298307)
+++ head/sys/i386/linux/linux_sysvec.c Tue Apr 19 23:41:46 2016 (r298308)
@@ -184,7 +184,7 @@ static int _bsd_to_linux_trapcode[] = {
15 /* 30 T_RESERVED */
};
#define bsd_to_linux_trapcode(code) \
- ((code)<sizeof(_bsd_to_linux_trapcode)/sizeof(*_bsd_to_linux_trapcode)? \
+ ((code)<nitems(_bsd_to_linux_trapcode)? \
_bsd_to_linux_trapcode[(code)]: \
LINUX_T_UNKNOWN)
Modified: head/sys/x86/isa/atpic.c
==============================================================================
--- head/sys/x86/isa/atpic.c Tue Apr 19 23:37:24 2016 (r298307)
+++ head/sys/x86/isa/atpic.c Tue Apr 19 23:41:46 2016 (r298308)
@@ -155,7 +155,7 @@ static struct atpic_intsrc atintrs[] = {
INTSRC(15),
};
-CTASSERT(sizeof(atintrs) / sizeof(atintrs[0]) == NUM_ISA_IRQS);
+CTASSERT(nitems(atintrs) == NUM_ISA_IRQS);
static __inline void
_atpic_eoi_master(struct intsrc *isrc)
Modified: head/sys/x86/x86/identcpu.c
==============================================================================
--- head/sys/x86/x86/identcpu.c Tue Apr 19 23:37:24 2016 (r298307)
+++ head/sys/x86/x86/identcpu.c Tue Apr 19 23:41:46 2016 (r298308)
@@ -1589,7 +1589,7 @@ find_cpu_vendor_id(void)
{
int i;
- for (i = 0; i < sizeof(cpu_vendors) / sizeof(cpu_vendors[0]); i++)
+ for (i = 0; i < nitems(cpu_vendors); i++)
if (strcmp(cpu_vendor, cpu_vendors[i].vendor) == 0)
return (cpu_vendors[i].vendor_id);
return (0);
Modified: head/sys/x86/x86/local_apic.c
==============================================================================
--- head/sys/x86/x86/local_apic.c Tue Apr 19 23:37:24 2016 (r298307)
+++ head/sys/x86/x86/local_apic.c Tue Apr 19 23:41:46 2016 (r298308)
@@ -1183,8 +1183,8 @@ lapic_timer_set_divisor(u_int divisor)
{
KASSERT(powerof2(divisor), ("lapic: invalid divisor %u", divisor));
- KASSERT(ffs(divisor) <= sizeof(lapic_timer_divisors) /
- sizeof(u_int32_t), ("lapic: invalid divisor %u", divisor));
+ KASSERT(ffs(divisor) <= nitems(lapic_timer_divisors),
+ ("lapic: invalid divisor %u", divisor));
lapic_write32(LAPIC_DCR_TIMER, lapic_timer_divisors[ffs(divisor) - 1]);
}
More information about the svn-src-head
mailing list