]> xenbits.xensource.com Git - rumpuser-xen.git/commitdiff
unifdef -UHAVE_LIBC
authorAntti Kantee <pooka@iki.fi>
Mon, 2 Sep 2013 19:29:01 +0000 (21:29 +0200)
committerAntti Kantee <pooka@iki.fi>
Mon, 2 Sep 2013 19:29:01 +0000 (21:29 +0200)
We're going to have a real libc, and we don't want
this code around complicating things.

31 files changed:
arch/x86/mm.c
blkfront.c
console/console.c
console/xenbus.c
console/xencons_ring.c
fbfront.c
include/arch/cc.h
include/blkfront.h
include/console.h
include/ctype.h
include/errno.h
include/fbfront.h
include/fcntl.h
include/lib.h
include/mm.h
include/netfront.h
include/sched.h
include/sys/lock.h
include/sys/time.h
include/time.h
include/types.h
include/xmalloc.h
lib/ctype.c
lib/math.c
lib/sys.c
lib/xs.c
lock.c
main.c
mm.c
netfront.c
sched.c

index 80aceacd2a28d07e4930fdc0bb9a40ab9ac8c388..76742b4757138ddc3608db01da2111dfa743f568 100644 (file)
@@ -499,16 +499,7 @@ static unsigned long demand_map_area_start;
 #define DEMAND_MAP_PAGES ((2ULL << 30) / PAGE_SIZE)
 #endif
 
-#ifndef HAVE_LIBC
 #define HEAP_PAGES 0
-#else
-unsigned long heap, brk, heap_mapped, heap_end;
-#ifdef __x86_64__
-#define HEAP_PAGES ((128ULL << 30) / PAGE_SIZE)
-#else
-#define HEAP_PAGES ((1ULL << 30) / PAGE_SIZE)
-#endif
-#endif
 
 void arch_init_demand_mapping_area(unsigned long cur_pfn)
 {
@@ -519,13 +510,6 @@ void arch_init_demand_mapping_area(unsigned long cur_pfn)
     printk("Demand map pfns at %lx-%lx.\n", 
            demand_map_area_start, pfn_to_virt(cur_pfn));
 
-#ifdef HAVE_LIBC
-    cur_pfn++;
-    heap_mapped = brk = heap = (unsigned long) pfn_to_virt(cur_pfn);
-    cur_pfn += HEAP_PAGES;
-    heap_end = (unsigned long) pfn_to_virt(cur_pfn);
-    printk("Heap resides at %lx-%lx.\n", brk, heap_end);
-#endif
 }
 
 unsigned long allocate_ondemand(unsigned long n, unsigned long alignment)
index ef2eb85bda7e534ded6d225317f3e13b1daea4a2..a7eaaaf76bf6db7defd33576cdb81f0860dc7853 100644 (file)
@@ -50,20 +50,10 @@ struct blkfront_dev {
 
     xenbus_event_queue events;
 
-#ifdef HAVE_LIBC
-    int fd;
-#endif
 };
 
 void blkfront_handler(evtchn_port_t port, struct pt_regs *regs, void *data)
 {
-#ifdef HAVE_LIBC
-    struct blkfront_dev *dev = data;
-    int fd = dev->fd;
-
-    if (fd != -1)
-        files[fd].read = 1;
-#endif
     wake_up(&blkfront_queue);
 }
 
@@ -102,9 +92,6 @@ struct blkfront_dev *init_blkfront(char *_nodename, struct blkfront_info *info)
     dev = malloc(sizeof(*dev));
     memset(dev, 0, sizeof(*dev));
     dev->nodename = strdup(nodename);
-#ifdef HAVE_LIBC
-    dev->fd = -1;
-#endif
 
     snprintf(path, sizeof(path), "%s/backend-id", nodename);
     dev->dom = xenbus_read_integer(path); 
@@ -479,12 +466,6 @@ int blkfront_aio_poll(struct blkfront_dev *dev)
     int nr_consumed;
 
 moretodo:
-#ifdef HAVE_LIBC
-    if (dev->fd != -1) {
-        files[dev->fd].read = 0;
-        mb(); /* Make sure to let the handler set read to 1 before we start looking at the ring */
-    }
-#endif
 
     rp = dev->ring.sring->rsp_prod;
     rmb(); /* Ensure we see queued responses up to 'rp'. */
@@ -540,12 +521,3 @@ moretodo:
     return nr_consumed;
 }
 
-#ifdef HAVE_LIBC
-int blkfront_open(struct blkfront_dev *dev)
-{
-    dev->fd = alloc_fd(FTYPE_BLK);
-    printk("blk_open(%s) -> %d\n", dev->nodename, dev->fd);
-    files[dev->fd].blk.dev = dev;
-    return dev->fd;
-}
-#endif
index 0bd0443087fd7181a71acc92c193f63313d31590..7c85c6f0004f54ec84053a1a53a3bf5498d5055c 100644 (file)
@@ -55,7 +55,6 @@
 static int console_initialised = 0;
 
 
-#ifndef HAVE_LIBC
 void xencons_rx(char *buf, unsigned len, struct pt_regs *regs)
 {
     if(len > 0)
@@ -73,7 +72,6 @@ void xencons_tx(void)
 {
     /* Do nothing, handled by _rx */
 }
-#endif
 
 
 void console_print(struct consfront_dev *dev, char *data, int length)
index 77de82a0fa313c7123af51298537385bfb8be08c..bf03ed0407caf833318aa67baf3f89428a71e90e 100644 (file)
@@ -79,9 +79,6 @@ struct consfront_dev *init_consfront(char *_nodename)
     dev = malloc(sizeof(*dev));
     memset(dev, 0, sizeof(*dev));
     dev->nodename = strdup(nodename);
-#ifdef HAVE_LIBC
-    dev->fd = -1;
-#endif
 
     snprintf(path, sizeof(path), "%s/backend-id", nodename);
     if ((res = xenbus_read_integer(path)) < 0) 
index 81c8e997a9c4feaa7e0a7045870cc553308190db..0a35fbfbbe910084bd38b3fb572b537a6a8dc146 100644 (file)
@@ -74,14 +74,6 @@ int xencons_ring_send(struct consfront_dev *dev, const char *data, unsigned len)
 void console_handle_input(evtchn_port_t port, struct pt_regs *regs, void *data)
 {
        struct consfront_dev *dev = (struct consfront_dev *) data;
-#ifdef HAVE_LIBC
-        int fd = dev ? dev->fd : -1;
-
-        if (fd != -1)
-            files[fd].read = 1;
-
-        wake_up(&console_queue);
-#else
        struct xencons_interface *intf = xencons_interface();
        XENCONS_RING_IDX cons, prod;
 
@@ -101,57 +93,8 @@ void console_handle_input(evtchn_port_t port, struct pt_regs *regs, void *data)
        notify_daemon(dev);
 
        xencons_tx();
-#endif
 }
 
-#ifdef HAVE_LIBC
-int xencons_ring_avail(struct consfront_dev *dev)
-{
-       struct xencons_interface *intf;
-       XENCONS_RING_IDX cons, prod;
-
-        if (!dev)
-            intf = xencons_interface();
-        else
-            intf = dev->ring;
-
-       cons = intf->in_cons;
-       prod = intf->in_prod;
-       mb();
-       BUG_ON((prod - cons) > sizeof(intf->in));
-
-        return prod - cons;
-}
-
-int xencons_ring_recv(struct consfront_dev *dev, char *data, unsigned len)
-{
-       struct xencons_interface *intf;
-       XENCONS_RING_IDX cons, prod;
-        unsigned filled = 0;
-
-        if (!dev)
-            intf = xencons_interface();
-        else
-            intf = dev->ring;
-
-       cons = intf->in_cons;
-       prod = intf->in_prod;
-       mb();
-       BUG_ON((prod - cons) > sizeof(intf->in));
-
-        while (filled < len && cons + filled != prod) {
-                data[filled] = *(intf->in + MASK_XENCONS_IDX(cons + filled, intf->in));
-                filled++;
-       }
-
-       mb();
-        intf->in_cons = cons + filled;
-
-       notify_daemon(dev);
-
-        return filled;
-}
-#endif
 
 struct consfront_dev *xencons_ring_init(void)
 {
@@ -168,9 +111,6 @@ struct consfront_dev *xencons_ring_init(void)
        dev->backend = 0;
        dev->ring_ref = 0;
 
-#ifdef HAVE_LIBC
-       dev->fd = -1;
-#endif
        dev->evtchn = start_info.console.domU.evtchn;
        dev->ring = (struct xencons_interface *) mfn_to_virt(start_info.console.domU.mfn);
 
index 54a5e67f6cc3a90daebe2b1d3088b1dee8c789a5..3e999b8f41e389300fbce2464b1d086b1511962b 100644 (file)
--- a/fbfront.c
+++ b/fbfront.c
@@ -33,20 +33,10 @@ struct kbdfront_dev {
 
     xenbus_event_queue events;
 
-#ifdef HAVE_LIBC
-    int fd;
-#endif
 };
 
 void kbdfront_handler(evtchn_port_t port, struct pt_regs *regs, void *data)
 {
-#ifdef HAVE_LIBC
-    struct kbdfront_dev *dev = data;
-    int fd = dev->fd;
-
-    if (fd != -1)
-        files[fd].read = 1;
-#endif
     wake_up(&kbdfront_queue);
 }
 
@@ -82,9 +72,6 @@ struct kbdfront_dev *init_kbdfront(char *_nodename, int abs_pointer)
     dev = malloc(sizeof(*dev));
     memset(dev, 0, sizeof(*dev));
     dev->nodename = strdup(nodename);
-#ifdef HAVE_LIBC
-    dev->fd = -1;
-#endif
 
     snprintf(path, sizeof(path), "%s/backend-id", nodename);
     dev->dom = xenbus_read_integer(path); 
@@ -203,12 +190,6 @@ int kbdfront_receive(struct kbdfront_dev *dev, union xenkbd_in_event *buf, int n
     uint32_t prod, cons;
     int i;
 
-#ifdef HAVE_LIBC
-    if (dev->fd != -1) {
-        files[dev->fd].read = 0;
-        mb(); /* Make sure to let the handler set read to 1 before we start looking at the ring */
-    }
-#endif
 
     prod = page->in_prod;
 
@@ -224,11 +205,6 @@ int kbdfront_receive(struct kbdfront_dev *dev, union xenkbd_in_event *buf, int n
     page->in_cons = cons;
     notify_remote_via_evtchn(dev->evtchn);
 
-#ifdef HAVE_LIBC
-    if (cons != prod && dev->fd != -1)
-        /* still some events to read */
-        files[dev->fd].read = 1;
-#endif
 
     return i;
 }
@@ -292,15 +268,6 @@ close_kbdfront:
         free_kbdfront(dev);
 }
 
-#ifdef HAVE_LIBC
-int kbdfront_open(struct kbdfront_dev *dev)
-{
-    dev->fd = alloc_fd(FTYPE_KBD);
-    printk("kbd_open(%s) -> %d\n", dev->nodename, dev->fd);
-    files[dev->fd].kbd.dev = dev;
-    return dev->fd;
-}
-#endif
 
 
 
@@ -332,20 +299,10 @@ struct fbfront_dev {
 
     xenbus_event_queue events;
 
-#ifdef HAVE_LIBC
-    int fd;
-#endif
 };
 
 void fbfront_handler(evtchn_port_t port, struct pt_regs *regs, void *data)
 {
-#ifdef HAVE_LIBC
-    struct fbfront_dev *dev = data;
-    int fd = dev->fd;
-
-    if (fd != -1)
-        files[fd].read = 1;
-#endif
     wake_up(&fbfront_queue);
 }
 
@@ -369,12 +326,6 @@ int fbfront_receive(struct fbfront_dev *dev, union xenfb_in_event *buf, int n)
     uint32_t prod, cons;
     int i;
 
-#ifdef HAVE_LIBC
-    if (dev->fd != -1) {
-        files[dev->fd].read = 0;
-        mb(); /* Make sure to let the handler set read to 1 before we start looking at the ring */
-    }
-#endif
 
     prod = page->in_prod;
 
@@ -390,11 +341,6 @@ int fbfront_receive(struct fbfront_dev *dev, union xenfb_in_event *buf, int n)
     page->in_cons = cons;
     notify_remote_via_evtchn(dev->evtchn);
 
-#ifdef HAVE_LIBC
-    if (cons != prod && dev->fd != -1)
-        /* still some events to read */
-        files[dev->fd].read = 1;
-#endif
 
     return i;
 }
@@ -420,9 +366,6 @@ struct fbfront_dev *init_fbfront(char *_nodename, unsigned long *mfns, int width
     dev = malloc(sizeof(*dev));
     memset(dev, 0, sizeof(*dev));
     dev->nodename = strdup(nodename);
-#ifdef HAVE_LIBC
-    dev->fd = -1;
-#endif
 
     snprintf(path, sizeof(path), "%s/backend-id", nodename);
     dev->dom = xenbus_read_integer(path); 
@@ -687,13 +630,4 @@ close_fbfront:
         free_fbfront(dev);
 }
 
-#ifdef HAVE_LIBC
-int fbfront_open(struct fbfront_dev *dev)
-{
-    dev->fd = alloc_fd(FTYPE_FB);
-    printk("fb_open(%s) -> %d\n", dev->nodename, dev->fd);
-    files[dev->fd].fb.dev = dev;
-    return dev->fd;
-}
-#endif
 
index 85cfbdba8f3decac2d9b558ebe87dd7e0cb97810..af893292d241b695ae27a0eedc879b4273bc0101 100644 (file)
@@ -54,14 +54,7 @@ extern void lwip_die(char *fmt, ...);
 #include <errno.h>
 
 /*   Not required by the docs, but needed for network-order calculations */
-#ifdef HAVE_LIBC
-#include <machine/endian.h>
-#ifndef BIG_ENDIAN
-#error endian.h does not define byte order
-#endif
-#else
 #include <endian.h>
-#endif
 
 #include <inttypes.h>
 #define S16_F PRIi16
index 724137eb45596036aac883d561486bf7784b7ee2..977f4cd82af5282489f4066142c4735ca0df815c 100644 (file)
@@ -27,9 +27,6 @@ struct blkfront_info
     int flush;
 };
 struct blkfront_dev *init_blkfront(char *nodename, struct blkfront_info *info);
