📄 ptt_glibc-2.4.patch
字号:
/* Record the ownership. */+#ifdef PTT_LIBPTHREAD+ if(mutex->__data.__owner != 0)+ {+ /* MUTEX_LOCK_OUT */+ PTT_TRACE (PTT_LEVEL_MUTEX_IO, TR_MUTEX_8, mutex, -1);+ }+#endif /* PTT_LIBPTHREAD */+ mutex->__data.__owner = id; #ifndef NO_INCR ++mutex->__data.__nusers; #endif +#ifdef PTT_LIBPTHREAD+ /* MUTEX_OWNER_CHANGE, MUTEX_LOCK_OUT */+ PTT_TRACE (PTT_LEVEL_MUTEX_IO, TR_MUTEX_13, mutex, id, mutex, 0);+#endif /* PTT_LIBPTHREAD */+ return retval; } #ifndef __pthread_mutex_lockdiff -Naur ori_glibc/nptl/pthread_mutex_lock_nt.c new_glibc/nptl/pthread_mutex_lock_nt.c--- ori_glibc/nptl/pthread_mutex_lock_nt.c 1970-01-01 01:00:00.000000000 +0100+++ new_glibc/nptl/pthread_mutex_lock_nt.c 2006-04-04 15:03:37.000000000 +0200@@ -0,0 +1,35 @@+/* Copyright (C) 2004,2005,2006 Bull S.A.+ *+ * This library is free software; you can redistribute it and/or+ * modify it under the terms of the GNU Lesser General Public+ * License as published by the Free Software Foundation; either+ * version 2.1 of the License, or (at your option) any later version.+ *+ * This library is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU+ * Lesser General Public License for more details.+ *+ * You should have received a copy of the GNU Lesser General Public+ * License along with this library; if not, write to the Free Software+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA+ */++/* pthread_mutex_lock_nt: original pthread_mutex_lock (without traces) */++#ifdef PTT_LIBPTHREAD++#define __pthread_mutex_lock __pthread_mutex_lock_nt+#define pthread_mutex_lock pthread_mutex_lock_nt+#define __pthread_mutex_lock_internal __pthread_mutex_lock_nt_internal++#include "ptt_trace.h"+#undef PTT_TRACE+#define PTT_TRACE(...)+ +#include "pthread_mutex_lock.c"+ +strong_alias (__pthread_mutex_lock_nt, __pthread_mutex_lock_nt_internal)++#endif /* PTT_LIBPTHREAD */+diff -Naur ori_glibc/nptl/pthread_mutex_unlock.c new_glibc/nptl/pthread_mutex_unlock.c--- ori_glibc/nptl/pthread_mutex_unlock.c 2006-04-04 15:07:43.000000000 +0200+++ new_glibc/nptl/pthread_mutex_unlock.c 2006-05-10 11:37:40.000000000 +0200@@ -31,23 +31,47 @@ { int newowner = 0; +#ifdef PTT_LIBPTHREAD+ /* MUTEX_UNLOCK_IN */+ PTT_TRACE (PTT_LEVEL_MUTEX_IO, TR_MUTEX_14, mutex);+#endif /* PTT_LIBPTHREAD */+ switch (__builtin_expect (mutex->__data.__kind, PTHREAD_MUTEX_TIMED_NP)) { case PTHREAD_MUTEX_RECURSIVE_NP: /* Recursive mutex. */ if (mutex->__data.__owner != THREAD_GETMEM (THREAD_SELF, tid))+ {+#ifdef PTT_LIBPTHREAD+ /* MUTEX_UNLOCK_OUT */+ PTT_TRACE (PTT_LEVEL_MUTEX_IO, TR_MUTEX_15, mutex, EPERM);+#endif /* PTT_LIBPTHREAD */ return EPERM;+ } if (--mutex->__data.__count != 0)+ { /* We still hold the mutex. */+#ifdef PTT_LIBPTHREAD+ /* MUTEX_COUNT_DEC, MUTEX_UNLOCK_OUT */+ PTT_TRACE (PTT_LEVEL_MUTEX_IO, TR_MUTEX_16, mutex,+ mutex->__data.__count, mutex, 0);+#endif /* PTT_LIBPTHREAD */ return 0;+ } goto normal; case PTHREAD_MUTEX_ERRORCHECK_NP: /* Error checking mutex. */ if (mutex->__data.__owner != THREAD_GETMEM (THREAD_SELF, tid) || ! lll_mutex_islocked (mutex->__data.__lock))+ {+#ifdef PTT_LIBPTHREAD+ /* MUTEX_UNLOCK_OUT */+ PTT_TRACE (PTT_LEVEL_MUTEX_IO, TR_MUTEX_15, mutex, EPERM);+#endif /* PTT_LIBPTHREAD */ return EPERM;+ } /* FALLTHROUGH */ case PTHREAD_MUTEX_TIMED_NP:@@ -55,11 +79,21 @@ /* Always reset the owner field. */ normal: mutex->__data.__owner = 0;++#ifdef PTT_LIBPTHREAD+ /* MUTEX_OWNER_CHANGE */+ PTT_TRACE (PTT_LEVEL_MUTEX, TR_MUTEX_17, mutex, 0);+#endif /* PTT_LIBPTHREAD */+ if (decr) /* One less user. */ --mutex->__data.__nusers; /* Unlock. */+#ifdef PTT_LIBPTHREAD+ /* MUTEX_STATE_FREE */+ PTT_TRACE (PTT_LEVEL_MUTEX, TR_MUTEX_18, mutex, mutex->__data.__lock);+#endif /* PTT_LIBPTHREAD */ lll_mutex_unlock (mutex->__data.__lock); break; @@ -76,11 +110,23 @@ } if (mutex->__data.__owner != THREAD_GETMEM (THREAD_SELF, tid))+ {+#ifdef PTT_LIBPTHREAD+ /* MUTEX_UNLOCK_OUT */+ PTT_TRACE (PTT_LEVEL_MUTEX_IO, TR_MUTEX_15, mutex, EPERM);+#endif /* PTT_LIBPTHREAD */ return EPERM;+ } if (--mutex->__data.__count != 0)+ { /* We still hold the mutex. */+#ifdef PTT_LIBPTHREAD+ /* MUTEX_UNLOCK_OUT */+ PTT_TRACE (PTT_LEVEL_MUTEX_IO, TR_MUTEX_15, mutex, 0);+#endif /* PTT_LIBPTHREAD */ return 0;+ } goto robust; @@ -90,7 +136,13 @@ if ((mutex->__data.__lock & FUTEX_TID_MASK) != THREAD_GETMEM (THREAD_SELF, tid) || ! lll_mutex_islocked (mutex->__data.__lock))+ {+#ifdef PTT_LIBPTHREAD+ /* MUTEX_UNLOCK_OUT */+ PTT_TRACE (PTT_LEVEL_MUTEX_IO, TR_MUTEX_15, mutex, EPERM);+#endif /* PTT_LIBPTHREAD */ return EPERM;+ } /* If the previous owner died and the caller did not succeed in making the state consistent, mark the mutex as unrecoverable@@ -115,9 +167,17 @@ default: /* Correct code cannot set any other type. */+#ifdef PTT_LIBPTHREAD+ /* MUTEX_UNLOCK_OUT */+ PTT_TRACE (PTT_LEVEL_MUTEX_IO, TR_MUTEX_15, mutex, EINVAL);+#endif /* PTT_LIBPTHREAD */ return EINVAL; } +#ifdef PTT_LIBPTHREAD+ /* MUTEX_UNLOCK_OUT */+ PTT_TRACE (PTT_LEVEL_MUTEX_IO, TR_MUTEX_15, mutex, 0);+#endif /* PTT_LIBPTHREAD */ return 0; } diff -Naur ori_glibc/nptl/pthread_mutex_unlock_nt.c new_glibc/nptl/pthread_mutex_unlock_nt.c--- ori_glibc/nptl/pthread_mutex_unlock_nt.c 1970-01-01 01:00:00.000000000 +0100+++ new_glibc/nptl/pthread_mutex_unlock_nt.c 2006-04-04 15:03:37.000000000 +0200@@ -0,0 +1,34 @@+/* Copyright (C) 2004,2005,2006 Bull S.A.+ *+ * This library is free software; you can redistribute it and/or+ * modify it under the terms of the GNU Lesser General Public+ * License as published by the Free Software Foundation; either+ * version 2.1 of the License, or (at your option) any later version.+ *+ * This library is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU+ * Lesser General Public License for more details.+ *+ * You should have received a copy of the GNU Lesser General Public+ * License along with this library; if not, write to the Free Software+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA+ */++/* pthread_mutex_unlock_nt: original pthread_mutex_unlock (without traces) */++#ifdef PTT_LIBPTHREAD++#define __pthread_mutex_unlock __pthread_mutex_unlock_nt+#define pthread_mutex_unlock pthread_mutex_unlock_nt+#define __pthread_mutex_unlock_internal __pthread_mutex_unlock_nt_internal+#define __pthread_mutex_unlock_usercnt __pthread_mutex_unlock_usercnt_nt++#include "ptt_trace.h"+#undef PTT_TRACE+#define PTT_TRACE(...)+ +#include "pthread_mutex_unlock.c"++#endif /* PTT_LIBPTHREAD */+diff -Naur ori_glibc/nptl/pthreadP.h new_glibc/nptl/pthreadP.h--- ori_glibc/nptl/pthreadP.h 2006-04-04 15:08:04.000000000 +0200+++ new_glibc/nptl/pthreadP.h 2006-04-11 09:59:22.000000000 +0200@@ -31,6 +31,9 @@ #include <internaltypes.h> #include <pthread-functions.h> #include <atomic.h>+#ifdef PTT_LIBPTHREAD+#include "ptt_module.h"+#endif /* PTT_LIBPTHREAD */ /* Atomic operations on TLS memory. */@@ -349,11 +352,19 @@ extern int __pthread_mutex_lock (pthread_mutex_t *__mutex); extern int __pthread_mutex_lock_internal (pthread_mutex_t *__mutex) attribute_hidden;+#ifdef PTT_LIBPTHREAD+extern int __pthread_mutex_lock_nt_internal (pthread_mutex_t *__mutex)+ attribute_hidden;+#endif /* PTT_LIBPTHREAD */ extern int __pthread_mutex_cond_lock (pthread_mutex_t *__mutex) attribute_hidden internal_function; extern int __pthread_mutex_unlock (pthread_mutex_t *__mutex); extern int __pthread_mutex_unlock_internal (pthread_mutex_t *__mutex) attribute_hidden;+#ifdef PTT_LIBPTHREAD+extern int __pthread_mutex_unlock_nt_internal (pthread_mutex_t *__mutex)+ attribute_hidden;+#endif /* PTT_LIBPTHREAD */ extern int __pthread_mutex_unlock_usercnt (pthread_mutex_t *__mutex, int __decr) attribute_hidden internal_function;@@ -436,6 +447,11 @@ extern int __pthread_enable_asynccancel (void) attribute_hidden; extern void __pthread_disable_asynccancel (int oldtype) internal_function attribute_hidden;+#ifdef PTT_LIBPTHREAD+extern int __pthread_enable_synccancel (void) attribute_hidden;+extern void __pthread_disable_synccancel (int oldtype)+ internal_function attribute_hidden;+#endif /* PTT_LIBPTHREAD */ extern int __pthread_cond_broadcast_2_0 (pthread_cond_2_0_t *cond); extern int __pthread_cond_destroy_2_0 (pthread_cond_2_0_t *cond);diff -Naur ori_glibc/nptl/ptt_debug.h new_glibc/nptl/ptt_debug.h--- ori_glibc/nptl/ptt_debug.h 1970-01-01 01:00:00.000000000 +0100+++ new_glibc/nptl/ptt_debug.h 2006-04-07 11:29:59.000000000 +0200@@ -0,0 +1,65 @@+/* Copyright (C) 2004,2005,2006 Bull S.A.+ *+ * This library is free software; you can redistribute it and/or+ * modify it under the terms of the GNU Lesser General Public+ * License as published by the Free Software Foundation; either+ * version 2.1 of the License, or (at your option) any later version.+ *+ * This library is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU+ * Lesser General Public License for more details.+ *+ * You should have received a copy of the GNU Lesser General Public+ * License along with this library; if not, write to the Free Software+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA+ */++/* PTT internals trace mechanism macros+ * PTT_DBG = trace level of ptt internals+ * if not defined, ifdef PTT_TRACE_INFO, PTT_DBG = PTT_DBG_ALL+ * else PTT_DBG = PTT_DBG_NONE+ */ ++#ifdef PTT_NEW_FILES+#ifndef PTT_DEBUG_H +#define PTT_DEBUG_H ++/* trace the lowest level */+#define PTT_DBG_GENERAL 0x1+/* trace ptt_trace */+#define PTT_DBG_TRACE 0x2+/* trace ptt_initialize */+#define PTT_DBG_INIT 0x4+/* trace ptt_finish */+#define PTT_DBG_FINI 0x8+/* trace errors */+#define PTT_DBG_ERROR 0x10++/* don't trace ptt internals */+#define PTT_DBG_NONE 0+/* trace whole ptt internals */+#define PTT_DBG_ALL ( \+ PTT_DBG_GENERAL | PTT_DBG_TRACE | PTT_DBG_INIT | PTT_DBG_FINI | \+ PTT_DBG_ERROR)++/* default debug level */+#ifndef PTT_DBG+#ifdef PTT_TRACE_INFO+#define PTT_DBG PTT_DBG_ALL+#else /* ifndef PTT_TRACE_INFO */+#define PTT_DBG PTT_DBG_NONE+#endif /* PTT_TRACE_INFO */+#endif /* PTT_DBG */++/* define PTT_TRACE_INTERNALS */+#if (PTT_DBG == PTT_DBG_NONE)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -