summaryrefslogtreecommitdiff
path: root/upb/bindings/linux
diff options
context:
space:
mode:
authorJosh Haberman <jhaberman@gmail.com>2014-01-21 18:38:49 -0800
committerJosh Haberman <jhaberman@gmail.com>2014-01-21 18:38:49 -0800
commit0fd2f830882402979a83010e89650e7245960d39 (patch)
tree0968ca9424c5fb2433047519cbd54d3dd8d0b863 /upb/bindings/linux
parentce9bba3cb5409844f8f3d7dcc235a9ea30cad090 (diff)
Sync to internal Google development.
Diffstat (limited to 'upb/bindings/linux')
-rw-r--r--upb/bindings/linux/Makefile20
-rw-r--r--upb/bindings/linux/assert.h20
-rw-r--r--upb/bindings/linux/errno.h8
-rw-r--r--upb/bindings/linux/stdint.h8
-rw-r--r--upb/bindings/linux/stdio.h10
-rw-r--r--upb/bindings/linux/stdlib.h22
-rw-r--r--upb/bindings/linux/string.h13
7 files changed, 101 insertions, 0 deletions
diff --git a/upb/bindings/linux/Makefile b/upb/bindings/linux/Makefile
new file mode 100644
index 0000000..1736b61
--- /dev/null
+++ b/upb/bindings/linux/Makefile
@@ -0,0 +1,20 @@
+obj-m = upb.o
+
+upb-objs = \
+ ../../upb/upb.o \
+ ../../upb/bytestream.o \
+ ../../upb/def.o \
+ ../../upb/handlers.o \
+ ../../upb/table.o \
+ ../../upb/refcount.o \
+ ../../upb/msg.o \
+
+KVERSION = $(shell uname -r)
+
+ccflags-y := -I$(PWD) -I$(PWD)/../.. -Wno-declaration-after-statement -std=gnu99
+
+all:
+ make -C /lib/modules/$(KVERSION)/build M=$(PWD) modules
+
+clean:
+ make -C /lib/modules/$(KVERSION)/build M=$(PWD) clean
diff --git a/upb/bindings/linux/assert.h b/upb/bindings/linux/assert.h
new file mode 100644
index 0000000..26d8ab6
--- /dev/null
+++ b/upb/bindings/linux/assert.h
@@ -0,0 +1,20 @@
+/*
+ * upb - a minimalist implementation of protocol buffers.
+ *
+ * Copyright (c) 2012 Google Inc. See LICENSE for details.
+ * Author: Josh Haberman <jhaberman@gmail.com>
+ */
+
+#include <linux/kernel.h>
+
+#ifndef UPB_LINUX_ASSERT_H
+#define UPB_LINUX_ASSERT_H
+
+#ifdef NDEBUG
+#define assert(x)
+#else
+#define assert(x) \
+ if (!(x)) panic("Assertion failed: %s at %s:%d", #x, __FILE__, __LINE__);
+#endif
+
+#endif
diff --git a/upb/bindings/linux/errno.h b/upb/bindings/linux/errno.h
new file mode 100644
index 0000000..f45d939
--- /dev/null
+++ b/upb/bindings/linux/errno.h
@@ -0,0 +1,8 @@
+/*
+ * upb - a minimalist implementation of protocol buffers.
+ *
+ * Copyright (c) 2012 Google Inc. See LICENSE for details.
+ * Author: Josh Haberman <jhaberman@gmail.com>
+ */
+
+#include <linux/errno.h>
diff --git a/upb/bindings/linux/stdint.h b/upb/bindings/linux/stdint.h
new file mode 100644
index 0000000..2524b23
--- /dev/null
+++ b/upb/bindings/linux/stdint.h
@@ -0,0 +1,8 @@
+/*
+ * upb - a minimalist implementation of protocol buffers.
+ *
+ * Copyright (c) 2012 Google Inc. See LICENSE for details.
+ * Author: Josh Haberman <jhaberman@gmail.com>
+ */
+
+#include <linux/types.h>
diff --git a/upb/bindings/linux/stdio.h b/upb/bindings/linux/stdio.h
new file mode 100644
index 0000000..72c1b0d
--- /dev/null
+++ b/upb/bindings/linux/stdio.h
@@ -0,0 +1,10 @@
+/*
+ * upb - a minimalist implementation of protocol buffers.
+ *
+ * Copyright (c) 2012 Google Inc. See LICENSE for details.
+ * Author: Josh Haberman <jhaberman@gmail.com>
+ *
+ * Linux-kernel implementations of some stdlib.h functions.
+ */
+
+#include <linux/kernel.h> // For sprintf and friends.
diff --git a/upb/bindings/linux/stdlib.h b/upb/bindings/linux/stdlib.h
new file mode 100644
index 0000000..8381b13
--- /dev/null
+++ b/upb/bindings/linux/stdlib.h
@@ -0,0 +1,22 @@
+/*
+ * upb - a minimalist implementation of protocol buffers.
+ *
+ * Copyright (c) 2012 Google Inc. See LICENSE for details.
+ * Author: Josh Haberman <jhaberman@gmail.com>
+ *
+ * Linux-kernel implementations of some stdlib.h functions.
+ */
+
+#include <linux/slab.h>
+
+#ifndef UPB_LINUX_STDLIB_H
+#define UPB_LINUX_STDLIB_H
+
+static inline void *malloc(size_t size) { return kmalloc(size, GFP_ATOMIC); }
+static inline void free(void *p) { kfree(p); }
+
+static inline void *realloc(void *p, size_t size) {
+ return krealloc(p, size, GFP_ATOMIC);
+}
+
+#endif
diff --git a/upb/bindings/linux/string.h b/upb/bindings/linux/string.h
new file mode 100644
index 0000000..30ebf8a
--- /dev/null
+++ b/upb/bindings/linux/string.h
@@ -0,0 +1,13 @@
+/*
+ * upb - a minimalist implementation of protocol buffers.
+ *
+ * Copyright (c) 2012 Google Inc. See LICENSE for details.
+ * Author: Josh Haberman <jhaberman@gmail.com>
+ */
+
+#ifndef UPB_LINUX_STRING_H_
+#define UPB_LINUX_STRING_H_
+
+#include <linux/string.h>
+
+#endif /* UPB_DEF_H_ */
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback