Bug 729511: (and Bug 783843) build libsctp within Mozilla tree r=biesi r=ted
authorRandell Jesup <rjesup@jesup.org>
Thu, 29 Mar 2012 17:25:15 -0400
changeset 115890 059041691d7f9df8bca1d4b2eb1f7ce904f048a5
parent 115889 d85136cf566a0bf4d90ab636e35a8c9f1477fb24
child 115891 c2d9b920fc7206d44d47c365a82fc9f8ec93a05d
push id239
push userakeybl@mozilla.com
push dateThu, 03 Jan 2013 21:54:43 +0000
treeherdermozilla-release@3a7b66445659 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbiesi, ted
bugs729511, 783843
milestone18.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 729511: (and Bug 783843) build libsctp within Mozilla tree r=biesi r=ted
configure.in
netwerk/Makefile.in
netwerk/build/Makefile.in
netwerk/sctp/src/Makefile.in
netwerk/sctp/src/README.sctp
netwerk/sctp/update_sctp.sh
--- a/configure.in
+++ b/configure.in
@@ -2972,21 +2972,55 @@ freebsd*|openbsd*)
     ;;
 esac
 MOZ_CHECK_COMMON_HEADERS
 
 dnl These are all the places some variant of statfs can be hiding.
 MOZ_CHECK_HEADERS(sys/statvfs.h sys/statfs.h sys/vfs.h sys/mount.h)
 
 dnl Quota support
+dnl SCTP support - needs various network include headers
 MOZ_CHECK_HEADERS(sys/quota.h sys/sysmacros.h)
