Changeset 58775d30 in mainline for uspace/lib/c/include
- Timestamp:
- 2015-03-16T16:07:21Z (11 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 2003739
- Parents:
- 6069061 (diff), 795e2bf (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/include
- Files:
-
- 2 added
- 7 edited
-
adt/list.h (modified) (1 diff)
-
compiler/barrier.h (added)
-
futex.h (modified) (1 diff)
-
io/window.h (modified) (2 diffs)
-
ipc/common.h (modified) (2 diffs)
-
malloc.h (modified) (1 diff)
-
rwlock.h (modified) (1 diff)
-
smp_memory_barrier.h (added)
-
sys/time.h (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/include/adt/list.h
r6069061 r58775d30 58 58 */ 59 59 #define LIST_INITIALIZE(name) \ 60 list_t name = { \ 60 list_t name = LIST_INITIALIZER(name) 61 62 /** Initializer for statically allocated list. 63 * 64 * @code 65 * struct named_list { 66 * const char *name; 67 * list_t list; 68 * } var = { 69 * .name = "default name", 70 * .list = LIST_INITIALIZER(name_list.list) 71 * }; 72 * @endcode 73 * 74 * @param name Name of the new statically allocated list. 75 * 76 */ 77 #define LIST_INITIALIZER(name) \ 78 { \ 61 79 .head = { \ 62 80 .prev = &(name).head, \ -
uspace/lib/c/include/futex.h
r6069061 r58775d30 38 38 #include <atomic.h> 39 39 #include <sys/types.h> 40 #include <libc.h> 40 41 41 #define FUTEX_INITIALIZER {1} 42 typedef struct futex { 43 atomic_t val; 44 #ifdef FUTEX_UPGRADABLE 45 int upgraded; 46 #endif 47 } futex_t; 42 48 43 typedef atomic_t futex_t;44 49 45 50 extern void futex_initialize(futex_t *futex, int value); 46 extern int futex_down(futex_t *futex); 47 extern int futex_trydown(futex_t *futex); 48 extern int futex_up(futex_t *futex); 51 52 #ifdef FUTEX_UPGRADABLE 53 #include <rcu.h> 54 55 #define FUTEX_INITIALIZE(val) {{ (val) }, 0} 56 57 #define futex_lock(fut) \ 58 ({ \ 59 rcu_read_lock(); \ 60 (fut)->upgraded = rcu_access(_upgrade_futexes); \ 61 if ((fut)->upgraded) \ 62 (void) futex_down((fut)); \ 63 }) 64 65 #define futex_trylock(fut) \ 66 ({ \ 67 rcu_read_lock(); \ 68 int _upgraded = rcu_access(_upgrade_futexes); \ 69 if (_upgraded) { \ 70 int _acquired = futex_trydown((fut)); \ 71 if (!_acquired) { \ 72 rcu_read_unlock(); \ 73 } else { \ 74 (fut)->upgraded = true; \ 75 } \ 76 _acquired; \ 77 } else { \ 78 (fut)->upgraded = false; \ 79 1; \ 80 } \ 81 }) 82 83 #define futex_unlock(fut) \ 84 ({ \ 85 if ((fut)->upgraded) \ 86 (void) futex_up((fut)); \ 87 rcu_read_unlock(); \ 88 }) 89 90 extern int _upgrade_futexes; 91 92 extern void futex_upgrade_all_and_wait(void); 93 94 #else 95 96 #define FUTEX_INITIALIZE(val) {{ (val) }} 97 98 #define futex_lock(fut) (void) futex_down((fut)) 99 #define futex_trylock(fut) futex_trydown((fut)) 100 #define futex_unlock(fut) (void) futex_up((fut)) 101 102 #endif 103 104 #define FUTEX_INITIALIZER FUTEX_INITIALIZE(1) 105 106 /** Try to down the futex. 107 * 108 * @param futex Futex. 109 * 110 * @return Non-zero if the futex was acquired. 111 * @return Zero if the futex was not acquired. 112 * 113 */ 114 static inline int futex_trydown(futex_t *futex) 115 { 116 return cas(&futex->val, 1, 0); 117 } 118 119 /** Down the futex. 120 * 121 * @param futex Futex. 122 * 123 * @return ENOENT if there is no such virtual address. 124 * @return Zero in the uncontended case. 125 * @return Otherwise one of ESYNCH_OK_ATOMIC or ESYNCH_OK_BLOCKED. 126 * 127 */ 128 static inline int futex_down(futex_t *futex) 129 { 130 if ((atomic_signed_t) atomic_predec(&futex->val) < 0) 131 return __SYSCALL1(SYS_FUTEX_SLEEP, (sysarg_t) &futex->val.count); 132 133 return 0; 134 } 135 136 /** Up the futex. 137 * 138 * @param futex Futex. 139 * 140 * @return ENOENT if there is no such virtual address. 141 * @return Zero in the uncontended case. 142 * 143 */ 144 static inline int futex_up(futex_t *futex) 145 { 146 if ((atomic_signed_t) atomic_postinc(&futex->val) < 0) 147 return __SYSCALL1(SYS_FUTEX_WAKEUP, (sysarg_t) &futex->val.count); 148 149 return 0; 150 } 49 151 50 152 #endif -
uspace/lib/c/include/io/window.h
r6069061 r58775d30 42 42 #include <io/kbd_event.h> 43 43 #include <io/pos_event.h> 44 45 typedef enum { 46 WINDOW_MAIN = 1, 47 WINDOW_DECORATED = 2, 48 WINDOW_RESIZEABLE = 4 49 } window_flags_t; 44 50 45 51 typedef enum { … … 108 114 } window_event_t; 109 115 110 extern int win_register(async_sess_t *, service_id_t *, service_id_t *); 116 extern int win_register(async_sess_t *, window_flags_t, service_id_t *, 117 service_id_t *); 111 118 112 119 extern int win_get_event(async_sess_t *, window_event_t *); -
uspace/lib/c/include/ipc/common.h
r6069061 r58775d30 40 40 #include <atomic.h> 41 41 #include <abi/proc/task.h> 42 #include <futex.h> 42 43 43 44 #define IPC_FLAG_BLOCKING 0x01 … … 51 52 typedef sysarg_t ipc_callid_t; 52 53 53 extern atomic_t async_futex;54 extern futex_t async_futex; 54 55 55 56 #endif -
uspace/lib/c/include/malloc.h
r6069061 r58775d30 48 48 extern void *heap_check(void); 49 49 50 extern void malloc_enable_multithreaded(void); 50 51 #endif 51 52 -
uspace/lib/c/include/rwlock.h
r6069061 r58775d30 49 49 50 50 #define rwlock_initialize(rwlock) futex_initialize((rwlock), 1) 51 #define rwlock_read_lock(rwlock) futex_ down((rwlock))52 #define rwlock_write_lock(rwlock) futex_ down((rwlock))53 #define rwlock_read_unlock(rwlock) futex_u p((rwlock))54 #define rwlock_write_unlock(rwlock) futex_u p((rwlock))51 #define rwlock_read_lock(rwlock) futex_lock((rwlock)) 52 #define rwlock_write_lock(rwlock) futex_lock((rwlock)) 53 #define rwlock_read_unlock(rwlock) futex_unlock((rwlock)) 54 #define rwlock_write_unlock(rwlock) futex_unlock((rwlock)) 55 55 56 56 #endif -
uspace/lib/c/include/sys/time.h
r6069061 r58775d30 50 50 51 51 struct tm { 52 int tm_usec; /* Microseconds [0,999999]. */ 52 53 int tm_sec; /* Seconds [0,60]. */ 53 54 int tm_min; /* Minutes [0,59]. */ … … 71 72 }; 72 73 73 extern void tv_add(struct timeval *, suseconds_t); 74 extern suseconds_t tv_sub(struct timeval *, struct timeval *); 74 extern void tv_add_diff(struct timeval *, suseconds_t); 75 extern void tv_add(struct timeval *, struct timeval *); 76 extern suseconds_t tv_sub_diff(struct timeval *, struct timeval *); 77 extern void tv_sub(struct timeval *, struct timeval *); 75 78 extern int tv_gt(struct timeval *, struct timeval *); 76 79 extern int tv_gteq(struct timeval *, struct timeval *); … … 79 82 80 83 extern void udelay(useconds_t); 84 extern int usleep(useconds_t); 81 85 82 86 extern time_t mktime(struct tm *); … … 84 88 extern int time_utc2str(const time_t, char *); 85 89 extern void time_tm2str(const struct tm *, char *); 90 extern int time_tv2tm(const struct timeval *, struct tm *); 86 91 extern int time_local2tm(const time_t, struct tm *); 87 92 extern int time_local2str(const time_t, char *);
Note:
See TracChangeset
for help on using the changeset viewer.
