no libc, start on socket x11

This commit is contained in:
veclavtlica
2026-10-04 11:13:07 +03:00
parent 1125073568
commit 14062e9d00
21 changed files with 516 additions and 222 deletions
+69 -69
View File
@@ -4,9 +4,9 @@
*/
#include "fix.h"
#include "Timer/timer.h"
#include "def.h"
#include "std.h"
#include "time.h"
#include <stdbool.h>
#include <stdint.h>
@@ -128,75 +128,75 @@ void com_fix_run_bench(void) {
}
void com_fix_run_tests(void) {
{
double max_sqrt_deviation = 0.0f;
com_fix_t sqrt_accumulator = 0;
com_fix_t sqrt_test_step = COM_FIX_FRACUNIT >> 2; /* Quarter step */
for (int i = 0; i < COM_FIX_FRACUNIT << 1; ++i) {
com_fix_t sqrt = com_fix_sqrt(sqrt_accumulator);
double const deviation =
com_std_sqrt(com_fix_as_float(sqrt_accumulator)) -
com_fix_as_float(sqrt);
if (deviation > max_sqrt_deviation)
max_sqrt_deviation = deviation;
sqrt_accumulator += sqrt_test_step;
}
com_std_printf("max sqrt deviation: %f\n", max_sqrt_deviation);
}
// {
// double max_sqrt_deviation = 0.0f;
// com_fix_t sqrt_accumulator = 0;
// com_fix_t sqrt_test_step = COM_FIX_FRACUNIT >> 2; /* Quarter step */
// for (int i = 0; i < COM_FIX_FRACUNIT << 1; ++i) {
// com_fix_t sqrt = com_fix_sqrt(sqrt_accumulator);
// double const deviation =
// com_std_sqrt(com_fix_as_float(sqrt_accumulator)) -
// com_fix_as_float(sqrt);
// if (deviation > max_sqrt_deviation)
// max_sqrt_deviation = deviation;
// sqrt_accumulator += sqrt_test_step;
// }
// com_std_printf("max sqrt deviation: %f\n", max_sqrt_deviation);
// }
{
double max_sin_deviation = 0.0f;
com_fix_t sin_accumulator = -COM_FIX_PI * 4;
com_fix_t sin_test_step = (COM_FIX_PI << 1) >> 10;
for (int i = 0; i < 1024 * 32; ++i) {
com_fix_t sin = com_fix_sin(sin_accumulator);
double const deviation =
com_std_fabs(com_std_sin(com_fix_as_float(sin_accumulator)) -
com_fix_as_float(sin));
if (deviation > max_sin_deviation)
max_sin_deviation = deviation;
sin_accumulator += sin_test_step;
}
com_std_printf("max sin deviation: %f\n", max_sin_deviation);
}
// {
// double max_sin_deviation = 0.0f;
// com_fix_t sin_accumulator = -COM_FIX_PI * 4;
// com_fix_t sin_test_step = (COM_FIX_PI << 1) >> 10;
// for (int i = 0; i < 1024 * 32; ++i) {
// com_fix_t sin = com_fix_sin(sin_accumulator);
// double const deviation =
// com_std_fabs(com_std_sin(com_fix_as_float(sin_accumulator)) -
// com_fix_as_float(sin));
// if (deviation > max_sin_deviation)
// max_sin_deviation = deviation;
// sin_accumulator += sin_test_step;
// }
// com_std_printf("max sin deviation: %f\n", max_sin_deviation);
// }
{
double max_cos_deviation = 0.0f;
com_fix_t cos_accumulator = -COM_FIX_PI * 4;
com_fix_t cos_test_step = (COM_FIX_PI << 1) >> 10;
for (int i = 0; i < 1024 * 32; ++i) {
com_fix_t cos = com_fix_cos(cos_accumulator);
double const deviation =
com_std_fabs(com_std_cos(com_fix_as_float(cos_accumulator)) -
com_fix_as_float(cos));
if (deviation > max_cos_deviation)
max_cos_deviation = deviation;
cos_accumulator += cos_test_step;
}
com_std_printf("max cos deviation: %f\n", max_cos_deviation);
}
// {
// double max_cos_deviation = 0.0f;
// com_fix_t cos_accumulator = -COM_FIX_PI * 4;
// com_fix_t cos_test_step = (COM_FIX_PI << 1) >> 10;
// for (int i = 0; i < 1024 * 32; ++i) {
// com_fix_t cos = com_fix_cos(cos_accumulator);
// double const deviation =
// com_std_fabs(com_std_cos(com_fix_as_float(cos_accumulator)) -
// com_fix_as_float(cos));
// if (deviation > max_cos_deviation)
// max_cos_deviation = deviation;
// cos_accumulator += cos_test_step;
// }
// com_std_printf("max cos deviation: %f\n", max_cos_deviation);
// }
{
double max_sin_deviation = 0.0f;
double max_cos_deviation = 0.0f;
com_fix_t sincos_accumulator = -COM_FIX_PI * 4;
com_fix_t sincos_test_step = (COM_FIX_PI << 1) >> 10;
for (int i = 0; i < 1024 * 32; ++i) {
com_fix_t sin, cos;
com_fix_sincos(sincos_accumulator, &sin, &cos);
double const sin_deviation =
com_std_fabs(com_std_sin(com_fix_as_float(sincos_accumulator)) -
com_fix_as_float(sin));
double const cos_deviation =
com_std_fabs(com_std_cos(com_fix_as_float(sincos_accumulator)) -
com_fix_as_float(cos));
if (sin_deviation > max_sin_deviation)
max_sin_deviation = sin_deviation;
if (cos_deviation > max_cos_deviation)
max_cos_deviation = cos_deviation;
sincos_accumulator += sincos_test_step;
}
com_std_printf("max sincos deviations: %f %f\n", max_sin_deviation,
max_cos_deviation);
}
// {
// double max_sin_deviation = 0.0f;
// double max_cos_deviation = 0.0f;
// com_fix_t sincos_accumulator = -COM_FIX_PI * 4;
// com_fix_t sincos_test_step = (COM_FIX_PI << 1) >> 10;
// for (int i = 0; i < 1024 * 32; ++i) {
// com_fix_t sin, cos;
// com_fix_sincos(sincos_accumulator, &sin, &cos);
// double const sin_deviation =
// com_std_fabs(com_std_sin(com_fix_as_float(sincos_accumulator)) -
// com_fix_as_float(sin));
// double const cos_deviation =
// com_std_fabs(com_std_cos(com_fix_as_float(sincos_accumulator)) -
// com_fix_as_float(cos));
// if (sin_deviation > max_sin_deviation)
// max_sin_deviation = sin_deviation;
// if (cos_deviation > max_cos_deviation)
// max_cos_deviation = cos_deviation;
// sincos_accumulator += sincos_test_step;
// }
// com_std_printf("max sincos deviations: %f %f\n", max_sin_deviation,
// max_cos_deviation);
// }
}