I want to generate random number between two numbers in C (Kernel). It's easy in C with standard library, but in C without library, I just found this links: link 1, link 2 and I don't know how can I use the codes are in links.
I cannot show my code. Because my code is too long (+1000 lines of code).
Edit
Here is my incomplete code:
#include <lib.h>
int rand()
{
unsigned long int next = 1;
next = next * 1103515245 + 12345;
return (unsigned int)(next / 65536) % (RAND_MAX + 1);
}
int rrand(int min, int max)
{
/* incomplete */
}
lib.h:
#ifndef _LIB_H
# define _LIB_H
#endif
#ifdef _LIB_H
# ifndef _DEF_H /* this line isn't important for this question */
# include <def.h> /* this line isn't important for this question */
# endif
# define RAND_MAX 32767
extern int rand();
extern int rrand(int min, int max);
extern void *malloc(size_t size); /* this line isn't important for this question */
extern int atoi(char *str); /* this line isn't important for this question */
extern char *itoa(int value, char *str, int base); /* this line isn't important for this question */
#endif
Edit 2
I can compile my code without error.