1
0
mirror of https://github.com/simh/simh.git synced 2026-04-26 03:57:11 +00:00

slirp_glue: Set line endings to CRLF for consistency with other simh source

This commit is contained in:
Mark Pizzolato
2023-02-27 10:45:11 -10:00
parent 5483ffbbbd
commit 0429c25ae7
9 changed files with 827 additions and 827 deletions

View File

@@ -1,43 +1,43 @@
/* /*
* QEMU System Emulator * QEMU System Emulator
* *
* Copyright (c) 2003-2008 Fabrice Bellard * Copyright (c) 2003-2008 Fabrice Bellard
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights * in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is * copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions: * furnished to do so, subject to the following conditions:
* *
* The above copyright notice and this permission notice shall be included in * The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software. * all copies or substantial portions of the Software.
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE. * THE SOFTWARE.
*/ */
#ifndef QEMU_MAIN_LOOP_H #ifndef QEMU_MAIN_LOOP_H
#define QEMU_MAIN_LOOP_H 1 #define QEMU_MAIN_LOOP_H 1
/** /**
* qemu_notify_event: Force processing of pending events. * qemu_notify_event: Force processing of pending events.
* *
* Similar to signaling a condition variable, qemu_notify_event forces * Similar to signaling a condition variable, qemu_notify_event forces
* main_loop_wait to look at pending events and exit. The caller of * main_loop_wait to look at pending events and exit. The caller of
* main_loop_wait will usually call it again very soon, so qemu_notify_event * main_loop_wait will usually call it again very soon, so qemu_notify_event
* also has the side effect of recalculating the sets of file descriptors * also has the side effect of recalculating the sets of file descriptors
* that the main loop waits for. * that the main loop waits for.
* *
* Calling qemu_notify_event is rarely necessary, because main loop * Calling qemu_notify_event is rarely necessary, because main loop
* services (bottom halves and timers) call it themselves. * services (bottom halves and timers) call it themselves.
*/ */
void qemu_notify_event(void); void qemu_notify_event(void);
#endif #endif

View File

@@ -1,8 +1,8 @@
#ifndef MONITOR_H #ifndef MONITOR_H
#define MONITOR_H #define MONITOR_H
#include "qemu-common.h" #include "qemu-common.h"
void monitor_printf(Monitor *mon, const char *fmt, ...) GCC_FMT_ATTR(2, 3); void monitor_printf(Monitor *mon, const char *fmt, ...) GCC_FMT_ATTR(2, 3);
#endif /* !MONITOR_H */ #endif /* !MONITOR_H */

View File

@@ -1,54 +1,54 @@
/* Common header file that is included by all of QEMU. /* Common header file that is included by all of QEMU.
* *
* This file is supposed to be included only by .c files. No header file should * This file is supposed to be included only by .c files. No header file should
* depend on qemu-common.h, as this would easily lead to circular header * depend on qemu-common.h, as this would easily lead to circular header
* dependencies. * dependencies.
* *
* If a header file uses a definition from qemu-common.h, that definition * If a header file uses a definition from qemu-common.h, that definition
* must be moved to a separate header file, and the header that uses it * must be moved to a separate header file, and the header that uses it
* must include that header. * must include that header.
*/ */
#ifndef QEMU_COMMON_H #ifndef QEMU_COMMON_H
#define QEMU_COMMON_H #define QEMU_COMMON_H
#include "qemu/osdep.h" #include "qemu/osdep.h"
#include "qemu/typedefs.h" #include "qemu/typedefs.h"
#include "glib.h" #include "glib.h"
#include "config-host.h" #include "config-host.h"
#if defined(O_BINARY) /* O_BINARY isn't used in slirp */ #if defined(O_BINARY) /* O_BINARY isn't used in slirp */
#undef O_BINARY /* Avoid potential redefinition elsewhere */ #undef O_BINARY /* Avoid potential redefinition elsewhere */
#endif #endif
/* HOST_LONG_BITS is the size of a native pointer in bits. */ /* HOST_LONG_BITS is the size of a native pointer in bits. */
#if UINTPTR_MAX == UINT32_MAX #if UINTPTR_MAX == UINT32_MAX
# define HOST_LONG_BITS 32 # define HOST_LONG_BITS 32
#elif UINTPTR_MAX == UINT64_MAX #elif UINTPTR_MAX == UINT64_MAX
# define HOST_LONG_BITS 64 # define HOST_LONG_BITS 64
#else #else
# error Unknown pointer size # error Unknown pointer size
#endif #endif
/* util/cutils.c */ /* util/cutils.c */
/** /**
* pstrcpy: * pstrcpy:
* @buf: buffer to copy string into * @buf: buffer to copy string into
* @buf_size: size of @buf in bytes * @buf_size: size of @buf in bytes
* @str: string to copy * @str: string to copy
* *
* Copy @str into @buf, including the trailing NUL, but do not * Copy @str into @buf, including the trailing NUL, but do not
* write more than @buf_size bytes. The resulting buffer is * write more than @buf_size bytes. The resulting buffer is
* always NUL terminated (even if the source string was too long). * always NUL terminated (even if the source string was too long).
* If @buf_size is zero or negative then no bytes are copied. * If @buf_size is zero or negative then no bytes are copied.
* *
* This function is similar to strncpy(), but avoids two of that * This function is similar to strncpy(), but avoids two of that
* function's problems: * function's problems:
* * if @str fits in the buffer, pstrcpy() does not zero-fill the * * if @str fits in the buffer, pstrcpy() does not zero-fill the
* remaining space at the end of @buf * remaining space at the end of @buf
* * if @str is too long, pstrcpy() will copy the first @buf_size-1 * * if @str is too long, pstrcpy() will copy the first @buf_size-1
* bytes and then add a NUL * bytes and then add a NUL
*/ */
void pstrcpy(char *buf, int buf_size, const char *str); void pstrcpy(char *buf, int buf_size, const char *str);
#endif #endif

View File

