Changeset e4f8c77 in mainline for uspace/lib/c
- Timestamp:
- 2011-07-13T22:39:18Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- e6910c8
- Parents:
- 5974661 (diff), 8ecef91 (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:
-
- 21 added
- 2 deleted
- 48 edited
- 5 moved
-
Makefile (modified) (1 diff)
-
arch/mips32/Makefile.common (modified) (1 diff)
-
arch/mips32/include/atomic.h (modified) (1 diff)
-
arch/mips32/include/fibril.h (modified) (1 diff)
-
arch/mips32/include/thread.h (modified) (1 diff)
-
arch/mips32/include/tls.h (modified) (1 diff)
-
arch/mips32/include/types.h (modified) (1 diff)
-
arch/mips32/src/syscall.c (modified) (2 diffs)
-
arch/mips32/src/tls.c (modified) (1 diff)
-
arch/mips32eb/Makefile.common (modified) (1 diff)
-
arch/mips64/Makefile.common (moved) (moved from uspace/srv/hw/irc/fhc/Makefile ) (2 diffs)
-
arch/mips64/Makefile.inc (moved) (moved from uspace/srv/hid/char_mouse/Makefile ) (2 diffs)
-
arch/mips64/_link.ld.in (added)
-
arch/mips64/include/atomic.h (added)
-
arch/mips64/include/config.h (added)
-
arch/mips64/include/ddi.h (added)
-
arch/mips64/include/faddr.h (added)
-
arch/mips64/include/fibril.h (added)
-
arch/mips64/include/inttypes.h (added)
-
arch/mips64/include/istate.h (moved) (moved from uspace/srv/hid/adb_mouse/adb_dev.h ) (2 diffs)
-
arch/mips64/include/syscall.h (added)
-
arch/mips64/include/thread.h (added)
-
arch/mips64/include/tls.h (added)
-
arch/mips64/include/types.h (added)
-
arch/mips64/src/entry.s (added)
-
arch/mips64/src/entryjmp.s (added)
-
arch/mips64/src/fibril.S (added)
-
arch/mips64/src/stacktrace.c (moved) (moved from uspace/lib/c/include/devman_obsolete.h ) (3 diffs)
-
arch/mips64/src/stacktrace_asm.S (added)
-
arch/mips64/src/syscall.c (added)
-
arch/mips64/src/thread_entry.s (added)
-
arch/mips64/src/tls.c (added)
-
generic/adt/hash_table.c (modified) (5 diffs)
-
generic/adt/list.c (modified) (3 diffs)
-
generic/adt/measured_strings.c (modified) (12 diffs)
-
generic/adt/prodcons.c (modified) (1 diff)
-
generic/async.c (modified) (27 diffs)
-
generic/async_obsolete.c (modified) (3 diffs)
-
generic/devman.c (modified) (4 diffs)
-
generic/devman_obsolete.c (deleted)
-
generic/devmap.c (modified) (1 diff)
-
generic/devmap_obsolete.c (deleted)
-
generic/fibril.c (modified) (3 diffs)
-
generic/fibril_synch.c (modified) (3 diffs)
-
generic/io/console.c (modified) (1 diff)
-
generic/io/io.c (modified) (1 diff)
-
generic/ipc.c (modified) (2 diffs)
-
generic/net/icmp_api.c (modified) (4 diffs)
-
generic/net/icmp_common.c (modified) (1 diff)
-
generic/net/modules.c (modified) (5 diffs)
-
generic/net/socket_client.c (modified) (33 diffs)
-
generic/ns.c (modified) (1 diff)
-
generic/str.c (modified) (1 diff)
-
generic/task.c (modified) (2 diffs)
-
include/adt/hash_table.h (modified) (1 diff)
-
include/adt/list.h (modified) (13 diffs)
-
include/adt/measured_strings.h (modified) (2 diffs)
-
include/adt/prodcons.h (modified) (1 diff)
-
include/async.h (modified) (5 diffs)
-
include/async_obsolete.h (modified) (2 diffs)
-
include/bitops.h (modified) (1 diff)
-
include/fibril_synch.h (modified) (6 diffs)
-
include/fourcc.h (added)
-
include/ipc/clipboard.h (modified) (1 diff)
-
include/ipc/console.h (modified) (1 diff)
-
include/ipc/devman.h (modified) (3 diffs)
-
include/ipc/input.h (added)
-
include/ipc/kbdev.h (added)
-
include/ipc/mouseev.h (moved) (moved from uspace/lib/c/include/ipc/kbd.h ) (3 diffs)
-
include/ipc/net.h (modified) (1 diff)
-
include/ipc/services.h (modified) (1 diff)
-
include/net/icmp_api.h (modified) (2 diffs)
-
include/net/icmp_common.h (modified) (1 diff)
-
include/net/modules.h (modified) (1 diff)
-
include/str.h (modified) (2 diffs)
-
include/task.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/Makefile
r5974661 re4f8c77 68 68 generic/clipboard.c \ 69 69 generic/devmap.c \ 70 generic/devmap_obsolete.c \71 70 generic/devman.c \ 72 generic/devman_obsolete.c \73 71 generic/device/hw_res.c \ 74 72 generic/device/char_dev.c \ -
uspace/lib/c/arch/mips32/Makefile.common
r5974661 re4f8c77 27 27 # 28 28 29 GCC_CFLAGS += -mips3 29 GCC_CFLAGS += -mips3 -mabi=32 30 30 31 31 ENDIANESS = LE -
uspace/lib/c/arch/mips32/include/atomic.h
r5974661 re4f8c77 31 31 */ 32 32 /** @file 33 * @ingroup libcmips32 eb33 * @ingroup libcmips32 34 34 */ 35 35 -
uspace/lib/c/arch/mips32/include/fibril.h
r5974661 re4f8c77 27 27 */ 28 28 29 /** @addtogroup libcmips32 29 /** @addtogroup libcmips32 30 30 * @{ 31 31 */ 32 32 /** @file 33 * @ingroup libcmips32 eb33 * @ingroup libcmips32 34 34 */ 35 35 -
uspace/lib/c/arch/mips32/include/thread.h
r5974661 re4f8c77 27 27 */ 28 28 29 /** @addtogroup libcmips32 29 /** @addtogroup libcmips32 30 30 * @{ 31 31 */ 32 32 /** @file 33 * @ingroup libcmips32 eb33 * @ingroup libcmips32 34 34 */ 35 35 -
uspace/lib/c/arch/mips32/include/tls.h
r5974661 re4f8c77 27 27 */ 28 28 29 /** @addtogroup libcmips32 29 /** @addtogroup libcmips32 30 30 * @{ 31 31 */ 32 32 /** @file 33 * @ingroup libcmips32 eb33 * @ingroup libcmips32 34 34 */ 35 35 -
uspace/lib/c/arch/mips32/include/types.h
r5974661 re4f8c77 31 31 */ 32 32 /** @file 33 * @ingroup libcmips32 eb33 * @ingroup libcmips32 34 34 */ 35 35 -
uspace/lib/c/arch/mips32/src/syscall.c
r5974661 re4f8c77 27 27 */ 28 28 29 /** @addtogroup libcmips3229 /** @addtogroup libcmips32 30 30 * @{ 31 31 */ 32 32 /** @file 33 * @ingroup libcmips32 eb33 * @ingroup libcmips32 34 34 */ 35 35 … … 64 64 } 65 65 66 /** @}66 /** @} 67 67 */ 68 -
uspace/lib/c/arch/mips32/src/tls.c
r5974661 re4f8c77 27 27 */ 28 28 29 /** @addtogroup libcmips32 29 /** @addtogroup libcmips32 30 30 * @{ 31 31 */ 32 32 /** @file 33 * @ingroup libcmips32 eb33 * @ingroup libcmips32 34 34 */ 35 35 -
uspace/lib/c/arch/mips32eb/Makefile.common
r5974661 re4f8c77 27 27 # 28 28 29 GCC_CFLAGS += -mips3 29 GCC_CFLAGS += -mips3 -mabi=32 30 30 31 31 ENDIANESS = BE -
uspace/lib/c/arch/mips64/Makefile.common
r5974661 re4f8c77 1 1 # 2 2 # Copyright (c) 2005 Martin Decky 3 # Copyright (c) 2007 Jakub Jermar4 3 # All rights reserved. 5 4 # … … 28 27 # 29 28 30 USPACE_PREFIX = ../../../.. 31 BINARY = fhc 29 GCC_CFLAGS += -mips3 -mabi=64 30 AFLAGS = -64 32 31 33 SOURCES = \ 34 fhc.c 32 ENDIANESS = LE 35 33 36 include $(USPACE_PREFIX)/Makefile.common 34 BFD_ARCH = mips:4000 35 BFD_NAME = elf64-tradlittlemips -
uspace/lib/c/arch/mips64/Makefile.inc
r5974661 re4f8c77 1 1 # 2 2 # Copyright (c) 2005 Martin Decky 3 # Copyright (c) 2007 Jakub Jermar4 3 # All rights reserved. 5 4 # … … 28 27 # 29 28 30 USPACE_PREFIX = ../../.. 31 EXTRA_CFLAGS = -Iinclude 32 BINARY = char_ms 29 ARCH_SOURCES = \ 30 arch/$(UARCH)/src/entry.s \ 31 arch/$(UARCH)/src/entryjmp.s \ 32 arch/$(UARCH)/src/thread_entry.s \ 33 arch/$(UARCH)/src/syscall.c \ 34 arch/$(UARCH)/src/fibril.S \ 35 arch/$(UARCH)/src/tls.c \ 36 arch/$(UARCH)/src/stacktrace.c \ 37 arch/$(UARCH)/src/stacktrace_asm.S 33 38 34 SOURCES = \ 35 proto/ps2.c \ 36 char_mouse.c \ 37 chardev.c 38 39 include $(USPACE_PREFIX)/Makefile.common 39 .PRECIOUS: arch/$(UARCH)/src/entry.o -
uspace/lib/c/arch/mips64/include/istate.h
r5974661 re4f8c77 27 27 */ 28 28 29 /** @addtogroup mouse 30 * @brief 29 /** @addtogroup libcmips64 31 30 * @{ 32 31 */ … … 34 33 */ 35 34 36 #ifndef ADBDEV_H_37 #define ADBDEV_H_35 #ifndef LIBC_mips64__ISTATE_H_ 36 #define LIBC_mips64__ISTATE_H_ 38 37 39 #include <sys/types.h> 40 41 extern int adb_dev_init(void); 38 #include <arch/istate.h> 42 39 43 40 #endif 44 41 45 /** 46 * @} 47 */ 48 42 /** @} 43 */ -
uspace/lib/c/arch/mips64/src/stacktrace.c
r5974661 re4f8c77 1 1 /* 2 * Copyright (c) 20 09 Jiri Svoboda3 * Copyright (c) 2010 Lenka Trochtova2 * Copyright (c) 2010 Jakub Jermar 3 * Copyright (c) 2010 Jiri Svoboda 4 4 * All rights reserved. 5 5 * … … 28 28 */ 29 29 30 /** @addtogroup libc 30 /** @addtogroup libcmips64 mips64 31 * @ingroup lc 31 32 * @{ 32 33 */ … … 34 35 */ 35 36 36 #ifndef LIBC_DEVMAN_OBSOLETE_H_ 37 #define LIBC_DEVMAN_OBSOLETE_H_ 37 #include <sys/types.h> 38 #include <bool.h> 39 #include <errno.h> 38 40 39 #include <ipc/devman.h> 40 #include <async.h> 41 #include <bool.h> 41 #include <stacktrace.h> 42 42 43 extern int devman_obsolete_get_phone(devman_interface_t, unsigned int); 44 extern void devman_obsolete_hangup_phone(devman_interface_t); 43 bool stacktrace_fp_valid(stacktrace_t *st, uintptr_t fp) 44 { 45 (void) st; (void) fp; 46 return false; 47 } 45 48 46 extern int devman_obsolete_device_connect(devman_handle_t, unsigned int); 47 extern int devman_obsolete_parent_device_connect(devman_handle_t, unsigned int); 49 int stacktrace_fp_prev(stacktrace_t *st, uintptr_t fp, uintptr_t *prev) 50 { 51 (void) st; (void) fp; (void) prev; 52 return ENOTSUP; 53 } 48 54 49 #endif 55 int stacktrace_ra_get(stacktrace_t *st, uintptr_t fp, uintptr_t *ra) 56 { 57 (void) st; (void) fp; (void) ra; 58 return ENOTSUP; 59 } 50 60 51 61 /** @} -
uspace/lib/c/generic/adt/hash_table.c
r5974661 re4f8c77 61 61 assert(max_keys > 0); 62 62 63 h->entry = malloc(m * sizeof(li nk_t));63 h->entry = malloc(m * sizeof(list_t)); 64 64 if (!h->entry) 65 65 return false; 66 66 67 memset((void *) h->entry, 0, m * sizeof(li nk_t));67 memset((void *) h->entry, 0, m * sizeof(list_t)); 68 68 69 69 hash_count_t i; … … 123 123 assert(chain < h->entries); 124 124 125 link_t *cur; 126 for (cur = h->entry[chain].next; cur != &h->entry[chain]; 127 cur = cur->next) { 125 list_foreach(h->entry[chain], cur) { 128 126 if (h->op->compare(key, h->max_keys, cur)) { 129 127 /* … … 153 151 assert(keys <= h->max_keys); 154 152 155 link_t *cur;156 157 153 if (keys == h->max_keys) { 154 link_t *cur; 155 158 156 /* 159 157 * All keys are known, hash_table_find() can be used to find the … … 176 174 hash_index_t chain; 177 175 for (chain = 0; chain < h->entries; chain++) { 178 for (cur = h->entry[chain].next; cur != &h->entry[chain]; 176 link_t *cur; 177 178 for (cur = h->entry[chain].head.next; cur != &h->entry[chain].head; 179 179 cur = cur->next) { 180 180 if (h->op->compare(key, keys, cur)) { … … 203 203 { 204 204 hash_index_t bucket; 205 link_t *cur;206 205 207 206 for (bucket = 0; bucket < h->entries; bucket++) { 208 for (cur = h->entry[bucket].next; cur != &h->entry[bucket]; 209 cur = cur->next) { 207 list_foreach(h->entry[bucket], cur) { 210 208 f(cur, arg); 211 209 } -
uspace/lib/c/generic/adt/list.c
r5974661 re4f8c77 30 30 * @{ 31 31 */ 32 /** @file 32 33 /** 34 * @file 35 * @brief Functions completing doubly linked circular list implementaion. 36 * 37 * This file contains some of the functions implementing doubly linked circular lists. 38 * However, this ADT is mostly implemented in @ref list.h. 33 39 */ 34 40 35 41 #include <adt/list.h> 36 42 #include <bool.h> 37 43 38 44 /** Check for membership 39 45 * 40 * Check whether link is contained in the list head.41 * The membership is defined as pointer equivalence.46 * Check whether link is contained in a list. 47 * Membership is defined as pointer equivalence. 42 48 * 43 * @param link Item to look for.44 * @param headList to look in.49 * @param link Item to look for. 50 * @param list List to look in. 45 51 * 46 52 * @return true if link is contained in head, false otherwise. 47 53 * 48 54 */ 49 int list_member(const link_t *link, const li nk_t *head)55 int list_member(const link_t *link, const list_t *list) 50 56 { 51 int found = 0;52 link_t *hlp = head->next;57 bool found = false; 58 link_t *hlp = list->head.next; 53 59 54 while (hlp != head) {60 while (hlp != &list->head) { 55 61 if (hlp == link) { 56 found = 1;62 found = true; 57 63 break; 58 64 } … … 63 69 } 64 70 65 66 71 /** Concatenate two lists 67 72 * 68 * Concatenate lists head1 and head2, producing a single69 * list head1 containing items from both (in head1, head270 * order) and empty list head2.73 * Concatenate lists @a list1 and @a list2, producing a single 74 * list @a list1 containing items from both (in @a list1, @a list2 75 * order) and empty list @a list2. 71 76 * 72 * @param head1First list and concatenated output73 * @param head2Second list and empty output.77 * @param list1 First list and concatenated output 78 * @param list2 Second list and empty output. 74 79 * 75 80 */ 76 void list_concat(li nk_t *head1, link_t *head2)81 void list_concat(list_t *list1, list_t *list2) 77 82 { 78 if (list_empty( head2))83 if (list_empty(list2)) 79 84 return; 80 81 head2->next->prev = head1->prev;82 head2->prev->next = head1;83 head1->prev->next = head2->next;84 head1->prev = head2->prev;85 list_initialize( head2);85 86 list2->head.next->prev = list1->head.prev; 87 list2->head.prev->next = &list1->head; 88 list1->head.prev->next = list2->head.next; 89 list1->head.prev = list2->head.prev; 90 list_initialize(list2); 86 91 } 87 88 92 89 93 /** Count list items … … 91 95 * Return the number of items in the list. 92 96 * 93 * @param link List to count. 94 * 95 * @return Number of items in the list. 96 * 97 * @param list List to count. 98 * @return Number of items in the list. 97 99 */ 98 unsigned int list_count(const li nk_t *link)100 unsigned int list_count(const list_t *list) 99 101 { 100 102 unsigned int count = 0; 101 link_t *hlp = link->next;102 103 103 while (hlp !=link) {104 list_foreach(*list, link) { 104 105 count++; 105 hlp = hlp->next;106 106 } 107 107 -
uspace/lib/c/generic/adt/measured_strings.c
r5974661 re4f8c77 42 42 #include <errno.h> 43 43 #include <async.h> 44 #include <async_obsolete.h>45 44 46 45 /** Creates a new measured string bundled with a copy of the given string … … 298 297 * size has to be negotiated in advance. 299 298 * 300 * @param[in] phone The other module phone.299 * @param[in] exch Exchange. 301 300 * @param[out] strings The returned measured strings array. 302 301 * @param[out] data The measured strings data. This memory block stores the … … 305 304 * @return EOK on success. 306 305 * @return EINVAL if the strings or data parameter is NULL. 307 * @return EINVAL if the phone or count parameter is not positive.306 * @return EINVAL if the exch or count parameter is invalid. 308 307 * @return EINVAL if the sent array differs in size. 309 308 * @return ENOMEM if there is not enough memory left. … … 311 310 * async_data_read_start() function. 312 311 */ 313 int 314 measured_strings_return(int phone, measured_string_t **strings, uint8_t **data, 315 size_t count) 312 int measured_strings_return(async_exch_t *exch, measured_string_t **strings, 313 uint8_t **data, size_t count) 316 314 { 317 315 size_t *lengths; … … 320 318 int rc; 321 319 322 if (( phone < 0) || (!strings) || (!data) || (count <= 0))320 if ((exch == NULL) || (!strings) || (!data) || (count <= 0)) 323 321 return EINVAL; 324 322 … … 327 325 return ENOMEM; 328 326 329 rc = async_ obsolete_data_read_start(phone, lengths,327 rc = async_data_read_start(exch, lengths, 330 328 sizeof(size_t) * (count + 1)); 331 329 if (rc != EOK) { … … 352 350 (*strings)[index].length = lengths[index]; 353 351 if (lengths[index] > 0) { 354 rc = async_ obsolete_data_read_start(phone, next, lengths[index]);352 rc = async_data_read_start(exch, next, lengths[index]); 355 353 if (rc != EOK) { 356 354 free(lengths); … … 376 374 * size has to be negotiated in advance. 377 375 * 378 * @param[in] phone The other module phone.376 * @param[in] exch Exchange. 379 377 * @param[in] strings The measured strings array to be transferred. 380 378 * @param[in] count The measured strings array size. 381 379 * @return EOK on success. 382 380 * @return EINVAL if the strings parameter is NULL. 383 * @return EINVAL if the phone or count parameter is not positive.381 * @return EINVAL if the exch or count parameter is invalid. 384 382 * @return Other error codes as defined for the 385 383 * async_data_write_start() function. 386 384 */ 387 int 388 measured_strings_send(int phone, const measured_string_t *strings, 385 int measured_strings_send(async_exch_t *exch, const measured_string_t *strings, 389 386 size_t count) 390 387 { … … 393 390 int rc; 394 391 395 if (( phone < 0) || (!strings) || (count <= 0))392 if ((exch == NULL) || (!strings) || (count <= 0)) 396 393 return EINVAL; 397 394 … … 400 397 return ENOMEM; 401 398 402 rc = async_ obsolete_data_write_start(phone, lengths,399 rc = async_data_write_start(exch, lengths, 403 400 sizeof(size_t) * (count + 1)); 404 401 if (rc != EOK) { … … 411 408 for (index = 0; index < count; index++) { 412 409 if (strings[index].length > 0) { 413 rc = async_ obsolete_data_write_start(phone, strings[index].value,410 rc = async_data_write_start(exch, strings[index].value, 414 411 strings[index].length); 415 412 if (rc != EOK) … … 423 420 /** @} 424 421 */ 425 -
uspace/lib/c/generic/adt/prodcons.c
r5974661 re4f8c77 61 61 fibril_condvar_wait(&pc->cv, &pc->mtx); 62 62 63 link_t *head = pc->list.next;63 link_t *head = list_first(&pc->list); 64 64 list_remove(head); 65 65 -
uspace/lib/c/generic/async.c
r5974661 re4f8c77 160 160 161 161 /** Messages that should be delivered to this fibril. */ 162 li nk_t msg_queue;162 list_t msg_queue; 163 163 164 164 /** Identification of the opening call. */ … … 166 166 /** Call data of the opening call. */ 167 167 ipc_call_t call; 168 /** Local argument or NULL if none. */ 169 void *carg; 168 170 169 171 /** Identification of the closing call. */ … … 171 173 172 174 /** Fibril function that will be used to handle the connection. */ 173 void (*cfibril)(ipc_callid_t, ipc_call_t *);175 async_client_conn_t cfibril; 174 176 } connection_t; 175 177 … … 213 215 * @param callid Hash of the incoming call. 214 216 * @param call Data of the incoming call. 215 * 216 */ 217 static void default_client_connection(ipc_callid_t callid, ipc_call_t *call) 217 * @param arg Local argument 218 * 219 */ 220 static void default_client_connection(ipc_callid_t callid, ipc_call_t *call, 221 void *arg) 218 222 { 219 223 ipc_answer_0(callid, ENOENT); … … 226 230 * @param callid Hash of the incoming call. 227 231 * @param call Data of the incoming call. 232 * @param arg Local argument. 228 233 * 229 234 */ … … 233 238 234 239 static async_client_conn_t client_connection = default_client_connection; 235 static async_ client_conn_t interrupt_received = default_interrupt_received;240 static async_interrupt_handler_t interrupt_received = default_interrupt_received; 236 241 237 242 /** Setter for client_connection function pointer. … … 250 255 * notification fibril. 251 256 */ 252 void async_set_interrupt_received(async_ client_conn_t intr)257 void async_set_interrupt_received(async_interrupt_handler_t intr) 253 258 { 254 259 interrupt_received = intr; … … 356 361 wd->to_event.inlist = true; 357 362 358 link_t *tmp = timeout_list. next;359 while (tmp != &timeout_list ) {363 link_t *tmp = timeout_list.head.next; 364 while (tmp != &timeout_list.head) { 360 365 awaiter_t *cur 361 366 = list_get_instance(tmp, awaiter_t, to_event.link); … … 367 372 } 368 373 369 list_ append(&wd->to_event.link, tmp);374 list_insert_before(&wd->to_event.link, tmp); 370 375 } 371 376 … … 564 569 } 565 570 566 msg_t *msg = list_get_instance( conn->msg_queue.next, msg_t, link);571 msg_t *msg = list_get_instance(list_first(&conn->msg_queue), msg_t, link); 567 572 list_remove(&msg->link); 568 573 … … 633 638 */ 634 639 fibril_connection->cfibril(fibril_connection->callid, 635 &fibril_connection->call );640 &fibril_connection->call, fibril_connection->carg); 636 641 637 642 /* … … 670 675 while (!list_empty(&fibril_connection->msg_queue)) { 671 676 msg_t *msg = 672 list_get_instance( fibril_connection->msg_queue.next, msg_t,673 link);677 list_get_instance(list_first(&fibril_connection->msg_queue), 678 msg_t, link); 674 679 675 680 list_remove(&msg->link); … … 704 709 * @param cfibril Fibril function that should be called upon opening the 705 710 * connection. 711 * @param carg Extra argument to pass to the connection fibril 706 712 * 707 713 * @return New fibril id or NULL on failure. … … 710 716 fid_t async_new_connection(sysarg_t in_task_hash, sysarg_t in_phone_hash, 711 717 ipc_callid_t callid, ipc_call_t *call, 712 async_client_conn_t cfibril )718 async_client_conn_t cfibril, void *carg) 713 719 { 714 720 connection_t *conn = malloc(sizeof(*conn)); … … 725 731 conn->callid = callid; 726 732 conn->close_callid = 0; 733 conn->carg = carg; 727 734 728 735 if (call) … … 779 786 /* Open new connection with fibril, etc. */ 780 787 async_new_connection(call->in_task_hash, IPC_GET_ARG5(*call), 781 callid, call, client_connection );788 callid, call, client_connection, NULL); 782 789 return; 783 790 } … … 799 806 futex_down(&async_futex); 800 807 801 link_t *cur = timeout_list.next;802 while (cur != &timeout_list) {808 link_t *cur = list_first(&timeout_list); 809 while (cur != NULL) { 803 810 awaiter_t *waiter = 804 811 list_get_instance(cur, awaiter_t, to_event.link); … … 806 813 if (tv_gt(&waiter->to_event.expires, &tv)) 807 814 break; 808 809 cur = cur->next;810 815 811 816 list_remove(&waiter->to_event.link); … … 821 826 fibril_add_ready(waiter->fid); 822 827 } 828 829 cur = list_first(&timeout_list); 823 830 } 824 831 … … 847 854 suseconds_t timeout; 848 855 if (!list_empty(&timeout_list)) { 849 awaiter_t *waiter = list_get_instance( timeout_list.next,850 awaiter_t, to_event.link);856 awaiter_t *waiter = list_get_instance( 857 list_first(&timeout_list), awaiter_t, to_event.link); 851 858 852 859 struct timeval tv; … … 1414 1421 */ 1415 1422 int async_connect_to_me(async_exch_t *exch, sysarg_t arg1, sysarg_t arg2, 1416 sysarg_t arg3, async_client_conn_t client_receiver )1423 sysarg_t arg3, async_client_conn_t client_receiver, void *carg) 1417 1424 { 1418 1425 if (exch == NULL) … … 1428 1435 if (client_receiver != NULL) 1429 1436 async_new_connection(task_hash, phone_hash, 0, NULL, 1430 client_receiver );1437 client_receiver, carg); 1431 1438 1432 1439 return EOK; … … 1724 1731 */ 1725 1732 exch = (async_exch_t *) 1726 list_get_instance(sess->exch_list.next, async_exch_t, sess_link); 1733 list_get_instance(list_first(&sess->exch_list), 1734 async_exch_t, sess_link); 1735 1727 1736 list_remove(&exch->sess_link); 1728 1737 list_remove(&exch->global_link); … … 1736 1745 exch = (async_exch_t *) malloc(sizeof(async_exch_t)); 1737 1746 if (exch != NULL) { 1738 li st_initialize(&exch->sess_link);1739 li st_initialize(&exch->global_link);1747 link_initialize(&exch->sess_link); 1748 link_initialize(&exch->global_link); 1740 1749 exch->sess = sess; 1741 1750 exch->phone = sess->phone; … … 1754 1763 exch = (async_exch_t *) malloc(sizeof(async_exch_t)); 1755 1764 if (exch != NULL) { 1756 li st_initialize(&exch->sess_link);1757 li st_initialize(&exch->global_link);1765 link_initialize(&exch->sess_link); 1766 link_initialize(&exch->global_link); 1758 1767 exch->sess = sess; 1759 1768 exch->phone = phone; … … 1767 1776 */ 1768 1777 exch = (async_exch_t *) 1769 list_get_instance(inactive_exch_list.next, async_exch_t, 1770 global_link); 1778 list_get_instance(list_first(&inactive_exch_list), 1779 async_exch_t, global_link); 1780 1771 1781 list_remove(&exch->sess_link); 1772 1782 list_remove(&exch->global_link); … … 1808 1818 async_sess_t *sess = exch->sess; 1809 1819 1820 atomic_dec(&sess->refcnt); 1821 1810 1822 if (sess->mgmt == EXCHANGE_SERIALIZE) 1811 1823 fibril_mutex_unlock(&sess->mutex); -
uspace/lib/c/generic/async_obsolete.c
r5974661 re4f8c77 166 166 } 167 167 168 void async_obsolete_serialize_start(void)169 {170 fibril_inc_sercount();171 }172 173 void async_obsolete_serialize_end(void)174 {175 fibril_dec_sercount();176 }177 178 168 /** Wrapper for IPC_M_DATA_WRITE calls using the async framework. 179 169 * … … 240 230 */ 241 231 int async_obsolete_connect_to_me(int phone, sysarg_t arg1, sysarg_t arg2, 242 sysarg_t arg3, async_client_conn_t client_receiver )232 sysarg_t arg3, async_client_conn_t client_receiver, void *carg) 243 233 { 244 234 sysarg_t task_hash; … … 251 241 if (client_receiver != NULL) 252 242 async_new_connection(task_hash, phone_hash, 0, NULL, 253 client_receiver );243 client_receiver, carg); 254 244 255 245 return EOK; -
uspace/lib/c/generic/devman.c
r5974661 re4f8c77 35 35 */ 36 36 37 #include <adt/list.h> 37 38 #include <str.h> 38 39 #include <ipc/services.h> … … 194 195 195 196 exch = devman_exchange_begin(DEVMAN_DRIVER); 196 async_connect_to_me(exch, 0, 0, 0, NULL );197 async_connect_to_me(exch, 0, 0, 0, NULL, NULL); 197 198 devman_exchange_end(exch); 198 199 … … 231 232 } 232 233 233 link_t *link = match_ids->ids.next;234 234 match_id_t *match_id = NULL; 235 235 236 while (link != &match_ids->ids) {236 list_foreach(match_ids->ids, link) { 237 237 match_id = list_get_instance(link, match_id_t, link); 238 238 … … 255 255 return retval; 256 256 } 257 258 link = link->next;259 257 } 260 258 -
uspace/lib/c/generic/devmap.c
r5974661 re4f8c77 187 187 188 188 exch = devmap_exchange_begin(DEVMAP_DRIVER); 189 async_connect_to_me(exch, 0, 0, 0, NULL );189 async_connect_to_me(exch, 0, 0, 0, NULL, NULL); 190 190 devmap_exchange_end(exch); 191 191 -
uspace/lib/c/generic/fibril.c
r5974661 re4f8c77 222 222 fibril_t *dstf; 223 223 if ((stype == FIBRIL_TO_MANAGER) || (stype == FIBRIL_FROM_DEAD)) { 224 dstf = list_get_instance(manager_list.next, fibril_t, link); 224 dstf = list_get_instance(list_first(&manager_list), fibril_t, 225 link); 225 226 if (serialization_count && stype == FIBRIL_TO_MANAGER) { 226 227 serialized_threads++; … … 233 234 } else { 234 235 if (!list_empty(&serialized_list)) { 235 dstf = list_get_instance( serialized_list.next, fibril_t,236 link);236 dstf = list_get_instance(list_first(&serialized_list), 237 fibril_t, link); 237 238 serialized_threads--; 238 239 } else { 239 dstf = list_get_instance( ready_list.next, fibril_t,240 link);240 dstf = list_get_instance(list_first(&ready_list), 241 fibril_t, link); 241 242 } 242 243 } … … 326 327 327 328 if (!list_empty(&manager_list)) 328 list_remove( manager_list.next);329 list_remove(list_first(&manager_list)); 329 330 330 331 futex_up(&fibril_futex); -
uspace/lib/c/generic/fibril_synch.c
r5974661 re4f8c77 148 148 fibril_t *f; 149 149 150 assert(!list_empty(&fm->waiters));151 tmp = fm->waiters.next;150 tmp = list_first(&fm->waiters); 151 assert(tmp != NULL); 152 152 wdp = list_get_instance(tmp, awaiter_t, wu_event.link); 153 153 wdp->active = true; … … 279 279 280 280 while (!list_empty(&frw->waiters)) { 281 link_t *tmp = frw->waiters.next;281 link_t *tmp = list_first(&frw->waiters); 282 282 awaiter_t *wdp; 283 283 fibril_t *f; … … 422 422 futex_down(&async_futex); 423 423 while (!list_empty(&fcv->waiters)) { 424 tmp = fcv->waiters.next;424 tmp = list_first(&fcv->waiters); 425 425 wdp = list_get_instance(tmp, awaiter_t, wu_event.link); 426 426 list_remove(&wdp->wu_event.link); -
uspace/lib/c/generic/io/console.c
r5974661 re4f8c77 76 76 bool console_kcon(void) 77 77 { 78 #if 079 78 return __SYSCALL0(SYS_DEBUG_ACTIVATE_CONSOLE); 80 #endif81 82 return false;83 79 } 84 80 -
uspace/lib/c/generic/io/io.c
r5974661 re4f8c77 127 127 void __stdio_done(void) 128 128 { 129 link_t *link = files.next; 130 131 while (link != &files) { 132 FILE *file = list_get_instance(link, FILE, link); 129 while (!list_empty(&files)) { 130 FILE *file = list_get_instance(list_first(&files), FILE, link); 133 131 fclose(file); 134 link = files.next;135 132 } 136 133 } -
uspace/lib/c/generic/ipc.c
r5974661 re4f8c77 458 458 while (!list_empty(&queued_calls)) { 459 459 async_call_t *call = 460 list_get_instance( queued_calls.next, async_call_t, list);460 list_get_instance(list_first(&queued_calls), async_call_t, list); 461 461 ipc_callid_t callid = 462 462 ipc_call_async_internal(call->u.msg.phoneid, &call->u.msg.data); … … 511 511 512 512 link_t *item; 513 for (item = dispatched_calls. next; item != &dispatched_calls;513 for (item = dispatched_calls.head.next; item != &dispatched_calls.head; 514 514 item = item->next) { 515 515 async_call_t *call = -
uspace/lib/c/generic/net/icmp_api.c
r5974661 re4f8c77 42 42 #include <net/ip_codes.h> 43 43 #include <async.h> 44 #include <async_obsolete.h>45 44 #include <sys/types.h> 46 45 #include <sys/time.h> … … 55 54 * timeout occurs. 56 55 * 57 * @param[in] icmp_phone The ICMP module phone used for (semi)remote calls.56 * @param[in] sess The ICMP session. 58 57 * @param[in] size The message data length in bytes. 59 58 * @param[in] timeout The timeout in milliseconds. … … 74 73 */ 75 74 int 76 icmp_echo_msg( int icmp_phone, size_t size, mseconds_t timeout, ip_ttl_t ttl,75 icmp_echo_msg(async_sess_t *sess, size_t size, mseconds_t timeout, ip_ttl_t ttl, 77 76 ip_tos_t tos, int dont_fragment, const struct sockaddr *addr, 78 77 socklen_t addrlen) … … 83 82 if (addrlen <= 0) 84 83 return EINVAL; 85 86 message_id = async_obsolete_send_5(icmp_phone, NET_ICMP_ECHO, size, timeout, ttl, 84 85 async_exch_t *exch = async_exchange_begin(sess); 86 87 message_id = async_send_5(exch, NET_ICMP_ECHO, size, timeout, ttl, 87 88 tos, (sysarg_t) dont_fragment, NULL); 88 89 89 90 /* Send the address */ 90 async_obsolete_data_write_start(icmp_phone, addr, (size_t) addrlen); 91 async_data_write_start(exch, addr, (size_t) addrlen); 92 93 async_exchange_end(exch); 91 94 92 95 async_wait_for(message_id, &result); -
uspace/lib/c/generic/net/icmp_common.c
r5974661 re4f8c77 45 45 /** Connect to the ICMP module. 46 46 * 47 * @param[in] timeout Connection timeout in microseconds, zero 48 * for no timeout. 49 * 50 * @return ICMP module phone on success. 51 * @return ETIMEOUT if the connection timeouted. 47 * @return ICMP module session. 52 48 * 53 49 */ 54 int icmp_connect_module(suseconds_t timeout)50 async_sess_t *icmp_connect_module(void) 55 51 { 56 return connect_to_service _timeout(SERVICE_ICMP, timeout);52 return connect_to_service(SERVICE_ICMP); 57 53 } 58 54 -
uspace/lib/c/generic/net/modules.c
r5974661 re4f8c77 40 40 41 41 #include <async.h> 42 #include <async_obsolete.h>43 42 #include <malloc.h> 44 43 #include <errno.h> … … 47 46 #include <net/modules.h> 48 47 #include <ns.h> 49 #include <ns_obsolete.h>50 51 /** The time between connect requests in microseconds. */52 #define MODULE_WAIT_TIME (10 * 1000)53 48 54 49 /** Answer a call. … … 98 93 } 99 94 100 /** Create bidirectional connection with the needed module service and register s95 /** Create bidirectional connection with the needed module service and register 101 96 * the message receiver. 102 97 * 103 * @param[in] need The needed module service. 104 * @param[in] arg1 The first parameter. 105 * @param[in] arg2 The second parameter. 106 * @param[in] arg3 The third parameter. 107 * @param[in] client_receiver The message receiver. 108 * 109 * @return The phone of the needed service. 110 * @return Other error codes as defined for the ipc_connect_to_me() 111 * function. 112 */ 113 int bind_service(services_t need, sysarg_t arg1, sysarg_t arg2, sysarg_t arg3, 114 async_client_conn_t client_receiver) 115 { 116 return bind_service_timeout(need, arg1, arg2, arg3, client_receiver, 0); 117 } 118 119 /** Create bidirectional connection with the needed module service and registers 120 * the message receiver. 121 * 122 * @param[in] need The needed module service. 123 * @param[in] arg1 The first parameter. 124 * @param[in] arg2 The second parameter. 125 * @param[in] arg3 The third parameter. 126 * @param[in] client_receiver The message receiver. 127 * @param[in] timeout The connection timeout in microseconds. No timeout if 128 * set to zero (0). 129 * 130 * @return The phone of the needed service. 131 * @return ETIMEOUT if the connection timeouted. 132 * @return Other error codes as defined for the ipc_connect_to_me() 133 * function. 134 * 135 */ 136 int bind_service_timeout(services_t need, sysarg_t arg1, sysarg_t arg2, 137 sysarg_t arg3, async_client_conn_t client_receiver, suseconds_t timeout) 98 * @param[in] need Needed module service. 99 * @param[in] arg1 First parameter. 100 * @param[in] arg2 Second parameter. 101 * @param[in] arg3 Third parameter. 102 * @param[in] client_receiver Message receiver. 103 * 104 * @return Session to the needed service. 105 * @return Other error codes as defined for the async_connect_to_me() 106 * function. 107 * 108 */ 109 async_sess_t *bind_service(services_t need, sysarg_t arg1, sysarg_t arg2, 110 sysarg_t arg3, async_client_conn_t client_receiver) 138 111 { 139 112 /* Connect to the needed service */ 140 int phone = connect_to_service_timeout(need, timeout);141 if ( phone >= 0) {113 async_sess_t *sess = connect_to_service(need); 114 if (sess != NULL) { 142 115 /* Request the bidirectional connection */ 143 int rc = async_obsolete_connect_to_me(phone, arg1, arg2, arg3, client_receiver); 116 async_exch_t *exch = async_exchange_begin(sess); 117 int rc = async_connect_to_me(exch, arg1, arg2, arg3, 118 client_receiver, NULL); 119 async_exchange_end(exch); 120 144 121 if (rc != EOK) { 145 async_obsolete_hangup(phone); 146 return rc; 122 async_hangup(sess); 123 errno = rc; 124 return NULL; 147 125 } 148 126 } 149 127 150 return phone; 151 } 152 153 /** Connects to the needed module. 154 * 155 * @param[in] need The needed module service. 156 * @return The phone of the needed service. 157 */ 158 int connect_to_service(services_t need) 159 { 160 return connect_to_service_timeout(need, 0); 161 } 162 163 /** Connects to the needed module. 164 * 165 * @param[in] need The needed module service. 166 * @param[in] timeout The connection timeout in microseconds. No timeout if 167 * set to zero (0). 168 * @return The phone of the needed service. 169 * @return ETIMEOUT if the connection timeouted. 170 */ 171 int connect_to_service_timeout(services_t need, suseconds_t timeout) 172 { 173 int phone; 174 175 /* If no timeout is set */ 176 if (timeout <= 0) 177 return service_obsolete_connect_blocking(need, 0, 0); 178 179 while (true) { 180 phone = service_obsolete_connect(need, 0, 0); 181 if ((phone >= 0) || (phone != ENOENT)) 182 return phone; 183 184 /* Abort if no time is left */ 185 if (timeout <= 0) 186 return ETIMEOUT; 187 188 /* Wait the minimum of the module wait time and the timeout */ 189 usleep((timeout <= MODULE_WAIT_TIME) ? 190 timeout : MODULE_WAIT_TIME); 191 timeout -= MODULE_WAIT_TIME; 192 } 193 } 194 195 /** Replies the data to the other party. 196 * 197 * @param[in] data The data buffer to be sent. 128 return sess; 129 } 130 131 /** Connect to the needed module. 132 * 133 * @param[in] need Needed module service. 134 * 135 * @return Session to the needed service. 136 * @return NULL if the connection timeouted. 137 * 138 */ 139 async_sess_t *connect_to_service(services_t need) 140 { 141 return service_connect_blocking(EXCHANGE_SERIALIZE, need, 0, 0); 142 } 143 144 /** Reply the data to the other party. 145 * 146 * @param[in] data The data buffer to be sent. 198 147 * @param[in] data_length The buffer length. 199 * @return EOK on success. 200 * @return EINVAL if the client does not expect the data. 201 * @return EOVERFLOW if the client does not expect all the data. 202 * Only partial data are transfered. 203 * @return Other error codes as defined for the 204 * async_data_read_finalize() function. 148 * 149 * @return EOK on success. 150 * @return EINVAL if the client does not expect the data. 151 * @return EOVERFLOW if the client does not expect all the data. 152 * Only partial data are transfered. 153 * @return Other error codes as defined for the 154 * async_data_read_finalize() function. 155 * 205 156 */ 206 157 int data_reply(void *data, size_t data_length) … … 208 159 size_t length; 209 160 ipc_callid_t callid; 210 161 211 162 /* Fetch the request */ 212 163 if (!async_data_read_receive(&callid, &length)) 213 164 return EINVAL; 214 165 215 166 /* Check the requested data size */ 216 167 if (length < data_length) { … … 218 169 return EOVERFLOW; 219 170 } 220 171 221 172 /* Send the data */ 222 173 return async_data_read_finalize(callid, data, data_length); -
uspace/lib/c/generic/net/socket_client.c
r5974661 re4f8c77 39 39 #include <assert.h> 40 40 #include <async.h> 41 #include <async_obsolete.h>42 41 #include <fibril_synch.h> 43 42 #include <stdint.h> … … 65 64 #define SOCKET_MAX_ACCEPTED_SIZE 0 66 65 67 /** Default timeout for connections in microseconds. */68 #define SOCKET_CONNECT_TIMEOUT (1 * 1000 * 1000)69 70 66 /** 71 67 * Maximum number of random attempts to find a new socket identifier before … … 87 83 /** Socket identifier. */ 88 84 int socket_id; 89 /** Parent module phone. */90 int phone;85 /** Parent module session. */ 86 async_sess_t *sess; 91 87 /** Parent module service. */ 92 88 services_t service; … … 147 143 /** Socket client library global data. */ 148 144 static struct socket_client_globals { 149 /** TCP module phone. */ 150 int tcp_phone; 151 /** UDP module phone. */ 152 int udp_phone; 153 154 // /** The last socket identifier. 155 // */ 156 // int last_id; 145 /** TCP module session. */ 146 async_sess_t *tcp_sess; 147 /** UDP module session. */ 148 async_sess_t *udp_sess; 157 149 158 150 /** Active sockets. */ … … 167 159 fibril_rwlock_t lock; 168 160 } socket_globals = { 169 .tcp_phone = -1, 170 .udp_phone = -1, 171 // .last_id = 0, 161 .tcp_sess = NULL, 162 .udp_sess = NULL, 172 163 .sockets = NULL, 173 164 .lock = FIBRIL_RWLOCK_INITIALIZER(socket_globals.lock) … … 203 194 * @param[in] iid The initial message identifier. 204 195 * @param[in] icall The initial message call structure. 205 */ 206 static void socket_connection(ipc_callid_t iid, ipc_call_t * icall) 196 * @param[in] arg Local argument. 197 */ 198 static void socket_connection(ipc_callid_t iid, ipc_call_t * icall, void *arg) 207 199 { 208 200 ipc_callid_t callid; … … 282 274 } 283 275 284 /** Returns the TCP module phone. 285 * 286 * Connects to the TCP module if necessary. 287 * 288 * @return The TCP module phone. 289 * @return Other error codes as defined for the 290 * bind_service_timeout() function. 291 */ 292 static int socket_get_tcp_phone(void) 293 { 294 if (socket_globals.tcp_phone < 0) { 295 socket_globals.tcp_phone = bind_service_timeout(SERVICE_TCP, 296 0, 0, SERVICE_TCP, socket_connection, 297 SOCKET_CONNECT_TIMEOUT); 298 } 299 300 return socket_globals.tcp_phone; 301 } 302 303 /** Returns the UDP module phone. 304 * 305 * Connects to the UDP module if necessary. 306 * 307 * @return The UDP module phone. 308 * @return Other error codes as defined for the 309 * bind_service_timeout() function. 310 */ 311 static int socket_get_udp_phone(void) 312 { 313 if (socket_globals.udp_phone < 0) { 314 socket_globals.udp_phone = bind_service_timeout(SERVICE_UDP, 315 0, 0, SERVICE_UDP, socket_connection, 316 SOCKET_CONNECT_TIMEOUT); 317 } 318 319 return socket_globals.udp_phone; 276 /** Return the TCP module session. 277 * 278 * Connect to the TCP module if necessary. 279 * 280 * @return The TCP module session. 281 * 282 */ 283 static async_sess_t *socket_get_tcp_sess(void) 284 { 285 if (socket_globals.tcp_sess == NULL) { 286 socket_globals.tcp_sess = bind_service(SERVICE_TCP, 287 0, 0, SERVICE_TCP, socket_connection); 288 } 289 290 return socket_globals.tcp_sess; 291 } 292 293 /** Return the UDP module session. 294 * 295 * Connect to the UDP module if necessary. 296 * 297 * @return The UDP module session. 298 * 299 */ 300 static async_sess_t *socket_get_udp_sess(void) 301 { 302 if (socket_globals.udp_sess == NULL) { 303 socket_globals.udp_sess = bind_service(SERVICE_UDP, 304 0, 0, SERVICE_UDP, socket_connection); 305 } 306 307 return socket_globals.udp_sess; 320 308 } 321 309 … … 333 321 sockets = socket_get_sockets(); 334 322 count = 0; 335 // socket_id = socket_globals.last_id;336 323 337 324 do { … … 346 333 if (socket_id < INT_MAX) { 347 334 ++socket_id; 348 /* } else if(socket_globals.last_id) { 349 * socket_globals.last_id = 0; 350 * socket_id = 1; 351 */ } else { 335 } else { 352 336 return ELIMIT; 353 337 } 354 338 } 355 339 } while (sockets_find(sockets, socket_id)); 356 357 // last_id = socket_id 340 358 341 return socket_id; 359 342 } … … 362 345 * 363 346 * @param[in,out] socket The socket to be initialized. 364 * @param[in] socket_id The new socket identifier. 365 * @param[in] phone The parent module phone. 366 * @param[in] service The parent module service. 367 */ 368 static void 369 socket_initialize(socket_t *socket, int socket_id, int phone, 370 services_t service) 347 * @param[in] socket_id The new socket identifier. 348 * @param[in] sess The parent module session. 349 * @param[in] service The parent module service. 350 */ 351 static void socket_initialize(socket_t *socket, int socket_id, 352 async_sess_t *sess, services_t service) 371 353 { 372 354 socket->socket_id = socket_id; 373 socket-> phone = phone;355 socket->sess = sess; 374 356 socket->service = service; 375 357 dyn_fifo_initialize(&socket->received, SOCKET_INITIAL_RECEIVED_SIZE); … … 396 378 * @return Other error codes as defined for the NET_SOCKET message. 397 379 * @return Other error codes as defined for the 398 * bind_service _timeout() function.380 * bind_service() function. 399 381 */ 400 382 int socket(int domain, int type, int protocol) 401 383 { 402 384 socket_t *socket; 403 int phone;385 async_sess_t *sess; 404 386 int socket_id; 405 387 services_t service; … … 418 400 switch (protocol) { 419 401 case IPPROTO_TCP: 420 phone = socket_get_tcp_phone();402 sess = socket_get_tcp_sess(); 421 403 service = SERVICE_TCP; 422 404 break; … … 433 415 switch (protocol) { 434 416 case IPPROTO_UDP: 435 phone = socket_get_udp_phone();417 sess = socket_get_udp_sess(); 436 418 service = SERVICE_UDP; 437 419 break; … … 454 436 } 455 437 456 if ( phone < 0)457 return phone;438 if (sess == NULL) 439 return ENOENT; 458 440 459 441 /* Create a new socket structure */ … … 472 454 return socket_id; 473 455 } 474 475 rc = (int) async_obsolete_req_3_3(phone, NET_SOCKET, socket_id, 0, service, NULL, 456 457 async_exch_t *exch = async_exchange_begin(sess); 458 rc = (int) async_req_3_3(exch, NET_SOCKET, socket_id, 0, service, NULL, 476 459 &fragment_size, &header_size); 460 async_exchange_end(exch); 461 477 462 if (rc != EOK) { 478 463 fibril_rwlock_write_unlock(&socket_globals.lock); … … 485 470 486 471 /* Finish the new socket initialization */ 487 socket_initialize(socket, socket_id, phone, service);472 socket_initialize(socket, socket_id, sess, service); 488 473 /* Store the new socket */ 489 474 rc = sockets_add(socket_get_sockets(), socket_id, socket); … … 494 479 dyn_fifo_destroy(&socket->accepted); 495 480 free(socket); 496 async_obsolete_msg_3(phone, NET_SOCKET_CLOSE, (sysarg_t) socket_id, 0, 481 482 exch = async_exchange_begin(sess); 483 async_msg_3(exch, NET_SOCKET_CLOSE, (sysarg_t) socket_id, 0, 497 484 service); 485 async_exchange_end(exch); 486 498 487 return rc; 499 488 } … … 539 528 540 529 /* Request the message */ 541 message_id = async_obsolete_send_3(socket->phone, message, 530 async_exch_t *exch = async_exchange_begin(socket->sess); 531 message_id = async_send_3(exch, message, 542 532 (sysarg_t) socket->socket_id, arg2, socket->service, NULL); 543 533 /* Send the address */ 544 async_obsolete_data_write_start(socket->phone, data, datalength); 534 async_data_write_start(exch, data, datalength); 535 async_exchange_end(exch); 545 536 546 537 fibril_rwlock_read_unlock(&socket_globals.lock); … … 599 590 600 591 /* Request listen backlog change */ 601 result = (int) async_obsolete_req_3_0(socket->phone, NET_SOCKET_LISTEN, 592 async_exch_t *exch = async_exchange_begin(socket->sess); 593 result = (int) async_req_3_0(exch, NET_SOCKET_LISTEN, 602 594 (sysarg_t) socket->socket_id, (sysarg_t) backlog, socket->service); 595 async_exchange_end(exch); 603 596 604 597 fibril_rwlock_read_unlock(&socket_globals.lock); … … 670 663 return socket_id; 671 664 } 672 socket_initialize(new_socket, socket_id, socket-> phone,665 socket_initialize(new_socket, socket_id, socket->sess, 673 666 socket->service); 674 667 result = sockets_add(socket_get_sockets(), new_socket->socket_id, … … 682 675 683 676 /* Request accept */ 684 message_id = async_obsolete_send_5(socket->phone, NET_SOCKET_ACCEPT, 677 async_exch_t *exch = async_exchange_begin(socket->sess); 678 message_id = async_send_5(exch, NET_SOCKET_ACCEPT, 685 679 (sysarg_t) socket->socket_id, 0, socket->service, 0, 686 680 new_socket->socket_id, &answer); 687 681 688 682 /* Read address */ 689 async_obsolete_data_read_start(socket->phone, cliaddr, *addrlen); 683 async_data_read_start(exch, cliaddr, *addrlen); 684 async_exchange_end(exch); 685 690 686 fibril_rwlock_write_unlock(&socket_globals.lock); 691 687 async_wait_for(message_id, &ipc_result); … … 781 777 782 778 /* Request close */ 783 rc = (int) async_obsolete_req_3_0(socket->phone, NET_SOCKET_CLOSE, 779 async_exch_t *exch = async_exchange_begin(socket->sess); 780 rc = (int) async_req_3_0(exch, NET_SOCKET_CLOSE, 784 781 (sysarg_t) socket->socket_id, 0, socket->service); 782 async_exchange_end(exch); 783 785 784 if (rc != EOK) { 786 785 fibril_rwlock_write_unlock(&socket_globals.lock); … … 854 853 855 854 /* Request send */ 856 message_id = async_obsolete_send_5(socket->phone, message, 855 async_exch_t *exch = async_exchange_begin(socket->sess); 856 857 message_id = async_send_5(exch, message, 857 858 (sysarg_t) socket->socket_id, 858 859 (fragments == 1 ? datalength : socket->data_fragment_size), … … 861 862 /* Send the address if given */ 862 863 if (!toaddr || 863 (async_ obsolete_data_write_start(socket->phone, toaddr, addrlen) == EOK)) {864 (async_data_write_start(exch, toaddr, addrlen) == EOK)) { 864 865 if (fragments == 1) { 865 866 /* Send all if only one fragment */ 866 async_ obsolete_data_write_start(socket->phone, data, datalength);867 async_data_write_start(exch, data, datalength); 867 868 } else { 868 869 /* Send the first fragment */ 869 async_ obsolete_data_write_start(socket->phone, data,870 async_data_write_start(exch, data, 870 871 socket->data_fragment_size - socket->header_size); 871 872 data = ((const uint8_t *) data) + … … 874 875 /* Send the middle fragments */ 875 876 while (--fragments > 1) { 876 async_ obsolete_data_write_start(socket->phone, data,877 async_data_write_start(exch, data, 877 878 socket->data_fragment_size); 878 879 data = ((const uint8_t *) data) + … … 881 882 882 883 /* Send the last fragment */ 883 async_ obsolete_data_write_start(socket->phone, data,884 async_data_write_start(exch, data, 884 885 (datalength + socket->header_size) % 885 886 socket->data_fragment_size); 886 887 } 887 888 } 889 890 async_exchange_end(exch); 888 891 889 892 async_wait_for(message_id, &result); … … 1027 1030 return 0; 1028 1031 } 1032 1033 async_exch_t *exch = async_exchange_begin(socket->sess); 1029 1034 1030 1035 /* Prepare lengths if more fragments */ … … 1039 1044 1040 1045 /* Request packet data */ 1041 message_id = async_ obsolete_send_4(socket->phone, message,1046 message_id = async_send_4(exch, message, 1042 1047 (sysarg_t) socket->socket_id, 0, socket->service, 1043 1048 (sysarg_t) flags, &answer); … … 1045 1050 /* Read the address if desired */ 1046 1051 if(!fromaddr || 1047 (async_ obsolete_data_read_start(socket->phone, fromaddr,1052 (async_data_read_start(exch, fromaddr, 1048 1053 *addrlen) == EOK)) { 1049 1054 /* Read the fragment lengths */ 1050 if (async_ obsolete_data_read_start(socket->phone, lengths,1055 if (async_data_read_start(exch, lengths, 1051 1056 sizeof(int) * (fragments + 1)) == EOK) { 1052 1057 if (lengths[fragments] <= datalength) { … … 1055 1060 for (index = 0; index < fragments; 1056 1061 ++index) { 1057 async_obsolete_data_read_start( 1058 socket->phone, data, 1062 async_data_read_start(exch, data, 1059 1063 lengths[index]); 1060 1064 data = ((uint8_t *) data) + … … 1068 1072 } else { /* fragments == 1 */ 1069 1073 /* Request packet data */ 1070 message_id = async_ obsolete_send_4(socket->phone, message,1074 message_id = async_send_4(exch, message, 1071 1075 (sysarg_t) socket->socket_id, 0, socket->service, 1072 1076 (sysarg_t) flags, &answer); … … 1074 1078 /* Read the address if desired */ 1075 1079 if (!fromaddr || 1076 (async_obsolete_data_read_start(socket->phone, fromaddr, 1077 *addrlen) == EOK)) { 1080 (async_data_read_start(exch, fromaddr, *addrlen) == EOK)) { 1078 1081 /* Read all if only one fragment */ 1079 async_ obsolete_data_read_start(socket->phone, data, datalength);1082 async_data_read_start(exch, data, datalength); 1080 1083 } 1081 1084 } 1085 1086 async_exchange_end(exch); 1082 1087 1083 1088 async_wait_for(message_id, &ipc_result); … … 1191 1196 1192 1197 /* Request option value */ 1193 message_id = async_obsolete_send_3(socket->phone, NET_SOCKET_GETSOCKOPT, 1198 async_exch_t *exch = async_exchange_begin(socket->sess); 1199 1200 message_id = async_send_3(exch, NET_SOCKET_GETSOCKOPT, 1194 1201 (sysarg_t) socket->socket_id, (sysarg_t) optname, socket->service, 1195 1202 NULL); 1196 1203 1197 1204 /* Read the length */ 1198 if (async_ obsolete_data_read_start(socket->phone, optlen,1205 if (async_data_read_start(exch, optlen, 1199 1206 sizeof(*optlen)) == EOK) { 1200 1207 /* Read the value */ 1201 async_obsolete_data_read_start(socket->phone, value, *optlen); 1202 } 1208 async_data_read_start(exch, value, *optlen); 1209 } 1210 1211 async_exchange_end(exch); 1203 1212 1204 1213 fibril_rwlock_read_unlock(&socket_globals.lock); -
uspace/lib/c/generic/ns.c
r5974661 re4f8c77 42 42 { 43 43 async_exch_t *exch = async_exchange_begin(session_ns); 44 int rc = async_connect_to_me(exch, service, 0, 0, NULL );44 int rc = async_connect_to_me(exch, service, 0, 0, NULL, NULL); 45 45 async_exchange_end(exch); 46 46 -
uspace/lib/c/generic/str.c
r5974661 re4f8c77 540 540 541 541 dstr_size = str_size(dest); 542 if (dstr_size >= size) 543 return; 544 542 545 str_cpy(dest + dstr_size, size - dstr_size, src); 546 } 547 548 /** Convert space-padded ASCII to string. 549 * 550 * Common legacy text encoding in hardware is 7-bit ASCII fitted into 551 * a fixed-with byte buffer (bit 7 always zero), right-padded with spaces 552 * (ASCII 0x20). Convert space-padded ascii to string representation. 553 * 554 * If the text does not fit into the destination buffer, the function converts 555 * as many characters as possible and returns EOVERFLOW. 556 * 557 * If the text contains non-ASCII bytes (with bit 7 set), the whole string is 558 * converted anyway and invalid characters are replaced with question marks 559 * (U_SPECIAL) and the function returns EIO. 560 * 561 * Regardless of return value upon return @a dest will always be well-formed. 562 * 563 * @param dest Destination buffer 564 * @param size Size of destination buffer 565 * @param src Space-padded ASCII. 566 * @param n Size of the source buffer in bytes. 567 * 568 * @return EOK on success, EOVERFLOW if the text does not fit 569 * destination buffer, EIO if the text contains 570 * non-ASCII bytes. 571 */ 572 int spascii_to_str(char *dest, size_t size, const uint8_t *src, size_t n) 573 { 574 size_t sidx; 575 size_t didx; 576 size_t dlast; 577 uint8_t byte; 578 int rc; 579 int result; 580 581 /* There must be space for a null terminator in the buffer. */ 582 assert(size > 0); 583 result = EOK; 584 585 didx = 0; 586 dlast = 0; 587 for (sidx = 0; sidx < n; ++sidx) { 588 byte = src[sidx]; 589 if (!ascii_check(byte)) { 590 byte = U_SPECIAL; 591 result = EIO; 592 } 593 594 rc = chr_encode(byte, dest, &didx, size - 1); 595 if (rc != EOK) { 596 assert(rc == EOVERFLOW); 597 dest[didx] = '\0'; 598 return rc; 599 } 600 601 /* Remember dest index after last non-empty character */ 602 if (byte != 0x20) 603 dlast = didx; 604 } 605 606 /* Terminate string after last non-empty character */ 607 dest[dlast] = '\0'; 608 return result; 543 609 } 544 610 -
uspace/lib/c/generic/task.c
r5974661 re4f8c77 101 101 int task_spawnv(task_id_t *id, const char *path, const char *const args[]) 102 102 { 103 /* Connect to a program loader. */104 loader_t *ldr = loader_connect();105 if (ldr == NULL)106 return EREFUSED;107 108 /* Get task ID. */109 task_id_t task_id;110 int rc = loader_get_task_id(ldr, &task_id);111 if (rc != EOK)112 goto error;113 114 /* Send spawner's current working directory. */115 rc = loader_set_cwd(ldr);116 if (rc != EOK)117 goto error;118 119 /* Send program pathname. */120 rc = loader_set_pathname(ldr, path);121 if (rc != EOK)122 goto error;123 124 /* Send arguments. */125 rc = loader_set_args(ldr, args);126 if (rc != EOK)127 goto error;128 129 103 /* Send default files */ 130 104 fdi_node_t *files[4]; … … 150 124 files[3] = NULL; 151 125 126 return task_spawnvf(id, path, args, files); 127 } 128 129 /** Create a new task by running an executable from the filesystem. 130 * 131 * This is really just a convenience wrapper over the more complicated 132 * loader API. Arguments are passed as a null-terminated array of strings. 133 * Files are passed as null-terminated array of pointers to fdi_node_t. 134 * 135 * @param id If not NULL, the ID of the task is stored here on success. 136 * @param path Pathname of the binary to execute. 137 * @param argv Command-line arguments. 138 * @param files Standard files to use. 139 * 140 * @return Zero on success or negative error code. 141 * 142 */ 143 int task_spawnvf(task_id_t *id, const char *path, const char *const args[], 144 fdi_node_t *const files[]) 145 { 146 /* Connect to a program loader. */ 147 loader_t *ldr = loader_connect(); 148 if (ldr == NULL) 149 return EREFUSED; 150 151 /* Get task ID. */ 152 task_id_t task_id; 153 int rc = loader_get_task_id(ldr, &task_id); 154 if (rc != EOK) 155 goto error; 156 157 /* Send spawner's current working directory. */ 158 rc = loader_set_cwd(ldr); 159 if (rc != EOK) 160 goto error; 161 162 /* Send program pathname. */ 163 rc = loader_set_pathname(ldr, path); 164 if (rc != EOK) 165 goto error; 166 167 /* Send arguments. */ 168 rc = loader_set_args(ldr, args); 169 if (rc != EOK) 170 goto error; 171 172 /* Send files */ 152 173 rc = loader_set_files(ldr, files); 153 174 if (rc != EOK) -
uspace/lib/c/include/adt/hash_table.h
r5974661 re4f8c77 75 75 /** Hash table structure. */ 76 76 typedef struct { 77 li nk_t *entry;77 list_t *entry; 78 78 hash_count_t entries; 79 79 hash_count_t max_keys; -
uspace/lib/c/include/adt/list.h
r5974661 re4f8c77 1 1 /* 2 2 * Copyright (c) 2001-2004 Jakub Jermar 3 * Copyright (c) 2011 Jiri Svoboda 3 4 * All rights reserved. 4 5 * … … 36 37 #define LIBC_LIST_H_ 37 38 39 #include <assert.h> 38 40 #include <unistd.h> 39 41 40 /** Doubly linked list head and link type. */42 /** Doubly linked list link. */ 41 43 typedef struct link { 42 44 struct link *prev; /**< Pointer to the previous item in the list. */ … … 44 46 } link_t; 45 47 48 /** Doubly linked list. */ 49 typedef struct list { 50 link_t head; /**< List head. Does not have any data. */ 51 } list_t; 52 46 53 /** Declare and initialize statically allocated list. 47 54 * … … 50 57 */ 51 58 #define LIST_INITIALIZE(name) \ 52 link_t name = { \ 53 .prev = &name, \ 54 .next = &name \ 59 list_t name = { \ 60 .head = { \ 61 .prev = &(name).head, \ 62 .next = &(name).head \ 63 } \ 55 64 } 56 65 … … 59 68 60 69 #define list_foreach(list, iterator) \ 61 for (link_t *iterator = (list).next; \ 62 iterator != &(list); iterator = iterator->next) 70 for (link_t *iterator = (list).head.next; \ 71 iterator != &(list).head; iterator = iterator->next) 72 73 #define assert_link_not_used(link) \ 74 assert((link)->prev == NULL && (link)->next == NULL) 63 75 64 76 /** Initialize doubly-linked circular list link … … 79 91 * Initialize doubly-linked circular list. 80 92 * 81 * @param list Pointer to link_t structure representing the list. 82 * 83 */ 84 static inline void list_initialize(link_t *list) 85 { 86 list->prev = list; 87 list->next = list; 93 * @param list Pointer to list_t structure. 94 * 95 */ 96 static inline void list_initialize(list_t *list) 97 { 98 list->head.prev = &list->head; 99 list->head.next = &list->head; 100 } 101 102 /** Insert item before another item in doubly-linked circular list. 103 * 104 */ 105 static inline void list_insert_before(link_t *lnew, link_t *lold) 106 { 107 lnew->next = lold; 108 lnew->prev = lold->prev; 109 lold->prev->next = lnew; 110 lold->prev = lnew; 111 } 112 113 /** Insert item after another item in doubly-linked circular list. 114 * 115 */ 116 static inline void list_insert_after(link_t *lnew, link_t *lold) 117 { 118 lnew->prev = lold; 119 lnew->next = lold->next; 120 lold->next->prev = lnew; 121 lold->next = lnew; 88 122 } 89 123 … … 93 127 * 94 128 * @param link Pointer to link_t structure to be added. 95 * @param list Pointer to link_t structure representing the list. 96 * 97 */ 98 static inline void list_prepend(link_t *link, link_t *list) 99 { 100 link->next = list->next; 101 link->prev = list; 102 list->next->prev = link; 103 list->next = link; 129 * @param list Pointer to list_t structure. 130 * 131 */ 132 static inline void list_prepend(link_t *link, list_t *list) 133 { 134 list_insert_after(link, &list->head); 104 135 } 105 136 … … 109 140 * 110 141 * @param link Pointer to link_t structure to be added. 111 * @param list Pointer to link_t structure representing the list. 112 * 113 */ 114 static inline void list_append(link_t *link, link_t *list) 115 { 116 link->prev = list->prev; 117 link->next = list; 118 list->prev->next = link; 119 list->prev = link; 120 } 121 122 /** Insert item before another item in doubly-linked circular list. 123 * 124 */ 125 static inline void list_insert_before(link_t *link, link_t *list) 126 { 127 list_append(link, list); 128 } 129 130 /** Insert item after another item in doubly-linked circular list. 131 * 132 */ 133 static inline void list_insert_after(link_t *link, link_t *list) 134 { 135 list_prepend(list, link); 142 * @param list Pointer to list_t structure. 143 * 144 */ 145 static inline void list_append(link_t *link, list_t *list) 146 { 147 list_insert_before(link, &list->head); 136 148 } 137 149 … … 155 167 * Query emptiness of doubly-linked circular list. 156 168 * 157 * @param list Pointer to lin k_t structure representing the list.158 * 159 */ 160 static inline int list_empty(li nk_t *list)161 { 162 return (list-> next == list);163 } 164 165 /** Get head item of alist.166 * 167 * @param list Pointer to li nk_t structure representing the list.169 * @param list Pointer to lins_t structure. 170 * 171 */ 172 static inline int list_empty(list_t *list) 173 { 174 return (list->head.next == &list->head); 175 } 176 177 /** Get first item in list. 178 * 179 * @param list Pointer to list_t structure. 168 180 * 169 181 * @return Head item of the list. … … 171 183 * 172 184 */ 173 static inline link_t *list_head(link_t *list) 174 { 175 return ((list->next == list) ? NULL : list->next); 185 static inline link_t *list_first(list_t *list) 186 { 187 return ((list->head.next == &list->head) ? NULL : list->head.next); 188 } 189 190 /** Get last item in list. 191 * 192 * @param list Pointer to list_t structure. 193 * 194 * @return Head item of the list. 195 * @return NULL if the list is empty. 196 * 197 */ 198 static inline link_t *list_last(list_t *list) 199 { 200 return ((list->head.prev == &list->head) ? NULL : list->head.prev); 176 201 } 177 202 … … 230 255 } 231 256 232 /** Get n-th item ofa list.257 /** Get n-th item in a list. 233 258 * 234 259 * @param list Pointer to link_t structure representing the list. … … 239 264 * 240 265 */ 241 static inline link_t *list_nth(li nk_t *list, unsigned int n)266 static inline link_t *list_nth(list_t *list, unsigned int n) 242 267 { 243 268 unsigned int cnt = 0; … … 253 278 } 254 279 255 extern int list_member(const link_t *, const li nk_t *);256 extern void list_concat(li nk_t *, link_t *);257 extern unsigned int list_count(const li nk_t *);280 extern int list_member(const link_t *, const list_t *); 281 extern void list_concat(list_t *, list_t *); 282 extern unsigned int list_count(const list_t *); 258 283 259 284 #endif -
uspace/lib/c/include/adt/measured_strings.h
r5974661 re4f8c77 41 41 42 42 #include <sys/types.h> 43 #include <async.h> 43 44 44 45 /** Type definition of the character string with measured length. … … 64 65 extern int measured_strings_receive(measured_string_t **, uint8_t **, size_t); 65 66 extern int measured_strings_reply(const measured_string_t *, size_t); 66 extern int measured_strings_return(int, measured_string_t **, uint8_t **, size_t); 67 extern int measured_strings_send(int, const measured_string_t *, size_t); 67 68 extern int measured_strings_return(async_exch_t *, measured_string_t **, 69 uint8_t **, size_t); 70 extern int measured_strings_send(async_exch_t *, const measured_string_t *, 71 size_t); 68 72 69 73 #endif -
uspace/lib/c/include/adt/prodcons.h
r5974661 re4f8c77 42 42 fibril_mutex_t mtx; 43 43 fibril_condvar_t cv; 44 li nk_t list;44 list_t list; 45 45 } prodcons_t; 46 46 -
uspace/lib/c/include/async.h
r5974661 re4f8c77 53 53 typedef void (*async_client_data_dtor_t)(void *); 54 54 55 typedef void (*async_client_conn_t)(ipc_callid_t, ipc_call_t *); 55 /** Client connection handler 56 * 57 * @param callid ID of incoming call or 0 if connection initiated from 58 * inside using async_connect_to_me() 59 * @param call Incoming call or 0 if connection initiated from inside 60 * @param arg Local argument passed from async_new_connection() or 61 * async_connect_to_me() 62 */ 63 typedef void (*async_client_conn_t)(ipc_callid_t, ipc_call_t *, void *); 64 65 /** Interrupt handler */ 66 typedef void (*async_interrupt_handler_t)(ipc_callid_t, ipc_call_t *); 56 67 57 68 /** Exchange management style … … 88 99 typedef struct { 89 100 /** List of inactive exchanges */ 90 li nk_t exch_list;101 list_t exch_list; 91 102 92 103 /** Exchange management style */ … … 166 177 167 178 extern fid_t async_new_connection(sysarg_t, sysarg_t, ipc_callid_t, 168 ipc_call_t *, async_client_conn_t );179 ipc_call_t *, async_client_conn_t, void *); 169 180 170 181 extern void async_usleep(suseconds_t); … … 177 188 178 189 extern void async_set_client_connection(async_client_conn_t); 179 extern void async_set_interrupt_received(async_ client_conn_t);190 extern void async_set_interrupt_received(async_interrupt_handler_t); 180 191 181 192 /* … … 351 362 352 363 extern int async_connect_to_me(async_exch_t *, sysarg_t, sysarg_t, sysarg_t, 353 async_client_conn_t );364 async_client_conn_t, void *); 354 365 355 366 extern int async_hangup(async_sess_t *); -
uspace/lib/c/include/async_obsolete.h
r5974661 re4f8c77 40 40 #define LIBC_ASYNC_OBSOLETE_H_ 41 41 42 extern void async_obsolete_serialize_start(void);43 extern void async_obsolete_serialize_end(void);44 45 42 #define async_obsolete_send_0(phoneid, method, dataptr) \ 46 43 async_obsolete_send_fast((phoneid), (method), 0, 0, 0, 0, (dataptr)) … … 198 195 199 196 extern int async_obsolete_connect_to_me(int, sysarg_t, sysarg_t, sysarg_t, 200 async_client_conn_t );197 async_client_conn_t, void *); 201 198 extern int async_obsolete_connect_me_to(int, sysarg_t, sysarg_t, sysarg_t); 202 199 extern int async_obsolete_connect_me_to_blocking(int, sysarg_t, sysarg_t, sysarg_t); -
uspace/lib/c/include/bitops.h
r5974661 re4f8c77 38 38 #include <sys/types.h> 39 39 40 /** Mask with bit @a n set. */ 41 #define BIT_V(type, n) \ 42 ((type)1 << ((n) - 1)) 43 44 /** Mask with rightmost @a n bits set. */ 45 #define BIT_RRANGE(type, n) \ 46 (BIT_V(type, (n) + 1) - 1) 47 48 /** Mask with bits @a hi .. @a lo set. @a hi >= @a lo. */ 49 #define BIT_RANGE(type, hi, lo) \ 50 (BIT_RRANGE(type, (hi) - (lo) + 1) << (lo)) 51 52 /** Extract range of bits @a hi .. @a lo from @a value. */ 53 #define BIT_RANGE_EXTRACT(type, hi, lo, value) \ 54 (((value) >> (lo)) & BIT_RRANGE(type, (hi) - (lo) + 1)) 40 55 41 56 /** Return position of first non-zero bit from left (i.e. [log_2(arg)]). -
uspace/lib/c/include/fibril_synch.h
r5974661 re4f8c77 45 45 fibril_owner_info_t oi; /**< Keep this the first thing. */ 46 46 int counter; 47 li nk_t waiters;47 list_t waiters; 48 48 } fibril_mutex_t; 49 49 … … 55 55 .counter = 1, \ 56 56 .waiters = { \ 57 .prev = &name.waiters, \ 58 .next = &name.waiters, \ 57 .head = { \ 58 .prev = &(name).waiters.head, \ 59 .next = &(name).waiters.head, \ 60 } \ 59 61 } \ 60 62 } … … 67 69 unsigned writers; 68 70 unsigned readers; 69 li nk_t waiters;71 list_t waiters; 70 72 } fibril_rwlock_t; 71 73 … … 78 80 .writers = 0, \ 79 81 .waiters = { \ 80 .prev = &name.waiters, \ 81 .next = &name.waiters, \ 82 .head = { \ 83 .prev = &(name).waiters.head, \ 84 .next = &(name).waiters.head, \ 85 } \ 82 86 } \ 83 87 } … … 87 91 88 92 typedef struct { 89 li nk_t waiters;93 list_t waiters; 90 94 } fibril_condvar_t; 91 95 … … 93 97 { \ 94 98 .waiters = { \ 95 .next = &name.waiters, \ 96 .prev = &name.waiters, \ 99 .head = { \ 100 .next = &(name).waiters.head, \ 101 .prev = &(name).waiters.head, \ 102 } \ 97 103 } \ 98 104 } -
uspace/lib/c/include/ipc/clipboard.h
r5974661 re4f8c77 36 36 #define LIBC_IPC_CLIPBOARD_H_ 37 37 38 #include <ipc/common.h> 39 38 40 typedef enum { 39 41 CLIPBOARD_PUT_DATA = IPC_FIRST_USER_METHOD, -
uspace/lib/c/include/ipc/console.h
r5974661 re4f8c77 48 48 CONSOLE_SET_COLOR, 49 49 CONSOLE_SET_RGB_COLOR, 50 CONSOLE_CURSOR_VISIBILITY, 51 CONSOLE_KCON_ENABLE 50 CONSOLE_CURSOR_VISIBILITY 52 51 } console_request_t; 53 52 -
uspace/lib/c/include/ipc/devman.h
r5974661 re4f8c77 72 72 */ 73 73 typedef struct match_id_list { 74 li nk_t ids;74 list_t ids; 75 75 } match_id_list_t; 76 76 … … 95 95 { 96 96 match_id_t *mid = NULL; 97 link_t *link = ids->ids. next;97 link_t *link = ids->ids.head.next; 98 98 99 while (link != &ids->ids ) {99 while (link != &ids->ids.head) { 100 100 mid = list_get_instance(link, match_id_t,link); 101 101 if (mid->score < id->score) { 102 102 break; 103 } 103 } 104 104 link = link->next; 105 105 } … … 118 118 match_id_t *id; 119 119 120 while (!list_empty(&ids->ids)) {121 link = ids->ids.next;122 list_remove(link); 120 while (!list_empty(&ids->ids)) { 121 link = list_first(&ids->ids); 122 list_remove(link); 123 123 id = list_get_instance(link, match_id_t, link); 124 delete_match_id(id); 125 } 124 delete_match_id(id); 125 } 126 126 } 127 127 -
uspace/lib/c/include/ipc/mouseev.h
r5974661 re4f8c77 27 27 */ 28 28 29 /** @addtogroup kbdgen generic 30 * @brief HelenOS generic uspace keyboard handler. 31 * @ingroup kbd 29 /** @addtogroup mouse 30 * @brief 32 31 * @{ 33 32 */ … … 35 34 */ 36 35 37 #ifndef LIBC_IPC_ KBD_H_38 #define LIBC_IPC_ KBD_H_36 #ifndef LIBC_IPC_MOUSEEV_H_ 37 #define LIBC_IPC_MOUSEEV_H_ 39 38 40 39 #include <ipc/common.h> … … 42 41 43 42 typedef enum { 44 KBD_YIELD = DEV_FIRST_CUSTOM_METHOD,45 KBD_RECLAIM46 } kbd_request_t;43 MOUSEEV_YIELD = DEV_FIRST_CUSTOM_METHOD, 44 MOUSEEV_RECLAIM 45 } mouseev_request_t; 47 46 48 47 typedef enum { 49 KBD_EVENT = IPC_FIRST_USER_METHOD 50 } kbd_notif_t; 48 MOUSEEV_MOVE_EVENT = IPC_FIRST_USER_METHOD, 49 MOUSEEV_BUTTON_EVENT 50 } mouseev_notif_t; 51 51 52 52 #endif -
uspace/lib/c/include/ipc/net.h
r5974661 re4f8c77 335 335 #define IPC_GET_ERROR(call) ((services_t) IPC_GET_ARG4(call)) 336 336 337 /** Return the phone message argument.338 *339 * @param[in] call Message call structure.340 *341 */342 #define IPC_GET_PHONE(call) ((int) IPC_GET_ARG5(call))343 344 337 /** Set the device identifier in the message answer. 345 338 * -
uspace/lib/c/include/ipc/services.h
r5974661 re4f8c77 38 38 #define LIBC_SERVICES_H_ 39 39 40 #include <fourcc.h> 41 40 42 typedef enum { 41 SERVICE_NONE = 0, 42 SERVICE_LOAD, 43 SERVICE_PCI, 44 SERVICE_VIDEO, 45 SERVICE_CONSOLE, 46 SERVICE_VFS, 47 SERVICE_DEVMAP, 48 SERVICE_DEVMAN, 49 SERVICE_IRC, 50 SERVICE_CLIPBOARD, 51 SERVICE_NETWORKING, 52 SERVICE_LO, 53 SERVICE_NE2000, 54 SERVICE_ETHERNET, 55 SERVICE_NILDUMMY, 56 SERVICE_IP, 57 SERVICE_ARP, 58 SERVICE_RARP, 59 SERVICE_ICMP, 60 SERVICE_UDP, 61 SERVICE_TCP, 62 SERVICE_SOCKET 43 SERVICE_NONE = 0, 44 SERVICE_LOAD = FOURCC('l', 'o', 'a', 'd'), 45 SERVICE_VIDEO = FOURCC('v', 'i', 'd', ' '), 46 SERVICE_VFS = FOURCC('v', 'f', 's', ' '), 47 SERVICE_DEVMAP = FOURCC('d', 'e', 'v', 'p'), 48 SERVICE_DEVMAN = FOURCC('d', 'e', 'v', 'n'), 49 SERVICE_IRC = FOURCC('i', 'r', 'c', ' '), 50 SERVICE_CLIPBOARD = FOURCC('c', 'l', 'i', 'p'), 51 SERVICE_NETWORKING = FOURCC('n', 'e', 't', ' '), 52 SERVICE_LO = FOURCC('l', 'o', ' ', ' '), 53 SERVICE_NE2000 = FOURCC('n', 'e', '2', 'k'), 54 SERVICE_ETHERNET = FOURCC('e', 't', 'h', ' '), 55 SERVICE_NILDUMMY = FOURCC('n', 'i', 'l', 'd'), 56 SERVICE_IP = FOURCC('i', 'p', 'v', '4'), 57 SERVICE_ARP = FOURCC('a', 'r', 'p', ' '), 58 SERVICE_ICMP = FOURCC('i', 'c', 'm', 'p'), 59 SERVICE_UDP = FOURCC('u', 'd', 'p', ' '), 60 SERVICE_TCP = FOURCC('t', 'c', 'p', ' ') 63 61 } services_t; 64 62 -
uspace/lib/c/include/net/icmp_api.h
r5974661 re4f8c77 42 42 #include <sys/types.h> 43 43 #include <sys/time.h> 44 45 44 #include <adt/measured_strings.h> 46 45 #include <net/ip_codes.h> 47 46 #include <net/icmp_codes.h> 48 47 #include <net/icmp_common.h> 48 #include <async.h> 49 49 50 50 /** @name ICMP module application interface … … 53 53 /*@{*/ 54 54 55 extern int icmp_echo_msg( int, size_t, mseconds_t, ip_ttl_t, ip_tos_t, int,56 const struct sockaddr *, socklen_t);55 extern int icmp_echo_msg(async_sess_t *, size_t, mseconds_t, ip_ttl_t, ip_tos_t, 56 int, const struct sockaddr *, socklen_t); 57 57 58 58 /*@}*/ -
uspace/lib/c/include/net/icmp_common.h
r5974661 re4f8c77 40 40 #include <ipc/services.h> 41 41 #include <sys/time.h> 42 #include <async.h> 42 43 43 /** Default timeout for incoming connections in microseconds (1 sec). */ 44 #define ICMP_CONNECT_TIMEOUT 1000000 45 46 extern int icmp_connect_module(suseconds_t); 44 extern async_sess_t *icmp_connect_module(void); 47 45 48 46 #endif -
uspace/lib/c/include/net/modules.h
r5974661 re4f8c77 46 46 #include <sys/time.h> 47 47 48 /** Connect to the neededmodule function type definition.48 /** Connect to module function type definition. 49 49 * 50 * @param[in] need The needed module service. 51 * 52 * @return The phone of the needed service. 50 * @return Session to the service. 53 51 * 54 52 */ 55 typedef int connect_module_t(services_t need);53 typedef async_sess_t *connect_module_t(services_t); 56 54 57 55 extern void answer_call(ipc_callid_t, int, ipc_call_t *, size_t); 58 extern intbind_service(services_t, sysarg_t, sysarg_t, sysarg_t,56 extern async_sess_t *bind_service(services_t, sysarg_t, sysarg_t, sysarg_t, 59 57 async_client_conn_t); 60 extern int bind_service_timeout(services_t, sysarg_t, sysarg_t, sysarg_t, 61 async_client_conn_t, suseconds_t); 62 extern int connect_to_service(services_t); 63 extern int connect_to_service_timeout(services_t, suseconds_t); 58 extern async_sess_t *connect_to_service(services_t); 64 59 extern int data_reply(void *, size_t); 65 60 extern void refresh_answer(ipc_call_t *, size_t *); -
uspace/lib/c/include/str.h
r5974661 re4f8c77 48 48 #define STR_BOUNDS(length) ((length) << 2) 49 49 50 /** 51 * Maximum size of a buffer needed to a string converted from space-padded 52 * ASCII of size @a spa_size using spascii_to_str(). 53 */ 54 #define SPASCII_STR_BUFSIZE(spa_size) ((spa_size) + 1) 55 50 56 extern wchar_t str_decode(const char *str, size_t *offset, size_t sz); 51 57 extern int chr_encode(const wchar_t ch, char *str, size_t *offset, size_t sz); … … 73 79 extern void str_append(char *dest, size_t size, const char *src); 74 80 81 extern int spascii_to_str(char *dest, size_t size, const uint8_t *src, size_t n); 75 82 extern void wstr_to_str(char *dest, size_t size, const wchar_t *src); 76 83 extern char *wstr_to_astr(const wchar_t *src); -
uspace/lib/c/include/task.h
r5974661 re4f8c77 37 37 38 38 #include <sys/types.h> 39 #include <vfs/vfs.h> 39 40 40 41 typedef uint64_t task_id_t; … … 51 52 extern task_id_t task_spawn(const char *, const char *const[], int *); 52 53 extern int task_spawnv(task_id_t *, const char *path, const char *const []); 54 extern int task_spawnvf(task_id_t *, const char *path, const char *const [], 55 fdi_node_t *const []); 53 56 extern int task_spawnl(task_id_t *, const char *path, ...); 54 57
Note:
See TracChangeset
for help on using the changeset viewer.
