Revision 19113504 vl.c

b/vl.c
1497 1497
    return qemu_set_fd_handler2(fd, NULL, fd_read, fd_write, opaque);
1498 1498
}
1499 1499

  
1500
#ifdef _WIN32
1501
/***********************************************************/
1502
/* Polling handling */
1503

  
1504
typedef struct PollingEntry {
1505
    PollingFunc *func;
1506
    void *opaque;
1507
    struct PollingEntry *next;
1508
} PollingEntry;
1509

  
1510
static PollingEntry *first_polling_entry;
1511

  
1512
int qemu_add_polling_cb(PollingFunc *func, void *opaque)
1513
{
1514
    PollingEntry **ppe, *pe;
1515
    pe = qemu_mallocz(sizeof(PollingEntry));
1516
    pe->func = func;
1517
    pe->opaque = opaque;
1518
    for(ppe = &first_polling_entry; *ppe != NULL; ppe = &(*ppe)->next);
1519
    *ppe = pe;
1520
    return 0;
1521
}
1522

  
1523
void qemu_del_polling_cb(PollingFunc *func, void *opaque)
1524
{
1525
    PollingEntry **ppe, *pe;
1526
    for(ppe = &first_polling_entry; *ppe != NULL; ppe = &(*ppe)->next) {
1527
        pe = *ppe;
1528
        if (pe->func == func && pe->opaque == opaque) {
1529
            *ppe = pe->next;
1530
            qemu_free(pe);
1531
            break;
1532
        }
1533
    }
1534
}
1535

  
1536
/***********************************************************/
1537
/* Wait objects support */
1538
typedef struct WaitObjects {
1539
    int num;
1540
    HANDLE events[MAXIMUM_WAIT_OBJECTS + 1];
1541
    WaitObjectFunc *func[MAXIMUM_WAIT_OBJECTS + 1];
1542
    void *opaque[MAXIMUM_WAIT_OBJECTS + 1];
1543
} WaitObjects;
1544

  
1545
static WaitObjects wait_objects = {0};
1546

  
1547
int qemu_add_wait_object(HANDLE handle, WaitObjectFunc *func, void *opaque)
1548
{
1549
    WaitObjects *w = &wait_objects;
1550

  
1551
    if (w->num >= MAXIMUM_WAIT_OBJECTS)
1552
        return -1;
1553
    w->events[w->num] = handle;
1554
    w->func[w->num] = func;
1555
    w->opaque[w->num] = opaque;
1556
    w->num++;
1557
    return 0;
1558
}
1559

  
1560
void qemu_del_wait_object(HANDLE handle, WaitObjectFunc *func, void *opaque)
1561
{
1562
    int i, found;
1563
    WaitObjects *w = &wait_objects;
1564

  
1565
    found = 0;
1566
    for (i = 0; i < w->num; i++) {
1567
        if (w->events[i] == handle)
1568
            found = 1;
1569
        if (found) {
1570
            w->events[i] = w->events[i + 1];
1571
            w->func[i] = w->func[i + 1];
1572
            w->opaque[i] = w->opaque[i + 1];
1573
        }
1574
    }
1575
    if (found)
1576
        w->num--;
1577
}
1578
#endif
1579

  
1580 1500
/***********************************************************/
1581 1501
/* machine registration */
1582 1502

  

Also available in: Unified diff