Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/printf/vprintf.c

    r28a5ebd r690ad20  
    3333 */
    3434
     35#include <arch/asm.h>
     36#include <console/console.h>
    3537#include <print.h>
    36 #include <printf/printf_core.h>
    37 #include <putchar.h>
     38#include <printf_core.h>
     39#include <str.h>
    3840#include <synch/spinlock.h>
    39 #include <arch/asm.h>
    4041#include <typedefs.h>
    41 #include <str.h>
    4242
    43 static int vprintf_str_write(const char *str, size_t size, void *data)
     43static errno_t vprintf_str_write(const char *str, size_t size, void *data)
    4444{
    45         size_t offset = 0;
    46         size_t chars = 0;
    47 
    48         while (offset < size) {
    49                 putuchar(str_decode(str, &offset, size));
    50                 chars++;
    51         }
    52 
    53         return chars;
    54 }
    55 
    56 static int vprintf_wstr_write(const char32_t *str, size_t size, void *data)
    57 {
    58         size_t offset = 0;
    59         size_t chars = 0;
    60 
    61         while (offset < size) {
    62                 putuchar(str[chars]);
    63                 chars++;
    64                 offset += sizeof(char32_t);
    65         }
    66 
    67         return chars;
     45        putstr(str, size);
     46        return EOK;
    6847}
    6948
    7049int puts(const char *str)
    7150{
    72         size_t offset = 0;
    73         size_t chars = 0;
    74         char32_t uc;
    75 
    76         while ((uc = str_decode(str, &offset, STR_NO_LIMIT)) != 0) {
    77                 putuchar(uc);
    78                 chars++;
    79         }
    80 
    81         putuchar('\n');
    82         return chars;
     51        size_t n = str_size(str);
     52        putstr(str, n);
     53        return n;
    8354}
    8455
     
    8758        printf_spec_t ps = {
    8859                vprintf_str_write,
    89                 vprintf_wstr_write,
    9060                NULL
    9161        };
    9262
    93         return printf_core(fmt, &ps, ap);
     63        console_lock();
     64        int ret = printf_core(fmt, &ps, ap);
     65        console_unlock();
     66        return ret;
    9467}
    9568
Note: See TracChangeset for help on using the changeset viewer.