Changeset 0b9ac3c in mainline for uspace/lib


Ignore:
Timestamp:
2010-02-23T19:03:28Z (16 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
c62d2e1
Parents:
1ccafee (diff), 5e50394 (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
Files:
22 added
69 edited
1 moved

Legend:

Unmodified
Added
Removed
  • uspace/lib/Makefile.common

    r1ccafee r0b9ac3c  
    3333# Individual makefiles set:
    3434#
    35 #       USPACE_PREFIX   relative path to uspace/ directory
    36 #       LIBS            libraries to link with (with relative path)
    37 #       EXTRA_CFLAGS    additional flags to pass to C compiler
    38 #       JOB             job file name (like appname.job)
    39 #       OUTPUT          output binary name (like appname)
    40 #       SOURCES         list of source files
     35#   USPACE_PREFIX  relative path to uspace/ directory
     36#   LIBS           libraries to link with (with relative path)
     37#   EXTRA_CFLAGS   additional flags to pass to C compiler
     38#   JOB            job file name (like appname.job)
     39#   OUTPUT         output binary name (like appname)
     40#   SOURCES        list of source files
    4141#
    4242
     
    7272        find . -name '*.o' -follow -exec rm \{\} \;
    7373
    74 build: 
     74build:
    7575
    7676-include $(DEPEND)
  • uspace/lib/libblock/libblock.c

    r1ccafee r0b9ac3c  
    11/*
    2  * Copyright (c) 2008 Jakub Jermar 
    3  * Copyright (c) 2008 Martin Decky 
     2 * Copyright (c) 2008 Jakub Jermar
     3 * Copyright (c) 2008 Martin Decky
    44 * All rights reserved.
    55 *
     
    5252#include <macros.h>
    5353#include <mem.h>
     54#include <sys/typefmt.h>
     55#include <stacktrace.h>
    5456
    5557/** Lock protecting the device connection list */
     
    7981        size_t comm_size;
    8082        void *bb_buf;
    81         bn_t bb_addr;
     83        aoff64_t bb_addr;
    8284        size_t pblock_size;             /**< Physical block size. */
    8385        cache_t *cache;
    8486} devcon_t;
    8587
    86 static int read_blocks(devcon_t *devcon, bn_t ba, size_t cnt);
    87 static int write_blocks(devcon_t *devcon, bn_t ba, size_t cnt);
     88static int read_blocks(devcon_t *devcon, aoff64_t ba, size_t cnt);
     89static int write_blocks(devcon_t *devcon, aoff64_t ba, size_t cnt);
    8890static int get_block_size(int dev_phone, size_t *bsize);
    89 static int get_num_blocks(int dev_phone, bn_t *nblocks);
     91static int get_num_blocks(int dev_phone, aoff64_t *nblocks);
    9092
    9193static devcon_t *devcon_search(dev_handle_t dev_handle)
     
    198200        assert(devcon);
    199201       
     202        if (devcon->cache)
     203                (void) block_cache_fini(dev_handle);
     204
    200205        devcon_remove(devcon);
    201206
     
    203208                free(devcon->bb_buf);
    204209
    205         if (devcon->cache) {
    206                 hash_table_destroy(&devcon->cache->block_hash);
    207                 free(devcon->cache);
    208         }
    209 
    210210        munmap(devcon->comm_area, devcon->comm_size);
    211211        ipc_hangup(devcon->dev_phone);
     
    214214}
    215215
    216 int block_bb_read(dev_handle_t dev_handle, bn_t ba)
     216int block_bb_read(dev_handle_t dev_handle, aoff64_t ba)
    217217{
    218218        void *bb_buf;
     
    305305}
    306306
     307int block_cache_fini(dev_handle_t dev_handle)
     308{
     309        devcon_t *devcon = devcon_search(dev_handle);
     310        cache_t *cache;
     311        int rc;
     312
     313        if (!devcon)
     314                return ENOENT;
     315        if (!devcon->cache)
     316                return EOK;
     317        cache = devcon->cache;
     318       
     319        /*
     320         * We are expecting to find all blocks for this device handle on the
     321         * free list, i.e. the block reference count should be zero. Do not
     322         * bother with the cache and block locks because we are single-threaded.
     323         */
     324        while (!list_empty(&cache->free_head)) {
     325                block_t *b = list_get_instance(cache->free_head.next,
     326                    block_t, free_link);
     327
     328                list_remove(&b->free_link);
     329                if (b->dirty) {
     330                        memcpy(devcon->comm_area, b->data, b->size);
     331                        rc = write_blocks(devcon, b->boff, 1);
     332                        if (rc != EOK)
     333                                return rc;
     334                }
     335
     336                unsigned long key = b->boff;
     337                hash_table_remove(&cache->block_hash, &key, 1);
     338               
     339                free(b->data);
     340                free(b);
     341        }
     342
     343        hash_table_destroy(&cache->block_hash);
     344        devcon->cache = NULL;
     345        free(cache);
     346
     347        return EOK;
     348}
     349
    307350#define CACHE_LO_WATERMARK      10     
    308351#define CACHE_HI_WATERMARK      20     
     
    339382 * @return                      EOK on success or a negative error code.
    340383 */
    341 int block_get(block_t **block, dev_handle_t dev_handle, bn_t boff, int flags)
     384int block_get(block_t **block, dev_handle_t dev_handle, aoff64_t boff, int flags)
    342385{
    343386        devcon_t *devcon;
     
    614657 * @return              EOK on success or a negative return code on failure.
    615658 */
    616 int block_seqread(dev_handle_t dev_handle, off_t *bufpos, size_t *buflen,
    617     off_t *pos, void *dst, size_t size)
    618 {
    619         off_t offset = 0;
     659int block_seqread(dev_handle_t dev_handle, size_t *bufpos, size_t *buflen,
     660    aoff64_t *pos, void *dst, size_t size)
     661{
     662        size_t offset = 0;
    620663        size_t left = size;
    621664        size_t block_size;
     
    647690                }
    648691               
    649                 if (*bufpos == (off_t) *buflen) {
     692                if (*bufpos == *buflen) {
    650693                        /* Refill the communication buffer with a new block. */
    651694                        int rc;
     
    675718 * @return              EOK on success or negative error code on failure.
    676719 */
    677 int block_read_direct(dev_handle_t dev_handle, bn_t ba, size_t cnt, void *buf)
     720int block_read_direct(dev_handle_t dev_handle, aoff64_t ba, size_t cnt, void *buf)
    678721{
    679722        devcon_t *devcon;
     
    703746 * @return              EOK on success or negative error code on failure.
    704747 */
    705 int block_write_direct(dev_handle_t dev_handle, bn_t ba, size_t cnt,
     748int block_write_direct(dev_handle_t dev_handle, aoff64_t ba, size_t cnt,
    706749    const void *data)
    707750{
     
    746789 * @return              EOK on success or negative error code on failure.
    747790 */
    748 int block_get_nblocks(dev_handle_t dev_handle, bn_t *nblocks)
     791int block_get_nblocks(dev_handle_t dev_handle, aoff64_t *nblocks)
    749792{
    750793        devcon_t *devcon;
     
    765808 * @return              EOK on success or negative error code on failure.
    766809 */
    767 static int read_blocks(devcon_t *devcon, bn_t ba, size_t cnt)
     810static int read_blocks(devcon_t *devcon, aoff64_t ba, size_t cnt)
    768811{
    769812        int rc;
     
    772815        rc = async_req_3_0(devcon->dev_phone, BD_READ_BLOCKS, LOWER32(ba),
    773816            UPPER32(ba), cnt);
     817        if (rc != EOK) {
     818                printf("Error %d reading %d blocks starting at block %" PRIuOFF64
     819                    " from device handle %d\n", rc, cnt, ba,
     820                    devcon->dev_handle);
     821#ifndef NDEBUG
     822                stacktrace_print();
     823#endif
     824        }
    774825        return rc;
    775826}
     
    784835 * @return              EOK on success or negative error code on failure.
    785836 */
    786 static int write_blocks(devcon_t *devcon, bn_t ba, size_t cnt)
     837static int write_blocks(devcon_t *devcon, aoff64_t ba, size_t cnt)
    787838{
    788839        int rc;
     
    791842        rc = async_req_3_0(devcon->dev_phone, BD_WRITE_BLOCKS, LOWER32(ba),
    792843            UPPER32(ba), cnt);
     844        if (rc != EOK) {
     845                printf("Error %d writing %d blocks starting at block %" PRIuOFF64
     846                    " to device handle %d\n", rc, cnt, ba, devcon->dev_handle);
     847#ifndef NDEBUG
     848                stacktrace_print();
     849#endif
     850        }
    793851        return rc;
    794852}
     
    808866
    809867/** Get total number of blocks on block device. */
    810 static int get_num_blocks(int dev_phone, bn_t *nblocks)
     868static int get_num_blocks(int dev_phone, aoff64_t *nblocks)
    811869{
    812870        ipcarg_t nb_l, nb_h;
     
    815873        rc = async_req_0_2(dev_phone, BD_GET_NUM_BLOCKS, &nb_l, &nb_h);
    816874        if (rc == EOK) {
    817                 *nblocks = (bn_t) MERGE_LOUP32(nb_l, nb_h);
     875                *nblocks = (aoff64_t) MERGE_LOUP32(nb_l, nb_h);
    818876        }
    819877
  • uspace/lib/libblock/libblock.h

    r1ccafee r0b9ac3c  
    7474        dev_handle_t dev_handle;
    7575        /** Block offset on the block device. Counted in 'size'-byte blocks. */
    76         bn_t boff;
     76        aoff64_t boff;
    7777        /** Size of the block. */
    7878        size_t size;
     
    9696extern void block_fini(dev_handle_t);
    9797
    98 extern int block_bb_read(dev_handle_t, bn_t);
     98extern int block_bb_read(dev_handle_t, aoff64_t);
    9999extern void *block_bb_get(dev_handle_t);
    100100
    101101extern int block_cache_init(dev_handle_t, size_t, unsigned, enum cache_mode);
     102extern int block_cache_fini(dev_handle_t);
    102103
    103 extern int block_get(block_t **, dev_handle_t, bn_t, int);
     104extern int block_get(block_t **, dev_handle_t, aoff64_t, int);
    104105extern int block_put(block_t *);
    105106
    106 extern int block_seqread(dev_handle_t, off_t *, size_t *, off_t *, void *,
     107extern int block_seqread(dev_handle_t, size_t *, size_t *, aoff64_t *, void *,
    107108    size_t);
    108109
    109110extern int block_get_bsize(dev_handle_t, size_t *);
    110 extern int block_get_nblocks(dev_handle_t, bn_t *);
    111 extern int block_read_direct(dev_handle_t, bn_t, size_t, void *);
    112 extern int block_write_direct(dev_handle_t, bn_t, size_t, const void *);
     111extern int block_get_nblocks(dev_handle_t, aoff64_t *);
     112extern int block_read_direct(dev_handle_t, aoff64_t, size_t, void *);
     113extern int block_write_direct(dev_handle_t, aoff64_t, size_t, const void *);
    113114
    114115#endif
  • uspace/lib/libc/Makefile

    r1ccafee r0b9ac3c  
    3131
    3232USPACE_PREFIX = $(shell pwd)/../..
    33 #LIBS = $(LIBC_PREFIX)/libc.a
    3433LIBS =
    3534
     
    9190        generic/stacktrace.c
    9291
    93 ARCH_SOURCES = \
    94         arch/$(UARCH)/src/entry.s \
    95         arch/$(UARCH)/src/thread_entry.s
    96 
    9792SOURCES = \
    9893        $(GENERIC_SOURCES) \
  • uspace/lib/libc/Makefile.toolchain

    r1ccafee r0b9ac3c  
    3030        -fexec-charset=UTF-8 -fwide-exec-charset=UTF-32$(ENDIANESS) \
    3131        -finput-charset=UTF-8 -ffreestanding -fno-builtin -nostdlib -nostdinc \
    32         -Wall -Wextra -Wno-unused-parameter -Wmissing-prototypes \
    33         -Werror-implicit-function-declaration -pipe -g -D__$(ENDIANESS)__
     32        -Wall -Wextra -Wno-clobbered -Wno-unused-parameter -Wmissing-prototypes \
     33        -Werror-implicit-function-declaration -Werror -pipe -g -D__$(ENDIANESS)__
    3434
    3535ICC_CFLAGS = -I$(LIBC_PREFIX)/include -O3 -imacros $(LIBC_PREFIX)/../../../config.h \
     
    3737        -finput-charset=UTF-8 -ffreestanding -fno-builtin -nostdlib -nostdinc \
    3838        -Wall -Wextra -Wno-unused-parameter -Wmissing-prototypes \
    39         -Werror-implicit-function-declaration -pipe -g -D__$(ENDIANESS)__
     39        -Werror-implicit-function-declaration -Werror -pipe -g -D__$(ENDIANESS)__
    4040
    4141CLANG_CFLAGS = -I$(LIBC_PREFIX)/include -O3 -imacros $(LIBC_PREFIX)/../../../config.h \
  • uspace/lib/libc/arch/abs32le/src/thread_entry.c

    r1ccafee r0b9ac3c  
    11/*
    2  * Copyright (c) 2007 Martin Decky
     2 * Copyright (c) 2010 Martin Decky
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 #ifndef KERN_mips32_DORDER_H_
    30 #define KERN_mips32_DORDER_H_
     29/** @file
     30 */
    3131
    32 extern void ipi_broadcast_arch(int ipi);
     32#include <unistd.h>
     33#include <thread.h>
    3334
    34 #endif
     35void __thread_entry(void)
     36{
     37        __thread_main(NULL);
     38}
     39
     40/** @}
     41 */
  • uspace/lib/libc/arch/amd64/Makefile.inc

    r1ccafee r0b9ac3c  
    3434TOOLCHAIN_DIR = $(CROSS_PREFIX)/amd64/bin
    3535
    36 ARCH_SOURCES += arch/$(UARCH)/src/syscall.S \
     36ARCH_SOURCES = \
     37        arch/$(UARCH)/src/entry.s \
     38        arch/$(UARCH)/src/thread_entry.s \
     39        arch/$(UARCH)/src/syscall.S \
    3740        arch/$(UARCH)/src/fibril.S \
    3841        arch/$(UARCH)/src/tls.c \
  • uspace/lib/libc/arch/amd64/include/atomic.h

    r1ccafee r0b9ac3c  
    4242#include <atomicdflt.h>
    4343
    44 static inline void atomic_inc(atomic_t *val) {
    45         asm volatile ("lock incq %0\n" : "+m" (val->count));
     44static inline void atomic_inc(atomic_t *val)
     45{
     46        asm volatile (
     47                "lock incq %[count]\n"
     48                : [count] "+m" (val->count)
     49        );
    4650}
    4751
    48 static inline void atomic_dec(atomic_t *val) {
    49         asm volatile ("lock decq %0\n" : "+m" (val->count));
     52static inline void atomic_dec(atomic_t *val)
     53{
     54        asm volatile (
     55                "lock decq %[count]\n"
     56                : [count] "+m" (val->count)
     57        );
    5058}
    5159
    52 static inline long atomic_postinc(atomic_t *val)
     60static inline atomic_count_t atomic_postinc(atomic_t *val)
    5361{
    54         long r;
    55 
    56         asm volatile (
    57                 "movq $1, %0\n"
    58                 "lock xaddq %0, %1\n"
    59                 : "=r" (r), "+m" (val->count)
    60         );
    61 
    62         return r;
    63 }
    64 
    65 static inline long atomic_postdec(atomic_t *val)
    66 {
    67         long r;
     62        atomic_count_t r = 1;
    6863       
    6964        asm volatile (
    70                 "movq $-1, %0\n"
    71                 "lock xaddq %0, %1\n"
    72                 : "=r" (r), "+m" (val->count)
     65                "lock xaddq %[r], %[count]\n"
     66                : [count] "+m" (val->count),
     67                  [r] "+r" (r)
    7368        );
    7469       
     
    7671}
    7772
    78 #define atomic_preinc(val) (atomic_postinc(val) + 1)
    79 #define atomic_predec(val) (atomic_postdec(val) - 1)
     73static inline atomic_count_t atomic_postdec(atomic_t *val)
     74{
     75        atomic_count_t r = -1;
     76       
     77        asm volatile (
     78                "lock xaddq %[r], %[count]\n"
     79                : [count] "+m" (val->count),
     80                  [r] "+r" (r)
     81        );
     82       
     83        return r;
     84}
     85
     86#define atomic_preinc(val)  (atomic_postinc(val) + 1)
     87#define atomic_predec(val)  (atomic_postdec(val) - 1)
    8088
    8189#endif
  • uspace/lib/libc/arch/amd64/include/limits.h

    r1ccafee r0b9ac3c  
    3636#define LIBC_amd64_LIMITS_H_
    3737
    38 # define LONG_MIN MIN_INT64
    39 # define LONG_MAX MAX_INT64
    40 # define ULONG_MIN MIN_UINT64
    41 # define ULONG_MAX MAX_UINT64
     38#define LONG_MIN MIN_INT64
     39#define LONG_MAX MAX_INT64
     40#define ULONG_MIN MIN_UINT64
     41#define ULONG_MAX MAX_UINT64
     42
     43#define SIZE_MIN MIN_UINT64
     44#define SIZE_MAX MAX_UINT64
     45#define SSIZE_MIN MIN_INT64
     46#define SSIZE_MAX MAX_INT64
    4247
    4348#endif
  • uspace/lib/libc/arch/amd64/include/types.h

    r1ccafee r0b9ac3c  
    5454
    5555typedef uint64_t uintptr_t;
     56typedef uint64_t atomic_count_t;
     57typedef int64_t atomic_signed_t;
    5658
    5759#endif
  • uspace/lib/libc/arch/arm32/Makefile.inc

    r1ccafee r0b9ac3c  
    3434TOOLCHAIN_DIR = $(CROSS_PREFIX)/arm32/bin
    3535
    36 ARCH_SOURCES += arch/$(UARCH)/src/syscall.c \
     36ARCH_SOURCES = \
     37        arch/$(UARCH)/src/entry.s \
     38        arch/$(UARCH)/src/thread_entry.s \
     39        arch/$(UARCH)/src/syscall.c \
    3740        arch/$(UARCH)/src/fibril.S \
    3841        arch/$(UARCH)/src/tls.c \
  • uspace/lib/libc/arch/arm32/include/atomic.h

    r1ccafee r0b9ac3c  
    2727 */
    2828
    29 /** @addtogroup libcarm32       
     29/** @addtogroup libcarm32
    3030 * @{
    3131 */
     
    3838
    3939#define LIBC_ARCH_ATOMIC_H_
    40 #define CAS 
     40#define CAS
    4141
    4242#include <atomicdflt.h>
     
    4646extern uintptr_t *ras_page;
    4747
    48 static inline bool cas(atomic_t *val, long ov, long nv)
    49 {
    50         long ret = 0;
    51 
     48static inline bool cas(atomic_t *val, atomic_count_t ov, atomic_count_t nv)
     49{
     50        atomic_count_t ret = 0;
     51       
    5252        /*
    5353         * The following instructions between labels 1 and 2 constitute a
     
    7575                : "memory"
    7676        );
    77 
     77       
    7878        ras_page[0] = 0;
    79         asm volatile ("" ::: "memory");
     79        asm volatile (
     80                "" ::: "memory"
     81        );
    8082        ras_page[1] = 0xffffffff;
    81 
     83       
    8284        return (bool) ret;
    8385}
     
    8991 *
    9092 * @return Value after addition.
    91  */
    92 static inline long atomic_add(atomic_t *val, int i)
    93 {
    94         long ret = 0;
    95 
     93 *
     94 */
     95static inline atomic_count_t atomic_add(atomic_t *val, atomic_count_t i)
     96{
     97        atomic_count_t ret = 0;
     98       
    9699        /*
    97100         * The following instructions between labels 1 and 2 constitute a
     
    115118                : [imm] "r" (i)
    116119        );
    117 
     120       
    118121        ras_page[0] = 0;
    119         asm volatile ("" ::: "memory");
     122        asm volatile (
     123                "" ::: "memory"
     124        );
    120125        ras_page[1] = 0xffffffff;
    121 
     126       
    122127        return ret;
    123128}
     
    127132 *
    128133 * @param val Variable to be incremented.
     134 *
    129135 */
    130136static inline void atomic_inc(atomic_t *val)
     
    137143 *
    138144 * @param val Variable to be decremented.
     145 *
    139146 */
    140147static inline void atomic_dec(atomic_t *val)
     
    148155 * @param val Variable to be incremented.
    149156 * @return    Value after incrementation.
    150  */
    151 static inline long atomic_preinc(atomic_t *val)
     157 *
     158 */
     159static inline atomic_count_t atomic_preinc(atomic_t *val)
    152160{
    153161        return atomic_add(val, 1);
     
    159167 * @param val Variable to be decremented.
    160168 * @return    Value after decrementation.
    161  */
    162 static inline long atomic_predec(atomic_t *val)
     169 *
     170 */
     171static inline atomic_count_t atomic_predec(atomic_t *val)
    163172{
    164173        return atomic_add(val, -1);
     
    170179 * @param val Variable to be incremented.
    171180 * @return    Value before incrementation.
    172  */
    173 static inline long atomic_postinc(atomic_t *val)
     181 *
     182 */
     183static inline atomic_count_t atomic_postinc(atomic_t *val)
    174184{
    175185        return atomic_add(val, 1) - 1;
     
    181191 * @param val Variable to be decremented.
    182192 * @return    Value before decrementation.
    183  */
    184 static inline long atomic_postdec(atomic_t *val)
     193 *
     194 */
     195static inline atomic_count_t atomic_postdec(atomic_t *val)
    185196{
    186197        return atomic_add(val, -1) + 1;
  • uspace/lib/libc/arch/arm32/include/limits.h

    r1ccafee r0b9ac3c  
    2727 */
    2828
    29 /** @addtogroup libcarm32       
     29/** @addtogroup libcarm32
    3030 * @{
    3131 */
    32 /** @file 
     32/** @file
    3333 *  @brief Limits declarations.
    3434 */
     
    4242#define ULONG_MAX MAX_UINT32
    4343
     44#define SIZE_MIN MIN_UINT32
     45#define SIZE_MAX MAX_UINT32
     46#define SSIZE_MIN MIN_INT32
     47#define SSIZE_MAX MAX_INT32
     48
    4449#endif
    4550
  • uspace/lib/libc/arch/arm32/include/types.h

    r1ccafee r0b9ac3c  
    5555
    5656typedef uint32_t uintptr_t;
     57typedef uint32_t atomic_count_t;
     58typedef int32_t atomic_signed_t;
    5759
    5860#endif
  • uspace/lib/libc/arch/ia32/Makefile.inc

    r1ccafee r0b9ac3c  
    3434TOOLCHAIN_DIR = $(CROSS_PREFIX)/ia32/bin
    3535
    36 ARCH_SOURCES += arch/$(UARCH)/src/syscall.S \
     36ARCH_SOURCES = \
     37        arch/$(UARCH)/src/entry.s \
     38        arch/$(UARCH)/src/thread_entry.s \
     39        arch/$(UARCH)/src/syscall.S \
    3740        arch/$(UARCH)/src/fibril.S \
    3841        arch/$(UARCH)/src/tls.c \
  • uspace/lib/libc/arch/ia32/include/atomic.h

    r1ccafee r0b9ac3c  
    4040#include <atomicdflt.h>
    4141
    42 static inline void atomic_inc(atomic_t *val) {
    43         asm volatile ("lock incl %0\n" : "+m" (val->count));
     42static inline void atomic_inc(atomic_t *val)
     43{
     44        asm volatile (
     45                "lock incl %[count]\n"
     46                : [count] "+m" (val->count)
     47        );
    4448}
    4549
    46 static inline void atomic_dec(atomic_t *val) {
    47         asm volatile ("lock decl %0\n" : "+m" (val->count));
     50static inline void atomic_dec(atomic_t *val)
     51{
     52        asm volatile (
     53                "lock decl %[count]\n"
     54                : [count] "+m" (val->count)
     55        );
    4856}
    4957
    50 static inline long atomic_postinc(atomic_t *val)
     58static inline atomic_count_t atomic_postinc(atomic_t *val)
    5159{
    52         long r;
    53 
    54         asm volatile (
    55                 "movl $1, %0\n"
    56                 "lock xaddl %0, %1\n"
    57                 : "=r" (r), "+m" (val->count)
    58         );
    59 
    60         return r;
    61 }
    62 
    63 static inline long atomic_postdec(atomic_t *val)
    64 {
    65         long r;
     60        atomic_count_t r = 1;
    6661       
    6762        asm volatile (
    68                 "movl $-1, %0\n"
    69                 "lock xaddl %0, %1\n"
    70                 : "=r" (r), "+m" (val->count)
     63                "lock xaddl %[r], %[count]\n"
     64                : [count] "+m" (val->count),
     65                  [r] "+r" (r)
    7166        );
    7267       
     
    7469}
    7570
    76 #define atomic_preinc(val) (atomic_postinc(val) + 1)
    77 #define atomic_predec(val) (atomic_postdec(val) - 1)
     71static inline atomic_count_t atomic_postdec(atomic_t *val)
     72{
     73        atomic_count_t r = -1;
     74       
     75        asm volatile (
     76                "lock xaddl %[r], %[count]\n"
     77                : [count] "+m" (val->count),
     78                  [r] "+r" (r)
     79        );
     80       
     81        return r;
     82}
     83
     84#define atomic_preinc(val)  (atomic_postinc(val) + 1)
     85#define atomic_predec(val)  (atomic_postdec(val) - 1)
    7886
    7987#endif
  • uspace/lib/libc/arch/ia32/include/limits.h

    r1ccafee r0b9ac3c  
    3636#define LIBC_ia32__LIMITS_H_
    3737
    38 # define LONG_MIN MIN_INT32
    39 # define LONG_MAX MAX_INT32
    40 # define ULONG_MIN MIN_UINT32
    41 # define ULONG_MAX MAX_UINT32
     38#define LONG_MIN MIN_INT32
     39#define LONG_MAX MAX_INT32
     40#define ULONG_MIN MIN_UINT32
     41#define ULONG_MAX MAX_UINT32
     42
     43#define SIZE_MIN MIN_UINT32
     44#define SIZE_MAX MAX_UINT32
     45#define SSIZE_MIN MIN_INT32
     46#define SSIZE_MAX MAX_INT32
    4247
    4348#endif
  • uspace/lib/libc/arch/ia32/include/syscall.h

    r1ccafee r0b9ac3c  
    4040#include <kernel/syscall/syscall.h>
    4141
    42 #define __syscall0      __syscall_fast_func
    43 #define __syscall1      __syscall_fast_func
    44 #define __syscall2      __syscall_fast_func
    45 #define __syscall3      __syscall_fast_func
    46 #define __syscall4      __syscall_fast_func
    47 #define __syscall5      __syscall_slow
    48 #define __syscall6      __syscall_slow
     42#define __syscall0  __syscall_fast_func
     43#define __syscall1  __syscall_fast_func
     44#define __syscall2  __syscall_fast_func
     45#define __syscall3  __syscall_fast_func
     46#define __syscall4  __syscall_fast_func
     47#define __syscall5  __syscall_slow
     48#define __syscall6  __syscall_slow
    4949
    50 extern sysarg_t
    51 (* __syscall_fast_func)(const sysarg_t, const sysarg_t, const sysarg_t,
     50extern sysarg_t (* __syscall_fast_func)(const sysarg_t, const sysarg_t,
     51    const sysarg_t, const sysarg_t, const sysarg_t, const sysarg_t,
     52    const syscall_t);
     53
     54extern sysarg_t __syscall_slow(const sysarg_t, const sysarg_t, const sysarg_t,
    5255    const sysarg_t, const sysarg_t, const sysarg_t, const syscall_t);
    53 
    54 extern sysarg_t
    55 __syscall_slow(const sysarg_t, const sysarg_t, const sysarg_t, const sysarg_t,
    56     const sysarg_t, const sysarg_t, const syscall_t);
    5756
    5857#endif
  • uspace/lib/libc/arch/ia32/include/tls.h

    r1ccafee r0b9ac3c  
    5353{
    5454        void *retval;
    55 
    56         asm ("movl %%gs:0, %0" : "=r"(retval));
     55       
     56        asm (
     57                "movl %%gs:0, %0"
     58                : "=r" (retval)
     59        );
     60       
    5761        return retval;
    5862}
  • uspace/lib/libc/arch/ia32/include/types.h

    r1ccafee r0b9ac3c  
    5454
    5555typedef uint32_t uintptr_t;
     56typedef uint32_t atomic_count_t;
     57typedef int32_t atomic_signed_t;
    5658
    5759#endif
  • uspace/lib/libc/arch/ia64/Makefile.inc

    r1ccafee r0b9ac3c  
    3333TOOLCHAIN_DIR = $(CROSS_PREFIX)/ia64/bin
    3434
    35 ARCH_SOURCES += arch/$(UARCH)/src/syscall.S \
     35ARCH_SOURCES = \
     36        arch/$(UARCH)/src/entry.s \
     37        arch/$(UARCH)/src/thread_entry.s \
     38        arch/$(UARCH)/src/syscall.S \
    3639        arch/$(UARCH)/src/fibril.S \
    3740        arch/$(UARCH)/src/tls.c \
  • uspace/lib/libc/arch/ia64/include/atomic.h

    r1ccafee r0b9ac3c  
    4242static inline void atomic_inc(atomic_t *val)
    4343{
    44         long v;
     44        atomic_count_t v;
    4545       
    4646        asm volatile (
     
    5353static inline void atomic_dec(atomic_t *val)
    5454{
    55         long v;
     55        atomic_count_t v;
    5656       
    5757        asm volatile (
     
    6262}
    6363
    64 static inline long atomic_preinc(atomic_t *val)
     64static inline atomic_count_t atomic_preinc(atomic_t *val)
    6565{
    66         long v;
     66        atomic_count_t v;
    6767       
    6868        asm volatile (
     
    7575}
    7676
    77 static inline long atomic_predec(atomic_t *val)
     77static inline atomic_count_t atomic_predec(atomic_t *val)
    7878{
    79         long v;
     79        atomic_count_t v;
    8080       
    8181        asm volatile (
     
    8888}
    8989
    90 static inline long atomic_postinc(atomic_t *val)
     90static inline atomic_count_t atomic_postinc(atomic_t *val)
    9191{
    92         long v;
     92        atomic_count_t v;
    9393       
    9494        asm volatile (
     
    101101}
    102102
    103 static inline long atomic_postdec(atomic_t *val)
     103static inline atomic_count_t atomic_postdec(atomic_t *val)
    104104{
    105         long v;
     105        atomic_count_t v;
    106106       
    107107        asm volatile (
  • uspace/lib/libc/arch/ia64/include/ddi.h

    r1ccafee r0b9ac3c  
    3939#include <libarch/types.h>
    4040
    41 #define IO_SPACE_BOUNDARY       (64 * 1024)
     41#define IO_SPACE_BOUNDARY       ((void *) (64 * 1024))
    4242
    4343uint64_t get_ia64_iospace_address(void);
  • uspace/lib/libc/arch/ia64/include/faddr.h

    r1ccafee r0b9ac3c  
    2727 */
    2828
    29 /** @addtogroup libcia64       
     29/** @addtogroup libcia64
    3030 * @{
    3131 */
     
    3838#include <libarch/types.h>
    3939
    40 /** 
     40/**
    4141 *
    4242 * Calculate absolute address of function
    4343 * referenced by fptr pointer.
    4444 *
    45  * @param f Function pointer.
     45 * @param fptr Function pointer.
    4646 *
    4747 */
    48 #define FADDR(f)         (*((uintptr_t *)(f)));
     48#define FADDR(fptr)  (((fncptr_t *) (fptr))->fnc)
    4949
    5050#endif
  • uspace/lib/libc/arch/ia64/include/fibril.h

    r1ccafee r0b9ac3c  
    5353#define PSTHREAD_INITIAL_STACK_DIVISION 2 
    5454
    55 #ifdef context_set
    56 #undef context_set
    57 #endif
    58 
    5955#define context_set(c, _pc, stack, size, tls)                                                           \
    6056        do {                                                                                            \
     
    110106        uint64_t pr;
    111107
    112         __r128 f2 __attribute__ ((aligned(16)));
    113         __r128 f3;
    114         __r128 f4;
    115         __r128 f5;
     108        uint128_t f2 __attribute__ ((aligned(16)));
     109        uint128_t f3;
     110        uint128_t f4;
     111        uint128_t f5;
    116112
    117         __r128 f16;
    118         __r128 f17;
    119         __r128 f18;
    120         __r128 f19;
    121         __r128 f20;
    122         __r128 f21;
    123         __r128 f22;
    124         __r128 f23;
    125         __r128 f24;
    126         __r128 f25;
    127         __r128 f26;
    128         __r128 f27;
    129         __r128 f28;
    130         __r128 f29;
    131         __r128 f30;
    132         __r128 f31;
     113        uint128_t f16;
     114        uint128_t f17;
     115        uint128_t f18;
     116        uint128_t f19;
     117        uint128_t f20;
     118        uint128_t f21;
     119        uint128_t f22;
     120        uint128_t f23;
     121        uint128_t f24;
     122        uint128_t f25;
     123        uint128_t f26;
     124        uint128_t f27;
     125        uint128_t f28;
     126        uint128_t f29;
     127        uint128_t f30;
     128        uint128_t f31;
    133129
    134130} context_t;
  • uspace/lib/libc/arch/ia64/include/limits.h

    r1ccafee r0b9ac3c  
    2727 */
    2828
    29 /** @addtogroup libcia64       
     29/** @addtogroup libcia64
    3030 * @{
    3131 */
     
    3636#define LIBC_ia64_LIMITS_H_
    3737
    38 # define LONG_MIN MIN_INT64
    39 # define LONG_MAX MAX_INT64
    40 # define ULONG_MIN MIN_UINT64
    41 # define ULONG_MAX MAX_UINT64
     38#define LONG_MIN MIN_INT64
     39#define LONG_MAX MAX_INT64
     40#define ULONG_MIN MIN_UINT64
     41#define ULONG_MAX MAX_UINT64
     42
     43#define SIZE_MIN MIN_UINT64
     44#define SIZE_MAX MAX_UINT64
     45#define SSIZE_MIN MIN_INT64
     46#define SSIZE_MAX MAX_INT64
    4247
    4348#endif
  • uspace/lib/libc/arch/ia64/include/types.h

    r1ccafee r0b9ac3c  
    2727 */
    2828
    29 /** @addtogroup libcia64       
     29/** @addtogroup libcia64
    3030 * @{
    3131 */
     
    5050typedef unsigned long int uint64_t;
    5151
     52typedef struct {
     53        uint64_t lo;
     54        uint64_t hi;
     55} uint128_t;
     56
    5257typedef int64_t ssize_t;
    5358typedef uint64_t size_t;
    5459
    5560typedef uint64_t uintptr_t;
     61typedef uint64_t atomic_count_t;
     62typedef int64_t atomic_signed_t;
    5663
    57 typedef unsigned char __r8;                     /* Reserve byte */
    58 typedef unsigned short __r16;
    59 typedef unsigned int __r32;
    60 typedef unsigned long __r64;
    61 
    62 typedef struct __r128{
    63         __r64 lo;
    64         __r64 hi;
    65 } __r128;
     64typedef struct {
     65        uintptr_t fnc;
     66        uintptr_t gp;
     67} __attribute__((may_alias)) fncptr_t;
    6668
    6769#endif
  • uspace/lib/libc/arch/mips32/Makefile.inc

    r1ccafee r0b9ac3c  
    3333TOOLCHAIN_DIR = $(CROSS_PREFIX)/mips32/bin
    3434
    35 ARCH_SOURCES += arch/$(UARCH)/src/syscall.c \
     35ARCH_SOURCES = \
     36        arch/$(UARCH)/src/entry.s \
     37        arch/$(UARCH)/src/thread_entry.s \
     38        arch/$(UARCH)/src/syscall.c \
    3639        arch/$(UARCH)/src/fibril.S \
    3740        arch/$(UARCH)/src/tls.c \
  • uspace/lib/libc/arch/mips32/include/atomic.h

    r1ccafee r0b9ac3c  
    2727 */
    2828
    29 /** @addtogroup libcmips32     
     29/** @addtogroup libcmips32
    3030 * @{
    3131 */
    3232/** @file
    33  * @ingroup libcmips32eb       
     33 * @ingroup libcmips32eb
    3434 */
    3535
     
    4141#include <atomicdflt.h>
    4242
    43 #define atomic_inc(x)   ((void) atomic_add(x, 1))
    44 #define atomic_dec(x)   ((void) atomic_add(x, -1))
     43#define atomic_inc(x)  ((void) atomic_add(x, 1))
     44#define atomic_dec(x)  ((void) atomic_add(x, -1))
    4545
    46 #define atomic_postinc(x) (atomic_add(x, 1) - 1)
    47 #define atomic_postdec(x) (atomic_add(x, -1) + 1)
     46#define atomic_postinc(x)  (atomic_add(x, 1) - 1)
     47#define atomic_postdec(x)  (atomic_add(x, -1) + 1)
    4848
    49 #define atomic_preinc(x) atomic_add(x, 1)
    50 #define atomic_predec(x) atomic_add(x, -1)
     49#define atomic_preinc(x)  atomic_add(x, 1)
     50#define atomic_predec(x)  atomic_add(x, -1)
    5151
    5252/* Atomic addition of immediate value.
    5353 *
    5454 * @param val Memory location to which will be the immediate value added.
    55  * @param i Signed immediate that will be added to *val.
     55 * @param i   Signed immediate that will be added to *val.
    5656 *
    5757 * @return Value after addition.
     58 *
    5859 */
    59 static inline long atomic_add(atomic_t *val, int i)
     60static inline atomic_count_t atomic_add(atomic_t *val, atomic_count_t i)
    6061{
    61         long tmp, v;
    62 
     62        atomic_count_t tmp;
     63        atomic_count_t v;
     64       
    6365        asm volatile (
    6466                "1:\n"
     
    7072                /*      nop     */              /* nop is inserted automatically by compiler */
    7173                "       nop\n"
    72                 : "=&r" (tmp), "+m" (val->count), "=&r" (v)
    73                 : "r" (i), "i" (0)
    74                 );
    75 
     74                : "=&r" (tmp),
     75                  "+m" (val->count),
     76                  "=&r" (v)
     77                : "r" (i),
     78                  "i" (0)
     79        );
     80       
    7681        return v;
    7782}
  • uspace/lib/libc/arch/mips32/include/limits.h

    r1ccafee r0b9ac3c  
    2727 */
    2828
    29 /** @addtogroup libcmips32     
     29/** @addtogroup libcmips32
    3030 * @{
    3131 */
    3232/** @file
    33  * @ingroup libcmips32eb       
     33 * @ingroup libcmips32eb
    3434 */
    3535
     
    3737#define LIBC_mips32__LIMITS_H_
    3838
    39 # define LONG_MIN MIN_INT32
    40 # define LONG_MAX MAX_INT32
    41 # define ULONG_MIN MIN_UINT32
    42 # define ULONG_MAX MAX_UINT32
     39#define LONG_MIN MIN_INT32
     40#define LONG_MAX MAX_INT32
     41#define ULONG_MIN MIN_UINT32
     42#define ULONG_MAX MAX_UINT32
     43
     44#define SIZE_MIN MIN_UINT32
     45#define SIZE_MAX MAX_UINT32
     46#define SSIZE_MIN MIN_INT32
     47#define SSIZE_MAX MAX_INT32
    4348
    4449#endif
  • uspace/lib/libc/arch/mips32/include/types.h

    r1ccafee r0b9ac3c  
    2727 */
    2828
    29 /** @addtogroup libcmips32     
     29/** @addtogroup libcmips32
    3030 * @{
    3131 */
     
    5555
    5656typedef uint32_t uintptr_t;
     57typedef uint32_t atomic_count_t;
     58typedef int32_t atomic_signed_t;
    5759
    5860#endif
  • uspace/lib/libc/arch/mips32eb/Makefile.inc

    r1ccafee r0b9ac3c  
    3333TOOLCHAIN_DIR = $(CROSS_PREFIX)/mips32eb/bin
    3434
    35 ARCH_SOURCES += arch/$(UARCH)/src/syscall.c \
     35ARCH_SOURCES = \
     36        arch/$(UARCH)/src/entry.s \
     37        arch/$(UARCH)/src/thread_entry.s \
     38        arch/$(UARCH)/src/syscall.c \
    3639        arch/$(UARCH)/src/fibril.S \
    3740        arch/$(UARCH)/src/tls.c \
  • uspace/lib/libc/arch/ppc32/Makefile.inc

    r1ccafee r0b9ac3c  
    3333TOOLCHAIN_DIR = $(CROSS_PREFIX)/ppc32/bin
    3434
    35 ARCH_SOURCES += arch/$(UARCH)/src/syscall.c \
     35ARCH_SOURCES = \
     36        arch/$(UARCH)/src/entry.s \
     37        arch/$(UARCH)/src/thread_entry.s \
     38        arch/$(UARCH)/src/syscall.c \
    3639        arch/$(UARCH)/src/fibril.S \
    3740        arch/$(UARCH)/src/tls.c \
  • uspace/lib/libc/arch/ppc32/include/atomic.h

    r1ccafee r0b9ac3c  
    2727 */
    2828
    29 /** @addtogroup libcppc32       
     29/** @addtogroup libcppc32
    3030 * @{
    3131 */
     
    4242static inline void atomic_inc(atomic_t *val)
    4343{
    44         long tmp;
    45 
     44        atomic_count_t tmp;
     45       
    4646        asm volatile (
    4747                "1:\n"
     
    5050                "stwcx. %0, 0, %2\n"
    5151                "bne- 1b"
    52                 : "=&r" (tmp), "=m" (val->count)
    53                 : "r" (&val->count), "m" (val->count)
    54                 : "cc");
     52                : "=&r" (tmp),
     53                  "=m" (val->count)
     54                : "r" (&val->count),
     55                  "m" (val->count)
     56                : "cc"
     57        );
    5558}
    5659
    5760static inline void atomic_dec(atomic_t *val)
    5861{
    59         long tmp;
    60 
     62        atomic_count_t tmp;
     63       
    6164        asm volatile (
    6265                "1:\n"
    6366                "lwarx %0, 0, %2\n"
    6467                "addic %0, %0, -1\n"
    65                 "stwcx. %0, 0, %2\n"
     68                "stwcx. %0, 0, %2\n"
    6669                "bne- 1b"
    67                 : "=&r" (tmp), "=m" (val->count)
    68                 : "r" (&val->count), "m" (val->count)
    69                 : "cc");
     70                : "=&r" (tmp),
     71                  "=m" (val->count)
     72                : "r" (&val->count),
     73                  "m" (val->count)
     74                : "cc"
     75        );
    7076}
    7177
    72 static inline long atomic_postinc(atomic_t *val)
     78static inline atomic_count_t atomic_postinc(atomic_t *val)
    7379{
    7480        atomic_inc(val);
     
    7682}
    7783
    78 static inline long atomic_postdec(atomic_t *val)
     84static inline atomic_count_t atomic_postdec(atomic_t *val)
    7985{
    8086        atomic_dec(val);
     
    8288}
    8389
    84 static inline long atomic_preinc(atomic_t *val)
     90static inline atomic_count_t atomic_preinc(atomic_t *val)
    8591{
    8692        atomic_inc(val);
     
    8894}
    8995
    90 static inline long atomic_predec(atomic_t *val)
     96static inline atomic_count_t atomic_predec(atomic_t *val)
    9197{
    9298        atomic_dec(val);
  • uspace/lib/libc/arch/ppc32/include/limits.h

    r1ccafee r0b9ac3c  
    2727 */
    2828
    29 /** @addtogroup libcppc32       
     29/** @addtogroup libcppc32
    3030 * @{
    3131 */
     
    4141#define ULONG_MAX MAX_UINT32
    4242
     43#define SIZE_MIN MIN_UINT32
     44#define SIZE_MAX MAX_UINT32
     45#define SSIZE_MIN MIN_INT32
     46#define SSIZE_MAX MAX_INT32
     47
    4348#endif
    4449
  • uspace/lib/libc/arch/ppc32/include/types.h

    r1ccafee r0b9ac3c  
    2727 */
    2828
    29 /** @addtogroup libcppc32       
     29/** @addtogroup libcppc32
    3030 * @{
    3131 */
     
    5454
    5555typedef uint32_t uintptr_t;
     56typedef uint32_t atomic_count_t;
     57typedef int32_t atomic_signed_t;
    5658
    5759#endif
  • uspace/lib/libc/arch/sparc64/Makefile.inc

    r1ccafee r0b9ac3c  
    3333TOOLCHAIN_DIR = $(CROSS_PREFIX)/sparc64/bin
    3434
    35 ARCH_SOURCES += arch/$(UARCH)/src/fibril.S \
     35ARCH_SOURCES = \
     36        arch/$(UARCH)/src/entry.s \
     37        arch/$(UARCH)/src/thread_entry.s \
     38        arch/$(UARCH)/src/fibril.S \
    3639        arch/$(UARCH)/src/tls.c \
    3740        arch/$(UARCH)/src/stacktrace.c \
     
    4548BFD_NAME = elf64-sparc
    4649BFD_ARCH = sparc
     50
     51ifeq ($(PROCESSOR),us)
     52        DEFS += -DSUN4U
     53endif
     54
     55ifeq ($(PROCESSOR),us3)
     56        DEFS += -DSUN4U
     57endif
     58
     59ifeq ($(PROCESSOR),sun4v)
     60        DEFS += -DSUN4V
     61endif
  • uspace/lib/libc/arch/sparc64/include/atomic.h

    r1ccafee r0b9ac3c  
    4646 *
    4747 * @param val Atomic variable.
    48  * @param i Signed value to be added.
     48 * @param i   Signed value to be added.
    4949 *
    5050 * @return Value of the atomic variable as it existed before addition.
     51 *
    5152 */
    52 static inline long atomic_add(atomic_t *val, int i)
     53static inline atomic_count_t atomic_add(atomic_t *val, atomic_count_t i)
    5354{
    54         uint64_t a, b;
    55 
     55        atomic_count_t a;
     56        atomic_count_t b;
     57       
    5658        do {
    57                 volatile uintptr_t x = (uint64_t) &val->count;
    58 
    59                 a = *((uint64_t *) x);
     59                volatile uintptr_t ptr = (uintptr_t) &val->count;
     60               
     61                a = *((atomic_count_t *) ptr);
    6062                b = a + i;
    61                 asm volatile ("casx %0, %2, %1\n" : "+m" (*((uint64_t *)x)), "+r" (b) : "r" (a));
     63               
     64                asm volatile (
     65                        "casx %0, %2, %1\n"
     66                        : "+m" (*((atomic_count_t *) ptr)),
     67                          "+r" (b)
     68                        : "r" (a)
     69                );
    6270        } while (a != b);
    63 
     71       
    6472        return a;
    6573}
    6674
    67 static inline long atomic_preinc(atomic_t *val)
     75static inline atomic_count_t atomic_preinc(atomic_t *val)
    6876{
    6977        return atomic_add(val, 1) + 1;
    7078}
    7179
    72 static inline long atomic_postinc(atomic_t *val)
     80static inline atomic_count_t atomic_postinc(atomic_t *val)
    7381{
    7482        return atomic_add(val, 1);
    7583}
    7684
    77 static inline long atomic_predec(atomic_t *val)
     85static inline atomic_count_t atomic_predec(atomic_t *val)
    7886{
    7987        return atomic_add(val, -1) - 1;
    8088}
    8189
    82 static inline long atomic_postdec(atomic_t *val)
     90static inline atomic_count_t atomic_postdec(atomic_t *val)
    8391{
    8492        return atomic_add(val, -1);
  • uspace/lib/libc/arch/sparc64/include/config.h

    r1ccafee r0b9ac3c  
    3636#define LIBC_sparc64_CONFIG_H_
    3737
     38#if defined (SUN4U)
    3839#define PAGE_WIDTH      14
     40#elif defined(SUN4V)
     41#define PAGE_WIDTH      13
     42#endif
     43
    3944#define PAGE_SIZE       (1 << PAGE_WIDTH)
    4045
  • uspace/lib/libc/arch/sparc64/include/ddi.h

    r1ccafee r0b9ac3c  
    3737#include <libarch/types.h>
    3838
    39 static inline memory_barrier(void)
     39static inline void memory_barrier(void)
    4040{
    41         asm volatile ("membar #LoadLoad | #StoreStore\n" ::: "memory");
     41        asm volatile (
     42                "membar #LoadLoad | #StoreStore\n"
     43                ::: "memory"
     44        );
    4245}
    4346
  • uspace/lib/libc/arch/sparc64/include/fibril.h

    r1ccafee r0b9ac3c  
    4242#define SP_DELTA        (STACK_WINDOW_SAVE_AREA_SIZE + STACK_ARG_SAVE_AREA_SIZE)
    4343
    44 #ifdef context_set
    45 #undef context_set
    46 #endif
    47 
    4844#define context_set(c, _pc, stack, size, ptls) \
    4945        do { \
     
    5248                    STACK_ALIGNMENT) - (STACK_BIAS + SP_DELTA); \
    5349                (c)->fp = -STACK_BIAS; \
    54                 (c)->tp = ptls; \
     50                (c)->tp = (uint64_t) ptls; \
    5551        } while (0)
    5652       
  • uspace/lib/libc/arch/sparc64/include/limits.h

    r1ccafee r0b9ac3c  
    2727 */
    2828
    29 /** @addtogroup libcsparc64     
     29/** @addtogroup libcsparc64
    3030 * @{
    3131 */
     
    4141#define ULONG_MAX MAX_UINT64
    4242
     43#define SIZE_MIN MIN_UINT64
     44#define SIZE_MAX MAX_UINT64
     45#define SSIZE_MIN MIN_INT64
     46#define SSIZE_MAX MAX_INT64
     47
    4348#endif
    4449
  • uspace/lib/libc/arch/sparc64/include/types.h

    r1ccafee r0b9ac3c  
    2727 */
    2828
    29 /** @addtogroup libcsparc64     
     29/** @addtogroup libcsparc64
    3030 * @{
    3131 */
     
    5454
    5555typedef uint64_t uintptr_t;
     56typedef uint64_t atomic_count_t;
     57typedef int64_t atomic_signed_t;
    5658
    5759#endif
  • uspace/lib/libc/arch/sparc64/src/thread_entry.s

    r1ccafee r0b9ac3c  
    3838        # Create the first stack frame.
    3939        #
    40         save %sp, -176, %sp
    41         flushw
    42         add %g0, -0x7ff, %fp
     40
     41        #save %sp, -176, %sp
     42        #flushw
     43        #add %g0, -0x7ff, %fp
    4344
    4445        sethi %hi(_gp), %l7
  • uspace/lib/libc/generic/async.c

    r1ccafee r0b9ac3c  
    11011101}
    11021102
     1103/** Wrapper for making IPC_M_CONNECT_ME_TO calls using the async framework.
     1104 *
     1105 * Ask through phone for a new connection to some service.
     1106 *
     1107 * @param phoneid       Phone handle used for contacting the other side.
     1108 * @param arg1          User defined argument.
     1109 * @param arg2          User defined argument.
     1110 * @param arg3          User defined argument.
     1111 *
     1112 * @return              New phone handle on success or a negative error code.
     1113 */
     1114int
     1115async_connect_me_to(int phoneid, ipcarg_t arg1, ipcarg_t arg2, ipcarg_t arg3)
     1116{
     1117        int rc;
     1118        ipcarg_t newphid;
     1119
     1120        rc = async_req_3_5(phoneid, IPC_M_CONNECT_ME_TO, arg1, arg2, arg3, NULL,
     1121            NULL, NULL, NULL, &newphid);
     1122       
     1123        if (rc != EOK) 
     1124                return rc;
     1125
     1126        return newphid;
     1127}
     1128
     1129/** Wrapper for making IPC_M_CONNECT_ME_TO calls using the async framework.
     1130 *
     1131 * Ask through phone for a new connection to some service and block until
     1132 * success.
     1133 *
     1134 * @param phoneid       Phone handle used for contacting the other side.
     1135 * @param arg1          User defined argument.
     1136 * @param arg2          User defined argument.
     1137 * @param arg3          User defined argument.
     1138 *
     1139 * @return              New phone handle on success or a negative error code.
     1140 */
     1141int
     1142async_connect_me_to_blocking(int phoneid, ipcarg_t arg1, ipcarg_t arg2,
     1143    ipcarg_t arg3)
     1144{
     1145        int rc;
     1146        ipcarg_t newphid;
     1147
     1148        rc = async_req_4_5(phoneid, IPC_M_CONNECT_ME_TO, arg1, arg2, arg3,
     1149            IPC_FLAG_BLOCKING, NULL, NULL, NULL, NULL, &newphid);
     1150       
     1151        if (rc != EOK) 
     1152                return rc;
     1153
     1154        return newphid;
     1155}
     1156
    11031157/** Wrapper for making IPC_M_SHARE_IN calls using the async framework.
    11041158 *
     
    12871341}
    12881342
     1343/** Wrapper for forwarding any read request
     1344 *
     1345 *
     1346 */
     1347int async_data_read_forward_fast(int phoneid, ipcarg_t method, ipcarg_t arg1,
     1348    ipcarg_t arg2, ipcarg_t arg3, ipcarg_t arg4, ipc_call_t *dataptr)
     1349{
     1350        ipc_callid_t callid;
     1351        if (!async_data_read_receive(&callid, NULL)) {
     1352                ipc_answer_0(callid, EINVAL);
     1353                return EINVAL;
     1354        }
     1355       
     1356        aid_t msg = async_send_fast(phoneid, method, arg1, arg2, arg3, arg4,
     1357            dataptr);
     1358        if (msg == 0) {
     1359                ipc_answer_0(callid, EINVAL);
     1360                return EINVAL;
     1361        }
     1362       
     1363        int retval = ipc_forward_fast(callid, phoneid, 0, 0, 0,
     1364            IPC_FF_ROUTE_FROM_ME);
     1365        if (retval != EOK) {
     1366                async_wait_for(msg, NULL);
     1367                ipc_answer_0(callid, retval);
     1368                return retval;
     1369        }
     1370       
     1371        ipcarg_t rc;
     1372        async_wait_for(msg, &rc);
     1373       
     1374        return (int) rc;
     1375}
     1376
    12891377/** Wrapper for making IPC_M_DATA_WRITE calls using the async framework.
    12901378 *
    1291  * @param phoneid       Phone that will be used to contact the receiving side.
    1292  * @param src           Address of the beginning of the source buffer.
    1293  * @param size          Size of the source buffer.
    1294  *
    1295  * @return              Zero on success or a negative error code from errno.h.
     1379 * @param phoneid Phone that will be used to contact the receiving side.
     1380 * @param src     Address of the beginning of the source buffer.
     1381 * @param size    Size of the source buffer.
     1382 *
     1383 * @return Zero on success or a negative error code from errno.h.
     1384 *
    12961385 */
    12971386int async_data_write_start(int phoneid, const void *src, size_t size)
     
    13081397 * So far, this wrapper is to be used from within a connection fibril.
    13091398 *
    1310  * @param callid        Storage where the hash of the IPC_M_DATA_WRITE call will
    1311  *                      be stored.
    1312  * @param size          Storage where the suggested size will be stored. May be
    1313  *                      NULL
    1314  *
    1315  * @return              Non-zero on success, zero on failure.
     1399 * @param callid Storage where the hash of the IPC_M_DATA_WRITE call will
     1400 *               be stored.
     1401 * @param size   Storage where the suggested size will be stored. May be
     1402 *               NULL
     1403 *
     1404 * @return Non-zero on success, zero on failure.
     1405 *
    13161406 */
    13171407int async_data_write_receive(ipc_callid_t *callid, size_t *size)
     
    13201410       
    13211411        assert(callid);
    1322 
     1412       
    13231413        *callid = async_get_call(&data);
    13241414        if (IPC_GET_METHOD(data) != IPC_M_DATA_WRITE)
    13251415                return 0;
     1416       
    13261417        if (size)
    13271418                *size = (size_t) IPC_GET_ARG2(data);
     1419       
    13281420        return 1;
    13291421}
     
    13341426 * so that the user doesn't have to remember the meaning of each IPC argument.
    13351427 *
    1336  * @param callid        Hash of the IPC_M_DATA_WRITE call to answer.
    1337  * @param dst           Final destination address for the IPC_M_DATA_WRITE call.
    1338  * @param size          Final size for the IPC_M_DATA_WRITE call.
    1339  *
    1340  * @return              Zero on success or a value from @ref errno.h on failure.
     1428 * @param callid Hash of the IPC_M_DATA_WRITE call to answer.
     1429 * @param dst    Final destination address for the IPC_M_DATA_WRITE call.
     1430 * @param size   Final size for the IPC_M_DATA_WRITE call.
     1431 *
     1432 * @return Zero on success or a value from @ref errno.h on failure.
     1433 *
    13411434 */
    13421435int async_data_write_finalize(ipc_callid_t callid, void *dst, size_t size)
     
    13451438}
    13461439
    1347 /** Wrapper for receiving blobs via the async_data_write_*
     1440/** Wrapper for receiving binary data or strings
    13481441 *
    13491442 * This wrapper only makes it more comfortable to use async_data_write_*
    1350  * functions to receive blobs.
    1351  *
    1352  * @param blob     Pointer to data pointer (which should be later disposed
    1353  *                 by free()). If the operation fails, the pointer is not
    1354  *                 touched.
    1355  * @param max_size Maximum size (in bytes) of the blob to receive. 0 means
    1356  *                 no limit.
    1357  * @param received If not NULL, the size of the received data is stored here.
     1443 * functions to receive binary data or strings.
     1444 *
     1445 * @param data       Pointer to data pointer (which should be later disposed
     1446 *                   by free()). If the operation fails, the pointer is not
     1447 *                   touched.
     1448 * @param nullterm   If true then the received data is always zero terminated.
     1449 *                   This also causes to allocate one extra byte beyond the
     1450 *                   raw transmitted data.
     1451 * @param min_size   Minimum size (in bytes) of the data to receive.
     1452 * @param max_size   Maximum size (in bytes) of the data to receive. 0 means
     1453 *                   no limit.
     1454 * @param granulariy If non-zero then the size of the received data has to
     1455 *                   be divisible by this value.
     1456 * @param received   If not NULL, the size of the received data is stored here.
    13581457 *
    13591458 * @return Zero on success or a value from @ref errno.h on failure.
    13601459 *
    13611460 */
    1362 int async_data_blob_receive(char **blob, const size_t max_size, size_t *received)
     1461int async_data_write_accept(void **data, const bool nullterm,
     1462    const size_t min_size, const size_t max_size, const size_t granularity,
     1463    size_t *received)
    13631464{
    13641465        ipc_callid_t callid;
     
    13691470        }
    13701471       
     1472        if (size < min_size) {
     1473                ipc_answer_0(callid, EINVAL);
     1474                return EINVAL;
     1475        }
     1476       
    13711477        if ((max_size > 0) && (size > max_size)) {
    13721478                ipc_answer_0(callid, EINVAL);
     
    13741480        }
    13751481       
    1376         char *data = (char *) malloc(size);
    1377         if (data == NULL) {
     1482        if ((granularity > 0) && ((size % granularity) != 0)) {
     1483                ipc_answer_0(callid, EINVAL);
     1484                return EINVAL;
     1485        }
     1486       
     1487        void *_data;
     1488       
     1489        if (nullterm)
     1490                _data = malloc(size + 1);
     1491        else
     1492                _data = malloc(size);
     1493       
     1494        if (_data == NULL) {
    13781495                ipc_answer_0(callid, ENOMEM);
    13791496                return ENOMEM;
    13801497        }
    13811498       
    1382         int rc = async_data_write_finalize(callid, data, size);
     1499        int rc = async_data_write_finalize(callid, _data, size);
    13831500        if (rc != EOK) {
    1384                 free(data);
     1501                free(_data);
    13851502                return rc;
    13861503        }
    13871504       
    1388         *blob = data;
     1505        if (nullterm)
     1506                ((char *) _data)[size] = 0;
     1507       
     1508        *data = _data;
    13891509        if (received != NULL)
    13901510                *received = size;
     
    13931513}
    13941514
    1395 /** Wrapper for receiving strings via the async_data_write_*
    1396  *
    1397  * This wrapper only makes it more comfortable to use async_data_write_*
    1398  * functions to receive strings.
    1399  *
    1400  * @param str      Pointer to string pointer (which should be later disposed
    1401  *                 by free()). If the operation fails, the pointer is not
    1402  *                 touched.
    1403  * @param max_size Maximum size (in bytes) of the string to receive. 0 means
    1404  *                 no limit.
    1405  *
    1406  * @return Zero on success or a value from @ref errno.h on failure.
    1407  *
    1408  */
    1409 int async_data_string_receive(char **str, const size_t max_size)
     1515/** Wrapper for voiding any data that is about to be received
     1516 *
     1517 * This wrapper can be used to void any pending data
     1518 *
     1519 * @param retval Error value from @ref errno.h to be returned to the caller.
     1520 *
     1521 */
     1522void async_data_write_void(const int retval)
    14101523{
    14111524        ipc_callid_t callid;
    1412         size_t size;
    1413         if (!async_data_write_receive(&callid, &size)) {
     1525        async_data_write_receive(&callid, NULL);
     1526        ipc_answer_0(callid, retval);
     1527}
     1528
     1529/** Wrapper for forwarding any data that is about to be received
     1530 *
     1531 *
     1532 */
     1533int async_data_write_forward_fast(int phoneid, ipcarg_t method, ipcarg_t arg1,
     1534    ipcarg_t arg2, ipcarg_t arg3, ipcarg_t arg4, ipc_call_t *dataptr)
     1535{
     1536        ipc_callid_t callid;
     1537        if (!async_data_write_receive(&callid, NULL)) {
    14141538                ipc_answer_0(callid, EINVAL);
    14151539                return EINVAL;
    14161540        }
    14171541       
    1418         if ((max_size > 0) && (size > max_size)) {
     1542        aid_t msg = async_send_fast(phoneid, method, arg1, arg2, arg3, arg4,
     1543            dataptr);
     1544        if (msg == 0) {
    14191545                ipc_answer_0(callid, EINVAL);
    14201546                return EINVAL;
    14211547        }
    14221548       
    1423         char *data = (char *) malloc(size + 1);
    1424         if (data == NULL) {
    1425                 ipc_answer_0(callid, ENOMEM);
    1426                 return ENOMEM;
    1427         }
    1428        
    1429         int rc = async_data_write_finalize(callid, data, size);
    1430         if (rc != EOK) {
    1431                 free(data);
    1432                 return rc;
    1433         }
    1434        
    1435         data[size] = 0;
    1436         *str = data;
    1437         return EOK;
     1549        int retval = ipc_forward_fast(callid, phoneid, 0, 0, 0,
     1550            IPC_FF_ROUTE_FROM_ME);
     1551        if (retval != EOK) {
     1552                async_wait_for(msg, NULL);
     1553                ipc_answer_0(callid, retval);
     1554                return retval;
     1555        }
     1556       
     1557        ipcarg_t rc;
     1558        async_wait_for(msg, &rc);
     1559       
     1560        return (int) rc;
    14381561}
    14391562
  • uspace/lib/libc/generic/clipboard.c

    r1ccafee r0b9ac3c  
    8484                clip_connect();
    8585               
    86                 aid_t req = async_send_1(clip_phone, CLIPBOARD_PUT_DATA, CLIPBOARD_TAG_BLOB, NULL);
     86                aid_t req = async_send_1(clip_phone, CLIPBOARD_PUT_DATA, CLIPBOARD_TAG_DATA, NULL);
    8787                ipcarg_t rc = async_data_write_start(clip_phone, (void *) str, size);
    8888                if (rc != EOK) {
     
    139139                        *str = sbuf;
    140140                        return EOK;
    141                 case CLIPBOARD_TAG_BLOB:
     141                case CLIPBOARD_TAG_DATA:
    142142                        sbuf = malloc(size + 1);
    143143                        if (sbuf == NULL)
     
    148148                        aid_t req = async_send_1(clip_phone, CLIPBOARD_GET_DATA, tag, NULL);
    149149                        rc = async_data_read_start(clip_phone, (void *) sbuf, size);
    150                         if (rc == EOVERFLOW) {
     150                        if ((int) rc == EOVERFLOW) {
    151151                                /*
    152152                                 * The data in the clipboard has changed since
  • uspace/lib/libc/generic/fibril.c

    r1ccafee r0b9ac3c  
    4141#include <unistd.h>
    4242#include <stdio.h>
     43#include <arch/barrier.h>
    4344#include <libarch/faddr.h>
    4445#include <futex.h>
     
    133134int fibril_switch(fibril_switch_type_t stype)
    134135{
    135         fibril_t *srcf, *dstf;
    136136        int retval = 0;
    137137       
    138138        futex_down(&fibril_futex);
    139 
     139       
    140140        if (stype == FIBRIL_PREEMPT && list_empty(&ready_list))
    141141                goto ret_0;
    142 
     142       
    143143        if (stype == FIBRIL_FROM_MANAGER) {
    144                 if (list_empty(&ready_list) && list_empty(&serialized_list))
     144                if ((list_empty(&ready_list)) && (list_empty(&serialized_list)))
    145145                        goto ret_0;
     146               
    146147                /*
    147148                 * Do not preempt if there is not enough threads to run the
    148149                 * ready fibrils which are not serialized.
    149150                 */
    150                 if (list_empty(&serialized_list) &&
    151                     threads_in_manager <= serialized_threads) {
     151                if ((list_empty(&serialized_list)) &&
     152                    (threads_in_manager <= serialized_threads)) {
    152153                        goto ret_0;
    153154                }
    154155        }
     156       
    155157        /* If we are going to manager and none exists, create it */
    156         if (stype == FIBRIL_TO_MANAGER || stype == FIBRIL_FROM_DEAD) {
     158        if ((stype == FIBRIL_TO_MANAGER) || (stype == FIBRIL_FROM_DEAD)) {
    157159                while (list_empty(&manager_list)) {
    158160                        futex_up(&fibril_futex);
     
    162164        }
    163165       
    164         srcf = __tcb_get()->fibril_data;
     166        fibril_t *srcf = __tcb_get()->fibril_data;
    165167        if (stype != FIBRIL_FROM_DEAD) {
     168               
    166169                /* Save current state */
    167170                if (!context_save(&srcf->ctx)) {
    168171                        if (serialization_count)
    169172                                srcf->flags &= ~FIBRIL_SERIALIZED;
     173                       
    170174                        if (srcf->clean_after_me) {
    171175                                /*
     
    173177                                 * restored context here.
    174178                                 */
    175                                 void *stack = srcf->clean_after_me->stack; 
     179                                void *stack = srcf->clean_after_me->stack;
    176180                                if (stack) {
    177181                                        /*
     
    188192                                srcf->clean_after_me = NULL;
    189193                        }
     194                       
    190195                        return 1;       /* futex_up already done here */
    191196                }
    192 
     197               
    193198                /* Save myself to the correct run list */
    194199                if (stype == FIBRIL_PREEMPT)
     
    197202                        list_append(&srcf->link, &manager_list);
    198203                        threads_in_manager--;
    199                 } else {       
     204                } else {
    200205                        /*
    201206                         * If stype == FIBRIL_TO_MANAGER, don't put ourselves to
     
    207212       
    208213        /* Choose a new fibril to run */
    209         if (stype == FIBRIL_TO_MANAGER || stype == FIBRIL_FROM_DEAD) {
     214        fibril_t *dstf;
     215        if ((stype == FIBRIL_TO_MANAGER) || (stype == FIBRIL_FROM_DEAD)) {
    210216                dstf = list_get_instance(manager_list.next, fibril_t, link);
    211217                if (serialization_count && stype == FIBRIL_TO_MANAGER) {
     
    214220                }
    215221                threads_in_manager++;
    216 
     222               
    217223                if (stype == FIBRIL_FROM_DEAD)
    218224                        dstf->clean_after_me = srcf;
     
    228234        }
    229235        list_remove(&dstf->link);
    230 
     236       
    231237        futex_up(&fibril_futex);
    232238        context_restore(&dstf->ctx);
    233239        /* not reached */
    234 
     240       
    235241ret_0:
    236242        futex_up(&fibril_futex);
  • uspace/lib/libc/generic/futex.c

    r1ccafee r0b9ac3c  
    6868int futex_down(futex_t *futex)
    6969{
    70         if (atomic_predec(futex) < 0)
     70        if ((atomic_signed_t) atomic_predec(futex) < 0)
    7171                return __SYSCALL1(SYS_FUTEX_SLEEP, (sysarg_t) &futex->count);
    7272
     
    8282int futex_up(futex_t *futex)
    8383{
    84         if (atomic_postinc(futex) < 0)
     84        if ((atomic_signed_t) atomic_postinc(futex) < 0)
    8585                return __SYSCALL1(SYS_FUTEX_WAKEUP, (sysarg_t) &futex->count);
    8686               
  • uspace/lib/libc/generic/io/io.c

    r1ccafee r0b9ac3c  
    541541}
    542542
    543 int fseek(FILE *stream, long offset, int origin)
    544 {
    545         off_t rc = lseek(stream->fd, offset, origin);
    546         if (rc == (off_t) (-1)) {
    547                 /* errno has been set by lseek. */
     543int fseek(FILE *stream, off64_t offset, int whence)
     544{
     545        off64_t rc = lseek(stream->fd, offset, whence);
     546        if (rc == (off64_t) (-1)) {
     547                /* errno has been set by lseek64. */
    548548                return -1;
    549549        }
     
    554554}
    555555
    556 int ftell(FILE *stream)
    557 {
    558         off_t rc = lseek(stream->fd, 0, SEEK_CUR);
    559         if (rc == (off_t) (-1)) {
    560                 /* errno has been set by lseek. */
    561                 return -1;
    562         }
    563 
    564         return rc;
     556off64_t ftell(FILE *stream)
     557{
     558        return lseek(stream->fd, 0, SEEK_CUR);
    565559}
    566560
  • uspace/lib/libc/generic/ipc.c

    r1ccafee r0b9ac3c  
    728728    int *flags)
    729729{
    730         int res;
    731         sysarg_t tmp_flags;
    732         res = ipc_call_sync_3_2(phoneid, IPC_M_SHARE_IN, (ipcarg_t) dst,
     730        sysarg_t tmp_flags = 0;
     731        int res = ipc_call_sync_3_2(phoneid, IPC_M_SHARE_IN, (ipcarg_t) dst,
    733732            (ipcarg_t) size, arg, NULL, &tmp_flags);
     733       
    734734        if (flags)
    735735                *flags = tmp_flags;
     736       
    736737        return res;
    737738}
  • uspace/lib/libc/generic/malloc.c

    r1ccafee r0b9ac3c  
    164164{
    165165        if (size == 0)
     166                return false;
     167
     168        if ((heap_start + size < heap_start) || (heap_end + size < heap_end))
    166169                return false;
    167170       
  • uspace/lib/libc/generic/mman.c

    r1ccafee r0b9ac3c  
    3939
    4040void *mmap(void *start, size_t length, int prot, int flags, int fd,
    41     off_t offset)
     41    aoff64_t offset)
    4242{
    4343        if (!start)
  • uspace/lib/libc/generic/vfs/vfs.c

    r1ccafee r0b9ac3c  
    3535#include <vfs/vfs.h>
    3636#include <vfs/canonify.h>
     37#include <macros.h>
    3738#include <stdlib.h>
    3839#include <unistd.h>
     
    120121    const char *opts, unsigned int flags)
    121122{
    122         int res;
    123         ipcarg_t rc;
    124         ipcarg_t rc_orig;
    125         aid_t req;
     123        int null_id = -1;
     124        char null[DEVMAP_NAME_MAXLEN];
     125       
     126        if (str_cmp(fqdn, "") == 0) {
     127                /* No device specified, create a fresh
     128                   null/%d device instead */
     129                null_id = devmap_null_create();
     130               
     131                if (null_id == -1)
     132                        return ENOMEM;
     133               
     134                snprintf(null, DEVMAP_NAME_MAXLEN, "null/%d", null_id);
     135                fqdn = null;
     136        }
     137       
    126138        dev_handle_t dev_handle;
    127        
    128         res = devmap_device_get_handle(fqdn, &dev_handle, flags);
    129         if (res != EOK)
     139        int res = devmap_device_get_handle(fqdn, &dev_handle, flags);
     140        if (res != EOK) {
     141                if (null_id != -1)
     142                        devmap_null_destroy(null_id);
     143               
    130144                return res;
     145        }
    131146       
    132147        size_t mpa_size;
    133148        char *mpa = absolutize(mp, &mpa_size);
    134         if (!mpa)
     149        if (!mpa) {
     150                if (null_id != -1)
     151                        devmap_null_destroy(null_id);
     152               
    135153                return ENOMEM;
    136        
    137         futex_down(&vfs_phone_futex);
    138         async_serialize_start();
    139         vfs_connect();
    140        
    141         req = async_send_2(vfs_phone, VFS_IN_MOUNT, dev_handle, flags, NULL);
    142         rc = async_data_write_start(vfs_phone, (void *) mpa, mpa_size);
     154        }
     155       
     156        futex_down(&vfs_phone_futex);
     157        async_serialize_start();
     158        vfs_connect();
     159       
     160        ipcarg_t rc_orig;
     161        aid_t req = async_send_2(vfs_phone, VFS_IN_MOUNT, dev_handle, flags, NULL);
     162        ipcarg_t rc = async_data_write_start(vfs_phone, (void *) mpa, mpa_size);
    143163        if (rc != EOK) {
    144164                async_wait_for(req, &rc_orig);
     
    146166                futex_up(&vfs_phone_futex);
    147167                free(mpa);
     168               
     169                if (null_id != -1)
     170                        devmap_null_destroy(null_id);
     171               
    148172                if (rc_orig == EOK)
    149173                        return (int) rc;
     
    158182                futex_up(&vfs_phone_futex);
    159183                free(mpa);
    160                 if (rc_orig == EOK)
    161                         return (int) rc;
    162                 else
    163                         return (int) rc_orig;
    164         }
    165 
     184               
     185                if (null_id != -1)
     186                        devmap_null_destroy(null_id);
     187               
     188                if (rc_orig == EOK)
     189                        return (int) rc;
     190                else
     191                        return (int) rc_orig;
     192        }
     193       
    166194        rc = async_data_write_start(vfs_phone, (void *) fs_name, str_size(fs_name));
    167195        if (rc != EOK) {
     
    170198                futex_up(&vfs_phone_futex);
    171199                free(mpa);
    172                 if (rc_orig == EOK)
    173                         return (int) rc;
    174                 else
    175                         return (int) rc_orig;
    176         }
    177 
     200               
     201                if (null_id != -1)
     202                        devmap_null_destroy(null_id);
     203               
     204                if (rc_orig == EOK)
     205                        return (int) rc;
     206                else
     207                        return (int) rc_orig;
     208        }
     209       
    178210        /* Ask VFS whether it likes fs_name. */
    179211        rc = async_req_0_0(vfs_phone, IPC_M_PING);
     
    183215                futex_up(&vfs_phone_futex);
    184216                free(mpa);
     217               
     218                if (null_id != -1)
     219                        devmap_null_destroy(null_id);
     220               
    185221                if (rc_orig == EOK)
    186222                        return (int) rc;
     
    193229        futex_up(&vfs_phone_futex);
    194230        free(mpa);
     231       
     232        if ((rc != EOK) && (null_id != -1))
     233                devmap_null_destroy(null_id);
    195234       
    196235        return (int) rc;
     
    396435}
    397436
    398 off_t lseek(int fildes, off_t offset, int whence)
    399 {
    400         ipcarg_t rc;
    401 
    402         futex_down(&vfs_phone_futex);
    403         async_serialize_start();
    404         vfs_connect();
    405        
    406         ipcarg_t newoffs;
    407         rc = async_req_3_1(vfs_phone, VFS_IN_SEEK, fildes, offset, whence,
    408             &newoffs);
    409 
    410         async_serialize_end();
    411         futex_up(&vfs_phone_futex);
    412 
     437off64_t lseek(int fildes, off64_t offset, int whence)
     438{
     439        futex_down(&vfs_phone_futex);
     440        async_serialize_start();
     441        vfs_connect();
     442       
     443        ipcarg_t newoff_lo;
     444        ipcarg_t newoff_hi;
     445        ipcarg_t rc = async_req_4_2(vfs_phone, VFS_IN_SEEK, fildes,
     446            LOWER32(offset), UPPER32(offset), whence,
     447            &newoff_lo, &newoff_hi);
     448       
     449        async_serialize_end();
     450        futex_up(&vfs_phone_futex);
     451       
    413452        if (rc != EOK)
    414                 return (off_t) -1;
    415        
    416         return (off_t) newoffs;
    417 }
    418 
    419 int ftruncate(int fildes, off_t length)
    420 {
    421         ipcarg_t rc;
    422        
    423         futex_down(&vfs_phone_futex);
    424         async_serialize_start();
    425         vfs_connect();
    426        
    427         rc = async_req_2_0(vfs_phone, VFS_IN_TRUNCATE, fildes, length);
    428         async_serialize_end();
    429         futex_up(&vfs_phone_futex);
     453                return (off64_t) -1;
     454       
     455        return (off64_t) MERGE_LOUP32(newoff_lo, newoff_hi);
     456}
     457
     458int ftruncate(int fildes, aoff64_t length)
     459{
     460        ipcarg_t rc;
     461       
     462        futex_down(&vfs_phone_futex);
     463        async_serialize_start();
     464        vfs_connect();
     465       
     466        rc = async_req_3_0(vfs_phone, VFS_IN_TRUNCATE, fildes,
     467            LOWER32(length), UPPER32(length));
     468        async_serialize_end();
     469        futex_up(&vfs_phone_futex);
     470       
    430471        return (int) rc;
    431472}
     
    441482       
    442483        req = async_send_1(vfs_phone, VFS_IN_FSTAT, fildes, NULL);
    443         rc = async_data_read_start(vfs_phone, (void *)stat, sizeof(struct stat));
     484        rc = async_data_read_start(vfs_phone, (void *) stat, sizeof(struct stat));
    444485        if (rc != EOK) {
    445486                ipcarg_t rc_orig;
     
    515556        if (!abs) {
    516557                free(dirp);
    517                 return ENOMEM;
     558                return NULL;
    518559        }
    519560       
  • uspace/lib/libc/include/async.h

    r1ccafee r0b9ac3c  
    259259}
    260260
     261extern int async_connect_me_to(int, ipcarg_t, ipcarg_t, ipcarg_t);
     262extern int async_connect_me_to_blocking(int, ipcarg_t, ipcarg_t, ipcarg_t);
     263
    261264/*
    262265 * User-friendly wrappers for async_share_in_start().
     
    277280extern int async_share_out_receive(ipc_callid_t *, size_t *, int *);
    278281extern int async_share_out_finalize(ipc_callid_t, void *);
     282
     283/*
     284 * User-friendly wrappers for async_data_read_forward_fast().
     285 */
     286#define async_data_read_forward_0_0(phoneid, method, answer) \
     287        async_data_read_forward_fast((phoneid), (method), 0, 0, 0, 0, NULL)
     288#define async_data_read_forward_0_1(phoneid, method, answer) \
     289        async_data_read_forward_fast((phoneid), (method), 0, 0, 0, 0, (answer))
     290#define async_data_read_forward_1_0(phoneid, method, arg1, answer) \
     291        async_data_read_forward_fast((phoneid), (method), (arg1), 0, 0, 0, NULL)
     292#define async_data_read_forward_1_1(phoneid, method, arg1, answer) \
     293        async_data_read_forward_fast((phoneid), (method), (arg1), 0, 0, 0, (answer))
     294#define async_data_read_forward_2_0(phoneid, method, arg1, arg2, answer) \
     295        async_data_read_forward_fast((phoneid), (method), (arg1), (arg2), 0, 0, NULL)
     296#define async_data_read_forward_2_1(phoneid, method, arg1, arg2, answer) \
     297        async_data_read_forward_fast((phoneid), (method), (arg1), (arg2), 0, 0, \
     298            (answer))
     299#define async_data_read_forward_3_0(phoneid, method, arg1, arg2, arg3, answer) \
     300        async_data_read_forward_fast((phoneid), (method), (arg1), (arg2), (arg3), 0, \
     301            NULL)
     302#define async_data_read_forward_3_1(phoneid, method, arg1, arg2, arg3, answer) \
     303        async_data_read_forward_fast((phoneid), (method), (arg1), (arg2), (arg3), 0, \
     304            (answer))
     305#define async_data_read_forward_4_0(phoneid, method, arg1, arg2, arg3, arg4, answer) \
     306        async_data_read_forward_fast((phoneid), (method), (arg1), (arg2), (arg3), \
     307            (arg4), NULL)
     308#define async_data_read_forward_4_1(phoneid, method, arg1, arg2, arg3, arg4, answer) \
     309        async_data_read_forward_fast((phoneid), (method), (arg1), (arg2), (arg3), \
     310            (arg4), (answer))
     311
    279312extern int async_data_read_start(int, void *, size_t);
    280313extern int async_data_read_receive(ipc_callid_t *, size_t *);
    281314extern int async_data_read_finalize(ipc_callid_t, const void *, size_t);
     315
     316extern int async_data_read_forward_fast(int, ipcarg_t, ipcarg_t, ipcarg_t,
     317    ipcarg_t, ipcarg_t, ipc_call_t *);
     318
     319/*
     320 * User-friendly wrappers for async_data_write_forward_fast().
     321 */
     322#define async_data_write_forward_0_0(phoneid, method, answer) \
     323        async_data_write_forward_fast((phoneid), (method), 0, 0, 0, 0, NULL)
     324#define async_data_write_forward_0_1(phoneid, method, answer) \
     325        async_data_write_forward_fast((phoneid), (method), 0, 0, 0, 0, (answer))
     326#define async_data_write_forward_1_0(phoneid, method, arg1, answer) \
     327        async_data_write_forward_fast((phoneid), (method), (arg1), 0, 0, 0, NULL)
     328#define async_data_write_forward_1_1(phoneid, method, arg1, answer) \
     329        async_data_write_forward_fast((phoneid), (method), (arg1), 0, 0, 0, \
     330            (answer))
     331#define async_data_write_forward_2_0(phoneid, method, arg1, arg2, answer) \
     332        async_data_write_forward_fast((phoneid), (method), (arg1), (arg2), 0, 0, \
     333            NULL)
     334#define async_data_write_forward_2_1(phoneid, method, arg1, arg2, answer) \
     335        async_data_write_forward_fast((phoneid), (method), (arg1), (arg2), 0, 0, \
     336            (answer))
     337#define async_data_write_forward_3_0(phoneid, method, arg1, arg2, arg3, answer) \
     338        async_data_write_forward_fast((phoneid), (method), (arg1), (arg2), (arg3), \
     339            0, NULL)
     340#define async_data_write_forward_3_1(phoneid, method, arg1, arg2, arg3, answer) \
     341        async_data_write_forward_fast((phoneid), (method), (arg1), (arg2), (arg3), \
     342            0, (answer))
     343#define async_data_write_forward_4_0(phoneid, method, arg1, arg2, arg3, arg4, answer) \
     344        async_data_write_forward_fast((phoneid), (method), (arg1), (arg2), (arg3), \
     345            (arg4), NULL)
     346#define async_data_write_forward_4_1(phoneid, method, arg1, arg2, arg3, arg4, answer) \
     347        async_data_write_forward_fast((phoneid), (method), (arg1), (arg2), (arg3), \
     348            (arg4), (answer))
     349
    282350extern int async_data_write_start(int, const void *, size_t);
    283351extern int async_data_write_receive(ipc_callid_t *, size_t *);
    284352extern int async_data_write_finalize(ipc_callid_t, void *, size_t);
    285353
    286 extern int async_data_blob_receive(char **, const size_t, size_t *);
    287 extern int async_data_string_receive(char **, const size_t);
     354extern int async_data_write_accept(void **, const bool, const size_t,
     355    const size_t, const size_t, size_t *);
     356extern void async_data_write_void(const int);
     357
     358extern int async_data_write_forward_fast(int, ipcarg_t, ipcarg_t, ipcarg_t,
     359    ipcarg_t, ipcarg_t, ipc_call_t *);
    288360
    289361#endif
  • uspace/lib/libc/include/atomicdflt.h

    r1ccafee r0b9ac3c  
    3737
    3838#ifndef LIBC_ARCH_ATOMIC_H_
    39 #error This file cannot be included directly, include atomic.h instead.
     39        #error This file cannot be included directly, include atomic.h instead.
    4040#endif
    4141
     42#include <stdint.h>
    4243#include <bool.h>
    4344
    4445typedef struct atomic {
    45         volatile long count;
     46        volatile atomic_count_t count;
    4647} atomic_t;
    4748
    48 static inline void atomic_set(atomic_t *val, long i)
     49static inline void atomic_set(atomic_t *val, atomic_count_t i)
    4950{
    50         val->count = i;
     51        val->count = i;
    5152}
    5253
    53 static inline long atomic_get(atomic_t *val)
     54static inline atomic_count_t atomic_get(atomic_t *val)
    5455{
    55         return val->count;
     56        return val->count;
    5657}
    5758
    58 #ifndef CAS 
    59 static inline bool cas(atomic_t *val, long ov, long nv)
     59#ifndef CAS
     60static inline bool cas(atomic_t *val, atomic_count_t ov, atomic_count_t nv)
    6061{
    6162        return __sync_bool_compare_and_swap(&val->count, ov, nv);
  • uspace/lib/libc/include/fibril.h

    r1ccafee r0b9ac3c  
    4040#include <libarch/tls.h>
    4141
    42 #ifndef context_set
    43 #define context_set(c, _pc, stack, size, ptls) \
     42#define context_set_generic(c, _pc, stack, size, ptls) \
    4443        (c)->pc = (sysarg_t) (_pc); \
    4544        (c)->sp = ((sysarg_t) (stack)) + (size) - SP_DELTA; \
    4645        (c)->tls = (sysarg_t) (ptls);
    47 #endif /* context_set */
    4846
    49 #define FIBRIL_SERIALIZED       1
    50 #define FIBRIL_WRITER           2
     47#define FIBRIL_SERIALIZED  1
     48#define FIBRIL_WRITER      2
    5149
    5250typedef enum {
     
    5957typedef sysarg_t fid_t;
    6058
    61 struct fibril {
     59typedef struct fibril {
    6260        link_t link;
    6361        context_t ctx;
     
    7068        int retval;
    7169        int flags;
    72 };
    73 typedef struct fibril fibril_t;
     70} fibril_t;
    7471
    7572/** Fibril-local variable specifier */
    7673#define fibril_local __thread
    7774
    78 extern int context_save(context_t *c) __attribute__ ((returns_twice));
    79 extern void context_restore(context_t *c) __attribute__ ((noreturn));
     75extern int context_save(context_t *ctx) __attribute__((returns_twice));
     76extern void context_restore(context_t *ctx) __attribute__((noreturn));
    8077
    8178extern fid_t fibril_create(int (*func)(void *), void *arg);
     
    9087extern void fibril_dec_sercount(void);
    9188
    92 static inline int fibril_yield(void) {
     89static inline int fibril_yield(void)
     90{
    9391        return fibril_switch(FIBRIL_PREEMPT);
    9492}
  • uspace/lib/libc/include/ipc/clipboard.h

    r1ccafee r0b9ac3c  
    4646typedef enum {
    4747        CLIPBOARD_TAG_NONE,
    48         CLIPBOARD_TAG_BLOB
     48        CLIPBOARD_TAG_DATA
    4949} clipboard_tag_t;
    5050
  • uspace/lib/libc/include/ipc/services.h

    r1ccafee r0b9ac3c  
    4747        SERVICE_FHC,
    4848        SERVICE_OBIO,
    49         SERVICE_CLIPBOARD
     49        SERVICE_CLIPBOARD,
     50        SERVICE_NETWORKING,
     51        SERVICE_LO,
     52        SERVICE_DP8390,
     53        SERVICE_ETHERNET,
     54        SERVICE_NILDUMMY,
     55        SERVICE_IP,
     56        SERVICE_ARP,
     57        SERVICE_RARP,
     58        SERVICE_ICMP,
     59        SERVICE_UDP,
     60        SERVICE_TCP,
     61        SERVICE_SOCKET
    5062} services_t;
    5163
  • uspace/lib/libc/include/limits.h

    r1ccafee r0b9ac3c  
    4646
    4747#ifdef __CHAR_UNSIGNED__
    48 # define CHAR_MIN UCHAR_MIN
    49 # define CHAR_MAX UCHAR_MAX
     48        #define CHAR_MIN UCHAR_MIN
     49        #define CHAR_MAX UCHAR_MAX
    5050#else
    51 # define CHAR_MIN SCHAR_MIN
    52 # define CHAR_MAX SCHAR_MAX
     51        #define CHAR_MIN SCHAR_MIN
     52        #define CHAR_MAX SCHAR_MAX
    5353#endif
    5454
     
    5959#define USHRT_MAX MAX_UINT16
    6060
     61/* int */
    6162#define INT_MIN MIN_INT32
    6263#define INT_MAX MAX_INT32
     
    6465#define UINT_MAX MAX_UINT32
    6566
     67/* long long int */
    6668#define LLONG_MIN MIN_INT64
    6769#define LLONG_MAX MAX_INT64
     
    6971#define ULLONG_MAX MAX_UINT64
    7072
     73/* off64_t */
     74#define OFF64_MIN MIN_INT64
     75#define OFF64_MAX MAX_INT64
     76
     77/* aoff64_t */
     78#define AOFF64_MIN MIN_UINT64
     79#define AOFF64_MAX MAX_UINT64
     80
    7181#endif
    7282
  • uspace/lib/libc/include/macros.h

    r1ccafee r0b9ac3c  
    4848#define STRING_ARG(arg)  #arg
    4949
    50 #define LOWER32(arg)  ((arg) & 0xffffffff)
    51 #define UPPER32(arg)  (((arg) >> 32) & 0xffffffff)
     50#define LOWER32(arg)  (((uint64_t) (arg)) & 0xffffffff)
     51#define UPPER32(arg)  (((((uint64_t) arg)) >> 32) & 0xffffffff)
    5252
    5353#define MERGE_LOUP32(lo, up) \
  • uspace/lib/libc/include/stacktrace.h

    r1ccafee r0b9ac3c  
    5757extern void stacktrace_prepare(void);
    5858extern uintptr_t stacktrace_fp_get(void);
    59 extern uintptr_t stacktrace_pc_get();
     59extern uintptr_t stacktrace_pc_get(void);
    6060
    6161#endif
  • uspace/lib/libc/include/stdio.h

    r1ccafee r0b9ac3c  
    4646#define BUFSIZ  4096
    4747
    48 #define DEBUG(fmt, ...) \
     48#define DEBUG(fmt, ...)se\
    4949        { \
    5050                char _buf[256]; \
     
    5656#ifndef SEEK_SET
    5757        #define SEEK_SET  0
     58#endif
     59
     60#ifndef SEEK_CUR
    5861        #define SEEK_CUR  1
     62#endif
     63
     64#ifndef SEEK_END
    5965        #define SEEK_END  2
    6066#endif
     
    135141extern size_t fwrite(const void *, size_t, size_t, FILE *);
    136142
    137 extern int fseek(FILE *, long, int);
     143extern int fseek(FILE *, off64_t, int);
    138144extern void rewind(FILE *);
    139 extern int ftell(FILE *);
     145extern off64_t ftell(FILE *);
    140146extern int feof(FILE *);
    141147
  • uspace/lib/libc/include/sys/mman.h

    r1ccafee r0b9ac3c  
    4141#define MAP_FAILED  ((void *) -1)
    4242
    43 #define MAP_SHARED       (1 << 0)
    44 #define MAP_PRIVATE      (1 << 1)
    45 #define MAP_FIXED        (1 << 2)
    46 #define MAP_ANONYMOUS    (1 << 3)
     43#define MAP_SHARED     (1 << 0)
     44#define MAP_PRIVATE    (1 << 1)
     45#define MAP_FIXED      (1 << 2)
     46#define MAP_ANONYMOUS  (1 << 3)
    4747
    4848#define PROTO_READ   AS_AREA_READ
     
    5050#define PROTO_EXEC   AS_AREA_EXEC
    5151
    52 extern void *mmap(void  *start, size_t length, int prot, int flags, int fd,
    53     off_t offset);
     52extern void *mmap(void *start, size_t length, int prot, int flags, int fd,
     53    aoff64_t offset);
    5454extern int munmap(void *start, size_t length);
    5555
  • uspace/lib/libc/include/sys/stat.h

    r1ccafee r0b9ac3c  
    3131 */
    3232/** @file
    33  */ 
     33 */
    3434
    3535#ifndef LIBC_SYS_STAT_H_
     
    4848        bool is_file;
    4949        bool is_directory;
    50         off_t size;
     50        aoff64_t size;
    5151        dev_handle_t device;
    5252};
  • uspace/lib/libc/include/sys/time.h

    r1ccafee r0b9ac3c  
    3131 */
    3232/** @file
    33  */ 
     33 */
    3434
    3535#ifndef LIBC_SYS_TIME_H_
     
    4444
    4545struct timeval {
    46         time_t         tv_sec;        /* seconds */
    47         suseconds_t    tv_usec;  /* microseconds */
     46        time_t tv_sec;        /* seconds */
     47        suseconds_t tv_usec;  /* microseconds */
    4848};
    4949
    5050struct timezone {
    51         int  tz_minuteswest; /* minutes W of Greenwich */
    52         int  tz_dsttime;     /* type of dst correction */
     51        int tz_minuteswest; /* minutes W of Greenwich */
     52        int tz_dsttime;      /* type of dst correction */
    5353};
    5454
  • uspace/lib/libc/include/sys/typefmt.h

    r1ccafee r0b9ac3c  
    3939#include <inttypes.h>
    4040
    41 /* off_t */
    42 #define PRIdOFF "ld"
    43 #define PRIuOFF "lu"
    44 #define PRIxOFF "lx"
    45 #define PRIXOFF "lX"
    46 
    47 /* bn_t */
    48 #define PRIdBN PRId64
    49 #define PRIuBN PRIu64
    50 #define PRIxBN PRIx64
    51 #define PRIXBN PRIX64
     41/* off64_t */
     42#define PRIdOFF64 PRId64
     43#define PRIuOFF64 PRIu64
     44#define PRIxOFF64 PRIx64
     45#define PRIXOFF64 PRIX64
    5246
    5347/* (s)size_t */
  • uspace/lib/libc/include/sys/types.h

    r1ccafee r0b9ac3c  
    3838#include <libarch/types.h>
    3939
    40 typedef long off_t;
    41 typedef int mode_t;
    42 typedef uint64_t bn_t;  /**< Block number type. */
     40typedef unsigned int mode_t;
    4341
     42/** Relative offset */
     43typedef int64_t off64_t;
     44
     45/** Absolute offset */
     46typedef uint64_t aoff64_t;
     47
     48/** Unicode code point */
    4449typedef int32_t wchar_t;
    4550
  • uspace/lib/libc/include/unistd.h

    r1ccafee r0b9ac3c  
    4747#ifndef SEEK_SET
    4848        #define SEEK_SET  0
     49#endif
     50
     51#ifndef SEEK_CUR
    4952        #define SEEK_CUR  1
     53#endif
     54
     55#ifndef SEEK_END
    5056        #define SEEK_END  2
    5157#endif
     
    5864extern ssize_t read(int, void *, size_t);
    5965
    60 extern off_t lseek(int, off_t, int);
    61 extern int ftruncate(int, off_t);
     66extern off64_t lseek(int, off64_t, int);
     67extern int ftruncate(int, aoff64_t);
    6268
    6369extern int close(int);
     
    6975extern int chdir(const char *);
    7076
    71 extern void _exit(int status) __attribute__ ((noreturn));
    72 extern int usleep(useconds_t uses);
    73 extern unsigned int sleep(unsigned int se);
     77extern void _exit(int) __attribute__((noreturn));
     78extern int usleep(useconds_t);
     79extern unsigned int sleep(unsigned int);
    7480
    7581#endif
  • uspace/lib/libfs/libfs.c

    r1ccafee r0b9ac3c  
    3737#include "libfs.h"
    3838#include "../../srv/vfs/vfs.h"
     39#include <macros.h>
    3940#include <errno.h>
    4041#include <async.h>
     
    161162        /* Accept the phone */
    162163        callid = async_get_call(&call);
    163         int mountee_phone = (int)IPC_GET_ARG1(call);
     164        int mountee_phone = (int) IPC_GET_ARG1(call);
    164165        if ((IPC_GET_METHOD(call) != IPC_M_CONNECTION_CLONE) ||
    165166            (mountee_phone < 0)) {
     
    172173        ipc_answer_0(callid, EOK);
    173174       
    174         res = async_data_write_receive(&callid, NULL);
    175         if (!res) {
    176                 ipc_hangup(mountee_phone);
    177                 ipc_answer_0(callid, EINVAL);
    178                 ipc_answer_0(rid, EINVAL);
    179                 return;
    180         }
    181        
    182175        fs_node_t *fn;
    183176        res = ops->node_get(&fn, mp_dev_handle, mp_fs_index);
    184177        if ((res != EOK) || (!fn)) {
    185178                ipc_hangup(mountee_phone);
    186                 ipc_answer_0(callid, combine_rc(res, ENOENT));
     179                async_data_write_void(combine_rc(res, ENOENT));
    187180                ipc_answer_0(rid, combine_rc(res, ENOENT));
    188181                return;
     
    192185                ipc_hangup(mountee_phone);
    193186                (void) ops->node_put(fn);
    194                 ipc_answer_0(callid, EBUSY);
     187                async_data_write_void(EBUSY);
    195188                ipc_answer_0(rid, EBUSY);
    196189                return;
     
    201194                ipc_hangup(mountee_phone);
    202195                (void) ops->node_put(fn);
    203                 ipc_answer_0(callid, rc);
     196                async_data_write_void(rc);
    204197                ipc_answer_0(rid, rc);
    205198                return;
     
    207200       
    208201        ipc_call_t answer;
    209         aid_t msg = async_send_1(mountee_phone, VFS_OUT_MOUNTED, mr_dev_handle,
    210             &answer);
    211         ipc_forward_fast(callid, mountee_phone, 0, 0, 0, IPC_FF_ROUTE_FROM_ME);
    212         async_wait_for(msg, &rc);
     202        rc = async_data_write_forward_1_1(mountee_phone, VFS_OUT_MOUNTED,
     203            mr_dev_handle, &answer);
    213204       
    214205        if (rc == EOK) {
     
    408399                                                ipc_answer_0(rid, rc);
    409400                                        } else {
    410                                                 ipc_answer_5(rid, EOK,
    411                                                     fs_handle, dev_handle,
     401                                                aoff64_t size = ops->size_get(fn);
     402                                                ipc_answer_5(rid, fs_handle,
     403                                                    dev_handle,
    412404                                                    ops->index_get(fn),
    413                                                     ops->size_get(fn),
     405                                                    LOWER32(size),
     406                                                    UPPER32(size),
    414407                                                    ops->lnkcnt_get(fn));
    415408                                                (void) ops->node_put(fn);
     
    488481                                        ipc_answer_0(rid, rc);
    489482                                } else {
    490                                         ipc_answer_5(rid, EOK,
    491                                             fs_handle, dev_handle,
     483                                        aoff64_t size = ops->size_get(fn);
     484                                        ipc_answer_5(rid, fs_handle,
     485                                            dev_handle,
    492486                                            ops->index_get(fn),
    493                                             ops->size_get(fn),
     487                                            LOWER32(size),
     488                                            UPPER32(size),
    494489                                            ops->lnkcnt_get(fn));
    495490                                        (void) ops->node_put(fn);
     
    511506                unsigned int old_lnkcnt = ops->lnkcnt_get(cur);
    512507                rc = ops->unlink(par, cur, component);
    513                 ipc_answer_5(rid, (ipcarg_t) rc, fs_handle, dev_handle,
    514                     ops->index_get(cur), ops->size_get(cur), old_lnkcnt);
     508               
     509                if (rc == EOK) {
     510                        aoff64_t size = ops->size_get(cur);
     511                        ipc_answer_5(rid, fs_handle, dev_handle,
     512                            ops->index_get(cur), LOWER32(size), UPPER32(size),
     513                            old_lnkcnt);
     514                } else
     515                        ipc_answer_0(rid, rc);
     516               
    515517                goto out;
    516518        }
     
    543545                        rc = ops->node_open(cur);
    544546               
    545                 ipc_answer_5(rid, rc, fs_handle, dev_handle,
    546                     ops->index_get(cur), ops->size_get(cur),
    547                     ops->lnkcnt_get(cur));
     547                if (rc == EOK) {
     548                        aoff64_t size = ops->size_get(cur);
     549                        ipc_answer_5(rid, fs_handle, dev_handle,
     550                            ops->index_get(cur), LOWER32(size), UPPER32(size),
     551                            ops->lnkcnt_get(cur));
     552                } else
     553                        ipc_answer_0(rid, rc);
     554               
    548555        } else
    549556                ipc_answer_0(rid, rc);
     
    612619        dev_handle_t dev_handle = IPC_GET_ARG1(*request);
    613620        fs_index_t index = IPC_GET_ARG2(*request);
     621       
    614622        fs_node_t *fn;
    615         int rc;
    616        
    617         rc = ops->node_get(&fn, dev_handle, index);
     623        int rc = ops->node_get(&fn, dev_handle, index);
    618624        on_error(rc, answer_and_return(rid, rc));
    619625       
     
    624630       
    625631        rc = ops->node_open(fn);
    626         ipc_answer_3(rid, rc, ops->size_get(fn), ops->lnkcnt_get(fn),
     632        aoff64_t size = ops->size_get(fn);
     633        ipc_answer_4(rid, rc, LOWER32(size), UPPER32(size), ops->lnkcnt_get(fn),
    627634            (ops->is_file(fn) ? L_FILE : 0) | (ops->is_directory(fn) ? L_DIRECTORY : 0));
    628635       
  • uspace/lib/libfs/libfs.h

    r1ccafee r0b9ac3c  
    7676         */
    7777        fs_index_t (* index_get)(fs_node_t *);
    78         size_t (* size_get)(fs_node_t *);
     78        aoff64_t (* size_get)(fs_node_t *);
    7979        unsigned int (* lnkcnt_get)(fs_node_t *);
    8080        char (* plb_get_char)(unsigned pos);
Note: See TracChangeset for help on using the changeset viewer.