Move kernelcompat.h to include/ust/ and share.h, usterr.h to include/
authorJan Blunck <jblunck@suse.de>
Sun, 25 Oct 2009 13:57:47 +0000 (14:57 +0100)
committerJan Blunck <jblunck@suse.de>
Sun, 25 Oct 2009 14:09:30 +0000 (15:09 +0100)
kernelcompat.h is included by marker.h and tracepoint.h therefore it should
be in include/ust/ as well. Move shared headers to include/ as well.

Signed-off-by: Jan Blunck <jblunck@suse.de>
35 files changed:
Makefile.am
include/Makefile.am
include/share.h [new file with mode: 0644]
include/ust/kernelcompat.h [new file with mode: 0644]
include/ust/marker.h
include/ust/tracepoint.h
include/usterr.h [new file with mode: 0644]
java/Makefile.am
libinterfork/Makefile.am
libinterfork/interfork.c
libmallocwrap/Makefile.am
libust/Makefile.am
libust/channels.c
libust/channels.h
libust/marker-control.c
libust/marker.c
libust/relay.c
libust/serialize.c
libust/tracepoint.c
libust/tracer.c
libust/tracer.h
libust/tracercore.c
libust/tracercore.h
share/kernelcompat.h [deleted file]
share/share.h [deleted file]
share/usterr.h [deleted file]
tests/basic/Makefile.am
tests/basic_long/Makefile.am
tests/fork/Makefile.am
tests/hello/Makefile.am
tests/hello/hello.c
tests/hello2/Makefile.am
ustctl/Makefile.am
ustd/Makefile.am
ustd/ustd.c

index 1ab59487cc26af608819e12ee2fe1e3a3a7ca2f6..1bdedea2118f695c470d052f51b8d7bccfc76532 100644 (file)
@@ -1,7 +1,5 @@
 ACLOCAL_AMFLAGS = -I m4
 SUBDIRS = libust tests libmallocwrap ustd ustctl libinterfork include
 
-EXTRA_DIST = doc share/kernelcompat.h share/share.h share/usterr.h
+EXTRA_DIST = doc
 dist_bin_SCRIPTS = usttrace
-
-include_HEADERS = share/kernelcompat.h share/usterr.h
index 0a4f87da6808323b202bcaaa5e6784a75be014ed..48a898b67ce330bd8a67a8d65d55c6e739e5311a 100644 (file)
@@ -1 +1,4 @@
-nobase_include_HEADERS = ust/immediate.h ust/marker.h ust/tracepoint.h
+nobase_include_HEADERS = ust/immediate.h ust/kernelcompat.h ust/marker.h \
+       ust/tracepoint.h
+
+noinst_HEADERS = share.h usterr.h
diff --git a/include/share.h b/include/share.h
new file mode 100644 (file)
index 0000000..f674f31
--- /dev/null
@@ -0,0 +1,34 @@
+#ifndef UST_SHARE_H
+#define UST_SHARE_H
+
+#include <unistd.h>
+#include <errno.h>
+
+/* This write is patient because it restarts if it was incomplete.
+ */
+
+static inline ssize_t patient_write(int fd, const void *buf, size_t count)
+{
+       const char *bufc = (const char *) buf;
+       int result;
+
+       for(;;) {
+               result = write(fd, bufc, count);
+               if(result == -1 && errno == EINTR) {
+                       continue;
+               }
+               if(result <= 0) {
+                       return result;
+               }
+               count -= result;
+               bufc += result;
+
+               if(count == 0) {
+                       break;
+               }
+       }
+
+       return bufc-(const char *)buf;
+}
+
+#endif /* UST_SHARE_H */
diff --git a/include/ust/kernelcompat.h b/include/ust/kernelcompat.h
new file mode 100644 (file)
index 0000000..5cc5eaa
--- /dev/null
@@ -0,0 +1,206 @@
+#ifndef KERNELCOMPAT_H
+#define KERNELCOMPAT_H
+
+#include <kcompat.h>
+
+#include <string.h>
+#include <sys/time.h>
+
+/* FIXME: libkcompat must not define arch-specific local ops, as ust *must*
+ * fallback to the normal atomic ops. Fix things so we don't add them and
+ * break things accidentally.
+ */
+
+#define container_of(ptr, type, member) ({                      \
+        const typeof( ((type *)0)->member ) *__mptr = (ptr);    \
+        (type *)( (char *)__mptr - offsetof(type,member) );})
+
+#define KERN_DEBUG ""
+#define KERN_NOTICE ""
+#define KERN_INFO ""
+#define KERN_ERR ""
+#define KERN_ALERT ""
+#define KERN_WARNING ""
+
+/* ERROR OPS */
+
+#define MAX_ERRNO      4095
+
+#define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)
+
+static inline void *ERR_PTR(long error)
+{
+       return (void *) error;
+}
+
+static inline long PTR_ERR(const void *ptr)
+{
+       return (long) ptr;
+}
+
+static inline long IS_ERR(const void *ptr)
+{
+       return IS_ERR_VALUE((unsigned long)ptr);
+}
+
+
+/* Min / Max */
+
+#define min_t(type, x, y) ({                    \
+       type __min1 = (x);                      \
+       type __min2 = (y);                      \
+       __min1 < __min2 ? __min1: __min2; })
+
+#define max_t(type, x, y) ({                    \
+       type __max1 = (x);                      \
+       type __max2 = (y);                      \
+       __max1 > __max2 ? __max1: __max2; })
+
+
+/* MUTEXES */
+
+#include <pthread.h>
+
+#define DEFINE_MUTEX(m) pthread_mutex_t (m) = PTHREAD_MUTEX_INITIALIZER;
+#define DECLARE_MUTEX(m) extern pthread_mutex_t (m);
+
+#define mutex_lock(m) pthread_mutex_lock(m)
+
+#define mutex_unlock(m) pthread_mutex_unlock(m)
+
+
+/* MALLOCATION */
+
+#include <stdlib.h>
+
+#define kmalloc(s, t) malloc(s)
+#define kzalloc(s, t) zmalloc(s)
+#define kfree(p) free((void *)p)
+#define kstrdup(s, t) strdup(s)
+
+#define zmalloc(s) calloc(1, s)
+
+#define GFP_KERNEL
+
+/* PRINTK */
+
+#include <stdio.h>
+#define printk(fmt, args...) printf(fmt, ## args)
+
+
+/* ATTRIBUTES */
+
+#define ____cacheline_aligned
+
+/* MATH */
+
+static inline unsigned int hweight32(unsigned int w)
+{
+       unsigned int res = w - ((w >> 1) & 0x55555555);
+       res = (res & 0x33333333) + ((res >> 2) & 0x33333333);
+       res = (res + (res >> 4)) & 0x0F0F0F0F;
+       res = res + (res >> 8);
+       return (res + (res >> 16)) & 0x000000FF;
+}
+
+static inline int fls(int x)
+{
+        int r;
+//ust// #ifdef CONFIG_X86_CMOV
+        asm("bsrl %1,%0\n\t"
+            "cmovzl %2,%0"
+            : "=&r" (r) : "rm" (x), "rm" (-1));
+//ust// #else
+//ust//         asm("bsrl %1,%0\n\t"
+//ust//             "jnz 1f\n\t"
+//ust//             "movl $-1,%0\n"
+//ust//             "1:" : "=r" (r) : "rm" (x));
+//ust// #endif
+        return r + 1;
+}
+
+static __inline__ int get_count_order(unsigned int count)
+{
+       int order;
+       
+       order = fls(count) - 1;
+       if (count & (count - 1))
+               order++;
+       return order;
+}
+
+
+
+
+#include <unistd.h>
+
+#define ALIGN(x,a)             __ALIGN_MASK(x,(typeof(x))(a)-1)
+#define __ALIGN_MASK(x,mask)   (((x)+(mask))&~(mask))
+#define PAGE_ALIGN(addr) ALIGN(addr, PAGE_SIZE)
+#define PAGE_SIZE sysconf(_SC_PAGE_SIZE)
+#define PAGE_MASK (~(PAGE_SIZE-1))
+
+
+
+
+/* ARRAYS */
+
+#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
+
+/* TRACE CLOCK */
+
+/* There are two types of clocks that can be used.
+   - TSC based clock
+   - gettimeofday() clock
+
+   Microbenchmarks on Linux 2.6.30 on Core2 Duo 3GHz (functions are inlined):
+     Calls (100000000) to tsc(): 4004035641 cycles or 40 cycles/call
+     Calls (100000000) to gettimeofday(): 9723158352 cycles or 97 cycles/call
+
+   For merging traces with the kernel, a time source compatible with that of
+   the kernel is necessary.
+
+*/
+
+#if 0
+/* WARNING: Make sure to set frequency and scaling functions that will not
+ * result in lttv timestamps (sec.nsec) with seconds greater than 2**32-1.
+ */
+static inline u64 trace_clock_read64(void)
+{
+       uint32_t low;
+       uint32_t high;
+       uint64_t retval;
+       __asm__ volatile ("rdtsc\n" : "=a" (low), "=d" (high));
+
+       retval = high;
+       retval <<= 32;
+       return retval | low;
+}
+#endif
+
+static inline u64 trace_clock_read64(void)
+{
+       struct timeval tv;
+       u64 retval;
+
+       gettimeofday(&tv, NULL);
+       retval = tv.tv_sec;
+       retval *= 1000000;
+       retval += tv.tv_usec;
+
+       return retval;
+}
+
+static inline u64 trace_clock_frequency(void)
+{
+       return 1000000LL;
+}
+
+static inline u32 trace_clock_freq_scale(void)
+{
+       return 1;
+}
+
+
+#endif /* KERNELCOMPAT_H */
index cb2c46d974a1b0f16e69d87231b43591e39a7c2b..2b5a0c38ba701dfe6f1874eecee097b6bbd47e5a 100644 (file)
@@ -28,9 +28,8 @@
 //ust// #include <linux/types.h>
 #include <ust/immediate.h>
 //ust// #include <linux/ltt-channels.h>
