Changeset 4c14b88 in mainline for uspace/lib


Ignore:
Timestamp:
2013-12-31T07:57:14Z (12 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
1b973dc
Parents:
6297465 (diff), 208b5f5 (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:

mainline changes

Location:
uspace/lib
Files:
57 added
7 deleted
46 edited
6 moved

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/Makefile

    r6297465 r4c14b88  
    6161        generic/bd.c \
    6262        generic/bd_srv.c \
    63         generic/bitops.c \
    6463        generic/cap.c \
    6564        generic/cfg.c \
     
    7776        generic/device/pci.c \
    7877        generic/device/ahci.c \
     78        generic/dhcp.c \
    7979        generic/dnsr.c \
    8080        generic/dlfcn.c \
     
    9999        generic/inetcfg.c \
    100100        generic/inetping.c \
    101         generic/inetping6.c \
    102101        generic/io/asprintf.c \
    103102        generic/io/input.c \
     
    129128        generic/loader.c \
    130129        generic/getopt.c \
     130        generic/adt/checksum.c \
    131131        generic/adt/list.c \
    132132        generic/adt/hash_table.c \
     
    143143        generic/net/socket_client.c \
    144144        generic/net/socket_parse.c \
     145        generic/setjmp.c \
    145146        generic/stack.c \
    146147        generic/stacktrace.c \
  • uspace/lib/c/arch/abs32le/include/libarch/atomic.h

    r6297465 r4c14b88  
    5353}
    5454
    55 static inline void atomic_inc(atomic_t *val) {
     55static inline void atomic_inc(atomic_t *val)
     56{
    5657        /* On real hardware the increment has to be done
    5758           as an atomic action. */
     
    6061}
    6162
    62 static inline void atomic_dec(atomic_t *val) {
     63static inline void atomic_dec(atomic_t *val)
     64{
    6365        /* On real hardware the decrement has to be done
    6466           as an atomic action. */
  • uspace/lib/c/arch/amd64/_link.ld.in

    r6297465 r4c14b88  
    3939        .data : {
    4040                *(.data);
     41                *(.data.rel*);
    4142        } :data
    4243       
  • uspace/lib/c/arch/ia32/Makefile.inc

    r6297465 r4c14b88  
    3434        arch/$(UARCH)/src/fibril.S \
    3535        arch/$(UARCH)/src/tls.c \
    36         arch/$(UARCH)/src/setjmp.S \
    3736        arch/$(UARCH)/src/stacktrace.c \
    3837        arch/$(UARCH)/src/stacktrace_asm.S \
  • uspace/lib/c/arch/sparc32/src/stacktrace_asm.S

    r6297465 r4c14b88  
    11#
    2 # Copyright (c) 2008 Josef Cejka
     2# Copyright (c) 2009 Jakub Jermar
    33# All rights reserved.
    44#
     
    2727#
    2828
    29 #include <libarch/context_offset.h>
     29#include <libarch/stack.h>
    3030
    3131.text
    32 .global setjmp
    33 .global longjmp
    3432
    35 .type setjmp,@function
    36 setjmp:
    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
     33.global stacktrace_prepare
     34.global stacktrace_fp_get
     35.global stacktrace_pc_get
     36
     37stacktrace_prepare:
     38        save %sp, -(STACK_WINDOW_SAVE_AREA_SIZE+STACK_ARG_SAVE_AREA_SIZE), %sp
    3939       
    40         # save registers to the jmp_buf structure
    41         CONTEXT_SAVE_ARCH_CORE %edx %eax
     40        # Flush all other windows to memory so that we can read their contents.
    4241       
    43         xorl %eax, %eax     # set_jmp returns 0
     42        mov 7, %g1
     43        1:
     44                subcc %g1, 1, %g1
     45                bg 1b
     46                save %sp, -64, %sp
     47       
     48        mov 7, %g1
     49        1:
     50                subcc %g1, 1, %g1
     51                bg 1b
     52       
    4453        ret
     54        restore
    4555
    46 .type longjmp,@function
    47 longjmp:
    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
    52         CONTEXT_RESTORE_ARCH_CORE %ecx %edx
    53        
    54         movl %edx, 0(%esp)  # put saved pc on stack
    55         ret
     56stacktrace_fp_get:
     57        # Add the stack bias to %sp to get the actual address.
     58        retl
     59        mov %sp,  %o0
     60
     61stacktrace_pc_get:
     62        retl
     63        mov %o7, %o0
  • uspace/lib/c/generic/dnsr.c

    r6297465 r4c14b88  
    6767}
    6868
    69 int dnsr_name2host(const char *name, dnsr_hostinfo_t **rinfo, uint16_t af)
     69int dnsr_name2host(const char *name, dnsr_hostinfo_t **rinfo, ip_ver_t ver)
    7070{
    7171        dnsr_hostinfo_t *info = calloc(1, sizeof(dnsr_hostinfo_t));
     
    7676       
    7777        ipc_call_t answer;
    78         aid_t req = async_send_1(exch, DNSR_NAME2HOST, (sysarg_t) af,
     78        aid_t req = async_send_1(exch, DNSR_NAME2HOST, (sysarg_t) ver,
    7979            &answer);
    8080       
  • uspace/lib/c/generic/inet.c

    r6297465 r4c14b88  
    3030#include <assert.h>
    3131#include <errno.h>
    32 #include <net/socket_codes.h>
    3332#include <inet/inet.h>
    3433#include <ipc/inet.h>
  • uspace/lib/c/generic/inet/addr.c

    r6297465 r4c14b88  
    3333 */
    3434
     35#include <assert.h>
    3536#include <errno.h>
    3637#include <unistd.h>
     
    5960
    6061static const inet_addr_t inet_addr_any_addr = {
    61         .family = AF_INET,
     62        .version = ip_v4,
    6263        .addr = 0
    6364};
    6465
    6566static const inet_addr_t inet_addr_any_addr6 = {
    66         .family = AF_INET6,
     67        .version = ip_v6,
    6768        .addr6 = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
    6869};
     
    7879}
    7980
     81/** Compare addr48.
     82  *
     83  * @return Non-zero if equal, zero if not equal.
     84  */
    8085int addr48_compare(const addr48_t a, const addr48_t b)
    8186{
    82         return memcmp(a, b, 6);
    83 }
    84 
     87        return memcmp(a, b, 6) == 0;
     88}
     89
     90/** Compare addr128.
     91  *
     92  * @return Non-zero if equal, zero if not equal.
     93  */
    8594int addr128_compare(const addr128_t a, const addr128_t b)
    8695{
    87         return memcmp(a, b, 16);
     96        return memcmp(a, b, 16) == 0;
    8897}
    8998
     
    102111void host2addr128_t_be(const addr128_t host, addr128_t be)
    103112{
    104 #ifdef __BE__
    105113        memcpy(be, host, 16);
    106 #else
    107         be[0] = host[15];
    108         be[1] = host[14];
    109         be[2] = host[13];
    110         be[3] = host[12];
    111         be[4] = host[11];
    112         be[5] = host[10];
    113         be[6] = host[9];
    114         be[7] = host[8];
    115         be[8] = host[7];
    116         be[9] = host[6];
    117         be[10] = host[5];
    118         be[11] = host[4];
    119         be[12] = host[3];
    120         be[13] = host[2];
    121         be[14] = host[1];
    122         be[15] = host[0];
    123 #endif
    124114}
    125115
    126116void addr128_t_be2host(const addr128_t be, addr128_t host)
    127117{
    128 #ifdef __BE__
    129118        memcpy(host, be, 16);
    130 #else
    131         host[0] = be[15];
    132         host[1] = be[14];
    133         host[2] = be[13];
    134         host[3] = be[12];
    135         host[4] = be[11];
    136         host[5] = be[10];
    137         host[6] = be[9];
    138         host[7] = be[8];
    139         host[8] = be[7];
    140         host[9] = be[6];
    141         host[10] = be[5];
    142         host[11] = be[4];
    143         host[12] = be[3];
    144         host[13] = be[2];
    145         host[14] = be[1];
    146         host[15] = be[0];
    147 #endif
    148119}
    149120
    150121void inet_addr(inet_addr_t *addr, uint8_t a, uint8_t b, uint8_t c, uint8_t d)
    151122{
    152         addr->family = AF_INET;
     123        addr->version = ip_v4;
    153124        addr->addr = ((addr32_t) a << 24) | ((addr32_t) b << 16) |
    154125            ((addr32_t) c << 8) | ((addr32_t) d);
     
    158129    uint8_t prefix)
    159130{
    160         naddr->family = AF_INET;
     131        naddr->version = ip_v4;
    161132        naddr->addr = ((addr32_t) a << 24) | ((addr32_t) b << 16) |
    162133            ((addr32_t) c << 8) | ((addr32_t) d);
     
    167138    uint16_t d, uint16_t e, uint16_t f, uint16_t g, uint16_t h)
    168139{
    169         addr->family = AF_INET6;
     140        addr->version = ip_v6;
    170141        addr->addr6[0] = (a >> 8) & 0xff;
    171142        addr->addr6[1] = a & 0xff;
     
    189160    uint16_t d, uint16_t e, uint16_t f, uint16_t g, uint16_t h, uint8_t prefix)
    190161{
    191         naddr->family = AF_INET6;
     162        naddr->version = ip_v6;
    192163        naddr->addr6[0] = (a >> 8) & 0xff;
    193164        naddr->addr6[1] = a & 0xff;
     
    209180}
    210181
    211 /** Parse network address family.
    212  *
    213  * @param text Network address in common notation.
    214  * @param af   Place to store network address family.
     182/** Determine address version.
     183 *
     184 * @param text Address in common notation.
     185 * @param af   Place to store address version.
    215186 *
    216187 * @return EOK on success, EINVAL if input is not in valid format.
    217188 *
    218189 */
    219 int inet_addr_family(const char *text, uint16_t *af)
     190static int inet_addr_version(const char *text, ip_ver_t *ver)
    220191{
    221192        char *dot = str_chr(text, '.');
    222193        if (dot != NULL) {
    223                 *af = AF_INET;
     194                *ver = ip_v4;
    224195                return EOK;
    225196        }
    226        
     197
    227198        char *collon = str_chr(text, ':');
    228199        if (collon != NULL) {
    229                 *af = AF_INET6;
     200                *ver = ip_v6;
    230201                return EOK;
    231202        }
    232        
     203
    233204        return EINVAL;
    234205}
    235206
     207static int ipver_af(ip_ver_t ver)
     208{
     209        switch (ver) {
     210        case ip_any:
     211                return AF_NONE;
     212        case ip_v4:
     213                return AF_INET;
     214        case ip_v6:
     215                return AF_INET6;
     216        default:
     217                assert(false);
     218                return EINVAL;
     219        }
     220}
     221
     222ip_ver_t ipver_from_af(int af)
     223{
     224        switch (af) {
     225        case AF_NONE:
     226                return ip_any;
     227        case AF_INET:
     228                return ip_v4;
     229        case AF_INET6:
     230                return ip_v6;
     231        default:
     232                assert(false);
     233                return EINVAL;
     234        }
     235}
     236
    236237void inet_naddr_addr(const inet_naddr_t *naddr, inet_addr_t *addr)
    237238{
    238         addr->family = naddr->family;
     239        addr->version = naddr->version;
    239240        memcpy(addr->addr6, naddr->addr6, 16);
    240241}
     
    243244    inet_naddr_t *naddr)
    244245{
    245         naddr->family = addr->family;
     246        naddr->version = addr->version;
    246247        memcpy(naddr->addr6, addr->addr6, 16);
    247248        naddr->prefix = prefix;
     
    250251void inet_addr_any(inet_addr_t *addr)
    251252{
    252         addr->family = AF_NONE;
     253        addr->version = ip_any;
    253254        memset(addr->addr6, 0, 16);
    254255}
     
    256257void inet_naddr_any(inet_naddr_t *naddr)
    257258{
    258         naddr->family = AF_NONE;
     259        naddr->version = ip_any;
    259260        memset(naddr->addr6, 0, 16);
    260261        naddr->prefix = 0;
     
    263264int inet_addr_compare(const inet_addr_t *a, const inet_addr_t *b)
    264265{
    265         if (a->family != b->family)
     266        if (a->version != b->version)
    266267                return 0;
    267        
    268         switch (a->family) {
    269         case AF_INET:
     268
     269        switch (a->version) {
     270        case ip_v4:
    270271                return (a->addr == b->addr);
    271         case AF_INET6:
     272        case ip_v6:
    272273                return addr128_compare(a->addr6, b->addr6);
    273274        default:
     
    278279int inet_addr_is_any(const inet_addr_t *addr)
    279280{
    280         return ((addr->family == 0) ||
     281        return ((addr->version == ip_any) ||
    281282            (inet_addr_compare(addr, &inet_addr_any_addr)) ||
    282283            (inet_addr_compare(addr, &inet_addr_any_addr6)));
     
    285286int inet_naddr_compare(const inet_naddr_t *naddr, const inet_addr_t *addr)
    286287{
    287         if (naddr->family != addr->family)
     288        if (naddr->version != addr->version)
    288289                return 0;
    289290       
    290         switch (naddr->family) {
    291         case AF_INET:
     291        switch (naddr->version) {
     292        case ip_v4:
    292293                return (naddr->addr == addr->addr);
    293         case AF_INET6:
     294        case ip_v6:
    294295                return addr128_compare(naddr->addr6, addr->addr6);
    295296        default:
     
    300301int inet_naddr_compare_mask(const inet_naddr_t *naddr, const inet_addr_t *addr)
    301302{
    302         if (naddr->family != addr->family)
     303        if (naddr->version != addr->version)
    303304                return 0;
    304        
    305         switch (naddr->family) {
    306         case AF_INET:
     305
     306        switch (naddr->version) {
     307        case ip_v4:
    307308                if (naddr->prefix > 32)
    308309                        return 0;
    309                
     310
    310311                addr32_t mask =
    311312                    BIT_RANGE(addr32_t, 31, 31 - (naddr->prefix - 1));
    312313                return ((naddr->addr & mask) == (addr->addr & mask));
    313         case AF_INET6:
     314        case ip_v6:
    314315                if (naddr->prefix > 128)
    315316                        return 0;
     
    352353int inet_addr_parse(const char *text, inet_addr_t *addr)
    353354{
    354         int rc = inet_addr_family(text, &addr->family);
     355        int rc = inet_addr_version(text, &addr->version);
    355356        if (rc != EOK)
    356357                return rc;
    357358       
    358359        uint8_t buf[16];
    359         rc = inet_pton(addr->family, text, buf);
     360        rc = inet_pton(ipver_af(addr->version), text, buf);
    360361        if (rc != EOK)
    361362                return rc;
    362363       
    363         switch (addr->family) {
    364         case AF_INET:
     364        switch (addr->version) {
     365        case ip_v4:
    365366                addr->addr = (buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) |
    366367                    buf[3];
    367368                break;
    368         case AF_INET6:
     369        case ip_v6:
    369370                memcpy(addr->addr6, buf, 16);
    370371                break;
     
    392393        *slash = 0;
    393394       
    394         int rc = inet_addr_family(text, &naddr->family);
     395        int rc = inet_addr_version(text, &naddr->version);
    395396        if (rc != EOK)
    396397                return rc;
    397398       
    398399        uint8_t buf[16];
    399         rc = inet_pton(naddr->family, text, buf);
     400        rc = inet_pton(ipver_af(naddr->version), text, buf);
    400401        *slash = '/';
    401402       
     
    406407        uint8_t prefix;
    407408       
    408         switch (naddr->family) {
    409         case AF_INET:
     409        switch (naddr->version) {
     410        case ip_v4:
    410411                prefix = strtoul(slash, &slash, 10);
    411412                if (prefix > 32)
     
    417418               
    418419                break;
    419         case AF_INET6:
     420        case ip_v6:
    420421                prefix = strtoul(slash, &slash, 10);
    421422                if (prefix > 128)
     
    447448        int rc = 0;
    448449       
    449         switch (addr->family) {
    450         case AF_NONE:
     450        switch (addr->version) {
     451        case ip_any:
    451452                rc = asprintf(bufp, "none");
    452453                break;
    453         case AF_INET:
     454        case ip_v4:
    454455                rc = asprintf(bufp, "%u.%u.%u.%u", (addr->addr >> 24) & 0xff,
    455456                    (addr->addr >> 16) & 0xff, (addr->addr >> 8) & 0xff,
    456457                    addr->addr & 0xff);
    457458                break;
    458         case AF_INET6:
     459        case ip_v6:
    459460                *bufp = (char *) malloc(INET6_ADDRSTRLEN);
    460461                if (*bufp == NULL)
     
    487488        char prefix[INET_PREFIXSTRSIZE];
    488489       
    489         switch (naddr->family) {
    490         case AF_NONE:
     490        switch (naddr->version) {
     491        case ip_any:
    491492                rc = asprintf(bufp, "none");
    492493                break;
    493         case AF_INET:
     494        case ip_v4:
    494495                rc = asprintf(bufp, "%" PRIu8 ".%" PRIu8 ".%" PRIu8 ".%" PRIu8
    495496                    "/%" PRIu8, (naddr->addr >> 24) & 0xff,
     
    497498                    naddr->addr & 0xff, naddr->prefix);
    498499                break;
    499         case AF_INET6:
     500        case ip_v6:
    500501                *bufp = (char *) malloc(INET6_ADDRSTRLEN + INET_PREFIXSTRSIZE);
    501502                if (*bufp == NULL)
     
    529530}
    530531
    531 uint16_t inet_addr_get(const inet_addr_t *addr, addr32_t *v4, addr128_t *v6)
    532 {
    533         switch (addr->family) {
    534         case AF_INET:
     532ip_ver_t inet_addr_get(const inet_addr_t *addr, addr32_t *v4, addr128_t *v6)
     533{
     534        switch (addr->version) {
     535        case ip_v4:
    535536                if (v4 != NULL)
    536537                        *v4 = addr->addr;
    537                
    538                 break;
    539         case AF_INET6:
     538                break;
     539        case ip_v6:
    540540                if (v6 != NULL)
    541541                        memcpy(*v6, addr->addr6, 16);
    542                
    543                 break;
    544         }
    545        
    546         return addr->family;
    547 }
    548 
    549 uint16_t inet_naddr_get(const inet_naddr_t *naddr, addr32_t *v4, addr128_t *v6,
     542                break;
     543        default:
     544                assert(false);
     545                break;
     546        }
     547
     548        return addr->version;
     549}
     550
     551ip_ver_t inet_naddr_get(const inet_naddr_t *naddr, addr32_t *v4, addr128_t *v6,
    550552    uint8_t *prefix)
    551553{
    552         switch (naddr->family) {
    553         case AF_INET:
     554        switch (naddr->version) {
     555        case ip_v4:
    554556                if (v4 != NULL)
    555557                        *v4 = naddr->addr;
    556                
    557558                if (prefix != NULL)
    558559                        *prefix = naddr->prefix;
    559                
    560                 break;
    561         case AF_INET6:
     560                break;
     561        case ip_v6:
    562562                if (v6 != NULL)
    563563                        memcpy(*v6, naddr->addr6, 16);
    564                
    565564                if (prefix != NULL)
    566565                        *prefix = naddr->prefix;
    567                
    568                 break;
    569         }
    570        
    571         return naddr->family;
     566                break;
     567        default:
     568                assert(false);
     569                break;
     570        }
     571
     572        return naddr->version;
    572573}
    573574
    574575void inet_addr_set(addr32_t v4, inet_addr_t *addr)
    575576{
    576         addr->family = AF_INET;
     577        addr->version = ip_v4;
    577578        addr->addr = v4;
    578579}
     
    580581void inet_naddr_set(addr32_t v4, uint8_t prefix, inet_naddr_t *naddr)
    581582{
    582         naddr->family = AF_INET;
     583        naddr->version = ip_v4;
    583584        naddr->addr = v4;
    584585        naddr->prefix = prefix;
     
    587588void inet_sockaddr_in_addr(const sockaddr_in_t *sockaddr_in, inet_addr_t *addr)
    588589{
    589         addr->family = AF_INET;
     590        addr->version = ip_v4;
    590591        addr->addr = uint32_t_be2host(sockaddr_in->sin_addr.s_addr);
    591592}
     
    593594void inet_addr_set6(addr128_t v6, inet_addr_t *addr)
    594595{
    595         addr->family = AF_INET6;
     596        addr->version = ip_v6;
    596597        memcpy(addr->addr6, v6, 16);
    597598}
     
    599600void inet_naddr_set6(addr128_t v6, uint8_t prefix, inet_naddr_t *naddr)
    600601{
    601         naddr->family = AF_INET6;
     602        naddr->version = ip_v6;
    602603        memcpy(naddr->addr6, v6, 16);
    603604        naddr->prefix = prefix;
     
    607608    inet_addr_t *addr)
    608609{
    609         addr->family = AF_INET6;
     610        addr->version = ip_v6;
    610611        addr128_t_be2host(sockaddr_in6->sin6_addr.s6_addr, addr->addr6);
    611612}
     
    614615    sockaddr_in_t *sockaddr_in, sockaddr_in6_t *sockaddr_in6)
    615616{
    616         switch (addr->family) {
    617         case AF_INET:
     617        switch (addr->version) {
     618        case ip_v4:
    618619                if (sockaddr_in != NULL) {
    619620                        sockaddr_in->sin_family = AF_INET;
    620621                        sockaddr_in->sin_addr.s_addr = host2uint32_t_be(addr->addr);
    621622                }
    622                
    623                 break;
    624         case AF_INET6:
     623                break;
     624        case ip_v6:
    625625                if (sockaddr_in6 != NULL) {
    626626                        sockaddr_in6->sin6_family = AF_INET6;
    627627                        host2addr128_t_be(addr->addr6, sockaddr_in6->sin6_addr.s6_addr);
    628628                }
    629                
    630                 break;
    631         }
    632        
    633         return addr->family;
     629                break;
     630        default:
     631                assert(false);
     632                break;
     633        }
     634
     635        return ipver_af(addr->version);
     636}
     637
     638int inet_addr_sockaddr(const inet_addr_t *addr, uint16_t port,
     639    sockaddr_t **nsockaddr, socklen_t *naddrlen)
     640{
     641        sockaddr_in_t *sa4;
     642        sockaddr_in6_t *sa6;
     643
     644        switch (addr->version) {
     645        case ip_v4:
     646                sa4 = calloc(1, sizeof(sockaddr_in_t));
     647                if (sa4 == NULL)
     648                        return ENOMEM;
     649
     650                sa4->sin_family = AF_INET;
     651                sa4->sin_port = host2uint16_t_be(port);
     652                sa4->sin_addr.s_addr = host2uint32_t_be(addr->addr);
     653                if (nsockaddr != NULL)
     654                        *nsockaddr = (sockaddr_t *)sa4;
     655                if (naddrlen != NULL)
     656                        *naddrlen = sizeof(*sa4);
     657                break;
     658        case ip_v6:
     659                sa6 = calloc(1, sizeof(sockaddr_in6_t));
     660                if (sa6 == NULL)
     661                        return ENOMEM;
     662
     663                sa6->sin6_family = AF_INET6;
     664                sa6->sin6_port = host2uint16_t_be(port);
     665                host2addr128_t_be(addr->addr6, sa6->sin6_addr.s6_addr);
     666                if (nsockaddr != NULL)
     667                        *nsockaddr = (sockaddr_t *)sa6;
     668                if (naddrlen != NULL)
     669                        *naddrlen = sizeof(*sa6);
     670                break;
     671        default:
     672                assert(false);
     673                break;
     674        }
     675
     676        return EOK;
    634677}
    635678
  • uspace/lib/c/generic/inetcfg.c

    r6297465 r4c14b88  
    267267}
    268268
     269int inetcfg_link_add(sysarg_t link_id)
     270{
     271        async_exch_t *exch = async_exchange_begin(inetcfg_sess);
     272
     273        int rc = async_req_1_0(exch, INETCFG_LINK_ADD, link_id);
     274        async_exchange_end(exch);
     275
     276        return rc;
     277}
     278
    269279int inetcfg_link_get(sysarg_t link_id, inet_link_info_t *linfo)
    270280{
     
    305315}
    306316
     317int inetcfg_link_remove(sysarg_t link_id)
     318{
     319        async_exch_t *exch = async_exchange_begin(inetcfg_sess);
     320
     321        int rc = async_req_1_0(exch, INETCFG_LINK_REMOVE, link_id);
     322        async_exchange_end(exch);
     323
     324        return rc;
     325}
     326
    307327int inetcfg_sroute_create(const char *name, inet_naddr_t *dest,
    308328    inet_addr_t *router, sysarg_t *sroute_id)
  • uspace/lib/c/generic/inetping.c

    r6297465 r4c14b88  
    11/*
    2  * Copyright (c) 2012 Jiri Svoboda
     2 * Copyright (c) 2013 Jiri Svoboda
     3 * Copyright (c) 2013 Martin Decky
    34 * All rights reserved.
    45 *
     
    4950
    5051        assert(inetping_sess == NULL);
    51        
     52
    5253        inetping_ev_ops = ev_ops;
    53        
     54
    5455        rc = loc_service_get_id(SERVICE_NAME_INETPING, &inetping_svc,
    5556            IPC_FLAG_BLOCKING);
    5657        if (rc != EOK)
    5758                return ENOENT;
    58        
     59
    5960        inetping_sess = loc_service_connect(EXCHANGE_SERIALIZE, inetping_svc,
    6061            IPC_FLAG_BLOCKING);
    6162        if (inetping_sess == NULL)
    6263                return ENOENT;
    63        
     64
    6465        async_exch_t *exch = async_exchange_begin(inetping_sess);
    6566
    6667        rc = async_connect_to_me(exch, 0, 0, 0, inetping_cb_conn, NULL);
    6768        async_exchange_end(exch);
    68        
     69
    6970        if (rc != EOK) {
    7071                async_hangup(inetping_sess);
     
    7273                return rc;
    7374        }
    74        
     75
    7576        return EOK;
    7677}
     
    7980{
    8081        async_exch_t *exch = async_exchange_begin(inetping_sess);
    81        
     82
    8283        ipc_call_t answer;
    83         aid_t req = async_send_3(exch, INETPING_SEND, (sysarg_t) sdu->src,
    84             (sysarg_t) sdu->dest, sdu->seq_no, &answer);
    85         sysarg_t retval = async_data_write_start(exch, sdu->data, sdu->size);
    86        
     84        aid_t req = async_send_1(exch, INETPING_SEND, sdu->seq_no, &answer);
     85
     86        int rc = async_data_write_start(exch, &sdu->src, sizeof(sdu->src));
     87        if (rc != EOK) {
     88                async_exchange_end(exch);
     89                async_forget(req);
     90                return rc;
     91        }
     92
     93        rc = async_data_write_start(exch, &sdu->dest, sizeof(sdu->dest));
     94        if (rc != EOK) {
     95                async_exchange_end(exch);
     96                async_forget(req);
     97                return rc;
     98        }
     99
     100        rc = async_data_write_start(exch, sdu->data, sdu->size);
     101
    87102        async_exchange_end(exch);
    88        
    89         if (retval != EOK) {
    90                 async_forget(req);
    91                 return retval;
    92         }
    93        
     103
     104        if (rc != EOK) {
     105                async_forget(req);
     106                return rc;
     107        }
     108
     109        sysarg_t retval;
    94110        async_wait_for(req, &retval);
    95         return retval;
    96 }
    97 
    98 int inetping_get_srcaddr(uint32_t remote, uint32_t *local)
     111
     112        return (int) retval;
     113}
     114
     115int inetping_get_srcaddr(const inet_addr_t *remote, inet_addr_t *local)
    99116{
    100117        async_exch_t *exch = async_exchange_begin(inetping_sess);
    101        
    102         sysarg_t local_addr;
    103         int rc = async_req_1_1(exch, INETPING_GET_SRCADDR, (sysarg_t) remote,
    104             &local_addr);
    105        
     118
     119        ipc_call_t answer;
     120        aid_t req = async_send_0(exch, INETPING_GET_SRCADDR, &answer);
     121
     122        int rc = async_data_write_start(exch, remote, sizeof(*remote));
     123        if (rc != EOK) {
     124                async_exchange_end(exch);
     125                async_forget(req);
     126                return rc;
     127        }
     128
     129        ipc_call_t answer_local;
     130        aid_t req_local = async_data_read(exch, local, sizeof(*local),
     131            &answer_local);
     132
    106133        async_exchange_end(exch);
    107        
    108         if (rc != EOK)
    109                 return rc;
    110        
    111         *local = (uint32_t) local_addr;
    112         return EOK;
    113 }
    114 
    115 static void inetping_ev_recv(ipc_callid_t callid, ipc_call_t *call)
     134
     135        sysarg_t retval_local;
     136        async_wait_for(req_local, &retval_local);
     137
     138        if (retval_local != EOK) {
     139                async_forget(req);
     140                return (int) retval_local;
     141        }
     142
     143        sysarg_t retval;
     144        async_wait_for(req, &retval);
     145
     146        return (int) retval;
     147}
     148
     149static void inetping_ev_recv(ipc_callid_t iid, ipc_call_t *icall)
    116150{
    117151        inetping_sdu_t sdu;
    118        
    119         sdu.src = IPC_GET_ARG1(*call);
    120         sdu.dest = IPC_GET_ARG2(*call);
    121         sdu.seq_no = IPC_GET_ARG3(*call);
    122        
    123         int rc = async_data_write_accept(&sdu.data, false, 0, 0, 0, &sdu.size);
     152
     153        sdu.seq_no = IPC_GET_ARG1(*icall);
     154
     155        ipc_callid_t callid;
     156        size_t size;
     157        if (!async_data_write_receive(&callid, &size)) {
     158                async_answer_0(callid, EREFUSED);
     159                async_answer_0(iid, EREFUSED);
     160                return;
     161        }
     162
     163        if (size != sizeof(sdu.src)) {
     164                async_answer_0(callid, EINVAL);
     165                async_answer_0(iid, EINVAL);
     166                return;
     167        }
     168
     169        int rc = async_data_write_finalize(callid, &sdu.src, size);
    124170        if (rc != EOK) {
    125171                async_answer_0(callid, rc);
    126                 return;
    127         }
    128        
     172                async_answer_0(iid, rc);
     173                return;
     174        }
     175
     176        if (!async_data_write_receive(&callid, &size)) {
     177                async_answer_0(callid, EREFUSED);
     178                async_answer_0(iid, EREFUSED);
     179                return;
     180        }
     181
     182        if (size != sizeof(sdu.dest)) {
     183                async_answer_0(callid, EINVAL);
     184                async_answer_0(iid, EINVAL);
     185                return;
     186        }
     187
     188        rc = async_data_write_finalize(callid, &sdu.dest, size);
     189        if (rc != EOK) {
     190                async_answer_0(callid, rc);
     191                async_answer_0(iid, rc);
     192                return;
     193        }
     194
     195        rc = async_data_write_accept(&sdu.data, false, 0, 0, 0, &sdu.size);
     196        if (rc != EOK) {
     197                async_answer_0(iid, rc);
     198                return;
     199        }
     200
    129201        rc = inetping_ev_ops->recv(&sdu);
    130202        free(sdu.data);
    131         async_answer_0(callid, rc);
     203        async_answer_0(iid, rc);
    132204}
    133205
  • uspace/lib/c/generic/iplink.c

    r6297465 r4c14b88  
    218218        iplink_recv_sdu_t sdu;
    219219       
    220         uint16_t af = IPC_GET_ARG1(*icall);
     220        ip_ver_t ver = IPC_GET_ARG1(*icall);
    221221       
    222222        int rc = async_data_write_accept(&sdu.data, false, 0, 0, 0,
     
    227227        }
    228228       
    229         rc = iplink->ev_ops->recv(iplink, &sdu, af);
     229        rc = iplink->ev_ops->recv(iplink, &sdu, ver);
    230230        free(sdu.data);
    231231        async_answer_0(iid, rc);
  • uspace/lib/c/generic/iplink_srv.c

    r6297465 r4c14b88  
    272272}
    273273
    274 int iplink_ev_recv(iplink_srv_t *srv, iplink_recv_sdu_t *sdu, uint16_t af)
     274/* XXX Version should be part of @a sdu */
     275int iplink_ev_recv(iplink_srv_t *srv, iplink_recv_sdu_t *sdu, ip_ver_t ver)
    275276{
    276277        if (srv->client_sess == NULL)
     
    280281       
    281282        ipc_call_t answer;
    282         aid_t req = async_send_1(exch, IPLINK_EV_RECV, (sysarg_t) af,
     283        aid_t req = async_send_1(exch, IPLINK_EV_RECV, (sysarg_t)ver,
    283284            &answer);
    284285       
  • uspace/lib/c/generic/rtld/module.c

    r6297465 r4c14b88  
    9393module_t *module_find(const char *name)
    9494{
    95         module_t *m;
    9695        const char *p, *soname;
    9796
     
    107106
    108107        /* Traverse list of all modules. Not extremely fast, but simple */
    109         list_foreach(runtime_env->modules, cur) {
    110                 DPRINTF("cur = %p\n", cur);
    111                 m = list_get_instance(cur, module_t, modules_link);
     108        list_foreach(runtime_env->modules, modules_link, module_t, m) {
     109                DPRINTF("m = %p\n", m);
    112110                if (str_cmp(m->dyn.soname, soname) == 0) {
    113111                        return m; /* Found */
     
    245243void modules_process_relocs(module_t *start)
    246244{
    247         module_t *m;
    248 
    249         list_foreach(runtime_env->modules, cur) {
    250                 m = list_get_instance(cur, module_t, modules_link);
    251 
     245        list_foreach(runtime_env->modules, modules_link, module_t, m) {
    252246                /* Skip rtld, since it has already been processed */
    253247                if (m != &runtime_env->rtld) {
     
    261255void modules_untag(void)
    262256{
    263         module_t *m;
    264 
    265         list_foreach(runtime_env->modules, cur) {
    266                 m = list_get_instance(cur, module_t, modules_link);
     257        list_foreach(runtime_env->modules, modules_link, module_t, m) {
    267258                m->bfs_tag = false;
    268259        }
  • uspace/lib/c/generic/vfs/vfs.c

    r6297465 r4c14b88  
    342342}
    343343
    344 ssize_t read(int fildes, void *buf, size_t nbyte) 
     344ssize_t read(int fildes, void *buf, size_t nbyte)
    345345{
    346346        sysarg_t rc;
     
    348348        aid_t req;
    349349       
     350        if (nbyte > DATA_XFER_LIMIT)
     351                nbyte = DATA_XFER_LIMIT;
     352       
    350353        async_exch_t *exch = vfs_exchange_begin();
    351354       
    352355        req = async_send_1(exch, VFS_IN_READ, fildes, &answer);
    353         rc = async_data_read_start(exch, (void *)buf, nbyte);
     356        rc = async_data_read_start(exch, (void *) buf, nbyte);
    354357        if (rc != EOK) {
    355358                vfs_exchange_end(exch);
     
    377380        aid_t req;
    378381       
     382        if (nbyte > DATA_XFER_LIMIT)
     383                nbyte = DATA_XFER_LIMIT;
     384       
    379385        async_exch_t *exch = vfs_exchange_begin();
    380386       
    381387        req = async_send_1(exch, VFS_IN_WRITE, fildes, &answer);
    382         rc = async_data_write_start(exch, (void *)buf, nbyte);
     388        rc = async_data_write_start(exch, (void *) buf, nbyte);
    383389        if (rc != EOK) {
    384390                vfs_exchange_end(exch);
     
    736742}
    737743
     744int remove(const char *path)
     745{
     746        return unlink(path);
     747}
     748
    738749int chdir(const char *path)
    739750{
  • uspace/lib/c/include/adt/checksum.h

    r6297465 r4c14b88  
    11/*
    2  * Copyright (c) 2009 Lukas Mejdrech
     2 * Copyright (c) 2012 Dominik Taborsky
    33 * All rights reserved.
    44 *
     
    3030 * @{
    3131 */
    32 
    3332/** @file
    34  * Network device.
    3533 */
    3634
    37 #ifndef LIBC_NET_DEVICE_H_
    38 #define LIBC_NET_DEVICE_H_
     35#ifndef LIBC_CHECKSUM_H_
     36#define LIBC_CHECKSUM_H_
    3937
    40 #include <adt/int_map.h>
    41 #include <nic/nic.h>
     38#include <sys/types.h>
    4239
    43 /** Device identifier to generic type map declaration. */
    44 #define DEVICE_MAP_DECLARE  INT_MAP_DECLARE
    45 
    46 /** Device identifier to generic type map implementation. */
    47 #define DEVICE_MAP_IMPLEMENT  INT_MAP_IMPLEMENT
    48 
    49 /** Device identifier type. */
    50 typedef int nic_device_id_t;
    51 
    52 /** Invalid device identifier. */
    53 #define NIC_DEVICE_INVALID_ID  (-1)
     40extern uint32_t compute_crc32(uint8_t *, size_t);
     41extern uint32_t compute_crc32_seed(uint8_t *, size_t, uint32_t);
    5442
    5543#endif
  • uspace/lib/c/include/adt/list.h

    r6297465 r4c14b88  
    3838
    3939#include <assert.h>
     40#include <stdbool.h>
    4041#include <unistd.h>
    4142
     
    7273            iterator = list_get_instance(_link, itype, member), \
    7374            _link != &(list).head; _link = _link->next)
     75
     76#define list_foreach_rev(list, member, itype, iterator) \
     77        for (itype *iterator = NULL; iterator == NULL; iterator = (itype *) 1) \
     78            for (link_t *_link = (list).head.prev; \
     79            iterator = list_get_instance(_link, itype, member), \
     80            _link != &(list).head; _link = _link->prev)
    7481
    7582/** Unlike list_foreach(), allows removing items while traversing a list.
     
    105112
    106113#define assert_link_not_used(link) \
    107         assert(((link)->prev == NULL) && ((link)->next == NULL))
     114        assert(!link_used(link))
    108115
    109116/** Returns true if the link is definitely part of a list. False if not sure. */
     
    357364}
    358365
     366/** Determine if link is used.
     367 *
     368 * @param link Link
     369 * @return @c true if link is used, @c false if not.
     370 */
     371static inline bool link_used(link_t *link)
     372{
     373        if (link->prev == NULL && link->next == NULL)
     374                return false;
     375
     376        assert(link->prev != NULL && link->next != NULL);
     377        return true;
     378}
     379
    359380extern int list_member(const link_t *, const list_t *);
    360381extern void list_concat(list_t *, list_t *);
  • uspace/lib/c/include/bitops.h

    r6297465 r4c14b88  
    107107}
    108108
    109 extern int __popcountsi2(int);
    110 
    111109#endif
    112110
  • uspace/lib/c/include/inet/addr.h

    r6297465 r4c14b88  
    3939#include <net/in.h>
    4040#include <net/in6.h>
     41#include <net/socket.h>
    4142
    4243typedef uint32_t addr32_t;
     
    4445typedef uint8_t addr128_t[16];
    4546
     47typedef enum {
     48        /** Any IP protocol version */
     49        ip_any,
     50        /** IPv4 */
     51        ip_v4,
     52        /** IPv6 */
     53        ip_v6
     54} ip_ver_t;
     55
    4656/** Node address */
    4757typedef struct {
    48         uint16_t family;
     58        /** IP version */
     59        ip_ver_t version;
    4960        union {
    5061                addr32_t addr;
     
    5566/** Network address */
    5667typedef struct {
    57         /** Address family */
    58         uint16_t family;
     68        /** IP version */
     69        ip_ver_t version;
    5970       
    6071        /** Address */
     
    91102    uint16_t, uint16_t, uint16_t, uint16_t, uint8_t);
    92103
    93 extern int inet_addr_family(const char *, uint16_t *);
    94104extern void inet_naddr_addr(const inet_naddr_t *, inet_addr_t *);
    95105extern void inet_addr_naddr(const inet_addr_t *, uint8_t, inet_naddr_t *);
     
    110120extern int inet_naddr_format(const inet_naddr_t *, char **);
    111121
    112 extern uint16_t inet_addr_get(const inet_addr_t *, addr32_t *, addr128_t *);
    113 extern uint16_t inet_naddr_get(const inet_naddr_t *, addr32_t *, addr128_t *,
     122extern ip_ver_t inet_addr_get(const inet_addr_t *, addr32_t *, addr128_t *);
     123extern ip_ver_t inet_naddr_get(const inet_naddr_t *, addr32_t *, addr128_t *,
    114124    uint8_t *);
    115125
     
    125135    sockaddr_in6_t *);
    126136
     137extern ip_ver_t ipver_from_af(int af);
     138extern int inet_addr_sockaddr(const inet_addr_t *, uint16_t, sockaddr_t **,
     139    socklen_t *);
     140
    127141#endif
    128142
  • uspace/lib/c/include/inet/dnsr.h

    r6297465 r4c14b88  
    5151
    5252extern int dnsr_init(void);
    53 extern int dnsr_name2host(const char *, dnsr_hostinfo_t **, uint16_t);
     53extern int dnsr_name2host(const char *, dnsr_hostinfo_t **, ip_ver_t);
    5454extern void dnsr_hostinfo_destroy(dnsr_hostinfo_t *);
    5555extern int dnsr_get_srvaddr(inet_addr_t *);
  • uspace/lib/c/include/inet/inetcfg.h

    r6297465 r4c14b88  
    4848extern int inetcfg_get_link_list(sysarg_t **, size_t *);
    4949extern int inetcfg_get_sroute_list(sysarg_t **, size_t *);
     50extern int inetcfg_link_add(sysarg_t);
    5051extern int inetcfg_link_get(sysarg_t, inet_link_info_t *);
     52extern int inetcfg_link_remove(sysarg_t);
    5153extern int inetcfg_sroute_get(sysarg_t, inet_sroute_info_t *);
    5254extern int inetcfg_sroute_get_id(const char *, sysarg_t *);
  • uspace/lib/c/include/inet/inetping.h

    r6297465 r4c14b88  
    11/*
    2  * Copyright (c) 2012 Jiri Svoboda
     2 * Copyright (c) 2013 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    3838#include <inet/inet.h>
    3939#include <sys/types.h>
    40 
    41 typedef struct {
    42         uint32_t src;
    43         uint32_t dest;
    44         uint16_t seq_no;
    45         void *data;
    46         size_t size;
    47 } inetping_sdu_t;
     40#include <types/inetping.h>
    4841
    4942typedef struct inetping_ev_ops {
     
    5346extern int inetping_init(inetping_ev_ops_t *);
    5447extern int inetping_send(inetping_sdu_t *);
    55 extern int inetping_get_srcaddr(uint32_t, uint32_t *);
     48extern int inetping_get_srcaddr(const inet_addr_t *, inet_addr_t *);
    5649
    5750#endif
  • uspace/lib/c/include/inet/iplink.h

    r6297465 r4c14b88  
    3737
    3838#include <async.h>
    39 #include <sys/types.h>
    4039#include <inet/addr.h>
    4140
     
    7877
    7978typedef struct iplink_ev_ops {
    80         int (*recv)(iplink_t *, iplink_recv_sdu_t *, uint16_t);
     79        int (*recv)(iplink_t *, iplink_recv_sdu_t *, ip_ver_t);
    8180} iplink_ev_ops_t;
    8281
  • uspace/lib/c/include/inet/iplink_srv.h

    r6297465 r4c14b88  
    3939#include <fibril_synch.h>
    4040#include <stdbool.h>
    41 #include <sys/types.h>
    4241#include <inet/addr.h>
    4342#include <inet/iplink.h>
     
    6766
    6867extern int iplink_conn(ipc_callid_t, ipc_call_t *, void *);
    69 extern int iplink_ev_recv(iplink_srv_t *, iplink_recv_sdu_t *, uint16_t);
     68extern int iplink_ev_recv(iplink_srv_t *, iplink_recv_sdu_t *, ip_ver_t);
    7069
    7170#endif
  • uspace/lib/c/include/ipc/inet.h

    r6297465 r4c14b88  
    7272        INETCFG_GET_LINK_LIST,
    7373        INETCFG_GET_SROUTE_LIST,
     74        INETCFG_LINK_ADD,
    7475        INETCFG_LINK_GET,
     76        INETCFG_LINK_REMOVE,
    7577        INETCFG_SROUTE_CREATE,
    7678        INETCFG_SROUTE_DELETE,
     
    9092} inetping_request_t;
    9193
    92 /** Events on Inet ping6 port */
    93 typedef enum {
    94         INETPING6_EV_RECV = IPC_FIRST_USER_METHOD
    95 } inetping6_event_t;
    96 
    97 /** Requests on Inet ping6 port */
    98 typedef enum {
    99         INETPING6_SEND = IPC_FIRST_USER_METHOD,
    100         INETPING6_GET_SRCADDR
    101 } inetping6_request_t;
    102 
    10394#endif
    10495
  • uspace/lib/c/include/ipc/services.h

    r6297465 r4c14b88  
    5454
    5555#define SERVICE_NAME_CORECFG    "corecfg"
     56#define SERVICE_NAME_DHCP       "net/dhcp"
    5657#define SERVICE_NAME_DNSR       "net/dnsr"
    5758#define SERVICE_NAME_INET       "net/inet"
     
    5960#define SERVICE_NAME_INETPING   "net/inetping"
    6061#define SERVICE_NAME_INETPING6  "net/inetping6"
     62#define SERVICE_NAME_NETCONF    "net/netconf"
    6163
    6264#endif
  • uspace/lib/c/include/setjmp.h

    r6297465 r4c14b88  
    11/*
    22 * Copyright (c) 2008 Josef Cejka
     3 * Copyright (c) 2013 Vojtech Horky
    34 * All rights reserved.
    45 *
     
    3031 * @{
    3132 */
    32 /** @file
     33/** @file Long jump implementation.
     34 *
     35 * Implementation inspired by Jiri Zarevucky's code from
     36 * http://bazaar.launchpad.net/~zarevucky-jiri/helenos/stdc/revision/1544/uspace/lib/posix/setjmp.h
    3337 */
    3438
     
    3842#include <libarch/fibril.h>
    3943
    40 typedef context_t jmp_buf[1];
     44struct jmp_buf_interal {
     45        context_t context;
     46        int return_value;
     47};
     48typedef struct jmp_buf_interal jmp_buf[1];
    4149
    42 extern int setjmp(jmp_buf env);
     50/*
     51 * Specified as extern to minimize number of included headers
     52 * because this file is used as is in libposix too.
     53 */
     54extern int context_save(context_t *ctx) __attribute__((returns_twice));
     55
     56/**
     57 * Save current environment (registers).
     58 *
     59 * This function may return twice.
     60 *
     61 * @param env Variable where to save the environment (of type jmp_buf).
     62 * @return Whether the call returned after longjmp.
     63 * @retval 0 Environment was saved, normal execution.
     64 * @retval other longjmp was executed and returned here.
     65 */
     66#define setjmp(env) \
     67        ((env)[0].return_value = 0, \
     68        context_save(&(env)[0].context), \
     69        (env)[0].return_value)
     70
    4371extern void longjmp(jmp_buf env, int val) __attribute__((noreturn));
    4472
  • uspace/lib/c/include/stdio.h

    r6297465 r4c14b88  
    151151/* Misc file functions */
    152152extern int rename(const char *, const char *);
     153extern int remove(const char *);
    153154
    154155#endif
  • uspace/lib/c/include/types/inetping.h

    r6297465 r4c14b88  
    11/*
    2  * Copyright (c) 2013 Martin Decky
     2 * Copyright (c) 2013 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    3030 * @{
    3131 */
    32 /** @file
     32/**
     33 * @file
     34 * @brief
    3335 */
    3436
    35 #ifndef LIBC_INET_INETPING6_H_
    36 #define LIBC_INET_INETPING6_H_
     37#ifndef LIBC_TYPES_INETPING_H_
     38#define LIBC_TYPES_INETPING_H_
    3739
    38 #include <inet/inet.h>
     40#include <inet/addr.h>
    3941#include <sys/types.h>
    4042
    4143typedef struct {
    42         addr128_t src;
    43         addr128_t dest;
     44        inet_addr_t src;
     45        inet_addr_t dest;
    4446        uint16_t seq_no;
    4547        void *data;
    4648        size_t size;
    47 } inetping6_sdu_t;
    48 
    49 typedef struct inetping6_ev_ops {
    50         int (*recv)(inetping6_sdu_t *);
    51 } inetping6_ev_ops_t;
    52 
    53 extern int inetping6_init(inetping6_ev_ops_t *);
    54 extern int inetping6_send(inetping6_sdu_t *);
    55 extern int inetping6_get_srcaddr(addr128_t, addr128_t);
     49} inetping_sdu_t;
    5650
    5751#endif
  • uspace/lib/gui/canvas.c

    r6297465 r4c14b88  
    105105static void canvas_handle_keyboard_event(widget_t *widget, kbd_event_t event)
    106106{
    107         /* No-op */
     107        canvas_t *canvas = (canvas_t *) widget;
     108       
     109        sig_send(&canvas->keyboard_event, &event);
    108110}
    109111
    110112static void canvas_handle_position_event(widget_t *widget, pos_event_t event)
    111113{
    112         /* No-op */
     114        canvas_t *canvas = (canvas_t *) widget;
     115        pos_event_t tevent;
     116       
     117        tevent = event;
     118        tevent.hpos -= widget->hpos;
     119        tevent.vpos -= widget->vpos;
     120       
     121        sig_send(&canvas->position_event, &tevent);
    113122}
    114123
     
    142151}
    143152
     153bool update_canvas(canvas_t *canvas, surface_t *surface)
     154{
     155        if (surface != NULL)
     156                canvas->surface = surface;
     157       
     158        canvas_repaint(&canvas->widget);
     159        return true;
     160}
     161
    144162canvas_t *create_canvas(widget_t *parent, sysarg_t width, sysarg_t height,
    145163    surface_t *surface)
  • uspace/lib/gui/canvas.h

    r6297465 r4c14b88  
    4242#include <surface.h>
    4343#include "widget.h"
     44#include "connection.h"
    4445
    4546typedef struct {
     
    4849        sysarg_t height;
    4950        surface_t *surface;
     51        signal_t keyboard_event;
     52        signal_t position_event;
    5053} canvas_t;
    5154
     
    5356    surface_t *);
    5457extern canvas_t *create_canvas(widget_t *, sysarg_t, sysarg_t, surface_t *);
     58extern bool update_canvas(canvas_t *, surface_t *);
    5559extern void deinit_canvas(canvas_t *);
    5660
  • uspace/lib/gui/window.c

    r6297465 r4c14b88  
    529529}
    530530
    531 window_t *window_open(char *winreg, bool is_main, bool is_decorated,
     531window_t *window_open(const char *winreg, bool is_main, bool is_decorated,
    532532    const char *caption, sysarg_t x_offset, sysarg_t y_offset)
    533533{
  • uspace/lib/gui/window.h

    r6297465 r4c14b88  
    6666 * If the window is declared as main, its closure causes termination of the
    6767 * whole application. Note that opened window does not have any surface yet. */
    68 extern window_t *window_open(char *, bool, bool, const char *, sysarg_t, sysarg_t);
     68extern window_t *window_open(const char *, bool, bool, const char *, sysarg_t,
     69    sysarg_t);
    6970
    7071/**
  • uspace/lib/http/Makefile

    r6297465 r4c14b88  
    3131SLIBRARY = libhttp.so.0.0
    3232LSONAME = libhttp.so0
    33 #EXTRA_CFLAGS +=
     33EXTRA_CFLAGS += -Iinclude
    3434
    3535SOURCES = \
    36         http.c
     36        src/http.c \
     37        src/headers.c \
     38        src/request.c \
     39        src/response.c \
     40        src/receive-buffer.c
    3741
    3842include $(USPACE_PREFIX)/Makefile.common
  • uspace/lib/http/include/http/http.h

    r6297465 r4c14b88  
    4141#include <inet/addr.h>
    4242
     43#include "receive-buffer.h"
     44
    4345typedef struct {
    4446        char *host;
     
    5052       
    5153        size_t buffer_size;
    52         char *recv_buffer;
    53         size_t recv_buffer_in;
    54         size_t recv_buffer_out;
     54        receive_buffer_t recv_buffer;
    5555} http_t;
    5656
     
    6767
    6868typedef struct {
     69        list_t list;
     70} http_headers_t;
     71
     72typedef struct {
    6973        char *method;
    7074        char *path;
    71         list_t headers;
     75        http_headers_t headers;
    7276} http_request_t;
    7377
     
    7680        uint16_t status;
    7781        char *message;
    78         list_t headers;
     82        http_headers_t headers;
    7983} http_response_t;
    8084
    8185extern http_t *http_create(const char *, uint16_t);
    8286extern int http_connect(http_t *);
     87
     88extern void http_header_init(http_header_t *);
    8389extern http_header_t *http_header_create(const char *, const char *);
    84 extern http_header_t *http_header_create_no_copy(char *, char *);
     90extern int http_header_receive_name(receive_buffer_t *, receive_buffer_mark_t *);
     91extern int http_header_receive_value(receive_buffer_t *, receive_buffer_mark_t *,
     92    receive_buffer_mark_t *);
     93extern int http_header_receive(receive_buffer_t *, http_header_t *, size_t,
     94    size_t *);
     95extern void http_header_normalize_value(char *);
     96extern bool http_header_name_match(const char *, const char *);
     97ssize_t http_header_encode(http_header_t *, char *, size_t);
    8598extern void http_header_destroy(http_header_t *);
     99
     100extern void http_headers_init(http_headers_t *);
     101extern int http_headers_find_single(http_headers_t *, const char *,
     102    http_header_t **);
     103extern int http_headers_append(http_headers_t *, const char *, const char *);
     104extern int http_headers_set(http_headers_t *, const char *, const char *);
     105extern int http_headers_get(http_headers_t *, const char *, char **);
     106extern int http_headers_receive(receive_buffer_t *, http_headers_t *, size_t,
     107    unsigned);
     108extern void http_headers_clear(http_headers_t *);
     109
     110#define http_headers_foreach(headers, iter) \
     111    list_foreach((headers).list, link, http_header_t, (iter))
     112
     113static inline void http_headers_remove(http_headers_t *headers,
     114    http_header_t *header)
     115{
     116        list_remove(&header->link);
     117}
     118
     119static inline void http_headers_append_header(http_headers_t *headers,
     120    http_header_t *header)
     121{
     122        list_append(&header->link, &headers->list);
     123}
     124
    86125extern http_request_t *http_request_create(const char *, const char *);
    87126extern void http_request_destroy(http_request_t *);
    88127extern int http_request_format(http_request_t *, char **, size_t *);
    89128extern int http_send_request(http_t *, http_request_t *);
    90 extern int http_parse_status(const char *, http_version_t *, uint16_t *,
     129extern int http_receive_status(receive_buffer_t *, http_version_t *, uint16_t *,
    91130    char **);
    92 extern int http_parse_header(const char *, char **, char **);
    93 extern int http_receive_response(http_t *, http_response_t **);
    94 extern int http_receive_body(http_t *, void *, size_t);
     131extern int http_receive_response(receive_buffer_t *, http_response_t **,
     132    size_t, unsigned);
    95133extern void http_response_destroy(http_response_t *);
    96134extern int http_close(http_t *);
  • uspace/lib/math/Makefile

    r6297465 r4c14b88  
    11#
    2 # Copyright (c) 2013 Antonin Steinhauser
     2# Copyright (c) 2013 Vojtech Horky
    33# All rights reserved.
    44#
     
    2828
    2929USPACE_PREFIX = ../..
    30 BINARY = ping6
     30LIBRARY = libmath
    3131
    3232SOURCES = \
    33         ping6.c
     33        src/dummy.c
    3434
    3535include $(USPACE_PREFIX)/Makefile.common
  • uspace/lib/net/include/socket_core.h

    r6297465 r4c14b88  
    4343#include <adt/int_map.h>
    4444#include <net/in.h>
    45 #include <net/device.h>
    4645#include <async.h>
    4746
  • uspace/lib/posix/Makefile

    r6297465 r4c14b88  
    4242FIXED_C_LIBRARY = libc4posix.a
    4343
    44 REDEFS_HIDE_LIBC = redefs-hide-libc.xargs
    45 REDEFS_SHOW_LIBPOSIX = redefs-show-posix.xargs
     44REDEFS_HIDE_LIBC = redefs-hide-libc-symbols.list
     45REDEFS_SHOW_LIBPOSIX = redefs-show-posix-symbols.list
    4646COLLISIONS_LIST = collisions.list
    4747
     
    6060        source/getopt.c \
    6161        source/locale.c \
    62         source/math.c \
     62        source/pthread/condvar.c \
     63        source/pthread/keys.c \
     64        source/pthread/mutex.c \
     65        source/pthread/threads.c \
    6366        source/pwd.c \
    6467        source/signal.c \
     
    8184
    8285$(FIXED_C_LIBRARY): $(REDEFS_HIDE_LIBC) $(REDEFS_SHOW_LIBPOSIX)
    83         ./tools/transform-symbols.sh \
    84                 $(OBJCOPY) $(AR) echo \
    85                 $(LIBC_FILE) $@ \
    86                 $(REDEFS_HIDE_LIBC) $(REDEFS_SHOW_LIBPOSIX)
     86        $(OBJCOPY) --redefine-syms=$(REDEFS_HIDE_LIBC) $(LIBC_FILE) $@
     87        $(OBJCOPY) --redefine-syms=$(REDEFS_SHOW_LIBPOSIX) $@ $@
    8788
    8889$(FIXED_POSIX_LIBRARY): $(LIBRARY).a $(REDEFS_HIDE_LIBC) $(REDEFS_SHOW_LIBPOSIX)
    89         ./tools/transform-symbols.sh \
    90                 $(OBJCOPY) $(AR) echo \
    91                 $(LIBRARY).a $@ \
    92                 $(REDEFS_HIDE_LIBC) $(REDEFS_SHOW_LIBPOSIX)
     90        $(OBJCOPY) --redefine-syms=$(REDEFS_HIDE_LIBC) $(LIBRARY).a $@
     91        $(OBJCOPY) --redefine-syms=$(REDEFS_SHOW_LIBPOSIX) $@ $@
    9392
    9493$(REDEFS_HIDE_LIBC): $(COLLISIONS_LIST)
    95         ./tools/create-redefines.sh "" "__helenos_libc_" <$(COLLISIONS_LIST) >$@
    96        
     94        sed 's/.*/& __helenos_libc_&/' <$(COLLISIONS_LIST) >$@
     95
    9796$(REDEFS_SHOW_LIBPOSIX): $(COLLISIONS_LIST)
    98         ./tools/create-redefines.sh "posix_" "" <$(COLLISIONS_LIST) >$@
     97        sed 's/.*/posix_& &/' <$(COLLISIONS_LIST) >$@
    9998
    10099$(COLLISIONS_LIST):
    101         ./tools/get-collision-list.sh ./include/posix >$@
     100        find ./include/posix -name '*.h' -exec \
     101                sed -n -e '/^#/d' -e 's/__POSIX_DEF__/\n&/gp' {} \; | \
     102                sed -n -e 's/__POSIX_DEF__(\([^)]*\)).*/\1/p' | \
     103                sort -u >$@
  • uspace/lib/posix/include/posix/float.h

    r6297465 r4c14b88  
    5959        #undef DBL_EPSILON
    6060        #define DBL_EPSILON __DBL_EPSILON__
     61        #undef LDBL_EPSILON
     62        #define LDBL_EPSILON __LDBL_EPSILON__
    6163        #undef FLT_RADIX
    6264        #define FLT_RADIX __FLT_RADIX__
     65        #undef FLT_MIN
     66        #define FLT_MIN __FLT_MIN__
     67        #undef FLT_MAX
     68        #define FLT_MAX __FLT_MAX__
     69        #undef FLT_EPSILON
     70        #define FLT_EPSILON __FLT_EPSILON__
     71        #undef FLT_MANT_DIG
     72        #define FLT_MANT_DIG __FLT_MANT_DIG__
     73        #undef LDBL_MIN
     74        #define LDBL_MIN __LDBL_MIN__
     75        #undef LDBL_MAX
     76        #define LDBL_MAX __LDBL_MAX__
     77        #undef LDBL_MANT_DIG
     78        #define LDBL_MANT_DIG __LDBL_MANT_DIG__
    6379#else
    6480/* For something else than GCC, following definitions are provided.
  • uspace/lib/posix/include/posix/math.h

    r6297465 r4c14b88  
    3636#define POSIX_MATH_H_
    3737
    38 #ifndef __POSIX_DEF__
    39 #define __POSIX_DEF__(x) x
    40 #endif
    41 
    42 #ifdef __GNUC__
    43         #define HUGE_VAL (__builtin_huge_val())
    44 #endif
    45 
    46 /* Normalization Functions */
    47 extern double __POSIX_DEF__(ldexp)(double x, int exp);
    48 extern double __POSIX_DEF__(frexp)(double num, int *exp);
    49 
    50 double __POSIX_DEF__(fabs)(double x);
    51 double __POSIX_DEF__(floor)(double x);
    52 double __POSIX_DEF__(modf)(double x, double *iptr);
    53 double __POSIX_DEF__(fmod)(double x, double y);
    54 double __POSIX_DEF__(pow)(double x, double y);
    55 double __POSIX_DEF__(exp)(double x);
    56 double __POSIX_DEF__(sqrt)(double x);
    57 double __POSIX_DEF__(log)(double x);
    58 double __POSIX_DEF__(sin)(double x);
    59 double __POSIX_DEF__(cos)(double x);
    60 double __POSIX_DEF__(atan2)(double y, double x);
     38#include "libc/math.h"
    6139
    6240#endif /* POSIX_MATH_H_ */
  • uspace/lib/posix/include/posix/setjmp.h

    r6297465 r4c14b88  
    2727 */
    2828
    29 /** @addtogroup libc
     29/** @addtogroup libposix
    3030 * @{
    3131 */
    3232
    33 #include <bitops.h>
    34 
    35 extern int __popcountsi2(int a)
    36 {
    37         return __builtin_popcount(a);
    38 }
    39 
     33/*
     34 * Just a pass-through to libc setjmp.
     35 */
     36#include "libc/setjmp.h"
    4037
    4138/** @}
  • uspace/lib/posix/include/posix/stdint.h

    r6297465 r4c14b88  
    108108
    109109
     110/*
     111 * Fast* and least* integer types.
     112 *
     113 * The definitions below are definitely safe if not the best.
     114 */
     115typedef uint8_t uint_least8_t;
     116typedef uint16_t uint_least16_t;
     117typedef uint32_t uint_least32_t;
     118typedef uint64_t uint_least64_t;
     119
     120typedef int8_t int_least8_t;
     121typedef int16_t int_least16_t;
     122typedef int32_t int_least32_t;
     123typedef int64_t int_least64_t;
     124
     125typedef uint8_t uint_fast8_t;
     126typedef uint16_t uint_fast16_t;
     127typedef uint32_t uint_fast32_t;
     128typedef uint64_t uint_fast64_t;
     129
     130typedef int8_t int_fast8_t;
     131typedef int16_t int_fast16_t;
     132typedef int32_t int_fast32_t;
     133typedef int64_t int_fast64_t;
     134
    110135#endif /* POSIX_STDINT_H_ */
    111136
  • uspace/lib/posix/include/posix/stdio.h

    r6297465 r4c14b88  
    123123
    124124extern void setvbuf(FILE *, void *, int, size_t);
    125 
     125extern void setbuf(FILE *, void *);
    126126
    127127/* POSIX specific stuff. */
  • uspace/lib/posix/include/posix/stdlib.h

    r6297465 r4c14b88  
    5656#define _Exit exit
    5757extern int __POSIX_DEF__(atexit)(void (*func)(void));
    58 extern void exit(int status);
     58extern void exit(int status) __attribute__((noreturn));
    5959extern void abort(void) __attribute__((noreturn));
    6060
  • uspace/lib/posix/include/posix/time.h

    r6297465 r4c14b88  
    104104extern char *__POSIX_DEF__(ctime_r)(const time_t *timer, char *buf);
    105105extern char *__POSIX_DEF__(ctime)(const time_t *timer);
     106extern time_t time(time_t *t);
    106107
    107108/* Clocks */
  • uspace/lib/posix/source/internal/common.h

    r6297465 r4c14b88  
    3939#include <stdlib.h>
    4040
    41 #define not_implemented() (fprintf(stderr, \
    42     "Function %s() in file %s at line %d is not implemented\n", \
    43     __func__, __FILE__, __LINE__), abort())
     41#define not_implemented() do { \
     42                static int __not_implemented_counter = 0; \
     43                if (__not_implemented_counter == 0) { \
     44                        fprintf(stderr, "%s() not implemented in %s:%d, something will NOT work.\n", \
     45                                __func__, __FILE__, __LINE__); \
     46                } \
     47                __not_implemented_counter++; \
     48        } while (0)
    4449
    4550/* A little helper macro to avoid typing this over and over. */
  • uspace/lib/posix/source/stdlib.c

    r6297465 r4c14b88  
    6363        // TODO: low priority, just a compile-time dependency of binutils
    6464        not_implemented();
    65         return 1;
     65        return 0;
    6666}
    6767
  • uspace/lib/posix/source/unistd.c

    r6297465 r4c14b88  
    389389        // TODO: low priority, just a compile-time dependency of binutils
    390390        not_implemented();
     391        return -1;
    391392}
    392393
     
    399400        // TODO: low priority, just a compile-time dependency of binutils
    400401        not_implemented();
     402        return -1;
    401403}
    402404
     
    411413        // TODO: low priority, just a compile-time dependency of binutils
    412414        not_implemented();
     415        return -1;
    413416}
    414417
     
    423426        // TODO: low priority, just a compile-time dependency of binutils
    424427        not_implemented();
     428        return -1;
    425429}
    426430
     
    434438        // TODO: low priority, just a compile-time dependency of binutils
    435439        not_implemented();
     440        return -1;
    436441}
    437442
  • uspace/lib/softfloat/softfloat.c

    r6297465 r4c14b88  
    12651265}
    12661266
     1267float __aeabi_d2f(double a)
     1268{
     1269        return __truncdfsf2(a);
     1270}
     1271
     1272double __aeabi_f2d(float a)
     1273{
     1274        return __extendsfdf2(a);
     1275}
     1276
     1277
    12671278float __aeabi_i2f(int i)
    12681279{
     
    12851296}
    12861297
     1298double __aeabi_l2d(long long i)
     1299{
     1300        return __floattidf(i);
     1301}
     1302
     1303float __aeabi_l2f(long long i)
     1304{
     1305        return __floattisf(i);
     1306}
     1307
     1308float __aeabi_ul2f(unsigned long long u)
     1309{
     1310        return __floatuntisf(u);
     1311}
     1312
    12871313int __aeabi_f2iz(float a)
    12881314{
     
    13051331}
    13061332
     1333long long __aeabi_d2lz(double a)
     1334{
     1335        return __fixdfti(a);
     1336}
     1337
    13071338int __aeabi_fcmpge(float a, float b)
    13081339{
     
    13391370        return __ltdf2(a, b);
    13401371}
     1372
     1373int __aeabi_dcmple(double a, double b)
     1374{
     1375        return __ledf2(a, b);
     1376}
     1377
    13411378
    13421379int __aeabi_dcmpeq(double a, double b)
  • uspace/lib/softfloat/softfloat.h

    r6297465 r4c14b88  
    204204
    205205/* ARM EABI */
     206extern float __aeabi_d2f(double);
     207extern double __aeabi_f2d(float);
    206208extern float __aeabi_i2f(int);
    207209extern float __aeabi_ui2f(int);
    208210extern double __aeabi_i2d(int);
    209211extern double __aeabi_ui2d(unsigned int);
     212extern double __aeabi_l2d(long long);
     213extern float __aeabi_l2f(long long);
     214extern float __aeabi_ul2f(unsigned long long);
    210215extern unsigned int __aeabi_d2uiz(double);
     216extern long long __aeabi_d2lz(double);
    211217
    212218extern int __aeabi_f2iz(float);
     
    222228extern int __aeabi_dcmpgt(double, double);
    223229extern int __aeabi_dcmplt(double, double);
     230extern int __aeabi_dcmple(double, double);
    224231extern int __aeabi_dcmpeq(double, double);
    225232
  • uspace/lib/softint/Makefile

    r6297465 r4c14b88  
    3535
    3636SOURCES = \
     37        generic/bits.c \
    3738        generic/comparison.c \
    3839        generic/division.c \
  • uspace/lib/softint/generic/shift.c

    r6297465 r4c14b88  
    123123}
    124124
     125long long __aeabi_llsl(long long val, int shift)
     126{
     127        return __ashldi3(val, shift);
     128}
     129
    125130/** @}
    126131 */
  • uspace/lib/softint/include/shift.h

    r6297465 r4c14b88  
    4646extern long long __lshrdi3(long long, int);
    4747
     48
     49/* ARM EABI */
     50extern long long __aeabi_llsl(long long, int);
     51
    4852#endif
    4953
Note: See TracChangeset for help on using the changeset viewer.