talideon.com

Pick a card, any card...

April 28, 2008 at 3:30PM Patch to get the copy of IO tagged 2008.03.30 to build on FreeBSD

I’m sick as a plague hospital right now and got next to nothing done over the weekend. Let’s just say that what’s wrong with me is embarrassingly gross and seems to have to do with every part of my digestive tract south of my stomach.

I did manage to get io (download tag, though the patch also works on the master branch at the time of posting) running on my FreeBSD laptop though.

What I had to patch was somewhere where the log2() function which, annoyingly, isn’t in libm. Seeing as the code that needed it was just counting bytes, it seemed logical to substitute a function that did just that.

The patch also removes some annoying build warnings.

--- libs/iovm/source/IoNumber.c.orig	2008-04-26 15:56:13.000000000 +0100
+++ libs/iovm/source/IoNumber.c	2008-04-26 16:25:42.000000000 +0100
@@ -423,6 +423,20 @@
 	return string;
 }

+static int countBytes(long ld)
+{
+	int n = 1;
+	for (;;)
+	{
+		ld >>= 8;
+		if (ld == 0)
+		{
+			return n;
+		}
+		n++;
+	}
+}
+
 IoObject *IoNumber_asCharacter(IoNumber *self, IoObject *locals, IoMessage *m)
 {
 	/*doc Number asCharacter
@@ -441,7 +455,7 @@
 	else
 	{
 		uint32_t i = io_uint32InBigEndian((uint32_t)d);
-		int bytes = d > 0 ? log2(d) / 8 : 1;
+		int bytes = countBytes(ld);
 		IoSeq *s;

 		if (bytes == 0)
--- libs/iovm/source/IoState_exceptions.h.orig	2008-04-26 18:35:41.000000000 +0100
+++ libs/iovm/source/IoState_exceptions.h	2008-04-26 18:35:50.000000000 +0100
@@ -8,4 +8,4 @@

 IOVM_API void IoState_error_(IoState *self, IoMessage *m, const char *format, ...);

-IOVM_API IoObject *IoState_setErrorDescription_(IoState *self, const char *format, ...);
\ No newline at end of file
+IOVM_API IoObject *IoState_setErrorDescription_(IoState *self, const char *format, ...);
--- build/Project.io.orig	2008-04-26 20:00:28.000000000 +0100
+++ build/Project.io	2008-04-26 20:00:53.000000000 +0100
@@ -74,7 +74,7 @@
 		if (platform == "windows",
 			"-MD -Zi -DWIN32 -DNDEBUG -DIOBINDINGS -D_CRT_SECURE_NO_DEPRECATE"
 		,
-			"-Os -g -Wall -DSANE_POPEN -DIOBINDINGS"
+			"-Os -g -Wall -pipe -fno-strict-aliasing -DSANE_POPEN -DIOBINDINGS"
 		)
 	)

I hereby place this patch in the public domain.

[download patch]

Update (May 1st): patch committed! Yay!

Technorati Search Technorati Search Irish Bloggers

Comments

No comments.

Post a comment

All form information is optional, but it’s a good idea to fill in your name and email address if you want me to take your comment seriously.

Spammers, don’t bother posting crap down here. The site is set up so that legitimate search engines (Google, for instance) won’t index pages with comments on them. Posting crud here only means you’re wasting my time and patience. Shoo!

Real names, please. Please include!
Won’t be displayed. Please include!
Displayed, if present.