aboutsummaryrefslogtreecommitdiff
path: root/cddl/contrib/opensolaris/head
diff options
context:
space:
mode:
authorPawel Jakub Dawidek <pjd@FreeBSD.org>2007-04-06 01:09:06 +0000
committerPawel Jakub Dawidek <pjd@FreeBSD.org>2007-04-06 01:09:06 +0000
commitf0a75d274af375d15b97b830966b99a02b7db911 (patch)
tree3061c8734d9ce560165e672836837a0f411a83c9 /cddl/contrib/opensolaris/head
parentc8c0ba192e3ac07c3797a1bbca52e5575e019890 (diff)
downloadsrc-f0a75d274af375d15b97b830966b99a02b7db911.tar.gz
src-f0a75d274af375d15b97b830966b99a02b7db911.zip
Please welcome ZFS - The last word in file systems.
ZFS file system was ported from OpenSolaris operating system. The code in under CDDL license. I'd like to thank all SUN developers that created this great piece of software. Supported by: Wheel LTD (http://www.wheel.pl/) Supported by: The FreeBSD Foundation (http://www.freebsdfoundation.org/) Supported by: Sentex (http://www.sentex.net/)
Notes
Notes: svn path=/head/; revision=168404
Diffstat (limited to 'cddl/contrib/opensolaris/head')
-rw-r--r--cddl/contrib/opensolaris/head/assert.h82
-rw-r--r--cddl/contrib/opensolaris/head/atomic.h34
-rw-r--r--cddl/contrib/opensolaris/head/libintl.h124
-rw-r--r--cddl/contrib/opensolaris/head/stdio_ext.h32
-rw-r--r--cddl/contrib/opensolaris/head/synch.h264
-rw-r--r--cddl/contrib/opensolaris/head/thread.h99
6 files changed, 635 insertions, 0 deletions
diff --git a/cddl/contrib/opensolaris/head/assert.h b/cddl/contrib/opensolaris/head/assert.h
new file mode 100644
index 000000000000..b088033ef678
--- /dev/null
+++ b/cddl/contrib/opensolaris/head/assert.h
@@ -0,0 +1,82 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/* Copyright (c) 1988 AT&T */
+/* All Rights Reserved */
+
+
+/*
+ * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef _ASSERT_H
+#define _ASSERT_H
+
+#pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.6.1.4 */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if defined(__STDC__)
+#if __STDC_VERSION__ - 0 >= 199901L
+extern void __assert_c99(const char *, const char *, int, const char *);
+#else
+extern void __assert(const char *, const char *, int);
+#endif /* __STDC_VERSION__ - 0 >= 199901L */
+#else
+extern void _assert();
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _ASSERT_H */
+
+/*
+ * Note that the ANSI C Standard requires all headers to be idempotent except
+ * <assert.h> which is explicitly required not to be idempotent (section 4.1.2).
+ * Therefore, it is by intent that the header guards (#ifndef _ASSERT_H) do
+ * not span this entire file.
+ */
+
+#undef assert
+
+#ifdef NDEBUG
+
+#define assert(EX) ((void)0)
+
+#else
+
+#if defined(__STDC__)
+#if __STDC_VERSION__ - 0 >= 199901L
+#define assert(EX) (void)((EX) || \
+ (__assert_c99(#EX, __FILE__, __LINE__, __func__), 0))
+#else
+#define assert(EX) (void)((EX) || (__assert(#EX, __FILE__, __LINE__), 0))
+#endif /* __STDC_VERSION__ - 0 >= 199901L */
+#else
+#define assert(EX) (void)((EX) || (_assert("EX", __FILE__, __LINE__), 0))
+#endif /* __STDC__ */
+
+#endif /* NDEBUG */
diff --git a/cddl/contrib/opensolaris/head/atomic.h b/cddl/contrib/opensolaris/head/atomic.h
new file mode 100644
index 000000000000..00c947604eb8
--- /dev/null
+++ b/cddl/contrib/opensolaris/head/atomic.h
@@ -0,0 +1,34 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef _ATOMIC_H
+#define _ATOMIC_H
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <sys/atomic.h>
+
+#endif /* _ATOMIC_H */
diff --git a/cddl/contrib/opensolaris/head/libintl.h b/cddl/contrib/opensolaris/head/libintl.h
new file mode 100644
index 000000000000..94b4d031536e
--- /dev/null
+++ b/cddl/contrib/opensolaris/head/libintl.h
@@ -0,0 +1,124 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+/* Libintl is a library of advanced internationalization functions. */
+
+#ifndef _LIBINTL_H
+#define _LIBINTL_H
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <sys/isa_defs.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * wchar_t is a built-in type in standard C++ and as such is not
+ * defined here when using standard C++. However, the GNU compiler
+ * fixincludes utility nonetheless creates its own version of this
+ * header for use by gcc and g++. In that version it adds a redundant
+ * guard for __cplusplus. To avoid the creation of a gcc/g++ specific
+ * header we need to include the following magic comment:
+ *
+ * we must use the C++ compiler's type
+ *
+ * The above comment should not be removed or changed until GNU
+ * gcc/fixinc/inclhack.def is updated to bypass this header.
+ */
+#if !defined(__cplusplus) || (__cplusplus < 199711L && !defined(__GNUG__))
+#ifndef _WCHAR_T
+#define _WCHAR_T
+#if defined(_LP64)
+typedef int wchar_t;
+#else
+typedef long wchar_t;
+#endif
+#endif /* !_WCHAR_T */
+#endif /* !defined(__cplusplus) ... */
+
+#define TEXTDOMAINMAX 256
+
+#ifdef __STDC__
+extern char *dcgettext(const char *, const char *, const int);
+extern char *dgettext(const char *, const char *);
+extern char *gettext(const char *);
+extern char *textdomain(const char *);
+extern char *bindtextdomain(const char *, const char *);
+
+/*
+ * LI18NUX 2000 Globalization Specification Version 1.0
+ * with Amendment 2
+ */
+extern char *dcngettext(const char *, const char *,
+ const char *, unsigned long int, int);
+extern char *dngettext(const char *, const char *,
+ const char *, unsigned long int);
+extern char *ngettext(const char *, const char *, unsigned long int);
+extern char *bind_textdomain_codeset(const char *, const char *);
+
+/* Word handling functions --- requires dynamic linking */
+/* Warning: these are experimental and subject to change. */
+extern int wdinit(void);
+extern int wdchkind(wchar_t);
+extern int wdbindf(wchar_t, wchar_t, int);
+extern wchar_t *wddelim(wchar_t, wchar_t, int);
+extern wchar_t mcfiller(void);
+extern int mcwrap(void);
+
+#else
+extern char *dcgettext();
+extern char *dgettext();
+extern char *gettext();
+extern char *textdomain();
+extern char *bindtextdomain();
+
+/*
+ * LI18NUX 2000 Globalization Specification Version 1.0
+ * with Amendment 2
+ */
+extern char *dcngettext();
+extern char *dngettext();
+extern char *ngettext();
+extern char *bind_textdomain_codeset();
+
+/* Word handling functions --- requires dynamic linking */
+/* Warning: these are experimental and subject to change. */
+extern int wdinit();
+extern int wdchkind();
+extern int wdbindf();
+extern wchar_t *wddelim();
+extern wchar_t mcfiller();
+extern int mcwrap();
+
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _LIBINTL_H */
diff --git a/cddl/contrib/opensolaris/head/stdio_ext.h b/cddl/contrib/opensolaris/head/stdio_ext.h
new file mode 100644
index 000000000000..839e05f7eebd
--- /dev/null
+++ b/cddl/contrib/opensolaris/head/stdio_ext.h
@@ -0,0 +1,32 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef _STDIO_EXT_H
+#define _STDIO_EXT_H
+
+#define enable_extended_FILE_stdio(x,y) (0)
+
+#endif
diff --git a/cddl/contrib/opensolaris/head/synch.h b/cddl/contrib/opensolaris/head/synch.h
new file mode 100644
index 000000000000..8d825d55a828
--- /dev/null
+++ b/cddl/contrib/opensolaris/head/synch.h
@@ -0,0 +1,264 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef _SYNCH_H
+#define _SYNCH_H
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * synch.h:
+ * definitions needed to use the thread synchronization interface
+ */
+
+#ifndef _ASM
+#include <sys/machlock.h>
+#include <sys/time_impl.h>
+#include <sys/synch.h>
+#endif /* _ASM */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef _ASM
+
+/*
+ * Semaphores
+ */
+typedef struct _sema {
+ /* this structure must be the same as sem_t in <semaphore.h> */
+ uint32_t count; /* semaphore count */
+ uint16_t type;
+ uint16_t magic;
+ upad64_t pad1[3]; /* reserved for a mutex_t */
+ upad64_t pad2[2]; /* reserved for a cond_t */
+} sema_t;
+
+/*
+ * POSIX.1c Note:
+ * POSIX.1c requires that <pthread.h> define the structures pthread_mutex_t
+ * and pthread_cond_t. These structures are identical to mutex_t (lwp_mutex_t)
+ * and cond_t (lwp_cond_t) which are defined in <synch.h>. A nested included
+ * of <synch.h> (to allow a "#typedef mutex_t pthread_mutex_t") would pull in
+ * non-posix symbols/constants violating the namespace restrictions. Hence,
+ * pthread_mutex_t/pthread_cond_t have been redefined in <pthread.h> (actually
+ * in <sys/types.h>). Any modifications done to mutex_t/lwp_mutex_t or
+ * cond_t/lwp_cond_t should also be done to pthread_mutex_t/pthread_cond_t.
+ */
+typedef lwp_mutex_t mutex_t;
+typedef lwp_cond_t cond_t;
+
+/*
+ * Readers/writer locks
+ *
+ * NOTE: The layout of this structure should be kept in sync with the layout
+ * of the correponding structure of pthread_rwlock_t in sys/types.h.
+ * Also, there is an identical structure for lwp_rwlock_t in <sys/synch.h>.
+ * Because we have to deal with C++, we cannot redefine this one as that one.
+ */
+typedef struct _rwlock {
+ int32_t readers; /* -1 == writer else # of readers */
+ uint16_t type;
+ uint16_t magic;
+ mutex_t mutex; /* used to indicate ownership */
+ cond_t readercv; /* unused */
+ cond_t writercv; /* unused */
+} rwlock_t;
+
+#ifdef __STDC__
+int _lwp_mutex_lock(lwp_mutex_t *);
+int _lwp_mutex_unlock(lwp_mutex_t *);
+int _lwp_mutex_trylock(lwp_mutex_t *);
+int _lwp_cond_wait(lwp_cond_t *, lwp_mutex_t *);
+int _lwp_cond_timedwait(lwp_cond_t *, lwp_mutex_t *, timespec_t *);
+int _lwp_cond_reltimedwait(lwp_cond_t *, lwp_mutex_t *, timespec_t *);
+int _lwp_cond_signal(lwp_cond_t *);
+int _lwp_cond_broadcast(lwp_cond_t *);
+int _lwp_sema_init(lwp_sema_t *, int);
+int _lwp_sema_wait(lwp_sema_t *);
+int _lwp_sema_trywait(lwp_sema_t *);
+int _lwp_sema_post(lwp_sema_t *);
+int cond_init(cond_t *, int, void *);
+int cond_destroy(cond_t *);
+int cond_wait(cond_t *, mutex_t *);
+int cond_timedwait(cond_t *, mutex_t *, const timespec_t *);
+int cond_reltimedwait(cond_t *, mutex_t *, const timespec_t *);
+int cond_signal(cond_t *);
+int cond_broadcast(cond_t *);
+int mutex_init(mutex_t *, int, void *);
+int mutex_destroy(mutex_t *);
+int mutex_lock(mutex_t *);
+int mutex_trylock(mutex_t *);
+int mutex_unlock(mutex_t *);
+int rwlock_init(rwlock_t *, int, void *);
+int rwlock_destroy(rwlock_t *);
+int rw_rdlock(rwlock_t *);
+int rw_wrlock(rwlock_t *);
+int rw_unlock(rwlock_t *);
+int rw_tryrdlock(rwlock_t *);
+int rw_trywrlock(rwlock_t *);
+int sema_init(sema_t *, unsigned int, int, void *);
+int sema_destroy(sema_t *);
+int sema_wait(sema_t *);
+int sema_timedwait(sema_t *, const timespec_t *);
+int sema_reltimedwait(sema_t *, const timespec_t *);
+int sema_post(sema_t *);
+int sema_trywait(sema_t *);
+
+#else /* __STDC__ */
+
+int _lwp_mutex_lock();
+int _lwp_mutex_unlock();
+int _lwp_mutex_trylock();
+int _lwp_cond_wait();
+int _lwp_cond_timedwait();
+int _lwp_cond_reltimedwait();
+int _lwp_cond_signal();
+int _lwp_cond_broadcast();
+int _lwp_sema_init();
+int _lwp_sema_wait();
+int _lwp_sema_trywait();
+int _lwp_sema_post();
+int cond_init();
+int cond_destroy();
+int cond_wait();
+int cond_timedwait();
+int cond_reltimedwait();
+int cond_signal();
+int cond_broadcast();
+int mutex_init();
+int mutex_destroy();
+int mutex_lock();
+int mutex_trylock();
+int mutex_unlock();
+int rwlock_init();
+int rwlock_destroy();
+int rw_rdlock();
+int rw_wrlock();
+int rw_unlock();
+int rw_tryrdlock();
+int rw_trywrlock();
+int sema_init();
+int sema_destroy();
+int sema_wait();
+int sema_timedwait();
+int sema_reltimedwait();
+int sema_post();
+int sema_trywait();
+
+#endif /* __STDC__ */
+
+#endif /* _ASM */
+
+/* "Magic numbers" tagging synchronization object types */
+#define MUTEX_MAGIC _MUTEX_MAGIC
+#define SEMA_MAGIC _SEMA_MAGIC
+#define COND_MAGIC _COND_MAGIC
+#define RWL_MAGIC _RWL_MAGIC
+
+/*
+ * POSIX.1c Note:
+ * DEFAULTMUTEX is defined same as PTHREAD_MUTEX_INITIALIZER in <pthread.h>.
+ * DEFAULTCV is defined same as PTHREAD_COND_INITIALIZER in <pthread.h>.
+ * DEFAULTRWLOCK is defined same as PTHREAD_RWLOCK_INITIALIZER in <pthread.h>.
+ * Any changes to these macros should be reflected in <pthread.h>
+ */
+#define DEFAULTMUTEX \
+ {{0, 0, 0, {USYNC_THREAD}, MUTEX_MAGIC}, \
+ {{{0, 0, 0, 0, 0, 0, 0, 0}}}, 0}
+#define SHAREDMUTEX \
+ {{0, 0, 0, {USYNC_PROCESS}, MUTEX_MAGIC}, \
+ {{{0, 0, 0, 0, 0, 0, 0, 0}}}, 0}
+#define RECURSIVEMUTEX \
+ {{0, 0, 0, {USYNC_THREAD|LOCK_RECURSIVE}, MUTEX_MAGIC}, \
+ {{{0, 0, 0, 0, 0, 0, 0, 0}}}, 0}
+#define ERRORCHECKMUTEX \
+ {{0, 0, 0, {USYNC_THREAD|LOCK_ERRORCHECK}, MUTEX_MAGIC}, \
+ {{{0, 0, 0, 0, 0, 0, 0, 0}}}, 0}
+#define RECURSIVE_ERRORCHECKMUTEX \
+ {{0, 0, 0, {USYNC_THREAD|LOCK_RECURSIVE|LOCK_ERRORCHECK}, \
+ MUTEX_MAGIC}, {{{0, 0, 0, 0, 0, 0, 0, 0}}}, 0}
+#define DEFAULTCV \
+ {{{0, 0, 0, 0}, USYNC_THREAD, COND_MAGIC}, 0}
+#define SHAREDCV \
+ {{{0, 0, 0, 0}, USYNC_PROCESS, COND_MAGIC}, 0}
+#define DEFAULTSEMA \
+ {0, USYNC_THREAD, SEMA_MAGIC, {0, 0, 0}, {0, 0}}
+#define SHAREDSEMA \
+ {0, USYNC_PROCESS, SEMA_MAGIC, {0, 0, 0}, {0, 0}}
+#define DEFAULTRWLOCK \
+ {0, USYNC_THREAD, RWL_MAGIC, DEFAULTMUTEX, DEFAULTCV, DEFAULTCV}
+#define SHAREDRWLOCK \
+ {0, USYNC_PROCESS, RWL_MAGIC, SHAREDMUTEX, SHAREDCV, SHAREDCV}
+
+/*
+ * Tests on lock states.
+ */
+#define SEMA_HELD(x) _sema_held(x)
+#define RW_READ_HELD(x) _rw_read_held(x)
+#define RW_WRITE_HELD(x) _rw_write_held(x)
+#define RW_LOCK_HELD(x) (RW_READ_HELD(x) || RW_WRITE_HELD(x))
+#define MUTEX_HELD(x) _mutex_held(x)
+
+/*
+ * The following definitions are for assertions which can be checked
+ * statically by tools like lock_lint. You can also define your own
+ * run-time test for each. If you don't, we define them to 1 so that
+ * such assertions simply pass.
+ */
+#ifndef NO_LOCKS_HELD
+#define NO_LOCKS_HELD 1
+#endif
+#ifndef NO_COMPETING_THREADS
+#define NO_COMPETING_THREADS 1
+#endif
+
+#ifndef _ASM
+
+#ifdef __STDC__
+
+int _sema_held(sema_t *);
+int _rw_read_held(rwlock_t *);
+int _rw_write_held(rwlock_t *);
+int _mutex_held(mutex_t *);
+
+#else /* __STDC__ */
+
+int _sema_held();
+int _rw_read_held();
+int _rw_write_held();
+int _mutex_held();
+
+#endif /* __STDC__ */
+
+#endif /* _ASM */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _SYNCH_H */
diff --git a/cddl/contrib/opensolaris/head/thread.h b/cddl/contrib/opensolaris/head/thread.h
new file mode 100644
index 000000000000..b9ed9527c548
--- /dev/null
+++ b/cddl/contrib/opensolaris/head/thread.h
@@ -0,0 +1,99 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef _THREAD_H
+#define _THREAD_H
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <pthread.h>
+#include <assert.h>
+
+/*
+ * Compatibility thread stuff needed for Solaris -> Linux port
+ */
+
+typedef pthread_t thread_t;
+typedef pthread_mutex_t mutex_t;
+typedef pthread_cond_t cond_t;
+typedef pthread_rwlock_t rwlock_t;
+
+#define USYNC_THREAD 0
+
+#define thr_self() (unsigned long)pthread_self()
+#define thr_equal(a,b) pthread_equal(a,b)
+#define thr_join(t,d,s) pthread_join(t,s)
+#define thr_exit(r) pthread_exit(r)
+#define _mutex_init(l,f,a) pthread_mutex_init(l,NULL)
+#define _mutex_destroy(l) pthread_mutex_destroy(l)
+#define mutex_lock(l) pthread_mutex_lock(l)
+#define mutex_trylock(l) pthread_mutex_trylock(l)
+#define mutex_unlock(l) pthread_mutex_unlock(l)
+#define rwlock_init(l,f,a) pthread_rwlock_init(l,NULL)
+#define rwlock_destroy(l) pthread_rwlock_destroy(l)
+#define rw_rdlock(l) pthread_rwlock_rdlock(l)
+#define rw_wrlock(l) pthread_rwlock_wrlock(l)
+#define rw_tryrdlock(l) pthread_rwlock_tryrdlock(l)
+#define rw_trywrlock(l) pthread_rwlock_trywrlock(l)
+#define rw_unlock(l) pthread_rwlock_unlock(l)
+#define cond_init(l,f,a) pthread_cond_init(l,NULL)
+#define cond_destroy(l) pthread_cond_destroy(l)
+#define cond_wait(l,m) pthread_cond_wait(l,m)
+#define cond_signal(l) pthread_cond_signal(l)
+#define cond_broadcast(l) pthread_cond_broadcast(l)
+
+#define THR_BOUND 0x00000001 /* = PTHREAD_SCOPE_SYSTEM */
+#define THR_NEW_LWP 0x00000002
+#define THR_DETACHED 0x00000040 /* = PTHREAD_CREATE_DETACHED */
+#define THR_SUSPENDED 0x00000080
+#define THR_DAEMON 0x00000100
+
+static __inline int
+thr_create(void *stack_base, size_t stack_size, void *(*start_func) (void*),
+ void *arg, long flags, thread_t *new_thread_ID)
+{
+ int ret;
+
+ assert(stack_base == NULL);
+ assert(stack_size == 0);
+ assert((flags & ~THR_BOUND & ~THR_DETACHED) == 0);
+
+ pthread_attr_t attr;
+ pthread_attr_init(&attr);
+
+ if(flags & THR_DETACHED)
+ pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
+
+ /* This function ignores the THR_BOUND flag, since NPTL doesn't seem to support PTHREAD_SCOPE_PROCESS */
+
+ ret = pthread_create(new_thread_ID, &attr, start_func, arg);
+
+ pthread_attr_destroy(&attr);
+
+ return (ret);
+}
+
+#endif /* _THREAD_H */