Diff between a7cfbaf711fb9c7c462547502ce91d2fa16ac3a4 and 261948090e9073514ac4b5f64c8715cf0a71eafa

Changed Files

File Additions Deletions Status
android/avdtptest.c +1 -0 modified
android/avrcp-lib.c +1 -0 modified
android/bluetooth.c +2 -2 modified
android/client/haltest.c +1 -0 modified
android/client/if-audio.c +1 -0 modified
android/client/if-av-sink.c +1 -0 modified
android/client/if-av.c +1 -0 modified
android/client/if-bt.c +1 -0 modified
android/client/if-gatt.c +1 -1 modified
android/client/if-hf-client.c +1 -0 modified
android/client/if-hf.c +1 -0 modified
android/client/if-hh.c +1 -0 modified
android/client/if-hl.c +1 -0 modified
android/client/if-mce.c +1 -0 modified
android/client/if-pan.c +1 -0 modified
android/client/if-rc-ctrl.c +1 -0 modified
android/client/if-rc.c +1 -0 modified
android/client/if-sco.c +1 -0 modified
android/client/if-sock.c +1 -0 modified
android/client/tabcompletion.c +1 -0 modified
android/gatt.c +3 -3 modified
android/hal-audio-aptx.c +1 -0 modified
android/hal-audio-sbc.c +1 -0 modified
android/hal-audio.c +1 -0 modified
android/hal-avrcp-ctrl.c +1 -0 modified
android/hal-avrcp.c +1 -0 modified
android/hal-bluetooth.c +1 -0 modified
android/hal-gatt.c +1 -0 modified
android/hal-handsfree.c +1 -0 modified
android/hal-pan.c +1 -0 modified
android/hal-sco.c +1 -0 modified
android/hal-socket.c +1 -0 modified
android/hal-utils.c +1 -0 modified
android/hardware/hardware.c +1 -0 modified
android/health.c +1 -0 modified
android/ipc-tester.c +1 -0 modified
android/main.c +1 -0 modified
android/pan.c +1 -0 modified
android/system-emulator.c +1 -0 modified
android/tester-a2dp.c +1 -0 modified
android/tester-avrcp.c +1 -0 modified
android/tester-bluetooth.c +2 -0 modified
android/tester-gatt.c +1 -0 modified
android/tester-hdp.c +1 -0 modified
android/tester-hidhost.c +1 -0 modified
android/tester-main.c +2 -0 modified
android/tester-map-client.c +1 -0 modified
android/tester-pan.c +1 -0 modified
android/tester-socket.c +1 -0 modified
attrib/att.c +1 -1 modified
attrib/gattrib.c +1 -1 modified
attrib/interactive.c +2 -1 modified
attrib/utils.c +1 -1 modified
btio/btio.c +1 -1 modified
client/advertising.c +1 -0 modified
client/display.c +1 -0 modified
client/gatt.c +1 -0 modified
client/main.c +1 -0 modified
configure.ac +0 -1 modified
emulator/amp.c +1 -0 modified
emulator/b1ee.c +1 -0 modified
emulator/bthost.c +1 -0 modified
emulator/hciemu.c +1 -0 modified
emulator/phy.c +1 -0 modified
emulator/serial.c +1 -0 modified
gdbus/client.c +1 -0 modified
gobex/gobex.c +1 -1 modified
lib/hci.c +1 -0 modified
mesh/appkey.c +1 -0 modified
mesh/btmesh.c +1 -0 modified
mesh/crypto.c +1 -0 modified
mesh/main.c +1 -0 modified
mesh/mesh-db.c +1 -0 modified
mesh/mesh.c +1 -0 modified
mesh/net.c +1 -0 modified
mesh/storage.c +1 -0 modified
mesh/util.c +1 -0 modified
monitor/a2dp.c +1 -0 modified
monitor/avctp.c +1 -0 modified
monitor/avdtp.c +1 -0 modified
monitor/bnep.c +1 -0 modified
monitor/broadcom.c +1 -0 modified
monitor/control.c +1 -0 modified
monitor/display.c +1 -0 modified
monitor/ellisys.c +1 -0 modified
monitor/hcidump.c +1 -0 modified
monitor/hwdb.c +1 -0 modified
monitor/intel.c +1 -0 modified
monitor/l2cap.c +1 -0 modified
monitor/ll.c +1 -0 modified
monitor/lmp.c +1 -0 modified
monitor/main.c +1 -0 modified
monitor/packet.c +1 -0 modified
monitor/rfcomm.c +1 -0 modified
monitor/sdp.c +1 -0 modified
monitor/vendor.c +1 -0 modified
obexd/client/driver.c +1 -0 modified
obexd/client/ftp.c +1 -0 modified
obexd/client/map.c +1 -0 modified
obexd/client/mns.c +1 -0 modified
obexd/client/pbap.c +1 -0 modified
obexd/client/transport.c +1 -0 modified
obexd/plugins/filesystem.c +1 -0 modified
obexd/plugins/irmc.c +1 -0 modified
obexd/plugins/mas.c +1 -0 modified
obexd/plugins/phonebook-dummy.c +1 -0 modified
obexd/plugins/phonebook-tracker.c +1 -1 modified
obexd/src/log.c +1 -0 modified
obexd/src/main.c +1 -0 modified
obexd/src/mimetype.c +1 -0 modified
peripheral/attach.c +1 -0 modified
peripheral/efivars.c +1 -0 modified
peripheral/log.c +1 -0 modified
peripheral/main.c +1 -0 modified
plugins/neard.c +1 -0 modified
plugins/sixaxis.c +1 -0 modified
profiles/audio/avrcp.c +1 -0 modified
profiles/audio/media.c +1 -0 modified
profiles/audio/player.c +1 -0 modified
profiles/audio/transport.c +1 -0 modified
profiles/cups/main.c +1 -0 modified
profiles/gap/gas.c +1 -0 modified
profiles/health/hdp.c +2 -1 modified
profiles/health/hdp_util.c +1 -0 modified
profiles/health/mcap.c +3 -1 modified
profiles/iap/main.c +1 -0 modified
profiles/input/device.c +1 -0 modified
profiles/network/bnep.c +1 -0 modified
profiles/network/connection.c +1 -0 modified
profiles/network/server.c +1 -0 modified
src/adapter.c +1 -0 modified
src/advertising.c +5 -0 modified
src/device.c +1 -0 modified
src/eir.c +1 -0 modified
src/gatt-client.c +1 -0 modified
src/log.c +1 -0 modified
src/main.c +1 -0 modified
src/oui.c +1 -0 modified
src/profile.c +1 -0 modified
src/rfkill.c +1 -0 modified
src/sdp-xml.c +1 -0 modified
src/sdpd-server.c +1 -0 modified
src/shared/ad.c +7 -1 modified
src/shared/btsnoop.c +1 -0 modified
src/shared/ecc.c +2 -0 modified
src/shared/hfp.c +1 -0 modified
src/shared/log.c +1 -0 modified
src/shared/mainloop-glib.c +1 -0 modified
src/shared/mainloop-notify.c +1 -0 modified
src/shared/mainloop.c +1 -0 modified
src/shared/pcap.c +1 -0 modified
src/shared/ringbuf.c +1 -0 modified
src/shared/shell.c +1 -0 modified
src/shared/tester.c +1 -0 modified
src/shared/uhid.c +1 -0 modified
src/shared/util.c +1 -0 modified
src/storage.c +1 -0 modified
src/textfile.c +1 -0 modified
src/uuid-helper.c +1 -0 modified
tools/bccmd.c +1 -0 modified
tools/bcmfw.c +1 -0 modified
tools/bluetooth-player.c +1 -0 modified
tools/bneptest.c +1 -0 modified
tools/btattach.c +1 -0 modified
tools/btgatt-client.c +1 -0 modified
tools/btgatt-server.c +1 -0 modified
tools/btiotest.c +1 -1 modified
tools/btmgmt.c +1 -0 modified
tools/btmon-logger.c +1 -0 modified
tools/btproxy.c +1 -0 modified
tools/btsnoop.c +1 -0 modified
tools/check-selftest.c +1 -0 modified
tools/ciptool.c +1 -0 modified
tools/create-image.c +1 -0 modified
tools/csr.c +1 -0 modified
tools/csr_bcsp.c +1 -0 modified
tools/csr_h4.c +1 -0 modified
tools/csr_usb.c +1 -0 modified
tools/gatt-service.c +1 -0 modified
tools/hciattach.c +1 -0 modified
tools/hciattach_ath3k.c +1 -0 modified
tools/hciattach_bcm43xx.c +1 -0 modified
tools/hciattach_intel.c +1 -0 modified
tools/hciattach_qualcomm.c +1 -0 modified
tools/hciattach_ti.c +1 -0 modified
tools/hciattach_tialt.c +1 -0 modified
tools/hciconfig.c +1 -0 modified
tools/hcidump.c +1 -0 modified
tools/hcitool.c +1 -0 modified
tools/hex2hcd.c +1 -0 modified
tools/hid2hci.c +1 -0 modified
tools/l2ping.c +1 -0 modified
tools/l2test.c +1 -0 modified
tools/mcaptest.c +1 -0 modified
tools/meshctl.c +1 -0 modified
tools/mpris-proxy.c +1 -0 modified
tools/nokfw.c +1 -0 modified
tools/obex-client-tool.c +2 -1 modified
tools/obex-server-tool.c +2 -1 modified
tools/obexctl.c +1 -0 modified
tools/parser/amp.c +1 -0 modified
tools/parser/att.c +1 -0 modified
tools/parser/avctp.c +1 -0 modified
tools/parser/avdtp.c +1 -0 modified
tools/parser/avrcp.c +1 -0 modified
tools/parser/bnep.c +1 -0 modified
tools/parser/bpa.c +1 -0 modified
tools/parser/capi.c +1 -0 modified
tools/parser/cmtp.c +1 -0 modified
tools/parser/csr.c +1 -0 modified
tools/parser/ericsson.c +1 -0 modified
tools/parser/hci.c +1 -0 modified
tools/parser/hcrp.c +1 -0 modified
tools/parser/hidp.c +1 -0 modified
tools/parser/l2cap.c +1 -0 modified
tools/parser/lmp.c +1 -0 modified
tools/parser/obex.c +1 -0 modified
tools/parser/parser.c +1 -0 modified
tools/parser/ppp.c +1 -0 modified
tools/parser/rfcomm.c +1 -0 modified
tools/parser/sap.c +1 -0 modified
tools/parser/sdp.c +1 -0 modified
tools/parser/smp.c +1 -0 modified
tools/parser/tcpip.c +1 -0 modified
tools/rctest.c +1 -0 modified
tools/rfcomm.c +1 -0 modified
tools/rtlfw.c +1 -0 modified
tools/scotest.c +1 -0 modified
tools/sdptool.c +1 -0 modified
tools/seq2bseq.c +1 -0 modified
tools/test-runner.c +1 -0 modified
unit/test-gobex-apparam.c +1 -1 modified
unit/test-gobex-header.c +1 -1 modified
unit/test-gobex-packet.c +1 -1 modified
unit/test-gobex-transfer.c +1 -1 modified
unit/test-gobex.c +1 -1 modified
unit/test-hog.c +1 -0 modified
unit/test-lib.c +3 -2 modified
unit/test-ringbuf.c +1 -0 modified
unit/test-textfile.c +1 -0 modified
unit/util.c +1 -1 modified

