Skip to contentSkip to conversation

alsamixer: define _GNU_SOURCE to get exp10

PATCH Applied [email protected] 2 participants 4 messages Jan 16, 2019 – Jan 18, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 alsamixer: define _GNU_SOURCE to get exp10

Fixes Master, Headphones and Speaker stuck at -8 percentage after building with Clang 7.0.1 and getting warned about implicit declaration of exp10, which is behind _GNU_SOURCE as a non-standard feature. Thanks Takashi Iwai for the CFLAGS suggestion on the mailing list. GCC build is not affected, so not adding a compiler check to the configure script.

uClibc-ng has got exp10 since 1.0.12, so the fallback macro is no longer needed. However, alsa-utils relies on gettext so might need further patches to actually work on uClibc systems.

alsamixer/volume_mapping.c +0 -5
index 94bd0fe..48cfbe2 100644
@@ -36,11 +36,6 @@
 #include <stdbool.h>
 #include "volume_mapping.h"
 
-#ifdef __UCLIBC__
-/* 10^x = 10^(log e^x) = (e^x)^log10 = e^(x * log 10) */
-#define exp10(x) (exp((x) * log(10)))
-#endif /* __UCLIBC__ */
-
 #define MAX_LINEAR_DB_SCALE    24
 
 static inline bool use_linear_dB_scale(long dBmin, long dBmax)
configure.ac +2 -0
index 7938996..0d54942 100644
@@ -350,6 +350,8 @@ if test x$alsamixer = xtrue; then
 
 
   AC_MSG_RESULT([$CURSESLIB])
+
+  CFLAGS="$CFLAGS -D_GNU_SOURCE"
 
 
 AC_SUBST(CURSESINC)
Signature · 1 line
2.20.1
#1 lore raw

Dne 16.1.2019 v 02:35 [email protected] napsal(a):

Quoted 33 lines

Fixes Master, Headphones and Speaker stuck at -8 percentage after building with Clang 7.0.1 and getting warned about implicit declaration of exp10, which is behind _GNU_SOURCE as a non-standard feature. Thanks Takashi Iwai for the CFLAGS suggestion on the mailing list. GCC build is not affected, so not adding a compiler check to the configure script.

uClibc-ng has got exp10 since 1.0.12, so the fallback macro is no longer needed. However, alsa-utils relies on gettext so might need further patches to actually work on uClibc systems.

alsamixer/volume_mapping.c +0 -5
index 94bd0fe..48cfbe2 100644
@@ -36,11 +36,6 @@
  #include <stdbool.h>
  #include "volume_mapping.h"
 
-#ifdef __UCLIBC__
-/* 10^x = 10^(log e^x) = (e^x)^log10 = e^(x * log 10) */
-#define exp10(x) (exp((x) * log(10)))
-#endif /* __UCLIBC__ */
-
  #define MAX_LINEAR_DB_SCALE    24
 
  static inline bool use_linear_dB_scale(long dBmin, long dBmax)
configure.ac +0 -0
index 7938996..0d54942 100644

configure.ac if test x$alsamixer = xtrue; then · line 354

Quoted 5 lines
configure.ac +2 -0
@@ -350,6 +350,8 @@ if test x$alsamixer = xtrue; then
 
 
    AC_MSG_RESULT([$CURSESLIB])
+
+  CFLAGS="$CFLAGS -D_GNU_SOURCE"

It would be propably better to put this to the local makefile for alsamixer:

alsamixer/Makefile.am +1 -1
index 259b29e..249e8f8 100644
@@ -1,4 +1,4 @@
-AM_CFLAGS = @CURSES_CFLAGS@ -DCURSESINC="@CURSESINC@"
+AM_CFLAGS = -D_GNU_SOURCE @CURSES_CFLAGS@ -DCURSESINC="@CURSESINC@"
 LDADD = @CURSESLIB@
 
 bin_PROGRAMS = alsamixer

The reason, why the problem is not visible with the standard gcc/glibc/ncurses is that this definition is activated by ncurses:

$ find alsamixer -type f -exec grep -H GNU_SOURCE {} \;
alsamixer/Makefile:CURSES_CFLAGS = -D_GNU_SOURCE -D_DEFAULT_SOURCE
alsamixer/Makefile:NCURSESW_CFLAGS = -D_GNU_SOURCE -D_DEFAULT_SOURCE
alsamixer/Makefile:AM_CFLAGS = -D_GNU_SOURCE -D_DEFAULT_SOURCE
-DCURSESINC="<ncurses.h>"

Jaroslav

Signature · 2 lines
Jaroslav Kysela <[email protected]>
Linux Sound Maintainer; ALSA Project; Red Hat, Inc.
#2 lore raw

These flags vary between systems, on the Gentoo where I have access the Makefile generated from e1aa6d4 contains:

$ ack '^(AM|CURSES|NCURSESW)_CFLAGS' alsamixer/Makefile
CURSES_CFLAGS = -I/usr/include/ncursesw
NCURSESW_CFLAGS = -I/usr/include/ncursesw
AM_CFLAGS = -I/usr/include/ncursesw  -DCURSESINC="<ncurses.h>"

Files in /usr/include/ncursesw don't mention _GNU_SOURCE so I'm baffled where GCC gets it from.

Indeed the local alsamixer/Makefile.am is a more suitable place to put the flag. A newbie question follows, should I somehow update the patch with your edit and reply to this message, or did you generate the diff from an already edited version?

Quoted 63 lines · Jaroslav Kysela

Dne 16.1.2019 v 02:35 [email protected] napsal(a):

Quoted 33 lines

Fixes Master, Headphones and Speaker stuck at -8 percentage after building with Clang 7.0.1 and getting warned about implicit declaration of exp10, which is behind _GNU_SOURCE as a non-standard feature. Thanks Takashi Iwai for the CFLAGS suggestion on the mailing list. GCC build is not affected, so not adding a compiler check to the configure script.

uClibc-ng has got exp10 since 1.0.12, so the fallback macro is no longer needed. However, alsa-utils relies on gettext so might need further patches to actually work on uClibc systems.

alsamixer/volume_mapping.c +0 -5
index 94bd0fe..48cfbe2 100644
@@ -36,11 +36,6 @@
  #include <stdbool.h>
  #include "volume_mapping.h"
 
-#ifdef __UCLIBC__
-/* 10^x = 10^(log e^x) = (e^x)^log10 = e^(x * log 10) */
-#define exp10(x) (exp((x) * log(10)))
-#endif /* __UCLIBC__ */
-
  #define MAX_LINEAR_DB_SCALE    24
 
  static inline bool use_linear_dB_scale(long dBmin, long dBmax)
configure.ac +0 -0
index 7938996..0d54942 100644

configure.ac if test x$alsamixer = xtrue; then · line 354

Quoted 5 lines
configure.ac +2 -0
@@ -350,6 +350,8 @@ if test x$alsamixer = xtrue; then
 
 
    AC_MSG_RESULT([$CURSESLIB])
+
+  CFLAGS="$CFLAGS -D_GNU_SOURCE"

It would be propably better to put this to the local makefile for alsamixer:

alsamixer/Makefile.am +1 -1
index 259b29e..249e8f8 100644
@@ -1,4 +1,4 @@
-AM_CFLAGS = @CURSES_CFLAGS@ -DCURSESINC="@CURSESINC@"
+AM_CFLAGS = -D_GNU_SOURCE @CURSES_CFLAGS@ -DCURSESINC="@CURSESINC@"
 LDADD = @CURSESLIB@
 
 bin_PROGRAMS = alsamixer

The reason, why the problem is not visible with the standard gcc/glibc/ncurses is that this definition is activated by ncurses:

$ find alsamixer -type f -exec grep -H GNU_SOURCE {} \;
alsamixer/Makefile:CURSES_CFLAGS = -D_GNU_SOURCE -D_DEFAULT_SOURCE
alsamixer/Makefile:NCURSESW_CFLAGS = -D_GNU_SOURCE -D_DEFAULT_SOURCE
alsamixer/Makefile:AM_CFLAGS = -D_GNU_SOURCE -D_DEFAULT_SOURCE
-DCURSESINC="<ncurses.h>"

Jaroslav

#3 lore raw

Dne 17.1.2019 v 01:16 [email protected] napsal(a):

Quoted 8 lines

These flags vary between systems, on the Gentoo where I have access the Makefile generated from e1aa6d4 contains:

$ ack '^(AM|CURSES|NCURSESW)_CFLAGS' alsamixer/Makefile
CURSES_CFLAGS = -I/usr/include/ncursesw
NCURSESW_CFLAGS = -I/usr/include/ncursesw
AM_CFLAGS = -I/usr/include/ncursesw  -DCURSESINC="<ncurses.h>"
Quoted 7 lines

Files in /usr/include/ncursesw don't mention _GNU_SOURCE so I'm baffled where GCC gets it from.

Indeed the local alsamixer/Makefile.am is a more suitable place to put the flag. A newbie question follows, should I somehow update the patch with your edit and reply to this message, or did you generate the diff from an already edited version?

Applied to the repository:

http://git.alsa-project.org/?p=alsa-utils.git;a=commitdiff;h=116488e5f2f1b897084bd151381ee254e1cc177d

Thanks,
Jaroslav

Quoted 70 lines · Jaroslav Kysela
Quoted 68 lines

Dne 16.1.2019 v 02:35 [email protected] napsal(a):

Quoted 37 lines

Fixes Master, Headphones and Speaker stuck at -8 percentage after building with Clang 7.0.1 and getting warned about implicit declaration
of exp10, which is behind _GNU_SOURCE as a non-standard feature. Thanks
Takashi Iwai for the CFLAGS suggestion on the mailing list. GCC build is
not affected, so not adding a compiler check to the configure script.

uClibc-ng has got exp10 since 1.0.12, so the fallback macro is no longer
needed. However, alsa-utils relies on gettext so might need further patches to actually work on uClibc systems.

alsamixer/volume_mapping.c +0 -5
index 94bd0fe..48cfbe2 100644
@@ -36,11 +36,6 @@
  #include <stdbool.h>
  #include "volume_mapping.h"
 
-#ifdef __UCLIBC__
-/* 10^x = 10^(log e^x) = (e^x)^log10 = e^(x * log 10) */
-#define exp10(x) (exp((x) * log(10)))
-#endif /* __UCLIBC__ */
-
  #define MAX_LINEAR_DB_SCALE    24
 
  static inline bool use_linear_dB_scale(long dBmin, long dBmax)
configure.ac +0 -0
index 7938996..0d54942 100644

configure.ac if test x$alsamixer = xtrue; then · line 354

Quoted 5 lines
configure.ac +2 -0
@@ -350,6 +350,8 @@ if test x$alsamixer = xtrue; then
 
 
    AC_MSG_RESULT([$CURSESLIB])
+
+  CFLAGS="$CFLAGS -D_GNU_SOURCE"

It would be propably better to put this to the local makefile for alsamixer:

alsamixer/Makefile.am +1 -1
index 259b29e..249e8f8 100644
@@ -1,4 +1,4 @@
-AM_CFLAGS = @CURSES_CFLAGS@ -DCURSESINC="@CURSESINC@"
+AM_CFLAGS = -D_GNU_SOURCE @CURSES_CFLAGS@ -DCURSESINC="@CURSESINC@"
 LDADD = @CURSESLIB@
 
 bin_PROGRAMS = alsamixer

The reason, why the problem is not visible with the standard gcc/glibc/ncurses is that this definition is activated by ncurses:

$ find alsamixer -type f -exec grep -H GNU_SOURCE {} \;
alsamixer/Makefile:CURSES_CFLAGS = -D_GNU_SOURCE -D_DEFAULT_SOURCE
alsamixer/Makefile:NCURSESW_CFLAGS = -D_GNU_SOURCE -D_DEFAULT_SOURCE
alsamixer/Makefile:AM_CFLAGS = -D_GNU_SOURCE -D_DEFAULT_SOURCE
-DCURSESINC="<ncurses.h>"

Jaroslav

Signature · 1 line
Jaroslav Kysela <[email protected]>