Lines Matching refs:t

336 static ssize_t read_wrap(struct thread *t, void *buf, size_t nbytes);
337 static ssize_t write_wrap(struct thread *t, const void *buf, size_t nbytes);
338 static ssize_t ep0_consume(struct thread *t, const void *buf, size_t nbytes);
339 static ssize_t fill_in_buf(struct thread *t, void *buf, size_t nbytes);
340 static ssize_t empty_out_buf(struct thread *t, const void *buf, size_t nbytes);
379 static void init_thread(struct thread *t) in init_thread() argument
381 t->buf = malloc(t->buf_size); in init_thread()
382 die_on(!t->buf, "malloc"); in init_thread()
384 t->fd = open(t->filename, O_RDWR); in init_thread()
385 die_on(t->fd < 0, "%s", t->filename); in init_thread()
390 struct thread *t = arg; in cleanup_thread() local
393 fd = t->fd; in cleanup_thread()
394 if (t->fd < 0) in cleanup_thread()
396 t->fd = -1; in cleanup_thread()
399 if (t != threads) { in cleanup_thread()
404 err("%s: get fifo status", t->filename); in cleanup_thread()
406 warn("%s: unclaimed = %d\n", t->filename, ret); in cleanup_thread()
408 err("%s: fifo flush", t->filename); in cleanup_thread()
413 err("%s: close", t->filename); in cleanup_thread()
415 free(t->buf); in cleanup_thread()
416 t->buf = NULL; in cleanup_thread()
422 struct thread *t = arg; in start_thread_helper() local
425 info("%s: starts\n", t->filename); in start_thread_helper()
426 in_name = t->in_name ? t->in_name : t->filename; in start_thread_helper()
427 out_name = t->out_name ? t->out_name : t->filename; in start_thread_helper()
434 ret = t->in(t, t->buf, t->buf_size); in start_thread_helper()
436 ret = t->out(t, t->buf, ret); in start_thread_helper()
459 t->status = ret; in start_thread_helper()
460 info("%s: ends\n", t->filename); in start_thread_helper()
464 static void start_thread(struct thread *t) in start_thread() argument
466 debug("%s: starting\n", t->filename); in start_thread()
468 die_on(pthread_create(&t->id, NULL, start_thread_helper, t) < 0, in start_thread()
469 "pthread_create(%s)", t->filename); in start_thread()
472 static void join_thread(struct thread *t) in join_thread() argument
474 int ret = pthread_join(t->id, NULL); in join_thread()
477 err("%s: joining thread", t->filename); in join_thread()
479 debug("%s: joined\n", t->filename); in join_thread()
483 static ssize_t read_wrap(struct thread *t, void *buf, size_t nbytes) in read_wrap() argument
485 return read(t->fd, buf, nbytes); in read_wrap()
488 static ssize_t write_wrap(struct thread *t, const void *buf, size_t nbytes) in write_wrap() argument
490 return write(t->fd, buf, nbytes); in write_wrap()
626 static void ep0_init(struct thread *t, bool legacy_descriptors) in ep0_init() argument
633 info("%s: writing descriptors\n", t->filename); in ep0_init()
637 info("%s: writing descriptors (in v2 format)\n", t->filename); in ep0_init()
638 ret = write(t->fd, &descriptors, sizeof descriptors); in ep0_init()
641 warn("%s: new format rejected, trying legacy\n", t->filename); in ep0_init()
645 ret = write(t->fd, legacy, len); in ep0_init()
649 die_on(ret < 0, "%s: write: descriptors", t->filename); in ep0_init()
651 info("%s: writing strings\n", t->filename); in ep0_init()
652 ret = write(t->fd, &strings, sizeof strings); in ep0_init()
653 die_on(ret < 0, "%s: write: strings", t->filename); in ep0_init()