Lines Matching refs:fda
5 static void fdarray__init_revents(struct fdarray *fda, short revents) in fdarray__init_revents() argument
9 fda->nr = fda->nr_alloc; in fdarray__init_revents()
11 for (fd = 0; fd < fda->nr; ++fd) { in fdarray__init_revents()
12 fda->entries[fd].fd = fda->nr - fd; in fdarray__init_revents()
13 fda->entries[fd].revents = revents; in fdarray__init_revents()
17 static int fdarray__fprintf_prefix(struct fdarray *fda, const char *prefix, FILE *fp) in fdarray__fprintf_prefix() argument
25 return printed + fdarray__fprintf(fda, fp); in fdarray__fprintf_prefix()
31 struct fdarray *fda = fdarray__new(5, 5); in test__fdarray__filter() local
33 if (fda == NULL) { in test__fdarray__filter()
38 fdarray__init_revents(fda, POLLIN); in test__fdarray__filter()
39 nr_fds = fdarray__filter(fda, POLLHUP, NULL); in test__fdarray__filter()
40 if (nr_fds != fda->nr_alloc) { in test__fdarray__filter()
42 nr_fds, fda->nr_alloc); in test__fdarray__filter()
46 fdarray__init_revents(fda, POLLHUP); in test__fdarray__filter()
47 nr_fds = fdarray__filter(fda, POLLHUP, NULL); in test__fdarray__filter()
50 nr_fds, fda->nr_alloc); in test__fdarray__filter()
54 fdarray__init_revents(fda, POLLHUP); in test__fdarray__filter()
55 fda->entries[2].revents = POLLIN; in test__fdarray__filter()
56 expected_fd[0] = fda->entries[2].fd; in test__fdarray__filter()
59 fdarray__fprintf_prefix(fda, "before", stderr); in test__fdarray__filter()
60 nr_fds = fdarray__filter(fda, POLLHUP, NULL); in test__fdarray__filter()
61 fdarray__fprintf_prefix(fda, " after", stderr); in test__fdarray__filter()
67 if (fda->entries[0].fd != expected_fd[0]) { in test__fdarray__filter()
69 fda->entries[0].fd, expected_fd[0]); in test__fdarray__filter()
73 fdarray__init_revents(fda, POLLHUP); in test__fdarray__filter()
74 fda->entries[0].revents = POLLIN; in test__fdarray__filter()
75 expected_fd[0] = fda->entries[0].fd; in test__fdarray__filter()
76 fda->entries[3].revents = POLLIN; in test__fdarray__filter()
77 expected_fd[1] = fda->entries[3].fd; in test__fdarray__filter()
80 fdarray__fprintf_prefix(fda, "before", stderr); in test__fdarray__filter()
81 nr_fds = fdarray__filter(fda, POLLHUP, NULL); in test__fdarray__filter()
82 fdarray__fprintf_prefix(fda, " after", stderr); in test__fdarray__filter()
90 if (fda->entries[fd].fd != expected_fd[fd]) { in test__fdarray__filter()
92 fda->entries[fd].fd, expected_fd[fd]); in test__fdarray__filter()
101 fdarray__delete(fda); in test__fdarray__filter()
109 struct fdarray *fda = fdarray__new(2, 2); in test__fdarray__add() local
111 if (fda == NULL) { in test__fdarray__add()
117 if (fda->entries[_idx].fd != _fd) { \ in test__fdarray__add()
119 __LINE__, _idx, fda->entries[1].fd, _fd); \ in test__fdarray__add()
122 if (fda->entries[_idx].events != (_revents)) { \ in test__fdarray__add()
124 __LINE__, _idx, fda->entries[_idx].fd, _revents); \ in test__fdarray__add()
129 if (fdarray__add(fda, _fd, _revents) < 0) { \ in test__fdarray__add()
134 if (fda->nr != _nr) { \ in test__fdarray__add()
136 __LINE__,_fd, _revents, fda->nr, _nr); \ in test__fdarray__add()
144 fdarray__fprintf_prefix(fda, "before growing array", stderr); in test__fdarray__add()
148 if (fda->entries == NULL) { in test__fdarray__add()
153 fdarray__fprintf_prefix(fda, "after 3rd add", stderr); in test__fdarray__add()
157 fdarray__fprintf_prefix(fda, "after 4th add", stderr); in test__fdarray__add()
171 fdarray__delete(fda); in test__fdarray__add()