/*
	Copyright (C) 2025 Mark Tyler

	This program is free software; you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation; either version 3 of the License, or
	(at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program in the file COPYING.
*/

#include "private.h"



int mtkit_cpu_is_little_endian(void)
{
	static unsigned int const x = 1;
	return *(unsigned char const *)&x == 1;
}

int mtkit_cpu_threads(void)
{
	long const num_threads = sysconf( _SC_NPROCESSORS_ONLN );

	if (num_threads < 1)
	{
		return 1;
	}

	if (num_threads > INT_MAX)
	{
		return INT_MAX;
	}

	return (int)num_threads;
}

