diff options
author | Keir Fraser <keir.fraser@citrix.com> | 2008-01-22 14:20:22 +0000 |
---|---|---|
committer | Keir Fraser <keir.fraser@citrix.com> | 2008-01-22 14:20:22 +0000 |
commit | e8c1abd6e75d35e747611bcad82d0d4a6564beca (patch) | |
tree | 932aa4b778d3c4871b21f89eaa4db484c34e1d21 /extras/mini-os/lib | |
parent | dfba81d2fcc227ffc2ce546d9884580f682e68b5 (diff) | |
download | xen-e8c1abd6e75d35e747611bcad82d0d4a6564beca.tar.gz xen-e8c1abd6e75d35e747611bcad82d0d4a6564beca.tar.bz2 xen-e8c1abd6e75d35e747611bcad82d0d4a6564beca.zip |
minios: POSIX fixes
Fixes some functions which are POSIX. Also make them ifndef HAVE_LIBC.
Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>
Diffstat (limited to 'extras/mini-os/lib')
-rw-r--r-- | extras/mini-os/lib/math.c | 17 | ||||
-rw-r--r-- | extras/mini-os/lib/xmalloc.c | 2 |
2 files changed, 19 insertions, 0 deletions
diff --git a/extras/mini-os/lib/math.c b/extras/mini-os/lib/math.c index 5f5ed55ec2..807bcc8e0d 100644 --- a/extras/mini-os/lib/math.c +++ b/extras/mini-os/lib/math.c @@ -56,6 +56,8 @@ */ #include <types.h> +#include <lib.h> +#include <time.h> /* On ia64 these functions lead to crashes. These are replaced by * assembler functions. */ @@ -85,7 +87,9 @@ union uu { * These are used for shifting, and also below for halfword extraction * and assembly. */ +#ifndef HAVE_LIBC #define CHAR_BIT 8 /* number of bits in a char */ +#endif #define QUAD_BITS (sizeof(s64) * CHAR_BIT) #define LONG_BITS (sizeof(long) * CHAR_BIT) #define HALF_BITS (sizeof(long) * CHAR_BIT / 2) @@ -385,3 +389,16 @@ __umoddi3(u_quad_t a, u_quad_t b) } #endif /* !defined(__ia64__) */ + +#ifndef HAVE_LIBC +/* Should be random enough for our uses */ +int rand(void) +{ + static unsigned int previous; + struct timeval tv; + gettimeofday(&tv, NULL); + previous += tv.tv_sec + tv.tv_usec; + previous *= RAND_MIX; + return previous; +} +#endif diff --git a/extras/mini-os/lib/xmalloc.c b/extras/mini-os/lib/xmalloc.c index be3d228c04..9e59c9f834 100644 --- a/extras/mini-os/lib/xmalloc.c +++ b/extras/mini-os/lib/xmalloc.c @@ -43,6 +43,7 @@ #include <list.h> #include <xmalloc.h> +#ifndef HAVE_LIBC static LIST_HEAD(freelist); /* static spinlock_t freelist_lock = SPIN_LOCK_UNLOCKED; */ @@ -295,3 +296,4 @@ void *_realloc(void *ptr, size_t size) return new; } +#endif |