Lines Matching refs:t

288 static ssize_t read_wrap(struct thread *t, void *buf, size_t nbytes);
289 static ssize_t write_wrap(struct thread *t, const void *buf, size_t nbytes);
290 static ssize_t ep0_consume(struct thread *t, const void *buf, size_t nbytes);
291 static ssize_t fill_in_buf(struct thread *t, void *buf, size_t nbytes);
292 static ssize_t empty_out_buf(struct thread *t, const void *buf, size_t nbytes);
331 static void init_thread(struct thread *t) in init_thread() argument
333 t->buf = malloc(t->buf_size); in init_thread()
334 die_on(!t->buf, "malloc"); in init_thread()
336 t->fd = open(t->filename, O_RDWR); in init_thread()
337 die_on(t->fd < 0, "%s", t->filename); in init_thread()
342 struct thread *t = arg; in cleanup_thread() local
345 fd = t->fd; in cleanup_thread()
346 if (t->fd < 0) in cleanup_thread()
348 t->fd = -1; in cleanup_thread()
351 if (t != threads) { in cleanup_thread()
356 err("%s: get fifo status", t->filename); in cleanup_thread()
358 warn("%s: unclaimed = %d\n", t->filename, ret); in cleanup_thread()
360 err("%s: fifo flush", t->filename); in cleanup_thread()
365 err("%s: close", t->filename); in cleanup_thread()
367 free(t->buf); in cleanup_thread()
368 t->buf = NULL; in cleanup_thread()
374 struct thread *t = arg; in start_thread_helper() local
377 info("%s: starts\n", t->filename); in start_thread_helper()
378 in_name = t->in_name ? t->in_name : t->filename; in start_thread_helper()
379 out_name = t->out_name ? t->out_name : t->filename; in start_thread_helper()
386 ret = t->in(t, t->buf, t->buf_size); in start_thread_helper()
388 ret = t->out(t, t->buf, ret); in start_thread_helper()
411 t->status = ret; in start_thread_helper()
412 info("%s: ends\n", t->filename); in start_thread_helper()
416 static void start_thread(struct thread *t) in start_thread() argument
418 debug("%s: starting\n", t->filename); in start_thread()
420 die_on(pthread_create(&t->id, NULL, start_thread_helper, t) < 0, in start_thread()
421 "pthread_create(%s)", t->filename); in start_thread()
424 static void join_thread(struct thread *t) in join_thread() argument
426 int ret = pthread_join(t->id, NULL); in join_thread()
429 err("%s: joining thread", t->filename); in join_thread()
431 debug("%s: joined\n", t->filename); in join_thread()
435 static ssize_t read_wrap(struct thread *t, void *buf, size_t nbytes) in read_wrap() argument
437 return read(t->fd, buf, nbytes); in read_wrap()
440 static ssize_t write_wrap(struct thread *t, const void *buf, size_t nbytes) in write_wrap() argument
442 return write(t->fd, buf, nbytes); in write_wrap()
578 static void ep0_init(struct thread *t, bool legacy_descriptors) in ep0_init() argument
585 info("%s: writing descriptors\n", t->filename); in ep0_init()
589 info("%s: writing descriptors (in v2 format)\n", t->filename); in ep0_init()
590 ret = write(t->fd, &descriptors, sizeof descriptors); in ep0_init()
593 warn("%s: new format rejected, trying legacy\n", t->filename); in ep0_init()
597 ret = write(t->fd, legacy, len); in ep0_init()
601 die_on(ret < 0, "%s: write: descriptors", t->filename); in ep0_init()
603 info("%s: writing strings\n", t->filename); in ep0_init()
604 ret = write(t->fd, &strings, sizeof strings); in ep0_init()
605 die_on(ret < 0, "%s: write: strings", t->filename); in ep0_init()