Lines Matching +full:sync +full:- +full:1
1 // SPDX-License-Identifier: GPL-2.0+
3 * Helper functions to sync execution between parent and child processes.
29 #define CHILD_FAIL_IF(x, sync) \ argument
34 (sync)->child_gave_up = true; \
35 prod_parent(sync); \
36 return 1; \
40 #define PARENT_FAIL_IF(x, sync) \ argument
45 (sync)->parent_gave_up = true; \
46 prod_child(sync); \
47 return 1; \
51 #define PARENT_SKIP_IF_UNSUPPORTED(x, sync, msg) \ argument
53 if ((x) == -1 && (errno == ENODEV || errno == EINVAL)) { \
54 (sync)->parent_gave_up = true; \
55 prod_child(sync); \
56 SKIP_IF_MSG(1, msg); \
60 int init_child_sync(struct child_sync *sync) in init_child_sync() argument
64 ret = sem_init(&sync->sem_parent, 1, 0); in init_child_sync()
67 return 1; in init_child_sync()
70 ret = sem_init(&sync->sem_child, 1, 0); in init_child_sync()
73 return 1; in init_child_sync()
79 void destroy_child_sync(struct child_sync *sync) in destroy_child_sync() argument
81 sem_destroy(&sync->sem_parent); in destroy_child_sync()
82 sem_destroy(&sync->sem_child); in destroy_child_sync()
85 int wait_child(struct child_sync *sync) in wait_child() argument
90 ret = sem_wait(&sync->sem_parent); in wait_child()
93 return 1; in wait_child()
96 return sync->child_gave_up; in wait_child()
99 int prod_child(struct child_sync *sync) in prod_child() argument
104 ret = sem_post(&sync->sem_child); in prod_child()
107 return 1; in prod_child()
113 int wait_parent(struct child_sync *sync) in wait_parent() argument
118 ret = sem_wait(&sync->sem_child); in wait_parent()
121 return 1; in wait_parent()
124 return sync->parent_gave_up; in wait_parent()
127 int prod_parent(struct child_sync *sync) in prod_parent() argument
132 ret = sem_post(&sync->sem_parent); in prod_parent()
135 return 1; in prod_parent()