All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Christoph Egger" <Christoph.Egger@amd.com>
To: Keir Fraser <Keir.Fraser@cl.cam.ac.uk>
Cc: xen-devel@lists.xensource.com
Subject: Re: [PATCH 3/3] Add support for OpenBSD
Date: Wed, 18 Oct 2006 10:55:57 +0200	[thread overview]
Message-ID: <200610181055.58035.Christoph.Egger@amd.com> (raw)
In-Reply-To: <C15CED1F.2C05%Keir.Fraser@cl.cam.ac.uk>

On Thursday 19 October 2006 09:51, Keir Fraser wrote:
> On 18/10/06 8:08 am, "Christoph Egger" <Christoph.Egger@amd.com> wrote:
> > /usr/include/sys/endian.h:156:1: this is the location of the previous
> > definition
> > boot/mkelf32.c:94:1: "swap32" redefined
> > /usr/include/sys/endian.h:157:1: this is the location of the previous
> > definition
> > boot/mkelf32.c:95:1: "swap64" redefined
> > /usr/include/sys/endian.h:158:1: this is the location of the previous
> > definition
>
> Is there a standard definition for these functions (i.e., can we be *sure*
> the original definitions have the same semantics as our own)? If not, which
> I think is the case, we're better off #undef'ing the old definitions.

This is the snippet of /usr/include/endian.h:

-----------------------------------------------------------------------------------
#ifdef __GNUC__

#define __swap16gen(x) __statement({                                    \
        __uint16_t __swap16gen_x = (x);                                 \
                                                                        \
        (__uint16_t)((__swap16gen_x & 0xff) << 8 |                      \
            (__swap16gen_x & 0xff00) >> 8);                             \
})

#define __swap32gen(x) __statement({                                    \
        __uint32_t __swap32gen_x = (x);                                 \
                                                                        \
        (__uint32_t)((__swap32gen_x & 0xff) << 24 |                     \
            (__swap32gen_x & 0xff00) << 8 |                             \
            (__swap32gen_x & 0xff0000) >> 8 |                           \
            (__swap32gen_x & 0xff000000) >> 24);                        \
})

#define __swap64gen(x) __statement({                                    \
        __uint64_t __swap64gen_x = (x);                                 \
                                                                        \
        (__uint64_t)((__swap64gen_x & 0xff) << 56 |                     \
            (__swap64gen_x & 0xff00ULL) << 40 |                         \
            (__swap64gen_x & 0xff0000ULL) << 24 |                       \
            (__swap64gen_x & 0xff000000ULL) << 8 |                      \
            (__swap64gen_x & 0xff00000000ULL) >> 8 |                    \
            (__swap64gen_x & 0xff0000000000ULL) >> 24 |                 \
            (__swap64gen_x & 0xff000000000000ULL) >> 40 |               \
            (__swap64gen_x & 0xff00000000000000ULL) >> 56);             \
})

#else /* __GNUC__ */

/* Note that these macros evaluate their arguments several times.  */
#define __swap16gen(x)                                                  \
    (__uint16_t)(((__uint16_t)(x) & 0xffU) << 8 | ((__uint16_t)(x) & 0xff00U) 
>> 8)

#define __swap32gen(x)                                                  \
    (__uint32_t)(((__uint32_t)(x) & 0xff) << 24 |                       \
    ((__uint32_t)(x) & 0xff00) << 8 | ((__uint32_t)(x) & 0xff0000) >> 8 |\
    ((__uint32_t)(x) & 0xff000000) >> 24)

#define __swap64gen(x)                                                  \
        (__uint64_t)((((__uint64_t)(x) & 0xff) << 56) |                 \
            ((__uint64_t)(x) & 0xff00ULL) << 40 |                       \
            ((__uint64_t)(x) & 0xff0000ULL) << 24 |                     \
            ((__uint64_t)(x) & 0xff000000ULL) << 8 |                    \
            ((__uint64_t)(x) & 0xff00000000ULL) >> 8 |                  \
            ((__uint64_t)(x) & 0xff0000000000ULL) >> 24 |               \
            ((__uint64_t)(x) & 0xff000000000000ULL) >> 40 |             \
            ((__uint64_t)(x) & 0xff00000000000000ULL) >> 56)

#endif /* __GNUC__ */
-----------------------------------------------------------------------------------

  reply	other threads:[~2006-10-18  8:55 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-17 14:44 [PATCH 3/3] Add support for OpenBSD Christoph Egger
2006-10-18 15:51 ` Keir Fraser
2006-10-18  7:08   ` Christoph Egger
2006-10-19  7:51     ` Keir Fraser
2006-10-18  8:55       ` Christoph Egger [this message]
2006-10-19 11:23         ` Keir Fraser
2006-10-19 14:21           ` Christoph Egger

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=200610181055.58035.Christoph.Egger@amd.com \
    --to=christoph.egger@amd.com \
    --cc=Keir.Fraser@cl.cam.ac.uk \
    --cc=xen-devel@lists.xensource.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.