Changeset 0b9ac3c in mainline for uspace/lib
- Timestamp:
- 2010-02-23T19:03:28Z (16 years ago)
- 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. - Location:
- uspace/lib
- Files:
-
- 22 added
- 69 edited
- 1 moved
-
Makefile.common (modified) (2 diffs)
-
libblock/libblock.c (modified) (19 diffs)
-
libblock/libblock.h (modified) (2 diffs)
-
libc/Makefile (modified) (2 diffs)
-
libc/Makefile.toolchain (modified) (2 diffs)
-
libc/arch/abs32le/Makefile.inc (added)
-
libc/arch/abs32le/_link.ld.in (added)
-
libc/arch/abs32le/include/atomic.h (added)
-
libc/arch/abs32le/include/config.h (added)
-
libc/arch/abs32le/include/ddi.h (added)
-
libc/arch/abs32le/include/entry.h (added)
-
libc/arch/abs32le/include/faddr.h (added)
-
libc/arch/abs32le/include/fibril.h (added)
-
libc/arch/abs32le/include/inttypes.h (added)
-
libc/arch/abs32le/include/istate.h (added)
-
libc/arch/abs32le/include/limits.h (added)
-
libc/arch/abs32le/include/syscall.h (added)
-
libc/arch/abs32le/include/thread.h (added)
-
libc/arch/abs32le/include/tls.h (added)
-
libc/arch/abs32le/include/types.h (added)
-
libc/arch/abs32le/src/entry.c (added)
-
libc/arch/abs32le/src/fibril.c (added)
-
libc/arch/abs32le/src/stacktrace.c (added)
-
libc/arch/abs32le/src/syscall.c (added)
-
libc/arch/abs32le/src/thread_entry.c (moved) (moved from kernel/arch/mips32/include/smp/dorder.h ) (2 diffs)
-
libc/arch/abs32le/src/tls.c (added)
-
libc/arch/amd64/Makefile.inc (modified) (1 diff)
-
libc/arch/amd64/include/atomic.h (modified) (2 diffs)
-
libc/arch/amd64/include/limits.h (modified) (1 diff)
-
libc/arch/amd64/include/types.h (modified) (1 diff)
-
libc/arch/arm32/Makefile.inc (modified) (1 diff)
-
libc/arch/arm32/include/atomic.h (modified) (12 diffs)
-
libc/arch/arm32/include/limits.h (modified) (2 diffs)
-
libc/arch/arm32/include/types.h (modified) (1 diff)
-
libc/arch/ia32/Makefile.inc (modified) (1 diff)
-
libc/arch/ia32/include/atomic.h (modified) (2 diffs)
-
libc/arch/ia32/include/limits.h (modified) (1 diff)
-
libc/arch/ia32/include/syscall.h (modified) (1 diff)
-
libc/arch/ia32/include/tls.h (modified) (1 diff)
-
libc/arch/ia32/include/types.h (modified) (1 diff)
-
libc/arch/ia64/Makefile.inc (modified) (1 diff)
-
libc/arch/ia64/include/atomic.h (modified) (6 diffs)
-
libc/arch/ia64/include/ddi.h (modified) (1 diff)
-
libc/arch/ia64/include/faddr.h (modified) (2 diffs)
-
libc/arch/ia64/include/fibril.h (modified) (2 diffs)
-
libc/arch/ia64/include/limits.h (modified) (2 diffs)
-
libc/arch/ia64/include/types.h (modified) (2 diffs)
-
libc/arch/mips32/Makefile.inc (modified) (1 diff)
-
libc/arch/mips32/include/atomic.h (modified) (3 diffs)
-
libc/arch/mips32/include/limits.h (modified) (2 diffs)
-
libc/arch/mips32/include/types.h (modified) (2 diffs)
-
libc/arch/mips32eb/Makefile.inc (modified) (1 diff)
-
libc/arch/ppc32/Makefile.inc (modified) (1 diff)
-
libc/arch/ppc32/include/atomic.h (modified) (6 diffs)
-
libc/arch/ppc32/include/limits.h (modified) (2 diffs)
-
libc/arch/ppc32/include/types.h (modified) (2 diffs)
-
libc/arch/sparc64/Makefile.inc (modified) (2 diffs)
-
libc/arch/sparc64/include/atomic.h (modified) (1 diff)
-
libc/arch/sparc64/include/config.h (modified) (1 diff)
-
libc/arch/sparc64/include/ddi.h (modified) (1 diff)
-
libc/arch/sparc64/include/fibril.h (modified) (2 diffs)
-
libc/arch/sparc64/include/limits.h (modified) (2 diffs)
-
libc/arch/sparc64/include/types.h (modified) (2 diffs)
-
libc/arch/sparc64/src/thread_entry.s (modified) (1 diff)
-
libc/generic/async.c (modified) (9 diffs)
-
libc/generic/clipboard.c (modified) (3 diffs)
-
libc/generic/fibril.c (modified) (9 diffs)
-
libc/generic/futex.c (modified) (2 diffs)
-
libc/generic/io/io.c (modified) (2 diffs)
-
libc/generic/ipc.c (modified) (1 diff)
-
libc/generic/malloc.c (modified) (1 diff)
-
libc/generic/mman.c (modified) (1 diff)
-
libc/generic/vfs/vfs.c (modified) (10 diffs)
-
libc/include/async.h (modified) (2 diffs)
-
libc/include/atomicdflt.h (modified) (1 diff)
-
libc/include/fibril.h (modified) (4 diffs)
-
libc/include/ipc/adb.h (added)
-
libc/include/ipc/clipboard.h (modified) (1 diff)
-
libc/include/ipc/services.h (modified) (1 diff)
-
libc/include/limits.h (modified) (4 diffs)
-
libc/include/macros.h (modified) (1 diff)
-
libc/include/stacktrace.h (modified) (1 diff)
-
libc/include/stdio.h (modified) (3 diffs)
-
libc/include/sys/mman.h (modified) (2 diffs)
-
libc/include/sys/stat.h (modified) (2 diffs)
-
libc/include/sys/time.h (modified) (2 diffs)
-
libc/include/sys/typefmt.h (modified) (1 diff)
-
libc/include/sys/types.h (modified) (1 diff)
-
libc/include/unistd.h (modified) (3 diffs)
-
libfs/libfs.c (modified) (12 diffs)
-
libfs/libfs.h (modified) (1 diff)
-
softfloat/arch/abs32le/include/functions.h (added)
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/Makefile.common
r1ccafee r0b9ac3c 33 33 # Individual makefiles set: 34 34 # 35 # USPACE_PREFIXrelative path to uspace/ directory36 # LIBSlibraries to link with (with relative path)37 # EXTRA_CFLAGSadditional flags to pass to C compiler38 # JOBjob file name (like appname.job)39 # OUTPUToutput binary name (like appname)40 # SOURCESlist of source files35 # 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 41 41 # 42 42 … … 72 72 find . -name '*.o' -follow -exec rm \{\} \; 73 73 74 build: 74 build: 75 75 76 76 -include $(DEPEND) -
uspace/lib/libblock/libblock.c
r1ccafee r0b9ac3c 1 1 /* 2 * Copyright (c) 2008 Jakub Jermar 3 * Copyright (c) 2008 Martin Decky 2 * Copyright (c) 2008 Jakub Jermar 3 * Copyright (c) 2008 Martin Decky 4 4 * All rights reserved. 5 5 * … … 52 52 #include <macros.h> 53 53 #include <mem.h> 54 #include <sys/typefmt.h> 55 #include <stacktrace.h> 54 56 55 57 /** Lock protecting the device connection list */ … … 79 81 size_t comm_size; 80 82 void *bb_buf; 81 bn_t bb_addr;83 aoff64_t bb_addr; 82 84 size_t pblock_size; /**< Physical block size. */ 83 85 cache_t *cache; 84 86 } devcon_t; 85 87 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);88 static int read_blocks(devcon_t *devcon, aoff64_t ba, size_t cnt); 89 static int write_blocks(devcon_t *devcon, aoff64_t ba, size_t cnt); 88 90 static int get_block_size(int dev_phone, size_t *bsize); 89 static int get_num_blocks(int dev_phone, bn_t *nblocks);91 static int get_num_blocks(int dev_phone, aoff64_t *nblocks); 90 92 91 93 static devcon_t *devcon_search(dev_handle_t dev_handle) … … 198 200 assert(devcon); 199 201 202 if (devcon->cache) 203 (void) block_cache_fini(dev_handle); 204 200 205 devcon_remove(devcon); 201 206 … … 203 208 free(devcon->bb_buf); 204 209 205 if (devcon->cache) {206 hash_table_destroy(&devcon->cache->block_hash);207 free(devcon->cache);208 }209 210 210 munmap(devcon->comm_area, devcon->comm_size); 211 211 ipc_hangup(devcon->dev_phone); … … 214 214 } 215 215 216 int block_bb_read(dev_handle_t dev_handle, bn_t ba)216 int block_bb_read(dev_handle_t dev_handle, aoff64_t ba) 217 217 { 218 218 void *bb_buf; … … 305 305 } 306 306 307 int 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 307 350 #define CACHE_LO_WATERMARK 10 308 351 #define CACHE_HI_WATERMARK 20 … … 339 382 * @return EOK on success or a negative error code. 340 383 */ 341 int block_get(block_t **block, dev_handle_t dev_handle, bn_t boff, int flags)384 int block_get(block_t **block, dev_handle_t dev_handle, aoff64_t boff, int flags) 342 385 { 343 386 devcon_t *devcon; … … 614 657 * @return EOK on success or a negative return code on failure. 615 658 */ 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;659 int 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; 620 663 size_t left = size; 621 664 size_t block_size; … … 647 690 } 648 691 649 if (*bufpos == (off_t)*buflen) {692 if (*bufpos == *buflen) { 650 693 /* Refill the communication buffer with a new block. */ 651 694 int rc; … … 675 718 * @return EOK on success or negative error code on failure. 676 719 */ 677 int block_read_direct(dev_handle_t dev_handle, bn_t ba, size_t cnt, void *buf)720 int block_read_direct(dev_handle_t dev_handle, aoff64_t ba, size_t cnt, void *buf) 678 721 { 679 722 devcon_t *devcon; … … 703 746 * @return EOK on success or negative error code on failure. 704 747 */ 705 int block_write_direct(dev_handle_t dev_handle, bn_t ba, size_t cnt,748 int block_write_direct(dev_handle_t dev_handle, aoff64_t ba, size_t cnt, 706 749 const void *data) 707 750 { … … 746 789 * @return EOK on success or negative error code on failure. 747 790 */ 748 int block_get_nblocks(dev_handle_t dev_handle, bn_t *nblocks)791 int block_get_nblocks(dev_handle_t dev_handle, aoff64_t *nblocks) 749 792 { 750 793 devcon_t *devcon; … … 765 808 * @return EOK on success or negative error code on failure. 766 809 */ 767 static int read_blocks(devcon_t *devcon, bn_t ba, size_t cnt)810 static int read_blocks(devcon_t *devcon, aoff64_t ba, size_t cnt) 768 811 { 769 812 int rc; … … 772 815 rc = async_req_3_0(devcon->dev_phone, BD_READ_BLOCKS, LOWER32(ba), 773 816 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 } 774 825 return rc; 775 826 } … … 784 835 * @return EOK on success or negative error code on failure. 785 836 */ 786 static int write_blocks(devcon_t *devcon, bn_t ba, size_t cnt)837 static int write_blocks(devcon_t *devcon, aoff64_t ba, size_t cnt) 787 838 { 788 839 int rc; … … 791 842 rc = async_req_3_0(devcon->dev_phone, BD_WRITE_BLOCKS, LOWER32(ba), 792 843 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 } 793 851 return rc; 794 852 } … … 808 866 809 867 /** Get total number of blocks on block device. */ 810 static int get_num_blocks(int dev_phone, bn_t *nblocks)868 static int get_num_blocks(int dev_phone, aoff64_t *nblocks) 811 869 { 812 870 ipcarg_t nb_l, nb_h; … … 815 873 rc = async_req_0_2(dev_phone, BD_GET_NUM_BLOCKS, &nb_l, &nb_h); 816 874 if (rc == EOK) { 817 *nblocks = ( bn_t) MERGE_LOUP32(nb_l, nb_h);875 *nblocks = (aoff64_t) MERGE_LOUP32(nb_l, nb_h); 818 876 } 819 877 -
uspace/lib/libblock/libblock.h
r1ccafee r0b9ac3c 74 74 dev_handle_t dev_handle; 75 75 /** Block offset on the block device. Counted in 'size'-byte blocks. */ 76 bn_t boff;76 aoff64_t boff; 77 77 /** Size of the block. */ 78 78 size_t size; … … 96 96 extern void block_fini(dev_handle_t); 97 97 98 extern int block_bb_read(dev_handle_t, bn_t);98 extern int block_bb_read(dev_handle_t, aoff64_t); 99 99 extern void *block_bb_get(dev_handle_t); 100 100 101 101 extern int block_cache_init(dev_handle_t, size_t, unsigned, enum cache_mode); 102 extern int block_cache_fini(dev_handle_t); 102 103 103 extern int block_get(block_t **, dev_handle_t, bn_t, int);104 extern int block_get(block_t **, dev_handle_t, aoff64_t, int); 104 105 extern int block_put(block_t *); 105 106 106 extern int block_seqread(dev_handle_t, off_t *, size_t *, off_t *, void *,107 extern int block_seqread(dev_handle_t, size_t *, size_t *, aoff64_t *, void *, 107 108 size_t); 108 109 109 110 extern 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 *);111 extern int block_get_nblocks(dev_handle_t, aoff64_t *); 112 extern int block_read_direct(dev_handle_t, aoff64_t, size_t, void *); 113 extern int block_write_direct(dev_handle_t, aoff64_t, size_t, const void *); 113 114 114 115 #endif -
uspace/lib/libc/Makefile
r1ccafee r0b9ac3c 31 31 32 32 USPACE_PREFIX = $(shell pwd)/../.. 33 #LIBS = $(LIBC_PREFIX)/libc.a34 33 LIBS = 35 34 … … 91 90 generic/stacktrace.c 92 91 93 ARCH_SOURCES = \94 arch/$(UARCH)/src/entry.s \95 arch/$(UARCH)/src/thread_entry.s96 97 92 SOURCES = \ 98 93 $(GENERIC_SOURCES) \ -
uspace/lib/libc/Makefile.toolchain
r1ccafee r0b9ac3c 30 30 -fexec-charset=UTF-8 -fwide-exec-charset=UTF-32$(ENDIANESS) \ 31 31 -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)__ 34 34 35 35 ICC_CFLAGS = -I$(LIBC_PREFIX)/include -O3 -imacros $(LIBC_PREFIX)/../../../config.h \ … … 37 37 -finput-charset=UTF-8 -ffreestanding -fno-builtin -nostdlib -nostdinc \ 38 38 -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)__ 40 40 41 41 CLANG_CFLAGS = -I$(LIBC_PREFIX)/include -O3 -imacros $(LIBC_PREFIX)/../../../config.h \ -
uspace/lib/libc/arch/abs32le/src/thread_entry.c
r1ccafee r0b9ac3c 1 1 /* 2 * Copyright (c) 20 07Martin Decky2 * Copyright (c) 2010 Martin Decky 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 #ifndef KERN_mips32_DORDER_H_ 30 #define KERN_mips32_DORDER_H_ 29 /** @file 30 */ 31 31 32 extern void ipi_broadcast_arch(int ipi); 32 #include <unistd.h> 33 #include <thread.h> 33 34 34 #endif 35 void __thread_entry(void) 36 { 37 __thread_main(NULL); 38 } 39 40 /** @} 41 */ -
uspace/lib/libc/arch/amd64/Makefile.inc
r1ccafee r0b9ac3c 34 34 TOOLCHAIN_DIR = $(CROSS_PREFIX)/amd64/bin 35 35 36 ARCH_SOURCES += arch/$(UARCH)/src/syscall.S \ 36 ARCH_SOURCES = \ 37 arch/$(UARCH)/src/entry.s \ 38 arch/$(UARCH)/src/thread_entry.s \ 39 arch/$(UARCH)/src/syscall.S \ 37 40 arch/$(UARCH)/src/fibril.S \ 38 41 arch/$(UARCH)/src/tls.c \ -
uspace/lib/libc/arch/amd64/include/atomic.h
r1ccafee r0b9ac3c 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/limits.h
r1ccafee r0b9ac3c 36 36 #define LIBC_amd64_LIMITS_H_ 37 37 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 42 47 43 48 #endif -
uspace/lib/libc/arch/amd64/include/types.h
r1ccafee r0b9ac3c 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/Makefile.inc
r1ccafee r0b9ac3c 34 34 TOOLCHAIN_DIR = $(CROSS_PREFIX)/arm32/bin 35 35 36 ARCH_SOURCES += arch/$(UARCH)/src/syscall.c \ 36 ARCH_SOURCES = \ 37 arch/$(UARCH)/src/entry.s \ 38 arch/$(UARCH)/src/thread_entry.s \ 39 arch/$(UARCH)/src/syscall.c \ 37 40 arch/$(UARCH)/src/fibril.S \ 38 41 arch/$(UARCH)/src/tls.c \ -
uspace/lib/libc/arch/arm32/include/atomic.h
r1ccafee r0b9ac3c 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/limits.h
r1ccafee r0b9ac3c 27 27 */ 28 28 29 /** @addtogroup libcarm32 29 /** @addtogroup libcarm32 30 30 * @{ 31 31 */ 32 /** @file 32 /** @file 33 33 * @brief Limits declarations. 34 34 */ … … 42 42 #define ULONG_MAX MAX_UINT32 43 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 48 44 49 #endif 45 50 -
uspace/lib/libc/arch/arm32/include/types.h
r1ccafee r0b9ac3c 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/Makefile.inc
r1ccafee r0b9ac3c 34 34 TOOLCHAIN_DIR = $(CROSS_PREFIX)/ia32/bin 35 35 36 ARCH_SOURCES += arch/$(UARCH)/src/syscall.S \ 36 ARCH_SOURCES = \ 37 arch/$(UARCH)/src/entry.s \ 38 arch/$(UARCH)/src/thread_entry.s \ 39 arch/$(UARCH)/src/syscall.S \ 37 40 arch/$(UARCH)/src/fibril.S \ 38 41 arch/$(UARCH)/src/tls.c \ -
uspace/lib/libc/arch/ia32/include/atomic.h
r1ccafee r0b9ac3c 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/limits.h
r1ccafee r0b9ac3c 36 36 #define LIBC_ia32__LIMITS_H_ 37 37 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 42 47 43 48 #endif -
uspace/lib/libc/arch/ia32/include/syscall.h
r1ccafee r0b9ac3c 40 40 #include <kernel/syscall/syscall.h> 41 41 42 #define __syscall0 __syscall_fast_func43 #define __syscall1 __syscall_fast_func44 #define __syscall2 __syscall_fast_func45 #define __syscall3 __syscall_fast_func46 #define __syscall4 __syscall_fast_func47 #define __syscall5 __syscall_slow48 #define __syscall6 __syscall_slow42 #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 49 49 50 extern sysarg_t 51 (* __syscall_fast_func)(const sysarg_t, const sysarg_t, const sysarg_t, 50 extern 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 54 extern sysarg_t __syscall_slow(const sysarg_t, const sysarg_t, const sysarg_t, 52 55 const sysarg_t, const sysarg_t, const sysarg_t, const syscall_t); 53 54 extern sysarg_t55 __syscall_slow(const sysarg_t, const sysarg_t, const sysarg_t, const sysarg_t,56 const sysarg_t, const sysarg_t, const syscall_t);57 56 58 57 #endif -
uspace/lib/libc/arch/ia32/include/tls.h
r1ccafee r0b9ac3c 53 53 { 54 54 void *retval; 55 56 asm ("movl %%gs:0, %0" : "=r"(retval)); 55 56 asm ( 57 "movl %%gs:0, %0" 58 : "=r" (retval) 59 ); 60 57 61 return retval; 58 62 } -
uspace/lib/libc/arch/ia32/include/types.h
r1ccafee r0b9ac3c 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/Makefile.inc
r1ccafee r0b9ac3c 33 33 TOOLCHAIN_DIR = $(CROSS_PREFIX)/ia64/bin 34 34 35 ARCH_SOURCES += arch/$(UARCH)/src/syscall.S \ 35 ARCH_SOURCES = \ 36 arch/$(UARCH)/src/entry.s \ 37 arch/$(UARCH)/src/thread_entry.s \ 38 arch/$(UARCH)/src/syscall.S \ 36 39 arch/$(UARCH)/src/fibril.S \ 37 40 arch/$(UARCH)/src/tls.c \ -
uspace/lib/libc/arch/ia64/include/atomic.h
r1ccafee r0b9ac3c 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/ddi.h
r1ccafee r0b9ac3c 39 39 #include <libarch/types.h> 40 40 41 #define IO_SPACE_BOUNDARY ( 64 * 1024)41 #define IO_SPACE_BOUNDARY ((void *) (64 * 1024)) 42 42 43 43 uint64_t get_ia64_iospace_address(void); -
uspace/lib/libc/arch/ia64/include/faddr.h
r1ccafee r0b9ac3c 27 27 */ 28 28 29 /** @addtogroup libcia64 29 /** @addtogroup libcia64 30 30 * @{ 31 31 */ … … 38 38 #include <libarch/types.h> 39 39 40 /** 40 /** 41 41 * 42 42 * Calculate absolute address of function 43 43 * referenced by fptr pointer. 44 44 * 45 * @param f Function pointer.45 * @param fptr Function pointer. 46 46 * 47 47 */ 48 #define FADDR(f ) (*((uintptr_t *)(f)));48 #define FADDR(fptr) (((fncptr_t *) (fptr))->fnc) 49 49 50 50 #endif -
uspace/lib/libc/arch/ia64/include/fibril.h
r1ccafee r0b9ac3c 53 53 #define PSTHREAD_INITIAL_STACK_DIVISION 2 54 54 55 #ifdef context_set56 #undef context_set57 #endif58 59 55 #define context_set(c, _pc, stack, size, tls) \ 60 56 do { \ … … 110 106 uint64_t pr; 111 107 112 __r128f2 __attribute__ ((aligned(16)));113 __r128f3;114 __r128f4;115 __r128f5;108 uint128_t f2 __attribute__ ((aligned(16))); 109 uint128_t f3; 110 uint128_t f4; 111 uint128_t f5; 116 112 117 __r128f16;118 __r128f17;119 __r128f18;120 __r128f19;121 __r128f20;122 __r128f21;123 __r128f22;124 __r128f23;125 __r128f24;126 __r128f25;127 __r128f26;128 __r128f27;129 __r128f28;130 __r128f29;131 __r128f30;132 __r128f31;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; 133 129 134 130 } context_t; -
uspace/lib/libc/arch/ia64/include/limits.h
r1ccafee r0b9ac3c 27 27 */ 28 28 29 /** @addtogroup libcia64 29 /** @addtogroup libcia64 30 30 * @{ 31 31 */ … … 36 36 #define LIBC_ia64_LIMITS_H_ 37 37 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 42 47 43 48 #endif -
uspace/lib/libc/arch/ia64/include/types.h
r1ccafee r0b9ac3c 27 27 */ 28 28 29 /** @addtogroup libcia64 29 /** @addtogroup libcia64 30 30 * @{ 31 31 */ … … 50 50 typedef unsigned long int uint64_t; 51 51 52 typedef struct { 53 uint64_t lo; 54 uint64_t hi; 55 } uint128_t; 56 52 57 typedef int64_t ssize_t; 53 58 typedef uint64_t size_t; 54 59 55 60 typedef uint64_t uintptr_t; 61 typedef uint64_t atomic_count_t; 62 typedef int64_t atomic_signed_t; 56 63 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; 64 typedef struct { 65 uintptr_t fnc; 66 uintptr_t gp; 67 } __attribute__((may_alias)) fncptr_t; 66 68 67 69 #endif -
uspace/lib/libc/arch/mips32/Makefile.inc
r1ccafee r0b9ac3c 33 33 TOOLCHAIN_DIR = $(CROSS_PREFIX)/mips32/bin 34 34 35 ARCH_SOURCES += arch/$(UARCH)/src/syscall.c \ 35 ARCH_SOURCES = \ 36 arch/$(UARCH)/src/entry.s \ 37 arch/$(UARCH)/src/thread_entry.s \ 38 arch/$(UARCH)/src/syscall.c \ 36 39 arch/$(UARCH)/src/fibril.S \ 37 40 arch/$(UARCH)/src/tls.c \ -
uspace/lib/libc/arch/mips32/include/atomic.h
r1ccafee r0b9ac3c 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/limits.h
r1ccafee r0b9ac3c 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 … … 37 37 #define LIBC_mips32__LIMITS_H_ 38 38 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 43 48 44 49 #endif -
uspace/lib/libc/arch/mips32/include/types.h
r1ccafee r0b9ac3c 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/mips32eb/Makefile.inc
r1ccafee r0b9ac3c 33 33 TOOLCHAIN_DIR = $(CROSS_PREFIX)/mips32eb/bin 34 34 35 ARCH_SOURCES += arch/$(UARCH)/src/syscall.c \ 35 ARCH_SOURCES = \ 36 arch/$(UARCH)/src/entry.s \ 37 arch/$(UARCH)/src/thread_entry.s \ 38 arch/$(UARCH)/src/syscall.c \ 36 39 arch/$(UARCH)/src/fibril.S \ 37 40 arch/$(UARCH)/src/tls.c \ -
uspace/lib/libc/arch/ppc32/Makefile.inc
r1ccafee r0b9ac3c 33 33 TOOLCHAIN_DIR = $(CROSS_PREFIX)/ppc32/bin 34 34 35 ARCH_SOURCES += arch/$(UARCH)/src/syscall.c \ 35 ARCH_SOURCES = \ 36 arch/$(UARCH)/src/entry.s \ 37 arch/$(UARCH)/src/thread_entry.s \ 38 arch/$(UARCH)/src/syscall.c \ 36 39 arch/$(UARCH)/src/fibril.S \ 37 40 arch/$(UARCH)/src/tls.c \ -
uspace/lib/libc/arch/ppc32/include/atomic.h
r1ccafee r0b9ac3c 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/limits.h
r1ccafee r0b9ac3c 27 27 */ 28 28 29 /** @addtogroup libcppc32 29 /** @addtogroup libcppc32 30 30 * @{ 31 31 */ … … 41 41 #define ULONG_MAX MAX_UINT32 42 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 47 43 48 #endif 44 49 -
uspace/lib/libc/arch/ppc32/include/types.h
r1ccafee r0b9ac3c 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/Makefile.inc
r1ccafee r0b9ac3c 33 33 TOOLCHAIN_DIR = $(CROSS_PREFIX)/sparc64/bin 34 34 35 ARCH_SOURCES += arch/$(UARCH)/src/fibril.S \ 35 ARCH_SOURCES = \ 36 arch/$(UARCH)/src/entry.s \ 37 arch/$(UARCH)/src/thread_entry.s \ 38 arch/$(UARCH)/src/fibril.S \ 36 39 arch/$(UARCH)/src/tls.c \ 37 40 arch/$(UARCH)/src/stacktrace.c \ … … 45 48 BFD_NAME = elf64-sparc 46 49 BFD_ARCH = sparc 50 51 ifeq ($(PROCESSOR),us) 52 DEFS += -DSUN4U 53 endif 54 55 ifeq ($(PROCESSOR),us3) 56 DEFS += -DSUN4U 57 endif 58 59 ifeq ($(PROCESSOR),sun4v) 60 DEFS += -DSUN4V 61 endif -
uspace/lib/libc/arch/sparc64/include/atomic.h
r1ccafee r0b9ac3c 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/config.h
r1ccafee r0b9ac3c 36 36 #define LIBC_sparc64_CONFIG_H_ 37 37 38 #if defined (SUN4U) 38 39 #define PAGE_WIDTH 14 40 #elif defined(SUN4V) 41 #define PAGE_WIDTH 13 42 #endif 43 39 44 #define PAGE_SIZE (1 << PAGE_WIDTH) 40 45 -
uspace/lib/libc/arch/sparc64/include/ddi.h
r1ccafee r0b9ac3c 37 37 #include <libarch/types.h> 38 38 39 static inline memory_barrier(void)39 static inline void memory_barrier(void) 40 40 { 41 asm volatile ("membar #LoadLoad | #StoreStore\n" ::: "memory"); 41 asm volatile ( 42 "membar #LoadLoad | #StoreStore\n" 43 ::: "memory" 44 ); 42 45 } 43 46 -
uspace/lib/libc/arch/sparc64/include/fibril.h
r1ccafee r0b9ac3c 42 42 #define SP_DELTA (STACK_WINDOW_SAVE_AREA_SIZE + STACK_ARG_SAVE_AREA_SIZE) 43 43 44 #ifdef context_set45 #undef context_set46 #endif47 48 44 #define context_set(c, _pc, stack, size, ptls) \ 49 45 do { \ … … 52 48 STACK_ALIGNMENT) - (STACK_BIAS + SP_DELTA); \ 53 49 (c)->fp = -STACK_BIAS; \ 54 (c)->tp = ptls; \50 (c)->tp = (uint64_t) ptls; \ 55 51 } while (0) 56 52 -
uspace/lib/libc/arch/sparc64/include/limits.h
r1ccafee r0b9ac3c 27 27 */ 28 28 29 /** @addtogroup libcsparc64 29 /** @addtogroup libcsparc64 30 30 * @{ 31 31 */ … … 41 41 #define ULONG_MAX MAX_UINT64 42 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 47 43 48 #endif 44 49 -
uspace/lib/libc/arch/sparc64/include/types.h
r1ccafee r0b9ac3c 27 27 */ 28 28 29 /** @addtogroup libcsparc64 29 /** @addtogroup libcsparc64 30 30 * @{ 31 31 */ … … 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/sparc64/src/thread_entry.s
r1ccafee r0b9ac3c 38 38 # Create the first stack frame. 39 39 # 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 43 44 44 45 sethi %hi(_gp), %l7 -
uspace/lib/libc/generic/async.c
r1ccafee r0b9ac3c 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 * … … 1287 1341 } 1288 1342 1343 /** Wrapper for forwarding any read request 1344 * 1345 * 1346 */ 1347 int 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 1289 1377 /** Wrapper for making IPC_M_DATA_WRITE calls using the async framework. 1290 1378 * 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 * 1296 1385 */ 1297 1386 int async_data_write_start(int phoneid, const void *src, size_t size) … … 1308 1397 * So far, this wrapper is to be used from within a connection fibril. 1309 1398 * 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 * 1316 1406 */ 1317 1407 int async_data_write_receive(ipc_callid_t *callid, size_t *size) … … 1320 1410 1321 1411 assert(callid); 1322 1412 1323 1413 *callid = async_get_call(&data); 1324 1414 if (IPC_GET_METHOD(data) != IPC_M_DATA_WRITE) 1325 1415 return 0; 1416 1326 1417 if (size) 1327 1418 *size = (size_t) IPC_GET_ARG2(data); 1419 1328 1420 return 1; 1329 1421 } … … 1334 1426 * so that the user doesn't have to remember the meaning of each IPC argument. 1335 1427 * 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 * 1341 1434 */ 1342 1435 int async_data_write_finalize(ipc_callid_t callid, void *dst, size_t size) … … 1345 1438 } 1346 1439 1347 /** Wrapper for receiving b lobs via the async_data_write_*1440 /** Wrapper for receiving binary data or strings 1348 1441 * 1349 1442 * 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. 1358 1457 * 1359 1458 * @return Zero on success or a value from @ref errno.h on failure. 1360 1459 * 1361 1460 */ 1362 int async_data_blob_receive(char **blob, const size_t max_size, size_t *received) 1461 int 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) 1363 1464 { 1364 1465 ipc_callid_t callid; … … 1369 1470 } 1370 1471 1472 if (size < min_size) { 1473 ipc_answer_0(callid, EINVAL); 1474 return EINVAL; 1475 } 1476 1371 1477 if ((max_size > 0) && (size > max_size)) { 1372 1478 ipc_answer_0(callid, EINVAL); … … 1374 1480 } 1375 1481 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) { 1378 1495 ipc_answer_0(callid, ENOMEM); 1379 1496 return ENOMEM; 1380 1497 } 1381 1498 1382 int rc = async_data_write_finalize(callid, data, size);1499 int rc = async_data_write_finalize(callid, _data, size); 1383 1500 if (rc != EOK) { 1384 free( data);1501 free(_data); 1385 1502 return rc; 1386 1503 } 1387 1504 1388 *blob = data; 1505 if (nullterm) 1506 ((char *) _data)[size] = 0; 1507 1508 *data = _data; 1389 1509 if (received != NULL) 1390 1510 *received = size; … … 1393 1513 } 1394 1514 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 */ 1522 void async_data_write_void(const int retval) 1410 1523 { 1411 1524 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 */ 1533 int 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)) { 1414 1538 ipc_answer_0(callid, EINVAL); 1415 1539 return EINVAL; 1416 1540 } 1417 1541 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) { 1419 1545 ipc_answer_0(callid, EINVAL); 1420 1546 return EINVAL; 1421 1547 } 1422 1548 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; 1438 1561 } 1439 1562 -
uspace/lib/libc/generic/clipboard.c
r1ccafee r0b9ac3c 84 84 clip_connect(); 85 85 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); 87 87 ipcarg_t rc = async_data_write_start(clip_phone, (void *) str, size); 88 88 if (rc != EOK) { … … 139 139 *str = sbuf; 140 140 return EOK; 141 case CLIPBOARD_TAG_ BLOB:141 case CLIPBOARD_TAG_DATA: 142 142 sbuf = malloc(size + 1); 143 143 if (sbuf == NULL) … … 148 148 aid_t req = async_send_1(clip_phone, CLIPBOARD_GET_DATA, tag, NULL); 149 149 rc = async_data_read_start(clip_phone, (void *) sbuf, size); 150 if ( rc == EOVERFLOW) {150 if ((int) rc == EOVERFLOW) { 151 151 /* 152 152 * The data in the clipboard has changed since -
uspace/lib/libc/generic/fibril.c
r1ccafee r0b9ac3c 41 41 #include <unistd.h> 42 42 #include <stdio.h> 43 #include <arch/barrier.h> 43 44 #include <libarch/faddr.h> 44 45 #include <futex.h> … … 133 134 int fibril_switch(fibril_switch_type_t stype) 134 135 { 135 fibril_t *srcf, *dstf;136 136 int retval = 0; 137 137 138 138 futex_down(&fibril_futex); 139 139 140 140 if (stype == FIBRIL_PREEMPT && list_empty(&ready_list)) 141 141 goto ret_0; 142 142 143 143 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))) 145 145 goto ret_0; 146 146 147 /* 147 148 * Do not preempt if there is not enough threads to run the 148 149 * ready fibrils which are not serialized. 149 150 */ 150 if ( list_empty(&serialized_list) &&151 threads_in_manager <= serialized_threads) {151 if ((list_empty(&serialized_list)) && 152 (threads_in_manager <= serialized_threads)) { 152 153 goto ret_0; 153 154 } 154 155 } 156 155 157 /* 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)) { 157 159 while (list_empty(&manager_list)) { 158 160 futex_up(&fibril_futex); … … 162 164 } 163 165 164 srcf = __tcb_get()->fibril_data;166 fibril_t *srcf = __tcb_get()->fibril_data; 165 167 if (stype != FIBRIL_FROM_DEAD) { 168 166 169 /* Save current state */ 167 170 if (!context_save(&srcf->ctx)) { 168 171 if (serialization_count) 169 172 srcf->flags &= ~FIBRIL_SERIALIZED; 173 170 174 if (srcf->clean_after_me) { 171 175 /* … … 173 177 * restored context here. 174 178 */ 175 void *stack = srcf->clean_after_me->stack; 179 void *stack = srcf->clean_after_me->stack; 176 180 if (stack) { 177 181 /* … … 188 192 srcf->clean_after_me = NULL; 189 193 } 194 190 195 return 1; /* futex_up already done here */ 191 196 } 192 197 193 198 /* Save myself to the correct run list */ 194 199 if (stype == FIBRIL_PREEMPT) … … 197 202 list_append(&srcf->link, &manager_list); 198 203 threads_in_manager--; 199 } else { 204 } else { 200 205 /* 201 206 * If stype == FIBRIL_TO_MANAGER, don't put ourselves to … … 207 212 208 213 /* 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)) { 210 216 dstf = list_get_instance(manager_list.next, fibril_t, link); 211 217 if (serialization_count && stype == FIBRIL_TO_MANAGER) { … … 214 220 } 215 221 threads_in_manager++; 216 222 217 223 if (stype == FIBRIL_FROM_DEAD) 218 224 dstf->clean_after_me = srcf; … … 228 234 } 229 235 list_remove(&dstf->link); 230 236 231 237 futex_up(&fibril_futex); 232 238 context_restore(&dstf->ctx); 233 239 /* not reached */ 234 240 235 241 ret_0: 236 242 futex_up(&fibril_futex); -
uspace/lib/libc/generic/futex.c
r1ccafee r0b9ac3c 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
r1ccafee r0b9ac3c 541 541 } 542 542 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 . */543 int 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. */ 548 548 return -1; 549 549 } … … 554 554 } 555 555 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; 556 off64_t ftell(FILE *stream) 557 { 558 return lseek(stream->fd, 0, SEEK_CUR); 565 559 } 566 560 -
uspace/lib/libc/generic/ipc.c
r1ccafee r0b9ac3c 728 728 int *flags) 729 729 { 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, 733 732 (ipcarg_t) size, arg, NULL, &tmp_flags); 733 734 734 if (flags) 735 735 *flags = tmp_flags; 736 736 737 return res; 737 738 } -
uspace/lib/libc/generic/malloc.c
r1ccafee r0b9ac3c 164 164 { 165 165 if (size == 0) 166 return false; 167 168 if ((heap_start + size < heap_start) || (heap_end + size < heap_end)) 166 169 return false; 167 170 -
uspace/lib/libc/generic/mman.c
r1ccafee r0b9ac3c 39 39 40 40 void *mmap(void *start, size_t length, int prot, int flags, int fd, 41 off_t offset)41 aoff64_t offset) 42 42 { 43 43 if (!start) -
uspace/lib/libc/generic/vfs/vfs.c
r1ccafee r0b9ac3c 35 35 #include <vfs/vfs.h> 36 36 #include <vfs/canonify.h> 37 #include <macros.h> 37 38 #include <stdlib.h> 38 39 #include <unistd.h> … … 120 121 const char *opts, unsigned int flags) 121 122 { 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 126 138 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 130 144 return res; 145 } 131 146 132 147 size_t mpa_size; 133 148 char *mpa = absolutize(mp, &mpa_size); 134 if (!mpa) 149 if (!mpa) { 150 if (null_id != -1) 151 devmap_null_destroy(null_id); 152 135 153 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); 143 163 if (rc != EOK) { 144 164 async_wait_for(req, &rc_orig); … … 146 166 futex_up(&vfs_phone_futex); 147 167 free(mpa); 168 169 if (null_id != -1) 170 devmap_null_destroy(null_id); 171 148 172 if (rc_orig == EOK) 149 173 return (int) rc; … … 158 182 futex_up(&vfs_phone_futex); 159 183 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 166 194 rc = async_data_write_start(vfs_phone, (void *) fs_name, str_size(fs_name)); 167 195 if (rc != EOK) { … … 170 198 futex_up(&vfs_phone_futex); 171 199 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 178 210 /* Ask VFS whether it likes fs_name. */ 179 211 rc = async_req_0_0(vfs_phone, IPC_M_PING); … … 183 215 futex_up(&vfs_phone_futex); 184 216 free(mpa); 217 218 if (null_id != -1) 219 devmap_null_destroy(null_id); 220 185 221 if (rc_orig == EOK) 186 222 return (int) rc; … … 193 229 futex_up(&vfs_phone_futex); 194 230 free(mpa); 231 232 if ((rc != EOK) && (null_id != -1)) 233 devmap_null_destroy(null_id); 195 234 196 235 return (int) rc; … … 396 435 } 397 436 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 &newoff s);409 410 async_serialize_end(); 411 futex_up(&vfs_phone_futex); 412 437 off64_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 413 452 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 458 int 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 430 471 return (int) rc; 431 472 } … … 441 482 442 483 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)); 444 485 if (rc != EOK) { 445 486 ipcarg_t rc_orig; … … 515 556 if (!abs) { 516 557 free(dirp); 517 return ENOMEM;558 return NULL; 518 559 } 519 560 -
uspace/lib/libc/include/async.h
r1ccafee r0b9ac3c 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(). … … 277 280 extern int async_share_out_receive(ipc_callid_t *, size_t *, int *); 278 281 extern 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 279 312 extern int async_data_read_start(int, void *, size_t); 280 313 extern int async_data_read_receive(ipc_callid_t *, size_t *); 281 314 extern int async_data_read_finalize(ipc_callid_t, const void *, size_t); 315 316 extern 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 282 350 extern int async_data_write_start(int, const void *, size_t); 283 351 extern int async_data_write_receive(ipc_callid_t *, size_t *); 284 352 extern int async_data_write_finalize(ipc_callid_t, void *, size_t); 285 353 286 extern int async_data_blob_receive(char **, const size_t, size_t *); 287 extern int async_data_string_receive(char **, const size_t); 354 extern int async_data_write_accept(void **, const bool, const size_t, 355 const size_t, const size_t, size_t *); 356 extern void async_data_write_void(const int); 357 358 extern int async_data_write_forward_fast(int, ipcarg_t, ipcarg_t, ipcarg_t, 359 ipcarg_t, ipcarg_t, ipc_call_t *); 288 360 289 361 #endif -
uspace/lib/libc/include/atomicdflt.h
r1ccafee r0b9ac3c 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 #ifndef CAS 59 static inline bool cas(atomic_t *val, long ov, longnv)59 #ifndef CAS 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/fibril.h
r1ccafee r0b9ac3c 40 40 #include <libarch/tls.h> 41 41 42 #ifndef context_set 43 #define context_set(c, _pc, stack, size, ptls) \ 42 #define context_set_generic(c, _pc, stack, size, ptls) \ 44 43 (c)->pc = (sysarg_t) (_pc); \ 45 44 (c)->sp = ((sysarg_t) (stack)) + (size) - SP_DELTA; \ 46 45 (c)->tls = (sysarg_t) (ptls); 47 #endif /* context_set */48 46 49 #define FIBRIL_SERIALIZED 150 #define FIBRIL_WRITER 247 #define FIBRIL_SERIALIZED 1 48 #define FIBRIL_WRITER 2 51 49 52 50 typedef enum { … … 59 57 typedef sysarg_t fid_t; 60 58 61 struct fibril {59 typedef struct fibril { 62 60 link_t link; 63 61 context_t ctx; … … 70 68 int retval; 71 69 int flags; 72 }; 73 typedef struct fibril fibril_t; 70 } fibril_t; 74 71 75 72 /** Fibril-local variable specifier */ 76 73 #define fibril_local __thread 77 74 78 extern int context_save(context_t *c ) __attribute__((returns_twice));79 extern void context_restore(context_t *c ) __attribute__((noreturn));75 extern int context_save(context_t *ctx) __attribute__((returns_twice)); 76 extern void context_restore(context_t *ctx) __attribute__((noreturn)); 80 77 81 78 extern fid_t fibril_create(int (*func)(void *), void *arg); … … 90 87 extern void fibril_dec_sercount(void); 91 88 92 static inline int fibril_yield(void) { 89 static inline int fibril_yield(void) 90 { 93 91 return fibril_switch(FIBRIL_PREEMPT); 94 92 } -
uspace/lib/libc/include/ipc/clipboard.h
r1ccafee r0b9ac3c 46 46 typedef enum { 47 47 CLIPBOARD_TAG_NONE, 48 CLIPBOARD_TAG_ BLOB48 CLIPBOARD_TAG_DATA 49 49 } clipboard_tag_t; 50 50 -
uspace/lib/libc/include/ipc/services.h
r1ccafee r0b9ac3c 47 47 SERVICE_FHC, 48 48 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 50 62 } services_t; 51 63 -
uspace/lib/libc/include/limits.h
r1ccafee r0b9ac3c 46 46 47 47 #ifdef __CHAR_UNSIGNED__ 48 #define CHAR_MIN UCHAR_MIN49 #define CHAR_MAX UCHAR_MAX48 #define CHAR_MIN UCHAR_MIN 49 #define CHAR_MAX UCHAR_MAX 50 50 #else 51 #define CHAR_MIN SCHAR_MIN52 #define CHAR_MAX SCHAR_MAX51 #define CHAR_MIN SCHAR_MIN 52 #define CHAR_MAX SCHAR_MAX 53 53 #endif 54 54 … … 59 59 #define USHRT_MAX MAX_UINT16 60 60 61 /* int */ 61 62 #define INT_MIN MIN_INT32 62 63 #define INT_MAX MAX_INT32 … … 64 65 #define UINT_MAX MAX_UINT32 65 66 67 /* long long int */ 66 68 #define LLONG_MIN MIN_INT64 67 69 #define LLONG_MAX MAX_INT64 … … 69 71 #define ULLONG_MAX MAX_UINT64 70 72 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 71 81 #endif 72 82 -
uspace/lib/libc/include/macros.h
r1ccafee r0b9ac3c 48 48 #define STRING_ARG(arg) #arg 49 49 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) 52 52 53 53 #define MERGE_LOUP32(lo, up) \ -
uspace/lib/libc/include/stacktrace.h
r1ccafee r0b9ac3c 57 57 extern void stacktrace_prepare(void); 58 58 extern uintptr_t stacktrace_fp_get(void); 59 extern uintptr_t stacktrace_pc_get( );59 extern uintptr_t stacktrace_pc_get(void); 60 60 61 61 #endif -
uspace/lib/libc/include/stdio.h
r1ccafee r0b9ac3c 46 46 #define BUFSIZ 4096 47 47 48 #define DEBUG(fmt, ...) \48 #define DEBUG(fmt, ...)se\ 49 49 { \ 50 50 char _buf[256]; \ … … 56 56 #ifndef SEEK_SET 57 57 #define SEEK_SET 0 58 #endif 59 60 #ifndef SEEK_CUR 58 61 #define SEEK_CUR 1 62 #endif 63 64 #ifndef SEEK_END 59 65 #define SEEK_END 2 60 66 #endif … … 135 141 extern size_t fwrite(const void *, size_t, size_t, FILE *); 136 142 137 extern int fseek(FILE *, long, int);143 extern int fseek(FILE *, off64_t, int); 138 144 extern void rewind(FILE *); 139 extern int ftell(FILE *);145 extern off64_t ftell(FILE *); 140 146 extern int feof(FILE *); 141 147 -
uspace/lib/libc/include/sys/mman.h
r1ccafee r0b9ac3c 41 41 #define MAP_FAILED ((void *) -1) 42 42 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) 47 47 48 48 #define PROTO_READ AS_AREA_READ … … 50 50 #define PROTO_EXEC AS_AREA_EXEC 51 51 52 extern void *mmap(void *start, size_t length, int prot, int flags, int fd,53 off_t offset);52 extern void *mmap(void *start, size_t length, int prot, int flags, int fd, 53 aoff64_t offset); 54 54 extern int munmap(void *start, size_t length); 55 55 -
uspace/lib/libc/include/sys/stat.h
r1ccafee r0b9ac3c 31 31 */ 32 32 /** @file 33 */ 33 */ 34 34 35 35 #ifndef LIBC_SYS_STAT_H_ … … 48 48 bool is_file; 49 49 bool is_directory; 50 off_t size;50 aoff64_t size; 51 51 dev_handle_t device; 52 52 }; -
uspace/lib/libc/include/sys/time.h
r1ccafee r0b9ac3c 31 31 */ 32 32 /** @file 33 */ 33 */ 34 34 35 35 #ifndef LIBC_SYS_TIME_H_ … … 44 44 45 45 struct 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 */ 48 48 }; 49 49 50 50 struct 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 */ 53 53 }; 54 54 -
uspace/lib/libc/include/sys/typefmt.h
r1ccafee r0b9ac3c 39 39 #include <inttypes.h> 40 40 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 52 46 53 47 /* (s)size_t */ -
uspace/lib/libc/include/sys/types.h
r1ccafee r0b9ac3c 38 38 #include <libarch/types.h> 39 39 40 typedef long off_t; 41 typedef int mode_t; 42 typedef uint64_t bn_t; /**< Block number type. */ 40 typedef unsigned int mode_t; 43 41 42 /** Relative offset */ 43 typedef int64_t off64_t; 44 45 /** Absolute offset */ 46 typedef uint64_t aoff64_t; 47 48 /** Unicode code point */ 44 49 typedef int32_t wchar_t; 45 50 -
uspace/lib/libc/include/unistd.h
r1ccafee r0b9ac3c 47 47 #ifndef SEEK_SET 48 48 #define SEEK_SET 0 49 #endif 50 51 #ifndef SEEK_CUR 49 52 #define SEEK_CUR 1 53 #endif 54 55 #ifndef SEEK_END 50 56 #define SEEK_END 2 51 57 #endif … … 58 64 extern ssize_t read(int, void *, size_t); 59 65 60 extern off _t lseek(int, off_t, int);61 extern int ftruncate(int, off_t);66 extern off64_t lseek(int, off64_t, int); 67 extern int ftruncate(int, aoff64_t); 62 68 63 69 extern int close(int); … … 69 75 extern int chdir(const char *); 70 76 71 extern void _exit(int status) __attribute__((noreturn));72 extern int usleep(useconds_t uses);73 extern unsigned int sleep(unsigned int se);77 extern void _exit(int) __attribute__((noreturn)); 78 extern int usleep(useconds_t); 79 extern unsigned int sleep(unsigned int); 74 80 75 81 #endif -
uspace/lib/libfs/libfs.c
r1ccafee r0b9ac3c 37 37 #include "libfs.h" 38 38 #include "../../srv/vfs/vfs.h" 39 #include <macros.h> 39 40 #include <errno.h> 40 41 #include <async.h> … … 161 162 /* Accept the phone */ 162 163 callid = async_get_call(&call); 163 int mountee_phone = (int) IPC_GET_ARG1(call);164 int mountee_phone = (int) IPC_GET_ARG1(call); 164 165 if ((IPC_GET_METHOD(call) != IPC_M_CONNECTION_CLONE) || 165 166 (mountee_phone < 0)) { … … 172 173 ipc_answer_0(callid, EOK); 173 174 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 182 175 fs_node_t *fn; 183 176 res = ops->node_get(&fn, mp_dev_handle, mp_fs_index); 184 177 if ((res != EOK) || (!fn)) { 185 178 ipc_hangup(mountee_phone); 186 ipc_answer_0(callid,combine_rc(res, ENOENT));179 async_data_write_void(combine_rc(res, ENOENT)); 187 180 ipc_answer_0(rid, combine_rc(res, ENOENT)); 188 181 return; … … 192 185 ipc_hangup(mountee_phone); 193 186 (void) ops->node_put(fn); 194 ipc_answer_0(callid,EBUSY);187 async_data_write_void(EBUSY); 195 188 ipc_answer_0(rid, EBUSY); 196 189 return; … … 201 194 ipc_hangup(mountee_phone); 202 195 (void) ops->node_put(fn); 203 ipc_answer_0(callid,rc);196 async_data_write_void(rc); 204 197 ipc_answer_0(rid, rc); 205 198 return; … … 207 200 208 201 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); 213 204 214 205 if (rc == EOK) { … … 408 399 ipc_answer_0(rid, rc); 409 400 } 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, 412 404 ops->index_get(fn), 413 ops->size_get(fn), 405 LOWER32(size), 406 UPPER32(size), 414 407 ops->lnkcnt_get(fn)); 415 408 (void) ops->node_put(fn); … … 488 481 ipc_answer_0(rid, rc); 489 482 } 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, 492 486 ops->index_get(fn), 493 ops->size_get(fn), 487 LOWER32(size), 488 UPPER32(size), 494 489 ops->lnkcnt_get(fn)); 495 490 (void) ops->node_put(fn); … … 511 506 unsigned int old_lnkcnt = ops->lnkcnt_get(cur); 512 507 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 515 517 goto out; 516 518 } … … 543 545 rc = ops->node_open(cur); 544 546 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 548 555 } else 549 556 ipc_answer_0(rid, rc); … … 612 619 dev_handle_t dev_handle = IPC_GET_ARG1(*request); 613 620 fs_index_t index = IPC_GET_ARG2(*request); 621 614 622 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); 618 624 on_error(rc, answer_and_return(rid, rc)); 619 625 … … 624 630 625 631 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), 627 634 (ops->is_file(fn) ? L_FILE : 0) | (ops->is_directory(fn) ? L_DIRECTORY : 0)); 628 635 -
uspace/lib/libfs/libfs.h
r1ccafee r0b9ac3c 76 76 */ 77 77 fs_index_t (* index_get)(fs_node_t *); 78 size_t (* size_get)(fs_node_t *);78 aoff64_t (* size_get)(fs_node_t *); 79 79 unsigned int (* lnkcnt_get)(fs_node_t *); 80 80 char (* plb_get_char)(unsigned pos);
Note:
See TracChangeset
for help on using the changeset viewer.
