PERFORCE change 67677 for review
David Xu
davidxu at FreeBSD.org
Sat Dec 25 05:13:28 PST 2004
http://perforce.freebsd.org/chv.cgi?CH=67677
Change 67677 by davidxu at davidxu_tiger on 2004/12/25 13:13:11
Fix some ugly MACRO/funcion names.
Affected files ...
.. //depot/projects/davidxu_thread/src/lib/libthread/Makefile#6 edit
.. //depot/projects/davidxu_thread/src/lib/libthread/sys/lock.h#5 edit
.. //depot/projects/davidxu_thread/src/lib/libthread/thread/thr_init.c#4 edit
.. //depot/projects/davidxu_thread/src/lib/libthread/thread/thr_kern.c#5 edit
.. //depot/projects/davidxu_thread/src/lib/libthread/thread/thr_private.h#7 edit
.. //depot/projects/davidxu_thread/src/lib/libthread/thread/thr_pspinlock.c#4 edit
.. //depot/projects/davidxu_thread/src/lib/libthread/thread/thr_spinlock.c#4 edit
Differences ...
==== //depot/projects/davidxu_thread/src/lib/libthread/Makefile#6 (text+ko) ====
@@ -13,6 +13,7 @@
LIB=thread
.endif
SHLIB_MAJOR= 1
+CFLAGS=
CFLAGS+=-DPTHREAD_KERNEL
CFLAGS+=-I${.CURDIR}/../libc/include -I${.CURDIR}/thread \
-I${.CURDIR}/../../include
@@ -20,9 +21,9 @@
CFLAGS+=-I${.CURDIR}/sys
CFLAGS+=-I${.CURDIR}/../../libexec/rtld-elf
CFLAGS+=-I${.CURDIR}/../../libexec/rtld-elf/${MACHINE_ARCH}
-CFLAGS+=-fno-builtin
+CFLAGS+=-fno-builtin -Winline
-#CFLAGS+= -g
+CFLAGS+= -g
# Uncomment this if you want to build a 1:1 threading mode library
# however it is no longer strictly conformed to POSIX
==== //depot/projects/davidxu_thread/src/lib/libthread/sys/lock.h#5 (text+ko) ====
@@ -39,25 +39,8 @@
#define _UMTX_INITIALIZER(lck) { {UMTX_UNOWNED} }
-static inline void
-_UMTX_INIT(struct umtx *m)
-{
- m->u_owner = UMTX_UNOWNED;
-}
-
-static inline void
-_UMTX_REINIT(struct umtx *m)
-{
- m->u_owner = UMTX_UNOWNED;
-}
-
-static inline void
-_UMTX_DESTROY(struct umtx *m __unused)
-{
-}
-
static inline int
-_UMTX_LOCK(struct umtx *m, long tid)
+UMTX_LOCK(struct umtx *m, long tid)
{
int err;
@@ -69,7 +52,7 @@
}
static inline void
-_UMTX_ACQUIRE(struct umtx *m, long tid)
+UMTX_ACQUIRE(struct umtx *m, long tid)
{
int err;
@@ -80,7 +63,7 @@
}
static inline void
-_UMTX_RELEASE(struct umtx *m, long tid)
+UMTX_RELEASE(struct umtx *m, long tid)
{
if (umtx_unlock(m, tid))
_thr_exit(__FILE__, __LINE__, "umtx_unlock failed.\n");
==== //depot/projects/davidxu_thread/src/lib/libthread/thread/thr_init.c#4 (text+ko) ====
@@ -388,21 +388,21 @@
TAILQ_INIT(&_thr_atfork_list);
- _UMTX_INIT(&_thread_signal_lock);
- _UMTX_INIT(&_mutex_static_lock);
- _UMTX_INIT(&_cond_static_lock);
- _UMTX_INIT(&_rwlock_static_lock);
- _UMTX_INIT(&_keytable_lock);
- _UMTX_INIT(&_thread_list_lock);
+ umtx_init(&_thread_signal_lock);
+ umtx_init(&_mutex_static_lock);
+ umtx_init(&_cond_static_lock);
+ umtx_init(&_rwlock_static_lock);
+ umtx_init(&_keytable_lock);
+ umtx_init(&_thread_list_lock);
_thr_spinlock_init();
_pthread_mutex_init(&_thr_atfork_mutex, NULL);
} else {
- _UMTX_REINIT(&_thread_signal_lock);
- _UMTX_REINIT(&_mutex_static_lock);
- _UMTX_REINIT(&_cond_static_lock);
- _UMTX_REINIT(&_rwlock_static_lock);
- _UMTX_REINIT(&_keytable_lock);
- _UMTX_REINIT(&_thread_list_lock);
+ umtx_init(&_thread_signal_lock);
+ umtx_init(&_mutex_static_lock);
+ umtx_init(&_cond_static_lock);
+ umtx_init(&_rwlock_static_lock);
+ umtx_init(&_keytable_lock);
+ umtx_init(&_thread_list_lock);
/* reinitialized in thr_fork.c */
#if 0
_thr_spinlock_init();
==== //depot/projects/davidxu_thread/src/lib/libthread/thread/thr_kern.c#5 (text+ko) ====
@@ -126,7 +126,7 @@
{
curthread->cancelflags &= ~THR_CANCELLING;
/* clear aother thread locked us. */
- _UMTX_REINIT(&curthread->lock);
+ umtx_init(&curthread->lock);
thr_self(&curthread->tid);
/* reinitialize libc spinlocks, this includes __malloc_lock. */
_thr_spinlock_init();
@@ -151,12 +151,12 @@
TAILQ_INIT(&free_threadq);
_gc_count = 0;
if (inited == 0) {
- _UMTX_INIT(&free_thread_lock);
- _UMTX_INIT(&tcb_lock);
+ umtx_init(&free_thread_lock);
+ umtx_init(&tcb_lock);
inited = 1;
} else {
- _UMTX_REINIT(&free_thread_lock);
- _UMTX_REINIT(&tcb_lock);
+ umtx_init(&free_thread_lock);
+ umtx_init(&tcb_lock);
}
}
@@ -581,10 +581,10 @@
/*
* Initialize thread locking.
*/
- _UMTX_INIT(&thread->lock);
+ umtx_init(&thread->lock);
}
} else if (thread != NULL) {
- _UMTX_REINIT(&thread->lock);
+ umtx_init(&thread->lock);
}
return (thread);
}
@@ -611,7 +611,6 @@
static void
thr_destroy(struct pthread *curthread, struct pthread *thread)
{
- _UMTX_DESTROY(&thread->lock);
if (curthread) {
THR_LOCK_ACQUIRE(curthread, &tcb_lock);
_tcb_dtor(thread->tcb);
==== //depot/projects/davidxu_thread/src/lib/libthread/thread/thr_private.h#7 (text+ko) ====
@@ -40,6 +40,7 @@
/*
* Include files.
*/
+#include <sys/limits.h>
#include <setjmp.h>
#include <signal.h>
#include <stdio.h>
@@ -166,7 +167,7 @@
#define PTHREAD_MUTEXATTR_STATIC_INITIALIZER \
{ PTHREAD_MUTEX_DEFAULT, PTHREAD_PRIO_NONE, 0, MUTEX_FLAGS_PRIVATE }
-/*
+/*
* Condition variable definitions.
*/
enum pthread_cond_type {
@@ -178,12 +179,9 @@
/*
* Lock for accesses to this structure.
*/
- struct umtx c_lock;
- enum pthread_cond_type c_type;
- TAILQ_HEAD(cond_head, pthread) c_queue;
- struct pthread_mutex *c_mutex;
- long c_flags;
- long c_seqno;
+ struct umtx c_lock;
+ long c_flags;
+ int c_count;
};
struct pthread_cond_attr {
@@ -255,7 +253,7 @@
/*
* Miscellaneous definitions.
*/
-#define THR_STACK_DEFAULT 65536
+#define THR_STACK_DEFAULT 0x100000
/*
* Maximum size of initial thread's stack. This perhaps deserves to be larger
@@ -597,13 +595,13 @@
#define THR_LOCK_ACQUIRE(thrd, lck) \
do { \
(thrd)->locklevel++; \
- _UMTX_ACQUIRE((lck), (thrd)->tid); \
+ UMTX_ACQUIRE((lck), (thrd)->tid); \
} while (0)
#define THR_LOCK_RELEASE(thrd, lck) \
do { \
if ((thrd)->locklevel > 0) { \
- _UMTX_RELEASE((lck), (thrd)->tid); \
+ UMTX_RELEASE((lck), (thrd)->tid); \
(thrd)->locklevel--; \
if ((thrd)->locklevel == 0) \
THR_YIELD_CHECK(thrd); \
@@ -655,10 +653,10 @@
/* Take the scheduling lock with the intent to call the scheduler. */
#define THR_LOCK_SWITCH(curthr) do { \
curthread->lock_switch++; \
- _UMTX_ACQUIRE(&(curthr->lock), (curthr)->tid); \
+ UMTX_ACQUIRE(&(curthr->lock), (curthr)->tid); \
} while (0)
#define THR_UNLOCK_SWITCH(curthr) do { \
- _UMTX_RELEASE(&(curthr->lock), (curthr)->tid); \
+ UMTX_RELEASE(&(curthr->lock), (curthr)->tid); \
curthread->lock_switch--; \
THR_YIELD_CHECK(curthr); \
} while (0)
==== //depot/projects/davidxu_thread/src/lib/libthread/thread/thr_pspinlock.c#4 (text+ko) ====
@@ -50,7 +50,7 @@
else if ((lck = malloc(sizeof(struct pthread_spinlock))) == NULL)
ret = ENOMEM;
else {
- _UMTX_INIT(&lck->s_lock);
+ UMTX_INIT(&lck->s_lock);
*lock = lck;
ret = 0;
}
@@ -66,7 +66,6 @@
if (lock == NULL || *lock == NULL)
ret = EINVAL;
else {
- _UMTX_DESTROY(&(*lock)->s_lock);
free(*lock);
*lock = NULL;
ret = 0;
==== //depot/projects/davidxu_thread/src/lib/libthread/thread/thr_spinlock.c#4 (text+ko) ====
@@ -65,7 +65,7 @@
struct spinlock_extra *extra;
extra = (struct spinlock_extra *)lck->fname;
- pthread_mutex_unlock(&extra->lock);
+ _pthread_mutex_unlock(&extra->lock);
}
/*
@@ -90,7 +90,7 @@
if (lck->fname == NULL)
init_spinlock(lck);
extra = (struct spinlock_extra *)lck->fname;
- pthread_mutex_lock(&extra->lock);
+ _pthread_mutex_lock(&extra->lock);
}
/*
@@ -112,13 +112,13 @@
static void
init_spinlock(spinlock_t *lck)
{
- pthread_mutex_lock(&spinlock_static_lock);
+ _pthread_mutex_lock(&spinlock_static_lock);
if ((lck->fname == NULL) && (spinlock_count < MAX_SPINLOCKS)) {
lck->fname = (char *)&extra[spinlock_count];
extra[spinlock_count].owner = lck;
spinlock_count++;
}
- pthread_mutex_unlock(&spinlock_static_lock);
+ _pthread_mutex_unlock(&spinlock_static_lock);
if (lck->fname == NULL)
PANIC("Exceeded max spinlocks");
}
@@ -133,10 +133,10 @@
for (i = 0; i < spinlock_count; i++)
_thr_mutex_reinit(&extra[i].lock);
} else {
- if (pthread_mutex_init(&spinlock_static_lock, NULL))
+ if (_pthread_mutex_init(&spinlock_static_lock, NULL))
PANIC("Cannot initialize spinlock_static_lock");
for (i = 0; i < MAX_SPINLOCKS; i++) {
- if (pthread_mutex_init(&extra[i].lock, NULL))
+ if (_pthread_mutex_init(&extra[i].lock, NULL))
PANIC("Cannot initialize spinlock extra");
}
initialized = 1;
More information about the p4-projects
mailing list