diff options
Diffstat (limited to 'lib/libc/include')
-rw-r--r-- | lib/libc/include/fpmath.h | 66 | ||||
-rw-r--r-- | lib/libc/include/libc_private.h | 175 | ||||
-rw-r--r-- | lib/libc/include/namespace.h | 259 | ||||
-rw-r--r-- | lib/libc/include/nscache.h | 197 | ||||
-rw-r--r-- | lib/libc/include/nscachedcli.h | 107 | ||||
-rw-r--r-- | lib/libc/include/nss_tls.h | 80 | ||||
-rw-r--r-- | lib/libc/include/port_after.h | 11 | ||||
-rw-r--r-- | lib/libc/include/port_before.h | 22 | ||||
-rw-r--r-- | lib/libc/include/reentrant.h | 135 | ||||
-rw-r--r-- | lib/libc/include/spinlock.h | 73 | ||||
-rw-r--r-- | lib/libc/include/un-namespace.h | 249 |
11 files changed, 1374 insertions, 0 deletions
diff --git a/lib/libc/include/fpmath.h b/lib/libc/include/fpmath.h new file mode 100644 index 0000000..d33cfdc --- /dev/null +++ b/lib/libc/include/fpmath.h @@ -0,0 +1,66 @@ +/*- + * Copyright (c) 2003 Mike Barcroft <mike@FreeBSD.org> + * Copyright (c) 2002 David Schultz <das@FreeBSD.ORG> + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. + * + * $FreeBSD$ + */ + +#include <sys/endian.h> +#include "_fpmath.h" + +union IEEEf2bits { + float f; + struct { +#if _BYTE_ORDER == _LITTLE_ENDIAN + unsigned int man :23; + unsigned int exp :8; + unsigned int sign :1; +#else /* _BIG_ENDIAN */ + unsigned int sign :1; + unsigned int exp :8; + unsigned int man :23; +#endif + } bits; +}; + +#define DBL_MANH_SIZE 20 +#define DBL_MANL_SIZE 32 + +union IEEEd2bits { + double d; + struct { +#if _BYTE_ORDER == _LITTLE_ENDIAN + unsigned int manl :32; + unsigned int manh :20; + unsigned int exp :11; + unsigned int sign :1; +#else /* _BIG_ENDIAN */ + unsigned int sign :1; + unsigned int exp :11; + unsigned int manh :20; + unsigned int manl :32; +#endif + } bits; +}; diff --git a/lib/libc/include/libc_private.h b/lib/libc/include/libc_private.h new file mode 100644 index 0000000..cd5769e --- /dev/null +++ b/lib/libc/include/libc_private.h @@ -0,0 +1,175 @@ +/* + * 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. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by John Birrell. + * 4. Neither the name of the author nor the names of any co-contributors + * 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. + * + * $FreeBSD$ + * + * Private definitions for libc, libc_r and libpthread. + * + */ + +#ifndef _LIBC_PRIVATE_H_ +#define _LIBC_PRIVATE_H_ + +/* + * 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; + +/* + * 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 +#define _FLOCKFILE(x) _flockfile(x) +#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) +#define FUNLOCKFILE(fp) if (__isthreaded) _funlockfile(fp) + +/* + * 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 { + 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, + PJT_COND_BROADCAST, + PJT_COND_DESTROY, + PJT_COND_INIT, + PJT_COND_SIGNAL, + PJT_COND_TIMEDWAIT, + PJT_COND_WAIT, + PJT_DETACH, + PJT_EQUAL, + PJT_EXIT, + PJT_GETSPECIFIC, + PJT_JOIN, + PJT_KEY_CREATE, + PJT_KEY_DELETE, + PJT_KILL, + PJT_MAIN_NP, + PJT_MUTEXATTR_DESTROY, + PJT_MUTEXATTR_INIT, + PJT_MUTEXATTR_SETTYPE, + 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, + PJT_SETCANCELSTATE, + PJT_SETCANCELTYPE, + PJT_SETSPECIFIC, + PJT_SIGMASK, + PJT_TESTCANCEL, + PJT_MAX +} pjt_index_t; + +typedef int (*pthread_func_t)(void); +typedef pthread_func_t pthread_func_entry_t[2]; + +extern pthread_func_entry_t __thr_jtable[]; + +/* + * yplib internal interfaces + */ +#ifdef YP +int _yp_check(char **); +#endif + +/* + * Initialise TLS for static programs + */ +void _init_tls(void); + +/* + * Set the TLS thread pointer + */ +void _set_tp(void *tp); + +/* + * This is a pointer in the C run-time startup code. It is used + * by getprogname() and setprogname(). + */ +extern const char *__progname; + +/* + * These functions are used by the threading libraries in order to protect + * malloc across fork(). + */ +void _malloc_prefork(void); +void _malloc_postfork(void); + +/* + * Function to clean up streams, called from abort() and exit(). + */ +extern void (*__cleanup)(void); + +#endif /* _LIBC_PRIVATE_H_ */ diff --git a/lib/libc/include/namespace.h b/lib/libc/include/namespace.h new file mode 100644 index 0000000..9ad181e --- /dev/null +++ b/lib/libc/include/namespace.h @@ -0,0 +1,259 @@ +/* + * Copyright (c) 2001 Daniel Eischen <deischen@FreeBSD.org>. + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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. + * + * $FreeBSD$ + */ + +#ifndef _NAMESPACE_H_ +#define _NAMESPACE_H_ + +/* + * Adjust names so that headers declare "hidden" names. + * + * README: When modifying this file don't forget to make the appropriate + * changes in un-namespace.h!!! + */ + +/* + * ISO C (C90) section. Most names in libc aren't in ISO C, so they + * should be here. Most aren't here... + */ +#define err _err +#define warn _warn +#define nsdispatch _nsdispatch + +/* + * Prototypes for syscalls/functions that need to be overridden + * in libc_r/libpthread. + */ +#define accept _accept +#define __acl_aclcheck_fd ___acl_aclcheck_fd +#define __acl_delete_fd ___acl_delete_fd +#define __acl_get_fd ___acl_get_fd +#define __acl_set_fd ___acl_set_fd +#define bind _bind +#define __cap_get_fd ___cap_get_fd +#define __cap_set_fd ___cap_set_fd +#define close _close +#define connect _connect +#define dup _dup +#define dup2 _dup2 +#define execve _execve +#define fcntl _fcntl +/*#define flock _flock */ +#define flockfile _flockfile +#define fpathconf _fpathconf +#define fstat _fstat +#define fstatfs _fstatfs +#define fsync _fsync +#define funlockfile _funlockfile +#define getdirentries _getdirentries +#define getlogin _getlogin +#define getpeername _getpeername +#define getprogname _getprogname +#define getsockname _getsockname +#define getsockopt _getsockopt +#define ioctl _ioctl +/* #define kevent _kevent */ +#define listen _listen +#define nanosleep _nanosleep +#define open _open +#define poll _poll +#define pthread_atfork _pthread_atfork +#define pthread_attr_destroy _pthread_attr_destroy +#define pthread_attr_get_np _pthread_attr_get_np +#define pthread_attr_getdetachstate _pthread_attr_getdetachstate +#define pthread_attr_getguardsize _pthread_attr_getguardsize +#define pthread_attr_getinheritsched _pthread_attr_getinheritsched +#define pthread_attr_getschedparam _pthread_attr_getschedparam +#define pthread_attr_getschedpolicy _pthread_attr_getschedpolicy +#define pthread_attr_getscope _pthread_attr_getscope +#define pthread_attr_getstack _pthread_attr_getstack +#define pthread_attr_getstackaddr _pthread_attr_getstackaddr +#define pthread_attr_getstacksize _pthread_attr_getstacksize +#define pthread_attr_init _pthread_attr_init +#define pthread_attr_setcreatesuspend_np _pthread_attr_setcreatesuspend_np +#define pthread_attr_setdetachstate _pthread_attr_setdetachstate +#define pthread_attr_setguardsize _pthread_attr_setguardsize +#define pthread_attr_setinheritsched _pthread_attr_setinheritsched +#define pthread_attr_setschedparam _pthread_attr_setschedparam +#define pthread_attr_setschedpolicy _pthread_attr_setschedpolicy +#define pthread_attr_setscope _pthread_attr_setscope +#define pthread_attr_setstack _pthread_attr_setstack +#define pthread_attr_setstackaddr _pthread_attr_setstackaddr +#define pthread_attr_setstacksize _pthread_attr_setstacksize +#define pthread_barrier_destroy _pthread_barrier_destroy +#define pthread_barrier_init _pthread_barrier_init +#define pthread_barrier_wait _pthread_barrier_wait +#define pthread_barrierattr_destroy _pthread_barrierattr_destroy +#define pthread_barrierattr_getpshared _pthread_barrierattr_getpshared +#define pthread_barrierattr_init _pthread_barrierattr_init +#define pthread_barrierattr_setpshared _pthread_barrierattr_setpshared +#define pthread_cancel _pthread_cancel +#define pthread_cleanup_pop _pthread_cleanup_pop +#define pthread_cleanup_push _pthread_cleanup_push +#define pthread_cond_broadcast _pthread_cond_broadcast +#define pthread_cond_destroy _pthread_cond_destroy +#define pthread_cond_init _pthread_cond_init +#define pthread_cond_signal _pthread_cond_signal +#define pthread_cond_timedwait _pthread_cond_timedwait +#define pthread_cond_wait _pthread_cond_wait +#define pthread_condattr_destroy _pthread_condattr_destroy +#define pthread_condattr_getclock _pthread_condattr_getclock +#define pthread_condattr_getpshared _pthread_condattr_getpshared +#define pthread_condattr_init _pthread_condattr_init +#define pthread_condattr_setclock _pthread_condattr_setclock +#define pthread_condattr_setpshared _pthread_condattr_setpshared +#define pthread_create _pthread_create +#define pthread_detach _pthread_detach +#define pthread_equal _pthread_equal +#define pthread_exit _pthread_exit +#define pthread_getconcurrency _pthread_getconcurrency +#define pthread_getprio _pthread_getprio +#define pthread_getschedparam _pthread_getschedparam +#define pthread_getspecific _pthread_getspecific +#define pthread_join _pthread_join +#define pthread_key_create _pthread_key_create +#define pthread_key_delete _pthread_key_delete +#define pthread_kill _pthread_kill +#define pthread_main_np _pthread_main_np +#define pthread_multi_np _pthread_multi_np +#define pthread_mutex_destroy _pthread_mutex_destroy +#define pthread_mutex_getprioceiling _pthread_mutex_getprioceiling +#define pthread_mutex_init _pthread_mutex_init +#define pthread_mutex_lock _pthread_mutex_lock +#define pthread_mutex_setprioceiling _pthread_mutex_setprioceiling +#define pthread_mutex_timedlock _pthread_mutex_timedlock +#define pthread_mutex_trylock _pthread_mutex_trylock +#define pthread_mutex_unlock _pthread_mutex_unlock +#define pthread_mutexattr_destroy _pthread_mutexattr_destroy +#define pthread_mutexattr_getkind_np _pthread_mutexattr_getkind_np +#define pthread_mutexattr_getprioceiling _pthread_mutexattr_getprioceiling +#define pthread_mutexattr_getprotocol _pthread_mutexattr_getprotocol +#define pthread_mutexattr_getpshared _pthread_mutexattr_getpshared +#define pthread_mutexattr_gettype _pthread_mutexattr_gettype +#define pthread_mutexattr_init _pthread_mutexattr_init +#define pthread_mutexattr_setkind_np _pthread_mutexattr_setkind_np +#define pthread_mutexattr_setprioceiling _pthread_mutexattr_setprioceiling +#define pthread_mutexattr_setprotocol _pthread_mutexattr_setprotocol +#define pthread_mutexattr_setpshared _pthread_mutexattr_setpshared +#define pthread_mutexattr_settype _pthread_mutexattr_settype +#define pthread_once _pthread_once +#define pthread_resume_all_np _pthread_resume_all_np +#define pthread_resume_np _pthread_resume_np +#define pthread_rwlock_destroy _pthread_rwlock_destroy +#define pthread_rwlock_init _pthread_rwlock_init +#define pthread_rwlock_rdlock _pthread_rwlock_rdlock +#define pthread_rwlock_timedrdlock _pthread_rwlock_timedrdlock +#define pthread_rwlock_timedwrlock _pthread_rwlock_timedwrlock +#define pthread_rwlock_tryrdlock _pthread_rwlock_tryrdlock +#define pthread_rwlock_trywrlock _pthread_rwlock_trywrlock +#define pthread_rwlock_unlock _pthread_rwlock_unlock +#define pthread_rwlock_wrlock _pthread_rwlock_wrlock +#define pthread_rwlockattr_destroy _pthread_rwlockattr_destroy +#define pthread_rwlockattr_getpshared _pthread_rwlockattr_getpshared +#define pthread_rwlockattr_init _pthread_rwlockattr_init +#define pthread_rwlockattr_setpshared _pthread_rwlockattr_setpshared +#define pthread_self _pthread_self +#define pthread_set_name_np _pthread_set_name_np +#define pthread_setcancelstate _pthread_setcancelstate +#define pthread_setcanceltype _pthread_setcanceltype +#define pthread_setconcurrency _pthread_setconcurrency +#define pthread_setprio _pthread_setprio +#define pthread_setschedparam _pthread_setschedparam +#define pthread_setspecific _pthread_setspecific +#define pthread_sigmask _pthread_sigmask +#define pthread_single_np _pthread_single_np +#define pthread_spin_destroy _pthread_spin_destroy +#define pthread_spin_init _pthread_spin_init +#define pthread_spin_lock _pthread_spin_lock +#define pthread_spin_trylock _pthread_spin_trylock +#define pthread_spin_unlock _pthread_spin_unlock +#define pthread_suspend_all_np _pthread_suspend_all_np +#define pthread_suspend_np _pthread_suspend_np +#define pthread_switch_add_np _pthread_switch_add_np +#define pthread_switch_delete_np _pthread_switch_delete_np +#define pthread_testcancel _pthread_testcancel +#define pthread_timedjoin_np _pthread_timedjoin_np +#define pthread_yield _pthread_yield +#define read _read +#define readv _readv +#define recvfrom _recvfrom +#define recvmsg _recvmsg +#define select _select +#define sem_close _sem_close +#define sem_destroy _sem_destroy +#define sem_getvalue _sem_getvalue +#define sem_init _sem_init +#define sem_open _sem_open +#define sem_post _sem_post +#define sem_timedwait _sem_timedwait +#define sem_trywait _sem_trywait +#define sem_unlink _sem_unlink +#define sem_wait _sem_wait +#define sendmsg _sendmsg +#define sendto _sendto +#define setsockopt _setsockopt +/*#define sigaction _sigaction*/ +#define sigprocmask _sigprocmask +#define sigsuspend _sigsuspend +#define socket _socket +#define socketpair _socketpair +#define usleep _usleep +#define wait4 _wait4 +#define waitpid _waitpid +#define write _write +#define writev _writev + + +/* + * Other hidden syscalls/functions that libc_r needs to override + * but are not used internally by libc. + * + * XXX - When modifying libc to use one of the following, remove + * the prototype from below and place it in the list above. + */ +#if 0 +#define creat _creat +#define fchflags _fchflags +#define fchmod _fchmod +#define ftrylockfile _ftrylockfile +#define msync _msync +#define nfssvc _nfssvc +#define pause _pause +#define sched_yield _sched_yield +#define sendfile _sendfile +#define shutdown _shutdown +#define sigaltstack _sigaltstack +#define sigpending _sigpending +#define sigreturn _sigreturn +#define sigsetmask _sigsetmask +#define sleep _sleep +#define system _system +#define tcdrain _tcdrain +#define wait _wait +#endif + +#endif /* _NAMESPACE_H_ */ diff --git a/lib/libc/include/nscache.h b/lib/libc/include/nscache.h new file mode 100644 index 0000000..015c4ec --- /dev/null +++ b/lib/libc/include/nscache.h @@ -0,0 +1,197 @@ +/*- + * Copyright (c) 2005 Michael Bushkov <bushman@rsu.ru> + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. + * + * $FreeBSD$ + */ + +#ifndef __NS_CACHE_H__ +#define __NS_CACHE_H__ + +#include "nscachedcli.h" + +typedef int (*nss_cache_id_func_t)(char *, size_t *, va_list, void *); +typedef int (*nss_cache_marshal_func_t)(char *, size_t *, void *, va_list, + void *); +typedef int (*nss_cache_unmarshal_func_t)(char *, size_t, void *, va_list, + void *); + +typedef void (*nss_set_mp_ws_func_t)(cached_mp_write_session); +typedef cached_mp_write_session (*nss_get_mp_ws_func_t)(void); + +typedef void (*nss_set_mp_rs_func_t)(cached_mp_read_session); +typedef cached_mp_read_session (*nss_get_mp_rs_func_t)(void); + +typedef struct _nss_cache_info { + char *entry_name; + void *mdata; + + /* + * These 3 functions should be implemented specifically for each + * nsswitch database. + */ + nss_cache_id_func_t id_func; /* marshals the request parameters */ + nss_cache_marshal_func_t marshal_func; /* marshals response */ + nss_cache_unmarshal_func_t unmarshal_func; /* unmarshals response */ + + /* + * These 4 functions should be generated with NSS_MP_CACHE_HANDLING + * macro. + */ + nss_set_mp_ws_func_t set_mp_ws_func; /* sets current write session */ + nss_get_mp_ws_func_t get_mp_ws_func; /* gets current write session */ + + nss_set_mp_rs_func_t set_mp_rs_func; /* sets current read session */ + nss_get_mp_rs_func_t get_mp_rs_func; /* gets current read session */ +} nss_cache_info; + +/* + * NSS_MP_CACHE_HANDLING implements the set_mp_ws, get_mp_ws, set_mp_rs, + * get_mp_rs functions, that are used in _nss_cache_info. It uses + * NSS_TLS_HANDLING macro to organize thread local storage. + */ +#define NSS_MP_CACHE_HANDLING(name) \ +struct name##_mp_state { \ + cached_mp_write_session mp_write_session; \ + cached_mp_read_session mp_read_session; \ +}; \ + \ +static void \ +name##_mp_endstate(void *s) { \ + struct name##_mp_state *mp_state; \ + \ + mp_state = (struct name##_mp_state *)s; \ + if (mp_state->mp_write_session != INVALID_CACHED_MP_WRITE_SESSION)\ + __abandon_cached_mp_write_session(mp_state->mp_write_session);\ + \ + if (mp_state->mp_read_session != INVALID_CACHED_MP_READ_SESSION)\ + __close_cached_mp_read_session(mp_state->mp_read_session);\ +} \ +NSS_TLS_HANDLING(name##_mp); \ + \ +static void \ +name##_set_mp_ws(cached_mp_write_session ws) \ +{ \ + struct name##_mp_state *mp_state; \ + int res; \ + \ + res = name##_mp_getstate(&mp_state); \ + if (res != 0) \ + return; \ + \ + mp_state->mp_write_session = ws; \ +} \ + \ +static cached_mp_write_session \ +name##_get_mp_ws(void) \ +{ \ + struct name##_mp_state *mp_state; \ + int res; \ + \ + res = name##_mp_getstate(&mp_state); \ + if (res != 0) \ + return (INVALID_CACHED_MP_WRITE_SESSION); \ + \ + return (mp_state->mp_write_session); \ +} \ + \ +static void \ +name##_set_mp_rs(cached_mp_read_session rs) \ +{ \ + struct name##_mp_state *mp_state; \ + int res; \ + \ + res = name##_mp_getstate(&mp_state); \ + if (res != 0) \ + return; \ + \ + mp_state->mp_read_session = rs; \ +} \ + \ +static cached_mp_read_session \ +name##_get_mp_rs(void) \ +{ \ + struct name##_mp_state *mp_state; \ + int res; \ + \ + res = name##_mp_getstate(&mp_state); \ + if (res != 0) \ + return (INVALID_CACHED_MP_READ_SESSION); \ + \ + return (mp_state->mp_read_session); \ +} + +/* + * These macros should be used to initialize _nss_cache_info structure. For + * multipart queries in setXXXent and getXXXent functions mf and uf + * (marshal function and unmarshal function) should be both NULL. + */ +#define NS_COMMON_CACHE_INFO_INITIALIZER(name, mdata, if, mf, uf) \ + {#name, mdata, if, mf, uf, NULL, NULL, NULL, NULL} +#define NS_MP_CACHE_INFO_INITIALIZER(name, mdata, mf, uf) \ + {#name, mdata, NULL, mf, uf, name##_set_mp_ws, name##_get_mp_ws,\ + name##_set_mp_rs, name##_get_mp_rs } + +/* + * Analog of other XXX_CB macros. Has the pointer to _nss_cache_info + * structure as the only argument. + */ +#define NS_CACHE_CB(cinfo) {NSSRC_CACHE, __nss_cache_handler, (void *)(cinfo) }, + +/* args are: current pointer, current buffer, initial buffer, pointer type */ +#define NS_APPLY_OFFSET(cp, cb, ib, p_type) \ + if ((cp) != NULL) \ + (cp) = (p_type)((char *)(cb) + (size_t)(cp) - (size_t)(ib)) +/* + * Gets new pointer from the marshalled buffer by uisng initial address + * and initial buffer address + */ +#define NS_GET_NEWP(cp, cb, ib) \ + ((char *)(cb) + (size_t)(cp) - (size_t)(ib)) + +typedef struct _nss_cache_data { + char *key; + size_t key_size; + + nss_cache_info const *info; +} nss_cache_data; + +__BEGIN_DECLS +/* dummy function, which is needed to make nss_method_lookup happy */ +extern int __nss_cache_handler(void *, void *, va_list); + +#ifdef _NS_PRIVATE +extern int __nss_common_cache_read(void *, void *, va_list); +extern int __nss_common_cache_write(void *, void *, va_list); +extern int __nss_common_cache_write_negative(void *); + +extern int __nss_mp_cache_read(void *, void *, va_list); +extern int __nss_mp_cache_write(void *, void *, va_list); +extern int __nss_mp_cache_write_submit(void *, void *, va_list); +extern int __nss_mp_cache_end(void *, void *, va_list); +#endif /* _NS_PRIVATE */ + +__END_DECLS + +#endif diff --git a/lib/libc/include/nscachedcli.h b/lib/libc/include/nscachedcli.h new file mode 100644 index 0000000..b0f79bd --- /dev/null +++ b/lib/libc/include/nscachedcli.h @@ -0,0 +1,107 @@ +/*- + * Copyright (c) 2004 Michael Bushkov <bushman@rsu.ru> + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. + * + * $FreeBSD$ + */ + +#ifndef __NS_CACHED_CLI_H__ +#define __NS_CACHED_CLI_H__ + +/* + * This file contains API for working with caching daemon + */ + +enum comm_element_t { + CET_UNDEFINED = 0, + CET_WRITE_REQUEST = 1, + CET_WRITE_RESPONSE = 2, + CET_READ_REQUEST = 3, + CET_READ_RESPONSE = 4, + CET_TRANSFORM_REQUEST = 5, + CET_TRANSFORM_RESPONSE = 6, + CET_MP_WRITE_SESSION_REQUEST = 7, + CET_MP_WRITE_SESSION_RESPONSE = 8, + CET_MP_WRITE_SESSION_WRITE_REQUEST = 9, + CET_MP_WRITE_SESSION_WRITE_RESPONSE = 10, + CET_MP_WRITE_SESSION_CLOSE_NOTIFICATION = 11, + CET_MP_WRITE_SESSION_ABANDON_NOTIFICATION = 12, + CET_MP_READ_SESSION_REQUEST = 13, + CET_MP_READ_SESSION_RESPONSE = 14, + CET_MP_READ_SESSION_READ_REQUEST = 15, + CET_MP_READ_SESSION_READ_RESPONSE = 16, + CET_MP_READ_SESSION_CLOSE_NOTIFICATION = 17 +}; + +struct cached_connection_params { + char *socket_path; + struct timeval timeout; +}; + +struct cached_connection_ { + int sockfd; + int read_queue; + int write_queue; + + int mp_flag; /* shows if the connection is used for + * multipart operations */ +}; + +/* simple abstractions for not to write "struct" every time */ +typedef struct cached_connection_ *cached_connection; +typedef struct cached_connection_ *cached_mp_write_session; +typedef struct cached_connection_ *cached_mp_read_session; + +#define INVALID_CACHED_CONNECTION (NULL) +#define INVALID_CACHED_MP_WRITE_SESSION (NULL) +#define INVALID_CACHED_MP_READ_SESSION (NULL) + +__BEGIN_DECLS + +/* initialization/destruction routines */ +extern cached_connection __open_cached_connection( + struct cached_connection_params const *); +extern void __close_cached_connection(cached_connection); + +/* simple read/write operations */ +extern int __cached_write(cached_connection, const char *, const char *, + size_t, const char *, size_t); +extern int __cached_read(cached_connection, const char *, const char *, + size_t, char *, size_t *); + +/* multipart read/write operations */ +extern cached_mp_write_session __open_cached_mp_write_session( + struct cached_connection_params const *, const char *); +extern int __cached_mp_write(cached_mp_write_session, const char *, size_t); +extern int __abandon_cached_mp_write_session(cached_mp_write_session); +extern int __close_cached_mp_write_session(cached_mp_write_session); + +extern cached_mp_read_session __open_cached_mp_read_session( + struct cached_connection_params const *, const char *); +extern int __cached_mp_read(cached_mp_read_session, char *, size_t *); +extern int __close_cached_mp_read_session(cached_mp_read_session); + +__END_DECLS + +#endif diff --git a/lib/libc/include/nss_tls.h b/lib/libc/include/nss_tls.h new file mode 100644 index 0000000..13ab367 --- /dev/null +++ b/lib/libc/include/nss_tls.h @@ -0,0 +1,80 @@ +/*- + * Copyright (c) 2003 Networks Associates Technology, Inc. + * All rights reserved. + * + * This software was developed for the FreeBSD Project by + * Jacques A. Vidrine, Safeport Network Services, and Network + * Associates Laboratories, the Security Research Division of Network + * Associates, Inc. under DARPA/SPAWAR contract N66001-01-C-8035 + * ("CBOSS"), as part of the DARPA CHATS research program. + * + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. + * + * $FreeBSD$ + * + * Macros which generate thread local storage handling code in NSS modules. + */ +#ifndef _NSS_TLS_H_ +#define _NSS_TLS_H_ + +#define NSS_TLS_HANDLING(name) \ +static pthread_key_t name##_state_key; \ +static void name##_keyinit(void); \ +static int name##_getstate(struct name##_state **); \ +\ +static void \ +name##_keyinit(void) \ +{ \ + (void)_pthread_key_create(&name##_state_key, name##_endstate); \ +} \ +\ +static int \ +name##_getstate(struct name##_state **p) \ +{ \ + static struct name##_state st; \ + static pthread_once_t keyinit = PTHREAD_ONCE_INIT; \ + int rv; \ + \ + if (!__isthreaded || _pthread_main_np() != 0) { \ + *p = &st; \ + return (0); \ + } \ + rv = _pthread_once(&keyinit, name##_keyinit); \ + if (rv != 0) \ + return (rv); \ + *p = _pthread_getspecific(name##_state_key); \ + if (*p != NULL) \ + return (0); \ + *p = calloc(1, sizeof(**p)); \ + if (*p == NULL) \ + return (ENOMEM); \ + rv = _pthread_setspecific(name##_state_key, *p); \ + if (rv != 0) { \ + free(*p); \ + *p = NULL; \ + } \ + return (rv); \ +} \ +/* allow the macro invocation to end with a semicolon */ \ +struct _clashproof_bmVjdGFy + +#endif /* _NSS_TLS_H_ */ diff --git a/lib/libc/include/port_after.h b/lib/libc/include/port_after.h new file mode 100644 index 0000000..94f3a64 --- /dev/null +++ b/lib/libc/include/port_after.h @@ -0,0 +1,11 @@ +/* $FreeBSD$ */ + +#ifndef _PORT_AFTER_H_ +#define _PORT_AFTER_H_ + +#define HAVE_SA_LEN 1 +#define HAS_INET6_STRUCTS 1 +#define HAVE_SIN6_SCOPE_ID 1 +#define HAVE_TIME_R 1 + +#endif /* _PORT_AFTER_H_ */ diff --git a/lib/libc/include/port_before.h b/lib/libc/include/port_before.h new file mode 100644 index 0000000..beef71d --- /dev/null +++ b/lib/libc/include/port_before.h @@ -0,0 +1,22 @@ +/* $FreeBSD$ */ + +#ifndef _PORT_BEFORE_H_ +#define _PORT_BEFORE_H_ + +#define _LIBC 1 +#define DO_PTHREADS 1 +#define USE_KQUEUE 1 + +#define ISC_SOCKLEN_T socklen_t +#define ISC_FORMAT_PRINTF(fmt, args) \ + __attribute__((__format__(__printf__, fmt, args))) +#define DE_CONST(konst, var) \ + do { \ + union { const void *k; void *v; } _u; \ + _u.k = konst; \ + var = _u.v; \ + } while (0) + +#define UNUSED(x) (x) = (x) + +#endif /* _PORT_BEFORE_H_ */ diff --git a/lib/libc/include/reentrant.h b/lib/libc/include/reentrant.h new file mode 100644 index 0000000..8ab328b --- /dev/null +++ b/lib/libc/include/reentrant.h @@ -0,0 +1,135 @@ +/*- + * Copyright (c) 1997,98 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by J.T. Conklin. + * + * 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. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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. + * + * $FreeBSD$ + */ + +/* + * Requirements: + * + * 1. The thread safe mechanism should be lightweight so the library can + * be used by non-threaded applications without unreasonable overhead. + * + * 2. There should be no dependency on a thread engine for non-threaded + * applications. + * + * 3. There should be no dependency on any particular thread engine. + * + * 4. The library should be able to be compiled without support for thread + * safety. + * + * + * Rationale: + * + * One approach for thread safety is to provide discrete versions of the + * library: one thread safe, the other not. The disadvantage of this is + * that libc is rather large, and two copies of a library which are 99%+ + * identical is not an efficent use of resources. + * + * Another approach is to provide a single thread safe library. However, + * it should not add significant run time or code size overhead to non- + * threaded applications. + * + * Since the NetBSD C library is used in other projects, it should be + * easy to replace the mutual exclusion primitives with ones provided by + * another system. Similarly, it should also be easy to remove all + * support for thread safety completely if the target environment does + * not support threads. + * + * + * Implementation Details: + * + * The mutex primitives used by the library (mutex_t, mutex_lock, etc.) + * are macros which expand to the cooresponding primitives provided by + * the thread engine or to nothing. The latter is used so that code is + * not unreasonably cluttered with #ifdefs when all thread safe support + * is removed. + * + * The mutex macros can be directly mapped to the mutex primitives from + * pthreads, however it should be reasonably easy to wrap another mutex + * implementation so it presents a similar interface. + * + * Stub implementations of the mutex functions are provided with *weak* + * linkage. These functions simply return success. When linked with a + * thread library (i.e. -lpthread), the functions will override the + * stubs. + */ + +#include <pthread.h> +#include <pthread_np.h> +#include "libc_private.h" + +#define mutex_t pthread_mutex_t +#define cond_t pthread_cond_t +#define rwlock_t pthread_rwlock_t +#define once_t pthread_once_t + +#define thread_key_t pthread_key_t +#define MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER +#define RWLOCK_INITIALIZER PTHREAD_RWLOCK_INITIALIZER +#define ONCE_INITIALIZER PTHREAD_ONCE_INIT + +#define mutex_init(m, a) _pthread_mutex_init(m, a) +#define mutex_lock(m) if (__isthreaded) \ + _pthread_mutex_lock(m) +#define mutex_unlock(m) if (__isthreaded) \ + _pthread_mutex_unlock(m) +#define mutex_trylock(m) (__isthreaded ? 0 : _pthread_mutex_trylock(m)) + +#define cond_init(c, a, p) _pthread_cond_init(c, a) +#define cond_signal(m) if (__isthreaded) \ + _pthread_cond_signal(m) +#define cond_broadcast(m) if (__isthreaded) \ + _pthread_cond_broadcast(m) +#define cond_wait(c, m) if (__isthreaded) \ + _pthread_cond_wait(c, m) + +#define rwlock_init(l, a) _pthread_rwlock_init(l, a) +#define rwlock_rdlock(l) if (__isthreaded) \ + _pthread_rwlock_rdlock(l) +#define rwlock_wrlock(l) if (__isthreaded) \ + _pthread_rwlock_wrlock(l) +#define rwlock_unlock(l) if (__isthreaded) \ + _pthread_rwlock_unlock(l) + +#define thr_keycreate(k, d) _pthread_key_create(k, d) +#define thr_setspecific(k, p) _pthread_setspecific(k, p) +#define thr_getspecific(k) _pthread_getspecific(k) +#define thr_sigsetmask(f, n, o) _pthread_sigmask(f, n, o) + +#define thr_once(o, i) _pthread_once(o, i) +#define thr_self() _pthread_self() +#define thr_exit(x) _pthread_exit(x) +#define thr_main() _pthread_main_np() diff --git a/lib/libc/include/spinlock.h b/lib/libc/include/spinlock.h new file mode 100644 index 0000000..eee1969 --- /dev/null +++ b/lib/libc/include/spinlock.h @@ -0,0 +1,73 @@ +/* + * 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. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by John Birrell. + * 4. Neither the name of the author nor the names of any co-contributors + * 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. + * + * $FreeBSD$ + * + * Lock definitions used in both libc and libpthread. + * + */ + +#ifndef _SPINLOCK_H_ +#define _SPINLOCK_H_ +#include <sys/cdefs.h> +#include <sys/types.h> + +/* + * Lock structure with room for debugging information. + */ +struct _spinlock { + volatile long access_lock; + volatile long lock_owner; + volatile char *fname; + volatile int lineno; +}; +typedef struct _spinlock spinlock_t; + +#define _SPINLOCK_INITIALIZER { 0, 0, 0, 0 } + +#define _SPINUNLOCK(_lck) _spinunlock(_lck); +#ifdef _LOCK_DEBUG +#define _SPINLOCK(_lck) _spinlock_debug(_lck, __FILE__, __LINE__) +#else +#define _SPINLOCK(_lck) _spinlock(_lck) +#endif + +/* + * Thread function prototype definitions: + */ +__BEGIN_DECLS +long _atomic_lock(volatile long *); +void _spinlock(spinlock_t *); +void _spinunlock(spinlock_t *); +void _spinlock_debug(spinlock_t *, char *, int); +__END_DECLS + +#endif /* _SPINLOCK_H_ */ diff --git a/lib/libc/include/un-namespace.h b/lib/libc/include/un-namespace.h new file mode 100644 index 0000000..ccdc2a1 --- /dev/null +++ b/lib/libc/include/un-namespace.h @@ -0,0 +1,249 @@ +/* + * Copyright (c) 2001 Daniel Eischen <deischen@FreeBSD.org>. + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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. + * + * $FreeBSD$ + */ + +#ifndef _UN_NAMESPACE_H_ +#define _UN_NAMESPACE_H_ + +#undef accept +#undef __acl_aclcheck_fd +#undef __acl_delete_fd +#undef __acl_get_fd +#undef __acl_set_fd +#undef bind +#undef __cap_get_fd +#undef __cap_set_fd +#undef close +#undef connect +#undef dup +#undef dup2 +#undef execve +#undef fcntl +#undef flock +#undef flockfile +#undef fpathconf +#undef fstat +#undef fstatfs +#undef fsync +#undef funlockfile +#undef getdirentries +#undef getlogin +#undef getpeername +#undef getprogname +#undef getsockname +#undef getsockopt +#undef ioctl +#undef kevent +#undef listen +#undef nanosleep +#undef open +#undef poll +#undef pthread_atfork +#undef pthread_attr_destroy +#undef pthread_attr_get_np +#undef pthread_attr_getdetachstate +#undef pthread_attr_getguardsize +#undef pthread_attr_getinheritsched +#undef pthread_attr_getschedparam +#undef pthread_attr_getschedpolicy +#undef pthread_attr_getscope +#undef pthread_attr_getstack +#undef pthread_attr_getstackaddr +#undef pthread_attr_getstacksize +#undef pthread_attr_init +#undef pthread_attr_setcreatesuspend_np +#undef pthread_attr_setdetachstate +#undef pthread_attr_setguardsize +#undef pthread_attr_setinheritsched +#undef pthread_attr_setschedparam +#undef pthread_attr_setschedpolicy +#undef pthread_attr_setscope +#undef pthread_attr_setstack +#undef pthread_attr_setstackaddr +#undef pthread_attr_setstacksize +#undef pthread_barrier_destroy +#undef pthread_barrier_init +#undef pthread_barrier_wait +#undef pthread_barrierattr_destroy +#undef pthread_barrierattr_getpshared +#undef pthread_barrierattr_init +#undef pthread_barrierattr_setpshared +#undef pthread_cancel +#undef pthread_cleanup_pop +#undef pthread_cleanup_push +#undef pthread_cond_broadcast +#undef pthread_cond_destroy +#undef pthread_cond_init +#undef pthread_cond_signal +#undef pthread_cond_timedwait +#undef pthread_cond_wait +#undef pthread_condattr_destroy +#undef pthread_condattr_getclock +#undef pthread_condattr_getpshared +#undef pthread_condattr_init +#undef pthread_condattr_setclock +#undef pthread_condattr_setpshared +#undef pthread_create +#undef pthread_detach +#undef pthread_equal +#undef pthread_exit +#undef pthread_getconcurrency +#undef pthread_getprio +#undef pthread_getschedparam +#undef pthread_getspecific +#undef pthread_join +#undef pthread_key_create +#undef pthread_key_delete +#undef pthread_kill +#undef pthread_main_np +#undef pthread_multi_np +#undef pthread_mutex_destroy +#undef pthread_mutex_getprioceiling +#undef pthread_mutex_init +#undef pthread_mutex_lock +#undef pthread_mutex_setprioceiling +#undef pthread_mutex_timedlock +#undef pthread_mutex_trylock +#undef pthread_mutex_unlock +#undef pthread_mutexattr_destroy +#undef pthread_mutexattr_getkind_np +#undef pthread_mutexattr_getprioceiling +#undef pthread_mutexattr_getprotocol +#undef pthread_mutexattr_getpshared +#undef pthread_mutexattr_gettype +#undef pthread_mutexattr_init +#undef pthread_mutexattr_setkind_np +#undef pthread_mutexattr_setprioceiling +#undef pthread_mutexattr_setprotocol +#undef pthread_mutexattr_setpshared +#undef pthread_mutexattr_settype +#undef pthread_once +#undef pthread_resume_all_np +#undef pthread_resume_np +#undef pthread_rwlock_destroy +#undef pthread_rwlock_init +#undef pthread_rwlock_rdlock +#undef pthread_rwlock_timedrdlock +#undef pthread_rwlock_timedwrlock +#undef pthread_rwlock_tryrdlock +#undef pthread_rwlock_trywrlock +#undef pthread_rwlock_unlock +#undef pthread_rwlock_wrlock +#undef pthread_rwlockattr_destroy +#undef pthread_rwlockattr_getpshared +#undef pthread_rwlockattr_init +#undef pthread_rwlockattr_setpshared +#undef pthread_self +#undef pthread_set_name_np +#undef pthread_setcancelstate +#undef pthread_setcanceltype +#undef pthread_setconcurrency +#undef pthread_setprio +#undef pthread_setschedparam +#undef pthread_setspecific +#undef pthread_sigmask +#undef pthread_single_np +#undef pthread_spin_destroy +#undef pthread_spin_init +#undef pthread_spin_lock +#undef pthread_spin_trylock +#undef pthread_spin_unlock +#undef pthread_suspend_all_np +#undef pthread_suspend_np +#undef pthread_switch_add_np +#undef pthread_switch_delete_np +#undef pthread_testcancel +#undef pthread_timedjoin_np +#undef pthread_yield +#undef read +#undef readv +#undef recvfrom +#undef recvmsg +#undef select +#undef sem_close +#undef sem_destroy +#undef sem_getvalue +#undef sem_init +#undef sem_open +#undef sem_post +#undef sem_timedwait +#undef sem_trywait +#undef sem_unlink +#undef sem_wait +#undef sendmsg +#undef sendto +#undef setsockopt +#undef sigaction +#undef sigprocmask +#undef sigsuspend +#undef socket +#undef socketpair +#undef usleep +#undef wait4 +#undef waitpid +#undef write +#undef writev + +#if 0 +#undef creat +#undef fchflags +#undef fchmod +#undef ftrylockfile +#undef msync +#undef nfssvc +#undef pause +#undef sched_yield +#undef sendfile +#undef shutdown +#undef sigaltstack +#undef sigpending +#undef sigreturn +#undef sigsetmask +#undef sleep +#undef system +#undef tcdrain +#undef wait +#endif /* 0 */ + +#ifdef _SIGNAL_H_ +int _sigaction(int, const struct sigaction *, struct sigaction *); +#endif + +#ifdef _SYS_EVENT_H_ +int _kevent(int, const struct kevent *, int, struct kevent *, + int, const struct timespec *); +#endif + +#ifdef _SYS_FCNTL_H_ +int _flock(int, int); +#endif + +#undef err +#undef warn +#undef nsdispatch + +#endif /* _UN_NAMESPACE_H_ */ |