-MOZ_CHECK_HEADERS(linux/quota.h)
+MOZ_CHECK_HEADERS([linux/quota.h linux/if_addr.h linux/rtnetlink.h],,,[#include <sys/socket.h>])
 
 MOZ_CHECK_HEADERS(sys/types.h netinet/in.h byteswap.h)
 
+dnl Check for sin_len and sin6_len - used by SCTP; only appears in Mac/*BSD generally
+AC_CACHE_CHECK(for sockaddr_in.sin_len,
+                   ac_cv_sockaddr_in_sin_len,
+                   [AC_TRY_COMPILE([#ifdef HAVE_SYS_TYPES_H
+                                    #include <sys/types.h>
+                                    #endif
+                                    #include <netinet/in.h>
+                                    struct sockaddr_in x;
+                                    void *foo = (void*) &x.sin_len;],
+                                   [],
+                                   [ac_cv_sockaddr_in_sin_len=true],
+                                   [ac_cv_sockaddr_in_sin_len=false])])
+if test "$ac_cv_sockaddr_in_sin_len" = true ; then
+  AC_DEFINE(HAVE_SIN_LEN)
+dnl HAVE_CONN_LEN must be the same as HAVE_SIN_LEN (and HAVE_SIN6_LEN too)
+  AC_DEFINE(HAVE_CONN_LEN)
+fi
+
+AC_CACHE_CHECK(for sockaddr_in6.sin6_len,
+               ac_cv_sockaddr_in6_sin6_len,
+               [AC_TRY_COMPILE([#ifdef HAVE_SYS_TYPES_H
+                                #include <sys/types.h>
+                                #endif
+                                #include <netinet/in.h>
+                                struct sockaddr_in6 x;
+                                void *foo = (void*) &x.sin6_len;],
+                               [],
+                               [ac_cv_sockaddr_in6_sin6_len=true],
+                               [ac_cv_sockaddr_in6_sin6_len=false])])
+if test "$ac_cv_sockaddr_in6_sin6_len" = true ; then
+  AC_DEFINE(HAVE_SIN6_LEN)
+fi
+
 dnl Check whether the compiler supports the new-style C++ standard
 dnl library headers (i.e. <new>) or needs the old "new.h"
 AC_LANG_CPLUSPLUS
 NEW_H=new.h
 MOZ_CHECK_HEADER(new, [NEW_H=new])
 AC_DEFINE_UNQUOTED(NEW_H, <$NEW_H>)
 AC_LANG_C
 
@@ -4188,16 +4222,17 @@ MOZ_SAMPLE_TYPE_FLOAT32=
 MOZ_SAMPLE_TYPE_S16=
 MOZ_MEDIA=
 MOZ_OPUS=1
 MOZ_WEBM=1
 MOZ_DASH=
 MOZ_WEBRTC=1
 MOZ_SRTP=
 MOZ_WEBRTC_SIGNALING=
+MOZ_SCTP=
 MOZ_MEDIA_PLUGINS=
 MOZ_MEDIA_NAVIGATOR=
 MOZ_OMX_PLUGIN=
 MOZ_VP8=
 MOZ_VP8_ERROR_CONCEALMENT=
 MOZ_VP8_ENCODER=
 VPX_AS=
 VPX_ASFLAGS=
@@ -5183,21 +5218,24 @@ MOZ_ARG_DISABLE_BOOL(webrtc,
 
 if test -n "$MOZ_WEBRTC"; then
     AC_DEFINE(MOZ_WEBRTC)
     MOZ_MEDIA=1
     MOZ_RAW=1
     MOZ_VP8=1
     MOZ_VP8_ENCODER=1
     MOZ_VP8_ERROR_CONCEALMENT=1
+    MOZ_SCTP=1
     MOZ_SRTP=1
+    AC_DEFINE(MOZ_SCTP)
     AC_DEFINE(MOZ_SRTP)
 fi
 
 AC_SUBST(MOZ_WEBRTC)
+AC_SUBST(MOZ_SCTP)
 AC_SUBST(MOZ_SRTP)
 
 case "$target_cpu" in
 arm*)
     MOZ_SAMPLE_TYPE_S16=1
     AC_DEFINE(MOZ_SAMPLE_TYPE_S16)
     AC_SUBST(MOZ_SAMPLE_TYPE_S16)
 ;;
--- a/netwerk/Makefile.in
+++ b/netwerk/Makefile.in
@@ -26,16 +26,22 @@ PARALLEL_DIRS = \
   $(NULL)
 
 ifdef MOZ_SRTP
 PARALLEL_DIRS += \
   srtp/src \
   $(NULL)
 endif
 
+ifdef MOZ_SCTP
+PARALLEL_DIRS += \
+  sctp/src \
+  $(NULL)
+endif
+
 ifdef NECKO_WIFI
 PARALLEL_DIRS += wifi
 endif
 
 PARALLEL_DIRS += locales
 
 ifdef MOZ_DASH
 PARALLEL_DIRS += dash
--- a/netwerk/build/Makefile.in
+++ b/netwerk/build/Makefile.in
@@ -37,16 +37,22 @@ SHARED_LIBRARY_LIBS = \
   $(NULL)
 
 ifdef MOZ_SRTP
 SHARED_LIBRARY_LIBS += \
   ../srtp/src/$(LIB_PREFIX)nksrtp_s.$(LIB_SUFFIX) \
   $(NULL)
 endif
 
+ifdef MOZ_SCTP
+SHARED_LIBRARY_LIBS += \
+  ../sctp/src/$(LIB_PREFIX)nksctp_s.$(LIB_SUFFIX) \
+  $(NULL)
+endif
+
 ifeq ($(OS_ARCH),WINNT)
     SHARED_LIBRARY_LIBS += \
         ../system/win32/$(LIB_PREFIX)neckosystem_s.$(LIB_SUFFIX)
 endif
 
 ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
     SHARED_LIBRARY_LIBS += \
         ../system/mac/$(LIB_PREFIX)neckosystem_s.$(LIB_SUFFIX)
new file mode 100644
--- /dev/null
+++ b/netwerk/sctp/src/Makefile.in
@@ -0,0 +1,115 @@
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+DEPTH     = ../../..
+topsrcdir = @top_srcdir@
+srcdir    = @srcdir@
+VPATH     = \
+  @srcdir@ \
+  @srcdir@/netinet \
+  @srcdir@/netinet6 \
+  $(NULL)
+
+include $(DEPTH)/config/autoconf.mk
+
+MODULE         = necko
+LIBRARY_NAME   = nksctp_s
+LIBXUL_LIBRARY = 1
+XPIDL_MODULE   = necko_sctp
+GRE_MODULE     = 1
+FORCE_STATIC_LIB = 1
+
+EXPORTS_NAMESPACES = mozilla/net
+
+XPIDLSRCS = \
+  $(NULL)
+
+CSRCS = \
+  user_environment.c \
+  user_mbuf.c \
+  user_recv_thread.c \
+  user_sctp_timer_iterate.c \
+  user_socket.c \
+  sctp_asconf.c \
+  sctp_auth.c \
+  sctp_bsd_addr.c \
+  sctp_callout.c \
+  sctp_cc_functions.c \
+  sctp_crc32.c \
+  sctp_hashdriver.c \
+  sctp_indata.c \
+  sctp_input.c \
+  sctp_output.c \
+  sctp_pcb.c \
+  sctp_peeloff.c \
+  sctp_sha1.c \
+  sctp_ss_functions.c \
+  sctp_sysctl.c \
+  sctp_userspace.c \
+  sctp_timer.c \
+  sctp_usrreq.c \
+  sctputil.c \
+  sctp6_usrreq.c \
+  $(NULL)
+
+EXPORTS_mozilla/net = \
+  usrsctp.h \
+  $(NULL)
+
+LOCAL_INCLUDES = \
+  -I$(srcdir)/../../base/src \
+  -I$(topsrcdir)/content/base/src \
+  -I$(topsrcdir)/content/events/src \
+  -I$(topsrcdir)/xpcom/ds \
+  $(NULL)
+
+DEFINES = \
+  -DSCTP_SIMPLE_ALLOCATOR=1 \
+  -DUSE_SCTP_SHA1=1 \
+  -DSCTP_PROCESS_LEVEL_LOCKS=1 \
+  -D__Userspace__=1 \
+  -DINET=1 \
+  -DINET6=1 \
+  -DCALLBACK_API=1 \
+  -DSCTP_DEBUG=1 \
+  $(NULL)
+
+ifeq ($(OS_TARGET),WINNT)
+DEFINES += \
+  -D__Userspace_os_Windows=1 \
+  -D_LIB=1 \
+  $(NULL)
+else
+ifeq ($(OS_TARGET),Darwin)
+DEFINES += \
+  -D__Userspace_os_Darwin=1 \
+  -D__APPLE_USE_RFC_2292=1 \
+  -U__APPLE__ \
+  $(NULL)
+else
+ifeq ($(OS_TARGET),Linux)
+DEFINES += -D__Userspace_os_Linux=1
+else
+ifeq ($(OS_TARGET),FreeBSD)
+DEFINES += \
+  -D__Userspace_os_FreeBSD=1 \
+  -U__FreeBSD__ \
+  $(NULL)
+else
+#error Unsupported platform!
+endif
+endif
+endif
+endif
+
+include $(topsrcdir)/config/config.mk
+include $(topsrcdir)/ipc/chromium/chromium-config.mk
+include $(topsrcdir)/config/rules.mk
+
+ifdef GNU_CC
+CFLAGS += -std=gnu99
+endif
+
+DEFINES += -DIMPL_NS_NET
new file mode 100644
--- /dev/null
+++ b/netwerk/sctp/src/README.sctp
@@ -0,0 +1,16 @@
+This code is imported from the usrsctp library via netwerk/sctp/update_sctp.sh.
+
+The project is accessed via:
+
+svn co --username your.username https://sctp-refimpl.googlecode.com/svn/trunk sctpSVN
+
+If you just want a read-only copy use
+
+svn co http://sctp-refimpl.googlecode.com/svn/trunk sctpSVN
+
+The usrsctp library is based on the FreeBSD kernel implementation, and the
+userspace implementation was largely done my Michael Tuexen and Irene
+Rungler of the Munster University of Applied Sciences.  Thanks also to
+Randall Stewart for his help.
+
+The library is covered by a BSD license - see headers in files.
new file mode 100755
--- /dev/null
+++ b/netwerk/sctp/update_sctp.sh
@@ -0,0 +1,33 @@
+#!/bin/bash
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+# assume $1 is the directory with a SVN checkout of the libsctp source
+#
+# sctp usrlib source is available (via svn) at:
+# svn co https://sctp-refimpl.googlecode.com/svn/trunk sctpSVN
+#
+# also assumes we've made *NO* changes to the SCTP sources!  If we do, we have to merge by
+# hand after this process, or use a more complex one.
+#
+# For example, one could update an sctp library import head, and merge back to default.  Or keep a
+# separate repo with this in it, and pull from there to m-c and merge.
+if [ "$1" ] ; then
+  export date=`date`
+  export revision=`(cd $1; svnversion -n)`
+
+  cp $1/KERN/usrsctp/usrsctplib/*.c $1/KERN/usrsctp/usrsctplib/*.h netwerk/sctp/src
+  cp $1/KERN/usrsctp/usrsctplib/netinet/*.c $1/KERN/usrsctp/usrsctplib/netinet/*.h netwerk/sctp/src/netinet
+  cp $1/KERN/usrsctp/usrsctplib/netinet6/*.c $1/KERN/usrsctp/usrsctplib/netinet6/*.h netwerk/sctp/src/netinet6
+
+  hg addremove netwerk/sctp/src --include "**.c" --include "**.h" --similarity 90
+
+  echo "sctp updated to version $revision from SVN on $date" >> netwerk/sctp/sctp_update.log
+  echo "sctp updated to version $revision from SVN on $date"
+  echo "WARNING: reapply any local patches!"
+else
+  echo "usage: $0 path_to_sctpSVN_directory"
+  echo "run from the root of your m-c clone"
+fi