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 633e3738b2..3a0b5e8720 100644 Binary files a/programs/develop/libraries/kolibri-libc/lib/libc.obj.a and b/programs/develop/libraries/kolibri-libc/lib/libc.obj.a differ 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