Revision 9adea5f7

b/include/qemu-common.h
84 84
# error Unknown pointer size
85 85
#endif
86 86

  
87
#ifndef CONFIG_IOVEC
88
#define CONFIG_IOVEC
89
struct iovec {
90
    void *iov_base;
91
    size_t iov_len;
92
};
93
/*
94
 * Use the same value as Linux for now.
95
 */
96
#define IOV_MAX		1024
97
#else
98
#include <sys/uio.h>
99
#endif
100

  
101 87
typedef int (*fprintf_function)(FILE *f, const char *fmt, ...)
102 88
    GCC_FMT_ATTR(2, 3);
103 89

  
......
122 108
void configure_icount(const char *option);
123 109
extern int use_icount;
124 110

  
125
/* FIXME: Remove NEED_CPU_H.  */
126
#ifndef NEED_CPU_H
127

  
128 111
#include "qemu/osdep.h"
129 112
#include "qemu/bswap.h"
130 113

  
131
#else
132

  
114
/* FIXME: Remove NEED_CPU_H.  */
115
#ifdef NEED_CPU_H
133 116
#include "cpu.h"
134

  
135 117
#endif /* !defined(NEED_CPU_H) */
136 118

  
137 119
/* main function, renamed */
b/include/qemu/osdep.h
1 1
#ifndef QEMU_OSDEP_H
2 2
#define QEMU_OSDEP_H
3 3

  
4
#include "config-host.h"
4 5
#include <stdarg.h>
5 6
#include <stddef.h>
6 7
#include <stdbool.h>
......
161 162
int qemu_create_pidfile(const char *filename);
162 163
int qemu_get_thread_id(void);
163 164

  
165
#ifndef CONFIG_IOVEC
166
struct iovec {
167
    void *iov_base;
168
    size_t iov_len;
169
};
170
/*
171
 * Use the same value as Linux for now.
172
 */
173
#define IOV_MAX 1024
174

  
175
ssize_t readv(int fd, const struct iovec *iov, int iov_cnt);
176
ssize_t writev(int fd, const struct iovec *iov, int iov_cnt);
177
#else
178
#include <sys/uio.h>
179
#endif
180

  
164 181
#ifdef _WIN32
165 182
static inline void qemu_timersub(const struct timeval *val1,
166 183
                                 const struct timeval *val2,
b/util/iov.c
99 99
static ssize_t
100 100
do_send_recv(int sockfd, struct iovec *iov, unsigned iov_cnt, bool do_send)
101 101
{
102
#if defined CONFIG_IOVEC && defined CONFIG_POSIX
102
#ifdef CONFIG_POSIX
103 103
    ssize_t ret;
104 104
    struct msghdr msg;
105 105
    memset(&msg, 0, sizeof(msg));
b/util/osdep.c
429 429
#endif
430 430
    return 0;
431 431
}
432

  
433
#ifndef CONFIG_IOVEC
434
/* helper function for iov_send_recv() */
435
static ssize_t
436
readv_writev(int fd, const struct iovec *iov, int iov_cnt, bool do_write)
437
{
438
    unsigned i = 0;
439
    ssize_t ret = 0;
440
    while (i < iov_cnt) {
441
        ssize_t r = do_write
442
            ? write(fd, iov[i].iov_base, iov[i].iov_len)
443
            : read(fd, iov[i].iov_base, iov[i].iov_len);
444
        if (r > 0) {
445
            ret += r;
446
        } else if (!r) {
447
            break;
448
        } else if (errno == EINTR) {
449
            continue;
450
        } else {
451
            /* else it is some "other" error,
452
             * only return if there was no data processed. */
453
            if (ret == 0) {
454
                ret = -1;
455
            }
456
            break;
457
        }
458
        i++;
459
    }
460
    return ret;
461
}
462

  
463
ssize_t
464
readv(int fd, const struct iovec *iov, int iov_cnt)
465
{
466
    return readv_writev(fd, iov, iov_cnt, false);
467
}
468

  
469
ssize_t
470
writev(int fd, const struct iovec *iov, int iov_cnt)
471
{
472
    return readv_writev(fd, iov, iov_cnt, true);
473
}
474
#endif

Also available in: Unified diff