Skip to contentSkip to conversation

Phonet build work-arounds

PATCH New Rémi Denis-Courmont 1 participant 3 messages Jul 3, 2009

lore
Share & tools
lore
#0 lore raw

cover Phonet build work-arounds

 configure.ac           |   40 ++++++++++++++++++++++++++++++++++++++++
 drivers/atmodem/at.h   |    4 ----
 drivers/isimodem/isi.h |    4 ----
 gisi/client.c          |    8 +++-----
 gisi/netlink.c         |    7 +++----
 gisi/socket.c          |    9 +++------
 6 files changed, 49 insertions(+), 23 deletions(-)
Signature · 1 line
Rémi Denis-Courmont

From 44ed0e385e79c1230ecc6a3d583e1095eee7f9a0 Mon Sep 17 00:00:00 2001
From: =?utf-8?q?R=C3=A9mi=20Denis-Courmont?= <[email protected]>
Date: Thu, 2 Jul 2009 13:43:34 +0300
Subject: [PATCH 1/5] Do not include <config.h> from headers

From: Rémi Denis-Courmont <[email protected]>

It should be included _first_ in all modules, and it is not proof against multiple inclusions.

---
 drivers/atmodem/at.h   |    4 ----
 drivers/isimodem/isi.h |    4 ----
 2 files changed, 0 insertions(+), 8 deletions(-)
