1998-04-11 06:57:33 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 1998 John Birrell <jb@cimlogic.com.au>.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
2007-01-12 07:31:30 +00:00
|
|
|
* 3. Neither the name of the author nor the names of any co-contributors
|
1998-04-11 06:57:33 +00:00
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
1999-08-28 00:22:10 +00:00
|
|
|
* $FreeBSD$
|
1998-04-11 06:57:33 +00:00
|
|
|
*
|
|
|
|
* Private definitions for libc, libc_r and libpthread.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _LIBC_PRIVATE_H_
|
|
|
|
#define _LIBC_PRIVATE_H_
|
2012-06-22 07:13:30 +00:00
|
|
|
#include <sys/_types.h>
|
2009-11-20 19:19:51 +00:00
|
|
|
#include <sys/_pthreadtypes.h>
|
1998-04-11 06:57:33 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* This global flag is non-zero when a process has created one
|
|
|
|
* or more threads. It is used to avoid calling locking functions
|
|
|
|
* when they are not required.
|
|
|
|
*/
|
|
|
|
extern int __isthreaded;
|
|
|
|
|
2012-02-17 10:49:29 +00:00
|
|
|
/*
|
|
|
|
* Elf_Auxinfo *__elf_aux_vector, the pointer to the ELF aux vector
|
|
|
|
* provided by kernel. Either set for us by rtld, or found at runtime
|
|
|
|
* on stack for static binaries.
|
|
|
|
*
|
|
|
|
* Type is void to avoid polluting whole libc with ELF types.
|
|
|
|
*/
|
|
|
|
extern void *__elf_aux_vector;
|
|
|
|
|
2011-12-23 15:00:37 +00:00
|
|
|
/*
|
|
|
|
* libc should use libc_dlopen internally, which respects a global
|
|
|
|
* flag where loading of new shared objects can be restricted.
|
|
|
|
*/
|
|
|
|
void *libc_dlopen(const char *, int);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* For dynamic linker.
|
|
|
|
*/
|
|
|
|
void _rtld_error(const char *fmt, ...);
|
|
|
|
|
1998-04-11 06:57:33 +00:00
|
|
|
/*
|
|
|
|
* File lock contention is difficult to diagnose without knowing
|
|
|
|
* where locks were set. Allow a debug library to be built which
|
|
|
|
* records the source file and line number of each lock call.
|
|
|
|
*/
|
|
|
|
#ifdef _FLOCK_DEBUG
|
|
|
|
#define _FLOCKFILE(x) _flockfile_debug(x, __FILE__, __LINE__)
|
|
|
|
#else
|
2001-01-24 13:01:12 +00:00
|
|
|
#define _FLOCKFILE(x) _flockfile(x)
|
1998-04-11 06:57:33 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Macros for locking and unlocking FILEs. These test if the
|
|
|
|
* process is threaded to avoid locking when not required.
|
|
|
|
*/
|
|
|
|
#define FLOCKFILE(fp) if (__isthreaded) _FLOCKFILE(fp)
|
2001-01-24 13:01:12 +00:00
|
|
|
#define FUNLOCKFILE(fp) if (__isthreaded) _funlockfile(fp)
|
1998-04-11 06:57:33 +00:00
|
|
|
|
2012-04-24 17:51:36 +00:00
|
|
|
struct _spinlock;
|
2013-08-23 14:23:54 +00:00
|
|
|
extern struct _spinlock __stdio_thread_lock __hidden;
|
2012-04-24 17:51:36 +00:00
|
|
|
#define STDIO_THREAD_LOCK() \
|
|
|
|
do { \
|
|
|
|
if (__isthreaded) \
|
|
|
|
_SPINLOCK(&__stdio_thread_lock); \
|
|
|
|
} while (0)
|
|
|
|
#define STDIO_THREAD_UNLOCK() \
|
|
|
|
do { \
|
|
|
|
if (__isthreaded) \
|
|
|
|
_SPINUNLOCK(&__stdio_thread_lock); \
|
|
|
|
} while (0)
|
|
|
|
|
2015-02-14 11:47:40 +00:00
|
|
|
void __libc_spinlock_stub(struct _spinlock *);
|
|
|
|
void __libc_spinunlock_stub(struct _spinlock *);
|
|
|
|
|
2002-11-13 18:12:09 +00:00
|
|
|
/*
|
|
|
|
* Indexes into the pthread jump table.
|
|
|
|
*
|
|
|
|
* Warning! If you change this type, you must also change the threads
|
|
|
|
* libraries that reference it (libc_r, libpthread).
|
|
|
|
*/
|
|
|
|
typedef enum {
|
2006-03-05 18:10:28 +00:00
|
|
|
PJT_ATFORK,
|
|
|
|
PJT_ATTR_DESTROY,
|
|
|
|
PJT_ATTR_GETDETACHSTATE,
|
|
|
|
PJT_ATTR_GETGUARDSIZE,
|
|
|
|
PJT_ATTR_GETINHERITSCHED,
|
|
|
|
PJT_ATTR_GETSCHEDPARAM,
|
|
|
|
PJT_ATTR_GETSCHEDPOLICY,
|
|
|
|
PJT_ATTR_GETSCOPE,
|
|
|
|
PJT_ATTR_GETSTACKADDR,
|
|
|
|
PJT_ATTR_GETSTACKSIZE,
|
|
|
|
PJT_ATTR_INIT,
|
|
|
|
PJT_ATTR_SETDETACHSTATE,
|
|
|
|
PJT_ATTR_SETGUARDSIZE,
|
|
|
|
PJT_ATTR_SETINHERITSCHED,
|
|
|
|
PJT_ATTR_SETSCHEDPARAM,
|
|
|
|
PJT_ATTR_SETSCHEDPOLICY,
|
|
|
|
PJT_ATTR_SETSCOPE,
|
|
|
|
PJT_ATTR_SETSTACKADDR,
|
|
|
|
PJT_ATTR_SETSTACKSIZE,
|
|
|
|
PJT_CANCEL,
|
|
|
|
PJT_CLEANUP_POP,
|
|
|
|
PJT_CLEANUP_PUSH,
|
2002-11-13 18:12:09 +00:00
|
|
|
PJT_COND_BROADCAST,
|
|
|
|
PJT_COND_DESTROY,
|
|
|
|
PJT_COND_INIT,
|
|
|
|
PJT_COND_SIGNAL,
|
2006-03-05 18:10:28 +00:00
|
|
|
PJT_COND_TIMEDWAIT,
|
2002-11-13 18:12:09 +00:00
|
|
|
PJT_COND_WAIT,
|
2006-03-05 18:10:28 +00:00
|
|
|
PJT_DETACH,
|
|
|
|
PJT_EQUAL,
|
|
|
|
PJT_EXIT,
|
2002-11-13 18:12:09 +00:00
|
|
|
PJT_GETSPECIFIC,
|
2006-03-05 18:10:28 +00:00
|
|
|
PJT_JOIN,
|
2002-11-13 18:12:09 +00:00
|
|
|
PJT_KEY_CREATE,
|
|
|
|
PJT_KEY_DELETE,
|
2006-03-05 18:10:28 +00:00
|
|
|
PJT_KILL,
|
2002-11-13 18:12:09 +00:00
|
|
|
PJT_MAIN_NP,
|
2006-03-05 18:10:28 +00:00
|
|
|
PJT_MUTEXATTR_DESTROY,
|
|
|
|
PJT_MUTEXATTR_INIT,
|
|
|
|
PJT_MUTEXATTR_SETTYPE,
|
2002-11-13 18:12:09 +00:00
|
|
|
PJT_MUTEX_DESTROY,
|
|
|
|
PJT_MUTEX_INIT,
|
|
|
|
PJT_MUTEX_LOCK,
|
|
|
|
PJT_MUTEX_TRYLOCK,
|
|
|
|
PJT_MUTEX_UNLOCK,
|
|
|
|
PJT_ONCE,
|
|
|
|
PJT_RWLOCK_DESTROY,
|
|
|
|
PJT_RWLOCK_INIT,
|
|
|
|
PJT_RWLOCK_RDLOCK,
|
|
|
|
PJT_RWLOCK_TRYRDLOCK,
|
|
|
|
PJT_RWLOCK_TRYWRLOCK,
|
|
|
|
PJT_RWLOCK_UNLOCK,
|
|
|
|
PJT_RWLOCK_WRLOCK,
|
|
|
|
PJT_SELF,
|
2006-03-05 18:10:28 +00:00
|
|
|
PJT_SETCANCELSTATE,
|
|
|
|
PJT_SETCANCELTYPE,
|
2002-11-13 18:12:09 +00:00
|
|
|
PJT_SETSPECIFIC,
|
|
|
|
PJT_SIGMASK,
|
2006-03-05 18:10:28 +00:00
|
|
|
PJT_TESTCANCEL,
|
Use umtx to implement process sharable semaphore, to make this work,
now type sema_t is a structure which can be put in a shared memory area,
and multiple processes can operate it concurrently.
User can either use mmap(MAP_SHARED) + sem_init(pshared=1) or use sem_open()
to initialize a shared semaphore.
Named semaphore uses file system and is located in /tmp directory, and its
file name is prefixed with 'SEMD', so now it is chroot or jail friendly.
In simplist cases, both for named and un-named semaphore, userland code
does not have to enter kernel to reduce/increase semaphore's count.
The semaphore is designed to be crash-safe, it means even if an application
is crashed in the middle of operating semaphore, the semaphore state is
still safely recovered by later use, there is no waiter counter maintained
by userland code.
The main semaphore code is in libc and libthr only has some necessary stubs,
this makes it possible that a non-threaded application can use semaphore
without linking to thread library.
Old semaphore implementation is kept libc to maintain binary compatibility.
The kernel ksem API is no longer used in the new implemenation.
Discussed on: threads@
2010-01-05 02:37:59 +00:00
|
|
|
PJT_CLEANUP_POP_IMP,
|
|
|
|
PJT_CLEANUP_PUSH_IMP,
|
2010-09-25 01:57:47 +00:00
|
|
|
PJT_CANCEL_ENTER,
|
|
|
|
PJT_CANCEL_LEAVE,
|
Add implementation of robust mutexes, hopefully close enough to the
intention of the POSIX IEEE Std 1003.1TM-2008/Cor 1-2013.
A robust mutex is guaranteed to be cleared by the system upon either
thread or process owner termination while the mutex is held. The next
mutex locker is then notified about inconsistent mutex state and can
execute (or abandon) corrective actions.
The patch mostly consists of small changes here and there, adding
neccessary checks for the inconsistent and abandoned conditions into
existing paths. Additionally, the thread exit handler was extended to
iterate over the userspace-maintained list of owned robust mutexes,
unlocking and marking as terminated each of them.
The list of owned robust mutexes cannot be maintained atomically
synchronous with the mutex lock state (it is possible in kernel, but
is too expensive). Instead, for the duration of lock or unlock
operation, the current mutex is remembered in a special slot that is
also checked by the kernel at thread termination.
Kernel must be aware about the per-thread location of the heads of
robust mutex lists and the current active mutex slot. When a thread
touches a robust mutex for the first time, a new umtx op syscall is
issued which informs about location of lists heads.
The umtx sleep queues for PP and PI mutexes are split between
non-robust and robust.
Somewhat unrelated changes in the patch:
1. Style.
2. The fix for proper tdfind() call use in umtxq_sleep_pi() for shared
pi mutexes.
3. Removal of the userspace struct pthread_mutex m_owner field.
4. The sysctl kern.ipc.umtx_vnode_persistent is added, which controls
the lifetime of the shared mutex associated with a vnode' page.
Reviewed by: jilles (previous version, supposedly the objection was fixed)
Discussed with: brooks, Martin Simmons <martin@lispworks.com> (some aspects)
Tested by: pho
Sponsored by: The FreeBSD Foundation
2016-05-17 09:56:22 +00:00
|
|
|
PJT_MUTEX_CONSISTENT,
|
|
|
|
PJT_MUTEXATTR_GETROBUST,
|
|
|
|
PJT_MUTEXATTR_SETROBUST,
|
2002-11-13 18:12:09 +00:00
|
|
|
PJT_MAX
|
|
|
|
} pjt_index_t;
|
|
|
|
|
2002-11-13 19:35:40 +00:00
|
|
|
typedef int (*pthread_func_t)(void);
|
2002-11-13 21:55:22 +00:00
|
|
|
typedef pthread_func_t pthread_func_entry_t[2];
|
2002-11-13 18:12:09 +00:00
|
|
|
|
2002-11-13 21:55:22 +00:00
|
|
|
extern pthread_func_entry_t __thr_jtable[];
|
2002-11-13 18:12:09 +00:00
|
|
|
|
2015-01-05 01:06:54 +00:00
|
|
|
void __set_error_selector(int *(*arg)(void));
|
2015-01-03 18:38:46 +00:00
|
|
|
int _pthread_mutex_init_calloc_cb_stub(pthread_mutex_t *mutex,
|
|
|
|
void *(calloc_cb)(__size_t, __size_t));
|
|
|
|
|
|
|
|
typedef int (*interpos_func_t)(void);
|
|
|
|
interpos_func_t *__libc_interposing_slot(int interposno);
|
2015-01-05 01:06:54 +00:00
|
|
|
extern interpos_func_t __libc_interposing[] __hidden;
|
2015-01-03 18:38:46 +00:00
|
|
|
|
|
|
|
enum {
|
|
|
|
INTERPOS_accept,
|
|
|
|
INTERPOS_accept4,
|
|
|
|
INTERPOS_aio_suspend,
|
|
|
|
INTERPOS_close,
|
|
|
|
INTERPOS_connect,
|
|
|
|
INTERPOS_fcntl,
|
|
|
|
INTERPOS_fsync,
|
|
|
|
INTERPOS_fork,
|
|
|
|
INTERPOS_msync,
|
|
|
|
INTERPOS_nanosleep,
|
|
|
|
INTERPOS_openat,
|
|
|
|
INTERPOS_poll,
|
|
|
|
INTERPOS_pselect,
|
|
|
|
INTERPOS_recvfrom,
|
|
|
|
INTERPOS_recvmsg,
|
|
|
|
INTERPOS_select,
|
|
|
|
INTERPOS_sendmsg,
|
|
|
|
INTERPOS_sendto,
|
|
|
|
INTERPOS_setcontext,
|
|
|
|
INTERPOS_sigaction,
|
|
|
|
INTERPOS_sigprocmask,
|
|
|
|
INTERPOS_sigsuspend,
|
|
|
|
INTERPOS_sigwait,
|
|
|
|
INTERPOS_sigtimedwait,
|
|
|
|
INTERPOS_sigwaitinfo,
|
|
|
|
INTERPOS_swapcontext,
|
|
|
|
INTERPOS_system,
|
|
|
|
INTERPOS_tcdrain,
|
|
|
|
INTERPOS_read,
|
|
|
|
INTERPOS_readv,
|
|
|
|
INTERPOS_wait4,
|
|
|
|
INTERPOS_write,
|
|
|
|
INTERPOS_writev,
|
|
|
|
INTERPOS__pthread_mutex_init_calloc_cb,
|
2015-02-14 11:47:40 +00:00
|
|
|
INTERPOS_spinlock,
|
|
|
|
INTERPOS_spinunlock,
|
Make kevent(2) a cancellation point.
Note that to cancel blocked kevent(2) call, changelist must be empty,
since we cannot cancel a call which already made changes to the
process state. And in reverse, call which only makes changes to the
kqueue state, without waiting for an event, is not cancellable. This
makes a natural usage model to migrate kqueue loop to support
cancellation, where existing single kevent(2) call must be split into
two: first uncancellable update of kqueue, then cancellable wait for
events.
Note that this is ABI-incompatible change, but it is believed that
there is no cancel-safe code that relies on kevent(2) not being a
cancellation point. Option to preserve the ABI would be to keep
kevent(2) as is, but add new call with flags to specify cancellation
behaviour, which only value seems to add complications.
Suggested and reviewed by: jilles
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
2015-03-29 19:14:41 +00:00
|
|
|
INTERPOS_kevent,
|
2015-04-18 21:35:41 +00:00
|
|
|
INTERPOS_wait6,
|
|
|
|
INTERPOS_ppoll,
|
2016-02-08 19:24:13 +00:00
|
|
|
INTERPOS_map_stacks_exec,
|
2015-01-03 18:38:46 +00:00
|
|
|
INTERPOS_MAX
|
|
|
|
};
|
|
|
|
|
2003-02-27 13:40:01 +00:00
|
|
|
/*
|
|
|
|
* yplib internal interfaces
|
|
|
|
*/
|
|
|
|
#ifdef YP
|
|
|
|
int _yp_check(char **);
|
|
|
|
#endif
|
|
|
|
|
2004-08-15 16:18:52 +00:00
|
|
|
/*
|
|
|
|
* Initialise TLS for static programs
|
|
|
|
*/
|
|
|
|
void _init_tls(void);
|
|
|
|
|
2009-11-20 19:19:51 +00:00
|
|
|
/*
|
|
|
|
* Provides pthread_once()-like functionality for both single-threaded
|
|
|
|
* and multi-threaded applications.
|
|
|
|
*/
|
|
|
|
int _once(pthread_once_t *, void (*)(void));
|
|
|
|
|
2004-08-15 16:18:52 +00:00
|
|
|
/*
|
|
|
|
* Set the TLS thread pointer
|
|
|
|
*/
|
|
|
|
void _set_tp(void *tp);
|
2003-02-27 13:40:01 +00:00
|
|
|
|
2002-03-29 22:43:43 +00:00
|
|
|
/*
|
|
|
|
* This is a pointer in the C run-time startup code. It is used
|
|
|
|
* by getprogname() and setprogname().
|
|
|
|
*/
|
|
|
|
extern const char *__progname;
|
|
|
|
|
Add thread-specific caching for small size classes, based on magazines.
This caching allows for completely lock-free allocation/deallocation in the
steady state, at the expense of likely increased memory use and
fragmentation.
Reduce the default number of arenas to 2*ncpus, since thread-specific
caching typically reduces arena contention.
Modify size class spacing to include ranges of 2^n-spaced, quantum-spaced,
cacheline-spaced, and subpage-spaced size classes. The advantages are:
fewer size classes, reduced false cacheline sharing, and reduced internal
fragmentation for allocations that are slightly over 512, 1024, etc.
Increase RUN_MAX_SMALL, in order to limit fragmentation for the
subpage-spaced size classes.
Add a size-->bin lookup table for small sizes to simplify translating sizes
to size classes. Include a hard-coded constant table that is used unless
custom size class spacing is specified at run time.
Add the ability to disable tiny size classes at compile time via
MALLOC_TINY.
2008-08-27 02:00:53 +00:00
|
|
|
/*
|
|
|
|
* This function is used by the threading libraries to notify malloc that a
|
|
|
|
* thread is exiting.
|
|
|
|
*/
|
|
|
|
void _malloc_thread_cleanup(void);
|
|
|
|
|
2016-08-06 13:32:40 +00:00
|
|
|
/*
|
|
|
|
* This function is used by the threading libraries to notify libc that a
|
|
|
|
* thread is exiting, so its thread-local dtors should be called.
|
|
|
|
*/
|
|
|
|
void __cxa_thread_call_dtors(void);
|
|
|
|
|
2003-11-04 19:49:56 +00:00
|
|
|
/*
|
2006-01-12 07:28:21 +00:00
|
|
|
* These functions are used by the threading libraries in order to protect
|
|
|
|
* malloc across fork().
|
2003-11-04 19:49:56 +00:00
|
|
|
*/
|
2006-01-12 07:28:21 +00:00
|
|
|
void _malloc_prefork(void);
|
|
|
|
void _malloc_postfork(void);
|
2003-11-04 19:49:56 +00:00
|
|
|
|
2015-01-03 18:38:46 +00:00
|
|
|
void _malloc_first_thread(void);
|
|
|
|
|
2005-09-12 13:46:32 +00:00
|
|
|
/*
|
|
|
|
* Function to clean up streams, called from abort() and exit().
|
|
|
|
*/
|
2015-02-17 08:54:03 +00:00
|
|
|
extern void (*__cleanup)(void) __hidden;
|
2005-09-12 13:46:32 +00:00
|
|
|
|
2007-07-04 23:27:38 +00:00
|
|
|
/*
|
|
|
|
* Get kern.osreldate to detect ABI revisions. Explicitly
|
The lseek(2), mmap(2), truncate(2), ftruncate(2), pread(2), and
pwrite(2) syscalls are wrapped to provide compatibility with pre-7.x
kernels which required padding before the off_t parameter. The
fcntl(2) contains compatibility code to handle kernels before the
struct flock was changed during the 8.x CURRENT development. The
shims were reasonable to allow easier revert to the older kernel at
that time.
Now, two or three major releases later, shims do not serve any
purpose. Such old kernels cannot handle current libc, so revert the
compatibility code.
Make padded syscalls support conditional under the COMPAT6 config
option. For COMPAT32, the syscalls were under COMPAT6 already.
Remove WITHOUT_SYSCALL_COMPAT build option, which only purpose was to
(partially) disable the removed shims.
Reviewed by: jhb, imp (previous versions)
Discussed with: peter
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
2015-04-18 21:50:13 +00:00
|
|
|
* ignores value of $OSVERSION and caches result.
|
2007-07-04 23:27:38 +00:00
|
|
|
*/
|
2015-01-03 18:38:46 +00:00
|
|
|
int __getosreldate(void);
|
2007-07-04 23:27:38 +00:00
|
|
|
#include <sys/_types.h>
|
2015-01-03 18:38:46 +00:00
|
|
|
#include <sys/_sigset.h>
|
2007-07-04 23:27:38 +00:00
|
|
|
|
2015-01-03 18:38:46 +00:00
|
|
|
struct aiocb;
|
|
|
|
struct fd_set;
|
|
|
|
struct iovec;
|
Make kevent(2) a cancellation point.
Note that to cancel blocked kevent(2) call, changelist must be empty,
since we cannot cancel a call which already made changes to the
process state. And in reverse, call which only makes changes to the
kqueue state, without waiting for an event, is not cancellable. This
makes a natural usage model to migrate kqueue loop to support
cancellation, where existing single kevent(2) call must be split into
two: first uncancellable update of kqueue, then cancellable wait for
events.
Note that this is ABI-incompatible change, but it is believed that
there is no cancel-safe code that relies on kevent(2) not being a
cancellation point. Option to preserve the ABI would be to keep
kevent(2) as is, but add new call with flags to specify cancellation
behaviour, which only value seems to add complications.
Suggested and reviewed by: jilles
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
2015-03-29 19:14:41 +00:00
|
|
|
struct kevent;
|
2015-01-03 18:38:46 +00:00
|
|
|
struct msghdr;
|
|
|
|
struct pollfd;
|
|
|
|
struct rusage;
|
|
|
|
struct sigaction;
|
|
|
|
struct sockaddr;
|
2012-06-22 07:13:30 +00:00
|
|
|
struct timespec;
|
|
|
|
struct timeval;
|
|
|
|
struct timezone;
|
2015-01-03 18:38:46 +00:00
|
|
|
struct __siginfo;
|
|
|
|
struct __ucontext;
|
2015-04-18 21:35:41 +00:00
|
|
|
struct __wrusage;
|
|
|
|
enum idtype;
|
2015-01-03 18:38:46 +00:00
|
|
|
int __sys_aio_suspend(const struct aiocb * const[], int,
|
|
|
|
const struct timespec *);
|
|
|
|
int __sys_accept(int, struct sockaddr *, __socklen_t *);
|
|
|
|
int __sys_accept4(int, struct sockaddr *, __socklen_t *, int);
|
|
|
|
int __sys_clock_gettime(__clockid_t, struct timespec *ts);
|
|
|
|
int __sys_close(int);
|
|
|
|
int __sys_connect(int, const struct sockaddr *, __socklen_t);
|
|
|
|
int __sys_fcntl(int, int, ...);
|
|
|
|
int __sys_fsync(int);
|
|
|
|
__pid_t __sys_fork(void);
|
|
|
|
int __sys_ftruncate(int, __off_t);
|
|
|
|
int __sys_gettimeofday(struct timeval *, struct timezone *);
|
Make kevent(2) a cancellation point.
Note that to cancel blocked kevent(2) call, changelist must be empty,
since we cannot cancel a call which already made changes to the
process state. And in reverse, call which only makes changes to the
kqueue state, without waiting for an event, is not cancellable. This
makes a natural usage model to migrate kqueue loop to support
cancellation, where existing single kevent(2) call must be split into
two: first uncancellable update of kqueue, then cancellable wait for
events.
Note that this is ABI-incompatible change, but it is believed that
there is no cancel-safe code that relies on kevent(2) not being a
cancellation point. Option to preserve the ABI would be to keep
kevent(2) as is, but add new call with flags to specify cancellation
behaviour, which only value seems to add complications.
Suggested and reviewed by: jilles
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
2015-03-29 19:14:41 +00:00
|
|
|
int __sys_kevent(int, const struct kevent *, int, struct kevent *,
|
|
|
|
int, const struct timespec *);
|
2015-01-03 18:38:46 +00:00
|
|
|
__off_t __sys_lseek(int, __off_t, int);
|
|
|
|
void *__sys_mmap(void *, __size_t, int, int, int, __off_t);
|
|
|
|
int __sys_msync(void *, __size_t, int);
|
|
|
|
int __sys_nanosleep(const struct timespec *, struct timespec *);
|
|
|
|
int __sys_open(const char *, int, ...);
|
|
|
|
int __sys_openat(int, const char *, int, ...);
|
|
|
|
int __sys_pselect(int, struct fd_set *, struct fd_set *,
|
|
|
|
struct fd_set *, const struct timespec *,
|
|
|
|
const __sigset_t *);
|
|
|
|
int __sys_poll(struct pollfd *, unsigned, int);
|
2015-04-18 21:35:41 +00:00
|
|
|
int __sys_ppoll(struct pollfd *, unsigned, const struct timespec *,
|
|
|
|
const __sigset_t *);
|
2015-01-03 18:38:46 +00:00
|
|
|
__ssize_t __sys_pread(int, void *, __size_t, __off_t);
|
|
|
|
__ssize_t __sys_pwrite(int, const void *, __size_t, __off_t);
|
|
|
|
__ssize_t __sys_read(int, void *, __size_t);
|
|
|
|
__ssize_t __sys_readv(int, const struct iovec *, int);
|
|
|
|
__ssize_t __sys_recv(int, void *, __size_t, int);
|
|
|
|
__ssize_t __sys_recvfrom(int, void *, __size_t, int, struct sockaddr *,
|
|
|
|
__socklen_t *);
|
|
|
|
__ssize_t __sys_recvmsg(int, struct msghdr *, int);
|
|
|
|
int __sys_select(int, struct fd_set *, struct fd_set *,
|
|
|
|
struct fd_set *, struct timeval *);
|
|
|
|
__ssize_t __sys_sendmsg(int, const struct msghdr *, int);
|
|
|
|
__ssize_t __sys_sendto(int, const void *, __size_t, int,
|
|
|
|
const struct sockaddr *, __socklen_t);
|
|
|
|
int __sys_setcontext(const struct __ucontext *);
|
|
|
|
int __sys_sigaction(int, const struct sigaction *,
|
|
|
|
struct sigaction *);
|
|
|
|
int __sys_sigprocmask(int, const __sigset_t *, __sigset_t *);
|
|
|
|
int __sys_sigsuspend(const __sigset_t *);
|
|
|
|
int __sys_sigtimedwait(const __sigset_t *, struct __siginfo *,
|
|
|
|
const struct timespec *);
|
|
|
|
int __sys_sigwait(const __sigset_t *, int *);
|
|
|
|
int __sys_sigwaitinfo(const __sigset_t *, struct __siginfo *);
|
|
|
|
int __sys_swapcontext(struct __ucontext *,
|
|
|
|
const struct __ucontext *);
|
2015-01-11 22:16:31 +00:00
|
|
|
int __sys_thr_kill(long, int);
|
|
|
|
int __sys_thr_self(long *);
|
2015-01-03 18:38:46 +00:00
|
|
|
int __sys_truncate(const char *, __off_t);
|
|
|
|
__pid_t __sys_wait4(__pid_t, int *, int, struct rusage *);
|
2015-04-18 21:35:41 +00:00
|
|
|
__pid_t __sys_wait6(enum idtype, __id_t, int *, int,
|
|
|
|
struct __wrusage *, struct __siginfo *);
|
2015-01-03 18:38:46 +00:00
|
|
|
__ssize_t __sys_write(int, const void *, __size_t);
|
|
|
|
__ssize_t __sys_writev(int, const struct iovec *, int);
|
|
|
|
|
2015-08-29 14:25:01 +00:00
|
|
|
int __libc_sigaction(int, const struct sigaction *,
|
|
|
|
struct sigaction *) __hidden;
|
|
|
|
int __libc_sigprocmask(int, const __sigset_t *, __sigset_t *)
|
|
|
|
__hidden;
|
|
|
|
int __libc_sigsuspend(const __sigset_t *) __hidden;
|
2015-01-03 18:38:46 +00:00
|
|
|
int __libc_sigwait(const __sigset_t * __restrict,
|
|
|
|
int * restrict sig);
|
|
|
|
int __libc_system(const char *);
|
|
|
|
int __libc_tcdrain(int);
|
|
|
|
int __fcntl_compat(int fd, int cmd, ...);
|
2012-06-22 07:13:30 +00:00
|
|
|
|
2015-01-23 21:07:08 +00:00
|
|
|
int __sys_futimens(int fd, const struct timespec *times) __hidden;
|
|
|
|
int __sys_utimensat(int fd, const char *path,
|
|
|
|
const struct timespec *times, int flag) __hidden;
|
|
|
|
|
2008-06-23 05:22:06 +00:00
|
|
|
/* execve() with PATH processing to implement posix_spawnp() */
|
|
|
|
int _execvpe(const char *, char * const *, char * const *);
|
|
|
|
|
2010-08-17 09:13:26 +00:00
|
|
|
int _elf_aux_info(int aux, void *buf, int buflen);
|
2010-08-23 15:38:02 +00:00
|
|
|
struct dl_phdr_info;
|
|
|
|
int __elf_phdr_match_addr(struct dl_phdr_info *, void *);
|
2012-02-17 10:49:29 +00:00
|
|
|
void __init_elf_aux_vector(void);
|
2016-02-08 22:02:56 +00:00
|
|
|
void __libc_map_stacks_exec(void);
|
2010-08-17 09:13:26 +00:00
|
|
|
|
2010-09-25 01:57:47 +00:00
|
|
|
void _pthread_cancel_enter(int);
|
|
|
|
void _pthread_cancel_leave(int);
|
|
|
|
|
1998-04-11 06:57:33 +00:00
|
|
|
#endif /* _LIBC_PRIVATE_H_ */
|