Cleaned up src/lib/utils library. Renamed server_ functions to more logical

names. All system processes can now either use panic() or report() from
libutils, or redefine their own function. Assertions are done via the standard
<assert.h> functionality.
This commit is contained in:
Jorrit Herder
2005-06-01 14:31:00 +00:00
parent 75689debe3
commit 6d23f072f3
58 changed files with 364 additions and 498 deletions

View File

@@ -7,17 +7,16 @@ LIBUTILS = ../libutils.a
all: $(LIBUTILS)
OBJECTS = \
$(LIBUTILS)(tick_delay.o) \
$(LIBUTILS)(get_upt.o) \
$(LIBUTILS)(tickdelay.o) \
$(LIBUTILS)(getuptime.o) \
$(LIBUTILS)(get_mon_prm.o) \
$(LIBUTILS)(env_parse.o) \
$(LIBUTILS)(env_panic.o) \
$(LIBUTILS)(env_prefix.o) \
$(LIBUTILS)(fkey_ctl.o) \
$(LIBUTILS)(get_proc_nr.o) \
$(LIBUTILS)(srvr_assert.o) \
$(LIBUTILS)(srvr_panic.o) \
$(LIBUTILS)(srvr_report.o) \
$(LIBUTILS)(panic.o) \
$(LIBUTILS)(report.o) \
$(LIBUTILS)(taskcall.o) \
@@ -25,11 +24,11 @@ $(LIBUTILS): $(OBJECTS)
aal cr $@ *.o
rm *.o
$(LIBUTILS)(get_upt.o): get_upt.c
$(CC1) get_upt.c
$(LIBUTILS)(getuptime.o): getuptime.c
$(CC1) getuptime.c
$(LIBUTILS)(tick_delay.o): tick_delay.c
$(CC1) tick_delay.c
$(LIBUTILS)(tickdelay.o): tickdelay.c
$(CC1) tickdelay.c
$(LIBUTILS)(get_mon_prm.o): get_mon_prm.c
$(CC1) get_mon_prm.c
@@ -49,14 +48,11 @@ $(LIBUTILS)(fkey_ctl.o): fkey_ctl.c
$(LIBUTILS)(get_proc_nr.o): get_proc_nr.c
$(CC1) get_proc_nr.c
$(LIBUTILS)(srvr_assert.o): srvr_assert.c
$(CC1) srvr_assert.c
$(LIBUTILS)(panic.o): panic.c
$(CC1) panic.c
$(LIBUTILS)(srvr_panic.o): srvr_panic.c
$(CC1) srvr_panic.c
$(LIBUTILS)(srvr_report.o): srvr_report.c
$(CC1) srvr_report.c
$(LIBUTILS)(report.o): report.c
$(CC1) report.c
$(LIBUTILS)(taskcall.o): taskcall.c
$(CC1) taskcall.c

View File

@@ -14,6 +14,6 @@ char *key; /* environment variable whose value is bogus */
printf("WARNING: sys_getkenv() failed in env_panic(): %d\n", s);
}
printf("Bad environment setting: '%s = %s'\n", key, value);
server_panic("","", NO_NUM);
panic("","", NO_NUM);
}

View File

@@ -31,9 +31,6 @@ long min, max; /* minimum and maximum values for the parameter */
long newpar;
int s, i = 0, radix, r;
#if DEAD_CODE
if ((s=sys_getkenv(env, strlen(env), value, sizeof(value))) != 0) {
#endif
if ((s=get_mon_param(env, value, sizeof(value))) != 0) {
if (s == ESRCH) return(EP_UNSET); /* only error allowed */
printf("WARNING: sys_getkenv() failed in env_parse(): %d\n",s);

View File

@@ -1,12 +1,9 @@
#include "utils.h"
#include <unistd.h> /* need RBT_PANIC flag */
PRIVATE int panicking; /* inhibits recursive panics */
/*===========================================================================*
* server_panic *
* panic *
*===========================================================================*/
PUBLIC void server_panic(who, mess, num)
PUBLIC void panic(who, mess, num)
char *who; /* server identification */
char *mess; /* message format string */
int num; /* number to go with format string */
@@ -17,8 +14,6 @@ int num; /* number to go with format string */
*/
message m;
if (panicking) return; /* already a panic */
panicking = TRUE; /* prevent recursive panics */
if (NULL != who && NULL != mess) {
if (num != NO_NUM) {
printf("Panic in %s: %s: %d\n", who, mess, num);

View File

@@ -1,9 +1,9 @@
#include "utils.h"
/*===========================================================================*
* server_report *
* report *
*===========================================================================*/
PUBLIC void server_report(who, mess, num)
PUBLIC void report(who, mess, num)
char *who; /* server identification */
char *mess; /* message format to print */
int num; /* number to go with the message */

View File

@@ -1,38 +0,0 @@
#include "utils.h"
/* This file contains two very related procedures for debugging purposes:
* server_assert_failed
* server_compare_failed
* Also see <minix/serverassert.h>.
*/
#if !NDEBUG
/*=========================================================================*
* server_assert_failed *
*=========================================================================*/
PUBLIC void server_assert_failed(file, line, what)
char *file;
int line;
char *what;
{
printf("server panic at %s(%d): assertion \"%s\" failed\n",
file, line, what);
server_panic(NULL, NULL, NO_NUM);
}
/*=========================================================================*
* server_compare_failed *
*=========================================================================*/
PUBLIC void server_compare_failed(file, line, lhs, what, rhs)
char *file;
int line;
int lhs;
char *what;
int rhs;
{
printf("server panic at %s(%d): compare (%d) %s (%d) failed\n",
file, line, lhs, what, rhs);
server_panic(NULL, NULL, NO_NUM);
}
#endif /* !NDEBUG */

View File

@@ -1,9 +1,9 @@
#include "utils.h"
/*===========================================================================*
* tick_delay *
* tickdelay *
*===========================================================================*/
PUBLIC int tick_delay(ticks)
PUBLIC int tickdelay(ticks)
long ticks; /* number of ticks to wait */
{
/* This function uses the synchronous alarm to delay for a while. This works