-/* $OpenBSD: db_interface.c,v 1.20 2014/03/29 18:09:28 guenther Exp $ */
+/* $OpenBSD: db_interface.c,v 1.21 2014/07/13 12:11:01 jasper Exp $ */
/* $NetBSD: db_interface.c,v 1.8 1999/10/12 17:08:57 jdolecek Exp $ */
/*
{ "ai", &ddb_regs.tf_regs[FRAME_T11], FCN_NULL },
{ "pv", &ddb_regs.tf_regs[FRAME_T12], FCN_NULL },
};
-struct db_variable *db_eregs = db_regs + sizeof(db_regs)/sizeof(db_regs[0]);
+struct db_variable *db_eregs = db_regs + nitems(db_regs);
/*
* ddb_trap - field a kernel trap
-/* $OpenBSD: amd64_mem.c,v 1.7 2013/08/24 04:26:15 mlarkin Exp $ */
+/* $OpenBSD: amd64_mem.c,v 1.8 2014/07/13 12:11:01 jasper Exp $ */
/*
* Copyright (c) 1999 Michael Smith <msmith@freebsd.org>
* All rights reserved.
MDF_WRITEBACK
};
-#define MTRRTOMRTLEN (sizeof(mtrrtomrt) / sizeof(mtrrtomrt[0]))
-
int
mtrr2mrt(int val)
{
- if (val < 0 || val >= MTRRTOMRTLEN)
+ if (val < 0 || val >= nitems(mtrrtomrt))
return MDF_UNKNOWN;
return mtrrtomrt[val];
}
flags &= MDF_ATTRMASK;
- for (i = 0; i < MTRRTOMRTLEN; i++) {
+ for (i = 0; i < nitems(mtrrtomrt); i++) {
if (mtrrtomrt[i] == MDF_UNKNOWN)
continue;
if (flags == mtrrtomrt[i])
-/* $OpenBSD: amd64errata.c,v 1.6 2013/12/07 01:43:50 brad Exp $ */
+/* $OpenBSD: amd64errata.c,v 1.7 2014/07/13 12:11:01 jasper Exp $ */
/* $NetBSD: errata.c,v 1.6 2007/02/05 21:05:45 ad Exp $ */
/*-
}
}
- ex = errata + sizeof(errata) / sizeof(errata[0]);
+ ex = errata + nitems(errata);
/* Reset e_reporteds (for multiple CPUs) */
for (e = errata; e < ex; e++)
-/* $OpenBSD: bios.c,v 1.26 2013/11/19 04:12:17 guenther Exp $ */
+/* $OpenBSD: bios.c,v 1.27 2014/07/13 12:11:01 jasper Exp $ */
/*
* Copyright (c) 2006 Gordon Willem Klok <gklok@cogeco.ca>
*
char *p, *e;
int i;
- for (i = 0; i < sizeof(smbios_uninfo)/sizeof(smbios_uninfo[0]); i++)
+ for (i = 0; i < nitems(smbios_uninfo); i++)
if ((strncasecmp(s, smbios_uninfo[i],
strlen(smbios_uninfo[i])))==0)
return NULL;
-/* $OpenBSD: db_trace.c,v 1.7 2010/09/27 10:08:28 mikeb Exp $ */
+/* $OpenBSD: db_trace.c,v 1.8 2014/07/13 12:11:01 jasper Exp $ */
/* $NetBSD: db_trace.c,v 1.1 2003/04/26 18:39:27 fvdl Exp $ */
/*
{ "rsp", dbreg(rsp), db_x86_64_regop },
{ "ss", dbreg(ss), db_x86_64_regop },
};
-struct db_variable * db_eregs =
- db_regs + sizeof(db_regs)/sizeof(db_regs[0]);
+struct db_variable * db_eregs = db_regs + nitems(db_regs);
static int
db_x86_64_regop(struct db_variable *vp, db_expr_t *val, int opcode)
-/* $OpenBSD: identcpu.c,v 1.53 2014/07/03 21:15:28 matthew Exp $ */
+/* $OpenBSD: identcpu.c,v 1.54 2014/07/13 12:11:01 jasper Exp $ */
/* $NetBSD: identcpu.c,v 1.1 2003/04/26 18:39:28 fvdl Exp $ */
/*
u_int32_t dummy, val, pnfeatset;
u_int32_t brand[12];
char mycpu_model[48];
- int i, max;
+ int i;
char *brandstr_from, *brandstr_to;
int skipspace;
printf("\n%s: ", ci->ci_dev->dv_xname);
- max = sizeof(cpu_cpuid_features) / sizeof(cpu_cpuid_features[0]);
- for (i = 0; i < max; i++)
+ for (i = 0; i < nitems(cpu_cpuid_features); i++)
if (ci->ci_feature_flags & cpu_cpuid_features[i].bit)
printf("%s%s", i? "," : "", cpu_cpuid_features[i].str);
- max = sizeof(cpu_cpuid_ecxfeatures) / sizeof(cpu_cpuid_ecxfeatures[0]);
- for (i = 0; i < max; i++)
+ for (i = 0; i < nitems(cpu_cpuid_ecxfeatures); i++)
if (cpu_ecxfeature & cpu_cpuid_ecxfeatures[i].bit)
printf(",%s", cpu_cpuid_ecxfeatures[i].str);
- max = sizeof(cpu_ecpuid_features) / sizeof(cpu_ecpuid_features[0]);
- for (i = 0; i < max; i++)
+ for (i = 0; i < nitems(cpu_ecpuid_features); i++)
if (ci->ci_feature_eflags & cpu_ecpuid_features[i].bit)
printf(",%s", cpu_ecpuid_features[i].str);
- max = sizeof(cpu_ecpuid_ecxfeatures) / sizeof(cpu_ecpuid_ecxfeatures[0]);
- for (i = 0; i < max; i++)
+ for (i = 0; i < nitems(cpu_ecpuid_ecxfeatures); i++)
if (ecpu_ecxfeature & cpu_ecpuid_ecxfeatures[i].bit)
printf(",%s", cpu_ecpuid_ecxfeatures[i].str);
- max = sizeof(cpu_cpuid_perf_eax) / sizeof(cpu_cpuid_perf_eax[0]);
- for (i = 0; i < max; i++)
+ for (i = 0; i < nitems(cpu_cpuid_perf_eax); i++)
if (cpu_perf_eax & cpu_cpuid_perf_eax[i].bit)
printf(",%s", cpu_cpuid_perf_eax[i].str);
- max = sizeof(cpu_cpuid_apmi_edx) / sizeof(cpu_cpuid_apmi_edx[0]);
- for (i = 0; i < max; i++)
+ for (i = 0; i < nitems(cpu_cpuid_apmi_edx); i++)
if (cpu_apmi_edx & cpu_cpuid_apmi_edx[i].bit)
printf(",%s", cpu_cpuid_apmi_edx[i].str);
if (cpuid_level >= 0x07) {
/* "Structured Extended Feature Flags" */
CPUID_LEAF(0x7, 0, dummy, ci->ci_feature_sefflags, dummy, dummy);
- max = sizeof(cpu_seff0_ebxfeatures) /
- sizeof(cpu_seff0_ebxfeatures[0]);
- for (i = 0; i < max; i++)
+ for (i = 0; i < nitems(cpu_seff0_ebxfeatures); i++)
if (ci->ci_feature_sefflags &
cpu_seff0_ebxfeatures[i].bit)
printf(",%s", cpu_seff0_ebxfeatures[i].str);
-/* $OpenBSD: machdep.c,v 1.185 2014/07/11 22:28:05 uebayasi Exp $ */
+/* $OpenBSD: machdep.c,v 1.186 2014/07/13 12:11:01 jasper Exp $ */
/* $NetBSD: machdep.c,v 1.3 2003/05/07 22:58:18 fvdl Exp $ */
/*-
int unit = minor(cdp->consdev);
int consaddr = cdp->consaddr;
if (consaddr == -1 && unit >= 0 &&
- unit < (sizeof(ports)/sizeof(ports[0])))
+ unit < nitems(ports))
consaddr = ports[unit];
if (major(cdp->consdev) == 8 &&
consaddr != -1) {
-/* $OpenBSD: trap.c,v 1.41 2014/07/09 07:29:00 guenther Exp $ */
+/* $OpenBSD: trap.c,v 1.42 2014/07/13 12:11:01 jasper Exp $ */
/* $NetBSD: trap.c,v 1.2 2003/05/04 23:51:56 fvdl Exp $ */
/*-
"SSE FP exception", /* 19 T_XMM */
"reserved trap", /* 20 T_RESERVED */
};
-int trap_types = sizeof trap_type / sizeof trap_type[0];
+int trap_types = nitems(trap_type);
#ifdef DEBUG
int trapdebug = 0;
-/* $OpenBSD: db_interface.c,v 1.7 2013/04/30 11:50:47 patrick Exp $ */
+/* $OpenBSD: db_interface.c,v 1.8 2014/07/13 12:11:01 jasper Exp $ */
/* $NetBSD: db_interface.c,v 1.34 2003/10/26 23:11:15 chris Exp $ */
/*
extern label_t *db_recover;
-struct db_variable * db_eregs = db_regs + sizeof(db_regs)/sizeof(db_regs[0]);
+struct db_variable * db_eregs = db_regs + nitems(db_regs);
int db_active = 0;
-/* $OpenBSD: db_interface.c,v 1.34 2014/03/29 18:09:29 guenther Exp $ */
+/* $OpenBSD: db_interface.c,v 1.35 2014/07/13 12:11:01 jasper Exp $ */
/*
* Copyright (c) 1999-2003 Michael Shalayeff
{ "cr28", (long *)&ddb_regs.tf_cr28, FCN_NULL },
{ "cr30", (long *)&ddb_regs.tf_cr30, FCN_NULL },
};
-struct db_variable *db_eregs = db_regs + sizeof(db_regs)/sizeof(db_regs[0]);
+struct db_variable *db_eregs = db_regs + nitems(db_regs);
int db_active = 0;
void
-/* $OpenBSD: db_interface.c,v 1.3 2014/03/29 18:09:29 guenther Exp $ */
+/* $OpenBSD: db_interface.c,v 1.4 2014/07/13 12:11:01 jasper Exp $ */
/*
* Copyright (c) 2005 Michael Shalayeff
{ "pidr1", (long *)&ddb_regs.tf_pidr1, FCN_NULL },
{ "pidr2", (long *)&ddb_regs.tf_pidr2, FCN_NULL },
};
-struct db_variable *db_eregs = db_regs + sizeof(db_regs)/sizeof(db_regs[0]);
+struct db_variable *db_eregs = db_regs + nitems(db_regs);
int db_active = 0;
void
-/* $OpenBSD: db_trace.c,v 1.13 2006/11/28 18:56:17 uwe Exp $ */
+/* $OpenBSD: db_trace.c,v 1.14 2014/07/13 12:11:01 jasper Exp $ */
/* $NetBSD: db_trace.c,v 1.18 1996/05/03 19:42:01 christos Exp $ */
/*
{ "esp", (long *)&ddb_regs.tf_esp, FCN_NULL },
{ "ss", (long *)&ddb_regs.tf_ss, FCN_NULL },
};
-struct db_variable *db_eregs = db_regs + sizeof(db_regs)/sizeof(db_regs[0]);
+struct db_variable *db_eregs = db_regs + nitems(db_regs);
/*
* Stack trace.
-/* $OpenBSD: i686_mem.c,v 1.15 2013/08/24 04:26:16 mlarkin Exp $ */
+/* $OpenBSD: i686_mem.c,v 1.16 2014/07/13 12:11:01 jasper Exp $ */
/*
* Copyright (c) 1999 Michael Smith <msmith@freebsd.org>
* All rights reserved.
MDF_WRITEBACK
};
-#define MTRRTOMRTLEN (sizeof(mtrrtomrt) / sizeof(mtrrtomrt[0]))
-
int
mtrr2mrt(int val)
{
- if (val < 0 || val >= MTRRTOMRTLEN)
+ if (val < 0 || val >= nitems(mtrrtomrt))
return MDF_UNKNOWN;
return mtrrtomrt[val];
}
flags &= MDF_ATTRMASK;
- for (i = 0; i < MTRRTOMRTLEN; i++) {
+ for (i = 0; i < nitems(mtrrtomrt); i++) {
if (mtrrtomrt[i] == MDF_UNKNOWN)
continue;
if (flags == mtrrtomrt[i])
-/* $OpenBSD: db_trace.c,v 1.12 2011/01/03 05:58:19 miod Exp $ */
+/* $OpenBSD: db_trace.c,v 1.13 2014/07/13 12:11:01 jasper Exp $ */
/*
* Mach Operating System
* Copyright (c) 1993-1991 Carnegie Mellon University
};
#undef N
-struct db_variable *db_eregs = db_regs + sizeof(db_regs)/sizeof(db_regs[0]);
+struct db_variable *db_eregs = db_regs + nitems(db_regs);
#define TRASHES 0x001 /* clobbers instruction field D */
#define STORE 0x002 /* does a store to S1+IMM16 */
-/* $OpenBSD: db_machdep.c,v 1.41 2014/07/09 12:58:08 miod Exp $ */
+/* $OpenBSD: db_machdep.c,v 1.42 2014/07/13 12:11:01 jasper Exp $ */
/*
* Copyright (c) 1998-2003 Opsycon AB (www.opsycon.se)
{ "cs", (long *)&ddb_regs.cause, FCN_NULL },
{ "pc", (long *)&ddb_regs.pc, FCN_NULL },
};
-struct db_variable *db_eregs = db_regs + sizeof(db_regs)/sizeof(db_regs[0]);
+struct db_variable *db_eregs = db_regs + nitems(db_regs);
extern label_t *db_recover;
-/* $OpenBSD: db_trace.c,v 1.4 2003/10/15 01:06:13 drahn Exp $ */
+/* $OpenBSD: db_trace.c,v 1.5 2014/07/13 12:11:01 jasper Exp $ */
/* $NetBSD: db_trace.c,v 1.15 1996/02/22 23:23:41 gwr Exp $ */
/*
{ "msr", (long *)&(DDB_REGS->tf.srr1), FCN_NULL },
};
-struct db_variable *db_eregs = db_regs + sizeof(db_regs)/sizeof(db_regs[0]);
+struct db_variable *db_eregs = db_regs + nitems(db_regs);
extern label_t *db_recover;
-/* $OpenBSD: db_trace.c,v 1.5 2008/06/22 21:02:11 miod Exp $ */
+/* $OpenBSD: db_trace.c,v 1.6 2014/07/13 12:11:01 jasper Exp $ */
/* $NetBSD: db_trace.c,v 1.19 2006/01/21 22:10:59 uwe Exp $ */
/*-
{ "macl", (long *)&ddb_regs.tf_macl, FCN_NULL },
};
-struct db_variable *db_eregs =
- db_regs + sizeof(db_regs)/sizeof(db_regs[0]);
+struct db_variable *db_eregs = db_regs + nitems(db_regs);
void
db_stack_trace_print(db_expr_t addr, int have_addr, db_expr_t count,
-/* $OpenBSD: db_interface.c,v 1.13 2010/06/29 21:28:11 miod Exp $ */
+/* $OpenBSD: db_interface.c,v 1.14 2014/07/13 12:11:01 jasper Exp $ */
/* $NetBSD: db_interface.c,v 1.18 1997/09/01 00:16:31 pk Exp $ */
/*
{ "i6", (long *)&DDB_FR->fr_arg[6], FCN_NULL, },
{ "i7", (long *)&DDB_FR->fr_arg[7], FCN_NULL, },
};
-struct db_variable *db_eregs = db_regs + sizeof(db_regs)/sizeof(db_regs[0]);
+struct db_variable *db_eregs = db_regs + nitems(db_regs);
extern label_t *db_recover;
-/* $OpenBSD: db_interface.c,v 1.35 2014/05/10 18:46:20 kettenis Exp $ */
+/* $OpenBSD: db_interface.c,v 1.36 2014/07/13 12:11:01 jasper Exp $ */
/* $NetBSD: db_interface.c,v 1.61 2001/07/31 06:55:47 eeh Exp $ */
/*
{ "gsr", (long *)&DDB_FP->fs_gsr, FCN_NULL, },
};
-struct db_variable *db_eregs = db_regs + sizeof(db_regs)/sizeof(db_regs[0]);
+struct db_variable *db_eregs = db_regs + nitems(db_regs);
extern label_t *db_recover;
-/* $OpenBSD: db_machdep.c,v 1.18 2008/03/30 18:24:04 miod Exp $ */
+/* $OpenBSD: db_machdep.c,v 1.19 2014/07/13 12:11:01 jasper Exp $ */
/* $NetBSD: db_machdep.c,v 1.17 1999/06/20 00:58:23 ragge Exp $ */
/*
{"pc", (long *)&ddb_regs.pc, FCN_NULL},
{"psl", (long *)&ddb_regs.psl, FCN_NULL},
};
-struct db_variable *db_eregs = db_regs + sizeof(db_regs)/sizeof(db_regs[0]);
+struct db_variable *db_eregs = db_regs + nitems(db_regs);
#define IN_USERLAND(x) (((u_int)(x) & 0x80000000) == 0)