<commit_before>#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>

#define __TEST__
#include <timer.h>

#define mftb()	(stamp)
#define sync()

static uint64_t stamp, last;
struct lock;
static inline void lock(struct lock *l) { (void)l; }
static inline void unlock(struct lock *l) { (void)l; }

#include "../timer.c"

#define NUM_TIMERS	100

static struct timer timers[NUM_TIMERS];
static unsigned int rand_shift, count;

static void init_rand(void)
{
	unsigned long max = RAND_MAX;

	/* Get something reasonably small */
	while(max > 0x10000) {
		rand_shift++;
		max >>= 1;
	}
}

static void expiry(struct timer *t, void *data)
{
	(void)data;
	assert(t->target >= last);
	count--;
}

int main(void)
{
	unsigned int i;

	init_rand();
	for (i = 0; i < NUM_TIMERS; i++) {
		init_timer(&timers[i], expiry, NULL);
		schedule_timer(&timers[i], random() >> rand_shift);
	}
	count = NUM_TIMERS;
	while(count) {
		check_timers();
		stamp++;
	}
	return 0;
}<commit_msg>core/test: Fix timer test case<commit_after>#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>

#define __TEST__
#include <timer.h>

#define mftb()	(stamp)
#define sync()

static uint64_t stamp, last;
struct lock;
static inline void lock(struct lock *l) { (void)l; }
static inline void unlock(struct lock *l) { (void)l; }

#include "../timer.c"

#define NUM_TIMERS	100

static struct timer timers[NUM_TIMERS];
static unsigned int rand_shift, count;

static void init_rand(void)
{
	unsigned long max = RAND_MAX;

	/* Get something reasonably small */
	while(max > 0x10000) {
		rand_shift++;
		max >>= 1;
	}
}

static void expiry(struct timer *t, void *data)
{
	(void)data;
	assert(t->target >= last);
	count--;
}

int main(void)
{
	unsigned int i;

	init_rand();
	for (i = 0; i < NUM_TIMERS; i++) {
		init_timer(&timers[i], expiry, NULL);
		schedule_timer(&timers[i], random() >> rand_shift);
	}
	count = NUM_TIMERS;
	while(count) {
		check_timers(false);
		stamp++;
	}
	return 0;
}
{'fraction_non_alphanumeric': 0.15644171779141106, 'fraction_numerical': 0.014314928425357873, 'mean_word_length': 4.436111111111111, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 25, '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': '2842610', 'n_tokens_mistral': 808, 'n_tokens_neox': 754, 'n_words': 206}