new file mode 100644
@@ -0,0 +1,54 @@
+From 79381ab335898c9184e22dd25b544adefa9bf6c5 Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Mon, 7 Feb 2022 16:26:57 -0800
+Subject: [PATCH] librewrite: include ldap_pvt_thread.h before redefining
+ calloc
+
+This helps compiling with musl, where sched.h is included by
+ldap_pvt_thread.h which provides prototype for calloc() and conflicts
+
+/usr/include/sched.h:84:7: error: conflicting types for 'ber_memcalloc'
+| void *calloc(size_t, size_t);
+| ^1
+| warning and 1 error generated.
+| ./rewrite-int.h:44:21: note: expanded from macro 'calloc'
+| #define calloc(x,y) ber_memcalloc(x,y)
+| ^
+
+Upstream-Status: Pending
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+ libraries/librewrite/rewrite-int.h | 10 +++++-----
+ 1 file changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/libraries/librewrite/rewrite-int.h b/libraries/librewrite/rewrite-int.h
+index 4481dd3..5ec226d 100644
+--- a/libraries/librewrite/rewrite-int.h
++++ b/libraries/librewrite/rewrite-int.h
+@@ -40,6 +40,11 @@
+
+ #include <rewrite.h>
+
++#ifndef NO_THREADS
++#define USE_REWRITE_LDAP_PVT_THREADS
++#include <ldap_pvt_thread.h>
++#endif
++
+ #define malloc(x) ber_memalloc(x)
+ #define calloc(x,y) ber_memcalloc(x,y)
+ #define realloc(x,y) ber_memrealloc(x,y)
+@@ -47,11 +52,6 @@
+ #undef strdup
+ #define strdup(x) ber_strdup(x)
+
+-#ifndef NO_THREADS
+-#define USE_REWRITE_LDAP_PVT_THREADS
+-#include <ldap_pvt_thread.h>
+-#endif
+-
+ /*
+ * For details, see RATIONALE.
+ */
+--
+2.35.1
+
@@ -23,6 +23,7 @@ SRC_URI = "http://www.openldap.org/software/download/OpenLDAP/openldap-release/$
file://0001-ldif-filter-fix-parallel-build-failure.patch \
file://0001-build-top.mk-unset-STRIP_OPTS.patch \
file://0001-libraries-Makefile.in-ignore-the-mkdir-errors.patch \
+ file://0001-librewrite-include-ldap_pvt_thread.h-before-redefini.patch \
"
SRC_URI[md5sum] = "237fc2d881c27f8dd5d9f396e2865c11"
Signed-off-by: Khem Raj <raj.khem@gmail.com> --- ...de-ldap_pvt_thread.h-before-redefini.patch | 54 +++++++++++++++++++ .../openldap/openldap_2.5.9.bb | 1 + 2 files changed, 55 insertions(+) create mode 100644 meta-oe/recipes-support/openldap/openldap/0001-librewrite-include-ldap_pvt_thread.h-before-redefini.patch