Changeset 3dbe2d1f in mainline for uspace/libc/generic/io/io.c


Ignore:
Timestamp:
2007-04-07T18:00:18Z (18 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
2a98e58
Parents:
5b303ba
Message:

use futex instead of pthread serialization
synchronize only output to stdout
cleanup

File:
1 edited

Legend:

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

    r5b303ba r3dbe2d1f  
    3838#include <io/io.h>
    3939
    40 static char nl = '\n';
     40const static char nl = '\n';
    4141
    42 int puts(const char * str)
     42int puts(const char *str)
    4343{
    4444        size_t count;
    4545       
    46         if (str == NULL) {
    47                 return putnchars("(NULL)",6 );
    48         }
     46        if (str == NULL)
     47                return putnchars("(NULL)", 6);
    4948       
    5049        for (count = 0; str[count] != 0; count++);
    51         if (write(1, (void * ) str, count) == count) {
     50        if (write(1, (void *) str, count) == count) {
    5251                if (write(1, &nl, 1) == 1)
    5352                        return 0;
     
    6261 * @return 0 on succes, EOF on fail
    6362 */
    64 int putnchars(const char * buf, size_t count)
     63int putnchars(const char *buf, size_t count)
    6564{
    66         if (write(1, (void * ) buf, count) == count) {
     65        if (write(1, (void *) buf, count) == count)
    6766                        return 0;
    68         }
    6967       
    7068        return EOF;
     
    7472 *
    7573 */
    76 int putstr(const char * str)
     74int putstr(const char *str)
    7775{
    7876        size_t count;
    7977       
    80         if (str == NULL) {
    81                 return putnchars("(NULL)",6 );
    82         }
     78        if (str == NULL)
     79                return putnchars("(NULL)", 6);
    8380
    8481        for (count = 0; str[count] != 0; count++);
    85         if (write(1, (void * ) str, count) == count) {
     82        if (write(1, (void *) str, count) == count)
    8683                        return 0;
    87         }
    8884       
    8985        return EOF;
     
    9389{
    9490        unsigned char ch = c;
    95         if (write(1, (void *)&ch , 1) == 1) {
     91        if (write(1, (void *) &ch, 1) == 1)
    9692                        return c;
    97         }
    9893       
    9994        return EOF;
     
    10398{
    10499        unsigned char c;
    105         if (read(0, (void *)&c , 1) == 1) {
     100        if (read(0, (void *) &c, 1) == 1)
    106101                        return c;
    107         }
    108102       
    109103        return EOF;
Note: See TracChangeset for help on using the changeset viewer.