Changeset 46c20c8 in mainline for uspace/lib/c/include/ipc/packet.h
- Timestamp:
- 2010-11-26T20:08:10Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 45df59a
- Parents:
- fb150d78 (diff), ffdd2b9 (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. - File:
-
- 1 moved
-
uspace/lib/c/include/ipc/packet.h (moved) (moved from kernel/generic/include/synch/rwlock.h ) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/include/ipc/packet.h
rfb150d78 r46c20c8 1 1 /* 2 * Copyright (c) 200 1-2004 Jakub Jermar2 * Copyright (c) 2009 Lukas Mejdrech 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup sync 30 * @{ 31 */ 32 /** @file 29 /** @addtogroup libc 30 * @{ 33 31 */ 34 32 35 #ifndef KERN_RWLOCK_H_ 36 #define KERN_RWLOCK_H_ 33 /** @file 34 * Packet server module messages. 35 */ 37 36 38 #include <arch/types.h> 39 #include <synch/mutex.h> 40 #include <synch/synch.h> 41 #include <synch/spinlock.h> 37 #ifndef LIBC_PACKET_MESSAGES_ 38 #define LIBC_PACKET_MESSAGES_ 42 39 40 #include <ipc/ipc.h> 41 #include <ipc/net.h> 42 43 /** Packet server module messages. */ 43 44 typedef enum { 44 RWLOCK_NONE, 45 RWLOCK_READER, 46 RWLOCK_WRITER 47 } rwlock_type_t; 45 /** Create packet message with specified content length. 46 * @see packet_get_1() 47 */ 48 NET_PACKET_CREATE_1 = NET_PACKET_FIRST, 49 50 /** 51 * Create packet message with specified address length, prefix, content 52 * and suffix. 53 * @see packet_get_4() 54 */ 55 NET_PACKET_CREATE_4, 56 57 /** Get packet message. 58 * @see packet_return() */ 59 NET_PACKET_GET, 60 61 /** Get packet size message. 62 * @see packet_translate() 63 */ 64 NET_PACKET_GET_SIZE, 65 66 /** Release packet message. 67 * @see pq_release() 68 */ 69 NET_PACKET_RELEASE 70 } packet_messages; 48 71 49 typedef struct { 50 SPINLOCK_DECLARE(lock); 51 /** 52 * Mutex for writers, readers can bypass it if readers_in is positive. 53 */ 54 mutex_t exclusive; 55 /** Number of readers in critical section. */ 56 size_t readers_in; 57 } rwlock_t; 72 /** Returns the protocol service message parameter. */ 73 #define ARP_GET_PROTO(call) (services_t) IPC_GET_ARG2(*call) 58 74 59 #define rwlock_write_lock(rwl) \ 60 _rwlock_write_lock_timeout((rwl), SYNCH_NO_TIMEOUT, SYNCH_FLAGS_NONE) 61 #define rwlock_read_lock(rwl) \ 62 _rwlock_read_lock_timeout((rwl), SYNCH_NO_TIMEOUT, SYNCH_FLAGS_NONE) 63 #define rwlock_write_trylock(rwl) \ 64 _rwlock_write_lock_timeout((rwl), SYNCH_NO_TIMEOUT, \ 65 SYNCH_FLAGS_NON_BLOCKING) 66 #define rwlock_read_trylock(rwl) \ 67 _rwlock_read_lock_timeout((rwl), SYNCH_NO_TIMEOUT, \ 68 SYNCH_FLAGS_NON_BLOCKING) 69 #define rwlock_write_lock_timeout(rwl, usec) \ 70 _rwlock_write_lock_timeout((rwl), (usec), SYNCH_FLAGS_NONE) 71 #define rwlock_read_lock_timeout(rwl, usec) \ 72 _rwlock_read_lock_timeout((rwl), (usec), SYNCH_FLAGS_NONE) 75 /** Returns the packet identifier message parameter. */ 76 #define IPC_GET_ID(call) (packet_id_t) IPC_GET_ARG1(*call) 73 77 74 extern void rwlock_initialize(rwlock_t *rwl); 75 extern void rwlock_read_unlock(rwlock_t *rwl); 76 extern void rwlock_write_unlock(rwlock_t *rwl); 77 extern int _rwlock_read_lock_timeout(rwlock_t *rwl, uint32_t usec, int flags); 78 extern int _rwlock_write_lock_timeout(rwlock_t *rwl, uint32_t usec, int flags); 78 /** Returns the maximal content length message parameter. */ 79 #define IPC_GET_CONTENT(call) (size_t) IPC_GET_ARG1(*call) 80 81 /** Returns the maximal address length message parameter. */ 82 #define IPC_GET_ADDR_LEN(call) (size_t) IPC_GET_ARG2(*call) 83 84 /** Returns the maximal prefix length message parameter. */ 85 #define IPC_GET_PREFIX(call) (size_t) IPC_GET_ARG3(*call) 86 87 /** Returns the maximal suffix length message parameter. */ 88 #define IPC_GET_SUFFIX(call) (size_t) IPC_GET_ARG4(*call) 79 89 80 90 #endif
Note:
See TracChangeset
for help on using the changeset viewer.