-#include "kernelcompat.h"
+#include <ust/kernelcompat.h>
 #include <kcompat/list.h>
-#include "usterr.h"
 
 //ust// struct module;
 //ust// struct task_struct;
@@ -303,7 +302,6 @@ extern struct marker __stop___markers[] __attribute__((visibility("hidden")));
                                                                                        \
 static void __attribute__((constructor)) __markers__init(void)                                 \
 {                                                                                      \
-       DBG("next registration in "__FILE__"\n");\
        marker_register_lib(__start___markers, (((long)__stop___markers)-((long)__start___markers))/sizeof(struct marker));\
 }
 
index 7cfdbb01adbd4882a25165a9292170d63f0ba4df..56c62b0c6d3c884b1a6115cb4984eb9b17cb3de5 100644 (file)
@@ -32,7 +32,7 @@
 #include <urcu-bp.h>
 
 #include <ust/immediate.h>
-#include "kernelcompat.h"
+#include <ust/kernelcompat.h>
 
 struct module;
 struct tracepoint;
diff --git a/include/usterr.h b/include/usterr.h
new file mode 100644 (file)
index 0000000..1819f97
--- /dev/null
@@ -0,0 +1,80 @@
+#ifndef USTERR_H
+#define USTERR_H
+
+#include <string.h>
+#include <sys/types.h>
+#include <sys/syscall.h>
+#include <errno.h>
+#include <stdarg.h>
+
+#include "share.h"
+
+#ifndef UST_COMPONENT
+//#error UST_COMPONENT is undefined
+#define UST_COMPONENT libust
+#endif
+
+/* To stringify the expansion of a define */
+#define XSTR(d) STR(d)
+#define STR(s) #s
+
+/* We sometimes print in the tracing path, and tracing can occur in
+ * signal handlers, so we must use a print method which is signal safe.
+ */
+
+#define sigsafe_print_err(fmt, args...) \
+{ \
+       /* Can't use dynamic allocation. Limit ourselves to 250 chars. */ \
+       char ____buf[250]; \
+       int ____saved_errno; \
+\
+       /* Save the errno. */ \
+       ____saved_errno = errno; \
+\
+       snprintf(____buf, sizeof(____buf), fmt, ## args); \
+\
+       /* Add end of string in case of buffer overflow. */ \
+       ____buf[sizeof(____buf)-1] = 0; \
+\
+       patient_write(STDERR_FILENO, ____buf, strlen(____buf)); \
+       /* Can't print errors because we are in the error printing code path. */ \
+\
+       /* Restore errno, in order to be async-signal safe. */ \
+       errno = ____saved_errno; \
+}
+
+#define UST_STR_COMPONENT XSTR(UST_COMPONENT)
+
+#define ERRMSG(fmt, args...) do { sigsafe_print_err(UST_STR_COMPONENT "[%ld/%ld]: " fmt " (" __FILE__ ":" XSTR(__LINE__) ")\n", (long) getpid(), (long) syscall(SYS_gettid), ## args); fflush(stderr); } while(0)
+
+#define DEBUG
+#ifdef DEBUG
+# define DBG(fmt, args...) ERRMSG(fmt, ## args)
+#else
+# define DBG(fmt, args...) do {} while(0)
+#endif
+#define WARN(fmt, args...) ERRMSG("Warning: " fmt, ## args)
+#define ERR(fmt, args...) ERRMSG("Error: " fmt, ## args)
+#define BUG(fmt, args...) ERRMSG("BUG: " fmt, ## args)
+
+#if (_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && !defined(_GNU_SOURCE)
+#define PERROR(call, args...)\
+       do { \
+               char buf[200] = "Error in strerror_r()"; \
+               strerror_r(errno, buf, sizeof(buf)); \
+               ERRMSG("Error: " call ": %s", ## args, buf); \
+       } while(0);
+#else
+#define PERROR(call, args...)\
+       do { \
+               char *buf; \
+               char tmp[200]; \
+               buf = strerror_r(errno, tmp, sizeof(tmp)); \
+               ERRMSG("Error: " call ": %s", ## args, buf); \
+       } while(0);
+#endif
+
+#define BUG_ON(condition) do { if (unlikely(condition)) ERR("condition not respected (BUG)"); } while(0)
+#define WARN_ON(condition) do { if (unlikely(condition)) WARN("condition not respected on line %s:%d", __FILE__, __LINE__); } while(0)
+
+#endif /* USTERR_H */
index f9deb7acfe289b75377534fd3a8f816ef168301f..fa536287827edd13db88a8bc8d0209309a92ba7e 100644 (file)
@@ -1,4 +1,4 @@
-INCLUDES = -I$(top_builddir)/share -I$(top_builddir)/libust
+AM_CPPFLAGS = -I$(top_builddir)/include -I$(top_builddir)/libust
 
 lib_LTLIBRARIES = libustjava.la
 libustjava_la_SOURCES = UST.c UST.h
index 2bcebb115a3769ccfa74255ab93278970f50ef63..6540103badc7990f0cd0ea1502a69925f1654043 100644 (file)
@@ -1,3 +1,5 @@
+AM_CPPFLAGS = -I$(top_builddir)/include
+
 lib_LTLIBRARIES = libinterfork.la
 libinterfork_la_SOURCES = interfork.c
 libinterfork_la_LIBADD = -ldl
index 26a8bd6ad9f314525b6cc9b079d0fb03fd295ef5..e9dce9bfb188d7f60032d04a5f2b9d9dfd5f9f2b 100644 (file)
@@ -20,7 +20,7 @@
 #include <unistd.h>
 #include <stdio.h>
 #include <signal.h>
-#include "share/usterr.h"
+#include "usterr.h"
 
 extern void ust_fork(void);
 extern void ust_potential_exec(void);
index fa0930718b394ad2daa5320c11410394f0f74e4c..23b7004e6219e5acb772b59bb31f787fba4fb45c 100644 (file)
@@ -1,4 +1,4 @@
-INCLUDES = -I$(top_builddir)/share -I$(top_builddir)/include
+AM_CPPFLAGS = -I$(top_builddir)/include
 
 lib_LTLIBRARIES = libmallocwrap.la
 libmallocwrap_la_SOURCES = mallocwrap.c
index a8986f2f76ec362192c12992197b5c979bf46255..9ee3c9a21d2dee898b4599df9fdbd9f1eca3eaa5 100644 (file)
@@ -1,7 +1,7 @@
-AM_CPPFLAGS = -I$(top_builddir)/share -I$(top_builddir)/libustcomm -I$(top_builddir)/include
+AM_CPPFLAGS = -I$(top_builddir)/include -I$(top_builddir)/libustcomm
 
 lib_LTLIBRARIES = libust.la
-libust_la_SOURCES = buffer.h marker.c tracepoint.c channels.c channels.h marker-control.c marker-control.h relay.c relay.h tracer.c tracer.h tracercore.c tracercore.h serialize.c tracectl.c $(top_builddir)/libustcomm/ustcomm.c $(top_builddir)/share/usterr.h
+libust_la_SOURCES = buffer.h marker.c tracepoint.c channels.c channels.h marker-control.c marker-control.h relay.c relay.h tracer.c tracer.h tracercore.c tracercore.h serialize.c tracectl.c $(top_builddir)/libustcomm/ustcomm.c
 libust_la_LDFLAGS = -no-undefined -version-info 0:0:0
 libust_la_LIBADD = -lpthread
 libust_la_CFLAGS = -DUST_COMPONENT="libust"
index a4f4af1043c7ddc5998a277852345504139c092f..27ceefc6d6a1cd7921ebb09f91c6d585615348e3 100644 (file)
@@ -28,7 +28,7 @@
 //ust// #include <linux/mutex.h>
 //ust// #include <linux/vmalloc.h>
 
-#include "kernelcompat.h"
+#include <ust/kernelcompat.h>
 #include "channels.h"
 #include "usterr.h"
 #include <ust/marker.h>
index c91874b5c5cc23284ef4a698cc19d45dd8d49113..e460e12b916f0faa9ad58634ae180fa791db2a2e 100644 (file)
@@ -26,7 +26,7 @@
 //ust// #include <linux/list.h>
 #include <errno.h>
 
-#include "kernelcompat.h"
+#include <ust/kernelcompat.h>
 #include <kcompat/kref.h>
 
 #define EVENTS_PER_CHANNEL     65536
index c874c946d5647ee8d7ea4f90a1270464dfa6a5e6..a0786bad6fb306af26c8c1c300b01d5f2526f1db 100644 (file)
@@ -33,7 +33,7 @@
 //ust// #include <linux/slab.h>
 #include <ctype.h>
 
-#include "kernelcompat.h"
+#include <ust/kernelcompat.h>
 //#include "list.h"
 #include "tracer.h"
 #include "usterr.h"
index cebf07dde412e18dc34353a1216f6a1f9ac2b9de..8690d2b1151e0a5861c2c81327226cb55e46757a 100644 (file)
@@ -33,7 +33,7 @@
 #define _LGPL_SOURCE
 #include <urcu-bp.h>
 
-#include "kernelcompat.h"
+#include <ust/kernelcompat.h>
 
 #include <ust/marker.h>
 #include "usterr.h"
index 0326adc119943240fd9957659af8bf2a0ea1b790..408ce906f82c7f0262d71c2ea59270790f82b052 100644 (file)
@@ -22,7 +22,7 @@
 //ust// #include <linux/cpu.h>
 //ust// #include <linux/splice.h>
 //ust// #include <linux/bitops.h>
-#include "kernelcompat.h"
+#include <ust/kernelcompat.h>
 #include <sys/mman.h>
 #include <sys/ipc.h>
 #include <sys/shm.h>
index 0055d99403e0bd57f63fa4d4db478d642c50e58c..99d4dce4194e076ea5644d9780a89f14ff33a480 100644 (file)
@@ -32,7 +32,7 @@
 #include <string.h>
 #include <stdint.h>
 
-#include "kernelcompat.h"
+#include <ust/kernelcompat.h>
 #define _LGPL_SOURCE
 #include <urcu-bp.h>
 #include <urcu/rculist.h>
index 9de21c884892b64b78365bef3718aa5c547fcf08..cc2adf15e8e8c7ded54281be445528ac4086dcc0 100644 (file)
@@ -32,7 +32,7 @@
 
 #include <errno.h>
 
-#include "kernelcompat.h"
+#include <ust/kernelcompat.h>
 #include <ust/tracepoint.h>
 #include "usterr.h"
 //#include "list.h"
index 4150551af9efb09a028878a3eb4b19116a4441d8..a3ace72c0811de72d9cf08824dfab2137f80f229 100644 (file)
@@ -54,7 +54,7 @@
 //ust// #include <asm/atomic.h>
 #include <urcu/rculist.h>
 
-#include "kernelcompat.h"
+#include <ust/kernelcompat.h>
 #include "tracercore.h"
 #include "tracer.h"
 #include "usterr.h"
index 9275fd0d90deaed14d1d620232b45ce2bc3e030c..cb84dad7e05332725a20a54b65b6d2cf9b82a9e3 100644 (file)
@@ -27,7 +27,7 @@
 #include <sys/types.h>
 #include <stdarg.h>
 //#include "list.h"
-#include "kernelcompat.h"
+#include <ust/kernelcompat.h>
 #include "buffer.h"
 #include "relay.h"
 #include "channels.h"
index 90adee45b42c6734693356504b59926862bfbc4a..652de1b1eb4f67592bc4122e3dc326aff3d37c20 100644 (file)
@@ -22,7 +22,7 @@
 //ust// #include <linux/percpu.h>
 //ust// #include <linux/module.h>
 //ust// #include <linux/debugfs.h>
-#include "kernelcompat.h"
+#include <ust/kernelcompat.h>
 #include "tracercore.h"
 
 /* Traces structures */
index 8dfffa13f2c0750ca2d9b9a0bf5e739bb9479a3e..5a088db65e4e2c5c4e81ec91ecb640da7897aed5 100644 (file)
@@ -21,7 +21,7 @@
 #ifndef LTT_CORE_H
 #define LTT_CORE_H
 
-#include "kernelcompat.h"
+#include <ust/kernelcompat.h>
 //ust// #include <linux/percpu.h>
 
 /* ltt's root dir in debugfs */
diff --git a/share/kernelcompat.h b/share/kernelcompat.h
deleted file mode 100644 (file)
index 5cc5eaa..0000000
+++ /dev/null
@@ -1,206 +0,0 @@
-#ifndef KERNELCOMPAT_H
-#define KERNELCOMPAT_H
-
-#include <kcompat.h>
-
-#include <string.h>
-#include <sys/time.h>
-
-/* FIXME: libkcompat must not define arch-specific local ops, as ust *must*
- * fallback to the normal atomic ops. Fix things so we don't add them and
- * break things accidentally.
- */
-
-#define container_of(ptr, type, member) ({                      \
-        const typeof( ((type *)0)->member ) *__mptr = (ptr);    \
-        (type *)( (char *)__mptr - offsetof(type,member) );})
-
-#define KERN_DEBUG ""
-#define KERN_NOTICE ""
-#define KERN_INFO ""
-#define KERN_ERR ""
-#define KERN_ALERT ""
-#define KERN_WARNING ""
-
-/* ERROR OPS */
-
-#define MAX_ERRNO      4095
-
-#define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)
-
-static inline void *ERR_PTR(long error)
-{
-       return (void *) error;
-}
-
-static inline long PTR_ERR(const void *ptr)
-{
-       return (long) ptr;
-}
-
-static inline long IS_ERR(const void *ptr)
-{
-       return IS_ERR_VALUE((unsigned long)ptr);
-}
-
-
-/* Min / Max */
-
-#define min_t(type, x, y) ({                    \
-       type __min1 = (x);                      \
-       type __min2 = (y);                      \
-       __min1 < __min2 ? __min1: __min2; })
-
-#define max_t(type, x, y) ({                    \
-       type __max1 = (x);                      \
-       type __max2 = (y);                      \
-       __max1 > __max2 ? __max1: __max2; })
-
-
-/* MUTEXES */
-
-#include <pthread.h>
-
-#define DEFINE_MUTEX(m) pthread_mutex_t (m) = PTHREAD_MUTEX_INITIALIZER;
-#define DECLARE_MUTEX(m) extern pthread_mutex_t (m);
-
-#define mutex_lock(m) pthread_mutex_lock(m)
-
-#define mutex_unlock(m) pthread_mutex_unlock(m)
-
-
-/* MALLOCATION */
-
-#include <stdlib.h>
-
-#define kmalloc(s, t) malloc(s)
-#define kzalloc(s, t) zmalloc(s)
-#define kfree(p) free((void *)p)
-#define kstrdup(s, t) strdup(s)
-
-#define zmalloc(s) calloc(1, s)
-
-#define GFP_KERNEL
-
-/* PRINTK */
-
-#include <stdio.h>
-#define printk(fmt, args...) printf(fmt, ## args)
-
-
-/* ATTRIBUTES */
-
-#define ____cacheline_aligned
-
-/* MATH */
-
-static inline unsigned int hweight32(unsigned int w)
-{
-       unsigned int res = w - ((w >> 1) & 0x55555555);
-       res = (res & 0x33333333) + ((res >> 2) & 0x33333333);
-       res = (res + (res >> 4)) & 0x0F0F0F0F;
-       res = res + (res >> 8);
-       return (res + (res >> 16)) & 0x000000FF;
-}
-
-static inline int fls(int x)
-{
-        int r;
-//ust// #ifdef CONFIG_X86_CMOV
-        asm("bsrl %1,%0\n\t"
-            "cmovzl %2,%0"
-            : "=&r" (r) : "rm" (x), "rm" (-1));
-//ust// #else
-//ust//         asm("bsrl %1,%0\n\t"
-//ust//             "jnz 1f\n\t"
-//ust//             "movl $-1,%0\n"
-//ust//             "1:" : "=r" (r) : "rm" (x));
-//ust// #endif
-        return r + 1;
-}
-
-static __inline__ int get_count_order(unsigned int count)
-{
-       int order;
-       
-       order = fls(count) - 1;
-       if (count & (count - 1))
-               order++;
-       return order;
-}
-
-
-
-
-#include <unistd.h>
-
-#define ALIGN(x,a)             __ALIGN_MASK(x,(typeof(x))(a)-1)
-#define __ALIGN_MASK(x,mask)   (((x)+(mask))&~(mask))
-#define PAGE_ALIGN(addr) ALIGN(addr, PAGE_SIZE)
-#define PAGE_SIZE sysconf(_SC_PAGE_SIZE)
-#define PAGE_MASK (~(PAGE_SIZE-1))
-
-
-
-
-/* ARRAYS */
-
-#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
-
-/* TRACE CLOCK */
-
-/* There are two types of clocks that can be used.
-   - TSC based clock
-   - gettimeofday() clock
-
-   Microbenchmarks on Linux 2.6.30 on Core2 Duo 3GHz (functions are inlined):
-     Calls (100000000) to tsc(): 4004035641 cycles or 40 cycles/call
-     Calls (100000000) to gettimeofday(): 9723158352 cycles or 97 cycles/call
-
-   For merging traces with the kernel, a time source compatible with that of
-   the kernel is necessary.
-
-*/
-
-#if 0
-/* WARNING: Make sure to set frequency and scaling functions that will not
- * result in lttv timestamps (sec.nsec) with seconds greater than 2**32-1.
- */
-static inline u64 trace_clock_read64(void)
-{
-       uint32_t low;
-       uint32_t high;
-       uint64_t retval;
-       __asm__ volatile ("rdtsc\n" : "=a" (low), "=d" (high));
-
-       retval = high;
-       retval <<= 32;
-       return retval | low;
-}
-#endif
-
-static inline u64 trace_clock_read64(void)
-{
-       struct timeval tv;
-       u64 retval;
-
-       gettimeofday(&tv, NULL);
-       retval = tv.tv_sec;
-       retval *= 1000000;
-       retval += tv.tv_usec;
-
-       return retval;
-}
-
-static inline u64 trace_clock_frequency(void)
-{
-       return 1000000LL;
-}
-
-static inline u32 trace_clock_freq_scale(void)
-{
-       return 1;
-}
-
-
-#endif /* KERNELCOMPAT_H */
diff --git a/share/share.h b/share/share.h
deleted file mode 100644 (file)
index f674f31..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-#ifndef UST_SHARE_H
-#define UST_SHARE_H
-
-#include <unistd.h>
-#include <errno.h>
-
-/* This write is patient because it restarts if it was incomplete.
- */
-
-static inline ssize_t patient_write(int fd, const void *buf, size_t count)
-{
-       const char *bufc = (const char *) buf;
-       int result;
-
-       for(;;) {
-               result = write(fd, bufc, count);
-               if(result == -1 && errno == EINTR) {
-                       continue;
-               }
-               if(result <= 0) {
-                       return result;
-               }
-               count -= result;
-               bufc += result;
-
-               if(count == 0) {
-                       break;
-               }
-       }
-
-       return bufc-(const char *)buf;
-}
-
-#endif /* UST_SHARE_H */
diff --git a/share/usterr.h b/share/usterr.h
deleted file mode 100644 (file)
index 1819f97..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-#ifndef USTERR_H
-#define USTERR_H
-
-#include <string.h>
-#include <sys/types.h>
-#include <sys/syscall.h>
-#include <errno.h>
-#include <stdarg.h>
-
-#include "share.h"
-
-#ifndef UST_COMPONENT
-//#error UST_COMPONENT is undefined
-#define UST_COMPONENT libust
-#endif
-
-/* To stringify the expansion of a define */
-#define XSTR(d) STR(d)
-#define STR(s) #s
-
-/* We sometimes print in the tracing path, and tracing can occur in
- * signal handlers, so we must use a print method which is signal safe.
- */
-
-#define sigsafe_print_err(fmt, args...) \
-{ \
-       /* Can't use dynamic allocation. Limit ourselves to 250 chars. */ \
-       char ____buf[250]; \
-       int ____saved_errno; \
-\
-       /* Save the errno. */ \
-       ____saved_errno = errno; \
-\
-       snprintf(____buf, sizeof(____buf), fmt, ## args); \
-\
-       /* Add end of string in case of buffer overflow. */ \
-       ____buf[sizeof(____buf)-1] = 0; \
-\
-       patient_write(STDERR_FILENO, ____buf, strlen(____buf)); \
-       /* Can't print errors because we are in the error printing code path. */ \
-\
-       /* Restore errno, in order to be async-signal safe. */ \
-       errno = ____saved_errno; \
-}
-
-#define UST_STR_COMPONENT XSTR(UST_COMPONENT)
-
-#define ERRMSG(fmt, args...) do { sigsafe_print_err(UST_STR_COMPONENT "[%ld/%ld]: " fmt " (" __FILE__ ":" XSTR(__LINE__) ")\n", (long) getpid(), (long) syscall(SYS_gettid), ## args); fflush(stderr); } while(0)
-
-#define DEBUG
-#ifdef DEBUG
-# define DBG(fmt, args...) ERRMSG(fmt, ## args)
-#else
-# define DBG(fmt, args...) do {} while(0)
-#endif
-#define WARN(fmt, args...) ERRMSG("Warning: " fmt, ## args)
-#define ERR(fmt, args...) ERRMSG("Error: " fmt, ## args)
-#define BUG(fmt, args...) ERRMSG("BUG: " fmt, ## args)
-
-#if (_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && !defined(_GNU_SOURCE)
-#define PERROR(call, args...)\
-       do { \
-               char buf[200] = "Error in strerror_r()"; \
-               strerror_r(errno, buf, sizeof(buf)); \
-               ERRMSG("Error: " call ": %s", ## args, buf); \
-       } while(0);
-#else
-#define PERROR(call, args...)\
-       do { \
-               char *buf; \
-               char tmp[200]; \
-               buf = strerror_r(errno, tmp, sizeof(tmp)); \
-               ERRMSG("Error: " call ": %s", ## args, buf); \
-       } while(0);
-#endif
-
-#define BUG_ON(condition) do { if (unlikely(condition)) ERR("condition not respected (BUG)"); } while(0)
-#define WARN_ON(condition) do { if (unlikely(condition)) WARN("condition not respected on line %s:%d", __FILE__, __LINE__); } while(0)
-
-#endif /* USTERR_H */
index bfb77fcdf781908f36a741ae2b68e6b7dce5ec4c..4945cdf15764254bcdb3ccc84dfe3b5a77daf234 100644 (file)
@@ -1,4 +1,4 @@
-INCLUDES = -I$(top_builddir)/share -I$(top_builddir)/include
+AM_CPPFLAGS = -I$(top_builddir)/include
 
 noinst_PROGRAMS = basic
 basic_SOURCES = basic.c
index 867ac837cdc79c499c31811af33cf6591cf8115e..00b5ec618a40d98a3e75d08afd92728be65cda93 100644 (file)
@@ -1,4 +1,4 @@
-INCLUDES = -I$(top_builddir)/share -I$(top_builddir)/include
+AM_CPPFLAGS = -I$(top_builddir)/include
 
 noinst_PROGRAMS = basic_long
 basic_long_SOURCES = basic_long.c
index 4e2baf897c8f22b510d60c2d7b8a1c455b5e2fc0..7bbef71d5b2699b6adab4ff7264a2b3dff472907 100644 (file)
@@ -1,4 +1,4 @@
-INCLUDES = -I$(top_builddir)/share -I$(top_builddir)/include
+AM_CPPFLAGS = -I$(top_builddir)/include
 
 noinst_PROGRAMS = fork fork2
 fork_SOURCES = fork.c
index e6b33857377127122d18f9b3c724ba38fec9fefd..ce0ad2fe86d1af397482f6cb9bfabe42650ca17d 100644 (file)
@@ -1,4 +1,4 @@
-INCLUDES = -I$(top_builddir)/share -I$(top_builddir)/include
+AM_CPPFLAGS = -I$(top_builddir)/include
 
 noinst_PROGRAMS = hello
 hello_SOURCES = hello.c tp.c tp.h
index dc220c46075141063200ea856dab819f311b7579..c48b6df53359474c1410323bbf3f4a3631766093 100644 (file)
@@ -8,6 +8,7 @@
 #include <signal.h>
 
 #include <ust/marker.h>
+#include "usterr.h"
 #include "tp.h"
 
 
index 85cfd2b87fbdb1bbbc1181c0f26711846bba0f2f..e06d50592c8539b7ec4c29298ca1d22063906e13 100644 (file)
@@ -1,4 +1,4 @@
-INCLUDES = -I$(top_builddir)/share -I$(top_builddir)/include
+AM_CPPFLAGS = -I$(top_builddir)/include
 
 noinst_PROGRAMS = hello2
 hello2_SOURCES = hello2.c
index a27880a03404ae3dd7642ac77ab9a4b3fd552720..93c5629c98b5a7c501a0c4ec69fbfcf5f38c9e43 100644 (file)
@@ -1,8 +1,7 @@
+AM_CPPFLAGS = -I$(top_builddir)/include -I$(top_builddir)/libustcomm \
+       -I$(top_builddir)/libustcmd $(KCOMPAT_CFLAGS)
+
 bin_PROGRAMS = ustctl
-ustctl_SOURCES = ustctl.c $(top_builddir)/libustcomm/ustcomm.c $(top_builddir)/libustcomm/ustcomm.h $(top_builddir)/libustcmd/ustcmd.c $(top_builddir)/libustcmd/ustcmd.h $(top_builddir)/share/usterr.h
+ustctl_SOURCES = ustctl.c $(top_builddir)/libustcomm/ustcomm.c $(top_builddir)/libustcomm/ustcomm.h $(top_builddir)/libustcmd/ustcmd.c $(top_builddir)/libustcmd/ustcmd.h
 ustctl_CFLAGS = -DUST_COMPONENT=ustctl
 
-INCLUDES = $(KCOMPAT_CFLAGS)
-INCLUDES += -I$(top_builddir)/libustcomm
-INCLUDES += -I$(top_builddir)/libustcmd
-INCLUDES += -I$(top_builddir)/share
index e8fa272bcb938ee2e51d9ac5bafd18307fd64343..8c8fe647ab328b67d06069c39df1a1e86c9d9cae 100644 (file)
@@ -1,7 +1,7 @@
-AM_CPPFLAGS = -I$(top_builddir)/share -I$(top_builddir)/libust \
-        -I$(top_builddir)/libustcomm -I$(top_builddir)/include
+AM_CPPFLAGS = -I$(top_builddir)/libust -I$(top_builddir)/libustcomm \
+       -I$(top_builddir)/include
 
 bin_PROGRAMS = ustd
-ustd_SOURCES = lowlevel.c ustd.c ustd.h $(top_builddir)/libustcomm/ustcomm.c $(top_builddir)/libustcomm/ustcomm.h $(top_builddir)/share/usterr.h
+ustd_SOURCES = lowlevel.c ustd.c ustd.h $(top_builddir)/libustcomm/ustcomm.c $(top_builddir)/libustcomm/ustcomm.h
 ustd_LDFLAGS = -lpthread
 ustd_CFLAGS = -DUST_COMPONENT=ustd
index fef0eae1680336dfe83eb05b8ca16b37d1d6fa39..0026c3b12a88816392df29447289d48404656d16 100644 (file)
@@ -35,7 +35,6 @@
 #include "ustd.h"
 #include "usterr.h"
 #include "ustcomm.h"
-#include "share.h"
 
 /* return value: 0 = subbuffer is finished, it won't produce data anymore
  *               1 = got subbuffer successfully
This page took 0.039773 seconds and 4 git commands to generate.