Changeset 19b3cc6 in mainline for uspace/lib/c/include/io/klog.h


Ignore:
Timestamp:
2014-01-17T23:12:10Z (10 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
e26a9d95
Parents:
fddffb2 (diff), facc34d (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge libdrv-cleanup branch (includes mainline changes)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/include/io/klog.h

    rfddffb2 r19b3cc6  
    11/*
    2  * Copyright (c) 2006 Jakub Vana
     2 * Copyright (c) 2013 Martin Sucha
    33 * All rights reserved.
    44 *
     
    3939#include <stdarg.h>
    4040#include <io/verify.h>
     41#include <stdio.h>
     42#include <stdlib.h>
     43#include <str.h>
     44#include <abi/log.h>
    4145
    42 extern size_t klog_write(const void *, size_t);
    43 extern void klog_update(void);
    44 extern void klog_command(const void *, size_t);
    45 extern int klog_printf(const char *, ...)
    46     PRINTF_ATTRIBUTE(1, 2);
    47 extern int klog_vprintf(const char *, va_list);
     46extern size_t klog_write(log_level_t, const void *, size_t);
     47extern int klog_read(void *, size_t);
     48
     49#define KLOG_PRINTF(lvl, fmt, ...) ({ \
     50        char *_fmt = str_dup(fmt); \
     51        size_t _fmtsize = str_size(_fmt); \
     52        if (_fmtsize > 0 && _fmt[_fmtsize - 1] == '\n') \
     53                _fmt[_fmtsize - 1] = 0; \
     54        char *_s; \
     55        int _c = asprintf(&_s, _fmt, ##__VA_ARGS__); \
     56        free(_fmt); \
     57        if (_c >= 0) { \
     58                _c = klog_write((lvl), _s, str_size(_s)); \
     59                free(_s); \
     60        }; \
     61        (_c >= 0); \
     62})
    4863
    4964#endif
Note: See TracChangeset for help on using the changeset viewer.