From: Kenneth Graunke <kenneth@whitecape.org>
To: Sateesh Kavuri <sateesh.kavuri@intel.com>
Cc: intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH] Android port of intel-gpu-tools
Date: Tue, 10 Jan 2012 23:54:29 -0800 [thread overview]
Message-ID: <4F0D4035.8050201@whitecape.org> (raw)
In-Reply-To: <1326170701-22099-1-git-send-email-sateesh.kavuri@intel.com>
On 01/09/2012 08:45 PM, Sateesh Kavuri wrote:
> Added support for Android. Changes include fixes for compilation issues
> related to Android using an older version of GCC compiler (ver 4.3.3)
> while the latest version of intel-gpu-tools confirms to GCC ver 4.5.2
> (C99 standard functions), using functions like getline(). Fixed such
> functions, header dependencies for android and added an Android.mk file.
>
> signed-off-by: Sateesh Kavuri<sateesh.kavuri@intel.com>
> ---
> Android.mk | 528 ++++++++++++++++++++++++++++++++++++++++++++
> lib/intel_drm.c | 6 +-
> lib/intel_mmio.c | 4 +
> lib/intel_pci.c | 4 +
> tools/intel_decode.c | 10 +
> tools/intel_dump_decode.c | 14 +-
> tools/intel_error_decode.c | 14 ++
> tools/intel_gpu_top.c | 6 +-
> tools/intel_reg_write.c | 2 +
> 9 files changed, 584 insertions(+), 4 deletions(-)
> create mode 100644 Android.mk
>
> diff --git a/Android.mk b/Android.mk
> new file mode 100644
> index 0000000..0fc04cd
> --- /dev/null
> +++ b/Android.mk
> @@ -0,0 +1,528 @@
> +LOCAL_PATH := $(call my-dir)
> +include $(CLEAR_VARS)
> +
> +LOCAL_SRC_FILES := \
> + tools/intel_reg_write.c \
> + lib/intel_pci.c \
> + lib/intel_gpu_tools.h \
> + tools/intel_reg.h \
> + lib/intel_batchbuffer.h \
> + lib/intel_batchbuffer.c \
> + lib/intel_reg_map.c \
> + lib/intel_mmio.c \
> + tools/intel_chipset.h
> +
> +
> +LOCAL_C_INCLUDES += \
> + $(LOCAL_PATH)/lib \
> + $(TOPDIR)hardware/intel/libdrm/include/drm \
> + $(TOPDIR)hardware/intel/libdrm/intel \
> + $(LOCAL_PATH)/../libpciaccess/include/
> +
> +LOCAL_CFLAGS += -DHAVE_LIBDRM_ATOMIC_PRIMITIVES=1
> +LOCAL_CFLAGS += -DANDROID
> +
> +LOCAL_MODULE := intel_reg_write
> +LOCAL_MODULE_TAGS := optional
> +
> +LOCAL_SHARED_LIBRARIES := libpciaccess \
> + libdrm \
> + libdrm_intel
> +
> +include $(BUILD_EXECUTABLE)
> +
> +#================
> +include $(CLEAR_VARS)
> +
> +LOCAL_SRC_FILES := \
> + tools/intel_reg_read.c \
> + lib/intel_pci.c \
> + lib/intel_gpu_tools.h \
> + tools/intel_reg.h \
> + lib/intel_batchbuffer.h \
> + lib/intel_batchbuffer.c \
> + lib/intel_reg_map.c \
> + lib/intel_mmio.c \
> + tools/intel_chipset.h
> +
> +
> +LOCAL_C_INCLUDES += \
> + $(LOCAL_PATH)/lib \
> + $(TOPDIR)hardware/intel/libdrm/include/drm \
> + $(TOPDIR)hardware/intel/libdrm/intel \
> + $(LOCAL_PATH)/../libpciaccess/include/
> +
> +LOCAL_CFLAGS += -DHAVE_LIBDRM_ATOMIC_PRIMITIVES=1
> +LOCAL_CFLAGS += -DANDROID
> +
> +
> +LOCAL_MODULE := intel_reg_read
> +LOCAL_MODULE_TAGS := optional
> +
> +LOCAL_SHARED_LIBRARIES := libpciaccess \
> + libdrm \
> + libdrm_intel
> +
> +include $(BUILD_EXECUTABLE)
> +
> +#================
> +include $(CLEAR_VARS)
> +
> +LOCAL_SRC_FILES := \
> + tools/intel_disable_clock_gating.c \
> + lib/intel_pci.c \
> + lib/intel_gpu_tools.h \
> + tools/intel_reg.h \
> + lib/intel_batchbuffer.h \
> + lib/intel_batchbuffer.c \
> + lib/intel_mmio.c \
> + tools/intel_chipset.h
> +
> +
> +LOCAL_C_INCLUDES += \
> + $(LOCAL_PATH)/lib \
> + $(TOPDIR)hardware/intel/libdrm/include/drm \
> + $(TOPDIR)hardware/intel/libdrm/intel \
> + $(LOCAL_PATH)/../libpciaccess/include/
> +
> +LOCAL_CFLAGS += -DHAVE_LIBDRM_ATOMIC_PRIMITIVES=1
> +LOCAL_CFLAGS += -DANDROID
> +
> +
> +LOCAL_MODULE := intel_disable_clock_gating
> +LOCAL_MODULE_TAGS := optional
> +
> +LOCAL_SHARED_LIBRARIES := libpciaccess \
> + libdrm \
> + libdrm_intel
> +
> +include $(BUILD_EXECUTABLE)
> +
> +#================
> +include $(CLEAR_VARS)
> +
> +LOCAL_SRC_FILES := \
> + tools/intel_audio_dump.c \
> + lib/intel_pci.c \
> + lib/intel_gpu_tools.h \
> + tools/intel_reg.h \
> + lib/intel_batchbuffer.h \
> + lib/intel_batchbuffer.c \
> + lib/intel_mmio.c \
> + tools/intel_chipset.h
> +
> +
> +LOCAL_C_INCLUDES += \
> + $(LOCAL_PATH)/lib \
> + $(TOPDIR)hardware/intel/libdrm/include/drm \
> + $(TOPDIR)hardware/intel/libdrm/intel \
> + $(LOCAL_PATH)/../libpciaccess/include/
> +
> +LOCAL_CFLAGS += -DHAVE_LIBDRM_ATOMIC_PRIMITIVES=1
> +LOCAL_CFLAGS += -DANDROID
> +
> +
> +LOCAL_MODULE := intel_audio_dump
> +LOCAL_MODULE_TAGS := optional
> +
> +LOCAL_SHARED_LIBRARIES := libpciaccess \
> + libdrm \
> + libdrm_intel
> +
> +include $(BUILD_EXECUTABLE)
> +
> +#================
> +include $(CLEAR_VARS)
> +
> +LOCAL_SRC_FILES := \
> + tools/intel_backlight.c \
> + lib/intel_pci.c \
> + lib/intel_gpu_tools.h \
> + tools/intel_reg.h \
> + lib/intel_batchbuffer.h \
> + lib/intel_batchbuffer.c \
> + lib/intel_mmio.c \
> + tools/intel_chipset.h
> +
> +
> +LOCAL_C_INCLUDES += \
> + $(LOCAL_PATH)/lib \
> + $(TOPDIR)hardware/intel/libdrm/include/drm \
> + $(TOPDIR)hardware/intel/libdrm/intel \
> + $(LOCAL_PATH)/../libpciaccess/include/
> +
> +LOCAL_CFLAGS += -DHAVE_LIBDRM_ATOMIC_PRIMITIVES=1
> +LOCAL_CFLAGS += -DANDROID
> +
> +
> +LOCAL_MODULE := intel_backlight
> +LOCAL_MODULE_TAGS := optional
> +
> +LOCAL_SHARED_LIBRARIES := libpciaccess \
> + libdrm \
> + libdrm_intel
> +
> +include $(BUILD_EXECUTABLE)
> +
> +#================
> +include $(CLEAR_VARS)
> +
> +LOCAL_SRC_FILES := \
> + tools/intel_bios_dumper.c \
> + lib/intel_pci.c \
> + lib/intel_gpu_tools.h \
> + tools/intel_reg.h \
> + lib/intel_batchbuffer.h \
> + lib/intel_batchbuffer.c \
> + lib/intel_mmio.c \
> + tools/intel_chipset.h
> +
> +
> +LOCAL_C_INCLUDES += \
> + $(LOCAL_PATH)/lib \
> + $(TOPDIR)hardware/intel/libdrm/include/drm \
> + $(TOPDIR)hardware/intel/libdrm/intel \
> + $(LOCAL_PATH)/../libpciaccess/include/
> +
> +LOCAL_CFLAGS += -DHAVE_LIBDRM_ATOMIC_PRIMITIVES=1
> +LOCAL_CFLAGS += -DANDROID
> +
> +
> +LOCAL_MODULE := intel_bios_dumper
> +LOCAL_MODULE_TAGS := optional
> +
> +LOCAL_SHARED_LIBRARIES := libpciaccess \
> + libdrm \
> + libdrm_intel
> +
> +include $(BUILD_EXECUTABLE)
> +
> +#================
> +include $(CLEAR_VARS)
> +
> +LOCAL_SRC_FILES := \
> + tools/intel_bios_reader.c \
> + lib/intel_pci.c \
> + lib/intel_gpu_tools.h \
> + tools/intel_reg.h \
> + lib/intel_batchbuffer.h \
> + lib/intel_batchbuffer.c \
> + lib/intel_mmio.c \
> + tools/intel_chipset.h
> +
> +
> +LOCAL_C_INCLUDES += \
> + $(LOCAL_PATH)/lib \
> + $(TOPDIR)hardware/intel/libdrm/include/drm \
> + $(TOPDIR)hardware/intel/libdrm/intel \
> + $(LOCAL_PATH)/../libpciaccess/include/
> +
> +LOCAL_CFLAGS += -DHAVE_LIBDRM_ATOMIC_PRIMITIVES=1
> +LOCAL_CFLAGS += -DANDROID
> +
> +
> +LOCAL_MODULE := intel_bios_reader
> +LOCAL_MODULE_TAGS := optional
> +
> +LOCAL_SHARED_LIBRARIES := libpciaccess \
> + libdrm \
> + libdrm_intel
> +
> +include $(BUILD_EXECUTABLE)
> +
> +#================
> +include $(CLEAR_VARS)
> +
> +LOCAL_SRC_FILES := \
> + tools/intel_error_decode.c \
> + lib/intel_pci.c \
> + lib/intel_gpu_tools.h \
> + tools/intel_reg.h \
> + lib/intel_batchbuffer.h \
> + lib/intel_batchbuffer.c \
> + lib/intel_mmio.c \
> + tools/intel_chipset.h \
> + lib/instdone.h \
> + lib/instdone.c \
> + tools/intel_decode.h \
> + tools/intel_decode.c \
> + lib/intel_drm.c
> +
> +
> +LOCAL_C_INCLUDES += \
> + $(LOCAL_PATH)/lib \
> + $(TOPDIR)hardware/intel/libdrm/include/drm \
> + $(TOPDIR)hardware/intel/libdrm/intel \
> + $(LOCAL_PATH)/../libpciaccess/include/
> +
> +LOCAL_CFLAGS += -DHAVE_LIBDRM_ATOMIC_PRIMITIVES=1
> +LOCAL_CFLAGS += -DANDROID
> +
> +
> +LOCAL_MODULE := intel_error_decode
> +LOCAL_MODULE_TAGS := optional
> +
> +LOCAL_SHARED_LIBRARIES := libpciaccess \
> + libdrm \
> + libdrm_intel
> +
> +include $(BUILD_EXECUTABLE)
> +
> +#================
> +include $(CLEAR_VARS)
> +
> +LOCAL_SRC_FILES := \
> + tools/intel_gpu_top.c \
> + lib/intel_pci.c \
> + lib/intel_gpu_tools.h \
> + tools/intel_reg.h \
> + lib/intel_batchbuffer.h \
> + lib/intel_batchbuffer.c \
> + lib/intel_mmio.c \
> + tools/intel_chipset.h \
> + lib/instdone.h \
> + lib/instdone.c \
> + lib/intel_reg_map.c
> +
> +
> +LOCAL_C_INCLUDES += \
> + $(LOCAL_PATH)/lib \
> + $(TOPDIR)hardware/intel/libdrm/include/drm \
> + $(TOPDIR)hardware/intel/libdrm/intel \
> + $(LOCAL_PATH)/../libpciaccess/include/
> +
> +LOCAL_CFLAGS += -DHAVE_LIBDRM_ATOMIC_PRIMITIVES=1
> +LOCAL_CFLAGS += -DANDROID
> +
> +
> +LOCAL_MODULE := intel_gpu_top
> +LOCAL_MODULE_TAGS := optional
> +
> +LOCAL_SHARED_LIBRARIES := libpciaccess \
> + libdrm \
> + libdrm_intel
> +
> +include $(BUILD_EXECUTABLE)
> +
> +#================
> +include $(CLEAR_VARS)
> +
> +LOCAL_SRC_FILES := \
> + tools/intel_gpu_time.c \
> + lib/intel_pci.c \
> + lib/intel_gpu_tools.h \
> + tools/intel_reg.h \
> + lib/intel_batchbuffer.h \
> + lib/intel_batchbuffer.c \
> + lib/intel_mmio.c \
> + tools/intel_chipset.h
> +
> +
> +LOCAL_C_INCLUDES += \
> + $(LOCAL_PATH)/lib \
> + $(TOPDIR)hardware/intel/libdrm/include/drm \
> + $(TOPDIR)hardware/intel/libdrm/intel \
> + $(LOCAL_PATH)/../libpciaccess/include/
> +
> +LOCAL_CFLAGS += -DHAVE_LIBDRM_ATOMIC_PRIMITIVES=1
> +LOCAL_CFLAGS += -DANDROID
> +
> +
> +LOCAL_MODULE := intel_gpu_time
> +LOCAL_MODULE_TAGS := optional
> +
> +LOCAL_SHARED_LIBRARIES := libpciaccess \
> + libdrm \
> + libdrm_intel
> +
> +include $(BUILD_EXECUTABLE)
> +
> +#================
> +include $(CLEAR_VARS)
> +
> +LOCAL_SRC_FILES := \
> + tools/intel_gtt.c \
> + lib/intel_pci.c \
> + lib/intel_gpu_tools.h \
> + tools/intel_reg.h \
> + lib/intel_batchbuffer.h \
> + lib/intel_batchbuffer.c \
> + lib/intel_mmio.c \
> + tools/intel_chipset.h
> +
> +
> +LOCAL_C_INCLUDES += \
> + $(LOCAL_PATH)/lib \
> + $(TOPDIR)hardware/intel/libdrm/include/drm \
> + $(TOPDIR)hardware/intel/libdrm/intel \
> + $(LOCAL_PATH)/../libpciaccess/include/
> +
> +LOCAL_CFLAGS += -DHAVE_LIBDRM_ATOMIC_PRIMITIVES=1
> +
> +LOCAL_MODULE := intel_gtt
> +LOCAL_MODULE_TAGS := optional
> +
> +LOCAL_SHARED_LIBRARIES := libpciaccess \
> + libdrm \
> + libdrm_intel
> +
> +include $(BUILD_EXECUTABLE)
> +
> +#================
> +include $(CLEAR_VARS)
> +
> +LOCAL_SRC_FILES := \
> + tools/intel_stepping.c \
> + lib/intel_pci.c \
> + lib/intel_gpu_tools.h \
> + tools/intel_reg.h \
> + lib/intel_batchbuffer.h \
> + lib/intel_batchbuffer.c \
> + lib/intel_mmio.c \
> + tools/intel_chipset.h
> +
> +
> +LOCAL_C_INCLUDES += \
> + $(LOCAL_PATH)/lib \
> + $(TOPDIR)hardware/intel/libdrm/include/drm \
> + $(TOPDIR)hardware/intel/libdrm/intel \
> + $(LOCAL_PATH)/../libpciaccess/include/
> +
> +LOCAL_CFLAGS += -DHAVE_LIBDRM_ATOMIC_PRIMITIVES=1
> +LOCAL_CFLAGS += -DANDROID
> +
> +
> +LOCAL_MODULE := intel_stepping
> +LOCAL_MODULE_TAGS := optional
> +
> +LOCAL_SHARED_LIBRARIES := libpciaccess \
> + libdrm \
> + libdrm_intel
> +
> +include $(BUILD_EXECUTABLE)
> +
> +#================
> +include $(CLEAR_VARS)
> +
> +LOCAL_SRC_FILES := \
> + tools/intel_reg_dumper.c \
> + lib/intel_pci.c \
> + lib/intel_gpu_tools.h \
> + tools/intel_reg.h \
> + lib/intel_batchbuffer.h \
> + lib/intel_batchbuffer.c \
> + lib/intel_mmio.c \
> + tools/intel_chipset.h
> +
> +
> +LOCAL_C_INCLUDES += \
> + $(LOCAL_PATH)/lib \
> + $(TOPDIR)hardware/intel/libdrm/include/drm \
> + $(TOPDIR)hardware/intel/libdrm/intel \
> + $(LOCAL_PATH)/../libpciaccess/include/
> +
> +LOCAL_CFLAGS += -DHAVE_LIBDRM_ATOMIC_PRIMITIVES=1
> +LOCAL_CFLAGS += -DANDROID
> +
> +
> +LOCAL_MODULE := intel_reg_dumper
> +LOCAL_MODULE_TAGS := optional
> +
> +LOCAL_SHARED_LIBRARIES := libpciaccess \
> + libdrm \
> + libdrm_intel
> +
> +include $(BUILD_EXECUTABLE)
> +
> +#================
> +include $(CLEAR_VARS)
> +
> +LOCAL_SRC_FILES := \
> + tools/intel_reg_snapshot.c \
> + lib/intel_pci.c \
> + lib/intel_gpu_tools.h \
> + tools/intel_reg.h \
> + lib/intel_batchbuffer.h \
> + lib/intel_batchbuffer.c \
> + lib/intel_mmio.c \
> + tools/intel_chipset.h
> +
> +
> +LOCAL_C_INCLUDES += \
> + $(LOCAL_PATH)/lib \
> + $(TOPDIR)hardware/intel/libdrm/include/drm \
> + $(TOPDIR)hardware/intel/libdrm/intel \
> + $(LOCAL_PATH)/../libpciaccess/include/
> +
> +LOCAL_CFLAGS += -DHAVE_LIBDRM_ATOMIC_PRIMITIVES=1
> +
> +LOCAL_MODULE := intel_reg_snapshot
> +LOCAL_MODULE_TAGS := optional
> +
> +LOCAL_SHARED_LIBRARIES := libpciaccess \
> + libdrm \
> + libdrm_intel
> +
> +include $(BUILD_EXECUTABLE)
> +
> +#================
> +include $(CLEAR_VARS)
> +
> +LOCAL_SRC_FILES := \
> + tools/forcewaked.c \
> + lib/intel_pci.c \
> + lib/intel_gpu_tools.h \
> + tools/intel_reg.h \
> + lib/intel_batchbuffer.h \
> + lib/intel_batchbuffer.c \
> + lib/intel_mmio.c \
> + tools/intel_chipset.h \
> + lib/intel_reg_map.c
> +
> +
> +LOCAL_C_INCLUDES += \
> + $(LOCAL_PATH)/lib \
> + $(TOPDIR)hardware/intel/libdrm/include/drm \
> + $(TOPDIR)hardware/intel/libdrm/intel \
> + $(LOCAL_PATH)/../libpciaccess/include/
> +
> +LOCAL_CFLAGS += -DHAVE_LIBDRM_ATOMIC_PRIMITIVES=1
> +LOCAL_CFLAGS += -DANDROID
> +
> +
> +LOCAL_MODULE := forcewaked
> +LOCAL_MODULE_TAGS := optional
> +
> +LOCAL_SHARED_LIBRARIES := libpciaccess \
> + libdrm \
> + libdrm_intel
> +
> +include $(BUILD_EXECUTABLE)
> +
> +#================
> +include $(CLEAR_VARS)
> +
> +LOCAL_SRC_FILES := \
> + lib/intel_gpu_tools.h \
> + tools/intel_reg_checker.c \
> + lib/intel_pci.c \
> + lib/intel_mmio.c
> +
> +
> +LOCAL_C_INCLUDES += \
> + $(LOCAL_PATH)/lib \
> + $(TOPDIR)hardware/intel/libdrm/include/drm \
> + $(TOPDIR)hardware/intel/libdrm/intel \
> + $(LOCAL_PATH)/../libpciaccess/include/
> +
> +LOCAL_CFLAGS += -DHAVE_LIBDRM_ATOMIC_PRIMITIVES=1
> +LOCAL_CFLAGS += -DANDROID
> +
> +
> +LOCAL_MODULE := intel_reg_checker
> +LOCAL_MODULE_TAGS := optional
> +
> +LOCAL_SHARED_LIBRARIES := libpciaccess
> +
> +include $(BUILD_EXECUTABLE)
> +
It's unfortunate that we need another build system, but I understand
that it's necessary---we ended up adding one in Mesa.
> diff --git a/lib/intel_drm.c b/lib/intel_drm.c
> index f8eca7d..1f51856 100644
> --- a/lib/intel_drm.c
> +++ b/lib/intel_drm.c
> @@ -25,7 +25,7 @@
> *
> */
>
> -#include "config.h"
> +#include "../config.h"
>
> #include<unistd.h>
> #include<stdlib.h>
> @@ -35,7 +35,11 @@
> #include<err.h>
> #include<assert.h>
> #include<sys/ioctl.h>
> +#ifdef ANDROID
> +#include<fcntl.h>
> +#else
> #include<sys/fcntl.h>
> +#endif
At least on my system, /usr/include/sys/fcntl.h is simply:
#include <fcntl.h>
So I think you could unconditionally change all of these to #include
<fcntl.h> without #ifdef ANDROID. Perhaps others can confirm that.
That would certainly be a lot nicer.
> #include<sys/stat.h>
> #include<sys/mman.h>
> #ifdef HAVE_STRUCT_SYSINFO_TOTALRAM
> diff --git a/lib/intel_mmio.c b/lib/intel_mmio.c
> index da68bdf..2020833 100644
> --- a/lib/intel_mmio.c
> +++ b/lib/intel_mmio.c
> @@ -38,7 +38,11 @@
> #include<err.h>
> #include<assert.h>
> #include<sys/ioctl.h>
> +#ifdef ANDROID
> +#include<fcntl.h>
> +#else
> #include<sys/fcntl.h>
> +#endif
> #include<sys/stat.h>
> #include<sys/mman.h>
>
> diff --git a/lib/intel_pci.c b/lib/intel_pci.c
> index 7bc7466..98889ca 100644
> --- a/lib/intel_pci.c
> +++ b/lib/intel_pci.c
> @@ -33,7 +33,11 @@
> #include<err.h>
> #include<assert.h>
> #include<sys/ioctl.h>
> +#ifdef ANDROID
> +#include<fcntl.h>
> +#else
> #include<sys/fcntl.h>
> +#endif
> #include<sys/stat.h>
> #include<sys/mman.h>
>
> diff --git a/tools/intel_decode.c b/tools/intel_decode.c
> index 344578b..5ed508f 100644
> --- a/tools/intel_decode.c
> +++ b/tools/intel_decode.c
> @@ -198,7 +198,12 @@ decode_mi(uint32_t *data, int count, uint32_t hw_offset, int *failures)
> if ((data[0]& 0x1f800000)>> 23 == opcodes_mi[opcode].opcode) {
>
> instr_out(data, hw_offset, 0, "%s\n", opcodes_mi[opcode].name);
> + #ifdef ANDROID
> + int i;
> + for (i = 1; i< len; i++) {
> + #else
> for (int i = 1; i< len; i++) {
> + #endif
Like Adam said...just use gcc -std=c99 if possible. We really want C99.
> if (i>= count)
> BUFFER_FAIL(count, len, opcodes_mi[opcode].name);
> instr_out(data, hw_offset, i, "dword %d\n", i);
> @@ -1164,7 +1169,12 @@ decode_3d_1d(uint32_t *data, int count,
> break;
> case 2:
> instr_out(data, hw_offset, i, "S2: texcoord formats: ");
> + #ifdef ANDROID
> + int tex_num;
> + for (tex_num = 0; tex_num< 8; tex_num++) {
> + #else
> for (int tex_num = 0; tex_num< 8; tex_num++) {
> + #endif
> switch((data[i]>>tex_num*4)&0xf) {
> case 0: fprintf(out, "%i=2D ", tex_num); break;
> case 1: fprintf(out, "%i=3D ", tex_num); break;
> diff --git a/tools/intel_dump_decode.c b/tools/intel_dump_decode.c
> index 26d57f5..57c1261 100644
> --- a/tools/intel_dump_decode.c
> +++ b/tools/intel_dump_decode.c
> @@ -67,6 +67,10 @@ read_data_file(uint32_t devid, const char * filename)
> FILE *file;
> uint32_t *data = NULL;
> int data_size = 0, count = 0, line_number = 0, matched;
> + #ifdef ANDROID
> + char line[1024];
> + size_t line_size = 1024;
> + #else
> char *line = NULL;
> size_t line_size;
> uint32_t offset, value;
> @@ -82,9 +86,15 @@ read_data_file(uint32_t devid, const char * filename)
> filename, strerror (errno));
> exit (1);
> }
> -
> +#ifdef ANDROID
> + while (fgets (line, line_size, file) != 0) {
> + line[strcspn(line, "\n")] = '\0';
> + if (line[0] == '\0') continue;
> +#else
> while (getline (&line,&line_size, file)> 0) {
> - line_number++;
> +#endif
Rather than rewriting every use of getline(), could we just include our
own implementation of getline() in an #ifdef ANDROID block? That way,
we work around the Bionic issues in one place.
> +
> + line_number++;
>
> matched = sscanf (line, "%08x : %08x",&offset,&value);
> if (matched != 2) {
> diff --git a/tools/intel_error_decode.c b/tools/intel_error_decode.c
> index 6ffaefe..c9c74ba 100644
> --- a/tools/intel_error_decode.c
> +++ b/tools/intel_error_decode.c
> @@ -280,15 +280,27 @@ read_data_file (FILE *file)
> uint32_t *data = NULL;
> long long unsigned fence;
> int data_size = 0, count = 0, line_number = 0, matched;
> +#ifdef ANDROID
> + char line[1024];
> + size_t line_size = 1024;
> +#else
> char *line = NULL;
> size_t line_size;
> +#endif
> uint32_t offset, value;
> uint32_t gtt_offset = 0, new_gtt_offset;
> char *buffer_type[2] = { "ringbuffer", "batchbuffer" };
> char *ring_name = NULL;
> int is_batch = 1;
>
> +#ifdef ANDROID
> + while (fgets (line, line_size, file) != 0) {
> + line[strcspn(line, "\n")] = '\0';
> + if (line[0] == '\0') continue;
> +#else
> while (getline (&line,&line_size, file)> 0) {
> +#endif
> +
> char *dashes;
> line_number++;
>
> @@ -404,7 +416,9 @@ read_data_file (FILE *file)
> }
>
> free (data);
> +#ifndef ANDROID
> free (line);
> +#endif
> free (ring_name);
> }
>
> diff --git a/tools/intel_gpu_top.c b/tools/intel_gpu_top.c
> index 033ba53..b9d1ce9 100644
> --- a/tools/intel_gpu_top.c
> +++ b/tools/intel_gpu_top.c
> @@ -27,7 +27,7 @@
> *
> */
>
> -#include "config.h"
> +#include "../config.h"
>
> #include<unistd.h>
> #include<stdlib.h>
> @@ -602,10 +602,14 @@ int main(int argc, char **argv)
> /* Limit the number of lines printed to the terminal height so the
> * most important info (at the top) will stay on screen. */
> unsigned short int max_lines = -1;
> +#ifndef ANDROID
> struct winsize ws;
> if (ioctl(0, TIOCGWINSZ,&ws) != -1)
> max_lines = ws.ws_row - 6; /* exclude header lines */
> if (max_lines>= num_instdone_bits)
> + // FIXME: ioctl-types.h still does not exist in Android. Hard code
> + // the max_lines value for now (winsize is part of ioctl-types.h
> +#endif
> max_lines = num_instdone_bits;
I'm okay with an #ifndef ANDROID workaround here, but would it be better
to use MAX_INSTDONE_BITS? Also, please use
/* FIXME: ..... */
rather than the C++ style comments.
Thanks for your work on this, it'll be nice to see intel-gpu-tools on
Android!
> t2 = gettime();
> diff --git a/tools/intel_reg_write.c b/tools/intel_reg_write.c
> index c8af9bb..81bceef 100644
> --- a/tools/intel_reg_write.c
> +++ b/tools/intel_reg_write.c
> @@ -25,6 +25,8 @@
> *
> */
>
> +#include "../config.h"
> +
> #include<unistd.h>
> #include<stdlib.h>
> #include<stdio.h>
prev parent reply other threads:[~2012-01-11 7:54 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-10 4:45 [PATCH] Android port of intel-gpu-tools Sateesh Kavuri
2012-01-10 12:47 ` Daniel Vetter
2012-01-16 18:25 ` Chad Versace
2012-01-16 18:36 ` Daniel Vetter
2012-01-16 18:53 ` Chad Versace
[not found] ` <4F147225.3000604-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2012-01-16 19:52 ` [Intel-gfx] " Daniel Stone
2012-01-16 19:43 ` Eugeni Dodonov
2012-01-10 15:03 ` Adam Jackson
2012-01-10 16:50 ` Kavuri, Sateesh
2012-01-16 17:58 ` Chad Versace
2012-01-11 7:54 ` Kenneth Graunke [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4F0D4035.8050201@whitecape.org \
--to=kenneth@whitecape.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=sateesh.kavuri@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox