Added sys_physzero library call for corresponding system call; modified

system-printf() so it returns number of characters printed (for use in
smart formatting)
This commit is contained in:
Ben Gras 2005-06-01 09:36:07 +00:00
parent dfe2b4513f
commit b4335679cb
4 changed files with 33 additions and 11 deletions

View file

@ -14,12 +14,12 @@
#define time _time
#define write _write
#include <lib.h>
#include <time.h>
#include <sys/ioctl.h>
#include <sys/asynchio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <time.h>
#include <signal.h>
#define IDLE 0

View file

@ -45,6 +45,7 @@ OBJECTS = \
$(LIBSYS)(sys_signalrm.o) \
$(LIBSYS)(sys_flagalrm.o) \
$(LIBSYS)(sys_syncalrm.o) \
$(LIBSYS)(sys_physzero.o) \
$(LIBSYS)(taskcall.o) \
$(LIBSYS): $(OBJECTS)
@ -165,6 +166,9 @@ $(LIBSYS)(sys_flagalrm.o): sys_flagalrm.c
$(LIBSYS)(sys_syncalrm.o): sys_syncalrm.c
$(CC1) sys_syncalrm.c
$(LIBSYS)(sys_physzero.o): sys_physcp.c
$(CC1) sys_physzero.c
$(LIBSYS)(taskcall.o): taskcall.c
$(CC1) taskcall.c

View file

@ -17,10 +17,12 @@ int printf(fmt) char *fmt;
/* Printf() uses kputc() to print characters. */
void kputc(int c);
#define count_kputc(c) do { charcount++; kputc(c); } while(0)
int printf(const char *fmt, ...)
#endif
{
int c;
int c, charcount = 0;
enum { LEFT, RIGHT } adjust;
enum { LONG, INT } intsize;
int fill;
@ -40,7 +42,7 @@ int printf(const char *fmt, ...)
while ((c= *fmt++) != 0) {
if (c != '%') {
/* Ordinary character. */
kputc(c);
count_kputc(c);
continue;
}
@ -162,26 +164,26 @@ int printf(const char *fmt, ...)
string_print:
width -= len;
if (i < 0) width--;
if (fill == '0' && i < 0) kputc('-');
if (fill == '0' && i < 0) count_kputc('-');
if (adjust == RIGHT) {
while (width > 0) { kputc(fill); width--; }
while (width > 0) { count_kputc(fill); width--; }
}
if (fill == ' ' && i < 0) kputc('-');
while (len > 0) { kputc((unsigned char) *p++); len--; }
while (width > 0) { kputc(fill); width--; }
if (fill == ' ' && i < 0) count_kputc('-');
while (len > 0) { count_kputc((unsigned char) *p++); len--; }
while (width > 0) { count_kputc(fill); width--; }
break;
/* Unrecognized format key, echo it back. */
default:
kputc('%');
kputc(c);
count_kputc('%');
count_kputc(c);
}
}
/* Mark the end with a null (should be something else, like -1). */
kputc(0);
va_end(argp);
return 0;
return charcount;
}
/*

16
lib/syslib/sys_physzero.c Normal file
View file

@ -0,0 +1,16 @@
#include "syslib.h"
PUBLIC int sys_physzero(phys_bytes base, phys_bytes bytes)
{
/* Zero a block of data. */
message mess;
if (bytes == 0L) return(OK);
mess.PZ_MEM_PTR = (char *) base;
mess.PZ_COUNT = bytes;
return(_taskcall(SYSTASK, SYS_PHYSZERO, &mess));
}