From: Richard Sailer Date: Fri, 8 Jul 2016 13:17:14 +0000 (+0200) Subject: PM: Convert K&R C -> ANSI C X-Git-Url: http://zhaoyanbai.com/repos/?a=commitdiff_plain;h=637f688f0d4ccff0fa8a6ddafcd1d89fdfbc462d;p=minix.git PM: Convert K&R C -> ANSI C Aditionally this removes all trailing whitespaces in pm server code using: sed -i 's/[[:space:]]*$//' *.c Change-Id: Ie44162fd56cd7042f4f0cc7bd7314b17ea128761 --- diff --git a/minix/servers/pm/alarm.c b/minix/servers/pm/alarm.c index 746e8eb82..d7ff11ba5 100644 --- a/minix/servers/pm/alarm.c +++ b/minix/servers/pm/alarm.c @@ -27,7 +27,7 @@ static void set_realtimer(struct mproc *mp, struct itimerval *value); static void cause_sigalrm(minix_timer_t *tp); /*===========================================================================* - * ticks_from_timeval * + * ticks_from_timeval * *===========================================================================*/ static clock_t ticks_from_timeval(tv) struct timeval *tv; @@ -48,7 +48,7 @@ struct timeval *tv; * this be declared properly without combinatorial explosion of message * types? */ - + /* In any case, the following conversion must always round up. */ ticks = system_hz * (unsigned long) tv->tv_sec; @@ -64,7 +64,7 @@ struct timeval *tv; } /*===========================================================================* - * timeval_from_ticks * + * timeval_from_ticks * *===========================================================================*/ static void timeval_from_ticks(tv, ticks) struct timeval *tv; @@ -75,20 +75,21 @@ clock_t ticks; } /*===========================================================================* - * is_sane_timeval * + * is_sane_timeval * *===========================================================================*/ -static int is_sane_timeval(tv) -struct timeval *tv; +static int +is_sane_timeval(struct timeval *tv) { /* This imposes a reasonable time value range for setitimer. */ return (tv->tv_sec >= 0 && tv->tv_sec <= MAX_SECS && tv->tv_usec >= 0 && tv->tv_usec < US); } - + /*===========================================================================* * do_itimer * *===========================================================================*/ -int do_itimer() +int +do_itimer(void) { struct itimerval ovalue, value; /* old and new interval timers */ int setval, getval; /* set and/or retrieve the values? */ @@ -152,13 +153,10 @@ int do_itimer() } /*===========================================================================* - * getset_vtimer * + * getset_vtimer * *===========================================================================*/ -static void getset_vtimer(rmp, which, value, ovalue) -struct mproc *rmp; -int which; -struct itimerval *value; -struct itimerval *ovalue; +static void +getset_vtimer(struct mproc *rmp, int which, struct itimerval *value, struct itimerval *ovalue) { clock_t newticks, *nptr; /* the new timer value, in ticks */ clock_t oldticks, *optr; /* the old ticks value, in ticks */ @@ -188,7 +186,7 @@ struct itimerval *ovalue; /* If no timer is set, the interval must be zero. */ if (newticks <= 0) rmp->mp_interval[which] = 0; - else + else rmp->mp_interval[which] = ticks_from_timeval(&value->it_interval); } @@ -217,11 +215,10 @@ struct itimerval *ovalue; } /*===========================================================================* - * check_vtimer * + * check_vtimer * *===========================================================================*/ -void check_vtimer(proc_nr, sig) -int proc_nr; -int sig; +void +check_vtimer(int proc_nr, int sig) { register struct mproc *rmp; int which, num; @@ -243,11 +240,10 @@ int sig; } /*===========================================================================* - * get_realtimer * + * get_realtimer * *===========================================================================*/ -static void get_realtimer(rmp, value) -struct mproc *rmp; -struct itimerval *value; +static void +get_realtimer(struct mproc *rmp, struct itimerval *value) { clock_t exptime; /* time at which alarm will expire */ clock_t uptime; /* current system time */ @@ -276,11 +272,10 @@ struct itimerval *value; } /*===========================================================================* - * set_realtimer * + * set_realtimer * *===========================================================================*/ -static void set_realtimer(rmp, value) -struct mproc *rmp; -struct itimerval *value; +static void +set_realtimer(struct mproc *rmp, struct itimerval *value) { clock_t ticks; /* New amount of ticks to the next alarm. */ clock_t interval; /* New amount of ticks for the alarm's interval. */ @@ -298,7 +293,7 @@ struct itimerval *value; } /*===========================================================================* - * set_alarm * + * set_alarm * *===========================================================================*/ void set_alarm(rmp, ticks) struct mproc *rmp; /* process that wants the alarm */ @@ -314,7 +309,7 @@ clock_t ticks; /* how many ticks delay before the signal */ } /*===========================================================================* - * cause_sigalrm * + * cause_sigalrm * *===========================================================================*/ static void cause_sigalrm(tp) minix_timer_t *tp; diff --git a/minix/servers/pm/event.c b/minix/servers/pm/event.c index b78662a3f..c0a9b96e6 100644 --- a/minix/servers/pm/event.c +++ b/minix/servers/pm/event.c @@ -310,7 +310,7 @@ do_proc_event_reply(void) /* * Publish a process event to interested subscribers. The event is determined - * from the process flags. In addition, if the event is a process exit, also + * from the process flags. In addition, if the event is a process exit, also * check if it is a subscribing service that died. */ void diff --git a/minix/servers/pm/exec.c b/minix/servers/pm/exec.c index 1323ce46a..9439c03eb 100644 --- a/minix/servers/pm/exec.c +++ b/minix/servers/pm/exec.c @@ -34,7 +34,8 @@ /*===========================================================================* * do_exec * *===========================================================================*/ -int do_exec() +int +do_exec(void) { message m; diff --git a/minix/servers/pm/forkexit.c b/minix/servers/pm/forkexit.c index f4524e225..b13c4abce 100644 --- a/minix/servers/pm/forkexit.c +++ b/minix/servers/pm/forkexit.c @@ -41,7 +41,8 @@ static void cleanup(register struct mproc *rmp); /*===========================================================================* * do_fork * *===========================================================================*/ -int do_fork() +int +do_fork(void) { /* The process pointed to by 'mp' has forked. Create a child process. */ register struct mproc *rmp; /* pointer to parent */ @@ -56,7 +57,7 @@ int do_fork() * way through is such a nuisance. */ rmp = mp; - if ((procs_in_use == NR_PROCS) || + if ((procs_in_use == NR_PROCS) || (procs_in_use >= NR_PROCS-LAST_FEW && rmp->mp_effuid != 0)) { printf("PM: warning, process table is full!\n"); @@ -141,7 +142,8 @@ int do_fork() /*===========================================================================* * do_srv_fork * *===========================================================================*/ -int do_srv_fork() +int +do_srv_fork(void) { /* The process pointed to by 'mp' has forked. Create a child process. */ register struct mproc *rmp; /* pointer to parent */ @@ -161,7 +163,7 @@ int do_srv_fork() * way through is such a nuisance. */ rmp = mp; - if ((procs_in_use == NR_PROCS) || + if ((procs_in_use == NR_PROCS) || (procs_in_use >= NR_PROCS-LAST_FEW && rmp->mp_effuid != 0)) { printf("PM: warning, process table is full!\n"); @@ -240,7 +242,8 @@ int do_srv_fork() /*===========================================================================* * do_exit * *===========================================================================*/ -int do_exit() +int +do_exit(void) { /* Perform the exit(status) system call. The real work is done by exit_proc(), * which is also called when a process is killed by a signal. System processes @@ -261,10 +264,12 @@ int do_exit() /*===========================================================================* * exit_proc * *===========================================================================*/ -void exit_proc(rmp, exit_status, dump_core) -register struct mproc *rmp; /* pointer to the process to be terminated */ -int exit_status; /* the process' exit status (for parent) */ -int dump_core; /* flag indicating whether to dump core */ +void +exit_proc( + register struct mproc *rmp, /* pointer to the process to be terminated */ + int exit_status, /* the process' exit status (for parent) */ + int dump_core /* flag indicating whether to dump core */ +) { /* A process is done. Release most of the process' possessions. If its * parent is waiting, release the rest, else keep the process slot and @@ -303,8 +308,8 @@ int dump_core; /* flag indicating whether to dump core */ rmp->mp_child_utime += user_time; /* add user time */ rmp->mp_child_stime += sys_time; /* add system time */ - /* Tell the kernel the process is no longer runnable to prevent it from - * being scheduled in between the following steps. Then tell VFS that it + /* Tell the kernel the process is no longer runnable to prevent it from + * being scheduled in between the following steps. Then tell VFS that it * the process has exited and finally, clean up the process at the kernel. * This order is important so that VFS can tell drivers to cancel requests * such as copying to/ from the exiting process, before it is gone. @@ -370,7 +375,7 @@ int dump_core; /* flag indicating whether to dump core */ rmp->mp_flags |= EXITING; /* Keep the process around until VFS is finished with it. */ - + rmp->mp_exitstatus = (char) exit_status; /* For normal exits, try to notify the parent as soon as possible. @@ -426,7 +431,7 @@ void exit_restart(struct mproc *rmp) */ printf("PM: The scheduler did not want to give up " "scheduling %s, ret=%d.\n", rmp->mp_name, r); - } + } /* sched_stop is either called when the process is exiting or it is * being moved between schedulers. If it is being moved between @@ -466,11 +471,12 @@ void exit_restart(struct mproc *rmp) /*===========================================================================* * do_wait4 * *===========================================================================*/ -int do_wait4() +int +do_wait4(void) { -/* A process wants to wait for a child to terminate. If a child is already +/* A process wants to wait for a child to terminate. If a child is already * waiting, go clean it up and let this WAIT4 call terminate. Otherwise, - * really wait. + * really wait. * A process calling WAIT4 never gets a reply in the usual way at the end * of the main loop (unless WNOHANG is set or no qualifying child exists). * If a child has already exited, the routine tell_parent() sends the reply @@ -560,9 +566,11 @@ int do_wait4() /*===========================================================================* * wait_test * *===========================================================================*/ -int wait_test(rmp, child) -struct mproc *rmp; /* process that may be waiting */ -struct mproc *child; /* process that may be waited for */ +int +wait_test( + struct mproc *rmp, /* process that may be waiting */ + struct mproc *child /* process that may be waited for */ +) { /* See if a parent or tracer process is waiting for a child process. * A tracer is considered to be a pseudo-parent. @@ -582,8 +590,8 @@ struct mproc *child; /* process that may be waited for */ /*===========================================================================* * zombify * *===========================================================================*/ -static void zombify(rmp) -struct mproc *rmp; +static void +zombify(struct mproc *rmp) { /* Zombify a process. First check if the exiting process is traced by a process * other than its parent; if so, the tracer must be notified about the exit @@ -618,9 +626,11 @@ struct mproc *rmp; /*===========================================================================* * check_parent * *===========================================================================*/ -static void check_parent(child, try_cleanup) -struct mproc *child; /* tells which process is exiting */ -int try_cleanup; /* clean up the child when done? */ +static void +check_parent( + struct mproc *child, /* tells which process is exiting */ + int try_cleanup /* clean up the child when done? */ +) { /* We would like to inform the parent of an exiting child about the child's * death. If the parent is waiting for the child, tell it immediately; @@ -718,8 +728,10 @@ static int tell_parent(struct mproc *child, vir_bytes addr) /*===========================================================================* * tell_tracer * *===========================================================================*/ -static void tell_tracer(child) -struct mproc *child; /* tells which process is exiting */ +static void +tell_tracer( + struct mproc *child /* tells which process is exiting */ +) { int mp_tracer; struct mproc *tracer; @@ -744,8 +756,10 @@ struct mproc *child; /* tells which process is exiting */ /*===========================================================================* * tracer_died * *===========================================================================*/ -static void tracer_died(child) -struct mproc *child; /* process being traced */ +static void +tracer_died( + struct mproc *child /* process being traced */ +) { /* The process that was tracing the given child, has died for some reason. * This is really the tracer's fault, but we can't let INIT deal with this. @@ -778,8 +792,10 @@ struct mproc *child; /* process being traced */ /*===========================================================================* * cleanup * *===========================================================================*/ -static void cleanup(rmp) -register struct mproc *rmp; /* tells which process is exiting */ +static void +cleanup( + register struct mproc *rmp /* tells which process is exiting */ +) { /* Release the process table entry and reinitialize some field. */ rmp->mp_pid = 0; diff --git a/minix/servers/pm/getset.c b/minix/servers/pm/getset.c index 7f2a9b580..f3d2e1202 100644 --- a/minix/servers/pm/getset.c +++ b/minix/servers/pm/getset.c @@ -15,7 +15,8 @@ /*===========================================================================* * do_get * *===========================================================================*/ -int do_get() +int +do_get(void) { /* Handle PM_GETUID, PM_GETGID, PM_GETGROUPS, PM_GETPID, PM_GETPGRP, PM_GETSID, * PM_ISSETUGID. @@ -82,7 +83,7 @@ int do_get() default: r = EINVAL; - break; + break; } return(r); } @@ -90,7 +91,8 @@ int do_get() /*===========================================================================* * do_set * *===========================================================================*/ -int do_set() +int +do_set(void) { /* Handle PM_SETUID, PM_SETEUID, PM_SETGID, PM_SETGROUPS, PM_SETEGID, and * SETSID. These calls have in common that, if successful, they will be @@ -173,7 +175,7 @@ int do_set() ngroups = m_in.m_lc_pm_groups.num; - if (ngroups > NGROUPS_MAX || ngroups < 0) + if (ngroups > NGROUPS_MAX || ngroups < 0) return(EINVAL); if (ngroups > 0 && m_in.m_lc_pm_groups.ptr == 0) @@ -182,7 +184,7 @@ int do_set() r = sys_datacopy(who_e, m_in.m_lc_pm_groups.ptr, SELF, (vir_bytes) rmp->mp_sgroups, ngroups * sizeof(gid_t)); - if (r != OK) + if (r != OK) return(r); for (i = 0; i < ngroups; i++) { diff --git a/minix/servers/pm/main.c b/minix/servers/pm/main.c index 814601502..bee852f1d 100644 --- a/minix/servers/pm/main.c +++ b/minix/servers/pm/main.c @@ -47,7 +47,8 @@ static int sef_cb_init_fresh(int type, sef_init_info_t *info); /*===========================================================================* * main * *===========================================================================*/ -int main() +int +main(void) { /* Main routine of the process manager. */ unsigned int call_index; @@ -112,7 +113,8 @@ int main() /*===========================================================================* * sef_local_startup * *===========================================================================*/ -static void sef_local_startup() +static void +sef_local_startup(void) { /* Register init callbacks. */ sef_setcb_init_fresh(sef_cb_init_fresh); @@ -137,7 +139,7 @@ static int sef_cb_init_fresh(int UNUSED(type), sef_init_info_t *UNUSED(info)) static char core_sigs[] = { SIGQUIT, SIGILL, SIGTRAP, SIGABRT, SIGEMT, SIGFPE, SIGBUS, SIGSEGV }; static char ign_sigs[] = { SIGCHLD, SIGWINCH, SIGCONT, SIGINFO }; - static char noign_sigs[] = { SIGILL, SIGTRAP, SIGEMT, SIGFPE, + static char noign_sigs[] = { SIGILL, SIGTRAP, SIGEMT, SIGFPE, SIGBUS, SIGSEGV }; register struct mproc *rmp; register char *sig_ptr; @@ -169,10 +171,10 @@ static int sef_cb_init_fresh(int UNUSED(type), sef_init_info_t *UNUSED(info)) if ((s=sys_getmonparams(monitor_params, sizeof(monitor_params))) != OK) panic("get monitor params failed: %d", s); - /* Initialize PM's process table. Request a copy of the system image table + /* Initialize PM's process table. Request a copy of the system image table * that is defined at the kernel level to see which slots to fill in. */ - if (OK != (s=sys_getimage(image))) + if (OK != (s=sys_getimage(image))) panic("couldn't get image table: %d", s); procs_in_use = 0; /* start populating table */ for (ip = &image[0]; ip < &image[NR_BOOT_PROCS]; ip++) { @@ -180,20 +182,20 @@ static int sef_cb_init_fresh(int UNUSED(type), sef_init_info_t *UNUSED(info)) procs_in_use += 1; /* found user process */ /* Set process details found in the image table. */ - rmp = &mproc[ip->proc_nr]; - strlcpy(rmp->mp_name, ip->proc_name, PROC_NAME_LEN); - (void) sigemptyset(&rmp->mp_ignore); + rmp = &mproc[ip->proc_nr]; + strlcpy(rmp->mp_name, ip->proc_name, PROC_NAME_LEN); + (void) sigemptyset(&rmp->mp_ignore); (void) sigemptyset(&rmp->mp_sigmask); (void) sigemptyset(&rmp->mp_catch); if (ip->proc_nr == INIT_PROC_NR) { /* user process */ /* INIT is root, we make it father of itself. This is * not really OK, INIT should have no father, i.e. - * a father with pid NO_PID. But PM currently assumes + * a father with pid NO_PID. But PM currently assumes * that mp_parent always points to a valid slot number. */ rmp->mp_parent = INIT_PROC_NR; rmp->mp_procgrp = rmp->mp_pid = INIT_PID; - rmp->mp_flags |= IN_USE; + rmp->mp_flags |= IN_USE; /* Set scheduling info */ rmp->mp_scheduler = KERNEL; @@ -246,9 +248,11 @@ static int sef_cb_init_fresh(int UNUSED(type), sef_init_info_t *UNUSED(info)) /*===========================================================================* * reply * *===========================================================================*/ -void reply(proc_nr, result) -int proc_nr; /* process to reply to */ -int result; /* result of call (usually OK or error #) */ +void +reply( + int proc_nr, /* process to reply to */ + int result /* result of call (usually OK or error #) */ +) { /* Send a reply to a user process. System calls may occasionally fill in other * fields, this is only for the main return value and for sending the reply. @@ -270,14 +274,16 @@ int result; /* result of call (usually OK or error #) */ /*===========================================================================* * get_nice_value * *===========================================================================*/ -static int get_nice_value(queue) -int queue; /* store mem chunks here */ +static int +get_nice_value( + int queue /* store mem chunks here */ +) { /* Processes in the boot image have a priority assigned. The PM doesn't know - * about priorities, but uses 'nice' values instead. The priority is between + * about priorities, but uses 'nice' values instead. The priority is between * MIN_USER_Q and MAX_USER_Q. We have to scale between PRIO_MIN and PRIO_MAX. - */ - int nice_val = (queue - USER_Q) * (PRIO_MAX-PRIO_MIN+1) / + */ + int nice_val = (queue - USER_Q) * (PRIO_MAX-PRIO_MIN+1) / (MIN_USER_Q-MAX_USER_Q+1); if (nice_val > PRIO_MAX) nice_val = PRIO_MAX; /* shouldn't happen */ if (nice_val < PRIO_MIN) nice_val = PRIO_MIN; /* shouldn't happen */ @@ -287,7 +293,8 @@ int queue; /* store mem chunks here */ /*===========================================================================* * handle_vfs_reply * *===========================================================================*/ -static void handle_vfs_reply() +static void +handle_vfs_reply(void) { struct mproc *rmp; endpoint_t proc_e; diff --git a/minix/servers/pm/mcontext.c b/minix/servers/pm/mcontext.c index 6c88e97e1..9e8911476 100644 --- a/minix/servers/pm/mcontext.c +++ b/minix/servers/pm/mcontext.c @@ -9,7 +9,8 @@ /*===========================================================================* * do_setmcontext * *===========================================================================*/ -int do_setmcontext() +int +do_setmcontext(void) { return sys_setmcontext(who_e, m_in.m_lc_pm_mcontext.ctx); } @@ -18,7 +19,8 @@ int do_setmcontext() /*===========================================================================* * do_getmcontext * *===========================================================================*/ -int do_getmcontext() +int +do_getmcontext(void) { return sys_getmcontext(who_e, m_in.m_lc_pm_mcontext.ctx); } diff --git a/minix/servers/pm/misc.c b/minix/servers/pm/misc.c index c304b1ac3..4e1da51f8 100644 --- a/minix/servers/pm/misc.c +++ b/minix/servers/pm/misc.c @@ -68,7 +68,8 @@ unsigned long calls_stats[NR_PM_CALLS]; /*===========================================================================* * do_sysuname * *===========================================================================*/ -int do_sysuname() +int +do_sysuname(void) { /* Set or get uname strings. */ int r; @@ -103,7 +104,8 @@ int do_sysuname() /*===========================================================================* * do_getsysinfo * *===========================================================================*/ -int do_getsysinfo() +int +do_getsysinfo(void) { vir_bytes src_addr, dst_addr; size_t len; @@ -128,7 +130,7 @@ int do_getsysinfo() case SI_CALL_STATS: src_addr = (vir_bytes) calls_stats; len = sizeof(calls_stats); - break; + break; #endif default: return(EINVAL); @@ -183,7 +185,8 @@ int do_getepinfo(void) /*===========================================================================* * do_reboot * *===========================================================================*/ -int do_reboot() +int +do_reboot(void) { message m; @@ -204,7 +207,7 @@ int do_reboot() /* Order matters here. When VFS is told to reboot, it exits all its * processes, and then would be confused if they're exited again by - * SIGKILL. So first kill, then reboot. + * SIGKILL. So first kill, then reboot. */ check_sig(-1, SIGKILL, FALSE /* ksig*/); /* kill all users except init */ @@ -222,7 +225,8 @@ int do_reboot() /*===========================================================================* * do_getsetpriority * *===========================================================================*/ -int do_getsetpriority() +int +do_getsetpriority(void) { int r, arg_which, arg_who, arg_pri; struct mproc *rmp; @@ -255,7 +259,7 @@ int do_getsetpriority() /* Only root is allowed to reduce the nice level. */ if (rmp->mp_nice > arg_pri && mp->mp_effuid != SUPER_USER) return(EACCES); - + /* We're SET, and it's allowed. * * The value passed in is currently between PRIO_MIN and PRIO_MAX. @@ -305,8 +309,8 @@ int do_svrctl(void) size_t copy_len; /* Copy sysgetenv structure to PM. */ - if (sys_datacopy(who_e, ptr, SELF, (vir_bytes) &sysgetenv, - sizeof(sysgetenv)) != OK) return(EFAULT); + if (sys_datacopy(who_e, ptr, SELF, (vir_bytes) &sysgetenv, + sizeof(sysgetenv)) != OK) return(EFAULT); /* Set a param override? */ if (req == PMSETPARAM || req == OPMSETPARAM) { @@ -318,7 +322,7 @@ int do_svrctl(void) || sysgetenv.vallen >= sizeof(local_param_overrides[local_params].value)) return EINVAL; - + if ((s = sys_datacopy(who_e, (vir_bytes) sysgetenv.key, SELF, (vir_bytes) local_param_overrides[local_params].name, sysgetenv.keylen)) != OK) @@ -338,7 +342,7 @@ int do_svrctl(void) if (sysgetenv.keylen == 0) { /* copy all parameters */ val_start = monitor_params; val_len = sizeof(monitor_params); - } + } else { /* lookup value for key */ int p; /* Try to get a copy of the requested key. */ @@ -367,8 +371,8 @@ int do_svrctl(void) return E2BIG; /* Value found, make the actual copy (as far as possible). */ - copy_len = MIN(val_len, sysgetenv.vallen); - if ((s=sys_datacopy(SELF, (vir_bytes) val_start, + copy_len = MIN(val_len, sysgetenv.vallen); + if ((s=sys_datacopy(SELF, (vir_bytes) val_start, who_e, (vir_bytes) sysgetenv.val, copy_len)) != OK) return(s); diff --git a/minix/servers/pm/schedule.c b/minix/servers/pm/schedule.c index 11b7025fb..df2cc8d2e 100644 --- a/minix/servers/pm/schedule.c +++ b/minix/servers/pm/schedule.c @@ -22,13 +22,13 @@ void sched_init(void) struct mproc *trmp; endpoint_t parent_e; int proc_nr, s; - + for (proc_nr=0, trmp=mproc; proc_nr < NR_PROCS; proc_nr++, trmp++) { /* Don't take over system processes. When the system starts, - * init is blocked on RTS_NO_QUANTUM until PM assigns a + * init is blocked on RTS_NO_QUANTUM until PM assigns a * scheduler, from which other. Given that all other user - * processes are forked from init and system processes are - * managed by RS, there should be no other process that needs + * processes are forked from init and system processes are + * managed by RS, there should be no other process that needs * to be assigned a scheduler here */ if (trmp->mp_flags & IN_USE && !(trmp->mp_flags & PRIV_PROC)) { assert(_ENDPOINT_P(trmp->mp_endpoint) == INIT_PROC_NR); @@ -62,10 +62,10 @@ int sched_start_user(endpoint_t ep, struct mproc *rmp) if ((rv = nice_to_priority(rmp->mp_nice, &maxprio)) != OK) { return rv; } - + /* scheduler must know the parent, which is not the case for a child - * of a system process created by a regular fork; in this case the - * scheduler should inherit settings from init rather than the real + * of a system process created by a regular fork; in this case the + * scheduler should inherit settings from init rather than the real * parent */ if (mproc[rmp->mp_parent].mp_flags & PRIV_PROC) { @@ -74,7 +74,7 @@ int sched_start_user(endpoint_t ep, struct mproc *rmp) } else { inherit_from = mproc[rmp->mp_parent].mp_endpoint; } - + /* inherit quantum */ return sched_inherit(ep, /* scheduler_e */ rmp->mp_endpoint, /* schedulee_e */ diff --git a/minix/servers/pm/signal.c b/minix/servers/pm/signal.c index b766d4e76..c3a9e4c25 100644 --- a/minix/servers/pm/signal.c +++ b/minix/servers/pm/signal.c @@ -367,7 +367,7 @@ int process_ksig(endpoint_t proc_nr_e, int signo) assert(!(rmp->mp_flags & DELAY_CALL)); } - + /* See if the process is still alive */ if ((mproc[proc_nr].mp_flags & (IN_USE | EXITING)) == IN_USE) { return OK; /* signal has been delivered */ @@ -380,22 +380,24 @@ int process_ksig(endpoint_t proc_nr_e, int signo) /*===========================================================================* * sig_proc * *===========================================================================*/ -void sig_proc(rmp, signo, trace, ksig) -register struct mproc *rmp; /* pointer to the process to be signaled */ -int signo; /* signal to send to process (1 to _NSIG-1) */ -int trace; /* pass signal to tracer first? */ -int ksig; /* non-zero means signal comes from kernel */ +void +sig_proc( + register struct mproc *rmp, /* pointer to the process to be signaled */ + int signo, /* signal to send to process (1 to _NSIG-1) */ + int trace, /* pass signal to tracer first? */ + int ksig /* non-zero means signal comes from kernel */ +) { /* Send a signal to a process. Check to see if the signal is to be caught, - * ignored, tranformed into a message (for system processes) or blocked. + * ignored, tranformed into a message (for system processes) or blocked. * - If the signal is to be transformed into a message, request the KERNEL to - * send the target process a system notification with the pending signal as an - * argument. - * - If the signal is to be caught, request the KERNEL to push a sigcontext - * structure and a sigframe structure onto the catcher's stack. Also, KERNEL - * will reset the program counter and stack pointer, so that when the process - * next runs, it will be executing the signal handler. When the signal handler - * returns, sigreturn(2) will be called. Then KERNEL will restore the signal + * send the target process a system notification with the pending signal as an + * argument. + * - If the signal is to be caught, request the KERNEL to push a sigcontext + * structure and a sigframe structure onto the catcher's stack. Also, KERNEL + * will reset the program counter and stack pointer, so that when the process + * next runs, it will be executing the signal handler. When the signal handler + * returns, sigreturn(2) will be called. Then KERNEL will restore the signal * context from the sigcontext structure. * If there is insufficient stack space, kill the process. */ @@ -482,7 +484,7 @@ int ksig; /* non-zero means signal comes from kernel */ sigismember(&rmp->mp_ignore, signo) || sigismember(&rmp->mp_sigmask, signo)); - if (!badignore && sigismember(&rmp->mp_ignore, signo)) { + if (!badignore && sigismember(&rmp->mp_ignore, signo)) { /* Signal should be ignored. */ return; } @@ -540,9 +542,11 @@ int ksig; /* non-zero means signal comes from kernel */ /*===========================================================================* * sig_proc_exit * *===========================================================================*/ -static void sig_proc_exit(rmp, signo) -struct mproc *rmp; /* process that must exit */ -int signo; /* signal that caused termination */ +static void +sig_proc_exit( + struct mproc *rmp, /* process that must exit */ + int signo /* signal that caused termination */ +) { rmp->mp_sigstatus = (char) signo; if (sigismember(&core_sset, signo)) { @@ -644,8 +648,8 @@ int ksig; /* non-zero means signal comes from kernel */ /*===========================================================================* * check_pending * *===========================================================================*/ -void check_pending(rmp) -register struct mproc *rmp; +void +check_pending(register struct mproc *rmp) { /* Check to see if any pending signals have been unblocked. Deliver as many * of them as we can, until we have to wait for a reply from VFS first. @@ -680,8 +684,8 @@ register struct mproc *rmp; /*===========================================================================* * restart_sigs * *===========================================================================*/ -void restart_sigs(rmp) -struct mproc *rmp; +void +restart_sigs(struct mproc *rmp) { /* VFS has replied to a request from us; do signal-related work. */ @@ -712,8 +716,10 @@ struct mproc *rmp; /*===========================================================================* * unpause * *===========================================================================*/ -static int unpause(rmp) -struct mproc *rmp; /* which process */ +static int +unpause( + struct mproc *rmp /* which process */ +) { /* A signal is to be sent to a process. If that process is hanging on a * system call, the system call must be terminated with EINTR. First check if @@ -766,9 +772,11 @@ struct mproc *rmp; /* which process */ /*===========================================================================* * sig_send * *===========================================================================*/ -static int sig_send(rmp, signo) -struct mproc *rmp; /* what process to spawn a signal handler in */ -int signo; /* signal to send to process (1 to _NSIG-1) */ +static int +sig_send( + struct mproc *rmp, /* what process to spawn a signal handler in */ + int signo /* signal to send to process (1 to _NSIG-1) */ +) { /* The process is supposed to catch this signal. Spawn a signal handler. * Return TRUE if this succeeded, FALSE otherwise. diff --git a/minix/servers/pm/time.c b/minix/servers/pm/time.c index d2f169081..697be7e2e 100644 --- a/minix/servers/pm/time.c +++ b/minix/servers/pm/time.c @@ -18,7 +18,8 @@ /*===========================================================================* * do_gettime * *===========================================================================*/ -int do_gettime() +int +do_gettime(void) { clock_t ticks, realtime, clock; time_t boottime; @@ -48,7 +49,8 @@ int do_gettime() /*===========================================================================* * do_getres * *===========================================================================*/ -int do_getres() +int +do_getres(void) { switch (m_in.m_lc_pm_time.clk_id) { case CLOCK_REALTIME: @@ -65,11 +67,12 @@ int do_getres() /*===========================================================================* * do_settime * *===========================================================================*/ -int do_settime() +int +do_settime(void) { int s; - if (mp->mp_effuid != SUPER_USER) { + if (mp->mp_effuid != SUPER_USER) { return(EPERM); } @@ -87,7 +90,8 @@ int do_settime() /*===========================================================================* * do_time * *===========================================================================*/ -int do_time() +int +do_time(void) { /* Perform the time(tp) system call. */ struct timespec tv; @@ -102,19 +106,20 @@ int do_time() /*===========================================================================* * do_stime * *===========================================================================*/ -int do_stime() +int +do_stime(void) { -/* Perform the stime(tp) system call. Retrieve the system's uptime (ticks +/* Perform the stime(tp) system call. Retrieve the system's uptime (ticks * since boot) and pass the new time in seconds at system boot to the kernel. */ clock_t uptime, realtime; time_t boottime; int s; - if (mp->mp_effuid != SUPER_USER) { + if (mp->mp_effuid != SUPER_USER) { return(EPERM); } - if ( (s=getuptime(&uptime, &realtime, &boottime)) != OK) + if ( (s=getuptime(&uptime, &realtime, &boottime)) != OK) panic("do_stime couldn't get uptime: %d", s); boottime = m_in.m_lc_pm_time.sec - (realtime/system_hz); diff --git a/minix/servers/pm/trace.c b/minix/servers/pm/trace.c index f742a0a0d..7906b0018 100644 --- a/minix/servers/pm/trace.c +++ b/minix/servers/pm/trace.c @@ -1,30 +1,30 @@ -/* This file handles the process manager's part of debugging, using the +/* This file handles the process manager's part of debugging, using the * ptrace system call. Most of the commands are passed on to the system * task for completion. * * The debugging commands available are: - * T_STOP stop the process + * T_STOP stop the process * T_OK enable tracing by parent for this process - * T_GETINS return value from instruction space - * T_GETDATA return value from data space + * T_GETINS return value from instruction space + * T_GETDATA return value from data space * T_GETUSER return value from user process table * T_SETINS set value in instruction space * T_SETDATA set value in data space - * T_SETUSER set value in user process table - * T_RESUME resume execution + * T_SETUSER set value in user process table + * T_RESUME resume execution * T_EXIT exit - * T_STEP set trace bit + * T_STEP set trace bit * T_SYSCALL trace system call * T_ATTACH attach to an existing process * T_DETACH detach from a traced process * T_SETOPT set trace options * T_GETRANGE get range of values * T_SETRANGE set range of values - * + * * The T_OK, T_ATTACH, T_EXIT, and T_SETOPT commands are handled here, and the * T_RESUME, T_STEP, T_SYSCALL, and T_DETACH commands are partially handled * here and completed by the system task. The rest are handled entirely by the - * system task. + * system task. */ #include "pm.h" @@ -38,7 +38,8 @@ /*===========================================================================* * do_trace * *===========================================================================*/ -int do_trace() +int +do_trace(void) { register struct mproc *child; struct ptrace_range pr; @@ -205,7 +206,7 @@ int do_trace() FALSE /* ksig */); } - /* Resume the child as if nothing ever happened. */ + /* Resume the child as if nothing ever happened. */ child->mp_flags &= ~TRACE_STOPPED; child->mp_trace_flags = 0; @@ -213,7 +214,7 @@ int do_trace() break; - case T_RESUME: + case T_RESUME: case T_STEP: case T_SYSCALL: /* resume execution */ if (m_in.m_lc_pm_ptrace.data < 0 || m_in.m_lc_pm_ptrace.data >= _NSIG) @@ -251,9 +252,8 @@ int do_trace() /*===========================================================================* * trace_stop * *===========================================================================*/ -void trace_stop(rmp, signo) -register struct mproc *rmp; -int signo; +void +trace_stop(register struct mproc *rmp, int signo) { /* A traced process got a signal so stop it. */ @@ -262,7 +262,7 @@ int signo; r = sys_trace(T_STOP, rmp->mp_endpoint, 0L, (long *) 0); if (r != OK) panic("sys_trace failed: %d", r); - + rmp->mp_flags |= TRACE_STOPPED; if (wait_test(rpmp, rmp)) { /* TODO: rusage support */ diff --git a/minix/servers/pm/utility.c b/minix/servers/pm/utility.c index 04a4b1c2f..7d061c47c 100644 --- a/minix/servers/pm/utility.c +++ b/minix/servers/pm/utility.c @@ -39,7 +39,7 @@ pid_t get_free_pid() /* Find a free pid for the child and put it in the table. */ do { - t = 0; + t = 0; next_pid = (next_pid < NR_PIDS ? next_pid + 1 : INIT_PID + 1); for (rmp = &mproc[0]; rmp < &mproc[NR_PROCS]; rmp++) if (rmp->mp_pid == next_pid || rmp->mp_procgrp == next_pid) { @@ -53,8 +53,8 @@ pid_t get_free_pid() /*===========================================================================* * find_param * *===========================================================================*/ -char *find_param(name) -const char *name; +char * +find_param(const char *name) { register const char *namep; register char *envp; @@ -62,7 +62,7 @@ const char *name; for (envp = (char *) monitor_params; *envp != 0;) { for (namep = name; *namep != 0 && *namep == *envp; namep++, envp++) ; - if (*namep == '\0' && *envp == '=') + if (*namep == '\0' && *envp == '=') return(envp + 1); while (*envp++ != 0) ;