aboutsummaryrefslogtreecommitdiffstats
path: root/extras/mini-os/include
diff options
context:
space:
mode:
authorKeir Fraser <keir.fraser@citrix.com>2008-01-22 14:20:22 +0000
committerKeir Fraser <keir.fraser@citrix.com>2008-01-22 14:20:22 +0000
commite8c1abd6e75d35e747611bcad82d0d4a6564beca (patch)
tree932aa4b778d3c4871b21f89eaa4db484c34e1d21 /extras/mini-os/include
parentdfba81d2fcc227ffc2ce546d9884580f682e68b5 (diff)
downloadxen-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/include')
-rw-r--r--extras/mini-os/include/blkfront.h2
-rw-r--r--extras/mini-os/include/ia64/os.h2
-rw-r--r--extras/mini-os/include/lib.h12
-rw-r--r--extras/mini-os/include/sched.h2
-rw-r--r--extras/mini-os/include/types.h19
-rw-r--r--extras/mini-os/include/xmalloc.h18
6 files changed, 45 insertions, 10 deletions
diff --git a/extras/mini-os/include/blkfront.h b/extras/mini-os/include/blkfront.h
index 9460a00942..92e658e899 100644
--- a/extras/mini-os/include/blkfront.h
+++ b/extras/mini-os/include/blkfront.h
@@ -7,7 +7,7 @@ struct blkfront_aiocb
struct blkfront_dev *aio_dev;
uint8_t *aio_buf;
size_t aio_nbytes;
- uint64_t aio_offset;
+ off_t aio_offset;
void *data;
grant_ref_t gref[BLKIF_MAX_SEGMENTS_PER_REQUEST];
diff --git a/extras/mini-os/include/ia64/os.h b/extras/mini-os/include/ia64/os.h
index 51e365e8a6..e6b7884d7a 100644
--- a/extras/mini-os/include/ia64/os.h
+++ b/extras/mini-os/include/ia64/os.h
@@ -38,7 +38,9 @@
typedef uint64_t paddr_t; /* Physical address. */
+#ifndef HAVE_LIBC
typedef uint64_t caddr_t; /* rr7/kernel memory address. */
+#endif
#include "page.h"
#include "mm.h"
diff --git a/extras/mini-os/include/lib.h b/extras/mini-os/include/lib.h
index 97a2305daa..d946e0a534 100644
--- a/extras/mini-os/include/lib.h
+++ b/extras/mini-os/include/lib.h
@@ -59,6 +59,9 @@
#include <stddef.h>
#include <console.h>
+#ifdef HAVE_LIBC
+#include <stdio.h>
+#else
/* printing */
#define _p(_x) ((void *)(unsigned long)(_x))
int vsnprintf(char *buf, size_t size, const char *fmt, va_list args);
@@ -69,13 +72,16 @@ int vsprintf(char *buf, const char *fmt, va_list args);
int sprintf(char * buf, const char *fmt, ...);
int vsscanf(const char * buf, const char * fmt, va_list args);
int sscanf(const char * buf, const char * fmt, ...);
+#endif
long simple_strtol(const char *cp,char **endp,unsigned int base);
unsigned long simple_strtoul(const char *cp,char **endp,unsigned int base);
long long simple_strtoll(const char *cp,char **endp,unsigned int base);
unsigned long long simple_strtoull(const char *cp,char **endp,unsigned int base);
-
+#ifdef HAVE_LIBC
+#include <string.h>
+#else
/* string and memory manipulation */
int memcmp(const void *cs, const void *ct, size_t count);
void *memcpy(void *dest, const void *src, size_t count);
@@ -91,7 +97,11 @@ char *strrchr(const char *s, int c);
char *strstr(const char *s1, const char *s2);
char * strcat(char * dest, const char * src);
char *strdup(const char *s);
+#endif
+
+#define RAND_MIX 2654435769U
+int rand(void);
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
diff --git a/extras/mini-os/include/sched.h b/extras/mini-os/include/sched.h
index 734e441a15..a3d2022b8a 100644
--- a/extras/mini-os/include/sched.h
+++ b/extras/mini-os/include/sched.h
@@ -47,6 +47,6 @@ void schedule(void);
void wake(struct thread *thread);
void block(struct thread *thread);
-void sleep(u32 millisecs);
+void msleep(u32 millisecs);
#endif /* __SCHED_H__ */
diff --git a/extras/mini-os/include/types.h b/extras/mini-os/include/types.h
index a53db24a93..c11765167d 100644
--- a/extras/mini-os/include/types.h
+++ b/extras/mini-os/include/types.h
@@ -42,7 +42,6 @@ typedef unsigned long u_long;
#ifdef __i386__
typedef long long quad_t;
typedef unsigned long long u_quad_t;
-typedef unsigned int uintptr_t;
#if !defined(CONFIG_X86_PAE)
typedef struct { unsigned long pte_low; } pte_t;
@@ -53,7 +52,6 @@ typedef struct { unsigned long pte_low, pte_high; } pte_t;
#elif defined(__x86_64__) || defined(__ia64__)
typedef long quad_t;
typedef unsigned long u_quad_t;
-typedef unsigned long uintptr_t;
typedef struct { unsigned long pte; } pte_t;
#endif /* __i386__ || __x86_64__ */
@@ -65,18 +63,31 @@ typedef struct { unsigned long pte; } pte_t;
((pte_t) {(unsigned long)(_x), (unsigned long)(_x>>32)}); })
#endif
+#ifdef HAVE_LIBC
+#include <limits.h>
+#include <stdint.h>
+#else
+#ifdef __i386__
+typedef unsigned int uintptr_t;
+typedef int intptr_t;
+#elif defined(__x86_64__) || defined(__ia64__)
+typedef unsigned long uintptr_t;
+typedef long intptr_t;
+#endif /* __i386__ || __x86_64__ */
typedef u8 uint8_t;
typedef s8 int8_t;
typedef u16 uint16_t;
typedef s16 int16_t;
typedef u32 uint32_t;
typedef s32 int32_t;
-typedef u64 uint64_t;
-typedef s64 int64_t;
+typedef u64 uint64_t, uintmax_t;
+typedef s64 int64_t, intmax_t;
+typedef u64 off_t;
#define INT_MAX ((int)(~0U>>1))
#define UINT_MAX (~0U)
typedef long ssize_t;
+#endif
#endif /* _TYPES_H_ */
diff --git a/extras/mini-os/include/xmalloc.h b/extras/mini-os/include/xmalloc.h
index 26ae9dd012..e168a84f88 100644
--- a/extras/mini-os/include/xmalloc.h
+++ b/extras/mini-os/include/xmalloc.h
@@ -1,11 +1,15 @@
#ifndef __XMALLOC_H__
#define __XMALLOC_H__
+#ifdef HAVE_LIBC
+
+#include <stdlib.h>
+#include <malloc.h>
/* Allocate space for typed object. */
-#define xmalloc(_type) ((_type *)_xmalloc(sizeof(_type), __alignof__(_type)))
+#define _xmalloc(size, align) memalign(align, size)
+#define xfree(ptr) free(ptr)
-/* Allocate space for array of typed objects. */
-#define xmalloc_array(_type, _num) ((_type *)_xmalloc_array(sizeof(_type), __alignof__(_type), _num))
+#else
#define DEFAULT_ALIGN (sizeof(unsigned long))
#define malloc(size) _xmalloc(size, DEFAULT_ALIGN)
@@ -19,6 +23,8 @@ extern void xfree(const void *);
extern void *_xmalloc(size_t size, size_t align);
extern void *_realloc(void *ptr, size_t size);
+#endif
+
static inline void *_xmalloc_array(size_t size, size_t align, size_t num)
{
/* Check for overflow. */
@@ -27,4 +33,10 @@ static inline void *_xmalloc_array(size_t size, size_t align, size_t num)
return _xmalloc(size * num, align);
}
+/* Allocate space for typed object. */
+#define xmalloc(_type) ((_type *)_xmalloc(sizeof(_type), __alignof__(_type)))
+
+/* Allocate space for array of typed objects. */
+#define xmalloc_array(_type, _num) ((_type *)_xmalloc_array(sizeof(_type), __alignof__(_type), _num))
+
#endif /* __XMALLOC_H__ */