* [PATCH] microblaze: Fix big endian struct handling
@ 2013-02-08 4:11 Nathan Rossi
2013-02-08 12:14 ` Anthony Green
0 siblings, 1 reply; 2+ messages in thread
From: Nathan Rossi @ 2013-02-08 4:11 UTC (permalink / raw)
To: libffi-discuss; +Cc: Nathan Rossi
Fix handling of big endian structures on MicroBlaze. This patch fixes the
accessing of structs that are smaller then 4 bytes, structs can be allocated
on the stack with non-word aligned addresses, replace word read/write accesses
with byte read/write accesses.
This fixes MicroBlaze big endian so that the cls_3_1byte test case functions
correctly.
Signed-off-by: Nathan Rossi <nathan.rossi@xilinx.com>
---
ChangeLog | 3 +++
src/microblaze/ffi.c | 22 ++--------------------
2 files changed, 5 insertions(+), 20 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index bf2c179..0da827b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,6 @@
+2013-02-08 Nathan Rossi <nathan.rossi@xilinx.com>
+ * src/microblaze/ffi.c: Fixed issue.
+
2013-02-07 Anthony Green <green@moxielogic.com>
* configure.ac: Update bug reporting address.
diff --git a/src/microblaze/ffi.c b/src/microblaze/ffi.c
index 86ea37d..2689cb0 100644
--- a/src/microblaze/ffi.c
+++ b/src/microblaze/ffi.c
@@ -119,16 +119,7 @@ void ffi_prep_args(void* stack, extended_cif* ecif)
*/
if (size < WORD_SIZE)
{
- if (size == 1) {
- *(unsigned int *)addr =
- (unsigned int)*(UINT8*)(value);
- } else if (size == 2) {
- *(unsigned int *)addr =
- (unsigned int)*(UINT16*)(value);
- } else {
- *(unsigned int *)addr =
- ((unsigned int)*(UINT32*)(value)) >> 8;
- }
+ memcpy(addr + (WORD_SIZE - size), value, size);
break;
}
#endif
@@ -250,16 +241,7 @@ void ffi_closure_call_SYSV(void* register_args, void* stack_args,
*/
if (arg_types[i]->size < WORD_SIZE)
{
- if (arg_types[i]->size == 1) {
- *(unsigned int *)ptr =
- ((unsigned int)*(UINT32*)(ptr)) << 24;
- } else if (arg_types[i]->size == 2) {
- *(unsigned int *)ptr =
- ((unsigned int)*(UINT32*)(ptr)) << 16;
- } else {
- *(unsigned int *)ptr =
- ((unsigned int)*(UINT32*)(ptr)) << 8;
- }
+ memcpy(ptr, ptr + (WORD_SIZE - arg_types[i]->size), arg_types[i]->size);
}
#endif
avalue[i] = (void*)ptr;
--
1.7.5.4
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] microblaze: Fix big endian struct handling
2013-02-08 4:11 [PATCH] microblaze: Fix big endian struct handling Nathan Rossi
@ 2013-02-08 12:14 ` Anthony Green
0 siblings, 0 replies; 2+ messages in thread
From: Anthony Green @ 2013-02-08 12:14 UTC (permalink / raw)
To: Nathan Rossi; +Cc: libffi-discuss
On Thu, Feb 7, 2013 at 11:11 PM, Nathan Rossi <nathan.rossi@xilinx.com> wrote:
> This fixes MicroBlaze big endian so that the cls_3_1byte test case functions
> correctly.
Thanks Nathan. I took some liberty with your ChangeLog entry to
provide more info. Hope you don't mind.
Also, thank you for posting your test results on the wiki.
AG
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-02-08 12:14 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-08 4:11 [PATCH] microblaze: Fix big endian struct handling Nathan Rossi
2013-02-08 12:14 ` Anthony Green
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 read-only IMAP folder(s) and NNTP newsgroup(s).