Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 20 Oct 2002 09:46:08 -0400
From:      Mike Barcroft <mike@FreeBSD.org>
To:        Kris Kennaway <kris@obsecurity.org>
Cc:        current@FreeBSD.org
Subject:   Re: Conflicting declarations for ffs()
Message-ID:  <20021020094608.F81582@espresso.q9media.com>
In-Reply-To: <20021020100158.GA18938@xor.obsecurity.org>; from kris@obsecurity.org on Sun, Oct 20, 2002 at 03:01:58AM -0700
References:  <20021020100158.GA18938@xor.obsecurity.org>

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

--tKW2IUtsqtDRztdT
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

Kris Kennaway <kris@obsecurity.org> writes:
> Take a look at:
> 
> http://bento.freebsd.org/errorlogs/5-full/cqcam-0.91_1.log
> 
> This port includes headers that declare the ffs() function twice: once
> with an inline version and once with a prototype.
> 
> Is the bug in the application, or the headers?

It looks like a bug in our headers.  I don't see why this is a new bug
though.  It looks like <string.h> (which <strings.h> used to include)
and i386's <machine/cpufunc.h> have been defining conflicting ffs()
prototypes since at least 1999.

Attached is an untested patch which should fix the problem.

Best regards,
Mike Barcroft

--tKW2IUtsqtDRztdT
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="ffs.diff"

Index: include/strings.h
===================================================================
RCS file: /work/repo/src/include/strings.h,v
retrieving revision 1.3
diff -u -r1.3 strings.h
--- include/strings.h	21 Aug 2002 16:19:55 -0000	1.3
+++ include/strings.h	20 Oct 2002 13:45:21 -0000
@@ -41,7 +41,10 @@
 int	 bcmp(const void *, const void *, size_t);	/* LEGACY */
 void	 bcopy(const void *, void *, size_t);		/* LEGACY */
 void	 bzero(void *, size_t);				/* LEGACY */
+#ifndef _FFS_DECLARED
+#define	_FFS_DECLARED
 int	 ffs(int);
+#endif
 char	*index(const char *, int);			/* LEGACY */
 char	*rindex(const char *, int);			/* LEGACY */
 int	 strcasecmp(const char *, const char *);
Index: sys/i386/include/cpufunc.h
===================================================================
RCS file: /work/repo/src/sys/i386/include/cpufunc.h,v
retrieving revision 1.130
diff -u -r1.130 cpufunc.h
--- sys/i386/include/cpufunc.h	22 Sep 2002 04:45:21 -0000	1.130
+++ sys/i386/include/cpufunc.h	20 Oct 2002 13:48:04 -0000
@@ -103,8 +103,9 @@
 	__asm __volatile("sti");
 }
 
+#ifndef _FFS_DECLARED
+#define	_FFS_DECLARED
 #define	HAVE_INLINE_FFS
-
 static __inline int
 ffs(int mask)
 {
@@ -116,6 +117,7 @@
 	 */
 	 return (mask == 0 ? mask : (int)bsfl((u_int)mask) + 1);
 }
+#endif
 
 #define	HAVE_INLINE_FLS
 
Index: sys/sparc64/include/cpufunc.h
===================================================================
RCS file: /work/repo/src/sys/sparc64/include/cpufunc.h,v
retrieving revision 1.14
diff -u -r1.14 cpufunc.h
--- sys/sparc64/include/cpufunc.h	1 Apr 2002 23:51:23 -0000	1.14
+++ sys/sparc64/include/cpufunc.h	20 Oct 2002 13:46:45 -0000
@@ -200,6 +200,8 @@
  * Ultrasparc II doesn't implement popc in hardware.  Suck.
  */
 #if 0
+#ifndef _FFS_DECLARED
+#define	_FFS_DECLARED
 #define	HAVE_INLINE_FFS
 /*
  * See page 202 of the SPARC v9 Architecture Manual.
@@ -219,6 +221,7 @@
 	: "=r" (result), "=r" (neg), "=r" (tmp) : "r" (mask));
 	return (result);
 }
+#endif
 #endif
 
 #undef LDNC_GEN

--tKW2IUtsqtDRztdT--

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




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