The Pedigree Project 0.1
event-descriptor-contract-test/contract.h
1#ifndef EVENT_DESCRIPTOR_CONTRACT_H
2#define EVENT_DESCRIPTOR_CONTRACT_H
3
4#include <errno.h>
5#include <stdint.h>
6#include <stdio.h>
7#include <time.h>
8
9#include <sys/types.h>
10
11#define CHECK(condition) \
12 do { \
13 if (!(condition)) { \
14 fprintf(stderr, "%s:%d: %s (errno=%d)\n", __FILE__, __LINE__, #condition, errno); \
15 failed = 1; \
16 goto out; \
17 } \
18 } while (0)
19
20#define EVENT_DESCRIPTOR_APP "/applications/event-descriptor-contract-test"
21
22int64_t ed_now(clockid_t clock);
23struct timespec ed_timespec(int64_t nanoseconds);
24void ed_pause(int milliseconds);
25int ed_wait(volatile int* flag, int milliseconds);
26int ed_reap(pid_t child, int milliseconds);
27int ed_send_fd(int socket, int fd);
28int ed_receive_fd(int socket);
29int ed_readable(int fd, int milliseconds);
30
31struct ed_reader {
32 int fd;
33 size_t size;
34 volatile int started, done;
35 ssize_t result;
36 int error;
37 int64_t finished;
38 unsigned char bytes[128];
39};
40void* ed_read_thread(void* argument);
41
42int event_descriptor_test_signalfd(void);
43int event_descriptor_test_timerfd(void);
44int event_descriptor_test_clock(void);
45int event_descriptor_signalfd_exec(int argc, char** argv);
46int event_descriptor_timerfd_exec(int argc, char** argv);
47
48#endif