drivers/atmodem/at.h +0 -4
index 0300282..3cc3cb1 100644
@@ -19,10 +19,6 @@
  *
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
 struct at_data {
 	GAtChat *parser;
 	struct ofono_modem *modem;
drivers/isimodem/isi.h +0 -4
index b89a694..e808bfd 100644
@@ -21,10 +21,6 @@
  *
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
 #define DECLARE_FAILURE(e) 			\
 	struct ofono_error e;			\
 	e.type = OFONO_ERROR_TYPE_FAILURE;	\
Signature · 1 line
1.6.0.4

From 3a7f8f26eb788a100742f8e64afb11cc7d35e15e Mon Sep 17 00:00:00 2001
From: =?utf-8?q?R=C3=A9mi=20Denis-Courmont?= <[email protected]>
Date: Thu, 2 Jul 2009 11:20:23 +0300
Subject: [PATCH 2/5] Centralized check for (A|P)F_PHONET

From: Rémi Denis-Courmont <[email protected]>

---
 configure.ac   |   10 ++++++++++
 gisi/client.c  |    3 ---
 gisi/netlink.c |    3 ---
 gisi/socket.c  |    4 ----
 4 files changed, 10 insertions(+), 10 deletions(-)
configure.ac +10 -0
index 9ba745f..a8d0d3f 100644
@@ -80,6 +80,16 @@ AC_SUBST([GDBUS_LIBS], ['$(top_builddir)/gdbus/libgdbus.la $(DBUS_LIBS)'])
 AC_SUBST([GATCHAT_CFLAGS], ['-I$(top_srcdir)/gatchat'])
 AC_SUBST([GATCHAT_LIBS], ['$(top_builddir)/gatchat/libgatchat.la'])
 
+AC_CHECK_DECLS([AF_PHONET], [], [],
+[#include <sys/types.h>
+#include <sys/socket.h>
+])
+AH_BOTTOM(
+[#if !HAVE_DECL_AF_PHONET
+#define AF_PHONET 35
+#define PF_PHONET AF_PHONET
+#endif
+])
 AC_SUBST([GISI_CFLAGS], ['-I$(top_srcdir)'])
 AC_SUBST([GISI_LIBS], ['$(top_builddir)/gisi/libgisi.la'])
 
gisi/client.c +0 -3
index ae8b030..1d99c80 100644
@@ -36,9 +36,6 @@
 #include <glib.h>
 #include <linux/types.h>
 #include <linux/phonet.h>
-#ifndef AF_PHONET
-#define AF_PHONET 35
-#endif
 
 #include "socket.h"
 #include "client.h"
gisi/netlink.c +0 -3
index d555588..5689f51 100644
@@ -36,9 +36,6 @@
 #ifndef SOL_NETLINK
 #define SOL_NETLINK 270 /* libc!? */
 #endif
-#ifndef AF_PHONET
-#define AF_PHONET 35
-#endif
 #include <linux/rtnetlink.h>
 #include <linux/phonet.h>
 #include <glib.h>
gisi/socket.c +0 -4
index 6f72120..ac69009 100644
@@ -35,10 +35,6 @@
 #include <linux/phonet.h>
 #include <glib.h>
 
-#ifndef AF_PHONET
-#define AF_PHONET 35
-#define PF_PHONET AF_PHONET
-#endif
 #include "socket.h"
 
 GIOChannel *phonet_new(uint8_t resource)
Signature · 1 line
1.6.0.4

From 02af1c71959afb9a1c1533630f316e29a851da6f Mon Sep 17 00:00:00 2001
From: =?utf-8?q?R=C3=A9mi=20Denis-Courmont?= <[email protected]>
Date: Thu, 2 Jul 2009 11:07:56 +0300
Subject: [PATCH 3/5] Check and use netphonet/phonet.h instead of linux/phonet.h

From: Rémi Denis-Courmont <[email protected]>

---
 configure.ac   |    4 ++++
 gisi/client.c  |    5 +++--
 gisi/netlink.c |    4 +++-
 gisi/socket.c  |    5 +++--
 4 files changed, 13 insertions(+), 5 deletions(-)
configure.ac +4 -0
index a8d0d3f..2989956 100644
@@ -80,6 +80,10 @@ AC_SUBST([GDBUS_LIBS], ['$(top_builddir)/gdbus/libgdbus.la $(DBUS_LIBS)'])
 AC_SUBST([GATCHAT_CFLAGS], ['-I$(top_srcdir)/gatchat'])
 AC_SUBST([GATCHAT_LIBS], ['$(top_builddir)/gatchat/libgatchat.la'])
 
+AC_CHECK_HEADERS([netphonet/phonet.h], [], [],
+[#include <sys/types.h>
+#include <sys/socket.h>
+])
 AC_CHECK_DECLS([AF_PHONET], [], [],
 [#include <sys/types.h>
 #include <sys/socket.h>
gisi/client.c +3 -2
index 1d99c80..555ff30 100644
@@ -33,9 +33,10 @@
 #include <sys/socket.h>
 #include <sys/uio.h>
 #include <errno.h>
+#ifdef HAVE_NETPHONET_PHONET_H
+#include <netphonet/phonet.h>
+#endif
 #include <glib.h>
-#include <linux/types.h>
-#include <linux/phonet.h>
 
 #include "socket.h"
 #include "client.h"
gisi/netlink.c +3 -1
index 5689f51..45f463e 100644
@@ -33,11 +33,13 @@
 #include <unistd.h>
 #include <fcntl.h>
 #include <sys/socket.h>
+#ifdef HAVE_NETPHONET_PHONET_H
+#include <netphonet/phonet.h>
+#endif
 #ifndef SOL_NETLINK
 #define SOL_NETLINK 270 /* libc!? */
 #endif
 #include <linux/rtnetlink.h>
-#include <linux/phonet.h>
 #include <glib.h>
 
 #include "netlink.h"
gisi/socket.c +3 -2
index ac69009..3f9aa02 100644
@@ -31,8 +31,9 @@
 #include <sys/ioctl.h>
 #include <unistd.h>
 #include <fcntl.h>
-#include <linux/types.h>
-#include <linux/phonet.h>
+#ifdef HAVE_NETPHONET_PHONET_H
+#include <netphonet/phonet.h>
+#endif
 #include <glib.h>
 
 #include "socket.h"
Signature · 1 line
1.6.0.4

From 18d147cc5f15b04f8e018f1ae64b297a9742f999 Mon Sep 17 00:00:00 2001
From: =?utf-8?q?R=C3=A9mi=20Denis-Courmont?= <[email protected]>
Date: Thu, 2 Jul 2009 11:31:05 +0300
Subject: [PATCH 4/5] Replace sockaddr_pn if missing

From: Rémi Denis-Courmont <[email protected]>

---
 configure.ac |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)
configure.ac +17 -0
index 2989956..c5f9d87 100644
@@ -88,11 +88,28 @@ AC_CHECK_DECLS([AF_PHONET], [], [],
 [#include <sys/types.h>
 #include <sys/socket.h>
 ])
+AC_CHECK_TYPES([struct sockaddr_pn], [], [],
+[#include <sys/types.h>
+#include <sys/socket.h>
+#ifdef HAVE_NETPHONET_PHONET_H
+#include <netphonet/phonet.h>
+#endif
+])
 AH_BOTTOM(
 [#if !HAVE_DECL_AF_PHONET
 #define AF_PHONET 35
 #define PF_PHONET AF_PHONET
 #endif
+
+#ifndef HAVE_STRUCT_SOCKADDR_PN
+struct sockaddr_pn {
+	unsigned short	spn_family;
+	unsigned char	spn_obj;
+	unsigned char	spn_dev;
+	unsigned char	spn_resource;
+	unsigned char	spn_zero[11];
+};
+#endif
 ])
 AC_SUBST([GISI_CFLAGS], ['-I$(top_srcdir)'])
 AC_SUBST([GISI_LIBS], ['$(top_builddir)/gisi/libgisi.la'])
Signature · 1 line
1.6.0.4

From 1d7d45e6412b657a063c0d6be43e10b1125b1468 Mon Sep 17 00:00:00 2001
From: =?utf-8?q?R=C3=A9mi=20Denis-Courmont?= <[email protected]>
Date: Fri, 3 Jul 2009 17:34:05 +0300
Subject: [PATCH 5/5] Replace RTNLGRP_PHONET_IFADDR if missing

From: Rémi Denis-Courmont <[email protected]>

---
 configure.ac |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)
configure.ac +9 -0
index c5f9d87..65fad6e 100644
@@ -95,6 +95,11 @@ AC_CHECK_TYPES([struct sockaddr_pn], [], [],
 #include <netphonet/phonet.h>
 #endif
 ])
