[3/3] sim: dv-sockser: enable for mingw targets too

Message ID 20210608051036.24813-3-vapier@gentoo.org
State New
Headers show
Series
  • [1/3] gnulib: import various network functions
Related show

Commit Message

Metzger, Markus T via Gdb-patches June 8, 2021, 5:10 a.m.
We have enough functionality from gnulib now to build sockser on
all platforms.
---
 sim/common/dv-sockser.c          |  6 +++++-
 sim/m4/sim_ac_option_hardware.m4 | 16 +++++-----------
 2 files changed, 10 insertions(+), 12 deletions(-)

-- 
2.31.1

Comments

John Baldwin June 8, 2021, 3:43 p.m. | #1
On 6/7/21 10:10 PM, Mike Frysinger via Gdb-patches wrote:
> We have enough functionality from gnulib now to build sockser on

> all platforms.

> ---

>   sim/common/dv-sockser.c          |  6 +++++-

>   sim/m4/sim_ac_option_hardware.m4 | 16 +++++-----------

>   2 files changed, 10 insertions(+), 12 deletions(-)

> 

> diff --git a/sim/common/dv-sockser.c b/sim/common/dv-sockser.c

> index 7f1cf798e4b9..f1ef22a53a8e 100644

> --- a/sim/common/dv-sockser.c

> +++ b/sim/common/dv-sockser.c

> @@ -43,7 +43,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.  */

>   #include <sys/socket.h>

>   

>   #ifndef __CYGWIN32__

> -#include <netinet/tcp.h>

> +//#include <netinet/tcp.h>

>   #endif

>   

>   #include "sim-assert.h"


This hunk looks like a temporary testing change?  Did you mean to remove the header
entirely?

-- 
John Baldwin
Metzger, Markus T via Gdb-patches June 8, 2021, 8:58 p.m. | #2
On 08 Jun 2021 08:43, John Baldwin wrote:
> On 6/7/21 10:10 PM, Mike Frysinger via Gdb-patches wrote:

> > We have enough functionality from gnulib now to build sockser on

> > all platforms.

> > ---

> >   sim/common/dv-sockser.c          |  6 +++++-

> >   sim/m4/sim_ac_option_hardware.m4 | 16 +++++-----------

> >   2 files changed, 10 insertions(+), 12 deletions(-)

> > 

> > diff --git a/sim/common/dv-sockser.c b/sim/common/dv-sockser.c

> > index 7f1cf798e4b9..f1ef22a53a8e 100644

> > --- a/sim/common/dv-sockser.c

> > +++ b/sim/common/dv-sockser.c

> > @@ -43,7 +43,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.  */

> >   #include <sys/socket.h>

> >   

> >   #ifndef __CYGWIN32__

> > -#include <netinet/tcp.h>

> > +//#include <netinet/tcp.h>

> >   #endif

> >   

> >   #include "sim-assert.h"

> 

> This hunk looks like a temporary testing change?  Did you mean to remove the header

> entirely?


err, yeah, i thought i finished that.  i meant to take a closer look to see why
we're even including it in the first place.  thanks.
-mike

Patch

diff --git a/sim/common/dv-sockser.c b/sim/common/dv-sockser.c
index 7f1cf798e4b9..f1ef22a53a8e 100644
--- a/sim/common/dv-sockser.c
+++ b/sim/common/dv-sockser.c
@@ -43,7 +43,7 @@  along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 #include <sys/socket.h>
 
 #ifndef __CYGWIN32__
-#include <netinet/tcp.h>
+//#include <netinet/tcp.h>
 #endif
 
 #include "sim-assert.h"
@@ -199,6 +199,7 @@  dv_sockser_init (SIM_DESC sd)
 
   /* Handle writes to missing client -> SIGPIPE.
      ??? Need a central signal management module.  */
+#ifdef SIGPIPE
   {
     RETSIGTYPE (*orig) ();
     orig = signal (SIGPIPE, SIG_IGN);
@@ -206,6 +207,7 @@  dv_sockser_init (SIM_DESC sd)
     if (orig != SIG_DFL && orig != SIG_IGN)
       signal (SIGPIPE, orig);
   }
+#endif
 
   return SIM_RC_OK;
 }
@@ -277,6 +279,7 @@  connected_p (SIM_DESC sd)
     return 0;
 
   /* Set non-blocking i/o.  */
+#ifdef F_GETFL
   flags = fcntl (sockser_fd, F_GETFL);
   flags |= O_NONBLOCK | O_NDELAY;
   if (fcntl (sockser_fd, F_SETFL, flags) == -1)
@@ -286,6 +289,7 @@  connected_p (SIM_DESC sd)
       sockser_fd = -1;
       return 0;
     }
+#endif
   return 1;
 }
 
diff --git a/sim/m4/sim_ac_option_hardware.m4 b/sim/m4/sim_ac_option_hardware.m4
index 75e331eb0b33..a4595cee056c 100644
--- a/sim/m4/sim_ac_option_hardware.m4
+++ b/sim/m4/sim_ac_option_hardware.m4
@@ -48,17 +48,11 @@  else
       *) sim_hw="$sim_hw $i" ; sim_hw_objs="$sim_hw_objs dv-$i.o";;
     esac
   done
-  # mingw does not support sockser
-  case ${host} in
-    *mingw*) ;;
-    *) # TODO: We don't add dv-sockser to sim_hw as it is not a "real" device
-       # that you instatiate.  Instead, other code will call into it directly.
-       # At some point, we should convert it over.
-       sim_hw_objs="$sim_hw_objs dv-sockser.o"
-       AC_DEFINE_UNQUOTED(
-         [HAVE_DV_SOCKSER], 1, [Define if dv-sockser is usable.])
-       ;;
-  esac
+  dnl TODO: We don't add dv-sockser to sim_hw as it is not a "real" device
+  dnl that you instatiate.  Instead, other code will call into it directly.
+  dnl At some point, we should convert it over.
+  sim_hw_objs="$sim_hw_objs dv-sockser.o"
+  AC_DEFINE_UNQUOTED([HAVE_DV_SOCKSER], 1, [Define if dv-sockser is usable.])
   if test x"$silent" != x"yes"; then
     echo "Setting hardware to $sim_hw_cflags, $sim_hw, $sim_hw_objs"
   fi