diff --git a/src/freedreno/common/meson.build b/src/freedreno/common/meson.build index a05116fea28..26ce856bc88 100644 --- a/src/freedreno/common/meson.build +++ b/src/freedreno/common/meson.build @@ -43,6 +43,7 @@ libfreedreno_common = static_library( 'freedreno_guardband.h', freedreno_devices_h, sha1_h, + 'redump.h' ], include_directories : [inc_freedreno, inc_include, inc_src], c_args : [no_override_init_args], diff --git a/src/freedreno/decode/redump.h b/src/freedreno/common/redump.h similarity index 60% rename from src/freedreno/decode/redump.h rename to src/freedreno/common/redump.h index 1325311900d..980e57488d1 100644 --- a/src/freedreno/decode/redump.h +++ b/src/freedreno/common/redump.h @@ -24,7 +24,7 @@ #ifndef REDUMP_H_ #define REDUMP_H_ -#include "util/u_math.h" +#include enum rd_sect_type { RD_NONE, @@ -60,31 +60,12 @@ enum rd_param_type { RD_PARAM_BLIT_Y2, /* BLIT_Y + BLIT_WIDTH */ }; -void rd_start(const char *name, const char *fmt, ...) __attribute__((weak)); -void rd_end(void) __attribute__((weak)); -void rd_write_section(enum rd_sect_type type, const void *buf, int sz) - __attribute__((weak)); - -/* for code that should run with and without libwrap, use the following - * macros which check if the fxns are present before calling - */ -#define RD_START(n, f, ...) \ - do { \ - if (rd_start) \ - rd_start(n, f, ##__VA_ARGS__); \ - } while (0) -#define RD_END() \ - do { \ - if (rd_end) \ - rd_end(); \ - } while (0) -#define RD_WRITE_SECTION(t, b, s) \ - do { \ - if (rd_write_section) \ - rd_write_section(t, b, s); \ - } while (0) - -#define min(a, b) (((a) < (b)) ? (a) : (b)) -#define max(a, b) (((a) > (b)) ? (a) : (b)) +static inline void +rd_write_section(int fd, enum rd_sect_type type, const void *buf, int sz) +{ + write(fd, &type, 4); + write(fd, &sz, 4); + write(fd, buf, sz); +} #endif /* REDUMP_H_ */ diff --git a/src/freedreno/decode/cffdec.c b/src/freedreno/decode/cffdec.c index cec8dabeb9a..c2c743eb275 100644 --- a/src/freedreno/decode/cffdec.c +++ b/src/freedreno/decode/cffdec.c @@ -448,7 +448,7 @@ disasm_gpuaddr(const char *name, uint64_t gpuaddr, int level) uint32_t sizedwords = hostlen(gpuaddr) / 4; const char *ext; - dump_hex(buf, min(64, sizedwords), level + 1); + dump_hex(buf, MIN2(64, sizedwords), level + 1); try_disasm_a3xx(buf, sizedwords, level + 2, stdout, options->info->chip * 100); /* this is a bit ugly way, but oh well.. */ @@ -1835,11 +1835,11 @@ dump_a2xx_shader_const(uint32_t *dwords, uint32_t sizedwords, uint32_t val, size, fmt); // TODO maybe dump these as bytes instead of dwords? size = (size + 3) / 4; // for now convert to dwords - dump_hex(addr, min(size, 64), level + 1); - if (size > min(size, 64)) + dump_hex(addr, MIN2(size, 64), level + 1); + if (size > MIN2(size, 64)) printf("%s\t\t...\n", levels[level + 1]); - dump_float(addr, min(size, 64), level + 1); - if (size > min(size, 64)) + dump_float(addr, MIN2(size, 64), level + 1); + if (size > MIN2(size, 64)) printf("%s\t\t...\n", levels[level + 1]); } } @@ -2179,13 +2179,13 @@ cp_draw_indirect_multi(uint32_t *dwords, uint32_t sizedwords, int level) printf("%sindirect count: %u\n", levels[level], *buf); if (*buf == 0 || *buf > max_indirect_draw_count) { /* garbage value */ - count = min(count, max_draw_count); + count = MIN2(count, max_draw_count); } else { /* not garbage */ - count = min(count, *buf); + count = MIN2(count, *buf); } } else { - count = min(count, max_draw_count); + count = MIN2(count, max_draw_count); } } diff --git a/src/freedreno/decode/rdcompiler-utils.h b/src/freedreno/decode/rdcompiler-utils.h index d52d734a35b..2547699f1f2 100644 --- a/src/freedreno/decode/rdcompiler-utils.h +++ b/src/freedreno/decode/rdcompiler-utils.h @@ -12,7 +12,7 @@ #include #include -#include "freedreno/decode/redump.h" +#include "redump.h" #include "util/u_math.h" @@ -378,4 +378,4 @@ gpu_print(struct replay_context *ctx, struct cmdstream *_cs, uint64_t iova, } end_ib(); -} \ No newline at end of file +}