[Skiboot] [RFC] Add support for glibc style endianess detection
Benjamin Herrenschmidt
benh at kernel.crashing.org
Thu May 4 07:56:20 AEST 2017
On Thu, 2017-05-04 at 01:37 +0530, Akshay Adiga wrote:
> CCAN defines HAVE_LITTLE_ENDIAN or HAVE_BIG_ENDIAN to endianess of the
> system and code developed on top of glibc expect __BYTE_ORDER to
> tell the endianess.
>
> Suggested-by: Benjamin Herrenschmidt <benh at kernel.crashing.org>
> Signed-off-by: Akshay Adiga <akshay.adiga at linux.vnet.ibm.com>
> ---
> Other attempt:
> 1) when named as include/endian.h, conflicted with host include
> files (gcov build failed).
I'd rather we fix the host include problem by using the proper
guards in that file for example if we can and call it "endian.h"
>
> include/glibc_endian.h | 36 ++++++++++++++++++++++++++++++++++++
> include/skiboot.h | 2 +-
> 2 files changed, 37 insertions(+), 1 deletion(-)
> create mode 100644 include/glibc_endian.h
>
> diff --git a/include/glibc_endian.h b/include/glibc_endian.h
> new file mode 100644
> index 0000000..8b1ce5f
> --- /dev/null
> +++ b/include/glibc_endian.h
> @@ -0,0 +1,36 @@
> +/* Copyright 2013-2014 IBM Corp.
> + *
> + * Licensed under the Apache License, Version 2.0 (the "License");
> + * you may not use this file except in compliance with the License.
> + * You may obtain a copy of the License at
> + *
> + * http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing, software
> + * distributed under the License is distributed on an "AS IS" BASIS,
> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> + * implied.
> + * See the License for the specific language governing permissions and
> + * limitations under the License.
> + */
> +
> +#ifndef GLIBC_ENDIAN_H
> +#define GLIBC_ENDIAN_H
> +
> +#include <ccan/endian/endian.h>
> +
> +/*
> + * CCAN does not export __BYTE_ORDER hence copying definitions from
> + * glibc
> + */
> +#define __LITTLE_ENDIAN 1234
> +#define __BIG_ENDIAN 4321
> +#ifdef HAVE_LITTLE_ENDIAN
> + #define __BYTE_ORDER __LITTLE_ENDIAN
> +#elif HAVE_BIG_ENDIAN
> + #define __BYTE_ORDER __BIG_ENDIAN
> +#else
> + #error
> +#endif
> +#endif
> +
> diff --git a/include/skiboot.h b/include/skiboot.h
> index 5c8b0c8..519c5fe 100644
> --- a/include/skiboot.h
> +++ b/include/skiboot.h
> @@ -27,13 +27,13 @@
> #include <errno.h>
> #include <bitutils.h>
> #include <types.h>
> +#include <glibc_endian.h>
>
> #include <ccan/container_of/container_of.h>
> #include <ccan/list/list.h>
> #include <ccan/short_types/short_types.h>
> #include <ccan/build_assert/build_assert.h>
> #include <ccan/array_size/array_size.h>
> -#include <ccan/endian/endian.h>
> #include <ccan/str/str.h>
>
> #include <libflash/blocklevel.h>
More information about the Skiboot
mailing list