WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] Clean up libelf endian macros and include

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] Clean up libelf endian macros and includes.
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Sun, 28 Jan 2007 13:30:16 -0800
Delivery-date: Sun, 28 Jan 2007 13:30:37 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User kaf24@xxxxxxxxxxxxxxxxxxxxx
# Date 1170010920 0
# Node ID f8ddcb7581173f1b3a756a1cb96491ec1ff65403
# Parent  bef8a8b1e400c89f68d498c204f2500e5e9dc11b
Clean up libelf endian macros and includes.
Based on a patch from John Levon <john.levon@xxxxxxx>
Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>
---
 xen/common/libelf/libelf-private.h |   36 ++++++++++++++++++++----------------
 xen/common/libelf/libelf-tools.c   |    4 ++--
 xen/include/public/libelf.h        |   33 ++++++++-------------------------
 3 files changed, 30 insertions(+), 43 deletions(-)

diff -r bef8a8b1e400 -r f8ddcb758117 xen/common/libelf/libelf-private.h
--- a/xen/common/libelf/libelf-private.h        Sun Jan 28 18:45:04 2007 +0000
+++ b/xen/common/libelf/libelf-private.h        Sun Jan 28 19:02:00 2007 +0000
@@ -1,7 +1,13 @@
+#ifndef __LIBELF_PRIVATE_H__
+#define __LIBELF_PRIVATE_H_
+
 #ifdef __XEN__
 
+#include <xen/config.h>
+#include <xen/types.h>
 #include <xen/string.h>
 #include <xen/lib.h>
+#include <asm/byteorder.h>
 #include <public/elfnote.h>
 #include <public/libelf.h>
 
@@ -11,29 +17,25 @@
        printk(fmt, ## args )
 
 #define strtoull(str, end, base) simple_strtoull(str, end, base)
-#define bswap_16(x) \
-     ((((x) >> 8) & 0xff) | (((x) & 0xff) << 8))
-#define bswap_32(x) \
-     (  (((x) & 0xff000000) >> 24)  \
-      | (((x) & 0x00ff0000) >>  8)  \
-      | (((x) & 0x0000ff00) <<  8)  \
-      | (((x) & 0x000000ff) << 24))
-#define bswap_64(x) \
-     (  (((x) & 0xff00000000000000ull) >> 56)  \
-      | (((x) & 0x00ff000000000000ull) >> 40)  \
-      | (((x) & 0x0000ff0000000000ull) >> 24)  \
-      | (((x) & 0x000000ff00000000ull) >> 8)   \
-      | (((x) & 0x00000000ff000000ull) << 8)   \
-      | (((x) & 0x0000000000ff0000ull) << 24)  \
-      | (((x) & 0x000000000000ff00ull) << 40)  \
-      | (((x) & 0x00000000000000ffull) << 56))
+#define bswap_16(x) swab16(x)
+#define bswap_32(x) swab32(x)
+#define bswap_64(x) swab64(x)
 
 #else /* !__XEN__ */
 
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <stddef.h>
+#include <inttypes.h>
+#ifdef __sun__
+#include <sys/byteorder.h>
+#define bswap_16(x) BSWAP_16(x)
+#define bswap_32(x) BSWAP_32(x)
+#define bswap_64(x) BSWAP_64(x)
+#else
 #include <byteswap.h>
+#endif
 #include <xen/elfnote.h>
 #include <xen/libelf.h>
 
@@ -49,3 +51,5 @@
        } while (0)
 
 #endif
+
+#endif /* __LIBELF_PRIVATE_H_ */
diff -r bef8a8b1e400 -r f8ddcb758117 xen/common/libelf/libelf-tools.c
--- a/xen/common/libelf/libelf-tools.c  Sun Jan 28 18:45:04 2007 +0000
+++ b/xen/common/libelf/libelf-tools.c  Sun Jan 28 19:02:00 2007 +0000
@@ -7,7 +7,7 @@
 /* ------------------------------------------------------------------------ */
 
 uint64_t elf_access_unsigned(struct elf_binary * elf, const void *ptr,
-                            off_t offset, size_t size)
+                            uint64_t offset, size_t size)
 {
     int need_swap = elf_swap(elf);
     const uint8_t *u8;
@@ -35,7 +35,7 @@ uint64_t elf_access_unsigned(struct elf_
 }
 
 int64_t elf_access_signed(struct elf_binary *elf, const void *ptr,
-                         off_t offset, size_t size)
+                         uint64_t offset, size_t size)
 {
     int need_swap = elf_swap(elf);
     const int8_t *s8;
diff -r bef8a8b1e400 -r f8ddcb758117 xen/include/public/libelf.h
--- a/xen/include/public/libelf.h       Sun Jan 28 18:45:04 2007 +0000
+++ b/xen/include/public/libelf.h       Sun Jan 28 19:02:00 2007 +0000
@@ -1,25 +1,12 @@
 #ifndef __XC_LIBELF__
 #define __XC_LIBELF__ 1
 
-#ifdef __XEN__
-
-#include <xen/inttypes.h>
-#include <public/features.h>
-typedef uint64_t off_t;
-
-#define LITTLE_ENDIAN 1234
-#define BIG_ENDIAN    4321
 #if defined(__i386__) || defined(__x86_64) || defined(__ia64__)
-#define BYTE_ORDER LITTLE_ENDIAN
+#define XEN_ELF_LITTLE_ENDIAN
 #elif defined(__powerpc__)
-#define BYTE_ORDER BIG_ENDIAN
-#endif
-
-#else /* !__XEN__ */
-
-#include <stddef.h>
-#include <inttypes.h>
-
+#define XEN_ELF_BIG_ENDIAN
+#else
+#error define architectural endianness
 #endif
 
 #undef ELFSIZE
@@ -91,14 +78,10 @@ struct elf_binary {
 /* ------------------------------------------------------------------------ */
 /* accessing elf header fields                                              */
 
-#if !defined(BYTE_ORDER)
-# error BYTE_ORDER not defined
-#elif BYTE_ORDER == BIG_ENDIAN
+#ifdef XEN_ELF_BIG_ENDIAN
 # define NATIVE_ELFDATA ELFDATA2MSB
-#elif BYTE_ORDER == LITTLE_ENDIAN
+#else
 # define NATIVE_ELFDATA ELFDATA2LSB
-#else
-# error BYTE_ORDER unknown
 #endif
 
 #define elf_32bit(elf) (ELFCLASS32 == (elf)->class)
@@ -131,9 +114,9 @@ struct elf_binary {
        : sizeof((str)->e32))
 
 uint64_t elf_access_unsigned(struct elf_binary *elf, const void *ptr,
-                            off_t offset, size_t size);
+                            uint64_t offset, size_t size);
 int64_t elf_access_signed(struct elf_binary *elf, const void *ptr,
-                         off_t offset, size_t size);
+                         uint64_t offset, size_t size);
 
 uint64_t elf_round_up(struct elf_binary *elf, uint64_t addr);
 

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] Clean up libelf endian macros and includes., Xen patchbot-unstable <=