r4598 - in glibc-package/branches/eglibc-2.13/debian: . patches/kfreebsd
Author: aurel32
Date: 2011-03-28 21:10:27 +0000 (Mon, 28 Mar 2011)
New Revision: 4598
Modified:
glibc-package/branches/eglibc-2.13/debian/changelog
glibc-package/branches/eglibc-2.13/debian/patches/kfreebsd/local-sysdeps.diff
Log:
kfreebsd/local-sysdeps.diff: update to revision 3286 (from glibc-bsd)
Modified: glibc-package/branches/eglibc-2.13/debian/changelog
===================================================================
--- glibc-package/branches/eglibc-2.13/debian/changelog 2011-03-27 17:09:32 UTC (rev 4597)
+++ glibc-package/branches/eglibc-2.13/debian/changelog 2011-03-28 21:10:27 UTC (rev 4598)
@@ -1,4 +1,4 @@
-eglibc (2.13-0exp3) experimental; urgency=low
+eglibc (2.13-0exp5) experimental; urgency=low
[ Aurelien Jarno ]
* New upstream release:
@@ -102,7 +102,7 @@
(CVE-2010-0015), but can be changed to FALSE to accomomdate some
NIS installations. Closes: #566297, #566844.
* kfreebsd/local-sysdeps.diff, kfreebsd/local-linuxthreads29.diff:
- update to revision 3262 (from glibc-bsd) Closes: #602776.
+ update to revision 3286 (from glibc-bsd) Closes: #602776.
* debian/rules: split build-indep and build-arch targets. Closes:
#611926.
* sysdeps/sparc.mk, sysdeps/sparc64.mk: build with --enable-multi-arch.
@@ -163,7 +163,7 @@
* debian/rules.d/debhelper.mk: set $rtlddir in the debhelper substitution
rules, so we don't substitute an empty string.
- -- Aurelien Jarno <aurel32@debian.org> Mon, 28 Feb 2011 23:43:03 +0100
+ -- Aurelien Jarno <aurel32@debian.org> Mon, 28 Mar 2011 19:04:57 +0200
eglibc (2.11.2-13) unstable; urgency=low
Modified: glibc-package/branches/eglibc-2.13/debian/patches/kfreebsd/local-sysdeps.diff
===================================================================
--- glibc-package/branches/eglibc-2.13/debian/patches/kfreebsd/local-sysdeps.diff 2011-03-27 17:09:32 UTC (rev 4597)
+++ glibc-package/branches/eglibc-2.13/debian/patches/kfreebsd/local-sysdeps.diff 2011-03-28 21:10:27 UTC (rev 4598)
@@ -7423,7 +7423,7 @@
+weak_alias (__clone, clone)
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/bsd4.4/kfreebsd/configure
-@@ -0,0 +1,349 @@
+@@ -0,0 +1,353 @@
+# This file is generated from configure.in by Autoconf. DO NOT EDIT!
+ # Local configure fragment for sysdeps/unix/bsd/bsd4.4/kfreebsd.
+
@@ -7432,6 +7432,10 @@
+ echo "Adding extra sysnames for kfreebsd/x86_64/elf"
+ sysnames="ports/sysdeps/unix/bsd/bsd4.4/kfreebsd/x86_64/elf $sysnames"
+ ;;
++ mips*)
++ echo "Adding extra sysnames for kfreebsd/mips/elf"
++ sysnames="ports/sysdeps/unix/bsd/bsd4.4/kfreebsd/mips/elf $sysnames"
++ ;;
+esac
+
+# The kFreeBSD headers can be found in
@@ -7775,7 +7779,7 @@
+_ACEOF
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/bsd4.4/kfreebsd/configure.in
-@@ -0,0 +1,273 @@
+@@ -0,0 +1,277 @@
+GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory.
+# Local configure fragment for sysdeps/unix/bsd/bsd4.4/kfreebsd.
+
@@ -7784,6 +7788,10 @@
+ echo "Adding extra sysnames for kfreebsd/x86_64/elf"
+ sysnames="ports/sysdeps/unix/bsd/bsd4.4/kfreebsd/x86_64/elf $sysnames"
+ ;;
++ mips*)
++ echo "Adding extra sysnames for kfreebsd/mips/elf"
++ sysnames="ports/sysdeps/unix/bsd/bsd4.4/kfreebsd/mips/elf $sysnames"
++ ;;
+esac
+
+# The kFreeBSD headers can be found in
@@ -12445,6 +12453,78 @@
+
+#endif /* _FREEBSD_TLS_H */
--- /dev/null
++++ b/ports/sysdeps/unix/bsd/bsd4.4/kfreebsd/i386/linuxthreads/vfork.S
+@@ -0,0 +1,69 @@
++/* Copyright (C) 1999, 2002 Free Software Foundation, Inc.
++ This file is part of the GNU C Library.
++
++ The GNU C Library is free software; you can redistribute it and/or
++ modify it under the terms of the GNU Lesser General Public
++ License as published by the Free Software Foundation; either
++ version 2.1 of the License, or (at your option) any later version.
++
++ The GNU C Library is distributed in the hope that it will be useful,
++ but WITHOUT ANY WARRANTY; without even the implied warranty of
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++ Lesser General Public License for more details.
++
++ You should have received a copy of the GNU Lesser General Public
++ License along with the GNU C Library; if not, write to the Free
++ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
++ 02111-1307 USA. */
++
++#include <sysdep.h>
++
++/* Clone the calling process, but without copying the whole address space.
++ The calling process is suspended until the new process exits or is
++ replaced by a call to `execve'. Return -1 for errors, 0 to the new process,
++ and the process ID of the new process to the old process. */
++
++ENTRY (__vfork)
++
++# ifdef SHARED
++ call __i686.get_pc_thunk.cx
++ addl $_GLOBAL_OFFSET_TABLE_, %ecx
++ cmpl $0, __libc_pthread_functions@GOTOFF(%ecx)
++# else
++ .weak pthread_create
++ movl $pthread_create, %eax
++ testl %eax, %eax
++# endif
++ jne HIDDEN_JUMPTARGET (__fork)
++
++ /* Pop the return PC value into ECX. */
++ popl %ecx
++ cfi_adjust_cfa_offset(-4)
++
++ /* Perform the system call. */
++ DO_CALL (vfork, 0)
++ jb L(error) /* Branch forward if it failed. */
++
++ /* In the parent process, %edx == 0, %eax == child pid. */
++ /* In the child process, %edx == 1, %eax == parent pid. */
++
++ /* Change %eax to be 0 in the child process. */
++ decl %edx
++ andl %edx, %eax
++
++ /* Jump to the return PC. */
++ jmp *%ecx
++
++L(error):
++ /* Push back the return PC. */
++ pushl %ecx
++ cfi_adjust_cfa_offset(4)
++
++ /* Branch to the error handler, hidden in PSEUDO_END. */
++ jmp SYSCALL_ERROR_LABEL
++L(pseudo_end):
++ ret
++PSEUDO_END (__vfork)
++libc_hidden_def (__vfork)
++
++weak_alias (__vfork, vfork)
+--- /dev/null
+++ b/ports/sysdeps/unix/bsd/bsd4.4/kfreebsd/i386/makecontext.S
@@ -0,0 +1,113 @@
+/* Create new context.
@@ -15943,6 +16023,1092 @@
+}
+hidden_def (__lxstat64)
--- /dev/null
++++ b/ports/sysdeps/unix/bsd/bsd4.4/kfreebsd/mips/____longjmp_chk.c
+@@ -0,0 +1,7 @@
++/* Jump to the position specified by ENV, causing the
++ setjmp call there to return VAL, or 1 if VAL is 0.
++ void __longjmp (__jmp_buf env, int val). */
++
++#warning longjmp_chk unimplemented
++#define __longjmp ____longjmp_chk
++#include <__longjmp.c>
+--- /dev/null
++++ b/ports/sysdeps/unix/bsd/bsd4.4/kfreebsd/mips/dl-machine.h
+@@ -0,0 +1,97 @@
++/* Machine-dependent ELF dynamic relocation inline functions. MIPS version.
++ Copyright (C) 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2010
++ Free Software Foundation, Inc.
++ This file is part of the GNU C Library.
++ Contributed by Kazumoto Kojima <kkojima@info.kanagawa-u.ac.jp>.
++ Port to kFreeBSD (kernel of FreeBSD) by Robert Millan.
++
++ The GNU C Library is free software; you can redistribute it and/or
++ modify it under the terms of the GNU Lesser General Public
++ License as published by the Free Software Foundation; either
++ version 2.1 of the License, or (at your option) any later version.
++
++ The GNU C Library is distributed in the hope that it will be useful,
++ but WITHOUT ANY WARRANTY; without even the implied warranty of
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++ Lesser General Public License for more details.
++
++ You should have received a copy of the GNU Lesser General Public
++ License along with the GNU C Library; if not, write to the Free
++ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
++ 02111-1307 USA. */
++
++#include_next <dl-machine.h>
++
++/* kFreeBSD puts arguments in a different location (see start.S). */
++#undef RTLD_START
++#define RTLD_START asm (\
++ ".text\n\
++ " _RTLD_PROLOGUE(ENTRY_POINT) "\
++ " STRINGXV(SETUP_GPX($25)) "\n\
++ " STRINGXV(SETUP_GPX64($18,$25)) "\n\
++ # i386 ABI book says that the first entry of GOT holds\n\
++ # the address of the dynamic structure. Though MIPS ABI\n\
++ # doesn't say nothing about this, I emulate this here.\n\
++ " STRINGXP(PTR_LA) " $9, _DYNAMIC\n\
++ # Subtract OFFSET_GP_GOT\n\
++ " STRINGXP(PTR_S) " $9, -0x7ff0($28)\n\
++ move $9, $29\n\
++ " STRINGXP(PTR_SUBIU) " $29, 16\n\
++ \n\
++ " STRINGXP(PTR_LA) " $8, .Lcoff\n\
++ bltzal $8, .Lcoff\n\
++.Lcoff: " STRINGXP(PTR_SUBU) " $8, $31, $8\n\
++ \n\
++ " STRINGXP(PTR_LA) " $25, _dl_start\n\
++ " STRINGXP(PTR_ADDU) " $25, $8\n\
++ jalr $25\n\
++ \n\
++ " STRINGXP(PTR_ADDIU) " $29, 16\n\
++ # Get the value of label '_dl_start_user' in t9 ($25).\n\
++ " STRINGXP(PTR_LA) " $25, _dl_start_user\n\
++ " _RTLD_EPILOGUE(ENTRY_POINT) "\
++ \n\
++ \n\
++ " _RTLD_PROLOGUE(_dl_start_user) "\
++ " STRINGXP(SETUP_GP) "\n\
++ " STRINGXV(SETUP_GP64($18,_dl_start_user)) "\n\
++ move $16, $28\n\
++ # Save the user entry point address in a saved register.\n\
++ move $17, $2\n\
++ # See if we were run as a command with the executable file\n\
++ # name as an extra leading argument.\n\
++ lw $2, _dl_skip_args\n\
++ beq $2, $0, 1f\n\
++ # Load the original argument count.\n\
++ " STRINGXP(PTR_L) " $10, 0($4)\n\
++ # Subtract _dl_skip_args from it.\n\
++ subu $10, $2\n\
++ # FIXME: unnecessary? Adjust the stack pointer to skip _dl_skip_args words.\n\
++ sll $2, " STRINGXP (PTRLOG) "\n\
++ " STRINGXP(PTR_ADDU) " $29, $2\n\
++ # Save back the modified argument count.\n\
++ " STRINGXP(PTR_S) " $10, 0($4)\n\
++1: # Call _dl_init (struct link_map *main_map, int argc, char **argv, char **env) \n\
++ " STRINGXP(PTR_L) /* or lw??? fixme */ " $5, 0($4)\n\
++ " STRINGXP(PTR_LA) " $6, " STRINGXP (PTRSIZE) "($4)\n\
++ " STRINGXP(PTR_L) " $4, _rtld_local\n\
++ sll $7, $5, " STRINGXP (PTRLOG) "\n\
++ " STRINGXP(PTR_ADDU) " $7, $7, $6\n\
++ " STRINGXP(PTR_ADDU) " $7, $7, " STRINGXP (PTRSIZE) " \n\
++ # Make sure the stack pointer is aligned for _dl_init_internal.\n\
++ and $2, $29, -2 * " STRINGXP(SZREG) "\n\
++ " STRINGXP(PTR_S) " $29, -" STRINGXP(SZREG) "($2)\n\
++ " STRINGXP(PTR_SUBIU) " $29, $2, 32\n\
++ " STRINGXP(SAVE_GP(16)) "\n\
++ # Call the function to run the initializers.\n\
++ jal _dl_init_internal\n\
++ # Restore the stack pointer for _start.\n\
++ " STRINGXP(PTR_L) " $29, 32-" STRINGXP(SZREG) "($29)\n\
++ # Pass our finalizer function to the user in $2 as per ELF ABI.\n\
++ " STRINGXP(PTR_LA) " $2, _dl_fini\n\
++ # Jump to the user entry point.\n\
++ move $25, $17\n\
++ jr $25\n\t"\
++ _RTLD_EPILOGUE(_dl_start_user)\
++ ".previous"\
++);
+--- /dev/null
++++ b/ports/sysdeps/unix/bsd/bsd4.4/kfreebsd/mips/elf/start.S
+@@ -0,0 +1,121 @@
++/* Startup code compliant to the ELF Mips ABI.
++ Copyright (C) 1995, 1997, 2000, 2001, 2002, 2003, 2004, 2010
++ Free Software Foundation, Inc.
++ Port to kFreeBSD (kernel of FreeBSD) by Robert Millan.
++
++ This file is part of the GNU C Library.
++
++ The GNU C Library is free software; you can redistribute it and/or
++ modify it under the terms of the GNU Lesser General Public
++ License as published by the Free Software Foundation; either
++ version 2.1 of the License, or (at your option) any later version.
++
++ In addition to the permissions in the GNU Lesser General Public
++ License, the Free Software Foundation gives you unlimited
++ permission to link the compiled version of this file with other
++ programs, and to distribute those programs without any restriction
++ coming from the use of this file. (The GNU Lesser General Public
++ License restrictions do apply in other respects; for example, they
++ cover modification of the file, and distribution when not linked
++ into another program.)
++
++ Note that people who make modified versions of this file are not
++ obligated to grant this special exception for their modified
++ versions; it is their choice whether to do so. The GNU Lesser
++ General Public License gives permission to release a modified
++ version without this exception; this exception also makes it
++ possible to release a modified version which carries forward this
++ exception.
++
++ The GNU C Library is distributed in the hope that it will be useful,
++ but WITHOUT ANY WARRANTY; without even the implied warranty of
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++ Lesser General Public License for more details.
++
++ You should have received a copy of the GNU Lesser General Public
++ License along with the GNU C Library; if not, write to the Free
++ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
++ 02111-1307 USA. */
++
++#define __ASSEMBLY__ 1
++#include <entry.h>
++#include <sgidefs.h>
++#include <sys/asm.h>
++
++#ifndef ENTRY_POINT
++#error ENTRY_POINT needs to be defined for start.S on MIPS/ELF.
++#endif
++
++/* This is the canonical entry point, usually the first thing in the text
++ segment. The SVR4/Mips ABI (pages 3-31, 3-32) says that when the entry
++ point runs, most registers' values are unspecified, except for:
++
++ v0 ($2) Contains a function pointer to be registered with `atexit'.
++ This is how the dynamic linker arranges to have DT_FINI
++ functions called for shared libraries that have been loaded
++ before this code runs.
++
++ a0 ($4) Contains a pointer to the arguments and environment:
++ 0(a0) argc
++ 4(a0) argv[0]
++ ...
++ (4*argc)(a0) NULL
++ (4*(argc+1))(a0) envp[0]
++ ...
++ NULL
++ ra ($31) The return address register is set to zero so that programs
++ that search backword through stack frames recognize the last
++ stack frame.
++*/
++
++
++/* We need to call:
++ __libc_start_main (int (*main) (int, char **, char **), int argc,
++ char **argv, void (*init) (void), void (*fini) (void),
++ void (*rtld_fini) (void), void *stack_end)
++*/
++
++ .text
++ .globl ENTRY_POINT
++ .type ENTRY_POINT,@function
++ENTRY_POINT:
++#ifdef __PIC__
++ SETUP_GPX($0)
++ SETUP_GPX64($25,$0)
++#else
++ PTR_LA $28, _gp /* Setup GP correctly if we're non-PIC. */
++ move $31, $0
++#endif
++
++ PTR_L $5, 0($4) /* argc */
++ PTR_ADDIU $6, $4, PTRSIZE /* argv */
++ PTR_LA $4, main /* main */
++
++ /* Allocate space on the stack for seven arguments (o32 only)
++ and make sure the stack is aligned to double words (8 bytes)
++ on o32 and quad words (16 bytes) on n32 and n64. */
++
++ and $29, -2 * SZREG
++#if _MIPS_SIM == _ABIO32
++ PTR_SUBIU $29, 32
++#endif
++ PTR_LA $7, __libc_csu_init /* init */
++ PTR_LA $8, __libc_csu_fini
++#if _MIPS_SIM == _ABIO32
++ PTR_S $8, 16($29) /* fini */
++ PTR_S $2, 20($29) /* rtld_fini */
++ PTR_S $29, 24($29) /* stack_end */
++#else
++ move $9, $2 /* rtld_fini */
++ move $10, $29 /* stack_end */
++#endif
++ jal __libc_start_main
++hlt: b hlt /* Crash if somehow it does return. */
++
++/* Define a symbol for the first piece of initialized data. */
++ .data
++ .globl __data_start
++__data_start:
++ .long 0
++ .weak data_start
++ data_start = __data_start
+--- /dev/null
++++ b/ports/sysdeps/unix/bsd/bsd4.4/kfreebsd/mips/entry.h
+@@ -0,0 +1,7 @@
++/* http://sources.redhat.com/bugzilla/show_bug.cgi?id=12297 */
++
++#ifndef __ASSEMBLY__
++extern void __start (void);
++#endif
++
++#define ENTRY_POINT __start
+--- /dev/null
++++ b/ports/sysdeps/unix/bsd/bsd4.4/kfreebsd/mips/linuxthreads/pt-machine.h
+@@ -0,0 +1,49 @@
++/* Machine-dependent pthreads configuration and inline functions.
++ MIPS kFreeBSD version.
++ Copyright (C) 2001, 2002, 2003, 2004, 2010 Free Software Foundation, Inc.
++ This file is part of the GNU C Library.
++
++ The GNU C Library is free software; you can redistribute it and/or
++ modify it under the terms of the GNU Lesser General Public
++ License as published by the Free Software Foundation; either
++ version 2.1 of the License, or (at your option) any later version.
++
++ The GNU C Library is distributed in the hope that it will be useful,
++ but WITHOUT ANY WARRANTY; without even the implied warranty of
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++ Lesser General Public License for more details.
++
++ You should have received a copy of the GNU Lesser General Public
++ License along with the GNU C Library; if not, write to the Free
++ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
++ 02111-1307 USA. */
++
++#ifndef _FREEBSD_PT_MACHINE_H
++#define _FREEBSD_PT_MACHINE_H 1
++
++/*
++ almost all parts are common with linux version
++ */
++
++#include <linuxthreads/sysdeps/mips/pt-machine.h>
++
++#ifndef __ASSEMBLER__
++
++/* and only one FreeBSD specifics */
++
++#include <machine/sysarch.h>
++
++/* Initialize the thread-unique value. */
++
++#undef INIT_THREAD_SELF
++#define INIT_THREAD_SELF(descr, nr) \
++ { \
++ if (sysarch (MIPS_SET_TLS, descr) != 0) \
++ { \
++ abort(); \
++ } \
++ }
++
++#endif /* !__ASSEMBLER__ */
++
++#endif /* pt-machine.h */
+--- /dev/null
++++ b/ports/sysdeps/unix/bsd/bsd4.4/kfreebsd/mips/linuxthreads/sysdep-cancel.h
+@@ -0,0 +1,29 @@
++/* Copyright (C) 2010 Free Software Foundation, Inc.
++ This file is part of the GNU C Library.
++ Contributed by Robert Millan.
++
++ The GNU C Library is free software; you can redistribute it and/or
++ modify it under the terms of the GNU Lesser General Public
++ License as published by the Free Software Foundation; either
++ version 2.1 of the License, or (at your option) any later version.
++
++ The GNU C Library is distributed in the hope that it will be useful,
++ but WITHOUT ANY WARRANTY; without even the implied warranty of
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++ Lesser General Public License for more details.
++
++ You should have received a copy of the GNU Lesser General Public
++ License along with the GNU C Library; if not, write to the Free
++ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
++ 02111-1307 USA. */
++
++#include <linuxthreads/sysdeps/unix/sysv/linux/mips/sysdep-cancel.h>
++
++/* workarounds for http://sources.redhat.com/bugzilla/show_bug.cgi?id=12300 */
++#ifdef __ASSEMBLER__
++# if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt
++# define RTLD_SINGLE_THREAD_P(reg) SINGLE_THREAD_P(reg)
++# endif
++#else
++# define RTLD_SINGLE_THREAD_P SINGLE_THREAD_P
++#endif
+--- /dev/null
++++ b/ports/sysdeps/unix/bsd/bsd4.4/kfreebsd/mips/linuxthreads/tls.h
+@@ -0,0 +1,206 @@
++/* Definitions for thread-local data handling. linuxthreads/MIPS version.
++ Copyright (C) 2005 Free Software Foundation, Inc.
++ This file is part of the GNU C Library.
++
++ The GNU C Library is free software; you can redistribute it and/or
++ modify it under the terms of the GNU Lesser General Public
++ License as published by the Free Software Foundation; either
++ version 2.1 of the License, or (at your option) any later version.
++
++ The GNU C Library is distributed in the hope that it will be useful,
++ but WITHOUT ANY WARRANTY; without even the implied warranty of
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++ Lesser General Public License for more details.
++
++ You should have received a copy of the GNU Lesser General Public
++ License along with the GNU C Library; if not, write to the Free
++ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
++ 02111-1307 USA. */
++
++#ifndef _TLS_H
++#define _TLS_H
++
++#ifndef __ASSEMBLER__
++
++# include <stdbool.h>
++# include <pt-machine.h>
++# include <stddef.h>
++
++/* Type for the dtv. */
++typedef union dtv
++{
++ size_t counter;
++ struct
++ {
++ void *val;
++ bool is_static;
++ } pointer;
++} dtv_t;
++
++# define READ_THREAD_POINTER() \
++ ({ void *__result; \
++ asm volatile (".set\tpush\n\t.set\tmips32r2\n\t" \
++ "rdhwr\t%0, $29\n\t.set\tpop" : "=v" (__result)); \
++ __result; })
++
++#else /* __ASSEMBLER__ */
++# include <tcb-offsets.h>
++
++/* Note: rd must be $v1 to be ABI-conformant. */
++# define READ_THREAD_POINTER(rd) \
++ .set push; \
++ .set mips32r2; \
++ rdhwr rd, $29; \
++ .set pop
++#endif /* __ASSEMBLER__ */
++
++/* LinuxThreads can only use TLS if both floating stacks (in the MIPS case,
++ that means support for "rdhwr") and support from the tools are available.
++
++ We have to define USE_TLS consistently, or ldsodefs.h will lay out types
++ differently between an NPTL build and a LinuxThreads build. It can be set
++ for libc.so and not libpthread.so, but only if we provide appropriate padding
++ in the _pthread_descr_struct.
++
++ Currently nothing defines FLOATING_STACKS. We could assume this based on
++ kernel version once the TLS patches are available in kernel.org, but
++ it hardly seems worth it. Use NPTL if you can.
++
++ To avoid bothering with the TLS support code at all, use configure
++ --without-tls. */
++
++#if defined HAVE_TLS_SUPPORT \
++ && (defined FLOATING_STACKS || !defined IS_IN_libpthread)
++
++/* Signal that TLS support is available. */
++# define USE_TLS 1
++
++/* Include padding in _pthread_descr_struct so that libc can find p_errno,
++ if libpthread will only include the padding because of the !IS_IN_libpthread
++ check. */
++#ifndef FLOATING_STACKS
++# define INCLUDE_TLS_PADDING 1
++#endif
++
++# ifndef __ASSEMBLER__
++
++/* This layout is actually wholly private and not affected by the ABI.
++ Nor does it overlap the pthread data structure, so we need nothing
++ extra here at all. */
++typedef struct
++{
++ dtv_t *dtv;
++ void *private;
++# ifdef __FreeBSD_kernel__
++ long gscope_flag;
++# else
++ int gscope_flag;
++# endif
++} tcbhead_t;
++
++/* This is the size of the initial TCB. */
++# define TLS_INIT_TCB_SIZE 0
++
++/* Alignment requirements for the initial TCB. */
++# define TLS_INIT_TCB_ALIGN __alignof__ (struct _pthread_descr_struct)
++
++/* This is the size of the TCB. */
++# define TLS_TCB_SIZE 0
++
++/* Alignment requirements for the TCB. */
++# define TLS_TCB_ALIGN __alignof__ (struct _pthread_descr_struct)
++
++/* This is the size we need before TCB. */
++# define TLS_PRE_TCB_SIZE \
++ (sizeof (struct _pthread_descr_struct) \
++ + ((sizeof (tcbhead_t) + TLS_TCB_ALIGN - 1) & ~(TLS_TCB_ALIGN - 1)))
++
++/* The thread pointer (in hardware register $29) points to the end of
++ the TCB + 0x7000, as for PowerPC. The pthread_descr structure is
++ immediately in front of the TCB. */
++#define TLS_TCB_OFFSET 0x7000
++
++/* The DTV is allocated at the TP; the TCB is placed elsewhere. */
++/* This is not really true for powerpc64. We are following alpha
++ where the DTV pointer is first doubleword in the TCB. */
++# define TLS_DTV_AT_TP 1
++
++/* Install the dtv pointer. The pointer passed is to the element with
++ index -1 which contain the length. */
++# define INSTALL_DTV(TCBP, DTVP) \
++ (((tcbhead_t *) (TCBP))[-1].dtv = (DTVP) + 1)
++
++/* Install new dtv for current thread. */
++# define INSTALL_NEW_DTV(DTV) (THREAD_DTV() = (DTV))
++
++/* Return dtv of given thread descriptor. */
++# define GET_DTV(TCBP) (((tcbhead_t *) (TCBP))[-1].dtv)
++
++/* Get system call information. */
++# include <sysdep.h>
++# include <machine/sysarch.h>
++
++/* Code to initially initialize the thread pointer. This might need
++ special attention since 'errno' is not yet available and if the
++ operation can cause a failure 'errno' must not be touched. */
++# define TLS_INIT_TP(tcbp, secondcall) \
++ ({ INTERNAL_SYSCALL_DECL (err); \
++ long result_var; \
++ result_var = INTERNAL_SYSCALL (sysarch, err, 2, \
++ MIPS_SET_TLS, \
++ (char *) (tcbp) + TLS_TCB_OFFSET); \
++ INTERNAL_SYSCALL_ERROR_P (result_var, err) \
++ ? "unknown error" : NULL; })
++
++/* Return the address of the dtv for the current thread. */
++# define THREAD_DTV() \
++ (((tcbhead_t *) (READ_THREAD_POINTER () - TLS_TCB_OFFSET))[-1].dtv)
++
++/* Return the thread descriptor for the current thread. */
++# undef THREAD_SELF
++# define THREAD_SELF \
++ ((pthread_descr) (READ_THREAD_POINTER () \
++ - TLS_TCB_OFFSET - TLS_PRE_TCB_SIZE))
++
++/* Get the thread descriptor definition. */
++# include <linuxthreads/descr.h>
++
++/* l_tls_offset == 0 is perfectly valid on MIPS, so we have to use some
++ different value to mean unset l_tls_offset. */
++# define NO_TLS_OFFSET -1
++
++/* Initializing the thread pointer requires a syscall which may not be
++ available, so don't do it if we don't need to. */
++# define TLS_INIT_TP_EXPENSIVE 1
++
++
++// fix based on local-linuxthreads-gscope.diff from debian
++
++/* Get and set the global scope generation counter in struct pthread. */
++# define THREAD_GSCOPE_FLAG_UNUSED 0
++# define THREAD_GSCOPE_FLAG_USED 1
++# define THREAD_GSCOPE_FLAG_WAIT 2
++# define THREAD_GSCOPE_RESET_FLAG() \
++ do \
++ { int __res \
++ = atomic_exchange_rel (&THREAD_SELF->p_gscope_flag, \
++ THREAD_GSCOPE_FLAG_UNUSED); \
++ if (__res == THREAD_GSCOPE_FLAG_WAIT) \
++ lll_futex_wake (&THREAD_SELF->p_gscope_flag, 1); \
++ } \
++ while (0)
++# define THREAD_GSCOPE_SET_FLAG() \
++ do \
++ { \
++ THREAD_SELF->p_gscope_flag = THREAD_GSCOPE_FLAG_USED; \
++ atomic_write_barrier (); \
++ } \
++ while (0)
++# define THREAD_GSCOPE_WAIT() \
++ GL(dl_wait_lookup_done) ()
++
++# endif /* __ASSEMBLER__ */
++
++#endif /* HAVE_TLS_SUPPORT */
++
++#endif /* tls.h */
+--- /dev/null
++++ b/ports/sysdeps/unix/bsd/bsd4.4/kfreebsd/mips/mips32/Makefile
+@@ -0,0 +1,2 @@
++# pull in __syscall_error routine (needed by sysdep.h in this directory)
++libpthread-routines += sysdep
+--- /dev/null
++++ b/ports/sysdeps/unix/bsd/bsd4.4/kfreebsd/mips/mips32/bits/mcontext.h
+@@ -0,0 +1,116 @@
++/* Machine-dependent processor state structure for kFreeBSD.
++ Copyright (C) 2010 Free Software Foundation, Inc.
++ This file is part of the GNU C Library. mips version.
++
++ The GNU C Library is free software; you can redistribute it and/or
++ modify it under the terms of the GNU Lesser General Public
++ License as published by the Free Software Foundation; either
++ version 2.1 of the License, or (at your option) any later version.
++
++ The GNU C Library is distributed in the hope that it will be useful,
++ but WITHOUT ANY WARRANTY; without even the implied warranty of
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++ Lesser General Public License for more details.
++
++ You should have received a copy of the GNU Lesser General Public
++ License along with the GNU C Library; if not, write to the Free
++ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
++ 02111-1307 USA. */
++
++#if !defined _SYS_UCONTEXT_H
++# error "Never use <bits/mcontext.h> directly; include <sys/ucontext.h> instead."
++#endif
++
++/*
++ * Copyright (c) 1992, 1993
++ * The Regents of the University of California. All rights reserved.
++ *
++ * This code is derived from software contributed to Berkeley by
++ * Ralph Campbell.
++ *
++ * Redistribution and use in source and binary forms, with or without
++ * modification, are permitted provided that the following conditions
++ * are met:
++ * 1. Redistributions of source code must retain the above copyright
++ * notice, this list of conditions and the following disclaimer.
++ * 2. Redistributions in binary form must reproduce the above copyright
++ * notice, this list of conditions and the following disclaimer in the
++ * documentation and/or other materials provided with the distribution.
++ * 4. Neither the name of the University nor the names of its contributors
++ * may be used to endorse or promote products derived from this software
++ * without specific prior written permission.
++ *
++ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
++ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
++ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
++ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
++ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
++ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
++ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
++ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
++ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
++ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
++ * SUCH DAMAGE.
++ *
++ * @(#)ucontext.h 8.1 (Berkeley) 6/10/93
++ * JNPR: ucontext.h,v 1.2 2007/08/09 11:23:32 katta
++ * $FreeBSD$
++ */
++
++typedef struct __mcontext {
++ /*
++ * These fields must match the corresponding fields in struct
++ * sigcontext which follow 'sc_mask'. That way we can support
++ * struct sigcontext and ucontext_t at the same time.
++ */
++ int mc_onstack; /* sigstack state to restore */
++ int mc_pc; /* pc at time of signal */
++ int mc_regs[32]; /* processor regs 0 to 31 */
++ int sr; /* status register */
++ int mullo, mulhi; /* mullo and mulhi registers... */
++ int mc_fpused; /* fp has been used */
++ int mc_fpregs[33]; /* fp regs 0 to 31 and csr */
++ int mc_fpc_eir; /* fp exception instruction reg */
++ int __spare__[8]; /* XXX reserved */
++} mcontext_t;
++
++#define SZREG 4
++
++/* offsets into mcontext_t */
++#define UCTX_REG(x) (8 + (x)*SZREG)
++
++#define UCR_ZERO UCTX_REG(0)
++#define UCR_AT UCTX_REG(1)
++#define UCR_V0 UCTX_REG(2)
++#define UCR_V1 UCTX_REG(3)
++#define UCR_A0 UCTX_REG(4)
++#define UCR_A1 UCTX_REG(5)
++#define UCR_A2 UCTX_REG(6)
++#define UCR_A3 UCTX_REG(7)
++#define UCR_T0 UCTX_REG(8)
++#define UCR_T1 UCTX_REG(9)
++#define UCR_T2 UCTX_REG(10)
++#define UCR_T3 UCTX_REG(11)
++#define UCR_T4 UCTX_REG(12)
++#define UCR_T5 UCTX_REG(13)
++#define UCR_T6 UCTX_REG(14)
++#define UCR_T7 UCTX_REG(15)
++#define UCR_S0 UCTX_REG(16)
++#define UCR_S1 UCTX_REG(17)
++#define UCR_S2 UCTX_REG(18)
++#define UCR_S3 UCTX_REG(19)
++#define UCR_S4 UCTX_REG(20)
++#define UCR_S5 UCTX_REG(21)
++#define UCR_S6 UCTX_REG(22)
++#define UCR_S7 UCTX_REG(23)
++#define UCR_T8 UCTX_REG(24)
++#define UCR_T9 UCTX_REG(25)
++#define UCR_K0 UCTX_REG(26)
++#define UCR_K1 UCTX_REG(27)
++#define UCR_GP UCTX_REG(28)
++#define UCR_SP UCTX_REG(29)
++#define UCR_S8 UCTX_REG(30)
++#define UCR_RA UCTX_REG(31)
++#define UCR_SR UCTX_REG(32)
++#define UCR_MDLO UCTX_REG(33)
++#define UCR_MDHI UCTX_REG(34)
+--- /dev/null
++++ b/ports/sysdeps/unix/bsd/bsd4.4/kfreebsd/mips/mips32/bits/sigcontext.h
+@@ -0,0 +1,92 @@
++/* Machine-dependent signal context structure for kFreeBSD. mips version.
++ Copyright (C) 1991-1992,1994,1997,2001-2002 Free Software Foundation, Inc.
++ This file is part of the GNU C Library.
++
++ The GNU C Library is free software; you can redistribute it and/or
++ modify it under the terms of the GNU Lesser General Public
++ License as published by the Free Software Foundation; either
++ version 2.1 of the License, or (at your option) any later version.
++
++ The GNU C Library is distributed in the hope that it will be useful,
++ but WITHOUT ANY WARRANTY; without even the implied warranty of
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++ Lesser General Public License for more details.
++
++ You should have received a copy of the GNU Lesser General Public
++ License along with the GNU C Library; if not, write to the Free
++ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
++ 02111-1307 USA. */
++
++#if !defined _SIGNAL_H && !defined _SYS_UCONTEXT_H
++# error "Never use <bits/sigcontext.h> directly; include <signal.h> instead."
++#endif
++
++#ifndef _BITS_SIGCONTEXT_H
++#define _BITS_SIGCONTEXT_H 1
++
++/* $OpenBSD: signal.h,v 1.2 1999/01/27 04:10:03 imp Exp $ */
++
++/*
++ * Copyright (c) 1992, 1993
++ * The Regents of the University of California. All rights reserved.
++ *
++ * This code is derived from software contributed to Berkeley by
++ * Ralph Campbell.
++ *
++ * Redistribution and use in source and binary forms, with or without
++ * modification, are permitted provided that the following conditions
++ * are met:
++ * 1. Redistributions of source code must retain the above copyright
++ * notice, this list of conditions and the following disclaimer.
++ * 2. Redistributions in binary form must reproduce the above copyright
++ * notice, this list of conditions and the following disclaimer in the
++ * documentation and/or other materials provided with the distribution.
++ * 4. Neither the name of the University nor the names of its contributors
++ * may be used to endorse or promote products derived from this software
++ * without specific prior written permission.
++ *
++ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
++ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
++ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
++ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
++ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
++ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
++ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
++ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
++ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
++ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
++ * SUCH DAMAGE.
++ *
++ * @(#)signal.h 8.1 (Berkeley) 6/10/93
++ * JNPR: signal.h,v 1.4 2007/01/08 04:58:37 katta
++ * $FreeBSD$
++ */
++
++/*
++ * Information pushed on stack when a signal is delivered.
++ * This is used by the kernel to restore state following
++ * execution of the signal handler. It is also made available
++ * to the handler to allow it to restore state properly if
++ * a non-standard exit is performed.
++ */
++
++__extension__ struct sigcontext {
++ /*
++ * The fields following 'sc_mask' must match the definition
++ * of struct __mcontext. That way we can support
++ * struct sigcontext and ucontext_t at the same
++ * time.
++ */
++ __sigset_t sc_mask; /* signal mask to restore */
++ int sc_onstack; /* sigstack state to restore */
++ int sc_pc; /* pc at time of signal */
++ int sc_regs[32]; /* processor regs 0 to 31 */
++ int mullo, mulhi; /* mullo and mulhi registers... */
++ int sc_fpused; /* fp has been used */
++ int sc_fpregs[33]; /* fp regs 0 to 31 and csr */
++ int sc_fpc_eir; /* fp exception instruction reg */
++ int xxx[8]; /* XXX reserved */
++};
++
++#endif /* _BITS_SIGCONTEXT_H */
++
+--- /dev/null
++++ b/ports/sysdeps/unix/bsd/bsd4.4/kfreebsd/mips/mips32/sysdep.h
+@@ -0,0 +1,49 @@
++/* Copyright (C) 2010 Free Software Foundation, Inc.
++ This file is part of the GNU C Library.
++ Contributed by Robert Millan.
++
++ The GNU C Library is free software; you can redistribute it and/or
++ modify it under the terms of the GNU Lesser General Public
++ License as published by the Free Software Foundation; either
++ version 2.1 of the License, or (at your option) any later version.
++
++ The GNU C Library is distributed in the hope that it will be useful,
++ but WITHOUT ANY WARRANTY; without even the implied warranty of
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++ Lesser General Public License for more details.
++
++ You should have received a copy of the GNU Lesser General Public
++ License along with the GNU C Library; if not, write to the Free
++ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
++ 02111-1307 USA. */
++
++#ifndef _KFREEBSD_MIPS_SYSDEP_H
++#define _KFREEBSD_MIPS_SYSDEP_H 1
++
++/* This drags in __syscall_error, keep in sync with Makefile in
++ this directory. */
++#include <ports/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h>
++
++/* Default INLINE_SYSCALL works but is buggy for 64-bit arguments
++ (breaks mmap, lseek...). */
++#undef INLINE_SYSCALL
++#define INLINE_SYSCALL(name, nr, args...) __syscall_##name(args)
++
++/* Revert Linux kludge. */
++#undef SYS_ify
++#ifdef __STDC__
++# define SYS_ify(syscall_name) SYS_##syscall_name
++#else
++# define SYS_ify(syscall_name) SYS_/**/syscall_name
++#endif
++
++/* Workaround for http://sources.redhat.com/bugzilla/show_bug.cgi?id=12301 */
++#ifdef __ASSEMBLER__
++/* We don't want the label for the error handler to be visible in the symbol
++ table when we define it here. */
++#ifdef __PIC__
++# define SYSCALL_ERROR_LABEL 99b
++#endif
++#endif /* ! __ASSEMBLER__ */
++
++#endif /* _KFREEBSD_MIPS_SYSDEP_H */
+--- /dev/null
++++ b/ports/sysdeps/unix/bsd/bsd4.4/kfreebsd/mips/mips64/bits/mcontext.h
+@@ -0,0 +1,116 @@
++/* Machine-dependent processor state structure for kFreeBSD.
++ Copyright (C) 2010 Free Software Foundation, Inc.
++ This file is part of the GNU C Library. mips version.
++
++ The GNU C Library is free software; you can redistribute it and/or
++ modify it under the terms of the GNU Lesser General Public
++ License as published by the Free Software Foundation; either
++ version 2.1 of the License, or (at your option) any later version.
++
++ The GNU C Library is distributed in the hope that it will be useful,
++ but WITHOUT ANY WARRANTY; without even the implied warranty of
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++ Lesser General Public License for more details.
++
++ You should have received a copy of the GNU Lesser General Public
++ License along with the GNU C Library; if not, write to the Free
++ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
++ 02111-1307 USA. */
++
++#if !defined _SYS_UCONTEXT_H
++# error "Never use <bits/mcontext.h> directly; include <sys/ucontext.h> instead."
++#endif
++
++/*
++ * Copyright (c) 1992, 1993
++ * The Regents of the University of California. All rights reserved.
++ *
++ * This code is derived from software contributed to Berkeley by
++ * Ralph Campbell.
++ *
++ * Redistribution and use in source and binary forms, with or without
++ * modification, are permitted provided that the following conditions
++ * are met:
++ * 1. Redistributions of source code must retain the above copyright
++ * notice, this list of conditions and the following disclaimer.
++ * 2. Redistributions in binary form must reproduce the above copyright
++ * notice, this list of conditions and the following disclaimer in the
++ * documentation and/or other materials provided with the distribution.
++ * 4. Neither the name of the University nor the names of its contributors
++ * may be used to endorse or promote products derived from this software
++ * without specific prior written permission.
++ *
++ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
++ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
++ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
++ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
++ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
++ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
++ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
++ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
++ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
++ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
++ * SUCH DAMAGE.
++ *
++ * @(#)ucontext.h 8.1 (Berkeley) 6/10/93
++ * JNPR: ucontext.h,v 1.2 2007/08/09 11:23:32 katta
++ * $FreeBSD$
++ */
++
++typedef struct __mcontext {
++ /*
++ * These fields must match the corresponding fields in struct
++ * sigcontext which follow 'sc_mask'. That way we can support
++ * struct sigcontext and ucontext_t at the same time.
++ */
++ int mc_onstack; /* sigstack state to restore */
++ long int mc_pc; /* pc at time of signal */
++ long int mc_regs[32]; /* processor regs 0 to 31 */
++ long int sr; /* status register */
++ long int mullo, mulhi; /* mullo and mulhi registers... */
++ int mc_fpused; /* fp has been used */
++ long int mc_fpregs[33]; /* fp regs 0 to 31 and csr */
++ long int mc_fpc_eir; /* fp exception instruction reg */
++ int __spare__[8]; /* XXX reserved */
++} mcontext_t;
++
++#define SZREG 4
++
++/* offsets into mcontext_t */
++#define UCTX_REG(x) (8 + (x)*SZREG)
++
++#define UCR_ZERO UCTX_REG(0)
++#define UCR_AT UCTX_REG(1)
++#define UCR_V0 UCTX_REG(2)
++#define UCR_V1 UCTX_REG(3)
++#define UCR_A0 UCTX_REG(4)
++#define UCR_A1 UCTX_REG(5)
++#define UCR_A2 UCTX_REG(6)
++#define UCR_A3 UCTX_REG(7)
++#define UCR_T0 UCTX_REG(8)
++#define UCR_T1 UCTX_REG(9)
++#define UCR_T2 UCTX_REG(10)
++#define UCR_T3 UCTX_REG(11)
++#define UCR_T4 UCTX_REG(12)
++#define UCR_T5 UCTX_REG(13)
++#define UCR_T6 UCTX_REG(14)
++#define UCR_T7 UCTX_REG(15)
++#define UCR_S0 UCTX_REG(16)
++#define UCR_S1 UCTX_REG(17)
++#define UCR_S2 UCTX_REG(18)
++#define UCR_S3 UCTX_REG(19)
++#define UCR_S4 UCTX_REG(20)
++#define UCR_S5 UCTX_REG(21)
++#define UCR_S6 UCTX_REG(22)
++#define UCR_S7 UCTX_REG(23)
++#define UCR_T8 UCTX_REG(24)
++#define UCR_T9 UCTX_REG(25)
++#define UCR_K0 UCTX_REG(26)
++#define UCR_K1 UCTX_REG(27)
++#define UCR_GP UCTX_REG(28)
++#define UCR_SP UCTX_REG(29)
++#define UCR_S8 UCTX_REG(30)
++#define UCR_RA UCTX_REG(31)
++#define UCR_SR UCTX_REG(32)
++#define UCR_MDLO UCTX_REG(33)
++#define UCR_MDHI UCTX_REG(34)
+--- /dev/null
++++ b/ports/sysdeps/unix/bsd/bsd4.4/kfreebsd/mips/mips64/bits/sigcontext.h
+@@ -0,0 +1,92 @@
++/* Machine-dependent signal context structure for kFreeBSD. mips version.
++ Copyright (C) 1991-1992,1994,1997,2001-2002 Free Software Foundation, Inc.
++ This file is part of the GNU C Library.
++
++ The GNU C Library is free software; you can redistribute it and/or
++ modify it under the terms of the GNU Lesser General Public
++ License as published by the Free Software Foundation; either
++ version 2.1 of the License, or (at your option) any later version.
++
++ The GNU C Library is distributed in the hope that it will be useful,
++ but WITHOUT ANY WARRANTY; without even the implied warranty of
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++ Lesser General Public License for more details.
++
++ You should have received a copy of the GNU Lesser General Public
++ License along with the GNU C Library; if not, write to the Free
++ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
++ 02111-1307 USA. */
++
++#if !defined _SIGNAL_H && !defined _SYS_UCONTEXT_H
++# error "Never use <bits/sigcontext.h> directly; include <signal.h> instead."
++#endif
++
++#ifndef _BITS_SIGCONTEXT_H
++#define _BITS_SIGCONTEXT_H 1
++
++/* $OpenBSD: signal.h,v 1.2 1999/01/27 04:10:03 imp Exp $ */
++
++/*
++ * Copyright (c) 1992, 1993
++ * The Regents of the University of California. All rights reserved.
++ *
++ * This code is derived from software contributed to Berkeley by
++ * Ralph Campbell.
++ *
++ * Redistribution and use in source and binary forms, with or without
++ * modification, are permitted provided that the following conditions
++ * are met:
++ * 1. Redistributions of source code must retain the above copyright
++ * notice, this list of conditions and the following disclaimer.
++ * 2. Redistributions in binary form must reproduce the above copyright
++ * notice, this list of conditions and the following disclaimer in the
++ * documentation and/or other materials provided with the distribution.
++ * 4. Neither the name of the University nor the names of its contributors
++ * may be used to endorse or promote products derived from this software
++ * without specific prior written permission.
++ *
++ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
++ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
++ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
++ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
++ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
++ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
++ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
++ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
++ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
++ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
++ * SUCH DAMAGE.
++ *
++ * @(#)signal.h 8.1 (Berkeley) 6/10/93
++ * JNPR: signal.h,v 1.4 2007/01/08 04:58:37 katta
++ * $FreeBSD$
++ */
++
++/*
++ * Information pushed on stack when a signal is delivered.
++ * This is used by the kernel to restore state following
++ * execution of the signal handler. It is also made available
++ * to the handler to allow it to restore state properly if
++ * a non-standard exit is performed.
++ */
++
++__extension__ struct sigcontext {
++ /*
++ * The fields following 'sc_mask' must match the definition
++ * of struct __mcontext. That way we can support
++ * struct sigcontext and ucontext_t at the same
++ * time.
++ */
++ __sigset_t sc_mask; /* signal mask to restore */
++ int sc_onstack; /* sigstack state to restore */
++ long int sc_pc; /* pc at time of signal */
++ long int sc_regs[32]; /* processor regs 0 to 31 */
++ long int mullo, mulhi; /* mullo and mulhi registers... */
++ int sc_fpused; /* fp has been used */
++ long int sc_fpregs[33]; /* fp regs 0 to 31 and csr */
++ long int sc_fpc_eir; /* fp exception instruction reg */
++ int xxx[8]; /* XXX reserved */
++};
++
++#endif /* _BITS_SIGCONTEXT_H */
++
+--- /dev/null
++++ b/ports/sysdeps/unix/bsd/bsd4.4/kfreebsd/mips/start_thread.S
+@@ -0,0 +1,56 @@
++/* Copyright (C) 2002 Free Software Foundation, Inc.
++ This file is part of the GNU C Library.
++ Contributed by Bruno Haible <bruno@clisp.org>, 2002.
++ Modification for amd64 contributed by Petr Salinger, 2006.
++
++ The GNU C Library is free software; you can redistribute it and/or
++ modify it under the terms of the GNU Lesser General Public
++ License as published by the Free Software Foundation; either
++ version 2.1 of the License, or (at your option) any later version.
++
++ The GNU C Library is distributed in the hope that it will be useful,
++ but WITHOUT ANY WARRANTY; without even the implied warranty of
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++ Lesser General Public License for more details.
++
++ You should have received a copy of the GNU Lesser General Public
++ License along with the GNU C Library; if not, write to the Free
++ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
++ 02111-1307 USA. */
++
++/* __start_thread (flags, stack, func, arg)
++ calls __rfork (flags), and in the child sets the stack pointer and then
++ calls _exit (func (arg)).
++ It cannot be done in portable C. */
++
++/*
++ The parameters are passed in registers:
++ rdi: flags for rfork
++ rsi: child_stack
++ rdx: func
++ rcx: arg
++*/
++
++#include <sysdep.h>
++#include <asm-syntax.h>
++
++#define SIG_SETMASK 3
++
++/* There is a window of a few instructions, right after the rfork
++ system call, where the handling of a signal would write garbage
++ into the stack shared by the parent and the child (assuming
++ RFMEM is set in flags). To solve this: 1. We block all signals
++ around the rfork system call and unblock them afterwards in
++ the parent and in the child (but only after changing the stack
++ pointer). 2. The child accesses only values passed in registers
++ and on its own stack. This way, if the parent is scheduled to
++ run first, and handles a signal, it will not affect the child;
++ and if the child runs first, and handles a signal, it will use
++ the child's stack and not affect the parent.
++*/
++
++/* FIXME */
++
++ .text
++ENTRY (__start_thread)
++PSEUDO_END (__start_thread)
+--- /dev/null
++++ b/ports/sysdeps/unix/bsd/bsd4.4/kfreebsd/mips/sys/tas.h
+@@ -0,0 +1,2 @@
++/* workaround for http://sources.redhat.com/bugzilla/show_bug.cgi?id=12298 */
++#include <ports/sysdeps/unix/sysv/linux/mips/sys/tas.h>
+--- /dev/null
+++ b/ports/sysdeps/unix/bsd/bsd4.4/kfreebsd/mkdirat.c
@@ -0,0 +1,126 @@
+/* Copyright (C) 2009 Free Software Foundation, Inc.
@@ -26334,6 +27500,76 @@
+
+#endif /* tls.h */
--- /dev/null
++++ b/ports/sysdeps/unix/bsd/bsd4.4/kfreebsd/x86_64/linuxthreads/vfork.S
+@@ -0,0 +1,67 @@
++/* Copyright (C) 1999, 2002 Free Software Foundation, Inc.
++ This file is part of the GNU C Library.
++
++ The GNU C Library is free software; you can redistribute it and/or
++ modify it under the terms of the GNU Lesser General Public
++ License as published by the Free Software Foundation; either
++ version 2.1 of the License, or (at your option) any later version.
++
++ The GNU C Library is distributed in the hope that it will be useful,
++ but WITHOUT ANY WARRANTY; without even the implied warranty of
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++ Lesser General Public License for more details.
++
++ You should have received a copy of the GNU Lesser General Public
++ License along with the GNU C Library; if not, write to the Free
++ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
++ 02111-1307 USA. */
++
++#include <sysdep.h>
++
++/* Clone the calling process, but without copying the whole address space.
++ The calling process is suspended until the new process exits or is
++ replaced by a call to `execve'. Return -1 for errors, 0 to the new process,
++ and the process ID of the new process to the old process. */
++
++ENTRY (__vfork)
++
++#ifdef SHARED
++ cmpq $0, __libc_pthread_functions(%rip)
++#else
++ .weak pthread_create
++ movq $pthread_create, %rax
++ testq %rax, %rax
++#endif
++ jne HIDDEN_JUMPTARGET (__fork)
++
++ /* Pop the return PC value into ESI. */
++ popq %rsi
++ cfi_adjust_cfa_offset(-8)
++
++ /* Perform the system call. */
++ DO_CALL (vfork, 0)
++ jb L(error) /* Branch forward if it failed. */
++
++ /* In the parent process, %rdx == 0, %rax == child pid. */
++ /* In the child process, %rdx == 1, %rax == parent pid. */
++
++ /* Change %rax to be 0 in the child process. */
++ decq %rdx
++ andq %rdx, %rax
++
++ /* Jump to the return PC. */
++ jmp *%rsi
++
++L(error):
++ /* Push back the return PC. */
++ pushq %rsi
++ cfi_adjust_cfa_offset(8)
++
++ /* Branch to the error handler, hidden in PSEUDO_END. */
++ jmp SYSCALL_ERROR_LABEL
++L(pseudo_end):
++ ret
++PSEUDO_END (__vfork)
++libc_hidden_def (__vfork)
++
++weak_alias (__vfork, vfork)
+--- /dev/null
+++ b/ports/sysdeps/unix/bsd/bsd4.4/kfreebsd/x86_64/makecontext.S
@@ -0,0 +1,146 @@
+/* makecontext() for FreeBSD/amd64.
Reply to: