Changeset 192565b in mainline for uspace/lib/c
- Timestamp:
- 2013-05-27T13:18:13Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f2c19b0
- Parents:
- d120133 (diff), c90aed4 (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:
-
- 7 added
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/Makefile
rd120133 r192565b 74 74 generic/device/pci.c \ 75 75 generic/device/ahci.c \ 76 generic/dnsr.c \ 76 77 generic/dlfcn.c \ 77 78 generic/elf/elf_load.c \ … … 91 92 generic/task.c \ 92 93 generic/futex.c \ 94 generic/inet/addr.c \ 93 95 generic/inet.c \ 94 96 generic/inetcfg.c \ -
uspace/lib/c/arch/ia32/src/setjmp.S
rd120133 r192565b 35 35 .type setjmp,@function 36 36 setjmp: 37 movl 0(%esp),%eax # save pc value into eax38 movl 4(%esp),%edx # address of the jmp_buf structure to save context to39 40 37 movl 0(%esp),%eax # save pc value into eax 38 movl 4(%esp),%edx # address of the jmp_buf structure to save context to 39 40 # save registers to the jmp_buf structure 41 41 CONTEXT_SAVE_ARCH_CORE %edx %eax 42 43 xorl %eax,%eax 42 43 xorl %eax,%eax # set_jmp returns 0 44 44 ret 45 45 46 46 .type longjmp,@function 47 47 longjmp: 48 49 movl 4(%esp), %ecx # put address of jmp_buf into ecx 50 movl 8(%esp), %eax # put return value into eax 51 52 # restore registers from the jmp_buf structure 48 movl 4(%esp), %ecx # put address of jmp_buf into ecx 49 movl 8(%esp), %eax # put return value into eax 50 51 # restore registers from the jmp_buf structure 53 52 CONTEXT_RESTORE_ARCH_CORE %ecx %edx 54 55 movl %edx,0(%esp) 53 54 movl %edx,0(%esp) # put saved pc on stack 56 55 ret 57 -
uspace/lib/c/generic/adt/hash_table.c
rd120133 r192565b 81 81 * @param init_size Initial desired number of hash table buckets. Pass zero 82 82 * if you want the default initial size. 83 * @param max_keys Maximal number of keys needed to identify an item. 83 * @param max_load The table is resized when the average load per bucket 84 * exceeds this number. Pass zero if you want the default. 84 85 * @param op Hash table operations structure. remove_callback() 85 86 * is optional and can be NULL if no action is to be taken -
uspace/lib/c/generic/async.c
rd120133 r192565b 2090 2090 * @param arg User defined argument. 2091 2091 * @param flags Storage for the received flags. Can be NULL. 2092 * @param dst Destination address space area base. Cannot be NULL. 2092 * @param dst Address of the storage for the destination address space area 2093 * base address. Cannot be NULL. 2093 2094 * 2094 2095 * @return Zero on success or a negative error code from errno.h. … … 2218 2219 * 2219 2220 * @param callid Hash of the IPC_M_DATA_WRITE call to answer. 2220 * @param dst Destination address space area base address. 2221 * @param dst Address of the storage for the destination address space area 2222 * base address. 2221 2223 * 2222 2224 * @return Zero on success or a value from @ref errno.h on failure. -
uspace/lib/c/generic/device/hw_res_parsed.c
rd120133 r192565b 221 221 hw_resource_list_t hw_resources; 222 222 hw_res_list_parsed_clean(hw_res_parsed); 223 bzero(&hw_resources, sizeof(hw_resource_list_t));223 memset(&hw_resources, 0, sizeof(hw_resource_list_t)); 224 224 225 225 int rc = hw_res_get_resource_list(sess, &hw_resources); -
uspace/lib/c/generic/io/con_srv.c
rd120133 r192565b 35 35 */ 36 36 #include <errno.h> 37 #include <io/cons_event.h> 37 38 #include <ipc/console.h> 38 39 #include <stdlib.h> … … 40 41 41 42 #include <io/con_srv.h> 43 44 static int console_ev_encode(cons_event_t *event, ipc_call_t *call) 45 { 46 IPC_SET_ARG1(*call, event->type); 47 48 switch (event->type) { 49 case CEV_KEY: 50 IPC_SET_ARG2(*call, event->ev.key.type); 51 IPC_SET_ARG3(*call, event->ev.key.key); 52 IPC_SET_ARG4(*call, event->ev.key.mods); 53 IPC_SET_ARG5(*call, event->ev.key.c); 54 break; 55 case CEV_POS: 56 IPC_SET_ARG2(*call, (event->ev.pos.pos_id << 16) | (event->ev.pos.type & 0xffff)); 57 IPC_SET_ARG3(*call, event->ev.pos.btn_num); 58 IPC_SET_ARG4(*call, event->ev.pos.hpos); 59 IPC_SET_ARG5(*call, event->ev.pos.vpos); 60 break; 61 default: 62 return EIO; 63 } 64 65 return EOK; 66 } 42 67 43 68 static void con_read_srv(con_srv_t *srv, ipc_callid_t callid, … … 273 298 { 274 299 int rc; 275 kbd_event_t event; 300 cons_event_t event; 301 ipc_call_t result; 276 302 277 303 if (srv->srvs->ops->get_event == NULL) { … … 281 307 282 308 rc = srv->srvs->ops->get_event(srv, &event); 283 async_answer_4(callid, rc, event.type, event.key, event.mods, event.c); 309 if (rc != EOK) { 310 async_answer_0(callid, rc); 311 return; 312 } 313 314 rc = console_ev_encode(&event, &result); 315 if (rc != EOK) { 316 async_answer_0(callid, rc); 317 return; 318 } 319 320 async_answer_5(callid, rc, IPC_GET_ARG1(result), IPC_GET_ARG2(result), 321 IPC_GET_ARG3(result), IPC_GET_ARG4(result), IPC_GET_ARG5(result)); 284 322 } 285 323 -
uspace/lib/c/generic/io/console.c
rd120133 r192565b 154 154 } 155 155 156 bool console_get_kbd_event(console_ctrl_t *ctrl, kbd_event_t *event) 156 static int console_ev_decode(ipc_call_t *call, cons_event_t *event) 157 { 158 event->type = IPC_GET_ARG1(*call); 159 160 switch (event->type) { 161 case CEV_KEY: 162 event->ev.key.type = IPC_GET_ARG2(*call); 163 event->ev.key.key = IPC_GET_ARG3(*call); 164 event->ev.key.mods = IPC_GET_ARG4(*call); 165 event->ev.key.c = IPC_GET_ARG5(*call); 166 break; 167 case CEV_POS: 168 event->ev.pos.pos_id = IPC_GET_ARG2(*call) >> 16; 169 event->ev.pos.type = IPC_GET_ARG2(*call) & 0xffff; 170 event->ev.pos.btn_num = IPC_GET_ARG3(*call); 171 event->ev.pos.hpos = IPC_GET_ARG4(*call); 172 event->ev.pos.vpos = IPC_GET_ARG5(*call); 173 break; 174 default: 175 return EIO; 176 } 177 178 return EOK; 179 } 180 181 bool console_get_event(console_ctrl_t *ctrl, cons_event_t *event) 157 182 { 158 183 if (ctrl->input_aid == 0) { 159 sysarg_t type; 160 sysarg_t key; 161 sysarg_t mods; 162 sysarg_t c; 184 ipc_call_t result; 163 185 164 186 async_exch_t *exch = async_exchange_begin(ctrl->input_sess); 165 int rc = async_req_0_4(exch, CONSOLE_GET_EVENT, &type, &key, &mods, &c);187 aid_t aid = async_send_0(exch, CONSOLE_GET_EVENT, &result); 166 188 async_exchange_end(exch); 189 190 sysarg_t rc; 191 async_wait_for(aid, &rc); 167 192 168 193 if (rc != EOK) { … … 171 196 } 172 197 173 event->type = type; 174 event->key = key; 175 event->mods = mods; 176 event->c = c; 198 rc = console_ev_decode(&result, event); 199 if (rc != EOK) { 200 errno = rc; 201 return false; 202 } 177 203 } else { 178 204 sysarg_t retval; … … 186 212 } 187 213 188 event->type = IPC_GET_ARG1(ctrl->input_call); 189 event->key = IPC_GET_ARG2(ctrl->input_call); 190 event->mods = IPC_GET_ARG3(ctrl->input_call); 191 event->c = IPC_GET_ARG4(ctrl->input_call); 214 int rc = console_ev_decode(&ctrl->input_call, event); 215 if (rc != EOK) { 216 errno = rc; 217 return false; 218 } 192 219 } 193 220 … … 195 222 } 196 223 197 bool console_get_ kbd_event_timeout(console_ctrl_t *ctrl, kbd_event_t *event,224 bool console_get_event_timeout(console_ctrl_t *ctrl, cons_event_t *event, 198 225 suseconds_t *timeout) 199 226 { … … 223 250 } 224 251 225 event->type = IPC_GET_ARG1(ctrl->input_call); 226 event->key = IPC_GET_ARG2(ctrl->input_call); 227 event->mods = IPC_GET_ARG3(ctrl->input_call); 228 event->c = IPC_GET_ARG4(ctrl->input_call); 252 rc = console_ev_decode(&ctrl->input_call, event); 253 if (rc != EOK) { 254 errno = rc; 255 return false; 256 } 229 257 230 258 /* Update timeout */ -
uspace/lib/c/generic/mem.c
rd120133 r192565b 224 224 * @param s1 Pointer to the first area to compare. 225 225 * @param s2 Pointer to the second area to compare. 226 * @param len Size of the first area in bytes. Both areas must have227 * the same length.228 * 229 * @return If len is 0, return zero. If the areas match, return230 * zero. Otherwise return non-zero.231 * 232 */ 233 int bcmp(const void *s1, const void *s2, size_t len)226 * @param len Size of the areas in bytes. 227 * 228 * @return Zero if areas have the same contents. If they differ, 229 * the sign of the result is the same as the sign of the 230 * difference of the first pair of different bytes. 231 * 232 */ 233 int memcmp(const void *s1, const void *s2, size_t len) 234 234 { 235 235 uint8_t *u1 = (uint8_t *) s1; 236 236 uint8_t *u2 = (uint8_t *) s2; 237 238 for (; (len != 0) && (*u1++ == *u2++); len--); 239 240 return len; 237 size_t i; 238 239 for (i = 0; i < len; i++) { 240 if (*u1 != *u2) 241 return (int)(*u1) - (int)(*u2); 242 ++u1; 243 ++u2; 244 } 245 246 return 0; 241 247 } 242 248 -
uspace/lib/c/generic/net/inet.c
rd120133 r192565b 144 144 /* Erase if no address */ 145 145 if (!address) { 146 bzero(data, count);146 memset(data, 0, count); 147 147 return ENOENT; 148 148 } … … 181 181 } else { 182 182 /* Erase the rest of the address */ 183 bzero(data + index, count - index);183 memset(data + index, 0, count - index); 184 184 return EOK; 185 185 } -
uspace/lib/c/generic/net/socket_client.c
rd120133 r192565b 446 446 return ENOMEM; 447 447 448 bzero(socket, sizeof(*socket));448 memset(socket, 0, sizeof(*socket)); 449 449 fibril_rwlock_write_lock(&socket_globals.lock); 450 450 … … 657 657 return ENOMEM; 658 658 } 659 bzero(new_socket, sizeof(*new_socket));659 memset(new_socket, 0, sizeof(*new_socket)); 660 660 socket_id = socket_generate_new_id(); 661 661 if (socket_id <= 0) { -
uspace/lib/c/include/device/hw_res_parsed.h
rd120133 r192565b 127 127 free(list->dma_channels.channels); 128 128 129 bzero(list, sizeof(hw_res_list_parsed_t));129 memset(list, 0, sizeof(hw_res_list_parsed_t)); 130 130 } 131 131 … … 136 136 static inline void hw_res_list_parsed_init(hw_res_list_parsed_t *list) 137 137 { 138 bzero(list, sizeof(hw_res_list_parsed_t));138 memset(list, 0, sizeof(hw_res_list_parsed_t)); 139 139 } 140 140 -
uspace/lib/c/include/inet/inet.h
rd120133 r192565b 36 36 #define LIBC_INET_INET_H_ 37 37 38 #include <inet/addr.h> 38 39 #include <sys/types.h> 39 40 40 41 #define INET_TTL_MAX 255 41 42 typedef struct {43 uint32_t ipv4;44 } inet_addr_t;45 42 46 43 typedef struct { -
uspace/lib/c/include/inet/inetcfg.h
rd120133 r192565b 38 38 #include <inet/inet.h> 39 39 #include <sys/types.h> 40 41 /** Network address */42 typedef struct {43 /** Address */44 uint32_t ipv4;45 /** Number of valid bits in @c ipv4 */46 int bits;47 } inet_naddr_t;48 40 49 41 /** Address object info */ -
uspace/lib/c/include/io/con_srv.h
rd120133 r192565b 41 41 #include <io/color.h> 42 42 #include <io/concaps.h> 43 #include <io/ kbd_event.h>43 #include <io/cons_event.h> 44 44 #include <io/pixel.h> 45 45 #include <io/style.h> … … 82 82 void (*set_rgb_color)(con_srv_t *, pixel_t, pixel_t); 83 83 void (*set_cursor_visibility)(con_srv_t *, bool); 84 int (*get_event)(con_srv_t *, kbd_event_t *);84 int (*get_event)(con_srv_t *, cons_event_t *); 85 85 } con_ops_t; 86 86 -
uspace/lib/c/include/io/console.h
rd120133 r192565b 39 39 #include <io/concaps.h> 40 40 #include <io/kbd_event.h> 41 #include <io/cons_event.h> 41 42 #include <io/keycode.h> 42 43 #include <async.h> … … 82 83 extern void console_cursor_visibility(console_ctrl_t *, bool); 83 84 extern int console_get_color_cap(console_ctrl_t *, sysarg_t *); 84 extern bool console_get_ kbd_event(console_ctrl_t *, kbd_event_t *);85 extern bool console_get_ kbd_event_timeout(console_ctrl_t *, kbd_event_t *,85 extern bool console_get_event(console_ctrl_t *, cons_event_t *); 86 extern bool console_get_event_timeout(console_ctrl_t *, cons_event_t *, 86 87 suseconds_t *); 87 88 -
uspace/lib/c/include/io/window.h
rd120133 r192565b 40 40 #include <async.h> 41 41 #include <loc.h> 42 #include <io/console.h> 43 44 typedef enum { 45 POS_UPDATE, 46 POS_PRESS, 47 POS_RELEASE 48 } pos_event_type_t; 49 50 typedef struct { 51 sysarg_t pos_id; 52 pos_event_type_t type; 53 sysarg_t btn_num; 54 sysarg_t hpos; 55 sysarg_t vpos; 56 } pos_event_t; 42 #include <io/kbd_event.h> 43 #include <io/pos_event.h> 57 44 58 45 typedef struct { -
uspace/lib/c/include/ipc/services.h
rd120133 r192565b 53 53 } services_t; 54 54 55 #define SERVICE_NAME_DNSR "net/dnsr" 55 56 #define SERVICE_NAME_INET "net/inet" 56 57 #define SERVICE_NAME_INETCFG "net/inetcfg" -
uspace/lib/c/include/mem.h
rd120133 r192565b 38 38 #include <sys/types.h> 39 39 40 #define bzero(ptr, len) memset((ptr), 0, (len))41 42 extern void *mem set(void *, int, size_t);43 extern void *memcpy(void *, const void *, size_t);40 extern void *memset(void *, int, size_t) 41 __attribute__ ((optimize("-fno-tree-loop-distribute-patterns"))); 42 extern void *memcpy(void *, const void *, size_t) 43 __attribute__ ((optimize("-fno-tree-loop-distribute-patterns"))); 44 44 extern void *memmove(void *, const void *, size_t); 45 46 extern int bcmp(const void *, const void *, size_t); 45 extern int memcmp(const void *, const void *, size_t); 47 46 48 47 #endif -
uspace/lib/c/include/setjmp.h
rd120133 r192565b 38 38 #include <libarch/fibril.h> 39 39 40 typedef context_t jmp_buf ;40 typedef context_t jmp_buf[1]; 41 41 42 42 extern int setjmp(jmp_buf env); … … 47 47 /** @} 48 48 */ 49 -
uspace/lib/c/include/sys/types.h
rd120133 r192565b 50 50 typedef volatile uint32_t ioport32_t; 51 51 52 typedef int16_t unaligned_int16_t __attribute__ ((aligned(1))); 53 typedef int32_t unaligned_int32_t __attribute__ ((aligned(1))); 54 typedef int64_t unaligned_int64_t __attribute__ ((aligned(1))); 55 56 typedef uint16_t unaligned_uint16_t __attribute__ ((aligned(1))); 57 typedef uint32_t unaligned_uint32_t __attribute__ ((aligned(1))); 58 typedef uint64_t unaligned_uint64_t __attribute__ ((aligned(1))); 59 52 60 #endif 53 61
Note:
See TracChangeset
for help on using the changeset viewer.