kolibrios-gitea/programs/develop/libraries/libs_v2/include/stdlib.c
pavelyakov befac9b242 source code library
git-svn-id: svn://kolibrios.org@5936 a494cfbc-eb01-0410-851d-a64ba20cac60
2015-11-27 09:20:48 +00:00

49 lines
808 B
C

#ifndef STDLIB_C_INCLUDE
#define STDLIB_C_INCLUDE
#define RAND_MAX 0x7FFFU
#define isspace(c) ((c)==' ')
#define abs(i) (((i)<0)?(-(i)):(i))
#define random(num) ((rand()*(num))/((RAND_MAX+1)))
static unsigned int seed_o = 0x45168297;
static inline void srand (unsigned seed)
{
seed_o = seed;
}
static inline int rand (void)
{
seed_o = seed_o * 0x15a4e35 + 1;
return(seed_o >> 16);
}
static inline void* malloc(unsigned s)
{
asm ("int $0x40"::"a"(68), "b"(12), "c"(s) );
}
static inline void free(void *p)
{
asm ("int $0x40"::"a"(68), "b"(13), "c"(p) );
}
static inline void *realloc(void *data, long size)
{
void *r = malloc(size);
byte *p = (byte *)r;
byte *pd = (byte *)data;
while(size--) *p++=*pd++;
free(data);
return r;
}
#endif