[pulseaudio-commits] [Git][pulseaudio/pulseaudio][master] 6 commits: build-sys: meson: Add atomic ops related checks

Arun Raghavan gitlab at gitlab.freedesktop.org
Sat Aug 17 07:16:51 UTC 2019



Arun Raghavan pushed to branch master at PulseAudio / pulseaudio


Commits:
1e996445 by Arun Raghavan at 2019-08-15T13:27:13Z
build-sys: meson: Add atomic ops related checks

- - - - -
c90fa7f8 by Arun Raghavan at 2019-08-15T13:27:13Z
build-sys: meson: Add ARMv6 instruction check

- - - - -
cd8dfee9 by Arun Raghavan at 2019-08-15T13:27:13Z
build-sys: meson: Add a check for fast 64-bit operations

- - - - -
2b0a3305 by Arun Raghavan at 2019-08-15T13:27:13Z
build-sys: meson: Add some missing declaration checks

- - - - -
0f1920f3 by Arun Raghavan at 2019-08-15T13:27:13Z
build-sys: meson: Add mkfifo checks for module-pipe-*

- - - - -
27e72814 by Arun Raghavan at 2019-08-15T13:27:13Z
build-sys: meson: Add a bunch of missing checks

- - - - -


9 changed files:

- meson.build
- meson_options.txt
- src/daemon/meson.build
- src/modules/alsa/meson.build
- src/modules/echo-cancel/meson.build
- src/modules/meson.build
- src/modules/rtp/meson.build
- src/pulsecore/meson.build
- src/tests/meson.build


Changes:

=====================================
meson.build
=====================================
@@ -167,6 +167,14 @@ elif host_machine.system() == 'windows'
 #  cdata.set('__EXTENSIONS__', 1)
 endif
 
