<commit_before>/* Utility functions.
 * It also includes emulation for a few functions from the ChipKit environment.
 * 
 */
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <stdint.h>
#include <stdlib.h>
#include <unistd.h>
#include <pthread.h>
#include <limits.h>
#include <sys/mman.h>
#include <time.h>
#include <errno.h>
#include "util.h"

unsigned pi_model, pi_revision;
char *pi_modelname, *pi_modelcode;

void
pi_hardware_revision(void)
{
	FILE *fp;
	char buf[512];
	char term;
	int chars = 4;

	pi_model = 0;
	pi_revision = 0;

	if ((fp = fopen ("/proc/cpuinfo", "r")) != NULL)
	{
		while (fgets(buf, sizeof(buf), fp) != NULL)
		{
			if (pi_model == 0)
			{
				if (!strncasecmp("model name", buf, 10))
				{
					if (strstr(buf, "ARMv6") != NULL)
					{
						pi_model = 1;
						chars = 4;
					}
					else if (strstr(buf, "ARMv7") != NULL)
					{
						pi_model = 2;
						chars = 6;
					}
					else if (strstr(buf, "ARMv8") != NULL)
					{
						pi_model = 2;
						chars = 6;
					}
				}
			}

			if (!strncasecmp("revision", buf, 8))
			{
				if (sscanf(buf + strlen(buf) - chars - 1,
				    "%x%c", &pi_revision, &term) == 2)
					if (term != '\n')
						pi_revision = 0;
			}
		}
		fclose(fp);
	}

	if (!pi_revision)
	{
		pi_modelname = "Unknown";
		pi_modelcode = "U";
	}
	else if (pi_revision < 4)
	{
		pi_modelname = "Pi 1 Model B Revision 1, 256MiB";
		pi_modelcode = "1B1";
	}
	else if (pi_revision < 7)
	{
		pi_modelname = "Pi 1 Model B Revision 2, 256MiB";
		pi_modelcode = "1B2";
	}
	else if (pi_revision < 0xd)<commit_msg>Remove any over-volt flag in revision number<commit_after>/* Utility functions.
 * It also includes emulation for a few functions from the ChipKit environment.
 * 
 */
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <stdint.h>
#include <stdlib.h>
#include <unistd.h>
#include <pthread.h>
#include <limits.h>
#include <sys/mman.h>
#include <time.h>
#include <errno.h>
#include "util.h"

unsigned pi_model, pi_revision;
char *pi_modelname, *pi_modelcode;

void
pi_hardware_revision(void)
{
	FILE *fp;
	char buf[512];
	char term;
	int chars = 4;

	pi_model = 0;
	pi_revision = 0;

	if ((fp = fopen ("/proc/cpuinfo", "r")) != NULL)
	{
		while (fgets(buf, sizeof(buf), fp) != NULL)
		{
			if (pi_model == 0)
			{
				if (!strncasecmp("model name", buf, 10))
				{
					if (strstr(buf, "ARMv6") != NULL)
					{
						pi_model = 1;
						chars = 4;
					}
					else if (strstr(buf, "ARMv7") != NULL)
					{
						pi_model = 2;
						chars = 6;
					}
					else if (strstr(buf, "ARMv8") != NULL)
					{
						pi_model = 2;
						chars = 6;
					}
				}
			}

			if (!strncasecmp("revision", buf, 8))
			{
				if (sscanf(buf + strlen(buf) - chars - 1,
				    "%x%c", &pi_revision, &term) == 2)
					if (term != '\n')
						pi_revision = 0;
			}
		}
		fclose(fp);
	}

	// Remove any over-volt flag
	pi_revision &= ~10000000;

	if (!pi_revision)
	{
		pi_modelname = "Unknown";
		pi_modelcode = "U";
	}
	else if (pi_revision < 4)
	{
		pi_modelname = "Pi 1 Model B Revision 1, 256MiB";
		pi_modelcode = "1B1";
	}
	else if (pi_revision < 7)
	{
		pi_modelname = "Pi 1 Model B Revision 2, 256MiB";
		pi_modelcode = "1B2";
	}
	else if (pi_revision < 0xd)
{'fraction_non_alphanumeric': 0.16393442622950818, 'fraction_numerical': 0.02660068048252397, 'mean_word_length': 2.717241379310345, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 25, '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': '2412122', 'n_tokens_mistral': 1664, 'n_tokens_neox': 1343, 'n_words': 335}