#include <pthread.h>
#include <stdint.h>
#include <syscall.h>
-#include <asm/timex.h>
#include <semaphore.h>
#include <signal.h>
-#ifdef powerpc
-#define __KERNEL__ /* Ugly hack : atomic.h is broken */
-#endif
-#include <asm/atomic.h>
-#ifdef powerpc
-#include "ltt/ltt-usertrace-ppc.h"
-#undef __KERNEL__ /* Ugly hack : atomic.h is broken */
-#endif
#include <ltt/ltt-facility-id-user_generic.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#ifndef LTT_N_SUBBUFS
#define LTT_N_SUBBUFS 2
#endif //LTT_N_SUBBUFS
int consumed_old, consumed_new;
int commit_count, reserve_count;
int ret;
+ sigset_t oldset, set;
+
+ /* sem_wait is not signal safe. Disable signals around it. */
+
+ /* Disable signals */
+ ret = sigfillset(&set);
+ if(ret) perror("LTT Error in sigfillset\n");
+
+ ret = pthread_sigmask(SIG_BLOCK, &set, &oldset);
+ if(ret) perror("LTT Error in pthread_sigmask\n");
do {
offset_old = atomic_read(<t_buf->offset);
//if((SUBBUF_TRUNC(offset_begin, ltt_buf)
// - SUBBUF_TRUNC(atomic_read(<t_buf->consumed), ltt_buf))
// >= ltt_buf->alloc_size) {
- /* sem_wait is not signal safe. Disable signals around it. */
{
- sigset_t oldset, set;
-
- /* Disable signals */
- ret = sigfillset(&set);
- if(ret) perror("LTT Error in sigfillset\n");
-
- ret = pthread_sigmask(SIG_BLOCK, &set, &oldset);
- if(ret) perror("LTT Error in pthread_sigmask\n");
-
sem_wait(<t_buf->writer_sem);
- /* Enable signals */
- ret = pthread_sigmask(SIG_SETMASK, &oldset, NULL);
- if(ret) perror("LTT Error in pthread_sigmask\n");
}
/* go on with the write */
} while(atomic_cmpxchg(<t_buf->offset, offset_old, offset_end)
!= offset_old);
+ /* Enable signals */
+ ret = pthread_sigmask(SIG_SETMASK, &oldset, NULL);
+ if(ret) perror("LTT Error in pthread_sigmask\n");
/* Push the reader if necessary */
do {
ltt_deliver_callback(ltt_buf, SUBBUF_INDEX(offset_begin, ltt_buf), NULL);
}
}
-
+
+#ifdef __cplusplus
+} /* end of extern "C" */
+#endif
#endif //LTT_TRACE_FAST
#endif //LTT_TRACE