Changeset 566f4cfb in mainline for uspace/lib/libc/generic/io/stream.c


Ignore:
Timestamp:
2009-04-24T08:01:05Z (15 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
402de0c
Parents:
ab1861a
Message:

use buffering for klog output (this can be used to avoid the ugly usleeps while starting tasks)
unify and cleanup console.c and related files

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/libc/generic/io/stream.c

    rab1861a r566f4cfb  
    5050#include <sys/types.h>
    5151
    52 ssize_t write_stderr(const void *buf, size_t count)
    53 {
    54         return count;
    55 }
    56 
    5752ssize_t read_stdin(void *buf, size_t count)
    5853{
    59         int cons_phone = console_phone_get(false);
    60 
     54        int cons_phone = console_open(false);
     55       
    6156        if (cons_phone >= 0) {
    6257                kbd_event_t ev;
    6358                int rc;
    6459                size_t i = 0;
    65        
     60               
    6661                while (i < count) {
    6762                        do {
     
    6964                                if (rc < 0) return -1;
    7065                        } while (ev.c == 0 || ev.type == KE_RELEASE);
    71 
     66                       
    7267                        ((char *) buf)[i++] = ev.c;
    7368                }
    7469                return i;
    75         } else {
     70        } else
    7671                return -1;
    77         }
    78 }
    79 
    80 ssize_t write_stdout(const void *buf, size_t count)
    81 {
    82         int cons_phone = console_phone_get(false);
    83         int left, rc;
    84 
    85         if (cons_phone >= 0) {
    86                 int i;
    87 
    88                 left = count;
    89                 while (left > 0) {
    90                         rc = console_write(buf, left);
    91                         if (rc < 0)
    92                                 break;
    93                         buf += rc;
    94                         left -= rc;
    95                 }
    96 
    97                 return count;
    98         } else
    99                 return __SYSCALL3(SYS_KLOG, 1, (sysarg_t) buf, count);
    100 }
    101 
    102 int flush_stdout(void)
    103 {
    104         console_flush();
    105         return 0;
    10672}
    10773
Note: See TracChangeset for help on using the changeset viewer.