<commit_before>#include <stdlib.h>

#include <sys/time.h>
#include <pthread.h> 
#include <signal.h>

#include "applicfg.h"
#include "timer.h"

pthread_mutex_t CanFestival_mutex = PTHREAD_MUTEX_INITIALIZER;

TASK_HANDLE TimerLoopThread;

TIMEVAL last_time_set = TIMEVAL_MAX;

struct timeval last_sig;

timer_t timer;

void TimerCleanup(void)
{
	/* only used in realtime apps */
}

void EnterMutex(void)
{
	pthread_mutex_lock(&CanFestival_mutex); 
}

void LeaveMutex(void)
{
	pthread_mutex_unlock(&CanFestival_mutex);
}

void timer_notify(sigval_t val)
{
	gettimeofday(&last_sig,NULL);
	EnterMutex();
	TimeDispatch();
	LeaveMutex();
//	printf("getCurrentTime() return=%u\n", p.tv_usec);
}

void TimerInit(void)
{
	struct sigevent sigev;

	// Take first absolute time ref.
	gettimeofday(&last_sig,NULL);

	memset (&sigev, 0, sizeof (struct sigevent));
	sigev.sigev_value.sival_int = 0;
	sigev.sigev_notify = SIGEV_THREAD;
	sigev.sigev_notify_attributes = NULL;
	sigev.sigev_notify_function = timer_notify;

	timer_create (CLOCK_REALTIME, &sigev, &timer);<commit_msg>create specific timer thread for UCLIBC support (with CLOCK_PROCESS_CPUTIME_ID parameter)<commit_after>#include <stdlib.h>

#include <sys/time.h>
#include <pthread.h> 
#include <signal.h>

#include "applicfg.h"
#include "timer.h"

pthread_mutex_t CanFestival_mutex = PTHREAD_MUTEX_INITIALIZER;

TASK_HANDLE TimerLoopThread;

TIMEVAL last_time_set = TIMEVAL_MAX;

struct timeval last_sig;

timer_t timer;

void TimerCleanup(void)
{
	/* only used in realtime apps */
}

void EnterMutex(void)
{
	pthread_mutex_lock(&CanFestival_mutex); 
}

void LeaveMutex(void)
{
	pthread_mutex_unlock(&CanFestival_mutex);
}

void timer_notify(sigval_t val)
{
	gettimeofday(&last_sig,NULL);
	EnterMutex();
	TimeDispatch();
	LeaveMutex();
//	printf("getCurrentTime() return=%u\n", p.tv_usec);
}

void TimerInit(void)
{
	struct sigevent sigev;

	// Take first absolute time ref.
	gettimeofday(&last_sig,NULL);

#if defined(__UCLIBC__)
	int ret;
	ret = timer_create(CLOCK_PROCESS_CPUTIME_ID, NULL, &timer);
	signal(SIGALRM, timer_notify);
#else
	memset (&sigev, 0, sizeof (struct sigevent));
	sigev.sigev_value.sival_int = 0;
	sigev.sigev_notify = SIGEV_THREAD;
	sigev.sigev_notify_attributes = NULL;
	sigev.sigev_notify_function = timer_notify;

	timer_create (CLOCK_REALTIME, &sigev, &timer);
#endif
{'fraction_non_alphanumeric': 0.11998292058070026, 'fraction_numerical': 0.0017079419299743809, 'mean_word_length': 6.231481481481482, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, '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': '2742695', 'n_tokens_mistral': 923, 'n_tokens_neox': 915, 'n_words': 174}