diff options
author | Bhanu Chetlapalli <bhanu@mips.com> | 2012-06-05 14:02:12 -0700 |
---|---|---|
committer | Bhanu Chetlapalli <bhanu@mips.com> | 2012-06-05 14:02:12 -0700 |
commit | 8c40e1fd6f29def81cd4fe8069eb88b369eb9557 (patch) | |
tree | cc26162942d0538ba46b8002c2a7324cd0d3fdaf /emulator/opengl/host | |
parent | 4d58f82e87a496ae2f29bcff648b7b6f1c143c78 (diff) | |
download | sdk-8c40e1fd6f29def81cd4fe8069eb88b369eb9557.zip sdk-8c40e1fd6f29def81cd4fe8069eb88b369eb9557.tar.gz sdk-8c40e1fd6f29def81cd4fe8069eb88b369eb9557.tar.bz2 |
[MIPS] Add support to handle unaligned accesses
MIPS cannot handle unaligned accesses, so this patch changes the
direct assignment of ints/floats to using memcpy
Signed-Off-By: Bhanu Chetlapalli <bhanu@mips.com>
Change-Id: I82600dece8f48f718f73b49cdf831094bbfdcde5
Diffstat (limited to 'emulator/opengl/host')
-rw-r--r-- | emulator/opengl/host/tools/emugen/ApiGen.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/emulator/opengl/host/tools/emugen/ApiGen.cpp b/emulator/opengl/host/tools/emugen/ApiGen.cpp index bf2d244..6964862 100644 --- a/emulator/opengl/host/tools/emugen/ApiGen.cpp +++ b/emulator/opengl/host/tools/emugen/ApiGen.cpp @@ -418,8 +418,9 @@ static void writeVarEncodingExpression(Var& var, FILE* fp) } else { // encode a non pointer variable if (!var.isVoid()) { - fprintf(fp, "\t*(%s *) (ptr) = %s; ptr += %u;\n", - var.type()->name().c_str(), varname, + fprintf(fp, "\t\tmemcpy(ptr, &%s, %u); ptr += %u;\n", + varname, + (uint) var.type()->bytes(), (uint) var.type()->bytes()); } } @@ -570,8 +571,8 @@ int ApiGen::genEncoderImpl(const std::string &filename) // encode packet header if needed. if (nvars == 0) { - fprintf(fp, "\t*(unsigned int *)(ptr) = OP_%s; ptr += 4;\n", e->name().c_str()); - fprintf(fp, "\t*(unsigned int *)(ptr) = (unsigned int) packetSize; ptr += 4;\n"); + fprintf(fp, "\tint tmp = OP_%s;memcpy(ptr, &tmp, 4); ptr += 4;\n", e->name().c_str()); + fprintf(fp, "\tmemcpy(ptr, &packetSize, 4); ptr += 4;\n\n"); } if (maxvars == 0) @@ -611,8 +612,8 @@ int ApiGen::genEncoderImpl(const std::string &filename) fprintf(fp, "\t unsigned char *ptr = stream->alloc(packetSize);\n\n"); // encode into the stream; - fprintf(fp, "\t*(unsigned int *)(ptr) = OP_%s; ptr += 4;\n", e->name().c_str()); - fprintf(fp, "\t*(unsigned int *)(ptr) = (unsigned int) packetSize; ptr += 4;\n\n"); + fprintf(fp, "\tint tmp = OP_%s; memcpy(ptr, &tmp, 4); ptr += 4;\n", e->name().c_str()); + fprintf(fp, "\tmemcpy(ptr, &packetSize, 4); ptr += 4;\n\n"); // out variables for (size_t j = 0; j < nvars; j++) { |