+AC_CHECK_DECLS([RTNLGRP_PHONET_IFADDR], [], [],
+[#include <sys/types.h>
+#include <sys/socket.h>
+#include <linux/rtnetlink.h>
+])
 AH_BOTTOM(
 [#if !HAVE_DECL_AF_PHONET
 #define AF_PHONET 35
@@ -110,6 +115,10 @@ struct sockaddr_pn {
 	unsigned char	spn_zero[11];
 };
 #endif
+
+#if !HAVE_DECL_RTNLGRP_PHONET_IFADDR
+#define RTNLGRP_PHONET_IFADDR (RTNLGRP_ND_USEROPT + 1)
+#endif
 ])
 AC_SUBST([GISI_CFLAGS], ['-I$(top_srcdir)'])
 AC_SUBST([GISI_LIBS], ['$(top_builddir)/gisi/libgisi.la'])
Signature · 1 line
1.6.0.4
#1 lore raw

cover Phonet build work-arounds take two

A variant with less configure and config.h clutter.

 configure.ac           |    4 +++
 drivers/atmodem/at.h   |    4 ---
 drivers/isimodem/isi.h |    4 ---
 gisi/client.c          |   10 ++++----
 gisi/netlink.c         |    9 ++++---
 gisi/phonet.h          |   56
+++++++++++++++++++++++++++++++++++++++++++++++++
 gisi/socket.c          |   11 ++++-----
 7 files changed, 75 insertions(+), 23 deletions(-)
Signature · 1 line
Rémi Denis-Courmont

From 44ed0e385e79c1230ecc6a3d583e1095eee7f9a0 Mon Sep 17 00:00:00 2001
From: =?utf-8?q?R=C3=A9mi=20Denis-Courmont?= <[email protected]>
Date: Thu, 2 Jul 2009 13:43:34 +0300
Subject: [PATCH] Do not include <config.h> from headers

It should be included _first_ in all modules, and it is not proof against multiple inclusions.

---
 drivers/atmodem/at.h   |    4 ----
 drivers/isimodem/isi.h |    4 ----
 2 files changed, 0 insertions(+), 8 deletions(-)
