commit ba3945e2c7828be7926fd55d50f03db97dc7e022 Author: Tom 'spot' Callaway Date: Tue Aug 31 13:38:21 2010 -0400 Fixed last remaining license issues Three files in libtirpc have the "BSD with advertising" or "BSD 4 clause" license on them (Free, but GPL incompatible). Thankfully, two of the three files (tirpc/libc_private.h and tirpc/nss_tls.h) aren't necessary on Linux at all. They were copied from FreeBSD, but FreeBSD (and NetBSD) include those headers, so they can be conditionalized out in the code. The third header, tirpc/reentrant.h originally came from FreeBSD, but had been modified to point to the Linux pthread equivalent functions. I'm pretty sure that would cause the code to break on FreeBSD/NetBSD. This patch does the following: - Zeros out tirpc/libc_private.h (This file should be deleted from the source control) - Zeros out tirpc/nss_tls.h (This file should be deleted from the source control) - Takes a fresh copy of tirpc/reentrant.h from FreeBSD CVS to inherit the new license (the advertising clause has been dropped in FreeBSD) - Updates tirpc/reentrant.h so that it contains the correct definition mappings for Linux, conditionalized only for Linux. - Updates all source files which #include libc_private.h so that the include is conditionalized on FreeBSD or NetBSD. I honestly don't think these files even need to be included on those platforms, but I'd rather be safe than sorry here. Signed-off-by: Steve Dickson diff --git a/src/getrpcent.c b/src/getrpcent.c index d7d7ddc..645f18f 100644 --- a/src/getrpcent.c +++ b/src/getrpcent.c @@ -46,7 +46,9 @@ #include #include #endif +#if defined(__FreeBSD__) || defined(__NetBSD__) #include +#endif /* * Internet version. diff --git a/src/mt_misc.c b/src/mt_misc.c index 4cba143..fe12c31 100644 --- a/src/mt_misc.c +++ b/src/mt_misc.c @@ -123,17 +123,17 @@ __rpc_createerr() void tsd_key_delete(void) { if (clnt_broadcast_key != -1) - thr_keydelete(clnt_broadcast_key); + pthread_key_delete(clnt_broadcast_key); if (rpc_call_key != -1) - thr_keydelete(rpc_call_key); + pthread_key_delete(rpc_call_key); if (tcp_key != -1) - thr_keydelete(tcp_key); + pthread_key_delete(tcp_key); if (udp_key != -1) - thr_keydelete(udp_key); + pthread_key_delete(udp_key); if (nc_key != -1) - thr_keydelete(nc_key); + pthread_key_delete(nc_key); if (rce_key != -1) - thr_keydelete(rce_key); + pthread_key_delete(rce_key); return; } diff --git a/src/svc_auth_des.c b/src/svc_auth_des.c index 479334f..e0ff6cb 100644 --- a/src/svc_auth_des.c +++ b/src/svc_auth_des.c @@ -60,7 +60,9 @@ #include #include #include +#if defined(__FreeBSD__) || defined(__NetBSD__) #include +#endif extern int key_decryptsession_pk(const char *, netobj *, des_block *); diff --git a/src/xdr_reference.c b/src/xdr_reference.c index 821dc8e..1da2c14 100644 --- a/src/xdr_reference.c +++ b/src/xdr_reference.c @@ -46,7 +46,10 @@ #include #include -#include "libc_private.h" + +#if defined(__FreeBSD__) || defined(__NetBSD__) +#include +#endif /* * XDR an indirect pointer diff --git a/tirpc/libc_private.h b/tirpc/libc_private.h index 63f8610..e69de29 100644 --- a/tirpc/libc_private.h +++ b/tirpc/libc_private.h @@ -1,129 +0,0 @@ -/* - * Copyright (c) 1998 John Birrell . - * 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: src/lib/libc/include/libc_private.h,v 1.11 2003/11/05 18:17:30 deischen Exp $ - * - * 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_COND_BROADCAST, - PJT_COND_DESTROY, - PJT_COND_INIT, - PJT_COND_SIGNAL, - PJT_COND_WAIT, - PJT_GETSPECIFIC, - PJT_KEY_CREATE, - PJT_KEY_DELETE, - PJT_MAIN_NP, - PJT_MUTEX_DESTROY, - PJT_MUTEX_INIT, - PJT_MUTEX_LOCK, - PJT_MUTEX_TRYLOCK, - PJT_MUTEX_UNLOCK, - PJT_MUTEXATTR_DESTROY, - PJT_MUTEXATTR_INIT, - PJT_MUTEXATTR_SETTYPE, - 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_SETSPECIFIC, - PJT_SIGMASK, - 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 - - -/* - * This is a pointer in the C run-time startup code. It is used - * by getprogname() and setprogname(). - */ -extern const char *__progname; - -/* - * This is the lock to make malloc() thread-safe. It is externalized - * so that thread libraries can protect malloc across fork(). - */ -extern struct _spinlock *__malloc_lock; - -#endif /* _LIBC_PRIVATE_H_ */ diff --git a/tirpc/nss_tls.h b/tirpc/nss_tls.h index 7536736..e69de29 100644 --- a/tirpc/nss_tls.h +++ b/tirpc/nss_tls.h @@ -1,80 +0,0 @@ -/*- - * 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: src/lib/libc/include/nss_tls.h,v 1.2 2003/04/21 15:44:25 nectar Exp $ - * - * 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 */ \ -typedef int _##name##_bmVjdGFy - -#endif /* _NSS_TLS_H_ */ diff --git a/tirpc/reentrant.h b/tirpc/reentrant.h index fda8f65..9489b15 100644 --- a/tirpc/reentrant.h +++ b/tirpc/reentrant.h @@ -13,13 +13,6 @@ * 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 @@ -33,95 +26,51 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - * $FreeBSD: src/lib/libc/include/reentrant.h,v 1.2 2002/11/01 09:37:17 dfr Exp $ */ -/* - * 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. +/* + * This file was derived from a copy in FreeBSD CVS on August 26, 2010. + * FreeBSD/NetBSD have slightly different definitions for some/most of + * these functions and types, so they should just use the ones found + * in their system copy of reentrant.h. + * These definitions are only guaranteed to be valid on Linux. */ -#ifndef _REENTRANT_H -#define _REENTRANT_H -#include -#include -#include +#if defined(__linux__) + +#include #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) pthread_mutex_lock(m) #define mutex_unlock(m) pthread_mutex_unlock(m) -#define mutex_trylock(m) pthread_mutex_trylock(m) -#define cond_init(c, a, p) pthread_cond_init(c, a) -#define cond_signal(m) pthread_cond_signal(m) -#define cond_broadcast(m) pthread_cond_broadcast(m) -#define cond_wait(c, m) pthread_cond_wait(c, m) +#define cond_init(c, a, p) pthread_cond_init(c, a) +#define cond_signal(m) pthread_cond_signal(m) +#define cond_broadcast(m) pthread_cond_broadcast(m) +#define cond_wait(c, m) pthread_cond_wait(c, m) -#define rwlock_init(l, a) pthread_rwlock_init(l, a) -#define rwlock_rdlock(l) pthread_rwlock_rdlock(l) -#define rwlock_wrlock(l) pthread_rwlock_wrlock(l) -#define rwlock_unlock(l) pthread_rwlock_unlock(l) +#define rwlock_init(l, a) pthread_rwlock_init(l, a) +#define rwlock_rdlock(l) pthread_rwlock_rdlock(l) +#define rwlock_wrlock(l) pthread_rwlock_wrlock(l) +#define rwlock_unlock(l) pthread_rwlock_unlock(l) -#define thr_keycreate(k, d) pthread_key_create(k, d) -#define thr_keydelete(k) pthread_key_delete(k) -#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_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_self() pthread_self() -#define thr_exit(x) pthread_exit(x) +#define thr_once(o, i) pthread_once(o, i) +#define thr_self() pthread_self() +#define thr_exit(x) pthread_exit(x) -#endif /* reentrant.h */ +#endif diff --git a/tirpc/spinlock.h b/tirpc/spinlock.h index 8e9adb1..393fb83 100644 --- a/tirpc/spinlock.h +++ b/tirpc/spinlock.h @@ -37,37 +37,5 @@ #ifndef _SPINLOCK_H_ #define _SPINLOCK_H_ -#include -#include - -/* - * 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_ */