Changeset ea15a89a in mainline for uspace/lib/c


Ignore:
Timestamp:
2013-04-29T14:26:22Z (12 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
533e2d7, 94dfb92
Parents:
b2fa2d86 (diff), 9e7898e (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:
1 added
11 edited
1 moved

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/arch/ia32/src/setjmp.S

    rb2fa2d86 rea15a89a  
    3535.type setjmp,@function
    3636setjmp:
    37         movl 0(%esp),%eax       # save pc value into eax       
    38         movl 4(%esp),%edx       # address of the jmp_buf structure to save context to
    39 
    40                 # save registers to the jmp_buf structure
     37        movl 0(%esp),%eax  # save pc value into eax
     38        movl 4(%esp),%edx  # address of the jmp_buf structure to save context to
     39       
     40        # save registers to the jmp_buf structure
    4141        CONTEXT_SAVE_ARCH_CORE %edx %eax
    42 
    43         xorl %eax,%eax          # set_jmp returns 0
     42       
     43        xorl %eax,%eax  # set_jmp returns 0
    4444        ret
    4545
    4646.type longjmp,@function
    4747longjmp:
    48 
    49         movl 4(%esp), %ecx      # put address of jmp_buf into ecx
    50         movl 8(%esp), %eax      # put return value into eax     
    51 
    52                 # restore registers from the jmp_buf structure
     48        movl 4(%esp), %ecx  # put address of jmp_buf into ecx
     49        movl 8(%esp), %eax  # put return value into eax
     50       
     51        # restore registers from the jmp_buf structure
    5352        CONTEXT_RESTORE_ARCH_CORE %ecx %edx
    54 
    55         movl %edx,0(%esp)       # put saved pc on stack
     53       
     54        movl %edx,0(%esp)  # put saved pc on stack
    5655        ret
    57 
  • uspace/lib/c/generic/adt/hash_table.c

    rb2fa2d86 rea15a89a  
    8181 * @param init_size Initial desired number of hash table buckets. Pass zero
    8282 *                 if you want the default initial size.
    83  * @param max_keys Maximal number of keys needed to identify an item.
     83 * @param max_load The table is resized when the average load per bucket
     84 *                 exceeds this number. Pass zero if you want the default.
    8485 * @param op       Hash table operations structure. remove_callback()
    8586 *                 is optional and can be NULL if no action is to be taken
  • uspace/lib/c/generic/async.c

    rb2fa2d86 rea15a89a  
    20902090 * @param arg   User defined argument.
    20912091 * @param flags Storage for the received flags. Can be NULL.
    2092  * @param dst   Destination address space area base. Cannot be NULL.
     2092 * @param dst   Address of the storage for the destination address space area
     2093 *              base address. Cannot be NULL.
    20932094 *
    20942095 * @return Zero on success or a negative error code from errno.h.
     
    22182219 *
    22192220 * @param callid Hash of the IPC_M_DATA_WRITE call to answer.
    2220  * @param dst    Destination address space area base address.
     2221 * @param dst    Address of the storage for the destination address space area
     2222 *               base address.
    22212223 *
    22222224 * @return Zero on success or a value from @ref errno.h on failure.
  • uspace/lib/c/generic/io/con_srv.c

    rb2fa2d86 rea15a89a  
    3535 */
    3636#include <errno.h>
     37#include <io/cons_event.h>
    3738#include <ipc/console.h>
    3839#include <stdlib.h>
     
    4041
    4142#include <io/con_srv.h>
     43
     44static int console_ev_encode(cons_event_t *event, ipc_call_t *call)
     45{
     46        IPC_SET_ARG1(*call, event->type);
     47
     48        switch (event->type) {
     49        case CEV_KEY:
     50                IPC_SET_ARG2(*call, event->ev.key.type);
     51                IPC_SET_ARG3(*call, event->ev.key.key);
     52                IPC_SET_ARG4(*call, event->ev.key.mods);
     53                IPC_SET_ARG5(*call, event->ev.key.c);
     54                break;
     55        case CEV_POS:
     56                IPC_SET_ARG2(*call, (event->ev.pos.pos_id << 16) | (event->ev.pos.type & 0xffff));
     57                IPC_SET_ARG3(*call, event->ev.pos.btn_num);
     58                IPC_SET_ARG4(*call, event->ev.pos.hpos);
     59                IPC_SET_ARG5(*call, event->ev.pos.vpos);
     60                break;
     61        default:
     62                return EIO;
     63        }
     64
     65        return EOK;
     66}
    4267
    4368static void con_read_srv(con_srv_t *srv, ipc_callid_t callid,
     
    273298{
    274299        int rc;
    275         kbd_event_t event;
     300        cons_event_t event;
     301        ipc_call_t result;
    276302
    277303        if (srv->srvs->ops->get_event == NULL) {
     
    281307
    282308        rc = srv->srvs->ops->get_event(srv, &event);
    283         async_answer_4(callid, rc, event.type, event.key, event.mods, event.c);
     309        if (rc != EOK) {
     310                async_answer_0(callid, rc);
     311                return;
     312        }
     313
     314        rc = console_ev_encode(&event, &result);
     315        if (rc != EOK) {
     316                async_answer_0(callid, rc);
     317                return;
     318        }
     319
     320        async_answer_5(callid, rc, IPC_GET_ARG1(result), IPC_GET_ARG2(result),
     321            IPC_GET_ARG3(result), IPC_GET_ARG4(result), IPC_GET_ARG5(result));
    284322}
    285323
  • uspace/lib/c/generic/io/console.c

    rb2fa2d86 rea15a89a  
    154154}
    155155
    156 bool console_get_kbd_event(console_ctrl_t *ctrl, kbd_event_t *event)
     156static int console_ev_decode(ipc_call_t *call, cons_event_t *event)
     157{
     158        event->type = IPC_GET_ARG1(*call);
     159
     160        switch (event->type) {
     161        case CEV_KEY:
     162                event->ev.key.type = IPC_GET_ARG2(*call);
     163                event->ev.key.key = IPC_GET_ARG3(*call);
     164                event->ev.key.mods = IPC_GET_ARG4(*call);
     165                event->ev.key.c = IPC_GET_ARG5(*call);
     166                break;
     167        case CEV_POS:
     168                event->ev.pos.pos_id = IPC_GET_ARG2(*call) >> 16;
     169                event->ev.pos.type = IPC_GET_ARG2(*call) & 0xffff;
     170                event->ev.pos.btn_num = IPC_GET_ARG3(*call);
     171                event->ev.pos.hpos = IPC_GET_ARG4(*call);
     172                event->ev.pos.vpos = IPC_GET_ARG5(*call);
     173                break;
     174        default:
     175                return EIO;
     176        }
     177
     178        return EOK;
     179}
     180
     181bool console_get_event(console_ctrl_t *ctrl, cons_event_t *event)
    157182{
    158183        if (ctrl->input_aid == 0) {
    159                 sysarg_t type;
    160                 sysarg_t key;
    161                 sysarg_t mods;
    162                 sysarg_t c;
     184                ipc_call_t result;
    163185               
    164186                async_exch_t *exch = async_exchange_begin(ctrl->input_sess);
    165                 int rc = async_req_0_4(exch, CONSOLE_GET_EVENT, &type, &key, &mods, &c);
     187                aid_t aid = async_send_0(exch, CONSOLE_GET_EVENT, &result);
    166188                async_exchange_end(exch);
     189               
     190                sysarg_t rc;
     191                async_wait_for(aid, &rc);
    167192               
    168193                if (rc != EOK) {
     
    171196                }
    172197               
    173                 event->type = type;
    174                 event->key = key;
    175                 event->mods = mods;
    176                 event->c = c;
     198                rc = console_ev_decode(&result, event);
     199                if (rc != EOK) {
     200                        errno = rc;
     201                        return false;
     202                }
    177203        } else {
    178204                sysarg_t retval;
     
    186212                }
    187213               
    188                 event->type = IPC_GET_ARG1(ctrl->input_call);
    189                 event->key = IPC_GET_ARG2(ctrl->input_call);
    190                 event->mods = IPC_GET_ARG3(ctrl->input_call);
    191                 event->c = IPC_GET_ARG4(ctrl->input_call);
     214                int rc = console_ev_decode(&ctrl->input_call, event);
     215                if (rc != EOK) {
     216                        errno = rc;
     217                        return false;
     218                }
    192219        }
    193220       
     
    195222}
    196223
    197 bool console_get_kbd_event_timeout(console_ctrl_t *ctrl, kbd_event_t *event,
     224bool console_get_event_timeout(console_ctrl_t *ctrl, cons_event_t *event,
    198225    suseconds_t *timeout)
    199226{
     
    223250        }
    224251       
    225         event->type = IPC_GET_ARG1(ctrl->input_call);
    226         event->key = IPC_GET_ARG2(ctrl->input_call);
    227         event->mods = IPC_GET_ARG3(ctrl->input_call);
    228         event->c = IPC_GET_ARG4(ctrl->input_call);
     252        rc = console_ev_decode(&ctrl->input_call, event);
     253        if (rc != EOK) {
     254                errno = rc;
     255                return false;
     256        }
    229257       
    230258        /* Update timeout */
  • uspace/lib/c/include/io/con_srv.h

    rb2fa2d86 rea15a89a  
    4141#include <io/color.h>
    4242#include <io/concaps.h>
    43 #include <io/kbd_event.h>
     43#include <io/cons_event.h>
    4444#include <io/pixel.h>
    4545#include <io/style.h>
     
    8282        void (*set_rgb_color)(con_srv_t *, pixel_t, pixel_t);
    8383        void (*set_cursor_visibility)(con_srv_t *, bool);
    84         int (*get_event)(con_srv_t *, kbd_event_t *);
     84        int (*get_event)(con_srv_t *, cons_event_t *);
    8585} con_ops_t;
    8686
  • uspace/lib/c/include/io/console.h

    rb2fa2d86 rea15a89a  
    3939#include <io/concaps.h>
    4040#include <io/kbd_event.h>
     41#include <io/cons_event.h>
    4142#include <io/keycode.h>
    4243#include <async.h>
     
    8283extern void console_cursor_visibility(console_ctrl_t *, bool);
    8384extern int console_get_color_cap(console_ctrl_t *, sysarg_t *);
    84 extern bool console_get_kbd_event(console_ctrl_t *, kbd_event_t *);
    85 extern bool console_get_kbd_event_timeout(console_ctrl_t *, kbd_event_t *,
     85extern bool console_get_event(console_ctrl_t *, cons_event_t *);
     86extern bool console_get_event_timeout(console_ctrl_t *, cons_event_t *,
    8687    suseconds_t *);
    8788
  • uspace/lib/c/include/io/pos_event.h

    rb2fa2d86 rea15a89a  
    11/*
    2  * Copyright (c) 2008 Martin Decky
     2 * Copyright (c) 2012 Petr Koupy
     3 * Copyright (c) 2013 Jiri Svoboda
    34 * All rights reserved.
    45 *
     
    2728 */
    2829
    29 /** @addtogroup genarch
     30/** @addtogroup libc
    3031 * @{
    3132 */
     
    3334 */
    3435
    35 #ifndef KERN_LOGO_196X66_H_
    36 #define KERN_LOGO_196X66_H_
     36#ifndef LIBC_IO_POS_EVENT_H_
     37#define LIBC_IO_POS_EVENT_H_
    3738
    38 #define LOGO_WIDTH   196
    39 #define LOGO_HEIGHT  66
    40 #define LOGO_COLOR   0xffffff
     39#include <sys/types.h>
    4140
    42 #include <typedefs.h>
     41typedef enum {
     42        POS_UPDATE,
     43        POS_PRESS,
     44        POS_RELEASE
     45} pos_event_type_t;
    4346
    44 extern uint32_t fb_logo[LOGO_WIDTH * LOGO_HEIGHT];
     47/** Positioning device event */
     48typedef struct {
     49        sysarg_t pos_id;
     50        pos_event_type_t type;
     51        sysarg_t btn_num;
     52        sysarg_t hpos;
     53        sysarg_t vpos;
     54} pos_event_t;
    4555
    4656#endif
  • uspace/lib/c/include/io/window.h

    rb2fa2d86 rea15a89a  
    4040#include <async.h>
    4141#include <loc.h>
    42 #include <io/console.h>
    43 
    44 typedef enum {
    45         POS_UPDATE,
    46         POS_PRESS,
    47         POS_RELEASE
    48 } pos_event_type_t;
    49 
    50 typedef struct {
    51         sysarg_t pos_id;
    52         pos_event_type_t type;
    53         sysarg_t btn_num;
    54         sysarg_t hpos;
    55         sysarg_t vpos;
    56 } pos_event_t;
     42#include <io/kbd_event.h>
     43#include <io/pos_event.h>
    5744
    5845typedef struct {
  • uspace/lib/c/include/mem.h

    rb2fa2d86 rea15a89a  
    4040#define bzero(ptr, len)  memset((ptr), 0, (len))
    4141
    42 extern void *memset(void *, int, size_t);
    43 extern void *memcpy(void *, const void *, size_t);
     42extern void *memset(void *, int, size_t)
     43    __attribute__ ((optimize("-fno-tree-loop-distribute-patterns")));
     44extern void *memcpy(void *, const void *, size_t)
     45    __attribute__ ((optimize("-fno-tree-loop-distribute-patterns")));
    4446extern void *memmove(void *, const void *, size_t);
    4547
  • uspace/lib/c/include/setjmp.h

    rb2fa2d86 rea15a89a  
    3838#include <libarch/fibril.h>
    3939
    40 typedef context_t jmp_buf;
     40typedef context_t jmp_buf[1];
    4141
    4242extern int setjmp(jmp_buf env);
     
    4747/** @}
    4848 */
    49 
  • uspace/lib/c/include/sys/types.h

    rb2fa2d86 rea15a89a  
    5050typedef volatile uint32_t ioport32_t;
    5151
     52typedef int16_t unaligned_int16_t __attribute__ ((aligned(1)));
     53typedef int32_t unaligned_int32_t __attribute__ ((aligned(1)));
     54typedef int64_t unaligned_int64_t __attribute__ ((aligned(1)));
     55
     56typedef uint16_t unaligned_uint16_t __attribute__ ((aligned(1)));
     57typedef uint32_t unaligned_uint32_t __attribute__ ((aligned(1)));
     58typedef uint64_t unaligned_uint64_t __attribute__ ((aligned(1)));
     59
    5260#endif
    5361
Note: See TracChangeset for help on using the changeset viewer.