From 4bc3d82296630ffd436ff617a1efe6b13abf6a26 Mon Sep 17 00:00:00 2001 From: turbocat Date: Tue, 25 May 2021 00:16:29 +0000 Subject: [PATCH] kolibri-libc - Added srand and rand - Added _libc_get_version - Update libc.obj.a binary git-svn-id: svn://kolibrios.org@8743 a494cfbc-eb01-0410-851d-a64ba20cac60 --- .../kolibri-libc/include/libc_version.h | 10 ++++++++++ .../libraries/kolibri-libc/include/stdlib.h | 5 ++++- .../libraries/kolibri-libc/lib/libc.obj.a | Bin 63614 -> 65304 bytes .../libraries/kolibri-libc/source/libc.c | 9 +++++++-- .../kolibri-libc/source/stdlib/rand.c | 15 +++++++++++++++ .../libraries/kolibri-libc/source/symbols.txt | 4 ++++ 6 files changed, 40 insertions(+), 3 deletions(-) create mode 100644 programs/develop/libraries/kolibri-libc/include/libc_version.h create mode 100644 programs/develop/libraries/kolibri-libc/source/stdlib/rand.c diff --git a/programs/develop/libraries/kolibri-libc/include/libc_version.h b/programs/develop/libraries/kolibri-libc/include/libc_version.h new file mode 100644 index 0000000000..bc49a9f62d --- /dev/null +++ b/programs/develop/libraries/kolibri-libc/include/libc_version.h @@ -0,0 +1,10 @@ +#ifndef _LIBC_VERSION_H_ +#define _LIBC_VERSION_H_ + +#include + +#define _LIBC_VERSION 8743 + +extern unsigned _FUNC(_libc_get_version)(); + +#endif diff --git a/programs/develop/libraries/kolibri-libc/include/stdlib.h b/programs/develop/libraries/kolibri-libc/include/stdlib.h index 8ea389bfe7..c01384e208 100644 --- a/programs/develop/libraries/kolibri-libc/include/stdlib.h +++ b/programs/develop/libraries/kolibri-libc/include/stdlib.h @@ -37,4 +37,7 @@ extern long int _FUNC(strtol)(const char* str, char** endptr, int base); extern void _FUNC(exit)(int status); -#endif \ No newline at end of file +extern void _FUNC(srand)(unsigned s); +extern int _FUNC(rand)(void); + +#endif diff --git a/programs/develop/libraries/kolibri-libc/lib/libc.obj.a b/programs/develop/libraries/kolibri-libc/lib/libc.obj.a index 633e3738b20e4bca2a2c06a6c88d0d0759b85599..3a0b5e8720a133ad1c3b083c798c63f73eda5b63 100644 GIT binary patch delta 859 zcma))e@K%-9EYE|&DmEOBh+`Y$p&-b{cklMebZq4xR zwa15>OAj=FHVC?DSR>Mu z;J6!#%Hf0uT-8uo3vS_5J(LTTf=BQ+K($cghgu`lnV~)oE{aS;ybmr(XcVK%V$^Jd zD|Wc*fNLVuA~M%Srd7BhLTw_{E<%3cw&V^OJB2Rco)fwY;l2p=h~PsJ>#c@9k?OC9 z$09M%2v3^fnK0M_L%vpc-Uh>dc+mkPUGTCSMtk5@FO2oW>j4-af;Yo3F#?mLFf|5m z$6?j`ZA$geG%J_?W)fk-*QV%~^i{vQ+53 delta 559 zcmW;HYeDu8O^u8S3yV&4qN1c?9m%lFPE=T^R9L8OqUD5Dj+7Sqk`j@T9hSAM zOpO$iihR*fV#o*y2?>cIBZiESkQgGd4}KW^>46{j{qTIb9$(xVpRzv4Fl;+k{XZ8{ zfa{P{2D2P6TXT-gb;5i}b-}_)NR!2~qzabF3J+FtQ20Z-LQm@M9MQGhl2VgtFo15eOfL z@skjdUwJSgzt6zrIrviqQ3p(w!L$?px*+DUJKWeyF1s&bW?K#=czxE#URz?hw>2@E YfH|J@!fE;{`_s+b)~w}blfOReA54&)X#fBK diff --git a/programs/develop/libraries/kolibri-libc/source/libc.c b/programs/develop/libraries/kolibri-libc/source/libc.c index 3e8d4ad953..279535aea7 100644 --- a/programs/develop/libraries/kolibri-libc/source/libc.c +++ b/programs/develop/libraries/kolibri-libc/source/libc.c @@ -1,3 +1,9 @@ +#include + +unsigned _libc_get_version(){ + return _LIBC_VERSION; +} + #include "ctype/is.c" #include "ctype/tolower.c" #include "ctype/toupper.c" @@ -99,6 +105,7 @@ #include "stdlib/itoa.c" #include "stdlib/time.c" #include "stdlib/strtol.c" +#include "stdlib/rand.c" #include "math/acosh.c" #include "math/asinh.c" @@ -110,7 +117,6 @@ #include "math/sinh.c" #include "math/tanh.c" - __asm__( ".include \"math/acos.s\"\n\t" ".include \"math/asin.s\"\n\t" @@ -136,5 +142,4 @@ __asm__( ); #include "stdlib/___chkstk_ms.c" - #include "exports/exports.c" diff --git a/programs/develop/libraries/kolibri-libc/source/stdlib/rand.c b/programs/develop/libraries/kolibri-libc/source/stdlib/rand.c new file mode 100644 index 0000000000..c000cd248c --- /dev/null +++ b/programs/develop/libraries/kolibri-libc/source/stdlib/rand.c @@ -0,0 +1,15 @@ +#include +#include + +static uint64_t seed; + +void srand(unsigned s) +{ + seed = s-1; +} + +int rand(void) +{ + seed = 6364136223846793005ULL*seed + 1; + return seed>>33; +} diff --git a/programs/develop/libraries/kolibri-libc/source/symbols.txt b/programs/develop/libraries/kolibri-libc/source/symbols.txt index 6d7625b6d1..f5e6981a84 100644 --- a/programs/develop/libraries/kolibri-libc/source/symbols.txt +++ b/programs/develop/libraries/kolibri-libc/source/symbols.txt @@ -62,6 +62,8 @@ mktime realloc strtol time +srand +rand !____STRING____ memcpy memchr @@ -130,3 +132,5 @@ tolower toupper !___CONIO___ con_set_title +!___LIBC_VERSION___ +_libc_get_version