[Glibc-bsd-commits] r4574 - in trunk/glibc-ports/kfreebsd: . fbtl fbtl/bits x86_64 x86_64/fbtl
Petr Salinger
ps-guest at alioth.debian.org
Mon Jul 8 12:42:53 UTC 2013
Author: ps-guest
Date: 2013-06-22 18:44:43 +0000 (Sat, 22 Jun 2013)
New Revision: 4574
Added:
trunk/glibc-ports/kfreebsd/fbtl/pthread_kill.c
trunk/glibc-ports/kfreebsd/fbtl/pthread_once.c
trunk/glibc-ports/kfreebsd/fbtl/pthread_yield.c
trunk/glibc-ports/kfreebsd/x86_64/pt-vfork.c
Modified:
trunk/glibc-ports/kfreebsd/fbtl/Makefile
trunk/glibc-ports/kfreebsd/fbtl/aio_misc.h
trunk/glibc-ports/kfreebsd/fbtl/bits/local_lim.h
trunk/glibc-ports/kfreebsd/kernel-features.h
trunk/glibc-ports/kfreebsd/x86_64/fbtl/tls.h
Log:
misc fixup
Modified: trunk/glibc-ports/kfreebsd/fbtl/Makefile
===================================================================
--- trunk/glibc-ports/kfreebsd/fbtl/Makefile 2013-06-22 18:44:19 UTC (rev 4573)
+++ trunk/glibc-ports/kfreebsd/fbtl/Makefile 2013-06-22 18:44:43 UTC (rev 4574)
@@ -22,6 +22,10 @@
libpthread-sysdep_routines += pt-fork pthread_mutex_cond_lock
+gen-as-const-headers += lowlevelrwlock.sym \
+ unwindbuf.sym \
+ structsem.sym
+
#gen-as-const-headers += lowlevelcond.sym lowlevelrwlock.sym \
# lowlevelbarrier.sym unwindbuf.sym \
# lowlevelrobustlock.sym pthread-pi-defines.sym \
@@ -34,5 +38,9 @@
CFLAGS-getpid.os = -fomit-frame-pointer
endif
+ifeq ($(subdir),posix)
+sysdep_routines += exit-thread
+endif
+
# Needed in both the signal and nptl subdir.
CFLAGS-sigaction.c = -DWRAPPER_INCLUDE='<fbtl/sigaction.c>'
Modified: trunk/glibc-ports/kfreebsd/fbtl/aio_misc.h
===================================================================
--- trunk/glibc-ports/kfreebsd/fbtl/aio_misc.h 2013-06-22 18:44:19 UTC (rev 4573)
+++ trunk/glibc-ports/kfreebsd/fbtl/aio_misc.h 2013-06-22 18:44:43 UTC (rev 4574)
@@ -31,7 +31,7 @@
{
sigset_t ss;
sigemptyset (&ss);
- INLINE_SYSCALL (sigprocmask, err, 3, SIG_SETMASK, &ss, NULL);
+ INLINE_SYSCALL (sigprocmask, 3, SIG_SETMASK, &ss, NULL);
}
extern inline int
@@ -52,12 +52,12 @@
sigset_t ss;
sigset_t oss;
sigfillset (&ss);
- INLINE_SYSCALL (sigprocmask, err, 3, SIG_SETMASK, &ss, &oss;
+ INLINE_SYSCALL (sigprocmask, 3, SIG_SETMASK, &ss, &oss;
int ret = pthread_create (threadp, &attr, tf, arg);
/* Restore the signal mask. */
- INLINE_SYSCALL (sigprocmask, err, 3, SIG_SETMASK, &oss, NULL);
+ INLINE_SYSCALL (sigprocmask, 3, SIG_SETMASK, &oss, NULL);
(void) pthread_attr_destroy (&attr);
return ret;
Modified: trunk/glibc-ports/kfreebsd/fbtl/bits/local_lim.h
===================================================================
--- trunk/glibc-ports/kfreebsd/fbtl/bits/local_lim.h 2013-06-22 18:44:19 UTC (rev 4573)
+++ trunk/glibc-ports/kfreebsd/fbtl/bits/local_lim.h 2013-06-22 18:44:43 UTC (rev 4574)
@@ -31,8 +31,8 @@
/* The number of threads per process. */
#define _POSIX_THREAD_THREADS_MAX 64
-/* This is the value this implementation supports. */
-#define PTHREAD_THREADS_MAX 1024
+/* We have no predefined limit on the number of threads. */
+#undef PTHREAD_THREADS_MAX
/* Maximum amount by which a process can descrease its asynchronous I/O
priority level. */
@@ -46,3 +46,6 @@
/* Maximum number of timer expiration overruns. */
#define DELAYTIMER_MAX 2147483647
+
+/* Maximum value the semaphore can have. */
+#define SEM_VALUE_MAX (2147483647)
Added: trunk/glibc-ports/kfreebsd/fbtl/pthread_kill.c
===================================================================
--- trunk/glibc-ports/kfreebsd/fbtl/pthread_kill.c (rev 0)
+++ trunk/glibc-ports/kfreebsd/fbtl/pthread_kill.c 2013-06-22 18:44:43 UTC (rev 4574)
@@ -0,0 +1,69 @@
+/* Copyright (C) 2002-2012 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper at redhat.com>, 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <errno.h>
+#include <signal.h>
+#include <pthreadP.h>
+#include <tls.h>
+#include <sysdep.h>
+#include <kernel-features.h>
+
+
+int
+__pthread_kill (threadid, signo)
+ pthread_t threadid;
+ int signo;
+{
+ struct pthread *pd = (struct pthread *) threadid;
+
+ /* Make sure the descriptor is valid. */
+ if (DEBUGGING_P && INVALID_TD_P (pd))
+ /* Not a valid thread handle. */
+ return ESRCH;
+
+ /* Force load of pd->tid into local variable or register. Otherwise
+ if a thread exits between ESRCH test and tgkill, we might return
+ EINVAL, because pd->tid would be cleared by the kernel. */
+ pid_t tid = atomic_forced_read (pd->tid);
+ if (__builtin_expect (tid <= 0, 0))
+ /* Not a valid thread handle. */
+ return ESRCH;
+
+ /* Disallow sending the signal we use for cancellation, timers,
+ for the setxid implementation. */
+ if (signo == SIGCANCEL || signo == SIGTIMER || signo == SIGSETXID)
+ return EINVAL;
+#warning kill needed
+#if 0
+ /* We have a special syscall to do the work. */
+ INTERNAL_SYSCALL_DECL (err);
+
+ /* One comment: The PID field in the TCB can temporarily be changed
+ (in fork). But this must not affect this code here. Since this
+ function would have to be called while the thread is executing
+ fork, it would have to happen in a signal handler. But this is
+ no allowed, pthread_kill is not guaranteed to be async-safe. */
+ int val;
+ val = INTERNAL_SYSCALL (tgkill, err, 3, THREAD_GETMEM (THREAD_SELF, pid),
+ tid, signo);
+
+ return (INTERNAL_SYSCALL_ERROR_P (val, err)
+ ? INTERNAL_SYSCALL_ERRNO (val, err) : 0);
+#endif
+}
+strong_alias (__pthread_kill, pthread_kill)
Added: trunk/glibc-ports/kfreebsd/fbtl/pthread_once.c
===================================================================
--- trunk/glibc-ports/kfreebsd/fbtl/pthread_once.c (rev 0)
+++ trunk/glibc-ports/kfreebsd/fbtl/pthread_once.c 2013-06-22 18:44:43 UTC (rev 4574)
@@ -0,0 +1,93 @@
+/* Copyright (C) 2003-2012 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jakub Jelinek <jakub at redhat.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 "pthreadP.h"
+#include <lowlevellock.h>
+
+
+unsigned long int __fork_generation attribute_hidden;
+
+
+static void
+clear_once_control (void *arg)
+{
+ pthread_once_t *once_control = (pthread_once_t *) arg;
+
+ *once_control = 0;
+ lll_private_futex_wake (once_control, INT_MAX);
+}
+
+
+int
+__pthread_once (once_control, init_routine)
+ pthread_once_t *once_control;
+ void (*init_routine) (void);
+{
+ while (1)
+ {
+ int oldval, val, newval;
+
+ val = *once_control;
+ do
+ {
+ /* Check if the initialized has already been done. */
+ if ((val & 2) != 0)
+ return 0;
+
+ oldval = val;
+ newval = (oldval & 3) | __fork_generation | 1;
+ val = atomic_compare_and_exchange_val_acq (once_control, newval,
+ oldval);
+ }
+ while (__builtin_expect (val != oldval, 0));
+
+ /* Check if another thread already runs the initializer. */
+ if ((oldval & 1) != 0)
+ {
+ /* Check whether the initializer execution was interrupted
+ by a fork. */
+ if (((oldval ^ newval) & -4) == 0)
+ {
+ /* Same generation, some other thread was faster. Wait. */
+ lll_private_futex_wait (once_control, newval);
+ continue;
+ }
+ }
+
+ /* This thread is the first here. Do the initialization.
+ Register a cleanup handler so that in case the thread gets
+ interrupted the initialization can be restarted. */
+ pthread_cleanup_push (clear_once_control, once_control);
+
+ init_routine ();
+
+ pthread_cleanup_pop (0);
+
+
+ /* Add one to *once_control. */
+ atomic_increment (once_control);
+
+ /* Wake up all other threads. */
+ lll_private_futex_wake (once_control, INT_MAX);
+ break;
+ }
+
+ return 0;
+}
+weak_alias (__pthread_once, pthread_once)
+hidden_def (__pthread_once)
Added: trunk/glibc-ports/kfreebsd/fbtl/pthread_yield.c
===================================================================
--- trunk/glibc-ports/kfreebsd/fbtl/pthread_yield.c (rev 0)
+++ trunk/glibc-ports/kfreebsd/fbtl/pthread_yield.c 2013-06-22 18:44:43 UTC (rev 4574)
@@ -0,0 +1,29 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper at redhat.com>, 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <pthread.h>
+#include <sched.h>
+
+
+/* With the 1-on-1 model we implement this function is equivalent to
+ the 'sched_yield' function. */
+int
+pthread_yield (void)
+{
+ return sched_yield ();
+}
Modified: trunk/glibc-ports/kfreebsd/kernel-features.h
===================================================================
--- trunk/glibc-ports/kfreebsd/kernel-features.h 2013-06-22 18:44:19 UTC (rev 4573)
+++ trunk/glibc-ports/kfreebsd/kernel-features.h 2013-06-22 18:44:43 UTC (rev 4574)
@@ -83,3 +83,6 @@
#if __KFREEBSD_KERNEL_VERSION >= 0x80300
# define __ASSUME_FALLOCATE 1
#endif
+
+/* Support for private "futexes" was added before we start with fbtl. */
+# define __ASSUME_PRIVATE_FUTEX 1
Modified: trunk/glibc-ports/kfreebsd/x86_64/fbtl/tls.h
===================================================================
--- trunk/glibc-ports/kfreebsd/x86_64/fbtl/tls.h 2013-06-22 18:44:19 UTC (rev 4573)
+++ trunk/glibc-ports/kfreebsd/x86_64/fbtl/tls.h 2013-06-22 18:44:43 UTC (rev 4574)
@@ -28,6 +28,18 @@
#include <sysarch.h>
#include <sys/syscall.h>
+#if 0
+/* in Linux one; */
+/* Magic for libthread_db to know how to do THREAD_SELF. */
+# define DB_THREAD_SELF_INCLUDE <sys/reg.h> /* For the FS constant. */
+# define DB_THREAD_SELF CONST_THREAD_AREA (64, FS)
+#else
+/* # warning proper FS constant needed */
+# undef DB_THREAD_SELF_INCLUDE
+# undef DB_THREAD_SELF
+# define DB_THREAD_SELF CONST_THREAD_AREA (64, 25)
+#endif
+
/* 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. */
Added: trunk/glibc-ports/kfreebsd/x86_64/pt-vfork.c
===================================================================
--- trunk/glibc-ports/kfreebsd/x86_64/pt-vfork.c (rev 0)
+++ trunk/glibc-ports/kfreebsd/x86_64/pt-vfork.c 2013-06-22 18:44:43 UTC (rev 4574)
@@ -0,0 +1 @@
+#warning TODO
More information about the Glibc-bsd-commits
mailing list