-#ifdef HAVE_LIBC
-int blkfront_open(struct blkfront_dev *dev);
-#endif
 void blkfront_aio(struct blkfront_aiocb *aiocbp, int write);
 #define blkfront_aio_read(aiocbp) blkfront_aio(aiocbp, 0)
 #define blkfront_aio_write(aiocbp) blkfront_aio(aiocbp, 1)
index 79277c2ffa4e3ae469d6d62da0ed7356504fa6e1..e6d657a509813ec985c9252dcd88deea695c5e4a 100644 (file)
@@ -56,9 +56,6 @@ struct consfront_dev {
 
     xenbus_event_queue events;
 
-#ifdef HAVE_LIBC
-    int fd;
-#endif
 };
 
 
index ac0dd67a3c93b87272f7dad577efb60a5e263e46..8c4ce7504f74415f6083e7337d55ba0029d914c4 100644 (file)
@@ -1,9 +1,6 @@
 #ifndef _CTYPE_H
 #define _CTYPE_H
 
-#ifdef HAVE_LIBC
-#include_next <ctype.h>
-#else
 /*
  * NOTE! This ctype does not handle EOF like the standard C
  * library is required to.
@@ -55,6 +52,5 @@ static inline unsigned char __toupper(unsigned char c)
 #define tolower(c) __tolower(c)
 #define toupper(c) __toupper(c)
 
-#endif
 
 #endif
index 6c7c2d99d4afefcf29544418ae49571e3f3d781c..73a6957f0e868bd912781468847792391bb8a292 100644 (file)
@@ -112,13 +112,6 @@ typedef int error_t;
 
 #define EFTYPE          132     /* Inappropriate file type or format */
 
-#ifdef HAVE_LIBC
-#include <mini-os/sched.h>
-extern int errno;
-#define ERRNO
-#define errno (get_current()->reent._errno)
-#else
 #define errno (get_current()->threrrno)
-#endif
 
 #endif
index d4851a4e9812136f03c3e034ae2eb5c52c2959d3..45b1fe3f40d2e830f8a2a850471b964020193c74 100644 (file)
@@ -23,9 +23,6 @@
 
 struct kbdfront_dev;
 struct kbdfront_dev *init_kbdfront(char *nodename, int abs_pointer);
-#ifdef HAVE_LIBC
-int kbdfront_open(struct kbdfront_dev *dev);
-#endif
 
 int kbdfront_receive(struct kbdfront_dev *dev, union xenkbd_in_event *buf, int n);
 extern struct wait_queue_head kbdfront_queue;
@@ -34,9 +31,6 @@ void shutdown_kbdfront(struct kbdfront_dev *dev);
 
 
 struct fbfront_dev *init_fbfront(char *nodename, unsigned long *mfns, int width, int height, int depth, int stride, int n);
-#ifdef HAVE_LIBC
-int fbfront_open(struct fbfront_dev *dev);
-#endif
 
 int fbfront_receive(struct fbfront_dev *dev, union xenfb_in_event *buf, int n);
 extern struct wait_queue_head fbfront_queue;
index cc59b3caa979538fa2aaa7b50e43aaffe2c5485e..2bcffac3528895e85112d1c614ecad43551b9c53 100644 (file)
@@ -1,9 +1,6 @@
 #ifndef _I386_FCNTL_H
 #define _I386_FCNTL_H
 
-#ifdef HAVE_LIBC
-#include_next <fcntl.h>
-#else
 
 /* open/fcntl - O_SYNC is only implemented on blocks devices and on files
    located on an ext2 file system */