@@ -1,431 +1,431 @@
/* $NetBSD: queue.h,v 1.52 2009/04/20 09:56:08 mschuett Exp $ */ /* $NetBSD: queue.h,v 1.52 2009/04/20 09:56:08 mschuett Exp $ */
/* /*
* QEMU version: Copy from netbsd, removed debug code, removed some of * QEMU version: Copy from netbsd, removed debug code, removed some of
* the implementations. Left in singly-linked lists, lists, simple * the implementations. Left in singly-linked lists, lists, simple
* queues, and tail queues. * queues, and tail queues.
*/ */
/* /*
* Copyright (c) 1991, 1993 * Copyright (c) 1991, 1993
* The Regents of the University of California. All rights reserved. * The Regents of the University of California. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
* are met: * are met:
* 1. Redistributions of source code must retain the above copyright * 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer. * notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright * 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software * may be used to endorse or promote products derived from this software
* without specific prior written permission. * without specific prior written permission.
* *
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* @(#)queue.h 8.5 (Berkeley) 8/20/94 * @(#)queue.h 8.5 (Berkeley) 8/20/94
*/ */
#ifndef QEMU_SYS_QUEUE_H_ #ifndef QEMU_SYS_QUEUE_H_
#define QEMU_SYS_QUEUE_H_ #define QEMU_SYS_QUEUE_H_
/* /*
* This file defines four types of data structures: singly-linked lists, * This file defines four types of data structures: singly-linked lists,
* lists, simple queues, and tail queues. * lists, simple queues, and tail queues.
* *
* A singly-linked list is headed by a single forward pointer. The * A singly-linked list is headed by a single forward pointer. The
* elements are singly linked for minimum space and pointer manipulation * elements are singly linked for minimum space and pointer manipulation
* overhead at the expense of O(n) removal for arbitrary elements. New * overhead at the expense of O(n) removal for arbitrary elements. New
* elements can be added to the list after an existing element or at the * elements can be added to the list after an existing element or at the
* head of the list. Elements being removed from the head of the list * head of the list. Elements being removed from the head of the list
* should use the explicit macro for this purpose for optimum * should use the explicit macro for this purpose for optimum
* efficiency. A singly-linked list may only be traversed in the forward * efficiency. A singly-linked list may only be traversed in the forward
* direction. Singly-linked lists are ideal for applications with large * direction. Singly-linked lists are ideal for applications with large
* datasets and few or no removals or for implementing a LIFO queue. * datasets and few or no removals or for implementing a LIFO queue.
* *
* A list is headed by a single forward pointer (or an array of forward * A list is headed by a single forward pointer (or an array of forward
* pointers for a hash table header). The elements are doubly linked * pointers for a hash table header). The elements are doubly linked
* so that an arbitrary element can be removed without a need to * so that an arbitrary element can be removed without a need to
* traverse the list. New elements can be added to the list before * traverse the list. New elements can be added to the list before
* or after an existing element or at the head of the list. A list * or after an existing element or at the head of the list. A list
* may only be traversed in the forward direction. * may only be traversed in the forward direction.
* *
* A simple queue is headed by a pair of pointers, one the head of the * A simple queue is headed by a pair of pointers, one the head of the
* list and the other to the tail of the list. The elements are singly * list and the other to the tail of the list. The elements are singly
* linked to save space, so elements can only be removed from the * linked to save space, so elements can only be removed from the
* head of the list. New elements can be added to the list after * head of the list. New elements can be added to the list after
* an existing element, at the head of the list, or at the end of the * an existing element, at the head of the list, or at the end of the
* list. A simple queue may only be traversed in the forward direction. * list. A simple queue may only be traversed in the forward direction.
* *
* A tail queue is headed by a pair of pointers, one to the head of the * A tail queue is headed by a pair of pointers, one to the head of the
* list and the other to the tail of the list. The elements are doubly * list and the other to the tail of the list. The elements are doubly
* linked so that an arbitrary element can be removed without a need to * linked so that an arbitrary element can be removed without a need to
* traverse the list. New elements can be added to the list before or * traverse the list. New elements can be added to the list before or
* after an existing element, at the head of the list, or at the end of * after an existing element, at the head of the list, or at the end of
* the list. A tail queue may be traversed in either direction. * the list. A tail queue may be traversed in either direction.
* *
* For details on the use of these macros, see the queue(3) manual page. * For details on the use of these macros, see the queue(3) manual page.
*/ */
/* /*
* List definitions. * List definitions.
*/ */
#define QLIST_HEAD(name, type) \ #define QLIST_HEAD(name, type) \
struct name { \ struct name { \
struct type *lh_first; /* first element */ \ struct type *lh_first; /* first element */ \
} }
#define QLIST_HEAD_INITIALIZER(head) \ #define QLIST_HEAD_INITIALIZER(head) \
{ NULL } { NULL }
#define QLIST_ENTRY(type) \ #define QLIST_ENTRY(type) \
struct { \ struct { \
struct type *le_next; /* next element */ \ struct type *le_next; /* next element */ \
struct type **le_prev; /* address of previous next element */ \ struct type **le_prev; /* address of previous next element */ \
} }
/* /*
* List functions. * List functions.
*/ */
#define QLIST_INIT(head) do { \ #define QLIST_INIT(head) do { \
(head)->lh_first = NULL; \ (head)->lh_first = NULL; \
} while (/*CONSTCOND*/0) } while (/*CONSTCOND*/0)
#define QLIST_SWAP(dstlist, srclist, field) do { \ #define QLIST_SWAP(dstlist, srclist, field) do { \
void *tmplist; \ void *tmplist; \
tmplist = (srclist)->lh_first; \ tmplist = (srclist)->lh_first; \
(srclist)->lh_first = (dstlist)->lh_first; \ (srclist)->lh_first = (dstlist)->lh_first; \
if ((srclist)->lh_first != NULL) { \ if ((srclist)->lh_first != NULL) { \
(srclist)->lh_first->field.le_prev = &(srclist)->lh_first; \ (srclist)->lh_first->field.le_prev = &(srclist)->lh_first; \
} \ } \
(dstlist)->lh_first = tmplist; \ (dstlist)->lh_first = tmplist; \
if ((dstlist)->lh_first != NULL) { \ if ((dstlist)->lh_first != NULL) { \
(dstlist)->lh_first->field.le_prev = &(dstlist)->lh_first; \ (dstlist)->lh_first->field.le_prev = &(dstlist)->lh_first; \
} \ } \
} while (/*CONSTCOND*/0) } while (/*CONSTCOND*/0)
#define QLIST_FIX_HEAD_PTR(head, field) do { \ #define QLIST_FIX_HEAD_PTR(head, field) do { \
if ((head)->lh_first != NULL) { \ if ((head)->lh_first != NULL) { \
(head)->lh_first->field.le_prev = &(head)->lh_first; \ (head)->lh_first->field.le_prev = &(head)->lh_first; \
} \ } \
} while (/*CONSTCOND*/0) } while (/*CONSTCOND*/0)
#define QLIST_INSERT_AFTER(listelm, elm, field) do { \ #define QLIST_INSERT_AFTER(listelm, elm, field) do { \
if (((elm)->field.le_next = (listelm)->field.le_next) != NULL) \ if (((elm)->field.le_next = (listelm)->field.le_next) != NULL) \
(listelm)->field.le_next->field.le_prev = \ (listelm)->field.le_next->field.le_prev = \
&(elm)->field.le_next; \ &(elm)->field.le_next; \
(listelm)->field.le_next = (elm); \ (listelm)->field.le_next = (elm); \
(elm)->field.le_prev = &(listelm)->field.le_next; \ (elm)->field.le_prev = &(listelm)->field.le_next; \
} while (/*CONSTCOND*/0) } while (/*CONSTCOND*/0)
#define QLIST_INSERT_BEFORE(listelm, elm, field) do { \ #define QLIST_INSERT_BEFORE(listelm, elm, field) do { \
(elm)->field.le_prev = (listelm)->field.le_prev; \ (elm)->field.le_prev = (listelm)->field.le_prev; \
(elm)->field.le_next = (listelm); \ (elm)->field.le_next = (listelm); \
*(listelm)->field.le_prev = (elm); \ *(listelm)->field.le_prev = (elm); \
(listelm)->field.le_prev = &(elm)->field.le_next; \ (listelm)->field.le_prev = &(elm)->field.le_next; \
} while (/*CONSTCOND*/0) } while (/*CONSTCOND*/0)
#define QLIST_INSERT_HEAD(head, elm, field) do { \ #define QLIST_INSERT_HEAD(head, elm, field) do { \
if (((elm)->field.le_next = (head)->lh_first) != NULL) \ if (((elm)->field.le_next = (head)->lh_first) != NULL) \
(head)->lh_first->field.le_prev = &(elm)->field.le_next;\ (head)->lh_first->field.le_prev = &(elm)->field.le_next;\
(head)->lh_first = (elm); \ (head)->lh_first = (elm); \
(elm)->field.le_prev = &(head)->lh_first; \ (elm)->field.le_prev = &(head)->lh_first; \
} while (/*CONSTCOND*/0) } while (/*CONSTCOND*/0)
#define QLIST_REMOVE(elm, field) do { \ #define QLIST_REMOVE(elm, field) do { \
if ((elm)->field.le_next != NULL) \ if ((elm)->field.le_next != NULL) \
(elm)->field.le_next->field.le_prev = \ (elm)->field.le_next->field.le_prev = \
(elm)->field.le_prev; \ (elm)->field.le_prev; \
*(elm)->field.le_prev = (elm)->field.le_next; \ *(elm)->field.le_prev = (elm)->field.le_next; \
} while (/*CONSTCOND*/0) } while (/*CONSTCOND*/0)
#define QLIST_FOREACH(var, head, field) \ #define QLIST_FOREACH(var, head, field) \
for ((var) = ((head)->lh_first); \ for ((var) = ((head)->lh_first); \
(var); \ (var); \
(var) = ((var)->field.le_next)) (var) = ((var)->field.le_next))
#define QLIST_FOREACH_SAFE(var, head, field, next_var) \ #define QLIST_FOREACH_SAFE(var, head, field, next_var) \
for ((var) = ((head)->lh_first); \ for ((var) = ((head)->lh_first); \
(var) && ((next_var) = ((var)->field.le_next), 1); \ (var) && ((next_var) = ((var)->field.le_next), 1); \
(var) = (next_var)) (var) = (next_var))
/* /*
* List access methods. * List access methods.
*/ */
#define QLIST_EMPTY(head) ((head)->lh_first == NULL) #define QLIST_EMPTY(head) ((head)->lh_first == NULL)
#define QLIST_FIRST(head) ((head)->lh_first) #define QLIST_FIRST(head) ((head)->lh_first)
#define QLIST_NEXT(elm, field) ((elm)->field.le_next) #define QLIST_NEXT(elm, field) ((elm)->field.le_next)
/* /*
* Singly-linked List definitions. * Singly-linked List definitions.
*/ */
#define QSLIST_HEAD(name, type) \ #define QSLIST_HEAD(name, type) \
struct name { \ struct name { \
struct type *slh_first; /* first element */ \ struct type *slh_first; /* first element */ \
} }
#define QSLIST_HEAD_INITIALIZER(head) \ #define QSLIST_HEAD_INITIALIZER(head) \
{ NULL } { NULL }
#define QSLIST_ENTRY(type) \ #define QSLIST_ENTRY(type) \
struct { \ struct { \
struct type *sle_next; /* next element */ \ struct type *sle_next; /* next element */ \
} }
/* /*
* Singly-linked List functions. * Singly-linked List functions.
*/ */
#define QSLIST_INIT(head) do { \ #define QSLIST_INIT(head) do { \
(head)->slh_first = NULL; \ (head)->slh_first = NULL; \
} while (/*CONSTCOND*/0) } while (/*CONSTCOND*/0)
#define QSLIST_INSERT_AFTER(slistelm, elm, field) do { \ #define QSLIST_INSERT_AFTER(slistelm, elm, field) do { \
(elm)->field.sle_next = (slistelm)->field.sle_next; \ (elm)->field.sle_next = (slistelm)->field.sle_next; \
(slistelm)->field.sle_next = (elm); \ (slistelm)->field.sle_next = (elm); \
} while (/*CONSTCOND*/0) } while (/*CONSTCOND*/0)
#define QSLIST_INSERT_HEAD(head, elm, field) do { \ #define QSLIST_INSERT_HEAD(head, elm, field) do { \
(elm)->field.sle_next = (head)->slh_first; \ (elm)->field.sle_next = (head)->slh_first; \
(head)->slh_first = (elm); \ (head)->slh_first = (elm); \
} while (/*CONSTCOND*/0) } while (/*CONSTCOND*/0)
#define QSLIST_REMOVE_HEAD(head, field) do { \ #define QSLIST_REMOVE_HEAD(head, field) do { \
(head)->slh_first = (head)->slh_first->field.sle_next; \ (head)->slh_first = (head)->slh_first->field.sle_next; \
} while (/*CONSTCOND*/0) } while (/*CONSTCOND*/0)
#define QSLIST_REMOVE_AFTER(slistelm, field) do { \ #define QSLIST_REMOVE_AFTER(slistelm, field) do { \
(slistelm)->field.sle_next = \ (slistelm)->field.sle_next = \
QSLIST_NEXT(QSLIST_NEXT((slistelm), field), field); \ QSLIST_NEXT(QSLIST_NEXT((slistelm), field), field); \
} while (/*CONSTCOND*/0) } while (/*CONSTCOND*/0)
#define QSLIST_FOREACH(var, head, field) \ #define QSLIST_FOREACH(var, head, field) \
for((var) = (head)->slh_first; (var); (var) = (var)->field.sle_next) for((var) = (head)->slh_first; (var); (var) = (var)->field.sle_next)
#define QSLIST_FOREACH_SAFE(var, head, field, tvar) \ #define QSLIST_FOREACH_SAFE(var, head, field, tvar) \
for ((var) = QSLIST_FIRST((head)); \ for ((var) = QSLIST_FIRST((head)); \
(var) && ((tvar) = QSLIST_NEXT((var), field), 1); \ (var) && ((tvar) = QSLIST_NEXT((var), field), 1); \
(var) = (tvar)) (var) = (tvar))
/* /*
* Singly-linked List access methods. * Singly-linked List access methods.
*/ */
#define QSLIST_EMPTY(head) ((head)->slh_first == NULL) #define QSLIST_EMPTY(head) ((head)->slh_first == NULL)
#define QSLIST_FIRST(head) ((head)->slh_first) #define QSLIST_FIRST(head) ((head)->slh_first)
#define QSLIST_NEXT(elm, field) ((elm)->field.sle_next) #define QSLIST_NEXT(elm, field) ((elm)->field.sle_next)
/* /*
* Simple queue definitions. * Simple queue definitions.
*/ */
#define QSIMPLEQ_HEAD(name, type) \ #define QSIMPLEQ_HEAD(name, type) \
struct name { \ struct name { \
struct type *sqh_first; /* first element */ \ struct type *sqh_first; /* first element */ \
struct type **sqh_last; /* addr of last next element */ \ struct type **sqh_last; /* addr of last next element */ \
} }
#define QSIMPLEQ_HEAD_INITIALIZER(head) \ #define QSIMPLEQ_HEAD_INITIALIZER(head) \
{ NULL, &(head).sqh_first } { NULL, &(head).sqh_first }
#define QSIMPLEQ_ENTRY(type) \ #define QSIMPLEQ_ENTRY(type) \
struct { \ struct { \
struct type *sqe_next; /* next element */ \ struct type *sqe_next; /* next element */ \
} }
/* /*
* Simple queue functions. * Simple queue functions.
*/ */
#define QSIMPLEQ_INIT(head) do { \ #define QSIMPLEQ_INIT(head) do { \
(head)->sqh_first = NULL; \ (head)->sqh_first = NULL; \
(head)->sqh_last = &(head)->sqh_first; \ (head)->sqh_last = &(head)->sqh_first; \
} while (/*CONSTCOND*/0) } while (/*CONSTCOND*/0)
#define QSIMPLEQ_INSERT_HEAD(head, elm, field) do { \ #define QSIMPLEQ_INSERT_HEAD(head, elm, field) do { \
if (((elm)->field.sqe_next = (head)->sqh_first) == NULL) \ if (((elm)->field.sqe_next = (head)->sqh_first) == NULL) \
(head)->sqh_last = &(elm)->field.sqe_next; \ (head)->sqh_last = &(elm)->field.sqe_next; \
(head)->sqh_first = (elm); \ (head)->sqh_first = (elm); \
} while (/*CONSTCOND*/0) } while (/*CONSTCOND*/0)
#define QSIMPLEQ_INSERT_TAIL(head, elm, field) do { \ #define QSIMPLEQ_INSERT_TAIL(head, elm, field) do { \
(elm)->field.sqe_next = NULL; \ (elm)->field.sqe_next = NULL; \
*(head)->sqh_last = (elm); \ *(head)->sqh_last = (elm); \
(head)->sqh_last = &(elm)->field.sqe_next; \ (head)->sqh_last = &(elm)->field.sqe_next; \
} while (/*CONSTCOND*/0) } while (/*CONSTCOND*/0)
#define QSIMPLEQ_INSERT_AFTER(head, listelm, elm, field) do { \ #define QSIMPLEQ_INSERT_AFTER(head, listelm, elm, field) do { \
if (((elm)->field.sqe_next = (listelm)->field.sqe_next) == NULL) \ if (((elm)->field.sqe_next = (listelm)->field.sqe_next) == NULL) \
(head)->sqh_last = &(elm)->field.sqe_next; \ (head)->sqh_last = &(elm)->field.sqe_next; \
(listelm)->field.sqe_next = (elm); \ (listelm)->field.sqe_next = (elm); \
} while (/*CONSTCOND*/0) } while (/*CONSTCOND*/0)
#define QSIMPLEQ_REMOVE_HEAD(head, field) do { \ #define QSIMPLEQ_REMOVE_HEAD(head, field) do { \
if (((head)->sqh_first = (head)->sqh_first->field.sqe_next) == NULL)\ if (((head)->sqh_first = (head)->sqh_first->field.sqe_next) == NULL)\
(head)->sqh_last = &(head)->sqh_first; \ (head)->sqh_last = &(head)->sqh_first; \
} while (/*CONSTCOND*/0) } while (/*CONSTCOND*/0)
#define QSIMPLEQ_SPLIT_AFTER(head, elm, field, removed) do { \ #define QSIMPLEQ_SPLIT_AFTER(head, elm, field, removed) do { \
QSIMPLEQ_INIT(removed); \ QSIMPLEQ_INIT(removed); \
if (((removed)->sqh_first = (head)->sqh_first) != NULL) { \ if (((removed)->sqh_first = (head)->sqh_first) != NULL) { \
if (((head)->sqh_first = (elm)->field.sqe_next) == NULL) { \ if (((head)->sqh_first = (elm)->field.sqe_next) == NULL) { \
(head)->sqh_last = &(head)->sqh_first; \ (head)->sqh_last = &(head)->sqh_first; \
} \ } \
(removed)->sqh_last = &(elm)->field.sqe_next; \ (removed)->sqh_last = &(elm)->field.sqe_next; \
(elm)->field.sqe_next = NULL; \ (elm)->field.sqe_next = NULL; \
} \ } \
} while (/*CONSTCOND*/0) } while (/*CONSTCOND*/0)
#define QSIMPLEQ_REMOVE(head, elm, type, field) do { \ #define QSIMPLEQ_REMOVE(head, elm, type, field) do { \
if ((head)->sqh_first == (elm)) { \ if ((head)->sqh_first == (elm)) { \
QSIMPLEQ_REMOVE_HEAD((head), field); \ QSIMPLEQ_REMOVE_HEAD((head), field); \
} else { \ } else { \
struct type *curelm = (head)->sqh_first; \ struct type *curelm = (head)->sqh_first; \
while (curelm->field.sqe_next != (elm)) \ while (curelm->field.sqe_next != (elm)) \
curelm = curelm->field.sqe_next; \ curelm = curelm->field.sqe_next; \
if ((curelm->field.sqe_next = \ if ((curelm->field.sqe_next = \
curelm->field.sqe_next->field.sqe_next) == NULL) \ curelm->field.sqe_next->field.sqe_next) == NULL) \
(head)->sqh_last = &(curelm)->field.sqe_next; \ (head)->sqh_last = &(curelm)->field.sqe_next; \
} \ } \
} while (/*CONSTCOND*/0) } while (/*CONSTCOND*/0)
#define QSIMPLEQ_FOREACH(var, head, field) \ #define QSIMPLEQ_FOREACH(var, head, field) \
for ((var) = ((head)->sqh_first); \ for ((var) = ((head)->sqh_first); \
(var); \ (var); \
(var) = ((var)->field.sqe_next)) (var) = ((var)->field.sqe_next))
#define QSIMPLEQ_FOREACH_SAFE(var, head, field, next) \ #define QSIMPLEQ_FOREACH_SAFE(var, head, field, next) \
for ((var) = ((head)->sqh_first); \ for ((var) = ((head)->sqh_first); \
(var) && ((next = ((var)->field.sqe_next)), 1); \ (var) && ((next = ((var)->field.sqe_next)), 1); \
(var) = (next)) (var) = (next))
#define QSIMPLEQ_CONCAT(head1, head2) do { \ #define QSIMPLEQ_CONCAT(head1, head2) do { \
if (!QSIMPLEQ_EMPTY((head2))) { \ if (!QSIMPLEQ_EMPTY((head2))) { \
*(head1)->sqh_last = (head2)->sqh_first; \ *(head1)->sqh_last = (head2)->sqh_first; \
(head1)->sqh_last = (head2)->sqh_last; \ (head1)->sqh_last = (head2)->sqh_last; \
QSIMPLEQ_INIT((head2)); \ QSIMPLEQ_INIT((head2)); \
} \ } \
} while (/*CONSTCOND*/0) } while (/*CONSTCOND*/0)
#define QSIMPLEQ_LAST(head, type, field) \ #define QSIMPLEQ_LAST(head, type, field) \
(QSIMPLEQ_EMPTY((head)) ? \ (QSIMPLEQ_EMPTY((head)) ? \
NULL : \ NULL : \
((struct type *)(void *) \ ((struct type *)(void *) \
((char *)((head)->sqh_last) - offsetof(struct type, field)))) ((char *)((head)->sqh_last) - offsetof(struct type, field))))
/* /*
* Simple queue access methods. * Simple queue access methods.
*/ */
#define QSIMPLEQ_EMPTY(head) ((head)->sqh_first == NULL) #define QSIMPLEQ_EMPTY(head) ((head)->sqh_first == NULL)
#define QSIMPLEQ_FIRST(head) ((head)->sqh_first) #define QSIMPLEQ_FIRST(head) ((head)->sqh_first)
#define QSIMPLEQ_NEXT(elm, field) ((elm)->field.sqe_next) #define QSIMPLEQ_NEXT(elm, field) ((elm)->field.sqe_next)
/* /*
* Tail queue definitions. * Tail queue definitions.
*/ */
#define Q_TAILQ_HEAD(name, type, qual) \ #define Q_TAILQ_HEAD(name, type, qual) \
struct name { \ struct name { \
qual type *tqh_first; /* first element */ \ qual type *tqh_first; /* first element */ \
qual type *qual *tqh_last; /* addr of last next element */ \ qual type *qual *tqh_last; /* addr of last next element */ \
} }
#define QTAILQ_HEAD(name, type) Q_TAILQ_HEAD(name, struct type,) #define QTAILQ_HEAD(name, type) Q_TAILQ_HEAD(name, struct type,)
#define QTAILQ_HEAD_INITIALIZER(head) \ #define QTAILQ_HEAD_INITIALIZER(head) \
{ NULL, &(head).tqh_first } { NULL, &(head).tqh_first }
#define Q_TAILQ_ENTRY(type, qual) \ #define Q_TAILQ_ENTRY(type, qual) \
struct { \ struct { \
qual type *tqe_next; /* next element */ \ qual type *tqe_next; /* next element */ \
qual type *qual *tqe_prev; /* address of previous next element */\ qual type *qual *tqe_prev; /* address of previous next element */\
} }
#define QTAILQ_ENTRY(type) Q_TAILQ_ENTRY(struct type,) #define QTAILQ_ENTRY(type) Q_TAILQ_ENTRY(struct type,)
/* /*
* Tail queue functions. * Tail queue functions.
*/ */
#define QTAILQ_INIT(head) do { \ #define QTAILQ_INIT(head) do { \
(head)->tqh_first = NULL; \ (head)->tqh_first = NULL; \
(head)->tqh_last = &(head)->tqh_first; \ (head)->tqh_last = &(head)->tqh_first; \
} while (/*CONSTCOND*/0) } while (/*CONSTCOND*/0)
#define QTAILQ_INSERT_HEAD(head, elm, field) do { \ #define QTAILQ_INSERT_HEAD(head, elm, field) do { \
if (((elm)->field.tqe_next = (head)->tqh_first) != NULL) \ if (((elm)->field.tqe_next = (head)->tqh_first) != NULL) \
(head)->tqh_first->field.tqe_prev = \ (head)->tqh_first->field.tqe_prev = \
&(elm)->field.tqe_next; \ &(elm)->field.tqe_next; \
else \ else \
(head)->tqh_last = &(elm)->field.tqe_next; \ (head)->tqh_last = &(elm)->field.tqe_next; \
(head)->tqh_first = (elm); \ (head)->tqh_first = (elm); \
(elm)->field.tqe_prev = &(head)->tqh_first; \ (elm)->field.tqe_prev = &(head)->tqh_first; \
} while (/*CONSTCOND*/0) } while (/*CONSTCOND*/0)
#define QTAILQ_INSERT_TAIL(head, elm, field) do { \ #define QTAILQ_INSERT_TAIL(head, elm, field) do { \
(elm)->field.tqe_next = NULL; \ (elm)->field.tqe_next = NULL; \
(elm)->field.tqe_prev = (head)->tqh_last; \ (elm)->field.tqe_prev = (head)->tqh_last; \
*(head)->tqh_last = (elm); \ *(head)->tqh_last = (elm); \
(head)->tqh_last = &(elm)->field.tqe_next; \ (head)->tqh_last = &(elm)->field.tqe_next; \
} while (/*CONSTCOND*/0) } while (/*CONSTCOND*/0)
#define QTAILQ_INSERT_AFTER(head, listelm, elm, field) do { \ #define QTAILQ_INSERT_AFTER(head, listelm, elm, field) do { \
if (((elm)->field.tqe_next = (listelm)->field.tqe_next) != NULL)\ if (((elm)->field.tqe_next = (listelm)->field.tqe_next) != NULL)\
(elm)->field.tqe_next->field.tqe_prev = \ (elm)->field.tqe_next->field.tqe_prev = \
&(elm)->field.tqe_next; \ &(elm)->field.tqe_next; \
else \ else \
(head)->tqh_last = &(elm)->field.tqe_next; \ (head)->tqh_last = &(elm)->field.tqe_next; \
(listelm)->field.tqe_next = (elm); \ (listelm)->field.tqe_next = (elm); \
(elm)->field.tqe_prev = &(listelm)->field.tqe_next; \ (elm)->field.tqe_prev = &(listelm)->field.tqe_next; \
} while (/*CONSTCOND*/0) } while (/*CONSTCOND*/0)
#define QTAILQ_INSERT_BEFORE(listelm, elm, field) do { \ #define QTAILQ_INSERT_BEFORE(listelm, elm, field) do { \
(elm)->field.tqe_prev = (listelm)->field.tqe_prev; \ (elm)->field.tqe_prev = (listelm)->field.tqe_prev; \
(elm)->field.tqe_next = (listelm); \ (elm)->field.tqe_next = (listelm); \
*(listelm)->field.tqe_prev = (elm); \ *(listelm)->field.tqe_prev = (elm); \
(listelm)->field.tqe_prev = &(elm)->field.tqe_next; \ (listelm)->field.tqe_prev = &(elm)->field.tqe_next; \
} while (/*CONSTCOND*/0) } while (/*CONSTCOND*/0)
#define QTAILQ_REMOVE(head, elm, field) do { \ #define QTAILQ_REMOVE(head, elm, field) do { \
if (((elm)->field.tqe_next) != NULL) \ if (((elm)->field.tqe_next) != NULL) \
(elm)->field.tqe_next->field.tqe_prev = \ (elm)->field.tqe_next->field.tqe_prev = \
(elm)->field.tqe_prev; \ (elm)->field.tqe_prev; \
else \ else \
(head)->tqh_last = (elm)->field.tqe_prev; \ (head)->tqh_last = (elm)->field.tqe_prev; \
*(elm)->field.tqe_prev = (elm)->field.tqe_next; \ *(elm)->field.tqe_prev = (elm)->field.tqe_next; \
} while (/*CONSTCOND*/0) } while (/*CONSTCOND*/0)
#define QTAILQ_FOREACH(var, head, field) \ #define QTAILQ_FOREACH(var, head, field) \
for ((var) = ((head)->tqh_first); \ for ((var) = ((head)->tqh_first); \
(var); \ (var); \
(var) = ((var)->field.tqe_next)) (var) = ((var)->field.tqe_next))
#define QTAILQ_FOREACH_SAFE(var, head, field, next_var) \ #define QTAILQ_FOREACH_SAFE(var, head, field, next_var) \
for ((var) = ((head)->tqh_first); \ for ((var) = ((head)->tqh_first); \
(var) && ((next_var) = ((var)->field.tqe_next), 1); \ (var) && ((next_var) = ((var)->field.tqe_next), 1); \
(var) = (next_var)) (var) = (next_var))
#define QTAILQ_FOREACH_REVERSE(var, head, headname, field) \ #define QTAILQ_FOREACH_REVERSE(var, head, headname, field) \
for ((var) = (*(((struct headname *)((head)->tqh_last))->tqh_last)); \ for ((var) = (*(((struct headname *)((head)->tqh_last))->tqh_last)); \
(var); \ (var); \
(var) = (*(((struct headname *)((var)->field.tqe_prev))->tqh_last))) (var) = (*(((struct headname *)((var)->field.tqe_prev))->tqh_last)))
/* /*
* Tail queue access methods. * Tail queue access methods.
*/ */
#define QTAILQ_EMPTY(head) ((head)->tqh_first == NULL) #define QTAILQ_EMPTY(head) ((head)->tqh_first == NULL)
#define QTAILQ_FIRST(head) ((head)->tqh_first) #define QTAILQ_FIRST(head) ((head)->tqh_first)
#define QTAILQ_NEXT(elm, field) ((elm)->field.tqe_next) #define QTAILQ_NEXT(elm, field) ((elm)->field.tqe_next)
#define QTAILQ_LAST(head, headname) \ #define QTAILQ_LAST(head, headname) \
(*(((struct headname *)((head)->tqh_last))->tqh_last)) (*(((struct headname *)((head)->tqh_last))->tqh_last))
#define QTAILQ_PREV(elm, headname, field) \ #define QTAILQ_PREV(elm, headname, field) \
(*(((struct headname *)((elm)->field.tqe_prev))->tqh_last)) (*(((struct headname *)((elm)->field.tqe_prev))->tqh_last))
#endif /* !QEMU_SYS_QUEUE_H_ */ #endif /* !QEMU_SYS_QUEUE_H_ */

