Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 17 Jun 2003 09:53:17 -0600
From:      Greg Lewis <glewis@misty.eyesbeyond.com>
To:        freebsd-hackers@freebsd.org
Cc:        Munehiro Matsuda <haro@h4.dion.ne.jp>
Subject:   Broken <sys/endian.h> in 5.1R and -current
Message-ID:  <20030617155317.GA86754@misty.eyesbeyond.com>

next in thread | raw e-mail | index | archive | help

--Qxx1br4bt0+wmkIi
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

Hi all,

While moving from its own internal endian defines to using <sys/endian.h>
the JDK 1.3.1 code has become broken on both 5.1R and -current.  The
problem is that C++ code that includes <sys/endian.h> (whether wrapped
in extern "C" { } or not) fails during compilation with errors such as:

In file included from ../../../src/share/native/sun/awt/font/FontWrapper.cpp:21:
/usr/include/sys/endian.h: In function `uint16_t be16dec(const void*)':
/usr/include/sys/endian.h:97: invalid conversion from `const void*' to `const 
   unsigned char*'
/usr/include/sys/endian.h: In function `uint32_t be32dec(const void*)':
/usr/include/sys/endian.h:105: invalid conversion from `const void*' to `const 
   unsigned char*'
/usr/include/sys/endian.h: In function `uint64_t be64dec(const void*)':
/usr/include/sys/endian.h:113: invalid conversion from `const void*' to `const 
   unsigned char*'
[...]
gmake[3]: *** [../../../build/bsd-i386/tmp/sun/sun.awt.font/fontmanager/obj/FontWrapper.o] Error 1

The developer who noticed this problem (Munehiro Matsuda - cc'ed) submitted
the attached patch which simply casts the function arguments to the
appropriate type.

Can someone please commit this, approve me to commit it (my commit bit
is docs and ports :) or suggest an alternative?  Thanks.

A bump of __FreeBSD_version would be great too, since then we could
detect this and work around it, however I'm not sure this meets the
criteria for such a bump.

-- 
Greg Lewis                          Email   : glewis@eyesbeyond.com
Eyes Beyond                         Web     : http://www.eyesbeyond.com
Information Technology              FreeBSD : glewis@FreeBSD.org


--Qxx1br4bt0+wmkIi
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="patch-sys-endian.h"

--- src/sys/sys/endian.h.ctm	Fri Apr  4 00:48:59 2003
+++ src/sys/sys/endian.h	Sun Jun 15 02:20:24 2003
@@ -94,7 +94,7 @@
 static __inline uint16_t
 be16dec(const void *pp)
 {
-	unsigned char const *p = pp;
+	unsigned char const *p = (unsigned char const *)pp;
 
 	return ((p[0] << 8) | p[1]);
 }
@@ -102,7 +102,7 @@
 static __inline uint32_t
 be32dec(const void *pp)
 {
-	unsigned char const *p = pp;
+	unsigned char const *p = (unsigned char const *)pp;
 
 	return ((p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]);
 }
@@ -110,7 +110,7 @@
 static __inline uint64_t
 be64dec(const void *pp)
 {
-	unsigned char const *p = pp;
+	unsigned char const *p = (unsigned char const *)pp;
 
 	return (((uint64_t)be32dec(p) << 32) | be32dec(p + 4));
 }
@@ -118,7 +118,7 @@
 static __inline uint16_t
 le16dec(const void *pp)
 {
-	unsigned char const *p = pp;
+	unsigned char const *p = (unsigned char const *)pp;
 
 	return ((p[1] << 8) | p[0]);
 }
@@ -126,7 +126,7 @@
 static __inline uint32_t
 le32dec(const void *pp)
 {
-	unsigned char const *p = pp;
+	unsigned char const *p = (unsigned char const *)pp;
 
 	return ((p[3] << 24) | (p[2] << 16) | (p[1] << 8) | p[0]);
 }
@@ -134,7 +134,7 @@
 static __inline uint64_t
 le64dec(const void *pp)
 {
-	unsigned char const *p = pp;
+	unsigned char const *p = (unsigned char const *)pp;
 
 	return (((uint64_t)le32dec(p + 4) << 32) | le32dec(p));
 }
@@ -142,7 +142,7 @@
 static __inline void
 be16enc(void *pp, uint16_t u)
 {
-	unsigned char *p = pp;
+	unsigned char *p = (unsigned char *)pp;
 
 	p[0] = (u >> 8) & 0xff;
 	p[1] = u & 0xff;
@@ -151,7 +151,7 @@
 static __inline void
 be32enc(void *pp, uint32_t u)
 {
-	unsigned char *p = pp;
+	unsigned char *p = (unsigned char *)pp;
 
 	p[0] = (u >> 24) & 0xff;
 	p[1] = (u >> 16) & 0xff;
@@ -162,7 +162,7 @@
 static __inline void
 be64enc(void *pp, uint64_t u)
 {
-	unsigned char *p = pp;
+	unsigned char *p = (unsigned char *)pp;
 
 	be32enc(p, u >> 32);
 	be32enc(p + 4, u & 0xffffffff);
@@ -171,7 +171,7 @@
 static __inline void
 le16enc(void *pp, uint16_t u)
 {
-	unsigned char *p = pp;
+	unsigned char *p = (unsigned char *)pp;
 
 	p[0] = u & 0xff;
 	p[1] = (u >> 8) & 0xff;
@@ -180,7 +180,7 @@
 static __inline void
 le32enc(void *pp, uint32_t u)
 {
-	unsigned char *p = pp;
+	unsigned char *p = (unsigned char *)pp;
 
 	p[0] = u & 0xff;
 	p[1] = (u >> 8) & 0xff;
@@ -191,7 +191,7 @@
 static __inline void
 le64enc(void *pp, uint64_t u)
 {
-	unsigned char *p = pp;
+	unsigned char *p = (unsigned char *)pp;
 
 	le32enc(p, u & 0xffffffff);
 	le32enc(p + 4, u >> 32);

--Qxx1br4bt0+wmkIi--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030617155317.GA86754>