--- /dev/null
+$NetBSD$
+
+--- net/tap-bsd.c.orig 2010-02-23 20:54:38.000000000 +0000
++++ net/tap-bsd.c
+@@ -27,6 +27,8 @@
+ #include "sysemu.h"
+
+ #ifdef __NetBSD__
++#include <sys/ioctl.h>
++#include <net/if.h>
+ #include <net/if_tap.h>
+ #endif
+
+@@ -45,6 +47,9 @@ int tap_open(char *ifname, int ifname_si
+ int fd;
+ char *dev;
+ struct stat s;
++#ifdef TAPGIFNAME
++ struct ifreq ifr;
++#endif
+
+ #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+ /* if no ifname is given, always start the search from tap0. */
+@@ -75,14 +80,26 @@ int tap_open(char *ifname, int ifname_si
+ #else
+ TFR(fd = open("/dev/tap", O_RDWR));
+ if (fd < 0) {
+- fprintf(stderr, "warning: could not open /dev/tap: no virtual network emulation\n");
++ fprintf(stderr, "warning: could not open /dev/tap: no virtual network emulation: %s\n", strerror(errno));
+ return -1;
+ }
+ #endif
+
+- fstat(fd, &s);
++#ifdef TAPGIFNAME
++ if (ioctl (fd, TAPGIFNAME, (void*)&ifr) < 0) {
++ fprintf(stderr, "warning: could not open get tap name: %s\n",
++ strerror(errno));
++ return -1;
++ }
++ pstrcpy(ifname, ifname_size, ifr.ifr_name);
++#else
++ if (fstat(fd, &s) < 0) {
++ fprintf(stderr, "warning: could not stat /dev/tap: no virtual network emulation: %s\n", strerror(errno));
++ return -1;
++ }
+ dev = devname(s.st_rdev, S_IFCHR);
+ pstrcpy(ifname, ifname_size, dev);
++#endif
+
+ if (*vnet_hdr) {
+ /* BSD doesn't have IFF_VNET_HDR */
--- /dev/null
+$NetBSD$
+
+--- exec.c.orig 2010-02-23 20:54:38.000000000 +0000
++++ exec.c
+@@ -463,7 +463,7 @@ static void code_gen_alloc(unsigned long
+ exit(1);
+ }
+ }
+-#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
++#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) || defined(__NetBSD__)
+ {
+ int flags;
+ void *addr = NULL;
--- /dev/null
+$NetBSD$
+
+See NetBSD PR pkg/43311 and QEMU Bugs #581737:
+https://bugs.launchpad.net/qemu/+bug/581737
+
+--- hw/e1000.c.orig 2010-02-24 05:54:38.000000000 +0900
++++ hw/e1000.c 2010-05-08 04:04:39.000000000 +0900
+@@ -259,21 +259,20 @@
+
+ s->eecd_state.old_eecd = val & (E1000_EECD_SK | E1000_EECD_CS |
+ E1000_EECD_DI|E1000_EECD_FWE_MASK|E1000_EECD_REQ);
++ if (!(E1000_EECD_CS & val)) // CS inactive; nothing to do
++ return;
++ if (E1000_EECD_CS & (val ^ oldval)) { // CS rise edge; reset state
++ s->eecd_state.val_in = 0;
++ s->eecd_state.bitnum_in = 0;
++ s->eecd_state.bitnum_out = 0;
++ s->eecd_state.reading = 0;
++ }
+ if (!(E1000_EECD_SK & (val ^ oldval))) // no clock edge
+ return;
+ if (!(E1000_EECD_SK & val)) { // falling edge
+ s->eecd_state.bitnum_out++;
+ return;
+ }
+- if (!(val & E1000_EECD_CS)) { // rising, no CS (EEPROM reset)
+- memset(&s->eecd_state, 0, sizeof s->eecd_state);
+- /*
+- * restore old_eecd's E1000_EECD_SK (known to be on)
+- * to avoid false detection of a clock edge
+- */
+- s->eecd_state.old_eecd = E1000_EECD_SK;
+- return;
+- }
+ s->eecd_state.val_in <<= 1;
+ if (val & E1000_EECD_DI)
+ s->eecd_state.val_in |= 1;
--- /dev/null
+$NetBSD$
+
+--- calendar/libedata-cal/Makefile.in.orig 2008-09-22 04:26:02.000000000 +0200
++++ calendar/libedata-cal/Makefile.in
+@@ -61,9 +61,6 @@ libedata_cal_1_2_la_DEPENDENCIES = \
+ $(top_builddir)/libedataserver/libedataserver-1.2.la \
+ $(top_builddir)/libebackend/libebackend-1.2.la \
+ $(am__DEPENDENCIES_1)
+-am__objects_1 = Evolution-DataServer-Calendar-common.lo \
+- Evolution-DataServer-Calendar-skels.lo \
+- Evolution-DataServer-Calendar-stubs.lo
+ am_libedata_cal_1_2_la_OBJECTS = $(am__objects_1) e-cal-backend.lo \
+ e-cal-backend-cache.lo e-cal-backend-factory.lo \
+ e-cal-backend-loader-factory.lo e-cal-backend-sexp.lo \
--- /dev/null
+$NetBSD: patch-ae,v 1.10 2010/03/14 23:07:30 tron Exp $
+
+Really turn AMD 3DNow (and MMX, etc.) because the shared library
+will otherwise not build (Mac OS X) or work (Solaris) on Intel CPUs.
+
+--- libswscale/rgb2rgb.c.orig Thu Mar 19 04:45:29 2009
++++ libswscale/rgb2rgb.c Sun Mar 14 23:55:39 2010
+@@ -101,7 +101,7 @@
+ long lumStride, long chromStride, long srcStride);
+
+
+-#if ARCH_X86 && CONFIG_GPL
++#if ARCH_X86 && CONFIG_GPL && !defined(sun)
+ DECLARE_ASM_CONST(8, uint64_t, mmx_null) = 0x0000000000000000ULL;
+ DECLARE_ASM_CONST(8, uint64_t, mmx_one) = 0xFFFFFFFFFFFFFFFFULL;
+ DECLARE_ASM_CONST(8, uint64_t, mask32b) = 0x000000FF000000FFULL;
+@@ -162,7 +162,7 @@
+ #define RENAME(a) a ## _C
+ #include "rgb2rgb_template.c"
+
+-#if ARCH_X86 && CONFIG_GPL
++#if ARCH_X86 && CONFIG_GPL && !defined(sun) && !defined(__APPLE__)
+
+ //MMX versions
+ #undef RENAME
--- /dev/null
+$NetBSD$
+
+1.) Fixes pkg/42000, not necessary after the next upgrade.
+2.) Really turn AMD 3DNow (and MMX, etc.) because the shared library
+ will otherwise not work on Intel CPUs.
+
+--- libswscale/swscale.c.orig Thu Jun 4 23:55:52 2009
++++ libswscale/swscale.c Sun Mar 14 23:53:08 2010
+@@ -221,7 +221,7 @@
+ write special BGR->BGR scaler
+ */
+
+-#if ARCH_X86 && CONFIG_GPL
++#if ARCH_X86 && CONFIG_GPL && !defined(sun)
+ DECLARE_ASM_CONST(8, uint64_t, bF8)= 0xF8F8F8F8F8F8F8F8LL;
+ DECLARE_ASM_CONST(8, uint64_t, bFC)= 0xFCFCFCFCFCFCFCFCLL;
+ DECLARE_ASM_CONST(8, uint64_t, w10)= 0x0010001000100010LL;
+@@ -1307,12 +1307,14 @@
+
+ #if ARCH_PPC
+ #if (HAVE_ALTIVEC || CONFIG_RUNTIME_CPUDETECT) && CONFIG_GPL
++#if !CONFIG_RUNTIME_CPUDETECT
+ #undef COMPILE_C
++#endif
+ #define COMPILE_ALTIVEC
+ #endif
+ #endif //ARCH_PPC
+
+-#if ARCH_X86
++#if ARCH_X86 && !defined(sun)
+
+ #if ((HAVE_MMX && !HAVE_AMD3DNOW && !HAVE_MMX2) || CONFIG_RUNTIME_CPUDETECT) && CONFIG_GPL
+ #define COMPILE_MMX
+@@ -1349,7 +1351,7 @@
+ #include "swscale_template.c"
+ #endif
+
+-#if ARCH_X86
++#if ARCH_X86 && !defined(sun)
+
+ //MMX versions
+ #ifdef COMPILE_MMX
+@@ -1417,7 +1419,7 @@
+ int64_t *filter2=NULL;
+ const int64_t fone= 1LL<<54;
+ int ret= -1;
+-#if ARCH_X86
++#if ARCH_X86 && !defined(sun)
+ if (flags & SWS_CPU_CAPS_MMX)
+ __asm__ volatile("emms\n\t"::: "memory"); //FIXME this should not be required but it IS (even for non-MMX versions)
+ #endif
+@@ -1976,7 +1978,7 @@
+ #if CONFIG_RUNTIME_CPUDETECT && CONFIG_GPL
+ int flags = c->flags;
+
+-#if ARCH_X86
++#if ARCH_X86 && !defined(sun)
+ // ordered per speed fastest first
+ if (flags & SWS_CPU_CAPS_MMX2) {
+ sws_init_swScale_MMX2(c);
+@@ -2561,7 +2563,7 @@
+ int unscaled, needsDither;
+ int srcRange, dstRange;
+ SwsFilter dummyFilter= {NULL, NULL, NULL, NULL};
+-#if ARCH_X86
++#if ARCH_X86 && !defined(sun)
+ if (flags & SWS_CPU_CAPS_MMX)
+ __asm__ volatile("emms\n\t"::: "memory");
+ #endif
+@@ -3046,7 +3048,7 @@
+ }
+ else
+ {
+-#if ARCH_X86
++#if ARCH_X86 && !defined(sun)
+ av_log(c, AV_LOG_VERBOSE, "using x86 asm scaler for horizontal scaling\n");
+ #else
+ if (flags & SWS_FAST_BILINEAR)
+@@ -3555,7 +3557,7 @@
+ av_freep(&c->hLumFilterPos);
+ av_freep(&c->hChrFilterPos);
+
+-#if ARCH_X86 && CONFIG_GPL
++#if ARCH_X86 && CONFIG_GPL && !defined(sun)
+ #ifdef MAP_ANONYMOUS
+ if (c->funnyYCode ) munmap(c->funnyYCode , MAX_FUNNY_CODE_SIZE);
+ if (c->funnyUVCode) munmap(c->funnyUVCode, MAX_FUNNY_CODE_SIZE);
--- /dev/null
+--- libavdevice/bktr.c.orig 2009-01-19 15:46:40 +0000
++++ libavdevice/bktr.c 2009-09-21 11:29:29 +0000
+@@ -24,7 +24,11 @@
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
++/* u_short, u_int */
+ #define _BSD_SOURCE 1
++#ifdef __NetBSD__
++# define _NETBSD_SOURCE 1
++#endif
+ #include "libavformat/avformat.h"
+ #if HAVE_DEV_BKTR_IOCTL_METEOR_H && HAVE_DEV_BKTR_IOCTL_BT848_H
+ # include <dev/bktr/ioctl_meteor.h>
+@@ -32,7 +36,7 @@
+ #elif HAVE_MACHINE_IOCTL_METEOR_H && HAVE_MACHINE_IOCTL_BT848_H
+ # include <machine/ioctl_meteor.h>
+ # include <machine/ioctl_bt848.h>
+-#elif HAVE_DEV_VIDEO_METEOR_IOCTL_METEOR_H && HAVE_DEV_VIDEO_METEOR_IOCTL_BT848_H
++#elif HAVE_DEV_VIDEO_METEOR_IOCTL_METEOR_H && HAVE_DEV_VIDEO_BKTR_IOCTL_BT848_H
+ # include <dev/video/meteor/ioctl_meteor.h>
+ # include <dev/video/bktr/ioctl_bt848.h>
+ #elif HAVE_DEV_IC_BT8XX_H
--- /dev/null
+$NetBSD$
+
+--- common/x86/predict-c.c.orig 2009-04-05 21:31:54.000000000 +0200
++++ common/x86/predict-c.c
+@@ -110,7 +110,7 @@ PREDICT_16x16_P( mmxext )
+ #endif
+ PREDICT_16x16_P( sse2 )
+
+-#ifdef __GNUC__
++#if 0
+ static void predict_16x16_p_ssse3( uint8_t *src )
+ {
+ int a, b, c, i00;
+@@ -170,7 +170,7 @@ PREDICT_8x8_P( mmxext )
+ #endif
+ PREDICT_8x8_P( sse2 )
+
+-#ifdef __GNUC__
++#if 0
+ static void predict_8x8c_p_ssse3( uint8_t *src )
+ {
+ int a, b, c, i00;
+@@ -394,7 +394,7 @@ void x264_predict_16x16_init_mmx( int cp
+ if( !(cpu&X264_CPU_SSSE3) )
+ return;
+ pf[I_PRED_16x16_H] = predict_16x16_h_ssse3;
+-#ifdef __GNUC__
++#if 0
+ pf[I_PRED_16x16_P] = predict_16x16_p_ssse3;
+ #endif
+ }
+@@ -421,7 +421,7 @@ void x264_predict_8x8c_init_mmx( int cpu
+ if( !(cpu&X264_CPU_SSSE3) )
+ return;
+ pf[I_PRED_CHROMA_H] = predict_8x8c_h_ssse3;
+-#ifdef __GNUC__
++#if 0
+ pf[I_PRED_CHROMA_P] = predict_8x8c_p_ssse3;
+ #endif
+ }
--- /dev/null
+$NetBSD$
+
+--- src/combined/ffmpeg/ff_video_decoder.c.orig 2009-12-02 17:53:56.000000000 +0100
++++ src/combined/ffmpeg/ff_video_decoder.c
+@@ -1235,8 +1235,10 @@ static void ff_handle_buffer (ff_video_d
+ if (this->decoder_init_mode) {
+ int codec_type = buf->type & 0xFFFF0000;
+
++#ifdef AVCODEC_HAS_REORDERED_OPAQUE
+ if (!ff_check_extradata(this, codec_type, buf))
+ return;
++#endif
+
+ /* init ffmpeg decoder */
+ init_video_codec(this, codec_type);
--- /dev/null
+$NetBSD: patch-ac,v 1.4 2009/01/24 05:34:42 jmcneill Exp $
+
+--- ../../src/xvid.c.orig 2009-01-24 00:33:11.000000000 -0500
++++ ../../src/xvid.c 2009-01-24 00:33:42.000000000 -0500
+@@ -679,7 +679,11 @@ xvid_gbl_info(xvid_gbl_info_t * info)
+
+ #else
+
++#if defined(_SC_NPROCESSORS_CONF)
+ info->num_threads = sysconf(_SC_NPROCESSORS_CONF);
++#else
++ info->num_threads = 1;
++#endif
+
+ #endif
+
--- /dev/null
+$NetBSD$
+
+--- configure.orig 2009-05-05 20:54:59.000000000 -0700
++++ configure 2009-05-05 20:55:22.000000000 -0700
+@@ -4780,7 +4780,7 @@ fi
+ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ { echo "$as_me:$LINENO: result: $clock_gettime" >&5
+ echo "${ECHO_T}$clock_gettime" >&6; }
+-if test $clock_gettime == yes; then
++if test $clock_gettime = yes; then
+ old_LIBS=$LIBS
+ LIBS=""
+ { echo "$as_me:$LINENO: checking for library containing clock_gettime" >&5
+@@ -4876,7 +4876,7 @@ fi
+ _ACEOF
+
+ fi
+-if test $clock_gettime == no; then
++if test $clock_gettime = no; then
+
+ for ac_func in mach_absolute_time
+ do
+@@ -5374,7 +5374,7 @@ echo "$as_me: error: $m is not a valid e
+ ;;
+ esac
+ done
+-if test x"$EVLOOP_METHOD" == x; then
++if test x"$EVLOOP_METHOD" = x; then
+ { { echo "$as_me:$LINENO: error: no suitable evloop method found
+ See \`config.log' for more details." >&5
+ echo "$as_me: error: no suitable evloop method found
+@@ -5388,7 +5388,7 @@ fi
+
+ for i in 0 1 2 3 4 5 6 7; do
+ case $i in
+- 0) if test x"$TD_CFLAGS$TD_LIBS" == x; then continue; fi;;
++ 0) if test x"$TD_CFLAGS$TD_LIBS" = x; then continue; fi;;
+ 1) TD_CFLAGS=-pthread;;
+ 2) TD_CFLAGS=-pthreads;;
+ 3) TD_CFLAGS=-kthread;;
--- /dev/null
+$NetBSD: patch-ad,v 1.6 2010/09/25 11:19:10 tron Exp $
+
+--- configure.orig 2010-08-29 23:20:30.000000000 +0100
++++ configure 2010-09-25 11:47:16.000000000 +0100
+@@ -19604,7 +19604,7 @@
+ fi
+
+
+- if test x$have_ige_mac == x
++ if test x$have_ige_mac = x
+ then
+ #
+ # Not found - check for the old integration functions in
+@@ -19660,7 +19660,7 @@
+
+ fi
+
+- if test x$have_ige_mac == x
++ if test x$have_ige_mac = x
+ then
+ #
+ # Not found - check for the old integration functions in
--- /dev/null
+$NetBSD$
+
+--- src/gtk/MainView.cxx.orig 2009-02-28 13:00:55.000000000 -0800
++++ src/gtk/MainView.cxx 2009-08-14 16:10:10.000000000 -0700
+@@ -77,7 +77,7 @@ static void main_window_zoom_in_cb (GtkW
+ static void main_window_zoom_out_cb (GtkWidget *, gpointer);
+ static void main_window_zoom_width_cb (GtkToggleAction *, gpointer);
+ static void main_window_set_page_mode (GtkRadioAction *, GtkRadioAction *, gpointer);
+-static void main_window_page_scrolled_cb (GtkWidget *widget, GdkEventScroll *event, gpointer data);
++static gboolean main_window_page_scrolled_cb (GtkWidget *widget, GdkEventScroll *event, gpointer data);
+
+ #if defined (HAVE_CUPS)
+ static void main_window_print_cb (GtkWidget *, gpointer);
+@@ -1479,18 +1479,25 @@ main_window_set_page_mode (GtkRadioActio
+ pter->setPageMode (mode);
+ }
+
+-void
++gboolean
+ main_window_page_scrolled_cb (GtkWidget *widget, GdkEventScroll *event, gpointer data)
+ {
+ g_assert ( NULL != data && "The data parameter is NULL.");
+
+ MainPter *pter = (MainPter *)data;
+ // Only zoom when the CTRL-Button is down...
+- if ( !(event->state & GDK_CONTROL_MASK) ) return;
+- if ( event->direction == GDK_SCROLL_UP ) {
+- pter->zoomInActivated ();
+- } else if ( event->direction == GDK_SCROLL_DOWN ) {
+- pter->zoomOutActivated ();
++ if ( GDK_CONTROL_MASK == (event->state & GDK_CONTROL_MASK) )
++ {
++ if ( event->direction == GDK_SCROLL_UP )
++ {
++ pter->zoomInActivated ();
++ }
++ else if ( event->direction == GDK_SCROLL_DOWN )
++ {
++ pter->zoomOutActivated ();
++ }
++ return TRUE;
+ }
++ return FALSE;
+ }
+
--- /dev/null
+$NetBSD$
+
+--- src/gtk/PageView.cxx.orig 2009-02-28 13:00:35.000000000 -0800
++++ src/gtk/PageView.cxx 2009-08-14 16:10:46.000000000 -0700
+@@ -527,13 +527,6 @@ page_view_scrolled_cb (GtkWidget *widget
+ {
+ g_assert ( NULL != data && "The data parameter is NULL.");
+
+- // don't scroll when the CRTL-Button is down, because then the page should
+- // actually be zoomed and not scrolled. Zooming is handelt by the MainView
+- // class.
+- if ( event->state & GDK_CONTROL_MASK )
+- {
+- return FALSE;
+- }
+ PagePter *pter = (PagePter *)data;
+ GtkAdjustment *adjustment =
+ gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (widget));
--- /dev/null
+$NetBSD$
+
+SHA1 (boxbackup-0.10.tgz) = 60bee707c6bb59f471546ae83ad0b89625228ded
+RMD160 (boxbackup-0.10.tgz) = 26f906f37a3b095026ddf12c9284e16515ceb752
+Size (boxbackup-0.10.tgz) = 842450 bytes
--- /dev/null
+$NetBSD$
+
+http://sourceforge.net/tracker/index.php?func=detail&aid=2016300&group_id=245&atid=100245
+
+--- gen/mk-static-filter.pl.orig 2007-12-03 06:43:09.000000000 +0000
++++ gen/mk-static-filter.pl
+@@ -159,7 +159,7 @@ while ($filter = shift @filterhashes) {
+ printf STATICFILTERS "\n const KeyInfo * ".${$filter}{"NAME"}."_options_begin = ".
+ ${$filter}{"NAME"}."_options;\n";
+ # If structure is empty, set options_end to same as options_begin.
+- if (%{$filter}) {
++ if ($firstopt) {
+ printf STATICFILTERS "\n const KeyInfo * ".${$filter}{"NAME"}."_options_end = ".
+ ${$filter}{"NAME"}."_options;\n";
+ } else {
--- /dev/null
+$NetBSD: patch-aa,v 1.2 2005/05/23 21:32:01 seb Exp $
+
+--- configure.orig 2005-03-14 01:32:18.000000000 +0000
++++ configure
+@@ -1095,7 +1095,7 @@ if test "${with_libxml_prefix+set}" = se
+ withval="$with_libxml_prefix"
+ LIBXML_PREFIX=$withval
+ LIBXML_CFLAGS="-I$withval/include/libxml2 -I$withval/include/libxml"
+- LIBXML_LIBS="$withval/lib/libxml2.a -lz -lm -lpthread -ldl"
++ LIBXML_LIBS="-L$withval/lib -lxml2 -lz -lm ${PTHREAD_LDFLAGS} ${PTHREAD_LIBS}"
+
+ fi
+
+@@ -1144,7 +1144,7 @@ if test "${with_libxslt_prefix+set}" = s
+ withval="$with_libxslt_prefix"
+ LIBXSLT_PREFIX=$withval
+ LIBXSLT_CFLAGS="-I$withval/include/libxslt -I$withval/include/libexslt"
+- LIBXSLT_LIBS="$withval/lib/libxslt.a $withval/lib/libexslt.a -lz -lm -lpthread"
++ LIBXSLT_LIBS="-L$withval/lib -lxslt -lexslt -lz -lm ${PTHREAD_LDFLAGS} ${PTHREAD_LIBS}"
+
+ fi
+
--- /dev/null
+$NetBSD$
+
+--- src/core/main.c.orig 2009-10-21 21:56:47.000000000 +0200
++++ src/core/main.c
+@@ -58,7 +58,7 @@
+
+ #include <stdlib.h>
+ #include <sys/types.h>
+-#include <wait.h>
++#include <sys/wait.h>
+ #include <stdio.h>
+ #include <string.h>
+ #include <signal.h>
--- /dev/null
+$NetBSD: patch-al,v 1.1.1.1 2009/08/05 02:59:48 tnn Exp $
+
+# Reported upstream as https://bugzilla.mozilla.org/show_bug.cgi?id=471179
+
+--- mozilla/nsprpub/pr/src/misc/prsystem.c.orig 2009-06-29 18:15:07.000000000 +0200
++++ mozilla/nsprpub/pr/src/misc/prsystem.c
+@@ -284,6 +284,20 @@ PR_IMPLEMENT(PRUint64) PR_GetPhysicalMem
+ long pageCount = sysconf(_SC_PHYS_PAGES);
+ bytes = (PRUint64) pageSize * pageCount;
+
++#elif defined(NETBSD)
++
++ int mib[2];
++ int rc;
++ uint64_t memSize;
++ size_t len = sizeof(memSize);
++
++ mib[0] = CTL_HW;
++ mib[1] = HW_PHYSMEM64;
++ rc = sysctl( mib, 2, &memSize, &len, NULL, 0 );
++ if ( -1 != rc ) {
++ bytes = memSize;
++ }
++
+ #elif defined(HPUX)
+
+ struct pst_static info;
--- /dev/null
+$NetBSD: patch-ap,v 1.8 2010/09/09 11:12:27 tnn Exp $
+
+--- mozilla/media/liboggz/include/oggz/oggz_off_t_generated.h.orig 2010-08-24 21:32:05.000000000 +0000
++++ mozilla/media/liboggz/include/oggz/oggz_off_t_generated.h
+@@ -59,7 +59,7 @@
+
+ #include <sys/types.h>
+
+-#if defined(__APPLE__) || defined(SOLARIS) || defined(OS2) || defined (_AIX)
++#if defined(__APPLE__) || defined(SOLARIS) || defined(OS2) || defined (_AIX) || defined(__NetBSD__) || defined(__DragonFly__) || defined(__FreeBSD__)
+ typedef off_t oggz_off_t;
+ #else
+ typedef loff_t oggz_off_t;
--- /dev/null
+$NetBSD: patch-aq,v 1.3 2009/10/28 11:36:36 tnn Exp $
+
+--- mozilla/media/liboggplay/src/liboggplay/std_semaphore.h.orig 2009-10-16 17:14:09.000000000 +0200
++++ mozilla/media/liboggplay/src/liboggplay/std_semaphore.h
+@@ -74,9 +74,9 @@
+ * @retval non-zero on error
+ */
+
+-#if defined(linux) || defined(SOLARIS) || defined(AIX) || defined(__FreeBSD__)
++#if defined(linux) || defined(SOLARIS) || defined(AIX) || defined(__FreeBSD__) || defined(__DragonFly__) || defined(__NetBSD__)
+ #include <semaphore.h>
+-#if defined(__FreeBSD__)
++#if defined(__FreeBSD__) || defined(__NetBSD__)
+ #define SEM_CREATE(p,s) sem_init(&(p), 0, s)
+ #else
+ #define SEM_CREATE(p,s) sem_init(&(p), 1, s)
--- /dev/null
+$NetBSD: patch-ar,v 1.1.1.1 2009/08/05 02:59:48 tnn Exp $
+
+Enable the sunaudio module to build on NetBSD.
+
+--- mozilla/media/libsydneyaudio/src/sydney_audio_sunaudio.c.orig 2009-06-29 18:15:03.000000000 +0200
++++ mozilla/media/libsydneyaudio/src/sydney_audio_sunaudio.c
+@@ -38,9 +38,14 @@
+ #include <sys/types.h>
+ #include <sys/stat.h>
+ #include <fcntl.h>
++#if defined(__NetBSD__)
++#include <sys/ioctl.h>
++#include <sys/audioio.h>
++#else
+ #include <stropts.h>
+ #include <sys/audio.h>
+ #include <sys/mixer.h>
++#endif
+ #include <errno.h>
+ #include <stdio.h>
+ #include <pthread.h>
+@@ -197,7 +202,7 @@ sa_stream_open(sa_stream_t *s)
+ s->default_rate = audio_info.play.sample_rate;
+ s->default_precision = audio_info.play.precision;
+
+- AUDIO_INITINFO(&audio_info)
++ AUDIO_INITINFO(&audio_info);
+
+ audio_info.play.sample_rate = s->rate;
+ audio_info.play.channels = s->n_channels;
+@@ -210,7 +215,7 @@ sa_stream_open(sa_stream_t *s)
+ if (err== -1)
+ return SA_ERROR_NOT_SUPPORTED;
+
+- AUDIO_INITINFO(&audio_info)
++ AUDIO_INITINFO(&audio_info);
+ err=ioctl(fd,AUDIO_GETINFO,&audio_info);
+ if (err== -1)
+ {
--- /dev/null
+$NetBSD: patch-bb,v 1.1 2010/01/10 09:43:06 tron Exp $
+
+Fix build using Sun Studio C++.
+
+--- mozilla/memory/jemalloc/jemalloc.h.orig 2009-12-02 04:29:06.000000000 +0000
++++ mozilla/memory/jemalloc/jemalloc.h 2010-01-09 23:24:34.000000000 +0000
+@@ -1,3 +1,4 @@
++#ifndef __cplusplus
+ #ifndef MOZ_MEMORY_WINDOWS
+ # include <stdbool.h>
+ #else
+@@ -6,6 +7,7 @@
+ # define bool BOOL
+ # endif
+ #endif
++#endif
+
+ extern const char *_malloc_options;
+
--- /dev/null
+$NetBSD: patch-directory_c-sdk_configure.in,v 1.1 2010/07/12 11:57:00 tnn Exp $
+
+Add DragonFly support.
+https://bugzilla.mozilla.org/show_bug.cgi?id=577298
+
+--- directory/c-sdk/configure.in.orig 2009-10-06 21:43:08.000000000 +0000
++++ directory/c-sdk/configure.in
+@@ -1233,6 +1233,16 @@ tools are selected during the Xcode/Deve
+ _DEBUG_FLAGS=
+ ;;
+
++*-dragonfly*)
++ if test -z "$USE_NSPR_THREADS"; then
++ USE_PTHREADS=1
++ fi
++ AC_DEFINE(XP_UNIX)
++ AC_DEFINE(DRAGONFLY)
++ DSO_CFLAGS=-fPIC
++ DSO_LDOPTS='-shared'
++ ;;
++
+ *-freebsd*)
+ if test -z "$USE_NSPR_THREADS"; then
+ USE_PTHREADS=1
--- /dev/null
+$NetBSD: patch-directory_c-sdk_ldap_libraries_libldap_Makefile.in,v 1.1 2010/07/12 11:57:00 tnn Exp $
+
+Add DragonFly support.
+https://bugzilla.mozilla.org/show_bug.cgi?id=577298
+
+--- directory/c-sdk/ldap/libraries/libldap/Makefile.in.orig 2008-12-24 09:39:55.000000000 +0000
++++ directory/c-sdk/ldap/libraries/libldap/Makefile.in
+@@ -262,6 +262,10 @@ ifeq ($(OS_ARCH), OpenBSD)
+ EXTRA_LIBS = -L$(dist_libdir) -l$(LBER_LIBNAME) -pthread
+ endif
+
++ifeq ($(OS_ARCH), DragonFly)
++EXTRA_LIBS = -L$(dist_libdir) -l$(LBER_LIBNAME)
++endif
++
+ ifeq ($(HAVE_SASL), 1)
+ EXTRA_LIBS += $(SASL_LINK)
+ endif
--- /dev/null
+$NetBSD: patch-na,v 1.1 2009/09/09 17:01:07 tnn Exp $
+
+# reported upstream as:
+# https://bugzilla.mozilla.org/show_bug.cgi?id=512802
+
+--- mozilla/js/src/jsscript.cpp.orig 2009-08-24 01:32:14.000000000 +0200
++++ mozilla/js/src/jsscript.cpp 2009-08-24 01:36:20.000000000 +0200
+@@ -1370,19 +1370,49 @@ js_NewScript(JSContext *cx, uint32 lengt
+ size_t size, vectorSize;
+ JSScript *script;
+ uint8 *cursor;
++#ifdef _LP64
++#define LP64_ALIGN(V) if ((V) & 7) (V) = (((V)|7) + 1)
++#define LP64_ALIGNP(P) if ((uintptr_t)(P) & 7) (P) = (uint8*)(((uintptr_t)(P)|7) + 1)
++#else
++#define LP64_ALIGN(V)
++#define LP64_ALIGNP(V)
++#endif
+
+- size = sizeof(JSScript) +
+- sizeof(JSAtom *) * natoms +
+- length * sizeof(jsbytecode) +
+- nsrcnotes * sizeof(jssrcnote);
+- if (nobjects != 0)
+- size += sizeof(JSObjectArray) + nobjects * sizeof(JSObject *);
+- if (nupvars != 0)
+- size += sizeof(JSUpvarArray) + nupvars * sizeof(uint32);
+- if (nregexps != 0)
+- size += sizeof(JSObjectArray) + nregexps * sizeof(JSObject *);
+- if (ntrynotes != 0)
+- size += sizeof(JSTryNoteArray) + ntrynotes * sizeof(JSTryNote);
++ size = sizeof(JSScript);
++ if (nobjects != 0) {
++ LP64_ALIGN(size);
++ size += sizeof(JSObjectArray);
++ }
++ if (nupvars != 0) {
++ LP64_ALIGN(size);
++ size += sizeof(JSUpvarArray);
++ }
++ if (nregexps != 0) {
++ LP64_ALIGN(size);
++ size += sizeof(JSObjectArray);
++ }
++ if (ntrynotes != 0) {
++ LP64_ALIGN(size);
++ size += sizeof(JSTryNoteArray);
++ }
++ if (natoms != 0) {
++ LP64_ALIGN(size);
++ size += sizeof(JSAtom *) * natoms;
++ }
++ if (nobjects != 0) {
++ LP64_ALIGN(size);
++ size += nobjects * sizeof(JSObject *);
++ }
++ if (nupvars != 0) {
++ size += nupvars * sizeof(uint32);
++ }
++ if (nregexps != 0) {
++ LP64_ALIGN(size);
++ size += nregexps * sizeof(JSObject *);
++ }
++ size += length * sizeof(jsbytecode) +
++ nsrcnotes * sizeof(jssrcnote) +
++ ntrynotes * sizeof(JSTryNote);
+
+ script = (JSScript *) JS_malloc(cx, size);
+ if (!script)
+@@ -1393,23 +1423,28 @@ js_NewScript(JSContext *cx, uint32 lengt
+
+ cursor = (uint8 *)script + sizeof(JSScript);
+ if (nobjects != 0) {
++ LP64_ALIGNP(cursor);
+ script->objectsOffset = (uint8)(cursor - (uint8 *)script);
+ cursor += sizeof(JSObjectArray);
+ }
+ if (nupvars != 0) {
++ LP64_ALIGNP(cursor);
+ script->upvarsOffset = (uint8)(cursor - (uint8 *)script);
+ cursor += sizeof(JSUpvarArray);
+ }
+ if (nregexps != 0) {
++ LP64_ALIGNP(cursor);
+ script->regexpsOffset = (uint8)(cursor - (uint8 *)script);
+ cursor += sizeof(JSObjectArray);
+ }
+ if (ntrynotes != 0) {
++ LP64_ALIGNP(cursor);
+ script->trynotesOffset = (uint8)(cursor - (uint8 *)script);
+ cursor += sizeof(JSTryNoteArray);
+ }
+
+ if (natoms != 0) {
++ LP64_ALIGNP(cursor);
+ script->atomMap.length = natoms;
+ script->atomMap.vector = (JSAtom **)cursor;
+ vectorSize = natoms * sizeof(script->atomMap.vector[0]);
+@@ -1423,6 +1458,7 @@ js_NewScript(JSContext *cx, uint32 lengt
+ }
+
+ if (nobjects != 0) {
++ LP64_ALIGNP(cursor);
+ JS_SCRIPT_OBJECTS(script)->length = nobjects;
+ JS_SCRIPT_OBJECTS(script)->vector = (JSObject **)cursor;
+ vectorSize = nobjects * sizeof(JS_SCRIPT_OBJECTS(script)->vector[0]);
+@@ -1431,6 +1467,7 @@ js_NewScript(JSContext *cx, uint32 lengt
+ }
+
+ if (nupvars != 0) {
++ LP64_ALIGNP(cursor);
+ JS_SCRIPT_UPVARS(script)->length = nupvars;
+ JS_SCRIPT_UPVARS(script)->vector = (uint32 *)cursor;
+ vectorSize = nupvars * sizeof(JS_SCRIPT_UPVARS(script)->vector[0]);
+@@ -1439,6 +1476,7 @@ js_NewScript(JSContext *cx, uint32 lengt
+ }
+
+ if (nregexps != 0) {
++ LP64_ALIGNP(cursor);
+ JS_SCRIPT_REGEXPS(script)->length = nregexps;
+ JS_SCRIPT_REGEXPS(script)->vector = (JSObject **)cursor;
+ vectorSize = nregexps * sizeof(JS_SCRIPT_REGEXPS(script)->vector[0]);
--- /dev/null
+$NetBSD: patch-nd,v 1.1 2009/09/09 17:01:07 tnn Exp $
+
+# reported upstream as
+# https://bugzilla.mozilla.org/show_bug.cgi?id=514002
+
+--- mozilla/gfx/qcms/iccread.c.orig 2009-07-30 17:30:16.000000000 +0200
++++ mozilla/gfx/qcms/iccread.c 2009-09-01 21:29:29.000000000 +0200
+@@ -23,6 +23,7 @@
+ #include <math.h>
+ #include <assert.h>
+ #include <stdlib.h>
++#include <string.h>
+ #include "qcmsint.h"
+
+ //XXX: use a better typename
+@@ -84,7 +85,9 @@ static uint32_t read_u32(struct mem_sour
+ invalid_source(mem, "Invalid offset");
+ return 0;
+ } else {
+- return be32_to_cpu(*(__be32*)(mem->buf + offset));
++ uint32_t v;
++ memcpy(&v, mem->buf + offset, 4);
++ return be32_to_cpu(v);
+ }
+ }
+
+@@ -94,7 +97,9 @@ static uint16_t read_u16(struct mem_sour
+ invalid_source(mem, "Invalid offset");
+ return 0;
+ } else {
+- return be16_to_cpu(*(__be16*)(mem->buf + offset));
++ uint16_t v;
++ memcpy(&v, mem->buf + offset, 2);
++ return be16_to_cpu(v);
+ }
+ }
+
--- /dev/null
+$NetBSD: patch-pe,v 1.1.1.1 2009/08/05 02:59:48 tnn Exp $
+
+--- mozilla/xulrunner/installer/libxul-unstable.pc.in.orig 2009-06-29 18:15:36.000000000 +0200
++++ mozilla/xulrunner/installer/libxul-unstable.pc.in
+@@ -8,5 +8,5 @@ Name: libxul
+ Description: The Mozilla Runtime and Embedding Engine (unstable API)
+ Version: %MOZILLA_VERSION%
+ Requires: %NSPR_NAME% >= %NSPR_VERSION%
+-Libs: -L${sdkdir}/lib -lxpcomglue_s -lxul -lxpcom
++Libs: -Wl,-R${prefix}/lib/xulrunner -L${prefix}/lib/xulrunner -lxpcomglue_s -lxul -lxpcom
+ Cflags: -I${includedir}/${includetype} %WCHAR_CFLAGS%
--- /dev/null
+$NetBSD: patch-pf,v 1.1.1.1 2009/08/05 02:59:48 tnn Exp $
+
+--- mozilla/xulrunner/installer/libxul-embedding-unstable.pc.in.orig 2009-06-29 18:15:36.000000000 +0200
++++ mozilla/xulrunner/installer/libxul-embedding-unstable.pc.in
+@@ -7,5 +7,5 @@ includetype=unstable
+ Name: libxul-embedding-unstable
+ Description: Static library for version-independent embedding of the Mozilla runtime (unstable API)
+ Version: %MOZILLA_VERSION%
+-Libs: -L${sdkdir}/lib -lxpcomglue
++Libs: -Wl,-R${prefix}/lib/xulrunner -L${prefix}/lib/xulrunner -lxpcomglue
+ Cflags: -DXPCOM_GLUE -I${includedir}/${includetype} %WCHAR_CFLAGS%
--- /dev/null
+$NetBSD: patch-ra,v 1.1 2009/10/11 10:49:56 tnn Exp $
+
+--- mozilla/browser/branding/unofficial/locales/browserconfig.properties.orig 2009-08-24 17:52:36.000000000 +0200
++++ mozilla/browser/branding/unofficial/locales/browserconfig.properties
+@@ -1,3 +1,3 @@
+ # Do NOT localize or otherwise change these values
+-browser.startup.homepage=http://www.mozilla.org/projects/shiretoko/
++browser.startup.homepage=http://www.google.com/firefox
+
--- /dev/null
+$NetBSD: patch-xh,v 1.1.1.1 2009/08/05 02:59:48 tnn Exp $
+
+NetBSD/amd64 xptcall support code. Originally from pkgsrc/www/mozilla.
+
+--- mozilla/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_unixish_amd64.cpp.orig 2009-06-30 22:20:24.000000000 +0200
++++ mozilla/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_unixish_amd64.cpp
+@@ -0,0 +1,174 @@
++/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
++// Platform specific code to invoke XPCOM methods on native objects
++
++#include "xptcprivate.h"
++
++// 6 integral parameters are passed in registers
++const PRUint32 GPR_COUNT = 6;
++
++// 8 floating point parameters are passed in SSE registers
++const PRUint32 FPR_COUNT = 8;
++
++// Remember that these 'words' are 64-bit long
++static inline void
++invoke_count_words(PRUint32 paramCount, nsXPTCVariant * s,
++ PRUint32 & nr_gpr, PRUint32 & nr_fpr, PRUint32 & nr_stack)
++{
++ nr_gpr = 1; // skip one GP register for 'that'
++ nr_fpr = 0;
++ nr_stack = 0;
++
++ /* Compute number of eightbytes of class MEMORY. */
++ for (uint32 i = 0; i < paramCount; i++, s++) {
++ if (!s->IsPtrData()
++ && (s->type == nsXPTType::T_FLOAT || s->type == nsXPTType::T_DOUBLE)) {
++ if (nr_fpr < FPR_COUNT)
++ nr_fpr++;
++ else
++ nr_stack++;
++ }
++ else {
++ if (nr_gpr < GPR_COUNT)
++ nr_gpr++;
++ else
++ nr_stack++;
++ }
++ }
++}
++
++static void
++invoke_copy_to_stack(PRUint64 * d, PRUint32 paramCount, nsXPTCVariant * s,
++ PRUint64 * gpregs, double * fpregs)
++{
++ PRUint32 nr_gpr = 1; // skip one GP register for 'that'
++ PRUint32 nr_fpr = 0;
++ PRUint64 value;
++
++ for (uint32 i = 0; i < paramCount; i++, s++) {
++ if (s->IsPtrData())
++ value = (PRUint64) s->ptr;
++ else {
++ switch (s->type) {
++ case nsXPTType::T_FLOAT: break;
++ case nsXPTType::T_DOUBLE: break;
++ case nsXPTType::T_I8: value = s->val.i8; break;
++ case nsXPTType::T_I16: value = s->val.i16; break;
++ case nsXPTType::T_I32: value = s->val.i32; break;
++ case nsXPTType::T_I64: value = s->val.i64; break;
++ case nsXPTType::T_U8: value = s->val.u8; break;
++ case nsXPTType::T_U16: value = s->val.u16; break;
++ case nsXPTType::T_U32: value = s->val.u32; break;
++ case nsXPTType::T_U64: value = s->val.u64; break;
++ case nsXPTType::T_BOOL: value = s->val.b; break;
++ case nsXPTType::T_CHAR: value = s->val.c; break;
++ case nsXPTType::T_WCHAR: value = s->val.wc; break;
++ default: value = (PRUint64) s->val.p; break;
++ }
++ }
++
++ if (!s->IsPtrData() && s->type == nsXPTType::T_DOUBLE) {
++ if (nr_fpr < FPR_COUNT)
++ fpregs[nr_fpr++] = s->val.d;
++ else {
++ *((double *)d) = s->val.d;
++ d++;
++ }
++ }
++ else if (!s->IsPtrData() && s->type == nsXPTType::T_FLOAT) {
++ if (nr_fpr < FPR_COUNT)
++ // The value in %xmm register is already prepared to
++ // be retrieved as a float. Therefore, we pass the
++ // value verbatim, as a double without conversion.
++ fpregs[nr_fpr++] = s->val.d;
++ else {
++ *((float *)d) = s->val.f;
++ d++;
++ }
++ }
++ else {
++ if (nr_gpr < GPR_COUNT)
++ gpregs[nr_gpr++] = value;
++ else
++ *d++ = value;
++ }
++ }
++}
++
++extern "C"
++XPTC_PUBLIC_API(nsresult)
++XPTC_InvokeByIndex(nsISupports * that, PRUint32 methodIndex,
++ PRUint32 paramCount, nsXPTCVariant * params)
++{
++ PRUint32 nr_gpr, nr_fpr, nr_stack;
++ invoke_count_words(paramCount, params, nr_gpr, nr_fpr, nr_stack);
++
++ // Stack, if used, must be 16-bytes aligned
++ if (nr_stack)
++ nr_stack = (nr_stack + 1) & ~1;
++
++ // Load parameters to stack, if necessary
++ PRUint64 *stack = (PRUint64 *) __builtin_alloca(nr_stack * 8);
++ PRUint64 gpregs[GPR_COUNT];
++ double fpregs[FPR_COUNT];
++ invoke_copy_to_stack(stack, paramCount, params, gpregs, fpregs);
++
++ // Load FPR registers from fpregs[]
++ register double d0 asm("xmm0");
++ register double d1 asm("xmm1");
++ register double d2 asm("xmm2");
++ register double d3 asm("xmm3");
++ register double d4 asm("xmm4");
++ register double d5 asm("xmm5");
++ register double d6 asm("xmm6");
++ register double d7 asm("xmm7");
++
++ switch (nr_fpr) {
++#define ARG_FPR(N) \
++ case N+1: d##N = fpregs[N];
++ ARG_FPR(7);
++ ARG_FPR(6);
++ ARG_FPR(5);
++ ARG_FPR(4);
++ ARG_FPR(3);
++ ARG_FPR(2);
++ ARG_FPR(1);
++ ARG_FPR(0);
++ case 0:;
++#undef ARG_FPR
++ }
++
++ // Load GPR registers from gpregs[]
++ register PRUint64 a0 asm("rdi");
++ register PRUint64 a1 asm("rsi");
++ register PRUint64 a2 asm("rdx");
++ register PRUint64 a3 asm("rcx");
++ register PRUint64 a4 asm("r8");
++ register PRUint64 a5 asm("r9");
++
++ switch (nr_gpr) {
++#define ARG_GPR(N) \
++ case N+1: a##N = gpregs[N];
++ ARG_GPR(5);
++ ARG_GPR(4);
++ ARG_GPR(3);
++ ARG_GPR(2);
++ ARG_GPR(1);
++ case 1: a0 = (PRUint64) that;
++ case 0:;
++#undef ARG_GPR
++ }
++
++ // Ensure that assignments to SSE registers won't be optimized away
++ asm("" ::
++ "x" (d0), "x" (d1), "x" (d2), "x" (d3),
++ "x" (d4), "x" (d5), "x" (d6), "x" (d7));
++
++ // Get pointer to method
++ PRUint64 methodAddress = *((PRUint64 *)that);
++ methodAddress += 8 * methodIndex;
++ methodAddress = *((PRUint64 *)methodAddress);
++
++ typedef PRUint32 (*Method)(PRUint64, PRUint64, PRUint64, PRUint64, PRUint64, PRUint64);
++ PRUint32 result = ((Method)methodAddress)(a0, a1, a2, a3, a4, a5);
++ return result;
++}
--- /dev/null
+$NetBSD: patch-xi,v 1.1.1.1 2009/08/05 02:59:49 tnn Exp $
+
+NetBSD/amd64 xptcall support code. Originally from pkgsrc/www/mozilla.
+
+--- mozilla/xpcom/reflect/xptcall/src/md/unix/xptcstubs_unixish_amd64.cpp.orig 2009-06-30 22:20:24.000000000 +0200
++++ mozilla/xpcom/reflect/xptcall/src/md/unix/xptcstubs_unixish_amd64.cpp
+@@ -0,0 +1,206 @@
++/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
++
++// Implement shared vtbl methods.
++
++#include "xptcprivate.h"
++
++// The Linux/x86-64 ABI passes the first 6 integral parameters and the
++// first 8 floating point parameters in registers (rdi, rsi, rdx, rcx,
++// r8, r9 and xmm0-xmm7), no stack space is allocated for these by the
++// caller. The rest of the parameters are passed in the callers stack
++// area.
++
++const PRUint32 PARAM_BUFFER_COUNT = 16;
++const PRUint32 GPR_COUNT = 6;
++const PRUint32 FPR_COUNT = 8;
++
++// PrepareAndDispatch() is called by SharedStub() and calls the actual method.
++//
++// - 'args[]' contains the arguments passed on stack
++// - 'gpregs[]' contains the arguments passed in integer registers
++// - 'fpregs[]' contains the arguments passed in floating point registers
++//
++// The parameters are mapped into an array of type 'nsXPTCMiniVariant'
++// and then the method gets called.
++
++extern "C" nsresult
++PrepareAndDispatch(nsXPTCStubBase * self, PRUint32 methodIndex,
++ PRUint64 * args, PRUint64 * gpregs, double *fpregs)
++{
++ nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
++ nsXPTCMiniVariant* dispatchParams = NULL;
++ nsIInterfaceInfo* iface_info = NULL;
++ const nsXPTMethodInfo* info;
++ PRUint32 paramCount;
++ PRUint32 i;
++ nsresult result = NS_ERROR_FAILURE;
++
++ NS_ASSERTION(self,"no self");
++
++ self->GetInterfaceInfo(&iface_info);
++ NS_ASSERTION(iface_info,"no interface info");
++ if (! iface_info)
++ return NS_ERROR_UNEXPECTED;
++
++ iface_info->GetMethodInfo(PRUint16(methodIndex), &info);
++ NS_ASSERTION(info,"no method info");
++ if (! info)
++ return NS_ERROR_UNEXPECTED;
++
++ paramCount = info->GetParamCount();
++
++ // setup variant array pointer
++ if(paramCount > PARAM_BUFFER_COUNT)
++ dispatchParams = new nsXPTCMiniVariant[paramCount];
++ else
++ dispatchParams = paramBuffer;
++
++ NS_ASSERTION(dispatchParams,"no place for params");
++ if (! dispatchParams)
++ return NS_ERROR_OUT_OF_MEMORY;
++
++ PRUint64* ap = args;
++ PRUint32 nr_gpr = 1; // skip one GPR register for 'that'
++ PRUint32 nr_fpr = 0;
++ PRUint64 value;
++
++ for(i = 0; i < paramCount; i++) {
++ const nsXPTParamInfo& param = info->GetParam(i);
++ const nsXPTType& type = param.GetType();
++ nsXPTCMiniVariant* dp = &dispatchParams[i];
++
++ if (!param.IsOut() && type == nsXPTType::T_DOUBLE) {
++ if (nr_fpr < FPR_COUNT)
++ dp->val.d = fpregs[nr_fpr++];
++ else
++ dp->val.d = *(double*) ap++;
++ continue;
++ }
++ else if (!param.IsOut() && type == nsXPTType::T_FLOAT) {
++ if (nr_fpr < FPR_COUNT)
++ // The value in %xmm register is already prepared to
++ // be retrieved as a float. Therefore, we pass the
++ // value verbatim, as a double without conversion.
++ dp->val.d = *(double*) ap++;
++ else
++ dp->val.f = *(float*) ap++;
++ continue;
++ }
++ else {
++ if (nr_gpr < GPR_COUNT)
++ value = gpregs[nr_gpr++];
++ else
++ value = *ap++;
++ }
++
++ if (param.IsOut() || !type.IsArithmetic()) {
++ dp->val.p = (void*) value;
++ continue;
++ }
++
++ switch (type) {
++ case nsXPTType::T_I8: dp->val.i8 = (PRInt8) value; break;
++ case nsXPTType::T_I16: dp->val.i16 = (PRInt16) value; break;
++ case nsXPTType::T_I32: dp->val.i32 = (PRInt32) value; break;
++ case nsXPTType::T_I64: dp->val.i64 = (PRInt64) value; break;
++ case nsXPTType::T_U8: dp->val.u8 = (PRUint8) value; break;
++ case nsXPTType::T_U16: dp->val.u16 = (PRUint16) value; break;
++ case nsXPTType::T_U32: dp->val.u32 = (PRUint32) value; break;
++ case nsXPTType::T_U64: dp->val.u64 = (PRUint64) value; break;
++ case nsXPTType::T_BOOL: dp->val.b = (PRBool) value; break;
++ case nsXPTType::T_CHAR: dp->val.c = (char) value; break;
++ case nsXPTType::T_WCHAR: dp->val.wc = (wchar_t) value; break;
++
++ default:
++ NS_ASSERTION(0, "bad type");
++ break;
++ }
++ }
++
++ result = self->CallMethod((PRUint16) methodIndex, info, dispatchParams);
++
++ NS_RELEASE(iface_info);
++
++ if (dispatchParams != paramBuffer)
++ delete [] dispatchParams;
++
++ return result;
++}
++
++#if defined(__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100 /* G++ V3 ABI */
++// Linux/x86-64 uses gcc >= 3.1
++#define STUB_ENTRY(n) \
++asm(".section \".text\"\n\t" \
++ ".align 2\n\t" \
++ ".if " #n " < 10\n\t" \
++ ".globl _ZN14nsXPTCStubBase5Stub" #n "Ev\n\t" \
++ ".type _ZN14nsXPTCStubBase5Stub" #n "Ev,@function\n" \
++ "_ZN14nsXPTCStubBase5Stub" #n "Ev:\n\t" \
++ ".elseif " #n " < 100\n\t" \
++ ".globl _ZN14nsXPTCStubBase6Stub" #n "Ev\n\t" \
++ ".type _ZN14nsXPTCStubBase6Stub" #n "Ev,@function\n" \
++ "_ZN14nsXPTCStubBase6Stub" #n "Ev:\n\t" \
++ ".elseif " #n " < 1000\n\t" \
++ ".globl _ZN14nsXPTCStubBase7Stub" #n "Ev\n\t" \
++ ".type _ZN14nsXPTCStubBase7Stub" #n "Ev,@function\n" \
++ "_ZN14nsXPTCStubBase7Stub" #n "Ev:\n\t" \
++ ".else\n\t" \
++ ".err \"stub number " #n " >= 1000 not yet supported\"\n\t" \
++ ".endif\n\t" \
++ "movl $" #n ", %eax\n\t" \
++ "jmp SharedStub\n\t" \
++ ".if " #n " < 10\n\t" \
++ ".size _ZN14nsXPTCStubBase5Stub" #n "Ev,.-_ZN14nsXPTCStubBase5Stub" #n "Ev\n\t" \
++ ".elseif " #n " < 100\n\t" \
++ ".size _ZN14nsXPTCStubBase6Stub" #n "Ev,.-_ZN14nsXPTCStubBase6Stub" #n "Ev\n\t" \
++ ".else\n\t" \
++ ".size _ZN14nsXPTCStubBase7Stub" #n "Ev,.-_ZN14nsXPTCStubBase7Stub" #n "Ev\n\t" \
++ ".endif");
++
++// static nsresult SharedStub(PRUint32 methodIndex)
++asm(".section \".text\"\n\t"
++ ".align 2\n\t"
++ ".type SharedStub,@function\n\t"
++ "SharedStub:\n\t"
++ // make room for gpregs (48), fpregs (64)
++ "pushq %rbp\n\t"
++ "movq %rsp,%rbp\n\t"
++ "subq $112,%rsp\n\t"
++ // save GP registers
++ "movq %rdi,-112(%rbp)\n\t"
++ "movq %rsi,-104(%rbp)\n\t"
++ "movq %rdx, -96(%rbp)\n\t"
++ "movq %rcx, -88(%rbp)\n\t"
++ "movq %r8 , -80(%rbp)\n\t"
++ "movq %r9 , -72(%rbp)\n\t"
++ "leaq -112(%rbp),%rcx\n\t"
++ // save FP registers
++ "movsd %xmm0,-64(%rbp)\n\t"
++ "movsd %xmm1,-56(%rbp)\n\t"
++ "movsd %xmm2,-48(%rbp)\n\t"
++ "movsd %xmm3,-40(%rbp)\n\t"
++ "movsd %xmm4,-32(%rbp)\n\t"
++ "movsd %xmm5,-24(%rbp)\n\t"
++ "movsd %xmm6,-16(%rbp)\n\t"
++ "movsd %xmm7, -8(%rbp)\n\t"
++ "leaq -64(%rbp),%r8\n\t"
++ // rdi has the 'self' pointer already
++ "movl %eax,%esi\n\t"
++ "leaq 16(%rbp),%rdx\n\t"
++ "call PrepareAndDispatch\n\t"
++ "leave\n\t"
++ "ret\n\t"
++ ".size SharedStub,.-SharedStub");
++
++#define SENTINEL_ENTRY(n) \
++nsresult nsXPTCStubBase::Sentinel##n() \
++{ \
++ NS_ASSERTION(0,"nsXPTCStubBase::Sentinel called"); \
++ return NS_ERROR_NOT_IMPLEMENTED; \
++}
++
++#include "xptcstubsdef.inc"
++
++#else
++#error "can't find a compiler to use"
++#endif /* __GNUC__ */