Changeset aa85487 in mainline for uspace/lib/libc
- Timestamp:
- 2010-03-07T15:11:56Z (16 years ago)
- 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. - Location:
- uspace/lib/libc
- Files:
-
- 32 edited
-
Makefile.toolchain (modified) (1 diff)
-
arch/abs32le/Makefile.inc (modified) (1 diff)
-
arch/abs32le/include/atomic.h (modified) (5 diffs)
-
arch/abs32le/include/types.h (modified) (1 diff)
-
arch/amd64/include/atomic.h (modified) (2 diffs)
-
arch/amd64/include/types.h (modified) (1 diff)
-
arch/arm32/include/atomic.h (modified) (12 diffs)
-
arch/arm32/include/types.h (modified) (1 diff)
-
arch/ia32/include/atomic.h (modified) (2 diffs)
-
arch/ia32/include/types.h (modified) (1 diff)
-
arch/ia64/include/atomic.h (modified) (6 diffs)
-
arch/ia64/include/types.h (modified) (1 diff)
-
arch/mips32/include/atomic.h (modified) (3 diffs)
-
arch/mips32/include/types.h (modified) (2 diffs)
-
arch/ppc32/include/atomic.h (modified) (6 diffs)
-
arch/ppc32/include/types.h (modified) (2 diffs)
-
arch/sparc64/include/atomic.h (modified) (1 diff)
-
arch/sparc64/include/types.h (modified) (1 diff)
-
generic/async.c (modified) (1 diff)
-
generic/futex.c (modified) (2 diffs)
-
generic/io/io.c (modified) (1 diff)
-
generic/loader.c (modified) (2 diffs)
-
generic/sysinfo.c (modified) (1 diff)
-
generic/task.c (modified) (1 diff)
-
generic/thread.c (modified) (1 diff)
-
include/async.h (modified) (1 diff)
-
include/atomicdflt.h (modified) (1 diff)
-
include/loader/loader.h (modified) (1 diff)
-
include/stdio.h (modified) (1 diff)
-
include/sysinfo.h (modified) (1 diff)
-
include/task.h (modified) (1 diff)
-
include/thread.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/libc/Makefile.toolchain
r2e99277 raa85487 27 27 # 28 28 29 GCC_CFLAGS = -I$(LIBC_PREFIX)/include -O3 -imacros $(LIBC_PREFIX)/../../../config.h \ 29 OPTIMIZATION = 3 30 31 GCC_CFLAGS = -I$(LIBC_PREFIX)/include -O$(OPTIMIZATION) -imacros $(LIBC_PREFIX)/../../../config.h \ 30 32 -fexec-charset=UTF-8 -fwide-exec-charset=UTF-32$(ENDIANESS) \ 31 33 -finput-charset=UTF-8 -ffreestanding -fno-builtin -nostdlib -nostdinc \ 32 34 -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)__ 34 37 35 ICC_CFLAGS = -I$(LIBC_PREFIX)/include -O3 -imacros $(LIBC_PREFIX)/../../../config.h \ 38 ICC_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 45 CLANG_CFLAGS = -I$(LIBC_PREFIX)/include -O$(OPTIMIZATION) -imacros $(LIBC_PREFIX)/../../../config.h \ 36 46 -fexec-charset=UTF-8 -fwide-exec-charset=UTF-32$(ENDIANESS) \ 37 47 -finput-charset=UTF-8 -ffreestanding -fno-builtin -nostdlib -nostdinc \ 38 48 -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)__ 47 51 48 52 LFLAGS = -M -N $(SOFTINT_PREFIX)/libsoftint.a -
uspace/lib/libc/arch/abs32le/Makefile.inc
r2e99277 raa85487 46 46 endif 47 47 48 ifeq ($(COMPILER),clang) 49 CLANG_ARCH = i386 50 endif 51 48 52 ARCH_SOURCES = \ 49 53 arch/$(UARCH)/src/entry.c \ -
uspace/lib/libc/arch/abs32le/include/atomic.h
r2e99277 raa85487 43 43 #include <atomicdflt.h> 44 44 45 static inline bool cas(atomic_t *val, long ov, longnv)45 static inline bool cas(atomic_t *val, atomic_count_t ov, atomic_count_t nv) 46 46 { 47 47 if (val->count == ov) { … … 67 67 } 68 68 69 static inline longatomic_postinc(atomic_t *val)69 static inline atomic_count_t atomic_postinc(atomic_t *val) 70 70 { 71 71 /* On real hardware both the storing of the previous … … 73 73 atomic action. */ 74 74 75 longprev = val->count;75 atomic_count_t prev = val->count; 76 76 77 77 val->count++; … … 79 79 } 80 80 81 static inline longatomic_postdec(atomic_t *val)81 static inline atomic_count_t atomic_postdec(atomic_t *val) 82 82 { 83 83 /* On real hardware both the storing of the previous … … 85 85 atomic action. */ 86 86 87 longprev = val->count;87 atomic_count_t prev = val->count; 88 88 89 89 val->count--; -
uspace/lib/libc/arch/abs32le/include/types.h
r2e99277 raa85487 54 54 55 55 typedef uint32_t uintptr_t; 56 typedef uint32_t atomic_count_t; 57 typedef int32_t atomic_signed_t; 56 58 57 59 #endif -
uspace/lib/libc/arch/amd64/include/atomic.h
r2e99277 raa85487 42 42 #include <atomicdflt.h> 43 43 44 static inline void atomic_inc(atomic_t *val) { 45 asm volatile ("lock incq %0\n" : "+m" (val->count)); 44 static inline void atomic_inc(atomic_t *val) 45 { 46 asm volatile ( 47 "lock incq %[count]\n" 48 : [count] "+m" (val->count) 49 ); 46 50 } 47 51 48 static inline void atomic_dec(atomic_t *val) { 49 asm volatile ("lock decq %0\n" : "+m" (val->count)); 52 static inline void atomic_dec(atomic_t *val) 53 { 54 asm volatile ( 55 "lock decq %[count]\n" 56 : [count] "+m" (val->count) 57 ); 50 58 } 51 59 52 static inline long atomic_postinc(atomic_t *val)60 static inline atomic_count_t atomic_postinc(atomic_t *val) 53 61 { 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; 68 63 69 64 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) 73 68 ); 74 69 … … 76 71 } 77 72 78 #define atomic_preinc(val) (atomic_postinc(val) + 1) 79 #define atomic_predec(val) (atomic_postdec(val) - 1) 73 static 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) 80 88 81 89 #endif -
uspace/lib/libc/arch/amd64/include/types.h
r2e99277 raa85487 54 54 55 55 typedef uint64_t uintptr_t; 56 typedef uint64_t atomic_count_t; 57 typedef int64_t atomic_signed_t; 56 58 57 59 #endif -
uspace/lib/libc/arch/arm32/include/atomic.h
r2e99277 raa85487 27 27 */ 28 28 29 /** @addtogroup libcarm32 29 /** @addtogroup libcarm32 30 30 * @{ 31 31 */ … … 38 38 39 39 #define LIBC_ARCH_ATOMIC_H_ 40 #define CAS 40 #define CAS 41 41 42 42 #include <atomicdflt.h> … … 46 46 extern uintptr_t *ras_page; 47 47 48 static inline bool cas(atomic_t *val, long ov, longnv)49 { 50 longret = 0;51 48 static inline bool cas(atomic_t *val, atomic_count_t ov, atomic_count_t nv) 49 { 50 atomic_count_t ret = 0; 51 52 52 /* 53 53 * The following instructions between labels 1 and 2 constitute a … … 75 75 : "memory" 76 76 ); 77 77 78 78 ras_page[0] = 0; 79 asm volatile ("" ::: "memory"); 79 asm volatile ( 80 "" ::: "memory" 81 ); 80 82 ras_page[1] = 0xffffffff; 81 83 82 84 return (bool) ret; 83 85 } … … 89 91 * 90 92 * @return Value after addition. 91 */ 92 static inline long atomic_add(atomic_t *val, int i) 93 { 94 long ret = 0; 95 93 * 94 */ 95 static inline atomic_count_t atomic_add(atomic_t *val, atomic_count_t i) 96 { 97 atomic_count_t ret = 0; 98 96 99 /* 97 100 * The following instructions between labels 1 and 2 constitute a … … 115 118 : [imm] "r" (i) 116 119 ); 117 120 118 121 ras_page[0] = 0; 119 asm volatile ("" ::: "memory"); 122 asm volatile ( 123 "" ::: "memory" 124 ); 120 125 ras_page[1] = 0xffffffff; 121 126 122 127 return ret; 123 128 } … … 127 132 * 128 133 * @param val Variable to be incremented. 134 * 129 135 */ 130 136 static inline void atomic_inc(atomic_t *val) … … 137 143 * 138 144 * @param val Variable to be decremented. 145 * 139 146 */ 140 147 static inline void atomic_dec(atomic_t *val) … … 148 155 * @param val Variable to be incremented. 149 156 * @return Value after incrementation. 150 */ 151 static inline long atomic_preinc(atomic_t *val) 157 * 158 */ 159 static inline atomic_count_t atomic_preinc(atomic_t *val) 152 160 { 153 161 return atomic_add(val, 1); … … 159 167 * @param val Variable to be decremented. 160 168 * @return Value after decrementation. 161 */ 162 static inline long atomic_predec(atomic_t *val) 169 * 170 */ 171 static inline atomic_count_t atomic_predec(atomic_t *val) 163 172 { 164 173 return atomic_add(val, -1); … … 170 179 * @param val Variable to be incremented. 171 180 * @return Value before incrementation. 172 */ 173 static inline long atomic_postinc(atomic_t *val) 181 * 182 */ 183 static inline atomic_count_t atomic_postinc(atomic_t *val) 174 184 { 175 185 return atomic_add(val, 1) - 1; … … 181 191 * @param val Variable to be decremented. 182 192 * @return Value before decrementation. 183 */ 184 static inline long atomic_postdec(atomic_t *val) 193 * 194 */ 195 static inline atomic_count_t atomic_postdec(atomic_t *val) 185 196 { 186 197 return atomic_add(val, -1) + 1; -
uspace/lib/libc/arch/arm32/include/types.h
r2e99277 raa85487 55 55 56 56 typedef uint32_t uintptr_t; 57 typedef uint32_t atomic_count_t; 58 typedef int32_t atomic_signed_t; 57 59 58 60 #endif -
uspace/lib/libc/arch/ia32/include/atomic.h
r2e99277 raa85487 40 40 #include <atomicdflt.h> 41 41 42 static inline void atomic_inc(atomic_t *val) { 43 asm volatile ("lock incl %0\n" : "+m" (val->count)); 42 static inline void atomic_inc(atomic_t *val) 43 { 44 asm volatile ( 45 "lock incl %[count]\n" 46 : [count] "+m" (val->count) 47 ); 44 48 } 45 49 46 static inline void atomic_dec(atomic_t *val) { 47 asm volatile ("lock decl %0\n" : "+m" (val->count)); 50 static inline void atomic_dec(atomic_t *val) 51 { 52 asm volatile ( 53 "lock decl %[count]\n" 54 : [count] "+m" (val->count) 55 ); 48 56 } 49 57 50 static inline long atomic_postinc(atomic_t *val)58 static inline atomic_count_t atomic_postinc(atomic_t *val) 51 59 { 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; 66 61 67 62 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) 71 66 ); 72 67 … … 74 69 } 75 70 76 #define atomic_preinc(val) (atomic_postinc(val) + 1) 77 #define atomic_predec(val) (atomic_postdec(val) - 1) 71 static 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) 78 86 79 87 #endif -
uspace/lib/libc/arch/ia32/include/types.h
r2e99277 raa85487 54 54 55 55 typedef uint32_t uintptr_t; 56 typedef uint32_t atomic_count_t; 57 typedef int32_t atomic_signed_t; 56 58 57 59 #endif -
uspace/lib/libc/arch/ia64/include/atomic.h
r2e99277 raa85487 42 42 static inline void atomic_inc(atomic_t *val) 43 43 { 44 longv;44 atomic_count_t v; 45 45 46 46 asm volatile ( … … 53 53 static inline void atomic_dec(atomic_t *val) 54 54 { 55 longv;55 atomic_count_t v; 56 56 57 57 asm volatile ( … … 62 62 } 63 63 64 static inline longatomic_preinc(atomic_t *val)64 static inline atomic_count_t atomic_preinc(atomic_t *val) 65 65 { 66 longv;66 atomic_count_t v; 67 67 68 68 asm volatile ( … … 75 75 } 76 76 77 static inline longatomic_predec(atomic_t *val)77 static inline atomic_count_t atomic_predec(atomic_t *val) 78 78 { 79 longv;79 atomic_count_t v; 80 80 81 81 asm volatile ( … … 88 88 } 89 89 90 static inline longatomic_postinc(atomic_t *val)90 static inline atomic_count_t atomic_postinc(atomic_t *val) 91 91 { 92 longv;92 atomic_count_t v; 93 93 94 94 asm volatile ( … … 101 101 } 102 102 103 static inline longatomic_postdec(atomic_t *val)103 static inline atomic_count_t atomic_postdec(atomic_t *val) 104 104 { 105 longv;105 atomic_count_t v; 106 106 107 107 asm volatile ( -
uspace/lib/libc/arch/ia64/include/types.h
r2e99277 raa85487 59 59 60 60 typedef uint64_t uintptr_t; 61 typedef uint64_t atomic_count_t; 62 typedef int64_t atomic_signed_t; 61 63 62 64 typedef struct { -
uspace/lib/libc/arch/mips32/include/atomic.h
r2e99277 raa85487 27 27 */ 28 28 29 /** @addtogroup libcmips32 29 /** @addtogroup libcmips32 30 30 * @{ 31 31 */ 32 32 /** @file 33 * @ingroup libcmips32eb 33 * @ingroup libcmips32eb 34 34 */ 35 35 … … 41 41 #include <atomicdflt.h> 42 42 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)) 45 45 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) 48 48 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) 51 51 52 52 /* Atomic addition of immediate value. 53 53 * 54 54 * @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. 56 56 * 57 57 * @return Value after addition. 58 * 58 59 */ 59 static inline long atomic_add(atomic_t *val, int i)60 static inline atomic_count_t atomic_add(atomic_t *val, atomic_count_t i) 60 61 { 61 long tmp, v; 62 62 atomic_count_t tmp; 63 atomic_count_t v; 64 63 65 asm volatile ( 64 66 "1:\n" … … 70 72 /* nop */ /* nop is inserted automatically by compiler */ 71 73 " 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 76 81 return v; 77 82 } -
uspace/lib/libc/arch/mips32/include/types.h
r2e99277 raa85487 27 27 */ 28 28 29 /** @addtogroup libcmips32 29 /** @addtogroup libcmips32 30 30 * @{ 31 31 */ … … 55 55 56 56 typedef uint32_t uintptr_t; 57 typedef uint32_t atomic_count_t; 58 typedef int32_t atomic_signed_t; 57 59 58 60 #endif -
uspace/lib/libc/arch/ppc32/include/atomic.h
r2e99277 raa85487 27 27 */ 28 28 29 /** @addtogroup libcppc32 29 /** @addtogroup libcppc32 30 30 * @{ 31 31 */ … … 42 42 static inline void atomic_inc(atomic_t *val) 43 43 { 44 longtmp;45 44 atomic_count_t tmp; 45 46 46 asm volatile ( 47 47 "1:\n" … … 50 50 "stwcx. %0, 0, %2\n" 51 51 "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 ); 55 58 } 56 59 57 60 static inline void atomic_dec(atomic_t *val) 58 61 { 59 longtmp;60 62 atomic_count_t tmp; 63 61 64 asm volatile ( 62 65 "1:\n" 63 66 "lwarx %0, 0, %2\n" 64 67 "addic %0, %0, -1\n" 65 "stwcx. %0, 0, %2\n"68 "stwcx. %0, 0, %2\n" 66 69 "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 ); 70 76 } 71 77 72 static inline longatomic_postinc(atomic_t *val)78 static inline atomic_count_t atomic_postinc(atomic_t *val) 73 79 { 74 80 atomic_inc(val); … … 76 82 } 77 83 78 static inline longatomic_postdec(atomic_t *val)84 static inline atomic_count_t atomic_postdec(atomic_t *val) 79 85 { 80 86 atomic_dec(val); … … 82 88 } 83 89 84 static inline longatomic_preinc(atomic_t *val)90 static inline atomic_count_t atomic_preinc(atomic_t *val) 85 91 { 86 92 atomic_inc(val); … … 88 94 } 89 95 90 static inline longatomic_predec(atomic_t *val)96 static inline atomic_count_t atomic_predec(atomic_t *val) 91 97 { 92 98 atomic_dec(val); -
uspace/lib/libc/arch/ppc32/include/types.h
r2e99277 raa85487 27 27 */ 28 28 29 /** @addtogroup libcppc32 29 /** @addtogroup libcppc32 30 30 * @{ 31 31 */ … … 54 54 55 55 typedef uint32_t uintptr_t; 56 typedef uint32_t atomic_count_t; 57 typedef int32_t atomic_signed_t; 56 58 57 59 #endif -
uspace/lib/libc/arch/sparc64/include/atomic.h
r2e99277 raa85487 46 46 * 47 47 * @param val Atomic variable. 48 * @param i Signed value to be added.48 * @param i Signed value to be added. 49 49 * 50 50 * @return Value of the atomic variable as it existed before addition. 51 * 51 52 */ 52 static inline long atomic_add(atomic_t *val, int i)53 static inline atomic_count_t atomic_add(atomic_t *val, atomic_count_t i) 53 54 { 54 uint64_t a, b; 55 55 atomic_count_t a; 56 atomic_count_t b; 57 56 58 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); 60 62 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 ); 62 70 } while (a != b); 63 71 64 72 return a; 65 73 } 66 74 67 static inline longatomic_preinc(atomic_t *val)75 static inline atomic_count_t atomic_preinc(atomic_t *val) 68 76 { 69 77 return atomic_add(val, 1) + 1; 70 78 } 71 79 72 static inline longatomic_postinc(atomic_t *val)80 static inline atomic_count_t atomic_postinc(atomic_t *val) 73 81 { 74 82 return atomic_add(val, 1); 75 83 } 76 84 77 static inline longatomic_predec(atomic_t *val)85 static inline atomic_count_t atomic_predec(atomic_t *val) 78 86 { 79 87 return atomic_add(val, -1) - 1; 80 88 } 81 89 82 static inline longatomic_postdec(atomic_t *val)90 static inline atomic_count_t atomic_postdec(atomic_t *val) 83 91 { 84 92 return atomic_add(val, -1); -
uspace/lib/libc/arch/sparc64/include/types.h
r2e99277 raa85487 54 54 55 55 typedef uint64_t uintptr_t; 56 typedef uint64_t atomic_count_t; 57 typedef int64_t atomic_signed_t; 56 58 57 59 #endif -
uspace/lib/libc/generic/async.c
r2e99277 raa85487 1101 1101 } 1102 1102 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 */ 1114 int 1115 async_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 */ 1141 int 1142 async_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 1103 1157 /** Wrapper for making IPC_M_SHARE_IN calls using the async framework. 1104 1158 * -
uspace/lib/libc/generic/futex.c
r2e99277 raa85487 68 68 int futex_down(futex_t *futex) 69 69 { 70 if ( atomic_predec(futex) < 0)70 if ((atomic_signed_t) atomic_predec(futex) < 0) 71 71 return __SYSCALL1(SYS_FUTEX_SLEEP, (sysarg_t) &futex->count); 72 72 … … 82 82 int futex_up(futex_t *futex) 83 83 { 84 if ( atomic_postinc(futex) < 0)84 if ((atomic_signed_t) atomic_postinc(futex) < 0) 85 85 return __SYSCALL1(SYS_FUTEX_WAKEUP, (sysarg_t) &futex->count); 86 86 -
uspace/lib/libc/generic/io/io.c
r2e99277 raa85487 536 536 } 537 537 538 char *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 538 565 int getchar(void) 539 566 { -
uspace/lib/libc/generic/loader.c
r2e99277 raa85487 183 183 * 184 184 */ 185 int loader_set_args(loader_t *ldr, c har *const argv[])185 int loader_set_args(loader_t *ldr, const char *const argv[]) 186 186 { 187 187 /* … … 189 189 * compute size of the buffer needed. 190 190 */ 191 c har *const *ap = argv;191 const char *const *ap = argv; 192 192 size_t buffer_size = 0; 193 193 while (*ap != NULL) { -
uspace/lib/libc/generic/sysinfo.c
r2e99277 raa85487 37 37 #include <string.h> 38 38 39 sysarg_t sysinfo_value(c har *name)39 sysarg_t sysinfo_value(const char *name) 40 40 { 41 return __SYSCALL2(SYS_SYSINFO_VALUE, (sysarg_t ) name,41 return __SYSCALL2(SYS_SYSINFO_VALUE, (sysarg_t) name, 42 42 (sysarg_t) str_size(name)); 43 43 } -
uspace/lib/libc/generic/task.c
r2e99277 raa85487 76 76 * 77 77 */ 78 task_id_t task_spawn(const char *path, c har *const args[])78 task_id_t task_spawn(const char *path, const char *const args[]) 79 79 { 80 80 /* Connect to a program loader. */ -
uspace/lib/libc/generic/thread.c
r2e99277 raa85487 86 86 * @return Zero on success or a code from @ref errno.h on failure. 87 87 */ 88 int thread_create(void (* function)(void *), void *arg, c har *name,88 int thread_create(void (* function)(void *), void *arg, const char *name, 89 89 thread_id_t *tid) 90 90 { -
uspace/lib/libc/include/async.h
r2e99277 raa85487 259 259 } 260 260 261 extern int async_connect_me_to(int, ipcarg_t, ipcarg_t, ipcarg_t); 262 extern int async_connect_me_to_blocking(int, ipcarg_t, ipcarg_t, ipcarg_t); 263 261 264 /* 262 265 * User-friendly wrappers for async_share_in_start(). -
uspace/lib/libc/include/atomicdflt.h
r2e99277 raa85487 37 37 38 38 #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. 40 40 #endif 41 41 42 #include <stdint.h> 42 43 #include <bool.h> 43 44 44 45 typedef struct atomic { 45 volatile longcount;46 volatile atomic_count_t count; 46 47 } atomic_t; 47 48 48 static inline void atomic_set(atomic_t *val, longi)49 static inline void atomic_set(atomic_t *val, atomic_count_t i) 49 50 { 50 val->count = i;51 val->count = i; 51 52 } 52 53 53 static inline longatomic_get(atomic_t *val)54 static inline atomic_count_t atomic_get(atomic_t *val) 54 55 { 55 return val->count;56 return val->count; 56 57 } 57 58 58 59 #ifndef CAS 59 static inline bool cas(atomic_t *val, long ov, longnv)60 static inline bool cas(atomic_t *val, atomic_count_t ov, atomic_count_t nv) 60 61 { 61 62 return __sync_bool_compare_and_swap(&val->count, ov, nv); -
uspace/lib/libc/include/loader/loader.h
r2e99277 raa85487 51 51 extern int loader_set_cwd(loader_t *); 52 52 extern int loader_set_pathname(loader_t *, const char *); 53 extern int loader_set_args(loader_t *, c har *const[]);53 extern int loader_set_args(loader_t *, const char *const[]); 54 54 extern int loader_set_files(loader_t *, fdi_node_t *const[]); 55 55 extern int loader_load_program(loader_t *); -
uspace/lib/libc/include/stdio.h
r2e99277 raa85487 110 110 /* Character and string input functions */ 111 111 extern int fgetc(FILE *); 112 extern char *fgets(char *, size_t, FILE *);112 extern char *fgets(char *, int, FILE *); 113 113 114 114 extern int getchar(void); -
uspace/lib/libc/include/sysinfo.h
r2e99277 raa85487 40 40 #include <string.h> 41 41 42 sysarg_t sysinfo_value(c har *name);42 sysarg_t sysinfo_value(const char *name); 43 43 44 44 #endif -
uspace/lib/libc/include/task.h
r2e99277 raa85487 47 47 extern task_id_t task_get_id(void); 48 48 extern int task_set_name(const char *name); 49 extern task_id_t task_spawn(const char *path, c har *const argv[]);49 extern task_id_t task_spawn(const char *path, const char *const argv[]); 50 50 extern int task_wait(task_id_t id, task_exit_t *texit, int *retval); 51 51 extern int task_retval(int val); -
uspace/lib/libc/include/thread.h
r2e99277 raa85487 45 45 extern void __thread_main(uspace_arg_t *); 46 46 47 extern int thread_create(void (*)(void *), void *, c har *, thread_id_t *);47 extern int thread_create(void (*)(void *), void *, const char *, thread_id_t *); 48 48 extern void thread_exit(int) __attribute__ ((noreturn)); 49 49 extern void thread_detach(thread_id_t);
Note:
See TracChangeset
for help on using the changeset viewer.