Full Patch

diff --git a/android/avdtptest.c b/android/avdtptest.c
index ce34443..98b9ef0 100644
--- a/android/avdtptest.c
+++ b/android/avdtptest.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <stdlib.h>
 #include <getopt.h>
diff --git a/android/avrcp-lib.c b/android/avrcp-lib.c
index 4edfd0e..2c87495 100644
--- a/android/avrcp-lib.c
+++ b/android/avrcp-lib.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdbool.h>
 #include <glib.h>
 #include <errno.h>
diff --git a/android/bluetooth.c b/android/bluetooth.c
index 9c7ee74..fb027bf 100644
--- a/android/bluetooth.c
+++ b/android/bluetooth.c
@@ -4093,7 +4093,7 @@ bool bt_le_add_advertising(struct adv_instance *adv,
 	DBG("lens: adv=%u sr=%u total=%zu",
 		cp->adv_data_len, cp->scan_rsp_len, len);
 
-	cb_data = new0(typeof(*cb_data), 1);
+	cb_data = new0(__typeof__(*cb_data), 1);
 	cb_data->cb = cb;
 	cb_data->user_data = user_data;
 
@@ -4134,7 +4134,7 @@ bool bt_le_remove_advertising(struct adv_instance *adv,
 	struct addrm_adv_user_data *cb_data;
 	bool ok;
 
-	cb_data = new0(typeof(*cb_data), 1);
+	cb_data = new0(__typeof__(*cb_data), 1);
 	cb_data->cb = cb;
 	cb_data->user_data = user_data;
 
diff --git a/android/client/haltest.c b/android/client/haltest.c
index 92cd811..e9a92a2 100644
--- a/android/client/haltest.c
+++ b/android/client/haltest.c
@@ -19,6 +19,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdlib.h>
 #include <stdbool.h>
 #include <string.h>
diff --git a/android/client/if-audio.c b/android/client/if-audio.c
index 65e2f2f..630b5e6 100644
--- a/android/client/if-audio.c
+++ b/android/client/if-audio.c
@@ -15,6 +15,7 @@
  *
  */
 
+#define _GNU_SOURCE
 #include <pthread.h>
 #include <unistd.h>
 #include <math.h>
diff --git a/android/client/if-av-sink.c b/android/client/if-av-sink.c
index 3087dcf..a6c8679 100644
--- a/android/client/if-av-sink.c
+++ b/android/client/if-av-sink.c
@@ -15,6 +15,7 @@
  *
  */
 
+#define _GNU_SOURCE
 #include "if-main.h"
 #include "../hal-utils.h"
 
diff --git a/android/client/if-av.c b/android/client/if-av.c
index 85c641b..798a47a 100644
--- a/android/client/if-av.c
+++ b/android/client/if-av.c
@@ -15,6 +15,7 @@
  *
  */
 
+#define _GNU_SOURCE
 #include "if-main.h"
 #include "../hal-utils.h"
 
diff --git a/android/client/if-bt.c b/android/client/if-bt.c
index c9acf6c..75403ec 100644
--- a/android/client/if-bt.c
+++ b/android/client/if-bt.c
@@ -15,6 +15,7 @@
  *
  */
 
+#define _GNU_SOURCE
 #include <string.h>
 #include <inttypes.h>
 
diff --git a/android/client/if-gatt.c b/android/client/if-gatt.c
index ed14f92..fbd9381 100644
--- a/android/client/if-gatt.c
+++ b/android/client/if-gatt.c
@@ -15,8 +15,8 @@
  *
  */
 
+#define _GNU_SOURCE
 #include <stdbool.h>
-
 #include <string.h>
 
 #include <hardware/bluetooth.h>
diff --git a/android/client/if-hf-client.c b/android/client/if-hf-client.c
index 3f6f7c2..f701a81 100644
--- a/android/client/if-hf-client.c
+++ b/android/client/if-hf-client.c
@@ -15,6 +15,7 @@
  *
  */
 
+#define _GNU_SOURCE
 #include "if-main.h"
 #include "../hal-utils.h"
 
diff --git a/android/client/if-hf.c b/android/client/if-hf.c
index 6b798f8..68df00b 100644
--- a/android/client/if-hf.c
+++ b/android/client/if-hf.c
@@ -15,6 +15,7 @@
  *
  */
 
+#define _GNU_SOURCE
 #include "if-main.h"
 #include "../hal-utils.h"
 
diff --git a/android/client/if-hh.c b/android/client/if-hh.c
index 25519e5..04a54de 100644
--- a/android/client/if-hh.c
+++ b/android/client/if-hh.c
@@ -15,6 +15,7 @@
  *
  */
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <ctype.h>
 #include <string.h>
diff --git a/android/client/if-hl.c b/android/client/if-hl.c
index bd05671..1498fd5 100644
--- a/android/client/if-hl.c
+++ b/android/client/if-hl.c
@@ -15,6 +15,7 @@
  *
  */
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <ctype.h>
 #include <unistd.h>
diff --git a/android/client/if-mce.c b/android/client/if-mce.c
index 5f101e0..ef19689 100644
--- a/android/client/if-mce.c
+++ b/android/client/if-mce.c
@@ -15,6 +15,7 @@
  *
  */
 
+#define _GNU_SOURCE
 #include "if-main.h"
 #include "../hal-utils.h"
 
diff --git a/android/client/if-pan.c b/android/client/if-pan.c
index b0c4b84..b3098ba 100644
--- a/android/client/if-pan.c
+++ b/android/client/if-pan.c
@@ -15,6 +15,7 @@
  *
  */
 
+#define _GNU_SOURCE
 #include "if-main.h"
 #include "../hal-utils.h"
 
diff --git a/android/client/if-rc-ctrl.c b/android/client/if-rc-ctrl.c
index 3980764..39e4b90 100644
--- a/android/client/if-rc-ctrl.c
+++ b/android/client/if-rc-ctrl.c
@@ -15,6 +15,7 @@
  *
  */
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <ctype.h>
 #include <string.h>
diff --git a/android/client/if-rc.c b/android/client/if-rc.c
index ed65600..6a5bffb 100644
--- a/android/client/if-rc.c
+++ b/android/client/if-rc.c
@@ -15,6 +15,7 @@
  *
  */
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <ctype.h>
 #include <string.h>
diff --git a/android/client/if-sco.c b/android/client/if-sco.c
index 5a68ed5..6b570d2 100644
--- a/android/client/if-sco.c
+++ b/android/client/if-sco.c
@@ -15,6 +15,7 @@
  *
  */
 
+#define _GNU_SOURCE
 #include <pthread.h>
 #include <unistd.h>
 #include <math.h>
diff --git a/android/client/if-sock.c b/android/client/if-sock.c
index ee2c1e8..a188cf6 100644
--- a/android/client/if-sock.c
+++ b/android/client/if-sock.c
@@ -15,6 +15,7 @@
  *
  */
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <ctype.h>
 #include <unistd.h>
diff --git a/android/client/tabcompletion.c b/android/client/tabcompletion.c
index bcca5fa..dc6faa8 100644
--- a/android/client/tabcompletion.c
+++ b/android/client/tabcompletion.c
@@ -15,6 +15,7 @@
  *
  */
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <ctype.h>
 #include <string.h>
diff --git a/android/gatt.c b/android/gatt.c
index 6b36985..9351a66 100644
--- a/android/gatt.c
+++ b/android/gatt.c
@@ -5636,7 +5636,7 @@ static struct adv_instance *find_adv_instance(uint32_t client_if)
 	if (!inst)
 		return NULL;
 
-	adv = new0(typeof(*adv), 1);
+	adv = new0(__typeof__(*adv), 1);
 	adv->instance = inst;
 	app->adv = adv;
 
@@ -5834,7 +5834,7 @@ static void handle_client_setup_multi_adv_inst(const void *buf, uint16_t len)
 		adv->ad = adv_data;
 	}
 
-	cb_data = new0(typeof(*cb_data), 1);
+	cb_data = new0(__typeof__(*cb_data), 1);
 	cb_data->client_if = cmd->client_if;
 	cb_data->adv = adv;
 
@@ -5894,7 +5894,7 @@ static void handle_client_disable_multi_adv_inst(const void *buf, uint16_t len)
 	if (!adv)
 		goto out;
 
-	cb_data = new0(typeof(*cb_data), 1);
+	cb_data = new0(__typeof__(*cb_data), 1);
 	cb_data->client_if = cmd->client_if;
 	cb_data->adv = adv;
 
diff --git a/android/hal-audio-aptx.c b/android/hal-audio-aptx.c
index a800075..bff2331 100644
--- a/android/hal-audio-aptx.c
+++ b/android/hal-audio-aptx.c
@@ -15,6 +15,7 @@
  *
  */
 
+#define _GNU_SOURCE
 #include <stdint.h>
 #include <stdbool.h>
 #include <string.h>
diff --git a/android/hal-audio-sbc.c b/android/hal-audio-sbc.c
index 7ad3a6a..9da9575 100644
--- a/android/hal-audio-sbc.c
+++ b/android/hal-audio-sbc.c
@@ -15,6 +15,7 @@
  *
  */
 
+#define _GNU_SOURCE
 #include <stdbool.h>
 #include <string.h>
 #include <malloc.h>
diff --git a/android/hal-audio.c b/android/hal-audio.c
index 207101f..2b25b6e 100644
--- a/android/hal-audio.c
+++ b/android/hal-audio.c
@@ -15,6 +15,7 @@
  *
  */
 
+#define _GNU_SOURCE
 #include <errno.h>
 #include <pthread.h>
 #include <poll.h>
diff --git a/android/hal-avrcp-ctrl.c b/android/hal-avrcp-ctrl.c
index 46b77fd..a6137a5 100644
--- a/android/hal-avrcp-ctrl.c
+++ b/android/hal-avrcp-ctrl.c
@@ -15,6 +15,7 @@
  *
  */
 
+#define _GNU_SOURCE
 #include <stdbool.h>
 #include <stddef.h>
 #include <string.h>
diff --git a/android/hal-avrcp.c b/android/hal-avrcp.c
index f935eda..b2127ad 100644
--- a/android/hal-avrcp.c
+++ b/android/hal-avrcp.c
@@ -15,6 +15,7 @@
  *
  */
 
+#define _GNU_SOURCE
 #include <stdbool.h>
 #include <stddef.h>
 #include <string.h>
diff --git a/android/hal-bluetooth.c b/android/hal-bluetooth.c
index 66f4a37..f22801b 100644
--- a/android/hal-bluetooth.c
+++ b/android/hal-bluetooth.c
@@ -15,6 +15,7 @@
  *
  */
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdbool.h>
diff --git a/android/hal-gatt.c b/android/hal-gatt.c
index f7217c7..2e706cf 100644
--- a/android/hal-gatt.c
+++ b/android/hal-gatt.c
@@ -15,6 +15,7 @@
  *
  */
 
+#define _GNU_SOURCE
 #include <stdbool.h>
 #include <string.h>
 #include <stdlib.h>
diff --git a/android/hal-handsfree.c b/android/hal-handsfree.c
index 3847901..af21b67 100644
--- a/android/hal-handsfree.c
+++ b/android/hal-handsfree.c
@@ -15,6 +15,7 @@
  *
  */
 
+#define _GNU_SOURCE
 #include <stdbool.h>
 #include <stddef.h>
 #include <string.h>
diff --git a/android/hal-pan.c b/android/hal-pan.c
index 61d44a9..5e1afc8 100644
--- a/android/hal-pan.c
+++ b/android/hal-pan.c
@@ -15,6 +15,7 @@
  *
  */
 
+#define _GNU_SOURCE
 #include <stdbool.h>
 #include <stddef.h>
 #include <string.h>
diff --git a/android/hal-sco.c b/android/hal-sco.c
index 2c95866..f4b4d31 100644
--- a/android/hal-sco.c
+++ b/android/hal-sco.c
@@ -15,6 +15,7 @@
  *
  */
 
+#define _GNU_SOURCE
 #include <errno.h>
 #include <pthread.h>
 #include <poll.h>
diff --git a/android/hal-socket.c b/android/hal-socket.c
index cfd50d1..b971074 100644
--- a/android/hal-socket.c
+++ b/android/hal-socket.c
@@ -15,6 +15,7 @@
  *
  */
 
+#define _GNU_SOURCE
 #include <stdbool.h>
 #include <stdint.h>
 #include <stdlib.h>
diff --git a/android/hal-utils.c b/android/hal-utils.c
index e45f6e4..74f2927 100644
--- a/android/hal-utils.c
+++ b/android/hal-utils.c
@@ -15,6 +15,7 @@
  *
  */
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <string.h>
 #include <stdint.h>
diff --git a/android/hardware/hardware.c b/android/hardware/hardware.c
index 3a45fe1..42d03ba 100644
--- a/android/hardware/hardware.c
+++ b/android/hardware/hardware.c
@@ -14,6 +14,7 @@
  * limitations under the License.
  */
 
+#define _GNU_SOURCE
 #include <hardware/hardware.h>
 
 #include <dlfcn.h>
diff --git a/android/health.c b/android/health.c
index eb02a64..90253ac 100644
--- a/android/health.c
+++ b/android/health.c
@@ -26,6 +26,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdint.h>
 #include <stdbool.h>
 #include <errno.h>
diff --git a/android/ipc-tester.c b/android/ipc-tester.c
index 3b7f13a..c1d0e8a 100644
--- a/android/ipc-tester.c
+++ b/android/ipc-tester.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdlib.h>
 #include <unistd.h>
 #include <errno.h>
diff --git a/android/main.c b/android/main.c
index 03c8760..b505c2f 100644
--- a/android/main.c
+++ b/android/main.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdbool.h>
 #include <signal.h>
 #include <stdint.h>
diff --git a/android/pan.c b/android/pan.c
index c40a6d3..1e6d876 100644
--- a/android/pan.c
+++ b/android/pan.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdint.h>
 #include <stdbool.h>
 #include <errno.h>
diff --git a/android/system-emulator.c b/android/system-emulator.c
index 8bcf660..edf3e89 100644
--- a/android/system-emulator.c
+++ b/android/system-emulator.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <errno.h>
 #include <unistd.h>
diff --git a/android/tester-a2dp.c b/android/tester-a2dp.c
index 8397eef..554a394 100644
--- a/android/tester-a2dp.c
+++ b/android/tester-a2dp.c
@@ -15,6 +15,7 @@
  *
  */
 
+#define _GNU_SOURCE
 #include <stdbool.h>
 
 #include "emulator/bthost.h"
diff --git a/android/tester-avrcp.c b/android/tester-avrcp.c
index 737602e..e0e7b7f 100644
--- a/android/tester-avrcp.c
+++ b/android/tester-avrcp.c
@@ -15,6 +15,7 @@
  *
  */
 
+#define _GNU_SOURCE
 #include <stdbool.h>
 
 #include "emulator/bthost.h"
diff --git a/android/tester-bluetooth.c b/android/tester-bluetooth.c
index b42a81d..6db337a 100644
--- a/android/tester-bluetooth.c
+++ b/android/tester-bluetooth.c
@@ -14,6 +14,8 @@
  * limitations under the License.
  *
  */
+
+#define _GNU_SOURCE
 #include <stdbool.h>
 
 #include "emulator/bthost.h"
diff --git a/android/tester-gatt.c b/android/tester-gatt.c
index 6400a3f..c106097 100644
--- a/android/tester-gatt.c
+++ b/android/tester-gatt.c
@@ -15,6 +15,7 @@
  *
  */
 
+#define _GNU_SOURCE
 #include <stdbool.h>
 
 #include "emulator/bthost.h"
diff --git a/android/tester-hdp.c b/android/tester-hdp.c
index e849820..b4d14a3 100644
--- a/android/tester-hdp.c
+++ b/android/tester-hdp.c
@@ -15,6 +15,7 @@
  *
  */
 
+#define _GNU_SOURCE
 #include <stdlib.h>
 #include <stdbool.h>
 
diff --git a/android/tester-hidhost.c b/android/tester-hidhost.c
index 221b122..73092cd 100644
--- a/android/tester-hidhost.c
+++ b/android/tester-hidhost.c
@@ -15,6 +15,7 @@
  *
  */
 
+#define _GNU_SOURCE
 #include <stdbool.h>
 
 #include "emulator/bthost.h"
diff --git a/android/tester-main.c b/android/tester-main.c
index 8d9add9..3c5af29 100644
--- a/android/tester-main.c
+++ b/android/tester-main.c
@@ -14,6 +14,8 @@
  * limitations under the License.
  *
  */
+
+#define _GNU_SOURCE
 #include <stdbool.h>
 #include <unistd.h>
 #include <libgen.h>
diff --git a/android/tester-map-client.c b/android/tester-map-client.c
index 695c797..ff3f272 100644
--- a/android/tester-map-client.c
+++ b/android/tester-map-client.c
@@ -15,6 +15,7 @@
  *
  */
 
+#define _GNU_SOURCE
 #include <stdbool.h>
 
 #include "emulator/bthost.h"
diff --git a/android/tester-pan.c b/android/tester-pan.c
index 9da2488..74ad107 100644
--- a/android/tester-pan.c
+++ b/android/tester-pan.c
@@ -15,6 +15,7 @@
  *
  */
 
+#define _GNU_SOURCE
 #include <stdbool.h>
 
 #include "emulator/bthost.h"
diff --git a/android/tester-socket.c b/android/tester-socket.c
index 2264a1f..ac77e5a 100644
--- a/android/tester-socket.c
+++ b/android/tester-socket.c
@@ -15,6 +15,7 @@
  *
  */
 
+#define _GNU_SOURCE
 #include <fcntl.h>
 #include <unistd.h>
 #include <stdbool.h>
diff --git a/attrib/att.c b/attrib/att.c
index 826b3c1..c0438a3 100644
--- a/attrib/att.c
+++ b/attrib/att.c
@@ -23,7 +23,7 @@
  */
 
 #ifdef HAVE_CONFIG_H
-#include "config.h"
+#include <config.h>
 #endif
 
 #include <errno.h>
diff --git a/attrib/gattrib.c b/attrib/gattrib.c
index 2e1e39a..57ca015 100644
--- a/attrib/gattrib.c
+++ b/attrib/gattrib.c
@@ -23,7 +23,7 @@
  */
 
 #ifdef HAVE_CONFIG_H
-#include "config.h"
+#include <config.h>
 #endif
 
 #include <stdio.h>
diff --git a/attrib/interactive.c b/attrib/interactive.c
index 7d4786a..9a7976d 100644
--- a/attrib/interactive.c
+++ b/attrib/interactive.c
@@ -22,9 +22,10 @@
  */
 
 #ifdef HAVE_CONFIG_H
-#include "config.h"
+#include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <string.h>
 #include <stdlib.h>
 #include <stdarg.h>
diff --git a/attrib/utils.c b/attrib/utils.c
index 8e2fc1a..a749029 100644
--- a/attrib/utils.c
+++ b/attrib/utils.c
@@ -22,7 +22,7 @@
  */
 
 #ifdef HAVE_CONFIG_H
-#include "config.h"
+#include <config.h>
 #endif
 
 #include <stdlib.h>
diff --git a/btio/btio.c b/btio/btio.c
index 969cd3a..af2276d 100644
--- a/btio/btio.c
+++ b/btio/btio.c
@@ -23,7 +23,7 @@
  */
 
 #ifdef HAVE_CONFIG_H
-#include "config.h"
+#include <config.h>
 #endif
 
 #include <stdarg.h>
diff --git a/client/advertising.c b/client/advertising.c
index 73f2f3d..960cdd6 100644
--- a/client/advertising.c
+++ b/client/advertising.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdint.h>
diff --git a/client/display.c b/client/display.c
index bd23e8c..0561386 100644
--- a/client/display.c
+++ b/client/display.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdarg.h>
diff --git a/client/gatt.c b/client/gatt.c
index 9877c4b..b6b517b 100644
--- a/client/gatt.c
+++ b/client/gatt.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <errno.h>
 #include <unistd.h>
diff --git a/client/main.c b/client/main.c
index 196b31a..a4647f3 100644
--- a/client/main.c
+++ b/client/main.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <errno.h>
 #include <unistd.h>
diff --git a/configure.ac b/configure.ac
index f46e381..1a095a3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -4,7 +4,6 @@ AC_INIT(bluez, 5.50)
 AM_INIT_AUTOMAKE([foreign subdir-objects color-tests silent-rules
 					tar-pax no-dist-gzip dist-xz])
 AC_CONFIG_HEADERS(config.h)
-AC_USE_SYSTEM_EXTENSIONS
 
 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
 
diff --git a/emulator/amp.c b/emulator/amp.c
index c5c6b81..605c6c8 100644
--- a/emulator/amp.c
+++ b/emulator/amp.c
@@ -26,6 +26,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <fcntl.h>
 #include <unistd.h>
 #include <stdlib.h>
diff --git a/emulator/b1ee.c b/emulator/b1ee.c
index 0d5226f..377181b 100644
--- a/emulator/b1ee.c
+++ b/emulator/b1ee.c
@@ -26,6 +26,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <errno.h>
 #include <fcntl.h>
diff --git a/emulator/bthost.c b/emulator/bthost.c
index d37957f..6482bbe 100644
--- a/emulator/bthost.c
+++ b/emulator/bthost.c
@@ -26,6 +26,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <ctype.h>
 #include <stdlib.h>
diff --git a/emulator/hciemu.c b/emulator/hciemu.c
index bc36773..1045043 100644
--- a/emulator/hciemu.c
+++ b/emulator/hciemu.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <fcntl.h>
 #include <unistd.h>
diff --git a/emulator/phy.c b/emulator/phy.c
index c63dc38..beb8bbb 100644
--- a/emulator/phy.c
+++ b/emulator/phy.c
@@ -26,6 +26,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <fcntl.h>
 #include <unistd.h>
 #include <stdlib.h>
diff --git a/emulator/serial.c b/emulator/serial.c
index f404b15..1c324d5 100644
--- a/emulator/serial.c
+++ b/emulator/serial.c
@@ -26,6 +26,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <errno.h>
 #include <ctype.h>
diff --git a/gdbus/client.c b/gdbus/client.c
index dd5d2eb..86e1c76 100644
--- a/gdbus/client.c
+++ b/gdbus/client.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <string.h>
 #include <glib.h>
diff --git a/gobex/gobex.c b/gobex/gobex.c
index ef5355a..77f1aaa 100644
--- a/gobex/gobex.c
+++ b/gobex/gobex.c
@@ -21,7 +21,7 @@
  */
 
 #ifdef HAVE_CONFIG_H
-# include "config.h"
+#include <config.h>
 #endif
 
 #include <unistd.h>
diff --git a/lib/hci.c b/lib/hci.c
index 28e53f4..ccaef6b 100644
--- a/lib/hci.c
+++ b/lib/hci.c
@@ -27,6 +27,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <errno.h>
 #include <fcntl.h>
diff --git a/mesh/appkey.c b/mesh/appkey.c
index 2ddb1eb..3d445d2 100644
--- a/mesh/appkey.c
+++ b/mesh/appkey.c
@@ -22,6 +22,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <ell/ell.h>
 
 #include "mesh/mesh-defs.h"
diff --git a/mesh/btmesh.c b/mesh/btmesh.c
index 083947b..5b72423 100644
--- a/mesh/btmesh.c
+++ b/mesh/btmesh.c
@@ -22,6 +22,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <ctype.h>
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/mesh/crypto.c b/mesh/crypto.c
index dda8679..e68cc2d 100644
--- a/mesh/crypto.c
+++ b/mesh/crypto.c
@@ -21,6 +21,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <fcntl.h>
 #include <unistd.h>
 #include <string.h>
diff --git a/mesh/main.c b/mesh/main.c
index db6bee5..173f57a 100644
--- a/mesh/main.c
+++ b/mesh/main.c
@@ -22,6 +22,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <getopt.h>
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/mesh/mesh-db.c b/mesh/mesh-db.c
index 7bddab0..86e17ed 100644
--- a/mesh/mesh-db.c
+++ b/mesh/mesh-db.c
@@ -22,6 +22,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <errno.h>
 #include <stdbool.h>
 #include <stdio.h>
diff --git a/mesh/mesh.c b/mesh/mesh.c
index 3fba014..d1d4096 100644
--- a/mesh/mesh.c
+++ b/mesh/mesh.c
@@ -22,6 +22,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <time.h>
 #include <ell/ell.h>
 
diff --git a/mesh/net.c b/mesh/net.c
index 30dc803..97b6f5b 100644
--- a/mesh/net.c
+++ b/mesh/net.c
@@ -21,6 +21,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdlib.h>
 #include <stdio.h>
 #include <sys/time.h>
diff --git a/mesh/storage.c b/mesh/storage.c
index 937f801..1f3b258 100644
--- a/mesh/storage.c
+++ b/mesh/storage.c
@@ -22,6 +22,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <errno.h>
 #include <fcntl.h>
 #include <stdio.h>
diff --git a/mesh/util.c b/mesh/util.c
index 5d77143..2cdcdf3 100644
--- a/mesh/util.c
+++ b/mesh/util.c
@@ -22,6 +22,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdbool.h>
 #include <stdint.h>
 #include <stdio.h>
diff --git a/monitor/a2dp.c b/monitor/a2dp.c
index 94f9758..6a27121 100644
--- a/monitor/a2dp.c
+++ b/monitor/a2dp.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
diff --git a/monitor/avctp.c b/monitor/avctp.c
index 94385d2..fe96f6d 100644
--- a/monitor/avctp.c
+++ b/monitor/avctp.c
@@ -26,6 +26,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
diff --git a/monitor/avdtp.c b/monitor/avdtp.c
index f5ef4c0..6a342a2 100644
--- a/monitor/avdtp.c
+++ b/monitor/avdtp.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
diff --git a/monitor/bnep.c b/monitor/bnep.c
index 1d9d8fc..6af54e0 100644
--- a/monitor/bnep.c
+++ b/monitor/bnep.c
@@ -26,6 +26,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
diff --git a/monitor/broadcom.c b/monitor/broadcom.c
index fb96609..787ff29 100644
--- a/monitor/broadcom.c
+++ b/monitor/broadcom.c
@@ -26,6 +26,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <inttypes.h>
 
diff --git a/monitor/control.c b/monitor/control.c
index 46eed2a..39a413b 100644
--- a/monitor/control.c
+++ b/monitor/control.c
@@ -26,6 +26,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <stdbool.h>
 #include <stddef.h>
diff --git a/monitor/display.c b/monitor/display.c
index 411af94..9903954 100644
--- a/monitor/display.c
+++ b/monitor/display.c
@@ -26,6 +26,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <errno.h>
 #include <unistd.h>
diff --git a/monitor/ellisys.c b/monitor/ellisys.c
index bafbb5d..e533eec 100644
--- a/monitor/ellisys.c
+++ b/monitor/ellisys.c
@@ -26,6 +26,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <unistd.h>
 #include <string.h>
diff --git a/monitor/hcidump.c b/monitor/hcidump.c
index bef1338..8b6f846 100644
--- a/monitor/hcidump.c
+++ b/monitor/hcidump.c
@@ -26,6 +26,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <errno.h>
 #include <unistd.h>
diff --git a/monitor/hwdb.c b/monitor/hwdb.c
index 6931660..f2431fa 100644
--- a/monitor/hwdb.c
+++ b/monitor/hwdb.c
@@ -26,6 +26,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <string.h>
 
diff --git a/monitor/intel.c b/monitor/intel.c
index 4cd1788..41e70ba 100644
--- a/monitor/intel.c
+++ b/monitor/intel.c
@@ -26,6 +26,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <inttypes.h>
 
diff --git a/monitor/l2cap.c b/monitor/l2cap.c
index 05a33b9..1e6ca34 100644
--- a/monitor/l2cap.c
+++ b/monitor/l2cap.c
@@ -26,6 +26,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
diff --git a/monitor/ll.c b/monitor/ll.c
index c5e1105..3ddbf7a 100644
--- a/monitor/ll.c
+++ b/monitor/ll.c
@@ -26,6 +26,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <inttypes.h>
 
diff --git a/monitor/lmp.c b/monitor/lmp.c
index b87b549..3088c5e 100644
--- a/monitor/lmp.c
+++ b/monitor/lmp.c
@@ -26,6 +26,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <string.h>
 
diff --git a/monitor/main.c b/monitor/main.c
index 8640c02..acd44a0 100644
--- a/monitor/main.c
+++ b/monitor/main.c
@@ -26,6 +26,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <ctype.h>
 #include <stdlib.h>
diff --git a/monitor/packet.c b/monitor/packet.c
index eabd219..06830fd 100644
--- a/monitor/packet.c
+++ b/monitor/packet.c
@@ -26,6 +26,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <errno.h>
 #include <ctype.h>
diff --git a/monitor/rfcomm.c b/monitor/rfcomm.c
index f3daf95..94d28de 100644
--- a/monitor/rfcomm.c
+++ b/monitor/rfcomm.c
@@ -26,6 +26,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
diff --git a/monitor/sdp.c b/monitor/sdp.c
index 1df26a0..575eda5 100644
--- a/monitor/sdp.c
+++ b/monitor/sdp.c
@@ -26,6 +26,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
diff --git a/monitor/vendor.c b/monitor/vendor.c
index 8d3b614..3dda2ae 100644
--- a/monitor/vendor.c
+++ b/monitor/vendor.c
@@ -26,6 +26,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include "packet.h"
 #include "vendor.h"
 
diff --git a/obexd/client/driver.c b/obexd/client/driver.c
index 27857b5..0dae356 100644
--- a/obexd/client/driver.c
+++ b/obexd/client/driver.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <string.h>
 #include <errno.h>
 #include <glib.h>
diff --git a/obexd/client/ftp.c b/obexd/client/ftp.c
index d799821..5e30654 100644
--- a/obexd/client/ftp.c
+++ b/obexd/client/ftp.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <errno.h>
 #include <string.h>
 
diff --git a/obexd/client/map.c b/obexd/client/map.c
index 3e581c8..550c5af 100644
--- a/obexd/client/map.c
+++ b/obexd/client/map.c
@@ -24,6 +24,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <errno.h>
 #include <string.h>
 #include <stdio.h>
diff --git a/obexd/client/mns.c b/obexd/client/mns.c
index 14b1848..4912cb9 100644
--- a/obexd/client/mns.c
+++ b/obexd/client/mns.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <string.h>
 #include <errno.h>
 #include <glib.h>
diff --git a/obexd/client/pbap.c b/obexd/client/pbap.c
index 1ab34a7..3f5665f 100644
--- a/obexd/client/pbap.c
+++ b/obexd/client/pbap.c
@@ -26,6 +26,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <errno.h>
 #include <string.h>
 #include <stdio.h>
diff --git a/obexd/client/transport.c b/obexd/client/transport.c
index aae6780..4cd7706 100644
--- a/obexd/client/transport.c
+++ b/obexd/client/transport.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <string.h>
 #include <errno.h>
 #include <glib.h>
diff --git a/obexd/plugins/filesystem.c b/obexd/plugins/filesystem.c
index 0e6cd49..48239a8 100644
--- a/obexd/plugins/filesystem.c
+++ b/obexd/plugins/filesystem.c
@@ -26,6 +26,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <errno.h>
 #include <stdlib.h>
diff --git a/obexd/plugins/irmc.c b/obexd/plugins/irmc.c
index a3bbd60..fcf5340 100644
--- a/obexd/plugins/irmc.c
+++ b/obexd/plugins/irmc.c
@@ -24,6 +24,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <string.h>
 #include <errno.h>
diff --git a/obexd/plugins/mas.c b/obexd/plugins/mas.c
index ef67ec5..f73c3e9 100644
--- a/obexd/plugins/mas.c
+++ b/obexd/plugins/mas.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <string.h>
 #include <errno.h>
 #include <glib.h>
diff --git a/obexd/plugins/phonebook-dummy.c b/obexd/plugins/phonebook-dummy.c
index b9e3a0d..9279ef2 100644
--- a/obexd/plugins/phonebook-dummy.c
+++ b/obexd/plugins/phonebook-dummy.c
@@ -26,6 +26,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <dirent.h>
 #include <errno.h>
 #include <stdio.h>
diff --git a/obexd/plugins/phonebook-tracker.c b/obexd/plugins/phonebook-tracker.c
index 0743629..c1d1407 100644
--- a/obexd/plugins/phonebook-tracker.c
+++ b/obexd/plugins/phonebook-tracker.c
@@ -21,7 +21,7 @@
  */
 
 #ifdef HAVE_CONFIG_H
-#include "config.h"
+#include <config.h>
 #endif
 
 #include <string.h>
diff --git a/obexd/src/log.c b/obexd/src/log.c
index f259728..8e2ebaa 100644
--- a/obexd/src/log.c
+++ b/obexd/src/log.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <stdarg.h>
 #include <syslog.h>
diff --git a/obexd/src/main.c b/obexd/src/main.c
index c774cda..139f141 100644
--- a/obexd/src/main.c
+++ b/obexd/src/main.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <errno.h>
 #include <unistd.h>
diff --git a/obexd/src/mimetype.c b/obexd/src/mimetype.c
index 833ddc7..c8b040a 100644
--- a/obexd/src/mimetype.c
+++ b/obexd/src/mimetype.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <errno.h>
 #include <string.h>
diff --git a/peripheral/attach.c b/peripheral/attach.c
index a70ca55..1de02ac 100644
--- a/peripheral/attach.c
+++ b/peripheral/attach.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <fcntl.h>
 #include <unistd.h>
 #include <sys/ioctl.h>
diff --git a/peripheral/efivars.c b/peripheral/efivars.c
index a86031f..3cc213c 100644
--- a/peripheral/efivars.c
+++ b/peripheral/efivars.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <errno.h>
 #include <fcntl.h>
diff --git a/peripheral/log.c b/peripheral/log.c
index 7aaeb4d..d5834eb 100644
--- a/peripheral/log.c
+++ b/peripheral/log.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <errno.h>
 #include <fcntl.h>
diff --git a/peripheral/main.c b/peripheral/main.c
index 93abe20..75427ab 100644
--- a/peripheral/main.c
+++ b/peripheral/main.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <errno.h>
 #include <unistd.h>
diff --git a/plugins/neard.c b/plugins/neard.c
index cabcf34..6ffcd6e 100644
--- a/plugins/neard.c
+++ b/plugins/neard.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdlib.h>
 #include <errno.h>
 
diff --git a/plugins/sixaxis.c b/plugins/sixaxis.c
index 9290dbe..fed68d2 100644
--- a/plugins/sixaxis.c
+++ b/plugins/sixaxis.c
@@ -27,6 +27,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stddef.h>
 #include <errno.h>
 #include <fcntl.h>
diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c
index d5eba39..6b3f685 100644
--- a/profiles/audio/avrcp.c
+++ b/profiles/audio/avrcp.c
@@ -27,6 +27,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdlib.h>
 #include <stdint.h>
 #include <inttypes.h>
diff --git a/profiles/audio/media.c b/profiles/audio/media.c
index 23d1561..e2a447e 100644
--- a/profiles/audio/media.c
+++ b/profiles/audio/media.c
@@ -27,6 +27,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <errno.h>
 #include <inttypes.h>
 
diff --git a/profiles/audio/player.c b/profiles/audio/player.c
index 048f98f..f47f626 100644
--- a/profiles/audio/player.c
+++ b/profiles/audio/player.c
@@ -26,6 +26,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdlib.h>
 #include <stdint.h>
 #include <inttypes.h>
diff --git a/profiles/audio/transport.c b/profiles/audio/transport.c
index b9d357e..98f4e1f 100644
--- a/profiles/audio/transport.c
+++ b/profiles/audio/transport.c
@@ -26,6 +26,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <errno.h>
 
 #include <glib.h>
diff --git a/profiles/cups/main.c b/profiles/cups/main.c
index aed8d31..1fac726 100644
--- a/profiles/cups/main.c
+++ b/profiles/cups/main.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <errno.h>
 #include <fcntl.h>
diff --git a/profiles/gap/gas.c b/profiles/gap/gas.c
index 43b7c3d..dffa313 100644
--- a/profiles/gap/gas.c
+++ b/profiles/gap/gas.c
@@ -20,6 +20,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <ctype.h>
 #include <stdbool.h>
 #include <stdlib.h>
diff --git a/profiles/health/hdp.c b/profiles/health/hdp.c
index a6de97f..5417383 100644
--- a/profiles/health/hdp.c
+++ b/profiles/health/hdp.c
@@ -21,9 +21,10 @@
  */
 
 #ifdef HAVE_CONFIG_H
-#include "config.h"
+#include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdlib.h>
 #include <stdint.h>
 #include <stdbool.h>
diff --git a/profiles/health/hdp_util.c b/profiles/health/hdp_util.c
index b459eaa..64debfc 100644
--- a/profiles/health/hdp_util.c
+++ b/profiles/health/hdp_util.c
@@ -24,6 +24,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdint.h>
 #include <stdbool.h>
 
diff --git a/profiles/health/mcap.c b/profiles/health/mcap.c
index b8522c2..249a753 100644
--- a/profiles/health/mcap.c
+++ b/profiles/health/mcap.c
@@ -23,13 +23,15 @@
  */
 
 #ifdef HAVE_CONFIG_H
-#include "config.h"
+#include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <netinet/in.h>
 #include <stdlib.h>
 #include <errno.h>
 #include <unistd.h>
+#include <time.h>
 
 #include <glib.h>
 
diff --git a/profiles/iap/main.c b/profiles/iap/main.c
index 53dd9fb..2fd34c0 100644
--- a/profiles/iap/main.c
+++ b/profiles/iap/main.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <errno.h>
 #include <ctype.h>
diff --git a/profiles/input/device.c b/profiles/input/device.c
index 8461478..a711ef5 100644
--- a/profiles/input/device.c
+++ b/profiles/input/device.c
@@ -26,6 +26,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdlib.h>
 #include <stdbool.h>
 #include <errno.h>
diff --git a/profiles/network/bnep.c b/profiles/network/bnep.c
index 789c18d..d0ad9e4 100644
--- a/profiles/network/bnep.c
+++ b/profiles/network/bnep.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <errno.h>
 #include <unistd.h>
diff --git a/profiles/network/connection.c b/profiles/network/connection.c
index 5305ace..97b87d0 100644
--- a/profiles/network/connection.c
+++ b/profiles/network/connection.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <stdbool.h>
 #include <errno.h>
diff --git a/profiles/network/server.c b/profiles/network/server.c
index 175e582..c462677 100644
--- a/profiles/network/server.c
+++ b/profiles/network/server.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <unistd.h>
 #include <stdlib.h>
diff --git a/src/adapter.c b/src/adapter.c
index c244321..b8a6bb6 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -26,6 +26,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <inttypes.h>
 #include <errno.h>
diff --git a/src/advertising.c b/src/advertising.c
index 625750c..a843dbb 100644
--- a/src/advertising.c
+++ b/src/advertising.c
@@ -17,6 +17,11 @@
  *
  */
 
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#define _GNU_SOURCE
 #include <stdint.h>
 #include <stdbool.h>
 #include <errno.h>
diff --git a/src/device.c b/src/device.c
index 60b991c..79ede37 100644
--- a/src/device.c
+++ b/src/device.c
@@ -26,6 +26,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
diff --git a/src/eir.c b/src/eir.c
index 25d961d..fa52a2b 100644
--- a/src/eir.c
+++ b/src/eir.c
@@ -26,6 +26,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <errno.h>
 #include <ctype.h>
 #include <stdlib.h>
diff --git a/src/gatt-client.c b/src/gatt-client.c
index 45ed3b1..c0cc3cd 100644
--- a/src/gatt-client.c
+++ b/src/gatt-client.c
@@ -21,6 +21,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdbool.h>
 #include <stdint.h>
 #include <errno.h>
diff --git a/src/log.c b/src/log.c
index ea639cb..11d26d5 100644
--- a/src/log.c
+++ b/src/log.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <errno.h>
 #include <syslog.h>
diff --git a/src/main.c b/src/main.c
index 67eb6ac..6967283 100644
--- a/src/main.c
+++ b/src/main.c
@@ -27,6 +27,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <errno.h>
 #include <stdio.h>
 #include <unistd.h>
diff --git a/src/oui.c b/src/oui.c
index 5fe2c5c..8059c0a 100644
--- a/src/oui.c
+++ b/src/oui.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include "lib/bluetooth.h"
 #include "oui.h"
 
diff --git a/src/profile.c b/src/profile.c
index 1e9c585..192fd02 100644
--- a/src/profile.c
+++ b/src/profile.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdbool.h>
 #include <stdint.h>
 #include <stdlib.h>
diff --git a/src/rfkill.c b/src/rfkill.c
index 74eeb6a..fb2d113 100644
--- a/src/rfkill.c
+++ b/src/rfkill.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <errno.h>
 #include <stdio.h>
 #include <fcntl.h>
diff --git a/src/sdp-xml.c b/src/sdp-xml.c
index 0a3eb60..6f83173 100644
--- a/src/sdp-xml.c
+++ b/src/sdp-xml.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <errno.h>
 #include <ctype.h>
diff --git a/src/sdpd-server.c b/src/sdpd-server.c
index 54de393..ef35309 100644
--- a/src/sdpd-server.c
+++ b/src/sdpd-server.c
@@ -28,6 +28,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <errno.h>
 #include <unistd.h>
 #include <stdlib.h>
diff --git a/src/shared/ad.c b/src/shared/ad.c
index 3ceb876..8d27684 100644
--- a/src/shared/ad.c
+++ b/src/shared/ad.c
@@ -21,6 +21,12 @@
  *
  */
 
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#define _GNU_SOURCE
+
 #include "src/shared/ad.h"
 
 #include "src/eir.h"
@@ -245,7 +251,7 @@ static size_t uuid_data_length(struct queue *uuid_data)
 static size_t name_length(const char *name, size_t *pos)
 {
 	size_t len;
-	
+
 	if (!name)
 		return 0;
 
diff --git a/src/shared/btsnoop.c b/src/shared/btsnoop.c
index f367aff..f0d0747 100644
--- a/src/shared/btsnoop.c
+++ b/src/shared/btsnoop.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <endian.h>
 #include <fcntl.h>
 #include <unistd.h>
diff --git a/src/shared/ecc.c b/src/shared/ecc.c
index 8149f1d..1b45e0d 100644
--- a/src/shared/ecc.c
+++ b/src/shared/ecc.c
@@ -28,8 +28,10 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <fcntl.h>
 #include <unistd.h>
+#include <stdlib.h>
 #include <sys/types.h>
 #include <string.h>
 
diff --git a/src/shared/hfp.c b/src/shared/hfp.c
index d9f7659..5bddc96 100644
--- a/src/shared/hfp.c
+++ b/src/shared/hfp.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <unistd.h>
 #include <string.h>
diff --git a/src/shared/log.c b/src/shared/log.c
index d42bae7..7c8b712 100644
--- a/src/shared/log.c
+++ b/src/shared/log.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <errno.h>
 #include <inttypes.h>
diff --git a/src/shared/mainloop-glib.c b/src/shared/mainloop-glib.c
index e441973..2508a1f 100644
--- a/src/shared/mainloop-glib.c
+++ b/src/shared/mainloop-glib.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <errno.h>
 #include <unistd.h>
diff --git a/src/shared/mainloop-notify.c b/src/shared/mainloop-notify.c
index 17bf2c0..89a8800 100644
--- a/src/shared/mainloop-notify.c
+++ b/src/shared/mainloop-notify.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <errno.h>
 #include <unistd.h>
diff --git a/src/shared/mainloop.c b/src/shared/mainloop.c
index 6a65fa4..8a8e2c0 100644
--- a/src/shared/mainloop.c
+++ b/src/shared/mainloop.c
@@ -26,6 +26,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <errno.h>
 #include <unistd.h>
diff --git a/src/shared/pcap.c b/src/shared/pcap.c
index bd7675f..0d887e2 100644
--- a/src/shared/pcap.c
+++ b/src/shared/pcap.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <fcntl.h>
 #include <unistd.h>
 #include <stdlib.h>
diff --git a/src/shared/ringbuf.c b/src/shared/ringbuf.c
index 8e7c50e..8cf0b5b 100644
--- a/src/shared/ringbuf.c
+++ b/src/shared/ringbuf.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <string.h>
 #include <sys/uio.h>
diff --git a/src/shared/shell.c b/src/shared/shell.c
index 8ccfe85..6e6648c 100644
--- a/src/shared/shell.c
+++ b/src/shared/shell.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <errno.h>
 #include <syslog.h>
diff --git a/src/shared/tester.c b/src/shared/tester.c
index 3d79e41..62e5c1a 100644
--- a/src/shared/tester.c
+++ b/src/shared/tester.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <errno.h>
 #include <syslog.h>
diff --git a/src/shared/uhid.c b/src/shared/uhid.c
index 1c684cd..685f902 100644
--- a/src/shared/uhid.c
+++ b/src/shared/uhid.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <unistd.h>
 #include <string.h>
diff --git a/src/shared/util.c b/src/shared/util.c
index 43a81af..145bb2a 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <ctype.h>
 #include <stdarg.h>
diff --git a/src/storage.c b/src/storage.c
index 734a9e0..8cbb5b2 100644
--- a/src/storage.c
+++ b/src/storage.c
@@ -26,6 +26,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <errno.h>
 #include <ctype.h>
diff --git a/src/textfile.c b/src/textfile.c
index 7267f3a..371651b 100644
--- a/src/textfile.c
+++ b/src/textfile.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <errno.h>
 #include <ctype.h>
diff --git a/src/uuid-helper.c b/src/uuid-helper.c
index d751817..2c897d8 100644
--- a/src/uuid-helper.c
+++ b/src/uuid-helper.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdlib.h>
 #include <stdio.h>
 #include <stdbool.h>
diff --git a/tools/bccmd.c b/tools/bccmd.c
index 84f1a4a..2c215ac 100644
--- a/tools/bccmd.c
+++ b/tools/bccmd.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <errno.h>
 #include <stdlib.h>
diff --git a/tools/bcmfw.c b/tools/bcmfw.c
index ff94c4f..80d8e71 100644
--- a/tools/bcmfw.c
+++ b/tools/bcmfw.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <errno.h>
 #include <fcntl.h>
diff --git a/tools/bluetooth-player.c b/tools/bluetooth-player.c
index ccb0b5e..c1005c9 100644
--- a/tools/bluetooth-player.c
+++ b/tools/bluetooth-player.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <stdbool.h>
 #include <errno.h>
diff --git a/tools/bneptest.c b/tools/bneptest.c
index a7d5815..8bc7596 100644
--- a/tools/bneptest.c
+++ b/tools/bneptest.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <signal.h>
 #include <stdlib.h>
diff --git a/tools/btattach.c b/tools/btattach.c
index 6eb99ba..56315d0 100644
--- a/tools/btattach.c
+++ b/tools/btattach.c
@@ -26,6 +26,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <errno.h>
 #include <fcntl.h>
diff --git a/tools/btgatt-client.c b/tools/btgatt-client.c
index 31e849a..7df6597 100644
--- a/tools/btgatt-client.c
+++ b/tools/btgatt-client.c
@@ -24,6 +24,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <stdbool.h>
 #include <stdint.h>
diff --git a/tools/btgatt-server.c b/tools/btgatt-server.c
index bc32789..d9d96e6 100644
--- a/tools/btgatt-server.c
+++ b/tools/btgatt-server.c
@@ -20,6 +20,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <stdbool.h>
 #include <stdint.h>
diff --git a/tools/btiotest.c b/tools/btiotest.c
index 10e78d5..6c778e3 100644
--- a/tools/btiotest.c
+++ b/tools/btiotest.c
@@ -23,7 +23,7 @@
  */
 
 #ifdef HAVE_CONFIG_H
-#include "config.h"
+#include <config.h>
 #endif
 
 #include <stdio.h>
diff --git a/tools/btmgmt.c b/tools/btmgmt.c
index 6922f3d..78b9fda 100644
--- a/tools/btmgmt.c
+++ b/tools/btmgmt.c
@@ -23,6 +23,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <stdarg.h>
 #include <errno.h>
diff --git a/tools/btmon-logger.c b/tools/btmon-logger.c
index 65953d2..9c23d3c 100644
--- a/tools/btmon-logger.c
+++ b/tools/btmon-logger.c
@@ -27,6 +27,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <stdlib.h>
 #include <limits.h>
diff --git a/tools/btproxy.c b/tools/btproxy.c
index fd53ca2..fb67a57 100644
--- a/tools/btproxy.c
+++ b/tools/btproxy.c
@@ -26,6 +26,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <errno.h>
 #include <ctype.h>
diff --git a/tools/btsnoop.c b/tools/btsnoop.c
index 3eb8082..9f30437 100644
--- a/tools/btsnoop.c
+++ b/tools/btsnoop.c
@@ -26,6 +26,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <errno.h>
 #include <fcntl.h>
diff --git a/tools/check-selftest.c b/tools/check-selftest.c
index 6006b80..0de6362 100644
--- a/tools/check-selftest.c
+++ b/tools/check-selftest.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <unistd.h>
 #include <stdlib.h>
diff --git a/tools/ciptool.c b/tools/ciptool.c
index e60493d..b898ae8 100644
--- a/tools/ciptool.c
+++ b/tools/ciptool.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <errno.h>
 #include <stdlib.h>
diff --git a/tools/create-image.c b/tools/create-image.c
index d94f99d..ca9d011 100644
--- a/tools/create-image.c
+++ b/tools/create-image.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <fcntl.h>
 #include <unistd.h>
diff --git a/tools/csr.c b/tools/csr.c
index 9408fb6..61bdaa0 100644
--- a/tools/csr.c
+++ b/tools/csr.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <errno.h>
 #include <fcntl.h>
diff --git a/tools/csr_bcsp.c b/tools/csr_bcsp.c
index f7afe53..e3eea34 100644
--- a/tools/csr_bcsp.c
+++ b/tools/csr_bcsp.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <errno.h>
 #include <fcntl.h>
diff --git a/tools/csr_h4.c b/tools/csr_h4.c
index 3371770..2dcaec1 100644
--- a/tools/csr_h4.c
+++ b/tools/csr_h4.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <errno.h>
 #include <fcntl.h>
diff --git a/tools/csr_usb.c b/tools/csr_usb.c
index a1d7324..f3ab2dd 100644
--- a/tools/csr_usb.c
+++ b/tools/csr_usb.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <errno.h>
 #include <ctype.h>
diff --git a/tools/gatt-service.c b/tools/gatt-service.c
index 2ce8a1f..374a4c9 100644
--- a/tools/gatt-service.c
+++ b/tools/gatt-service.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <errno.h>
 #include <stdio.h>
 #include <stdbool.h>
diff --git a/tools/hciattach.c b/tools/hciattach.c
index fad176c..9a02173 100644
--- a/tools/hciattach.c
+++ b/tools/hciattach.c
@@ -27,6 +27,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <errno.h>
 #include <fcntl.h>
diff --git a/tools/hciattach_ath3k.c b/tools/hciattach_ath3k.c
index bb0d51e..d920050 100644
--- a/tools/hciattach_ath3k.c
+++ b/tools/hciattach_ath3k.c
@@ -21,6 +21,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <errno.h>
 #include <unistd.h>
diff --git a/tools/hciattach_bcm43xx.c b/tools/hciattach_bcm43xx.c
index ac1b3c1..be82cd0 100644
--- a/tools/hciattach_bcm43xx.c
+++ b/tools/hciattach_bcm43xx.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
diff --git a/tools/hciattach_intel.c b/tools/hciattach_intel.c
index 2650dcb..0f0b60f 100644
--- a/tools/hciattach_intel.c
+++ b/tools/hciattach_intel.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
diff --git a/tools/hciattach_qualcomm.c b/tools/hciattach_qualcomm.c
index 22ac629..29d15a5 100644
--- a/tools/hciattach_qualcomm.c
+++ b/tools/hciattach_qualcomm.c
@@ -26,6 +26,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <errno.h>
 #include <fcntl.h>
diff --git a/tools/hciattach_ti.c b/tools/hciattach_ti.c
index 828dd61..1838394 100644
--- a/tools/hciattach_ti.c
+++ b/tools/hciattach_ti.c
@@ -26,6 +26,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <errno.h>
 #include <unistd.h>
diff --git a/tools/hciattach_tialt.c b/tools/hciattach_tialt.c
index f6ef068..78498ed 100644
--- a/tools/hciattach_tialt.c
+++ b/tools/hciattach_tialt.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <errno.h>
 #include <fcntl.h>
diff --git a/tools/hciconfig.c b/tools/hciconfig.c
index 8a97cc4..ddc17c4 100644
--- a/tools/hciconfig.c
+++ b/tools/hciconfig.c
@@ -27,6 +27,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <errno.h>
 #include <ctype.h>
diff --git a/tools/hcidump.c b/tools/hcidump.c
index af8f592..33d429b 100644
--- a/tools/hcidump.c
+++ b/tools/hcidump.c
@@ -26,6 +26,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <errno.h>
 #include <fcntl.h>
diff --git a/tools/hcitool.c b/tools/hcitool.c
index 945f675..9250c41 100644
--- a/tools/hcitool.c
+++ b/tools/hcitool.c
@@ -27,6 +27,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <errno.h>
 #include <ctype.h>
diff --git a/tools/hex2hcd.c b/tools/hex2hcd.c
index 943531c..1148bbb 100644
--- a/tools/hex2hcd.c
+++ b/tools/hex2hcd.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <errno.h>
 #include <fcntl.h>
diff --git a/tools/hid2hci.c b/tools/hid2hci.c
index 8f060f2..1e0f7aa 100644
--- a/tools/hid2hci.c
+++ b/tools/hid2hci.c
@@ -26,6 +26,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <errno.h>
 #include <fcntl.h>
diff --git a/tools/l2ping.c b/tools/l2ping.c
index fa97fe3..db120a5 100644
--- a/tools/l2ping.c
+++ b/tools/l2ping.c
@@ -27,6 +27,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <errno.h>
 #include <unistd.h>
diff --git a/tools/l2test.c b/tools/l2test.c
index 1819423..e755ac8 100644
--- a/tools/l2test.c
+++ b/tools/l2test.c
@@ -27,6 +27,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <stdbool.h>
 #include <errno.h>
diff --git a/tools/mcaptest.c b/tools/mcaptest.c
index 3092873..82663d8 100644
--- a/tools/mcaptest.c
+++ b/tools/mcaptest.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <stdlib.h>
 #include <getopt.h>
diff --git a/tools/meshctl.c b/tools/meshctl.c
index cbf62ce..6b6f108 100644
--- a/tools/meshctl.c
+++ b/tools/meshctl.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <errno.h>
 #include <unistd.h>
diff --git a/tools/mpris-proxy.c b/tools/mpris-proxy.c
index bf8148f..617f805 100644
--- a/tools/mpris-proxy.c
+++ b/tools/mpris-proxy.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <errno.h>
 #include <unistd.h>
diff --git a/tools/nokfw.c b/tools/nokfw.c
index 20ff846..6209642 100644
--- a/tools/nokfw.c
+++ b/tools/nokfw.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <errno.h>
 #include <fcntl.h>
diff --git a/tools/obex-client-tool.c b/tools/obex-client-tool.c
index 1e3e6f0..3d61c00 100644
--- a/tools/obex-client-tool.c
+++ b/tools/obex-client-tool.c
@@ -20,9 +20,10 @@
  */
 
 #ifdef HAVE_CONFIG_H
-#include "config.h"
+#include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <fcntl.h>
diff --git a/tools/obex-server-tool.c b/tools/obex-server-tool.c
index a16c46f..b20dfaa 100644
--- a/tools/obex-server-tool.c
+++ b/tools/obex-server-tool.c
@@ -20,9 +20,10 @@
  */
 
 #ifdef HAVE_CONFIG_H
-# include "config.h"
+#include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <fcntl.h>
diff --git a/tools/obexctl.c b/tools/obexctl.c
index f839ab0..0709f69 100644
--- a/tools/obexctl.c
+++ b/tools/obexctl.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <stdbool.h>
 #include <errno.h>
diff --git a/tools/parser/amp.c b/tools/parser/amp.c
index 158ca4a..7c85fb9 100644
--- a/tools/parser/amp.c
+++ b/tools/parser/amp.c
@@ -24,6 +24,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include "parser.h"
 #include "lib/amp.h"
 
diff --git a/tools/parser/att.c b/tools/parser/att.c
index 82766c7..688ed48 100644
--- a/tools/parser/att.c
+++ b/tools/parser/att.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <errno.h>
 #include <unistd.h>
diff --git a/tools/parser/avctp.c b/tools/parser/avctp.c
index 70c5f66..5038443 100644
--- a/tools/parser/avctp.c
+++ b/tools/parser/avctp.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <errno.h>
 #include <unistd.h>
diff --git a/tools/parser/avdtp.c b/tools/parser/avdtp.c
index 5397a42..18569c8 100644
--- a/tools/parser/avdtp.c
+++ b/tools/parser/avdtp.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <errno.h>
 #include <unistd.h>
diff --git a/tools/parser/avrcp.c b/tools/parser/avrcp.c
index 5f29272..dfc6d05 100644
--- a/tools/parser/avrcp.c
+++ b/tools/parser/avrcp.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <errno.h>
 #include <unistd.h>
diff --git a/tools/parser/bnep.c b/tools/parser/bnep.c
index 7c549f4..c3bbae7 100644
--- a/tools/parser/bnep.c
+++ b/tools/parser/bnep.c
@@ -26,6 +26,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <errno.h>
 #include <unistd.h>
diff --git a/tools/parser/bpa.c b/tools/parser/bpa.c
index 74a3457..aac010b 100644
--- a/tools/parser/bpa.c
+++ b/tools/parser/bpa.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <errno.h>
 #include <unistd.h>
diff --git a/tools/parser/capi.c b/tools/parser/capi.c
index b8d05c2..ef6ac06 100644
--- a/tools/parser/capi.c
+++ b/tools/parser/capi.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <errno.h>
 #include <ctype.h>
diff --git a/tools/parser/cmtp.c b/tools/parser/cmtp.c
index ed5d13b..e7ac4b5 100644
--- a/tools/parser/cmtp.c
+++ b/tools/parser/cmtp.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <errno.h>
 #include <unistd.h>
diff --git a/tools/parser/csr.c b/tools/parser/csr.c
index a0a4eb5..718baab 100644
--- a/tools/parser/csr.c
+++ b/tools/parser/csr.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <errno.h>
 #include <unistd.h>
diff --git a/tools/parser/ericsson.c b/tools/parser/ericsson.c
index 3d52411..d148c93 100644
--- a/tools/parser/ericsson.c
+++ b/tools/parser/ericsson.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <errno.h>
 
diff --git a/tools/parser/hci.c b/tools/parser/hci.c
index 4e6c360..41f6fe0 100644
--- a/tools/parser/hci.c
+++ b/tools/parser/hci.c
@@ -26,6 +26,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <errno.h>
 #include <ctype.h>
diff --git a/tools/parser/hcrp.c b/tools/parser/hcrp.c
index 444ec23..7c46cb6 100644
--- a/tools/parser/hcrp.c
+++ b/tools/parser/hcrp.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <errno.h>
 #include <unistd.h>
diff --git a/tools/parser/hidp.c b/tools/parser/hidp.c
index 1adf8ed..703049a 100644
--- a/tools/parser/hidp.c
+++ b/tools/parser/hidp.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <errno.h>
 #include <unistd.h>
diff --git a/tools/parser/l2cap.c b/tools/parser/l2cap.c
index 5daefcb..e43761c 100644
--- a/tools/parser/l2cap.c
+++ b/tools/parser/l2cap.c
@@ -26,6 +26,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <errno.h>
 #include <unistd.h>
diff --git a/tools/parser/lmp.c b/tools/parser/lmp.c
index 3d2772c..a7879fb 100644
--- a/tools/parser/lmp.c
+++ b/tools/parser/lmp.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <errno.h>
 #include <ctype.h>
diff --git a/tools/parser/obex.c b/tools/parser/obex.c
index 0612c30..51719aa 100644
--- a/tools/parser/obex.c
+++ b/tools/parser/obex.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <errno.h>
 #include <unistd.h>
diff --git a/tools/parser/parser.c b/tools/parser/parser.c
index de8dbe8..61c5b1c 100644
--- a/tools/parser/parser.c
+++ b/tools/parser/parser.c
@@ -26,6 +26,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <errno.h>
 #include <ctype.h>
diff --git a/tools/parser/ppp.c b/tools/parser/ppp.c
index 3847ff3..55aaa60 100644
--- a/tools/parser/ppp.c
+++ b/tools/parser/ppp.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <errno.h>
 #include <unistd.h>
diff --git a/tools/parser/rfcomm.c b/tools/parser/rfcomm.c
index ea8dfad..d800b7e 100644
--- a/tools/parser/rfcomm.c
+++ b/tools/parser/rfcomm.c
@@ -26,6 +26,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <errno.h>
 #include <unistd.h>
diff --git a/tools/parser/sap.c b/tools/parser/sap.c
index f51f0cc..0a875fc 100644
--- a/tools/parser/sap.c
+++ b/tools/parser/sap.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <errno.h>
 #include <unistd.h>
diff --git a/tools/parser/sdp.c b/tools/parser/sdp.c
index dba9a36..7477037 100644
--- a/tools/parser/sdp.c
+++ b/tools/parser/sdp.c
@@ -26,6 +26,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <errno.h>
 #include <ctype.h>
diff --git a/tools/parser/smp.c b/tools/parser/smp.c
index 97f02fa..817e08e 100644
--- a/tools/parser/smp.c
+++ b/tools/parser/smp.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <errno.h>
 #include <unistd.h>
diff --git a/tools/parser/tcpip.c b/tools/parser/tcpip.c
index 6f2c3cb..8ccfb00 100644
--- a/tools/parser/tcpip.c
+++ b/tools/parser/tcpip.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <errno.h>
 #include <unistd.h>
diff --git a/tools/rctest.c b/tools/rctest.c
index 6d84e07..94490f4 100644
--- a/tools/rctest.c
+++ b/tools/rctest.c
@@ -26,6 +26,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <errno.h>
 #include <ctype.h>
diff --git a/tools/rfcomm.c b/tools/rfcomm.c
index 809c240..177d8f8 100644
--- a/tools/rfcomm.c
+++ b/tools/rfcomm.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <errno.h>
 #include <fcntl.h>
diff --git a/tools/rtlfw.c b/tools/rtlfw.c
index 5e354a3..375f075 100644
--- a/tools/rtlfw.c
+++ b/tools/rtlfw.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <errno.h>
 #include <fcntl.h>
diff --git a/tools/scotest.c b/tools/scotest.c
index f894c24..08bc8a8 100644
--- a/tools/scotest.c
+++ b/tools/scotest.c
@@ -26,6 +26,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <errno.h>
 #include <ctype.h>
diff --git a/tools/sdptool.c b/tools/sdptool.c
index b1cbcfd..3c5d840 100644
--- a/tools/sdptool.c
+++ b/tools/sdptool.c
@@ -29,6 +29,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <errno.h>
 #include <ctype.h>
diff --git a/tools/seq2bseq.c b/tools/seq2bseq.c
index 23f6c9e..9268ecd 100644
--- a/tools/seq2bseq.c
+++ b/tools/seq2bseq.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <fcntl.h>
 #include <unistd.h>
diff --git a/tools/test-runner.c b/tools/test-runner.c
index 7a97111..bd3c730 100644
--- a/tools/test-runner.c
+++ b/tools/test-runner.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <errno.h>
 #include <fcntl.h>
diff --git a/unit/test-gobex-apparam.c b/unit/test-gobex-apparam.c
index 7541c49..59393c6 100644
--- a/unit/test-gobex-apparam.c
+++ b/unit/test-gobex-apparam.c
@@ -21,7 +21,7 @@
  */
 
 #ifdef HAVE_CONFIG_H
-#include "config.h"
+#include <config.h>
 #endif
 
 #include <stdint.h>
diff --git a/unit/test-gobex-header.c b/unit/test-gobex-header.c
index 8705892..3450f81 100644
--- a/unit/test-gobex-header.c
+++ b/unit/test-gobex-header.c
@@ -21,7 +21,7 @@
  */
 
 #ifdef HAVE_CONFIG_H
-#include "config.h"
+#include <config.h>
 #endif
 
 #include <stdint.h>
diff --git a/unit/test-gobex-packet.c b/unit/test-gobex-packet.c
index 0d62460..d382ee5 100644
--- a/unit/test-gobex-packet.c
+++ b/unit/test-gobex-packet.c
@@ -21,7 +21,7 @@
  */
 
 #ifdef HAVE_CONFIG_H
-#include "config.h"
+#include <config.h>
 #endif
 
 #include <stdint.h>
diff --git a/unit/test-gobex-transfer.c b/unit/test-gobex-transfer.c
index 6807c9f..3f8905c 100644
--- a/unit/test-gobex-transfer.c
+++ b/unit/test-gobex-transfer.c
@@ -21,7 +21,7 @@
  */
 
 #ifdef HAVE_CONFIG_H
-#include "config.h"
+#include <config.h>
 #endif
 
 #include <stdlib.h>
diff --git a/unit/test-gobex.c b/unit/test-gobex.c
index 66531a2..1afb7ce 100644
--- a/unit/test-gobex.c
+++ b/unit/test-gobex.c
@@ -21,7 +21,7 @@
  */
 
 #ifdef HAVE_CONFIG_H
-#include "config.h"
+#include <config.h>
 #endif
 
 #include <stdlib.h>
diff --git a/unit/test-hog.c b/unit/test-hog.c
index d117968..37d3abe 100644
--- a/unit/test-hog.c
+++ b/unit/test-hog.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <unistd.h>
 #include <string.h>
 #include <sys/socket.h>
diff --git a/unit/test-lib.c b/unit/test-lib.c
index bd4c5ee..1dd5d92 100644
--- a/unit/test-lib.c
+++ b/unit/test-lib.c
@@ -23,12 +23,13 @@
  */
 
 #ifdef HAVE_CONFIG_H
-#include "config.h"
+#include <config.h>
 #endif
 
-#include <glib.h>
+#define _GNU_SOURCE
 #include <stdlib.h>
 #include <errno.h>
+#include <glib.h>
 
 #include "src/shared/util.h"
 #include "src/shared/tester.h"
diff --git a/unit/test-ringbuf.c b/unit/test-ringbuf.c
index a97524e..ef3bf0a 100644
--- a/unit/test-ringbuf.c
+++ b/unit/test-ringbuf.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <string.h>
 #include <stdint.h>
diff --git a/unit/test-textfile.c b/unit/test-textfile.c
index 5250f98..4b43898 100644
--- a/unit/test-textfile.c
+++ b/unit/test-textfile.c
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <fcntl.h>
 #include <unistd.h>
diff --git a/unit/util.c b/unit/util.c
index ce4d65a..c8054d2 100644
--- a/unit/util.c
+++ b/unit/util.c
@@ -20,7 +20,7 @@
  */
 
 #ifdef HAVE_CONFIG_H
-#include "config.h"
+#include <config.h>
 #endif
 
 #include <sys/types.h>