Changeset aa85487 in mainline for uspace/lib/libc


Ignore:
Timestamp:
2010-03-07T15:11:56Z (16 years ago)
Author:
Lukas Mejdrech <lukasmejdrech@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
aadf01e
Parents:
2e99277 (diff), 137691a (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, revision 308

Location:
uspace/lib/libc
Files:
32 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/libc/Makefile.toolchain

    r2e99277 raa85487  
    2727#
    2828
    29 GCC_CFLAGS = -I$(LIBC_PREFIX)/include -O3 -imacros $(LIBC_PREFIX)/../../../config.h \
     29OPTIMIZATION = 3
     30
     31GCC_CFLAGS = -I$(LIBC_PREFIX)/include -O$(OPTIMIZATION) -imacros $(LIBC_PREFIX)/../../../config.h \
    3032        -fexec-charset=UTF-8 -fwide-exec-charset=UTF-32$(ENDIANESS) \
    3133        -finput-charset=UTF-8 -ffreestanding -fno-builtin -nostdlib -nostdinc \
    3234        -Wall -Wextra -Wno-clobbered -Wno-unused-parameter -Wmissing-prototypes \
    33         -Werror-implicit-function-declaration -Werror -pipe -g -D__$(ENDIANESS)__
     35        -Werror-implicit-function-declaration -Wwrite-strings \
     36        -Werror -pipe -g -D__$(ENDIANESS)__
    3437
    35 ICC_CFLAGS = -I$(LIBC_PREFIX)/include -O3 -imacros $(LIBC_PREFIX)/../../../config.h \
     38ICC_CFLAGS = -I$(LIBC_PREFIX)/include -O$(OPTIMIZATION) -imacros $(LIBC_PREFIX)/../../../config.h \
     39        -fexec-charset=UTF-8 -fwide-exec-charset=UTF-32$(ENDIANESS) \
     40        -finput-charset=UTF-8 -ffreestanding -fno-builtin -nostdlib -nostdinc \
     41        -Wall -Wextra -Wno-clobbered -Wno-unused-parameter -Wmissing-prototypes \
     42        -Werror-implicit-function-declaration -Wwrite-strings \
     43        -Werror -pipe -g -D__$(ENDIANESS)__
     44
     45CLANG_CFLAGS = -I$(LIBC_PREFIX)/include -O$(OPTIMIZATION) -imacros $(LIBC_PREFIX)/../../../config.h \
    3646        -fexec-charset=UTF-8 -fwide-exec-charset=UTF-32$(ENDIANESS) \
    3747        -finput-charset=UTF-8 -ffreestanding -fno-builtin -nostdlib -nostdinc \
    3848        -Wall -Wextra -Wno-unused-parameter -Wmissing-prototypes \
    39         -Werror-implicit-function-declaration -Werror -pipe -g -D__$(ENDIANESS)__
    40 
    41 CLANG_CFLAGS = -I$(LIBC_PREFIX)/include -O3 -imacros $(LIBC_PREFIX)/../../../config.h \
    42         -fexec-charset=UTF-8 -fwide-exec-charset=UTF-32$(ENDIANESS) \
    43         -finput-charset=UTF-8 -ffreestanding -fno-builtin -nostdlib -nostdinc \
    44         -Wall -Wextra -Wno-unused-parameter -Wmissing-prototypes \
    45         -Werror-implicit-function-declaration -pipe -g -arch $(CLANG_ARCH) \
    46         -D__$(ENDIANESS)__
     49        -Werror-implicit-function-declaration -Wwrite-strings \
     50        -pipe -g -arch $(CLANG_ARCH) -D__$(ENDIANESS)__
    4751
    4852LFLAGS = -M -N $(SOFTINT_PREFIX)/libsoftint.a
  • uspace/lib/libc/arch/abs32le/Makefile.inc

    r2e99277 raa85487  
    4646endif
    4747
     48ifeq ($(COMPILER),clang)
     49        CLANG_ARCH = i386
     50endif
     51
    4852ARCH_SOURCES = \
    4953        arch/$(UARCH)/src/entry.c \
  • uspace/lib/libc/arch/abs32le/include/atomic.h

    r2e99277 raa85487  
    4343#include <atomicdflt.h>
    4444
    45 static inline bool cas(atomic_t *val, long ov, long nv)
     45static inline bool cas(atomic_t *val, atomic_count_t ov, atomic_count_t nv)
    4646{
    4747        if (val->count == ov) {
     
    6767}
    6868
    69 static inline long atomic_postinc(atomic_t *val)
     69static inline atomic_count_t atomic_postinc(atomic_t *val)
    7070{
    7171        /* On real hardware both the storing of the previous
     
    7373           atomic action. */
    7474       
    75         long prev = val->count;
     75        atomic_count_t prev = val->count;
    7676       
    7777        val->count++;
     
    7979}
    8080
    81 static inline long atomic_postdec(atomic_t *val)
     81static inline atomic_count_t atomic_postdec(atomic_t *val)
    8282{
    8383        /* On real hardware both the storing of the previous
     
    8585           atomic action. */
    8686       
    87         long prev = val->count;
     87        atomic_count_t prev = val->count;
    8888       
    8989        val->count--;
  • uspace/lib/libc/arch/abs32le/include/types.h

    r2e99277 raa85487  
    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/amd64/include/atomic.h

    r2e99277 raa85487  
    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/types.h

    r2e99277 raa85487  
    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/include/atomic.h

    r2e99277 raa85487  
    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/types.h

    r2e99277 raa85487  
    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/include/atomic.h

    r2e99277 raa85487  
    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/types.h

    r2e99277 raa85487  
    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/include/atomic.h

    r2e99277 raa85487  
    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/types.h

    r2e99277 raa85487  
    5959
    6060typedef uint64_t uintptr_t;
     61typedef uint64_t atomic_count_t;
     62typedef int64_t atomic_signed_t;
    6163
    6264typedef struct {
  • uspace/lib/libc/arch/mips32/include/atomic.h

    r2e99277 raa85487  
    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/types.h

    r2e99277 raa85487  
    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/ppc32/include/atomic.h

    r2e99277 raa85487  
    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/types.h

    r2e99277 raa85487  
    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/include/atomic.h

    r2e99277 raa85487  
    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/types.h

    r2e99277 raa85487  
    5454
    5555typedef uint64_t uintptr_t;
     56typedef uint64_t atomic_count_t;
     57typedef int64_t atomic_signed_t;
    5658
    5759#endif
  • uspace/lib/libc/generic/async.c

    r2e99277 raa85487  
    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 *
  • uspace/lib/libc/generic/futex.c

    r2e99277 raa85487  
    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

    r2e99277 raa85487  
    536536}
    537537
     538char *fgets(char *str, int size, FILE *stream)
     539{
     540        int c;
     541        int idx;
     542
     543        idx = 0;
     544        while (idx < size - 1) {
     545                c = fgetc(stream);
     546                if (c == EOF)
     547                        break;
     548
     549                str[idx++] = c;
     550
     551                if (c == '\n')
     552                        break;
     553        }
     554
     555        if (ferror(stream))
     556                return NULL;
     557
     558        if (idx == 0)
     559                return NULL;
     560
     561        str[idx] = '\0';
     562        return str;
     563}
     564
    538565int getchar(void)
    539566{
  • uspace/lib/libc/generic/loader.c

    r2e99277 raa85487  
    183183 *
    184184 */
    185 int loader_set_args(loader_t *ldr, char *const argv[])
     185int loader_set_args(loader_t *ldr, const char *const argv[])
    186186{
    187187        /*
     
    189189         * compute size of the buffer needed.
    190190         */
    191         char *const *ap = argv;
     191        const char *const *ap = argv;
    192192        size_t buffer_size = 0;
    193193        while (*ap != NULL) {
  • uspace/lib/libc/generic/sysinfo.c

    r2e99277 raa85487  
    3737#include <string.h>
    3838
    39 sysarg_t sysinfo_value(char *name)
     39sysarg_t sysinfo_value(const char *name)
    4040{
    41         return __SYSCALL2(SYS_SYSINFO_VALUE, (sysarg_t ) name,
     41        return __SYSCALL2(SYS_SYSINFO_VALUE, (sysarg_t) name,
    4242            (sysarg_t) str_size(name));
    4343}
  • uspace/lib/libc/generic/task.c

    r2e99277 raa85487  
    7676 *
    7777 */
    78 task_id_t task_spawn(const char *path, char *const args[])
     78task_id_t task_spawn(const char *path, const char *const args[])
    7979{
    8080        /* Connect to a program loader. */
  • uspace/lib/libc/generic/thread.c

    r2e99277 raa85487  
    8686 * @return Zero on success or a code from @ref errno.h on failure.
    8787 */
    88 int thread_create(void (* function)(void *), void *arg, char *name,
     88int thread_create(void (* function)(void *), void *arg, const char *name,
    8989    thread_id_t *tid)
    9090{
  • uspace/lib/libc/include/async.h

    r2e99277 raa85487  
    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().
  • uspace/lib/libc/include/atomicdflt.h

    r2e99277 raa85487  
    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
    5859#ifndef CAS
    59 static inline bool cas(atomic_t *val, long ov, long nv)
     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/loader/loader.h

    r2e99277 raa85487  
    5151extern int loader_set_cwd(loader_t *);
    5252extern int loader_set_pathname(loader_t *, const char *);
    53 extern int loader_set_args(loader_t *, char *const[]);
     53extern int loader_set_args(loader_t *, const char *const[]);
    5454extern int loader_set_files(loader_t *, fdi_node_t *const[]);
    5555extern int loader_load_program(loader_t *);
  • uspace/lib/libc/include/stdio.h

    r2e99277 raa85487  
    110110/* Character and string input functions */
    111111extern int fgetc(FILE *);
    112 extern char *fgets(char *, size_t, FILE *);
     112extern char *fgets(char *, int, FILE *);
    113113
    114114extern int getchar(void);
  • uspace/lib/libc/include/sysinfo.h

    r2e99277 raa85487  
    4040#include <string.h>
    4141
    42 sysarg_t sysinfo_value(char *name);
     42sysarg_t sysinfo_value(const char *name);
    4343
    4444#endif
  • uspace/lib/libc/include/task.h

    r2e99277 raa85487  
    4747extern task_id_t task_get_id(void);
    4848extern int task_set_name(const char *name);
    49 extern task_id_t task_spawn(const char *path, char *const argv[]);
     49extern task_id_t task_spawn(const char *path, const char *const argv[]);
    5050extern int task_wait(task_id_t id, task_exit_t *texit, int *retval);
    5151extern int task_retval(int val);
  • uspace/lib/libc/include/thread.h

    r2e99277 raa85487  
    4545extern void __thread_main(uspace_arg_t *);
    4646
    47 extern int thread_create(void (*)(void *), void *, char *, thread_id_t *);
     47extern int thread_create(void (*)(void *), void *, const char *, thread_id_t *);
    4848extern void thread_exit(int) __attribute__ ((noreturn));
    4949extern void thread_detach(thread_id_t);
Note: See TracChangeset for help on using the changeset viewer.