]> Zhao Yanbai Git Server - minix.git/commitdiff
Added sys_physzero library call for corresponding system call; modified
authorBen Gras <ben@minix3.org>
Wed, 1 Jun 2005 09:36:07 +0000 (09:36 +0000)
committerBen Gras <ben@minix3.org>
Wed, 1 Jun 2005 09:36:07 +0000 (09:36 +0000)
system-printf() so it returns number of characters printed (for use in
smart formatting)

lib/other/asynchio.c
lib/syslib/Makefile
lib/syslib/kprintf.c
lib/syslib/sys_physzero.c [new file with mode: 0644]

index aed3ecb1d2005c5f25bfeadd1373f7bcd7c6a04c..77141080d8f0ebc9a75c851363ca4d8247680547 100755 (executable)
 #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
index ff51fe0761d5c8cf4161444c8a3aade496582dc0..d6bc2ae1856695edff727d5183fd719a3912484e 100755 (executable)
@@ -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
 
index 5428b75d81b593992721fdd8dac9cd138461a8f6..8341474e9d62b745c3b21bfe1aae7cf2c3f35cae 100755 (executable)
@@ -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;
 }
 
 /*
diff --git a/lib/syslib/sys_physzero.c b/lib/syslib/sys_physzero.c
new file mode 100644 (file)
index 0000000..ef542e5
--- /dev/null
@@ -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));
+}
+