[Ltrace-devel] [PATCH RESEND] Add POSIX Threads prototypes

Роман Донченко dpb at corrigendum.ru
Fri Mar 6 18:16:44 UTC 2015


This includes prototypes for every pthread_* function defined by POSIX,
except pthread_cleanup_{pop,push}, which can be defined as macros (and
in Glibc, are).
---

Looks like the original email has been lost in the moderation queue, so I'm
sending it again.

Notes:
    I'm somewhat dissatisfied with this addition for two reasons:
    
    * Some of the libpthread functions use types that are also used by
      libc functions. I had to duplicate those types' definitions from
      libc.so.conf.
    
    * libc.so actually defines several of the pthread_* functions (as stubs)
      so that if a program doesn't create any threads (and doesn't link to
      libpthread.so), any synchronization calls in it are sped up. Calls to
      those stubs won't be matched to the prototypes, since they're in the
      wrong library.
    
    Both of these could be resolved if conf files could include other files,
    but no such functionality is available at the moment, so this is the best
    I can do.

 Makefile.am            |   2 +-
 etc/libpthread.so.conf | 154 +++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 155 insertions(+), 1 deletion(-)
 create mode 100644 etc/libpthread.so.conf

diff --git a/Makefile.am b/Makefile.am
index 6ab11f5..f63fa09 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -72,7 +72,7 @@ dist_man5_MANS = ltrace.conf.5
 dist_doc_DATA = COPYING CREDITS INSTALL README TODO
 
 dist_pkgdata_DATA = etc/syscalls.conf etc/libc.so.conf	\
-	etc/libm.so.conf etc/libacl.so.conf
+	etc/libm.so.conf etc/libacl.so.conf etc/libpthread.so.conf
 
 EXTRA_DIST = \
 	debian/changelog \