View File

@@ -1,52 +1,52 @@
/* headers to use the BSD sockets */ /* headers to use the BSD sockets */
#ifndef QEMU_SOCKET_H #ifndef QEMU_SOCKET_H
#define QEMU_SOCKET_H #define QEMU_SOCKET_H
#ifdef _WIN32 #ifdef _WIN32
#include <windows.h> #include <windows.h>
#include <winsock2.h> #include <winsock2.h>
#include <ws2tcpip.h> #include <ws2tcpip.h>
#define socket_error() WSAGetLastError() #define socket_error() WSAGetLastError()
extern char *socket_strerror(int errcode); extern char *socket_strerror(int errcode);
#define strerror socket_strerror #define strerror socket_strerror
int inet_aton(const char *cp, struct in_addr *ia); int inet_aton(const char *cp, struct in_addr *ia);
#else #else
#include <sys/types.h> #include <sys/types.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <netinet/in.h> #include <netinet/in.h>
#include <netinet/tcp.h> #include <netinet/tcp.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#include <netdb.h> #include <netdb.h>
#include <sys/un.h> #include <sys/un.h>
#define socket_error() errno #define socket_error() errno
#endif /* !_WIN32 */ #endif /* !_WIN32 */
/* misc helpers */ /* misc helpers */
int qemu_socket(int domain, int type, int protocol); int qemu_socket(int domain, int type, int protocol);
int qemu_accept(int s, struct sockaddr *addr, socklen_t *addrlen); int qemu_accept(int s, struct sockaddr *addr, socklen_t *addrlen);
int socket_set_cork(int fd, int v); int socket_set_cork(int fd, int v);
int socket_set_nodelay(int fd); int socket_set_nodelay(int fd);
void qemu_set_block(int fd); void qemu_set_block(int fd);
void qemu_set_nonblock(int fd); void qemu_set_nonblock(int fd);
int socket_set_fast_reuse(int fd); int socket_set_fast_reuse(int fd);
#ifdef _WIN32 #ifdef _WIN32
/* MinGW needs type casts for the 'buf' and 'optval' arguments. */ /* MinGW needs type casts for the 'buf' and 'optval' arguments. */
#define qemu_sendto(sockfd, buf, len, flags, destaddr, addrlen) \ #define qemu_sendto(sockfd, buf, len, flags, destaddr, addrlen) \
sendto(sockfd, (const void *)buf, len, flags, destaddr, addrlen) sendto(sockfd, (const void *)buf, len, flags, destaddr, addrlen)
/* Windows has different names for the same constants with the same values */ /* Windows has different names for the same constants with the same values */
#define SHUT_RD 0 #define SHUT_RD 0
#define SHUT_WR 1 #define SHUT_WR 1
#define SHUT_RDWR 2 #define SHUT_RDWR 2
#endif #endif
#endif /* QEMU_SOCKET_H */ #endif /* QEMU_SOCKET_H */

