esnet / iperf

iperf3: A TCP, UDP, and SCTP network bandwidth measurement tool
Other
6.77k stars 1.27k forks source link

Possible compile on Solaris 10 #964

Open zoeloe opened 4 years ago

zoeloe commented 4 years ago

EDIT: Reformatted code for legibility. --bmah

Context

Solaris 10

gcc

Not being used with pull request I submit here some code that seems to fix something under Solaris 10: Add the follwing in iperf_auth.c found this on https://github.com/firnsy/barnyard2/issues/98

#if defined(__sun)
/* Written by Kaveh R. Ghazi <ghazi@caip.rutgers.edu> */
char *
strndup (const char *s, size_t n)
{
  char *result;
  size_t len = strlen (s);

  if (n < len)
    len = n;

  result = (char *) malloc (len + 1);
  if (!result)
    return 0;

  memcpy (result, s, len);
  result[len] = '\0';
  return(result);
}
#endif
bmah888 commented 4 years ago

Thanks for the suggestion and implementation! A more portable way to figure out if the substitute stndup() is needed is to do a check in the configure script and key off of that. See for example the implementation of daemon(), where we have an implementation that is conditionally compiled in src/iperf_util.c.

If someone were package this up along with the autoconf goop as as pull request, and test it to confirm it all works (don't have that platform handy), that'd stand a pretty good chance of getting merged.

PartialVolume commented 3 years ago

I've got some SPARC hardware available Ultra 10, Ultra 60 and Blade 150. I think the OS installed is sunos 5 with Solaris 8. However I'll see if I can compile iperf and let you know the results in due course.