ia64/xen-unstable

changeset 18396:7a28400271f7

stubdom: add v?errx? and v?warnx? functions

Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Wed Aug 27 14:57:51 2008 +0100 (2008-08-27)
parents 03bdbb7e7add
children ab8212bd5604
files extras/mini-os/include/posix/err.h extras/mini-os/lib/sys.c
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/extras/mini-os/include/posix/err.h	Wed Aug 27 14:57:51 2008 +0100
     1.3 @@ -0,0 +1,15 @@
     1.4 +#ifndef _POSIX_ERR_H
     1.5 +#define _POSIX_ERR_H
     1.6 +
     1.7 +#include <stdarg.h>
     1.8 +
     1.9 +void err(int eval, const char *fmt, ...);
    1.10 +void errx(int eval, const char *fmt, ...);
    1.11 +void warn(const char *fmt, ...);
    1.12 +void warnx(const char *fmt, ...);
    1.13 +void verr(int eval, const char *fmt, va_list args);
    1.14 +void verrx(int eval, const char *fmt, va_list args);
    1.15 +void vwarn(const char *fmt, va_list args);
    1.16 +void vwarnx(const char *fmt, va_list args);
    1.17 +
    1.18 +#endif /* _POSIX_ERR_H */
     2.1 --- a/extras/mini-os/lib/sys.c	Wed Aug 27 14:57:23 2008 +0100
     2.2 +++ b/extras/mini-os/lib/sys.c	Wed Aug 27 14:57:51 2008 +0100
     2.3 @@ -1035,6 +1035,68 @@ void closelog(void)
     2.4      syslog_ident = NULL;
     2.5  }
     2.6  
     2.7 +void vwarn(const char *format, va_list ap)
     2.8 +{
     2.9 +    int the_errno = errno;
    2.10 +    printk("stubdom: ");
    2.11 +    if (format) {
    2.12 +        print(0, format, ap);
    2.13 +        printk(", ");
    2.14 +    }
    2.15 +    printk("%s", strerror(the_errno));
    2.16 +}
    2.17 +
    2.18 +void warn(const char *format, ...)
    2.19 +{
    2.20 +    va_list ap;
    2.21 +    va_start(ap, format);
    2.22 +    vwarn(format, ap);
    2.23 +    va_end(ap);
    2.24 +}
    2.25 +
    2.26 +void verr(int eval, const char *format, va_list ap)
    2.27 +{
    2.28 +    vwarn(format, ap);
    2.29 +    exit(eval);
    2.30 +}
    2.31 +
    2.32 +void err(int eval, const char *format, ...)
    2.33 +{
    2.34 +    va_list ap;
    2.35 +    va_start(ap, format);
    2.36 +    verr(eval, format, ap);
    2.37 +    va_end(ap);
    2.38 +}
    2.39 +
    2.40 +void vwarnx(const char *format, va_list ap)
    2.41 +{
    2.42 +    printk("stubdom: ");
    2.43 +    if (format)
    2.44 +        print(0, format, ap);
    2.45 +}
    2.46 +
    2.47 +void warnx(const char *format, ...)
    2.48 +{
    2.49 +    va_list ap;
    2.50 +    va_start(ap, format);
    2.51 +    vwarnx(format, ap);
    2.52 +    va_end(ap);
    2.53 +}
    2.54 +
    2.55 +void verrx(int eval, const char *format, va_list ap)
    2.56 +{
    2.57 +    vwarnx(format, ap);
    2.58 +    exit(eval);
    2.59 +}
    2.60 +
    2.61 +void errx(int eval, const char *format, ...)
    2.62 +{
    2.63 +    va_list ap;
    2.64 +    va_start(ap, format);
    2.65 +    verrx(eval, format, ap);
    2.66 +    va_end(ap);
    2.67 +}
    2.68 +
    2.69  int nanosleep(const struct timespec *req, struct timespec *rem)
    2.70  {
    2.71      s_time_t start = NOW();