Changeset 3dbe2d1f in mainline


Ignore:
Timestamp:
2007-04-07T18:00:18Z (17 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

Location:
uspace
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • uspace/kbd/generic/key_buffer.c

    r5b303ba r3dbe2d1f  
    112112 * @}
    113113 */
    114 
  • 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;
  • uspace/libc/generic/io/printf.c

    r5b303ba r3dbe2d1f  
    5757/** @}
    5858 */
    59  
    60  
  • uspace/libc/generic/io/printf_core.c

    r5b303ba r3dbe2d1f  
    4141#include <ctype.h>
    4242#include <string.h>
    43 /* For serialization */
    44 #include <async.h>
    4543
    4644#define __PRINTF_FLAG_PREFIX            0x00000001      /**< show prefixes 0x or 0*/
     
    9391        size_t count;
    9492       
    95         if (str == NULL) {
     93        if (str == NULL)
    9694                return printf_putnchars("(NULL)", 6, ps);
    97         }
    9895
    9996        for (count = 0; str[count] != 0; count++);
    10097
    101         if (ps->write((void *) str, count, ps->data) == count) {
     98        if (ps->write((void *) str, count, ps->data) == count)
    10299                return 0;
    103         }
    104100       
    105101        return EOF;
     
    448444        uint64_t flags;
    449445       
    450         /* Don't let other threads interfere */
    451         async_serialize_start();
    452 
    453446        counter = 0;
    454447       
     
    682675        }
    683676       
    684         async_serialize_end();
    685677        return counter;
    686678minus_out:
    687         async_serialize_end();
    688679        return -counter;
    689680}
  • uspace/libc/generic/io/vprintf.c

    r5b303ba r3dbe2d1f  
    3737#include <unistd.h>
    3838#include <io/printf_core.h>
     39#include <futex.h>
    3940
    40 int vprintf_write(const char *str, size_t count, void *unused);
     41atomic_t printf_futex = FUTEX_INITIALIZER;
    4142
    42 int vprintf_write(const char *str, size_t count, void *unused)
     43static int vprintf_write(const char *str, size_t count, void *unused)
    4344{
    4445        return write(1, str, count);
     
    5253int vprintf(const char *fmt, va_list ap)
    5354{
    54         struct printf_spec ps = {(int(*)(void *, size_t, void *))vprintf_write, NULL};
    55         return printf_core(fmt, &ps, ap);
    56 
     55        struct printf_spec ps = {(int(*)(void *, size_t, void *)) vprintf_write, NULL};
     56       
     57        futex_down(&printf_futex);
     58        int ret = printf_core(fmt, &ps, ap);
     59        futex_up(&printf_futex);
     60       
     61        return ret;
    5762}
    5863
  • uspace/libc/generic/io/vsnprintf.c

    r5b303ba r3dbe2d1f  
    4444};
    4545
    46 int vsnprintf_write(const char *str, size_t count, struct vsnprintf_data *data);
    47 
    4846/** Write string to given buffer.
    4947 * Write at most data->size characters including trailing zero. According to C99 has snprintf to return number
     
    5654 * @return number of characters to print (not characters really printed!)
    5755 */
    58 int vsnprintf_write(const char *str, size_t count, struct vsnprintf_data *data)
     56static int vsnprintf_write(const char *str, size_t count, struct vsnprintf_data *data)
    5957{
    6058        size_t i;
     
    9896{
    9997        struct vsnprintf_data data = {size, 0, str};
    100         struct printf_spec ps = {(int(*)(void *, size_t, void *))vsnprintf_write, &data};
     98        struct printf_spec ps = {(int(*)(void *, size_t, void *)) vsnprintf_write, &data};
    10199
    102100        /* Print 0 at end of string - fix the case that nothing will be printed */
  • uspace/libc/generic/io/vsprintf.c

    r5b303ba r3dbe2d1f  
    4545int vsprintf(char *str, const char *fmt, va_list ap)
    4646{
    47         return vsnprintf(str, (size_t)-1, fmt, ap);
     47        return vsnprintf(str, (size_t) - 1, fmt, ap);
    4848}
    4949
  • uspace/libc/include/async.h

    r5b303ba r3dbe2d1f  
    117117                 ipcarg_t arg3);
    118118void async_msg_2(int phoneid, ipcarg_t method, ipcarg_t arg1, ipcarg_t arg2);
    119 #define async_msg(ph,m,a1) async_msg_2(ph,m,a1,0)
     119#define async_msg(ph, m, a1) async_msg_2(ph, m, a1, 0)
    120120
    121121static inline void async_serialize_start(void)
     
    123123        psthread_inc_sercount();
    124124}
     125
    125126static inline void async_serialize_end(void)
    126127{
Note: See TracChangeset for help on using the changeset viewer.