[Olsr-dev] [PATCH v1 1/2] android: fix type punning warnings on IN6_IS_ADDR_V4MAPPED

Ferry Huberts (spam-protected)
Mon Oct 22 10:59:56 CEST 2012



On 19-10-12 18:12, Hans-Christoph Steiner wrote:
>
> Android is not GNU and its not UNIX, so including a header from GNU seems like
> a bad idea.  Android does not use GNU libc nor does it use BSD libc.  It uses
> bionic libc.  Yes, Android uses the Linux kernel, but these headers are not
> from the Linux kernel, they are related to libc.
>
> I think we'll have to do something ugly anyhow, unfortunately.  Maybe for
> android, the v6 part of p->prefix.v6 will need to be defined the same way that
> its done in the Android in6.h header and wrapped in a #ifdef __ANDROID__ #else
>

I see no problem in doing it this way.
However, if you want it different, then can you please show us that 
change/patch?

We're almost at the point of zero warnings after we fix this one, so why 
stop now?


> .hc
>
> On 10/19/2012 12:05 PM, Ferry Huberts wrote:
>> From: Ferry Huberts <(spam-protected)>
>>
>> Signed-off-by: Ferry Huberts <(spam-protected)>
>> ---
>>   android/linux/olsr_netinet_in.h | 52 +++++++++++++++++++++++++++++++++++++++++
>>   src/ipcalc.h                    |  4 ++++
>>   2 files changed, 56 insertions(+)
>>   create mode 100644 android/linux/olsr_netinet_in.h
>>
>> diff --git a/android/linux/olsr_netinet_in.h b/android/linux/olsr_netinet_in.h
>> new file mode 100644
>> index 0000000..7500c80
>> --- /dev/null
>> +++ b/android/linux/olsr_netinet_in.h
>> @@ -0,0 +1,52 @@
>> +/* Copyright (C) 1991-2001, 2003, 2004, 2006, 2007, 2008, 2011
>> +   Free Software Foundation, Inc.
>> +   This file is part of the GNU C Library.
>> +
>> +   The GNU C Library is free software; you can redistribute it and/or
>> +   modify it under the terms of the GNU Lesser General Public
>> +   License as published by the Free Software Foundation; either
>> +   version 2.1 of the License, or (at your option) any later version.
>> +
>> +   The GNU C Library 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
>> +   Lesser General Public License for more details.
>> +
>> +   You should have received a copy of the GNU Lesser General Public
>> +   License along with the GNU C Library; if not, write to the Free
>> +   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
>> +   02111-1307 USA.
>> +
>> +
>> +   This is a stripped copy of netinet/in.h that includes only the
>> +   IN6_IS_ADDR_V4MAPPED define. It is used to fix warnings on the
>> +   Android build.
>> +*/
>> +
>> +#ifndef	_OLSR_NETINET_IN_H
>> +#define	_OLSR_NETINET_IN_H	1
>> +
>> +#ifdef IN6_IS_ADDR_V4MAPPED
>> +  #undef IN6_IS_ADDR_V4MAPPED
>> +#endif
>> +
>> +
>> +#ifdef __GNUC__
>> +
>> +# define IN6_IS_ADDR_V4MAPPED(a) \
>> +  (__extension__							      \
>> +   ({ __const struct in6_addr *__a = (__const struct in6_addr *) (a);	      \
>> +      __a->s6_addr32[0] == 0						      \
>> +      && __a->s6_addr32[1] == 0						      \
>> +      && __a->s6_addr32[2] == htonl (0xffff); }))
>> +
>> +#else
>> +
>> +# define IN6_IS_ADDR_V4MAPPED(a) \
>> +	((((__const uint32_t *) (a))[0] == 0)				      \
>> +	 && (((__const uint32_t *) (a))[1] == 0)			      \
>> +	 && (((__const uint32_t *) (a))[2] == htonl (0xffff)))
>> +
>> +#endif
>> +
>> +#endif	/* _OLSR_NETINET_IN_H */
>> diff --git a/src/ipcalc.h b/src/ipcalc.h
>> index 30b8068..4dde3f4 100644
>> --- a/src/ipcalc.h
>> +++ b/src/ipcalc.h
>> @@ -49,6 +49,10 @@
>>   #include <arpa/inet.h>
>>   #include <netinet/in.h>
>>
>> +#ifdef __ANDROID__
>> +  #include <linux/olsr_netinet_in.h>
>> +#endif
>> +
>>   extern const struct olsr_ip_prefix ipv4_internet_route;
>>   extern const struct olsr_ip_prefix ipv6_mappedv4_route;
>>   extern const struct olsr_ip_prefix ipv6_internet_route;
>>

-- 
Ferry Huberts




More information about the Olsr-dev mailing list