@@ -91,7 +88,6 @@ struct flock64 {
 #define F_LINUX_SPECIFIC_BASE  1024
 */
 
-#endif
 
 int open(const char *path, int flags, ...) asm("open64");
 int fcntl(int fd, int cmd, ...);
index 581b65f2d3c85675192b9be03363e9ed7ca2291c..ab474903d1ca7a014906cbfc785971d51e81acb5 100644 (file)
@@ -55,9 +55,6 @@
 #include <sys/queue.h>
 #include "gntmap.h"
 
-#ifdef HAVE_LIBC
-#include <stdio.h>
-#endif
 
 int            sprintf(char *, const char *, ...);
 int            snprintf(char *, size_t, const char *, ...);
@@ -66,9 +63,6 @@ int           vsprintf(char *, const char *, va_list);
 int            vsnprintf(char *, size_t, const char *, va_list);
 unsigned long  strtoul(const char *, char **, int);
 
-#ifdef HAVE_LIBC
-#include <string.h>
-#else
 /* string and memory manipulation */
 
 /*
@@ -103,7 +97,6 @@ char *strrchr(const char *p, int ch);
 void   *memcpy(void *to, const void *from, size_t len);
 
 size_t strnlen(const char *, size_t);
-#endif
 
 #include <mini-os/console.h>
 
@@ -131,79 +124,5 @@ do {                                                           \
 /* Consistency check as much as possible. */
 void sanity_check(void);
 
-#ifdef HAVE_LIBC
-enum fd_type {
-    FTYPE_NONE = 0,
-    FTYPE_CONSOLE,
-    FTYPE_FILE,
-    FTYPE_XENBUS,
-    FTYPE_XC,
-    FTYPE_EVTCHN,
-    FTYPE_GNTMAP,
-    FTYPE_SOCKET,
-    FTYPE_TAP,
-    FTYPE_BLK,
-    FTYPE_KBD,
-    FTYPE_FB,
-    FTYPE_MEM,
-    FTYPE_SAVEFILE,
-};
-
-LIST_HEAD(evtchn_port_list, evtchn_port_info);
-
-struct evtchn_port_info {
-        LIST_ENTRY(evtchn_port_info) list;
-        evtchn_port_t port;
-        unsigned long pending;
-        int bound;
-};
-
-extern struct file {
-    enum fd_type type;
-    union {
-       struct {
-            /* lwIP fd */
-           int fd;
-       } socket;
-       struct {
-            /* FS import fd */
-           int fd;
-           off_t offset;
-       } file;
-       struct {
-           struct evtchn_port_list ports;
-       } evtchn;
-       struct gntmap gntmap;
-       struct {
-           struct netfront_dev *dev;
-       } tap;
-       struct {
-           struct blkfront_dev *dev;
-       } blk;
-       struct {
-           struct kbdfront_dev *dev;
-       } kbd;
-       struct {
-           struct fbfront_dev *dev;
-       } fb;
-       struct {
-           struct consfront_dev *dev;
-       } cons;
-#ifdef CONFIG_XENBUS
-        struct {
-            /* To each xenbus FD is associated a queue of watch events for this
-             * FD.  */
-            xenbus_event_queue events;
-        } xenbus;
-#endif
-    };
-    int read;  /* maybe available for read */
-} files[];
-
-int alloc_fd(enum fd_type type);
-void close_all_files(void);
-extern struct thread *main_thread;
-void sparse(unsigned long data, size_t size);
-#endif
 
 #endif /* _LIB_H_ */
index 2fd43f30b20ab14ff048553c7ca7ee52c52b1a28..720bbbf44166572a1205fc762f518dbcf522376d 100644 (file)
@@ -73,9 +73,6 @@ void do_map_frames(unsigned long addr,
        unsigned long increment, domid_t id, int *err, unsigned long prot);
 int unmap_frames(unsigned long va, unsigned long num_frames);
 unsigned long alloc_contig_pages(int order, unsigned int addr_bits);
-#ifdef HAVE_LIBC
-extern unsigned long heap, brk, heap_mapped, heap_end;
-#endif
 
 int free_physical_pages(xen_pfn_t *mfns, int n);
 void fini_mm(void);
index 952238711ae9d4f0e486aa2e3a9f4c3c2dae249c..71db7341ea3734e02fbc47bafd17e62b47852d14 100644 (file)
@@ -6,10 +6,6 @@ struct netfront_dev;
 struct netfront_dev *init_netfront(char *nodename, void (*netif_rx)(struct netfront_dev *, unsigned char *data, int len), unsigned char rawmac[6], char **ip, void *priv);
 void netfront_xmit(struct netfront_dev *dev, unsigned char* data,int len);
 void shutdown_netfront(struct netfront_dev *dev);
-#ifdef HAVE_LIBC
-int netfront_tap_open(char *nodename);
-ssize_t netfront_receive(struct netfront_dev *dev, unsigned char *data, size_t len);
-#endif
 
 void *netfront_get_private(struct netfront_dev *);
 
index b9d243d7f210561b12acc85196e0363a135d0c7f..6b42dc94b48b92c514803b7b1c0af122b995d1c7 100644 (file)
@@ -4,9 +4,6 @@
 #include <mini-os/list.h>
 #include <mini-os/time.h>
 #include <mini-os/arch_sched.h>
-#ifdef HAVE_LIBC
-#include <sys/reent.h>
-#endif
 
 struct thread {
     const char *name;
@@ -21,11 +18,7 @@ struct thread {
     MINIOS_TAILQ_ENTRY(struct thread) thread_list;
     uint32_t flags;
     s_time_t wakeup_time;
-#ifdef HAVE_LIBC
-    struct _reent reent;
-#else
     int threrrno;
-#endif
     void *lwp;
 };
 
index 8004536d0250f6f66e61eb43d774f6b1054d2c9d..aae0cda5865fb6f5052d2075f26980a641caa84e 100644 (file)
@@ -1,52 +1,5 @@
 #ifndef _MINIOS_SYS_LOCK_H_
 #define _MINIOS_SYS_LOCK_H_
 
-#ifdef HAVE_LIBC
-
-/* Due to inclusion loop, we can not include sched.h, so have to hide things */
-
-#include <mini-os/waittypes.h>
-
-
-typedef struct {
-        int busy;
-        struct wait_queue_head wait;
-} _LOCK_T;
-
-#define __LOCK_INIT(class,lock) \
-    class _LOCK_T lock = { .wait = __WAIT_QUEUE_HEAD_INITIALIZER(lock.wait) }
-int ___lock_init(_LOCK_T *lock);
-int ___lock_acquire(_LOCK_T *lock);
-int ___lock_try_acquire(_LOCK_T *lock);
-int ___lock_release(_LOCK_T *lock);
-int ___lock_close(_LOCK_T *lock);
-#define __lock_init(__lock) ___lock_init(&__lock)
-#define __lock_acquire(__lock) ___lock_acquire(&__lock)
-#define __lock_release(__lock) ___lock_release(&__lock)
-#define __lock_try_acquire(__lock) ___lock_try_acquire(&__lock)
-#define __lock_close(__lock) 0
-
-
-typedef struct {
-    struct thread *owner;
-    int count;
-    struct wait_queue_head wait;
-} _LOCK_RECURSIVE_T;
-
-#define __LOCK_INIT_RECURSIVE(class, lock) \
-    class _LOCK_RECURSIVE_T lock = { .wait = __WAIT_QUEUE_HEAD_INITIALIZER((lock).wait) }
-
-int ___lock_init_recursive(_LOCK_RECURSIVE_T *lock);
-int ___lock_acquire_recursive(_LOCK_RECURSIVE_T *lock);
-int ___lock_try_acquire_recursive(_LOCK_RECURSIVE_T *lock);
-int ___lock_release_recursive(_LOCK_RECURSIVE_T *lock);
-int ___lock_close_recursive(_LOCK_RECURSIVE_T *lock);
-#define __lock_init_recursive(__lock) ___lock_init_recursive(&__lock)
-#define __lock_acquire_recursive(__lock) ___lock_acquire_recursive(&__lock)
-#define __lock_release_recursive(__lock) ___lock_release_recursive(&__lock)
-#define __lock_try_acquire_recursive(__lock) ___lock_try_acquire_recursive(&__lock)
-#define __lock_close_recursive(__lock) 0
-
-#endif
 
 #endif /* _MINIOS_SYS_LOCK_H_ */
index d6623a4e774c69d02f9dd9d2caec5e5f19eba610..87887c27d1536bb7426e974901083a37712be9f3 100644 (file)
@@ -20,9 +20,6 @@
 #ifndef _MINIOS_SYS_TIME_H_
 #define _MINIOS_SYS_TIME_H_
 
-#ifdef HAVE_LIBC
-#include_next <sys/time.h>
-#else
 struct timespec {
     time_t      tv_sec;
     long        tv_nsec;
@@ -37,6 +34,5 @@ struct timeval {
 };
 
 int      gettimeofday(struct timeval *tv, void *tz);
-#endif
 
 #endif /* _MINIOS_SYS_TIME_H_ */
index 5d6ed672d1a738ce831da461a15031ea70a4e724..1ec7c7849642bb329560c32133f2f0aa57ba6933 100644 (file)
@@ -48,9 +48,6 @@ typedef long suseconds_t;
 
 #include <sys/time.h>
 
-#ifdef HAVE_LIBC
-#include_next <time.h>
-#endif
 
 /* prototypes */
 void     init_time(void);
index 456e21ac0687ae33d7b937e20ed69663e471ee8f..d0d95a51f32e6782674ffe079a74ec4262497049 100644 (file)
 #include <stddef.h>
 
 /* FreeBSD compat types */
-#ifndef HAVE_LIBC
 typedef unsigned char       u_char;
 typedef unsigned int        u_int;
 typedef unsigned long       u_long;
-#endif
 #ifdef __i386__
 typedef long long           quad_t;
 typedef unsigned long long  u_quad_t;
@@ -47,10 +45,6 @@ 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;
@@ -74,13 +68,10 @@ typedef unsigned long uint64_t;
 typedef uint64_t uintmax_t;
 typedef  int64_t intmax_t;
 typedef uint64_t off_t;
-#endif
 
 typedef intptr_t            ptrdiff_t;
 
 
-#ifndef HAVE_LIBC
 typedef long ssize_t;
-#endif
 
 #endif /* _TYPES_H_ */
index 95c4e902e9a801de5d883ea3b8b7affcfd8bc695..8e861048c99e086f9b98d951d648145c15ff80c4 100644 (file)
@@ -1,15 +1,6 @@
 #ifndef __XMALLOC_H__
 #define __XMALLOC_H__
 
-#ifdef HAVE_LIBC
-
-#include <stdlib.h>
-#include <malloc.h>
-/* Allocate space for typed object. */
-#define _xmalloc(size, align) memalign(align, size)
-#define xfree(ptr) free(ptr)
-
-#else
 
 #include <limits.h>
 
@@ -26,7 +17,6 @@ void *        calloc(size_t, size_t);
 #define _xmalloc(size, align) memalloc(size, align)
 #define xfree(ptr) free(ptr)
 
-#endif
 
 static inline void *_xmalloc_array(size_t size, size_t align, size_t num)
 {
index 3f3bdb00a94718661c48b37625056002f16df574..be0959391410b7ae9ab8eda1fbbce10120e38835 100644 (file)
@@ -1,4 +1,3 @@
-#ifndef HAVE_LIBC
 #include <ctype.h>
 
 unsigned char _ctype[] = {
@@ -26,4 +25,3 @@ _U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,       /* 192-207 */
 _U,_U,_U,_U,_U,_U,_U,_P,_U,_U,_U,_U,_U,_U,_U,_L,       /* 208-223 */
 _L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,       /* 224-239 */
 _L,_L,_L,_L,_L,_L,_L,_P,_L,_L,_L,_L,_L,_L,_L,_L};      /* 240-255 */
-#endif
index c8f8d33d31dd6df7d2d8fa72782bf7be10cd9719..ad58a0be456a3e68340d5ce6de3b4a92fb3ac8c1 100644 (file)
@@ -85,9 +85,7 @@ 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(quad_t) * CHAR_BIT)
 #define        LONG_BITS       (sizeof(int32_t) * CHAR_BIT)
 #define        HALF_BITS       (sizeof(int32_t) * CHAR_BIT / 2)
@@ -430,7 +428,6 @@ __moddi3(quad_t a, quad_t b)
 }
 #endif /* !defined(__ia64__) */
 
-#ifndef HAVE_LIBC
 /* Should be random enough for our uses */
 int rand(void)
 {
@@ -441,4 +438,3 @@ int rand(void)
     previous *= RAND_MIX;
     return previous;
 }
-#endif
index a7d35d689ef142d0a01502b5439fb628b5a38b19..454c2ab5d78f72d5a24a38d9bde84666e50b754e 100644 (file)
--- a/lib/sys.c
+++ b/lib/sys.c
 #define DEBUG(fmt,...)
 #endif
 
-#ifdef HAVE_LIBC
-#include <os.h>
-#include <console.h>
-#include <sched.h>
-#include <events.h>
-#include <wait.h>
-#include <netfront.h>
-#include <blkfront.h>
-#include <fbfront.h>
-#include <xenbus.h>
-#include <xenstore.h>
-
-#include <sys/types.h>
-#include <sys/unistd.h>
-#include <sys/stat.h>
-#include <sys/mman.h>
-#include <net/if.h>
-#include <time.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <pthread.h>
-#include <assert.h>
-#include <dirent.h>
-#include <stdlib.h>
-#include <math.h>
-
-#ifdef HAVE_LWIP
-#include <lwip/sockets.h>
-#endif
-
-#define debug(fmt, ...) \
-
-#define print_unsupported(fmt, ...) \
-    printk("Unsupported function "fmt" called in Mini-OS kernel\n", ## __VA_ARGS__);
-
-/* Crash on function call */
-#define unsupported_function_crash(function) \
-    int __unsup_##function(void) asm(#function); \
-    int __unsup_##function(void) \
-    { \
-       print_unsupported(#function); \
-       do_exit(); \
-    }
-
-/* Log and err out on function call */
-#define unsupported_function_log(type, function, ret) \
-    type __unsup_##function(void) asm(#function); \
-    type __unsup_##function(void) \
-    { \
-       print_unsupported(#function); \
-       errno = ENOSYS; \
-       return ret; \
-    }
-
-/* Err out on function call */
-#define unsupported_function(type, function, ret) \
-    type __unsup_##function(void) asm(#function); \
-    type __unsup_##function(void) \
-    { \
-       errno = ENOSYS; \
-       return ret; \
-    }
-
-#define NOFILE 32
-extern void minios_interface_close_fd(int fd);
-extern void minios_evtchn_close_fd(int fd);
-extern void minios_gnttab_close_fd(int fd);
-
-pthread_mutex_t fd_lock = PTHREAD_MUTEX_INITIALIZER;
-struct file files[NOFILE] = {
-    { .type = FTYPE_CONSOLE }, /* stdin */
-    { .type = FTYPE_CONSOLE }, /* stdout */
-    { .type = FTYPE_CONSOLE }, /* stderr */
-};
-
-DECLARE_WAIT_QUEUE_HEAD(event_queue);
-
-int alloc_fd(enum fd_type type)
-{
-    int i;
-    pthread_mutex_lock(&fd_lock);
-    for (i=0; i<NOFILE; i++) {
-       if (files[i].type == FTYPE_NONE) {
-           files[i].type = type;
-           pthread_mutex_unlock(&fd_lock);
-           return i;
-       }
-    }
-    pthread_mutex_unlock(&fd_lock);
-    printk("Too many opened files\n");
-    do_exit();
-}
-
-void close_all_files(void)
-{
-    int i;
-    pthread_mutex_lock(&fd_lock);
-    for (i=NOFILE - 1; i > 0; i--)
-       if (files[i].type != FTYPE_NONE)
-            close(i);
-    pthread_mutex_unlock(&fd_lock);
-}
-
-int dup2(int oldfd, int newfd)
-{
-    pthread_mutex_lock(&fd_lock);
-    if (files[newfd].type != FTYPE_NONE)
-       close(newfd);
-    // XXX: this is a bit bogus, as we are supposed to share the offset etc
-    files[newfd] = files[oldfd];
-    pthread_mutex_unlock(&fd_lock);
-    return 0;
-}
-
-pid_t getpid(void)
-{
-    return 1;
-}
-
-pid_t getppid(void)
-{
-    return 1;
-}
-
-pid_t setsid(void)
-{
-    return 1;
-}
-
-char *getcwd(char *buf, size_t size)
-{
-    snprintf(buf, size, "/");
-    return buf;
-}
-
-#define LOG_PATH "/var/log/"
-#define SAVE_PATH "/var/lib/xen"
-#define SAVE_CONSOLE 1
-#define RESTORE_CONSOLE 2
-
-int mkdir(const char *pathname, mode_t mode)
-{
-    errno = EIO;
-    return -1;
-}
-
-#ifdef CONFIG_CONSFRONT
-int posix_openpt(int flags)
-{
-    struct consfront_dev *dev;
-
-    /* Ignore flags */
-
-    dev = init_consfront(NULL);
-    dev->fd = alloc_fd(FTYPE_CONSOLE);
-    files[dev->fd].cons.dev = dev;
-
-    printk("fd(%d) = posix_openpt\n", dev->fd);
-    return(dev->fd);
-}
-
-int open_savefile(const char *path, int save)
-{
-    struct consfront_dev *dev;
-    char nodename[64];
-
-    snprintf(nodename, sizeof(nodename), "device/console/%d", save ? SAVE_CONSOLE : RESTORE_CONSOLE);
-
-    dev = init_consfront(nodename);
-    dev->fd = alloc_fd(FTYPE_SAVEFILE);
-    files[dev->fd].cons.dev = dev;
-
-    printk("fd(%d) = open_savefile\n", dev->fd);
-    return(dev->fd);
-}
-#else
-int posix_openpt(int flags)
-{
-       errno = EIO;
-       return -1;
-}
-int open_savefile(const char *path, int save)
-{
-       errno = EIO;
-       return -1;
-}
-#endif
-
-int open(const char *pathname, int flags, ...)
-{
-    int fd;
-    /* Ugly, but fine.  */
-    if (!strncmp(pathname,LOG_PATH,strlen(LOG_PATH))) {
-       fd = alloc_fd(FTYPE_CONSOLE);
-        printk("open(%s) -> %d\n", pathname, fd);
-        return fd;
-    }
-    if (!strncmp(pathname, "/dev/mem", strlen("/dev/mem"))) {
-        fd = alloc_fd(FTYPE_MEM);
-        printk("open(/dev/mem) -> %d\n", fd);
-        return fd;
-    }
-    if (!strncmp(pathname, "/dev/ptmx", strlen("/dev/ptmx")))
-        return posix_openpt(flags);
-    if (!strncmp(pathname,SAVE_PATH,strlen(SAVE_PATH)))
-        return open_savefile(pathname, flags & O_WRONLY);
-    errno = EIO;
-    return -1;
-}
-
-int isatty(int fd)
-{
-    return files[fd].type == FTYPE_CONSOLE;
-}
-
-int read(int fd, void *buf, size_t nbytes)
-{
-    switch (files[fd].type) {
-        case FTYPE_SAVEFILE:
-       case FTYPE_CONSOLE: {
-           int ret;
-            DEFINE_WAIT(w);
-            while(1) {
-                add_waiter(w, console_queue);
-                ret = xencons_ring_recv(files[fd].cons.dev, buf, nbytes);
-                if (ret)
-                    break;
-                schedule();
-            }
-            remove_waiter(w, console_queue);
-            return ret;
-        }
-#ifdef HAVE_LWIP
-       case FTYPE_SOCKET:
-           return lwip_read(files[fd].socket.fd, buf, nbytes);
-#endif
-#ifdef CONFIG_NETFRONT
-       case FTYPE_TAP: {
-           ssize_t ret;
-           ret = netfront_receive(files[fd].tap.dev, buf, nbytes);
-           if (ret <= 0) {
-               errno = EAGAIN;
-               return -1;
-           }
-           return ret;
-       }
-#endif
-#ifdef CONFIG_KBDFRONT
-        case FTYPE_KBD: {
-            int ret, n;
-            n = nbytes / sizeof(union xenkbd_in_event);
-            ret = kbdfront_receive(files[fd].kbd.dev, buf, n);
-           if (ret <= 0) {
-               errno = EAGAIN;
-               return -1;
-           }
-           return ret * sizeof(union xenkbd_in_event);
-        }
-#endif
-#ifdef CONFIG_FBFRONT
-        case FTYPE_FB: {
-            int ret, n;
-            n = nbytes / sizeof(union xenfb_in_event);
-            ret = fbfront_receive(files[fd].fb.dev, buf, n);
-           if (ret <= 0) {
-               errno = EAGAIN;
-               return -1;
-           }
-           return ret * sizeof(union xenfb_in_event);
-        }
-#endif
-       default:
-           break;
-    }
-    printk("read(%d): Bad descriptor\n", fd);
-    errno = EBADF;
-    return -1;
-}
-
-int write(int fd, const void *buf, size_t nbytes)
-{
-    switch (files[fd].type) {
-        case FTYPE_SAVEFILE: {
-                int ret = 0, tot = nbytes;
-                while (nbytes > 0) {
-                    ret = xencons_ring_send(files[fd].cons.dev, (char *)buf, nbytes);
-                    nbytes -= ret;
-                    buf = (char *)buf + ret;
-                }
-                return tot - nbytes;
-            }
-       case FTYPE_CONSOLE:
-           console_print(files[fd].cons.dev, (char *)buf, nbytes);
-           return nbytes;
-#ifdef HAVE_LWIP
-       case FTYPE_SOCKET:
-           return lwip_write(files[fd].socket.fd, (void*) buf, nbytes);
-#endif
-#ifdef CONFIG_NETFRONT
-       case FTYPE_TAP:
-           netfront_xmit(files[fd].tap.dev, (void*) buf, nbytes);
-           return nbytes;
-#endif
-       default:
-           break;
-    }
-    printk("write(%d): Bad descriptor\n", fd);
-    errno = EBADF;
-    return -1;
-}
-
-off_t lseek(int fd, off_t offset, int whence)
-{
-    errno = ESPIPE;
-    return (off_t) -1;
-}
-
-int fsync(int fd) {
-    errno = EBADF;
-    return -1;
-}
-
-int close(int fd)
-{
-    printk("close(%d)\n", fd);
-    switch (files[fd].type) {
-        default:
-           files[fd].type = FTYPE_NONE;
-           return 0;
-#ifdef CONFIG_XENBUS
-       case FTYPE_XENBUS:
-            xs_daemon_close((void*)(intptr_t) fd);
-            return 0;
-#endif
-#ifdef HAVE_LWIP
-       case FTYPE_SOCKET: {
-           int res = lwip_close(files[fd].socket.fd);
-           files[fd].type = FTYPE_NONE;
-           return res;
-       }
-#endif
-       case FTYPE_XC:
-           minios_interface_close_fd(fd);
-           return 0;
-       case FTYPE_EVTCHN:
-           minios_evtchn_close_fd(fd);
-            return 0;
-       case FTYPE_GNTMAP:
-           minios_gnttab_close_fd(fd);
-           return 0;
-#ifdef CONFIG_NETFRONT
-       case FTYPE_TAP:
-           shutdown_netfront(files[fd].tap.dev);
-           files[fd].type = FTYPE_NONE;
-           return 0;
-#endif
-#ifdef CONFIG_BLKFRONT
-       case FTYPE_BLK:
-            shutdown_blkfront(files[fd].blk.dev);
-           files[fd].type = FTYPE_NONE;
-           return 0;
-#endif
-#ifdef CONFIG_KBDFRONT
-       case FTYPE_KBD:
-            shutdown_kbdfront(files[fd].kbd.dev);
-            files[fd].type = FTYPE_NONE;
-            return 0;
-#endif
-#ifdef CONFIG_FBFRONT
-       case FTYPE_FB:
-            shutdown_fbfront(files[fd].fb.dev);
-            files[fd].type = FTYPE_NONE;
-            return 0;
-#endif
-#ifdef CONFIG_CONSFRONT
-        case FTYPE_SAVEFILE:
-        case FTYPE_CONSOLE:
-            fini_console(files[fd].cons.dev);
-            files[fd].type = FTYPE_NONE;
-            return 0;
-#endif
-       case FTYPE_NONE:
-           break;
-    }
-    printk("close(%d): Bad descriptor\n", fd);
-    errno = EBADF;
-    return -1;
-}
-
-static void init_stat(struct stat *buf)
-{
-    memset(buf, 0, sizeof(*buf));
-    buf->st_dev = 0;
-    buf->st_ino = 0;
-    buf->st_nlink = 1;
-    buf->st_rdev = 0;
-    buf->st_blksize = 4096;
-    buf->st_blocks = 0;
-}
-
-int stat(const char *path, struct stat *buf)
-{
-    errno = EIO;
-    return -1;
-}
-
-int fstat(int fd, struct stat *buf)
-{
-    init_stat(buf);
-    switch (files[fd].type) {
-       case FTYPE_SAVEFILE:
-       case FTYPE_CONSOLE:
-       case FTYPE_SOCKET: {
-            if (files[fd].type == FTYPE_CONSOLE)
-                buf->st_mode = S_IFCHR|S_IRUSR|S_IWUSR;
-            else if (files[fd].type == FTYPE_SOCKET)
-                buf->st_mode = S_IFSOCK|S_IRUSR|S_IWUSR;
-            else if (files[fd].type == FTYPE_SAVEFILE)
-                buf->st_mode = S_IFREG|S_IRUSR|S_IWUSR;
-           buf->st_uid = 0;
-           buf->st_gid = 0;
-           buf->st_size = 0;
-           buf->st_atime = 
-           buf->st_mtime = 
-           buf->st_ctime = time(NULL);
-           return 0;
-       }
-       default:
-           break;
-    }
-
-    printk("statf(%d): Bad descriptor\n", fd);
-    errno = EBADF;
-    return -1;
-}
-
-int ftruncate(int fd, off_t length)
-{
-    errno = EBADF;
-    return -1;
-}
-
-int remove(const char *pathname)
-{
-    errno = EIO;
-    return -1;
-}
-
-int unlink(const char *pathname)
-{
-    return remove(pathname);
-}
-
-int rmdir(const char *pathname)
-{
-    return remove(pathname);
-}
-
-int fcntl(int fd, int cmd, ...)
-{
-    long arg;
-    va_list ap;
-    va_start(ap, cmd);
-    arg = va_arg(ap, long);
-    va_end(ap);
-
-    switch (cmd) {
-#ifdef HAVE_LWIP
-       case F_SETFL:
-           if (files[fd].type == FTYPE_SOCKET && !(arg & ~O_NONBLOCK)) {
-               /* Only flag supported: non-blocking mode */
-               uint32_t nblock = !!(arg & O_NONBLOCK);
-               return lwip_ioctl(files[fd].socket.fd, FIONBIO, &nblock);
-           }
-           /* Fallthrough */
-#endif
-       default:
-           printk("fcntl(%d, %d, %lx/%lo)\n", fd, cmd, arg, arg);
-           errno = ENOSYS;
-           return -1;
-    }
-}
-
-DIR *opendir(const char *name)
-{
-    DIR *ret;
-    ret = malloc(sizeof(*ret));
-    ret->name = strdup(name);
-    ret->offset = 0;
-    ret->entries = NULL;
-    ret->curentry = -1;
-    ret->nbentries = 0;
-    ret->has_more = 1;
-    return ret;
-}
-
-struct dirent *readdir(DIR *dir)
-{
-    return NULL;
-} 
-
-int closedir(DIR *dir)
-{
-    int i;
-    for (i=0; i<dir->nbentries; i++)
-        free(dir->entries[i]);
-    free(dir->entries);
-    free(dir->name);
-    free(dir);
-    return 0;
-}
-
-/* We assume that only the main thread calls select(). */
-
-static const char file_types[] = {
-    [FTYPE_NONE]       = 'N',
-    [FTYPE_CONSOLE]    = 'C',
-    [FTYPE_XENBUS]     = 'S',
-    [FTYPE_XC]         = 'X',
-    [FTYPE_EVTCHN]     = 'E',
-    [FTYPE_SOCKET]     = 's',
-    [FTYPE_TAP]                = 'T',
-    [FTYPE_BLK]                = 'B',
-    [FTYPE_KBD]                = 'K',
-    [FTYPE_FB]         = 'G',
-};
-#ifdef LIBC_DEBUG
-static void dump_set(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout)
-{
-    int i, comma;
-#define printfds(set) do {\
-    comma = 0; \
-    for (i = 0; i < nfds; i++) { \
-       if (FD_ISSET(i, set)) { \
-           if (comma) \
-               printk(", "); \
-           printk("%d(%c)", i, file_types[files[i].type]); \
-           comma = 1; \
-       } \
-    } \
-} while (0)
-
-    printk("[");
-    if (readfds)
-       printfds(readfds);
-    printk("], [");
-    if (writefds)
-       printfds(writefds);
-    printk("], [");
-    if (exceptfds)
-       printfds(exceptfds);
-    printk("], ");
-    if (timeout)
-       printk("{ %ld, %ld }", timeout->tv_sec, timeout->tv_usec);
-}
-#else
-#define dump_set(nfds, readfds, writefds, exceptfds, timeout)
-#endif
-
-/* Just poll without blocking */
-static int select_poll(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds)
-{
-    int i, n = 0;
-#ifdef HAVE_LWIP
-    int sock_n = 0, sock_nfds = 0;
-    fd_set sock_readfds, sock_writefds, sock_exceptfds;
-    struct timeval timeout = { .tv_sec = 0, .tv_usec = 0};
-#endif
-
-#ifdef LIBC_VERBOSE
-    static int nb;
-    static int nbread[NOFILE], nbwrite[NOFILE], nbexcept[NOFILE];
-    static s_time_t lastshown;
-
-    nb++;
-#endif
-
-#ifdef HAVE_LWIP
-    /* first poll network */
-    FD_ZERO(&sock_readfds);
-    FD_ZERO(&sock_writefds);
-    FD_ZERO(&sock_exceptfds);
-    for (i = 0; i < nfds; i++) {
-       if (files[i].type == FTYPE_SOCKET) {
-           if (FD_ISSET(i, readfds)) {
-               FD_SET(files[i].socket.fd, &sock_readfds);
-               sock_nfds = i+1;
-           }
-           if (FD_ISSET(i, writefds)) {
-               FD_SET(files[i].socket.fd, &sock_writefds);
-               sock_nfds = i+1;
-           }
-           if (FD_ISSET(i, exceptfds)) {
-               FD_SET(files[i].socket.fd, &sock_exceptfds);
-               sock_nfds = i+1;
-           }
-       }
-    }
-    if (sock_nfds > 0) {
-        DEBUG("lwip_select(");
-        dump_set(nfds, &sock_readfds, &sock_writefds, &sock_exceptfds, &timeout);
-        DEBUG("); -> ");
-        sock_n = lwip_select(sock_nfds, &sock_readfds, &sock_writefds, &sock_exceptfds, &timeout);
-        dump_set(nfds, &sock_readfds, &sock_writefds, &sock_exceptfds, &timeout);
-        DEBUG("\n");
-    }
-#endif
-
-    /* Then see others as well. */
-    for (i = 0; i < nfds; i++) {
-       switch(files[i].type) {
-       default:
-           if (FD_ISSET(i, readfds) || FD_ISSET(i, writefds) || FD_ISSET(i, exceptfds))
-               printk("bogus fd %d in select\n", i);
-           /* Fallthrough.  */
-       case FTYPE_CONSOLE:
-           if (FD_ISSET(i, readfds)) {
-                if (xencons_ring_avail(files[i].cons.dev))
-                   n++;
-               else
-                   FD_CLR(i, readfds);
-            }
-           if (FD_ISSET(i, writefds))
-                n++;
-           FD_CLR(i, exceptfds);
-           break;
-#ifdef CONFIG_XENBUS
-       case FTYPE_XENBUS:
-           if (FD_ISSET(i, readfds)) {
-                if (files[i].xenbus.events)
-                   n++;
-               else
-                   FD_CLR(i, readfds);
-           }
-           FD_CLR(i, writefds);
-           FD_CLR(i, exceptfds);
-           break;
-#endif
-       case FTYPE_EVTCHN:
-       case FTYPE_TAP:
-       case FTYPE_BLK:
-       case FTYPE_KBD:
-       case FTYPE_FB:
-           if (FD_ISSET(i, readfds)) {
-               if (files[i].read)
-                   n++;
-               else
-                   FD_CLR(i, readfds);
-           }
-           FD_CLR(i, writefds);
-           FD_CLR(i, exceptfds);
-           break;
-#ifdef HAVE_LWIP
-       case FTYPE_SOCKET:
-           if (FD_ISSET(i, readfds)) {
-               /* Optimize no-network-packet case.  */
-               if (sock_n && FD_ISSET(files[i].socket.fd, &sock_readfds))
-                   n++;
-               else
-                   FD_CLR(i, readfds);
-           }
-            if (FD_ISSET(i, writefds)) {
-               if (sock_n && FD_ISSET(files[i].socket.fd, &sock_writefds))
-                   n++;
-               else
-                   FD_CLR(i, writefds);
-            }
-            if (FD_ISSET(i, exceptfds)) {
-               if (sock_n && FD_ISSET(files[i].socket.fd, &sock_exceptfds))
-                   n++;
-               else
-                   FD_CLR(i, exceptfds);
-            }
-           break;
-#endif
-       }
-#ifdef LIBC_VERBOSE
-       if (FD_ISSET(i, readfds))
-           nbread[i]++;
-       if (FD_ISSET(i, writefds))
-           nbwrite[i]++;
-       if (FD_ISSET(i, exceptfds))
-           nbexcept[i]++;
-#endif
-    }
-#ifdef LIBC_VERBOSE
-    if (NOW() > lastshown + 1000000000ull) {
-       lastshown = NOW();
-       printk("%lu MB free, ", num_free_pages() / ((1 << 20) / PAGE_SIZE));
-       printk("%d(%d): ", nb, sock_n);
-       for (i = 0; i < nfds; i++) {
-           if (nbread[i] || nbwrite[i] || nbexcept[i])
-               printk(" %d(%c):", i, file_types[files[i].type]);
-           if (nbread[i])
-               printk(" %dR", nbread[i]);
-           if (nbwrite[i])
-               printk(" %dW", nbwrite[i]);
-           if (nbexcept[i])
-               printk(" %dE", nbexcept[i]);
-       }
-       printk("\n");
-       memset(nbread, 0, sizeof(nbread));
-       memset(nbwrite, 0, sizeof(nbwrite));
-       memset(nbexcept, 0, sizeof(nbexcept));
-       nb = 0;
-    }
-#endif
-    return n;
-}
-
-/* The strategy is to
- * - announce that we will maybe sleep
- * - poll a bit ; if successful, return
- * - if timeout, return
- * - really sleep (except if somebody woke us in the meanwhile) */
-int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
-       struct timeval *timeout)
-{
-    int n, ret;
-    fd_set myread, mywrite, myexcept;
-    struct thread *thread = get_current();
-    s_time_t start = NOW(), stop;
-#ifdef CONFIG_NETFRONT
-    DEFINE_WAIT(netfront_w);
-#endif
-    DEFINE_WAIT(event_w);
-#ifdef CONFIG_BLKFRONT
-    DEFINE_WAIT(blkfront_w);
-#endif
-#ifdef CONFIG_XENBUS
-    DEFINE_WAIT(xenbus_watch_w);
-#endif
-#ifdef CONFIG_KBDFRONT
-    DEFINE_WAIT(kbdfront_w);
-#endif
-    DEFINE_WAIT(console_w);
-
-    assert(thread == main_thread);
-
-    DEBUG("select(%d, ", nfds);
-    dump_set(nfds, readfds, writefds, exceptfds, timeout);
-    DEBUG(");\n");
-
-    if (timeout)
-       stop = start + SECONDS(timeout->tv_sec) + timeout->tv_usec * 1000;
-    else
-       /* just make gcc happy */
-       stop = start;
-
-    /* Tell people we're going to sleep before looking at what they are
-     * saying, hence letting them wake us if events happen between here and
-     * schedule() */
-#ifdef CONFIG_NETFRONT
-    add_waiter(netfront_w, netfront_queue);
-#endif
-    add_waiter(event_w, event_queue);
-#ifdef CONFIG_BLKFRONT
-    add_waiter(blkfront_w, blkfront_queue);
-#endif
-#ifdef CONFIG_XENBUS
-    add_waiter(xenbus_watch_w, xenbus_watch_queue);
-#endif
-#ifdef CONFIG_KBDFRONT
-    add_waiter(kbdfront_w, kbdfront_queue);
-#endif
-    add_waiter(console_w, console_queue);
-
-    if (readfds)
-        myread = *readfds;
-    else
-        FD_ZERO(&myread);
-    if (writefds)
-        mywrite = *writefds;
-    else
-        FD_ZERO(&mywrite);
-    if (exceptfds)
-        myexcept = *exceptfds;
-    else
-        FD_ZERO(&myexcept);
-
-    DEBUG("polling ");
-    dump_set(nfds, &myread, &mywrite, &myexcept, timeout);
-    DEBUG("\n");
-    n = select_poll(nfds, &myread, &mywrite, &myexcept);
-
-    if (n) {
-       dump_set(nfds, readfds, writefds, exceptfds, timeout);
-       if (readfds)
-           *readfds = myread;
-       if (writefds)
-           *writefds = mywrite;
-       if (exceptfds)
-           *exceptfds = myexcept;
-       DEBUG(" -> ");
-       dump_set(nfds, readfds, writefds, exceptfds, timeout);
-       DEBUG("\n");
-       wake(thread);
-       ret = n;
-       goto out;
-    }
-    if (timeout && NOW() >= stop) {
-       if (readfds)
-           FD_ZERO(readfds);
-       if (writefds)
-           FD_ZERO(writefds);
-       if (exceptfds)
-           FD_ZERO(exceptfds);
-       timeout->tv_sec = 0;
-       timeout->tv_usec = 0;
-       wake(thread);
-       ret = 0;
-       goto out;
-    }
-
-    if (timeout)
-       thread->wakeup_time = stop;
-    schedule();
-
-    if (readfds)
-        myread = *readfds;
-    else
-        FD_ZERO(&myread);
-    if (writefds)
-        mywrite = *writefds;
-    else
-        FD_ZERO(&mywrite);
-    if (exceptfds)
-        myexcept = *exceptfds;
-    else
-        FD_ZERO(&myexcept);
-
-    n = select_poll(nfds, &myread, &mywrite, &myexcept);
-
-    if (n) {
-       if (readfds)
-           *readfds = myread;
-       if (writefds)
-           *writefds = mywrite;
-       if (exceptfds)
-           *exceptfds = myexcept;
-       ret = n;
-       goto out;
-    }
-    errno = EINTR;
-    ret = -1;
-
-out:
-#ifdef CONFIG_NETFRONT
-    remove_waiter(netfront_w, netfront_queue);
-#endif
-    remove_waiter(event_w, event_queue);
-#ifdef CONFIG_BLKFRONT
-    remove_waiter(blkfront_w, blkfront_queue);
-#endif
-#ifdef CONFIG_XENBUS
-    remove_waiter(xenbus_watch_w, xenbus_watch_queue);
-#endif
-#ifdef CONFIG_KBDFRONT
-    remove_waiter(kbdfront_w, kbdfront_queue);
-#endif
-    remove_waiter(console_w, console_queue);
-    return ret;
-}
-
-#ifdef HAVE_LWIP
-int socket(int domain, int type, int protocol)
-{
-    int fd, res;
-    fd = lwip_socket(domain, type, protocol);
-    if (fd < 0)
-       return -1;
-    res = alloc_fd(FTYPE_SOCKET);
-    printk("socket -> %d\n", res);
-    files[res].socket.fd = fd;
-    return res;
-}
-
-int accept(int s, struct sockaddr *addr, socklen_t *addrlen)
-{
-    int fd, res;
-    if (files[s].type != FTYPE_SOCKET) {
-       printk("accept(%d): Bad descriptor\n", s);
-       errno = EBADF;
-       return -1;
-    }
-    fd = lwip_accept(files[s].socket.fd, addr, addrlen);
-    if (fd < 0)
-       return -1;
-    res = alloc_fd(FTYPE_SOCKET);
-    files[res].socket.fd = fd;
-    printk("accepted on %d -> %d\n", s, res);
-    return res;
-}
-
-#define LWIP_STUB(ret, name, proto, args) \
-ret name proto \
-{ \
-    if (files[s].type != FTYPE_SOCKET) { \
-       printk(#name "(%d): Bad descriptor\n", s); \
-       errno = EBADF; \
-       return -1; \
-    } \
-    s = files[s].socket.fd; \
-    return lwip_##name args; \
-}
-
-LWIP_STUB(int, bind, (int s, struct sockaddr *my_addr, socklen_t addrlen), (s, my_addr, addrlen))
-LWIP_STUB(int, getsockopt, (int s, int level, int optname, void *optval, socklen_t *optlen), (s, level, optname, optval, optlen))
-LWIP_STUB(int, setsockopt, (int s, int level, int optname, void *optval, socklen_t optlen), (s, level, optname, optval, optlen))
-LWIP_STUB(int, connect, (int s, struct sockaddr *serv_addr, socklen_t addrlen), (s, serv_addr, addrlen))
-LWIP_STUB(int, listen, (int s, int backlog), (s, backlog));
-LWIP_STUB(ssize_t, recv, (int s, void *buf, size_t len, int flags), (s, buf, len, flags))
-LWIP_STUB(ssize_t, recvfrom, (int s, void *buf, size_t len, int flags, struct sockaddr *from, socklen_t *fromlen), (s, buf, len, flags, from, fromlen))
-LWIP_STUB(ssize_t, send, (int s, void *buf, size_t len, int flags), (s, buf, len, flags))
-LWIP_STUB(ssize_t, sendto, (int s, void *buf, size_t len, int flags, struct sockaddr *to, socklen_t tolen), (s, buf, len, flags, to, tolen))
-LWIP_STUB(int, getsockname, (int s, struct sockaddr *name, socklen_t *namelen), (s, name, namelen))
-#endif
-
-static char *syslog_ident;
-void openlog(const char *ident, int option, int facility)
-{
-    if (syslog_ident)
-        free(syslog_ident);
-    syslog_ident = strdup(ident);
-}
-
-void vsyslog(int priority, const char *format, va_list ap)
-{
-    printk("%s: ", syslog_ident);
-    print(0, format, ap);
-}
-
-void syslog(int priority, const char *format, ...)
-{
-    va_list ap;
-    va_start(ap, format);
-    vsyslog(priority, format, ap);
-    va_end(ap);
-}
-
-void closelog(void)
-{
-    free(syslog_ident);
-    syslog_ident = NULL;
-}
-
-void vwarn(const char *format, va_list ap)
-{
-    int the_errno = errno;
-    printk("stubdom: ");
-    if (format) {
-        print(0, format, ap);
-        printk(", ");
-    }
-    printk("%s", strerror(the_errno));
-}
-
-void warn(const char *format, ...)
-{
-    va_list ap;
-    va_start(ap, format);
-    vwarn(format, ap);
-    va_end(ap);
-}
-
-void verr(int eval, const char *format, va_list ap)
-{
-    vwarn(format, ap);
-    exit(eval);
-}
-
-void err(int eval, const char *format, ...)
-{
-    va_list ap;
-    va_start(ap, format);
-    verr(eval, format, ap);
-    va_end(ap);
-}
-
-void vwarnx(const char *format, va_list ap)
-{
-    printk("stubdom: ");
-    if (format)
-        print(0, format, ap);
-}
-
-void warnx(const char *format, ...)
-{
-    va_list ap;
-    va_start(ap, format);
-    vwarnx(format, ap);
-    va_end(ap);
-}
-
-void verrx(int eval, const char *format, va_list ap)
-{
-    vwarnx(format, ap);
-    exit(eval);
-}
-
-void errx(int eval, const char *format, ...)
-{
-    va_list ap;
-    va_start(ap, format);
-    verrx(eval, format, ap);
-    va_end(ap);
-}
-
-int nanosleep(const struct timespec *req, struct timespec *rem)
-{
-    s_time_t start = NOW();
-    s_time_t stop = start + SECONDS(req->tv_sec) + req->tv_nsec;
-    s_time_t stopped;
-    struct thread *thread = get_current();
-
-    thread->wakeup_time = stop;
-    clear_runnable(thread);
-    schedule();
-    stopped = NOW();
-
-    if (rem)
-    {
-       s_time_t remaining = stop - stopped;
-       if (remaining > 0)
-       {
-           rem->tv_nsec = remaining % 1000000000ULL;
-           rem->tv_sec  = remaining / 1000000000ULL;
-       } else memset(rem, 0, sizeof(*rem));
-    }
-
-    return 0;
-}
-
-int usleep(useconds_t usec)
-{
-    /* "usec shall be less than one million."  */
-    struct timespec req;
-    req.tv_nsec = usec * 1000;
-    req.tv_sec = 0;
-
-    if (nanosleep(&req, NULL))
-       return -1;
-
-    return 0;
-}
-
-unsigned int sleep(unsigned int seconds)
-{
-    struct timespec req, rem;
-    req.tv_sec = seconds;
-    req.tv_nsec = 0;
-
-    if (nanosleep(&req, &rem))
-       return -1;
-
-    if (rem.tv_nsec > 0)
-       rem.tv_sec++;
-
-    return rem.tv_sec;
-}
-
-int clock_gettime(clockid_t clk_id, struct timespec *tp)
-{
-    switch (clk_id) {
-       case CLOCK_MONOTONIC:
-       {
-           struct timeval tv;
-
-           gettimeofday(&tv, NULL);
-
-           tp->tv_sec = tv.tv_sec;
-           tp->tv_nsec = tv.tv_usec * 1000;
-
-           break;
-       }
-       case CLOCK_REALTIME:
-       {
-           uint64_t nsec = monotonic_clock();
-
-           tp->tv_sec = nsec / 1000000000ULL;
-           tp->tv_nsec = nsec % 1000000000ULL;
-
-           break;
-       }
-       default:
-           print_unsupported("clock_gettime(%d)", clk_id);
-           errno = EINVAL;
-           return -1;
-    }
-
-    return 0;
-}
-
-uid_t getuid(void)
-{
-       return 0;
-}
-
-uid_t geteuid(void)
-{
-       return 0;
-}
-
-gid_t getgid(void)
-{
-       return 0;
-}
-
-gid_t getegid(void)
-{
-       return 0;
-}
-
-int gethostname(char *name, size_t namelen)
-{
-       strncpy(name, "mini-os", namelen);
-       return 0;
-}
-
-size_t getpagesize(void)
-{
-    return PAGE_SIZE;
-}
-
-void *mmap(void *start, size_t length, int prot, int flags, int fd, off_t offset)
-{
-    unsigned long n = (length + PAGE_SIZE - 1) / PAGE_SIZE;
-
-    ASSERT(!start);
-    ASSERT(prot == (PROT_READ|PROT_WRITE));
-    ASSERT((fd == -1 && (flags == (MAP_SHARED|MAP_ANON) || flags == (MAP_PRIVATE|MAP_ANON)))
-        || (fd != -1 && flags == MAP_SHARED));
-
-    if (fd == -1)
-        return map_zero(n, 1);
-    else if (files[fd].type == FTYPE_XC) {
-        unsigned long zero = 0;
-        return map_frames_ex(&zero, n, 0, 0, 1, DOMID_SELF, NULL, 0);
-    } else if (files[fd].type == FTYPE_MEM) {
-        unsigned long first_mfn = offset >> PAGE_SHIFT;
-        return map_frames_ex(&first_mfn, n, 0, 1, 1, DOMID_IO, NULL, _PAGE_PRESENT|_PAGE_RW);
-    } else ASSERT(0);
-}
-
-int munmap(void *start, size_t length)
-{
-    int total = length / PAGE_SIZE;
-    int ret;
-
-    ret = unmap_frames((unsigned long)start, (unsigned long)total);
-    if (ret) {
-        errno = ret;
-        return -1;
-    }
-    return 0;
-}
-
-void sparse(unsigned long data, size_t size)
-{
-    unsigned long newdata;
-    xen_pfn_t *mfns;
-    int i, n;
-
-    newdata = (data + PAGE_SIZE - 1) & PAGE_MASK;
-    if (newdata - data > size)
-        return;
-    size -= newdata - data;
-    data = newdata;
-    n = size / PAGE_SIZE;
-    size = n * PAGE_SIZE;
-
-    mfns = malloc(n * sizeof(*mfns));
-    for (i = 0; i < n; i++) {
-#ifdef LIBC_DEBUG
-        int j;
-        for (j=0; j<PAGE_SIZE; j++)
-            if (((char*)data + i * PAGE_SIZE)[j]) {
-                printk("%lx is not zero!\n", data + i * PAGE_SIZE + j);
-                exit(1);
-            }
-#endif
-        mfns[i] = virtual_to_mfn(data + i * PAGE_SIZE);
-    }
-
-    printk("sparsing %ldMB at %lx\n", size >> 20, data);
-
-    munmap((void *) data, size);
-    free_physical_pages(mfns, n);
-    do_map_zero(data, n);
-}
-
-int nice(int inc)
-{
-    printk("nice() stub called with inc=%d\n", inc);
-    return 0;
-}
-
-
-/* Not supported by FS yet.  */
-unsupported_function_crash(link);
-unsupported_function(int, readlink, -1);
-unsupported_function_crash(umask);
-
-/* We could support that.  */
-unsupported_function_log(int, chdir, -1);
-
-/* No dynamic library support.  */ 
-unsupported_function_log(void *, dlopen, NULL);
-unsupported_function_log(void *, dlsym, NULL);
-unsupported_function_log(char *, dlerror, NULL);
-unsupported_function_log(int, dlclose, -1);
-
-/* We don't raise signals anyway.  */
-unsupported_function(int, sigemptyset, -1);
-unsupported_function(int, sigfillset, -1);
-unsupported_function(int, sigaddset, -1);
-unsupported_function(int, sigdelset, -1);
-unsupported_function(int, sigismember, -1);
-unsupported_function(int, sigprocmask, -1);
-unsupported_function(int, sigaction, -1);
-unsupported_function(int, __sigsetjmp, 0);
-unsupported_function(int, sigaltstack, -1);
-unsupported_function_crash(kill);
-
-/* Unsupported */
-unsupported_function_crash(pipe);
-unsupported_function_crash(fork);
-unsupported_function_crash(execv);
-unsupported_function_crash(execve);
-unsupported_function_crash(waitpid);
-unsupported_function_crash(wait);
-unsupported_function_crash(lockf);
-unsupported_function_crash(sysconf);
-unsupported_function(int, tcsetattr, -1);
-unsupported_function(int, tcgetattr, 0);
-unsupported_function(int, grantpt, -1);
-unsupported_function(int, unlockpt, -1);
-unsupported_function(char *, ptsname, NULL);
-unsupported_function(int, poll, -1);
-
-/* net/if.h */
-unsupported_function_log(unsigned int, if_nametoindex, -1);
-unsupported_function_log(char *, if_indextoname, (char *) NULL);
-unsupported_function_log(struct  if_nameindex *, if_nameindex, (struct  if_nameindex *) NULL);
-unsupported_function_crash(if_freenameindex);
-
-/* Linuxish abi for the Caml runtime, don't support 
-   Log, and return an error code if possible.  If it is not possible
-   to inform the application of an error, then crash instead!
-*/
-unsupported_function_log(struct dirent *, readdir64, NULL);
-unsupported_function_log(int, getrusage, -1);
-unsupported_function_log(int, getrlimit, -1);
-unsupported_function_log(int, getrlimit64, -1);
-unsupported_function_log(int, __xstat64, -1);
-unsupported_function_log(long, __strtol_internal, LONG_MIN);
-unsupported_function_log(double, __strtod_internal, HUGE_VAL);
-unsupported_function_log(int, utime, -1);
-unsupported_function_log(int, truncate64, -1);
-unsupported_function_log(int, tcflow, -1);
-unsupported_function_log(int, tcflush, -1);
-unsupported_function_log(int, tcdrain, -1);
-unsupported_function_log(int, tcsendbreak, -1);
-unsupported_function_log(int, cfsetospeed, -1);
-unsupported_function_log(int, cfsetispeed, -1);
-unsupported_function_crash(cfgetospeed);
-unsupported_function_crash(cfgetispeed);
-unsupported_function_log(int, symlink, -1);
-unsupported_function_log(const char*, inet_ntop, NULL);
-unsupported_function_crash(__fxstat64);
-unsupported_function_crash(__lxstat64);
-unsupported_function_log(int, socketpair, -1);
-unsupported_function_crash(sigsuspend);
-unsupported_function_log(int, sigpending, -1);
-unsupported_function_log(int, shutdown, -1);
-unsupported_function_log(int, setuid, -1);
-unsupported_function_log(int, setgid, -1);
-unsupported_function_crash(rewinddir);
-unsupported_function_log(int, getpriority, -1);
-unsupported_function_log(int, setpriority, -1);
-unsupported_function_log(int, mkfifo, -1);
-unsupported_function_log(int, getitimer, -1);
-unsupported_function_log(int, setitimer, -1);
-unsupported_function_log(void *, getservbyport, NULL);
-unsupported_function_log(void *, getservbyname, NULL);
-unsupported_function_log(void *, getpwuid, NULL);
-unsupported_function_log(void *, getpwnam, NULL);
-unsupported_function_log(void *, getprotobynumber, NULL);
-unsupported_function_log(void *, getprotobyname, NULL);
-unsupported_function_log(int, getpeername, -1);
-unsupported_function_log(int, getnameinfo, -1);
-unsupported_function_log(char *, getlogin, NULL);
-unsupported_function_crash(__h_errno_location);
-unsupported_function_log(int, gethostbyname_r, -1);
-unsupported_function_log(int, gethostbyaddr_r, -1);
-unsupported_function_log(int, getgroups, -1);
-unsupported_function_log(void *, getgrgid, NULL);
-unsupported_function_log(void *, getgrnam, NULL);
-unsupported_function_log(int, getaddrinfo, -1);
-unsupported_function_log(int, freeaddrinfo, -1);
-unsupported_function_log(int, ftruncate64, -1);
-unsupported_function_log(int, fchown, -1);
-unsupported_function_log(int, fchmod, -1);
-unsupported_function_crash(execvp);
-unsupported_function_log(int, dup, -1)
-unsupported_function_log(int, chroot, -1)
-unsupported_function_log(int, chown, -1);
-unsupported_function_log(int, chmod, -1);
-unsupported_function_crash(alarm);
-unsupported_function_log(int, inet_pton, -1);
-unsupported_function_log(int, access, -1);
-#endif
index a2a122098cce7d42647c328283af021787f83f27..ca34711e85be36b5d40e19f307926a6f5035756c 100644 (file)
--- a/lib/xs.c
+++ b/lib/xs.c
@@ -6,184 +6,3 @@
  * Mere wrapper around xenbus_*
  */
 
-#ifdef HAVE_LIBC
-#include <os.h>
-#include <lib.h>
-#include <xenstore.h>
-#include <xenbus.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-static inline int _xs_fileno(struct xs_handle *h) {
-    return (intptr_t) h;
-}
-
-struct xs_handle *xs_daemon_open()
-{
-    int fd = alloc_fd(FTYPE_XENBUS);
-    files[fd].xenbus.events = NULL;
-    printk("xs_daemon_open -> %d, %p\n", fd, &files[fd].xenbus.events);
-    return (void*)(intptr_t) fd;
-}
-
-void xs_daemon_close(struct xs_handle *h)
-{
-    int fd = _xs_fileno(h);
-    struct xenbus_event *event;
-    for (event = files[fd].xenbus.events; event; event = event->next)
-        free(event);
-    files[fd].type = FTYPE_NONE;
-}
-
-int xs_fileno(struct xs_handle *h)
-{
-    return _xs_fileno(h);
-}
-
-void *xs_read(struct xs_handle *h, xs_transaction_t t,
-            const char *path, unsigned int *len)
-{
-    char *value;
-    char *msg;
-
-    msg = xenbus_read(t, path, &value);
-    if (msg) {
-       printk("xs_read(%s): %s\n", path, msg);
-       free(msg);
-       return NULL;
-    }
-
-    if (len)
-       *len = strlen(value);
-    return value;
-}
-
-bool xs_write(struct xs_handle *h, xs_transaction_t t,
-             const char *path, const void *data, unsigned int len)
-{
-    char value[len + 1];
-    char *msg;
-
-    memcpy(value, data, len);
-    value[len] = 0;
-
-    msg = xenbus_write(t, path, value);
-    if (msg) {
-       printk("xs_write(%s): %s\n", path, msg);
-       free(msg);
-       return false;
-    }
-    return true;
-}
-
-static bool xs_bool(char *reply)
-{
-    if (!reply)
-       return true;
-    free(reply);
-    return false;
-}
-
-bool xs_rm(struct xs_handle *h, xs_transaction_t t, const char *path)
-{
-    return xs_bool(xenbus_rm(t, path));
-}
-
-static void *xs_talkv(struct xs_handle *h, xs_transaction_t t,
-               enum xsd_sockmsg_type type,
-               struct write_req *iovec,
-               unsigned int num_vecs,
-               unsigned int *len)
-{
-    struct xsd_sockmsg *msg;
-    void *ret;
-
-    msg = xenbus_msg_reply(type, t, iovec, num_vecs);
-    ret = malloc(msg->len);
-    memcpy(ret, (char*) msg + sizeof(*msg), msg->len);
-    if (len)
-       *len = msg->len - 1;
-    free(msg);
-    return ret;
-}
-
-static void *xs_single(struct xs_handle *h, xs_transaction_t t,
-               enum xsd_sockmsg_type type,
-               const char *string,
-               unsigned int *len)
-{
-    struct write_req iovec;
-
-    iovec.data = (void *)string;
-    iovec.len = strlen(string) + 1;
-
-    return xs_talkv(h, t, type, &iovec, 1, len);
-}
-
-char *xs_get_domain_path(struct xs_handle *h, unsigned int domid)
-{
-    char domid_str[MAX_STRLEN(domid)];
-
-    sprintf(domid_str, "%u", domid);
-
-    return xs_single(h, XBT_NULL, XS_GET_DOMAIN_PATH, domid_str, NULL);
-}
-
-char **xs_directory(struct xs_handle *h, xs_transaction_t t,
-                   const char *path, unsigned int *num)
-{
-    char *msg;
-    char **entries, **res;
-    char *entry;
-    int i, n;
-    int size;
-
-    msg = xenbus_ls(t, path, &res);
-    if (msg) {
-       printk("xs_directory(%s): %s\n", path, msg);
-       return NULL;
-    }
-
-    size = 0;
-    for (n = 0; res[n]; n++)
-       size += strlen(res[n]) + 1;
-
-    entries = malloc(n * sizeof(char *) + size);
-    entry = (char *) (&entries[n]);
-
-    for (i = 0; i < n; i++) {
-       int l = strlen(res[i]) + 1;
-       memcpy(entry, res[i], l);
-       free(res[i]);
-       entries[i] = entry;
-       entry += l;
-    }
-
-    *num = n;
-    return entries;
-}
-
-bool xs_watch(struct xs_handle *h, const char *path, const char *token)
-{
-    int fd = _xs_fileno(h);
-    printk("xs_watch(%s, %s)\n", path, token);
-    return xs_bool(xenbus_watch_path_token(XBT_NULL, path, token, &files[fd].xenbus.events));
-}
-
-char **xs_read_watch(struct xs_handle *h, unsigned int *num)
-{
-    int fd = _xs_fileno(h);
-    struct xenbus_event *event;
-    event = files[fd].xenbus.events;
-    files[fd].xenbus.events = event->next;
-    printk("xs_read_watch() -> %s %s\n", event->path, event->token);
-    *num = 2;
-    return (char **) &event->path;
-}
-
-bool xs_unwatch(struct xs_handle *h, const char *path, const char *token)
-{
-    printk("xs_unwatch(%s, %s)\n", path, token);
-    return xs_bool(xenbus_unwatch_path_token(XBT_NULL, path, token));
-}
-#endif
diff --git a/lock.c b/lock.c
index 71a4971015eb27f6b3fdf09d8fb32b1e9c8b7b84..512a50008ba87285774fdc138e307a9225b8c435 100644 (file)
--- a/lock.c
+++ b/lock.c
@@ -4,108 +4,3 @@
  * Samuel Thibault <Samuel.Thibault@eu.citrix.net>, July 20008
  */
 
-#ifdef HAVE_LIBC
-
-#include <sys/lock.h>
-#include <sched.h>
-#include <wait.h>
-
-int ___lock_init(_LOCK_T *lock)
-{
-    lock->busy = 0;
-    init_waitqueue_head(&lock->wait);
-    return 0;
-}
-
-int ___lock_acquire(_LOCK_T *lock)
-{
-    unsigned long flags;
-    while(1) {
-        wait_event(lock->wait, !lock->busy);
-        local_irq_save(flags);
-        if (!lock->busy)
-            break;
-        local_irq_restore(flags);
-    }
-    lock->busy = 1;
-    local_irq_restore(flags);
-    return 0;
-}
-
-int ___lock_try_acquire(_LOCK_T *lock)
-{
-    unsigned long flags;
-    int ret = -1;
-    local_irq_save(flags);
-    if (!lock->busy) {
-        lock->busy = 1;
-        ret = 0;
-    }
-    local_irq_restore(flags);
-    return ret;
-}
-
-int ___lock_release(_LOCK_T *lock)
-{
-    unsigned long flags;
-    local_irq_save(flags);
-    lock->busy = 0;
-    wake_up(&lock->wait);
-    local_irq_restore(flags);
-    return 0;
-}
-
-
-int ___lock_init_recursive(_LOCK_RECURSIVE_T *lock)
-{
-    lock->owner = NULL;
-    init_waitqueue_head(&lock->wait);
-    return 0;
-}
-
-int ___lock_acquire_recursive(_LOCK_RECURSIVE_T *lock)
-{
-    unsigned long flags;
-    if (lock->owner != get_current()) {
-        while (1) {
-            wait_event(lock->wait, lock->owner == NULL);
-            local_irq_save(flags);
-            if (lock->owner == NULL)
-                break;
-            local_irq_restore(flags);
-        }
-        lock->owner = get_current();
-        local_irq_restore(flags);
-    }
-    lock->count++;
-    return 0;
-}
-
-int ___lock_try_acquire_recursive(_LOCK_RECURSIVE_T *lock)
-{
-    unsigned long flags;
-    int ret = -1;
-    local_irq_save(flags);
-    if (!lock->owner) {
-        ret = 0;
-        lock->owner = get_current();
-        lock->count++;
-    }
-    local_irq_restore(flags);
-    return ret;
-}
-
-int ___lock_release_recursive(_LOCK_RECURSIVE_T *lock)
-{
-    unsigned long flags;
-    BUG_ON(lock->owner != get_current());
-    if (--lock->count)
-        return 0;
-    local_irq_save(flags);
-    lock->owner = NULL;
-    wake_up(&lock->wait);
-    local_irq_restore(flags);
-    return 0;
-}
-
-#endif
diff --git a/main.c b/main.c
index 73eb6fb234476d4d6a5eed4c55944ccfbe529375..244a15eb7b3b1242a6385ae9b32a335597528eec 100644 (file)
--- a/main.c
+++ b/main.c
@@ -4,189 +4,3 @@
  * Samuel Thibault <Samuel.Thibault@eu.citrix.net>, October 2007
  */
 
-#ifdef HAVE_LIBC
-#include <os.h>
-#include <sched.h>
-#include <console.h>
-#include <netfront.h>
-#include <pcifront.h>
-#include <time.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <xenbus.h>
-#include <events.h>
-
-extern int main(int argc, char *argv[], char *envp[]);
-extern void __libc_init_array(void);
-extern void __libc_fini_array(void);
-extern unsigned long __CTOR_LIST__[];
-extern unsigned long __DTOR_LIST__[];
-
-#if 0
-#include <stdio.h>
-int main(int argc, char *argv[], char *envp[])
-{
-    printf("Hello, World!\n");
-    return 1;
-}
-#endif
-
-void _init(void)
-{
-}
-
-void _fini(void)
-{
-}
-
-extern char __app_bss_start, __app_bss_end;
-static void call_main(void *p)
-{
-    char *c, quote;
-#ifdef CONFIG_QEMU_XS_ARGS
-    char *domargs, *msg;
-#endif
-    int argc;
-    char **argv;
-    char *envp[] = { NULL };
-#ifdef CONFIG_QEMU_XS_ARGS
-    char *vm;
-    char path[128];
-    int domid;
-#endif
-    int i;
-
-    /* Let other parts initialize (including console output) before maybe
-     * crashing. */
-    //sleep(1);
-
-#ifdef CONFIG_SPARSE_BSS
-    sparse((unsigned long) &__app_bss_start, &__app_bss_end - &__app_bss_start);
-#endif
-#if defined(HAVE_LWIP) && defined(CONFIG_START_NETWORK) && defined(CONFIG_NETFRONT)
-    start_networking();
-#endif
-#ifdef CONFIG_PCIFRONT
-    create_thread("pcifront", pcifront_watches, NULL);
-#endif
-
-#ifdef CONFIG_QEMU_XS_ARGS
-    /* Fetch argc, argv from XenStore */
-    domid = xenbus_read_integer("target");
-    if (domid == -1) {
-        printk("Couldn't read target\n");
-        do_exit();
-    }
-
-    snprintf(path, sizeof(path), "/local/domain/%d/vm", domid);
-    msg = xenbus_read(XBT_NIL, path, &vm);
-    if (msg) {
-        printk("Couldn't read vm path\n");
-        do_exit();
-    }
-    printk("dom vm is at %s\n", vm);
-
-    snprintf(path, sizeof(path), "%s/image/dmargs", vm);
-    free(vm);
-    msg = xenbus_read(XBT_NIL, path, &domargs);
-
-    if (msg) {
-        printk("Couldn't get stubdom args: %s\n", msg);
-        domargs = strdup("");
-    }
-#endif
-
-    argc = 1;
-
-#define PARSE_ARGS(ARGS,START,QUOTE,END) \
-    c = ARGS; \
-    quote = 0; \
-    while (*c) { \
-       if (*c != ' ') { \
-           START; \
-           while (*c) { \
-               if (quote) { \
-                   if (*c == quote) { \
-                       quote = 0; \
-                       QUOTE; \
-                       continue; \
-                   } \
-               } else if (*c == ' ') \
-                   break; \
-               if (*c == '"' || *c == '\'') { \
-                   quote = *c; \
-                   QUOTE; \
-                   continue; \
-               } \
-               c++; \
-           } \
-       } else { \
-            END; \
-           while (*c == ' ') \
-               c++; \
-       } \
-    } \
-    if (quote) {\
-       printk("Warning: unterminated quotation %c\n", quote); \
-       quote = 0; \
-    }
-#define PARSE_ARGS_COUNT(ARGS) PARSE_ARGS(ARGS, argc++, c++, )
-#define PARSE_ARGS_STORE(ARGS) PARSE_ARGS(ARGS, argv[argc++] = c, memmove(c, c + 1, strlen(c + 1) + 1), *c++ = 0)
-
-    PARSE_ARGS_COUNT((char*)start_info.cmd_line);
-#ifdef CONFIG_QEMU_XS_ARGS
-    PARSE_ARGS_COUNT(domargs);
-#endif
-
-    argv = alloca((argc + 1) * sizeof(char *));
-    argv[0] = "main";
-    argc = 1;
-
-    PARSE_ARGS_STORE((char*)start_info.cmd_line)
-#ifdef CONFIG_QEMU_XS_ARGS
-    PARSE_ARGS_STORE(domargs)
-#endif
-
-    argv[argc] = NULL;
-
-    for (i = 0; i < argc; i++)
-       printf("\"%s\" ", argv[i]);
-    printf("\n");
-
-    __libc_init_array();
-    environ = envp;
-    for (i = 0; __CTOR_LIST__[i] != 0; i++)
-        ((void((*)(void)))__CTOR_LIST__[i]) ();
-    tzset();
-
-    exit(main(argc, argv, envp));
-}
-
-void _exit(int ret)
-{
-    int i;
-
-    for (i = 0; __DTOR_LIST__[i] != 0; i++)
-        ((void((*)(void)))__DTOR_LIST__[i]) ();
-    close_all_files();
-    __libc_fini_array();
-    printk("main returned %d\n", ret);
-#if defined(HAVE_LWIP) && defined(CONFIG_NETFRONT)
-    stop_networking();
-#endif
-    stop_kernel();
-    if (!ret) {
-       /* No problem, just shutdown.  */
-        struct sched_shutdown sched_shutdown = { .reason = SHUTDOWN_poweroff };
-        HYPERVISOR_sched_op(SCHEDOP_shutdown, &sched_shutdown);
-    }
-    do_exit();
-}
-
-int app_main(start_info_t *si)
-{
-    printk("Dummy main: start_info=%p\n", si);
-    main_thread = create_thread("main", call_main, si);
-    return 0;
-}
-#endif
diff --git a/mm.c b/mm.c
index 743d45d051343b0b55e066e4ff490194a60810fe..bde4c3f119e90a82e6a8490af418d61f0f471694 100644 (file)
--- a/mm.c
+++ b/mm.c
@@ -374,28 +374,6 @@ int free_physical_pages(xen_pfn_t *mfns, int n)
 }
 #endif
 
-#ifdef HAVE_LIBC
-void *sbrk(ptrdiff_t increment)
-{
-    unsigned long old_brk = brk;
-    unsigned long new_brk = old_brk + increment;
-
-    if (new_brk > heap_end) {
-       printk("Heap exhausted: %p + %lx = %p > %p\n", old_brk, increment, new_brk, heap_end);
-       return NULL;
-    }
-    
-    if (new_brk > heap_mapped) {
-        unsigned long n = (new_brk - heap_mapped + PAGE_SIZE - 1) / PAGE_SIZE;
-        do_map_zero(heap_mapped, n);
-        heap_mapped += n * PAGE_SIZE;
-    }
-
-    brk = new_brk;
-
-    return (void *) old_brk;
-}
-#endif
 
 
 
index 0b136cbdf3a589b8335135171f7fe284aad26992..29e6621c54c7d7fbf0334e27efd1715a4d949999 100644 (file)
@@ -19,9 +19,6 @@
 
 DECLARE_WAIT_QUEUE_HEAD(netfront_queue);
 
-#ifdef HAVE_LIBC
-#define NETIF_SELECT_RX ((void*)-1)
-#endif
 
 
 
@@ -56,12 +53,6 @@ struct netfront_dev {
 
     xenbus_event_queue events;
 
-#ifdef HAVE_LIBC
-    int fd;
-    unsigned char *data;
-    size_t len;
-    size_t rlen;
-#endif
 
     void (*netif_rx)(struct netfront_dev *, unsigned char* data, int len);
     void *netfront_priv;
@@ -129,17 +120,6 @@ moretodo:
 
         if(rx->status>0)
         {
-#ifdef HAVE_LIBC
-           if (dev->netif_rx == NETIF_SELECT_RX) {
-               int len = rx->status;
-               ASSERT(current == main_thread);
-               if (len > dev->len)
-                   len = dev->len;
-               memcpy(dev->data, page+rx->offset, len);
-               dev->rlen = len;
-               some = 1;
-           } else
-#endif
                dev->netif_rx(dev, page+rx->offset,rx->status);
         }
     }
@@ -238,22 +218,6 @@ void netfront_handler(evtchn_port_t port, struct pt_regs *regs, void *data)
     local_irq_restore(flags);
 }
 
-#ifdef HAVE_LIBC
-void netfront_select_handler(evtchn_port_t port, struct pt_regs *regs, void *data)
-{
-    int flags;
-    struct netfront_dev *dev = data;
-    int fd = dev->fd;
-
-    local_irq_save(flags);
-    network_tx_buf_gc(dev);
-    local_irq_restore(flags);
-
-    if (fd != -1)
-        files[fd].read = 1;
-    wake_up(&netfront_queue);
-}
-#endif
 
 static void free_netfront(struct netfront_dev *dev)
 {
@@ -315,9 +279,6 @@ struct netfront_dev *init_netfront(char *_nodename, void (*thenetif_rx)(struct n
     memset(dev, 0, sizeof(*dev));
     dev->nodename = strdup(nodename);
     dev->netfront_priv = priv;
-#ifdef HAVE_LIBC
-    dev->fd = -1;
-#endif
 
     printk("net TX ring size %d\n", NET_TX_RING_SIZE);
     printk("net RX ring size %d\n", NET_RX_RING_SIZE);
@@ -336,11 +297,6 @@ struct netfront_dev *init_netfront(char *_nodename, void (*thenetif_rx)(struct n
 
     snprintf(path, sizeof(path), "%s/backend-id", nodename);
     dev->dom = xenbus_read_integer(path);
-#ifdef HAVE_LIBC
-    if (thenetif_rx == NETIF_SELECT_RX)
-        evtchn_alloc_unbound(dev->dom, netfront_select_handler, dev, &dev->evtchn);
-    else
-#endif
         evtchn_alloc_unbound(dev->dom, netfront_handler, dev, &dev->evtchn);
 
     txs = (struct netif_tx_sring *) alloc_page();
@@ -485,22 +441,6 @@ error:
     return NULL;
 }
 
-#ifdef HAVE_LIBC
-int netfront_tap_open(char *nodename) {
-    struct netfront_dev *dev;
-
-    dev = init_netfront(nodename, NETIF_SELECT_RX, NULL, NULL);
-    if (!dev) {
-       printk("TAP open failed\n");
-       errno = EIO;
-       return -1;
-    }
-    dev->fd = alloc_fd(FTYPE_TAP);
-    printk("tap_open(%s) -> %d\n", nodename, dev->fd);
-    files[dev->fd].tap.dev = dev;
-    return dev->fd;
-}
-#endif
 
 void shutdown_netfront(struct netfront_dev *dev)
 {
@@ -650,29 +590,3 @@ netfront_get_private(struct netfront_dev *dev)
        return dev->netfront_priv;
 }
 
-#ifdef HAVE_LIBC
-ssize_t netfront_receive(struct netfront_dev *dev, unsigned char *data, size_t len)
-{
-    unsigned long flags;
-    int fd = dev->fd;
-    ASSERT(current == main_thread);
-
-    dev->rlen = 0;
-    dev->data = data;
-    dev->len = len;
-
-    local_irq_save(flags);
-    network_rx(dev);
-    if (!dev->rlen && fd != -1)
-       /* No data for us, make select stop returning */
-       files[fd].read = 0;
-    /* Before re-enabling the interrupts, in case a packet just arrived in the
-     * meanwhile. */
-    local_irq_restore(flags);
-
-    dev->data = NULL;
-    dev->len = 0;
-
-    return dev->rlen;
-}
-#endif
diff --git a/sched.c b/sched.c
index 5511e7ff14adc5f849859a2b3ea76b5afca92c3e..d08f365df4cde10856b18eac1ab58ac50f440a0e 100644 (file)
--- a/sched.c
+++ b/sched.c
@@ -149,9 +149,6 @@ create_thread(const char *name, void (*function)(void *), void *data)
     thread->flags = 0;
     thread->wakeup_time = 0LL;
     thread->lwp = NULL;
-#ifdef HAVE_LIBC
-    _REENT_INIT_PTR((&thread->reent))
-#endif
     set_runnable(thread);
     local_irq_save(flags);
     MINIOS_TAILQ_INSERT_TAIL(&thread_list, thread, thread_list);
@@ -159,41 +156,6 @@ create_thread(const char *name, void (*function)(void *), void *data)
     return thread;
 }
 
-#ifdef HAVE_LIBC
-static struct _reent callback_reent;
-struct _reent *__getreent(void)
-{
-    struct _reent *_reent;
-
-    if (!threads_started)
-       _reent = _impure_ptr;
-    else if (in_callback)
-       _reent = &callback_reent;
-    else
-       _reent = &get_current()->reent;
-
-#ifndef NDEBUG
-#if defined(__x86_64__) || defined(__x86__)
-    {
-#ifdef __x86_64__
-       register unsigned long sp asm ("rsp");
-#else
-       register unsigned long sp asm ("esp");
-#endif
-       if ((sp & (STACK_SIZE-1)) < STACK_SIZE / 16) {
-           static int overflowing;
-           if (!overflowing) {
-               overflowing = 1;
-               printk("stack overflow\n");
-               BUG();
-           }
-       }
-    }
-#endif
-#endif
-    return _reent;
-}
-#endif
 
 void exit_thread(void)
 {
@@ -286,9 +248,6 @@ void init_sched(void)
 {
     printk("Initialising scheduler\n");
 
-#ifdef HAVE_LIBC
-    _REENT_INIT_PTR((&callback_reent))
-#endif
     idle_thread = create_thread("Idle", idle_thread_fn, NULL);
 }