diff --git a/etc/libpthread.so.conf b/etc/libpthread.so.conf
new file mode 100644
index 0000000..1096463
--- /dev/null
+++ b/etc/libpthread.so.conf
@@ -0,0 +1,154 @@
+typedef clockid_t = int;
+typedef size_t = ulong;
+
+typedef sched_param = struct(int);
+typedef sigset_t = bitvec(ulong);
+typedef timespec = struct(long, long);
+
+typedef sched_policy_e = enum[int](SCHED_FIFO=1, SCHED_RR=2, SCHED_OTHER=0);
+
+typedef pthread_t = ulong;
+typedef pthread_attr_t = void;
+typedef pthread_barrier_t = void;
+typedef pthread_barrierattr_t = void;
+typedef pthread_cond_t = void;
+typedef pthread_condattr_t = void;
+typedef pthread_key_t = uint;
+typedef pthread_mutex_t = void;
+typedef pthread_mutexattr_t = void;
+typedef pthread_once_t = void;
+typedef pthread_rwlock_t = void;
+typedef pthread_rwlockattr_t = void;
+typedef pthread_spinlock_t = void;
+
+typedef pthread_cancel_state_e = enum[int](PTHREAD_CANCEL_DISABLE=1, PTHREAD_CANCEL_ENABLE=0);
+typedef pthread_cancel_type_e = enum[int](PTHREAD_CANCEL_ASYNCHRONOUS=1, PTHREAD_CANCEL_DEFERRED=0);
+typedef pthread_detach_state_e = enum[int](PTHREAD_CREATE_DETACHED=1, PTHREAD_CREATE_JOINABLE=0);
+typedef pthread_inherit_sched_e = enum[int](PTHREAD_EXPLICIT_SCHED=1, PTHREAD_INHERIT_SCHED=0);
+typedef pthread_mutex_protocol_e = enum[int](PTHREAD_PRIO_INHERIT=1, PTHREAD_PRIO_NONE=0, PTHREAD_PRIO_PROTECT=2);
+typedef pthread_mutex_robust_e = enum[int](PTHREAD_MUTEX_ROBUST=1, PTHREAD_MUTEX_STALLED=0);
+typedef pthread_mutex_type_e = enum[int](PTHREAD_MUTEX_ERRORCHECK=2, PTHREAD_MUTEX_NORMAL=0, PTHREAD_MUTEX_RECURSIVE=1);
+typedef pthread_pshared_e = enum[int](PTHREAD_PROCESS_SHARED=1, PTHREAD_PROCESS_PRIVATE=0);
+typedef pthread_scope_e = enum[int](PTHREAD_SCOPE_PROCESS=1, PTHREAD_SCOPE_SYSTEM=0);
+
+# <pthread.h>
+
+int   pthread_atfork(void *, void *, void *);
+
+int   pthread_attr_destroy(pthread_attr_t *);
+int   pthread_attr_getdetachstate(pthread_attr_t *, +pthread_detach_state_e *);
+int   pthread_attr_getguardsize(pthread_attr_t *, +size_t *);
+int   pthread_attr_getinheritsched(pthread_attr_t *, +pthread_inherit_sched_e *);
+int   pthread_attr_getschedparam(pthread_attr_t *, +sched_param *);
+int   pthread_attr_getschedpolicy(pthread_attr_t *, +sched_policy_e *);
+int   pthread_attr_getscope(pthread_attr_t *, +pthread_scope_e *);
+int   pthread_attr_getstack(pthread_attr_t *, +void **, +size_t *);
+int   pthread_attr_getstacksize(pthread_attr_t *, +size_t *);
+int   pthread_attr_init(pthread_attr_t *);
+int   pthread_attr_setdetachstate(pthread_attr_t *, pthread_detach_state_e);
+int   pthread_attr_setguardsize(pthread_attr_t *, size_t);
+int   pthread_attr_setinheritsched(pthread_attr_t *, pthread_inherit_sched_e);
+int   pthread_attr_setschedparam(pthread_attr_t *, sched_param *);
+int   pthread_attr_setschedpolicy(pthread_attr_t *, sched_policy_e);
+int   pthread_attr_setscope(pthread_attr_t *, pthread_scope_e);
+int   pthread_attr_setstack(pthread_attr_t *, void *, size_t);
+int   pthread_attr_setstacksize(pthread_attr_t *, size_t);
+
+int   pthread_barrier_destroy(pthread_barrier_t *);
+int   pthread_barrier_init(pthread_barrier_t *, pthread_barrierattr_t *, uint);
+int   pthread_barrier_wait(pthread_barrier_t *);
+
+int   pthread_barrierattr_destroy(pthread_barrierattr_t *);
+int   pthread_barrierattr_getpshared(pthread_barrierattr_t *, +pthread_pshared_e *);
+int   pthread_barrierattr_init(pthread_barrierattr_t *);
+int   pthread_barrierattr_setpshared(pthread_barrierattr_t *, pthread_pshared_e);
+
+int   pthread_cancel(pthread_t);
+
+int   pthread_cond_broadcast(pthread_cond_t *);
+int   pthread_cond_destroy(pthread_cond_t *);
+int   pthread_cond_init(pthread_cond_t *, pthread_condattr_t *);
+int   pthread_cond_signal(pthread_cond_t *);
+int   pthread_cond_timedwait(pthread_cond_t *, pthread_mutex_t *, timespec *);
+int   pthread_cond_wait(pthread_cond_t *, pthread_mutex_t *);
+
+int   pthread_condattr_destroy(pthread_condattr_t *);
+int   pthread_condattr_getclock(pthread_condattr_t *, +clockid_t *);
+int   pthread_condattr_getpshared(pthread_condattr_t *, +pthread_pshared_e *);
+int   pthread_condattr_init(pthread_condattr_t *);
+int   pthread_condattr_setclock(pthread_condattr_t *, clockid_t);
+int   pthread_condattr_setpshared(pthread_condattr_t *, pthread_pshared_e);
+
+int   pthread_create(+pthread_t *, pthread_attr_t *, void *, void *);
+int   pthread_detach(pthread_t);
+int   pthread_equal(pthread_t, pthread_t);
+void  pthread_exit(void *);
+int   pthread_getconcurrency(void);
+int   pthread_getcpuclockid(pthread_t, +clockid_t *);
+int   pthread_getschedparam(pthread_t, +sched_policy_e *, +sched_param *);
+void *pthread_getspecific(pthread_key_t);
+int   pthread_join(pthread_t, +void **);
+
+int   pthread_key_create(+pthread_key_t *, void *);
+int   pthread_key_delete(pthread_key_t);
+
+int   pthread_mutex_consistent(pthread_mutex_t *);
+int   pthread_mutex_destroy(pthread_mutex_t *);
+int   pthread_mutex_getprioceiling(pthread_mutex_t *, +int *);
+int   pthread_mutex_init(pthread_mutex_t *, pthread_mutexattr_t *);
+int   pthread_mutex_lock(pthread_mutex_t *);
+int   pthread_mutex_setprioceiling(pthread_mutex_t *, int, +int *);
+int   pthread_mutex_timedlock(pthread_mutex_t *, timespec *);
+int   pthread_mutex_trylock(pthread_mutex_t *);
+int   pthread_mutex_unlock(pthread_mutex_t *);
+
+int   pthread_mutexattr_destroy(pthread_mutexattr_t *);
+int   pthread_mutexattr_getprioceiling(pthread_mutexattr_t *, +int *);
+int   pthread_mutexattr_getprotocol(pthread_mutexattr_t *, +pthread_mutex_protocol_e *);
+int   pthread_mutexattr_getpshared(pthread_mutexattr_t *, +pthread_pshared_e *);
+int   pthread_mutexattr_getrobust(pthread_mutexattr_t *, +pthread_mutex_robust_e *);
+int   pthread_mutexattr_gettype(pthread_mutexattr_t *, +pthread_mutex_type_e *);
+int   pthread_mutexattr_init(pthread_mutexattr_t *);
+int   pthread_mutexattr_setprioceiling(pthread_mutexattr_t *, int);
+int   pthread_mutexattr_setprotocol(pthread_mutexattr_t *, pthread_mutex_protocol_e);
+int   pthread_mutexattr_setpshared(pthread_mutexattr_t *, pthread_pshared_e);
+int   pthread_mutexattr_setrobust(pthread_mutexattr_t *, pthread_mutex_robust_e);
+int   pthread_mutexattr_settype(pthread_mutexattr_t *, pthread_mutex_type_e);
+
+int   pthread_once(pthread_once_t *, void *);
+
+int   pthread_rwlock_destroy(pthread_rwlock_t *);
+int   pthread_rwlock_init(pthread_rwlock_t *, pthread_rwlockattr_t *);
+int   pthread_rwlock_rdlock(pthread_rwlock_t *);
+int   pthread_rwlock_timedrdlock(pthread_rwlock_t *, timespec *);
+int   pthread_rwlock_timedwrlock(pthread_rwlock_t *, timespec *);
+int   pthread_rwlock_tryrdlock(pthread_rwlock_t *);
+int   pthread_rwlock_trywrlock(pthread_rwlock_t *);
+int   pthread_rwlock_unlock(pthread_rwlock_t *);
+int   pthread_rwlock_wrlock(pthread_rwlock_t *);
+
+int   pthread_rwlockattr_destroy(pthread_rwlockattr_t *);
+int   pthread_rwlockattr_getpshared(pthread_rwlockattr_t *, +pthread_pshared_e *);
+int   pthread_rwlockattr_init(pthread_rwlockattr_t *);
+int   pthread_rwlockattr_setpshared(pthread_rwlockattr_t *, pthread_pshared_e);
+
+pthread_t pthread_self(void);
+int   pthread_setcancelstate(pthread_cancel_state_e, +pthread_cancel_state_e *);
+int   pthread_setcanceltype(pthread_cancel_type_e, +pthread_cancel_type_e *);
+int   pthread_setconcurrency(int);
+int   pthread_setschedparam(pthread_t, sched_policy_e, sched_param *);
+int   pthread_setschedprio(pthread_t, int);
+int   pthread_setspecific(pthread_key_t, void *);
+
+int   pthread_spin_destroy(pthread_spinlock_t *);
+int   pthread_spin_init(pthread_spinlock_t *, pthread_pshared_e);
+int   pthread_spin_lock(pthread_spinlock_t *);
+int   pthread_spin_trylock(pthread_spinlock_t *);
+int   pthread_spin_unlock(pthread_spinlock_t *);
+
+void  pthread_testcancel(void);
+
+# <signal.h>
+
+int    pthread_kill(pthread_t, int);
+int    pthread_sigmask(int, sigset_t *, +sigset_t *);
-- 
2.1.4




More information about the Ltrace-devel mailing list