]> git.alsa-project.org Git - alsa-lib.git/commitdiff
pcm: dmix: assembly: fix the interface for safety (mmx)
authorFrédéric Recoules <frederic.recoules@orange.fr>
Wed, 6 May 2020 17:19:22 +0000 (19:19 +0200)
committerTakashi Iwai <tiwai@suse.de>
Wed, 6 May 2020 20:26:04 +0000 (22:26 +0200)
- add mm0 in the clobber list if the compiler
  is aware of the mmx technology;
- otherwise, add the mmx aliased x87 floating point
  registers in the clobbers;
- the configure now checks if the compiler is aware of
  the MMX technology.

  The compiler assumes none of the mmx or x87 registers are used
  by the function. If it chooses to store some data in them, they
  will be overwritten by the chunk.
  Recall that any mmx instruction invalidate the whole set of
  x87 floating point registers.

  Note: currently does not impact the binary output.

Signed-off-by: Frédéric Recoules <frederic.recoules@orange.fr>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
configure.ac
src/pcm/pcm_dmix_i386.h
src/pcm/pcm_dmix_x86_64.h

index 4b5ab6628bffbfa82e2cddd1167b7bd812d00a95..1838e50bc9e1717fba6339a0cb712f1612c35486 100644 (file)
@@ -516,6 +516,13 @@ if test -z "$gcc_have_atomics"; then
 fi
 AC_MSG_RESULT($gcc_have_atomics)
 
+dnl check mmx register for pcm_dmix_i386
+
+AC_TRY_LINK([],
+    [__asm__ volatile ("" : : : "mm0");],
+    [AC_DEFINE([HAVE_MMX], "1", [MMX technology is enabled])],
+    [])
+
 PCM_PLUGIN_LIST="copy linear route mulaw alaw adpcm rate plug multi shm file null empty share meter hooks lfloat ladspa dmix dshare dsnoop asym iec958 softvol extplug ioplug mmap_emul"
 
 build_pcm_plugin="no"
index 3ea0737d71f53bbfba074adddaaa42bdbaa3d400..5c900bf112334bb1ce61dc8764c28426d0301e5d 100644 (file)
@@ -237,6 +237,12 @@ static void MIX_AREAS_16_MMX(unsigned int size,
                  [dst_step] "m" (dst_step),  [src_step] "m" (src_step),
                  [sum_step] "m" (sum_step)
                : "esi", "edi", "edx", "ecx", "eax", "memory", "cc"
+#ifdef HAVE_MMX
+                 , "mm0"
+#else
+                 , "st", "st(1)", "st(2)", "st(3)",
+                 "st(4)", "st(5)", "st(6)", "st(7)"
+#endif
        );
 }
 
index 7f711547d0f3a5515e489b09adfb358e9eb3c83e..803d3b2409f6108620283cc232e2419369533729 100644 (file)
@@ -119,6 +119,12 @@ static void MIX_AREAS_16(unsigned int size,
                  [dst_step] "m" (dst_step),  [src_step] "m" (src_step),
                  [sum_step] "m" (sum_step)
                : "rsi", "rdi", "edx", "ecx", "eax", "memory", "cc"
+#ifdef HAVE_MMX
+                 , "mm0"
+#else
+                 , "st", "st(1)", "st(2)", "st(3)",
+                 "st(4)", "st(5)", "st(6)", "st(7)"
+#endif
        );
 }