<commit_before>#include <time.h>
#include "pthread_impl.h"

struct ksigevent {
	union sigval sigev_value;
	int sigev_signo;
	int sigev_notify;
	int sigev_tid;
};

struct start_args {
	pthread_barrier_t b;
	struct sigevent *sev;
};

void __sigtimer_handler(pthread_t self)
{
	int st;
	void (*notify)(union sigval) = (void (*)(union sigval))self->start;
	union sigval val = { .sival_ptr = self->start_arg };

	pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &st);
	notify(val);
	pthread_setcancelstate(st, 0);
}

static void cleanup(void *p)
{
	pthread_t self = p;
	__syscall(SYS_timer_delete, self->result);
}

static void *start(void *arg)
{
	pthread_t self = __pthread_self();
	struct start_args *args = arg;

	/* Reuse no-longer-needed thread structure fields to avoid
	 * needing the timer address in the signal handler. */
	self->start = (void *(*)(void *))args->sev->sigev_notify_function;
	self->start_arg = args->sev->sigev_value.sival_ptr;
	self->result = (void *)-1;

	pthread_cleanup_push(cleanup, self);
	pthread_barrier_wait(&args->b);
	pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, 0);
	/* Loop on async-signal-safe cancellation point */
	for (;;) sleep(1);
	pthread_cleanup_pop(0);
	return 0;
}

int timer_create(clockid_t clk, struct sigevent *evp, timer_t *res)
{
	struct sigevent sev = { 
		.sigev_notify = SIGEV_SIGNAL,
		.sigev_signo = SIGALRM
	};
	pthread_t td;
	pthread_attr_t attr;
	int r;<commit_msg>timer threads should sleep and stay asleep... a long time<commit_after>#include <time.h>
#include "pthread_impl.h"

struct ksigevent {
	union sigval sigev_value;
	int sigev_signo;
	int sigev_notify;
	int sigev_tid;
};

struct start_args {
	pthread_barrier_t b;
	struct sigevent *sev;
};

void __sigtimer_handler(pthread_t self)
{
	int st;
	void (*notify)(union sigval) = (void (*)(union sigval))self->start;
	union sigval val = { .sival_ptr = self->start_arg };

	pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &st);
	notify(val);
	pthread_setcancelstate(st, 0);
}

static void cleanup(void *p)
{
	pthread_t self = p;
	__syscall(SYS_timer_delete, self->result);
}

static void *start(void *arg)
{
	pthread_t self = __pthread_self();
	struct start_args *args = arg;

	/* Reuse no-longer-needed thread structure fields to avoid
	 * needing the timer address in the signal handler. */
	self->start = (void *(*)(void *))args->sev->sigev_notify_function;
	self->start_arg = args->sev->sigev_value.sival_ptr;
	self->result = (void *)-1;

	pthread_cleanup_push(cleanup, self);
	pthread_barrier_wait(&args->b);
	pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, 0);
	/* Loop on async-signal-safe cancellation point */
	for (;;) sleep(1000000000);
	pthread_cleanup_pop(0);
	return 0;
}

int timer_create(clockid_t clk, struct sigevent *evp, timer_t *res)
{
	struct sigevent sev = { 
		.sigev_notify = SIGEV_SIGNAL,
		.sigev_signo = SIGALRM
	};
	pthread_t td;
	pthread_attr_t attr;
	int r;
{'fraction_non_alphanumeric': 0.12693498452012383, 'fraction_numerical': 0.007223942208462332, 'mean_word_length': 5.147991543340381, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 1, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6577620', 'n_tokens_mistral': 1160, 'n_tokens_neox': 1115, 'n_words': 254}