* [PATCH] Fix implicit declaration of inb/outb
@ 2008-06-02 23:20 Bernhard Walle
2008-06-03 1:43 ` Jamey Sharp
0 siblings, 1 reply; 5+ messages in thread
From: Bernhard Walle @ 2008-06-02 23:20 UTC (permalink / raw)
To: kexec; +Cc: Bernhard Walle
This patch fixes following compiler warning:
purgatory/arch/i386/console-x86.c:84: \
warning: implicit declaration of function `outb'
purgatory/arch/i386/console-x86.c:89: \
warning: implicit declaration of function `inb'
Found on x86_64. The problem did not happen with i386.
Fix tested on x86_64-suse-linux and i586-suse-linux.
Signed-off-by: Bernhard Walle <bwalle@suse.de>
---
purgatory/arch/i386/console-x86.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/purgatory/arch/i386/console-x86.c b/purgatory/arch/i386/console-x86.c
index 9773573..68f5daf 100644
--- a/purgatory/arch/i386/console-x86.c
+++ b/purgatory/arch/i386/console-x86.c
@@ -1,5 +1,5 @@
#include <stdint.h>
-#include <arch/io.h>
+#include <sys/io.h>
#include <purgatory.h>
/*
--
1.5.4.5
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] Fix implicit declaration of inb/outb
2008-06-02 23:20 [PATCH] Fix implicit declaration of inb/outb Bernhard Walle
@ 2008-06-03 1:43 ` Jamey Sharp
2008-06-03 7:33 ` Bernhard Walle
2008-06-03 7:36 ` Bernhard Walle
0 siblings, 2 replies; 5+ messages in thread
From: Jamey Sharp @ 2008-06-03 1:43 UTC (permalink / raw)
To: Bernhard Walle; +Cc: kexec
On Mon, Jun 2, 2008 at 4:20 PM, Bernhard Walle <bwalle@suse.de> wrote:
> --- a/purgatory/arch/i386/console-x86.c
> +++ b/purgatory/arch/i386/console-x86.c
> @@ -1,5 +1,5 @@
> #include <stdint.h>
> -#include <arch/io.h>
> +#include <sys/io.h>
> #include <purgatory.h>
Oh, dear--that doesn't work. I just submitted the opposite patch a few
weeks ago, because readw and writew are in arch/io.h but not sys/io.h.
Undoing that would break i386 again; details are in the commit
message.
Jamey
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] Fix implicit declaration of inb/outb
2008-06-03 1:43 ` Jamey Sharp
@ 2008-06-03 7:33 ` Bernhard Walle
2008-06-12 2:09 ` Simon Horman
2008-06-03 7:36 ` Bernhard Walle
1 sibling, 1 reply; 5+ messages in thread
From: Bernhard Walle @ 2008-06-03 7:33 UTC (permalink / raw)
To: kexec; +Cc: Bernhard Walle
This patch fixes following compiler warning:
purgatory/arch/i386/console-x86.c:84: \
warning: implicit declaration of function `outb'
purgatory/arch/i386/console-x86.c:89: \
warning: implicit declaration of function `inb'
Found on x86_64. The problem did not happen with i386.
Fix tested on x86_64-suse-linux and i586-suse-linux.
I also added __always_inline__ to make sure that the function gets always
inlined, regardless of optimisation compiler flags.
Signed-off-by: Bernhard Walle <bwalle@suse.de>
---
purgatory/arch/i386/include/arch/io.h | 42 ++++++++++++++++++++-----------
purgatory/arch/x86_64/include/arch/io.h | 40 +++--------------------------
2 files changed, 31 insertions(+), 51 deletions(-)
diff --git a/purgatory/arch/i386/include/arch/io.h b/purgatory/arch/i386/include/arch/io.h
index 13ad887..0a9430a 100644
--- a/purgatory/arch/i386/include/arch/io.h
+++ b/purgatory/arch/i386/include/arch/io.h
@@ -1,10 +1,11 @@
-#ifndef ARCH_IO_H
-#define ARCH_IO_H
+#ifndef ARCH_I386_IO_H
+#define ARCH_I386_IO_H
#include <stdint.h>
/* Helper functions for directly doing I/O */
-extern inline uint8_t inb(uint16_t port)
+static inline __attribute__((__always_inline__))
+uint8_t inb(uint16_t port)
{
uint8_t result;
@@ -15,7 +16,8 @@ extern inline uint8_t inb(uint16_t port)
return result;
}
-extern inline uint16_t inw(uint16_t port)
+static inline __attribute__((__always_inline__))
+uint16_t inw(uint16_t port)
{
uint16_t result;
@@ -26,7 +28,8 @@ extern inline uint16_t inw(uint16_t port)
return result;
}
-extern inline uint32_t inl(uint32_t port)
+static inline __attribute__((__always_inline__))
+uint32_t inl(uint32_t port)
{
uint32_t result;
@@ -37,7 +40,8 @@ extern inline uint32_t inl(uint32_t port)
return result;
}
-extern inline void outb (uint8_t value, uint16_t port)
+static inline __attribute__((__always_inline__))
+void outb (uint8_t value, uint16_t port)
{
__asm__ __volatile__ (
"outb %b0,%w1"
@@ -45,7 +49,8 @@ extern inline void outb (uint8_t value, uint16_t port)
:"a" (value), "Nd" (port));
}
-extern inline void outw (uint16_t value, uint16_t port)
+static inline __attribute__((__always_inline__))
+void outw (uint16_t value, uint16_t port)
{
__asm__ __volatile__ (
"outw %w0,%w1"
@@ -53,7 +58,8 @@ extern inline void outw (uint16_t value, uint16_t port)
:"a" (value), "Nd" (port));
}
-extern inline void outl (uint32_t value, uint16_t port)
+static inline __attribute__((__always_inline__))
+void outl (uint32_t value, uint16_t port)
{
__asm__ __volatile__ (
"outl %0,%w1"
@@ -69,30 +75,36 @@ extern inline void outl (uint32_t value, uint16_t port)
* memory location directly.
*/
-static inline unsigned char readb(const volatile void *addr)
+static inline __attribute__((__always_inline__))
+unsigned char readb(const volatile void *addr)
{
return *(volatile unsigned char *) addr;
}
-static inline unsigned short readw(const volatile void *addr)
+static inline __attribute__((__always_inline__))
+unsigned short readw(const volatile void *addr)
{
return *(volatile unsigned short *) addr;
}
-static inline unsigned int readl(const volatile void *addr)
+static inline __attribute__((__always_inline__))
+unsigned int readl(const volatile void *addr)
{
return *(volatile unsigned int *) addr;
}
-static inline void writeb(unsigned char b, volatile void *addr)
+static inline __attribute__((__always_inline__))
+void writeb(unsigned char b, volatile void *addr)
{
*(volatile unsigned char *) addr = b;
}
-static inline void writew(unsigned short b, volatile void *addr)
+static inline __attribute__((__always_inline__))
+void writew(unsigned short b, volatile void *addr)
{
*(volatile unsigned short *) addr = b;
}
-static inline void writel(unsigned int b, volatile void *addr)
+static inline __attribute__((__always_inline__))
+void writel(unsigned int b, volatile void *addr)
{
*(volatile unsigned int *) addr = b;
}
-#endif /* ARCH_IO_H */
+#endif /* ARCH_I386_IO_H */
diff --git a/purgatory/arch/x86_64/include/arch/io.h b/purgatory/arch/x86_64/include/arch/io.h
index dcd01bf..464cd14 100644
--- a/purgatory/arch/x86_64/include/arch/io.h
+++ b/purgatory/arch/x86_64/include/arch/io.h
@@ -1,39 +1,7 @@
-#ifndef ARCH_IO_H
-#define ARCH_IO_H
+#ifndef ARCH_X86_64_IO_H
+#define ARCH_X86_64_IO_H
#include <stdint.h>
+#include "../../../i386/include/arch/io.h"
-/*
- * readX/writeX() are used to access memory mapped devices. On some
- * architectures the memory mapped IO stuff needs to be accessed
- * differently. On the x86 architecture, we just read/write the
- * memory location directly.
- */
-
-static inline unsigned char readb(const volatile void *addr)
-{
- return *(volatile unsigned char *) addr;
-}
-static inline unsigned short readw(const volatile void *addr)
-{
- return *(volatile unsigned short *) addr;
-}
-static inline unsigned int readl(const volatile void *addr)
-{
- return *(volatile unsigned int *) addr;
-}
-
-static inline void writeb(unsigned char b, volatile void *addr)
-{
- *(volatile unsigned char *) addr = b;
-}
-static inline void writew(unsigned short b, volatile void *addr)
-{
- *(volatile unsigned short *) addr = b;
-}
-static inline void writel(unsigned int b, volatile void *addr)
-{
- *(volatile unsigned int *) addr = b;
-}
-
-#endif /* ARCH_IO_H */
+#endif /* ARCH_X86_64_IO_H */
--
1.5.4.5
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] Fix implicit declaration of inb/outb
2008-06-03 1:43 ` Jamey Sharp
2008-06-03 7:33 ` Bernhard Walle
@ 2008-06-03 7:36 ` Bernhard Walle
1 sibling, 0 replies; 5+ messages in thread
From: Bernhard Walle @ 2008-06-03 7:36 UTC (permalink / raw)
To: Jamey Sharp; +Cc: kexec
* Jamey Sharp [2008-06-02 18:43]:
>
> Oh, dear--that doesn't work.
Thanks for catching that issue. But it also means that it *didn't* work
on x86-64 because inb() needed to call a function (I don't think that
the compiler did inline something when it even didn't know the
prototype).
My next patch should address that issue by just using the same header
file for i386 and x86-64. No need for code duplication here. And I
think we should use __always_inline__ in that case (yes, it's GNU only
but I think we can afford that for kexec-tools) to make sure that the
inlining takes also place for -O0.'
Bernhard
--
Bernhard Walle, SUSE LINUX Products GmbH, Architecture Maintenance
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Fix implicit declaration of inb/outb
2008-06-03 7:33 ` Bernhard Walle
@ 2008-06-12 2:09 ` Simon Horman
0 siblings, 0 replies; 5+ messages in thread
From: Simon Horman @ 2008-06-12 2:09 UTC (permalink / raw)
To: Bernhard Walle; +Cc: kexec, Jamey Sharp
On Tue, Jun 03, 2008 at 09:33:57AM +0200, Bernhard Walle wrote:
> This patch fixes following compiler warning:
>
> purgatory/arch/i386/console-x86.c:84: \
> warning: implicit declaration of function `outb'
> purgatory/arch/i386/console-x86.c:89: \
> warning: implicit declaration of function `inb'
>
> Found on x86_64. The problem did not happen with i386.
> Fix tested on x86_64-suse-linux and i586-suse-linux.
>
> I also added __always_inline__ to make sure that the function gets always
> inlined, regardless of optimisation compiler flags.
Thanks, applied.
--
Horms
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2008-06-12 2:10 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-02 23:20 [PATCH] Fix implicit declaration of inb/outb Bernhard Walle
2008-06-03 1:43 ` Jamey Sharp
2008-06-03 7:33 ` Bernhard Walle
2008-06-12 2:09 ` Simon Horman
2008-06-03 7:36 ` Bernhard Walle
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox