[Mesa-dev] [PATCH] gallium: replace bswap_32 calls with util_bswap32
Jonathan Gray
jsg at jsg.id.au
Sun Jun 16 08:11:01 PDT 2013
byteswap.h and bswap_32 aren't portable, replace them with calls to
gallium's util_bswap32 as suggested by Mark Kettenis. Lets these files
build on OpenBSD.
Signed-off-by: Jonathan Gray <jsg at jsg.id.au>
---
src/gallium/drivers/r600/r600_asm.c | 4 ++--
src/gallium/drivers/r600/r600_shader.c | 4 ++--
src/gallium/drivers/r600/r600_state_common.c | 4 ++--
src/gallium/drivers/radeonsi/r600_buffer.c | 4 +---
4 files changed, 7 insertions(+), 9 deletions(-)
diff --git src/gallium/drivers/r600/r600_asm.c src/gallium/drivers/r600/r600_asm.c
index 08fe24e..b8eedae 100644
--- src/gallium/drivers/r600/r600_asm.c
+++ src/gallium/drivers/r600/r600_asm.c
@@ -27,9 +27,9 @@
#include "r600d.h"
#include <errno.h>
-#include <byteswap.h>
#include "util/u_dump.h"
#include "util/u_memory.h"
+#include "util/u_math.h"
#include "pipe/p_shader_tokens.h"
#include "sb/sb_public.h"
@@ -2419,7 +2419,7 @@ void *r600_create_vertex_fetch_shader(struct pipe_context *ctx,
if (R600_BIG_ENDIAN) {
for (i = 0; i < fs_size / 4; ++i) {
- bytecode[i] = bswap_32(bc.bytecode[i]);
+ bytecode[i] = util_bswap32(bc.bytecode[i]);
}
} else {
memcpy(bytecode, bc.bytecode, fs_size);
diff --git src/gallium/drivers/r600/r600_shader.c src/gallium/drivers/r600/r600_shader.c
index 81ed3ce..3a734bc 100644
--- src/gallium/drivers/r600/r600_shader.c
+++ src/gallium/drivers/r600/r600_shader.c
@@ -35,9 +35,9 @@
#include "tgsi/tgsi_scan.h"
#include "tgsi/tgsi_dump.h"
#include "util/u_memory.h"
+#include "util/u_math.h"
#include <stdio.h>
#include <errno.h>
-#include <byteswap.h>
/* CAYMAN notes
Why CAYMAN got loops for lots of instructions is explained here.
@@ -194,7 +194,7 @@ int r600_pipe_shader_create(struct pipe_context *ctx,
ptr = r600_buffer_mmap_sync_with_rings(rctx, shader->bo, PIPE_TRANSFER_WRITE);
if (R600_BIG_ENDIAN) {
for (i = 0; i < shader->shader.bc.ndw; ++i) {
- ptr[i] = bswap_32(shader->shader.bc.bytecode[i]);
+ ptr[i] = util_bswap32(shader->shader.bc.bytecode[i]);
}
} else {
memcpy(ptr, shader->shader.bc.bytecode, shader->shader.bc.ndw * sizeof(*ptr));
diff --git src/gallium/drivers/r600/r600_state_common.c src/gallium/drivers/r600/r600_state_common.c
index 4995c81..b9a8f0b 100644
--- src/gallium/drivers/r600/r600_state_common.c
+++ src/gallium/drivers/r600/r600_state_common.c
@@ -32,8 +32,8 @@
#include "util/u_index_modify.h"
#include "util/u_memory.h"
#include "util/u_upload_mgr.h"
+#include "util/u_math.h"
#include "tgsi/tgsi_parse.h"
-#include <byteswap.h>
#define R600_PRIM_RECTANGLE_LIST PIPE_PRIM_MAX
@@ -953,7 +953,7 @@ static void r600_set_constant_buffer(struct pipe_context *ctx, uint shader, uint
}
for (i = 0; i < size / 4; ++i) {
- tmpPtr[i] = bswap_32(((uint32_t *)ptr)[i]);
+ tmpPtr[i] = util_bswap32(((uint32_t *)ptr)[i]);
}
u_upload_data(rctx->uploader, 0, size, tmpPtr, &cb->buffer_offset, &cb->buffer);
diff --git src/gallium/drivers/radeonsi/r600_buffer.c src/gallium/drivers/radeonsi/r600_buffer.c
index 3d295e8..2bc47c1 100644
--- src/gallium/drivers/radeonsi/r600_buffer.c
+++ src/gallium/drivers/radeonsi/r600_buffer.c
@@ -25,8 +25,6 @@
* Corbin Simpson <MostAwesomeDude at gmail.com>
*/
-#include <byteswap.h>
-
#include "pipe/p_screen.h"
#include "util/u_format.h"
#include "util/u_math.h"
@@ -185,7 +183,7 @@ void r600_upload_const_buffer(struct r600_context *rctx, struct si_resource **rb
}
for (i = 0; i < size / 4; ++i) {
- tmpPtr[i] = bswap_32(((uint32_t *)ptr)[i]);
+ tmpPtr[i] = util_bswap32(((uint32_t *)ptr)[i]);
}
u_upload_data(rctx->uploader, 0, size, tmpPtr, const_offset,
--
1.8.3
More information about the mesa-dev
mailing list