Hi Jukka,

> These come from kernel include/linux/unalignment directory.
> ---
>  Makefile.am                       |  7 ++-
>  include/unaligned.h               | 54 +++++++++++++++++++++++
>  include/unaligned_be_byteshift.h  | 90 
> +++++++++++++++++++++++++++++++++++++++
>  include/unaligned_be_struct.h     | 58 +++++++++++++++++++++++++
>  include/unaligned_generic.h       | 90 
> +++++++++++++++++++++++++++++++++++++++
>  include/unaligned_le_byteshift.h  | 90 
> +++++++++++++++++++++++++++++++++++++++
>  include/unaligned_le_struct.h     | 58 +++++++++++++++++++++++++
>  include/unaligned_packed_struct.h | 66 ++++++++++++++++++++++++++++
>  8 files changed, 512 insertions(+), 1 deletion(-)
>  create mode 100644 include/unaligned.h
>  create mode 100644 include/unaligned_be_byteshift.h
>  create mode 100644 include/unaligned_be_struct.h
>  create mode 100644 include/unaligned_generic.h
>  create mode 100644 include/unaligned_le_byteshift.h
>  create mode 100644 include/unaligned_le_struct.h
>  create mode 100644 include/unaligned_packed_struct.h
> 
> diff --git a/Makefile.am b/Makefile.am
> index 31a42e4..5afa6a2 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -8,7 +8,12 @@ include_HEADERS = include/types.h include/log.h 
> include/plugin.h \
>                       include/resolver.h include/ipconfig.h \
>                       include/device.h include/network.h include/inet.h \
>                       include/storage.h include/provision.h \
> -                     include/session.h
> +                     include/session.h include/unaligned.h \
> +                     include/unaligned_be_byteshift.h \
> +                     include/unaligned_be_struct.h \
> +                     include/unaligned_generic.h \
> +                     include/unaligned_le_struct.h \
> +                     include/unaligned_packed_struct.h
>  
>  nodist_include_HEADERS = include/version.h
>  
> diff --git a/include/unaligned.h b/include/unaligned.h
> new file mode 100644
> index 0000000..ca8edc2
> --- /dev/null
> +++ b/include/unaligned.h
> @@ -0,0 +1,54 @@
> +/*
> + *
> + *  Connection Manager
> + *
> + *  The unaligned routines copied from linux kernel sources in
> + *  include/linux/unaligned directory.
> + *
> + *  This program is free software; you can redistribute it and/or modify
> + *  it under the terms of the GNU General Public License version 2 as
> + *  published by the Free Software Foundation.
> + *
> + *  This program is distributed in the hope that it will be useful,
> + *  but WITHOUT ANY WARRANTY; without even the implied warranty of
> + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + *  GNU General Public License for more details.
> + *
> + *  You should have received a copy of the GNU General Public License
> + *  along with this program; if not, write to the Free Software
> + *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  
> USA
> + *
> + */
> +
> +#ifndef __CONNMAN_UNALIGNED_H
> +#define __CONNMAN_UNALIGNED_H
> +
> +#include <stdint.h>
> +
> +typedef uint8_t  u8;
> +typedef uint16_t u16;
> +typedef uint32_t u32;
> +typedef uint64_t u64;

this is not making it better. It is actually worse :(

> +
> +/*
> + * This is the most generic implementation of unaligned accesses
> + * and should work almost anywhere.
> + */
> +
> +#if defined(__LITTLE_ENDIAN)
> +# include <connman/unaligned_le_struct.h>
> +# include <connman/unaligned_be_byteshift.h>
> +# include <connman/unaligned_generic.h>
> +# define get_unaligned       __get_unaligned_le
> +# define put_unaligned       __put_unaligned_le
> +#elif defined(__BIG_ENDIAN)
> +# include <connman/unaligned_be_struct.h>
> +# include <connman/unaligned_le_byteshift.h>
> +# include <connman/unaligned_generic.h>
> +# define get_unaligned       __get_unaligned_be
> +# define put_unaligned       __put_unaligned_be
> +#else
> +# error need to define endianess
> +#endif

Please look at the macros we use in BlueZ. They are a bit more generic.

Regards

Marcel


_______________________________________________
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman

Reply via email to