+if cc.has_type('_Bool')
+  cdata.set('HAVE_STD_BOOL', 1)
+endif
+
+if host_machine.cpu_family() == 'x86_64' or cc.sizeof('void *') >= 8
+  cdata.set('HAVE_FAST_64BIT_OPERATIONS', 1)
+endif
+
 # Headers
 
 check_headers = [
@@ -190,7 +198,9 @@ check_headers = [
   'regex.h',
   'sched.h',
   'stdint.h',
+  'sys/atomic.h',
   'sys/capability.h',
+  'sys/conf.h',
   'sys/dl.h',
   'sys/eventfd.h',
   'sys/filio.h',
@@ -221,6 +231,10 @@ if cc.has_header('pthread.h')
   cdata.set('HAVE_PTHREAD', 1)
 endif
 
+if cc.has_header_symbol('pthread.h', 'PTHREAD_PRIO_INHERIT')
+  cdata.set('HAVE_PTHREAD_PRIO_INHERIT', 1)
+endif
+
 # Functions
 
 check_functions = [
@@ -295,6 +309,20 @@ if not cc.has_header_symbol('netinet/in.h', 'INADDR_NONE')
   endif
 endif
 
+check_decls = [
+  [ 'environ', 'unistd.h', '#define _GNU_SOURCE' ],
+  [ 'SOUND_PCM_READ_RATE', 'sys/soundcard.h', '' ],
+  [ 'SOUND_PCM_READ_CHANNELS', 'sys/soundcard.h', '' ],
+  [ 'SOUND_PCM_READ_BITS', 'sys/soundcard.h', '' ],
+]
+
+foreach s : check_decls
+  if cc.has_header_symbol(s[1], s[0], prefix : s[2])
+    define = 'HAVE_DECL_' + s[0].to_upper()
+    cdata.set(define, 1)
+  endif
+endforeach
+
 # Types
 
 # FIXME: do we ever care about gid_t not being defined / smaller than an int?
@@ -371,12 +399,23 @@ size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, si
   endif
 endif
 
+# Atomic operations
+
+if get_option('atomic-arm-memory-barrier')
+    cdata.set('ATOMIC_ARM_MEMORY_BARRIER_ENABLED', 1)
+endif
+
+need_libatomic_ops = false
+
 atomictest = '''void func() {
   volatile int atomic = 2;
   __sync_bool_compare_and_swap (&atomic, 2, 3);
 }
 '''
+
 if cc.compiles(atomictest)
+  cdata.set('HAVE_ATOMIC_BUILTINS', 1)
+
   newatomictest = '''void func() {
     int c = 0;
     __atomic_store_n(&c, 4, __ATOMIC_SEQ_CST);
@@ -384,13 +423,73 @@ if cc.compiles(atomictest)
   '''
 
   if(cc.compiles(newatomictest))
-    cdata.set('HAVE_ATOMIC_BUILTINS_MEMORY_MODEL', true)
+    cdata.set('HAVE_ATOMIC_BUILTINS_MEMORY_MODEL', 1)
   endif
 
-  cdata.set('HAVE_ATOMIC_BUILTINS', true)
+elif host_machine.cpu_family() == 'arm'
+  if host_machine.system() == 'linux' and get_option('atomic-arm-linux-helpers')
+    cdata.set('ATOMIC_ARM_LINUX_HELPERS', 1)
+  else
+    armatomictest = '''void func() {
+      volatile int a=0;
+      int o=0, n=1, r;
+      asm volatile ("ldrex    %0, [%1]\n"
+      "subs  %0, %0, %2\n"
+      "strexeq %0, %3, [%1]\n"
+      : "=&r" (r)
+      : "r" (&a), "Ir" (o), "r" (n)
+      : "cc");
+      return (a==1 ? 0 : -1);
+    '''
+
+    if cc.compiles(aratomictest)
+      cdata.set('ATOMIC_ARM_INLINE_ASM', 1)
+    else
+      need_libatomic_ops = true
+    endif
+  endif # arm && !linux
+
+elif not ['freebsd', 'netbsd'].contains(host_machine.system())
+  need_libatomic_ops = true
+endif # !atomic helpers && !arm
+
+if need_libatomic_ops
+  assert(cc.has_header('atomic_ops.h'), 'Need libatomic_ops')
+
+  cdata.set('AO_REQUIRE_CAS', 1)
+
+  if host_machine.system() != 'windows'
+    libatomic_ops_dep = cc.find_library('atomic_ops', required : true)
+  else
+    libatomic_ops_dep = dependency('', required: false)
+  endif
 else
-  # FIXME: check if we need libatomic_ops
+  libatomic_ops_dep = dependency('', required: false)
+endif
+
+# ARM checks
+# ARMV6 instructions we need
+if host_machine.cpu_family() == 'arm'
+  armv6test = '''void func() {
+    volatile int a = -60000, b = 0xaaaabbbb, c = 0xccccdddd;
+    asm volatile ("ldr r0, %2 \n"
+                  "ldr r2, %3 \n"
+                  "ldr r3, %4 \n"
+                  "ssat r1, #8, r0 \n"
+                  "str r1, %0 \n"
+                  "pkhbt r1, r3, r2, LSL #8 \n"
+                  "str r1, %1 \n"
+                  : "=m" (a), "=m" (b)
+                  : "m" (a), "m" (b), "m" (c)
+                  : "r0", "r1", "r2", "r3", "cc");
+    return (a == -128 && b == 0xaabbdddd) ? 0 : -1;
+  '''
+
+  if cc.compiles(armv6test)
+    cdata.set('HAVE_ARMV6', 1)
+  endif
 endif
+# NEON checks are automatically done by the unstable-simd module
 
 # FIXME: make sure it's >= 2.2
 ltdl_dep = cc.find_library('ltdl', required : true)


=====================================
meson_options.txt
=====================================
@@ -27,6 +27,12 @@ option('legacy-database-entry-format',
 option('running-from-build-tree',
        type : 'boolean',
        description : 'Enable running from build tree')
+option('atomic-arm-linux-helpers',
+       type : 'boolean', value : true,
+       description : 'Use inline asm or libatomic_ops instead')
+option('atomic-arm-memory-barrier',
+       type : 'boolean', value : false,
+       description : 'Enable memory barriers (only really needed in SMP arm systems)')
 
 # Paths
 


=====================================
src/daemon/meson.build
=====================================
@@ -94,6 +94,7 @@ default_conf.set('PA_BINARY', cdata.get_unquoted('PA_BINARY'))
 default_conf.set('PA_SOEXT', cdata.get_unquoted('PA_SOEXT'))
 default_conf.set10('HAVE_AF_UNIX', cc.has_header('sys/un.h'))
 default_conf.set10('OS_IS_WIN32', host_machine.system() == 'windows')
+default_conf.set10('HAVE_MKFIFO', cc.has_function('mkfifo'))
 # We don't support the deprecated GConf option in meson
 default_conf.set10('HAVE_GCONF', 0)
 


=====================================
src/modules/alsa/meson.build
=====================================
@@ -32,7 +32,7 @@ libalsa_util = shared_library('alsa-util',
   c_args : [pa_c_args, server_c_args],
   link_args : [nodelete_link_args],
   include_directories : [configinc, topinc],
-  dependencies : [libpulse_dep, libpulsecommon_dep, libpulsecore_dep, alsa_dep, dbus_dep, libm_dep, udev_dep],
+  dependencies : [libpulse_dep, libpulsecommon_dep, libpulsecore_dep, alsa_dep, dbus_dep, libatomic_ops_dep, libm_dep, udev_dep],
   install : true,
   install_rpath : privlibdir,
   install_dir : modlibexecdir,


=====================================
src/modules/echo-cancel/meson.build
=====================================
@@ -14,7 +14,7 @@ libwebrtc_util = shared_library('webrtc-util',
   libwebrtc_util_sources,
   cpp_args : [pa_c_args, server_c_args],
   include_directories : [configinc, topinc],
-  dependencies : [libpulse_dep, libpulsecommon_dep, libpulsecore_dep, webrtc_dep],
+  dependencies : [libpulse_dep, libpulsecommon_dep, libpulsecore_dep, libatomic_ops_dep, webrtc_dep],
   link_args : [nodelete_link_args, '-Wl,--unresolved-symbols=ignore-in-object-files'],
   install : true,
   install_rpath : privlibdir,


=====================================
src/modules/meson.build
=====================================
@@ -38,8 +38,6 @@ all_modules = [
   [ 'module-native-protocol-unix', 'module-protocol-stub.c', [], ['-DUSE_PROTOCOL_NATIVE', '-DUSE_UNIX_SOCKETS'], [], libprotocol_native ],
   [ 'module-null-sink', 'module-null-sink.c' ],
   [ 'module-null-source', 'module-null-source.c' ],
-  [ 'module-pipe-sink', 'module-pipe-sink.c' ],
-  [ 'module-pipe-source', 'module-pipe-source.c' ],
   [ 'module-position-event-sounds', 'module-position-event-sounds.c' ],
   [ 'module-remap-sink', 'module-remap-sink.c' ],
   [ 'module-remap-source', 'module-remap-source.c' ],
@@ -83,6 +81,13 @@ if cc.has_header('sys/soundcard.h')
   ]
 endif
 
+if cc.has_function('mkfifo')
+  all_modules += [
+    [ 'module-pipe-sink', 'module-pipe-sink.c' ],
+    [ 'module-pipe-source', 'module-pipe-source.c' ]
+  ]
+endif
+
 # Modules enabled by dependencies
 
 if alsa_dep.found()


=====================================
src/modules/rtp/meson.build
=====================================
@@ -20,7 +20,7 @@ librtp = shared_library('rtp',
   c_args : [pa_c_args, server_c_args],
   link_args : [nodelete_link_args],
   include_directories : [configinc, topinc],
-  dependencies : [libpulse_dep, libpulsecommon_dep, libpulsecore_dep],
+  dependencies : [libpulse_dep, libpulsecommon_dep, libpulsecore_dep, libatomic_ops_dep],
   install : true,
   install_rpath : privlibdir,
   install_dir : modlibexecdir,


=====================================
src/pulsecore/meson.build
=====================================
@@ -198,7 +198,7 @@ libpulsecore = shared_library('pulsecore-' + pa_version_major_minor,
   install_rpath : privlibdir,
   install_dir : privlibdir,
   link_with : libpulsecore_simd_lib,
-  dependencies : [libm_dep, libpulsecommon_dep, libpulse_dep, ltdl_dep, shm_dep, sndfile_dep, database_dep, dbus_dep, orc_dep, samplerate_dep, soxr_dep, speex_dep, x11_dep],
+  dependencies : [libm_dep, libpulsecommon_dep, libpulse_dep, ltdl_dep, shm_dep, sndfile_dep, database_dep, dbus_dep, libatomic_ops_dep, orc_dep, samplerate_dep, soxr_dep, speex_dep, x11_dep],
   implicit_include_directories : false)
 
 libpulsecore_dep = declare_dependency(link_with: libpulsecore)


=====================================
src/tests/meson.build
=====================================
@@ -82,7 +82,7 @@ endif
 if host_machine.system() != 'darwin'
   default_tests += [
     [ 'once-test', 'once-test.c',
-      [ check_dep, thread_dep, libpulse_dep, libpulsecommon_dep, libpulsecore_dep ] ],
+      [ check_dep, thread_dep, libpulse_dep, libpulsecommon_dep, libpulsecore_dep, libatomic_ops_dep ] ],
   ]
 endif
 



View it on GitLab: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/compare/25308fe88f83bed2f4554bdaf6cefa8e18100c3f...27e72814d0921c43c31071fa2cbd0e23f4638af5

-- 
View it on GitLab: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/compare/25308fe88f83bed2f4554bdaf6cefa8e18100c3f...27e72814d0921c43c31071fa2cbd0e23f4638af5
You're receiving this email because of your account on gitlab.freedesktop.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/pulseaudio-commits/attachments/20190817/0fc37bb2/attachment-0001.html>


More information about the pulseaudio-commits mailing list