free hit counter

Tuesday, February 26, 2008

Type punning

After seeing the warning:
"dereferencing type-punned pointer will break strict-aliasing rules"
I got curious: What the hell is type punning?

Type Punning (from wikipedia)
In computer science, type punning is a common term for any programming technique that subverts or circumvents the type system of a programming language in order to achieve an effect that would be difficult or impossible to achieve within the bounds of the formal language.

Turns out I've been doing these kinds of hacks for ages, but didn't know there was a formal name for them! With default flags GCC does some optimizations that rely on strict aliasing of variables that type punning may break.


Friday, February 22, 2008

decent code style guide

This is about the closest code formating document that matches with my sensibilities. I agree with 90% of it, and the 10% I don't agree with is the totally arbitrary stuff.

Framewave Development Guide


Thursday, February 21, 2008

Famos F-16 inversion bug

"Apparently a problem in the navigation software inverted the [f-16] aircraft whenever it crosssed the equator. Luckily it was caught early in simulation testing and promptly fixed. In the July issue, J.N. Frisina at Singer-Kearfott wrote to Mr. Neumann, 'concerned that readers might have mistakenly believed there was a bug in the flight software, which was of course not the case.'

Mr. Frisina wrote: 'In the current search for reliable software, the F16 Navigation software is an example of the high degree of reliability and quality that can be obtained with the application of proper design verification and testing methodologies. All primary misison functions were software correct.'"

old school linkage


Thursday, February 14, 2008

Interesting Company: Fulcrum Microsystems

Fabless Semi building chips to connect data center nodes with 40GB/s ethernet.

Fulcrum Microsystems - The Leader in Performance Interconnects

Closely related is Luxtera, who makes the active optical interconnect cables. Or as they say: Fiber to the chip


comp sci 101 practices realy do work

They teach all kinds of maxims in your first programming class: no magic numbers, no gotos, no globals, etc.

It's still amazing how many people still violate these maxims though. Today I saw further evidence supporting my favorite of these maxims: no magic numbers.

consider the call to a wait function when reading an accelerometer:

It would have been only slightly less clear, but by no means unintelligible to call:

And clarity could have been fixed if the function were named differently:

But two months after I originally wrote this code, and several slight revisions by another developer later, we found that .08% of accelerometer samples were getting corrupted because we needed to wait a little longer than the 200us the accelerometer datasheet recommends.

This is when the compiler and the no magic numbers maxim helped me avoid a stupid error. You see, I changed the #define to be:
#define wait_225_usecs 225

Unbeknownst to me, at another place in the same file someone else was sampling the accelerometer using the wait_200_usecs constant. Had they both been magic numbers, I might have only fixed the error in once place.


Wednesday, February 13, 2008

use SpaceNavigator in MSOffice

My only complaint about my SpaceNavigator 6 degree of freedom mouse is that more programs don't support it.

The plugin for MS-Office isn't installed by default and is buried on their legacy support page. Works fine as long as you're in 32 bit windows.


Friday, February 08, 2008

Intersting Company: Silicon & Software Systems

Thursday, February 07, 2008

SVN email on commit

So getting SVN to email on commit was way harder than it should have been, but it was mostly this was because I'm running my SVN server under Windows.

I was running around in circles with the usual \r\n differences, but the real problem was finding a compliant command line email utility. mailsend was the first one that worked not just when I was logged in and testing, but more importantly when the Apache service kicked off the job.

My post-commit.bat file in the hooks directory:

@echo off
:: emails out the log message after a commit
perl d:\svn\ %1 %2 testing

My full perl script (which isn't working without the testing flag being set):

# Rian Sanderson
# Feb 7 2008
# First two inputs are standard issue from SVN
# Last argument is optional, and modifies the send to address so you
# don't start spamming your group with half baked emails
# Have users include a tilde (~) in their log messages for a quiet
# mode
# broken: does not work without testing flag
$repos=~ s/\\/\\\\/g;

if ($testingFlag) {
$debugLogName= "$repos/hooks/debug-log-post-commit-hook.txt";

$theTime= localtime time;
print DEBUGLOG "\n\n--$theTime\n";
print DEBUGLOG " $repos $rev\n";

$quietModeFlag=`svnlook log -r $rev $repos | grep '~'`;

if ($quietModeFlag ) {
if ($testingFlag){
print DEBUGLOG " not generating an email per the user's request.\n";
exit 0;

#create the subject
$numFiles=`svnlook changed -r $rev $repos | wc -l`;
$synopsis=`svnlook log -r $rev $repos | head -c 42`;
$synopsis=~ s/\s*$//;
$subject="\"[$rev] $numFiles files: $synopsis...\"";
#$subject="\"[$rev]: $synopsis...\"";
if ("$testingFlag") {
print DEBUGLOG " numFiles: $numFiles\n";
print DEBUGLOG " subject: $subject\n";

# create the body of the message
$bodyFile= "$repos/hooks/$rev.txt";
`echo >> "$bodyFile"`;
system("svnlook log -r $rev $repos > $bodyFile");
`echo >> "$bodyFile"`;
`echo >> "$bodyFile"`;
`echo "files changed:" >> "$bodyFile"`;
system("svnlook changed -r $rev $repos >> $bodyFile");
`echo "." >> "$bodyFile"`;

#ship it off
if ("$testingFlag") {
else {
$fromAddr= '';
#$mailCmd="blat $bodyFile -server -to $toAddr -from $fromAddr -subject $subject ";
$mailCmd="-d -smtp -t $toAddr -from $fromAddr -sub $subject -m $bodyFile,text/plain +cc +bc";
if ("$testingFlag") {
print DEBUGLOG " mailsend $mailCmd";

system("mailsend $mailCmd >> $debugLogName");

#dispose of the body
if (! $testingFlag) {


Wednesday, February 06, 2008

Fix group pictures

Whenever taking a picture of a group of people it always seems that someone blinks, or something pops into the backgroud.

Photoshop Elements 6 has a feature to merge select portions of several pictures to get that 'right shot'

Microsoft Research has a dedicated application they give away for free:
Microsoft Research Group Shot

Here's a less polished bit of research to do similar things:

Monday, February 04, 2008

wiiuse - The Wiimote C Library

I would love to be able to play around with this:

wiiuse - The Wiimote C Library

and use the Wiimote in Windows. (boy does that sound like Elmer Fudd or what?


MapReduce != RDBMS

The guys who wrote this critique on mapReduce just don't seem to understand that it's a distributed computing framework, not a relational database framework.
MapReduce: A major step backwards - The Database Column

The best rebuttle I've seen: