socsvn commit: r271079 - in soc2014/dpl/netmap-ipfwjit: . sys/netpfil/ipfw

dpl at FreeBSD.org dpl at FreeBSD.org
Fri Jul 18 13:54:32 UTC 2014


Author: dpl
Date: Fri Jul 18 13:54:29 2014
New Revision: 271079
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=271079

Log:
  Modularized the code and modified Makefiles, there's "only" all the LLVM stuff left.
  

Added:
  soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/ip_fw2.c
     - copied, changed from r271013, soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/ip_fw2.cc
  soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/jit.cc
  soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/jit.h
Deleted:
  soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/ip_fw2.cc
Modified:
  soc2014/dpl/netmap-ipfwjit/Makefile
  soc2014/dpl/netmap-ipfwjit/Makefile.kipfw

Modified: soc2014/dpl/netmap-ipfwjit/Makefile
==============================================================================
--- soc2014/dpl/netmap-ipfwjit/Makefile	Fri Jul 18 12:51:35 2014	(r271078)
+++ soc2014/dpl/netmap-ipfwjit/Makefile	Fri Jul 18 13:54:29 2014	(r271079)
@@ -26,7 +26,7 @@
 clean:
 	- at rm -rf $(OBJDIR) kipfw
 	@(cd ipfw && $(MAKE) clean )
-	@rm ./ip_fw_rules.bc
+	@rm -f ./ip_fw_rules.bc
 
 tgz:
 	@$(MAKE) clean

Modified: soc2014/dpl/netmap-ipfwjit/Makefile.kipfw
==============================================================================
--- soc2014/dpl/netmap-ipfwjit/Makefile.kipfw	Fri Jul 18 12:51:35 2014	(r271078)
+++ soc2014/dpl/netmap-ipfwjit/Makefile.kipfw	Fri Jul 18 13:54:29 2014	(r271079)
@@ -136,8 +136,7 @@
 EFILES = $(foreach i,$(EDIRS),$(subst $(empty) , $(i)/, $(EFILES_$(i):  = )))
 
 BCFLAGS=-emit-llvm -c
-CXX=clang++
-CXXFLAGS= $(CFLAGS) `llvm-config-devel --cxxflags --libs jit support`
+CXXFLAGS= `llvm-config-devel --cxxflags --libs jit support`
 
 include_e:
 	- at echo "Building $(OBJPATH)/include_e ..."
@@ -149,13 +148,14 @@
 $(IPFW_OBJS) : ../extra/glue.h
 
 ip_fw2.o ip_dummynet.o: # EFLAGS= -include missing.h
+ip_fw2.o: jit.o
 
 radix.o:#	CFLAGS += -U_KERNEL
 
 # session.o:	CFLAGS = -O2
 nm_util.o:	CFLAGS = -O2 -Wall -Werror $(NETMAP_FLAGS)
 
-$(MOD): $(IPFW_OBJS) ../ip_fw_rules.bc
+$(MOD): $(IPFW_OBJS) ../ip_fw_rules.bc jit.o
 	$(MSG) "   LD $@"
 	$(HIDE)$(CC) -o $@ $^ $(LIBS)
 
@@ -163,9 +163,8 @@
 ../ip_fw_rules.bc:
 	@$(CC) $(CFLAGS) $(BCFLAGS) -o ../ip_fw_rules.bc ../sys/netpfil/ipfw/ip_fw_rules.h
 
-ip_fw2.o: ip_fw2.cc
-	@echo "Building ip_fw2.cc"
-	clang++ $(CXXFLAGS) ../sys/netpfil/ipfw/ip_fw2.cc -o ./ip_fw2.o
+jit.o: jit.cc
+	@clang++ $(CXXFLAGS) ../sys/netpfil/ipfw/jit.cc -o ./jit.o
 
 clean:
 	-rm -f *.o $(DN) $(MOD)

Copied and modified: soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/ip_fw2.c (from r271013, soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/ip_fw2.cc)
==============================================================================
--- soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/ip_fw2.cc	Thu Jul 17 09:48:34 2014	(r271013, copy source)
+++ soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/ip_fw2.c	Fri Jul 18 13:54:29 2014	(r271079)
@@ -39,6 +39,7 @@
 #include "opt_inet6.h"
 #include "opt_ipsec.h"
 #include "ip_fw_rules.h"
+#include "jit.h"
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -230,6 +231,9 @@
 static inline void rule_nat(struct ip_fw_args *, int, struct ip_fw_chain *, ipfw_insn *, struct mbuf *, uint32_t, int *, int *, int *);
 static inline void rule_reass(struct ip_fw *, int, struct ip_fw_chain *, int, struct ip *, struct ip_fw_args *, struct mbuf *, int *, int *, int *);
 
+/* JIT compiling API */
+static void ipfw_jit_init();
+
 /*
  * Each rule belongs to one of 32 different sets (0..31).
  * The variable set_disable contains one bit per set.
@@ -1319,20 +1323,7 @@
 	  default_fw_tables = IPFW_TABLES_MAX;
 
 	ipfw_log_bpf(1); /* init */
-
-#include <llvm/IR/LLVMContext.h>
-#include <llvm/IR/Module.h>
-#include <llvm/Support/MemoryBuffer.h>
-
-using namespace llvm;
-
-	/* JIT */
-	Module *Mod;
-	LLVMContext &C;
-	/* We load the bc for JIT compilation */
-	char *buffer;
-	MemoryBuffer::getFile("ip_fw_rules.bc", buffer);
-	Module *Mod = ParseBitcodeFile(buffer.get(), C);
+	ipfw_jit_init();
 
 	return (error);
 }

Added: soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/jit.cc
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/jit.cc	Fri Jul 18 13:54:29 2014	(r271079)
@@ -0,0 +1,24 @@
+/* JIT compilation code */
+#include <llvm/ADT/OwningPtr.h>
+#include <llvm/Bitcode/ReaderWriter.h>
+#include <llvm/IR/LLVMContext.h>
+#include <llvm/IR/Module.h>
+#include <llvm/Support/MemoryBuffer.h>
+#include <llvm/Support/ErrorOr.h>
+
+using namespace llvm;
+
+ErrorOr<Module *> ptr;
+Module *mod;
+LLVMContext con;
+LLVMContext &c = con;
+OwningPtr<MemoryBuffer> buffer;
+
+static void
+ipfw_jit_init()
+{
+	ptr = mod;
+	/* We load the bc for JIT compilation */
+	MemoryBuffer::getFile("ip_fw_rules.bc", buffer);
+	ptr = parseBitcodeFile(buffer.get(), c);
+}

Added: soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/jit.h
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/jit.h	Fri Jul 18 13:54:29 2014	(r271079)
@@ -0,0 +1,2 @@
+
+static void ipfw_jit_init();


More information about the svn-soc-all mailing list