move libkcompat inside ust
authorPierre-Marc Fournier <pierre-marc.fournier@polymtl.ca>
Tue, 16 Mar 2010 20:53:35 +0000 (16:53 -0400)
committerPierre-Marc Fournier <pierre-marc.fournier@polymtl.ca>
Tue, 16 Mar 2010 20:53:35 +0000 (16:53 -0400)
16 files changed:
configure.ac
include/Makefile.am
include/ust/kcompat/compiler.h [new file with mode: 0644]
include/ust/kcompat/disable.h [new file with mode: 0644]
include/ust/kcompat/hlist.h [new file with mode: 0644]
include/ust/kcompat/jhash.h [new file with mode: 0644]
include/ust/kcompat/kcompat.h [new file with mode: 0644]
include/ust/kcompat/kref.h [new file with mode: 0644]
include/ust/kcompat/simple.h [new file with mode: 0644]
include/ust/kcompat/types.h [new file with mode: 0644]
include/ust/kernelcompat.h
libust/buffers.c
libust/buffers.h
libust/channels.h
libust/marker.c
libustcomm/ustcomm.h

index b1fb068bd85c0fcddab6466f9a37ecd753679231..e8cedce65fcfce67064da11c72134104e2fc8e89 100644 (file)
@@ -61,10 +61,6 @@ This error can also occur when the liburcu package's configure script has not be
 # urcu - check that URCU lib is available to compilation
 AC_CHECK_LIB([urcu-bp], [synchronize_rcu], [], [AC_MSG_ERROR([Cannot find liburcu-bp lib. Use [LDFLAGS]=-Ldir to specify its location.])])
 
-# kcompat
-
-AC_CHECK_HEADERS([kcompat.h], [], [AC_MSG_ERROR([Cannot find kcompat headers (kcompat.h). Use [CFLAGS]=-Idir to specify their location.])])
-
 # Check for various supplementary host information (beyond the
 # triplet) which might affect the library format choices.  E.g., we
 # can be building with `i686-unknown-linux-gnu-gcc -m64'
index ac8fffeaf80245038889239b9a13cafb50540351..a98cee1a560ad525c038370137c1cb1abfc3bc3b 100644 (file)
@@ -1,4 +1,18 @@
-nobase_include_HEADERS = ust/immediate.h ust/kernelcompat.h ust/marker.h \
-       ust/tracepoint.h ust/processor.h ust/probe.h ust/ust.h ust/tracectl.h
+nobase_include_HEADERS = \
+       ust/immediate.h \
+       ust/kernelcompat.h \
+       ust/marker.h \
+       ust/tracepoint.h \
+       ust/processor.h \
+       ust/probe.h \
+       ust/ust.h \
+       ust/tracectl.h \
+       ust/kcompat/compiler.h \
+       ust/kcompat/disable.h \
+       ust/kcompat/hlist.h \
+       ust/kcompat/jhash.h \
+       ust/kcompat/kref.h \
+       ust/kcompat/simple.h \
+       ust/kcompat/types.h
 
 noinst_HEADERS = share.h usterr.h ust_snprintf.h
