laforge has uploaded this change for review.

View Change

Fix building in environments that define _GNU_SOURCE

On Debian unstable, this is now the case as liburing 2.7
has the following in its pkg-config file:

Cflags: -I${includedir} -D_GNU_SOURCE

As our configure script inherits that, we are building all of the
source with that, and we will get compilation errors about re-defining
something that's already defined...

Change-Id: I36cb3a5555cb35ddc44f06d447268bd9cc0ce9b4
---
M src/core/exec.c
M src/core/socket.c
M src/core/thread.c
M src/vty/cpu_sched_vty.c
M tests/fr/fr_test.c
M tests/logging/logging_vty_test.c
M tests/tdef/tdef_vty_config_root_test.c
M tests/tdef/tdef_vty_config_subnode_test.c
M tests/tdef/tdef_vty_dynamic_test.c
9 files changed, 19 insertions(+), 1 deletion(-)

git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/03/38003/1
diff --git a/src/core/exec.c b/src/core/exec.c
index 2e33788..2d1df82 100644
--- a/src/core/exec.c
+++ b/src/core/exec.c
@@ -19,7 +19,9 @@
#include "config.h"
#ifndef EMBEDDED

+#ifndef _GNU_SOURCE
#define _GNU_SOURCE
+#endif
#include <unistd.h>

#include <errno.h>
diff --git a/src/core/socket.c b/src/core/socket.c
index 90cf4ca..915c70e 100644
--- a/src/core/socket.c
+++ b/src/core/socket.c
@@ -26,7 +26,9 @@
* \file socket.c */

#ifdef HAVE_SYS_SOCKET_H
+#ifndef _GNU_SOURCE
#define _GNU_SOURCE /* for struct ucred on glibc >= 2.8 */
+#endif

#include <osmocom/core/logging.h>
#include <osmocom/core/select.h>
diff --git a/src/core/thread.c b/src/core/thread.c
index d9a9842..116eaea 100644
--- a/src/core/thread.c
+++ b/src/core/thread.c
@@ -28,8 +28,10 @@

/* If HAVE_GETTID, then "_GNU_SOURCE" may need to be defined to use gettid() */
#if HAVE_GETTID
+#ifndef _GNU_SOURCE
#define _GNU_SOURCE
-#endif
+#endif /* ifndef _GNU_SOURCE */
+#endif /* if HAVE_GETTID */
#include <unistd.h>
#include <sys/types.h>

diff --git a/src/vty/cpu_sched_vty.c b/src/vty/cpu_sched_vty.c
index 7198f74..60fe930 100644
--- a/src/vty/cpu_sched_vty.c
+++ b/src/vty/cpu_sched_vty.c
@@ -23,7 +23,9 @@
* SPDX-License-Identifier: GPLv2+
*/

+#ifndef _GNU_SOURCE
#define _GNU_SOURCE
+#endif

#include "config.h"

diff --git a/tests/fr/fr_test.c b/tests/fr/fr_test.c
index cdcdb43..64ae710 100644
--- a/tests/fr/fr_test.c
+++ b/tests/fr/fr_test.c
@@ -14,7 +14,9 @@
*
*/

+#ifndef _GNU_SOURCE
#define _GNU_SOURCE
+#endif
#include <osmocom/core/application.h>

#include <osmocom/gprs/gprs_ns.h>
diff --git a/tests/logging/logging_vty_test.c b/tests/logging/logging_vty_test.c
index c1a2853..16a8277 100644
--- a/tests/logging/logging_vty_test.c
+++ b/tests/logging/logging_vty_test.c
@@ -17,7 +17,9 @@
*
*/

+#ifndef _GNU_SOURCE
#define _GNU_SOURCE
+#endif
#include <getopt.h>

#include <signal.h>
diff --git a/tests/tdef/tdef_vty_config_root_test.c b/tests/tdef/tdef_vty_config_root_test.c
index 8c46d95..7810c0b 100644
--- a/tests/tdef/tdef_vty_config_root_test.c
+++ b/tests/tdef/tdef_vty_config_root_test.c
@@ -19,7 +19,9 @@
* GNU General Public License for more details.
*/

+#ifndef _GNU_SOURCE
#define _GNU_SOURCE
+#endif
#include <getopt.h>
#include <signal.h>
#include <limits.h>
diff --git a/tests/tdef/tdef_vty_config_subnode_test.c b/tests/tdef/tdef_vty_config_subnode_test.c
index e3e165d..a249f46 100644
--- a/tests/tdef/tdef_vty_config_subnode_test.c
+++ b/tests/tdef/tdef_vty_config_subnode_test.c
@@ -19,7 +19,9 @@
* GNU General Public License for more details.
*/

+#ifndef _GNU_SOURCE
#define _GNU_SOURCE
+#endif
#include <getopt.h>
#include <signal.h>
#include <limits.h>
diff --git a/tests/tdef/tdef_vty_dynamic_test.c b/tests/tdef/tdef_vty_dynamic_test.c
index b646c54..f901f6c 100644
--- a/tests/tdef/tdef_vty_dynamic_test.c
+++ b/tests/tdef/tdef_vty_dynamic_test.c
@@ -19,7 +19,9 @@
* GNU General Public License for more details.
*/

+#ifndef _GNU_SOURCE
#define _GNU_SOURCE
+#endif
#include <getopt.h>
#include <signal.h>
#include <limits.h>

To view, visit change 38003. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: newchange
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I36cb3a5555cb35ddc44f06d447268bd9cc0ce9b4
Gerrit-Change-Number: 38003
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge@osmocom.org>