r5597 - in glibc-package/trunk/debian: . patches/kfreebsd
Author: ps-guest
Date: 2013-05-14 06:44:26 +0000 (Tue, 14 May 2013)
New Revision: 5597
Modified:
glibc-package/trunk/debian/changelog
glibc-package/trunk/debian/patches/kfreebsd/local-sysdeps.diff
Log:
kfreebsd/local-sysdeps.diff: update to revision 4438 (from glibc-bsd).
Modified: glibc-package/trunk/debian/changelog
===================================================================
--- glibc-package/trunk/debian/changelog 2013-05-13 21:19:11 UTC (rev 5596)
+++ glibc-package/trunk/debian/changelog 2013-05-14 06:44:26 UTC (rev 5597)
@@ -3,6 +3,7 @@
[ Petr Salinger ]
* Allow failure of tst-secure-getenv on kfreebsd-*, as the kernel
in squeeze provides /proc/self/exe only on a best effort basis.
+ * kfreebsd/local-sysdeps.diff: update to revision 4438 (from glibc-bsd).
[ Aurelien Jarno ]
* Add s390x symbols files.
Modified: glibc-package/trunk/debian/patches/kfreebsd/local-sysdeps.diff
===================================================================
--- glibc-package/trunk/debian/patches/kfreebsd/local-sysdeps.diff 2013-05-13 21:19:11 UTC (rev 5596)
+++ glibc-package/trunk/debian/patches/kfreebsd/local-sysdeps.diff 2013-05-14 06:44:26 UTC (rev 5597)
@@ -46,7 +46,7 @@
+gnu
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/bsd4.4/kfreebsd/Makefile
-@@ -0,0 +1,135 @@
+@@ -0,0 +1,133 @@
+# Use bash, not /bin/sh, for executing scripts, because the native
+# FreeBSD /bin/sh does not interpret the IFS="<tab>" read ... command
+# in localedata/tst-fmon.sh correctly.
@@ -81,15 +81,13 @@
+
+ifeq ($(subdir),io)
+# For <unistd.h>.
-+sysdep_routines += sys_access sys_faccessat sys_fchownat sys_fexecve sys_getcwd sys_linkat sys_lseek sys_freebsd6_lseek sys_readlinkat sys_symlinkat sys_unlinkat
++sysdep_routines += sys_access sys_faccessat sys_getcwd
+# For <fcntl.h>.
+sysdep_routines += sys_open sys_openat open_2
+# For <sys/stat.h>.
-+sysdep_routines += sys_fchmodat sys_fstat sys_fstatat sys_lstat sys_mkdirat sys_mkfifoat sys_mknod sys_mknodat sys_nfstat sys_nlstat sys_nstat sys_stat lchflags
++sysdep_routines += sys_fstat sys_fstatat sys_lstat sys_mkfifoat sys_mknod sys_mknodat sys_nfstat sys_nlstat sys_nstat sys_stat lchflags
+# For <sys/statfs.h>.
+sysdep_routines += fstatfs64 statfs64 sys_fstatfs sys_statfs
-+# For <stdio.h>
-+sysdep_routines += sys_renameat
+# For <sys/times.h>.
+sysdep_routines += sys_futimesat
+# Other.
@@ -107,7 +105,7 @@
+# For <sched.h>.
+sysdep_routines += clone start_thread
+# For <unistd.h>.
-+sysdep_routines += sys_ftruncate sys_freebsd6_ftruncate sys_truncate sys_freebsd6_truncate getosreldate
++sysdep_routines += getosreldate
+# For <sys/acl.h>.
+sysdep_routines += acl_aclcheck_fd acl_aclcheck_file acl_delete_fd acl_delete_file acl_get_fd acl_get_file acl_set_fd acl_set_file
+# For <sys/extattr.h>.
@@ -119,7 +117,7 @@
+# For <sys/linker.h>.
+sysdep_routines += kldfind kldfirstmod kldload kldnext kldstat kldsym kldunload kldunloadf
+# For <sys/mman.h>.
-+sysdep_routines += minherit sys_mmap sys_freebsd6_mmap sys_munmap
++sysdep_routines += minherit sys_mmap sys_munmap
+# For <sys/mount.h>.
+sysdep_routines += fhopen sys_fhstat sys_fhstatfs fhstat fhstat64 fhstatfs fhstatfs64 getfh getfsstat getfsstat64 sys_getfsstat getmntinfo getmntinfo64 mount nmount unmount
+# For <sys/rfork.h>.
@@ -140,12 +138,12 @@
+sysdep_routines += sys_fork sys_execve sys_sigaction sys_close sys_fcntl
+sysdep_routines += sys_clock_getres sys_clock_gettime sys_clock_settime
+sysdep_routines += sys_ktimer_create sys_ktimer_gettime sys_ktimer_settime sys_ktimer_getoverrun sys_ktimer_delete
-+sysdep_routines += sys_shm_open sys_shm_unlink sys_pselect sys_semctl
++sysdep_routines += sys_semctl
+endif
+
+ifeq ($(subdir),posix)
+# For <unistd.h>.
-+sysdep_routines += sys_getlogin sys_pread sys_freebsd6_pread sys_pwrite sys_freebsd6_pwrite sys_setlogin sys_read sys_write
++sysdep_routines += sys_getlogin sys_setlogin sys_read sys_write
+# for <sched.h>
+sysdep_routines += sys_cpuset_getaffinity sys_cpuset_setaffinity
+endif
@@ -175,7 +173,7 @@
+
+# Special ELF hacks.
+ifeq ($(subdir),elf)
-+sysdep-rtld-routines += dl-brk dl-sbrk dl-getcwd
++sysdep-rtld-routines += dl-brk dl-sbrk dl-getcwd dl-openat64
+sysdep_routines += sys_umtx
+endif
+
@@ -184,7 +182,7 @@
+endif
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/bsd4.4/kfreebsd/Versions
-@@ -0,0 +1,121 @@
+@@ -0,0 +1,118 @@
+libc {
+ # The comment lines with "#errlist-compat" are magic; see errlist-compat.awk.
+ # When you get an error from errlist-compat.awk, you need to add a new
@@ -296,10 +294,7 @@
+ # needed by librt as INLINE_SYSCALL:
+ __syscall_clock_getres; __syscall_clock_gettime; __syscall_clock_settime;
+ __syscall_ktimer_create; __syscall_ktimer_gettime; __syscall_ktimer_settime; __syscall_ktimer_getoverrun; __syscall_ktimer_delete;
-+ __syscall_shm_open; __syscall_shm_unlink;
+ # misc fixes for FreeBSD:
-+ __syscall_freebsd6_lseek; __syscall_freebsd6_pread; __syscall_freebsd6_pwrite;
-+ __syscall_lseek; __syscall_pread; __syscall_pwrite;
+ __syscall_connect; __syscall_sendto;
+ __syscall_cpuset_getaffinity ; __syscall_cpuset_setaffinity;
+ # global variable used in brk()
@@ -4949,7 +4944,7 @@
+__brk (addr)
+ void *addr;
+{
-+ if (addr < &_end)
++ if ((char*)addr < _end)
+ return 0;
+
+ if (INLINE_SYSCALL (obreak, 1, addr) == -1)
@@ -6085,6 +6080,45 @@
@@ -0,0 +1 @@
+#include "getcwd.c"
--- /dev/null
++++ b/ports/sysdeps/unix/bsd/bsd4.4/kfreebsd/dl-openat64.c
+@@ -0,0 +1,36 @@
++/* Copyright (C) 2011 Free Software Foundation, Inc.
++ This file is part of the GNU C Library.
++ Contributed by Ulrich Drepper <drepper@gmain.com>, 2003.
++
++ 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, see
++ <http://www.gnu.org/licenses/>. */
++
++#include <assert.h>
++#include <errno.h>
++#include <fcntl.h>
++#include <sysdep.h>
++
++extern int __syscall_openat (int fd, const char *path, int flag, mode_t mode);
++libc_hidden_proto (__syscall_openat)
++
++int
++openat64 (dfd, file, oflag)
++ int dfd;
++ const char *file;
++ int oflag;
++{
++ assert ((oflag & O_CREAT) == 0);
++
++ return INLINE_SYSCALL (openat, 4, dfd, file, oflag, 0);
++}
+--- /dev/null
+++ b/ports/sysdeps/unix/bsd/bsd4.4/kfreebsd/dl-origin.c
@@ -0,0 +1,123 @@
+/* Find path of executable.
@@ -6645,7 +6679,7 @@
+#endif
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/bsd4.4/kfreebsd/faccessat.c
-@@ -0,0 +1,198 @@
+@@ -0,0 +1,69 @@
+/* Test for access to file, relative to open directory. Linux version.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
@@ -6697,17 +6731,7 @@
+ int mode;
+ int flag;
+{
-+# ifndef __ASSUME_ATFCTS
-+ if (__have_atfcts >= 0)
-+# endif
-+ {
-+ int result = INLINE_SYSCALL (faccessat, 4, fd, file, mode, flag);
-+# ifndef __ASSUME_ATFCTS
-+ if (result == -1 && errno == ENOSYS)
-+ __have_atfcts = -1;
-+ else
-+# endif
-+ {
++ int result = INLINE_SYSCALL (faccessat, 4, fd, file, mode, flag);
+ if ((result == 0) && (mode & X_OK))
+ {
+ uid_t uid = (flag & AT_EACCESS) ? __geteuid () : __getuid ();
@@ -6724,408 +6748,8 @@
+ }
+ }
+ return result;
-+ }
-+ }
-+
-+#ifndef __ASSUME_ATFCTS
-+ if (flag & ~(AT_SYMLINK_NOFOLLOW | AT_EACCESS))
-+ {
-+ __set_errno (EINVAL);
-+ return -1;
-+ }
-+
-+ if ((!(flag & AT_EACCESS) || !__libc_enable_secure)
-+ && !(flag & AT_SYMLINK_NOFOLLOW))
-+ {
-+ /* If we are not set-uid or set-gid, access does the same. */
-+ if (fd != AT_FDCWD && file[0] != '/')
-+ {
-+ int mib[4];
-+ size_t kf_len = 0;
-+ char *kf_buf, *kf_bufp;
-+ size_t filelen;
-+
-+ if (fd < 0)
-+ {
-+ __set_errno (EBADF);
-+ return -1;
-+ }
-+
-+ filelen = strlen (file);
-+ if (__builtin_expect (filelen == 0, 0))
-+ {
-+ __set_errno (ENOENT);
-+ return -1;
-+ }
-+
-+ mib[0] = CTL_KERN;
-+ mib[1] = KERN_PROC;
-+ mib[2] = KERN_PROC_FILEDESC;
-+ mib[3] = __getpid ();
-+
-+ if (__sysctl (mib, 4, NULL, &kf_len, NULL, 0) != 0)
-+ {
-+ __set_errno (ENOSYS);
-+ return -1;
-+ }
-+
-+ kf_buf = alloca (kf_len + filelen);
-+ if (__sysctl (mib, 4, kf_buf, &kf_len, NULL, 0) != 0)
-+ {
-+ __set_errno (ENOSYS);
-+ return -1;
-+ }
-+
-+ kf_bufp = kf_buf;
-+ while (kf_bufp < kf_buf + kf_len)
-+ {
-+ struct kinfo_file *kf =
-+ (struct kinfo_file *) (uintptr_t) kf_bufp;
-+
-+ if (kf->kf_fd == fd)
-+ {
-+ if (kf->kf_type != KF_TYPE_VNODE ||
-+ kf->kf_vnode_type != KF_VTYPE_VDIR)
-+ {
-+ __set_errno (ENOTDIR);
-+ return -1;
-+ }
-+
-+ strcat (kf->kf_path, "/");
-+ strcat (kf->kf_path, file);
-+ file = kf->kf_path;
-+ break;
-+ }
-+ kf_bufp += kf->kf_structsize;
-+ }
-+
-+ if (kf_bufp >= kf_buf + kf_len)
-+ {
-+ __set_errno (EBADF);
-+ return -1;
-+ }
-+ }
-+
-+ return __access (file, mode);
-+ }
-+#endif
-+
-+ struct stat64 stats;
-+ if (fstatat64 (fd, file, &stats, flag & AT_SYMLINK_NOFOLLOW))
-+ return -1;
-+
-+ mode &= (X_OK | W_OK | R_OK); /* Clear any bogus bits. */
-+#if R_OK != S_IROTH || W_OK != S_IWOTH || X_OK != S_IXOTH
-+# error Oops, portability assumptions incorrect.
-+#endif
-+
-+ if (mode == F_OK)
-+ return 0; /* The file exists. */
-+
-+ uid_t uid = (flag & AT_EACCESS) ? __geteuid () : __getuid ();
-+
-+ /* The super-user can read and write any file, and execute any file
-+ that anyone can execute. */
-+ if (uid == 0 && ((mode & X_OK) == 0
-+ || (stats.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))))
-+ return 0;
-+
-+ int granted = (uid == stats.st_uid
-+ ? (unsigned int) (stats.st_mode & (mode << 6)) >> 6
-+ : (stats.st_gid == ((flag & AT_EACCESS)
-+ ? __getegid () : __getgid ())
-+ || __group_member (stats.st_gid))
-+ ? (unsigned int) (stats.st_mode & (mode << 3)) >> 3
-+ : (stats.st_mode & mode));
-+
-+ if (granted == mode)
-+ return 0;
-+
-+ __set_errno (EACCES);
-+ return -1;
+}
--- /dev/null
-+++ b/ports/sysdeps/unix/bsd/bsd4.4/kfreebsd/fchmodat.c
-@@ -0,0 +1,138 @@
-+/* Copyright (C) 2009 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 <errno.h>
-+#include <fcntl.h>
-+#include <stddef.h>
-+#include <stdio.h>
-+#include <stdint.h>
-+#include <stdlib.h>
-+#include <string.h>
-+#include <sysdep.h>
-+#include <sys/stat.h>
-+#include <sys/sysctl.h>
-+#include <sys/user.h>
-+#include <kernel-features.h>
-+
-+extern int __syscall_fchmodat (int fd, const char *path,
-+ mode_t mode, int flag);
-+libc_hidden_proto (__syscall_fchmodat)
-+
-+/* This is specific to kFreeBSD. */
-+extern int __lchmod (__const char *__file, __mode_t __mode);
-+
-+int
-+fchmodat (fd, file, mode, flag)
-+ int fd;
-+ const char *file;
-+ mode_t mode;
-+ int flag;
-+{
-+# ifndef __ASSUME_ATFCTS
-+ if (__have_atfcts >= 0)
-+# endif
-+ {
-+ int result = INLINE_SYSCALL (fchmodat, 4, fd, file, mode, flag);
-+# ifndef __ASSUME_ATFCTS
-+ if (result == -1 && errno == ENOSYS)
-+ __have_atfcts = -1;
-+ else
-+# endif
-+ return result;
-+ }
-+
-+#ifndef __ASSUME_ATFCTS
-+ if (flag & ~AT_SYMLINK_NOFOLLOW)
-+ {
-+ __set_errno (EINVAL);
-+ return -1;
-+ }
-+
-+ if (fd != AT_FDCWD && file[0] != '/')
-+ {
-+ int mib[4];
-+ size_t kf_len = 0;
-+ char *kf_buf, *kf_bufp;
-+ size_t filelen;
-+
-+ if (fd < 0)
-+ {
-+ __set_errno (EBADF);
-+ return -1;
-+ }
-+
-+ filelen = strlen (file);
-+ if (__builtin_expect (filelen == 0, 0))
-+ {
-+ __set_errno (ENOENT);
-+ return -1;
-+ }
-+
-+ mib[0] = CTL_KERN;
-+ mib[1] = KERN_PROC;
-+ mib[2] = KERN_PROC_FILEDESC;
-+ mib[3] = __getpid ();
-+
-+ if (__sysctl (mib, 4, NULL, &kf_len, NULL, 0) != 0)
-+ {
-+ __set_errno (ENOSYS);
-+ return -1;
-+ }
-+
-+ kf_buf = alloca (kf_len + filelen);
-+ if (__sysctl (mib, 4, kf_buf, &kf_len, NULL, 0) != 0)
-+ {
-+ __set_errno (ENOSYS);
-+ return -1;
-+ }
-+
-+ kf_bufp = kf_buf;
-+ while (kf_bufp < kf_buf + kf_len)
-+ {
-+ struct kinfo_file *kf = (struct kinfo_file *) (uintptr_t) kf_bufp;
-+
-+ if (kf->kf_fd == fd)
-+ {
-+ if (kf->kf_type != KF_TYPE_VNODE ||
-+ kf->kf_vnode_type != KF_VTYPE_VDIR)
-+ {
-+ __set_errno (ENOTDIR);
-+ return -1;
-+ }
-+
-+ strcat (kf->kf_path, "/");
-+ strcat (kf->kf_path, file);
-+ file = kf->kf_path;
-+ break;
-+ }
-+ kf_bufp += kf->kf_structsize;
-+ }
-+
-+ if (kf_bufp >= kf_buf + kf_len)
-+ {
-+ __set_errno (EBADF);
-+ return -1;
-+ }
-+ }
-+
-+ if (flag & AT_SYMLINK_NOFOLLOW)
-+ return __lchmod(file, mode);
-+ else
-+ return __chmod(file, mode);
-+#endif
-+}
---- /dev/null
-+++ b/ports/sysdeps/unix/bsd/bsd4.4/kfreebsd/fchownat.c
-@@ -0,0 +1,137 @@
-+/* Copyright (C) 2009 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 <errno.h>
-+#include <fcntl.h>
-+#include <stddef.h>
-+#include <stdio.h>
-+#include <stdint.h>
-+#include <stdlib.h>
-+#include <string.h>
-+#include <sysdep.h>
-+#include <unistd.h>
-+#include <sys/sysctl.h>
-+#include <sys/user.h>
-+#include <kernel-features.h>
-+
-+extern int __syscall_fchownat (int fd, const char *path, uid_t uid,
-+ gid_t gid, int flag);
-+libc_hidden_proto (__syscall_fchownat)
-+
-+/* Change the owner and group of FILE. */
-+int
-+fchownat (fd, file, owner, group, flag)
-+ int fd;
-+ const char *file;
-+ uid_t owner;
-+ gid_t group;
-+ int flag;
-+{
-+# ifndef __ASSUME_ATFCTS
-+ if (__have_atfcts >= 0)
-+# endif
-+ {
-+ int result = INLINE_SYSCALL (fchownat, 5, fd, file, owner, group, flag);
-+# ifndef __ASSUME_ATFCTS
-+ if (result == -1 && errno == ENOSYS)
-+ __have_atfcts = -1;
-+ else
-+# endif
-+ return result;
-+ }
-+
-+#ifndef __ASSUME_ATFCTS
-+ if (flag & ~AT_SYMLINK_NOFOLLOW)
-+ {
-+ __set_errno (EINVAL);
-+ return -1;
-+ }
-+
-+ if (fd != AT_FDCWD && file[0] != '/')
-+ {
-+ int mib[4];
-+ size_t kf_len = 0;
-+ char *kf_buf, *kf_bufp;
-+ size_t filelen;
-+
-+ if (fd < 0)
-+ {
-+ __set_errno (EBADF);
-+ return -1;
-+ }
-+
-+ filelen = strlen (file);
-+ if (__builtin_expect (filelen == 0, 0))
-+ {
-+ __set_errno (ENOENT);
-+ return -1;
-+ }
-+
-+ mib[0] = CTL_KERN;
-+ mib[1] = KERN_PROC;
-+ mib[2] = KERN_PROC_FILEDESC;
-+ mib[3] = __getpid ();
-+
-+ if (__sysctl (mib, 4, NULL, &kf_len, NULL, 0) != 0)
-+ {
-+ __set_errno (ENOSYS);
-+ return -1;
-+ }
-+
-+ kf_buf = alloca (kf_len + filelen);
-+ if (__sysctl (mib, 4, kf_buf, &kf_len, NULL, 0) != 0)
-+ {
-+ __set_errno (ENOSYS);
-+ return -1;
-+ }
-+
-+ kf_bufp = kf_buf;
-+ while (kf_bufp < kf_buf + kf_len)
-+ {
-+ struct kinfo_file *kf = (struct kinfo_file *) (uintptr_t) kf_bufp;
-+
-+ if (kf->kf_fd == fd)
-+ {
-+ if (kf->kf_type != KF_TYPE_VNODE ||
-+ kf->kf_vnode_type != KF_VTYPE_VDIR)
-+ {
-+ __set_errno (ENOTDIR);
-+ return -1;
-+ }
-+
-+ strcat (kf->kf_path, "/");
-+ strcat (kf->kf_path, file);
-+ file = kf->kf_path;
-+ break;
-+ }
-+ kf_bufp += kf->kf_structsize;
-+ }
-+
-+ if (kf_bufp >= kf_buf + kf_len)
-+ {
-+ __set_errno (EBADF);
-+ return -1;
-+ }
-+ }
-+
-+ if (flag & AT_SYMLINK_NOFOLLOW)
-+ return __lchown(file, owner, group);
-+ else
-+ return __chown(file, owner, group);
-+#endif
-+}
---- /dev/null
+++ b/ports/sysdeps/unix/bsd/bsd4.4/kfreebsd/fcntl.c
@@ -0,0 +1,69 @@
+/* Copyright (C) 2000, 2002, 2003, 2004 Free Software Foundation, Inc.
@@ -7198,112 +6822,6 @@
+libc_hidden_weak (__fcntl)
+weak_alias (__libc_fcntl, fcntl)
--- /dev/null
-+++ b/ports/sysdeps/unix/bsd/bsd4.4/kfreebsd/fexecve.c
-@@ -0,0 +1,103 @@
-+/* Copyright (C) 2009 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 <errno.h>
-+#include <fcntl.h>
-+#include <stddef.h>
-+#include <stdio.h>
-+#include <stdint.h>
-+#include <stdlib.h>
-+#include <string.h>
-+#include <sysdep.h>
-+#include <unistd.h>
-+#include <sys/sysctl.h>
-+#include <sys/user.h>
-+#include <kernel-features.h>
-+
-+extern int __syscall_fexecve (int fd, char *const argv[], char *const envp[]);
-+libc_hidden_proto (__syscall_fexecve);
-+
-+/* Execute the file FD refers to, overlaying the running program image.
-+ ARGV and ENVP are passed to the new program, as for `execve'. */
-+int
-+fexecve (fd, argv, envp)
-+ int fd;
-+ char *const argv[];
-+ char *const envp[];
-+{
-+# ifndef __ASSUME_ATFCTS
-+ if (__have_atfcts >= 0)
-+# endif
-+ {
-+ int result = INLINE_SYSCALL (fexecve, 3, fd, argv, envp);
-+# ifndef __ASSUME_ATFCTS
-+ if (result == -1 && errno == ENOSYS)
-+ __have_atfcts = -1;
-+ else
-+# endif
-+ return result;
-+ }
-+
-+#ifndef __ASSUME_ATFCTS
-+ if (fd < 0 || argv == NULL || envp == NULL)
-+ {
-+ __set_errno (EINVAL);
-+ return -1;
-+ }
-+
-+ int mib[4];
-+ size_t kf_len = 0;
-+ char *kf_buf, *kf_bufp;
-+
-+ mib[0] = CTL_KERN;
-+ mib[1] = KERN_PROC;
-+ mib[2] = KERN_PROC_FILEDESC;
-+ mib[3] = __getpid ();
-+
-+ if (__sysctl (mib, 4, NULL, &kf_len, NULL, 0) != 0)
-+ {
-+ __set_errno (ENOSYS);
-+ return -1;
-+ }
-+
-+ kf_buf = alloca (kf_len);
-+ if (__sysctl (mib, 4, kf_buf, &kf_len, NULL, 0) != 0)
-+ {
-+ __set_errno (ENOSYS);
-+ return -1;
-+ }
-+
-+ kf_bufp = kf_buf;
-+ while (kf_bufp < kf_buf + kf_len)
-+ {
-+ struct kinfo_file *kf = (struct kinfo_file *) (uintptr_t) kf_bufp;
-+
-+ if (kf->kf_fd == fd)
-+ {
-+ if (kf->kf_type == KF_TYPE_VNODE &&
-+ kf->kf_vnode_type == KF_VTYPE_VREG)
-+ return __execve (kf->kf_path, argv, envp);
-+ break;
-+ }
-+ kf_bufp += kf->kf_structsize;
-+ }
-+
-+ __set_errno (EINVAL);
-+ return -1;
-+#endif
-+}
---- /dev/null
+++ b/ports/sysdeps/unix/bsd/bsd4.4/kfreebsd/fhstat.c
@@ -0,0 +1,40 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
@@ -7636,67 +7154,12 @@
+
+weak_alias (__fstatvfs64, fstatvfs64)
--- /dev/null
-+++ b/ports/sysdeps/unix/bsd/bsd4.4/kfreebsd/ftruncate.c
-@@ -0,0 +1,52 @@
-+/* Copyright (C) 2002 Free Software Foundation, Inc.
-+ This file is part of the GNU C Library.
-+ Contributed by Bruno Haible <bruno@clisp.org>, 2002.
-+
-+ 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 <unistd.h>
-+#include <sys/types.h>
-+#include <sysdep.h>
-+#include <errno.h>
-+
-+extern int __syscall_ftruncate (int __fd, __off_t __length) __THROW;
-+libc_hidden_proto (__syscall_ftruncate)
-+extern int __syscall_freebsd6_ftruncate (int __fd, int __unused1,
-+ __off_t __length) __THROW;
-+libc_hidden_proto (__syscall_freebsd6_ftruncate)
-+
-+int
-+__ftruncate (int fd, __off_t length)
-+{
-+ int result;
-+
-+ /* First try the new syscall. */
-+ result = INLINE_SYSCALL (ftruncate, 2, fd, length);
-+
-+#ifndef __ASSUME_TRUNCATE_SYSCALL
-+ if (result == -1 && errno == ENOSYS)
-+ /* New syscall not available, us the old one. */
-+ result = INLINE_SYSCALL (freebsd6_ftruncate, 3, fd, 0, length);
-+#endif
-+
-+ return result;
-+}
-+
-+weak_alias (__ftruncate, ftruncate)
-+
-+/* 'ftruncate64' is the same as 'ftruncate', because __off64_t == __off_t. */
-+strong_alias (__ftruncate, __ftruncate64)
-+weak_alias (__ftruncate64, ftruncate64)
---- /dev/null
+++ b/ports/sysdeps/unix/bsd/bsd4.4/kfreebsd/ftruncate64.c
@@ -0,0 +1 @@
+/* 'ftruncate64' is the same as 'ftruncate', because __off64_t == __off_t. */
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/bsd4.4/kfreebsd/futimesat.c
-@@ -0,0 +1,138 @@
+@@ -0,0 +1,48 @@
+/* Copyright (C) 2009 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
@@ -7740,100 +7203,10 @@
+ const char *file;
+ const struct timeval tvp[2];
+{
-+# ifndef __ASSUME_ATFCTS
-+ if (__have_atfcts >= 0)
-+# endif
-+ {
-+ int result;
-+
+ if (file == NULL)
+ return __futimes (fd, tvp);
+
-+ result = INLINE_SYSCALL (futimesat, 3, fd, file, tvp);
-+# ifndef __ASSUME_ATFCTS
-+ if (result == -1 && errno == ENOSYS)
-+ __have_atfcts = -1;
-+ else
-+# endif
-+ return result;
-+ }
-+
-+#ifndef __ASSUME_ATFCTS
-+ if ((file == NULL) || (fd != AT_FDCWD && file[0] != '/'))
-+ {
-+ int mib[4];
-+ size_t kf_len = 0;
-+ char *kf_buf, *kf_bufp;
-+ size_t filelen;
-+
-+ if (fd < 0)
-+ {
-+ __set_errno (EBADF);
-+ return -1;
-+ }
-+
-+ filelen = strlen (file);
-+ if (__builtin_expect (filelen == 0, 0))
-+ {
-+ __set_errno (ENOENT);
-+ return -1;
-+ }
-+
-+ mib[0] = CTL_KERN;
-+ mib[1] = KERN_PROC;
-+ mib[2] = KERN_PROC_FILEDESC;
-+ mib[3] = __getpid ();
-+
-+ if (__sysctl (mib, 4, NULL, &kf_len, NULL, 0) != 0)
-+ {
-+ __set_errno (ENOSYS);
-+ return -1;
-+ }
-+
-+ if (file == NULL)
-+ kf_buf = alloca (kf_len);
-+ else
-+ kf_buf = alloca (kf_len + filelen);
-+
-+ if (__sysctl (mib, 4, kf_buf, &kf_len, NULL, 0) != 0)
-+ {
-+ __set_errno (ENOSYS);
-+ return -1;
-+ }
-+
-+ kf_bufp = kf_buf;
-+ while (kf_bufp < kf_buf + kf_len)
-+ {
-+ struct kinfo_file *kf = (struct kinfo_file *) (uintptr_t) kf_bufp;
-+
-+ if (kf->kf_fd == fd)
-+ {
-+ if (kf->kf_type != KF_TYPE_VNODE ||
-+ kf->kf_vnode_type != KF_VTYPE_VDIR)
-+ {
-+ __set_errno (ENOTDIR);
-+ return -1;
-+ }
-+ if (file != NULL)
-+ {
-+ strcat (kf->kf_path, "/");
-+ strcat (kf->kf_path, file);
-+ }
-+ file = kf->kf_path;
-+ break;
-+ }
-+ kf_bufp += kf->kf_structsize;
-+ }
-+
-+ if (kf_bufp >= kf_buf + kf_len)
-+ {
-+ __set_errno (EBADF);
-+ return -1;
-+ }
-+ }
-+
-+ return __utimes(file, tvp);
-+#endif
++ return INLINE_SYSCALL (futimesat, 3, fd, file, tvp);
+}
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/bsd4.4/kfreebsd/fxstat.c
@@ -7935,7 +7308,7 @@
+hidden_def (__fxstat64)
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/bsd4.4/kfreebsd/fxstatat.c
-@@ -0,0 +1,158 @@
+@@ -0,0 +1,68 @@
+/* Copyright (C) 2009 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
@@ -7978,10 +7351,6 @@
+int
+__fxstatat (int vers, int fd, const char *file, struct stat *st, int flag)
+{
-+# ifndef __ASSUME_ATFCTS
-+ if (__have_atfcts >= 0)
-+# endif
-+ {
+ int result;
+
+ if (__builtin_expect (vers == _STAT_VER, 1))
@@ -8004,99 +7373,13 @@
+ __set_errno (EINVAL);
+ return -1;
+ }
-+# ifndef __ASSUME_ATFCTS
-+ if (result == -1 && errno == ENOSYS)
-+ __have_atfcts = -1;
-+ else
-+# endif
+ return result;
-+ }
-+
-+#ifndef __ASSUME_ATFCTS
-+ if (flag & ~AT_SYMLINK_NOFOLLOW)
-+ {
-+ __set_errno (EINVAL);
-+ return -1;
-+ }
-+
-+ if (fd != AT_FDCWD && file[0] != '/')
-+ {
-+ int mib[4];
-+ size_t kf_len = 0;
-+ char *kf_buf, *kf_bufp;
-+ size_t filelen;
-+
-+ if (fd < 0)
-+ {
-+ __set_errno (EBADF);
-+ return -1;
-+ }
-+
-+ filelen = strlen (file);
-+ if (__builtin_expect (filelen == 0, 0))
-+ {
-+ __set_errno (ENOENT);
-+ return -1;
-+ }
-+
-+ mib[0] = CTL_KERN;
-+ mib[1] = KERN_PROC;
-+ mib[2] = KERN_PROC_FILEDESC;
-+ mib[3] = __getpid ();
-+
-+ if (__sysctl (mib, 4, NULL, &kf_len, NULL, 0) != 0)
-+ {
-+ __set_errno (ENOSYS);
-+ return -1;
-+ }
-+
-+ kf_buf = alloca (kf_len + filelen);
-+ if (__sysctl (mib, 4, kf_buf, &kf_len, NULL, 0) != 0)
-+ {
-+ __set_errno (ENOSYS);
-+ return -1;
-+ }
-+
-+ kf_bufp = kf_buf;
-+ while (kf_bufp < kf_buf + kf_len)
-+ {
-+ struct kinfo_file *kf = (struct kinfo_file *) (uintptr_t) kf_bufp;
-+
-+ if (kf->kf_fd == fd)
-+ {
-+ if (kf->kf_type != KF_TYPE_VNODE ||
-+ kf->kf_vnode_type != KF_VTYPE_VDIR)
-+ {
-+ __set_errno (ENOTDIR);
-+ return -1;
-+ }
-+
-+ strcat (kf->kf_path, "/");
-+ strcat (kf->kf_path, file);
-+ file = kf->kf_path;
-+ break;
-+ }
-+ kf_bufp += kf->kf_structsize;
-+ }
-+
-+ if (kf_bufp >= kf_buf + kf_len)
-+ {
-+ __set_errno (EBADF);
-+ return -1;
-+ }
-+ }
-+
-+ if (flag & AT_SYMLINK_NOFOLLOW)
-+ return __lxstat (vers, file, st);
-+ else
-+ return __xstat (vers, file, st);
-+#endif
+}
+
+libc_hidden_def (__fxstatat)
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/bsd4.4/kfreebsd/fxstatat64.c
-@@ -0,0 +1,152 @@
+@@ -0,0 +1,62 @@
+/* Copyright (C) 2009 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
@@ -8139,10 +7422,6 @@
+int
+__fxstatat64 (int vers, int fd, const char *file, struct stat64 *st, int flag)
+{
-+# ifndef __ASSUME_ATFCTS
-+ if (__have_atfcts >= 0)
-+# endif
-+ {
+ int result;
+
+ if (__builtin_expect (vers == _STAT_VER, 1))
@@ -8159,99 +7438,13 @@
+ __set_errno (EINVAL);
+ return -1;
+ }
-+# ifndef __ASSUME_ATFCTS
-+ if (result == -1 && errno == ENOSYS)
-+ __have_atfcts = -1;
-+ else
-+# endif
+ return result;
-+ }
-+
-+#ifndef __ASSUME_ATFCTS
-+ if (flag & ~AT_SYMLINK_NOFOLLOW)
-+ {
-+ __set_errno (EINVAL);
-+ return -1;
-+ }
-+
-+ if (fd != AT_FDCWD && file[0] != '/')
-+ {
-+ int mib[4];
-+ size_t kf_len = 0;
-+ char *kf_buf, *kf_bufp;
-+ size_t filelen;
-+
-+ if (fd < 0)
-+ {
-+ __set_errno (EBADF);
-+ return -1;
-+ }
-+
-+ filelen = strlen (file);
-+ if (__builtin_expect (filelen == 0, 0))
-+ {
-+ __set_errno (ENOENT);
-+ return -1;
-+ }
-+
-+ mib[0] = CTL_KERN;
-+ mib[1] = KERN_PROC;
-+ mib[2] = KERN_PROC_FILEDESC;
-+ mib[3] = __getpid ();
-+
-+ if (__sysctl (mib, 4, NULL, &kf_len, NULL, 0) != 0)
-+ {
-+ __set_errno (ENOSYS);
-+ return -1;
-+ }
-+
-+ kf_buf = alloca (kf_len + filelen);
-+ if (__sysctl (mib, 4, kf_buf, &kf_len, NULL, 0) != 0)
-+ {
-+ __set_errno (ENOSYS);
-+ return -1;
-+ }
-+
-+ kf_bufp = kf_buf;
-+ while (kf_bufp < kf_buf + kf_len)
-+ {
-+ struct kinfo_file *kf = (struct kinfo_file *) (uintptr_t) kf_bufp;
-+
-+ if (kf->kf_fd == fd)
-+ {
-+ if (kf->kf_type != KF_TYPE_VNODE ||
-+ kf->kf_vnode_type != KF_VTYPE_VDIR)
-+ {
-+ __set_errno (ENOTDIR);
-+ return -1;
-+ }
-+
-+ strcat (kf->kf_path, "/");
-+ strcat (kf->kf_path, file);
-+ file = kf->kf_path;
-+ break;
-+ }
-+ kf_bufp += kf->kf_structsize;
-+ }
-+
-+ if (kf_bufp >= kf_buf + kf_len)
-+ {
-+ __set_errno (EBADF);
-+ return -1;
-+ }
-+ }
-+
-+ if (flag & AT_SYMLINK_NOFOLLOW)
-+ return __lxstat64 (vers, file, st);
-+ else
-+ return __xstat64 (vers, file, st);
-+#endif
+}
+
+libc_hidden_def (__fxstatat64)
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/bsd4.4/kfreebsd/getcwd.c
-@@ -0,0 +1,110 @@
+@@ -0,0 +1,104 @@
+/* Determine current working directory. FreeBSD version.
+ Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
@@ -8347,21 +7540,15 @@
+ memcpy (buf, tmpbuf, len);
+ return buf;
+ }
-+#ifdef IS_IN_rtld
-+ return NULL;
-+#else
+ return generic_getcwd (buf, size);
-+#endif
+}
+
+weak_alias (__getcwd, getcwd)
+
-+#ifndef IS_IN_rtld
+/* Get the code for the generic version. */
+#define GETCWD_RETURN_TYPE static char * internal_function
+#define __getcwd generic_getcwd
+#include <sysdeps/posix/getcwd.c>
-+#endif
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/bsd4.4/kfreebsd/getdents.c
@@ -0,0 +1,90 @@
@@ -9170,7 +8357,7 @@
+}
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/bsd4.4/kfreebsd/getosreldate.c
-@@ -0,0 +1,76 @@
+@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 1989, 1993
+ * The Regents of the University of California. All rights reserved.
@@ -9229,8 +8416,6 @@
+{
+ static int osreldate;
+
-+ int mib[2];
-+ size_t size;
+ char *temp;
+
+ if (osreldate == 0)
@@ -10811,6 +9996,62 @@
+
+weak_alias (__vfork, vfork)
--- /dev/null
++++ b/ports/sysdeps/unix/bsd/bsd4.4/kfreebsd/i386/lseek.S
+@@ -0,0 +1,53 @@
++/* Copyright (C) 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>
++
++/* lseek returns a 64-bit result in %eax, %edx. This means that in the
++ error case we have to set both %eax and %edx to -1. */
++
++PSEUDO_NOERRNO(__lseek, lseek, 3)
++ jnb L(no_error)
++ call SYSCALL_ERROR_LABEL;
++ orl $-1, %edx;
++L(pseudo_end):
++L(no_error):
++ ret
++PSEUDO_END(__lseek)
++libc_hidden_def (__lseek)
++
++strong_alias (__lseek, __libc_lseek)
++libc_hidden_def (__libc_lseek)
++
++strong_alias (__lseek, __libc_lseek64)
++libc_hidden_def (__libc_lseek64)
++
++strong_alias (__lseek, __lseek64)
++libc_hidden_def (__lseek64)
++
++strong_alias (__lseek, __llseek)
++libc_hidden_def (__llseek)
++
++weak_alias (__lseek, lseek)
++libc_hidden_weak (lseek)
++
++weak_alias (__lseek, lseek64)
++libc_hidden_weak (lseek64)
++
++weak_alias (__lseek, llseek)
++libc_hidden_weak (llseek)
+--- /dev/null
+++ b/ports/sysdeps/unix/bsd/bsd4.4/kfreebsd/i386/makecontext.S
@@ -0,0 +1,113 @@
+/* Create new context.
@@ -11616,76 +10857,6 @@
+PSEUDO_END (__syscall_fork)
+libc_hidden_def (__syscall_fork)
--- /dev/null
-+++ b/ports/sysdeps/unix/bsd/bsd4.4/kfreebsd/i386/sys_freebsd6_lseek.S
-@@ -0,0 +1,32 @@
-+/* Copyright (C) 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>
-+
-+/* lseek returns a 64-bit result in %eax, %edx. This means that in the
-+ error case we have to set both %eax and %edx to -1. */
-+
-+PSEUDO_NOERRNO(__syscall_freebsd6_lseek, freebsd6_lseek, 4)
-+ jnb L(no_error)
-+ call SYSCALL_ERROR_LABEL;
-+ orl $-1, %edx;
-+L(pseudo_end):
-+L(no_error):
-+ ret
-+PSEUDO_END(__syscall_freebsd6_lseek)
-+libc_hidden_def (__syscall_freebsd6_lseek)
---- /dev/null
-+++ b/ports/sysdeps/unix/bsd/bsd4.4/kfreebsd/i386/sys_lseek.S
-@@ -0,0 +1,32 @@
-+/* Copyright (C) 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>
-+
-+/* lseek returns a 64-bit result in %eax, %edx. This means that in the
-+ error case we have to set both %eax and %edx to -1. */
-+
-+PSEUDO_NOERRNO(__syscall_lseek, lseek, 3)
-+ jnb L(no_error)
-+ call SYSCALL_ERROR_LABEL;
-+ orl $-1, %edx;
-+L(pseudo_end):
-+L(no_error):
-+ ret
-+PSEUDO_END(__syscall_lseek)
-+libc_hidden_def (__syscall_lseek)
---- /dev/null
+++ b/ports/sysdeps/unix/bsd/bsd4.4/kfreebsd/i386/sysarch.h
@@ -0,0 +1,81 @@
+/* Parameters for the architecture specific system call. i386 version.
@@ -13234,7 +12405,7 @@
+#endif /* !_KENV_H */
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/bsd4.4/kfreebsd/kernel-features.h
-@@ -0,0 +1,92 @@
+@@ -0,0 +1,81 @@
+/* Set flags signalling availability of kernel features based on given
+ kernel version number.
+ Copyright (C) 2002 Free Software Foundation, Inc.
@@ -13290,43 +12461,32 @@
+*/
+
+/* Real-time signals introduced in FreeBSD 7.x. */
-+#if __KFREEBSD_KERNEL_VERSION >= 0x70032
+# define __ASSUME_REALTIME_SIGNALS 1
-+#endif
+
+/* Use signals #32, #33, #34 for internal linuxthreads communication */
+#define PTHREAD_SIGBASE 32
+
+/* The `ftruncate' syscall was introduced in kFreeBSD 7.0. */
-+#if __KFREEBSD_KERNEL_VERSION >= 0x70032
+# define __ASSUME_TRUNCATE_SYSCALL 1
-+#endif
+
+/* The `lseek' syscall was introduced in kFreeBSD 7.0. */
-+#if __KFREEBSD_KERNEL_VERSION >= 0x70032
+# define __ASSUME_LSEEK_SYSCALL 1
-+#endif
+
+/* The `mmap' syscall was introduced in kFreeBSD 7.0. */
-+#if __KFREEBSD_KERNEL_VERSION >= 0x70032
+# define __ASSUME_MMAP_SYSCALL 1
-+#endif
+
+/* The `pread' and `pwrite' syscalls were introduced in kFreeBSD 7.0. */
-+#if __KFREEBSD_KERNEL_VERSION >= 0x70032
+# define __ASSUME_PREAD_PWRITE_SYSCALLS 1
-+#endif
+
+/* The `shm_*' syscalls were introduced in kFreeBSD 8.0 */
-+#if __KFREEBSD_KERNEL_VERSION >= 0x8000C
+# define __ASSUME_SHMFCTS 1
-+#endif
+
+/* The `*at' syscalls were introduced in kFreeBSD 8.0. */
-+#if __KFREEBSD_KERNEL_VERSION >= 0x8001D
+# define __ASSUME_ATFCTS 1
-+#endif
+
++/* The pselect syscall was introduced in kFreeBSD 8.1. */
++# define __ASSUME_PSELECT 1
++
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/bsd4.4/kfreebsd/kernel-posix-cpu-timers.h
@@ -0,0 +1,5 @@
@@ -13397,190 +12557,6 @@
+
+#endif /* ldsodefs.h */
--- /dev/null
-+++ b/ports/sysdeps/unix/bsd/bsd4.4/kfreebsd/linkat.c
-@@ -0,0 +1,181 @@
-+/* Copyright (C) 2009 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 <errno.h>
-+#include <fcntl.h>
-+#include <stddef.h>
-+#include <stdio.h>
-+#include <stdint.h>
-+#include <stdlib.h>
-+#include <string.h>
-+#include <sysdep.h>
-+#include <stdio.h>
-+#include <sys/sysctl.h>
-+#include <sys/user.h>
-+#include <kernel-features.h>
-+
-+extern int __syscall_linkat (int fd1, const char *path1, int fd2,
-+ const char *path2, int flags);
-+libc_hidden_proto (__syscall_linkat)
-+
-+/* Make a link to FROM named TO but relative paths in TO and FROM are
-+ interpreted relative to FROMFD and TOFD respectively. */
-+int
-+linkat (fromfd, from, tofd, to, flags)
-+ int fromfd;
-+ const char *from;
-+ int tofd;
-+ const char *to;
-+ int flags;
-+{
-+# ifndef __ASSUME_ATFCTS
-+ if (__have_atfcts >= 0)
-+# endif
-+ {
-+ int result = INLINE_SYSCALL (linkat, 5, fromfd, from, tofd, to, flags);
-+# ifndef __ASSUME_ATFCTS
-+ if (result == -1 && errno == ENOSYS)
-+ __have_atfcts = -1;
-+ else
-+# endif
-+ return result;
-+ }
-+
-+#ifndef __ASSUME_ATFCTS
-+ /* Without kernel support we cannot handle AT_SYMLINK_FOLLOW. */
-+ if (flags != 0)
-+ {
-+ __set_errno (EINVAL);
-+ return -1;
-+ }
-+
-+ if ((fromfd != AT_FDCWD && from[0] != '/')
-+ || (tofd != AT_FDCWD && to[0] != '/'))
-+ {
-+ int mib[4];
-+ size_t kf_len = 0;
-+ char *kf_buf, *kf_bufp;
-+ size_t fromlen, tolen;
-+
-+ if ((fromfd < 0) || (tofd < 0))
-+ {
-+ __set_errno (EBADF);
-+ return -1;
-+ }
-+
-+ fromlen = strlen (from);
-+ tolen = strlen (to);
-+ if (__builtin_expect (fromlen == 0, 0)
-+ || __builtin_expect (tolen == 0, 0))
-+ {
-+ __set_errno (ENOENT);
-+ return -1;
-+ }
-+
-+ mib[0] = CTL_KERN;
-+ mib[1] = KERN_PROC;
-+ mib[2] = KERN_PROC_FILEDESC;
-+ mib[3] = __getpid ();
-+
-+ if (__sysctl (mib, 4, NULL, &kf_len, NULL, 0) != 0)
-+ {
-+ __set_errno (ENOSYS);
-+ return -1;
-+ }
-+
-+ kf_buf = alloca (kf_len);
-+ if (__sysctl (mib, 4, kf_buf, &kf_len, NULL, 0) != 0)
-+ {
-+ __set_errno (ENOSYS);
-+ return -1;
-+ }
-+
-+ if (fromfd != AT_FDCWD && from[0] != '/')
-+ {
-+ kf_bufp = kf_buf;
-+ while (kf_bufp < kf_buf + kf_len)
-+ {
-+ struct kinfo_file *kf =
-+ (struct kinfo_file *) (uintptr_t) kf_bufp;
-+
-+ if (kf->kf_fd == fromfd)
-+ {
-+ char *buf;
-+ if (kf->kf_type != KF_TYPE_VNODE ||
-+ kf->kf_vnode_type != KF_VTYPE_VDIR)
-+ {
-+ __set_errno (ENOTDIR);
-+ return -1;
-+ }
-+
-+ buf = alloca (strlen (kf->kf_path) + fromlen + 2);
-+ strcpy(buf, kf->kf_path);
-+ strcat (buf, "/");
-+ strcat (buf, from);
-+ from = buf;
-+ break;
-+ }
-+ kf_bufp += kf->kf_structsize;
-+ }
-+
-+ if (kf_bufp >= kf_buf + kf_len)
-+ {
-+ __set_errno (EBADF);
-+ return -1;
-+ }
-+ }
-+
-+ if (tofd != AT_FDCWD && to[0] != '/')
-+ {
-+ kf_bufp = kf_buf;
-+ while (kf_bufp < kf_buf + kf_len)
-+ {
-+ struct kinfo_file *kf =
-+ (struct kinfo_file *) (uintptr_t) kf_bufp;
-+
-+ if (kf->kf_fd == tofd)
-+ {
-+ char *buf;
-+ if (kf->kf_type != KF_TYPE_VNODE ||
-+ kf->kf_vnode_type != KF_VTYPE_VDIR)
-+ {
-+ __set_errno (ENOTDIR);
-+ return -1;
-+ }
-+
-+ buf = alloca (strlen (kf->kf_path) + tolen + 2);
-+ strcpy(buf, kf->kf_path);
-+ strcat (buf, "/");
-+ strcat (buf, to);
-+ to = buf;
-+ break;
-+ }
-+ kf_bufp += kf->kf_structsize;
-+ }
-+
-+ if (kf_bufp >= kf_buf + kf_len)
-+ {
-+ __set_errno (EBADF);
-+ return -1;
-+ }
-+ }
-+ }
-+
-+ return __link (from, to);
-+#endif
-+}
---- /dev/null
+++ b/ports/sysdeps/unix/bsd/bsd4.4/kfreebsd/linuxthreads/Implies
@@ -0,0 +1 @@
+pthread
@@ -15196,68 +14172,6 @@
+link_warning (llseek, "\
+the `llseek' function may be dangerous; use `lseek64' instead.")
--- /dev/null
-+++ b/ports/sysdeps/unix/bsd/bsd4.4/kfreebsd/lseek.c
-@@ -0,0 +1,59 @@
-+/* Copyright (C) 2002 Free Software Foundation, Inc.
-+ This file is part of the GNU C Library.
-+ Contributed by Bruno Haible <bruno@clisp.org>, 2002.
-+
-+ 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 <unistd.h>
-+#include <sys/types.h>
-+#include <sysdep.h>
-+#include <errno.h>
-+
-+extern __off_t __syscall_lseek (int __fd, __off_t __offset, int __whence) __THROW;
-+libc_hidden_proto (__syscall_lseek)
-+extern __off_t __syscall_freebsd6_lseek (int __fd, int __unused1, __off_t __offset,
-+ int __whence) __THROW;
-+libc_hidden_proto (__syscall_freebsd6_lseek)
-+
-+__off_t
-+__libc_lseek (int fd, __off_t offset, int whence)
-+{
-+ __off_t result;
-+
-+ /* First try the new syscall. */
-+ result = INLINE_SYSCALL (lseek, 3, fd, offset, whence);
-+
-+#ifndef __ASSUME_LSEEK_SYSCALL
-+ if (result == -1 && errno == ENOSYS)
-+ /* New syscall not available, us the old one. */
-+ result = INLINE_SYSCALL (freebsd6_lseek, 4, fd, 0, offset, whence);
-+#endif
-+
-+ return result;
-+}
-+
-+weak_alias (__libc_lseek, __lseek)
-+libc_hidden_def (__lseek)
-+weak_alias (__libc_lseek, lseek)
-+
-+/* 'lseek64' is the same as 'lseek', because __off64_t == __off_t. */
-+strong_alias (__libc_lseek, __libc_lseek64)
-+weak_alias (__libc_lseek64, __lseek64)
-+weak_alias (__lseek64, lseek64)
-+
-+/* 'llseek' is the same as 'lseek', because __off64_t == __off_t. */
-+strong_alias (__libc_lseek, __llseek)
-+weak_alias (__llseek, llseek)
---- /dev/null
+++ b/ports/sysdeps/unix/bsd/bsd4.4/kfreebsd/lseek64.c
@@ -0,0 +1 @@
+/* 'lseek64' is the same as 'lseek', because __off64_t == __off_t. */
@@ -16449,137 +15363,8 @@
+/* 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.
-+ 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 file the Free
-+ Software Foundation, Inc., 59 Temple Place, Suite 330, Bosfilen, MA
-+ 02111-1307 USA. */
-+
-+#include <errno.h>
-+#include <fcntl.h>
-+#include <stddef.h>
-+#include <stdio.h>
-+#include <stdint.h>
-+#include <stdlib.h>
-+#include <string.h>
-+#include <sysdep.h>
-+#include <sys/stat.h>
-+#include <sys/sysctl.h>
-+#include <sys/user.h>
-+#include <kernel-features.h>
-+
-+extern int __syscall_mkdirat (int fd, const char *path, mode_t mode);
-+libc_hidden_proto (__syscall_mkdirat)
-+
-+/* Create a new direcfilery with permission bits MODE. But interpret
-+ relative PATH names relative file the direcfilery associated with FD. */
-+int
-+mkdirat (fd, file, mode)
-+ int fd;
-+ const char *file;
-+ mode_t mode;
-+{
-+# ifndef __ASSUME_ATFCTS
-+ if (__have_atfcts >= 0)
-+# endif
-+ {
-+ int result = INLINE_SYSCALL (mkdirat, 3, fd, file, mode);
-+# ifndef __ASSUME_ATFCTS
-+ if (result == -1 && errno == ENOSYS)
-+ __have_atfcts = -1;
-+ else
-+# endif
-+ return result;
-+ }
-+
-+#ifndef __ASSUME_ATFCTS
-+ if (fd != AT_FDCWD && file[0] != '/')
-+ {
-+ int mib[4];
-+ size_t kf_len = 0;
-+ char *kf_buf, *kf_bufp;
-+ size_t filelen;
-+
-+ if (fd < 0)
-+ {
-+ __set_errno (EBADF);
-+ return -1;
-+ }
-+
-+ filelen = strlen (file);
-+ if (__builtin_expect (filelen == 0, 0))
-+ {
-+ __set_errno (ENOENT);
-+ return -1;
-+ }
-+
-+ mib[0] = CTL_KERN;
-+ mib[1] = KERN_PROC;
-+ mib[2] = KERN_PROC_FILEDESC;
-+ mib[3] = __getpid ();
-+
-+ if (__sysctl (mib, 4, NULL, &kf_len, NULL, 0) != 0)
-+ {
-+ __set_errno (ENOSYS);
-+ return -1;
-+ }
-+
-+ kf_buf = alloca (kf_len + filelen);
-+ if (__sysctl (mib, 4, kf_buf, &kf_len, NULL, 0) != 0)
-+ {
-+ __set_errno (ENOSYS);
-+ return -1;
-+ }
-+
-+ kf_bufp = kf_buf;
-+ while (kf_bufp < kf_buf + kf_len)
-+ {
-+ struct kinfo_file *kf = (struct kinfo_file *) (uintptr_t) kf_bufp;
-+
-+ if (kf->kf_fd == fd)
-+ {
-+ if (kf->kf_type != KF_TYPE_VNODE ||
-+ kf->kf_vnode_type != KF_VTYPE_VDIR)
-+ {
-+ __set_errno (ENOTDIR);
-+ return -1;
-+ }
-+
-+ strcat (kf->kf_path, "/");
-+ strcat (kf->kf_path, file);
-+ file = kf->kf_path;
-+ break;
-+ }
-+ kf_bufp += kf->kf_structsize;
-+ }
-+
-+ if (kf_bufp >= kf_buf + kf_len)
-+ {
-+ __set_errno (EBADF);
-+ return -1;
-+ }
-+ }
-+
-+ return __mkdir (file, mode);
-+#endif
-+}
---- /dev/null
+++ b/ports/sysdeps/unix/bsd/bsd4.4/kfreebsd/mmap.c
-@@ -0,0 +1,86 @@
+@@ -0,0 +1,57 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Bruno Haible <bruno@clisp.org>, 2002.
@@ -16608,19 +15393,10 @@
+extern void *__syscall_mmap (void *__addr, size_t __len, int __prot,
+ int __flags, int __fd, __off_t __offset) __THROW;
+libc_hidden_proto (__syscall_mmap)
-+extern void *__syscall_freebsd6_mmap (void *__addr, size_t __len, int __prot,
-+ int __flags, int __fd, int __unused1,
-+ __off_t __offset) __THROW;
-+libc_hidden_proto (__syscall_freebsd6_mmap)
-+extern ssize_t __syscall_freebsd6_pread (int __fd, void *__buf, size_t __nbytes,
-+ int __unused1, __off_t __offset) __THROW;
-+libc_hidden_proto (__syscall_freebsd6_pread)
+
+void *
+__mmap (void *addr, size_t len, int prot, int flags, int fd, __off_t offset)
+{
-+ void *result;
-+
+ /* Validity checks not done by the kernel. */
+ if (offset != 0)
+ {
@@ -16638,27 +15414,7 @@
+ if (flags & MAP_ANON)
+ fd = -1;
+
-+ /* First try the new syscall. */
-+ result = (void *) INLINE_SYSCALL (mmap, 6, addr, len, prot, flags, fd, offset);
-+
-+#ifndef __ASSUME_MMAP_SYSCALL
-+ if (result == (void *) (-1) && errno == ENOSYS)
-+ {
-+ /* New syscall not available, use the old one. */
-+ result = (void *) INLINE_SYSCALL (freebsd6_mmap, 7, addr, len, prot, flags, fd, 0, offset);
-+ if (result != (void *) (-1) && fd >= 0 && len > 0)
-+ {
-+ /* Force an update of the atime. POSIX:2001 mandates that this happens
-+ at some time between the mmap() call and the first page-in. Since
-+ the FreeBSD 6.0 kernel doesn't update the atime upon a page-in, we
-+ do it here. */
-+ char dummy;
-+ INLINE_SYSCALL (freebsd6_pread, 5, fd, &dummy, 1, 0, offset);
-+ }
-+ }
-+#endif
-+
-+ return result;
++ return INLINE_SYSCALL (mmap, 6, addr, len, prot, flags, fd, offset);
+}
+
+weak_alias (__mmap, mmap)
@@ -20036,7 +18792,7 @@
+strong_alias (__open_2, __open64_2)
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/bsd4.4/kfreebsd/openat.c
-@@ -0,0 +1,189 @@
+@@ -0,0 +1,88 @@
+/* Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
@@ -20073,111 +18829,10 @@
+extern int __syscall_openat (int fd, const char *path, int flag, mode_t mode);
+libc_hidden_proto (__syscall_openat)
+
-+# ifndef __ASSUME_ATFCTS
-+int __have_atfcts = 0;
-+#endif
-+
+/* Open FILE with access OFLAG. Interpret relative paths relative to
+ the directory associated with FD. If OFLAG includes O_CREAT, a
+ third argument is the file protection. */
+int
-+__openat_nocancel (fd, file, oflag, mode)
-+ int fd;
-+ const char *file;
-+ int oflag;
-+ mode_t mode;
-+{
-+# ifndef __ASSUME_ATFCTS
-+ if (__have_atfcts >= 0)
-+# endif
-+ {
-+ int result = INLINE_SYSCALL (openat, 4, fd, file, oflag, mode);
-+# ifndef __ASSUME_ATFCTS
-+ if (result == -1 && errno == ENOSYS)
-+ __have_atfcts = -1;
-+ else
-+# endif
-+ return result;
-+ }
-+
-+#ifndef __ASSUME_ATFCTS
-+ if (fd != AT_FDCWD && file[0] != '/')
-+ {
-+ int mib[4];
-+ size_t kf_len = 0;
-+ char *kf_buf, *kf_bufp;
-+ size_t filelen;
-+
-+ if (fd < 0)
-+ {
-+ __set_errno (EBADF);
-+ return -1;
-+ }
-+
-+ filelen = strlen (file);
-+ if (__builtin_expect (filelen == 0, 0))
-+ {
-+ __set_errno (ENOENT);
-+ return -1;
-+ }
-+
-+ mib[0] = CTL_KERN;
-+ mib[1] = KERN_PROC;
-+ mib[2] = KERN_PROC_FILEDESC;
-+ mib[3] = __getpid ();
-+
-+ if (__sysctl (mib, 4, NULL, &kf_len, NULL, 0) != 0)
-+ {
-+ __set_errno (ENOSYS);
-+ return -1;
-+ }
-+
-+ kf_buf = alloca (kf_len + filelen);
-+ if (__sysctl (mib, 4, kf_buf, &kf_len, NULL, 0) != 0)
-+ {
-+ __set_errno (ENOSYS);
-+ return -1;
-+ }
-+
-+ kf_bufp = kf_buf;
-+ while (kf_bufp < kf_buf + kf_len)
-+ {
-+ struct kinfo_file *kf = (struct kinfo_file *) (uintptr_t) kf_bufp;
-+
-+ if (kf->kf_fd == fd)
-+ {
-+ if (kf->kf_type != KF_TYPE_VNODE ||
-+ kf->kf_vnode_type != KF_VTYPE_VDIR)
-+ {
-+ __set_errno (ENOTDIR);
-+ return -1;
-+ }
-+
-+ strcat (kf->kf_path, "/");
-+ strcat (kf->kf_path, file);
-+ file = kf->kf_path;
-+ break;
-+ }
-+ kf_bufp += kf->kf_structsize;
-+ }
-+
-+ if (kf_bufp >= kf_buf + kf_len)
-+ {
-+ __set_errno (EBADF);
-+ return -1;
-+ }
-+
-+ }
-+ return INLINE_SYSCALL (open, 3, file, oflag, mode);
-+#endif
-+}
-+
-+strong_alias (__openat_nocancel, __openat64_nocancel)
-+
-+/* Open FILE with access OFLAG. Interpret relative paths relative to
-+ the directory associated with FD. If OFLAG includes O_CREAT, a
-+ third argument is the file protection. */
-+int
+__openat (fd, file, oflag)
+ int fd;
+ const char *file;
@@ -20195,11 +18850,11 @@
+ }
+
+ if (SINGLE_THREAD_P)
-+ return __openat_nocancel(fd, file, oflag, mode);
++ return INLINE_SYSCALL (openat, 4, fd, file, oflag, mode);
+ else
+ {
+ int oldtype = LIBC_CANCEL_ASYNC ();
-+ result = __openat_nocancel(fd, file, oflag, mode);
++ result = INLINE_SYSCALL (openat, 4, fd, file, oflag, mode);
+ LIBC_CANCEL_RESET (oldtype);
+ }
+ return result;
@@ -20351,78 +19006,6 @@
+
+#endif /* elf.h */
--- /dev/null
-+++ b/ports/sysdeps/unix/bsd/bsd4.4/kfreebsd/pread.c
-@@ -0,0 +1,69 @@
-+/* Copyright (C) 2002 Free Software Foundation, Inc.
-+ This file is part of the GNU C Library.
-+ Contributed by Bruno Haible <bruno@clisp.org>, 2002.
-+
-+ 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 <unistd.h>
-+#include <sys/types.h>
-+#include <sysdep.h>
-+#include <sysdep-cancel.h>
-+#include <errno.h>
-+
-+extern ssize_t __syscall_pread (int __fd, void *__buf, size_t __nbytes,
-+ __off_t __offset) __THROW;
-+libc_hidden_proto(__syscall_pread)
-+extern ssize_t __syscall_freebsd6_pread (int __fd, void *__buf, size_t __nbytes,
-+ int __unused1, __off_t __offset) __THROW;
-+libc_hidden_proto(__syscall_freebsd6_pread)
-+
-+ssize_t
-+__libc_pread (int fd, void *buf, size_t nbytes, __off_t offset)
-+{
-+ ssize_t result;
-+
-+ if (SINGLE_THREAD_P)
-+ {
-+
-+ /* First try the new syscall. */
-+ result = INLINE_SYSCALL (pread, 4, fd, buf, nbytes, offset);
-+#ifndef __ASSUME_PREAD_PWRITE_SYSCALLS
-+ if (result == -1 && errno == ENOSYS)
-+ /* New syscall not available, us the old one. */
-+ result = INLINE_SYSCALL (freebsd6_pread, 5, fd, buf, nbytes, 0, offset);
-+#endif
-+ return result;
-+ }
-+
-+ int oldtype = LIBC_CANCEL_ASYNC ();
-+ /* First try the new syscall. */
-+ result = INLINE_SYSCALL (pread, 4, fd, buf, nbytes, offset);
-+#ifndef __ASSUME_PREAD_PWRITE_SYSCALLS
-+ if (result == -1 && errno == ENOSYS)
-+ /* New syscall not available, us the old one. */
-+ result = INLINE_SYSCALL (freebsd6_pread, 5, fd, buf, nbytes, 0, offset);
-+#endif
-+ LIBC_CANCEL_RESET (oldtype);
-+ return result;
-+}
-+
-+strong_alias (__libc_pread, __pread)
-+weak_alias (__pread, pread)
-+
-+/* 'pread64' is the same as 'pread', because __off64_t == __off_t. */
-+strong_alias (__libc_pread, __libc_pread64)
-+weak_alias (__libc_pread64, __pread64)
-+weak_alias (__libc_pread64, pread64)
---- /dev/null
+++ b/ports/sysdeps/unix/bsd/bsd4.4/kfreebsd/pread64.c
@@ -0,0 +1 @@
+/* 'pread64' is the same as 'pread', because __off64_t == __off_t. */
@@ -20481,81 +19064,6 @@
+}
+libc_hidden_def (__profile_frequency)
--- /dev/null
-+++ b/ports/sysdeps/unix/bsd/bsd4.4/kfreebsd/pselect.c
-@@ -0,0 +1,72 @@
-+/* Copyright (C) 2006, 2007, 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. */
-+
-+#include <errno.h>
-+#include <signal.h>
-+#include <time.h>
-+#include <sys/poll.h>
-+#include <kernel-features.h>
-+#include <sysdep-cancel.h>
-+
-+
-+#ifndef __ASSUME_PSELECT
-+static int __generic_pselect (int nfds, fd_set *readfds, fd_set *writefds,
-+ fd_set *exceptfds,
-+ const struct timespec *timeout,
-+ const sigset_t *sigmask);
-+#endif
-+
-+extern int __syscall_pselect (int nfds, fd_set *readfds, fd_set *writefds,
-+ fd_set *exceptfds,
-+ const struct timespec *timeout,
-+ const sigset_t *sigmask) __THROW;
-+
-+int
-+__pselect (int nfds, fd_set *readfds, fd_set *writefds,
-+ fd_set *exceptfds,
-+ const struct timespec *timeout,
-+ const sigset_t *sigmask)
-+{
-+ int result;
-+
-+ if (SINGLE_THREAD_P)
-+ result = INLINE_SYSCALL (pselect, 6, nfds, readfds, writefds, exceptfds,
-+ timeout, sigmask);
-+ else
-+ {
-+ int oldtype = LIBC_CANCEL_ASYNC ();
-+ result = INLINE_SYSCALL (pselect, 6, nfds, readfds, writefds, exceptfds,
-+ timeout, sigmask);
-+ LIBC_CANCEL_RESET (oldtype);
-+ }
-+
-+#ifndef __ASSUME_PSELECT
-+ if (result == -1 && errno == ENOSYS)
-+ return __generic_pselect (nfds, readfds, writefds, exceptfds,
-+ timeout, sigmask);
-+#endif
-+
-+ return result;
-+}
-+weak_alias (__pselect, pselect)
-+strong_alias (__pselect, __libc_pselect)
-+
-+#ifndef __ASSUME_PSELECT
-+# define __pselect static __generic_pselect
-+# include <misc/pselect.c>
-+#endif
---- /dev/null
+++ b/ports/sysdeps/unix/bsd/bsd4.4/kfreebsd/ptsname.c
@@ -0,0 +1,111 @@
+/* Copyright (C) 1998, 2002 Free Software Foundation, Inc.
@@ -20670,77 +19178,6 @@
+}
+weak_alias (__ptsname_r, ptsname_r)
--- /dev/null
-+++ b/ports/sysdeps/unix/bsd/bsd4.4/kfreebsd/pwrite.c
-@@ -0,0 +1,68 @@
-+/* Copyright (C) 2002 Free Software Foundation, Inc.
-+ This file is part of the GNU C Library.
-+ Contributed by Bruno Haible <bruno@clisp.org>, 2002.
-+
-+ 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 <unistd.h>
-+#include <sys/types.h>
-+#include <sysdep.h>
-+#include <sysdep-cancel.h>
-+#include <errno.h>
-+
-+extern ssize_t __syscall_pwrite (int __fd, const void *__buf, size_t __nbytes,
-+ __off_t __offset) __THROW;
-+libc_hidden_proto(__syscall_pwrite)
-+extern ssize_t __syscall_freebsd6_pwrite (int __fd, const void *__buf, size_t __nbytes,
-+ int __unused1, __off_t __offset) __THROW;
-+libc_hidden_proto(__syscall_freebsd6_pwrite)
-+
-+ssize_t
-+__libc_pwrite (int fd, const void *buf, size_t nbytes, __off_t offset)
-+{
-+ ssize_t result;
-+
-+ if (SINGLE_THREAD_P)
-+ {
-+ /* First try the new syscall. */
-+ result = INLINE_SYSCALL (pwrite, 4, fd, buf, nbytes, offset);
-+#ifndef __ASSUME_PREAD_PWRITE_SYSCALLS
-+ if (result == -1 && errno == ENOSYS)
-+ /* New syscall not available, us the old one. */
-+ result = INLINE_SYSCALL (freebsd6_pwrite, 5, fd, buf, nbytes, 0, offset);
-+#endif
-+ return result;
-+ }
-+
-+ int oldtype = LIBC_CANCEL_ASYNC ();
-+ /* First try the new syscall. */
-+ result = INLINE_SYSCALL (pwrite, 4, fd, buf, nbytes, offset);
-+#ifndef __ASSUME_PREAD_PWRITE_SYSCALLS
-+ if (result == -1 && errno == ENOSYS)
-+ /* New syscall not available, us the old one. */
-+ result = INLINE_SYSCALL (freebsd6_pwrite, 5, fd, buf, nbytes, 0, offset);
-+#endif
-+ LIBC_CANCEL_RESET (oldtype);
-+ return result;
-+}
-+
-+strong_alias (__libc_pwrite, __pwrite)
-+weak_alias (__pwrite, pwrite)
-+
-+/* 'pwrite64' is the same as 'pwrite', because __off64_t == __off_t. */
-+strong_alias (__libc_pwrite, __libc_pwrite64)
-+weak_alias (__libc_pwrite64, __pwrite64)
-+weak_alias (__libc_pwrite64, pwrite64)
---- /dev/null
+++ b/ports/sysdeps/unix/bsd/bsd4.4/kfreebsd/pwrite64.c
@@ -0,0 +1 @@
+/* 'pwrite64' is the same as 'pwrite', because __off64_t == __off_t. */
@@ -20787,139 +19224,6 @@
+strong_alias (__readdir_r, __readdir64_r)
+weak_alias (__readdir64_r, readdir64_r)
--- /dev/null
-+++ b/ports/sysdeps/unix/bsd/bsd4.4/kfreebsd/readlinkat.c
-@@ -0,0 +1,130 @@
-+/* Copyright (C) 2009 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 <errno.h>
-+#include <fcntl.h>
-+#include <stddef.h>
-+#include <stdio.h>
-+#include <stdint.h>
-+#include <stdlib.h>
-+#include <string.h>
-+#include <sysdep.h>
-+#include <unistd.h>
-+#include <sys/sysctl.h>
-+#include <sys/user.h>
-+#include <kernel-features.h>
-+
-+extern int __syscall_readlinkat (int fd, const char *path, char *buf,
-+ size_t bufsize);
-+libc_hidden_proto (__syscall_readlinkat)
-+
-+/* Read the contents of the symbolic link PATH relative to FD into no
-+ more than LEN bytes of BUF. */
-+ssize_t
-+readlinkat (fd, path, buf, len)
-+ int fd;
-+ const char *path;
-+ char *buf;
-+ size_t len;
-+{
-+# ifndef __ASSUME_ATFCTS
-+ if (__have_atfcts >= 0)
-+# endif
-+ {
-+ int result = INLINE_SYSCALL (readlinkat, 4, fd, path, buf, len);
-+# ifndef __ASSUME_ATFCTS
-+ if (result == -1 && errno == ENOSYS)
-+ __have_atfcts = -1;
-+ else
-+# endif
-+ return result;
-+ }
-+
-+#ifndef __ASSUME_ATFCTS
-+ if (fd != AT_FDCWD && path[0] != '/')
-+ {
-+ int mib[4];
-+ size_t kf_len = 0;
-+ char *kf_buf, *kf_bufp;
-+ size_t pathlen;
-+
-+ if (fd < 0)
-+ {
-+ __set_errno (EBADF);
-+ return -1;
-+ }
-+
-+ pathlen = strlen (path);
-+ if (__builtin_expect (pathlen == 0, 0))
-+ {
-+ __set_errno (ENOENT);
-+ return -1;
-+ }
-+
-+ mib[0] = CTL_KERN;
-+ mib[1] = KERN_PROC;
-+ mib[2] = KERN_PROC_FILEDESC;
-+ mib[3] = __getpid ();
-+
-+ if (__sysctl (mib, 4, NULL, &kf_len, NULL, 0) != 0)
-+ {
-+ __set_errno (ENOSYS);
-+ return -1;
-+ }
-+
-+ kf_buf = alloca (kf_len + pathlen);
-+ if (__sysctl (mib, 4, kf_buf, &kf_len, NULL, 0) != 0)
-+ {
-+ __set_errno (ENOSYS);
-+ return -1;
-+ }
-+
-+ kf_bufp = kf_buf;
-+ while (kf_bufp < kf_buf + kf_len)
-+ {
-+ struct kinfo_file *kf = (struct kinfo_file *) (uintptr_t) kf_bufp;
-+
-+ if (kf->kf_fd == fd)
-+ {
-+ if (kf->kf_type != KF_TYPE_VNODE ||
-+ kf->kf_vnode_type != KF_VTYPE_VDIR)
-+ {
-+ __set_errno (ENOTDIR);
-+ return -1;
-+ }
-+
-+ strcat (kf->kf_path, "/");
-+ strcat (kf->kf_path, path);
-+ path = kf->kf_path;
-+ break;
-+ }
-+ kf_bufp += kf->kf_structsize;
-+ }
-+
-+ if (kf_bufp >= kf_buf + kf_len)
-+ {
-+ __set_errno (EBADF);
-+ return -1;
-+ }
-+ }
-+
-+ return __readlink (path, buf, len);
-+#endif
-+}
-+
-+libc_hidden_def (readlinkat)
---- /dev/null
+++ b/ports/sysdeps/unix/bsd/bsd4.4/kfreebsd/readonly-area.c
@@ -0,0 +1,96 @@
+/* Copyright (C) 2004, 2005, 2009 Free Software Foundation, Inc.
@@ -21166,183 +19470,6 @@
+}
+libc_hidden_def (remove)
--- /dev/null
-+++ b/ports/sysdeps/unix/bsd/bsd4.4/kfreebsd/renameat.c
-@@ -0,0 +1,174 @@
-+/* Copyright (C) 2009 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 <errno.h>
-+#include <fcntl.h>
-+#include <stddef.h>
-+#include <stdio.h>
-+#include <stdint.h>
-+#include <stdlib.h>
-+#include <string.h>
-+#include <sysdep.h>
-+#include <stdio.h>
-+#include <sys/sysctl.h>
-+#include <sys/user.h>
-+#include <kernel-features.h>
-+
-+libc_hidden_proto (rename)
-+
-+extern int __syscall_renameat (int oldfd, const char *old, int newfd,
-+ const char *new);
-+libc_hidden_proto (__syscall_renameat)
-+
-+/* Rename the file OLD relative to OLDFD to NEW relative to NEWFD. */
-+int renameat (oldfd, old, newfd, new)
-+ int oldfd;
-+ const char *old;
-+ int newfd;
-+ const char *new;
-+{
-+# ifndef __ASSUME_ATFCTS
-+ if (__have_atfcts >= 0)
-+# endif
-+ {
-+ int result = INLINE_SYSCALL (renameat, 4, oldfd, old, newfd, new);
-+# ifndef __ASSUME_ATFCTS
-+ if (result == -1 && errno == ENOSYS)
-+ __have_atfcts = -1;
-+ else
-+# endif
-+ return result;
-+ }
-+
-+#ifndef __ASSUME_ATFCTS
-+ if ((oldfd != AT_FDCWD && old[0] != '/')
-+ || (newfd != AT_FDCWD && new[0] != '/'))
-+ {
-+ int mib[4];
-+ size_t kf_len = 0;
-+ char *kf_buf, *kf_bufp;
-+ size_t old_filelen, new_filelen;
-+
-+ if ((oldfd < 0) || (newfd < 0))
-+ {
-+ __set_errno (EBADF);
-+ return -1;
-+ }
-+
-+ old_filelen = strlen (old);
-+ new_filelen = strlen (new);
-+ if (__builtin_expect (old_filelen == 0, 0)
-+ || __builtin_expect (new_filelen == 0, 0))
-+ {
-+ __set_errno (ENOENT);
-+ return -1;
-+ }
-+
-+ mib[0] = CTL_KERN;
-+ mib[1] = KERN_PROC;
-+ mib[2] = KERN_PROC_FILEDESC;
-+ mib[3] = __getpid ();
-+
-+ if (__sysctl (mib, 4, NULL, &kf_len, NULL, 0) != 0)
-+ {
-+ __set_errno (ENOSYS);
-+ return -1;
-+ }
-+
-+ kf_buf = alloca (kf_len);
-+ if (__sysctl (mib, 4, kf_buf, &kf_len, NULL, 0) != 0)
-+ {
-+ __set_errno (ENOSYS);
-+ return -1;
-+ }
-+
-+ if (oldfd != AT_FDCWD && old[0] != '/')
-+ {
-+ kf_bufp = kf_buf;
-+ while (kf_bufp < kf_buf + kf_len)
-+ {
-+ struct kinfo_file *kf =
-+ (struct kinfo_file *) (uintptr_t) kf_bufp;
-+
-+ if (kf->kf_fd == oldfd)
-+ {
-+ char *buf;
-+ if (kf->kf_type != KF_TYPE_VNODE ||
-+ kf->kf_vnode_type != KF_VTYPE_VDIR)
-+ {
-+ __set_errno (ENOTDIR);
-+ return -1;
-+ }
-+
-+ buf = alloca (strlen (kf->kf_path) + old_filelen + 2);
-+ strcpy(buf, kf->kf_path);
-+ strcat (buf, "/");
-+ strcat (buf, old);
-+ old = buf;
-+ break;
-+ }
-+ kf_bufp += kf->kf_structsize;
-+ }
-+
-+ if (kf_bufp >= kf_buf + kf_len)
-+ {
-+ __set_errno (EBADF);
-+ return -1;
-+ }
-+ }
-+
-+ if (newfd != AT_FDCWD && new[0] != '/')
-+ {
-+ kf_bufp = kf_buf;
-+ while (kf_bufp < kf_buf + kf_len)
-+ {
-+ struct kinfo_file *kf =
-+ (struct kinfo_file *) (uintptr_t) kf_bufp;
-+
-+ if (kf->kf_fd == newfd)
-+ {
-+ char *buf;
-+ if (kf->kf_type != KF_TYPE_VNODE ||
-+ kf->kf_vnode_type != KF_VTYPE_VDIR)
-+ {
-+ __set_errno (ENOTDIR);
-+ return -1;
-+ }
-+
-+ buf = alloca (strlen (kf->kf_path) + new_filelen + 2);
-+ strcpy(buf, kf->kf_path);
-+ strcat (buf, "/");
-+ strcat (buf, new);
-+ new = buf;
-+ break;
-+ }
-+ kf_bufp += kf->kf_structsize;
-+ }
-+
-+ if (kf_bufp >= kf_buf + kf_len)
-+ {
-+ __set_errno (EBADF);
-+ return -1;
-+ }
-+ }
-+ }
-+
-+#define __rename rename /* there is no __rename */
-+ return __rename (old, new);
-+#endif
-+}
---- /dev/null
+++ b/ports/sysdeps/unix/bsd/bsd4.4/kfreebsd/rtld-lowlevel.h
@@ -0,0 +1,131 @@
+/* Definitions for lowlevel handling in ld.so, FreeBSD variant
@@ -22086,125 +20213,6 @@
@@ -0,0 +1 @@
+/* 'setrlimit64' is the same as 'setrlimit', because __rlim64_t == __rlim_t. */
--- /dev/null
-+++ b/ports/sysdeps/unix/bsd/bsd4.4/kfreebsd/shm_open.c
-@@ -0,0 +1,65 @@
-+/* Copyright (C) 2009 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 <sys/stat.h>
-+#include <sys/mman.h>
-+#include <unistd.h>
-+#include <fcntl.h>
-+#include <errno.h>
-+#include <sysdep.h>
-+
-+extern int __syscall_shm_open (const char *path, int flags, mode_t mode);
-+libc_hidden_proto (__syscall_shm_open);
-+
-+/* Open shared memory object. */
-+int
-+shm_open (const char *name, int oflag, mode_t mode)
-+{
-+ /* First try the new syscall. */
-+ int fd = INLINE_SYSCALL (shm_open, 3, name, oflag, mode);
-+
-+#ifndef __ASSUME_POSIXSHM_SYSCALL
-+ /* New syscall not available, use fallback code. */
-+ if (fd == -1 && errno == ENOSYS)
-+ {
-+ struct stat stab;
-+
-+ if ((oflag & O_ACCMODE) == O_WRONLY)
-+ return (EINVAL);
-+
-+ fd = __open (name, oflag, mode);
-+ if (fd != -1)
-+ {
-+ if (__fstat (fd, &stab) != 0 || !S_ISREG (stab.st_mode))
-+ {
-+ __close (fd);
-+ __set_errno (EINVAL);
-+ return -1;
-+ }
-+
-+ if (__fcntl (fd, F_SETFL, (int) FPOSIXSHM) != 0)
-+ {
-+ __close (fd);
-+ return -1;
-+ }
-+ }
-+ }
-+#endif
-+
-+ return fd;
-+}
---- /dev/null
-+++ b/ports/sysdeps/unix/bsd/bsd4.4/kfreebsd/shm_unlink.c
-@@ -0,0 +1,48 @@
-+/* Copyright (C) 2009 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 <sys/stat.h>
-+#include <sys/mman.h>
-+#include <unistd.h>
-+#include <errno.h>
-+#include <sysdep.h>
-+
-+extern int __syscall_shm_unlink (const char *name);
-+libc_hidden_proto (__syscall_shm_unlink)
-+
-+libc_hidden_proto (__unlink)
-+
-+/* Unlink a shared memory object. */
-+int
-+shm_unlink (const char *name)
-+{
-+ /* First try the new syscall. */
-+ int result = INLINE_SYSCALL (shm_unlink, 1, name);
-+
-+#ifndef __ASSUME_POSIXSHM_SYSCALL
-+ /* New syscall not available, simply unlink the file. */
-+ if (result == -1 && errno == ENOSYS)
-+# ifdef NOT_IN_libc
-+ return unlink (name);
-+# else
-+ return __unlink (name);
-+# endif
-+#endif
-+
-+ return result;
-+}
---- /dev/null
+++ b/ports/sysdeps/unix/bsd/bsd4.4/kfreebsd/sigaction.c
@@ -0,0 +1,47 @@
+/* Copyright (C) 1991,1995,1996,1997,2002,2004 Free Software Foundation, Inc.
@@ -22826,135 +20834,6 @@
+/* use stub only variant */
+#include <misc/stty.c>
--- /dev/null
-+++ b/ports/sysdeps/unix/bsd/bsd4.4/kfreebsd/symlinkat.c
-@@ -0,0 +1,126 @@
-+/* Copyright (C) 2009 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 <errno.h>
-+#include <fcntl.h>
-+#include <stddef.h>
-+#include <stdio.h>
-+#include <stdint.h>
-+#include <stdlib.h>
-+#include <string.h>
-+#include <sysdep.h>
-+#include <unistd.h>
-+#include <sys/sysctl.h>
-+#include <sys/user.h>
-+#include <kernel-features.h>
-+
-+extern int __syscall_symlinkat (const char *path1, int fd,
-+ const char *path2);
-+libc_hidden_proto (__syscall_symlinkat)
-+
-+/* Make a symbolic link to FROM named TO relative to TOFD. */
-+int
-+symlinkat (from, tofd, to)
-+ const char *from;
-+ int tofd;
-+ const char *to;
-+{
-+# ifndef __ASSUME_ATFCTS
-+ if (__have_atfcts >= 0)
-+# endif
-+ {
-+ int result = INLINE_SYSCALL (symlinkat, 3, from, tofd, to);
-+# ifndef __ASSUME_ATFCTS
-+ if (result == -1 && errno == ENOSYS)
-+ __have_atfcts = -1;
-+ else
-+# endif
-+ return result;
-+ }
-+
-+#ifndef __ASSUME_ATFCTS
-+ if (tofd != AT_FDCWD && to[0] != '/')
-+ {
-+ int mib[4];
-+ size_t kf_len = 0;
-+ char *kf_buf, *kf_bufp;
-+ size_t tolen;
-+
-+ if (tofd < 0)
-+ {
-+ __set_errno (EBADF);
-+ return -1;
-+ }
-+
-+ tolen = strlen (to);
-+ if (__builtin_expect (tolen == 0, 0))
-+ {
-+ __set_errno (ENOENT);
-+ return -1;
-+ }
-+
-+ mib[0] = CTL_KERN;
-+ mib[1] = KERN_PROC;
-+ mib[2] = KERN_PROC_FILEDESC;
-+ mib[3] = __getpid ();
-+
-+ if (__sysctl (mib, 4, NULL, &kf_len, NULL, 0) != 0)
-+ {
-+ __set_errno (ENOSYS);
-+ return -1;
-+ }
-+
-+ kf_buf = alloca (kf_len + tolen);
-+ if (__sysctl (mib, 4, kf_buf, &kf_len, NULL, 0) != 0)
-+ {
-+ __set_errno (ENOSYS);
-+ return -1;
-+ }
-+
-+ kf_bufp = kf_buf;
-+ while (kf_bufp < kf_buf + kf_len)
-+ {
-+ struct kinfo_file *kf = (struct kinfo_file *) (uintptr_t) kf_bufp;
-+
-+ if (kf->kf_fd == tofd)
-+ {
-+ if (kf->kf_type != KF_TYPE_VNODE ||
-+ kf->kf_vnode_type != KF_VTYPE_VDIR)
-+ {
-+ __set_errno (ENOTDIR);
-+ return -1;
-+ }
-+
-+ strcat (kf->kf_path, "/");
-+ strcat (kf->kf_path, to);
-+ to = kf->kf_path;
-+ break;
-+ }
-+ kf_bufp += kf->kf_structsize;
-+ }
-+
-+ if (kf_bufp >= kf_buf + kf_len)
-+ {
-+ __set_errno (EBADF);
-+ return -1;
-+ }
-+ }
-+
-+ return __symlink (from, to);
-+#endif
-+}
---- /dev/null
+++ b/ports/sysdeps/unix/bsd/bsd4.4/kfreebsd/sys/kd.h
@@ -0,0 +1,25 @@
+/* Copyright (C) 2005 Free Software Foundation, Inc.
@@ -24835,7 +22714,7 @@
+#endif
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/bsd4.4/kfreebsd/syscalls.list
-@@ -0,0 +1,202 @@
+@@ -0,0 +1,196 @@
+# File name Caller Syscall name # args Strong name Weak names
+sys_access - access i:si __syscall_access
+acl_aclcheck_fd - acl_aclcheck_fd i:iip __acl_aclcheck_fd
@@ -24874,8 +22753,7 @@
+sys_fstatfs - fstatfs i:ip __syscall_fstatfs
+sys_fhstatfs - fhstatfs i:pp __syscall_fhstatfs
+sys_fstat - fstat i:ip __syscall_fstat
-+sys_ftruncate - ftruncate i:ii __syscall_ftruncate
-+sys_freebsd6_ftruncate - freebsd6_ftruncate i:iii __syscall_freebsd6_ftruncate
++ftruncate - ftruncate i:ii __ftruncate !__ftruncate64 ftruncate ftruncate64
+futimes - futimes i:ip __futimes futimes
+sys_getcwd - getcwd i:bn __syscall_getcwd
+sys_getdents - getdents i:ibn __syscall_getdents
@@ -24911,8 +22789,7 @@
+lchmod - lchmod i:si __lchmod lchmod
+lchown - lchown i:sii __lchown lchown
+sys_lio_listio - lio_listio i:ibnP __syscall_lio_listio
-+sys_lseek - lseek i:iii __syscall_lseek
-+sys_freebsd6_lseek - freebsd6_lseek i:iiii __syscall_freebsd6_lseek
++lseek - lseek i:iii __libc_lseek !__lseek lseek !__libc_lseek64 !__lseek64 lseek64 !__llseek llseek
+sys_lstat - lstat i:sp __syscall_lstat
+lutimes - lutimes i:sp __lutimes lutimes
+posix_madvise - madvise i:pii posix_madvise
@@ -24923,7 +22800,6 @@
+mkfifo - mkfifo i:si __mkfifo mkfifo
+sys_mknod - mknod i:sii __syscall_mknod
+sys_mmap - mmap b:aniiii __syscall_mmap
-+sys_freebsd6_mmap - freebsd6_mmap b:aniiiii __syscall_freebsd6_mmap
+sys_munmap - munmap i:pi __syscall_munmap
+modfind - modfind i:s modfind
+modfnext - modfnext i:i modfnext
@@ -24947,10 +22823,8 @@
+obreak - obreak i:a __syscall_obreak
+sys_open - open i:siv __syscall_open
+poll - poll Ci:pii __poll poll
-+sys_pread - pread i:ibni __syscall_pread
-+sys_freebsd6_pread - freebsd6_pread i:ibnii __syscall_freebsd6_pread
-+sys_pwrite - pwrite i:ibni __syscall_pwrite
-+sys_freebsd6_pwrite - freebsd6_pwrite i:ibnii __syscall_freebsd6_pwrite
++pread - pread Ci:ibni __libc_pread !__pread pread !__libc_pread64 !__pread64 pread64
++pwrite - pwrite Ci:ibni __libc_pwrite !__pwrite pwrite !__libc_pwrite64 !__pwrite64 pwrite64
+preadv - preadv Ci:ipii __preadv preadv __preadv64 preadv64
+pwritev - pwritev Ci:ipii __pwritev pwritev __pwritev64 pwritev64
+quotactl - quotactl i:siip quotactl
@@ -24992,8 +22866,7 @@
+sys_stat - stat i:sp __syscall_stat
+sysarch - sysarch i:ip __sysarch sysarch
+sysctl - sysctl i:pibNbn __sysctl sysctl
-+sys_truncate - truncate i:sii __syscall_truncate
-+sys_freebsd6_truncate - freebsd6_truncate i:si __syscall_freebsd6_truncate
++truncate - truncate i:sii __truncate !__truncate64 truncate truncate64
+undelete - undelete i:s undelete
+unmount - unmount i:si unmount
+utrace - utrace i:bn utrace
@@ -25020,24 +22893,24 @@
+sys_cpuset_getaffinity - cpuset_getaffinity i:iiiip __syscall_cpuset_getaffinity
+sys_cpuset_setaffinity - cpuset_setaffinity i:iiiip __syscall_cpuset_setaffinity
+sys_faccessat - faccessat i:isii __syscall_faccessat
-+sys_fchmodat - fchmodat i:isii __syscall_fchmodat
-+sys_fchownat - fchownat i:isiii __syscall_fchownat
-+sys_fexecve - fexecve i:ipp __syscall_fexecve
++fchmodat - fchmodat i:isii fchmodat
++fchownat - fchownat i:isiii fchownat
++fexecve - fexecve i:ipp fexecve
+sys_fstatat - fstatat i:ispi __syscall_fstatat
+sys_futimesat - futimesat i:isp __syscall_futimesat
-+sys_linkat - linkat i:isisi __syscall_linkat
-+sys_mkdirat - mkdirat i:isi __syscall_mkdirat
++linkat - linkat i:isisi linkat
++mkdirat - mkdirat i:isi mkdirat
+sys_mkfifoat - mkfifoat i:isi __syscall_mkfifoat
+sys_mknodat - mknodat i:isii __syscall_mknodat
-+sys_openat - openat i:isii __syscall_openat
-+sys_readlinkat - readlinkat i:issi __syscall_readlinkat
-+sys_renameat - renameat i:isis __syscall_renameat
-+sys_symlinkat - symlinkat i:sis __syscall_symlinkat
-+sys_unlinkat - unlinkat i:isi __syscall_unlinkat
-+sys_shm_open - shm_open i:sii __syscall_shm_open
-+sys_shm_unlink - shm_unlink i:s __syscall_shm_unlink
++sys_openat - openat i:isii __syscall_openat !__openat_nocancel !__openat64_nocancel
++readlinkat - readlinkat i:issi readlinkat
++renameat - renameat i:isis renameat
++symlinkat - symlinkat i:sis symlinkat
++unlinkat - unlinkat i:isi unlinkat
++shm_open - shm_open i:sii shm_open
++shm_unlink - shm_unlink i:s shm_unlink
+readlink - readlink i:spi __syscall_readlink __readlink readlink
-+sys_pselect - pselect i:iPPPPP __syscall_pselect
++pselect - pselect Ci:iPPPPP __pselect !__libc_pselect pselect
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/bsd4.4/kfreebsd/sysconf.c
@@ -0,0 +1,69 @@
@@ -25250,7 +23123,7 @@
+#include <sysdeps/posix/telldir.c>
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/bsd4.4/kfreebsd/testrtsig.h
-@@ -0,0 +1,37 @@
+@@ -0,0 +1,31 @@
+/* Test whether RT signals are really available.
+ Copyright (C) 2008 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
@@ -25280,70 +23153,9 @@
+static int
+kernel_has_rtsig (void)
+{
-+#if __ASSUME_REALTIME_SIGNALS
+ return 1;
-+#else
-+ if (__kernel_getosreldate () < 700050) /* FreeBSD 7.0 is 700055 */
-+ return 0;
-+ return 1;
-+#endif
+}
--- /dev/null
-+++ b/ports/sysdeps/unix/bsd/bsd4.4/kfreebsd/truncate.c
-@@ -0,0 +1,52 @@
-+/* Copyright (C) 2002 Free Software Foundation, Inc.
-+ This file is part of the GNU C Library.
-+ Contributed by Bruno Haible <bruno@clisp.org>, 2002.
-+
-+ 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 <unistd.h>
-+#include <sys/types.h>
-+#include <sysdep.h>
-+#include <errno.h>
-+
-+extern int __syscall_truncate (const char *__file, __off_t __length) __THROW;
-+libc_hidden_proto (__syscall_truncate)
-+extern int __syscall_freebsd6_truncate (const char *__file, int __unused1,
-+ __off_t __length) __THROW;
-+libc_hidden_proto (__syscall_freebsd6_truncate)
-+
-+int
-+__truncate (const char *file, __off_t length)
-+{
-+ int result;
-+
-+ /* First try the new syscall. */
-+ result = INLINE_SYSCALL (truncate, 2, file, length);
-+
-+#ifndef __ASSUME_TRUNCATE_SYSCALL
-+ if (result == -1 && errno == ENOSYS)
-+ /* New syscall not available, us the old one. */
-+ result = INLINE_SYSCALL (freebsd6_truncate, 3, file, 0, length);
-+#endif
-+
-+ return result;
-+}
-+
-+weak_alias (__truncate, truncate)
-+
-+/* 'truncate64' is the same as 'truncate', because __off64_t == __off_t. */
-+strong_alias (__truncate, __truncate64)
-+weak_alias (__truncate64, truncate64)
---- /dev/null
+++ b/ports/sysdeps/unix/bsd/bsd4.4/kfreebsd/truncate64.c
@@ -0,0 +1 @@
+/* 'truncate64' is the same as 'truncate', because __off64_t == __off_t. */
@@ -25621,144 +23433,6 @@
+weak_alias (__uname, uname)
+libc_hidden_def (uname)
--- /dev/null
-+++ b/ports/sysdeps/unix/bsd/bsd4.4/kfreebsd/unlinkat.c
-@@ -0,0 +1,135 @@
-+/* Copyright (C) 2009 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 <errno.h>
-+#include <fcntl.h>
-+#include <stddef.h>
-+#include <stdio.h>
-+#include <stdint.h>
-+#include <stdlib.h>
-+#include <string.h>
-+#include <sysdep.h>
-+#include <unistd.h>
-+#include <sys/sysctl.h>
-+#include <sys/user.h>
-+#include <kernel-features.h>
-+
-+extern int __syscall_unlinkat (int fd, const char *file, int flag);
-+libc_hidden_proto (__syscall_unlinkat)
-+
-+libc_hidden_proto (__unlink)
-+
-+/* Remove the link named NAME. */
-+int
-+unlinkat (fd, file, flag)
-+ int fd;
-+ const char *file;
-+ int flag;
-+{
-+# ifndef __ASSUME_ATFCTS
-+ if (__have_atfcts >= 0)
-+# endif
-+ {
-+ int result = INLINE_SYSCALL (unlinkat, 3, fd, file, flag);
-+# ifndef __ASSUME_ATFCTS
-+ if (result == -1 && errno == ENOSYS)
-+ __have_atfcts = -1;
-+ else
-+# endif
-+ return result;
-+ }
-+
-+#ifndef __ASSUME_ATFCTS
-+ if (flag & ~AT_REMOVEDIR)
-+ {
-+ __set_errno (EINVAL);
-+ return -1;
-+ }
-+
-+ if (fd != AT_FDCWD && file[0] != '/')
-+ {
-+ int mib[4];
-+ size_t kf_len = 0;
-+ char *kf_buf, *kf_bufp;
-+ size_t filelen;
-+
-+ if (fd < 0)
-+ {
-+ __set_errno (EBADF);
-+ return -1;
-+ }
-+
-+ filelen = strlen (file);
-+ if (__builtin_expect (filelen == 0, 0))
-+ {
-+ __set_errno (ENOENT);
-+ return -1;
-+ }
-+
-+ mib[0] = CTL_KERN;
-+ mib[1] = KERN_PROC;
-+ mib[2] = KERN_PROC_FILEDESC;
-+ mib[3] = __getpid ();
-+
-+ if (__sysctl (mib, 4, NULL, &kf_len, NULL, 0) != 0)
-+ {
-+ __set_errno (ENOSYS);
-+ return -1;
-+ }
-+
-+ kf_buf = alloca (kf_len + filelen);
-+ if (__sysctl (mib, 4, kf_buf, &kf_len, NULL, 0) != 0)
-+ {
-+ __set_errno (ENOSYS);
-+ return -1;
-+ }
-+
-+ kf_bufp = kf_buf;
-+ while (kf_bufp < kf_buf + kf_len)
-+ {
-+ struct kinfo_file *kf = (struct kinfo_file *) (uintptr_t) kf_bufp;
-+
-+ if (kf->kf_fd == fd)
-+ {
-+ if (kf->kf_type != KF_TYPE_VNODE ||
-+ kf->kf_vnode_type != KF_VTYPE_VDIR)
-+ {
-+ __set_errno (ENOTDIR);
-+ return -1;
-+ }
-+
-+ strcat (kf->kf_path, "/");
-+ strcat (kf->kf_path, file);
-+ file = kf->kf_path;
-+ break;
-+ }
-+ kf_bufp += kf->kf_structsize;
-+ }
-+
-+ if (kf_bufp >= kf_buf + kf_len)
-+ {
-+ __set_errno (EBADF);
-+ return -1;
-+ }
-+ }
-+ if (flag & AT_REMOVEDIR)
-+ return __rmdir (file);
-+ else
-+ return __unlink (file);
-+#endif
-+}
---- /dev/null
+++ b/ports/sysdeps/unix/bsd/bsd4.4/kfreebsd/unlockpt.c
@@ -0,0 +1,45 @@
+/* Copyright (C) 2007 Free Software Foundation, Inc.
@@ -29315,7 +26989,7 @@
+weak_alias (__xmknod, _xmknod)
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/bsd4.4/kfreebsd/xmknodat.c
-@@ -0,0 +1,145 @@
+@@ -0,0 +1,60 @@
+/* Copyright (C) 2009 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
@@ -29367,97 +27041,12 @@
+ return -1;
+ }
+
-+# ifndef __ASSUME_ATFCTS
-+ if (__have_atfcts >= 0)
-+# endif
-+ {
-+ int result;
-+
+ /* The FreeBSD mknod() system call cannot be used to create FIFOs; we
+ must use the mkfifo() system call for this purpose. */
+ if (S_ISFIFO (mode))
-+ result = INLINE_SYSCALL (mkfifoat, 3, fd, file, mode);
++ return INLINE_SYSCALL (mkfifoat, 3, fd, file, mode);
+ else
-+ result = INLINE_SYSCALL (mknodat, 4, fd, file, mode, *dev);
-+
-+# ifndef __ASSUME_ATFCTS
-+ if (result == -1 && errno == ENOSYS)
-+ __have_atfcts = -1;
-+ else
-+# endif
-+ return result;
-+ }
-+
-+#ifndef __ASSUME_ATFCTS
-+ if (fd != AT_FDCWD && file[0] != '/')
-+ {
-+ int mib[4];
-+ size_t kf_len = 0;
-+ char *kf_buf, *kf_bufp;
-+ size_t filelen;
-+
-+ if (fd < 0)
-+ {
-+ __set_errno (EBADF);
-+ return -1;
-+ }
-+
-+ filelen = strlen (file);
-+ if (__builtin_expect (filelen == 0, 0))
-+ {
-+ __set_errno (ENOENT);
-+ return -1;
-+ }
-+
-+ mib[0] = CTL_KERN;
-+ mib[1] = KERN_PROC;
-+ mib[2] = KERN_PROC_FILEDESC;
-+ mib[3] = __getpid ();
-+
-+ if (__sysctl (mib, 4, NULL, &kf_len, NULL, 0) != 0)
-+ {
-+ __set_errno (ENOSYS);
-+ return -1;
-+ }
-+
-+ kf_buf = alloca (kf_len + filelen);
-+ if (__sysctl (mib, 4, kf_buf, &kf_len, NULL, 0) != 0)
-+ {
-+ __set_errno (ENOSYS);
-+ return -1;
-+ }
-+
-+ kf_bufp = kf_buf;
-+ while (kf_bufp < kf_buf + kf_len)
-+ {
-+ struct kinfo_file *kf = (struct kinfo_file *) (uintptr_t) kf_bufp;
-+
-+ if (kf->kf_fd == fd)
-+ {
-+ if (kf->kf_type != KF_TYPE_VNODE ||
-+ kf->kf_vnode_type != KF_VTYPE_VDIR)
-+ {
-+ __set_errno (ENOTDIR);
-+ return -1;
-+ }
-+
-+ strcat (kf->kf_path, "/");
-+ strcat (kf->kf_path, file);
-+ file = kf->kf_path;
-+ break;
-+ }
-+ kf_bufp += kf->kf_structsize;
-+ }
-+
-+ if (kf_bufp >= kf_buf + kf_len)
-+ {
-+ __set_errno (EBADF);
-+ return -1;
-+ }
-+ }
-+
-+ return __xmknod (vers, file, mode, dev);
-+#endif
++ return INLINE_SYSCALL (mknodat, 4, fd, file, mode, *dev);
+}
+
+libc_hidden_def (__xmknodat)
Reply to: