From: Stefan Weil <weil@mail.berlios.de>
To: QEMU Developers <qemu-devel@nongnu.org>
Subject: [Qemu-devel] [PATCH] Use standard header for offsetof
Date: Sun, 01 Jun 2008 19:37:43 +0200 [thread overview]
Message-ID: <4842DE67.9090207@mail.berlios.de> (raw)
[-- Attachment #1: Type: text/plain, Size: 313 bytes --]
This patch adds the standard header stddef.h to all files which call
offsetof.
It also removes several local definitions of offsetof which are no
longer needed.
If you prefer standard headers for standard macros instead of local
definitions
(like I do), you can add this patch to Qemu trunk.
Thanks,
Stefan
[-- Attachment #2: offsetof.patch --]
[-- Type: text/x-diff, Size: 9456 bytes --]
Index: translate-all.c
===================================================================
--- translate-all.c (revision 4638)
+++ translate-all.c (working copy)
@@ -18,6 +18,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <stdarg.h>
+#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
Index: target-cris/translate.c
===================================================================
--- target-cris/translate.c (revision 4638)
+++ target-cris/translate.c (working copy)
@@ -25,6 +25,7 @@
*/
#include <stdarg.h>
+#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
Index: softmmu_header.h
===================================================================
--- softmmu_header.h (revision 4638)
+++ softmmu_header.h (working copy)
@@ -17,6 +17,8 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+
+#include <stddef.h>
#if DATA_SIZE == 8
#define SUFFIX q
#define USUFFIX q
Index: target-sparc/translate.c
===================================================================
--- target-sparc/translate.c (revision 4638)
+++ target-sparc/translate.c (working copy)
@@ -20,6 +20,7 @@
*/
#include <stdarg.h>
+#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
Index: target-m68k/helper.c
===================================================================
--- target-m68k/helper.c (revision 4638)
+++ target-m68k/helper.c (working copy)
@@ -19,6 +19,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include <stddef.h>
#include <stdio.h>
#include <string.h>
Index: target-m68k/translate.c
===================================================================
--- target-m68k/translate.c (revision 4638)
+++ target-m68k/translate.c (working copy)
@@ -19,6 +19,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <stdarg.h>
+#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
Index: linux-user/signal.c
===================================================================
--- linux-user/signal.c (revision 4638)
+++ linux-user/signal.c (working copy)
@@ -17,6 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@@ -548,10 +549,6 @@
return ret;
}
-#ifndef offsetof
-#define offsetof(type, field) ((size_t) &((type *)0)->field)
-#endif
-
static inline int copy_siginfo_to_user(target_siginfo_t *tinfo,
const target_siginfo_t *info)
{
Index: target-mips/translate.c
===================================================================
--- target-mips/translate.c (revision 4638)
+++ target-mips/translate.c (working copy)
@@ -21,6 +21,7 @@
*/
#include <stdarg.h>
+#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
Index: tcg/arm/tcg-target.c
===================================================================
--- tcg/arm/tcg-target.c (revision 4638)
+++ tcg/arm/tcg-target.c (working copy)
@@ -21,6 +21,9 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
+
+#include <stddef.h>
+
const char *tcg_target_reg_names[TCG_TARGET_NB_REGS] = {
"%r0",
"%r1",
Index: tcg/ppc/tcg-target.c
===================================================================
--- tcg/ppc/tcg-target.c (revision 4638)
+++ tcg/ppc/tcg-target.c (working copy)
@@ -22,6 +22,8 @@
* THE SOFTWARE.
*/
+#include <stddef.h>
+
static uint8_t *tb_ret_addr;
#define FAST_PATH
Index: tcg/hppa/tcg-target.c
===================================================================
--- tcg/hppa/tcg-target.c (revision 4638)
+++ tcg/hppa/tcg-target.c (working copy)
@@ -22,6 +22,8 @@
* THE SOFTWARE.
*/
+#include <stddef.h>
+
static const char * const tcg_target_reg_names[TCG_TARGET_NB_REGS] = {
"%r0",
"%r1",
Index: tcg/i386/tcg-target.c
===================================================================
--- tcg/i386/tcg-target.c (revision 4638)
+++ tcg/i386/tcg-target.c (working copy)
@@ -21,6 +21,9 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
+
+#include <stddef.h>
+
const char *tcg_target_reg_names[TCG_TARGET_NB_REGS] = {
"%eax",
"%ecx",
Index: tcg/x86_64/tcg-target.c
===================================================================
--- tcg/x86_64/tcg-target.c (revision 4638)
+++ tcg/x86_64/tcg-target.c (working copy)
@@ -21,6 +21,9 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
+
+#include <stddef.h>
+
const char *tcg_target_reg_names[TCG_TARGET_NB_REGS] = {
"%rax",
"%rcx",
Index: tcg/sparc/tcg-target.c
===================================================================
--- tcg/sparc/tcg-target.c (revision 4638)
+++ tcg/sparc/tcg-target.c (working copy)
@@ -22,6 +22,8 @@
* THE SOFTWARE.
*/
+#include <stddef.h>
+
static const char * const tcg_target_reg_names[TCG_TARGET_NB_REGS] = {
"%g0",
"%g1",
Index: cpu-exec.c
===================================================================
--- cpu-exec.c (revision 4638)
+++ cpu-exec.c (working copy)
@@ -17,6 +17,7 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include <stddef.h>
#include "config.h"
#define CPU_NO_GLOBAL_REGS
#include "exec.h"
Index: block-qcow2.c
===================================================================
--- block-qcow2.c (revision 4638)
+++ block-qcow2.c (working copy)
@@ -21,6 +21,8 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
+
+#include <stddef.h>
#include "qemu-common.h"
#include "block_int.h"
#include <zlib.h>
@@ -59,10 +61,6 @@
#define REFCOUNT_SHIFT 1 /* refcount size is 2 bytes */
-#ifndef offsetof
-#define offsetof(type, field) ((size_t) &((type *)0)->field)
-#endif
-
typedef struct QCowHeader {
uint32_t magic;
uint32_t version;
Index: exec.c
===================================================================
--- exec.c (revision 4638)
+++ exec.c (working copy)
@@ -28,6 +28,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
+#include <stddef.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
Index: monitor.c
===================================================================
--- monitor.c (revision 4638)
+++ monitor.c (working copy)
@@ -21,6 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
+#include <stddef.h>
#include "hw/hw.h"
#include "hw/usb.h"
#include "hw/pcmcia.h"
@@ -43,10 +44,6 @@
//#define DEBUG
//#define DEBUG_COMPLETION
-#ifndef offsetof
-#define offsetof(type, field) ((size_t) &((type *)0)->field)
-#endif
-
/*
* Supported types:
*
Index: exec-all.h
===================================================================
--- exec-all.h (revision 4638)
+++ exec-all.h (working copy)
@@ -275,10 +275,6 @@
TranslationBlock *tb_find_pc(unsigned long pc_ptr);
-#ifndef offsetof
-#define offsetof(type, field) ((size_t) &((type *)0)->field)
-#endif
-
#if defined(_WIN32)
#define ASM_DATA_SECTION ".section \".data\"\n"
#define ASM_PREVIOUS_SECTION ".section .text\n"
Index: target-i386/helper.c
===================================================================
--- target-i386/helper.c (revision 4638)
+++ target-i386/helper.c (working copy)
@@ -18,6 +18,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <stdarg.h>
+#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
Index: target-i386/op_helper.c
===================================================================
--- target-i386/op_helper.c (revision 4638)
+++ target-i386/op_helper.c (working copy)
@@ -18,6 +18,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#define CPU_NO_GLOBAL_REGS
+#include <stddef.h>
#include "exec.h"
#include "host-utils.h"
Index: target-i386/translate.c
===================================================================
--- target-i386/translate.c (revision 4638)
+++ target-i386/translate.c (working copy)
@@ -18,6 +18,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <stdarg.h>
+#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
Index: target-arm/helper.c
===================================================================
--- target-arm/helper.c (revision 4638)
+++ target-arm/helper.c (working copy)
@@ -1,4 +1,5 @@
#include <stdio.h>
+#include <stddef.h>
#include <stdlib.h>
#include <string.h>
Index: target-arm/translate.c
===================================================================
--- target-arm/translate.c (revision 4638)
+++ target-arm/translate.c (working copy)
@@ -20,6 +20,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <stdarg.h>
+#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
next reply other threads:[~2008-06-01 17:37 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-01 17:37 Stefan Weil [this message]
2008-06-02 6:21 ` [Qemu-devel] [PATCH] Use standard header for offsetof Johannes Schindelin
2008-06-03 19:08 ` Anthony Liguori
2008-06-03 21:03 ` Stefan Weil
2008-06-03 21:24 ` Anthony Liguori
2008-06-06 19:44 ` Stefan Weil
2008-06-06 19:58 ` Andreas Färber
2008-06-09 10:30 ` Ian Jackson
2008-06-06 20:32 ` Anthony Liguori
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4842DE67.9090207@mail.berlios.de \
--to=weil@mail.berlios.de \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).