Changeset 96e01fbc in mainline for uspace/lib/c


Ignore:
Timestamp:
2012-08-31T17:30:29Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
2be2506a
Parents:
e0d5bc5 (diff), 0d57c3e (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 mainline changes.

Location:
uspace/lib/c
Files:
28 added
46 edited
2 moved

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/Makefile

    re0d5bc5 r96e01fbc  
    6262        generic/ddi.c \
    6363        generic/as.c \
     64        generic/bd.c \
     65        generic/bd_srv.c \
    6466        generic/cap.c \
    6567        generic/cfg.c \
     
    6971        generic/device/hw_res_parsed.c \
    7072        generic/device/char_dev.c \
     73        generic/device/graph_dev.c \
    7174        generic/device/nic.c \
    7275        generic/device/pci.c \
     76        generic/device/ahci.c \
    7377        generic/elf/elf_load.c \
    7478        generic/event.c \
     
    9195        generic/inetping.c \
    9296        generic/io/asprintf.c \
     97        generic/io/input.c \
    9398        generic/io/io.c \
     99        generic/io/chargrid.c \
     100        generic/io/output.c \
    94101        generic/io/printf.c \
    95102        generic/io/log.c \
     
    99106        generic/io/vsnprintf.c \
    100107        generic/io/printf_core.c \
     108        generic/io/con_srv.c \
    101109        generic/io/console.c \
     110        generic/io/visualizer.c \
     111        generic/io/window.c \
    102112        generic/iplink.c \
    103113        generic/iplink_srv.c \
  • uspace/lib/c/arch/abs32le/_link.ld.in

    re0d5bc5 r96e01fbc  
    1414SECTIONS {
    1515#ifdef LOADER
     16        . = 0x70001000 + SIZEOF_HEADERS;
     17       
    1618        .interp : {
    1719                *(.interp);
    18         } :interp
    19        
    20         . = 0x70001000 + SIZEOF_HEADERS;
     20        } :interp :text
    2121#else
    2222        . = 0x1000 + SIZEOF_HEADERS;
    2323#endif
     24       
     25        /* Make sure the code is aligned reasonably */
     26        . = ALIGN(., 16);
     27       
    2428        .text : {
    2529                *(.text .text.*);
  • uspace/lib/c/arch/abs32le/include/types.h

    re0d5bc5 r96e01fbc  
    4747
    4848typedef uint32_t sysarg_t;
     49typedef int32_t native_t;
    4950
    5051typedef int32_t ssize_t;
  • uspace/lib/c/arch/amd64/_link.ld.in

    re0d5bc5 r96e01fbc  
    1515SECTIONS {
    1616#ifdef LOADER
     17        . = 0x70001000 + SIZEOF_HEADERS;
     18       
    1719        .interp : {
    1820                *(.interp);
    19         } :interp
    20        
    21         . = 0x70001000 + SIZEOF_HEADERS;
     21        } :interp :text
    2222#else
    2323        . = 0x1000 + SIZEOF_HEADERS;
    2424#endif
     25       
     26        /* Make sure the code is aligned reasonably */
     27        . = ALIGN(., 16);
     28       
    2529        .init : {
    2630                *(.init);
  • uspace/lib/c/arch/amd64/include/elf_linux.h

    re0d5bc5 r96e01fbc  
    6666        uint64_t rsp;
    6767        uint64_t ss;
     68
     69        /*
     70         * The following registers need to be part of elf_regs_t.
     71         * Unfortunately, we don't have any information about them in our
     72         * istate_t.
     73         */
     74        uint64_t unused_fs_base;
     75        uint64_t unused_gs_base;
     76        uint64_t unused_ds;
     77        uint64_t unused_es;
     78        uint64_t unused_fs;
     79        uint64_t unused_gs;
    6880} elf_regs_t;
    6981
     
    91103        elf_regs->rsp = istate->rsp;
    92104        elf_regs->ss = istate->ss;
     105
     106        /*
     107         * Reset the registers for which there is not enough info in istate_t.
     108         */
     109        elf_regs->unused_fs_base = 0;
     110        elf_regs->unused_gs_base = 0;
     111        elf_regs->unused_ds = 0;
     112        elf_regs->unused_es = 0;
     113        elf_regs->unused_fs = 0;
     114        elf_regs->unused_gs = 0;
    93115}
    94116
  • uspace/lib/c/arch/amd64/include/types.h

    re0d5bc5 r96e01fbc  
    4747
    4848typedef uint64_t sysarg_t;
     49typedef int64_t native_t;
    4950
    5051typedef int64_t ssize_t;
  • uspace/lib/c/arch/arm32/_link.ld.in

    re0d5bc5 r96e01fbc  
    1414SECTIONS {
    1515#ifdef LOADER
     16        . = 0x70001000 + SIZEOF_HEADERS;
     17       
    1618        .interp : {
    1719                *(.interp);
    18         } :interp
    19        
    20         . = 0x70001000 + SIZEOF_HEADERS;
     20        } :interp :text
    2121#else
    2222        . = 0x1000 + SIZEOF_HEADERS;
    2323#endif
     24       
     25        /* Make sure the code is aligned reasonably */
     26        . = ALIGN(., 8);
     27       
    2428        .init : {
    2529                *(.init);
  • uspace/lib/c/arch/arm32/include/types.h

    re0d5bc5 r96e01fbc  
    4848
    4949typedef uint32_t sysarg_t;
     50typedef int32_t native_t;
    5051
    5152typedef int32_t ssize_t;
  • uspace/lib/c/arch/arm32/src/fibril.S

    re0d5bc5 r96e01fbc  
    3535        stmia r0!, {sp, lr}
    3636        stmia r0!, {r4-r11}
    37 
     37       
    3838        # return 1
    3939        mov r0, #1
     
    4343        ldmia r0!, {sp, lr}
    4444        ldmia r0!, {r4-r11}
    45 
    46         #return 0
     45       
     46        # return 0
    4747        mov r0, #0
    4848        mov pc, lr
  • uspace/lib/c/arch/arm32/src/stacktrace_asm.S

    re0d5bc5 r96e01fbc  
    4141
    4242stacktrace_pc_get:
    43         mov r0, lr 
     43        mov r0, lr
    4444        mov pc, lr
  • uspace/lib/c/arch/arm32/src/thread_entry.s

    re0d5bc5 r96e01fbc  
    4242        push {fp, ip, lr, pc}
    4343        sub fp, ip, #4
    44 
    45         b __thread_main
     44       
     45        b __thread_main
  • uspace/lib/c/arch/ia32/_link.ld.in

    re0d5bc5 r96e01fbc  
    1919
    2020SECTIONS {
    21 #if defined(LOADER) || defined(DLEXE)
    22         .interp : {
    23                 *(.interp);
    24         } :interp
    25 #endif
    2621#ifdef LOADER
    2722        . = 0x70001000 + SIZEOF_HEADERS;
     
    2924        . = 0x1000 + SIZEOF_HEADERS;
    3025#endif
     26       
     27#if defined(LOADER) || defined(DLEXE)
     28        .interp : {
     29                *(.interp);
     30        } :interp :text
     31#endif
     32       
     33        /* Make sure the code is aligned reasonably */
     34        . = ALIGN(., 16);
     35       
    3136        .init : {
    3237                *(.init);
     
    3742                *(.rodata .rodata.*);
    3843        } :text
    39 
     44       
    4045#if defined(SHLIB) || defined(DLEXE)
    4146        .rel.plt : {
     
    8085#if defined(SHLIB) || defined(DLEXE)
    8186        .data.rel : {
    82                 *(.data.rel .data.rel.*);
     87                *(.data.rel .data.rel.*);
    8388        } :data
    84 
     89       
    8590        .got : {
    86                 *(.got);
     91                *(.got);
    8792        } :data
     93       
    8894        .got.plt : {
    89                 *(.got.plt);
     95                *(.got.plt);
    9096        } :data
    9197#endif
  • uspace/lib/c/arch/ia32/include/types.h

    re0d5bc5 r96e01fbc  
    4747
    4848typedef uint32_t sysarg_t;
     49typedef int32_t native_t;
    4950
    5051typedef int32_t ssize_t;
  • uspace/lib/c/arch/ia64/Makefile.common

    re0d5bc5 r96e01fbc  
    2727#
    2828
    29 GCC_CFLAGS += -fno-unwind-tables
     29#
     30# FIXME:
     31#
     32# The -fno-selective-scheduling and -fno-selective-scheduling2 options
     33# should be removed as soon as a bug in GCC concerning unchecked
     34# speculative loads is fixed.
     35#
     36# See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53975 for reference.
     37#
     38
     39GCC_CFLAGS += -fno-unwind-tables -fno-selective-scheduling -fno-selective-scheduling2
    3040
    3141ENDIANESS = LE
  • uspace/lib/c/arch/ia64/_link.ld.in

    re0d5bc5 r96e01fbc  
    1414SECTIONS {
    1515#ifdef LOADER
     16        . = 0x800000000 + SIZEOF_HEADERS;
     17       
    1618        .interp : {
    1719                *(.interp);
    18         } :interp
    19        
    20         . = 0x800000000 + SIZEOF_HEADERS;
     20        } :interp :text
    2121#else
    2222        . = 0x4000 + SIZEOF_HEADERS;
    2323#endif
    24         /*
    25          * XXX This is just a work around. Problem: .init section does not
    26          * have the proper alignment.
    27          */
     24       
     25        /* Make sure the code is aligned reasonably */
    2826        . = ALIGN(., 16);
    29 
     27       
    3028        .init : {
    3129                *(.init);
  • uspace/lib/c/arch/ia64/include/types.h

    re0d5bc5 r96e01fbc  
    5757
    5858typedef uint64_t sysarg_t;
     59typedef int64_t native_t;
    5960
    6061typedef int64_t ssize_t;
  • uspace/lib/c/arch/mips32/Makefile.common

    re0d5bc5 r96e01fbc  
    2727#
    2828
    29 GCC_CFLAGS += -mips3 -mabi=32
     29GCC_CFLAGS += -msoft-float -mips3 -mabi=32
    3030
    3131ENDIANESS = LE
  • uspace/lib/c/arch/mips32/_link.ld.in

    re0d5bc5 r96e01fbc  
    1414SECTIONS {
    1515#ifdef LOADER
     16        . = 0x70004000 + SIZEOF_HEADERS;
     17       
    1618        .interp : {
    1719                *(.interp);
    18         } :interp
    19        
    20         . = 0x70004000 + SIZEOF_HEADERS;
     20        } :interp :text
    2121#else
    2222        . = 0x4000 + SIZEOF_HEADERS;
    2323#endif
     24       
     25        /* Make sure the code is aligned reasonably */
     26        . = ALIGN(., 16);
     27       
    2428        .init : {
    2529                *(.init);
  • uspace/lib/c/arch/mips32/include/types.h

    re0d5bc5 r96e01fbc  
    4848
    4949typedef uint32_t sysarg_t;
     50typedef int32_t native_t;
    5051
    5152typedef int32_t ssize_t;
  • uspace/lib/c/arch/mips32eb/Makefile.common

    re0d5bc5 r96e01fbc  
    2727#
    2828
    29 GCC_CFLAGS += -mips3 -mabi=32
     29GCC_CFLAGS += -msoft-float -mips3 -mabi=32
    3030
    3131ENDIANESS = BE
  • uspace/lib/c/arch/mips64/Makefile.common

    re0d5bc5 r96e01fbc  
    2727#
    2828
    29 GCC_CFLAGS += -mips3 -mabi=64
     29GCC_CFLAGS += -msoft-float -mips3 -mabi=64
    3030AFLAGS = -64
    3131
  • uspace/lib/c/arch/mips64/_link.ld.in

    re0d5bc5 r96e01fbc  
    1515SECTIONS {
    1616#ifdef LOADER
     17        . = 0x70004000 + SIZEOF_HEADERS;
     18       
    1719        .interp : {
    1820                *(.interp);
    19         } :interp
    20        
    21         . = 0x70004000 + SIZEOF_HEADERS;
     21        } :interp :text
    2222#else
    2323        . = 0x4000 + SIZEOF_HEADERS;
    2424#endif
     25       
     26        /* Make sure the code is aligned reasonably */
     27        . = ALIGN(., 16);
     28       
    2529        .init : {
    2630                *(.init);
  • uspace/lib/c/arch/mips64/include/types.h

    re0d5bc5 r96e01fbc  
    4848
    4949typedef uint64_t sysarg_t;
     50typedef int64_t native_t;
    5051
    5152typedef int64_t ssize_t;
  • uspace/lib/c/arch/ppc32/_link.ld.in

    re0d5bc5 r96e01fbc  
    1515SECTIONS {
    1616#ifdef LOADER
     17        . = 0x70001000 + SIZEOF_HEADERS;
     18       
    1719        .interp : {
    1820                *(.interp);
    19         } :interp
    20        
    21         . = 0x70001000 + SIZEOF_HEADERS;
     21        } :interp :text
    2222#else
    2323        . = 0x1000 + SIZEOF_HEADERS;
    2424#endif
     25       
     26        /* Make sure the code is aligned reasonably */
     27        . = ALIGN(., 4);
     28       
    2529        .init : {
    2630                *(.init);
  • uspace/lib/c/arch/ppc32/include/types.h

    re0d5bc5 r96e01fbc  
    4747
    4848typedef uint32_t sysarg_t;
     49typedef int32_t native_t;
    4950
    5051typedef int32_t ssize_t;
  • uspace/lib/c/arch/sparc64/_link.ld.in

    re0d5bc5 r96e01fbc  
    1414SECTIONS {
    1515#ifdef LOADER
     16        . = 0x70004000 + SIZEOF_HEADERS;
     17       
    1618        .interp : {
    1719                *(.interp);
    18         } :interp
    19        
    20         . = 0x70004000 + SIZEOF_HEADERS;
     20        } :interp :text
    2121#else
    2222        . = 0x4000 + SIZEOF_HEADERS;
    2323#endif
     24       
     25        /* Make sure the code is aligned reasonably */
     26        . = ALIGN(., 16);
     27       
    2428        .init : {
    2529                *(.init);
  • uspace/lib/c/arch/sparc64/include/types.h

    re0d5bc5 r96e01fbc  
    4747
    4848typedef uint64_t sysarg_t;
     49typedef int64_t native_t;
    4950
    5051typedef int64_t ssize_t;
  • uspace/lib/c/generic/async.c

    re0d5bc5 r96e01fbc  
    114114#include <stdlib.h>
    115115#include <macros.h>
     116#include "private/libc.h"
    116117
    117118#define CLIENT_HASH_TABLE_BUCKETS  32
     
    21662167int async_share_in_finalize(ipc_callid_t callid, void *src, unsigned int flags)
    21672168{
    2168         return ipc_share_in_finalize(callid, src, flags);
     2169        return ipc_answer_3(callid, EOK, (sysarg_t) src, (sysarg_t) flags,
     2170            (sysarg_t) __entry);
    21692171}
    21702172
     
    22332235int async_share_out_finalize(ipc_callid_t callid, void **dst)
    22342236{
    2235         return ipc_share_out_finalize(callid, dst);
     2237        return ipc_answer_2(callid, EOK, (sysarg_t) __entry, (sysarg_t) dst);
    22362238}
    22372239
     
    23172319int async_data_read_finalize(ipc_callid_t callid, const void *src, size_t size)
    23182320{
    2319         return ipc_data_read_finalize(callid, src, size);
     2321        return ipc_answer_2(callid, EOK, (sysarg_t) src, (sysarg_t) size);
    23202322}
    23212323
     
    24202422int async_data_write_finalize(ipc_callid_t callid, void *dst, size_t size)
    24212423{
    2422         return ipc_data_write_finalize(callid, dst, size);
     2424        return ipc_answer_2(callid, EOK, (sysarg_t) dst, (sysarg_t) size);
    24232425}
    24242426
  • uspace/lib/c/generic/io/chargrid.c

    re0d5bc5 r96e01fbc  
    2727 */
    2828
    29 /** @addtogroup console
     29/** @addtogroup libc
    3030 * @{
    3131 */
     
    3939#include <bool.h>
    4040#include <as.h>
    41 #include "screenbuffer.h"
    42 
    43 /** Structure for buffering state of one virtual console.
    44  *
    45  */
    46 struct screenbuffer {
    47         size_t size;                /**< Structure size */
    48         screenbuffer_flag_t flags;  /**< Screenbuffer flags */
    49        
    50         sysarg_t cols;              /**< Number of columns */
    51         sysarg_t rows;              /**< Number of rows */
    52        
    53         sysarg_t col;               /**< Current column */
    54         sysarg_t row;               /**< Current row */
    55         bool cursor_visible;        /**< Cursor visibility */
    56        
    57         char_attrs_t attrs;         /**< Current attributes */
    58        
    59         sysarg_t top_row;           /**< The first row in the cyclic buffer */
    60         charfield_t data[];         /**< Screen contents (cyclic buffer) */
    61 };
    62 
    63 /** Create a screenbuffer.
     41#include <io/chargrid.h>
     42
     43/** Create a chargrid.
    6444 *
    6545 * @param[in] cols  Number of columns.
    6646 * @param[in] rows  Number of rows.
    67  * @param[in] flags Screenbuffer flags.
    68  *
    69  * @return New screenbuffer.
     47 * @param[in] flags Chargrid flags.
     48 *
     49 * @return New chargrid.
    7050 * @return NULL on failure.
    7151 *
    7252 */
    73 screenbuffer_t *screenbuffer_create(sysarg_t cols, sysarg_t rows,
    74     screenbuffer_flag_t flags)
     53chargrid_t *chargrid_create(sysarg_t cols, sysarg_t rows,
     54    chargrid_flag_t flags)
    7555{
    7656        size_t size =
    77             sizeof(screenbuffer_t) + cols * rows * sizeof(charfield_t);
    78         screenbuffer_t *scrbuf;
    79        
    80         if ((flags & SCREENBUFFER_FLAG_SHARED) == SCREENBUFFER_FLAG_SHARED) {
    81                 scrbuf = (screenbuffer_t *) as_area_create(AS_AREA_ANY, size,
     57            sizeof(chargrid_t) + cols * rows * sizeof(charfield_t);
     58        chargrid_t *scrbuf;
     59       
     60        if ((flags & CHARGRID_FLAG_SHARED) == CHARGRID_FLAG_SHARED) {
     61                scrbuf = (chargrid_t *) as_area_create(AS_AREA_ANY, size,
    8262                    AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE);
    8363                if (scrbuf == AS_MAP_FAILED)
    8464                        return NULL;
    8565        } else {
    86                 scrbuf = (screenbuffer_t *) malloc(size);
     66                scrbuf = (chargrid_t *) malloc(size);
    8767                if (scrbuf == NULL)
    8868                        return NULL;
     
    9979       
    10080        scrbuf->top_row = 0;
    101         screenbuffer_clear(scrbuf);
     81        chargrid_clear(scrbuf);
    10282       
    10383        return scrbuf;
    10484}
    10585
    106 /** Return keyfield by coordinates
    107  *
    108  * The back buffer is organized as a cyclic buffer.
    109  * Therefore we must take into account the topmost column.
    110  *
    111  * @param scrbuf Screenbuffer
    112  * @param col    Column position on screen
    113  * @param row    Row position on screen
    114  *
    115  * @return Keyfield structure on (row, col)
    116  *
    117  */
    118 charfield_t *screenbuffer_field_at(screenbuffer_t *scrbuf, sysarg_t col,
    119     sysarg_t row)
    120 {
    121         return scrbuf->data +
    122             ((row + scrbuf->top_row) % scrbuf->rows) * scrbuf->cols +
    123             col;
    124 }
    125 
    126 bool screenbuffer_cursor_at(screenbuffer_t *scrbuf, sysarg_t col, sysarg_t row)
     86void chargrid_destroy(chargrid_t *srcbuf)
     87{
     88        // TODO
     89}
     90
     91bool chargrid_cursor_at(chargrid_t *scrbuf, sysarg_t col, sysarg_t row)
    12792{
    12893        return ((scrbuf->cursor_visible) && (scrbuf->col == col) &&
     
    13095}
    13196
    132 sysarg_t screenbuffer_get_top_row(screenbuffer_t *scrbuf)
     97sysarg_t chargrid_get_top_row(chargrid_t *scrbuf)
    13398{
    13499        return scrbuf->top_row;
    135100}
    136101
    137 static sysarg_t screenbuffer_update_rows(screenbuffer_t *scrbuf)
     102static sysarg_t chargrid_update_rows(chargrid_t *scrbuf)
    138103{
    139104        if (scrbuf->row == scrbuf->rows) {
    140105                scrbuf->row = scrbuf->rows - 1;
    141106                scrbuf->top_row = (scrbuf->top_row + 1) % scrbuf->rows;
    142                 screenbuffer_clear_row(scrbuf, scrbuf->row);
     107                chargrid_clear_row(scrbuf, scrbuf->row);
    143108               
    144109                return scrbuf->rows;
     
    148113}
    149114
    150 static sysarg_t screenbuffer_update_cols(screenbuffer_t *scrbuf)
     115static sysarg_t chargrid_update_cols(chargrid_t *scrbuf)
    151116{
    152117        /* Column overflow */
     
    154119                scrbuf->col = 0;
    155120                scrbuf->row++;
    156                 return screenbuffer_update_rows(scrbuf);
     121                return chargrid_update_rows(scrbuf);
    157122        }
    158123       
     
    160125}
    161126
    162 /** Store one character to screenbuffer.
     127/** Store one character to chargrid.
    163128 *
    164129 * Its position is determined by scrbuf->col
    165130 * and scrbuf->row.
    166131 *
    167  * @param scrbuf Screenbuffer.
     132 * @param scrbuf Chargrid.
    168133 * @param ch     Character to store.
    169134 * @param update Update coordinates.
     
    174139 *
    175140 */
    176 sysarg_t screenbuffer_putchar(screenbuffer_t *scrbuf, wchar_t ch, bool update)
     141sysarg_t chargrid_putchar(chargrid_t *scrbuf, wchar_t ch, bool update)
    177142{
    178143        assert(scrbuf->col < scrbuf->cols);
     
    180145       
    181146        charfield_t *field =
    182             screenbuffer_field_at(scrbuf, scrbuf->col, scrbuf->row);
     147            chargrid_charfield_at(scrbuf, scrbuf->col, scrbuf->row);
    183148       
    184149        field->ch = ch;
     
    188153        if (update) {
    189154                scrbuf->col++;
    190                 return screenbuffer_update_cols(scrbuf);
     155                return chargrid_update_cols(scrbuf);
    191156        }
    192157       
     
    194159}
    195160
    196 /** Jump to a new row in screenbuffer.
    197  *
    198  * @param scrbuf Screenbuffer.
     161/** Jump to a new row in chargrid.
     162 *
     163 * @param scrbuf Chargrid.
    199164 *
    200165 * @return Number of rows which have been affected. In usual
     
    203168 *
    204169 */
    205 sysarg_t screenbuffer_newline(screenbuffer_t *scrbuf)
     170sysarg_t chargrid_newline(chargrid_t *scrbuf)
    206171{
    207172        assert(scrbuf->col < scrbuf->cols);
     
    211176        scrbuf->row++;
    212177       
    213         return screenbuffer_update_rows(scrbuf);
    214 }
    215 
    216 /** Jump to a new row in screenbuffer.
    217  *
    218  * @param scrbuf   Screenbuffer.
     178        return chargrid_update_rows(scrbuf);
     179}
     180
     181/** Jump to a new row in chargrid.
     182 *
     183 * @param scrbuf   Chargrid.
    219184 * @param tab_size Tab size.
    220185 *
     
    224189 *
    225190 */
    226 sysarg_t screenbuffer_tabstop(screenbuffer_t *scrbuf, sysarg_t tab_size)
     191sysarg_t chargrid_tabstop(chargrid_t *scrbuf, sysarg_t tab_size)
    227192{
    228193        assert(scrbuf->col < scrbuf->cols);
     
    233198       
    234199        for (sysarg_t i = 0; i < spaces; i++)
    235                 flush += screenbuffer_putchar(scrbuf, ' ', true) - 1;
     200                flush += chargrid_putchar(scrbuf, ' ', true) - 1;
    236201       
    237202        return flush;
    238203}
    239204
    240 /** Jump to the previous character in screenbuffer.
     205/** Jump to the previous character in chargrid.
    241206 *
    242207 * Currently no scrollback is supported.
    243208 *
    244  * @param scrbuf Screenbuffer.
     209 * @param scrbuf Chargrid.
    245210 *
    246211 * @return Number of rows which have been affected. In usual
     
    250215 *
    251216 */
    252 sysarg_t screenbuffer_backspace(screenbuffer_t *scrbuf)
     217sysarg_t chargrid_backspace(chargrid_t *scrbuf)
    253218{
    254219        assert(scrbuf->col < scrbuf->cols);
     
    262227                scrbuf->row--;
    263228               
    264                 screenbuffer_putchar(scrbuf, ' ', false);
     229                chargrid_putchar(scrbuf, ' ', false);
    265230                return 2;
    266231        }
    267232       
    268233        scrbuf->col--;
    269         screenbuffer_putchar(scrbuf, ' ', false);
     234        chargrid_putchar(scrbuf, ' ', false);
    270235        return 1;
    271236}
    272237
    273 /** Clear the screenbuffer.
    274  *
    275  * @param scrbuf Screenbuffer.
    276  *
    277  */
    278 void screenbuffer_clear(screenbuffer_t *scrbuf)
     238/** Clear the chargrid.
     239 *
     240 * @param scrbuf Chargrid.
     241 *
     242 */
     243void chargrid_clear(chargrid_t *scrbuf)
    279244{
    280245        for (size_t pos = 0; pos < (scrbuf->cols * scrbuf->rows); pos++) {
     
    288253}
    289254
    290 /** Update current screenbuffer coordinates
    291  *
    292  * @param scrbuf Screenbuffer.
     255/** Update current chargrid coordinates
     256 *
     257 * @param scrbuf Chargrid.
    293258 * @param col    New column.
    294259 * @param row    New row.
    295260 *
    296261 */
    297 void screenbuffer_set_cursor(screenbuffer_t *scrbuf, sysarg_t col, sysarg_t row)
     262void chargrid_set_cursor(chargrid_t *scrbuf, sysarg_t col, sysarg_t row)
    298263{
    299264        scrbuf->col = col;
     
    301266}
    302267
    303 void screenbuffer_set_cursor_visibility(screenbuffer_t *scrbuf, bool visible)
     268void chargrid_set_cursor_visibility(chargrid_t *scrbuf, bool visible)
    304269{
    305270        scrbuf->cursor_visible = visible;
    306271}
    307272
    308 /** Get current screenbuffer coordinates
    309  *
    310  * @param scrbuf Screenbuffer.
     273/** Get current chargrid coordinates
     274 *
     275 * @param scrbuf Chargrid.
    311276 * @param col    Column.
    312277 * @param row    Row.
    313278 *
    314279 */
    315 void screenbuffer_get_cursor(screenbuffer_t *scrbuf, sysarg_t *col,
     280void chargrid_get_cursor(chargrid_t *scrbuf, sysarg_t *col,
    316281    sysarg_t *row)
    317282{
     
    323288}
    324289
    325 bool screenbuffer_get_cursor_visibility(screenbuffer_t *scrbuf)
     290bool chargrid_get_cursor_visibility(chargrid_t *scrbuf)
    326291{
    327292        return scrbuf->cursor_visible;
     
    330295/** Clear one buffer row.
    331296 *
    332  * @param scrbuf Screenbuffer.
     297 * @param scrbuf Chargrid.
    333298 * @param row    Row to clear.
    334299 *
    335300 */
    336 void screenbuffer_clear_row(screenbuffer_t *scrbuf, sysarg_t row)
     301void chargrid_clear_row(chargrid_t *scrbuf, sysarg_t row)
    337302{
    338303        for (sysarg_t col = 0; col < scrbuf->cols; col++) {
    339304                charfield_t *field =
    340                     screenbuffer_field_at(scrbuf, col, row);
     305                    chargrid_charfield_at(scrbuf, col, row);
    341306               
    342307                field->ch = 0;
     
    346311}
    347312
    348 /** Set screenbuffer style.
    349  *
    350  * @param scrbuf Screenbuffer.
     313/** Set chargrid style.
     314 *
     315 * @param scrbuf Chargrid.
    351316 * @param style  Style.
    352317 *
    353318 */
    354 void screenbuffer_set_style(screenbuffer_t *scrbuf, console_style_t style)
     319void chargrid_set_style(chargrid_t *scrbuf, console_style_t style)
    355320{
    356321        scrbuf->attrs.type = CHAR_ATTR_STYLE;
     
    358323}
    359324
    360 /** Set screenbuffer color.
    361  *
    362  * @param scrbuf  Screenbuffer.
     325/** Set chargrid color.
     326 *
     327 * @param scrbuf  Chargrid.
    363328 * @param bgcolor Background color.
    364329 * @param fgcolor Foreground color.
     
    366331 *
    367332 */
    368 void screenbuffer_set_color(screenbuffer_t *scrbuf, console_color_t bgcolor,
     333void chargrid_set_color(chargrid_t *scrbuf, console_color_t bgcolor,
    369334    console_color_t fgcolor, console_color_attr_t attr)
    370335{
     
    375340}
    376341
    377 /** Set screenbuffer RGB color.
    378  *
    379  * @param scrbuf  Screenbuffer.
     342/** Set chargrid RGB color.
     343 *
     344 * @param scrbuf  Chargrid.
    380345 * @param bgcolor Background color.
    381346 * @param fgcolor Foreground color.
    382347 *
    383348 */
    384 void screenbuffer_set_rgb_color(screenbuffer_t *scrbuf, pixel_t bgcolor,
     349void chargrid_set_rgb_color(chargrid_t *scrbuf, pixel_t bgcolor,
    385350    pixel_t fgcolor)
    386351{
  • uspace/lib/c/generic/io/console.c

    re0d5bc5 r96e01fbc  
    3838#include <async.h>
    3939#include <errno.h>
    40 #include <stdio.h>
    4140#include <malloc.h>
    4241#include <vfs/vfs_sess.h>
     
    126125{
    127126        async_exch_t *exch = async_exchange_begin(ctrl->output_sess);
    128         async_req_1_0(exch, CONSOLE_CURSOR_VISIBILITY, (show != false));
     127        async_req_1_0(exch, CONSOLE_SET_CURSOR_VISIBILITY, (show != false));
    129128        async_exchange_end(exch);
    130129}
     
    151150{
    152151        async_exch_t *exch = async_exchange_begin(ctrl->output_sess);
    153         async_req_2_0(exch, CONSOLE_GOTO, col, row);
     152        async_req_2_0(exch, CONSOLE_SET_POS, col, row);
    154153        async_exchange_end(exch);
    155154}
  • uspace/lib/c/generic/ipc.c

    re0d5bc5 r96e01fbc  
    4848#include <fibril.h>
    4949#include <macros.h>
    50 #include "private/libc.h"
    5150
    5251/**
     
    8382
    8483static atomic_t ipc_futex = FUTEX_INITIALIZER;
    85 
    86 /** Fast synchronous call.
    87  *
    88  * Only three payload arguments can be passed using this function. However,
    89  * this function is faster than the generic ipc_call_sync_slow() because
    90  * the payload is passed directly in registers.
    91  *
    92  * @param phoneid Phone handle for the call.
    93  * @param method  Requested method.
    94  * @param arg1    Service-defined payload argument.
    95  * @param arg2    Service-defined payload argument.
    96  * @param arg3    Service-defined payload argument.
    97  * @param result1 If non-NULL, the return ARG1 will be stored there.
    98  * @param result2 If non-NULL, the return ARG2 will be stored there.
    99  * @param result3 If non-NULL, the return ARG3 will be stored there.
    100  * @param result4 If non-NULL, the return ARG4 will be stored there.
    101  * @param result5 If non-NULL, the return ARG5 will be stored there.
    102  *
    103  * @return Negative values representing IPC errors.
    104  * @return Otherwise the RETVAL of the answer.
    105  *
    106  */
    107 int ipc_call_sync_fast(int phoneid, sysarg_t method, sysarg_t arg1,
    108     sysarg_t arg2, sysarg_t arg3, sysarg_t *result1, sysarg_t *result2,
    109     sysarg_t *result3, sysarg_t *result4, sysarg_t *result5)
    110 {
    111         ipc_call_t resdata;
    112         int callres = __SYSCALL6(SYS_IPC_CALL_SYNC_FAST, phoneid, method, arg1,
    113             arg2, arg3, (sysarg_t) &resdata);
    114         if (callres)
    115                 return callres;
    116        
    117         if (result1)
    118                 *result1 = IPC_GET_ARG1(resdata);
    119         if (result2)
    120                 *result2 = IPC_GET_ARG2(resdata);
    121         if (result3)
    122                 *result3 = IPC_GET_ARG3(resdata);
    123         if (result4)
    124                 *result4 = IPC_GET_ARG4(resdata);
    125         if (result5)
    126                 *result5 = IPC_GET_ARG5(resdata);
    127        
    128         return IPC_GET_RETVAL(resdata);
    129 }
    130 
    131 /** Synchronous call transmitting 5 arguments of payload.
    132  *
    133  * @param phoneid Phone handle for the call.
    134  * @param imethod Requested interface and method.
    135  * @param arg1    Service-defined payload argument.
    136  * @param arg2    Service-defined payload argument.
    137  * @param arg3    Service-defined payload argument.
    138  * @param arg4    Service-defined payload argument.
    139  * @param arg5    Service-defined payload argument.
    140  * @param result1 If non-NULL, storage for the first return argument.
    141  * @param result2 If non-NULL, storage for the second return argument.
    142  * @param result3 If non-NULL, storage for the third return argument.
    143  * @param result4 If non-NULL, storage for the fourth return argument.
    144  * @param result5 If non-NULL, storage for the fifth return argument.
    145  *
    146  * @return Negative values representing IPC errors.
    147  * @return Otherwise the RETVAL of the answer.
    148  *
    149  */
    150 int ipc_call_sync_slow(int phoneid, sysarg_t imethod, sysarg_t arg1,
    151     sysarg_t arg2, sysarg_t arg3, sysarg_t arg4, sysarg_t arg5,
    152     sysarg_t *result1, sysarg_t *result2, sysarg_t *result3, sysarg_t *result4,
    153     sysarg_t *result5)
    154 {
    155         ipc_call_t data;
    156        
    157         IPC_SET_IMETHOD(data, imethod);
    158         IPC_SET_ARG1(data, arg1);
    159         IPC_SET_ARG2(data, arg2);
    160         IPC_SET_ARG3(data, arg3);
    161         IPC_SET_ARG4(data, arg4);
    162         IPC_SET_ARG5(data, arg5);
    163        
    164         int callres = __SYSCALL3(SYS_IPC_CALL_SYNC_SLOW, phoneid,
    165             (sysarg_t) &data, (sysarg_t) &data);
    166         if (callres)
    167                 return callres;
    168        
    169         if (result1)
    170                 *result1 = IPC_GET_ARG1(data);
    171         if (result2)
    172                 *result2 = IPC_GET_ARG2(data);
    173         if (result3)
    174                 *result3 = IPC_GET_ARG3(data);
    175         if (result4)
    176                 *result4 = IPC_GET_ARG4(data);
    177         if (result5)
    178                 *result5 = IPC_GET_ARG5(data);
    179        
    180         return IPC_GET_RETVAL(data);
    181 }
    18284
    18385/** Send asynchronous message via syscall.
     
    611513}
    612514
    613 /** Request callback connection.
    614  *
    615  * The @a task_id and @a phonehash identifiers returned
    616  * by the kernel can be used for connection tracking.
    617  *
    618  * @param phoneid   Phone handle used for contacting the other side.
    619  * @param arg1      User defined argument.
    620  * @param arg2      User defined argument.
    621  * @param arg3      User defined argument.
    622  * @param task_id   Identifier of the client task.
    623  * @param phonehash Opaque identifier of the phone that will
    624  *                  be used for incoming calls.
    625  *
    626  * @return Zero on success or a negative error code.
    627  *
    628  */
    629 int ipc_connect_to_me(int phoneid, sysarg_t arg1, sysarg_t arg2, sysarg_t arg3,
    630     task_id_t *task_id, sysarg_t *phonehash)
    631 {
    632         ipc_call_t data;
    633         int rc = __SYSCALL6(SYS_IPC_CALL_SYNC_FAST, phoneid,
    634             IPC_M_CONNECT_TO_ME, arg1, arg2, arg3, (sysarg_t) &data);
    635         if (rc == EOK) {
    636                 *task_id = data.in_task_id;
    637                 *phonehash = IPC_GET_ARG5(data);
    638         }       
    639         return rc;
    640 }
    641 
    642 /** Request cloned connection.
    643  *
    644  * @param phoneid Phone handle used for contacting the other side.
    645  *
    646  * @return Cloned phone handle on success or a negative error code.
    647  *
    648  */
    649 int ipc_clone_establish(int phoneid)
    650 {
    651         sysarg_t newphid;
    652         int res = ipc_call_sync_0_5(phoneid, IPC_M_CLONE_ESTABLISH, NULL,
    653             NULL, NULL, NULL, &newphid);
    654         if (res)
    655                 return res;
    656        
    657         return newphid;
    658 }
    659 
    660 /** Request new connection.
    661  *
    662  * @param phoneid Phone handle used for contacting the other side.
    663  * @param arg1    User defined argument.
    664  * @param arg2    User defined argument.
    665  * @param arg3    User defined argument.
    666  *
    667  * @return New phone handle on success or a negative error code.
    668  *
    669  */
    670 int ipc_connect_me_to(int phoneid, sysarg_t arg1, sysarg_t arg2, sysarg_t arg3)
    671 {
    672         sysarg_t newphid;
    673         int res = ipc_call_sync_3_5(phoneid, IPC_M_CONNECT_ME_TO, arg1, arg2, arg3,
    674             NULL, NULL, NULL, NULL, &newphid);
    675         if (res)
    676                 return res;
    677        
    678         return newphid;
    679 }
    680 
    681 /** Request new connection (blocking)
    682  *
    683  * If the connection is not available at the moment, the
    684  * call should block. This has to be, however, implemented
    685  * on the server side.
    686  *
    687  * @param phoneid Phone handle used for contacting the other side.
    688  * @param arg1    User defined argument.
    689  * @param arg2    User defined argument.
    690  * @param arg3    User defined argument.
    691  *
    692  * @return New phone handle on success or a negative error code.
    693  *
    694  */
    695 int ipc_connect_me_to_blocking(int phoneid, sysarg_t arg1, sysarg_t arg2,
    696     sysarg_t arg3)
    697 {
    698         sysarg_t newphid;
    699         int res = ipc_call_sync_4_5(phoneid, IPC_M_CONNECT_ME_TO, arg1, arg2, arg3,
    700             IPC_FLAG_BLOCKING, NULL, NULL, NULL, NULL, &newphid);
    701         if (res)
    702                 return res;
    703        
    704         return newphid;
    705 }
    706 
    707515/** Hang up a phone.
    708516 *
     
    758566}
    759567
    760 /** Wrapper for IPC_M_SHARE_IN calls.
    761  *
    762  * @param phoneid Phone that will be used to contact the receiving side.
    763  * @param size    Size of the destination address space area.
    764  * @param arg     User defined argument.
    765  * @param flags   Storage for received flags. Can be NULL.
    766  * @param dst     Destination address space area base. Cannot be NULL.
    767  *
    768  * @return Zero on success or a negative error code from errno.h.
    769  *
    770  */
    771 int ipc_share_in_start(int phoneid, size_t size, sysarg_t arg,
    772     unsigned int *flags, void **dst)
    773 {
    774         sysarg_t _flags = 0;
    775         sysarg_t _dst = (sysarg_t) -1;
    776         int res = ipc_call_sync_2_4(phoneid, IPC_M_SHARE_IN, (sysarg_t) size,
    777             arg, NULL, &_flags, NULL, &_dst);
    778        
    779         if (flags)
    780                 *flags = (unsigned int) _flags;
    781        
    782         *dst = (void *) _dst;
    783         return res;
    784 }
    785 
    786 /** Wrapper for answering the IPC_M_SHARE_IN calls.
    787  *
    788  * This wrapper only makes it more comfortable to answer IPC_M_SHARE_IN
    789  * calls so that the user doesn't have to remember the meaning of each
    790  * IPC argument.
    791  *
    792  * @param callid Hash of the IPC_M_DATA_READ call to answer.
    793  * @param src    Source address space base.
    794  * @param flags Flags to be used for sharing. Bits can be only cleared.
    795  *
    796  * @return Zero on success or a value from @ref errno.h on failure.
    797  *
    798  */
    799 int ipc_share_in_finalize(ipc_callid_t callid, void *src, unsigned int flags)
    800 {
    801         return ipc_answer_3(callid, EOK, (sysarg_t) src, (sysarg_t) flags,
    802             (sysarg_t) __entry);
    803 }
    804 
    805 /** Wrapper for IPC_M_SHARE_OUT calls.
    806  *
    807  * @param phoneid Phone that will be used to contact the receiving side.
    808  * @param src     Source address space area base address.
    809  * @param flags   Flags to be used for sharing. Bits can be only cleared.
    810  *
    811  * @return Zero on success or a negative error code from errno.h.
    812  *
    813  */
    814 int ipc_share_out_start(int phoneid, void *src, unsigned int flags)
    815 {
    816         return ipc_call_sync_3_0(phoneid, IPC_M_SHARE_OUT, (sysarg_t) src, 0,
    817             (sysarg_t) flags);
    818 }
    819 
    820 /** Wrapper for answering the IPC_M_SHARE_OUT calls.
    821  *
    822  * This wrapper only makes it more comfortable to answer IPC_M_SHARE_OUT
    823  * calls so that the user doesn't have to remember the meaning of each
    824  * IPC argument.
    825  *
    826  * @param callid Hash of the IPC_M_DATA_WRITE call to answer.
    827  * @param dst    Destination address space area base address.
    828  *
    829  * @return Zero on success or a value from @ref errno.h on failure.
    830  *
    831  */
    832 int ipc_share_out_finalize(ipc_callid_t callid, void **dst)
    833 {
    834         return ipc_answer_2(callid, EOK, (sysarg_t) __entry, (sysarg_t) dst);
    835 }
    836 
    837 /** Wrapper for IPC_M_DATA_READ calls.
    838  *
    839  * @param phoneid Phone that will be used to contact the receiving side.
    840  * @param dst     Address of the beginning of the destination buffer.
    841  * @param size    Size of the destination buffer.
    842  *
    843  * @return Zero on success or a negative error code from errno.h.
    844  *
    845  */
    846 int ipc_data_read_start(int phoneid, void *dst, size_t size)
    847 {
    848         return ipc_call_sync_2_0(phoneid, IPC_M_DATA_READ, (sysarg_t) dst,
    849             (sysarg_t) size);
    850 }
    851 
    852 /** Wrapper for answering the IPC_M_DATA_READ calls.
    853  *
    854  * This wrapper only makes it more comfortable to answer IPC_M_DATA_READ
    855  * calls so that the user doesn't have to remember the meaning of each
    856  * IPC argument.
    857  *
    858  * @param callid Hash of the IPC_M_DATA_READ call to answer.
    859  * @param src    Source address for the IPC_M_DATA_READ call.
    860  * @param size   Size for the IPC_M_DATA_READ call. Can be smaller than
    861  *               the maximum size announced by the sender.
    862  *
    863  * @return Zero on success or a value from @ref errno.h on failure.
    864  *
    865  */
    866 int ipc_data_read_finalize(ipc_callid_t callid, const void *src, size_t size)
    867 {
    868         return ipc_answer_2(callid, EOK, (sysarg_t) src, (sysarg_t) size);
    869 }
    870 
    871 /** Wrapper for IPC_M_DATA_WRITE calls.
    872  *
    873  * @param phoneid Phone that will be used to contact the receiving side.
    874  * @param src     Address of the beginning of the source buffer.
    875  * @param size    Size of the source buffer.
    876  *
    877  * @return Zero on success or a negative error code from errno.h.
    878  *
    879  */
    880 int ipc_data_write_start(int phoneid, const void *src, size_t size)
    881 {
    882         return ipc_call_sync_2_0(phoneid, IPC_M_DATA_WRITE, (sysarg_t) src,
    883             (sysarg_t) size);
    884 }
    885 
    886 /** Wrapper for answering the IPC_M_DATA_WRITE calls.
    887  *
    888  * This wrapper only makes it more comfortable to answer IPC_M_DATA_WRITE
    889  * calls so that the user doesn't have to remember the meaning of each
    890  * IPC argument.
    891  *
    892  * @param callid Hash of the IPC_M_DATA_WRITE call to answer.
    893  * @param dst    Final destination address for the IPC_M_DATA_WRITE call.
    894  * @param size   Final size for the IPC_M_DATA_WRITE call.
    895  *
    896  * @return Zero on success or a value from @ref errno.h on failure.
    897  *
    898  */
    899 int ipc_data_write_finalize(ipc_callid_t callid, void *dst, size_t size)
    900 {
    901         return ipc_answer_2(callid, EOK, (sysarg_t) dst, (sysarg_t) size);
    902 }
    903 
    904568/** Connect to a task specified by id.
    905569 *
  • uspace/lib/c/generic/iplink_srv.c

    re0d5bc5 r96e01fbc  
    139139                if (!method) {
    140140                        /* The other side has hung up */
     141                        fibril_mutex_lock(&srv->lock);
     142                        srv->connected = false;
     143                        fibril_mutex_unlock(&srv->lock);
    141144                        async_answer_0(callid, EOK);
    142145                        break;
  • uspace/lib/c/generic/malloc.c

    re0d5bc5 r96e01fbc  
    109109        (((uintptr_t) (area)->end) - sizeof(heap_block_foot_t))
    110110
     111#define AREA_LAST_BLOCK_HEAD(area) \
     112        ((uintptr_t) BLOCK_HEAD(((heap_block_foot_t *) AREA_LAST_BLOCK_FOOT(area))))
     113
    111114/** Get header in heap block.
    112115 *
     
    346349                return false;
    347350       
    348         /* Add new free block */
    349         size_t net_size = (size_t) (end - area->end);
    350         if (net_size > 0)
    351                 block_init(area->end, net_size, true, area);
     351        heap_block_head_t *last_head =
     352            (heap_block_head_t *) AREA_LAST_BLOCK_HEAD(area);
     353       
     354        if (last_head->free) {
     355                /* Add the new space to the last block. */
     356                size_t net_size = (size_t) (end - area->end) + last_head->size;
     357                malloc_assert(net_size > 0);
     358                block_init(last_head, net_size, true, area);
     359        } else {
     360                /* Add new free block */
     361                size_t net_size = (size_t) (end - area->end);
     362                if (net_size > 0)
     363                        block_init(area->end, net_size, true, area);
     364        }
    352365       
    353366        /* Update heap area parameters */
     
    355368       
    356369        return true;
    357 }
    358 
    359 /** Try to enlarge any of the heap areas
    360  *
    361  * Should be called only inside the critical section.
    362  *
    363  * @param size Gross size of item to allocate (bytes).
    364  *
    365  */
    366 static bool heap_grow(size_t size)
    367 {
    368         if (size == 0)
    369                 return true;
    370        
    371         /* First try to enlarge some existing area */
    372         for (heap_area_t *area = first_heap_area; area != NULL;
    373             area = area->next) {
    374                 if (area_grow(area, size))
    375                         return true;
    376         }
    377        
    378         /* Eventually try to create a new area */
    379         return area_create(AREA_OVERHEAD(size));
    380370}
    381371
     
    661651}
    662652
     653/** Try to enlarge any of the heap areas.
     654 *
     655 * If successful, allocate block of the given size in the area.
     656 * Should be called only inside the critical section.
     657 *
     658 * @param size  Gross size of item to allocate (bytes).
     659 * @param align Memory address alignment.
     660 *
     661 * @return Allocated block.
     662 * @return NULL on failure.
     663 *
     664 */
     665static void *heap_grow_and_alloc(size_t size, size_t align)
     666{
     667        if (size == 0)
     668                return NULL;
     669       
     670        /* First try to enlarge some existing area */
     671        for (heap_area_t *area = first_heap_area; area != NULL;
     672            area = area->next) {
     673               
     674                if (area_grow(area, size + align)) {
     675                        heap_block_head_t *first =
     676                            (heap_block_head_t *) AREA_LAST_BLOCK_HEAD(area);
     677                       
     678                        void *addr =
     679                            malloc_area(area, first, NULL, size, align);
     680                        malloc_assert(addr != NULL);
     681                        return addr;
     682                }
     683        }
     684       
     685        /* Eventually try to create a new area */
     686        if (area_create(AREA_OVERHEAD(size + align))) {
     687                heap_block_head_t *first =
     688                    (heap_block_head_t *) AREA_FIRST_BLOCK_HEAD(last_heap_area);
     689               
     690                void *addr =
     691                    malloc_area(last_heap_area, first, NULL, size, align);
     692                malloc_assert(addr != NULL);
     693                return addr;
     694        }
     695       
     696        return NULL;
     697}
     698
    663699/** Allocate a memory block
    664700 *
     
    679715       
    680716        size_t falign = lcm(align, BASE_ALIGN);
    681         size_t real_size = GROSS_SIZE(ALIGN_UP(size, falign));
    682        
    683         bool retry = false;
    684         heap_block_head_t *split;
    685        
    686 loop:
     717       
     718        /* Check for integer overflow. */
     719        if (falign < align)
     720                return NULL;
     721       
     722        /*
     723         * The size of the allocated block needs to be naturally
     724         * aligned, because the footer structure also needs to reside
     725         * on a naturally aligned address in order to avoid unaligned
     726         * memory accesses.
     727         */
     728        size_t gross_size = GROSS_SIZE(ALIGN_UP(size, BASE_ALIGN));
    687729       
    688730        /* Try the next fit approach */
    689         split = next_fit;
     731        heap_block_head_t *split = next_fit;
    690732       
    691733        if (split != NULL) {
    692                 void *addr = malloc_area(split->area, split, NULL, real_size,
     734                void *addr = malloc_area(split->area, split, NULL, gross_size,
    693735                    falign);
    694736               
     
    703745                    AREA_FIRST_BLOCK_HEAD(area);
    704746               
    705                 void *addr = malloc_area(area, first, split, real_size,
     747                void *addr = malloc_area(area, first, split, gross_size,
    706748                    falign);
    707749               
     
    710752        }
    711753       
    712         if (!retry) {
    713                 /* Try to grow the heap space */
    714                 if (heap_grow(real_size)) {
    715                         retry = true;
    716                         goto loop;
    717                 }
    718         }
    719        
    720         return NULL;
     754        /* Finally, try to grow heap space and allocate in the new area. */
     755        return heap_grow_and_alloc(gross_size, falign);
    721756}
    722757
     
    731766void *calloc(const size_t nmemb, const size_t size)
    732767{
     768        // FIXME: Check for overflow
     769       
    733770        void *block = malloc(nmemb * size);
    734771        if (block == NULL)
     
    870907        if (addr == NULL)
    871908                return;
    872 
     909       
    873910        futex_down(&malloc_futex);
    874911       
  • uspace/lib/c/generic/str.c

    re0d5bc5 r96e01fbc  
    136136}
    137137
     138/** Decode a single character from a string to the left.
     139 *
     140 * Decode a single character from a string of size @a size. Decoding starts
     141 * at @a offset and this offset is moved to the beginning of the previous
     142 * character. In case of decoding error, offset generally decreases at least
     143 * by one. However, offset is never moved before 0.
     144 *
     145 * @param str    String (not necessarily NULL-terminated).
     146 * @param offset Byte offset in string where to start decoding.
     147 * @param size   Size of the string (in bytes).
     148 *
     149 * @return Value of decoded character, U_SPECIAL on decoding error or
     150 *         NULL if attempt to decode beyond @a start of str.
     151 *
     152 */
     153wchar_t str_decode_reverse(const char *str, size_t *offset, size_t size)
     154{
     155        if (*offset == 0)
     156                return 0;
     157       
     158        size_t processed = 0;
     159        /* Continue while continuation bytes found */
     160        while (*offset > 0 && processed < 4) {
     161                uint8_t b = (uint8_t) str[--(*offset)];
     162               
     163                if (processed == 0 && (b & 0x80) == 0) {
     164                        /* 0xxxxxxx (Plain ASCII) */
     165                        return b & 0x7f;
     166                }
     167                else if ((b & 0xe0) == 0xc0 || (b & 0xf0) == 0xe0 ||
     168                    (b & 0xf8) == 0xf0) {
     169                        /* Start byte */
     170                        size_t start_offset = *offset;
     171                        return str_decode(str, &start_offset, size);
     172                }
     173                else if ((b & 0xc0) != 0x80) {
     174                        /* Not a continuation byte */
     175                        return U_SPECIAL;
     176                }
     177                processed++;
     178        }
     179        /* Too many continuation bytes */
     180        return U_SPECIAL;
     181}
     182
    138183/** Encode a single character to string representation.
    139184 *
     
    399444}
    400445
     446/** Get character display width on a character cell display.
     447 *
     448 * @param ch    Character
     449 * @return      Width of character in cells.
     450 */
     451size_t chr_width(wchar_t ch)
     452{
     453        return 1;
     454}
     455
     456/** Get string display width on a character cell display.
     457 *
     458 * @param str   String
     459 * @return      Width of string in cells.
     460 */
     461size_t str_width(const char *str)
     462{
     463        size_t width = 0;
     464        size_t offset = 0;
     465        wchar_t ch;
     466       
     467        while ((ch = str_decode(str, &offset, STR_NO_LIMIT)) != 0)
     468                width += chr_width(ch);
     469       
     470        return width;
     471}
     472
    401473/** Check whether character is plain ASCII.
    402474 *
     
    428500 *
    429501 * Do a char-by-char comparison of two NULL-terminated strings.
    430  * The strings are considered equal iff they consist of the same
    431  * characters on the minimum of their lengths.
     502 * The strings are considered equal iff their length is equal
     503 * and both strings consist of the same sequence of characters.
     504 *
     505 * A string S1 is less than another string S2 if it has a character with
     506 * lower value at the first character position where the strings differ.
     507 * If the strings differ in length, the shorter one is treated as if
     508 * padded by characters with a value of zero.
    432509 *
    433510 * @param s1 First string to compare.
    434511 * @param s2 Second string to compare.
    435512 *
    436  * @return 0 if the strings are equal, -1 if first is smaller,
    437  *         1 if second smaller.
     513 * @return 0 if the strings are equal, -1 if the first is less than the second,
     514 *         1 if the second is less than the first.
    438515 *
    439516 */
     
    466543 *
    467544 * Do a char-by-char comparison of two NULL-terminated strings.
    468  * The strings are considered equal iff they consist of the same
    469  * characters on the minimum of their lengths and the length limit.
     545 * The strings are considered equal iff
     546 * min(str_length(s1), max_len) == min(str_length(s2), max_len)
     547 * and both strings consist of the same sequence of characters,
     548 * up to max_len characters.
     549 *
     550 * A string S1 is less than another string S2 if it has a character with
     551 * lower value at the first character position where the strings differ.
     552 * If the strings differ in length, the shorter one is treated as if
     553 * padded by characters with a value of zero. Only the first max_len
     554 * characters are considered.
    470555 *
    471556 * @param s1      First string to compare.
     
    473558 * @param max_len Maximum number of characters to consider.
    474559 *
    475  * @return 0 if the strings are equal, -1 if first is smaller,
    476  *         1 if second smaller.
     560 * @return 0 if the strings are equal, -1 if the first is less than the second,
     561 *         1 if the second is less than the first.
    477562 *
    478563 */
     
    508593        return 0;
    509594
     595}
     596
     597/** Test whether p is a prefix of s.
     598 *
     599 * Do a char-by-char comparison of two NULL-terminated strings
     600 * and determine if p is a prefix of s.
     601 *
     602 * @param s The string in which to look
     603 * @param p The string to check if it is a prefix of s
     604 *
     605 * @return true iff p is prefix of s else false
     606 *
     607 */
     608bool str_test_prefix(const char *s, const char *p)
     609{
     610        wchar_t c1 = 0;
     611        wchar_t c2 = 0;
     612       
     613        size_t off1 = 0;
     614        size_t off2 = 0;
     615
     616        while (true) {
     617                c1 = str_decode(s, &off1, STR_NO_LIMIT);
     618                c2 = str_decode(p, &off2, STR_NO_LIMIT);
     619               
     620                if (c2 == 0)
     621                        return true;
     622
     623                if (c1 != c2)
     624                        return false;
     625               
     626                if (c1 == 0)
     627                        break;
     628        }
     629
     630        return false;
    510631}
    511632
     
    10851206                c = (c >= 'a' ? c - 'a' + 10 : (c >= 'A' ? c - 'A' + 10 :
    10861207                    (c <= '9' ? c - '0' : 0xff)));
    1087                 if (c > base) {
     1208                if (c >= base) {
    10881209                        break;
    10891210                }
  • uspace/lib/c/generic/task.c

    re0d5bc5 r96e01fbc  
    201201 *
    202202 * This is really just a convenience wrapper over the more complicated
     203 * loader API. Arguments are passed in a va_list.
     204 *
     205 * @param id   If not NULL, the ID of the task is stored here on success.
     206 * @param path Pathname of the binary to execute.
     207 * @param cnt  Number of arguments.
     208 * @param ap   Command-line arguments.
     209 *
     210 * @return Zero on success or negative error code.
     211 *
     212 */
     213int task_spawn(task_id_t *task_id, const char *path, int cnt, va_list ap)
     214{
     215        /* Allocate argument list. */
     216        const char **arglist = malloc(cnt * sizeof(const char *));
     217        if (arglist == NULL)
     218                return ENOMEM;
     219       
     220        /* Fill in arguments. */
     221        const char *arg;
     222        cnt = 0;
     223        do {
     224                arg = va_arg(ap, const char *);
     225                arglist[cnt++] = arg;
     226        } while (arg != NULL);
     227       
     228        /* Spawn task. */
     229        int rc = task_spawnv(task_id, path, arglist);
     230       
     231        /* Free argument list. */
     232        free(arglist);
     233        return rc;
     234}
     235
     236/** Create a new task by running an executable from the filesystem.
     237 *
     238 * This is really just a convenience wrapper over the more complicated
    203239 * loader API. Arguments are passed as a null-terminated list of arguments.
    204240 *
     
    216252        va_list ap;
    217253        const char *arg;
    218         const char **arglist;
    219254        int cnt = 0;
    220255       
     
    226261        va_end(ap);
    227262       
    228         /* Allocate argument list. */
    229         arglist = malloc(cnt * sizeof(const char *));
    230         if (arglist == NULL)
    231                 return ENOMEM;
    232        
    233         /* Fill in arguments. */
    234         cnt = 0;
    235263        va_start(ap, path);
    236         do {
    237                 arg = va_arg(ap, const char *);
    238                 arglist[cnt++] = arg;
    239         } while (arg != NULL);
     264        int rc = task_spawn(task_id, path, cnt, ap);
    240265        va_end(ap);
    241266       
    242         /* Spawn task. */
    243         int rc = task_spawnv(task_id, path, arglist);
    244        
    245         /* Free argument list. */
    246         free(arglist);
    247267        return rc;
    248268}
  • uspace/lib/c/generic/tls.c

    re0d5bc5 r96e01fbc  
    4242#include <str.h>
    4343#include <align.h>
     44#include <unistd.h>
    4445
    4546/** Create TLS (Thread Local Storage) data structures.
     
    5758       
    5859        tcb = __alloc_tls(&data, tls_size);
     60        if (!tcb)
     61                return NULL;
    5962       
    6063        /*
     
    8992
    9093        result = malloc(sizeof(tcb_t) + size);
     94        if (!result)
     95                return NULL;
    9196        *data = ((void *)result) + sizeof(tcb_t);
     97
    9298        return result;
    9399}
     
    118124        size = ALIGN_UP(size, &_tls_alignment);
    119125        *data = memalign((uintptr_t) &_tls_alignment, sizeof(tcb_t) + size);
    120 
     126        if (!*data)
     127                return NULL;
    121128        tcb = (tcb_t *) (*data + size);
    122129        tcb->self = tcb;
  • uspace/lib/c/include/io/charfield.h

    re0d5bc5 r96e01fbc  
    11/*
    22 * Copyright (c) 2006 Josef Cejka
     3 * Copyright (c) 2011 Petr Koupy
    34 * All rights reserved.
    45 *
     
    3334 */
    3435
    35 #ifndef IMGMAP_SCREENBUFFER_H__
    36 #define IMGMAP_SCREENBUFFER_H__
     36#ifndef LIBC_IO_CHARFIELD_H_
     37#define LIBC_IO_CHARFIELD_H_
    3738
    3839#include <sys/types.h>
     
    4041#include <io/color.h>
    4142#include <io/style.h>
    42 #include "fb.h"
     43#include <io/pixel.h>
    4344
    4445typedef enum {
    45         SCREENBUFFER_FLAG_NONE = 0,
    46         SCREENBUFFER_FLAG_SHARED = 1
    47 } screenbuffer_flag_t;
     46        CHAR_FLAG_NONE = 0,
     47        CHAR_FLAG_DIRTY = 1
     48} char_flags_t;
    4849
    4950typedef enum {
     
    5253        CHAR_ATTR_RGB
    5354} char_attr_type_t;
    54 
    55 typedef enum {
    56         CHAR_FLAG_NONE = 0,
    57         CHAR_FLAG_DIRTY = 1
    58 } char_flags_t;
    5955
    6056typedef struct {
     
    6561
    6662typedef struct {
    67         pixel_t bgcolor;  /**< Background color */
    68         pixel_t fgcolor;  /**< Foreground color */
     63        pixel_t bgcolor;
     64        pixel_t fgcolor;
    6965} char_attr_rgb_t;
    7066
     
    8076} char_attrs_t;
    8177
    82 /** One field on screen. It contain one character and its attributes. */
    8378typedef struct {
    84         wchar_t ch;          /**< Character itself */
    85         char_attrs_t attrs;  /**< Character attributes */
    86         char_flags_t flags;  /**< Character flags */
     79        wchar_t ch;
     80        char_attrs_t attrs;
     81        char_flags_t flags;
    8782} charfield_t;
    8883
    89 /** Compare two sets of attributes.
    90  *
    91  * @param a1 First attribute.
    92  * @param a2 Second attribute.
    93  *
    94  * @return True on equality
    95  *
    96  */
    9784static inline bool attrs_same(char_attrs_t a1, char_attrs_t a2)
    9885{
     
    115102}
    116103
    117 extern screenbuffer_t *screenbuffer_create(sysarg_t, sysarg_t,
    118     screenbuffer_flag_t);
    119 
    120 extern charfield_t *screenbuffer_field_at(screenbuffer_t *, sysarg_t, sysarg_t);
    121 extern bool screenbuffer_cursor_at(screenbuffer_t *, sysarg_t, sysarg_t);
    122 
    123 extern sysarg_t screenbuffer_get_top_row(screenbuffer_t *);
    124 
    125 extern sysarg_t screenbuffer_putchar(screenbuffer_t *, wchar_t, bool);
    126 extern sysarg_t screenbuffer_newline(screenbuffer_t *);
    127 extern sysarg_t screenbuffer_tabstop(screenbuffer_t *, sysarg_t);
    128 extern sysarg_t screenbuffer_backspace(screenbuffer_t *);
    129 
    130 extern void screenbuffer_clear(screenbuffer_t *);
    131 extern void screenbuffer_clear_row(screenbuffer_t *, sysarg_t);
    132 
    133 extern void screenbuffer_set_cursor(screenbuffer_t *, sysarg_t, sysarg_t);
    134 extern void screenbuffer_set_cursor_visibility(screenbuffer_t *, bool);
    135 extern bool screenbuffer_get_cursor_visibility(screenbuffer_t *);
    136 
    137 extern void screenbuffer_get_cursor(screenbuffer_t *, sysarg_t *, sysarg_t *);
    138 
    139 extern void screenbuffer_set_style(screenbuffer_t *, console_style_t);
    140 extern void screenbuffer_set_color(screenbuffer_t *, console_color_t,
    141     console_color_t, console_color_attr_t);
    142 extern void screenbuffer_set_rgb_color(screenbuffer_t *, pixel_t, pixel_t);
    143 
    144104#endif
    145105
  • uspace/lib/c/include/io/console.h

    re0d5bc5 r96e01fbc  
    3737
    3838#include <sys/time.h>
     39#include <io/concaps.h>
     40#include <io/kbd_event.h>
    3941#include <io/keycode.h>
    4042#include <async.h>
    4143#include <bool.h>
    4244#include <stdio.h>
    43 
    44 typedef enum {
    45         CONSOLE_CAP_NONE = 0,
    46         CONSOLE_CAP_STYLE = 1,
    47         CONSOLE_CAP_INDEXED = 2,
    48         CONSOLE_CAP_RGB = 4
    49 } console_caps_t;
    5045
    5146/** Console control structure. */
     
    6964        aid_t input_aid;
    7065} console_ctrl_t;
    71 
    72 typedef enum {
    73         KEY_PRESS,
    74         KEY_RELEASE
    75 } kbd_event_type_t;
    76 
    77 /** Console event structure. */
    78 typedef struct {
    79         /** List handle */
    80         link_t link;
    81        
    82         /** Press or release event. */
    83         kbd_event_type_t type;
    84        
    85         /** Keycode of the key that was pressed or released. */
    86         keycode_t key;
    87        
    88         /** Bitmask of modifiers held. */
    89         keymod_t mods;
    90        
    91         /** The character that was generated or '\0' for none. */
    92         wchar_t c;
    93 } kbd_event_t;
    9466
    9567extern console_ctrl_t *console_init(FILE *, FILE *);
  • uspace/lib/c/include/io/klog.h

    re0d5bc5 r96e01fbc  
    3838#include <sys/types.h>
    3939#include <stdarg.h>
     40#include <io/verify.h>
    4041
    4142extern size_t klog_write(const void *, size_t);
    4243extern void klog_update(void);
    43 extern int klog_printf(const char *, ...);
     44extern int klog_printf(const char *, ...)
     45    PRINTF_ATTRIBUTE(1, 2);
    4446extern int klog_vprintf(const char *, va_list);
    4547
  • uspace/lib/c/include/io/log.h

    re0d5bc5 r96e01fbc  
    3636
    3737#include <stdarg.h>
     38#include <io/verify.h>
    3839
    3940typedef enum {
     
    4445        LVL_DEBUG,
    4546        LVL_DEBUG2,
    46 
     47       
    4748        /** For checking range of values */
    4849        LVL_LIMIT
     
    5051
    5152extern int log_init(const char *, log_level_t);
    52 extern void log_msg(log_level_t, const char *, ...);
     53extern void log_msg(log_level_t, const char *, ...)
     54    PRINTF_ATTRIBUTE(2, 3);
    5355extern void log_msgv(log_level_t, const char *, va_list);
    5456
  • uspace/lib/c/include/ipc/console.h

    re0d5bc5 r96e01fbc  
    4343        CONSOLE_GET_EVENT,
    4444        CONSOLE_GET_POS,
    45         CONSOLE_GOTO,
     45        CONSOLE_SET_POS,
    4646        CONSOLE_CLEAR,
    4747        CONSOLE_SET_STYLE,
    4848        CONSOLE_SET_COLOR,
    4949        CONSOLE_SET_RGB_COLOR,
    50         CONSOLE_CURSOR_VISIBILITY
     50        CONSOLE_SET_CURSOR_VISIBILITY
    5151} console_request_t;
    5252
  • uspace/lib/c/include/ipc/dev_iface.h

    re0d5bc5 r96e01fbc  
    3838        /** Character device interface */
    3939        CHAR_DEV_IFACE,
     40
     41        /** Graphic device interface */
     42        GRAPH_DEV_IFACE,
    4043       
    4144        /** Network interface controller interface */
     
    5154        /** Interface provided by USB HID devices. */
    5255        USBHID_DEV_IFACE,
     56        /** Interface provided by AHCI devices. */
     57        AHCI_DEV_IFACE,
    5358
    5459        DEV_IFACE_MAX
  • uspace/lib/c/include/ipc/input.h

    re0d5bc5 r96e01fbc  
    4646        INPUT_EVENT_KEY = IPC_FIRST_USER_METHOD,
    4747        INPUT_EVENT_MOVE,
     48        INPUT_EVENT_ABS_MOVE,
    4849        INPUT_EVENT_BUTTON
    4950} input_notif_t;
  • uspace/lib/c/include/ipc/ipc.h

    re0d5bc5 r96e01fbc  
    4747
    4848typedef void (*ipc_async_callback_t)(void *, int, ipc_call_t *);
    49 
    50 /*
    51  * User-friendly wrappers for ipc_call_sync_fast() and ipc_call_sync_slow().
    52  * They are in the form ipc_call_sync_m_n(), where m denotes the number of
    53  * arguments of payload and n denotes number of return values. Whenever
    54  * possible, the fast version is used.
    55  */
    56 
    57 #define ipc_call_sync_0_0(phoneid, method) \
    58         ipc_call_sync_fast((phoneid), (method), 0, 0, 0, 0, 0, 0, 0, 0)
    59 #define ipc_call_sync_0_1(phoneid, method, res1) \
    60         ipc_call_sync_fast((phoneid), (method), 0, 0, 0, (res1), 0, 0, 0, 0)
    61 #define ipc_call_sync_0_2(phoneid, method, res1, res2) \
    62         ipc_call_sync_fast((phoneid), (method), 0, 0, 0, (res1), (res2), 0, 0, 0)
    63 #define ipc_call_sync_0_3(phoneid, method, res1, res2, res3) \
    64         ipc_call_sync_fast((phoneid), (method), 0, 0, 0, (res1), (res2), (res3), \
    65             0, 0)
    66 #define ipc_call_sync_0_4(phoneid, method, res1, res2, res3, res4) \
    67         ipc_call_sync_fast((phoneid), (method), 0, 0, 0, (res1), (res2), (res3), \
    68             (res4), 0)
    69 #define ipc_call_sync_0_5(phoneid, method, res1, res2, res3, res4, res5) \
    70         ipc_call_sync_fast((phoneid), (method), 0, 0, 0, (res1), (res2), (res3), \
    71             (res4), (res5))
    72 
    73 #define ipc_call_sync_1_0(phoneid, method, arg1) \
    74         ipc_call_sync_fast((phoneid), (method), (arg1), 0, 0, 0, 0, 0, 0, 0)
    75 #define ipc_call_sync_1_1(phoneid, method, arg1, res1) \
    76         ipc_call_sync_fast((phoneid), (method), (arg1), 0, 0, (res1), 0, 0, 0, 0)
    77 #define ipc_call_sync_1_2(phoneid, method, arg1, res1, res2) \
    78         ipc_call_sync_fast((phoneid), (method), (arg1), 0, 0, (res1), (res2), 0, \
    79             0, 0)
    80 #define ipc_call_sync_1_3(phoneid, method, arg1, res1, res2, res3) \
    81         ipc_call_sync_fast((phoneid), (method), (arg1), 0, 0, (res1), (res2), \
    82             (res3), 0, 0)
    83 #define ipc_call_sync_1_4(phoneid, method, arg1, res1, res2, res3, res4) \
    84         ipc_call_sync_fast((phoneid), (method), (arg1), 0, 0, (res1), (res2), \
    85             (res3), (res4), 0)
    86 #define ipc_call_sync_1_5(phoneid, method, arg1, res1, res2, res3, res4, \
    87     res5) \
    88         ipc_call_sync_fast((phoneid), (method), (arg1), 0, 0, (res1), (res2), \
    89             (res3), (res4), (res5))
    90 
    91 #define ipc_call_sync_2_0(phoneid, method, arg1, arg2) \
    92         ipc_call_sync_fast((phoneid), (method), (arg1), (arg2), 0, 0, 0, 0, \
    93             0, 0)
    94 #define ipc_call_sync_2_1(phoneid, method, arg1, arg2, res1) \
    95         ipc_call_sync_fast((phoneid), (method), (arg1), (arg2), 0, (res1), 0, 0, \
    96             0, 0)
    97 #define ipc_call_sync_2_2(phoneid, method, arg1, arg2, res1, res2) \
    98         ipc_call_sync_fast((phoneid), (method), (arg1), (arg2), 0, (res1), \
    99             (res2), 0, 0, 0)
    100 #define ipc_call_sync_2_3(phoneid, method, arg1, arg2, res1, res2, res3) \
    101         ipc_call_sync_fast((phoneid), (method), (arg1), (arg2), 0, (res1), \
    102             (res2), (res3), 0, 0)
    103 #define ipc_call_sync_2_4(phoneid, method, arg1, arg2, res1, res2, res3, \
    104     res4) \
    105         ipc_call_sync_fast((phoneid), (method), (arg1), (arg2), 0, (res1), \
    106             (res2), (res3), (res4), 0)
    107 #define ipc_call_sync_2_5(phoneid, method, arg1, arg2, res1, res2, res3, \
    108     res4, res5)\
    109         ipc_call_sync_fast((phoneid), (method), (arg1), (arg2), 0, (res1), \
    110             (res2), (res3), (res4), (res5))
    111 
    112 #define ipc_call_sync_3_0(phoneid, method, arg1, arg2, arg3) \
    113         ipc_call_sync_fast((phoneid), (method), (arg1), (arg2), (arg3), 0, 0, 0, \
    114             0, 0)
    115 #define ipc_call_sync_3_1(phoneid, method, arg1, arg2, arg3, res1) \
    116         ipc_call_sync_fast((phoneid), (method), (arg1), (arg2), (arg3), (res1), \
    117             0, 0, 0, 0)
    118 #define ipc_call_sync_3_2(phoneid, method, arg1, arg2, arg3, res1, res2) \
    119         ipc_call_sync_fast((phoneid), (method), (arg1), (arg2), (arg3), (res1), \
    120             (res2), 0, 0, 0)
    121 #define ipc_call_sync_3_3(phoneid, method, arg1, arg2, arg3, res1, res2, \
    122     res3) \
    123         ipc_call_sync_fast((phoneid), (method), (arg1), (arg2), (arg3), \
    124             (res1), (res2), (res3), 0, 0)
    125 #define ipc_call_sync_3_4(phoneid, method, arg1, arg2, arg3, res1, res2, \
    126     res3, res4) \
    127         ipc_call_sync_fast((phoneid), (method), (arg1), (arg2), (arg3), \
    128             (res1), (res2), (res3), (res4), 0)
    129 #define ipc_call_sync_3_5(phoneid, method, arg1, arg2, arg3, res1, res2, \
    130     res3, res4, res5) \
    131         ipc_call_sync_fast((phoneid), (method), (arg1), (arg2), (arg3), \
    132             (res1), (res2), (res3), (res4), (res5))
    133 
    134 #define ipc_call_sync_4_0(phoneid, method, arg1, arg2, arg3, arg4) \
    135         ipc_call_sync_slow((phoneid), (method), (arg1), (arg2), (arg3), (arg4), 0, \
    136             0, 0, 0, 0, 0)
    137 #define ipc_call_sync_4_1(phoneid, method, arg1, arg2, arg3, arg4, res1) \
    138         ipc_call_sync_slow((phoneid), (method), (arg1), (arg2), (arg3), (arg4), 0, \
    139             (res1), 0, 0, 0, 0)
    140 #define ipc_call_sync_4_2(phoneid, method, arg1, arg2, arg3, arg4, res1, res2) \
    141         ipc_call_sync_slow((phoneid), (method), (arg1), (arg2), (arg3), (arg4), 0, \
    142             (res1), (res2), 0, 0, 0)
    143 #define ipc_call_sync_4_3(phoneid, method, arg1, arg2, arg3, arg4, res1, res2, \
    144     res3) \
    145         ipc_call_sync_slow((phoneid), (method), (arg1), (arg2), (arg3), \
    146             (arg4), 0, (res1), (res2), (res3), 0, 0)
    147 #define ipc_call_sync_4_4(phoneid, method, arg1, arg2, arg3, arg4, res1, res2, \
    148     res3, res4) \
    149         ipc_call_sync_slow((phoneid), (method), (arg1), (arg2), (arg3), \
    150             (arg4), 0, (res1), (res2), (res3), (res4), 0)
    151 #define ipc_call_sync_4_5(phoneid, method, arg1, arg2, arg3, arg4, res1, res2, \
    152     res3, res4, res5) \
    153         ipc_call_sync_slow((phoneid), (method), (arg1), (arg2), (arg3), \
    154             (arg4), 0, (res1), (res2), (res3), (res4), (res5))
    155 
    156 #define ipc_call_sync_5_0(phoneid, method, arg1, arg2, arg3, arg4, arg5) \
    157         ipc_call_sync_slow((phoneid), (method), (arg1), (arg2), (arg3), (arg4), \
    158             (arg5), 0, 0, 0, 0, 0)
    159 #define ipc_call_sync_5_1(phoneid, method, arg1, arg2, arg3, arg4, arg5, res1) \
    160         ipc_call_sync_slow((phoneid), (method), (arg1), (arg2), (arg3), (arg4), \
    161             (arg5), (res1), 0, 0, 0, 0)
    162 #define ipc_call_sync_5_2(phoneid, method, arg1, arg2, arg3, arg4, arg5, res1, \
    163     res2) \
    164         ipc_call_sync_slow((phoneid), (method), (arg1), (arg2), (arg3), \
    165             (arg4), (arg5), (res1), (res2), 0, 0, 0)
    166 #define ipc_call_sync_5_3(phoneid, method, arg1, arg2, arg3, arg4, arg5, res1, \
    167     res2, res3) \
    168         ipc_call_sync_slow((phoneid), (method), (arg1), (arg2), (arg3), \
    169             (arg4), (arg5), (res1), (res2), (res3), 0, 0)
    170 #define ipc_call_sync_5_4(phoneid, method, arg1, arg2, arg3, arg4, arg5, res1, \
    171     res2, res3, res4) \
    172         ipc_call_sync_slow((phoneid), (method), (arg1), (arg2), (arg3), \
    173             (arg4), (arg5), (res1), (res2), (res3), (res4), 0)
    174 #define ipc_call_sync_5_5(phoneid, method, arg1, arg2, arg3, arg4, arg5, res1, \
    175     res2, res3, res4, res5) \
    176         ipc_call_sync_slow((phoneid), (method), (arg1), (arg2), (arg3), \
    177             (arg4), (arg5), (res1), (res2), (res3), (res4), (res5))
    178 
    179 extern int ipc_call_sync_fast(int, sysarg_t, sysarg_t, sysarg_t, sysarg_t,
    180     sysarg_t *, sysarg_t *, sysarg_t *, sysarg_t *, sysarg_t *);
    181 
    182 extern int ipc_call_sync_slow(int, sysarg_t, sysarg_t, sysarg_t, sysarg_t,
    183     sysarg_t, sysarg_t, sysarg_t *, sysarg_t *, sysarg_t *, sysarg_t *,
    184     sysarg_t *);
    18549
    18650extern ipc_callid_t ipc_wait_cycle(ipc_call_t *, sysarg_t, unsigned int);
     
    254118    sysarg_t, sysarg_t, void *, ipc_async_callback_t, bool);
    255119
    256 extern int ipc_clone_establish(int);
    257 extern int ipc_connect_to_me(int, sysarg_t, sysarg_t, sysarg_t, task_id_t *,
    258     sysarg_t *);
    259 extern int ipc_connect_me_to(int, sysarg_t, sysarg_t, sysarg_t);
    260 extern int ipc_connect_me_to_blocking(int, sysarg_t, sysarg_t, sysarg_t);
    261 
    262120extern int ipc_hangup(int);
    263121
     
    267125    sysarg_t, sysarg_t, sysarg_t, unsigned int);
    268126
    269 /*
    270  * User-friendly wrappers for ipc_share_in_start().
    271  */
    272 
    273 #define ipc_share_in_start_0_0(phoneid, size, dst) \
    274         ipc_share_in_start((phoneid), (size), 0, NULL, (dst))
    275 #define ipc_share_in_start_0_1(phoneid, size, flags, dst) \
    276         ipc_share_in_start((phoneid), (size), 0, (flags), (dst))
    277 #define ipc_share_in_start_1_0(phoneid, size, arg, dst) \
    278         ipc_share_in_start((phoneid), (size), (arg), NULL, (dst))
    279 #define ipc_share_in_start_1_1(phoneid, size, arg, flags, dst) \
    280         ipc_share_in_start((phoneid), (size), (arg), (flags), (dst))
    281 
    282 extern int ipc_share_in_start(int, size_t, sysarg_t, unsigned int *, void **);
    283 extern int ipc_share_in_finalize(ipc_callid_t, void *, unsigned int);
    284 extern int ipc_share_out_start(int, void *, unsigned int);
    285 extern int ipc_share_out_finalize(ipc_callid_t, void **);
    286 extern int ipc_data_read_start(int, void *, size_t);
    287 extern int ipc_data_read_finalize(ipc_callid_t, const void *, size_t);
    288 extern int ipc_data_write_start(int, const void *, size_t);
    289 extern int ipc_data_write_finalize(ipc_callid_t, void *, size_t);
    290 
    291127extern int ipc_connect_kbox(task_id_t);
    292128
  • uspace/lib/c/include/ipc/mouseev.h

    re0d5bc5 r96e01fbc  
    4747typedef enum {
    4848        MOUSEEV_MOVE_EVENT = IPC_FIRST_USER_METHOD,
     49        MOUSEEV_ABS_MOVE_EVENT,
    4950        MOUSEEV_BUTTON_EVENT
    5051} mouseev_notif_t;
  • uspace/lib/c/include/stdio.h

    re0d5bc5 r96e01fbc  
    3939#include <stdarg.h>
    4040#include <str.h>
    41 
    42 #ifndef NVERIFY_PRINTF
    43 
    44 #define PRINTF_ATTRIBUTE(start, end) \
    45         __attribute__((format(gnu_printf, start, end)))
    46 
    47 #else /* NVERIFY_PRINTF */
    48 
    49 #define PRINTF_ATTRIBUTE(start, end)
    50 
    51 #endif /* NVERIFY_PRINTF */
     41#include <io/verify.h>
    5242
    5343#define EOF  (-1)
  • uspace/lib/c/include/str.h

    re0d5bc5 r96e01fbc  
    5656
    5757extern wchar_t str_decode(const char *str, size_t *offset, size_t sz);
     58extern wchar_t str_decode_reverse(const char *str, size_t *offset, size_t sz);
    5859extern int chr_encode(const wchar_t ch, char *str, size_t *offset, size_t sz);
    5960
     
    7374extern size_t wstr_nlength(const wchar_t *str, size_t size);
    7475
     76extern size_t chr_width(wchar_t ch);
     77extern size_t str_width(const char *str);
     78
    7579extern bool ascii_check(wchar_t ch);
    7680extern bool chr_check(wchar_t ch);
     
    7882extern int str_cmp(const char *s1, const char *s2);
    7983extern int str_lcmp(const char *s1, const char *s2, size_t max_len);
     84
     85extern bool str_test_prefix(const char *s, const char *p);
    8086
    8187extern void str_cpy(char *dest, size_t size, const char *src);
  • uspace/lib/c/include/task.h

    re0d5bc5 r96e01fbc  
    3838#include <sys/types.h>
    3939#include <abi/proc/task.h>
     40#include <stdarg.h>
    4041
    4142typedef enum {
     
    4849extern int task_kill(task_id_t);
    4950
    50 extern task_id_t task_spawn(const char *, const char *const[], int *);
    5151extern int task_spawnv(task_id_t *, const char *path, const char *const []);
    5252extern int task_spawnvf(task_id_t *, const char *path, const char *const [],
    5353    int *const []);
     54extern int task_spawn(task_id_t *, const char *path, int, va_list ap);
    5455extern int task_spawnl(task_id_t *, const char *path, ...);
    5556
Note: See TracChangeset for help on using the changeset viewer.