View File

@@ -1,21 +1,21 @@
#ifndef QEMU_CHAR_H #ifndef QEMU_CHAR_H
#define QEMU_CHAR_H #define QEMU_CHAR_H
#include "qemu-common.h" #include "qemu-common.h"
/** /**
* @qemu_chr_fe_write: * @qemu_chr_fe_write:
* *
* Write data to a character backend from the front end. This function * Write data to a character backend from the front end. This function
* will send data from the front end to the back end. This function * will send data from the front end to the back end. This function
* is thread-safe. * is thread-safe.
* *
* @buf the data * @buf the data
* @len the number of bytes to send * @len the number of bytes to send
* *
* Returns: the number of bytes consumed * Returns: the number of bytes consumed
*/ */
int qemu_chr_fe_write(CharDriverState *s, const uint8_t *buf, int len); int qemu_chr_fe_write(CharDriverState *s, const uint8_t *buf, int len);
#endif #endif

View File

@@ -1,112 +1,112 @@
/* /*
* win32 specific declarations * win32 specific declarations
* *
* Copyright (c) 2003-2008 Fabrice Bellard * Copyright (c) 2003-2008 Fabrice Bellard
* Copyright (c) 2010 Jes Sorensen <Jes.Sorensen@redhat.com> * Copyright (c) 2010 Jes Sorensen <Jes.Sorensen@redhat.com>
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights * in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is * copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions: * furnished to do so, subject to the following conditions:
* *
* The above copyright notice and this permission notice shall be included in * The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software. * all copies or substantial portions of the Software.
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE. * THE SOFTWARE.
*/ */
#ifndef QEMU_OS_WIN32_H #ifndef QEMU_OS_WIN32_H
#define QEMU_OS_WIN32_H #define QEMU_OS_WIN32_H
#include <windows.h> #include <windows.h>
#include <winsock2.h> #include <winsock2.h>
#if defined(_WIN64) #if defined(_WIN64)
/* MinGW-w64 has a 32 bit off_t, but we want 64 bit off_t. */ /* MinGW-w64 has a 32 bit off_t, but we want 64 bit off_t. */
# define off_t off64_t # define off_t off64_t
/* MinGW-w64 stdio.h defines SYS_OPEN. Allow a redefinition in arm-semi.c. */ /* MinGW-w64 stdio.h defines SYS_OPEN. Allow a redefinition in arm-semi.c. */
# undef SYS_OPEN # undef SYS_OPEN
#endif #endif
/* Workaround for older versions of MinGW. */ /* Workaround for older versions of MinGW. */
#ifndef ECONNREFUSED #ifndef ECONNREFUSED
# define ECONNREFUSED WSAECONNREFUSED # define ECONNREFUSED WSAECONNREFUSED
#endif #endif
#ifndef EINPROGRESS #ifndef EINPROGRESS
# define EINPROGRESS WSAEINPROGRESS # define EINPROGRESS WSAEINPROGRESS
#endif #endif
#ifndef EHOSTUNREACH #ifndef EHOSTUNREACH
# define EHOSTUNREACH WSAEHOSTUNREACH # define EHOSTUNREACH WSAEHOSTUNREACH
#endif #endif
#ifndef EINTR #ifndef EINTR
# define EINTR WSAEINTR # define EINTR WSAEINTR
#endif #endif
#ifndef EINPROGRESS #ifndef EINPROGRESS
# define EINPROGRESS WSAEINPROGRESS # define EINPROGRESS WSAEINPROGRESS
#endif #endif
#ifndef ENETUNREACH #ifndef ENETUNREACH
# define ENETUNREACH WSAENETUNREACH # define ENETUNREACH WSAENETUNREACH
#endif #endif
#ifndef ENOTCONN #ifndef ENOTCONN
# define ENOTCONN WSAENOTCONN # define ENOTCONN WSAENOTCONN
#endif #endif
#ifndef EWOULDBLOCK #ifndef EWOULDBLOCK
# define EWOULDBLOCK WSAEWOULDBLOCK # define EWOULDBLOCK WSAEWOULDBLOCK
#endif #endif
#if defined(_WIN64) #if defined(_WIN64)
/* On w64, setjmp is implemented by _setjmp which needs a second parameter. /* On w64, setjmp is implemented by _setjmp which needs a second parameter.
* If this parameter is NULL, longjump does no stack unwinding. * If this parameter is NULL, longjump does no stack unwinding.
* That is what we need for QEMU. Passing the value of register rsp (default) * That is what we need for QEMU. Passing the value of register rsp (default)
* lets longjmp try a stack unwinding which will crash with generated code. */ * lets longjmp try a stack unwinding which will crash with generated code. */
# undef setjmp # undef setjmp
# define setjmp(env) _setjmp(env, NULL) # define setjmp(env) _setjmp(env, NULL)
#endif #endif
/* QEMU uses sigsetjmp()/siglongjmp() as the portable way to specify /* QEMU uses sigsetjmp()/siglongjmp() as the portable way to specify
* "longjmp and don't touch the signal masks". Since we know that the * "longjmp and don't touch the signal masks". Since we know that the
* savemask parameter will always be zero we can safely define these * savemask parameter will always be zero we can safely define these
* in terms of setjmp/longjmp on Win32. * in terms of setjmp/longjmp on Win32.
*/ */
#define sigjmp_buf jmp_buf #define sigjmp_buf jmp_buf
#define sigsetjmp(env, savemask) setjmp(env) #define sigsetjmp(env, savemask) setjmp(env)
#define siglongjmp(env, val) longjmp(env, val) #define siglongjmp(env, val) longjmp(env, val)
/* Missing POSIX functions. Don't use MinGW-w64 macros. */ /* Missing POSIX functions. Don't use MinGW-w64 macros. */
#ifndef CONFIG_LOCALTIME_R #ifndef CONFIG_LOCALTIME_R
#undef gmtime_r #undef gmtime_r
struct tm *gmtime_r(const time_t *timep, struct tm *result); struct tm *gmtime_r(const time_t *timep, struct tm *result);
#undef localtime_r #undef localtime_r
struct tm *localtime_r(const time_t *timep, struct tm *result); struct tm *localtime_r(const time_t *timep, struct tm *result);
#endif /* CONFIG_LOCALTIME_R */ #endif /* CONFIG_LOCALTIME_R */
static inline void os_setup_signal_handling(void) {} static inline void os_setup_signal_handling(void) {}
static inline void os_daemonize(void) {} static inline void os_daemonize(void) {}
static inline void os_setup_post(void) {} static inline void os_setup_post(void) {}
void os_set_line_buffering(void); void os_set_line_buffering(void);
static inline void os_set_proc_name(const char *dummy) {} static inline void os_set_proc_name(const char *dummy) {}
size_t getpagesize(void); size_t getpagesize(void);
#if !defined(EPROTONOSUPPORT) #if !defined(EPROTONOSUPPORT)
# define EPROTONOSUPPORT EINVAL # define EPROTONOSUPPORT EINVAL
#endif #endif
int setenv(const char *name, const char *value, int overwrite); int setenv(const char *name, const char *value, int overwrite);
typedef struct { typedef struct {
long tv_sec; long tv_sec;
long tv_usec; long tv_usec;
} qemu_timeval; } qemu_timeval;
int qemu_gettimeofday(qemu_timeval *tp); int qemu_gettimeofday(qemu_timeval *tp);
#endif #endif

