[PATCH] <asm/byteorder.h> missing prototypes warning

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH] <asm/byteorder.h> missing prototypes warning

Yaakov (Cygwin/X)
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

This is similar in concept to the <stdio.h> patch I just posted to
newlib@.  It looks like I mistakenly removed the prototypes when I was
trying to fix the C99 inline issue in <asm/byteorder.h>.

Since this makes four lines which need the C99 inline workaround, I
decided to make a macro similar to that in <stdio.h>.  I didn't use the
same macro name, since I didn't want to deal with a possible collision
with, or dependency on, <stdio.h>.  Perhaps there is a better way of
dealing with this; I'm certainly open to ideas.

Patch attached.


Yaakov

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEAREIAAYFAknVfjsACgkQpiWmPGlmQSPH/gCgoxK1UgezIcUwFH3EHc0+rHRB
C14AnRZ2yQhc6uwvJbcQ98hUSxnxP38X
=8YGC
-----END PGP SIGNATURE-----

2009-04-02  Yaakov Selkowitz  <[hidden email]>

        * include/asm/byteorder.h (__ntohl, __ntohs): Prototype before
        define to avoid a warning with -Wmissing-prototypes.

Index: cygwin/include/asm/byteorder.h
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/include/asm/byteorder.h,v
retrieving revision 1.11
diff -u -r1.11 byteorder.h
--- include/asm/byteorder.h 26 Mar 2009 10:40:29 -0000 1.11
+++ include/asm/byteorder.h 3 Apr 2009 01:48:34 -0000
@@ -31,9 +31,15 @@
 extern uint16_t htons(uint16_t);
 
 #if defined(__GNUC__) && !defined(__GNUC_STDC_INLINE__)
-extern
+#define __ASM_BYTEORDER_INLINE extern __inline__
+#else
+#define __ASM_BYTEORDER_INLINE __inline__
 #endif
-__inline__ uint32_t
+
+__ASM_BYTEORDER_INLINE uint32_t __ntohl(uint32_t x);
+__ASM_BYTEORDER_INLINE uint16_t __ntohs(uint16_t x);
+
+__ASM_BYTEORDER_INLINE uint32_t
 __ntohl(uint32_t x)
 {
  __asm__("xchgb %b0,%h0\n\t" /* swap lower bytes */
@@ -50,10 +56,7 @@
    (((uint32_t)(x) & 0x00ff0000U) >>  8) | \
    (((uint32_t)(x) & 0xff000000U) >> 24)))
 
-#if defined(__GNUC__) && !defined(__GNUC_STDC_INLINE__)
-extern
-#endif
-__inline__ uint16_t
+__ASM_BYTEORDER_INLINE uint16_t
 __ntohs(uint16_t x)
 {
  __asm__("xchgb %b0,%h0" /* swap bytes */
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] <asm/byteorder.h> missing prototypes warning

Dave Korn-6
Yaakov (Cygwin/X) wrote:

> This is similar in concept to the <stdio.h> patch I just posted to
> newlib@.  It looks like I mistakenly removed the prototypes when I was
> trying to fix the C99 inline issue in <asm/byteorder.h>.
>
> Since this makes four lines which need the C99 inline workaround, I
> decided to make a macro similar to that in <stdio.h>.  I didn't use the
> same macro name, since I didn't want to deal with a possible collision
> with, or dependency on, <stdio.h>.  Perhaps there is a better way of
> dealing with this; I'm certainly open to ideas.

  I'll suggest upstream that since this macro trick is going to spread
increasingly to more and more header files, maybe we should actually provide a
predefined preprocessor macro for it.  If it's acceptable, I'll backport
support to the cygwin distro version.

  Maybe we can call it __extern__ (so it looks like a c99-compatible extension
keyword and doesn't cause problems for non-GCC compilers) and define it as
"'extern' if !__GNUC_STDC_INLINE__".  That might work well.

    cheers,
      DaveK


Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] <asm/byteorder.h> missing prototypes warning

Dave Korn-6
Dave Korn wrote:

>   Maybe we can call it __extern__ (so it looks like a c99-compatible extension
> keyword and doesn't cause problems for non-GCC compilers)

  ENOCOFFEE.  That's not a c99 extension, it's a gcc extension.  Dur me!

    cheers,
      DaveK
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] <asm/byteorder.h> missing prototypes warning

Corinna Vinschen-2
On Apr  3 09:15, Dave Korn wrote:
> Dave Korn wrote:
>
> >   Maybe we can call it __extern__ (so it looks like a c99-compatible extension
> > keyword and doesn't cause problems for non-GCC compilers)
>
>   ENOCOFFEE.  That's not a c99 extension, it's a gcc extension.  Dur me!

Who on earth decided that a redundant declaration of an inline function
is necessary to avoid a useless warning?


Corinna

--
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] <asm/byteorder.h> missing prototypes warning

Corinna Vinschen-2
In reply to this post by Yaakov (Cygwin/X)
On Apr  2 22:11, Yaakov S wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA256
>
> This is similar in concept to the <stdio.h> patch I just posted to
> newlib@.  It looks like I mistakenly removed the prototypes when I was
> trying to fix the C99 inline issue in <asm/byteorder.h>.
>
> Since this makes four lines which need the C99 inline workaround, I
> decided to make a macro similar to that in <stdio.h>.  I didn't use the
> same macro name, since I didn't want to deal with a possible collision
> with, or dependency on, <stdio.h>.  Perhaps there is a better way of
> dealing with this; I'm certainly open to ideas.
>
> Patch attached.

Wouldn't it be better to move newlib's _ELIDABLE_INLINE definition to
some nicely matchin header like _ansi.h and then use it wherever it
fits?


Corinna

--
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] <asm/byteorder.h> missing prototypes warning

Dave Korn-6
Corinna Vinschen wrote:

> Wouldn't it be better to move newlib's _ELIDABLE_INLINE definition to
> some nicely matchin header like _ansi.h and then use it wherever it
> fits?

  I think you're right.  Can one of you two please take care of it?  I've got
a bit of a load on right now what with gcc back in stage1.

    cheers,
      DaveK
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] <asm/byteorder.h> missing prototypes warning

Yaakov (Cygwin/X)
In reply to this post by Corinna Vinschen-2
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Corinna Vinschen wrote:
> Wouldn't it be better to move newlib's _ELIDABLE_INLINE definition to
> some nicely matchin header like _ansi.h and then use it wherever it
> fits?

As I said, perhaps there is a better way of dealing with this.  The main
reason I didn't go for that solution in the first place is that I didn't
find other newlib/cygwin headers that would require this.  If there are
indeed more, then centralizing this makes perfect sense.


Yaakov
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEAREIAAYFAknWNGcACgkQpiWmPGlmQSNATgCfQyBuNQ4mMjGfpY6/nb6W1V28
vkwAn0Uo0xSKwmAhK5vRcax6UTdTz+Wo
=7UOD
-----END PGP SIGNATURE-----
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] <asm/byteorder.h> missing prototypes warning

Corinna Vinschen-2
On Apr  3 11:08, Yaakov S wrote:
> Corinna Vinschen wrote:
> > Wouldn't it be better to move newlib's _ELIDABLE_INLINE definition to
> > some nicely matchin header like _ansi.h and then use it wherever it
> > fits?
>
> As I said, perhaps there is a better way of dealing with this.  The main
> reason I didn't go for that solution in the first place is that I didn't
> find other newlib/cygwin headers that would require this.  If there are
> indeed more, then centralizing this makes perfect sense.

I've applied this patch using the _ELIDABLE_INLINE macro.


Thanks,
Corinna

--
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat