Commit 137cf0af authored by Alessandro Rubini's avatar Alessandro Rubini

tools/wrpc-dump: support "spec-byte order" if WRPC_SPEC is set

Use an environment variable to check for spec byte order, and
fix the buffer before using it.
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent 65fb29b5
...@@ -511,12 +511,21 @@ int main(int argc, char **argv) ...@@ -511,12 +511,21 @@ int main(int argc, char **argv)
argv[2]); argv[2]);
exit(1); exit(1);
} }
mapaddr = mmap(0, st.st_size, PROT_READ, MAP_FILE | MAP_SHARED, fd, 0); mapaddr = mmap(0, st.st_size, PROT_READ | PROT_WRITE,
MAP_FILE | MAP_PRIVATE, fd, 0);
if (mapaddr == MAP_FAILED) { if (mapaddr == MAP_FAILED) {
fprintf(stderr, "%s: mmap(%s): %s\n", fprintf(stderr, "%s: mmap(%s): %s\n",
argv[0], argv[1], strerror(errno)); argv[0], argv[1], strerror(errno));
exit(1); exit(1);
} }
/* If the dump file needs "spec" byte order, fix it all */
if (getenv("WRPC_SPEC")) {
uint32_t *p = mapaddr;
int i;
for (i = 0; i < st.st_size / 4; i++, p++)
*p = __bswap_32(*p);
}
#define ARRAY_AND_SIZE(x) (x), ARRAY_SIZE(x) #define ARRAY_AND_SIZE(x) (x), ARRAY_SIZE(x)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment