From 8cef3c3f453df05b7e32f670afb786926583512e Mon Sep 17 00:00:00 2001
From: Chris Roberts <cpr420@gmail.com>
Date: Sun, 26 Jan 2014 11:57:02 -0700
Subject: applying patch libmicro-0.4.1.patch


diff --git a/Makefile.Haiku b/Makefile.Haiku
new file mode 100644
index 0000000..5181d91
--- /dev/null
+++ b/Makefile.Haiku
@@ -0,0 +1,43 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms
+# of the Common Development and Distribution License
+# (the "License").  You may not use this file except
+# in compliance with the License.
+#
+# You can obtain a copy of the license at
+# src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing
+# permissions and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL
+# HEADER in each file and include the License file at
+# usr/src/OPENSOLARIS.LICENSE.  If applicable,
+# add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your
+# own identifying information: Portions Copyright [yyyy]
+# [name of copyright owner]
+#
+# CDDL HEADER END
+#
+
+#
+# Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
+# Use is subject to license terms.
+#
+
+
+CC=		gcc
+
+#CFLAGS=		-O -DUSE_SEMOP
+CPPFLAGS=		-DUSE_SEMOP -D_REENTRANT
+MATHLIB=
+
+ELIDED_BENCHMARKS=	\
+	cachetocache	\
+	atomic
+
+
+include ../Makefile.com
diff --git a/Makefile.benchmarks b/Makefile.benchmarks
index ed1923a..d1b1ff8 100644
--- a/Makefile.benchmarks
+++ b/Makefile.benchmarks
@@ -50,7 +50,7 @@ ALL=				\
 		fcntl_ndelay	\
 		file_lock	\
 		fork		\
-		getcontext	\
+#		getcontext	\
 		getenv		\
 		gettimeofday	\
 		getpeername	\
diff --git a/Makefile.com b/Makefile.com
index 2ba7e76..5773900 100644
--- a/Makefile.com
+++ b/Makefile.com
@@ -54,10 +54,10 @@ lint:	libmicro.ln $(ALL:%=%.lint) $(EXTRA_CFILES:%.c=%.lint)
 
 
 $(EXTRA_CFILES:%.c=%.lint):
-	$(LINT) ../$(@:%.lint=%.c) -I. -mu -lc libmicro.ln -lm
+	$(LINT) ../$(@:%.lint=%.c) -I. -mu -lc libmicro.ln 
 
 %.lint:	../%.c libmicro.ln
-	$(LINT) -mu $(CPPFLAGS) $< libmicro.ln -lpthread -lsocket -lnsl -lm
+	$(LINT) -mu $(CPPFLAGS) $< libmicro.ln  -lnetwork
 
 %.o:	../%.c
 	$(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
@@ -107,13 +107,13 @@ tattle:		../tattle.c	libmicro.a
 	echo "char compiler_version[] = \""`$(COMPILER_VERSION_CMD)`"\";" > tattle.h
 	echo "char CC[] = \""$(CC)"\";" >> tattle.h
 	echo "char extra_compiler_flags[] = \""$(extra_CFLAGS)"\";" >> tattle.h
-	$(CC) -o tattle $(CFLAGS) -I. ../tattle.c libmicro.a -lrt -lm
+	$(CC) -o tattle $(CFLAGS) -I. ../tattle.c libmicro.a
 
 $(ELIDED_BENCHMARKS):	../elided.c
 	$(CC) -o $(@) ../elided.c
 
 %: libmicro.a %.o 
-	$(CC) -o $(@) $(@).o $($(@)_EXTRA_DEPS) $(CFLAGS) libmicro.a $($(@)_EXTRA_LIBS) $(EXTRA_LIBS) -lpthread -lm
+	$(CC) -o $(@) $(@).o $($(@)_EXTRA_DEPS) $(CFLAGS) libmicro.a $($(@)_EXTRA_LIBS) $(EXTRA_LIBS) -lnetwork
 
 exec:	exec_bin
 
diff --git a/bench.sh b/bench.sh
index 4795c10..24ca1d9 100644
--- a/bench.sh
+++ b/bench.sh
@@ -56,7 +56,7 @@ VDIR1=$VARROOT/0/1/2/3/4/5/6/7/8/9
 VDIR2=$VARROOT/1/2/3/4/5/6/7/8/9/0
 
 
-OPTS="-E -C 200 -L -S -W"
+OPTS="-l -E -C 200 -L -S -W"
 
 dd if=/dev/zero of=$TFILE bs=1024k count=10 2>/dev/null
 dd if=/dev/zero of=$VFILE bs=1024k count=10 2>/dev/null
@@ -65,7 +65,7 @@ mkdir -p $VDIR1 $VDIR2
 
 touch $IFILE
 
-ARCH=`arch -k`
+ARCH=`uname -m`
 
 # produce benchmark header for easier comparisons
 
diff --git a/cascade_flock.c b/cascade_flock.c
index 27d95d1..a6634a1 100644
--- a/cascade_flock.c
+++ b/cascade_flock.c
@@ -50,7 +50,7 @@
 #include "libmicro.h"
 
 #ifndef LOCK_EX
-#include "/usr/ucbinclude/sys/file.h"
+#include "sys/file.h"
 extern int flock(int fd, int operation);
 #endif
 
-- 
1.8.3.4


From 459c52bd6b2394e867ec1657a2b6d83eed4f048d Mon Sep 17 00:00:00 2001
From: Adrien Destugues <pulkomandy@pulkomandy.tk>
Date: Thu, 5 Jun 2014 12:50:10 +0200
Subject: Undo broken changes from libmicro 1.4.1 patchset.

* Comments inside a multiline in makefiles comment the whole thing. So
all benchmarks after getcontext were not compiled.
* Instead, use the ELIDED system that allows easy exclusion of
benchmarks in a platform specific way.
* Remove -l option from OPTS in the bench script, because the tests
don't know about it.

This gets the testsuite running, but the 3rd test deadlocks.

diff --git a/Makefile.Haiku b/Makefile.Haiku
index 5181d91..f034ce5 100644
--- a/Makefile.Haiku
+++ b/Makefile.Haiku
@@ -36,8 +36,11 @@ CPPFLAGS=		-DUSE_SEMOP -D_REENTRANT
 MATHLIB=
 
 ELIDED_BENCHMARKS=	\
+	atomic			\
 	cachetocache	\
-	atomic
+	getcontext		\
+	mmap			\
+	setcontext
 
 
 include ../Makefile.com
diff --git a/Makefile.benchmarks b/Makefile.benchmarks
index d1b1ff8..ed1923a 100644
--- a/Makefile.benchmarks
+++ b/Makefile.benchmarks
@@ -50,7 +50,7 @@ ALL=				\
 		fcntl_ndelay	\
 		file_lock	\
 		fork		\
-#		getcontext	\
+		getcontext	\
 		getenv		\
 		gettimeofday	\
 		getpeername	\
diff --git a/bench.sh b/bench.sh
index 24ca1d9..709cfe3 100644
--- a/bench.sh
+++ b/bench.sh
@@ -56,7 +56,7 @@ VDIR1=$VARROOT/0/1/2/3/4/5/6/7/8/9
 VDIR2=$VARROOT/1/2/3/4/5/6/7/8/9/0
 
 
-OPTS="-l -E -C 200 -L -S -W"
+OPTS="-E -C 200 -L -S -W"
 
 dd if=/dev/zero of=$TFILE bs=1024k count=10 2>/dev/null
 dd if=/dev/zero of=$VFILE bs=1024k count=10 2>/dev/null
-- 
1.8.3.4

