From 6b952069e917c28f6c9fb5266a83766840e81533 Mon Sep 17 00:00:00 2001 From: Lain Iwakura Date: Sun, 4 Jan 2026 14:12:13 +0300 Subject: feat(linux): some patches --- 2048.c | 2 +- freecell.c | 2 +- snake.c | 14 ++++++++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/2048.c b/2048.c index 3f92e5d..b042ee0 100644 --- a/2048.c +++ b/2048.c @@ -22,7 +22,7 @@ typedef unsigned uint; -#if !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__OpenBSD__) +#if !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__OpenBSD__) && (!defined(__GLIBC__) || !__GLIBC_PREREQ(2, 36)) static uint arc4random_uniform(uint upper_bound) { return rand() % upper_bound; } diff --git a/freecell.c b/freecell.c index a97e3b3..c543bda 100644 --- a/freecell.c +++ b/freecell.c @@ -30,7 +30,7 @@ typedef unsigned uint; -#if !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__OpenBSD__) +#if !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__OpenBSD__) && (!defined(__GLIBC__) || !__GLIBC_PREREQ(2, 36)) static uint arc4random_uniform(uint upper_bound) { return rand() % upper_bound; } diff --git a/snake.c b/snake.c index 50bee4d..06ec230 100644 --- a/snake.c +++ b/snake.c @@ -14,13 +14,24 @@ * along with this program. If not, see . */ +#ifndef _DEFAULT_SOURCE +#define _DEFAULT_SOURCE +#endif + #include #include #include #include +#include #include typedef unsigned uint; + +#if !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__OpenBSD__) && (!defined(__GLIBC__) || !__GLIBC_PREREQ(2, 36)) +static uint arc4random_uniform(uint upper_bound) { + return rand() % upper_bound; +} +#endif typedef unsigned char byte; enum { @@ -202,6 +213,9 @@ static void input(void) { } uint playSnake(void) { +#if !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__OpenBSD__) && (!defined(__GLIBC__) || !__GLIBC_PREREQ(2, 36)) + srand(time(NULL)); +#endif curse(); do { tick(); -- cgit 1.4.1