ANSIfy, KNF.

This commit is contained in:
uch 2001-09-27 16:31:23 +00:00
parent a9c5a86aa9
commit 69ed217599
7 changed files with 91 additions and 119 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: config_hook.c,v 1.1 2001/01/28 02:52:17 uch Exp $ */
/* $NetBSD: config_hook.c,v 1.2 2001/09/27 16:31:23 uch Exp $ */
/*-
* Copyright (c) 1999-2001
@ -48,7 +48,7 @@ struct hook_rec {
int hr_type;
long hr_id;
enum config_hook_mode hr_mode;
int (*hr_func) __P((void *, int, long, void *));
int (*hr_func)(void *, int, long, void *);
};
LIST_HEAD(hook_list, hook_rec);
@ -65,12 +65,8 @@ config_hook_init()
}
config_hook_tag
config_hook(type, id, mode, func, ctx)
int type;
long id;
enum config_hook_mode mode;
int (*func) __P((void*, int, long, void*));
void *ctx;
config_hook(int type, long id, enum config_hook_mode mode,
int (*func)(void *, int, long, void *), void *ctx)
{
struct hook_rec *hr, *prev_hr;
int s;
@ -85,12 +81,12 @@ config_hook(type, id, mode, func, ctx)
*/
prev_hr = NULL;
for (hr = LIST_FIRST(&hook_lists[type]); hr != NULL;
hr = LIST_NEXT(hr, hr_link)) {
hr = LIST_NEXT(hr, hr_link)) {
if (hr->hr_id == id) {
if (hr->hr_mode != mode) {
panic("config_hook: incompatible mode on "
"type=%d/id=%ld != %d",
type, id, hr->hr_mode);
"type=%d/id=%ld != %d",
type, id, hr->hr_mode);
}
prev_hr = hr;
}
@ -102,7 +98,7 @@ config_hook(type, id, mode, func, ctx)
case CONFIG_HOOK_REPLACE:
if (prev_hr != NULL) {
printf("config_hook: type=%d/id=%ld is replaced",
type, id);
type, id);
s = splhigh();
LIST_REMOVE(prev_hr, hr_link);
prev_hr->hr_link.le_next = NULL;
@ -112,7 +108,7 @@ config_hook(type, id, mode, func, ctx)
case CONFIG_HOOK_EXCLUSIVE:
if (prev_hr != NULL) {
panic("config_hook: type=%d/id=%ld is already "
"hooked(%p)", type, id, prev_hr);
"hooked(%p)", type, id, prev_hr);
}
break;
default:
@ -137,8 +133,7 @@ config_hook(type, id, mode, func, ctx)
}
void
config_unhook(hrx)
config_hook_tag hrx;
config_unhook(config_hook_tag hrx)
{
int s;
struct hook_rec *hr = (struct hook_rec*)hrx;
@ -153,10 +148,7 @@ config_unhook(hrx)
}
int
config_hook_call(type, id, msg)
int type;
long id;
void *msg;
config_hook_call(int type, long id, void *msg)
{
int res;
struct hook_rec *hr;
@ -168,10 +160,11 @@ config_hook_call(type, id, msg)
res = -1;
for (hr = LIST_FIRST(&hook_lists[type]); hr != NULL;
hr = LIST_NEXT(hr, hr_link)) {
hr = LIST_NEXT(hr, hr_link)) {
if (hr->hr_id == id) {
res = (*hr->hr_func)(hr->hr_ctx, type, id, msg);
}
}
return (res);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: config_hook.h,v 1.3 2001/07/19 11:38:01 sato Exp $ */
/* $NetBSD: config_hook.h,v 1.4 2001/09/27 16:31:23 uch Exp $ */
/*-
* Copyright (c) 1999-2001
@ -45,12 +45,11 @@ enum config_hook_mode {
typedef void *config_hook_tag;
void config_hook_init __P((void));
config_hook_tag config_hook __P((int type, long id, enum config_hook_mode mode,
int (*func) __P((void*, int, long, void*)),
void *ctx));
void config_unhook __P((config_hook_tag));
int config_hook_call __P((int type, long id, void *msg));
void config_hook_init(void);
config_hook_tag config_hook(int, long, enum config_hook_mode,
int (*func)(void *, int, long, void *), void *);
void config_unhook(config_hook_tag);
int config_hook_call(int, long, void *);
/*
* hook types and IDs
@ -310,7 +309,8 @@ int config_hook_call __P((int type, long id, void *msg));
#define CONFIG_HOOK_BATT_NO_SYSTEM_BATTERY 14
#define CONFIG_HOOK_MAXVALUE 14 /* max value, check in this file */
#define CONFIG_HOOK_VALUEP(p) ((int)(p)>= 0 && (int)(p)<= CONFIG_HOOK_MAXVALUE)
#define CONFIG_HOOK_VALUEP(p) \
((int)(p) >= 0 && (int)(p) <= CONFIG_HOOK_MAXVALUE)
#define CONFIG_HOOK_PTRP(p) (!CONFIG_HOOK_VALUEP(p))
#endif /* _CONFIG_HOOK_H_ */

View File

@ -1,4 +1,4 @@
/* $NetBSD: disksubr.c,v 1.1 2001/02/21 16:34:00 uch Exp $ */
/* $NetBSD: disksubr.c,v 1.2 2001/09/27 16:31:23 uch Exp $ */
/*
* Copyright (c) 1982, 1986, 1988 Regents of the University of California.
@ -52,7 +52,7 @@ int fat_types[] = { MBR_PTYPE_FAT12, MBR_PTYPE_FAT16S,
#define NO_MBR_SIGNATURE ((struct mbr_partition *) -1)
static struct mbr_partition *
mbr_findslice __P((struct mbr_partition* dp, struct buf *bp));
mbr_findslice(struct mbr_partition* dp, struct buf *bp);
/*
* Scan MBR for NetBSD partittion. Return NO_MBR_SIGNATURE if no MBR found
@ -61,9 +61,7 @@ mbr_findslice __P((struct mbr_partition* dp, struct buf *bp));
*/
static
struct mbr_partition *
mbr_findslice(dp, bp)
struct mbr_partition *dp;
struct buf *bp;
mbr_findslice(struct mbr_partition *dp, struct buf *bp)
{
struct mbr_partition *ourdp = NULL;
u_int16_t *mbrmagicp;
@ -124,11 +122,8 @@ mbr_findslice(dp, bp)
* Returns null on success and an error string on failure.
*/
char *
readdisklabel(dev, strat, lp, osdep)
dev_t dev;
void (*strat) __P((struct buf *));
struct disklabel *lp;
struct cpu_disklabel *osdep;
readdisklabel(dev_t dev, void (*strat)(struct buf *), struct disklabel *lp,
struct cpu_disklabel *osdep)
{
struct mbr_partition *dp;
struct partition *pp;
@ -319,10 +314,8 @@ done:
* before setting it.
*/
int
setdisklabel(olp, nlp, openmask, osdep)
struct disklabel *olp, *nlp;
u_long openmask;
struct cpu_disklabel *osdep;
setdisklabel(struct disklabel *olp, struct disklabel *nlp, u_long openmask,
struct cpu_disklabel *osdep)
{
int i;
struct partition *opp, *npp;
@ -375,11 +368,8 @@ setdisklabel(olp, nlp, openmask, osdep)
* Write disk label back to device after modification.
*/
int
writedisklabel(dev, strat, lp, osdep)
dev_t dev;
void (*strat) __P((struct buf *));
struct disklabel *lp;
struct cpu_disklabel *osdep;
writedisklabel(dev_t dev, void (*strat)(struct buf *), struct disklabel *lp,
struct cpu_disklabel *osdep)
{
struct mbr_partition *dp;
struct buf *bp;
@ -466,10 +456,7 @@ done:
* if needed, and signal errors or early completion.
*/
int
bounds_check_with_label(bp, lp, wlabel)
struct buf *bp;
struct disklabel *lp;
int wlabel;
bounds_check_with_label(struct buf *bp, struct disklabel *lp, int wlabel)
{
struct partition *p = lp->d_partitions + DISKPART(bp->b_dev);
int labelsector = lp->d_partitions[2].p_offset + LABELSECTOR;

View File

@ -1,4 +1,4 @@
/* $NetBSD: platid.c,v 1.2 2001/09/24 14:29:31 takemura Exp $ */
/* $NetBSD: platid.c,v 1.3 2001/09/27 16:31:23 uch Exp $ */
/*-
* Copyright (c) 1999-2001
@ -47,6 +47,7 @@ platid_t platid = {{ PLATID_UNKNOWN, PLATID_UNKNOWN }};
void
platid_ntoh(platid_t *pid)
{
pid->dw.dw0 = ntohl(pid->dw.dw0);
pid->dw.dw1 = ntohl(pid->dw.dw1);
}
@ -54,6 +55,7 @@ platid_ntoh(platid_t *pid)
void
platid_hton(platid_t *pid)
{
pid->dw.dw0 = htonl(pid->dw.dw0);
pid->dw.dw1 = htonl(pid->dw.dw1);
}
@ -63,6 +65,7 @@ platid_dump(char *name, void* pxx)
{
int i;
unsigned char* p = (unsigned char*)pxx;
printf("%14s: ", name);
for (i = 0; i < 8; i++) {
@ -74,7 +77,8 @@ platid_dump(char *name, void* pxx)
int
platid_match(platid_t *platid, platid_mask_t *mask)
{
return platid_match_sub(platid, mask, 0);
return (platid_match_sub(platid, mask, 0));
}
int
@ -127,8 +131,9 @@ platid_search_data(platid_t *platid, struct platid_data *datap)
while (datap->mask != NULL && !platid_match(platid, datap->mask))
datap++;
if (datap->mask == NULL && datap->data == NULL)
return NULL;
return datap;
return (NULL);
return (datap);
}
void *

View File

@ -1,4 +1,4 @@
/* $NetBSD: platid_gen.c,v 1.3 2001/04/20 10:15:03 sato Exp $ */
/* $NetBSD: platid_gen.c,v 1.4 2001/09/27 16:31:24 uch Exp $ */
/*-
* Copyright (c) 1999
@ -64,15 +64,15 @@ struct genctx_t {
/*
* function prototypes
*/
void gen_list __P((node_t*));
void gen_output __P((void));
void gen_header __P((void));
void gen_mask_h __P((void));
void gen_mask_c __P((void));
void gen_name_c __P((void));
void gen_comment __P((FILE *fp));
void enter __P((void));
void leave __P((void));
void gen_list(node_t *);
void gen_output(void);
void gen_header(void);
void gen_mask_h(void);
void gen_mask_c(void);
void gen_name_c(void);
void gen_comment(FILE *);
void enter(void);
void leave(void);
/*
* global data
@ -113,9 +113,7 @@ char* shift_names[NMODES][MAXNEST] = {
* program entry
*/
int
main(argc, argv)
int argc;
char *argv[];
main(int argc, char *argv[])
{
int i;
@ -126,17 +124,13 @@ main(argc, argv)
for (i = 1; i < argc; i++) {
if (strcmp(argv[i], "-header") == 0) {
form = FORM_GENHDR;
} else
if (strcmp(argv[i], "-mask_h") == 0) {
} else if (strcmp(argv[i], "-mask_h") == 0) {
form = FORM_MASK_H;
} else
if (strcmp(argv[i], "-mask_c") == 0) {
} else if (strcmp(argv[i], "-mask_c") == 0) {
form = FORM_MASK_C;
} else
if (strcmp(argv[i], "-name_c") == 0) {
} else if (strcmp(argv[i], "-name_c") == 0) {
form = FORM_NAME_C;
} else
if (strcmp(argv[i], "-parse_only") == 0) {
} else if (strcmp(argv[i], "-parse_only") == 0) {
form = FORM_PARSE_ONLY;
} else {
usage:
@ -199,11 +193,7 @@ main(argc, argv)
}
int
table_getnum(table, s, def, opt)
char **table;
char *s;
int def;
int opt;
table_getnum(char **table, char *s, int def, int opt)
{
int num;
@ -256,8 +246,7 @@ leave()
}
void
gen_comment(fp)
FILE *fp;
gen_comment(FILE *fp)
{
fprintf(fp, "/*\n");
fprintf(fp, " * Do not edit.\n");
@ -265,13 +254,8 @@ gen_comment(fp)
fprintf(fp, " */\n");
}
gen_name(buf, ctx, nest, name, punct, ignr)
char *buf;
struct genctx_t ctx[];
int nest;
int name;
char *punct;
int ignr;
gen_name(char *buf, struct genctx_t ctx[], int nest, int name, char *punct,
int ignr)
{
int i;
buf[0] = '\0';
@ -286,8 +270,7 @@ gen_name(buf, ctx, nest, name, punct, ignr)
}
void
gen_list(np)
node_t* np;
gen_list(node_t* np)
{
int i, t;
@ -296,7 +279,7 @@ gen_list(np)
case N_LABEL:
if ((mode = GET_MODE(np->ptr1)) == MODE_INVALID) {
fprintf(stderr, "invalid mode '%s'\n",
np->ptr1);
np->ptr1);
exit(1);
}
break;
@ -304,13 +287,13 @@ gen_list(np)
t = GET_ALT(np->ptr1);
if (t == MODE_INVALID) {
fprintf(stderr, "unknown alternater '%s'\n",
np->ptr1);
np->ptr1);
exit(1);
}
if (t == mode) {
fprintf(stderr,
"invalid alternater '%s' (ignored)\n",
np->ptr1);
"invalid alternater '%s' (ignored)\n",
np->ptr1);
exit(1);
}
genctx[mode][nest].alt = np->ptr2;
@ -319,8 +302,8 @@ gen_list(np)
if (np->ptr2 == NULL) {
char buf[MAXLEN];
sprintf(buf, "%s%s",
nest == 0 ? "" : " ",
np->ptr1);
nest == 0 ? "" : " ",
np->ptr1);
np->ptr2 = strdup(buf);
if (nest == 3)
np->val = 1;
@ -331,9 +314,9 @@ gen_list(np)
genctx[mode][nest].node_name[0] = np->ptr1;
genctx[mode][nest].node_name[1] = np->ptr2;
gen_name(genctx[mode][nest].sym, genctx[mode],
nest, 0, "_", nest == 3 ? 2 : nest);
nest, 0, "_", nest == 3 ? 2 : nest);
gen_name(genctx[mode][nest].name, genctx[mode],
nest, 1, "", nest - np->val);
nest, 1, "", nest - np->val);
gen_output();
break;
case N_LIST:
@ -398,18 +381,18 @@ gen_header()
char *name = genctx[mode][nest].sym;
if (mode == MODE_MACHINE) {
fprintf(fp_out, "#ifndef SPEC_PLATFORM\n");
fprintf(fp_out, "#define %s_%s_%s\n", "SPEC", prefix, name);
fprintf(fp_out, "#endif /* !SPEC_PLATFORM */\n");
fprintf(fp_out, "#ifndef SPEC_PLATFORM\n");
fprintf(fp_out, "#define %s_%s_%s\n", "SPEC", prefix, name);
fprintf(fp_out, "#endif /* !SPEC_PLATFORM */\n");
}
fprintf(fp_out, "#define %s_%s_%s_NUM\t%d\n", PREFIX, prefix, name,
genctx[mode][nest].num);
genctx[mode][nest].num);
fprintf(fp_out, "#define %s_%s_%s\t\\\n", PREFIX, prefix, name);
fprintf(fp_out, " ((%s_%s_%s_NUM << %s)", PREFIX, prefix, name,
shift_names[mode][nest]);
shift_names[mode][nest]);
if (0 < nest) {
fprintf(fp_out, "| \\\n %s_%s_%s",
PREFIX, prefix, genctx[mode][nest - 1].sym);
PREFIX, prefix, genctx[mode][nest - 1].sym);
}
fprintf(fp_out, ")\n");
}
@ -428,11 +411,11 @@ gen_mask_h()
char *name = genctx[mode][nest].sym;
fprintf(fp_out, "extern platid_t platid_mask_%s_%s;\n",
prefix_names[mode], name);
prefix_names[mode], name);
fprintf(fp_out, "#ifdef PLATID_DEFINE_MASK_NICKNAME\n");
fprintf(fp_out, "# define %s%s ((int)&platid_mask_%s_%s)\n",
(mode == MODE_CPU)?"GENERIC_":"",
name, prefix_names[mode], name);
(mode == MODE_CPU)?"GENERIC_":"",
name, prefix_names[mode], name);
fprintf(fp_out, "#endif\n");
}
@ -450,7 +433,7 @@ gen_mask_c()
char *name = genctx[mode][nest].sym;
fprintf(fp_out, "platid_t platid_mask_%s_%s = {{\n",
prefix_names[mode], name);
prefix_names[mode], name);
switch (mode) {
case MODE_CPU:
fprintf(fp_out, "\t%s_CPU_%s,\n", PREFIX, name);
@ -458,14 +441,14 @@ gen_mask_c()
fprintf(fp_out, "\t%s_WILD\n", PREFIX);
else
fprintf(fp_out, "\t%s_MACH_%s,\n", PREFIX,
genctx[mode][nest].alt);
genctx[mode][nest].alt);
break;
case MODE_MACHINE:
if (genctx[mode][nest].alt == NULL)
fprintf(fp_out, "\t%s_WILD,\n", PREFIX);
else
fprintf(fp_out, "\t%s_CPU_%s,\n", PREFIX,
genctx[mode][nest].alt);
genctx[mode][nest].alt);
fprintf(fp_out, "\t%s_MACH_%s\n", PREFIX, name);
break;
}
@ -479,7 +462,7 @@ void
gen_name_c()
{
fprintf(fp_out, "\t{ &platid_mask_%s_%s,\n",
prefix_names[mode], genctx[mode][nest].sym);
prefix_names[mode], genctx[mode][nest].sym);
fprintf(fp_out, "\t TEXT(\"%s\") },\n", genctx[mode][nest].name);
count++;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: platid_gen.h,v 1.2 2001/02/04 05:19:15 takemura Exp $ */
/* $NetBSD: platid_gen.h,v 1.3 2001/09/27 16:31:24 uch Exp $ */
/*-
* Copyright (c) 1999
@ -43,7 +43,7 @@ typedef struct node_s {
extern node_t* def_tree;
node_t* new_node __P((int, int, const void*, const void*, node_t*));
void* mem_alloc __P((int size));
void dump_node __P((char *prefix, node_t* n));
char* touppers __P((char*));
node_t *new_node(int, int, const void *, const void *, node_t *);
void *mem_alloc(int);
void *dump_node(char *, node_t *);
char *touppers(char*);

View File

@ -1,8 +1,12 @@
/* $NetBSD: cdefs.h,v 1.1 2001/02/09 18:35:24 uch Exp $ */
/* $NetBSD: cdefs.h,v 1.2 2001/09/27 16:31:25 uch Exp $ */
/* Windows CE architecture */
#define __BEGIN_MACRO do {
#define __END_MACRO } while (/*CONSTCOND*/0)
#define NAMESPACE_BEGIN(x) namespace x {
#define NAMESPACE_END }
#define USING_NAMESPACE(x) using namespace x;
#include <sys/cdefs.h>