diff --git a/boot/boot.c b/boot/boot.c index 3b3497eea..2f30fa172 100644 --- a/boot/boot.c +++ b/boot/boot.c @@ -743,7 +743,7 @@ static void sfree(char *s) if (s != nil && s != null) free(s); } -static char *copystr(char *s) +static char *copystr(const char *s) /* Copy a non-null string using malloc. */ { char *c; @@ -754,12 +754,12 @@ static char *copystr(char *s) return c; } -static int is_default(environment *e) +static int is_default(const environment *e) { return (e->flags & E_SPECIAL) && e->defval == nil; } -static environment **searchenv(char *name) +static environment **searchenv(const char *name) { environment **aenv= &env; @@ -1538,7 +1538,7 @@ int expired(void) return (Thandler != nil && milli_since(Tbase) >= Tcount); } -void delay(char *msec) +void delay(const char *msec) /* Delay for a given time. */ { u32_t base, count; @@ -1553,7 +1553,7 @@ void delay(char *msec) } while (!interrupt() && !expired() && milli_since(base) < count); } -static enum whatfun { NOFUN, SELECT, DEFFUN, USERFUN } menufun(environment *e) +static enum whatfun { NOFUN, SELECT, DEFFUN, USERFUN } menufun(const environment *e) { if (!(e->flags & E_FUNCTION) || e->arg[0] == 0) return NOFUN; if (e->arg[1] != ',') return SELECT; diff --git a/boot/boot.h b/boot/boot.h index 3aa625139..51ae27939 100644 --- a/boot/boot.h +++ b/boot/boot.h @@ -213,7 +213,7 @@ EXTERN char *drun; /* Initial command from DOS command line. */ #endif void readblock(off_t, char *, int); -void delay(char *); +void delay(const char *); /* * $PchId: boot.h,v 1.12 2002/02/27 19:42:45 philip Exp $ diff --git a/boot/bootimage.c b/boot/bootimage.c index a224ccba9..6c3ab3590 100644 --- a/boot/bootimage.c +++ b/boot/bootimage.c @@ -84,7 +84,7 @@ int n_procs; /* Number of processes. */ #define between(a, c, z) ((unsigned) ((c) - (a)) <= ((z) - (a))) -void pretty_image(char *image) +void pretty_image(const char *image) /* Pretty print the name of the image to load. Translate '/' and '_' to * space, first letter goes uppercase. An 'r' before a digit prints as * 'revision'. E.g. 'minix/1.6.16r10' -> 'Minix 1.6.16 revision 10'. @@ -234,7 +234,7 @@ void patch_sizes(void) put_word(process[FS].data + P_INIT_OFF+4, data_size); } -int selected(char *name) +int selected(const char *name) /* True iff name has no label or the proper label. */ { char *colon, *label; @@ -249,7 +249,7 @@ int selected(char *name) return cmp == 0; } -u32_t proc_size(struct image_header *hdr) +static u32_t proc_size(const struct image_header *hdr) /* Return the size of a process in sectors as found in an image. */ { u32_t len= hdr->process.a_text; diff --git a/boot/installboot.c b/boot/installboot.c index ccaf31dea..29e53a3d4 100644 --- a/boot/installboot.c +++ b/boot/installboot.c @@ -40,13 +40,13 @@ #define BOOT_BLOCK_SIZE 1024 -void report(char *label) +static void report(const char *label) /* installboot: label: No such file or directory */ { fprintf(stderr, "installboot: %s: %s\n", label, strerror(errno)); } -void fatal(char *label) +static void fatal(const char *label) { report(label); exit(1); @@ -75,7 +75,7 @@ char *basename(char *name) return base; } -void bread(FILE *f, char *name, void *buf, size_t len) +static void bread(FILE *f, char *name, void *buf, size_t len) /* Read len bytes. Don't dare return without them. */ { if (len > 0 && fread(buf, len, 1, f) != 1) { @@ -85,7 +85,7 @@ void bread(FILE *f, char *name, void *buf, size_t len) } } -void bwrite(FILE *f, char *name, void *buf, size_t len) +static void bwrite(FILE *f, char *name, const void *buf, size_t len) { if (len > 0 && fwrite(buf, len, 1, f) != 1) fatal(name); } @@ -351,7 +351,7 @@ void readblock(off_t blk, char *buf, int block_size) } } -void writeblock(off_t blk, char *buf, int block_size) +void writeblock(off_t blk, const char *buf, int block_size) /* Add a function to write blocks for local use. */ { if (lseek(rawfd, blk * block_size, SEEK_SET) < 0 @@ -685,7 +685,7 @@ void make_bootable(enum howto how, char *device, char *bootblock, } } -void install_master(char *device, char *masterboot, char **guide) +static void install_master(char *device, char *masterboot, char **guide) /* Booting a hard disk is a two stage process: The master bootstrap in sector * 0 loads the bootstrap from sector 0 of the active partition which in turn * starts the operating system. This code installs such a master bootstrap @@ -727,8 +727,8 @@ void install_master(char *device, char *masterboot, char **guide) if (guide[0] != nil) { /* Fixate partition to boot. */ - char *keys= guide[0]; - char *logical= guide[1]; + const char *keys= guide[0]; + const char *logical= guide[1]; size_t i; int logfd; u32_t offset; @@ -782,7 +782,7 @@ void install_master(char *device, char *masterboot, char **guide) writeblock(BOOTBLOCK, buf, BOOT_BLOCK_SIZE); } -void usage(void) +static void usage(void) { fprintf(stderr, "Usage: installboot -i(mage) image kernel mm fs ... init\n" @@ -793,7 +793,7 @@ void usage(void) exit(1); } -int isoption(char *option, char *test) +static int isoption(const char *option, char *test) /* Check if the option argument is equals "test". Also accept -i as short * for -image, and the special case -x for -extract. */ diff --git a/boot/rawfs.c b/boot/rawfs.c index a143dc8ff..e77ca35e9 100644 --- a/boot/rawfs.c +++ b/boot/rawfs.c @@ -286,7 +286,7 @@ off_t r_vir2abs(off_t virblk) return z; } -ino_t r_lookup(Ino_t cwd, char *path) +ino_t r_lookup(Ino_t cwd, const char *path) /* Translates a pathname to an inode number. This is just a nice utility * function, it only needs r_stat and r_readdir. */ diff --git a/boot/rawfs.h b/boot/rawfs.h index ccab56828..a177b7475 100644 --- a/boot/rawfs.h +++ b/boot/rawfs.h @@ -17,7 +17,7 @@ * Return next directory entry or 0 if there are no more. * Returns -1 and sets errno on error. * - * ino_t r_lookup(ino_t cwd, char *path); + * ino_t r_lookup(ino_t cwd, const char *path); * A utility function that translates a pathname to an * inode number. It starts from directory "cwd" unless * path starts with a '/', then from ROOT_INO. @@ -39,7 +39,7 @@ extern off_t r_super(int *); extern void r_stat(Ino_t file, struct stat *stp); extern off_t r_vir2abs(off_t virblockno); extern ino_t r_readdir(char *name); -extern ino_t r_lookup(Ino_t cwd, char *path); +extern ino_t r_lookup(Ino_t cwd, const char *path); /* * $PchId: rawfs.h,v 1.4 1996/04/19 08:16:36 philip Exp $ diff --git a/commands/ash/alias.c b/commands/ash/alias.c index 90ef85ba0..5a8a3c1cf 100644 --- a/commands/ash/alias.c +++ b/commands/ash/alias.c @@ -57,7 +57,7 @@ STATIC struct alias *atab[ATABSIZE]; STATIC void setalias(char *, char *); STATIC int unalias(char *); -STATIC struct alias **hashalias(char *); +STATIC struct alias **hashalias(const char *); STATIC void @@ -250,7 +250,7 @@ unaliascmd(int argc __unused, char **argv __unused) } STATIC struct alias ** -hashalias(char *p) +hashalias(const char *p) { unsigned int hashval; diff --git a/commands/ash/cd.c b/commands/ash/cd.c index e54289d7c..055cb75a0 100644 --- a/commands/ash/cd.c +++ b/commands/ash/cd.c @@ -68,10 +68,10 @@ __FBSDID("$FreeBSD: src/bin/sh/cd.c,v 1.34 2004/04/06 20:06:51 markm Exp $"); #include "cd.h" STATIC int cdlogical(char *); -STATIC int cdphysical(char *); +STATIC int cdphysical(const char *); STATIC int docd(char *, int, int); STATIC char *getcomponent(void); -STATIC int updatepwd(char *); +STATIC int updatepwd(const char *); STATIC char *curdir = NULL; /* current working directory */ STATIC char *prevdir; /* previous working directory */ @@ -212,7 +212,7 @@ cdlogical(char *dest) } STATIC int -cdphysical(char *dest) +cdphysical(const char *dest) { INTOFF; @@ -255,7 +255,7 @@ getcomponent(void) * that the current directory has changed. */ STATIC int -updatepwd(char *dir) +updatepwd(const char *dir) { char *new; char *p; diff --git a/commands/awk/b.c b/commands/awk/b.c index a4a46acbf..75c6992be 100644 --- a/commands/awk/b.c +++ b/commands/awk/b.c @@ -378,7 +378,7 @@ void cfoll(fa *f, Node *v) /* enter follow set of each leaf of vertex v into lfo } } -int first(Node *p) /* collects initially active leaves of p into setvec */ +int first(const Node *p) /* collects initially active leaves of p into setvec */ /* returns 0 if p matches empty string */ { int b, lp; diff --git a/commands/awk/proto.h b/commands/awk/proto.h index 0a68b3a81..359ae64c9 100644 --- a/commands/awk/proto.h +++ b/commands/awk/proto.h @@ -48,7 +48,7 @@ extern int quoted(char **); extern char *cclenter(const char *); extern void overflo(const char *); extern void cfoll(fa *, Node *); -extern int first(Node *); +extern int first(const Node *); extern void follow(Node *); extern int member(int, const char *); extern int match(fa *, const char *); @@ -97,12 +97,12 @@ extern void syminit(void); extern void arginit(int, char **); extern void envinit(char **); extern Array *makesymtab(int); -extern void freesymtab(Cell *); -extern void freeelem(Cell *, const char *); +extern void freesymtab(const Cell *); +extern void freeelem(const Cell *, const char *); extern Cell *setsymtab(const char *, const char *, double, unsigned int, Array *); extern int hash(const char *, int); extern void rehash(Array *); -extern Cell *lookup(const char *, Array *); +extern Cell *lookup(const char *, const Array *); extern double setfval(Cell *, double); extern void funnyvar(Cell *, const char *); extern char *setsval(Cell *, const char *); diff --git a/commands/awk/tran.c b/commands/awk/tran.c index c19ce9430..57dd281b3 100644 --- a/commands/awk/tran.c +++ b/commands/awk/tran.c @@ -154,7 +154,7 @@ Array *makesymtab(int n) /* make a new symbol table */ return(ap); } -void freesymtab(Cell *ap) /* free a symbol table */ +void freesymtab(const Cell *ap) /* free a symbol table */ { Cell *cp, *temp; Array *tp; @@ -182,7 +182,8 @@ void freesymtab(Cell *ap) /* free a symbol table */ free(tp); } -void freeelem(Cell *ap, const char *s) /* free elem s from ap (i.e., ap["s"] */ +void freeelem(const Cell *ap, const char *s) +/* free elem s from ap (i.e., ap["s"] */ { Array *tp; Cell *p, *prev = NULL; @@ -266,7 +267,7 @@ void rehash(Array *tp) /* rehash items in small table into big one */ tp->size = nsz; } -Cell *lookup(const char *s, Array *tp) /* look for s in tp */ +Cell *lookup(const char *s, const Array *tp) /* look for s in tp */ { Cell *p; int h; @@ -359,7 +360,8 @@ Awkfloat getfval(Cell *vp) /* get float val of a Cell */ return(vp->fval); } -static char *get_str_val(Cell *vp, char **fmt) /* get string val of a Cell */ +static char *get_str_val(Cell *vp, char **fmt) +/* get string val of a Cell */ { char s[100]; /* BUG: unchecked */ double dtemp; diff --git a/commands/simple/add_route.c b/commands/simple/add_route.c index cc7380c4f..738952126 100644 --- a/commands/simple/add_route.c +++ b/commands/simple/add_route.c @@ -28,8 +28,8 @@ static char *prog_name; static enum { ADD, DEL } action; static void usage(void); -static int name_to_ip(char *name, ipaddr_t *addr); -static int parse_cidr(char *cidr, ipaddr_t *addr, ipaddr_t *mask); +static int name_to_ip(const char *name, ipaddr_t *addr); +static int parse_cidr(const char *cidr, ipaddr_t *addr, ipaddr_t *mask); int main(int argc, char *argv[]) { @@ -297,7 +297,7 @@ static void usage(void) exit(1); } -static int name_to_ip(char *name, ipaddr_t *addr) +static int name_to_ip(const char *name, ipaddr_t *addr) { /* Translate a name to an IP address. Try first with inet_aton(), then * with gethostbyname(). (The latter can also recognize an IP address, @@ -314,7 +314,7 @@ static int name_to_ip(char *name, ipaddr_t *addr) return 1; } -static int parse_cidr(char *cidr, ipaddr_t *addr, ipaddr_t *mask) +static int parse_cidr(const char *cidr, ipaddr_t *addr, ipaddr_t *mask) { char *slash, *check; ipaddr_t a; diff --git a/commands/simple/arp.c b/commands/simple/arp.c index aef07c26f..7304f15ca 100644 --- a/commands/simple/arp.c +++ b/commands/simple/arp.c @@ -43,7 +43,7 @@ static void delete(char *hostname); static void do_set(char *hostname, char *ethername, int temp, int pub, int optdelete); static ipaddr_t nametoipaddr(char *hostname); -static void fatal(char *fmt, ...); +static void fatal(const char *fmt, ...); static void usage(void); int main(int argc, char *argv[]) @@ -444,7 +444,7 @@ static char *ether_ntoa(struct ether_addr *eap) } #endif -static void fatal(char *fmt, ...) +static void fatal(const char *fmt, ...) { va_list ap; diff --git a/commands/simple/cat.c b/commands/simple/cat.c index a16af02c1..6ed99a018 100644 --- a/commands/simple/cat.c +++ b/commands/simple/cat.c @@ -21,7 +21,7 @@ static char obuf[CHUNK_SIZE]; static char *op = obuf; static void copyout(const char *file, int fd); -static void output(char *buf, size_t count); +static void output(const char *buf, size_t count); static void report(const char *label); static void fatal(const char *label); @@ -103,7 +103,7 @@ static void copyout(const char *file, int fd) } } -static void output(char *buf, size_t count) +static void output(const char *buf, size_t count) { ssize_t n; diff --git a/commands/simple/chmod.c b/commands/simple/chmod.c index f37f718ab..1707a91f8 100644 --- a/commands/simple/chmod.c +++ b/commands/simple/chmod.c @@ -39,13 +39,11 @@ int rflag, errors; struct stat st; char path[PATH_MAX + 1]; -_PROTOTYPE(int main, (int argc, char **argv)); -_PROTOTYPE(mode_t parsemode, (char *symbolic, mode_t oldmode)); _PROTOTYPE(int do_change, (char *name)); _PROTOTYPE(void usage, (void)); /* Parse a P1003.2 4.7.7-conformant symbolic mode. */ -mode_t parsemode(char *symbolic, mode_t oldmode) +mode_t parsemode(const char *symbolic, mode_t oldmode) { mode_t who, mask, newmode, tmpmask; char action; @@ -160,9 +158,7 @@ mode_t parsemode(char *symbolic, mode_t oldmode) /* Main module. The single option possible (-R) does not warrant a call to * the getopt() stuff. */ -int main(argc, argv) -int argc; -char *argv[]; +int main(int argc, char *argv[]) { int ex_code = 0; diff --git a/commands/simple/cleantmp.c b/commands/simple/cleantmp.c index b98c547a1..a0d403e73 100644 --- a/commands/simple/cleantmp.c +++ b/commands/simple/cleantmp.c @@ -83,7 +83,7 @@ void days2time(unsigned long days, time_t *retired, time_t *dotretired) char *path; /* Path name constructed in path[]. */ int plen= 0, pidx= 0; /* Lenght/index for path[]. */ -void addpath(int *didx, char *name) +void addpath(int *didx, const char *name) /* Add a component to path. (name may also be a full path at the first call) * The index where the current path ends is stored in *pdi. */ @@ -171,7 +171,7 @@ struct file *shorten(struct file *list) struct file *ignore_list[1024]; size_t n_ignored= 0; -unsigned ihash(char *name) +unsigned ihash(const char *name) /* A simple hashing function on a file name. */ { unsigned h= 0; diff --git a/commands/simple/cp.c b/commands/simple/cp.c index 0439748eb..d4e8745d1 100644 --- a/commands/simple/cp.c +++ b/commands/simple/cp.c @@ -238,7 +238,7 @@ int writable(const struct stat *stp) #define PATH_MAX 1024 #endif -static char *link_islink(struct stat *stp, const char *file) +static char *link_islink(const struct stat *stp, const char *file) { /* Tell if a file, which stat(2) information in '*stp', has been seen * earlier by this function under a different name. If not return a @@ -347,7 +347,7 @@ static char *link_islink(struct stat *stp, const char *file) } int trylink(const char *src, const char *dst, struct stat *srcst, - struct stat *dstst) + const struct stat *dstst) /* Keep the link structure intact if src has been seen before. */ { char *olddst; @@ -679,7 +679,7 @@ void copy1(const char *src, const char *dst, struct stat *srcst, } } -void remove1(const char *src, struct stat *srcst) +void remove1(const char *src, const struct stat *srcst) { if (iflag || (!fflag && !writable(srcst))) { fprintf(stderr, "Remove %s? (mode = %03o) ", src, @@ -693,8 +693,8 @@ void remove1(const char *src, struct stat *srcst) } } -void link1(const char *src, const char *dst, struct stat *srcst, - struct stat *dstst) +void link1(const char *src, const char *dst, const struct stat *srcst, + const struct stat *dstst) { pathname_t sym; const char *p; diff --git a/commands/simple/df.c b/commands/simple/df.c index 823127960..908b58a10 100644 --- a/commands/simple/df.c +++ b/commands/simple/df.c @@ -55,7 +55,7 @@ struct mtab { /* List of mounted devices from /etc/mtab. */ } *mtab= NULL; struct mtab *searchtab(char *name); -void readmtab(char *type); +static void readmtab(const char *type); int df(const struct mtab *mt); bit_t bit_count(unsigned blocks, bit_t bits, int fd, int bs); @@ -132,7 +132,7 @@ Filesystem Files Free Used % BUsed% Mounted on" exit(ex); } -void readmtab(char *type) +static void readmtab(const char *type) /* Turn the mounted file table into a list. */ { struct mtab **amt= &mtab, *new; diff --git a/commands/simple/du.c b/commands/simple/du.c index 2803740d5..3e26ede44 100644 --- a/commands/simple/du.c +++ b/commands/simple/du.c @@ -138,7 +138,7 @@ nlink_t nlink; return(0); } -int get_block_size(char *dir, struct stat *st) +int get_block_size(const char *dir, const struct stat *st) { struct statfs stfs; static int fs_block_size = -1, fs_dev = -1; diff --git a/commands/simple/fix.c b/commands/simple/fix.c index 46541f746..af04cd60e 100644 --- a/commands/simple/fix.c +++ b/commands/simple/fix.c @@ -38,18 +38,15 @@ char *prog = 0, *processing = 0; -_PROTOTYPE(int main, (int argc, char **argv)); _PROTOTYPE(char *getline, (FILE *fp, char *b)); _PROTOTYPE(char *range, (char *s, int *p1, int *p2)); _PROTOTYPE(int getcommand, (FILE *fp, int *o1, int *o2, char *pcmd, int *n1, int *n2)); -_PROTOTYPE(void fatal, (char *s, ...)); +_PROTOTYPE(void fatal, (const char *s, ...)); _PROTOTYPE(int strwcmp, (char *s1, char *s2)); _PROTOTYPE(int whitespace, (int ch)); char * - getline(fp, b) -FILE *fp; -char *b; +getline(FILE *fp, char *b) { if (fgets(b, LINELEN, fp) == NULL) fatal("unexpected eof"); @@ -58,9 +55,7 @@ char *b; #define copy(str) printf("%s", str) -int main(argc, argv) -int argc; -char **argv; +int main(int argc, char **argv) { char cmd, *fl, *fd, obuf[LINELEN], nbuf[LINELEN]; int o1, o2, n1, n2, here; @@ -155,7 +150,7 @@ char *pcmd; } #ifdef __STDC__ -void fatal(char *s, ...) +void fatal(const char *s, ...) { va_list args; @@ -169,7 +164,7 @@ void fatal(char *s, ...) #else /* the K&R lib does not have vfprintf */ void fatal(s, a) -char *s, *a; +const char *s, *a; { fprintf(stderr, "%s: processing: %s fatal: ", prog, processing); fprintf(stderr, s, a); diff --git a/commands/simple/getty.c b/commands/simple/getty.c index 42d931f35..d4feb4541 100644 --- a/commands/simple/getty.c +++ b/commands/simple/getty.c @@ -47,7 +47,7 @@ char *tty_name; /* name of the line */ /* Crude indication of a tty being physically secure: */ #define securetty(dev) ((unsigned) ((dev) - 0x0400) < (unsigned) 8) -void std_out(char *s) +void std_out(const char *s) { write(1, s, strlen(s)); } diff --git a/kernel/arch/i386/apic.c b/kernel/arch/i386/apic.c index b5fa1a26f..1547ecca3 100644 --- a/kernel/arch/i386/apic.c +++ b/kernel/arch/i386/apic.c @@ -167,12 +167,12 @@ PUBLIC void apic_calibrate_clocks(void) cpu_set_freq(cpuid, cpu_freq); } -PRIVATE void lapic_set_timer_one_shot(u32_t value) +PRIVATE void lapic_set_timer_one_shot(const u32_t value) { /* sleep in micro seconds */ u32_t lvtt; u32_t ticks_per_us; - u8_t cpu = cpuid; + const u8_t cpu = cpuid; ticks_per_us = lapic_bus_freq[cpu] / 1000000; @@ -187,12 +187,12 @@ PRIVATE void lapic_set_timer_one_shot(u32_t value) lapic_write(LAPIC_TIMER_ICR, value * ticks_per_us); } -PUBLIC void lapic_set_timer_periodic(unsigned freq) +PUBLIC void lapic_set_timer_periodic(const unsigned freq) { /* sleep in micro seconds */ u32_t lvtt; u32_t lapic_ticks_per_clock_tick; - u8_t cpu = cpuid; + const u8_t cpu = cpuid; lapic_ticks_per_clock_tick = lapic_bus_freq[cpu] / freq; @@ -432,7 +432,7 @@ PRIVATE void lapic_set_dummy_handlers(void) #endif /* Build descriptors for interrupt gates in IDT. */ -PUBLIC void apic_idt_init(int reset) +PUBLIC void apic_idt_init(const int reset) { /* Set up idt tables for smp mode. */ diff --git a/kernel/arch/i386/breakpoints.c b/kernel/arch/i386/breakpoints.c index 0e9d40785..176ae609a 100644 --- a/kernel/arch/i386/breakpoints.c +++ b/kernel/arch/i386/breakpoints.c @@ -3,7 +3,7 @@ #include "debugreg.h" -int breakpoint_set(phys_bytes linaddr, int bp, int flags) +int breakpoint_set(phys_bytes linaddr, int bp, const int flags) { u32_t dr7, dr7flags; diff --git a/kernel/arch/i386/clock.c b/kernel/arch/i386/clock.c index 220d55550..09392c40b 100644 --- a/kernel/arch/i386/clock.c +++ b/kernel/arch/i386/clock.c @@ -33,7 +33,7 @@ PRIVATE irq_hook_t pic_timer_hook; /* interrupt handler hook */ /*===========================================================================* * init_8235A_timer * *===========================================================================*/ -PUBLIC int init_8253A_timer(unsigned freq) +PUBLIC int init_8253A_timer(const unsigned freq) { /* Initialize channel 0 of the 8253A timer to, e.g., 60 Hz, * and register the CLOCK task's interrupt handler to be run @@ -107,7 +107,7 @@ PUBLIC void arch_stop_local_timer(void) } } -PUBLIC int arch_register_local_timer_handler(irq_handler_t handler) +PUBLIC int arch_register_local_timer_handler(const irq_handler_t handler) { #ifdef CONFIG_APIC if (lapic_addr) { diff --git a/kernel/arch/i386/i8259.c b/kernel/arch/i386/i8259.c index 13e6a867f..4f99bed12 100644 --- a/kernel/arch/i386/i8259.c +++ b/kernel/arch/i386/i8259.c @@ -26,7 +26,7 @@ /*===========================================================================* * intr_init * *===========================================================================*/ -PUBLIC int intr_init(int mine, int auto_eoi) +PUBLIC int intr_init(const int mine, const int auto_eoi) { /* Initialize the 8259s, finishing with all interrupts disabled. This is * only done in protected mode, in real mode we don't touch the 8259s, but @@ -83,15 +83,15 @@ PUBLIC int intr_disabled(void) return 0; } -PUBLIC void irq_8259_unmask(int irq) +PUBLIC void irq_8259_unmask(const int irq) { - unsigned ctl_mask = irq < 8 ? INT_CTLMASK : INT2_CTLMASK; + const unsigned ctl_mask = irq < 8 ? INT_CTLMASK : INT2_CTLMASK; outb(ctl_mask, inb(ctl_mask) & ~(1 << (irq & 0x7))); } -PUBLIC void irq_8259_mask(int irq) +PUBLIC void irq_8259_mask(const int irq) { - unsigned ctl_mask = irq < 8 ? INT_CTLMASK : INT2_CTLMASK; + const unsigned ctl_mask = irq < 8 ? INT_CTLMASK : INT2_CTLMASK; outb(ctl_mask, inb(ctl_mask) | (1 << (irq & 0x7))); } diff --git a/kernel/arch/i386/memory.c b/kernel/arch/i386/memory.c index 4eaa6d82d..c65dac545 100644 --- a/kernel/arch/i386/memory.c +++ b/kernel/arch/i386/memory.c @@ -78,8 +78,8 @@ PUBLIC void vm_init(struct proc *newptproc) * for actual use by phys_copy or phys_memset. */ PRIVATE phys_bytes createpde( - struct proc *pr, /* Requested process, NULL for physical. */ - phys_bytes linaddr, /* Address after segment translation. */ + const struct proc *pr, /* Requested process, NULL for physical. */ + const phys_bytes linaddr,/* Address after segment translation. */ phys_bytes *bytes, /* Size of chunk, function may truncate it. */ int pde, /* freepde number to use for the mapping. */ int *changed /* If mapping is made, this is set to 1. */ @@ -199,7 +199,7 @@ PRIVATE int lin_lin_copy(struct proc *srcproc, vir_bytes srclinaddr, PRIVATE u32_t phys_get32(phys_bytes addr) { - u32_t v; + const u32_t v; int r; if(!vm_running) { @@ -285,8 +285,8 @@ PRIVATE void vm_enable_paging(void) } PUBLIC vir_bytes alloc_remote_segment(u32_t *selector, - segframe_t *segments, int index, phys_bytes phys, vir_bytes size, - int priv) + segframe_t *segments, const int index, phys_bytes phys, + vir_bytes size, int priv) { phys_bytes offset = 0; /* Check if the segment size can be recorded in bytes, that is, check @@ -309,8 +309,8 @@ PUBLIC vir_bytes alloc_remote_segment(u32_t *selector, return offset; } -PUBLIC phys_bytes umap_remote(struct proc* rp, int seg, - vir_bytes vir_addr, vir_bytes bytes) +PUBLIC phys_bytes umap_remote(const struct proc* rp, const int seg, + const vir_bytes vir_addr, const vir_bytes bytes) { /* Calculate the physical memory address for a given virtual address. */ struct far_mem *fm; @@ -423,7 +423,8 @@ vir_bytes bytes; /* # of bytes to be copied */ /*===========================================================================* * vm_lookup * *===========================================================================*/ -PUBLIC int vm_lookup(struct proc *proc, vir_bytes virtual, vir_bytes *physical, u32_t *ptent) +PUBLIC int vm_lookup(const struct proc *proc, const vir_bytes virtual, + vir_bytes *physical, u32_t *ptent) { u32_t *root, *pt; int pde, pte; @@ -535,8 +536,8 @@ PUBLIC int vm_contiguous(struct proc *targetproc, u32_t vir_buf, size_t bytes) /*===========================================================================* * vm_suspend * *===========================================================================*/ -PRIVATE void vm_suspend(struct proc *caller, struct proc *target, - vir_bytes linaddr, vir_bytes len, int type) +PRIVATE void vm_suspend(struct proc *caller, const struct proc *target, + const vir_bytes linaddr, const vir_bytes len, const int type) { /* This range is not OK for this process. Set parameters * of the request and notify VM about the pending request. @@ -593,7 +594,7 @@ int delivermsg(struct proc *rp) NOREC_RETURN(deliver, r); } -PRIVATE char *flagstr(u32_t e, int dir) +PRIVATE char *flagstr(u32_t e, const int dir) { static char str[80]; strcpy(str, ""); @@ -610,7 +611,7 @@ PRIVATE char *flagstr(u32_t e, int dir) return str; } -PRIVATE void vm_pt_print(u32_t *pagetable, u32_t v) +PRIVATE void vm_pt_print(u32_t *pagetable, const u32_t v) { int pte; int col = 0; @@ -667,7 +668,7 @@ PRIVATE void vm_print(u32_t *root) /*===========================================================================* * lin_memset * *===========================================================================*/ -int vm_phys_memset(phys_bytes ph, u8_t c, phys_bytes bytes) +int vm_phys_memset(phys_bytes ph, const u8_t c, phys_bytes bytes) { u32_t p; NOREC_ENTER(physmemset); @@ -857,8 +858,8 @@ int vmcheck; /* if nonzero, can return VMSUSPEND */ /*===========================================================================* * data_copy * *===========================================================================*/ -PUBLIC int data_copy(endpoint_t from_proc, vir_bytes from_addr, - endpoint_t to_proc, vir_bytes to_addr, +PUBLIC int data_copy(const endpoint_t from_proc, const vir_bytes from_addr, + const endpoint_t to_proc, const vir_bytes to_addr, size_t bytes) { struct vir_addr src, dst; @@ -876,8 +877,8 @@ PUBLIC int data_copy(endpoint_t from_proc, vir_bytes from_addr, * data_copy_vmcheck * *===========================================================================*/ PUBLIC int data_copy_vmcheck(struct proc * caller, - endpoint_t from_proc, vir_bytes from_addr, - endpoint_t to_proc, vir_bytes to_addr, + const endpoint_t from_proc, const vir_bytes from_addr, + const endpoint_t to_proc, const vir_bytes to_addr, size_t bytes) { struct vir_addr src, dst; @@ -894,7 +895,7 @@ PUBLIC int data_copy_vmcheck(struct proc * caller, /*===========================================================================* * arch_pre_exec * *===========================================================================*/ -PUBLIC void arch_pre_exec(struct proc *pr, u32_t ip, u32_t sp) +PUBLIC void arch_pre_exec(struct proc *pr, const u32_t ip, const u32_t sp) { /* wipe extra LDT entries, set program counter, and stack pointer. */ memset(pr->p_seg.p_ldt + EXTRA_LDT_INDEX, 0, @@ -923,14 +924,15 @@ PUBLIC int arch_umap(struct proc *pr, vir_bytes offset, vir_bytes count, } /* VM reports page directory slot we're allowed to use freely. */ -void i386_freepde(int pde) +void i386_freepde(const int pde) { if(nfreepdes >= MAX_FREEPDES) return; freepdes[nfreepdes++] = pde; } -PUBLIC int arch_phys_map(int index, phys_bytes *addr, phys_bytes *len, int *flags) +PUBLIC int arch_phys_map(const int index, phys_bytes *addr, + phys_bytes *len, int *flags) { #ifdef CONFIG_APIC /* map the local APIC if enabled */ @@ -947,7 +949,7 @@ PUBLIC int arch_phys_map(int index, phys_bytes *addr, phys_bytes *len, int *flag #endif } -PUBLIC int arch_phys_map_reply(int index, vir_bytes addr) +PUBLIC int arch_phys_map_reply(const int index, const vir_bytes addr) { #ifdef CONFIG_APIC /* if local APIC is enabled */ @@ -958,7 +960,7 @@ PUBLIC int arch_phys_map_reply(int index, vir_bytes addr) return OK; } -PUBLIC int arch_enable_paging(struct proc * caller, message * m_ptr) +PUBLIC int arch_enable_paging(struct proc * caller, const message * m_ptr) { struct vm_ep_data ep_data; int r; diff --git a/kernel/arch/i386/protect.c b/kernel/arch/i386/protect.c index a77dcbe25..7681cae61 100644 --- a/kernel/arch/i386/protect.c +++ b/kernel/arch/i386/protect.c @@ -48,7 +48,7 @@ PUBLIC void enable_iop(struct proc *pp) /*===========================================================================* * seg2phys * *===========================================================================*/ -PUBLIC phys_bytes seg2phys(U16_t seg) +PUBLIC phys_bytes seg2phys(const U16_t seg) { /* Return the base address of a segment, with seg being a * register, or a 286/386 segment selector. @@ -79,7 +79,7 @@ PRIVATE void phys2seg(u16_t *seg, vir_bytes *off, phys_bytes phys) * init_dataseg * *===========================================================================*/ PUBLIC void init_dataseg(register struct segdesc_s *segdp, - phys_bytes base, vir_bytes size, int privilege) + phys_bytes base, vir_bytes size, const int privilege) { /* Build descriptor for a data segment. */ sdesc(segdp, base, size); @@ -247,9 +247,9 @@ vir_bytes size; * int_gate * *===========================================================================*/ PUBLIC void int_gate(vec_nr, offset, dpl_type) -unsigned vec_nr; -vir_bytes offset; -unsigned dpl_type; +const unsigned vec_nr; +const vir_bytes offset; +const unsigned dpl_type; { /* Build descriptor for an interrupt gate. */ register struct gatedesc_s *idp; @@ -337,7 +337,8 @@ for (rp = BEG_PROC_ADDR; rp < END_PROC_ADDR; ++rp) { /*===========================================================================* * printseg * *===========================================================================*/ -PUBLIC void printseg(char *banner, int iscs, struct proc *pr, u32_t selector) +PUBLIC void printseg(char *banner, const int iscs, struct proc *pr, + const u32_t selector) { u32_t base, limit, index, dpl; struct segdesc_s *desc; @@ -424,7 +425,7 @@ PUBLIC void printseg(char *banner, int iscs, struct proc *pr, u32_t selector) /*===========================================================================* * prot_set_kern_seg_limit * *===========================================================================*/ -PUBLIC int prot_set_kern_seg_limit(vir_bytes limit) +PUBLIC int prot_set_kern_seg_limit(const vir_bytes limit) { struct proc *rp; int orig_click; diff --git a/kernel/arch/i386/system.c b/kernel/arch/i386/system.c index 665d85c87..5b99df26f 100644 --- a/kernel/arch/i386/system.c +++ b/kernel/arch/i386/system.c @@ -36,7 +36,7 @@ PUBLIC void arch_monitor(void) PUBLIC int cpu_has_tsc; -PUBLIC void arch_shutdown(int how) +PUBLIC void arch_shutdown(const int how) { /* Mask all interrupts, including the clock. */ outb( INT_CTLMASK, ~0); @@ -66,8 +66,8 @@ PUBLIC void arch_shutdown(int how) if(minix_panicing) { int source, dest; static char mybuffer[sizeof(params_buffer)]; - char *lead = "echo \\n*** kernel messages:\\n"; - int leadlen = strlen(lead); + const char *lead = "echo \\n*** kernel messages:\\n"; + const int leadlen = strlen(lead); strcpy(mybuffer, lead); #define DECSOURCE source = (source - 1 + _KMESS_BUF_SIZE) % _KMESS_BUF_SIZE @@ -79,7 +79,7 @@ PUBLIC void arch_shutdown(int how) DECSOURCE; while(dest >= leadlen) { - char c = kmess.km_buf[source]; + const char c = kmess.km_buf[source]; if(c == '\n') { mybuffer[dest--] = 'n'; mybuffer[dest] = '\\'; @@ -110,7 +110,7 @@ PUBLIC void arch_shutdown(int how) /* address of a.out headers, set in mpx386.s */ phys_bytes aout; -PUBLIC void arch_get_aout_headers(int i, struct exec *h) +PUBLIC void arch_get_aout_headers(const int i, struct exec *h) { /* The bootstrap loader created an array of the a.out headers at * absolute address 'aout'. Get one element to h. @@ -118,7 +118,8 @@ PUBLIC void arch_get_aout_headers(int i, struct exec *h) phys_copy(aout + i * A_MINHDR, vir2phys(h), (phys_bytes) A_MINHDR); } -PRIVATE void tss_init(struct tss_s * tss, void * kernel_stack, unsigned cpu) +PRIVATE void tss_init(struct tss_s * tss, void * kernel_stack, + const unsigned cpu) { /* * make space for process pointer and cpu id and point to the first @@ -275,7 +276,7 @@ PRIVATE void ser_dump_segs(void) } } -PRIVATE void ser_debug(int c) +PRIVATE void ser_debug(const int c) { serial_debug_active = 1; @@ -312,7 +313,7 @@ PRIVATE void ser_debug(int c) serial_debug_active = 0; } -PRIVATE void printslot(struct proc *pp, int level) +PRIVATE void printslot(struct proc *pp, const int level) { struct proc *depproc = NULL; endpoint_t dep; @@ -376,7 +377,7 @@ PUBLIC void ser_dump_proc() #if SPROFILE -PUBLIC int arch_init_profile_clock(u32_t freq) +PUBLIC int arch_init_profile_clock(const u32_t freq) { int r; /* Set CMOS timer frequency. */ @@ -415,7 +416,7 @@ PUBLIC void arch_ack_profile_clock(void) #define COLOR_BASE 0xB8000L -PRIVATE void cons_setc(int pos, int c) +PRIVATE void cons_setc(const int pos, const int c) { char ch; diff --git a/kernel/arch/i386/watchdog.c b/kernel/arch/i386/watchdog.c index 8cada4f63..41a876c20 100644 --- a/kernel/arch/i386/watchdog.c +++ b/kernel/arch/i386/watchdog.c @@ -44,7 +44,7 @@ PRIVATE void intel_arch_watchdog_init(int cpu) lapic_write(LAPIC_LVTPCR, APIC_ICR_DM_NMI); } -PRIVATE void intel_arch_watchdog_reinit(int cpu) +PRIVATE void intel_arch_watchdog_reinit(const int cpu) { lapic_write(LAPIC_LVTPCR, APIC_ICR_DM_NMI); ia32_msr_write(MSR_PERFMON_CRT0, 0, -watchdog->resetval); @@ -86,7 +86,7 @@ int arch_watchdog_init(void) return 0; } -void arch_watchdog_lockup(struct nmi_frame * frame) +void arch_watchdog_lockup(const struct nmi_frame * frame) { printf("KERNEL LOCK UP\n" "eax 0x%08x\n" diff --git a/kernel/clock.c b/kernel/clock.c index 0e453ed2e..d42560180 100644 --- a/kernel/clock.c +++ b/kernel/clock.c @@ -185,7 +185,7 @@ PUBLIC int ap_timer_int_handler(void) * user's system time. */ - unsigned ticks = 1; + const unsigned ticks = 1; struct proc * p, * billp; #ifdef CONFIG_WATCHDOG diff --git a/kernel/debug.c b/kernel/debug.c index 89d430fc8..9fc79255f 100644 --- a/kernel/debug.c +++ b/kernel/debug.c @@ -38,7 +38,8 @@ runqueues_ok(void) return 0; } for(xp = rdy_head[q]; xp != NIL_PROC; xp = xp->p_nextready) { - vir_bytes vxp = (vir_bytes) xp, dxp; + const vir_bytes vxp = (vir_bytes) xp; + vir_bytes dxp; if(vxp < (vir_bytes) BEG_PROC_ADDR || vxp >= (vir_bytes) END_PROC_ADDR) { printf("xp out of range\n"); return 0; @@ -108,7 +109,7 @@ runqueues_ok(void) } PUBLIC char * -rtsflagstr(int flags) +rtsflagstr(const int flags) { static char str[100]; str[0] = '\0'; @@ -135,7 +136,7 @@ rtsflagstr(int flags) } PUBLIC char * -miscflagstr(int flags) +miscflagstr(const int flags) { static char str[100]; str[0] = '\0'; diff --git a/kernel/interrupt.c b/kernel/interrupt.c index 123a06fe7..6482d8e32 100644 --- a/kernel/interrupt.c +++ b/kernel/interrupt.c @@ -27,7 +27,8 @@ PUBLIC irq_hook_t* irq_handlers[NR_IRQ_VECTORS] = {0}; * put_irq_handler * *===========================================================================*/ /* Register an interrupt handler. */ -PUBLIC void put_irq_handler( irq_hook_t* hook, int irq, irq_handler_t handler) +PUBLIC void put_irq_handler( irq_hook_t* hook, int irq, + const irq_handler_t handler) { int id; irq_hook_t **line; @@ -72,9 +73,9 @@ PUBLIC void put_irq_handler( irq_hook_t* hook, int irq, irq_handler_t handler) * rm_irq_handler * *===========================================================================*/ /* Unregister an interrupt handler. */ -PUBLIC void rm_irq_handler( irq_hook_t* hook ) { - int irq = hook->irq; - int id = hook->id; +PUBLIC void rm_irq_handler( const irq_hook_t* hook ) { + const int irq = hook->irq; + const int id = hook->id; irq_hook_t **line; if( irq < 0 || irq >= NR_IRQ_VECTORS ) @@ -155,8 +156,7 @@ PUBLIC void irq_handle(int irq) } /* Enable/Disable a interrupt line. */ -PUBLIC void enable_irq(hook) -irq_hook_t* hook; +PUBLIC void enable_irq(const irq_hook_t *hook) { if((irq_actids[hook->irq] &= ~hook->id) == 0) { hw_intr_unmask(hook->irq); @@ -164,8 +164,7 @@ irq_hook_t* hook; } /* Return true if the interrupt was enabled before call. */ -PUBLIC int disable_irq(hook) -irq_hook_t* hook; +PUBLIC int disable_irq(const irq_hook_t *hook) { if(irq_actids[hook->irq] & hook->id) /* already disabled */ return 0; diff --git a/kernel/main.c b/kernel/main.c index daf0989c2..84bd346c6 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -283,8 +283,7 @@ PRIVATE void announce(void) /*===========================================================================* * prepare_shutdown * *===========================================================================*/ -PUBLIC void prepare_shutdown(how) -int how; +PUBLIC void prepare_shutdown(const int how) { /* This function prepares to shutdown MINIX. */ static timer_t shutdown_timer; @@ -301,8 +300,7 @@ int how; /*===========================================================================* * shutdown * *===========================================================================*/ -PUBLIC void minix_shutdown(tp) -timer_t *tp; +PUBLIC void minix_shutdown(timer_t *tp) { /* This function is called from prepare_shutdown or stop_sequence to bring * down MINIX. How to shutdown is in the argument: RBT_HALT (return to the diff --git a/kernel/proc.c b/kernel/proc.c index 7062c5899..208f8268a 100644 --- a/kernel/proc.c +++ b/kernel/proc.c @@ -279,7 +279,7 @@ long bit_map; /* notification event set or flags */ * The trap is caught and sys_call() is called to send or receive a message * (or both). The caller is always given by 'proc_ptr'. */ - register struct proc *caller_ptr = proc_ptr; /* get pointer to caller */ + struct proc *const caller_ptr = proc_ptr; /* get pointer to caller */ int result; /* the system call's result */ int src_dst_p; /* Process slot number */ size_t msg_size; @@ -537,7 +537,7 @@ PRIVATE int mini_send(caller_ptr, dst_e, m_ptr, flags) register struct proc *caller_ptr; /* who is trying to send a message? */ int dst_e; /* to whom is message being sent? */ message *m_ptr; /* pointer to message buffer */ -int flags; +const int flags; { /* Send a message from 'caller_ptr' to 'dst'. If 'dst' is blocked waiting * for this message, copy the message to it and unblock 'dst'. If 'dst' is @@ -609,7 +609,7 @@ PRIVATE int mini_receive(caller_ptr, src_e, m_ptr, flags) register struct proc *caller_ptr; /* process trying to get message */ int src_e; /* which message source is wanted */ message *m_ptr; /* pointer to message buffer */ -int flags; +const int flags; { /* A process or task wants to get a message. If a message is already queued, * acquire it and deblock the sender. If no message from the desired source @@ -742,9 +742,10 @@ int flags; /*===========================================================================* * mini_notify * *===========================================================================*/ -PUBLIC int mini_notify(caller_ptr, dst_e) -register struct proc *caller_ptr; /* sender of the notification */ -endpoint_t dst_e; /* which process to notify */ +PUBLIC int mini_notify( + const struct proc *caller_ptr, /* sender of the notification */ + endpoint_t dst_e /* which process to notify */ +) { register struct proc *dst_ptr; int src_id; /* source id for late delivery */ @@ -821,7 +822,7 @@ PRIVATE int mini_senda(struct proc *caller_ptr, asynmsg_t *table, size_t size) struct proc *dst_ptr; struct priv *privp; asynmsg_t tabent; - vir_bytes table_v = (vir_bytes) table; + const vir_bytes table_v = (vir_bytes) table; vir_bytes linaddr; privp= priv(caller_ptr); @@ -1133,8 +1134,9 @@ PRIVATE int try_one(struct proc *src_ptr, struct proc *dst_ptr, int *postponed) /*===========================================================================* * enqueue * *===========================================================================*/ -PUBLIC void enqueue(rp) -register struct proc *rp; /* this process is now runnable */ +PUBLIC void enqueue( + register struct proc *rp /* this process is now runnable */ +) { /* Add 'rp' to one of the queues of runnable processes. This function is * responsible for inserting a process into one of the scheduling queues. @@ -1196,7 +1198,7 @@ register struct proc *rp; /* this process is now runnable */ */ PRIVATE void enqueue_head(struct proc *rp) { - int q = rp->p_priority; /* scheduling queue to use */ + const int q = rp->p_priority; /* scheduling queue to use */ assert(proc_ptr_ok(rp)); assert(proc_is_runnable(rp)); @@ -1229,8 +1231,8 @@ PRIVATE void enqueue_head(struct proc *rp) /*===========================================================================* * dequeue * *===========================================================================*/ -PUBLIC void dequeue(rp) -register struct proc *rp; /* this process is no longer runnable */ +PUBLIC void dequeue(const struct proc *rp) +/* this process is no longer runnable */ { /* A process must be removed from the scheduling queues, for example, because * it has blocked. If the currently active process is removed, a new process @@ -1284,7 +1286,7 @@ int *front; /* return: front or back */ * process must be added to one of the scheduling queues to decide where to * insert it. As a side-effect the process' priority may be updated. */ - int time_left = (rp->p_ticks_left > 0); /* quantum fully consumed */ + const int time_left = (rp->p_ticks_left > 0); /* quantum fully consumed? */ /* Check whether the process has time left. Otherwise give a new quantum * and lower the process' priority, unless the process already is in the @@ -1340,8 +1342,9 @@ PRIVATE struct proc * pick_proc(void) * balance_queues * *===========================================================================*/ #define Q_BALANCE_TICKS 100 -PUBLIC void balance_queues(tp) -timer_t *tp; /* watchdog timer pointer */ +PUBLIC void balance_queues( + timer_t *tp /* watchdog timer pointer */ +) { /* Check entire process table and give all process a higher priority. This * effectively means giving a new quantum. If a process already is at its @@ -1398,13 +1401,14 @@ PUBLIC struct proc *endpoint_lookup(endpoint_t e) *===========================================================================*/ #if DEBUG_ENABLE_IPC_WARNINGS PUBLIC int isokendpt_f(file, line, e, p, fatalflag) -char *file; +const char *file; int line; #else PUBLIC int isokendpt_f(e, p, fatalflag) #endif endpoint_t e; -int *p, fatalflag; +int *p; +const int fatalflag; { int ok = 0; /* Convert an endpoint number into a process number. diff --git a/kernel/proc.h b/kernel/proc.h index 0d8d7271d..df7262bb7 100644 --- a/kernel/proc.h +++ b/kernel/proc.h @@ -176,7 +176,7 @@ struct proc { /* Set flag and dequeue if the process was runnable. */ #define RTS_SET(rp, f) \ do { \ - int rts = (rp)->p_rts_flags; \ + const int rts = (rp)->p_rts_flags; \ (rp)->p_rts_flags |= (f); \ if(rts_f_is_runnable(rts) && !proc_is_runnable(rp)) { \ dequeue(rp); \ diff --git a/kernel/profile.c b/kernel/profile.c index 1a387e54f..84ec551ba 100644 --- a/kernel/profile.c +++ b/kernel/profile.c @@ -69,8 +69,7 @@ PUBLIC void stop_profile_clock() /*===========================================================================* * profile_clock_handler * *===========================================================================*/ -PRIVATE int profile_clock_handler(hook) -irq_hook_t *hook; +PRIVATE int profile_clock_handler(irq_hook_t *hook) { /* This executes on every tick of the CMOS timer. */ diff --git a/kernel/proto.h b/kernel/proto.h index 451bb9d71..858f5bc6f 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -38,15 +38,15 @@ _PROTOTYPE( void minix_shutdown, (struct timer *tp) ); /* proc.c */ _PROTOTYPE( int do_ipc, (int call_nr, int src_dst, message *m_ptr, long bit_map) ); -_PROTOTYPE( int mini_notify, (struct proc *src, endpoint_t dst) ); +_PROTOTYPE( int mini_notify, (const struct proc *src, endpoint_t dst) ); _PROTOTYPE( void enqueue, (struct proc *rp) ); -_PROTOTYPE( void dequeue, (struct proc *rp) ); +_PROTOTYPE( void dequeue, (const struct proc *rp) ); _PROTOTYPE( void balance_queues, (struct timer *tp) ); _PROTOTYPE( struct proc * schedcheck, (void) ); _PROTOTYPE( struct proc * arch_finish_schedcheck, (void) ); _PROTOTYPE( struct proc *endpoint_lookup, (endpoint_t ep) ); #if DEBUG_ENABLE_IPC_WARNINGS -_PROTOTYPE( int isokendpt_f, (char *file, int line, endpoint_t e, int *p, int f)); +_PROTOTYPE( int isokendpt_f, (const char *file, int line, endpoint_t e, int *p, int f)); #define isokendpt_d(e, p, f) isokendpt_f(__FILE__, __LINE__, (e), (p), (f)) #else _PROTOTYPE( int isokendpt_f, (endpoint_t e, int *p, int f) ); @@ -59,8 +59,8 @@ _PROTOTYPE( void cstart, (U16_t cs, U16_t ds, U16_t mds, /* system.c */ _PROTOTYPE( int get_priv, (register struct proc *rc, int proc_type) ); -_PROTOTYPE( void set_sendto_bit, (struct proc *rc, int id) ); -_PROTOTYPE( void unset_sendto_bit, (struct proc *rc, int id) ); +_PROTOTYPE( void set_sendto_bit, (const struct proc *rc, int id) ); +_PROTOTYPE( void unset_sendto_bit, (const struct proc *rc, int id) ); _PROTOTYPE( void send_sig, (int proc_nr, int sig_nr) ); _PROTOTYPE( void cause_sig, (proc_nr_t proc_nr, int sig_nr) ); _PROTOTYPE( void sig_delay_done, (struct proc *rp) ); @@ -83,9 +83,9 @@ _PROTOTYPE( void vtimer_check, (struct proc *rp) ); /* interrupt.c */ _PROTOTYPE( void put_irq_handler, (irq_hook_t *hook, int irq, irq_handler_t handler) ); -_PROTOTYPE( void rm_irq_handler, (irq_hook_t *hook) ); -_PROTOTYPE( void enable_irq, (irq_hook_t *hook) ); -_PROTOTYPE( int disable_irq, (irq_hook_t *hook) ); +_PROTOTYPE( void rm_irq_handler, (const irq_hook_t *hook) ); +_PROTOTYPE( void enable_irq, (const irq_hook_t *hook) ); +_PROTOTYPE( int disable_irq, (const irq_hook_t *hook) ); /* debug.c */ _PROTOTYPE( int runqueues_ok, (void) ); @@ -136,7 +136,7 @@ _PROTOTYPE( phys_bytes umap_local, (register struct proc *rp, int seg, vir_bytes vir_addr, vir_bytes bytes)); _PROTOTYPE( void cp_mess, (int src,phys_clicks src_clicks, vir_bytes src_offset, phys_clicks dst_clicks, vir_bytes dst_offset)); -_PROTOTYPE( phys_bytes umap_remote, (struct proc* rp, int seg, +_PROTOTYPE( phys_bytes umap_remote, (const struct proc* rp, int seg, vir_bytes vir_addr, vir_bytes bytes) ); _PROTOTYPE( phys_bytes umap_virtual, (struct proc* rp, int seg, vir_bytes vir_addr, vir_bytes bytes) ); @@ -167,13 +167,13 @@ _PROTOTYPE( int arch_umap, (struct proc *pr, vir_bytes, vir_bytes, _PROTOTYPE( int arch_do_vmctl, (message *m_ptr, struct proc *p)); _PROTOTYPE( int vm_contiguous, (struct proc *targetproc, u32_t vir_buf, size_t count)); _PROTOTYPE( void proc_stacktrace, (struct proc *proc) ); -_PROTOTYPE( int vm_lookup, (struct proc *proc, vir_bytes virtual, vir_bytes *result, u32_t *ptent)); +_PROTOTYPE( int vm_lookup, (const struct proc *proc, vir_bytes virtual, vir_bytes *result, u32_t *ptent)); _PROTOTYPE( int delivermsg, (struct proc *target)); _PROTOTYPE( void arch_do_syscall, (struct proc *proc) ); _PROTOTYPE( int arch_phys_map, (int index, phys_bytes *addr, phys_bytes *len, int *flags)); _PROTOTYPE( int arch_phys_map_reply, (int index, vir_bytes addr)); -_PROTOTYPE( int arch_enable_paging, (struct proc * caller, message * m_ptr)); +_PROTOTYPE( int arch_enable_paging, (struct proc * caller, const message * m_ptr)); _PROTOTYPE( int copy_msg_from_user, (struct proc * p, message * user_mbuf, message * dst)); diff --git a/kernel/start.c b/kernel/start.c index 8edffc28f..75e875ee6 100644 --- a/kernel/start.c +++ b/kernel/start.c @@ -11,7 +11,7 @@ #include "watchdog.h" #endif -FORWARD _PROTOTYPE( char *get_value, (_CONST char *params, _CONST char *key)); +FORWARD _PROTOTYPE( char *get_value, (const char *params, const char *key)); /*===========================================================================* * cstart * *===========================================================================*/ @@ -112,13 +112,13 @@ U16_t parmoff, parmsize; /* boot parameters offset and length */ *===========================================================================*/ PRIVATE char *get_value(params, name) -_CONST char *params; /* boot monitor parameters */ -_CONST char *name; /* key to look up */ + const char *params; /* boot monitor parameters */ + const char *name; /* key to look up */ { /* Get environment value - kernel version of getenv to avoid setting up the * usual environment array. */ - register _CONST char *namep; + register const char *namep; register char *envp; for (envp = (char *) params; *envp != 0;) { diff --git a/kernel/system.c b/kernel/system.c index 28ab09cd1..49e2f08f0 100644 --- a/kernel/system.c +++ b/kernel/system.c @@ -281,7 +281,7 @@ int priv_id; /* privilege id */ /*===========================================================================* * set_sendto_bit * *===========================================================================*/ -PUBLIC void set_sendto_bit(struct proc *rp, int id) +PUBLIC void set_sendto_bit(const struct proc *rp, int id) { /* Allow a process to send messages to the process(es) associated with the * system privilege structure with the given ID. @@ -309,7 +309,7 @@ PUBLIC void set_sendto_bit(struct proc *rp, int id) /*===========================================================================* * unset_sendto_bit * *===========================================================================*/ -PUBLIC void unset_sendto_bit(struct proc *rp, int id) +PUBLIC void unset_sendto_bit(const struct proc *rp, int id) { /* Prevent a process from sending to another process. Retain the send mask * symmetry by also unsetting the bit for the other direction. diff --git a/kernel/watchdog.h b/kernel/watchdog.h index 132fed9ac..9dd36ddc0 100644 --- a/kernel/watchdog.h +++ b/kernel/watchdog.h @@ -26,7 +26,7 @@ extern struct arch_watchdog *watchdog; /* let the arch code do whatever it needs to setup the watchdog */ int arch_watchdog_init(void); /* if the watchdog detects lockup, let the arch code to handle it */ -void arch_watchdog_lockup(struct nmi_frame * frame); +void arch_watchdog_lockup(const struct nmi_frame * frame); /* generic NMI handler. Takes one agument which points to where the arch * specific low level handler dumped CPU information and can be inspected by the diff --git a/lib/libc/ansi/misc.c b/lib/libc/ansi/misc.c index 9bb320dee..42333e055 100644 --- a/lib/libc/ansi/misc.c +++ b/lib/libc/ansi/misc.c @@ -188,7 +188,7 @@ parseRule(register char *buf, register const char *p) } static int -last_sunday(register int day, register struct tm *timep) +last_sunday(register int day, const register struct tm *timep) { int first = FIRSTSUNDAY(timep); @@ -198,7 +198,7 @@ last_sunday(register int day, register struct tm *timep) } static int -date_of(register struct dsttype *dst, struct tm *timep) +date_of(const register struct dsttype *dst, const struct tm *timep) { int leap = LEAPYEAR(YEAR0 + timep->tm_year); int firstday, tmpday;