View File

@@ -1,95 +1,95 @@
#ifndef QEMU_TIMER_H #ifndef QEMU_TIMER_H
#define QEMU_TIMER_H #define QEMU_TIMER_H
#include "qemu/typedefs.h" #include "qemu/typedefs.h"
#include "qemu-common.h" #include "qemu-common.h"
#define NANOSECONDS_PER_SECOND 1000000000LL #define NANOSECONDS_PER_SECOND 1000000000LL
/* timers */ /* timers */
#define SCALE_MS 1000000 #define SCALE_MS 1000000
#define SCALE_US 1000 #define SCALE_US 1000
#define SCALE_NS 1 #define SCALE_NS 1
/** /**
* QEMUClockType: * QEMUClockType:
* *
* The following clock types are available: * The following clock types are available:
* *
* @QEMU_CLOCK_REALTIME: Real time clock * @QEMU_CLOCK_REALTIME: Real time clock
* *
* The real time clock should be used only for stuff which does not * The real time clock should be used only for stuff which does not
* change the virtual machine state, as it is run even if the virtual * change the virtual machine state, as it is run even if the virtual
* machine is stopped. The real time clock has a frequency of 1000 * machine is stopped. The real time clock has a frequency of 1000
* Hz. * Hz.
* *
* @QEMU_CLOCK_VIRTUAL: virtual clock * @QEMU_CLOCK_VIRTUAL: virtual clock
* *
* The virtual clock is only run during the emulation. It is stopped * The virtual clock is only run during the emulation. It is stopped
* when the virtual machine is stopped. Virtual timers use a high * when the virtual machine is stopped. Virtual timers use a high
* precision clock, usually cpu cycles (use ticks_per_sec). * precision clock, usually cpu cycles (use ticks_per_sec).
* *
* @QEMU_CLOCK_HOST: host clock * @QEMU_CLOCK_HOST: host clock
* *
* The host clock should be use for device models that emulate accurate * The host clock should be use for device models that emulate accurate
* real time sources. It will continue to run when the virtual machine * real time sources. It will continue to run when the virtual machine
* is suspended, and it will reflect system time changes the host may * is suspended, and it will reflect system time changes the host may
* undergo (e.g. due to NTP). The host clock has the same precision as * undergo (e.g. due to NTP). The host clock has the same precision as
* the virtual clock. * the virtual clock.
* *
* @QEMU_CLOCK_VIRTUAL_RT: realtime clock used for icount warp * @QEMU_CLOCK_VIRTUAL_RT: realtime clock used for icount warp
* *
* Outside icount mode, this clock is the same as @QEMU_CLOCK_VIRTUAL. * Outside icount mode, this clock is the same as @QEMU_CLOCK_VIRTUAL.
* In icount mode, this clock counts nanoseconds while the virtual * In icount mode, this clock counts nanoseconds while the virtual
* machine is running. It is used to increase @QEMU_CLOCK_VIRTUAL * machine is running. It is used to increase @QEMU_CLOCK_VIRTUAL
* while the CPUs are sleeping and thus not executing instructions. * while the CPUs are sleeping and thus not executing instructions.
*/ */
typedef enum { typedef enum {
QEMU_CLOCK_REALTIME = 0, QEMU_CLOCK_REALTIME = 0,
QEMU_CLOCK_VIRTUAL = 1, QEMU_CLOCK_VIRTUAL = 1,
QEMU_CLOCK_HOST = 2, QEMU_CLOCK_HOST = 2,
QEMU_CLOCK_VIRTUAL_RT = 3, QEMU_CLOCK_VIRTUAL_RT = 3,
QEMU_CLOCK_MAX QEMU_CLOCK_MAX
} QEMUClockType; } QEMUClockType;
/* /*
* QEMUClockType * QEMUClockType
*/ */
/* /*
* qemu_clock_get_ns; * qemu_clock_get_ns;
* @type: the clock type * @type: the clock type
* *
* Get the nanosecond value of a clock with * Get the nanosecond value of a clock with
* type @type * type @type
* *
* Returns: the clock value in nanoseconds * Returns: the clock value in nanoseconds
*/ */
#if defined(__cplusplus) #if defined(__cplusplus)
extern "C" { extern "C" {
#endif #endif
int64_t qemu_clock_get_ns(QEMUClockType type); int64_t qemu_clock_get_ns(QEMUClockType type);
#if defined(__cplusplus) #if defined(__cplusplus)
} }
#endif #endif
/** /**
* qemu_clock_get_ms; * qemu_clock_get_ms;
* @type: the clock type * @type: the clock type
* *
* Get the millisecond value of a clock with * Get the millisecond value of a clock with
* type @type * type @type
* *
* Returns: the clock value in milliseconds * Returns: the clock value in milliseconds
*/ */
static inline int64_t qemu_clock_get_ms(QEMUClockType type) static inline int64_t qemu_clock_get_ms(QEMUClockType type)
{ {
return qemu_clock_get_ns(type) / SCALE_MS; return qemu_clock_get_ns(type) / SCALE_MS;
} }
#endif #endif

View File

@@ -1,11 +1,11 @@
#ifndef QEMU_TYPEDEFS_H #ifndef QEMU_TYPEDEFS_H
#define QEMU_TYPEDEFS_H #define QEMU_TYPEDEFS_H
/* A load of opaque types so that device init declarations don't have to /* A load of opaque types so that device init declarations don't have to
pull in all the real definitions. */ pull in all the real definitions. */
struct Monitor; struct Monitor;
typedef struct Monitor Monitor; typedef struct Monitor Monitor;
typedef struct CharDriverState CharDriverState; typedef struct CharDriverState CharDriverState;
typedef struct QEMUFile QEMUFile; typedef struct QEMUFile QEMUFile;
#endif /* QEMU_TYPEDEFS_H */ #endif /* QEMU_TYPEDEFS_H */