diff options
Diffstat (limited to '')
-rw-r--r-- | wiki.c | 30 |
1 files changed, 28 insertions, 2 deletions
@@ -21,6 +21,28 @@ #include <sys/mman.h> #undef __BSD_VISIBLE +#ifdef __linux__ +#include <linux/futex.h> +#include <sys/syscall.h> +#include <stdint.h> + +typedef uint32_t *futex_t; + +long futex_core(futex_t futex, int futex_op, uint32_t val, const struct timespec *timeout, uint32_t *uaddr2, uint32_t val3) { + return syscall(SYS_futex, uaddr, futex_op, val, timeout, uaddr2, val3); +} + +futex_wait(futex_t futex, uint32_t val) { + futex_core(futex, FUTEX_WAIT, val, NULL, NULL, 0); +} + +void suspend() { + futex( +} + +void wake(); +#endif + #include <syslog.h> #include <dirent.h> #include <unistd.h> @@ -149,7 +171,9 @@ static void *start_thread(void *d) { ssize_t len; // kill(data->peer_pid, SIGUSR1); + fprintf(stderr, "We are here\n"); pthread_cond_signal(data->cond); + fprintf(stderr, "Signaled\n"); munmap(data->cond, sizeof data->cond); struct timeval timeout = { @@ -330,9 +354,10 @@ int main (int argc, const char *argv[]) { { pthread_mutex_t cond_mutex; pthread_mutex_init(&cond_mutex, NULL); - fprintf(err, "Waiting on condition"); + syslog(4, "Test of syslog"); + fprintf(err, "Waiting on condition\n"); pthread_cond_wait(cond, &cond_mutex); - fprintf(err, "Awoken from condition"); + fprintf(err, "Awoken from condition\n"); pthread_mutex_unlock(&cond_mutex); pthread_mutex_destroy(&cond_mutex); } @@ -618,6 +643,7 @@ int wiki_do(const char *wiki_root, return 0; } if (cmp("echo", command[0])) { + syslog(3, "-- %s --", wiki); char *buf = malloc(0x100); // sprintf(buf, "/tmp/hugo/%i", getpid()); // FILE *log = fopen("/tmp/hugo/log", "a"); |