Changeset 8fb1bf82 in mainline for uspace/lib/c
- Timestamp:
- 2010-11-25T13:42:50Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 8df8415
- Parents:
- a93d79a (diff), eb667613 (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/c
- Files:
-
- 8 added
- 68 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/Makefile
ra93d79a r8fb1bf82 57 57 generic/clipboard.c \ 58 58 generic/devmap.c \ 59 generic/devman.c \ 60 generic/device/hw_res.c \ 61 generic/device/char.c \ 59 62 generic/event.c \ 60 63 generic/errno.c \ -
uspace/lib/c/arch/abs32le/include/fibril.h
ra93d79a r8fb1bf82 44 44 (ctx)->pc = (uintptr_t) (_pc); \ 45 45 (ctx)->sp = ((uintptr_t) (stack)) + (size) - SP_DELTA; \ 46 (ctx)->fp = 0; \ 46 47 (ctx)->tls = ((uintptr_t) (ptls)) + sizeof(tcb_t); \ 47 48 } while (0) … … 53 54 typedef struct { 54 55 uintptr_t sp; 56 uintptr_t fp; 55 57 uintptr_t pc; 56 58 uintptr_t tls; 57 59 } context_t; 60 61 static inline uintptr_t context_get_fp(context_t *ctx) 62 { 63 /* On real hardware, this function returns the frame pointer. */ 64 return ctx->fp; 65 } 58 66 59 67 #endif -
uspace/lib/c/arch/abs32le/include/inttypes.h
ra93d79a r8fb1bf82 34 34 #define LIBC_abs32le_INTTYPES_H_ 35 35 36 #define PRId8 "d" 37 #define PRId16 "d" 38 #define PRId32 "d" 39 #define PRId64 "lld" 40 #define PRIdPTR "d" 41 42 #define PRIo8 "o" 43 #define PRIo16 "o" 44 #define PRIo32 "o" 45 #define PRIo64 "llo" 46 #define PRIoPTR "o" 47 48 #define PRIu8 "u" 49 #define PRIu16 "u" 50 #define PRIu32 "u" 51 #define PRIu64 "llu" 52 #define PRIuPTR "u" 53 54 #define PRIx8 "x" 55 #define PRIx16 "x" 56 #define PRIx32 "x" 57 #define PRIx64 "llx" 58 #define PRIxPTR "x" 59 60 #define PRIX8 "X" 61 #define PRIX16 "X" 62 #define PRIX32 "X" 63 #define PRIX64 "llX" 64 #define PRIXPTR "X" 36 #define PRIdPTR PRId32 37 #define PRIoPTR PRIo32 38 #define PRIuPTR PRIu32 39 #define PRIxPTR PRIx32 40 #define PRIXPTR PRIX32 65 41 66 42 #endif -
uspace/lib/c/arch/abs32le/include/istate.h
ra93d79a r8fb1bf82 36 36 #define LIBC_abs32le__ISTATE_H_ 37 37 38 #include <sys/types.h> 39 40 /** Interrupt context. 41 * 42 * On real hardware this stores the registers which 43 * need to be preserved during interupts. 44 */ 45 typedef struct istate { 46 uintptr_t ip; 47 uintptr_t fp; 48 uint32_t stack[]; 49 } istate_t; 50 51 static inline uintptr_t istate_get_pc(istate_t *istate) 52 { 53 return istate->ip; 54 } 55 56 static inline uintptr_t istate_get_fp(istate_t *istate) 57 { 58 return istate->fp; 59 } 38 #include <arch/istate.h> 60 39 61 40 #endif -
uspace/lib/c/arch/abs32le/src/stacktrace.c
ra93d79a r8fb1bf82 56 56 uintptr_t stacktrace_fp_get(void) 57 57 { 58 return NULL;58 return (uintptr_t) NULL; 59 59 } 60 60 61 61 uintptr_t stacktrace_pc_get(void) 62 62 { 63 return NULL;63 return (uintptr_t) NULL; 64 64 } 65 65 -
uspace/lib/c/arch/abs32le/src/tls.c
ra93d79a r8fb1bf82 46 46 uintptr_t __aeabi_read_tp(void) 47 47 { 48 return NULL;48 return (uintptr_t) NULL; 49 49 } 50 50 -
uspace/lib/c/arch/amd64/include/fibril.h
ra93d79a r8fb1bf82 56 56 */ 57 57 typedef struct { 58 uint64_t sp; 59 uint64_t pc; 60 61 uint64_t rbx; 62 uint64_t rbp; 58 uint64_t sp; 59 uint64_t pc; 63 60 64 uint64_t r12; 65 uint64_t r13; 66 uint64_t r14; 67 uint64_t r15; 61 uint64_t rbx; 62 uint64_t rbp; 68 63 69 uint64_t tls; 64 uint64_t r12; 65 uint64_t r13; 66 uint64_t r14; 67 uint64_t r15; 68 69 uint64_t tls; 70 70 } context_t; 71 72 static inline uintptr_t context_get_fp(context_t *ctx) 73 { 74 return ctx->rbp; 75 } 71 76 72 77 #endif -
uspace/lib/c/arch/amd64/include/inttypes.h
ra93d79a r8fb1bf82 41 41 #define LIBC_amd64_INTTYPES_H_ 42 42 43 #define PRId8 "d" 44 #define PRId16 "d" 45 #define PRId32 "d" 46 #define PRId64 "lld" 47 #define PRIdPTR "lld" 48 49 #define PRIo8 "o" 50 #define PRIo16 "o" 51 #define PRIo32 "o" 52 #define PRIo64 "llo" 53 #define PRIoPTR "llo" 54 55 #define PRIu8 "u" 56 #define PRIu16 "u" 57 #define PRIu32 "u" 58 #define PRIu64 "llu" 59 #define PRIuPTR "llu" 60 61 #define PRIx8 "x" 62 #define PRIx16 "x" 63 #define PRIx32 "x" 64 #define PRIx64 "llx" 65 #define PRIxPTR "llx" 66 67 #define PRIX8 "X" 68 #define PRIX16 "X" 69 #define PRIX32 "X" 70 #define PRIX64 "llX" 71 #define PRIXPTR "llX" 43 #define PRIdPTR PRId64 44 #define PRIoPTR PRIo64 45 #define PRIuPTR PRIu64 46 #define PRIxPTR PRIx64 47 #define PRIXPTR PRIX64 72 48 73 49 #endif -
uspace/lib/c/arch/amd64/include/istate.h
ra93d79a r8fb1bf82 36 36 #define LIBC_amd64_ISTATE_H_ 37 37 38 #include <sys/types.h> 39 40 /** Interrupt context. 41 * 42 * This is a copy of the kernel definition with which it must be kept in sync. 43 */ 44 typedef struct istate { 45 uint64_t rax; 46 uint64_t rcx; 47 uint64_t rdx; 48 uint64_t rsi; 49 uint64_t rdi; 50 uint64_t r8; 51 uint64_t r9; 52 uint64_t r10; 53 uint64_t r11; 54 uint64_t rbp; 55 uint64_t error_word; 56 uint64_t rip; 57 uint64_t cs; 58 uint64_t rflags; 59 uint64_t stack[]; /* Additional data on stack */ 60 } istate_t; 61 62 static inline uintptr_t istate_get_pc(istate_t *istate) 63 { 64 return istate->rip; 65 } 66 67 static inline uintptr_t istate_get_fp(istate_t *istate) 68 { 69 return istate->rbp; 70 } 38 #include <arch/istate.h> 71 39 72 40 #endif -
uspace/lib/c/arch/amd64/src/entry.s
ra93d79a r8fb1bf82 42 42 # 43 43 pushq $0 44 mov %rsp, %rbp44 movq %rsp, %rbp 45 45 46 46 # %rdi was deliberately chosen as the first argument is also in %rdi -
uspace/lib/c/arch/amd64/src/fibril.S
ra93d79a r8fb1bf82 49 49 movq %rax, OFFSET_TLS(%rdi) 50 50 51 xor q %rax,%rax # context_save returns 152 inc q %rax51 xorl %eax, %eax # context_save returns 1 52 incl %eax 53 53 ret 54 54 … … 67 67 # Set thread local storage 68 68 movq OFFSET_TLS(%rdi), %rdi # Set arg1 to TLS addr 69 mov q $1, %rax # SYS_TLS_SET69 movl $1, %eax # SYS_TLS_SET 70 70 syscall 71 71 72 xor q %rax,%rax # context_restore returns 072 xorl %eax, %eax # context_restore returns 0 73 73 ret -
uspace/lib/c/arch/arm32/include/fibril.h
ra93d79a r8fb1bf82 86 86 } context_t; 87 87 88 static inline uintptr_t context_get_fp(context_t *ctx) 89 { 90 return ctx->fp; 91 } 92 88 93 89 94 #endif -
uspace/lib/c/arch/arm32/include/inttypes.h
ra93d79a r8fb1bf82 41 41 #define LIBC_arm32_INTTYPES_H_ 42 42 43 #define PRId8 "d" 44 #define PRId16 "d" 45 #define PRId32 "d" 46 #define PRId64 "lld" 47 #define PRIdPTR "d" 48 49 #define PRIo8 "o" 50 #define PRIo16 "o" 51 #define PRIo32 "o" 52 #define PRIo64 "llo" 53 #define PRIoPTR "o" 54 55 #define PRIu8 "u" 56 #define PRIu16 "u" 57 #define PRIu32 "u" 58 #define PRIu64 "llu" 59 #define PRIuPTR "u" 60 61 #define PRIx8 "x" 62 #define PRIx16 "x" 63 #define PRIx32 "x" 64 #define PRIx64 "llx" 65 #define PRIxPTR "x" 66 67 #define PRIX8 "X" 68 #define PRIX16 "X" 69 #define PRIX32 "X" 70 #define PRIX64 "llX" 71 #define PRIXPTR "X" 43 #define PRIdPTR PRId32 44 #define PRIoPTR PRIo32 45 #define PRIuPTR PRIu32 46 #define PRIxPTR PRIx32 47 #define PRIXPTR PRIX32 72 48 73 49 #endif -
uspace/lib/c/arch/arm32/include/istate.h
ra93d79a r8fb1bf82 36 36 #define LIBC_arm32__ISTATE_H_ 37 37 38 #include <sys/types.h> 39 40 /** Interrupt context. 41 * 42 * This is a copy of the kernel definition with which it must be kept in sync. 43 */ 44 typedef struct istate { 45 uint32_t spsr; 46 uint32_t sp; 47 uint32_t lr; 48 49 uint32_t r0; 50 uint32_t r1; 51 uint32_t r2; 52 uint32_t r3; 53 uint32_t r4; 54 uint32_t r5; 55 uint32_t r6; 56 uint32_t r7; 57 uint32_t r8; 58 uint32_t r9; 59 uint32_t r10; 60 uint32_t fp; 61 uint32_t r12; 62 63 uint32_t pc; 64 } istate_t; 65 66 static inline uintptr_t istate_get_pc(istate_t *istate) 67 { 68 return istate->pc; 69 } 70 71 static inline uintptr_t istate_get_fp(istate_t *istate) 72 { 73 return istate->fp; 74 } 38 #include <arch/istate.h> 75 39 76 40 #endif -
uspace/lib/c/arch/ia32/include/fibril.h
ra93d79a r8fb1bf82 67 67 } context_t; 68 68 69 static inline uintptr_t context_get_fp(context_t *ctx) 70 { 71 return ctx->ebp; 72 } 73 69 74 #endif 70 75 -
uspace/lib/c/arch/ia32/include/inttypes.h
ra93d79a r8fb1bf82 41 41 #define LIBC_ia32_INTTYPES_H_ 42 42 43 #define PRId8 "d" 44 #define PRId16 "d" 45 #define PRId32 "d" 46 #define PRId64 "lld" 47 #define PRIdPTR "d" 48 49 #define PRIo8 "o" 50 #define PRIo16 "o" 51 #define PRIo32 "o" 52 #define PRIo64 "llo" 53 #define PRIoPTR "o" 54 55 #define PRIu8 "u" 56 #define PRIu16 "u" 57 #define PRIu32 "u" 58 #define PRIu64 "llu" 59 #define PRIuPTR "u" 60 61 #define PRIx8 "x" 62 #define PRIx16 "x" 63 #define PRIx32 "x" 64 #define PRIx64 "llx" 65 #define PRIxPTR "x" 66 67 #define PRIX8 "X" 68 #define PRIX16 "X" 69 #define PRIX32 "X" 70 #define PRIX64 "llX" 71 #define PRIXPTR "X" 43 #define PRIdPTR PRId32 44 #define PRIoPTR PRIo32 45 #define PRIuPTR PRIu32 46 #define PRIxPTR PRIx32 47 #define PRIXPTR PRIX32 72 48 73 49 #endif -
uspace/lib/c/arch/ia32/include/istate.h
ra93d79a r8fb1bf82 36 36 #define LIBC_ia32__ISTATE_H_ 37 37 38 #include <sys/types.h> 39 40 /** Interrupt context. 41 * 42 * This is a copy of the kernel definition with which it must be kept in sync. 43 */ 44 typedef struct istate { 45 uint32_t eax; 46 uint32_t ecx; 47 uint32_t edx; 48 uint32_t ebp; 49 50 uint32_t gs; 51 uint32_t fs; 52 uint32_t es; 53 uint32_t ds; 54 55 uint32_t error_word; 56 uint32_t eip; 57 uint32_t cs; 58 uint32_t eflags; 59 uint32_t stack[]; 60 } istate_t; 61 62 static inline uintptr_t istate_get_pc(istate_t *istate) 63 { 64 return istate->eip; 65 } 66 67 static inline uintptr_t istate_get_fp(istate_t *istate) 68 { 69 return istate->ebp; 70 } 38 #include <arch/istate.h> 71 39 72 40 #endif -
uspace/lib/c/arch/ia64/include/fibril.h
ra93d79a r8fb1bf82 130 130 } context_t; 131 131 132 static inline uintptr_t context_get_fp(context_t *ctx) 133 { 134 return 0; /* FIXME */ 135 } 136 132 137 #endif 133 138 -
uspace/lib/c/arch/ia64/include/inttypes.h
ra93d79a r8fb1bf82 41 41 #define LIBC_ia64_INTTYPES_H_ 42 42 43 #define PRId8 "d" 44 #define PRId16 "d" 45 #define PRId32 "d" 46 #define PRId64 "ld" 47 #define PRIdPTR "ld" 48 49 #define PRIo8 "o" 50 #define PRIo16 "o" 51 #define PRIo32 "o" 52 #define PRIo64 "lo" 53 #define PRIoPTR "lo" 54 55 #define PRIu8 "u" 56 #define PRIu16 "u" 57 #define PRIu32 "u" 58 #define PRIu64 "lu" 59 #define PRIuPTR "lu" 60 61 #define PRIx8 "x" 62 #define PRIx16 "x" 63 #define PRIx32 "x" 64 #define PRIx64 "lx" 65 #define PRIxPTR "lx" 66 67 #define PRIX8 "X" 68 #define PRIX16 "X" 69 #define PRIX32 "X" 70 #define PRIX64 "lX" 71 #define PRIXPTR "lX" 43 #define PRIdPTR PRId64 44 #define PRIoPTR PRIo64 45 #define PRIuPTR PRIu64 46 #define PRIxPTR PRIx64 47 #define PRIXPTR PRIX64 72 48 73 49 #endif -
uspace/lib/c/arch/ia64/include/istate.h
ra93d79a r8fb1bf82 36 36 #define LIBC_ia64_ISTATE_H_ 37 37 38 #include <sys/types.h> 39 40 /** Interrupt context. 41 * 42 * This is a copy of the kernel definition with which it must be kept in sync. 43 */ 44 typedef struct istate { 45 /* TODO */ 46 } istate_t; 47 48 static inline uintptr_t istate_get_pc(istate_t *istate) 49 { 50 /* TODO */ 51 return 0; 52 } 53 54 static inline uintptr_t istate_get_fp(istate_t *istate) 55 { 56 /* TODO */ 57 return 0; 58 } 38 #include <arch/istate.h> 59 39 60 40 #endif -
uspace/lib/c/arch/mips32/include/fibril.h
ra93d79a r8fb1bf82 85 85 } context_t; 86 86 87 static inline uintptr_t context_get_fp(context_t *ctx) 88 { 89 return ctx->sp; 90 } 91 87 92 #endif 88 93 -
uspace/lib/c/arch/mips32/include/inttypes.h
ra93d79a r8fb1bf82 41 41 #define LIBC_mips32_INTTYPES_H_ 42 42 43 #define PRId8 "d" 44 #define PRId16 "d" 45 #define PRId32 "d" 46 #define PRId64 "lld" 47 #define PRIdPTR "d" 48 49 #define PRIo8 "o" 50 #define PRIo16 "o" 51 #define PRIo32 "o" 52 #define PRIo64 "llo" 53 #define PRIoPTR "o" 54 55 #define PRIu8 "u" 56 #define PRIu16 "u" 57 #define PRIu32 "u" 58 #define PRIu64 "llu" 59 #define PRIuPTR "u" 60 61 #define PRIx8 "x" 62 #define PRIx16 "x" 63 #define PRIx32 "x" 64 #define PRIx64 "llx" 65 #define PRIxPTR "x" 66 67 #define PRIX8 "X" 68 #define PRIX16 "X" 69 #define PRIX32 "X" 70 #define PRIX64 "llX" 71 #define PRIXPTR "x" 43 #define PRIdPTR PRId32 44 #define PRIoPTR PRIo32 45 #define PRIuPTR PRIu32 46 #define PRIxPTR PRIx32 47 #define PRIXPTR PRIX32 72 48 73 49 #endif -
uspace/lib/c/arch/mips32/include/istate.h
ra93d79a r8fb1bf82 36 36 #define LIBC_mips32__ISTATE_H_ 37 37 38 #include <sys/types.h> 39 40 /** Interrupt context. 41 * 42 * This is a copy of the kernel definition with which it must be kept in sync. 43 */ 44 typedef struct istate { 45 uint32_t at; 46 uint32_t v0; 47 uint32_t v1; 48 uint32_t a0; 49 uint32_t a1; 50 uint32_t a2; 51 uint32_t a3; 52 uint32_t t0; 53 uint32_t t1; 54 uint32_t t2; 55 uint32_t t3; 56 uint32_t t4; 57 uint32_t t5; 58 uint32_t t6; 59 uint32_t t7; 60 uint32_t t8; 61 uint32_t t9; 62 uint32_t gp; 63 uint32_t sp; 64 uint32_t ra; 65 66 uint32_t lo; 67 uint32_t hi; 68 69 uint32_t status; /* cp0_status */ 70 uint32_t epc; /* cp0_epc */ 71 uint32_t k1; /* We use it as thread-local pointer */ 72 } istate_t; 73 74 static inline uintptr_t istate_get_pc(istate_t *istate) 75 { 76 return istate->epc; 77 } 78 79 static inline uintptr_t istate_get_fp(istate_t *istate) 80 { 81 /* TODO */ 82 return 0; 83 } 38 #include <arch/istate.h> 84 39 85 40 #endif -
uspace/lib/c/arch/ppc32/include/fibril.h
ra93d79a r8fb1bf82 78 78 } __attribute__ ((packed)) context_t; 79 79 80 static inline uintptr_t context_get_fp(context_t *ctx) 81 { 82 return ctx->sp; 83 } 84 80 85 #endif 81 86 -
uspace/lib/c/arch/ppc32/include/inttypes.h
ra93d79a r8fb1bf82 41 41 #define LIBC_ppc32_INTTYPES_H_ 42 42 43 #define PRId8 "d" 44 #define PRId16 "d" 45 #define PRId32 "d" 46 #define PRId64 "lld" 47 #define PRIdPTR "d" 48 49 #define PRIo8 "o" 50 #define PRIo16 "o" 51 #define PRIo32 "o" 52 #define PRIo64 "llo" 53 #define PRIoPTR "o" 54 55 #define PRIu8 "u" 56 #define PRIu16 "u" 57 #define PRIu32 "u" 58 #define PRIu64 "llu" 59 #define PRIuPTR "u" 60 61 #define PRIx8 "x" 62 #define PRIx16 "x" 63 #define PRIx32 "x" 64 #define PRIx64 "llx" 65 #define PRIxPTR "x" 66 67 #define PRIX8 "X" 68 #define PRIX16 "X" 69 #define PRIX32 "X" 70 #define PRIX64 "llX" 71 #define PRIXPTR "X" 43 #define PRIdPTR PRId32 44 #define PRIoPTR PRIo32 45 #define PRIuPTR PRIu32 46 #define PRIxPTR PRIx32 47 #define PRIXPTR PRIX32 72 48 73 49 #endif -
uspace/lib/c/arch/sparc64/include/fibril.h
ra93d79a r8fb1bf82 77 77 } context_t; 78 78 79 static inline uintptr_t context_get_fp(context_t *ctx) 80 { 81 return ctx->sp + STACK_BIAS; 82 } 83 79 84 #endif 80 85 -
uspace/lib/c/arch/sparc64/include/inttypes.h
ra93d79a r8fb1bf82 41 41 #define LIBC_sparc64_INTTYPES_H_ 42 42 43 #define PRId8 "d" 44 #define PRId16 "d" 45 #define PRId32 "d" 46 #define PRId64 "lld" 47 #define PRIdPTR "lld" 48 49 #define PRIo8 "o" 50 #define PRIo16 "o" 51 #define PRIo32 "o" 52 #define PRIo64 "llo" 53 #define PRIoPTR "llo" 54 55 #define PRIu8 "u" 56 #define PRIu16 "u" 57 #define PRIu32 "u" 58 #define PRIu64 "llu" 59 #define PRIuPTR "llu" 60 61 #define PRIx8 "x" 62 #define PRIx16 "x" 63 #define PRIx32 "x" 64 #define PRIx64 "llx" 65 #define PRIxPTR "llx" 66 67 #define PRIX8 "X" 68 #define PRIX16 "X" 69 #define PRIX32 "X" 70 #define PRIX64 "llX" 71 #define PRIXPTR "llX" 43 #define PRIdPTR PRId64 44 #define PRIoPTR PRIo64 45 #define PRIuPTR PRIu64 46 #define PRIxPTR PRIx64 47 #define PRIXPTR PRIX64 72 48 73 49 #endif -
uspace/lib/c/arch/sparc64/include/istate.h
ra93d79a r8fb1bf82 36 36 #define LIBC_sparc64_ISTATE_H_ 37 37 38 #include <sys/types.h> 39 40 /** Interrupt context. 41 * 42 * This is a copy of the kernel definition with which it must be kept in sync. 43 */ 44 typedef struct istate { 45 /* TODO */ 46 } istate_t; 47 48 static inline uintptr_t istate_get_pc(istate_t *istate) 49 { 50 /* TODO */ 51 return 0; 52 } 53 54 static inline uintptr_t istate_get_fp(istate_t *istate) 55 { 56 /* TODO */ 57 return 0; 58 } 38 #include <arch/istate.h> 59 39 60 40 #endif -
uspace/lib/c/generic/adt/char_map.c
ra93d79a r8fb1bf82 60 60 * @param[in] value The integral value to be stored for the key character 61 61 * string. 62 * @return sEOK on success.63 * @return sENOMEM if there is not enough memory left.64 * @return sEEXIST if the key character string is already used.62 * @return EOK on success. 63 * @return ENOMEM if there is not enough memory left. 64 * @return EEXIST if the key character string is already used. 65 65 */ 66 66 static int 67 char_map_add_item(char_map_ refmap, const char *identifier, size_t length,67 char_map_add_item(char_map_t *map, const char *identifier, size_t length, 68 68 const int value) 69 69 { 70 70 if (map->next == (map->size - 1)) { 71 char_map_ ref*tmp;72 73 tmp = (char_map_ ref*) realloc(map->items,74 sizeof(char_map_ ref) * 2 * map->size);71 char_map_t **tmp; 72 73 tmp = (char_map_t **) realloc(map->items, 74 sizeof(char_map_t *) * 2 * map->size); 75 75 if (!tmp) 76 76 return ENOMEM; … … 80 80 } 81 81 82 map->items[map->next] = (char_map_ ref) malloc(sizeof(char_map_t));82 map->items[map->next] = (char_map_t *) malloc(sizeof(char_map_t)); 83 83 if (!map->items[map->next]) 84 84 return ENOMEM; … … 107 107 * 108 108 * @param[in] map The character string to integer map. 109 * @return sTRUE if the map is valid.110 * @return sFALSE otherwise.111 */ 112 static int char_map_is_valid(const char_map_ refmap)109 * @return TRUE if the map is valid. 110 * @return FALSE otherwise. 111 */ 112 static int char_map_is_valid(const char_map_t *map) 113 113 { 114 114 return map && (map->magic == CHAR_MAP_MAGIC_VALUE); … … 127 127 * @param[in] value The integral value to be stored for the key character 128 128 * string. 129 * @return sEOK on success.130 * @return sEINVAL if the map is not valid.131 * @return sEINVAL if the identifier parameter is NULL.132 * @return sEINVAL if the length parameter zero (0) and the129 * @return EOK on success. 130 * @return EINVAL if the map is not valid. 131 * @return EINVAL if the identifier parameter is NULL. 132 * @return EINVAL if the length parameter zero (0) and the 133 133 * identifier parameter is an empty character string (the 134 134 * first character is the terminating zero ('\0') 135 135 * character. 136 * @return sEEXIST if the key character string is already used.137 * @return sOther error codes as defined for the136 * @return EEXIST if the key character string is already used. 137 * @return Other error codes as defined for the 138 138 * char_map_add_item() function. 139 139 */ 140 140 int 141 char_map_add(char_map_ refmap, const char *identifier, size_t length,141 char_map_add(char_map_t *map, const char *identifier, size_t length, 142 142 const int value) 143 143 { … … 172 172 * @param[in,out] map The character string to integer map. 173 173 */ 174 void char_map_destroy(char_map_ refmap)174 void char_map_destroy(char_map_t *map) 175 175 { 176 176 if (char_map_is_valid(map)) { … … 196 196 * zero (0) which means that the string is processed until 197 197 * the terminating zero ('\0') character is found. 198 * @return sThe node holding the integral value assigned to the key198 * @return The node holding the integral value assigned to the key 199 199 * character string. 200 * @return sNULL if the key is not assigned a node.201 */ 202 static char_map_ ref203 char_map_find_node(const char_map_ refmap, const char *identifier,200 * @return NULL if the key is not assigned a node. 201 */ 202 static char_map_t * 203 char_map_find_node(const char_map_t *map, const char *identifier, 204 204 size_t length) 205 205 { … … 224 224 } 225 225 226 return map;226 return (char_map_t *) map; 227 227 } 228 228 … … 239 239 * zero (0) which means that the string is processed until 240 240 * the terminating zero ('\0') character is found. 241 * @return sThe integral value assigned to the key character string.242 * @return sCHAR_MAP_NULL if the key is not assigned a value.243 */ 244 int char_map_exclude(char_map_ refmap, const char *identifier, size_t length)245 { 246 char_map_ refnode;241 * @return The integral value assigned to the key character string. 242 * @return CHAR_MAP_NULL if the key is not assigned a value. 243 */ 244 int char_map_exclude(char_map_t *map, const char *identifier, size_t length) 245 { 246 char_map_t *node; 247 247 248 248 node = char_map_find_node(map, identifier, length); … … 267 267 * zero (0) which means that the string is processed until 268 268 * the terminating zero ('\0') character is found. 269 * @return sThe integral value assigned to the key character string.270 * @return sCHAR_MAP_NULL if the key is not assigned a value.271 */ 272 int char_map_find(const char_map_ refmap, const char *identifier, size_t length)273 { 274 char_map_ refnode;269 * @return The integral value assigned to the key character string. 270 * @return CHAR_MAP_NULL if the key is not assigned a value. 271 */ 272 int char_map_find(const char_map_t *map, const char *identifier, size_t length) 273 { 274 char_map_t *node; 275 275 276 276 node = char_map_find_node(map, identifier, length); … … 281 281 * 282 282 * @param[in,out] map The character string to integer map. 283 * @return sEOK on success.284 * @return sEINVAL if the map parameter is NULL.285 * @return sENOMEM if there is not enough memory left.286 */ 287 int char_map_initialize(char_map_ refmap)283 * @return EOK on success. 284 * @return EINVAL if the map parameter is NULL. 285 * @return ENOMEM if there is not enough memory left. 286 */ 287 int char_map_initialize(char_map_t *map) 288 288 { 289 289 if (!map) … … 295 295 map->next = 0; 296 296 297 map->items = malloc(sizeof(char_map_ ref) * map->size);297 map->items = malloc(sizeof(char_map_t *) * map->size); 298 298 if (!map->items) { 299 299 map->magic = 0; … … 319 319 * @param[in] value The integral value to be stored for the key character 320 320 * string. 321 * @return sEOK on success.322 * @return sEINVAL if the map is not valid.323 * @return sEINVAL if the identifier parameter is NULL.324 * @return sEINVAL if the length parameter zero (0) and the321 * @return EOK on success. 322 * @return EINVAL if the map is not valid. 323 * @return EINVAL if the identifier parameter is NULL. 324 * @return EINVAL if the length parameter zero (0) and the 325 325 * identifier parameter is an empty character string (the 326 326 * first character is the terminating zero ('\0) character. 327 * @return sEEXIST if the key character string is already used.328 * @return sOther error codes as defined for the char_map_add_item()327 * @return EEXIST if the key character string is already used. 328 * @return Other error codes as defined for the char_map_add_item() 329 329 * function. 330 330 */ 331 331 int 332 char_map_update(char_map_ refmap, const char *identifier, const size_t length,332 char_map_update(char_map_t *map, const char *identifier, const size_t length, 333 333 const int value) 334 334 { 335 char_map_ refnode;335 char_map_t *node; 336 336 337 337 node = char_map_find_node(map, identifier, length); -
uspace/lib/c/generic/adt/dynamic_fifo.c
ra93d79a r8fb1bf82 28 28 29 29 /** @addtogroup libc 30 * 30 * @{ 31 31 */ 32 32 … … 34 34 * Dynamic first in first out positive integer queue implementation. 35 35 */ 36 37 #include <adt/dynamic_fifo.h> 36 38 37 39 #include <errno.h> … … 39 41 #include <mem.h> 40 42 41 #include <adt/dynamic_fifo.h>42 43 43 /** Internal magic value for a consistency check. */ 44 44 #define DYN_FIFO_MAGIC_VALUE 0x58627659 … … 56 56 * 57 57 * @param[in] fifo The dynamic queue. 58 * @return sTRUE if the queue is valid.59 * @return sFALSE otherwise.60 */ 61 static int dyn_fifo_is_valid(dyn_fifo_ reffifo)58 * @return TRUE if the queue is valid. 59 * @return FALSE otherwise. 60 */ 61 static int dyn_fifo_is_valid(dyn_fifo_t *fifo) 62 62 { 63 63 return fifo && (fifo->magic_value == DYN_FIFO_MAGIC_VALUE); … … 68 68 * @param[in,out] fifo The dynamic queue. 69 69 * @param[in] size The initial queue size. 70 * @return sEOK on success.71 * @return sEINVAL if the queue is not valid.72 * @return sEBADMEM if the fifo parameter is NULL.73 * @return sENOMEM if there is not enough memory left.74 */ 75 int dyn_fifo_initialize(dyn_fifo_ reffifo, int size)70 * @return EOK on success. 71 * @return EINVAL if the queue is not valid. 72 * @return EBADMEM if the fifo parameter is NULL. 73 * @return ENOMEM if there is not enough memory left. 74 */ 75 int dyn_fifo_initialize(dyn_fifo_t *fifo, int size) 76 76 { 77 77 if (!fifo) … … 100 100 * this limit. May be zero or negative to indicate no 101 101 * limit. 102 * @return sEOK on success.103 * @return sEINVAL if the queue is not valid.104 * @return sENOMEM if there is not enough memory left.105 */ 106 int dyn_fifo_push(dyn_fifo_ reffifo, int value, int max_size)107 { 108 int * 102 * @return EOK on success. 103 * @return EINVAL if the queue is not valid. 104 * @return ENOMEM if there is not enough memory left. 105 */ 106 int dyn_fifo_push(dyn_fifo_t *fifo, int value, int max_size) 107 { 108 int *new_items; 109 109 110 110 if (!dyn_fifo_is_valid(fifo)) … … 149 149 /** Returns and excludes the first item in the queue. 150 150 * 151 * @param[in,out] fifo iThe dynamic queue.152 * @return sValue of the first item in the queue.153 * @return sEINVAL if the queue is not valid.154 * @return sENOENT if the queue is empty.155 */ 156 int dyn_fifo_pop(dyn_fifo_ reffifo)151 * @param[in,out] fifo The dynamic queue. 152 * @return Value of the first item in the queue. 153 * @return EINVAL if the queue is not valid. 154 * @return ENOENT if the queue is empty. 155 */ 156 int dyn_fifo_pop(dyn_fifo_t *fifo) 157 157 { 158 158 int value; … … 172 172 * 173 173 * @param[in,out] fifo The dynamic queue. 174 * @return siValue of the first item in the queue.175 * @return sEINVAL if the queue is not valid.176 * @return sENOENT if the queue is empty.177 */ 178 int dyn_fifo_value(dyn_fifo_ reffifo)174 * @return Value of the first item in the queue. 175 * @return EINVAL if the queue is not valid. 176 * @return ENOENT if the queue is empty. 177 */ 178 int dyn_fifo_value(dyn_fifo_t *fifo) 179 179 { 180 180 if (!dyn_fifo_is_valid(fifo)) … … 189 189 /** Clears and destroys the queue. 190 190 * 191 * @param[in,out] fifoThe dynamic queue.192 * @returnsEOK on success.193 * @returnsEINVAL if the queue is not valid.194 */ 195 int dyn_fifo_destroy(dyn_fifo_ reffifo)191 * @param[in,out] fifo The dynamic queue. 192 * @return EOK on success. 193 * @return EINVAL if the queue is not valid. 194 */ 195 int dyn_fifo_destroy(dyn_fifo_t *fifo) 196 196 { 197 197 if (!dyn_fifo_is_valid(fifo)) -
uspace/lib/c/generic/adt/measured_strings.c
ra93d79a r8fb1bf82 41 41 #include <unistd.h> 42 42 #include <errno.h> 43 #include <err.h>44 43 #include <async.h> 45 44 … … 52 51 * @param[in] string The initial character string to be stored. 53 52 * @param[in] length The length of the given string without the terminating 54 * zero (' /0') character. If the length is zero (0), the55 * actuallength is computed. The given length is used and56 * appended with the terminating zero ('\ \0') character53 * zero ('\0') character. If the length is zero, the actual 54 * length is computed. The given length is used and 55 * appended with the terminating zero ('\0') character 57 56 * otherwise. 58 * @return sThe new bundled character string with measured length.59 * @return sNULL if there is not enough memory left.60 */ 61 measured_string_ ref62 measured_string_create_bulk(const char * 63 { 64 measured_string_ refnew;57 * @return The new bundled character string with measured length. 58 * @return NULL if there is not enough memory left. 59 */ 60 measured_string_t * 61 measured_string_create_bulk(const char *string, size_t length) 62 { 63 measured_string_t *new; 65 64 66 65 if (length == 0) { 67 66 while (string[length]) 68 ++length;69 } 70 new = (measured_string_ ref) malloc(sizeof(measured_string_t) +67 length++; 68 } 69 new = (measured_string_t *) malloc(sizeof(measured_string_t) + 71 70 (sizeof(char) * (length + 1))); 72 71 if (!new) … … 85 84 * 86 85 * @param[in] source The source measured string to be copied. 87 * @return sThe copy of the given measured string.88 * @return sNULL if the source parameter is NULL.89 * @return sNULL if there is not enough memory left.90 */ 91 measured_string_ ref measured_string_copy(measured_string_refsource)92 { 93 measured_string_ refnew;86 * @return The copy of the given measured string. 87 * @return NULL if the source parameter is NULL. 88 * @return NULL if there is not enough memory left. 89 */ 90 measured_string_t *measured_string_copy(measured_string_t *source) 91 { 92 measured_string_t *new; 94 93 95 94 if (!source) 96 95 return NULL; 97 96 98 new = (measured_string_ ref) malloc(sizeof(measured_string_t));97 new = (measured_string_t *) malloc(sizeof(measured_string_t)); 99 98 if (new) { 100 99 new->value = (char *) malloc(source->length + 1); … … 104 103 new->value[new->length] = '\0'; 105 104 return new; 106 } else {107 free(new);108 105 } 106 free(new); 109 107 } 110 108 … … 122 120 * actual character strings. 123 121 * @param[in] count The size of the measured strings array. 124 * @return sEOK on success.125 * @return sEINVAL if the strings or data parameter is NULL.126 * @return sEINVAL if the count parameter is zero (0).127 * @return sEINVAL if the sent array differs in size.128 * @return sEINVAL if there is inconsistency in sent measured122 * @return EOK on success. 123 * @return EINVAL if the strings or data parameter is NULL. 124 * @return EINVAL if the count parameter is zero (0). 125 * @return EINVAL if the sent array differs in size. 126 * @return EINVAL if there is inconsistency in sent measured 129 127 * strings' lengths (should not occur). 130 * @return sENOMEM if there is not enough memory left.131 * @return sOther error codes as defined for the128 * @return ENOMEM if there is not enough memory left. 129 * @return Other error codes as defined for the 132 130 * async_data_write_finalize() function. 133 131 */ 134 132 int 135 measured_strings_receive(measured_string_ ref*strings, char **data,133 measured_strings_receive(measured_string_t **strings, char **data, 136 134 size_t count) 137 135 { 138 ERROR_DECLARE;139 140 136 size_t *lengths; 141 137 size_t index; … … 143 139 char *next; 144 140 ipc_callid_t callid; 141 int rc; 145 142 146 143 if ((!strings) || (!data) || (count <= 0)) … … 156 153 return EINVAL; 157 154 } 158 if(ERROR_OCCURRED(async_data_write_finalize(callid, lengths,159 sizeof(size_t) * (count + 1)))) {160 free(lengths); 161 return ERROR_CODE;155 rc = async_data_write_finalize(callid, lengths, length); 156 if (rc != EOK) { 157 free(lengths); 158 return rc; 162 159 } 163 160 164 161 *data = malloc(lengths[count]); 165 if (! (*data)) {162 if (!*data) { 166 163 free(lengths); 167 164 return ENOMEM; … … 169 166 (*data)[lengths[count] - 1] = '\0'; 170 167 171 *strings = (measured_string_ ref) malloc(sizeof(measured_string_t) *168 *strings = (measured_string_t *) malloc(sizeof(measured_string_t) * 172 169 count); 173 if (! (*strings)) {170 if (!*strings) { 174 171 free(lengths); 175 172 free(*data); … … 178 175 179 176 next = *data; 180 for (index = 0; index < count; ++index) {177 for (index = 0; index < count; index++) { 181 178 (*strings)[index].length = lengths[index]; 182 179 if (lengths[index] > 0) { 183 if ( (!async_data_write_receive(&callid, &length)) ||180 if (!async_data_write_receive(&callid, &length) || 184 181 (length != lengths[index])) { 185 182 free(*data); … … 188 185 return EINVAL; 189 186 } 190 ERROR_PROPAGATE(async_data_write_finalize(callid, next, 191 lengths[index])); 187 rc = async_data_write_finalize(callid, next, 188 lengths[index]); 189 if (rc != EOK) { 190 free(*data); 191 free(*strings); 192 free(lengths); 193 return rc; 194 } 192 195 (*strings)[index].value = next; 193 196 next += lengths[index]; 194 *next = '\0'; 195 ++next; 197 *next++ = '\0'; 196 198 } else { 197 199 (*strings)[index].value = NULL; … … 207 209 * @param[in] strings The measured strings array to be processed. 208 210 * @param[in] count The measured strings array size. 209 * @return sThe computed sizes array.210 * @return sNULL if there is not enough memory left.211 */ 212 static size_t *prepare_lengths(const measured_string_ refstrings, size_t count)211 * @return The computed sizes array. 212 * @return NULL if there is not enough memory left. 213 */ 214 static size_t *prepare_lengths(const measured_string_t *strings, size_t count) 213 215 { 214 216 size_t *lengths; … … 221 223 222 224 length = 0; 223 for (index = 0; index < count; ++ index) {225 for (index = 0; index < count; index++) { 224 226 lengths[index] = strings[index].length; 225 227 length += lengths[index] + 1; … … 236 238 * @param[in] strings The measured strings array to be transferred. 237 239 * @param[in] count The measured strings array size. 238 * @return sEOK on success.239 * @return sEINVAL if the strings parameter is NULL.240 * @return sEINVAL if the count parameter is zero (0).241 * @return sEINVAL if the calling module does not accept the given240 * @return EOK on success. 241 * @return EINVAL if the strings parameter is NULL. 242 * @return EINVAL if the count parameter is zero (0). 243 * @return EINVAL if the calling module does not accept the given 242 244 * array size. 243 * @return sEINVAL if there is inconsistency in sent measured245 * @return EINVAL if there is inconsistency in sent measured 244 246 * strings' lengths (should not occur). 245 * @return sOther error codes as defined for the247 * @return Other error codes as defined for the 246 248 * async_data_read_finalize() function. 247 249 */ 248 int measured_strings_reply(const measured_string_ref strings, size_t count) 249 { 250 ERROR_DECLARE; 251 250 int measured_strings_reply(const measured_string_t *strings, size_t count) 251 { 252 252 size_t *lengths; 253 253 size_t index; 254 254 size_t length; 255 255 ipc_callid_t callid; 256 int rc; 256 257 257 258 if ((!strings) || (count <= 0)) … … 262 263 return ENOMEM; 263 264 264 if ( (!async_data_read_receive(&callid, &length)) ||265 if (!async_data_read_receive(&callid, &length) || 265 266 (length != sizeof(size_t) * (count + 1))) { 266 267 free(lengths); 267 268 return EINVAL; 268 269 } 269 if (ERROR_OCCURRED(async_data_read_finalize(callid, lengths,270 sizeof(size_t) * (count + 1)))) {271 free(lengths); 272 return ERROR_CODE;270 rc = async_data_read_finalize(callid, lengths, length); 271 if (rc != EOK) { 272 free(lengths); 273 return rc; 273 274 } 274 275 free(lengths); 275 276 276 for (index = 0; index < count; ++ index) {277 for (index = 0; index < count; index++) { 277 278 if (strings[index].length > 0) { 278 if ((!async_data_read_receive(&callid, &length))||279 if (!async_data_read_receive(&callid, &length) || 279 280 (length != strings[index].length)) { 280 281 return EINVAL; 281 282 } 282 ERROR_PROPAGATE(async_data_read_finalize(callid, 283 strings[index].value, strings[index].length)); 283 rc = async_data_read_finalize(callid, 284 strings[index].value, strings[index].length); 285 if (rc != EOK) 286 return rc; 284 287 } 285 288 } … … 299 302 * actual character strings. 300 303 * @param[in] count The size of the measured strings array. 301 * @return sEOK on success.302 * @return sEINVAL if the strings or data parameter is NULL.303 * @return sEINVAL if the phone or count parameter is not positive.304 * @return sEINVAL if the sent array differs in size.305 * @return sENOMEM if there is not enough memory left.306 * @return sOther error codes as defined for the304 * @return EOK on success. 305 * @return EINVAL if the strings or data parameter is NULL. 306 * @return EINVAL if the phone or count parameter is not positive. 307 * @return EINVAL if the sent array differs in size. 308 * @return ENOMEM if there is not enough memory left. 309 * @return Other error codes as defined for the 307 310 * async_data_read_start() function. 308 311 */ 309 312 int 310 measured_strings_return(int phone, measured_string_ ref*strings, char **data,313 measured_strings_return(int phone, measured_string_t **strings, char **data, 311 314 size_t count) 312 315 { 313 ERROR_DECLARE;314 315 316 size_t *lengths; 316 317 size_t index; 317 318 char *next; 318 319 if ((phone <= 0) || (!strings) || (!data) || (count <= 0)) 319 int rc; 320 321 if ((phone < 0) || (!strings) || (!data) || (count <= 0)) 320 322 return EINVAL; 321 323 … … 324 326 return ENOMEM; 325 327 326 if (ERROR_OCCURRED(async_data_read_start(phone, lengths, 327 sizeof(size_t) * (count + 1)))) { 328 free(lengths); 329 return ERROR_CODE; 328 rc = async_data_read_start(phone, lengths, 329 sizeof(size_t) * (count + 1)); 330 if (rc != EOK) { 331 free(lengths); 332 return rc; 330 333 } 331 334 332 335 *data = malloc(lengths[count]); 333 if (! (*data)) {334 free(lengths); 335 return ENOMEM; 336 } 337 338 *strings = (measured_string_ ref) malloc(sizeof(measured_string_t) *336 if (!*data) { 337 free(lengths); 338 return ENOMEM; 339 } 340 341 *strings = (measured_string_t *) malloc(sizeof(measured_string_t) * 339 342 count); 340 if (! (*strings)) {343 if (!*strings) { 341 344 free(lengths); 342 345 free(*data); … … 345 348 346 349 next = *data; 347 for (index = 0; index < count; ++ index) {350 for (index = 0; index < count; index++) { 348 351 (*strings)[index].length = lengths[index]; 349 352 if (lengths[index] > 0) { 350 ERROR_PROPAGATE(async_data_read_start(phone, next, 351 lengths[index])); 353 rc = async_data_read_start(phone, next, lengths[index]); 354 if (rc != EOK) { 355 free(lengths); 356 free(data); 357 free(strings); 358 return rc; 359 } 352 360 (*strings)[index].value = next; 353 361 next += lengths[index]; 354 *next = '\0'; 355 ++ next; 362 *next++ = '\0'; 356 363 } else { 357 364 (*strings)[index].value = NULL; … … 371 378 * @param[in] strings The measured strings array to be transferred. 372 379 * @param[in] count The measured strings array size. 373 * @return sEOK on success.374 * @return sEINVAL if the strings parameter is NULL.375 * @return sEINVAL if the phone or count parameter is not positive.376 * @return sOther error codes as defined for the380 * @return EOK on success. 381 * @return EINVAL if the strings parameter is NULL. 382 * @return EINVAL if the phone or count parameter is not positive. 383 * @return Other error codes as defined for the 377 384 * async_data_write_start() function. 378 385 */ 379 386 int 380 measured_strings_send(int phone, const measured_string_ refstrings,387 measured_strings_send(int phone, const measured_string_t *strings, 381 388 size_t count) 382 389 { 383 ERROR_DECLARE;384 385 390 size_t *lengths; 386 391 size_t index; 387 388 if ((phone <= 0) || (!strings) || (count <= 0)) 392 int rc; 393 394 if ((phone < 0) || (!strings) || (count <= 0)) 389 395 return EINVAL; 390 396 … … 393 399 return ENOMEM; 394 400 395 if (ERROR_OCCURRED(async_data_write_start(phone, lengths, 396 sizeof(size_t) * (count + 1)))) { 397 free(lengths); 398 return ERROR_CODE; 401 rc = async_data_write_start(phone, lengths, 402 sizeof(size_t) * (count + 1)); 403 if (rc != EOK) { 404 free(lengths); 405 return rc; 399 406 } 400 407 401 408 free(lengths); 402 409 403 for (index = 0; index < count; ++index) {410 for (index = 0; index < count; index++) { 404 411 if (strings[index].length > 0) { 405 ERROR_PROPAGATE(async_data_write_start(phone, 406 strings[index].value, strings[index].length)); 412 rc = async_data_write_start(phone, strings[index].value, 413 strings[index].length); 414 if (rc != EOK) 415 return rc; 407 416 } 408 417 } -
uspace/lib/c/generic/async.c
ra93d79a r8fb1bf82 536 536 if (callid) 537 537 ipc_answer_0(callid, ENOMEM); 538 return NULL;538 return (uintptr_t) NULL; 539 539 } 540 540 … … 556 556 if (callid) 557 557 ipc_answer_0(callid, ENOMEM); 558 return NULL;558 return (uintptr_t) NULL; 559 559 } 560 560 -
uspace/lib/c/generic/ddi.c
ra93d79a r8fb1bf82 96 96 } 97 97 98 /** Enable an interrupt. 99 * 100 * @param irq the interrupt. 101 * 102 * @return Zero on success, negative error code otherwise. 103 */ 104 int interrupt_enable(int irq) 105 { 106 return __SYSCALL2(SYS_INTERRUPT_ENABLE, (sysarg_t) irq, 1); 107 } 108 109 /** Disable an interrupt. 110 * 111 * @param irq the interrupt. 112 * 113 * @return Zero on success, negative error code otherwise. 114 */ 115 int interrupt_disable(int irq) 116 { 117 return __SYSCALL2(SYS_INTERRUPT_ENABLE, (sysarg_t) irq, 0); 118 } 119 98 120 /** Enable PIO for specified I/O range. 99 121 * -
uspace/lib/c/generic/devmap.c
ra93d79a r8fb1bf82 132 132 * 133 133 */ 134 int devmap_device_register(const char *fqdn, dev _handle_t *handle)134 int devmap_device_register(const char *fqdn, devmap_handle_t *handle) 135 135 { 136 136 int phone = devmap_get_phone(DEVMAP_DRIVER, IPC_FLAG_BLOCKING); … … 163 163 164 164 if (handle != NULL) 165 *handle = (dev _handle_t) IPC_GET_ARG1(answer);165 *handle = (devmap_handle_t) IPC_GET_ARG1(answer); 166 166 167 167 return retval; 168 168 } 169 169 170 int devmap_device_get_handle(const char *fqdn, dev _handle_t *handle, unsigned int flags)170 int devmap_device_get_handle(const char *fqdn, devmap_handle_t *handle, unsigned int flags) 171 171 { 172 172 int phone = devmap_get_phone(DEVMAP_CLIENT, flags); … … 194 194 if (retval != EOK) { 195 195 if (handle != NULL) 196 *handle = (dev _handle_t) -1;196 *handle = (devmap_handle_t) -1; 197 197 return retval; 198 198 } 199 199 200 200 if (handle != NULL) 201 *handle = (dev _handle_t) IPC_GET_ARG1(answer);201 *handle = (devmap_handle_t) IPC_GET_ARG1(answer); 202 202 203 203 return retval; 204 204 } 205 205 206 int devmap_namespace_get_handle(const char *name, dev _handle_t *handle, unsigned int flags)206 int devmap_namespace_get_handle(const char *name, devmap_handle_t *handle, unsigned int flags) 207 207 { 208 208 int phone = devmap_get_phone(DEVMAP_CLIENT, flags); … … 230 230 if (retval != EOK) { 231 231 if (handle != NULL) 232 *handle = (dev _handle_t) -1;232 *handle = (devmap_handle_t) -1; 233 233 return retval; 234 234 } 235 235 236 236 if (handle != NULL) 237 *handle = (dev _handle_t) IPC_GET_ARG1(answer);237 *handle = (devmap_handle_t) IPC_GET_ARG1(answer); 238 238 239 239 return retval; 240 240 } 241 241 242 devmap_handle_type_t devmap_handle_probe(dev _handle_t handle)242 devmap_handle_type_t devmap_handle_probe(devmap_handle_t handle) 243 243 { 244 244 int phone = devmap_get_phone(DEVMAP_CLIENT, IPC_FLAG_BLOCKING); … … 255 255 } 256 256 257 int devmap_device_connect(dev _handle_t handle, unsigned int flags)257 int devmap_device_connect(devmap_handle_t handle, unsigned int flags) 258 258 { 259 259 int phone; … … 305 305 } 306 306 307 static size_t devmap_count_devices_internal(int phone, dev _handle_t ns_handle)307 static size_t devmap_count_devices_internal(int phone, devmap_handle_t ns_handle) 308 308 { 309 309 ipcarg_t count; … … 325 325 } 326 326 327 size_t devmap_count_devices(dev _handle_t ns_handle)327 size_t devmap_count_devices(devmap_handle_t ns_handle) 328 328 { 329 329 int phone = devmap_get_phone(DEVMAP_CLIENT, IPC_FLAG_BLOCKING); … … 387 387 } 388 388 389 size_t devmap_get_devices(dev _handle_t ns_handle, dev_desc_t **data)389 size_t devmap_get_devices(devmap_handle_t ns_handle, dev_desc_t **data) 390 390 { 391 391 int phone = devmap_get_phone(DEVMAP_CLIENT, IPC_FLAG_BLOCKING); -
uspace/lib/c/generic/fibril.c
ra93d79a r8fb1bf82 275 275 fibril->func = func; 276 276 fibril->arg = arg; 277 278 fibril->waits_for = NULL; 277 279 278 280 context_save(&fibril->ctx); -
uspace/lib/c/generic/fibril_synch.c
ra93d79a r8fb1bf82 42 42 #include <errno.h> 43 43 #include <assert.h> 44 #include <stacktrace.h> 45 #include <stdlib.h> 44 46 45 47 static void optimize_execution_power(void) … … 56 58 } 57 59 60 static void print_deadlock(fibril_owner_info_t *oi) 61 { 62 fibril_t *f = (fibril_t *) fibril_get_id(); 63 64 printf("Deadlock detected.\n"); 65 stacktrace_print(); 66 67 printf("Fibril %p waits for primitive %p.\n", f, oi); 68 69 while (oi && oi->owned_by) { 70 printf("Primitive %p is owned by fibril %p.\n", 71 oi, oi->owned_by); 72 if (oi->owned_by == f) 73 break; 74 stacktrace_print_fp_pc(context_get_fp(&oi->owned_by->ctx), 75 oi->owned_by->ctx.pc); 76 printf("Fibril %p waits for primitive %p.\n", 77 oi->owned_by, oi->owned_by->waits_for); 78 oi = oi->owned_by->waits_for; 79 } 80 } 81 82 83 static void check_for_deadlock(fibril_owner_info_t *oi) 84 { 85 while (oi && oi->owned_by) { 86 if (oi->owned_by == (fibril_t *) fibril_get_id()) { 87 print_deadlock(oi); 88 abort(); 89 } 90 oi = oi->owned_by->waits_for; 91 } 92 } 93 94 58 95 void fibril_mutex_initialize(fibril_mutex_t *fm) 59 96 { 97 fm->oi.owned_by = NULL; 60 98 fm->counter = 1; 61 99 list_initialize(&fm->waiters); … … 64 102 void fibril_mutex_lock(fibril_mutex_t *fm) 65 103 { 104 fibril_t *f = (fibril_t *) fibril_get_id(); 105 66 106 futex_down(&async_futex); 67 107 if (fm->counter-- <= 0) { … … 73 113 link_initialize(&wdata.wu_event.link); 74 114 list_append(&wdata.wu_event.link, &fm->waiters); 115 check_for_deadlock(&fm->oi); 116 f->waits_for = &fm->oi; 75 117 fibril_switch(FIBRIL_TO_MANAGER); 76 118 } else { 119 fm->oi.owned_by = f; 77 120 futex_up(&async_futex); 78 121 } … … 86 129 if (fm->counter > 0) { 87 130 fm->counter--; 131 fm->oi.owned_by = (fibril_t *) fibril_get_id(); 88 132 locked = true; 89 133 } … … 99 143 link_t *tmp; 100 144 awaiter_t *wdp; 145 fibril_t *f; 101 146 102 147 assert(!list_empty(&fm->waiters)); … … 105 150 wdp->active = true; 106 151 wdp->wu_event.inlist = false; 152 153 f = (fibril_t *) wdp->fid; 154 fm->oi.owned_by = f; 155 f->waits_for = NULL; 156 107 157 list_remove(&wdp->wu_event.link); 108 158 fibril_add_ready(wdp->fid); 109 159 optimize_execution_power(); 160 } else { 161 fm->oi.owned_by = NULL; 110 162 } 111 163 } … … 120 172 void fibril_rwlock_initialize(fibril_rwlock_t *frw) 121 173 { 174 frw->oi.owned_by = NULL; 122 175 frw->writers = 0; 123 176 frw->readers = 0; … … 127 180 void fibril_rwlock_read_lock(fibril_rwlock_t *frw) 128 181 { 182 fibril_t *f = (fibril_t *) fibril_get_id(); 183 129 184 futex_down(&async_futex); 130 185 if (frw->writers) { 131 fibril_t *f = (fibril_t *) fibril_get_id();132 186 awaiter_t wdata; 133 187 … … 138 192 f->flags &= ~FIBRIL_WRITER; 139 193 list_append(&wdata.wu_event.link, &frw->waiters); 194 check_for_deadlock(&frw->oi); 195 f->waits_for = &frw->oi; 140 196 fibril_switch(FIBRIL_TO_MANAGER); 141 197 } else { 142 frw->readers++; 198 /* Consider the first reader the owner. */ 199 if (frw->readers++ == 0) 200 frw->oi.owned_by = f; 143 201 futex_up(&async_futex); 144 202 } … … 147 205 void fibril_rwlock_write_lock(fibril_rwlock_t *frw) 148 206 { 207 fibril_t *f = (fibril_t *) fibril_get_id(); 208 149 209 futex_down(&async_futex); 150 210 if (frw->writers || frw->readers) { 151 fibril_t *f = (fibril_t *) fibril_get_id();152 211 awaiter_t wdata; 153 212 … … 158 217 f->flags |= FIBRIL_WRITER; 159 218 list_append(&wdata.wu_event.link, &frw->waiters); 219 check_for_deadlock(&frw->oi); 220 f->waits_for = &frw->oi; 160 221 fibril_switch(FIBRIL_TO_MANAGER); 161 222 } else { 223 frw->oi.owned_by = f; 162 224 frw->writers++; 163 225 futex_up(&async_futex); … … 170 232 assert(frw->readers || (frw->writers == 1)); 171 233 if (frw->readers) { 172 if (--frw->readers) 234 if (--frw->readers) { 235 if (frw->oi.owned_by == (fibril_t *) fibril_get_id()) { 236 /* 237 * If this reader firbril was considered the 238 * owner of this rwlock, clear the ownership 239 * information even if there are still more 240 * readers. 241 * 242 * This is the limitation of the detection 243 * mechanism rooted in the fact that tracking 244 * all readers would require dynamically 245 * allocated memory for keeping linkage info. 246 */ 247 frw->oi.owned_by = NULL; 248 } 173 249 goto out; 250 } 174 251 } else { 175 252 frw->writers--; … … 177 254 178 255 assert(!frw->readers && !frw->writers); 256 257 frw->oi.owned_by = NULL; 179 258 180 259 while (!list_empty(&frw->waiters)) { … … 185 264 wdp = list_get_instance(tmp, awaiter_t, wu_event.link); 186 265 f = (fibril_t *) wdp->fid; 266 267 f->waits_for = NULL; 187 268 188 269 if (f->flags & FIBRIL_WRITER) { … … 194 275 fibril_add_ready(wdp->fid); 195 276 frw->writers++; 277 frw->oi.owned_by = f; 196 278 optimize_execution_power(); 197 279 break; … … 201 283 list_remove(&wdp->wu_event.link); 202 284 fibril_add_ready(wdp->fid); 203 frw->readers++; 285 if (frw->readers++ == 0) { 286 /* Consider the first reader the owner. */ 287 frw->oi.owned_by = f; 288 } 204 289 optimize_execution_power(); 205 290 } -
uspace/lib/c/generic/io/klog.c
ra93d79a r8fb1bf82 52 52 void klog_update(void) 53 53 { 54 (void) __SYSCALL3(SYS_KLOG, 1, NULL, 0);54 (void) __SYSCALL3(SYS_KLOG, 1, (uintptr_t) NULL, 0); 55 55 } 56 56 -
uspace/lib/c/generic/net/icmp_api.c
ra93d79a r8fb1bf82 66 66 * @param[in] addr The target host address. 67 67 * @param[in] addrlen The torget host address length. 68 * @return sICMP_ECHO on success.69 * @return sETIMEOUT if the reply has not arrived before the68 * @return ICMP_ECHO on success. 69 * @return ETIMEOUT if the reply has not arrived before the 70 70 * timeout. 71 * @return sICMP type of the received error notification.72 * @return sEINVAL if the addrlen parameter is less or equal to71 * @return ICMP type of the received error notification. 72 * @return EINVAL if the addrlen parameter is less or equal to 73 73 * zero. 74 * @return sENOMEM if there is not enough memory left.75 * @return sEPARTY if there was an internal error.74 * @return ENOMEM if there is not enough memory left. 75 * @return EPARTY if there was an internal error. 76 76 */ 77 77 int -
uspace/lib/c/generic/net/icmp_common.c
ra93d79a r8fb1bf82 50 50 * @param[in] timeout The connection timeout in microseconds. No timeout if 51 51 * set to zero. 52 * @return sThe ICMP module phone on success.53 * @return sETIMEOUT if the connection timeouted.52 * @return The ICMP module phone on success. 53 * @return ETIMEOUT if the connection timeouted. 54 54 */ 55 55 int icmp_connect_module(services_t service, suseconds_t timeout) -
uspace/lib/c/generic/net/inet.c
ra93d79a r8fb1bf82 51 51 * @param[out] address The character buffer to be filled. 52 52 * @param[in] length The buffer length. 53 * @return sEOK on success.54 * @return sEINVAL if the data or address parameter is NULL.55 * @return sENOMEM if the character buffer is not long enough.56 * @return sENOTSUP if the address family is not supported.53 * @return EOK on success. 54 * @return EINVAL if the data or address parameter is NULL. 55 * @return ENOMEM if the character buffer is not long enough. 56 * @return ENOTSUP if the address family is not supported. 57 57 */ 58 58 int … … 101 101 * @param[in] address The character buffer to be parsed. 102 102 * @param[out] data The address data to be filled. 103 * @return sEOK on success.104 * @return sEINVAL if the data parameter is NULL.105 * @return sENOENT if the address parameter is NULL.106 * @return sENOTSUP if the address family is not supported.103 * @return EOK on success. 104 * @return EINVAL if the data parameter is NULL. 105 * @return ENOENT if the address parameter is NULL. 106 * @return ENOTSUP if the address family is not supported. 107 107 */ 108 108 int inet_pton(uint16_t family, const char *address, uint8_t *data) -
uspace/lib/c/generic/net/modules.c
ra93d79a r8fb1bf82 41 41 #include <async.h> 42 42 #include <malloc.h> 43 #include <err .h>43 #include <errno.h> 44 44 #include <sys/time.h> 45 45 … … 137 137 ipcarg_t arg3, async_client_conn_t client_receiver, suseconds_t timeout) 138 138 { 139 ERROR_DECLARE;139 int rc; 140 140 141 141 /* Connect to the needed service */ … … 144 144 /* Request the bidirectional connection */ 145 145 ipcarg_t phonehash; 146 if (ERROR_OCCURRED(ipc_connect_to_me(phone, arg1, arg2, arg3, 147 &phonehash))) { 146 147 rc = ipc_connect_to_me(phone, arg1, arg2, arg3, &phonehash); 148 if (rc != EOK) { 148 149 ipc_hangup(phone); 149 return ERROR_CODE;150 return rc; 150 151 } 151 152 async_new_connection(phonehash, 0, NULL, client_receiver); … … 158 159 * 159 160 * @param[in] need The needed module service. 160 * @return sThe phone of the needed service.161 * @return The phone of the needed service. 161 162 */ 162 163 int connect_to_service(services_t need) … … 170 171 * @param[in] timeout The connection timeout in microseconds. No timeout if 171 172 * set to zero (0). 172 * @return sThe phone of the needed service.173 * @return sETIMEOUT if the connection timeouted.173 * @return The phone of the needed service. 174 * @return ETIMEOUT if the connection timeouted. 174 175 */ 175 176 int connect_to_service_timeout(services_t need, suseconds_t timeout) … … 203 204 * @param[out] data The data buffer to be filled. 204 205 * @param[out] length The buffer length. 205 * @return sEOK on success.206 * @return sEBADMEM if the data or the length parameter is NULL.207 * @return sEINVAL if the client does not send data.208 * @return sENOMEM if there is not enough memory left.209 * @return sOther error codes as defined for the206 * @return EOK on success. 207 * @return EBADMEM if the data or the length parameter is NULL. 208 * @return EINVAL if the client does not send data. 209 * @return ENOMEM if there is not enough memory left. 210 * @return Other error codes as defined for the 210 211 * async_data_write_finalize() function. 211 212 */ 212 213 int data_receive(void **data, size_t *length) 213 214 { 214 ERROR_DECLARE;215 216 215 ipc_callid_t callid; 216 int rc; 217 217 218 218 if (!data || !length) … … 229 229 230 230 // fetch the data 231 if (ERROR_OCCURRED(async_data_write_finalize(callid, *data, *length))) { 231 rc = async_data_write_finalize(callid, *data, *length); 232 if (rc != EOK) { 232 233 free(data); 233 return ERROR_CODE;234 return rc; 234 235 } 235 236 … … 241 242 * @param[in] data The data buffer to be sent. 242 243 * @param[in] data_length The buffer length. 243 * @return sEOK on success.244 * @return sEINVAL if the client does not expect the data.245 * @return sEOVERFLOW if the client does not expect all the data.244 * @return EOK on success. 245 * @return EINVAL if the client does not expect the data. 246 * @return EOVERFLOW if the client does not expect all the data. 246 247 * Only partial data are transfered. 247 * @return sOther error codes as defined for the248 * @return Other error codes as defined for the 248 249 * async_data_read_finalize() function. 249 250 */ -
uspace/lib/c/generic/net/packet.c
ra93d79a r8fb1bf82 41 41 #include <unistd.h> 42 42 #include <errno.h> 43 #include <err.h>44 43 45 44 #include <sys/mman.h> … … 63 62 64 63 /** Type definition of the packet map page. */ 65 typedef packet_t packet_map_t[PACKET_MAP_SIZE]; 66 67 /** Type definition of the packet map page pointer. */ 68 typedef packet_map_t * packet_map_ref; 64 typedef packet_t *packet_map_t[PACKET_MAP_SIZE]; 69 65 70 66 /** Packet map. … … 86 82 /** Initializes the packet map. 87 83 * 88 * @return sEOK on success.89 * @return sENOMEM if there is not enough memory left.84 * @return EOK on success. 85 * @return ENOMEM if there is not enough memory left. 90 86 */ 91 87 int pm_init(void) 92 88 { 93 ERROR_DECLARE;89 int rc; 94 90 95 91 fibril_rwlock_initialize(&pm_globals.lock); 92 96 93 fibril_rwlock_write_lock(&pm_globals.lock); 97 ERROR_PROPAGATE(gpm_initialize(&pm_globals.packet_map));94 rc = gpm_initialize(&pm_globals.packet_map); 98 95 fibril_rwlock_write_unlock(&pm_globals.lock); 99 return EOK; 96 97 return rc; 100 98 } 101 99 … … 103 101 * 104 102 * @param[in] packet_id The packet identifier to be found. 105 * @return sThe found packet reference.106 * @return sNULL if the mapping does not exist.107 */ 108 packet_t pm_find(packet_id_t packet_id)109 { 110 packet_map_ refmap;111 packet_t packet;103 * @return The found packet reference. 104 * @return NULL if the mapping does not exist. 105 */ 106 packet_t *pm_find(packet_id_t packet_id) 107 { 108 packet_map_t *map; 109 packet_t *packet; 112 110 113 111 if (!packet_id) … … 132 130 * 133 131 * @param[in] packet The packet to be remembered. 134 * @returns EOK on success. 135 * @returns EINVAL if the packet is not valid. 136 * @returns EINVAL if the packet map is not initialized. 137 * @returns ENOMEM if there is not enough memory left. 138 */ 139 int pm_add(packet_t packet) 140 { 141 ERROR_DECLARE; 142 143 packet_map_ref map; 132 * @return EOK on success. 133 * @return EINVAL if the packet is not valid. 134 * @return EINVAL if the packet map is not initialized. 135 * @return ENOMEM if there is not enough memory left. 136 */ 137 int pm_add(packet_t *packet) 138 { 139 packet_map_t *map; 140 int rc; 144 141 145 142 if (!packet_is_valid(packet)) … … 154 151 } else { 155 152 do { 156 map = (packet_map_ ref) malloc(sizeof(packet_map_t));153 map = (packet_map_t *) malloc(sizeof(packet_map_t)); 157 154 if (!map) { 158 155 fibril_rwlock_write_unlock(&pm_globals.lock); … … 160 157 } 161 158 bzero(map, sizeof(packet_map_t)); 162 if ((ERROR_CODE =163 gpm_add(&pm_globals.packet_map, map))< 0) {159 rc = gpm_add(&pm_globals.packet_map, map); 160 if (rc < 0) { 164 161 fibril_rwlock_write_unlock(&pm_globals.lock); 165 162 free(map); 166 return ERROR_CODE;163 return rc; 167 164 } 168 165 } while (PACKET_MAP_PAGE(packet->packet_id) >= … … 180 177 int count; 181 178 int index; 182 packet_map_ refmap;183 packet_t packet;179 packet_map_t *map; 180 packet_t *packet; 184 181 185 182 fibril_rwlock_write_lock(&pm_globals.lock); … … 208 205 * @param[in] order The packet order value. 209 206 * @param[in] metric The metric value of the packet. 210 * @return sEOK on success.211 * @return sEINVAL if the first parameter is NULL.212 * @return sEINVAL if the packet is not valid.213 */ 214 int pq_add(packet_t * first, packet_tpacket, size_t order, size_t metric)215 { 216 packet_t item;207 * @return EOK on success. 208 * @return EINVAL if the first parameter is NULL. 209 * @return EINVAL if the packet is not valid. 210 */ 211 int pq_add(packet_t **first, packet_t *packet, size_t order, size_t metric) 212 { 213 packet_t *item; 217 214 218 215 if (!first || !packet_is_valid(packet)) … … 252 249 * @param[in] first The first packet of the queue. 253 250 * @param[in] order The packet order value. 254 * @return sThe packet with the given order.255 * @return sNULL if the first packet is not valid.256 * @return sNULL if the packet is not found.257 */ 258 packet_t pq_find(packet_tpacket, size_t order)259 { 260 packet_t item;251 * @return The packet with the given order. 252 * @return NULL if the first packet is not valid. 253 * @return NULL if the packet is not found. 254 */ 255 packet_t *pq_find(packet_t *packet, size_t order) 256 { 257 packet_t *item; 261 258 262 259 if (!packet_is_valid(packet)) … … 278 275 * @param[in] packet The packet in the queue. 279 276 * @param[in] new_packet The new packet to be inserted. 280 * @return sEOK on success.281 * @return sEINVAL if etiher of the packets is invalid.282 */ 283 int pq_insert_after(packet_t packet, packet_tnew_packet)284 { 285 packet_t item;277 * @return EOK on success. 278 * @return EINVAL if etiher of the packets is invalid. 279 */ 280 int pq_insert_after(packet_t *packet, packet_t *new_packet) 281 { 282 packet_t *item; 286 283 287 284 if (!packet_is_valid(packet) || !packet_is_valid(new_packet)) … … 301 298 * 302 299 * @param[in] packet The packet to be detached. 303 * @return sThe next packet in the queue. If the packet is the first300 * @return The next packet in the queue. If the packet is the first 304 301 * one of the queue, this becomes the new first one. 305 * @return sNULL if there is no packet left.306 * @return sNULL if the packet is not valid.307 */ 308 packet_t pq_detach(packet_tpacket)309 { 310 packet_t next;311 packet_t previous;302 * @return NULL if there is no packet left. 303 * @return NULL if the packet is not valid. 304 */ 305 packet_t *pq_detach(packet_t *packet) 306 { 307 packet_t *next; 308 packet_t *previous; 312 309 313 310 if (!packet_is_valid(packet)) … … 331 328 * @param[in] order The packet order value. 332 329 * @param[in] metric The metric value of the packet. 333 * @return sEOK on success.334 * @return sEINVAL if the packet is invalid.335 */ 336 int pq_set_order(packet_t packet, size_t order, size_t metric)330 * @return EOK on success. 331 * @return EINVAL if the packet is invalid. 332 */ 333 int pq_set_order(packet_t *packet, size_t order, size_t metric) 337 334 { 338 335 if (!packet_is_valid(packet)) … … 349 346 * @param[out] order The packet order value. 350 347 * @param[out] metric The metric value of the packet. 351 * @return sEOK on success.352 * @return sEINVAL if the packet is invalid.353 */ 354 int pq_get_order(packet_t packet, size_t *order, size_t *metric)348 * @return EOK on success. 349 * @return EINVAL if the packet is invalid. 350 */ 351 int pq_get_order(packet_t *packet, size_t *order, size_t *metric) 355 352 { 356 353 if (!packet_is_valid(packet)) … … 375 372 * packets after its detachment. 376 373 */ 377 void pq_destroy(packet_t first, void (*packet_release)(packet_tpacket))378 { 379 packet_t actual;380 packet_t next;374 void pq_destroy(packet_t *first, void (*packet_release)(packet_t *packet)) 375 { 376 packet_t *actual; 377 packet_t *next; 381 378 382 379 actual = first; … … 394 391 * 395 392 * @param[in] packet The packet queue member. 396 * @return sThe next packet in the queue.397 * @return sNULL if there is no next packet.398 * @return sNULL if the packet is not valid.399 */ 400 packet_t pq_next(packet_tpacket)393 * @return The next packet in the queue. 394 * @return NULL if there is no next packet. 395 * @return NULL if the packet is not valid. 396 */ 397 packet_t *pq_next(packet_t *packet) 401 398 { 402 399 if (!packet_is_valid(packet)) … … 409 406 * 410 407 * @param[in] packet The packet queue member. 411 * @return sThe previous packet in the queue.412 * @return sNULL if there is no previous packet.413 * @return sNULL if the packet is not valid.414 */ 415 packet_t pq_previous(packet_tpacket)408 * @return The previous packet in the queue. 409 * @return NULL if there is no previous packet. 410 * @return NULL if the packet is not valid. 411 */ 412 packet_t *pq_previous(packet_t *packet) 416 413 { 417 414 if (!packet_is_valid(packet)) -
uspace/lib/c/generic/net/socket_client.c
ra93d79a r8fb1bf82 43 43 #include <stdlib.h> 44 44 #include <errno.h> 45 #include <err.h>46 45 47 46 #include <ipc/services.h> … … 79 78 */ 80 79 typedef struct socket socket_t; 81 82 /** Type definition of the socket specific data pointer.83 * @see socket84 */85 typedef socket_t *socket_ref;86 80 87 81 /** Socket specific data. … … 163 157 164 158 /** Active sockets. */ 165 sockets_ refsockets;159 sockets_t *sockets; 166 160 167 161 /** Safety lock. … … 184 178 /** Returns the active sockets. 185 179 * 186 * @return sThe active sockets.187 */ 188 static sockets_ refsocket_get_sockets(void)180 * @return The active sockets. 181 */ 182 static sockets_t *socket_get_sockets(void) 189 183 { 190 184 if (!socket_globals.sockets) { 191 185 socket_globals.sockets = 192 (sockets_ ref) malloc(sizeof(sockets_t));186 (sockets_t *) malloc(sizeof(sockets_t)); 193 187 if (!socket_globals.sockets) 194 188 return NULL; … … 212 206 static void socket_connection(ipc_callid_t iid, ipc_call_t * icall) 213 207 { 214 ERROR_DECLARE;215 216 208 ipc_callid_t callid; 217 209 ipc_call_t call; 218 socket_ref socket; 210 socket_t *socket; 211 int rc; 219 212 220 213 loop: … … 231 224 SOCKET_GET_SOCKET_ID(call)); 232 225 if (!socket) { 233 ERROR_CODE= ENOTSOCK;226 rc = ENOTSOCK; 234 227 fibril_rwlock_read_unlock(&socket_globals.lock); 235 228 break; … … 240 233 fibril_mutex_lock(&socket->receive_lock); 241 234 // push the number of received packet fragments 242 if (!ERROR_OCCURRED(dyn_fifo_push(&socket->received,235 rc = dyn_fifo_push(&socket->received, 243 236 SOCKET_GET_DATA_FRAGMENTS(call), 244 SOCKET_MAX_RECEIVED_SIZE))) { 237 SOCKET_MAX_RECEIVED_SIZE); 238 if (rc == EOK) { 245 239 // signal the received packet 246 240 fibril_condvar_signal(&socket->receive_signal); … … 252 246 // push the new socket identifier 253 247 fibril_mutex_lock(&socket->accept_lock); 254 if (!ERROR_OCCURRED(dyn_fifo_push(&socket->accepted, 255 1, SOCKET_MAX_ACCEPTED_SIZE))) { 248 rc = dyn_fifo_push(&socket->accepted, 1, 249 SOCKET_MAX_ACCEPTED_SIZE); 250 if (rc == EOK) { 256 251 // signal the accepted socket 257 252 fibril_condvar_signal(&socket->accept_signal); … … 261 256 262 257 default: 263 ERROR_CODE= ENOTSUP;258 rc = ENOTSUP; 264 259 } 265 260 … … 280 275 281 276 default: 282 ERROR_CODE= ENOTSUP;283 } 284 285 ipc_answer_0(callid, (ipcarg_t) ERROR_CODE);277 rc = ENOTSUP; 278 } 279 280 ipc_answer_0(callid, (ipcarg_t) rc); 286 281 goto loop; 287 282 } … … 291 286 * Connects to the TCP module if necessary. 292 287 * 293 * @return sThe TCP module phone.294 * @return sOther error codes as defined for the288 * @return The TCP module phone. 289 * @return Other error codes as defined for the 295 290 * bind_service_timeout() function. 296 291 */ … … 310 305 * Connects to the UDP module if necessary. 311 306 * 312 * @return sThe UDP module phone.313 * @return sOther error codes as defined for the307 * @return The UDP module phone. 308 * @return Other error codes as defined for the 314 309 * bind_service_timeout() function. 315 310 */ … … 327 322 /** Tries to find a new free socket identifier. 328 323 * 329 * @return sThe new socket identifier.330 * @return sELIMIT if there is no socket identifier available.324 * @return The new socket identifier. 325 * @return ELIMIT if there is no socket identifier available. 331 326 */ 332 327 static int socket_generate_new_id(void) 333 328 { 334 sockets_ refsockets;329 sockets_t *sockets; 335 330 int socket_id = 0; 336 331 int count; … … 372 367 */ 373 368 static void 374 socket_initialize(socket_ refsocket, int socket_id, int phone,369 socket_initialize(socket_t *socket, int socket_id, int phone, 375 370 services_t service) 376 371 { … … 392 387 * @param[in] type Socket type. 393 388 * @param[in] protocol Socket protocol. 394 * @return sThe socket identifier on success.395 * @return sEPFNOTSUPPORT if the protocol family is not supported.396 * @return sESOCKNOTSUPPORT if the socket type is not supported.397 * @return sEPROTONOSUPPORT if the protocol is not supported.398 * @return sENOMEM if there is not enough memory left.399 * @return sELIMIT if there was not a free socket identifier found389 * @return The socket identifier on success. 390 * @return EPFNOTSUPPORT if the protocol family is not supported. 391 * @return ESOCKNOTSUPPORT if the socket type is not supported. 392 * @return EPROTONOSUPPORT if the protocol is not supported. 393 * @return ENOMEM if there is not enough memory left. 394 * @return ELIMIT if there was not a free socket identifier found 400 395 * this time. 401 * @return sOther error codes as defined for the NET_SOCKET message.402 * @return sOther error codes as defined for the396 * @return Other error codes as defined for the NET_SOCKET message. 397 * @return Other error codes as defined for the 403 398 * bind_service_timeout() function. 404 399 */ 405 400 int socket(int domain, int type, int protocol) 406 401 { 407 ERROR_DECLARE; 408 409 socket_ref socket; 402 socket_t *socket; 410 403 int phone; 411 404 int socket_id; … … 413 406 ipcarg_t fragment_size; 414 407 ipcarg_t header_size; 408 int rc; 415 409 416 410 // find the appropriate service … … 464 458 465 459 // create a new socket structure 466 socket = (socket_ ref) malloc(sizeof(socket_t));460 socket = (socket_t *) malloc(sizeof(socket_t)); 467 461 if (!socket) 468 462 return ENOMEM; … … 479 473 } 480 474 481 if (ERROR_OCCURRED((int) async_req_3_3(phone, NET_SOCKET, socket_id, 0, 482 service, NULL, &fragment_size, &header_size))) { 475 rc = (int) async_req_3_3(phone, NET_SOCKET, socket_id, 0, service, NULL, 476 &fragment_size, &header_size); 477 if (rc != EOK) { 483 478 fibril_rwlock_write_unlock(&socket_globals.lock); 484 479 free(socket); 485 return ERROR_CODE;480 return rc; 486 481 } 487 482 … … 492 487 socket_initialize(socket, socket_id, phone, service); 493 488 // store the new socket 494 ERROR_CODE= sockets_add(socket_get_sockets(), socket_id, socket);489 rc = sockets_add(socket_get_sockets(), socket_id, socket); 495 490 496 491 fibril_rwlock_write_unlock(&socket_globals.lock); 497 if ( ERROR_CODE< 0) {492 if (rc < 0) { 498 493 dyn_fifo_destroy(&socket->received); 499 494 dyn_fifo_destroy(&socket->accepted); … … 501 496 async_msg_3(phone, NET_SOCKET_CLOSE, (ipcarg_t) socket_id, 0, 502 497 service); 503 return ERROR_CODE;498 return rc; 504 499 } 505 500 … … 514 509 * @param[in] data The data to be sent. 515 510 * @param[in] datalength The data length. 516 * @return sEOK on success.517 * @return sENOTSOCK if the socket is not found.518 * @return sEBADMEM if the data parameter is NULL.519 * @return sNO_DATA if the datalength parameter is zero (0).520 * @return sOther error codes as defined for the spcific message.511 * @return EOK on success. 512 * @return ENOTSOCK if the socket is not found. 513 * @return EBADMEM if the data parameter is NULL. 514 * @return NO_DATA if the datalength parameter is zero (0). 515 * @return Other error codes as defined for the spcific message. 521 516 */ 522 517 static int … … 524 519 const void *data, size_t datalength) 525 520 { 526 socket_ refsocket;521 socket_t *socket; 527 522 aid_t message_id; 528 523 ipcarg_t result; … … 559 554 * @param[in] my_addr The port address. 560 555 * @param[in] addrlen The address length. 561 * @return sEOK on success.562 * @return sENOTSOCK if the socket is not found.563 * @return sEBADMEM if the my_addr parameter is NULL.564 * @return sNO_DATA if the addlen parameter is zero.565 * @return sOther error codes as defined for the NET_SOCKET_BIND556 * @return EOK on success. 557 * @return ENOTSOCK if the socket is not found. 558 * @return EBADMEM if the my_addr parameter is NULL. 559 * @return NO_DATA if the addlen parameter is zero. 560 * @return Other error codes as defined for the NET_SOCKET_BIND 566 561 * message. 567 562 */ … … 580 575 * @param[in] socket_id Socket identifier. 581 576 * @param[in] backlog The maximum number of waiting sockets to be accepted. 582 * @return sEOK on success.583 * @return sEINVAL if the backlog parameter is not positive (<=0).584 * @return sENOTSOCK if the socket is not found.585 * @return sOther error codes as defined for the NET_SOCKET_LISTEN577 * @return EOK on success. 578 * @return EINVAL if the backlog parameter is not positive (<=0). 579 * @return ENOTSOCK if the socket is not found. 580 * @return Other error codes as defined for the NET_SOCKET_LISTEN 586 581 * message. 587 582 */ 588 583 int listen(int socket_id, int backlog) 589 584 { 590 socket_ refsocket;585 socket_t *socket; 591 586 int result; 592 587 … … 618 613 * @param[out] cliaddr The remote client address. 619 614 * @param[in] addrlen The address length. 620 * @return sEOK on success.621 * @return sEBADMEM if the cliaddr or addrlen parameter is NULL.622 * @return sEINVAL if the backlog parameter is not positive (<=0).623 * @return sENOTSOCK if the socket is not found.624 * @return sOther error codes as defined for the NET_SOCKET_ACCEPT615 * @return EOK on success. 616 * @return EBADMEM if the cliaddr or addrlen parameter is NULL. 617 * @return EINVAL if the backlog parameter is not positive (<=0). 618 * @return ENOTSOCK if the socket is not found. 619 * @return Other error codes as defined for the NET_SOCKET_ACCEPT 625 620 * message. 626 621 */ 627 622 int accept(int socket_id, struct sockaddr * cliaddr, socklen_t * addrlen) 628 623 { 629 socket_ refsocket;630 socket_ refnew_socket;624 socket_t *socket; 625 socket_t *new_socket; 631 626 aid_t message_id; 632 627 ipcarg_t ipc_result; … … 661 656 662 657 // create a new scoket 663 new_socket = (socket_ ref) malloc(sizeof(socket_t));658 new_socket = (socket_t *) malloc(sizeof(socket_t)); 664 659 if (!new_socket) { 665 660 fibril_mutex_unlock(&socket->accept_lock); … … 721 716 * @param[in] serv_addr The remote server address. 722 717 * @param[in] addrlen The address length. 723 * @return sEOK on success.724 * @return sEBADMEM if the serv_addr parameter is NULL.725 * @return sNO_DATA if the addlen parameter is zero.726 * @return sENOTSOCK if the socket is not found.727 * @return sOther error codes as defined for the NET_SOCKET_CONNECT718 * @return EOK on success. 719 * @return EBADMEM if the serv_addr parameter is NULL. 720 * @return NO_DATA if the addlen parameter is zero. 721 * @return ENOTSOCK if the socket is not found. 722 * @return Other error codes as defined for the NET_SOCKET_CONNECT 728 723 * message. 729 724 */ … … 745 740 * @param[in] socket The socket to be destroyed. 746 741 */ 747 static void socket_destroy(socket_ refsocket)742 static void socket_destroy(socket_t *socket) 748 743 { 749 744 int accepted_id; … … 761 756 * 762 757 * @param[in] socket_id Socket identifier. 763 * @return sEOK on success.764 * @return sENOTSOCK if the socket is not found.765 * @return sEINPROGRESS if there is another blocking function in758 * @return EOK on success. 759 * @return ENOTSOCK if the socket is not found. 760 * @return EINPROGRESS if there is another blocking function in 766 761 * progress. 767 * @return sOther error codes as defined for the NET_SOCKET_CLOSE762 * @return Other error codes as defined for the NET_SOCKET_CLOSE 768 763 * message. 769 764 */ 770 765 int closesocket(int socket_id) 771 766 { 772 ERROR_DECLARE; 773 774 socket_ref socket; 767 socket_t *socket; 768 int rc; 775 769 776 770 fibril_rwlock_write_lock(&socket_globals.lock); … … 787 781 788 782 // request close 789 ERROR_PROPAGATE((int) async_req_3_0(socket->phone, NET_SOCKET_CLOSE, 790 (ipcarg_t) socket->socket_id, 0, socket->service)); 783 rc = (int) async_req_3_0(socket->phone, NET_SOCKET_CLOSE, 784 (ipcarg_t) socket->socket_id, 0, socket->service); 785 if (rc != EOK) { 786 fibril_rwlock_write_unlock(&socket_globals.lock); 787 return rc; 788 } 791 789 // free the socket structure 792 790 socket_destroy(socket); … … 808 806 * sockets. 809 807 * @param[in] addrlen The address length. Used only if toaddr is not NULL. 810 * @return sEOK on success.811 * @return sENOTSOCK if the socket is not found.812 * @return sEBADMEM if the data or toaddr parameter is NULL.813 * @return sNO_DATA if the datalength or the addrlen parameter is808 * @return EOK on success. 809 * @return ENOTSOCK if the socket is not found. 810 * @return EBADMEM if the data or toaddr parameter is NULL. 811 * @return NO_DATA if the datalength or the addrlen parameter is 814 812 * zero (0). 815 * @return sOther error codes as defined for the NET_SOCKET_SENDTO813 * @return Other error codes as defined for the NET_SOCKET_SENDTO 816 814 * message. 817 815 */ … … 821 819 socklen_t addrlen) 822 820 { 823 socket_ refsocket;821 socket_t *socket; 824 822 aid_t message_id; 825 823 ipcarg_t result; … … 910 908 * @param[in] datalength The data length. 911 909 * @param[in] flags Various send flags. 912 * @return sEOK on success.913 * @return sENOTSOCK if the socket is not found.914 * @return sEBADMEM if the data parameter is NULL.915 * @return sNO_DATA if the datalength parameter is zero.916 * @return sOther error codes as defined for the NET_SOCKET_SEND910 * @return EOK on success. 911 * @return ENOTSOCK if the socket is not found. 912 * @return EBADMEM if the data parameter is NULL. 913 * @return NO_DATA if the datalength parameter is zero. 914 * @return Other error codes as defined for the NET_SOCKET_SEND 917 915 * message. 918 916 */ … … 934 932 * @param[in] toaddr The destination address. 935 933 * @param[in] addrlen The address length. 936 * @return sEOK on success.937 * @return sENOTSOCK if the socket is not found.938 * @return sEBADMEM if the data or toaddr parameter is NULL.939 * @return sNO_DATA if the datalength or the addrlen parameter is934 * @return EOK on success. 935 * @return ENOTSOCK if the socket is not found. 936 * @return EBADMEM if the data or toaddr parameter is NULL. 937 * @return NO_DATA if the datalength or the addrlen parameter is 940 938 * zero. 941 * @return sOther error codes as defined for the NET_SOCKET_SENDTO939 * @return Other error codes as defined for the NET_SOCKET_SENDTO 942 940 * message. 943 941 */ … … 968 966 * read. The actual address length is set. Used only if 969 967 * fromaddr is not NULL. 970 * @return sEOK on success.971 * @return sENOTSOCK if the socket is not found.972 * @return sEBADMEM if the data parameter is NULL.973 * @return sNO_DATA if the datalength or addrlen parameter is zero.974 * @return sOther error codes as defined for the spcific message.968 * @return EOK on success. 969 * @return ENOTSOCK if the socket is not found. 970 * @return EBADMEM if the data parameter is NULL. 971 * @return NO_DATA if the datalength or addrlen parameter is zero. 972 * @return Other error codes as defined for the spcific message. 975 973 */ 976 974 static int … … 978 976 int flags, struct sockaddr *fromaddr, socklen_t *addrlen) 979 977 { 980 socket_ refsocket;978 socket_t *socket; 981 979 aid_t message_id; 982 980 ipcarg_t ipc_result; … … 1097 1095 * @param[in] datalength The data length. 1098 1096 * @param[in] flags Various receive flags. 1099 * @return sEOK on success.1100 * @return sENOTSOCK if the socket is not found.1101 * @return sEBADMEM if the data parameter is NULL.1102 * @return sNO_DATA if the datalength parameter is zero.1103 * @return sOther error codes as defined for the NET_SOCKET_RECV1097 * @return EOK on success. 1098 * @return ENOTSOCK if the socket is not found. 1099 * @return EBADMEM if the data parameter is NULL. 1100 * @return NO_DATA if the datalength parameter is zero. 1101 * @return Other error codes as defined for the NET_SOCKET_RECV 1104 1102 * message. 1105 1103 */ … … 1120 1118 * @param[in,out] addrlen The address length. The maximum address length is 1121 1119 * read. The actual address length is set. 1122 * @return sEOK on success.1123 * @return sENOTSOCK if the socket is not found.1124 * @return sEBADMEM if the data or fromaddr parameter is NULL.1125 * @return sNO_DATA if the datalength or addrlen parameter is zero.1126 * @return sOther error codes as defined for the NET_SOCKET_RECVFROM1120 * @return EOK on success. 1121 * @return ENOTSOCK if the socket is not found. 1122 * @return EBADMEM if the data or fromaddr parameter is NULL. 1123 * @return NO_DATA if the datalength or addrlen parameter is zero. 1124 * @return Other error codes as defined for the NET_SOCKET_RECVFROM 1127 1125 * message. 1128 1126 */ … … 1150 1148 * @param[in,out] optlen The value buffer length. The maximum length is read. 1151 1149 * The actual length is set. 1152 * @return sEOK on success.1153 * @return sENOTSOCK if the socket is not found.1154 * @return sEBADMEM if the value or optlen parameter is NULL.1155 * @return sNO_DATA if the optlen parameter is zero.1156 * @return sOther error codes as defined for the1150 * @return EOK on success. 1151 * @return ENOTSOCK if the socket is not found. 1152 * @return EBADMEM if the value or optlen parameter is NULL. 1153 * @return NO_DATA if the optlen parameter is zero. 1154 * @return Other error codes as defined for the 1157 1155 * NET_SOCKET_GETSOCKOPT message. 1158 1156 */ … … 1160 1158 getsockopt(int socket_id, int level, int optname, void *value, size_t *optlen) 1161 1159 { 1162 socket_ refsocket;1160 socket_t *socket; 1163 1161 aid_t message_id; 1164 1162 ipcarg_t result; … … 1203 1201 * @param[in] value The value to be set. 1204 1202 * @param[in] optlen The value length. 1205 * @return sEOK on success.1206 * @return sENOTSOCK if the socket is not found.1207 * @return sEBADMEM if the value parameter is NULL.1208 * @return sNO_DATA if the optlen parameter is zero.1209 * @return sOther error codes as defined for the1203 * @return EOK on success. 1204 * @return ENOTSOCK if the socket is not found. 1205 * @return EBADMEM if the value parameter is NULL. 1206 * @return NO_DATA if the optlen parameter is zero. 1207 * @return Other error codes as defined for the 1210 1208 * NET_SOCKET_SETSOCKOPT message. 1211 1209 */ -
uspace/lib/c/generic/task.c
ra93d79a r8fb1bf82 39 39 #include <errno.h> 40 40 #include <loader/loader.h> 41 #include <stdarg.h> 41 42 #include <str.h> 42 43 #include <ipc/ns.h> … … 68 69 * 69 70 * This is really just a convenience wrapper over the more complicated 70 * loader API. 71 * 72 * @param path Pathname of the binary to execute. 73 * @param argv Command-line arguments. 74 * @param err If not NULL, the error value is stored here. 75 * 76 * @return ID of the newly created task or zero on error. 77 * 78 */ 79 task_id_t task_spawn(const char *path, const char *const args[], int *err) 80 { 71 * loader API. Arguments are passed as a null-terminated array of strings. 72 * 73 * @param id If not NULL, the ID of the task is stored here on success. 74 * @param path Pathname of the binary to execute. 75 * @param argv Command-line arguments. 76 * 77 * @return Zero on success or negative error code. 78 */ 79 int task_spawnv(task_id_t *id, const char *path, const char *const args[]) 80 { 81 loader_t *ldr; 82 task_id_t task_id; 83 int rc; 84 81 85 /* Connect to a program loader. */ 82 loader_t *ldr = loader_connect(); 83 if (ldr == NULL) { 84 if (err != NULL) 85 *err = EREFUSED; 86 87 return 0; 88 } 86 ldr = loader_connect(); 87 if (ldr == NULL) 88 return EREFUSED; 89 89 90 90 /* Get task ID. */ 91 task_id_t task_id; 92 int rc = loader_get_task_id(ldr, &task_id); 91 rc = loader_get_task_id(ldr, &task_id); 93 92 if (rc != EOK) 94 93 goto error; … … 149 148 free(ldr); 150 149 151 if ( err!= NULL)152 * err = EOK;153 154 return task_id;150 if (id != NULL) 151 *id = task_id; 152 153 return EOK; 155 154 156 155 error: … … 158 157 loader_abort(ldr); 159 158 free(ldr); 160 161 if (err != NULL) 162 *err = rc; 163 164 return 0; 159 return rc; 160 } 161 162 /** Create a new task by running an executable from the filesystem. 163 * 164 * This is really just a convenience wrapper over the more complicated 165 * loader API. Arguments are passed as a null-terminated list of arguments. 166 * 167 * @param id If not NULL, the ID of the task is stored here on success. 168 * @param path Pathname of the binary to execute. 169 * @param ... Command-line arguments. 170 * 171 * @return Zero on success or negative error code. 172 */ 173 int task_spawnl(task_id_t *task_id, const char *path, ...) 174 { 175 va_list ap; 176 int rc, cnt; 177 const char *arg; 178 const char **arglist; 179 180 /* Count the number of arguments. */ 181 cnt = 0; 182 va_start(ap, path); 183 do { 184 arg = va_arg(ap, const char *); 185 cnt++; 186 } while (arg != NULL); 187 va_end(ap); 188 189 /* Allocate argument list. */ 190 arglist = malloc(cnt * sizeof(const char *)); 191 if (arglist == NULL) 192 return ENOMEM; 193 194 /* Fill in arguments. */ 195 cnt = 0; 196 va_start(ap, path); 197 do { 198 arg = va_arg(ap, const char *); 199 arglist[cnt++] = arg; 200 } while (arg != NULL); 201 va_end(ap); 202 203 /* Spawn task. */ 204 rc = task_spawnv(task_id, path, arglist); 205 206 /* Free argument list. */ 207 free(arglist); 208 return rc; 165 209 } 166 210 -
uspace/lib/c/generic/vfs/vfs.c
ra93d79a r8fb1bf82 136 136 } 137 137 138 dev _handle_t dev_handle;139 int res = devmap_device_get_handle(fqdn, &dev _handle, flags);138 devmap_handle_t devmap_handle; 139 int res = devmap_device_get_handle(fqdn, &devmap_handle, flags); 140 140 if (res != EOK) { 141 141 if (null_id != -1) … … 159 159 160 160 ipcarg_t rc_orig; 161 aid_t req = async_send_2(vfs_phone, VFS_IN_MOUNT, dev _handle, flags, NULL);161 aid_t req = async_send_2(vfs_phone, VFS_IN_MOUNT, devmap_handle, flags, NULL); 162 162 ipcarg_t rc = async_data_write_start(vfs_phone, (void *) mpa, mpa_size); 163 163 if (rc != EOK) { … … 328 328 ipc_call_t answer; 329 329 aid_t req = async_send_4(vfs_phone, VFS_IN_OPEN_NODE, node->fs_handle, 330 node->dev _handle, node->index, oflag, &answer);330 node->devmap_handle, node->index, oflag, &answer); 331 331 332 332 ipcarg_t rc; … … 797 797 if (rc == EOK) { 798 798 node->fs_handle = stat.fs_handle; 799 node->dev _handle = stat.dev_handle;799 node->devmap_handle = stat.devmap_handle; 800 800 node->index = stat.index; 801 801 } -
uspace/lib/c/include/adt/char_map.h
ra93d79a r8fb1bf82 48 48 typedef struct char_map char_map_t; 49 49 50 /** Type definition of the character string to integer map pointer.51 * @see char_map52 */53 typedef char_map_t *char_map_ref;54 55 50 /** Character string to integer map item. 56 51 * … … 69 64 int next; 70 65 /** Next character array. */ 71 char_map_ ref*items;66 char_map_t **items; 72 67 /** Consistency check magic value. */ 73 68 int magic; 74 69 }; 75 70 76 extern int char_map_initialize(char_map_ ref);77 extern void char_map_destroy(char_map_ ref);78 extern int char_map_exclude(char_map_ ref, const char *, size_t);79 extern int char_map_add(char_map_ ref, const char *, size_t, const int);80 extern int char_map_find(const char_map_ ref, const char *, size_t);81 extern int char_map_update(char_map_ ref, const char *, size_t, const int);71 extern int char_map_initialize(char_map_t *); 72 extern void char_map_destroy(char_map_t *); 73 extern int char_map_exclude(char_map_t *, const char *, size_t); 74 extern int char_map_add(char_map_t *, const char *, size_t, const int); 75 extern int char_map_find(const char_map_t *, const char *, size_t); 76 extern int char_map_update(char_map_t *, const char *, size_t, const int); 82 77 83 78 #endif -
uspace/lib/c/include/adt/dynamic_fifo.h
ra93d79a r8fb1bf82 44 44 typedef struct dyn_fifo dyn_fifo_t; 45 45 46 /** Type definition of the dynamic fifo queue pointer.47 * @see dyn_fifo48 */49 typedef dyn_fifo_t *dyn_fifo_ref;50 51 46 /** Dynamic first in first out positive integer queue. 52 47 * Possitive integer values only. … … 66 61 }; 67 62 68 extern int dyn_fifo_initialize(dyn_fifo_ ref, int);69 extern int dyn_fifo_destroy(dyn_fifo_ ref);70 extern int dyn_fifo_push(dyn_fifo_ ref, int, int);71 extern int dyn_fifo_pop(dyn_fifo_ ref);72 extern int dyn_fifo_value(dyn_fifo_ ref);63 extern int dyn_fifo_initialize(dyn_fifo_t *, int); 64 extern int dyn_fifo_destroy(dyn_fifo_t *); 65 extern int dyn_fifo_push(dyn_fifo_t *, int, int); 66 extern int dyn_fifo_pop(dyn_fifo_t *); 67 extern int dyn_fifo_value(dyn_fifo_t *); 73 68 74 69 #endif -
uspace/lib/c/include/adt/generic_char_map.h
ra93d79a r8fb1bf82 40 40 #include <unistd.h> 41 41 #include <errno.h> 42 #include <err.h>43 42 44 43 #include <adt/char_map.h> … … 56 55 \ 57 56 typedef struct name name##_t; \ 58 typedef name##_t *name##_ref; \59 57 \ 60 58 struct name { \ … … 64 62 }; \ 65 63 \ 66 int name##_add(name##_ ref, const char *, const size_t, type *); \67 int name##_count(name##_ ref); \68 void name##_destroy(name##_ ref); \69 void name##_exclude(name##_ ref, const char *, const size_t); \70 type *name##_find(name##_ ref, const char *, const size_t); \71 int name##_initialize(name##_ ref); \72 int name##_is_valid(name##_ ref);64 int name##_add(name##_t *, const char *, const size_t, type *); \ 65 int name##_count(name##_t *); \ 66 void name##_destroy(name##_t *); \ 67 void name##_exclude(name##_t *, const char *, const size_t); \ 68 type *name##_find(name##_t *, const char *, const size_t); \ 69 int name##_initialize(name##_t *); \ 70 int name##_is_valid(name##_t *); 73 71 74 72 /** Character string to generic type map implementation. … … 82 80 GENERIC_FIELD_IMPLEMENT(name##_items, type) \ 83 81 \ 84 int name##_add(name##_ refmap, const char *name, const size_t length, \82 int name##_add(name##_t *map, const char *name, const size_t length, \ 85 83 type *value) \ 86 84 { \ 87 ERROR_DECLARE; \85 int rc; \ 88 86 int index; \ 89 87 if (!name##_is_valid(map)) \ … … 92 90 if (index < 0) \ 93 91 return index; \ 94 if (ERROR_OCCURRED(char_map_add(&map->names, name, length,\95 index))) { \92 rc = char_map_add(&map->names, name, length, index); \ 93 if (rc != EOK) { \ 96 94 name##_items_exclude_index(&map->values, index); \ 97 return ERROR_CODE; \95 return rc; \ 98 96 } \ 99 97 return EOK; \ 100 98 } \ 101 99 \ 102 int name##_count(name##_ refmap) \100 int name##_count(name##_t *map) \ 103 101 { \ 104 102 return name##_is_valid(map) ? \ … … 106 104 } \ 107 105 \ 108 void name##_destroy(name##_ refmap) \106 void name##_destroy(name##_t *map) \ 109 107 { \ 110 108 if (name##_is_valid(map)) { \ … … 114 112 } \ 115 113 \ 116 void name##_exclude(name##_ refmap, const char *name, \114 void name##_exclude(name##_t *map, const char *name, \ 117 115 const size_t length) \ 118 116 { \ … … 126 124 } \ 127 125 \ 128 type *name##_find(name##_ refmap, const char *name, \126 type *name##_find(name##_t *map, const char *name, \ 129 127 const size_t length) \ 130 128 { \ … … 139 137 } \ 140 138 \ 141 int name##_initialize(name##_ refmap) \139 int name##_initialize(name##_t *map) \ 142 140 { \ 143 ERROR_DECLARE; \141 int rc; \ 144 142 if (!map) \ 145 143 return EINVAL; \ 146 ERROR_PROPAGATE(char_map_initialize(&map->names)); \ 147 if (ERROR_OCCURRED(name##_items_initialize(&map->values))) { \ 144 rc = char_map_initialize(&map->names); \ 145 if (rc != EOK) \ 146 return rc; \ 147 rc = name##_items_initialize(&map->values); \ 148 if (rc != EOK) { \ 148 149 char_map_destroy(&map->names); \ 149 return ERROR_CODE; \150 return rc; \ 150 151 } \ 151 152 map->magic = GENERIC_CHAR_MAP_MAGIC_VALUE; \ … … 153 154 } \ 154 155 \ 155 int name##_is_valid(name##_ refmap) \156 int name##_is_valid(name##_t *map) \ 156 157 { \ 157 158 return map && (map->magic == GENERIC_CHAR_MAP_MAGIC_VALUE); \ -
uspace/lib/c/include/adt/generic_field.h
ra93d79a r8fb1bf82 53 53 #define GENERIC_FIELD_DECLARE(name, type) \ 54 54 typedef struct name name##_t; \ 55 typedef name##_t *name##_ref; \56 55 \ 57 56 struct name { \ … … 62 61 }; \ 63 62 \ 64 int name##_add(name##_ ref, type *); \65 int name##_count(name##_ ref); \66 void name##_destroy(name##_ ref); \67 void name##_exclude_index(name##_ ref, int); \68 type **name##_get_field(name##_ ref); \69 type *name##_get_index(name##_ ref, int); \70 int name##_initialize(name##_ ref); \71 int name##_is_valid(name##_ ref);63 int name##_add(name##_t *, type *); \ 64 int name##_count(name##_t *); \ 65 void name##_destroy(name##_t *); \ 66 void name##_exclude_index(name##_t *, int); \ 67 type **name##_get_field(name##_t *); \ 68 type *name##_get_index(name##_t *, int); \ 69 int name##_initialize(name##_t *); \ 70 int name##_is_valid(name##_t *); 72 71 73 72 /** Generic type field implementation. … … 79 78 */ 80 79 #define GENERIC_FIELD_IMPLEMENT(name, type) \ 81 int name##_add(name##_ reffield, type *value) \80 int name##_add(name##_t *field, type *value) \ 82 81 { \ 83 82 if (name##_is_valid(field)) { \ … … 99 98 } \ 100 99 \ 101 int name##_count(name##_ reffield) \100 int name##_count(name##_t *field) \ 102 101 { \ 103 102 return name##_is_valid(field) ? field->next : -1; \ 104 103 } \ 105 104 \ 106 void name##_destroy(name##_ reffield) \105 void name##_destroy(name##_t *field) \ 107 106 { \ 108 107 if (name##_is_valid(field)) { \ … … 117 116 } \ 118 117 \ 119 void name##_exclude_index(name##_ reffield, int index) \118 void name##_exclude_index(name##_t *field, int index) \ 120 119 { \ 121 120 if (name##_is_valid(field) && (index >= 0) && \ … … 126 125 } \ 127 126 \ 128 type *name##_get_index(name##_ reffield, int index) \127 type *name##_get_index(name##_t *field, int index) \ 129 128 { \ 130 129 if (name##_is_valid(field) && (index >= 0) && \ … … 134 133 } \ 135 134 \ 136 type **name##_get_field(name##_ reffield) \135 type **name##_get_field(name##_t *field) \ 137 136 { \ 138 137 return name##_is_valid(field) ? field->items : NULL; \ 139 138 } \ 140 139 \ 141 int name##_initialize(name##_ reffield) \140 int name##_initialize(name##_t *field) \ 142 141 { \ 143 142 if (!field) \ … … 153 152 } \ 154 153 \ 155 int name##_is_valid(name##_ reffield) \154 int name##_is_valid(name##_t *field) \ 156 155 { \ 157 156 return field && (field->magic == GENERIC_FIELD_MAGIC_VALUE); \ -
uspace/lib/c/include/adt/int_map.h
ra93d79a r8fb1bf82 56 56 #define INT_MAP_DECLARE(name, type) \ 57 57 typedef struct name name##_t; \ 58 typedef name##_t *name##_ref; \59 58 typedef struct name##_item name##_item_t; \ 60 typedef name##_item_t *name##_item_ref; \61 59 \ 62 60 struct name##_item { \ … … 69 67 int size; \ 70 68 int next; \ 71 name##_item_ refitems; \69 name##_item_t *items; \ 72 70 int magic; \ 73 71 }; \ 74 72 \ 75 int name##_add(name##_ ref, int, type *); \76 void name##_clear(name##_ ref); \77 int name##_count(name##_ ref); \78 void name##_destroy(name##_ ref); \79 void name##_exclude(name##_ ref, int); \80 void name##_exclude_index(name##_ ref, int); \81 type *name##_find(name##_ ref, int); \82 int name##_update(name##_ ref, int, int); \83 type *name##_get_index(name##_ ref, int); \84 int name##_initialize(name##_ ref); \85 int name##_is_valid(name##_ ref); \86 void name##_item_destroy(name##_item_ ref); \87 int name##_item_is_valid(name##_item_ ref);73 int name##_add(name##_t *, int, type *); \ 74 void name##_clear(name##_t *); \ 75 int name##_count(name##_t *); \ 76 void name##_destroy(name##_t *); \ 77 void name##_exclude(name##_t *, int); \ 78 void name##_exclude_index(name##_t *, int); \ 79 type *name##_find(name##_t *, int); \ 80 int name##_update(name##_t *, int, int); \ 81 type *name##_get_index(name##_t *, int); \ 82 int name##_initialize(name##_t *); \ 83 int name##_is_valid(name##_t *); \ 84 void name##_item_destroy(name##_item_t *); \ 85 int name##_item_is_valid(name##_item_t *); 88 86 89 87 /** Integer to generic type map implementation. … … 95 93 */ 96 94 #define INT_MAP_IMPLEMENT(name, type) \ 97 int name##_add(name##_ refmap, int key, type *value) \95 int name##_add(name##_t *map, int key, type *value) \ 98 96 { \ 99 97 if (name##_is_valid(map)) { \ 100 98 if (map->next == (map->size - 1)) { \ 101 name##_item_ reftmp; \102 tmp = (name##_item_ ref) realloc(map->items, \99 name##_item_t *tmp; \ 100 tmp = (name##_item_t *) realloc(map->items, \ 103 101 sizeof(name##_item_t) * 2 * map->size); \ 104 102 if (!tmp) \ … … 117 115 } \ 118 116 \ 119 void name##_clear(name##_ refmap) \117 void name##_clear(name##_t *map) \ 120 118 { \ 121 119 if (name##_is_valid(map)) { \ … … 132 130 } \ 133 131 \ 134 int name##_count(name##_ refmap) \132 int name##_count(name##_t *map) \ 135 133 { \ 136 134 return name##_is_valid(map) ? map->next : -1; \ 137 135 } \ 138 136 \ 139 void name##_destroy(name##_ refmap) \137 void name##_destroy(name##_t *map) \ 140 138 { \ 141 139 if (name##_is_valid(map)) { \ … … 152 150 } \ 153 151 \ 154 void name##_exclude(name##_ refmap, int key) \152 void name##_exclude(name##_t *map, int key) \ 155 153 { \ 156 154 if (name##_is_valid(map)) { \ … … 166 164 } \ 167 165 \ 168 void name##_exclude_index(name##_ refmap, int index) \166 void name##_exclude_index(name##_t *map, int index) \ 169 167 { \ 170 168 if (name##_is_valid(map) && (index >= 0) && \ … … 175 173 } \ 176 174 \ 177 type *name##_find(name##_ refmap, int key) \175 type *name##_find(name##_t *map, int key) \ 178 176 { \ 179 177 if (name##_is_valid(map)) { \ … … 189 187 } \ 190 188 \ 191 int name##_update(name##_ refmap, int key, int new_key) \189 int name##_update(name##_t *map, int key, int new_key) \ 192 190 { \ 193 191 if (name##_is_valid(map)) { \ … … 208 206 } \ 209 207 \ 210 type *name##_get_index(name##_ refmap, int index) \208 type *name##_get_index(name##_t *map, int index) \ 211 209 { \ 212 210 if (name##_is_valid(map) && (index >= 0) && \ … … 218 216 } \ 219 217 \ 220 int name##_initialize(name##_ refmap) \218 int name##_initialize(name##_t *map) \ 221 219 { \ 222 220 if (!map) \ … … 224 222 map->size = 2; \ 225 223 map->next = 0; \ 226 map->items = (name##_item_ ref) malloc(sizeof(name##_item_t) * \224 map->items = (name##_item_t *) malloc(sizeof(name##_item_t) * \ 227 225 map->size); \ 228 226 if (!map->items) \ … … 233 231 } \ 234 232 \ 235 int name##_is_valid(name##_ refmap) \233 int name##_is_valid(name##_t *map) \ 236 234 { \ 237 235 return map && (map->magic == INT_MAP_MAGIC_VALUE); \ 238 236 } \ 239 237 \ 240 void name##_item_destroy(name##_item_ refitem) \238 void name##_item_destroy(name##_item_t *item) \ 241 239 { \ 242 240 if (name##_item_is_valid(item)) { \ … … 249 247 } \ 250 248 \ 251 int name##_item_is_valid(name##_item_ refitem) \249 int name##_item_is_valid(name##_item_t *item) \ 252 250 { \ 253 251 return item && (item->magic == INT_MAP_ITEM_MAGIC_VALUE); \ -
uspace/lib/c/include/adt/measured_strings.h
ra93d79a r8fb1bf82 43 43 44 44 /** Type definition of the character string with measured length. 45 * 45 * @see measured_string 46 46 */ 47 47 typedef struct measured_string measured_string_t; 48 49 /** Type definition of the character string with measured length pointer.50 * @see measured_string51 */52 typedef measured_string_t *measured_string_ref;53 48 54 49 /** Character string with measured length. … … 59 54 struct measured_string { 60 55 /** Character string data. */ 61 char * 56 char *value; 62 57 /** Character string length. */ 63 58 size_t length; 64 59 }; 65 60 66 extern measured_string_ refmeasured_string_create_bulk(const char *, size_t);67 extern measured_string_ ref measured_string_copy(measured_string_ref);68 extern int measured_strings_receive(measured_string_ ref*, char **, size_t);69 extern int measured_strings_reply(const measured_string_ ref, size_t);70 extern int measured_strings_return(int, measured_string_ ref*, char **, size_t);71 extern int measured_strings_send(int, const measured_string_ ref, size_t);61 extern measured_string_t *measured_string_create_bulk(const char *, size_t); 62 extern measured_string_t *measured_string_copy(measured_string_t *); 63 extern int measured_strings_receive(measured_string_t **, char **, size_t); 64 extern int measured_strings_reply(const measured_string_t *, size_t); 65 extern int measured_strings_return(int, measured_string_t **, char **, size_t); 66 extern int measured_strings_send(int, const measured_string_t *, size_t); 72 67 73 68 #endif -
uspace/lib/c/include/ddi.h
ra93d79a r8fb1bf82 42 42 extern int iospace_enable(task_id_t, void *, unsigned long); 43 43 extern int pio_enable(void *, size_t, void **); 44 extern int interrupt_enable(int); 45 extern int interrupt_disable(int); 44 46 45 47 #endif -
uspace/lib/c/include/device/char.h
ra93d79a r8fb1bf82 1 1 /* 2 * Copyright (c) 20 09 Lukas Mejdrech2 * Copyright (c) 2010 Lenka Trochtova 3 3 * All rights reserved. 4 4 * … … 26 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 27 */ 28 29 /** @addtogroup packet 30 * 28 29 /** @addtogroup libc 30 * @{ 31 31 */ 32 33 32 /** @file 34 33 */ 34 35 #ifndef LIBC_DEVICE_HW_RES_H_ 36 #define LIBC_DEVICE_HW_RES_H_ 35 37 36 #ifndef __NET_PACKET_LOCAL_H__ 37 #define __NET_PACKET_LOCAL_H__ 38 typedef enum { 39 CHAR_READ_DEV = 0, 40 CHAR_WRITE_DEV 41 } hw_res_funcs_t; 38 42 39 #include <net/packet.h> 40 41 /** @name Packet local interface 42 */ 43 /*@{*/ 44 45 extern int packet_translate_local(int, packet_ref, packet_id_t); 46 extern packet_t packet_get_4_local(int, size_t, size_t, size_t, size_t); 47 extern packet_t packet_get_1_local(int, size_t); 48 extern void pq_release_local(int, packet_id_t); 49 50 /*@}*/ 43 int read_dev(int dev_phone, void *buf, size_t len); 44 int write_dev(int dev_phone, void *buf, size_t len); 51 45 52 46 #endif -
uspace/lib/c/include/devman.h
ra93d79a r8fb1bf82 1 1 /* 2 * Copyright (c) 2009 Lukas Mejdrech 2 * Copyright (c) 2009 Jiri Svoboda 3 * Copyright (c) 2010 Lenka Trochtova 3 4 * All rights reserved. 4 5 * … … 27 28 */ 28 29 29 /** @addtogroup ip30 /** @addtogroup libc 30 31 * @{ 31 32 */ 33 /** @file 34 */ 32 35 33 #ifndef NET_IP_LOCAL_H_34 #define NET_IP_LOCAL_H_36 #ifndef LIBC_DEVMAN_H_ 37 #define LIBC_DEVMAN_H_ 35 38 39 #include <ipc/devman.h> 36 40 #include <async.h> 37 #include < ipc/services.h>41 #include <bool.h> 38 42 39 #include <net/ip_codes.h>40 #include <net/inet.h>41 #include <net/in.h>42 43 43 extern int ip_received_error_msg_local(int, device_id_t, packet_t, services_t, 44 services_t); 45 extern int ip_set_gateway_req_local(int, device_id_t, in_addr_t); 46 extern int ip_packet_size_req_local(int, device_id_t, packet_dimension_ref); 47 extern int ip_received_error_msg_local(int, device_id_t, packet_t, services_t, 48 services_t); 49 extern int ip_device_req_local(int, device_id_t, services_t); 50 extern int ip_add_route_req_local(int, device_id_t, in_addr_t, in_addr_t, 51 in_addr_t); 52 extern int ip_send_msg_local(int, device_id_t, packet_t, services_t, 53 services_t); 54 extern int ip_get_route_req_local(int, ip_protocol_t, const struct sockaddr *, 55 socklen_t, device_id_t *, void **, size_t *); 44 extern int devman_get_phone(devman_interface_t, unsigned int); 45 extern void devman_hangup_phone(devman_interface_t); 46 47 extern int devman_driver_register(const char *, async_client_conn_t); 48 extern int devman_child_device_register(const char *, match_id_list_t *, 49 devman_handle_t, devman_handle_t *); 50 51 extern int devman_device_connect(devman_handle_t, unsigned int); 52 extern int devman_parent_device_connect(devman_handle_t, unsigned int); 53 54 extern int devman_device_get_handle(const char *, devman_handle_t *, 55 unsigned int); 56 57 extern int devman_add_device_to_class(devman_handle_t, const char *); 56 58 57 59 #endif -
uspace/lib/c/include/devmap.h
ra93d79a r8fb1bf82 44 44 45 45 extern int devmap_driver_register(const char *, async_client_conn_t); 46 extern int devmap_device_register(const char *, dev _handle_t *);46 extern int devmap_device_register(const char *, devmap_handle_t *); 47 47 48 extern int devmap_device_get_handle(const char *, dev _handle_t *, unsigned int);49 extern int devmap_namespace_get_handle(const char *, dev _handle_t *, unsigned int);50 extern devmap_handle_type_t devmap_handle_probe(dev _handle_t);48 extern int devmap_device_get_handle(const char *, devmap_handle_t *, unsigned int); 49 extern int devmap_namespace_get_handle(const char *, devmap_handle_t *, unsigned int); 50 extern devmap_handle_type_t devmap_handle_probe(devmap_handle_t); 51 51 52 extern int devmap_device_connect(dev _handle_t, unsigned int);52 extern int devmap_device_connect(devmap_handle_t, unsigned int); 53 53 54 54 extern int devmap_null_create(void); … … 56 56 57 57 extern size_t devmap_count_namespaces(void); 58 extern size_t devmap_count_devices(dev _handle_t);58 extern size_t devmap_count_devices(devmap_handle_t); 59 59 60 60 extern size_t devmap_get_namespaces(dev_desc_t **); 61 extern size_t devmap_get_devices(dev _handle_t, dev_desc_t **);61 extern size_t devmap_get_devices(devmap_handle_t, dev_desc_t **); 62 62 63 63 #endif -
uspace/lib/c/include/err.h
ra93d79a r8fb1bf82 37 37 38 38 #include <stdio.h> 39 #include <errno.h>40 41 #ifdef CONFIG_DEBUG42 #include <str_error.h>43 #endif44 39 45 40 #define errx(status, fmt, ...) { \ … … 48 43 } 49 44 50 51 /** An actual stored error code. */52 #define ERROR_CODE error_check_return_value53 54 /** An error processing routines declaration.55 *56 * This has to be declared in the block where the error processing57 * is desired.58 */59 #define ERROR_DECLARE int ERROR_CODE60 61 /** Store the value as an error code and checks if an error occurred.62 *63 * @param[in] value The value to be checked. May be a function call.64 * @return False if the value indicates success (EOK).65 * @return True otherwise.66 */67 #ifdef CONFIG_DEBUG68 69 #define ERROR_OCCURRED(value) \70 (((ERROR_CODE = (value)) != EOK) && \71 ({ \72 fprintf(stderr, "libsocket error at %s:%d (%s)\n", \73 __FILE__, __LINE__, str_error(ERROR_CODE)); \74 1; \75 }))76 77 #else78 79 #define ERROR_OCCURRED(value) ((ERROR_CODE = (value)) != EOK)80 81 #endif82 83 #define ERROR_NONE(value) !ERROR_OCCURRED((value))84 85 /** Error propagation86 *87 * Check if an error occurred and immediately exit the actual88 * function returning the error code.89 *90 * @param[in] value The value to be checked. May be a function call.91 *92 */93 94 #define ERROR_PROPAGATE(value) \95 if (ERROR_OCCURRED(value)) \96 return ERROR_CODE97 98 45 #endif 99 46 100 47 /** @} 101 48 */ 49 -
uspace/lib/c/include/fibril.h
ra93d79a r8fb1bf82 48 48 #define FIBRIL_WRITER 2 49 49 50 struct fibril; 51 52 typedef struct { 53 struct fibril *owned_by; 54 } fibril_owner_info_t; 55 50 56 typedef enum { 51 57 FIBRIL_PREEMPT, … … 68 74 int retval; 69 75 int flags; 76 77 fibril_owner_info_t *waits_for; 70 78 } fibril_t; 71 79 -
uspace/lib/c/include/fibril_synch.h
ra93d79a r8fb1bf82 43 43 44 44 typedef struct { 45 fibril_owner_info_t oi; /* Keep this the first thing. */ 45 46 int counter; 46 47 link_t waiters; … … 49 50 #define FIBRIL_MUTEX_INITIALIZER(name) \ 50 51 { \ 52 .oi = { \ 53 .owned_by = NULL \ 54 }, \ 51 55 .counter = 1, \ 52 56 .waiters = { \ … … 60 64 61 65 typedef struct { 66 fibril_owner_info_t oi; /* Keep this the first thing. */ 62 67 unsigned writers; 63 68 unsigned readers; … … 67 72 #define FIBRIL_RWLOCK_INITIALIZER(name) \ 68 73 { \ 74 .oi = { \ 75 .owned_by = NULL \ 76 }, \ 69 77 .readers = 0, \ 70 78 .writers = 0, \ -
uspace/lib/c/include/ipc/devmap.h
ra93d79a r8fb1bf82 40 40 #define DEVMAP_NAME_MAXLEN 255 41 41 42 typedef ipcarg_t dev _handle_t;42 typedef ipcarg_t devmap_handle_t; 43 43 44 44 typedef enum { … … 81 81 82 82 typedef struct { 83 dev _handle_t handle;83 devmap_handle_t handle; 84 84 char name[DEVMAP_NAME_MAXLEN + 1]; 85 85 } dev_desc_t; -
uspace/lib/c/include/ipc/services.h
ra93d79a r8fb1bf82 39 39 40 40 typedef enum { 41 SERVICE_LOAD = 1, 41 SERVICE_NONE = 0, 42 SERVICE_LOAD, 42 43 SERVICE_PCI, 43 44 SERVICE_VIDEO, … … 45 46 SERVICE_VFS, 46 47 SERVICE_DEVMAP, 48 SERVICE_DEVMAN, 47 49 SERVICE_FHC, 48 50 SERVICE_OBIO, -
uspace/lib/c/include/net/device.h
ra93d79a r8fb1bf82 59 59 */ 60 60 typedef struct device_stats device_stats_t; 61 62 /** Type definition of the device usage statistics pointer.63 * @see device_stats64 */65 typedef device_stats_t *device_stats_ref;66 61 67 62 /** Device state. */ -
uspace/lib/c/include/net/icmp_codes.h
ra93d79a r8fb1bf82 42 42 #define LIBC_ICMP_CODES_H_ 43 43 44 #include <sys/types.h> 45 44 46 /** ICMP type type definition. */ 45 47 typedef uint8_t icmp_type_t; -
uspace/lib/c/include/net/modules.h
ra93d79a r8fb1bf82 69 69 * 70 70 * @param[in] need The needed module service. 71 * @return sThe phone of the needed service.71 * @return The phone of the needed service. 72 72 */ 73 73 typedef int connect_module_t(services_t need); -
uspace/lib/c/include/net/packet.h
ra93d79a r8fb1bf82 46 46 * @see packet 47 47 */ 48 typedef struct packet * packet_t; 49 50 /** Type definition of the packet pointer. 51 * @see packet 52 */ 53 typedef packet_t * packet_ref; 48 typedef struct packet packet_t; 54 49 55 50 /** Type definition of the packet dimension. … … 57 52 */ 58 53 typedef struct packet_dimension packet_dimension_t; 59 60 /** Type definition of the packet dimension pointer.61 * @see packet_dimension62 */63 typedef packet_dimension_t * packet_dimension_ref;64 54 65 55 /** Packet dimension. */ … … 79 69 /*@{*/ 80 70 81 extern packet_t pm_find(packet_id_t);82 extern int pm_add(packet_t );71 extern packet_t *pm_find(packet_id_t); 72 extern int pm_add(packet_t *); 83 73 extern int pm_init(void); 84 74 extern void pm_destroy(void); 85 75 86 extern int pq_add(packet_t * , packet_t, size_t, size_t);87 extern packet_t pq_find(packet_t, size_t);88 extern int pq_insert_after(packet_t , packet_t);89 extern packet_t pq_detach(packet_t);90 extern int pq_set_order(packet_t , size_t, size_t);91 extern int pq_get_order(packet_t , size_t *, size_t *);92 extern void pq_destroy(packet_t , void (*)(packet_t));93 extern packet_t pq_next(packet_t);94 extern packet_t pq_previous(packet_t);76 extern int pq_add(packet_t **, packet_t *, size_t, size_t); 77 extern packet_t *pq_find(packet_t *, size_t); 78 extern int pq_insert_after(packet_t *, packet_t *); 79 extern packet_t *pq_detach(packet_t *); 80 extern int pq_set_order(packet_t *, size_t, size_t); 81 extern int pq_get_order(packet_t *, size_t *, size_t *); 82 extern void pq_destroy(packet_t *, void (*)(packet_t *)); 83 extern packet_t *pq_next(packet_t *); 84 extern packet_t *pq_previous(packet_t *); 95 85 96 86 /*@}*/ -
uspace/lib/c/include/net/packet_header.h
ra93d79a r8fb1bf82 124 124 /** Returns whether the packet is valid. 125 125 * @param[in] packet The packet to be checked. 126 * @return sTrue if the packet is not NULL and the magic value is126 * @return True if the packet is not NULL and the magic value is 127 127 * correct. 128 * @return sFalse otherwise.128 * @return False otherwise. 129 129 */ 130 static inline int packet_is_valid(const packet_t packet)130 static inline int packet_is_valid(const packet_t *packet) 131 131 { 132 132 return packet && (packet->magic_value == PACKET_MAGIC_VALUE); -
uspace/lib/c/include/stdio.h
ra93d79a r8fb1bf82 46 46 #define BUFSIZ 4096 47 47 48 #define DEBUG(fmt, ...) se\48 #define DEBUG(fmt, ...) \ 49 49 { \ 50 50 char _buf[256]; \ -
uspace/lib/c/include/sys/stat.h
ra93d79a r8fb1bf82 43 43 struct stat { 44 44 fs_handle_t fs_handle; 45 dev _handle_t dev_handle;45 devmap_handle_t devmap_handle; 46 46 fs_index_t index; 47 47 unsigned int lnkcnt; … … 49 49 bool is_directory; 50 50 aoff64_t size; 51 dev _handle_t device;51 devmap_handle_t device; 52 52 }; 53 53 -
uspace/lib/c/include/task.h
ra93d79a r8fb1bf82 48 48 extern int task_set_name(const char *); 49 49 extern task_id_t task_spawn(const char *, const char *const[], int *); 50 extern int task_spawnv(task_id_t *, const char *path, const char *const []); 51 extern int task_spawnl(task_id_t *, const char *path, ...); 52 50 53 extern int task_wait(task_id_t id, task_exit_t *, int *); 51 54 extern int task_retval(int); -
uspace/lib/c/include/unistd.h
ra93d79a r8fb1bf82 41 41 42 42 #ifndef NULL 43 #define NULL 043 #define NULL ((void *) 0) 44 44 #endif 45 45 -
uspace/lib/c/include/vfs/vfs.h
ra93d79a r8fb1bf82 47 47 typedef struct { 48 48 fs_handle_t fs_handle; 49 dev _handle_t dev_handle;49 devmap_handle_t devmap_handle; 50 50 fs_index_t index; 51 51 } fdi_node_t;
Note:
See TracChangeset
for help on using the changeset viewer.