tools/testing/selftests/powerpc/ptrace/child.h
Source file repositories/reference/linux-study-clean/tools/testing/selftests/powerpc/ptrace/child.h
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/powerpc/ptrace/child.h- Extension
.h- Size
- 2661 bytes
- Lines
- 140
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: implementation source
- Status
- source implementation candidate
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
stdio.hstdbool.hsemaphore.h
Detected Declarations
struct child_syncfunction init_child_syncfunction destroy_child_syncfunction wait_childfunction prod_childfunction wait_parentfunction prod_parent
Annotated Snippet
struct child_sync {
/* The parent waits on this semaphore. */
sem_t sem_parent;
/* If true, the child should give up as well. */
bool parent_gave_up;
/* The child waits on this semaphore. */
sem_t sem_child;
/* If true, the parent should give up as well. */
bool child_gave_up;
};
#define CHILD_FAIL_IF(x, sync) \
do { \
if (x) { \
fprintf(stderr, \
"[FAIL] Test FAILED on line %d\n", __LINE__); \
(sync)->child_gave_up = true; \
prod_parent(sync); \
return 1; \
} \
} while (0)
#define PARENT_FAIL_IF(x, sync) \
do { \
if (x) { \
fprintf(stderr, \
"[FAIL] Test FAILED on line %d\n", __LINE__); \
(sync)->parent_gave_up = true; \
prod_child(sync); \
return 1; \
} \
} while (0)
#define PARENT_SKIP_IF_UNSUPPORTED(x, sync, msg) \
do { \
if ((x) == -1 && (errno == ENODEV || errno == EINVAL)) { \
(sync)->parent_gave_up = true; \
prod_child(sync); \
SKIP_IF_MSG(1, msg); \
} \
} while (0)
int init_child_sync(struct child_sync *sync)
{
int ret;
ret = sem_init(&sync->sem_parent, 1, 0);
if (ret) {
perror("Semaphore initialization failed");
return 1;
}
ret = sem_init(&sync->sem_child, 1, 0);
if (ret) {
perror("Semaphore initialization failed");
return 1;
}
return 0;
}
void destroy_child_sync(struct child_sync *sync)
{
sem_destroy(&sync->sem_parent);
sem_destroy(&sync->sem_child);
}
int wait_child(struct child_sync *sync)
{
int ret;
/* Wait until the child prods us. */
ret = sem_wait(&sync->sem_parent);
if (ret) {
perror("Error waiting for child");
return 1;
}
return sync->child_gave_up;
}
int prod_child(struct child_sync *sync)
{
int ret;
/* Unblock the child now. */
ret = sem_post(&sync->sem_child);
Annotation
- Immediate include surface: `stdio.h`, `stdbool.h`, `semaphore.h`.
- Detected declarations: `struct child_sync`, `function init_child_sync`, `function destroy_child_sync`, `function wait_child`, `function prod_child`, `function wait_parent`, `function prod_parent`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.