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:
parent
dfe2b4513f
commit
b4335679cb
@ -14,12 +14,12 @@
|
|||||||
#define time _time
|
#define time _time
|
||||||
#define write _write
|
#define write _write
|
||||||
#include <lib.h>
|
#include <lib.h>
|
||||||
|
#include <time.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <sys/asynchio.h>
|
#include <sys/asynchio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <time.h>
|
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
||||||
#define IDLE 0
|
#define IDLE 0
|
||||||
|
@ -45,6 +45,7 @@ OBJECTS = \
|
|||||||
$(LIBSYS)(sys_signalrm.o) \
|
$(LIBSYS)(sys_signalrm.o) \
|
||||||
$(LIBSYS)(sys_flagalrm.o) \
|
$(LIBSYS)(sys_flagalrm.o) \
|
||||||
$(LIBSYS)(sys_syncalrm.o) \
|
$(LIBSYS)(sys_syncalrm.o) \
|
||||||
|
$(LIBSYS)(sys_physzero.o) \
|
||||||
$(LIBSYS)(taskcall.o) \
|
$(LIBSYS)(taskcall.o) \
|
||||||
|
|
||||||
$(LIBSYS): $(OBJECTS)
|
$(LIBSYS): $(OBJECTS)
|
||||||
@ -165,6 +166,9 @@ $(LIBSYS)(sys_flagalrm.o): sys_flagalrm.c
|
|||||||
$(LIBSYS)(sys_syncalrm.o): sys_syncalrm.c
|
$(LIBSYS)(sys_syncalrm.o): sys_syncalrm.c
|
||||||
$(CC1) sys_syncalrm.c
|
$(CC1) sys_syncalrm.c
|
||||||
|
|
||||||
|
$(LIBSYS)(sys_physzero.o): sys_physcp.c
|
||||||
|
$(CC1) sys_physzero.c
|
||||||
|
|
||||||
$(LIBSYS)(taskcall.o): taskcall.c
|
$(LIBSYS)(taskcall.o): taskcall.c
|
||||||
$(CC1) taskcall.c
|
$(CC1) taskcall.c
|
||||||
|
|
||||||
|
@ -17,10 +17,12 @@ int printf(fmt) char *fmt;
|
|||||||
/* Printf() uses kputc() to print characters. */
|
/* Printf() uses kputc() to print characters. */
|
||||||
void kputc(int c);
|
void kputc(int c);
|
||||||
|
|
||||||
|
#define count_kputc(c) do { charcount++; kputc(c); } while(0)
|
||||||
|
|
||||||
int printf(const char *fmt, ...)
|
int printf(const char *fmt, ...)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
int c;
|
int c, charcount = 0;
|
||||||
enum { LEFT, RIGHT } adjust;
|
enum { LEFT, RIGHT } adjust;
|
||||||
enum { LONG, INT } intsize;
|
enum { LONG, INT } intsize;
|
||||||
int fill;
|
int fill;
|
||||||
@ -40,7 +42,7 @@ int printf(const char *fmt, ...)
|
|||||||
while ((c= *fmt++) != 0) {
|
while ((c= *fmt++) != 0) {
|
||||||
if (c != '%') {
|
if (c != '%') {
|
||||||
/* Ordinary character. */
|
/* Ordinary character. */
|
||||||
kputc(c);
|
count_kputc(c);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -162,26 +164,26 @@ int printf(const char *fmt, ...)
|
|||||||
string_print:
|
string_print:
|
||||||
width -= len;
|
width -= len;
|
||||||
if (i < 0) width--;
|
if (i < 0) width--;
|
||||||
if (fill == '0' && i < 0) kputc('-');
|
if (fill == '0' && i < 0) count_kputc('-');
|
||||||
if (adjust == RIGHT) {
|
if (adjust == RIGHT) {
|
||||||
while (width > 0) { kputc(fill); width--; }
|
while (width > 0) { count_kputc(fill); width--; }
|
||||||
}
|
}
|
||||||
if (fill == ' ' && i < 0) kputc('-');
|
if (fill == ' ' && i < 0) count_kputc('-');
|
||||||
while (len > 0) { kputc((unsigned char) *p++); len--; }
|
while (len > 0) { count_kputc((unsigned char) *p++); len--; }
|
||||||
while (width > 0) { kputc(fill); width--; }
|
while (width > 0) { count_kputc(fill); width--; }
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* Unrecognized format key, echo it back. */
|
/* Unrecognized format key, echo it back. */
|
||||||
default:
|
default:
|
||||||
kputc('%');
|
count_kputc('%');
|
||||||
kputc(c);
|
count_kputc(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Mark the end with a null (should be something else, like -1). */
|
/* Mark the end with a null (should be something else, like -1). */
|
||||||
kputc(0);
|
kputc(0);
|
||||||
va_end(argp);
|
va_end(argp);
|
||||||
return 0;
|
return charcount;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
16
lib/syslib/sys_physzero.c
Normal file
16
lib/syslib/sys_physzero.c
Normal 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));
|
||||||
|
}
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user