drivers/atmodem/at.h +0 -4
index 0300282..3cc3cb1 100644
@@ -19,10 +19,6 @@
  *
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
 struct at_data {
 	GAtChat *parser;
 	struct ofono_modem *modem;
drivers/isimodem/isi.h +0 -4
index b89a694..e808bfd 100644
@@ -21,10 +21,6 @@
  *
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
 #define DECLARE_FAILURE(e) 			\
 	struct ofono_error e;			\
 	e.type = OFONO_ERROR_TYPE_FAILURE;	\
Signature · 1 line
1.6.0.4

From f840ea7a705e3c03cd774149ccf4f4bb35c8a3ea Mon Sep 17 00:00:00 2001
From: =?utf-8?q?R=C3=A9mi=20Denis-Courmont?= <[email protected]>
Date: Fri, 3 Jul 2009 18:19:15 +0300
Subject: [PATCH] Replacement header for Phonet definitions

---
 gisi/phonet.h |   56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 56 insertions(+), 0 deletions(-)
 create mode 100644 gisi/phonet.h
gisi/phonet.h new file +56 -0

56 lines not on this page · raw message

Signature · 1 line
1.6.0.4

From 7e50d7580cdcddf55864ebad91396bc21e41c59f Mon Sep 17 00:00:00 2001
From: =?utf-8?q?R=C3=A9mi=20Denis-Courmont?= <[email protected]>
Date: Thu, 2 Jul 2009 11:07:56 +0300
Subject: [PATCH] Check and use netphonet/phonet.h instead of linux/phonet.h

---
 configure.ac   |    4 ++++
 gisi/client.c  |   10 +++++-----
 gisi/netlink.c |    9 +++++----
 gisi/socket.c  |   11 +++++------
 4 files changed, 19 insertions(+), 15 deletions(-)
configure.ac +4 -0
index 9ba745f..71989e0 100644
@@ -80,6 +80,10 @@ AC_SUBST([GDBUS_LIBS], ['$(top_builddir)/gdbus/libgdbus.la $(DBUS_LIBS)'])
 AC_SUBST([GATCHAT_CFLAGS], ['-I$(top_srcdir)/gatchat'])
 AC_SUBST([GATCHAT_LIBS], ['$(top_builddir)/gatchat/libgatchat.la'])
 
+AC_CHECK_HEADERS([netphonet/phonet.h], [], [],
+[#include <sys/types.h>
+#include <sys/socket.h>
+])
 AC_SUBST([GISI_CFLAGS], ['-I$(top_srcdir)'])
 AC_SUBST([GISI_LIBS], ['$(top_builddir)/gisi/libgisi.la'])
 
gisi/client.c +5 -5
index ae8b030..fd6dc87 100644
@@ -33,12 +33,12 @@
 #include <sys/socket.h>
 #include <sys/uio.h>
 #include <errno.h>
-#include <glib.h>
-#include <linux/types.h>
-#include <linux/phonet.h>
-#ifndef AF_PHONET
-#define AF_PHONET 35
+#ifdef HAVE_NETPHONET_PHONET_H
+#include <netphonet/phonet.h>
+#else
+#include "phonet.h"
 #endif
+#include <glib.h>
 
 #include "socket.h"
 #include "client.h"
gisi/netlink.c +5 -4
index d555588..b34e8b4 100644
@@ -33,14 +33,15 @@
 #include <unistd.h>
 #include <fcntl.h>
 #include <sys/socket.h>
+#ifdef HAVE_NETPHONET_PHONET_H
+#include <netphonet/phonet.h>
+#else
+#include "phonet.h"
+#endif
 #ifndef SOL_NETLINK
 #define SOL_NETLINK 270 /* libc!? */
 #endif
-#ifndef AF_PHONET
-#define AF_PHONET 35
-#endif
 #include <linux/rtnetlink.h>
-#include <linux/phonet.h>
 #include <glib.h>
 
 #include "netlink.h"
gisi/socket.c +5 -6
index 6f72120..2b0493c 100644
@@ -31,14 +31,13 @@
 #include <sys/ioctl.h>
 #include <unistd.h>
 #include <fcntl.h>
-#include <linux/types.h>
-#include <linux/phonet.h>
+#ifdef HAVE_NETPHONET_PHONET_H
+#include <netphonet/phonet.h>
+#else
+#include "phonet.h"
+#endif
 #include <glib.h>
 
-#ifndef AF_PHONET
-#define AF_PHONET 35
-#define PF_PHONET AF_PHONET
-#endif
 #include "socket.h"
 
 GIOChannel *phonet_new(uint8_t resource)
Signature · 1 line
1.6.0.4
#2 lore raw

Re: [0/3] Phonet build work-arounds take two

Simpler option for patch 3/3

Signature · 1 line
Rémi Denis-Courmont

From cc159ea567bca758984d0e445d78a45d426fa62f Mon Sep 17 00:00:00 2001
From: =?utf-8?q?R=C3=A9mi=20Denis-Courmont?= <[email protected]>
Date: Fri, 3 Jul 2009 18:32:31 +0300
Subject: [PATCH 3/3] Use phonet.h

---
 gisi/client.c  |    6 +-----
 gisi/netlink.c |    5 +----
 gisi/socket.c  |    7 +------
 3 files changed, 3 insertions(+), 15 deletions(-)
gisi/client.c +1 -5
index ae8b030..b12dc85 100644
@@ -33,12 +33,8 @@
 #include <sys/socket.h>
 #include <sys/uio.h>
 #include <errno.h>
+#include "phonet.h"
 #include <glib.h>
-#include <linux/types.h>
-#include <linux/phonet.h>
-#ifndef AF_PHONET
-#define AF_PHONET 35
-#endif
 
 #include "socket.h"
 #include "client.h"
gisi/netlink.c +1 -4
index d555588..837f98e 100644
@@ -36,11 +36,8 @@
 #ifndef SOL_NETLINK
 #define SOL_NETLINK 270 /* libc!? */
 #endif
-#ifndef AF_PHONET
-#define AF_PHONET 35
-#endif
+#include "phonet.h"
 #include <linux/rtnetlink.h>
-#include <linux/phonet.h>
 #include <glib.h>
 
 #include "netlink.h"
gisi/socket.c +1 -6
index 6f72120..3eef09c 100644
@@ -31,14 +31,9 @@
 #include <sys/ioctl.h>
 #include <unistd.h>
 #include <fcntl.h>
-#include <linux/types.h>
-#include <linux/phonet.h>
+#include "phonet.h"
 #include <glib.h>
 
-#ifndef AF_PHONET
-#define AF_PHONET 35
-#define PF_PHONET AF_PHONET
-#endif
 #include "socket.h"
 
 GIOChannel *phonet_new(uint8_t resource)
Signature · 1 line
1.6.0.4