diff --git a/include/ust/kcompat/compiler.h b/include/ust/kcompat/compiler.h
new file mode 100644 (file)
index 0000000..d3ef8a1
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * compiler.h
+ *
+ * Copyright (C) 2009 - Pierre-Marc Fournier (pierre-marc dot fournier at polymtl dot ca)
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
+ */
+
+#ifndef KCOMPAT_COMPILER_H
+#define KCOMPAT_COMPILER_H
+
+# define inline         inline          __attribute__((always_inline))
+# define __inline__     __inline__      __attribute__((always_inline))
+# define __inline       __inline        __attribute__((always_inline))
+
+#ifndef __always_inline
+#define __always_inline inline
+#endif
+
+#define __pure                          __attribute__((pure))
+#define __aligned(x)                    __attribute__((aligned(x)))
+#define __printf(a,b)                   __attribute__((format(printf,a,b)))
+#define  noinline                       __attribute__((noinline))
+#define __attribute_const__             __attribute__((__const__))
+#define __maybe_unused                  __attribute__((unused))
+
+#define notrace __attribute__((no_instrument_function))
+
+#endif /* KCOMPAT_COMPILER_H */
diff --git a/include/ust/kcompat/disable.h b/include/ust/kcompat/disable.h
new file mode 100644 (file)
index 0000000..36d36f5
--- /dev/null
@@ -0,0 +1,21 @@
+/*
+ * disable.h
+ *
+ * Copyright (C) 2009 - Pierre-Marc Fournier (pierre-marc dot fournier at polymtl dot ca)
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
+ */
+
+#define prefetch(a) ({ do {} while(0); })
diff --git a/include/ust/kcompat/hlist.h b/include/ust/kcompat/hlist.h
new file mode 100644 (file)
index 0000000..1bec11a
--- /dev/null
@@ -0,0 +1,73 @@
+#ifndef _KCOMPAT_HLIST_H
+#define _KCOMPAT_HLIST_H
+
+/*
+ * Kernel sourcecode compatible lightweight single pointer list head useful
+ * for implementing hash tables
+ *
+ * Copyright (C) 2009 Novell Inc.
+ *
+ * Author: Jan Blunck <jblunck@suse.de>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License version 2.1 as
+ * published by the Free  Software Foundation.
+ */
+
+struct hlist_head
+{
+       struct hlist_node *next;
+};
+
+struct hlist_node
+{
+       struct hlist_node *next;
+       struct hlist_node *prev;
+};
+
+/* Initialize a new list head.  */
+static inline void  INIT_HLIST_HEAD(struct hlist_head *ptr)
+{
+       ptr->next = NULL;
+}
+
+/* Get typed element from list at a given position.  */
+#define hlist_entry(ptr, type, member)                                 \
+       ((type *) ((char *) (ptr) - (unsigned long) (&((type *) 0)->member)))
+
+/* Add new element at the head of the list.  */
+static inline void hlist_add_head (struct hlist_node *newp,
+                                  struct hlist_head *head)
+{
+       if (head->next)
+               head->next->prev = newp;
+
+       newp->next = head->next;
+       newp->prev = (struct hlist_node *)head;
+       head->next = newp;
+}
+
+/* Remove element from list.  */
+static inline void hlist_del (struct hlist_node *elem)
+{
+       if (elem->next)
+               elem->next->prev = elem->prev;
+
+       elem->prev->next = elem->next;
+}
+
+#define hlist_for_each_entry(entry, pos, head, member)                 \
+       for (pos = (head)->next,                                        \
+                    entry = hlist_entry(pos, typeof(*entry), member);  \
+            pos != NULL;                                               \
+            pos = pos->next,                                   \
+                    entry = hlist_entry(pos, typeof(*entry), member))
+
+#define hlist_for_each_entry_safe(entry, pos, p, head, member)         \
+       for (pos = (head)->next,                                        \
+                    entry = hlist_entry(pos, typeof(*entry), member);  \
+            (pos != NULL) && ({ p = pos->next; 1;});                   \
+            pos = p,                                                   \
+                    entry = hlist_entry(pos, typeof(*entry), member))
+
+#endif /* _KCOMPAT_HLIST_H */
diff --git a/include/ust/kcompat/jhash.h b/include/ust/kcompat/jhash.h
new file mode 100644 (file)
index 0000000..dad0abb
--- /dev/null
@@ -0,0 +1,84 @@
+#ifndef KCOMPAT_JHASH_H
+#define KCOMPAT_JHASH_H
+
+/* jhash.h: Jenkins hash support.
+ *
+ * Copyright (C) 1996 Bob Jenkins (bob_jenkins@burtleburtle.net)
+ *
+ * http://burtleburtle.net/bob/hash/
+ *
+ * These are the credits from Bob's sources:
+ *
+ * lookup2.c, by Bob Jenkins, December 1996, Public Domain.
+ * hash(), hash2(), hash3, and mix() are externally useful functions.
+ * Routines to test the hash are included if SELF_TEST is defined.
+ * You can use this free for any purpose.  It has no warranty.
+ *
+ * Copyright (C) 2003 David S. Miller (davem@redhat.com)
+ *
+ * I've modified Bob's hash to be useful in the Linux kernel, and
+ * any bugs present are surely my fault.  -DaveM
+ */
+
+/* NOTE: Arguments are modified. */
+#define __jhash_mix(a, b, c) \
+{ \
+  a -= b; a -= c; a ^= (c>>13); \
+  b -= c; b -= a; b ^= (a<<8); \
+  c -= a; c -= b; c ^= (b>>13); \
+  a -= b; a -= c; a ^= (c>>12);  \
+  b -= c; b -= a; b ^= (a<<16); \
+  c -= a; c -= b; c ^= (b>>5); \
+  a -= b; a -= c; a ^= (c>>3);  \
+  b -= c; b -= a; b ^= (a<<10); \
+  c -= a; c -= b; c ^= (b>>15); \
+}
+
+/* The golden ration: an arbitrary value */
+#define JHASH_GOLDEN_RATIO     0x9e3779b9
+
+/* The most generic version, hashes an arbitrary sequence
+ * of bytes.  No alignment or length assumptions are made about
+ * the input key.
+ */
+static inline u32 jhash(const void *key, u32 length, u32 initval)
+{
+       u32 a, b, c, len;
+       const u8 *k = key;
+
+       len = length;
+       a = b = JHASH_GOLDEN_RATIO;
+       c = initval;
+
+       while (len >= 12) {
+               a += (k[0] +((u32)k[1]<<8) +((u32)k[2]<<16) +((u32)k[3]<<24));
+               b += (k[4] +((u32)k[5]<<8) +((u32)k[6]<<16) +((u32)k[7]<<24));
+               c += (k[8] +((u32)k[9]<<8) +((u32)k[10]<<16)+((u32)k[11]<<24));
+
+               __jhash_mix(a,b,c);
+
+               k += 12;
+               len -= 12;
+       }
+
+       c += length;
+       switch (len) {
+       case 11: c += ((u32)k[10]<<24);
+       case 10: c += ((u32)k[9]<<16);
+       case 9 : c += ((u32)k[8]<<8);
+       case 8 : b += ((u32)k[7]<<24);
+       case 7 : b += ((u32)k[6]<<16);
+       case 6 : b += ((u32)k[5]<<8);
+       case 5 : b += k[4];
+       case 4 : a += ((u32)k[3]<<24);
+       case 3 : a += ((u32)k[2]<<16);
+       case 2 : a += ((u32)k[1]<<8);
+       case 1 : a += k[0];
+       };
+
+       __jhash_mix(a,b,c);
+
+       return c;
+}
+
+#endif /* KCOMPAT_JHASH_H */
diff --git a/include/ust/kcompat/kcompat.h b/include/ust/kcompat/kcompat.h
new file mode 100644 (file)
index 0000000..4aea4cc
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+ * kcompat.h
+ *
+ * Copyright (C) 2009 - Pierre-Marc Fournier (pierre-marc dot fournier at polymtl dot ca)
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
+ */
+
+#ifndef KCOMPAT_H
+#define KCOMPAT_H
+
+#define __KERNEL__
+#define _LOOSE_KERNEL_NAMES
+
+#ifndef CONFIG_SMP
+#define CONFIG_SMP 1 /* Needed for urcu, verify it's ok to remove it. */
+#endif
+
+#include <limits.h>
+#include <bits/wordsize.h>
+#if __WORDSIZE == 32
+#define LIBKCOMPAT_X86_32
+#elif __WORDSIZE == 64
+#define LIBKCOMPAT_X86_64
+#else
+#error "Unsupported"
+#endif
+
+#ifdef LIBKCOMPAT_X86_32
+#define CONFIG_X86_32
+#define CONFIG_32BIT
+#endif
+
+#ifdef LIBKCOMPAT_X86_64
+#define CONFIG_X86_64
+#define CONFIG_64BIT
+#endif
+
+/* Standard libs */
+#include <stdint.h>
+#include <stddef.h>
+
+/* Taken from userspace-rcu */
+#include <urcu/arch.h>
+
+/* Kernel libs */
+#include <ust/kcompat/simple.h>
+#include <ust/kcompat/compiler.h>
+#include <ust/kcompat/types.h>
+#include <ust/kcompat/hlist.h>
+
+#include <ust/kcompat/jhash.h>
+
+#include <ust/kcompat/disable.h>
+
+#include <ust/kcompat/kref.h>
+
+#endif /* KCOMPAT_H */
diff --git a/include/ust/kcompat/kref.h b/include/ust/kcompat/kref.h
new file mode 100644 (file)
index 0000000..f0604ef
--- /dev/null
@@ -0,0 +1,46 @@
+#ifndef _KCOMPAT_KREF_H
+#define _KCOMPAT_KREF_H
+
+/*
+ * Kernel sourcecode compatible reference counting implementation
+ *
+ * Copyright (C) 2009 Novell Inc.
+ *
+ * Author: Jan Blunck <jblunck@suse.de>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License version 2.1 as
+ * published by the Free  Software Foundation.
+ */
+
+#include <assert.h>
+#include <urcu/uatomic_arch.h>
+
+struct kref {
+       long refcount; /* ATOMIC */
+};
+
+static inline void kref_set(struct kref *ref, int val)
+{
+       uatomic_set(&ref->refcount, val);
+}
+
+static inline void kref_init(struct kref *ref)
+{
+       kref_set(ref, 1);
+}
+
+static inline void kref_get(struct kref *ref)
+{
+       long result = uatomic_add_return(&ref->refcount, 1);
+       assert(result != 0);
+}
+
+static inline void kref_put(struct kref *ref, void (*release)(struct kref *))
+{
+       long res = uatomic_sub_return(&ref->refcount, 1);
+       if (res == 0)
+               release(ref);
+}
+
+#endif /* _KCOMPAT_KREF_H */
diff --git a/include/ust/kcompat/simple.h b/include/ust/kcompat/simple.h
new file mode 100644 (file)
index 0000000..762d802
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * simple.h
+ *
+ * Copyright (C) 2009 - Pierre-Marc Fournier (pierre-marc dot fournier at polymtl dot ca)
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
+ */
+
+#ifndef KCOMPAT_SIMPLE_H
+#define KCOMPAT_SIMPLE_H
+
+/**
+ * container_of - cast a member of a structure out to the containing structure
+ * @ptr:       the pointer to the member.
+ * @type:      the type of the container struct this is embedded in.
+ * @member:    the name of the member within the struct.
+ *
+ */
+#define container_of(ptr, type, member) ({                     \
+       const typeof( ((type *)0)->member ) *__mptr = (ptr);    \
+       (type *)( (char *)__mptr - offsetof(type,member) );})
+
+
+/* libkcompat: from rcupdate.h */
+
+struct rcu_head {
+       struct rcu_head *next;
+       void (*func)(struct rcu_head *head);
+};
+
+#endif /* KCOMPAT_SIMPLE_H */
diff --git a/include/ust/kcompat/types.h b/include/ust/kcompat/types.h
new file mode 100644 (file)
index 0000000..63f9ede
--- /dev/null
@@ -0,0 +1,32 @@
+#ifndef _KCOMPAT_TYPES
+#define _KCOMPAT_TYPES
+
+/*
+ * Kernel sourcecode compatibility layer
+ *
+ * Copyright (C) 2009 Novell Inc.
+ *
+ * Author: Jan Blunck <jblunck@suse.de>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License version 2.1 as
+ * published by the Free  Software Foundation.
+ */
+
+#include <asm/types.h>
+
+#ifdef __KERNEL__
+typedef __s8 s8;
+typedef __u8 u8;
+
+typedef __s16 s16;
+typedef __u16 u16;
+
+typedef __s32 s32;
+typedef __u32 u32;
+
+typedef __s64 s64;
+typedef __u64 u64;
+#endif
+
+#endif /* _KCOMPAT_TYPES */
index b6e85c3fb5353267b3a8d9988187c63c6d61acb1..e6885f7dca020cf92edf25c64e5992409457db0f 100644 (file)
@@ -18,7 +18,7 @@
 #ifndef KERNELCOMPAT_H
 #define KERNELCOMPAT_H
 
