--- /dev/null
+From a36bc959768e100d2d72e027746e3a9d95cf29af Mon Sep 17 00:00:00 2001
+From: Peter Seiderer <ps.report@gmx.net>
+Date: Wed, 12 May 2021 22:08:39 +0200
+Subject: [PATCH] meson: fix getrandom detection for uclibc
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+The getrandom() detection from meson.build failes with the following error
+message:
+
+ .../host/x86_64-buildroot-linux-uclibc/sysroot/usr/include/sys/random.h:27:35: error: unknown type name 'size_t'
+ 27 | extern int getrandom(void *__buf, size_t count, unsigned int flags)
+ | ^~~~~~
+ .../host/x86_64-buildroot-linux-uclibc/sysroot/usr/include/sys/random.h:8:1: note: 'size_t' is defined in header '<stddef.h>'; did you forget to '#include <stddef.h>'?
+
+Fix it by adding stddef.h include to the meson getrandom() detection.
+
+Fixes:
+
+ ../src/pipewire/impl-core.c:54:9: error: conflicting types for ‘getrandom’
+ 54 | ssize_t getrandom(void *buf, size_t buflen, unsigned int flags) {
+ | ^~~~~~~~~
+ In file included from ../src/pipewire/impl-core.c:34:
+ .../host/x86_64-buildroot-linux-uclibc/sysroot/usr/include/sys/random.h:27:12: note: previous declaration of ‘getrandom’ was here
+ 27 | extern int getrandom(void *__buf, size_t count, unsigned int flags)
+ | ^~~~~~~~~
+
+Signed-off-by: Peter Seiderer <ps.report@gmx.net>
+---
+ meson.build | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/meson.build b/meson.build
+index 03a9d174..01b4c7c8 100644
+--- a/meson.build
++++ b/meson.build
+@@ -274,7 +274,7 @@ if cc.has_function('memfd_create', prefix : '#include <sys/mman.h>', args : [ '-
+ cdata.set('HAVE_MEMFD_CREATE', 1)
+ endif
+
+-if cc.has_function('getrandom', prefix : '#include <sys/random.h>', args : [ '-D_GNU_SOURCE' ])
++if cc.has_function('getrandom', prefix : '#include <stddef.h>\n#include <sys/random.h>', args : [ '-D_GNU_SOURCE' ])
+ cdata.set('HAVE_GETRANDOM', 1)
+ endif
+
+--
+2.31.1
+
--- /dev/null
+From 5068aa54bde4e40d6faa8de43d93216bc3001a3e Mon Sep 17 00:00:00 2001
+From: Fabrice Fontaine <fontaine.fabrice@gmail.com>
+Date: Fri, 21 May 2021 07:47:46 +0200
+Subject: [PATCH] fix linking with -latomic
+
+Linking with -latomic has been added to pipewire-jack since
+https://gitlab.freedesktop.org/pipewire/pipewire/-/commit/b8c58c74d835ee2918f9e391abd65f9e0132bdb4
+
+However, this is not the right place to add this dependency, atomic_dep
+should be added to pipewire_dep to avoid the following build failure:
+
+/home/giuliobenetti/autobuild/run/instance-0/output-1/host/opt/ext-toolchain/bin/../lib/gcc/sparc-buildroot-linux-uclibc/9.3.0/../../../../sparc-buildroot-linux-uclibc/bin/ld: src/pipewire/libpipewire-0.3.so.0.326.0.p/filter.c.o: in function `impl_node_process':
+filter.c:(.text+0xf28): undefined reference to `__atomic_fetch_add_4'
+
+Indeed, atomic operation such as __atomic_fetch_add is used in libcamera
+as well as in ./spa/plugins/libcamera/libcamera_wrapper.cpp,
+./spa/include/spa/utils/ringbuffer.h and ./spa/include/spa/graph/graph.h
+
+Fixes:
+ - http://autobuild.buildroot.org/results/b5305e8e7dd1a5e8bfaba72b06251056ba7d1af1
+
+Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
+[Upstream status:
+https://gitlab.freedesktop.org/pipewire/pipewire/-/merge_requests/689]
+---
+ meson.build | 11 +++++------
+ pipewire-jack/src/meson.build | 4 ++--
+ src/pipewire/meson.build | 4 ++--
+ 3 files changed, 9 insertions(+), 10 deletions(-)
+
+diff --git a/meson.build b/meson.build
+index b6b4553b..1308373a 100644
+--- a/meson.build
++++ b/meson.build
+@@ -157,7 +157,7 @@ test_8_byte_atomic = '''
+ int main(void)
+ {
+ int64_t eight;
+- __atomic_store_n(&eight, 123, __ATOMIC_SEQ_CST);
++ __atomic_fetch_add(&eight, 123, __ATOMIC_SEQ_CST);
+ return 0;
+ }
+ '''
+@@ -166,16 +166,15 @@ int main(void)
+ # operations on any reasonable architecture.
+ if cc.links(
+ test_8_byte_atomic,
+- name : '8-byte __atomic_store_n without libatomic')
++ name : '8-byte __atomic_fetch_add without libatomic')
+ atomic_dep = dependency('', required: false)
+ elif cc.links(
+ test_8_byte_atomic,
+ dependencies : libatomic,
+- name : '8-byte __atomic_store_n with libatomic')
++ name : '8-byte __atomic_fetch_add with libatomic')
+ atomic_dep = libatomic
+-elif get_option('pipewire-jack').enabled()
+- # Currently only required for the JACK backend
+- error('8-byte atomic operations are required for pipewire-jack')
++else
++ error('8-byte atomic operations are required')
+ endif
+
+ cdata = configuration_data()
+diff --git a/pipewire-jack/src/meson.build b/pipewire-jack/src/meson.build
+index 83e340ba..386abc7f 100644
+--- a/pipewire-jack/src/meson.build
++++ b/pipewire-jack/src/meson.build
+@@ -42,7 +42,7 @@ pipewire_jack = shared_library('jack',
+ version : libversion,
+ c_args : pipewire_jack_c_args,
+ include_directories : [configinc, jack_inc],
+- dependencies : [pipewire_dep, atomic_dep, mathlib],
++ dependencies : [pipewire_dep, mathlib],
+ install : true,
+ install_dir : libjack_path,
+ )
+@@ -53,7 +53,7 @@ pipewire_jackserver = shared_library('jackserver',
+ version : libversion,
+ c_args : pipewire_jack_c_args,
+ include_directories : [configinc, jack_inc],
+- dependencies : [pipewire_dep, atomic_dep, mathlib],
++ dependencies : [pipewire_dep, mathlib],
+ install : true,
+ install_dir : libjack_path,
+ )
+diff --git a/src/pipewire/meson.build b/src/pipewire/meson.build
+index e80f3633..0fa6643a 100644
+--- a/src/pipewire/meson.build
++++ b/src/pipewire/meson.build
+@@ -102,12 +102,12 @@ libpipewire = shared_library(pipewire_name, pipewire_sources,
+ c_args : libpipewire_c_args,
+ include_directories : [pipewire_inc, configinc, spa_inc],
+ install : true,
+- dependencies : [dl_lib, mathlib, pthread_lib, libintl_dep, ],
++ dependencies : [dl_lib, mathlib, pthread_lib, libintl_dep, atomic_dep, ],
+ )
+
+ pipewire_dep = declare_dependency(link_with : libpipewire,
+ include_directories : [pipewire_inc, configinc, spa_inc],
+- dependencies : [pthread_lib, ],
++ dependencies : [pthread_lib, atomic_dep, ],
+ )
+
+ pkgconfig.generate(filebase : 'lib@0@'.format(pipewire_name),
+--
+2.30.2
+
+++ /dev/null
-From a36bc959768e100d2d72e027746e3a9d95cf29af Mon Sep 17 00:00:00 2001
-From: Peter Seiderer <ps.report@gmx.net>
-Date: Wed, 12 May 2021 22:08:39 +0200
-Subject: [PATCH] meson: fix getrandom detection for uclibc
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-The getrandom() detection from meson.build failes with the following error
-message:
-
- .../host/x86_64-buildroot-linux-uclibc/sysroot/usr/include/sys/random.h:27:35: error: unknown type name 'size_t'
- 27 | extern int getrandom(void *__buf, size_t count, unsigned int flags)
- | ^~~~~~
- .../host/x86_64-buildroot-linux-uclibc/sysroot/usr/include/sys/random.h:8:1: note: 'size_t' is defined in header '<stddef.h>'; did you forget to '#include <stddef.h>'?
-
-Fix it by adding stddef.h include to the meson getrandom() detection.
-
-Fixes:
-
- ../src/pipewire/impl-core.c:54:9: error: conflicting types for ‘getrandom’
- 54 | ssize_t getrandom(void *buf, size_t buflen, unsigned int flags) {
- | ^~~~~~~~~
- In file included from ../src/pipewire/impl-core.c:34:
- .../host/x86_64-buildroot-linux-uclibc/sysroot/usr/include/sys/random.h:27:12: note: previous declaration of ‘getrandom’ was here
- 27 | extern int getrandom(void *__buf, size_t count, unsigned int flags)
- | ^~~~~~~~~
-
-Signed-off-by: Peter Seiderer <ps.report@gmx.net>
----
- meson.build | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/meson.build b/meson.build
-index 03a9d174..01b4c7c8 100644
---- a/meson.build
-+++ b/meson.build
-@@ -274,7 +274,7 @@ if cc.has_function('memfd_create', prefix : '#include <sys/mman.h>', args : [ '-
- cdata.set('HAVE_MEMFD_CREATE', 1)
- endif
-
--if cc.has_function('getrandom', prefix : '#include <sys/random.h>', args : [ '-D_GNU_SOURCE' ])
-+if cc.has_function('getrandom', prefix : '#include <stddef.h>\n#include <sys/random.h>', args : [ '-D_GNU_SOURCE' ])
- cdata.set('HAVE_GETRANDOM', 1)
- endif
-
---
-2.31.1
-
+++ /dev/null
-From 8f1de87381d270a8f4e5927187ae0466a9c9504a Mon Sep 17 00:00:00 2001
-From: Fabrice Fontaine <fontaine.fabrice@gmail.com>
-Date: Tue, 4 May 2021 22:56:54 +0200
-Subject: [PATCH] meson.build: fix build with uclibc-ng
-
-Build with uclib-ng fails since commit
-a4b0b9afe5a782a7f4a8fe153ecf51bcb0180ae3 on:
-
-FAILED: src/pipewire/libpipewire-0.3.so.0.326.0.p/impl-core.c.o
-/srv/storage/autobuild/run/instance-2/output-1/host/bin/mips64el-linux-gcc -Isrc/pipewire/libpipewire-0.3.so.0.326.0.p -Isrc/pipewire -I../src/pipewire -Isrc -I../src -I. -I.. -Ispa/include -I../spa/include -fdiagnostics-color=always -pipe -Wall -Winvalid-pch -Wextra -Wpedantic -std=gnu99 -O3 -fvisibility=hidden -Werror=suggest-attribute=format -Wsign-compare -Wpointer-arith -Wpointer-sign -Wformat -Wformat-security -Wimplicit-fallthrough -Wmissing-braces -Wtype-limits -Wvariadic-macros -Wno-missing-field-initializers -Wno-unused-parameter -Wno-pedantic -Wold-style-declaration -Wunused-result -DFASTPATH -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Os -fPIC -pthread -DHAVE_CONFIG_H -D_GNU_SOURCE -D_POSIX_C_SOURCE -MD -MQ src/pipewire/libpipewire-0.3.so.0.326.0.p/impl-core.c.o -MF src/pipewire/libpipewire-0.3.so.0.326.0.p/impl-core.c.o.d -o src/pipewire/libpipewire-0.3.so.0.326.0.p/impl-core.c.o -c ../src/pipewire/impl-core.c
-../src/pipewire/impl-core.c:54:9: error: conflicting types for 'getrandom'
- ssize_t getrandom(void *buf, size_t buflen, unsigned int flags) {
- ^~~~~~~~~
-In file included from ../src/pipewire/impl-core.c:34:
-/srv/storage/autobuild/run/instance-2/output-1/host/mips64el-buildroot-linux-uclibc/sysroot/usr/include/sys/random.h:28:12: note: previous declaration of 'getrandom' was here
- extern int getrandom(void *__buf, size_t count, unsigned int flags)
- ^~~~~~~~~
-
-Fix this build failure by adding -D_GNU_SOURCE as getrandom is protected
-by:
-
-if defined __UCLIBC_LINUX_SPECIFIC__ && defined __USE_GNU
-
-Extracted from:
- - https://github.com/wbx-github/uclibc-ng/blob/master/libc/sysdeps/linux/common/sys/random.h
-
-Fixes:
- - http://autobuild.buildroot.org/results/a45f0ee009d90cef867dee4b1093225610fa10df
-
-Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
-[Upstream status:
-https://gitlab.freedesktop.org/pipewire/pipewire/-/merge_requests/649]
----
- meson.build | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/meson.build b/meson.build
-index 0a9963fb..11b63c08 100644
---- a/meson.build
-+++ b/meson.build
-@@ -274,7 +274,7 @@ if cc.has_function('memfd_create', prefix : '#include <sys/mman.h>', args : [ '-
- cdata.set('HAVE_MEMFD_CREATE', 1)
- endif
-
--if cc.has_function('getrandom', prefix : '#include <sys/random.h>')
-+if cc.has_function('getrandom', prefix : '#include <sys/random.h>', args : [ '-D_GNU_SOURCE' ])
- cdata.set('HAVE_GETRANDOM', 1)
- endif
-
---
-2.30.2
-
+++ /dev/null
-From 5068aa54bde4e40d6faa8de43d93216bc3001a3e Mon Sep 17 00:00:00 2001
-From: Fabrice Fontaine <fontaine.fabrice@gmail.com>
-Date: Fri, 21 May 2021 07:47:46 +0200
-Subject: [PATCH] fix linking with -latomic
-
-Linking with -latomic has been added to pipewire-jack since
-https://gitlab.freedesktop.org/pipewire/pipewire/-/commit/b8c58c74d835ee2918f9e391abd65f9e0132bdb4
-
-However, this is not the right place to add this dependency, atomic_dep
-should be added to pipewire_dep to avoid the following build failure:
-
-/home/giuliobenetti/autobuild/run/instance-0/output-1/host/opt/ext-toolchain/bin/../lib/gcc/sparc-buildroot-linux-uclibc/9.3.0/../../../../sparc-buildroot-linux-uclibc/bin/ld: src/pipewire/libpipewire-0.3.so.0.326.0.p/filter.c.o: in function `impl_node_process':
-filter.c:(.text+0xf28): undefined reference to `__atomic_fetch_add_4'
-
-Indeed, atomic operation such as __atomic_fetch_add is used in libcamera
-as well as in ./spa/plugins/libcamera/libcamera_wrapper.cpp,
-./spa/include/spa/utils/ringbuffer.h and ./spa/include/spa/graph/graph.h
-
-Fixes:
- - http://autobuild.buildroot.org/results/b5305e8e7dd1a5e8bfaba72b06251056ba7d1af1
-
-Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
-[Upstream status:
-https://gitlab.freedesktop.org/pipewire/pipewire/-/merge_requests/689]
----
- meson.build | 11 +++++------
- pipewire-jack/src/meson.build | 4 ++--
- src/pipewire/meson.build | 4 ++--
- 3 files changed, 9 insertions(+), 10 deletions(-)
-
-diff --git a/meson.build b/meson.build
-index b6b4553b..1308373a 100644
---- a/meson.build
-+++ b/meson.build
-@@ -157,7 +157,7 @@ test_8_byte_atomic = '''
- int main(void)
- {
- int64_t eight;
-- __atomic_store_n(&eight, 123, __ATOMIC_SEQ_CST);
-+ __atomic_fetch_add(&eight, 123, __ATOMIC_SEQ_CST);
- return 0;
- }
- '''
-@@ -166,16 +166,15 @@ int main(void)
- # operations on any reasonable architecture.
- if cc.links(
- test_8_byte_atomic,
-- name : '8-byte __atomic_store_n without libatomic')
-+ name : '8-byte __atomic_fetch_add without libatomic')
- atomic_dep = dependency('', required: false)
- elif cc.links(
- test_8_byte_atomic,
- dependencies : libatomic,
-- name : '8-byte __atomic_store_n with libatomic')
-+ name : '8-byte __atomic_fetch_add with libatomic')
- atomic_dep = libatomic
--elif get_option('pipewire-jack').enabled()
-- # Currently only required for the JACK backend
-- error('8-byte atomic operations are required for pipewire-jack')
-+else
-+ error('8-byte atomic operations are required')
- endif
-
- cdata = configuration_data()
-diff --git a/pipewire-jack/src/meson.build b/pipewire-jack/src/meson.build
-index 83e340ba..386abc7f 100644
---- a/pipewire-jack/src/meson.build
-+++ b/pipewire-jack/src/meson.build
-@@ -42,7 +42,7 @@ pipewire_jack = shared_library('jack',
- version : libversion,
- c_args : pipewire_jack_c_args,
- include_directories : [configinc, jack_inc],
-- dependencies : [pipewire_dep, atomic_dep, mathlib],
-+ dependencies : [pipewire_dep, mathlib],
- install : true,
- install_dir : libjack_path,
- )
-@@ -53,7 +53,7 @@ pipewire_jackserver = shared_library('jackserver',
- version : libversion,
- c_args : pipewire_jack_c_args,
- include_directories : [configinc, jack_inc],
-- dependencies : [pipewire_dep, atomic_dep, mathlib],
-+ dependencies : [pipewire_dep, mathlib],
- install : true,
- install_dir : libjack_path,
- )
-diff --git a/src/pipewire/meson.build b/src/pipewire/meson.build
-index e80f3633..0fa6643a 100644
---- a/src/pipewire/meson.build
-+++ b/src/pipewire/meson.build
-@@ -102,12 +102,12 @@ libpipewire = shared_library(pipewire_name, pipewire_sources,
- c_args : libpipewire_c_args,
- include_directories : [pipewire_inc, configinc, spa_inc],
- install : true,
-- dependencies : [dl_lib, mathlib, pthread_lib, libintl_dep, ],
-+ dependencies : [dl_lib, mathlib, pthread_lib, libintl_dep, atomic_dep, ],
- )
-
- pipewire_dep = declare_dependency(link_with : libpipewire,
- include_directories : [pipewire_inc, configinc, spa_inc],
-- dependencies : [pthread_lib, ],
-+ dependencies : [pthread_lib, atomic_dep, ],
- )
-
- pkgconfig.generate(filebase : 'lib@0@'.format(pipewire_name),
---
-2.30.2
-