⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 prf.c

📁 著名的AT&T UNIX v6 源码
💻 C
字号:
#include "../h/param.h"#include "../h/systm.h"#include "../h/seg.h"#include "../h/buf.h"#include "../h/conf.h"/* * In case console is off, * panicstr contains argument to last * call to panic. */char	*panicstr;/* * Scaled down version of C Library printf. * Only %s %u %d (==%u) %o %x %D are recognized. * Used to print diagnostic information * directly on console tty. * Since it is not interrupt driven, * all system activities are pretty much * suspended. * Printf should not be used for chit-chat. *//* VARARGS */printf(fmt, x1)register char *fmt;unsigned x1;{	register c;	register unsigned int *adx;	char *s;	adx = &x1;loop:	while((c = *fmt++) != '%') {		if(c == '\0')			return;		putchar(c);	}	c = *fmt++;	if(c == 'd' || c == 'u' || c == 'o' || c == 'x')		printn((long)*adx, c=='o'? 8: (c=='x'? 16:10));	else if(c == 's') {		s = (char *)*adx;		while(c = *s++)			putchar(c);	} else if (c == 'D') {		printn(*(long *)adx, 10);		adx += (sizeof(long) / sizeof(int)) - 1;	}	adx++;	goto loop;}/* * Print an unsigned integer in base b. */printn(n, b)long n;{	register long a;	if (n<0) {	/* shouldn't happen */		putchar('-');		n = -n;	}	if(a = n/b)		printn(a, b);	putchar("0123456789ABCDEF"[(int)(n%b)]);}/* * Panic is called on unresolvable * fatal errors. * It syncs, prints "panic: mesg" and * then loops. */panic(s)char *s;{	panicstr = s;	update();	printf("panic: %s\n", s);	for(;;)		idle();}/* * prdev prints a warning message of the * form "mesg on dev x/y". * x and y are the major and minor parts of * the device argument. */prdev(str, dev)char *str;dev_t dev;{	printf("%s on dev %u/%u\n", str, major(dev), minor(dev));}/* * deverr prints a diagnostic from * a device driver. * It prints the device, block number, * and an octal word (usually some error * status register) passed as argument. */deverror(bp, o1, o2)register struct buf *bp;{	prdev("err", bp->b_dev);	printf("bn=%d er=%x,%x\n", bp->b_blkno, o1,o2);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -