Fix compiler warnings and mutex deadlock
This commit is contained in:
parent
25bd2bd8fa
commit
b61266eb51
3 changed files with 9 additions and 3 deletions
|
@ -1,6 +1,6 @@
|
||||||
# Makefile for libmthread
|
# Makefile for libmthread
|
||||||
|
|
||||||
CPPFLAGS+=-O -D_MINIX -D_POSIX_SOURCE -Wall
|
CPPFLAGS+=-O -D_MINIX -D_POSIX_SOURCE -Wall -Werror
|
||||||
|
|
||||||
LIB= mthread
|
LIB= mthread
|
||||||
|
|
||||||
|
|
|
@ -21,11 +21,15 @@ PUBLIC void mthread_debug_f(const char *file, int line, const char *msg)
|
||||||
PUBLIC void mthread_panic_f(const char *file, int line, const char *msg)
|
PUBLIC void mthread_panic_f(const char *file, int line, const char *msg)
|
||||||
{
|
{
|
||||||
/* Print panic message to stdout and exit */
|
/* Print panic message to stdout and exit */
|
||||||
|
volatile int *sf;
|
||||||
|
|
||||||
|
sf = NULL;
|
||||||
|
|
||||||
printf("mthread panic (%s:%d): ", file, line);
|
printf("mthread panic (%s:%d): ", file, line);
|
||||||
printf(msg);
|
printf("%s", msg);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
fflush(stdout); /* Force debug print to screen */
|
fflush(stdout); /* Force debug print to screen */
|
||||||
*((int *)0) = 1; /* Cause segfault to generate trace */
|
*((int *) sf ) = 1; /* Cause segfault to generate trace */
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -190,6 +190,8 @@ mthread_mutex_t *mutex; /* Mutex that is to be locked */
|
||||||
m = (struct __mthread_mutex *) *mutex;
|
m = (struct __mthread_mutex *) *mutex;
|
||||||
if (!mthread_mutex_valid(&m))
|
if (!mthread_mutex_valid(&m))
|
||||||
return(EINVAL);
|
return(EINVAL);
|
||||||
|
else if (m->mm_owner == current_thread)
|
||||||
|
return(EDEADLK);
|
||||||
else if (m->mm_owner == NO_THREAD) {
|
else if (m->mm_owner == NO_THREAD) {
|
||||||
m->mm_owner = current_thread;
|
m->mm_owner = current_thread;
|
||||||
return(0);
|
return(0);
|
||||||
|
|
Loading…
Reference in a new issue