Skip to contentSkip to conversation

erofs-utils: lib: Explicitly include <pthread.h> where used

PATCH In review Satoshi Niwa via Linux-erofs 2 participants 2 messages Oct 8, 2024 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 erofs-utils: lib: Explicitly include <pthread.h> where used

compress.c and inode.c use pthread functions but do not explicitly include <pthread.h>. This causes build failures with the Android build system,
which throws "error: implicit declaration of function pthread_*".

---
 lib/compress.c | 3 +++
 lib/inode.c    | 3 +++
 2 files changed, 6 insertions(+)
lib/compress.c +3 -0
index 17e7112..5d6fb2a 100644
@@ -8,6 +8,9 @@
 #ifndef _LARGEFILE64_SOURCE
 #define _LARGEFILE64_SOURCE
 #endif
+#ifdef EROFS_MT_ENABLED
+#include <pthread.h>
+#endif
 #include <string.h>
 #include <stdlib.h>
 #include <unistd.h>
lib/inode.c +3 -0
index 7958d43..48f46b1 100644
@@ -6,6 +6,9 @@
  * with heavy changes by Gao Xiang <[email protected]>
  */
 #define _GNU_SOURCE
+#ifdef EROFS_MT_ENABLED
+#include <pthread.h>
+#endif
 #include <string.h>
 #include <stdlib.h>
 #include <stdio.h>
Signature · 1 line
2.47.0.rc0.187.ge670bccf7e-goog
Reviewed-by on v1 1/1
#1 lore raw

Hi Satoshi,

Quoted 4 lines · Satoshi Niwa via Linux-erofs

compress.c and inode.c use pthread functions but do not explicitly include <pthread.h>. This causes build failures with the Android build system,
which throws "error: implicit declaration of function pthread_*".

Quoted 1 line

Thanks for catching this!

Thanks,
Gao Xiang

Quoted 33 lines
---
  lib/compress.c | 3 +++
  lib/inode.c    | 3 +++
  2 files changed, 6 insertions(+)
lib/compress.c +3 -0
index 17e7112..5d6fb2a 100644
@@ -8,6 +8,9 @@
  #ifndef _LARGEFILE64_SOURCE
  #define _LARGEFILE64_SOURCE
  #endif
+#ifdef EROFS_MT_ENABLED
+#include <pthread.h>
+#endif
  #include <string.h>
  #include <stdlib.h>
  #include <unistd.h>
lib/inode.c +3 -0
index 7958d43..48f46b1 100644
@@ -6,6 +6,9 @@
   * with heavy changes by Gao Xiang <[email protected]>
   */
  #define _GNU_SOURCE
+#ifdef EROFS_MT_ENABLED
+#include <pthread.h>
+#endif
  #include <string.h>
  #include <stdlib.h>
  #include <stdio.h>