* [Qemu-devel] [PATCH 0/2] bswap: Clean prototypes of st* functions
@ 2014-02-19 5:11 Stefan Weil
2014-02-19 5:11 ` [Qemu-devel] [PATCH 1/2] bswap: Modify prototype of stb_p (avoid type conversions) Stefan Weil
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: Stefan Weil @ 2014-02-19 5:11 UTC (permalink / raw)
To: qemu-trivial; +Cc: Laszlo Ersek, qemu-devel
These modifications avoid type conversions for non optimized code.
ld* function prototypes will follow later.
[PATCH 1/2] bswap: Modify prototype of stb_p (avoid type
[PATCH 2/2] bswap: Modify prototypes of st[wl]_{le,be}_p (avoid type
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Qemu-devel] [PATCH 1/2] bswap: Modify prototype of stb_p (avoid type conversions)
2014-02-19 5:11 [Qemu-devel] [PATCH 0/2] bswap: Clean prototypes of st* functions Stefan Weil
@ 2014-02-19 5:11 ` Stefan Weil
2014-02-19 5:11 ` [Qemu-devel] [PATCH 2/2] bswap: Modify prototypes of st[wl]_{le, be}_p " Stefan Weil
` (2 subsequent siblings)
3 siblings, 0 replies; 6+ messages in thread
From: Stefan Weil @ 2014-02-19 5:11 UTC (permalink / raw)
To: qemu-trivial; +Cc: Stefan Weil, Laszlo Ersek, qemu-devel
The function uses an uint8_t value, so show this in the function
prototype. Non-optimizing compilers will avoid unnecessary type
conversions from (u)int8_t to int and back to uint8_t when generating
calls of this inline function.
stw_p, stl_p and stq_p already use similar prototypes.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
---
include/qemu/bswap.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/qemu/bswap.h b/include/qemu/bswap.h
index 437b8e0..0cc11a5 100644
--- a/include/qemu/bswap.h
+++ b/include/qemu/bswap.h
@@ -228,7 +228,7 @@ static inline int ldsb_p(const void *ptr)
return *(int8_t *)ptr;
}
-static inline void stb_p(void *ptr, int v)
+static inline void stb_p(void *ptr, uint8_t v)
{
*(uint8_t *)ptr = v;
}
--
1.7.10.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [Qemu-devel] [PATCH 2/2] bswap: Modify prototypes of st[wl]_{le, be}_p (avoid type conversions)
2014-02-19 5:11 [Qemu-devel] [PATCH 0/2] bswap: Clean prototypes of st* functions Stefan Weil
2014-02-19 5:11 ` [Qemu-devel] [PATCH 1/2] bswap: Modify prototype of stb_p (avoid type conversions) Stefan Weil
@ 2014-02-19 5:11 ` Stefan Weil
2014-02-19 5:19 ` Stefan Weil
2014-02-19 10:16 ` [Qemu-devel] [PATCH 0/2] bswap: Clean prototypes of st* functions Laszlo Ersek
2014-02-22 12:06 ` [Qemu-devel] [Qemu-trivial] " Michael Tokarev
3 siblings, 1 reply; 6+ messages in thread
From: Stefan Weil @ 2014-02-19 5:11 UTC (permalink / raw)
To: qemu-trivial; +Cc: Stefan Weil, Laszlo Ersek, qemu-devel
The function use uint16_t or uint32_t values, so show this in the function
prototypes. Non-optimizing compilers will avoid unnecessary type
conversions when generating calls of these inline function.
stq_le_p, stq_be_p already use similar prototypes.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
---
include/qemu/bswap.h | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/include/qemu/bswap.h b/include/qemu/bswap.h
index 0cc11a5..0cb7c05 100644
--- a/include/qemu/bswap.h
+++ b/include/qemu/bswap.h
@@ -300,12 +300,12 @@ static inline uint64_t ldq_le_p(const void *ptr)
return le_bswap(ldq_p(ptr), 64);
}
-static inline void stw_le_p(void *ptr, int v)
+static inline void stw_le_p(void *ptr, uint16_t v)
{
stw_p(ptr, le_bswap(v, 16));
}
-static inline void stl_le_p(void *ptr, int v)
+static inline void stl_le_p(void *ptr, uint32_t v)
{
stl_p(ptr, le_bswap(v, 32));
}
@@ -365,12 +365,12 @@ static inline uint64_t ldq_be_p(const void *ptr)
return be_bswap(ldq_p(ptr), 64);
}
-static inline void stw_be_p(void *ptr, int v)
+static inline void stw_be_p(void *ptr, uint16_t v)
{
stw_p(ptr, be_bswap(v, 16));
}
-static inline void stl_be_p(void *ptr, int v)
+static inline void stl_be_p(void *ptr, uint32_t v)
{
stl_p(ptr, be_bswap(v, 32));
}
--
1.7.10.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH 2/2] bswap: Modify prototypes of st[wl]_{le, be}_p (avoid type conversions)
2014-02-19 5:11 ` [Qemu-devel] [PATCH 2/2] bswap: Modify prototypes of st[wl]_{le, be}_p " Stefan Weil
@ 2014-02-19 5:19 ` Stefan Weil
0 siblings, 0 replies; 6+ messages in thread
From: Stefan Weil @ 2014-02-19 5:19 UTC (permalink / raw)
To: qemu-trivial; +Cc: qemu-devel
Am 19.02.2014 06:11, schrieb Stefan Weil:
> The function use uint16_t or uint32_t values, so show this in the function
The functions ...
> prototypes. Non-optimizing compilers will avoid unnecessary type
> conversions when generating calls of these inline function.
... inline functions.
Maybe these typos can be fixed during the commit.
Thanks,
Stefan
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH 0/2] bswap: Clean prototypes of st* functions
2014-02-19 5:11 [Qemu-devel] [PATCH 0/2] bswap: Clean prototypes of st* functions Stefan Weil
2014-02-19 5:11 ` [Qemu-devel] [PATCH 1/2] bswap: Modify prototype of stb_p (avoid type conversions) Stefan Weil
2014-02-19 5:11 ` [Qemu-devel] [PATCH 2/2] bswap: Modify prototypes of st[wl]_{le, be}_p " Stefan Weil
@ 2014-02-19 10:16 ` Laszlo Ersek
2014-02-22 12:06 ` [Qemu-devel] [Qemu-trivial] " Michael Tokarev
3 siblings, 0 replies; 6+ messages in thread
From: Laszlo Ersek @ 2014-02-19 10:16 UTC (permalink / raw)
To: Stefan Weil; +Cc: qemu-trivial, qemu-devel
On 02/19/14 06:11, Stefan Weil wrote:
> These modifications avoid type conversions for non optimized code.
>
> ld* function prototypes will follow later.
>
> [PATCH 1/2] bswap: Modify prototype of stb_p (avoid type
> [PATCH 2/2] bswap: Modify prototypes of st[wl]_{le,be}_p (avoid type
>
It probably wouldn't hurt to audit all call sites, but it does look
reasonable.
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [Qemu-trivial] [PATCH 0/2] bswap: Clean prototypes of st* functions
2014-02-19 5:11 [Qemu-devel] [PATCH 0/2] bswap: Clean prototypes of st* functions Stefan Weil
` (2 preceding siblings ...)
2014-02-19 10:16 ` [Qemu-devel] [PATCH 0/2] bswap: Clean prototypes of st* functions Laszlo Ersek
@ 2014-02-22 12:06 ` Michael Tokarev
3 siblings, 0 replies; 6+ messages in thread
From: Michael Tokarev @ 2014-02-22 12:06 UTC (permalink / raw)
To: Stefan Weil; +Cc: qemu-trivial, Laszlo Ersek, qemu-devel
19.02.2014 09:11, Stefan Weil wrote:
> These modifications avoid type conversions for non optimized code.
>
> ld* function prototypes will follow later.
>
> [PATCH 1/2] bswap: Modify prototype of stb_p (avoid type
> [PATCH 2/2] bswap: Modify prototypes of st[wl]_{le,be}_p (avoid type
Thanks, applied to the trivial patches queue, with s/function/functions/
change in description for the second patch.
/mjt
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2014-02-22 12:06 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-19 5:11 [Qemu-devel] [PATCH 0/2] bswap: Clean prototypes of st* functions Stefan Weil
2014-02-19 5:11 ` [Qemu-devel] [PATCH 1/2] bswap: Modify prototype of stb_p (avoid type conversions) Stefan Weil
2014-02-19 5:11 ` [Qemu-devel] [PATCH 2/2] bswap: Modify prototypes of st[wl]_{le, be}_p " Stefan Weil
2014-02-19 5:19 ` Stefan Weil
2014-02-19 10:16 ` [Qemu-devel] [PATCH 0/2] bswap: Clean prototypes of st* functions Laszlo Ersek
2014-02-22 12:06 ` [Qemu-devel] [Qemu-trivial] " Michael Tokarev
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).