Skip to contentSkip to conversation

tools/thermal: tmon: include pthread and time headers in tmon.h

PATCH In review Markus Mayer 4 participants 4 messages Jun 17, 2020 – Aug 9, 2020 Thermal

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tools/thermal: tmon: include pthread and time headers in tmon.h

Include sys/time.h and pthread.h in tmon.h, so that types "pthread_mutex_t" and "struct timeval tv" are known when tmon.h references them.

Without these headers, compiling tmon against musl-libc will fail with these errors:

In file included from sysfs.c:31:0:
tmon.h:47:8: error: unknown type name 'pthread_mutex_t'

 extern pthread_mutex_t input_lock;
        ^~~~~~~~~~~~~~~

make[3]: *** [<builtin>: sysfs.o] Error 1 make[3]: *** Waiting for unfinished jobs.... In file included from tui.c:31:0:
tmon.h:54:17: error: field 'tv' has incomplete type

  struct timeval tv;
                 ^~

make[3]: *** [<builtin>: tui.o] Error 1
make[2]: *** [Makefile:83: tmon] Error 2

---

The issue was discovered cross-compiling tmon for aarch64 with musl-libc. The build succeeds with glibc, because the required headers are included implicitly. This is not the case with musl-libc.

 tools/thermal/tmon/tmon.h | 3 +++
 1 file changed, 3 insertions(+)
tools/thermal/tmon/tmon.h +3 -0
index c9066ec104dd..44d16d778f04 100644
@@ -27,6 +27,9 @@
 #define NR_LINES_TZDATA 1
 #define TMON_LOG_FILE "/var/tmp/tmon.log"
 
+#include <sys/time.h>
+#include <pthread.h>
+
 extern unsigned long ticktime;
 extern double time_elapsed;
 extern unsigned long target_temp_user;
Signature · 1 line
2.17.1
Acked-by on v1 1/1
#1 lore raw
Quoted 15 lines · Markus Mayer

Include sys/time.h and pthread.h in tmon.h, so that types "pthread_mutex_t" and "struct timeval tv" are known when tmon.h references them.

Without these headers, compiling tmon against musl-libc will fail with these errors:

In file included from sysfs.c:31:0:
tmon.h:47:8: error: unknown type name 'pthread_mutex_t'

 extern pthread_mutex_t input_lock;
        ^~~~~~~~~~~~~~~

make[3]: *** [<builtin>: sysfs.o] Error 1 make[3]: *** Waiting for unfinished jobs.... In file included from tui.c:31:0:
tmon.h:54:17: error: field 'tv' has incomplete type

Quoted 6 lines
  struct timeval tv;
                 ^~

make[3]: *** [<builtin>: tui.o] Error 1
make[2]: *** [Makefile:83: tmon] Error 2

Signature · 1 line
Florian
Reviewed-by
#2 lore raw
Quoted 35 lines

-----Original Message-----
From: Florian Fainelli <[email protected]>
Sent: Thursday, June 18, 2020 8:23 AM
To: Markus Mayer <[email protected]>; Daniel Lezcano <[email protected]>; Pawnikar, Sumeet R <[email protected]>; Zhang, Rui <[email protected]>; Brian Norris <[email protected]>
Cc: Broadcom Kernel List <[email protected]>; Linux Kernel Mailing List <[email protected]>
Subject: Re: [PATCH] tools/thermal: tmon: include pthread and time headers in tmon.h

Quoted 20 lines · Markus Mayer

Include sys/time.h and pthread.h in tmon.h, so that types "pthread_mutex_t" and "struct timeval tv" are known when tmon.h references them.

Without these headers, compiling tmon against musl-libc will fail with these errors:

In file included from sysfs.c:31:0:
tmon.h:47:8: error: unknown type name 'pthread_mutex_t'

 extern pthread_mutex_t input_lock;
        ^~~~~~~~~~~~~~~

make[3]: *** [<builtin>: sysfs.o] Error 1 make[3]: *** Waiting for unfinished jobs.... In file included from tui.c:31:0:
tmon.h:54:17: error: field 'tv' has incomplete type

  struct timeval tv;
                 ^~

make[3]: *** [<builtin>: tui.o] Error 1
make[2]: *** [Makefile:83: tmon] Error 2

Quoted 5 lines
Quoted 1 line

--
Florian

Thanks,
Sumeet.

Acked-by Tested-by
#3 lore raw
Quoted 37 lines
Quoted 37 lines

-----Original Message-----
From: Florian Fainelli <[email protected]>
Sent: Thursday, June 18, 2020 8:23 AM
To: Markus Mayer <[email protected]>; Daniel Lezcano <[email protected]>; Pawnikar, Sumeet R <[email protected]>; Zhang, Rui <[email protected]>; Brian Norris <[email protected]>
Cc: Broadcom Kernel List <[email protected]>; Linux Kernel Mailing List <[email protected]>
Subject: Re: [PATCH] tools/thermal: tmon: include pthread and time headers in tmon.h

Quoted 21 lines · Markus Mayer

Include sys/time.h and pthread.h in tmon.h, so that types "pthread_mutex_t" and "struct timeval tv" are known when tmon.h references them.

Without these headers, compiling tmon against musl-libc will fail with these errors:

In file included from sysfs.c:31:0:
tmon.h:47:8: error: unknown type name 'pthread_mutex_t'

 extern pthread_mutex_t input_lock;
        ^~~~~~~~~~~~~~~

make[3]: *** [<builtin>: sysfs.o] Error 1 make[3]: *** Waiting for unfinished jobs.... In file included from tui.c:31:0:
tmon.h:54:17: error: field 'tv' has incomplete type

  struct timeval tv;
                 ^~

make[3]: *** [<builtin>: tui.o] Error 1
make[2]: *** [Makefile:83: tmon] Error 2

Quoted 8 lines
Quoted 3 lines

--
Florian

Thanks,
Sumeet.

I've tested this patch with musl-libc for the same arch. It works like a charm.