-#include <kcompat.h>
+#include <ust/kcompat/kcompat.h>
 #include <urcu/list.h>
 
 /* FIXME: libkcompat must not define arch-specific local ops, as ust *must*
index 88ec5d3b0aa87dd62fad00bfe6df2440d8960408..8cadeabf4207699473cbdadfc38c10da2c03d0f1 100644 (file)
@@ -26,7 +26,6 @@
 #include <sys/shm.h>
 #include <fcntl.h>
 #include <ust/kernelcompat.h>
-#include <kcompat/kref.h>
 #include <stdlib.h>
 #include "buffers.h"
 #include "channels.h"
index 44e8598d505ed4b37ed3d41703d35ef4caf6297b..d3267e102ca5e56a8b6da731ce778790d002f3f7 100644 (file)
 #ifndef _UST_BUFFERS_H
 #define _UST_BUFFERS_H
 
-#include <kcompat/kref.h>
 #include <assert.h>
+#include <ust/kernelcompat.h>
+#include "usterr.h"
 #include "channels.h"
 #include "tracerconst.h"
 #include "tracercore.h"
 #include "header-inline.h"
-#include <usterr.h>
 
 /***** FIXME: SHOULD BE REMOVED ***** */
 
index 0d2715d17166fbabfa4768b9f2591214d0546239..e92e6cced4b31c119927757c317899d2f860487d 100644 (file)
@@ -25,7 +25,6 @@
 #include <errno.h>
 
 #include <ust/kernelcompat.h>
-#include <kcompat/kref.h>
 
 #define EVENTS_PER_CHANNEL     65536
 #define MAX_CPUS               32
index ef6f029ac65a2dc75ccb6d84a69c823f74c6af20..4a3e16b96c7dd365aa352be1b0882f59390ff6d2 100644 (file)
@@ -20,6 +20,7 @@
 #include <errno.h>
 #define _LGPL_SOURCE
 #include <urcu-bp.h>
+#include <urcu/rculist.h>
 
 #include <ust/kernelcompat.h>
 #include <ust/marker.h>
index e7e73621dc4c74244dadd80c1870cf07cb9dbb7b..a8fd6408aa68540fc109dbdeec8e5dc17b4003fc 100644 (file)
@@ -22,7 +22,7 @@
 #include <sys/un.h>
 #include <urcu/list.h>
 
-#include "kcompat.h"
+#include <ust/kcompat/kcompat.h>
 #include "multipoll.h"
 
 #define SOCK_DIR "/tmp/ust-app-socks"
This page took 0.03151 seconds and 4 git commands to generate.