<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss'><id>tag:blogger.com,1999:blog-17885055</id><updated>2009-12-10T10:37:29.026+01:00</updated><title type='text'>The Julipedia: Blog</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://blog.julipedia.org/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default?start-index=26&amp;max-results=25'/><author><name>Julio Merino</name><uri>http://www.blogger.com/profile/08233346614736256024</uri><email>noreply@blogger.com</email></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>489</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-17885055.post-5706562320936440325</id><published>2009-10-25T13:33:00.002+01:00</published><updated>2009-10-25T13:43:08.845+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='atf'/><title type='text'>Processing Makefile.am with M4</title><content type='html'>ATF's Makefile.am, which is a single Makefile for the whole tree, was already at the 1300 lines mark and growing. At this size, it is unmanageable, and a quick look at its contents reveals tons of repeated delicate code.&lt;br /&gt;&lt;br /&gt;Why so much repeated code, you ask, if the whole point of Automake is to simplify Makefiles? Automake does in fact simplify Makefile code when you define targets known by Automake, such as binaries and/or libraries. However, as soon as you start doing fancy things with documentation, building tons of small programs or messing with shell scripts, things get out of control because you are left on your own to define their targets and their necessary build logic.&lt;br /&gt;&lt;br /&gt;Up until now, I had just kept up with the boilerplate code... but now that I'm starting to add pretty complex rules to generate HTML and plain text documentation out of XML files, the complexity must go. And here comes my solution:&lt;br /&gt;&lt;br /&gt;I've just committed an experiment to &lt;a href="http://mtn-host.prjek.net/viewmtn/atf/revision/info/aca66742e00b236d0b6dcb22ae70468736b612bc"&gt;process Makefile.am with M4&lt;/a&gt;. I've been trying to look for prior art behind this idea and couldn't find any, so I'm not sure how well this will work. But, so far, this has cut down 350 lines of Makefile.am code.&lt;br /&gt;&lt;br /&gt;How does this work? First of all, I've written a script to generate the Makefile.am from the Makefile.am.m4 and put it in admin/generate-makefile.sh. All this script does is call M4, but I want to keep this logic in a single place because it has to be used from two call sites as described below.&lt;br /&gt;&lt;br /&gt;Then, I've added an autogen.sh script to the top-level directory that generates Makefile.am (using the previous script) and calls autoreconf -is. I'm against autogen.sh scripts that pretend to be smart instead of just calling autoreconf, but in this case I see no other way around it.&lt;br /&gt;&lt;br /&gt;At last, I've modified Makefile.am to add an extra rule to generate itself based on the M4 version. This, of course, also uses generate-makefile.sh.&lt;br /&gt;&lt;br /&gt;We'll see how this scales, but I'm so far happy with the results.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-5706562320936440325?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/5706562320936440325/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=17885055&amp;postID=5706562320936440325' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/5706562320936440325'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/5706562320936440325'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2009/10/processing-makefileam-with-m4.html' title='Processing Makefile.am with M4'/><author><name>Julio Merino</name><uri>http://www.blogger.com/profile/08233346614736256024</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='11711662837553049744'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-190748834219167977</id><published>2009-09-23T11:10:00.002+02:00</published><updated>2009-09-23T11:14:09.347+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='pkgsrc'/><title type='text'>Extending sudo credentials</title><content type='html'>If you use sudo for, e.g. pkgsrc's just-in-time su, you may have often bitten by the problem that some compilations are slow and the build process stops right in the middle to ask you for a root password.  If you go away while the system compiles, you'll be frustrated when you come back, as the process may still well be at the very beginning.&lt;br /&gt;&lt;br /&gt;This happens because, unless disabled by the system administrator, your sudo credentials last for 5 minutes. If you hadn't used sudo for those 5 minutes, it will ask you for your password again. A simple workaround for the problem is to automatically renew your credentials, say, every 2 minutes. You can do this by running the following command (from the same console you are using later on!) right before starting a pkgsrc build:&lt;pre&gt;$ ( while :; do sudo -v; sleep 120; done ) &amp;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-190748834219167977?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/190748834219167977/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=17885055&amp;postID=190748834219167977' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/190748834219167977'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/190748834219167977'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2009/09/extending-sudo-credentials.html' title='Extending sudo credentials'/><author><name>Julio Merino</name><uri>http://www.blogger.com/profile/08233346614736256024</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='11711662837553049744'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-1338186479268297089</id><published>2009-08-31T13:36:00.004+02:00</published><updated>2009-08-31T13:39:33.178+02:00</updated><title type='text'>Best config setting ever</title><content type='html'>&lt;pre&gt;echo 'set editing-mode vi' &gt;&gt;~/.inputrc&lt;/pre&gt;This will enable vi-editing mode for all commands that use the GNU readline library (e.g. bash, python, bc, etc.), not only the shell.  For the shell only (including non-bash shells), add 'set -o vi' to your shrc file.&lt;br /&gt;&lt;br /&gt;I don't know why I didn't do this before given that I'm a pretty hard vi user.  Still, for some reason, I kept using emacs-like key bindings for command-line editing.  Not any more!  However, be careful: if you are used to vim's visual editing mode, you'll keep hitting 'v' in the command line and getting super annoyed.&lt;br /&gt;&lt;br /&gt;Enjoy!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-1338186479268297089?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/1338186479268297089/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=17885055&amp;postID=1338186479268297089' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/1338186479268297089'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/1338186479268297089'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2009/08/best-config-setting-ever.html' title='Best config setting ever'/><author><name>Julio Merino</name><uri>http://www.blogger.com/profile/08233346614736256024</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='11711662837553049744'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-681908603179050098</id><published>2009-08-03T21:59:00.002+02:00</published><updated>2009-08-03T22:02:32.120+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='atf'/><title type='text'>1000 revisions for ATF</title><content type='html'>Mmm!  Revision &lt;a href="http://mtn-host.prjek.net/viewmtn/atf/revision/info/7ca234b9aceabcfe9a8a1340baa07d6fdc9e3d33"&gt;7ca234b9aceabcfe9a8a1340baa07d6fdc9e3d33&lt;/a&gt;, committed about an hour ago, marks the 1000th revision in the ATF repository.  Thanks for staying with me if you are following the project :)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-681908603179050098?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/681908603179050098/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=17885055&amp;postID=681908603179050098' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/681908603179050098'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/681908603179050098'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2009/08/1000-revisions-for-atf.html' title='1000 revisions for ATF'/><author><name>Julio Merino</name><uri>http://www.blogger.com/profile/08233346614736256024</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='11711662837553049744'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-9020484380911179497</id><published>2009-08-03T19:42:00.002+02:00</published><updated>2009-08-03T19:46:08.414+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='books'/><title type='text'>Books by Joel Spolsky</title><content type='html'>I just finished reading the third book in a row from Joel Spolsky, titled Joel on Software. Before this one, I read More Joel on Software and The Best Software Writing 1, all in a bit over a month. Note: I hadn't read any book cover-to-cover for a loooong while. Very interesting and entertaining books; highly recommended.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Oh, and his writing style is really enjoyable. We, crappy blog writers, can learn a lot from him!&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-9020484380911179497?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/9020484380911179497/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=17885055&amp;postID=9020484380911179497' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/9020484380911179497'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/9020484380911179497'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2009/08/books-by-joel-spolsky.html' title='Books by Joel Spolsky'/><author><name>Julio Merino</name><uri>http://www.blogger.com/profile/08233346614736256024</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='11711662837553049744'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-4743147252783979430</id><published>2009-07-27T23:19:00.004+02:00</published><updated>2009-07-29T13:53:59.446+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='atf'/><title type='text'>Rearchitecting ATF</title><content type='html'>During the last few weeks, I've been doing some ATF coding and, well... I'm not happy. At all. I keep implementing features but I feel, more and more, that ATF is growing out of control and that it is way too sluggish. It oughtn't be so slow. About 6 minutes to run the whole test suite in a Mac G3 I just got? HA! I bet I can do much, much, much better than that. Come on, we are targeting NetBSD, so we should support all those niche platforms rather well, and speed matters.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The thing is, the current code base grew out of a prototype that didn't have that much of a design. Well, it had a design but, in my opinion, it has turned to be a bad design. I couldn't imagine that we could hit the bottlenecks (speed) and user-interface issues (for example, the huge difficulties that involve debugging a failing test case) that we are hitting.  So...&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;IT IS TIME FOR A CHANGE!!!&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I'm currently working on a written specification of what ATF will look like, hopefully, in the not-so-distant future. It will take a while to get there, but with enough effort, we soon will. And life will be better. And no, I'm not talking about a from-scratch rewrite; that'd only hurt the project. I plan to take incremental and safe steps, keeping the code base running all the time, but I will do a major face-lift of everything. (I wish I could say "we" instead of "I" here.  But not there yet.)&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Why am I writing a specification, you ask? Well, because that forces me (or ANY developer) to think how I want the thing to look like and to decide, exactly, on what the design will be, which technologies will be used, which languages will be involved and in what components, etc. And no, I'm not talking of a class model design; I'm just talking about the main design of the whole picture, which is quite hard by itself. Plus having a spec will allow me to show it to you before I start coding and you will say "oh, wonderful, this new design sucks so much that I'm not going to bother with the new version". Or maybe hell will freeze and you will think, "mmm, this looks interesting, maybe it will solve these issues I'm having as regards speed, ease of debugging and ease of use".&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Anyway, I hope to have a draft "soon" and to hear any of the two possible comments as a result!&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;Edit (July 29th)&lt;/b&gt;: Alright, I have uploaded an &lt;a href="http://www.netbsd.org/~jmmv/rearchitecting-atf/spec.html"&gt;extremely preliminary copy of the specification&lt;/a&gt; just so that you can see where my current ideas are headed. Expect many more changes to this document, so don't pay too much attention to the tiny details (most of which aren't there anyway yet).&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-4743147252783979430?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/4743147252783979430/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=17885055&amp;postID=4743147252783979430' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/4743147252783979430'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/4743147252783979430'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2009/07/rearchitecting-atf.html' title='Rearchitecting ATF'/><author><name>Julio Merino</name><uri>http://www.blogger.com/profile/08233346614736256024</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='11711662837553049744'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-8981481737885658422</id><published>2009-07-14T02:37:00.003+02:00</published><updated>2009-07-14T03:03:22.432+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='atf'/><title type='text'>The mess of ATF's code</title><content type='html'>Yes. ATF's code is a "bit" messy, to put it bluntly. I'm quite happy with some of the newest bits but there are some huge parts in it that stink. The main reason for this is that the "ugly" parts were the ones that were written first, and they were basically a prototype; we didn't know all the requirements for the code at that point... and we still don't know them, but we know we can do much better. Even though I'm writing in plural... I'm afraid we = I at the moment :-P&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;So, is it time for the big-rewrite-from-scratch? NO! Joel Spolsky wrote about why &lt;a href="http://www.joelonsoftware.com/articles/fog0000000348.html"&gt;this is a bad idea&lt;/a&gt; and I have to agree with him. Yeah, I'm basically the only developer of the code so everything is in my head, and I'd do a rewrite with a fresh mind, but... I'd lose tons of work and, specially, I'd lose tons of code that deals with tricky corner-cases that are hard to remember.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Sure, I want to clean things up but they'll happen incrementally. And preferably concurrently with feature additions. These two things could definitely happen at the same time if only I had infinite spare time...&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Anyway, the major point of this post is to describe what I don't like about the current code base and how I'd like to see it changing:&lt;/div&gt;&lt;div&gt;&lt;ul&gt;&lt;li&gt;A completely revamped C++ API for test cases. The current one sucks. It is not consistent with the C API. It lacks important functionality. It uses exceptions for test-case status reporting (yuck!). And it's ugly.&lt;/li&gt;&lt;li&gt;Clear separation of "internal/helper" APIs from the test APIs. You'll agree that the "fs" module, which provides path abstraction and other file system management routines, is something that cannot be part of ATF's API. ATF is about testing. Period. Either that fs module should be in a separate library or should be completely hidden from the public. Otherwise, it'll suffer from abuse and, what scares me, will have to become part of ATF's API. And likewise, most &amp;mdash; really &amp;mdash; most of the modules in the current code are internal.&lt;/li&gt;&lt;li&gt;Less dependencies from the C++ API to the C API. Most of the current C++ modules are wrappers of their corresponding C counterparts. This is nice for code reuse but makes the code extremely fragile. In C++, things like RAII can provide really robust code with minimum effort, but intermixing such C++ code with C makes things ugly really quickly. I'd like to find a way to keep the two libraries separate from each other (and thus keep the C++ binding "pure"), but at the same time I don't want to duplicate code... an interesting problem.&lt;/li&gt;&lt;li&gt;Split the tarball into smaller pieces. People writing test cases for C applications don't want to pull in a huge package that depends on C++ and whatnot. And ATF is huge. It takes forever to compile. And this is a serious issue for broad adoption. Note: whether the tools are written in C++ or not is a separate issue, because these are not a dependency for anything!&lt;/li&gt;&lt;li&gt;The shell binding is slow. Really slow compared to the other ones. Optimizations would be nice, but those do not address the root of the problem: it's costly to query information from shell-based tests at run time. I.e. it takes a long time to get the full list of test cases available in a test suite because you have to run every single test program with the -l flag. Keeping a separate file with test-case metadata alongside the binary could resolve this and allow more flexibility at run time.&lt;/li&gt;&lt;li&gt;And some other things.&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;Those are the major things I'd like to see addressed soon, but they involve tons of work. Of course, I'd like to be able to work on some features expected by other developers: easier debugging, DOCUMENTATION!...&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;So, helpers welcome :-)&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-8981481737885658422?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/8981481737885658422/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=17885055&amp;postID=8981481737885658422' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/8981481737885658422'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/8981481737885658422'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2009/07/mess-of-atfs-code.html' title='The mess of ATF&apos;s code'/><author><name>Julio Merino</name><uri>http://www.blogger.com/profile/08233346614736256024</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='11711662837553049744'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-2459937406467822931</id><published>2009-06-23T14:19:00.002+02:00</published><updated>2009-06-23T14:29:39.190+02:00</updated><title type='text'>Technicians and schedules</title><content type='html'>Here I am, on the afternoon of a work day, sitting at home waiting for an eircom technician to come set it up my phone line. How nice. The story goes like this:&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Two weeks ago, I placed an online order to request a phone line, explicitly specifying that the physical installation is already done (even though I don't know if it works or not, but that should be fairly easy for them to check). A few days later, the technician called me saying that he'd come today (two weeks after), anytime from 12.00 to 15.00, but that I'd call the company the same day to get a more accurate schedule.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Fine, I'll wait until the 23rd to do that call. But you know what happened, right? I called them this morning and they said that, effectively, the technician was coming today, from 12.30 &lt;i&gt;onwards&lt;/i&gt; but they were unable to provide me any more specific information because the technicians have &lt;i&gt;multiple appointments&lt;/i&gt;. What? Again, WHAT? At this age of technology, can't we implement a system to track technicians and their schedules? Can't we make some approximations of how long each visit will take? I bet it's trivial if you put in just some common sense.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;People have jobs, and they can't leave anytime for unknown periods of time; granted, I have some more freedom at Google, but that is absolutely not the case for most other companies. If you have to be at home at 12.30 sharp, and the appointment will last 30 minutes approximately, that is one thing, but having to be at home from 12.30 for an unexpected period of time, that is a very different thing.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Just wondering... couldn't they just make the technician call you about 20-30 minutes before arrival so that you could make the same arrangements as him and be there at the same time? It doesn't seem such an insane request.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-2459937406467822931?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/2459937406467822931/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=17885055&amp;postID=2459937406467822931' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/2459937406467822931'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/2459937406467822931'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2009/06/technicians-and-schedules.html' title='Technicians and schedules'/><author><name>Julio Merino</name><uri>http://www.blogger.com/profile/08233346614736256024</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='11711662837553049744'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-1880013018173418859</id><published>2009-06-21T19:40:00.006+02:00</published><updated>2009-06-22T23:21:37.974+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='atf'/><category scheme='http://www.blogger.com/atom/ns#' term='c'/><title type='text'>Child-process management in C for ATF</title><content type='html'>Let's face it: spawning child processes in Unix is a "mess". Yes, the interfaces involved (fork, wait, pipe) are really elegant and easy to understand, but every single time you need to spawn a new child process to, later on, execute a random command, you have to write quite a bunch of error-prone code to cope with it. If you have ever used any other programming language with higher-level abstraction layers — just check Python's subprocess.Popen — you surely understand what I mean.&lt;div&gt;&lt;br /&gt;&lt;div&gt;&lt;div&gt;The current code in ATF has many places were child processes have to be spawned. I recently had to add yet another case of this, and... enough was enough. Since then, I've been working on a C API to spawn child processes from within ATF's internals and just pushed it to the repository. It's still fairly incomplete, but with minor tweaks, it'll keep all the dirty details of process management contained in a single, one-day-to-be-portable module.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The interface tries to mimic the one that was designed on my Boost.Process Summer of Code project, but in C, which is quite painful. The main idea is to have a fork function to which you pass the subroutine you want to run on the child, the behavior you want for the stdout stream and the behavior you want for the stderr steam. These behaviors can be any of capture (aka create pipes for IPC communcations), silence (aka redirect to /dev/null), redirect to file descriptor and redirect to file. For simplicity, I've omitted stdin. With all this information, the fork function returns you an opaque structure representing the child, from which you can obtain the IPC channels if you requested them and on which you can wait for finalization.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Here is a little example, with tons of details such as error handling or resource finalization removed for simplicity. The code below would spawn "/bin/ls" and store its output in two files named ls.out and ls.err:&lt;/div&gt;&lt;pre&gt;static&lt;br /&gt;atf_error_t&lt;br /&gt;run_ls(const void *v)&lt;br /&gt;{&lt;br /&gt; system("/bin/ls");&lt;br /&gt; return atf_no_error();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;static&lt;br /&gt;void&lt;br /&gt;some_function(...)&lt;br /&gt;{&lt;br /&gt; atf_process_stream_t outsb, errsb;&lt;br /&gt; atf_process_child_t child;&lt;br /&gt; atf_process_status_t status;&lt;br /&gt;&lt;br /&gt; atf_process_status_init_redirect_path(&amp;amp;outsb, "ls.out");&lt;br /&gt; atf_process_status_init_redirect_path(&amp;amp;errsb, "ls.err");&lt;br /&gt;&lt;br /&gt; atf_process_fork(&amp;amp;child, run_ls, &amp;amp;outsb, &amp;amp;errsb, NULL);&lt;br /&gt; ... yeah, here comes the concurrency! ...&lt;br /&gt; atf_process_child_wait(&amp;amp;child, &amp;amp;status);&lt;br /&gt;&lt;br /&gt; if (atf_process_status_exited(&amp;amp;status))&lt;br /&gt;     printf("Exit: %d\n", atf_process_status_exitstatus(&amp;amp;status));&lt;br /&gt; else&lt;br /&gt;     printf("Error!");&lt;br /&gt;}&lt;/pre&gt;&lt;div&gt;Yeah, quite verbose, huh? Well, it's the price to pay to simulate namespaces and similar other things in C. I'm not too happy with the interface yet, though, because I've already encountered a few gotchas when trying to convert some of the existing old fork calls to the new module. But, should you want to check the whole mess, &lt;a href="http://mtn-host.prjek.net/viewmtn/atf/revision/info/3ba2af4ab1cad67108c3fb1aea15e8e0168667ff"&gt;check out the corresponding revision&lt;/a&gt;.&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-1880013018173418859?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/1880013018173418859/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=17885055&amp;postID=1880013018173418859' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/1880013018173418859'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/1880013018173418859'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2009/06/child-process-management-in-c-for-atf.html' title='Child-process management in C for ATF'/><author><name>Julio Merino</name><uri>http://www.blogger.com/profile/08233346614736256024</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='11711662837553049744'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-6501743084580398314</id><published>2009-06-13T03:18:00.003+02:00</published><updated>2009-06-13T03:42:49.168+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='housing'/><category scheme='http://www.blogger.com/atom/ns#' term='dublin'/><title type='text'>How to find an apartment in Dublin</title><content type='html'>It has been three weeks since I moved to Dublin, Ireland, and I finally have settled into my new apartment. It has taken me two weeks (I was pretty busy during the first one) to go through ads, visits and offers to finally get a place that is cozy, nicely decorated and decently located, all at a quite reasonable price. I could have gotten nicer places for a bit more money, but I'm happy with this one so far.&lt;br /&gt;&lt;br /&gt;If you are looking forward to finding a place to stay in Dublin, this post contains some suggestions based on my experience:&lt;br /&gt;&lt;br /&gt;First of all, keep in mind that Dublin is outrageously expensive. The prices for housing here are insane at the moment (OK, not as expensive as NYC or SF, but really expensive anyway). Be prepared to spend around 1K EUR for a nice 1 bedroom apartment, and 1.5K EUR for a nice 2 bedroom apartment. Things may improve in the next months, as they just did for the first quarter of the year.&lt;br /&gt;&lt;br /&gt;With that said, your first point of reference should be &lt;a href="http://daft.ie/"&gt;daft&lt;/a&gt;. This is the place where all landlords and agencies put their ads, and the place where everyone is looking for apartments. To get started, you need to know where you want to live. Get a rough idea and then locate that place in one of the &lt;a href="http://en.wikipedia.org/wiki/Dublin_postal_districts"&gt;Dublin postal districts&lt;/a&gt; and the ones surrounding it. Given that public transportation is... well... suboptimal, you don't want to live too far from your workplace. Then, hunt for places within your budget... and a budget a bit higher: you can always &lt;i&gt;try to&lt;/i&gt; negotiate the rent down and get a nicer apartment than you would otherwise, still staying within your initial budget.&lt;br /&gt;&lt;br /&gt;Once you have selected some of the apartments you want to check, call the landlords or agents and ask for an appointment as soon as possible. And, during the visit, check a few basic stuff:&lt;br /&gt;&lt;div&gt;&lt;ul&gt;&lt;li&gt;Whether the house is old or new: if it's new, it'll probably be in nicer condition overall.&lt;/li&gt;&lt;li&gt;Water pressure: old houses have poor water pressure.&lt;/li&gt;&lt;li&gt;Electric shower: this is really scary to me, but it is what most old houses have to deal with poor water pressure.&lt;/li&gt;&lt;li&gt;Carpet: nice, but a horrible mess to clean up.&lt;/li&gt;&lt;li&gt;Garbage collection service: if the building does not do this for you, you'll have to pay for garbage collection separately. I just bought 3 bin tags and those were almost 9 EUR. Yes: 9 EUR to pay for the collection of THREE garbage bags.&lt;/li&gt;&lt;li&gt;Location of supermarkets: Dublin is basically a big town, so most roads don't have shops. Make sure that you have a supermarket nearby where you can walk to to get basic stuff.&lt;/li&gt;&lt;li&gt;Availability of cable/phone: you'll need this for Internet.&lt;/li&gt;&lt;li&gt;Furniture: most apartments in Dublin are provided fully-furnished, so make sure to pick one with furniture that you like. Ask if you are allowed to replace some. Pay special attention to the mattress and couches!!&lt;/li&gt;&lt;li&gt;Cutlery: OK, this is part of the furniture, but check what you have. Your landlord may provide you additional stuff for free upon request.&lt;/li&gt;&lt;li&gt;Washer and &lt;i&gt;dryer&lt;/i&gt;: you want to have a dryer, as most lease contracts state you cannot hung clothes on public places.&lt;/li&gt;&lt;li&gt;Heating and double-windows: you'll need this during the winter.&lt;/li&gt;&lt;/ul&gt;And, at last, don't hurry! The housing market has improved during the last months, so if you see a place that you like, you'll &lt;i&gt;most likely&lt;/i&gt; have a few days to decide whether you want it or not (in the past, you had to decide during viewing time, or otherwise it'd be gone afterwards). Think well about your decision and negotiate; don't show yourself as impatient or you'd get worse deals!&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I think that's all for know. If there is anything else, the post will be updated :)&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-6501743084580398314?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/6501743084580398314/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=17885055&amp;postID=6501743084580398314' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/6501743084580398314'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/6501743084580398314'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2009/06/how-to-find-apartment-in-dublin.html' title='How to find an apartment in Dublin'/><author><name>Julio Merino</name><uri>http://www.blogger.com/profile/08233346614736256024</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='11711662837553049744'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-7459230551314143568</id><published>2009-06-11T00:09:00.003+02:00</published><updated>2009-06-11T00:10:40.460+02:00</updated><title type='text'>Trying AdSense</title><content type='html'>I've just decided to enable AdSense on this blog and see what the results are.  If they are not worth it (what I'm expecting), I'll disable ads after a while.  But who knows, maybe I get a nice surprise!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-7459230551314143568?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/7459230551314143568/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=17885055&amp;postID=7459230551314143568' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/7459230551314143568'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/7459230551314143568'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2009/06/trying-adsense.html' title='Trying AdSense'/><author><name>Julio Merino</name><uri>http://www.blogger.com/profile/08233346614736256024</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='11711662837553049744'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-4620782319169725789</id><published>2009-05-14T20:18:00.002+02:00</published><updated>2009-05-14T20:20:45.144+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='cooking'/><title type='text'>Paella in NYC</title><content type='html'>These days, I'm starting to cook by myself (aka learning) and yesterday I made paella for 6 people while staying in NYC (leaving on Sunday...).  This is the third time in two weeks that I cook this Spanish dish, but I think the results were pretty good despite the lack of ingredients.  After all, cooking is not as hard as I originally thought!  And it's pretty fun too!&lt;br /&gt;&lt;br /&gt;Just blogging this because the results look nice:&lt;br /&gt;&lt;br /&gt;&lt;div style='text-align:center;margin:0px auto 10px;'&gt;&lt;a href='http://2.bp.blogspot.com/_xLbGV919cEE/SgxglPObEeI/AAAAAAAAC5Q/na0_iEsVnAY/s1600-h/IMG_1329.JPG'&gt;&lt;img src='http://2.bp.blogspot.com/_xLbGV919cEE/SgxglPObEeI/AAAAAAAAC5Q/na0_iEsVnAY/s400/IMG_1329.JPG' border='0' alt='' /&gt;&lt;/a&gt;&amp;nbsp;&lt;/div&gt;P.S. I'm now eating the leftovers from yesterday. Yummm! :-)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-4620782319169725789?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/4620782319169725789/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=17885055&amp;postID=4620782319169725789' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/4620782319169725789'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/4620782319169725789'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2009/05/paella-in-nyc.html' title='Paella in NYC'/><author><name>Julio Merino</name><uri>http://www.blogger.com/profile/08233346614736256024</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='11711662837553049744'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_xLbGV919cEE/SgxglPObEeI/AAAAAAAAC5Q/na0_iEsVnAY/s72-c/IMG_1329.JPG' height='72' width='72'/><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-4782427967638867417</id><published>2009-05-13T23:15:00.002+02:00</published><updated>2009-05-13T23:28:48.913+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='software'/><title type='text'>Mailing lists for commit notifications</title><content type='html'>The project I'm currently working on at university uses Subversion as its version control system. Unfortunately, the project itself has no mailing list to receive notifications on every commit, and the managers refuse to set this up. They do not see the value of such a list and they are scared of it because they probably assume that &lt;i&gt;everyone&lt;/i&gt; ought to be subscribed to it.&lt;br /&gt;&lt;br /&gt;Having worked on projects that have a commit notification mailing list available, I strongly advise to have such a list anytime you have more than one developer working on a project[1]. Bonus points if every commit message comes with a bundled copy of the change's diff (in unified form!). This list &lt;i&gt;must be independent from the regular development mailing list&lt;/i&gt; and it &lt;i&gt;must be opt-in&lt;/i&gt;: i.e. never subscribe anyone by default, let themselves subscribe if they want to! Not everyone will need to receive this information, but it comes very useful... and it's extremely valuable for the project managers themselves!&lt;br /&gt;&lt;br /&gt;Why is this useful? Being subscribed to the commit notification mailing list, it is extremely easy to know what is going on on the project[2]. It is also really easy to review the code submissions as soon as they are made which, with proper reviews by other developers, &lt;i&gt;trains the authors&lt;/i&gt; and improves their skills. And if the revision diff is inlined, it is trivial to pinpoint mistakes in it (be them style errors, subtle bugs, or serious design problems) by replying to the email.&lt;br /&gt;&lt;br /&gt;So, to my current project managers: if you read me, here is a wish-list item.  And, for everyone else, if you need to set up a new project, consider creating this mailing list as soon as possible.  Maybe few developers will subscribe to it, but those that do will pay attention and will provide very valuable feedback in the form of replies.&lt;br /&gt;&lt;br /&gt;1: Shame on me for not having such a mailing list for ATF. Haven't investigated how to do so with Monotone.&lt;br /&gt;&lt;br /&gt;2: Of course, the developers must be conscious to commit early and often, and to provide well-formed changesets: i.e. self-contained and with descriptive logs.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-4782427967638867417?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/4782427967638867417/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=17885055&amp;postID=4782427967638867417' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/4782427967638867417'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/4782427967638867417'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2009/05/mailing-lists-for-commit-notifications.html' title='Mailing lists for commit notifications'/><author><name>Julio Merino</name><uri>http://www.blogger.com/profile/08233346614736256024</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='11711662837553049744'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-446058185749523279</id><published>2009-05-09T05:12:00.004+02:00</published><updated>2009-05-09T05:21:47.952+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='msdos'/><title type='text'>DEBUG.EXE dropped in Windows 7</title><content type='html'>Wow. &lt;a href="http://tech.slashdot.org/article.pl?sid=09/05/08/169226&amp;from=rss"&gt;DEBUG.EXE is being finally phased out in Windows 7&lt;/a&gt;.  I can't believe it was still there.&lt;br /&gt;&lt;br /&gt;This brings me back two different memories.  I had used this program in the past (a long while ago!) and it caused me both pain and joy.&lt;br /&gt;&lt;br /&gt;Regarding pain: I had an MS-DOS 5.x book that spent a whole section on DEBUG.EXE, and one of the examples in it contained a command that caused the program in memory to be written to some specific sectors of the floppy disk.  Guess what I tried?   I executed that same command but told it to use my hard disk instead of the floppy drive.  Result: a corrupted file system.  Had to run scandisk (remember it?), which marked some sectors as faulty and I thought I had ruined my precious 125MB WD Caviar hard disk.  It wasn't until much, much, much later that I learnt that such a thing was not possible, and that really formatting the disk with a tool that had no memory of "bad" sectors (aka, Linux's newfs) could revert the disk to a clean state.  (Actually, I kept that hard disk until very recently.)&lt;br /&gt;&lt;br /&gt;Regarding joy: On a boring weekend away from home, I used DEBUG.EXE on an old portable machine without internet connection to hack a version of PacMan.  I disassembled the code until I found where it kept track of the player's lives and tweaked the counter to be infinite (or extra large, can't remember).  &lt;i&gt;That&lt;/i&gt; was fun.  I could get to levels me and my father (who used to be an avid player) had never seen before!&lt;br /&gt;&lt;br /&gt;It's a pity this tool is going, but it must go.  It is way too outdated compared to current debuggers.  I wonder if anyone is still using it.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-446058185749523279?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/446058185749523279/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=17885055&amp;postID=446058185749523279' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/446058185749523279'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/446058185749523279'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2009/05/debugexe-dropped-in-windows-7.html' title='DEBUG.EXE dropped in Windows 7'/><author><name>Julio Merino</name><uri>http://www.blogger.com/profile/08233346614736256024</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='11711662837553049744'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-4155033642151738049</id><published>2009-05-08T00:20:00.005+02:00</published><updated>2009-05-08T03:32:32.300+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='c++'/><category scheme='http://www.blogger.com/atom/ns#' term='pin'/><title type='text'>Using C++ templates to optimize code</title><content type='html'>As part of the project I'm currently involved in at university, I started (re)writing a &lt;a href="http://www.pintool.org/"&gt;Pin&lt;/a&gt; tool to gather run-time traces of applications parallelized with OpenMP. This tool has to support two modes: one to generate a single trace for the whole application and one to generate one trace per parallel region of the application.&lt;br /&gt;&lt;br /&gt;In the initial versions of my rewrite, I followed the idea of the previous version of the tool: have a &lt;tt&gt;-split&lt;/tt&gt; flag in the frontend that enables or disables the behavior described above.  This flag was backed by an abstract class, &lt;tt&gt;Tracer&lt;/tt&gt;, and two implementations: &lt;tt&gt;PlainTracer&lt;/tt&gt; and &lt;tt&gt;SplittedTracer&lt;/tt&gt;.  The thread-initialization callback of the tool then allocated one of these objects for every new thread and the &lt;i&gt;per-instruction injected code&lt;/i&gt; used a pointer to the interface to call the appropriate specialized instrumentation routine.  This pretty much looked like this:&lt;pre&gt;void&lt;br /&gt;thread_start_callback(int tid, ...)&lt;br /&gt;{&lt;br /&gt;    if (splitting)&lt;br /&gt;        tracers[tid] = new SplittedTracer();&lt;br /&gt;    else&lt;br /&gt;        tracers[tid] = new PlainTracer();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;void&lt;br /&gt;per_instruction_callback(...)&lt;br /&gt;{&lt;br /&gt;    Tracer* t = tracers[PIN_ThreadId()];&lt;br /&gt;    t-&gt;instruction_callback(...);&lt;br /&gt;}&lt;/pre&gt;I knew from the very beginning that such an implementation was going to be inefficient due to the pointer dereference at each instruction and the vtable lookup for the correct virtual method implementation.  However, it was a very quick way to move forward because I could reuse some small parts of the old implementation.&lt;br /&gt;&lt;br /&gt;There were two ways to optimize this: the first one involved writing different versions of &lt;tt&gt;per_instruction_callback&lt;/tt&gt;, one for plain tracing and the other for splitted tracing, and then deciding which one to insert depending on the flag.  The other way was to use template metaprogramming.&lt;br /&gt;&lt;br /&gt;As you can imagine, this being C++, I opted to use template metaprogramming to heavily abstract the code in the Pin tool.  Now, I have an abstract core parametrized on the Tracer type.  When instantiated, I provide the correct Tracer class and the compiler does all the magic for me.  With this design, there is no need to have a parent Tracer class &amp;mdash; though I'd welcome having C++0x concepts available &amp;mdash;, and the callbacks can be easily inlined because there is no run-time vtable lookup.  It looks something like this:&lt;pre&gt;template&lt; class Tracer &gt;&lt;br /&gt;class BasicTool {&lt;br /&gt;    Tracer* tracers[MAX_THREADS];&lt;br /&gt;&lt;br /&gt;    Tracer* allocate_tracer(void) const = 0;&lt;br /&gt;&lt;br /&gt;public:&lt;br /&gt;    Tracer*&lt;br /&gt;    get_tracer(int tid)&lt;br /&gt;    {&lt;br /&gt;        return tracers[tid];&lt;br /&gt;    }&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;class PlainTool : public BasicTool&lt; PlainTracer &gt; {&lt;br /&gt;    PlainTracer*&lt;br /&gt;    allocate_tracer(void) const&lt;br /&gt;    {&lt;br /&gt;        return new PlainTracer();&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;public:&lt;br /&gt;    ...&lt;br /&gt;} the_plain_tool;&lt;br /&gt;&lt;br /&gt;// This is tool-specific, non-templated yet.&lt;br /&gt;void&lt;br /&gt;per_instruction_callback(...)&lt;br /&gt;{&lt;br /&gt;    the_plain_tool.get_tracer(PIN_ThreadId()).instruction_callback(...);&lt;br /&gt;}&lt;/pre&gt;What this design also does is force me to have two different Pin tools: one for plain tracing and another one for splitted tracing.  Of course, I chose it to be this way because I'm not a fan of run-time options (the &lt;tt&gt;-split&lt;/tt&gt; flag).  Having two separate tools with well-defined, non-optional features makes testing much, much easier and... follows the Unix philosophy of having each tool do exactly one thing, but doing it right!&lt;br /&gt;&lt;br /&gt;Result: around a 15% speedup.  And C++ was supposed to be slow? ;-)  You just need to know what the language provides you and choose wisely.  (Read: my initial, naive prototype had a run-time of 10 minutes to trace part of a small benchmark; after several rounds of optimizations, it's down to 1 minute and 50 seconds to trace the &lt;i&gt;whole&lt;/i&gt; benchmark!)&lt;br /&gt;&lt;br /&gt;Disclaimer: The code above is an oversimplification of what the tool contains.  It is completely fictitious and obviates many details.  I will admit, though, that the real code is too complex at the moment.  I'm looking for ways to simplify it.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-4155033642151738049?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/4155033642151738049/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=17885055&amp;postID=4155033642151738049' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/4155033642151738049'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/4155033642151738049'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2009/05/using-c-templates-to-optimize-code.html' title='Using C++ templates to optimize code'/><author><name>Julio Merino</name><uri>http://www.blogger.com/profile/08233346614736256024</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='11711662837553049744'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-8028620398342481804</id><published>2009-05-04T22:39:00.003+02:00</published><updated>2009-05-04T22:52:19.656+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='c++'/><title type='text'>Numeric limits in C++</title><content type='html'>By pure chance when trying to understand a build error of some C++ code I'm working on, I came across the correct C++ way of checking for numeric limits. Here is how.&lt;br /&gt;&lt;br /&gt;In C, when you need to check for the limits of native numeric types, such as &lt;tt&gt;int&lt;/tt&gt; or &lt;tt&gt;unsigned long&lt;/tt&gt;, you include the &lt;tt&gt;limits.h&lt;/tt&gt; header file and then use the &lt;tt&gt;INT_MIN&lt;/tt&gt;/&lt;tt&gt;INT_MAX&lt;/tt&gt; and &lt;tt&gt;ULONG_MAX&lt;/tt&gt; macros respectively.  In the C++ world, there is a corresponding &lt;tt&gt;climits&lt;/tt&gt; header file to get the definition of these macros, so I always thought this was the way to follow.&lt;br /&gt;&lt;br /&gt;However, it turns out that the C++ standard defines a &lt;tt&gt;limits&lt;/tt&gt; header file too, which provides the &lt;tt&gt;numeric_limits&amp;lt;T&amp;gt;&lt;/tt&gt; template. This template class is specialized in &lt;lt&gt;T&lt;/lt&gt; for every numeric type and provides a set of static methods to query properties about the corresponding type.  The simplest ones are &lt;tt&gt;min()&lt;/tt&gt; and &lt;tt&gt;max()&lt;/tt&gt;, which are what we need to replace the old-style &lt;tt&gt;*_MIN&lt;/tt&gt; and &lt;tt&gt;*_MAX&lt;/tt&gt; macros.&lt;br /&gt;&lt;br /&gt;As an example, this C code:&lt;pre&gt;#include &amp;lt;limits.h&amp;gt;&lt;br /&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;#include &amp;lt;stdlib.h&amp;gt;&lt;br /&gt;&lt;br /&gt;int&lt;br /&gt;main(void)&lt;br /&gt;{&lt;br /&gt;    printf("Integer range: %d to %d\n", INT_MIN, INT_MAX);&lt;br /&gt;    return EXIT_SUCCESS;&lt;br /&gt;}&lt;/pre&gt;becomes the following in C++:&lt;pre&gt;#include &amp;lt;cstdlib&amp;gt;&lt;br /&gt;#include &amp;lt;iostream&amp;gt;&lt;br /&gt;#include &amp;lt;limits&amp;gt;&lt;br /&gt;&lt;br /&gt;int&lt;br /&gt;main(void)&lt;br /&gt;{&lt;br /&gt;    std::cout &amp;lt;&amp;lt; "Integer range: "&lt;br /&gt;              &amp;lt;&amp;lt; std::numeric_limits&amp;lt; int &amp;gt::min()&lt;br /&gt;              &amp;lt;&amp;lt; " to "&lt;br /&gt;              &amp;lt;&amp;lt; std::numeric_limits&amp;lt; int &amp;gt::max()&lt;br /&gt;              &amp;lt;&amp;lt; "\n";&lt;br /&gt;    return EXIT_SUCCESS;&lt;br /&gt;}&lt;/pre&gt;Check out the &lt;a href="http://www.cplusplus.com/reference/std/limits/numeric_limits/"&gt;documentation&lt;/a&gt; for more details on additional methods!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-8028620398342481804?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/8028620398342481804/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=17885055&amp;postID=8028620398342481804' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/8028620398342481804'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/8028620398342481804'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2009/05/numeric-limits-in-c.html' title='Numeric limits in C++'/><author><name>Julio Merino</name><uri>http://www.blogger.com/profile/08233346614736256024</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='11711662837553049744'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-5467658448048251016</id><published>2009-05-04T20:32:00.003+02:00</published><updated>2009-05-04T20:47:43.045+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='netbsd'/><title type='text'>The NetBSD Blog</title><content type='html'>The NetBSD Project recently launched a new &lt;a href="http://blog.netbsd.org/"&gt;official blog for NetBSD&lt;/a&gt;. From here, I'd like to invite you to visit it and &lt;a href="http://blog.netbsd.org/tnf/feed/entries/atom"&gt;subscribe to it&lt;/a&gt;. It's only with your support (through reading and, specially, &lt;i&gt;commenting&lt;/i&gt;) that developers will post more entries!  Enjoy :-)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-5467658448048251016?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/5467658448048251016/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=17885055&amp;postID=5467658448048251016' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/5467658448048251016'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/5467658448048251016'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2009/05/netbsd-blog.html' title='The NetBSD Blog'/><author><name>Julio Merino</name><uri>http://www.blogger.com/profile/08233346614736256024</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='11711662837553049744'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-4081034348232814307</id><published>2009-04-02T11:46:00.004+02:00</published><updated>2009-04-02T11:50:38.146+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='soc'/><category scheme='http://www.blogger.com/atom/ns#' term='netbsd'/><title type='text'>NetBSD-SoC needs your application!</title><content type='html'>The Google Summer of Code 2009 application deadline for students is tomorrow and NetBSD has got very few applications so far. If you have the interest in working on a cool operating system project, where almost any project idea can fit, take the time to read &lt;a href="http://www.netbsd.org/contrib/soc-projects.html"&gt;our proposals&lt;/a&gt; and apply!  New, original ideas not listed there will also be considered.&lt;br /&gt;&lt;br /&gt;It'd be a pity if the number of assigned slots to NetBSD was small due to the low number of applications!  We did much better past year.&lt;br /&gt;&lt;br /&gt;Note that there are a couple of &lt;a href="http://www.NetBSD.org/~jmmv/atf/"&gt;ATF&lt;/a&gt;-related proposals in there. Help will be certainly welcome (by me ;-) in those areas!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-4081034348232814307?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/4081034348232814307/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=17885055&amp;postID=4081034348232814307' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/4081034348232814307'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/4081034348232814307'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2009/04/netbsd-soc-needs-your-application.html' title='NetBSD-SoC needs your application!'/><author><name>Julio Merino</name><uri>http://www.blogger.com/profile/08233346614736256024</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='11711662837553049744'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-898144593109126185</id><published>2009-04-01T14:25:00.004+02:00</published><updated>2009-04-01T14:27:39.820+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='google'/><title type='text'>Returning to Google</title><content type='html'>I've been holding back this announcement until all affected parties knew in advance.  They do know now, so I'm happy to announce that I'll be joining Google Dublin on May 25th as a Google.com Software Engineer!&lt;br /&gt;&lt;br /&gt;Thanks to everyone who made that possible.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-898144593109126185?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/898144593109126185/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=17885055&amp;postID=898144593109126185' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/898144593109126185'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/898144593109126185'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2009/04/returning-to-google.html' title='Returning to Google'/><author><name>Julio Merino</name><uri>http://www.blogger.com/profile/08233346614736256024</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='11711662837553049744'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-5724407113147228616</id><published>2009-03-24T14:35:00.002+01:00</published><updated>2009-03-24T14:36:59.843+01:00</updated><title type='text'>Comments for old posts now moderated</title><content type='html'>After waking up today and finding 80+ spam comments all around old posts in this blog, I have decided to set all new comments for posts older than 14 days old to be moderated.  Took half an hour to clean them all.  Thank you, spammers.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-5724407113147228616?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/5724407113147228616/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=17885055&amp;postID=5724407113147228616' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/5724407113147228616'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/5724407113147228616'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2009/03/comments-for-old-posts-now-moderated.html' title='Comments for old posts now moderated'/><author><name>Julio Merino</name><uri>http://www.blogger.com/profile/08233346614736256024</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='11711662837553049744'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-4053902384158212165</id><published>2009-03-23T16:35:00.003+01:00</published><updated>2009-03-23T16:43:57.131+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='c++'/><title type='text'>What are unnamed namespaces for in C++?</title><content type='html'>In the past, I had come by some C++ code that used unnamed namespaces everywhere as the following code shows, and I didn't really know what the meaning of it was:&lt;pre&gt;namespace {&lt;br /&gt;&lt;br /&gt;class something {&lt;br /&gt;...&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;} // namespace&lt;/pre&gt;Until now.&lt;br /&gt;&lt;br /&gt;Not using unnamed namespaces in my own code bit me with name clash errors. How? Take ATF. Some of its files declare classes in .cpp files (not headers).  I just copy/pasted some ATF code in another project and linked the libraries produced by each project together.  Boom!  Link error because of duplicate symbols.  And the linker is quite right in saying so!&lt;br /&gt;&lt;br /&gt;For some reason, I always assumed that classes declared in the .cpp files would be private to the module.  But if you just think a little bit about it, just a little, this cannot ever be the case: how could the compiler tell the difference between a class definition in a header file and a class definition in a source file?  The compiler sees preprocessed sources, not what the programmer wrote, so all class definitions look the same!&lt;br /&gt;&lt;br /&gt;So how do you resolve this problem?  Can you have a static class, pretty much like you can have a static variable or function?  No, you cannot.  Then, how do you declare implementation-specific classes private to a module?  Put them in an unnamed namespace as the code above shows and you are all set.  Every translation unit has its own unnamed namespace and everything you put in it will not conflict with any other translation unit.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-4053902384158212165?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/4053902384158212165/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=17885055&amp;postID=4053902384158212165' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/4053902384158212165'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/4053902384158212165'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2009/03/what-are-unnamed-namespaces-for-in-c.html' title='What are unnamed namespaces for in C++?'/><author><name>Julio Merino</name><uri>http://www.blogger.com/profile/08233346614736256024</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='11711662837553049744'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-6226640212762863520</id><published>2009-03-05T15:47:00.003+01:00</published><updated>2009-03-05T16:14:13.899+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='c++'/><category scheme='http://www.blogger.com/atom/ns#' term='atf'/><category scheme='http://www.blogger.com/atom/ns#' term='c'/><title type='text'>Making ATF "compiler-aware"</title><content type='html'>For a long time, ATF has shipped with &lt;a href="http://portal.pc.ac.upc.edu/viewmtn/atf/revision/browse/92e15dcd3de700ceaf558c43ed9de90e3c7d20d5/tests/build"&gt;build-time tests for its own header files&lt;/a&gt; to ensure that these files are self-contained and can be included from other sources without having to manually pull in obscure dependencies. However, the way I wrote these tests was a hack since the first day: I use automake to generate a temporary library that builds small source files, each one including one of the public header files. This approach works but has two drawbacks. First, if you do not have the source tree, you cannot reproduce these tests -- and one of ATF's major features is the ability to install tests and reproduce them even if you install from binaries, remember? And second, it's not reusable: I now find myself needing to do this exact same thing in another project... what if I could just use ATF for it?&lt;br /&gt;&lt;br /&gt;Even if the above were not an issue, build-time checks are a nice thing to have in virtually every project that installs libraries. You need to make sure that the installed library is linkable to new source code and, currently, there is no easy way to do this. As a matter of fact, &lt;a href="http://cvsweb.netbsd.org/bsdweb.cgi/src/regress/include/?only_with_tag=MAIN"&gt;the NetBSD tree has such tests&lt;/a&gt; and they haven't been migrated to ATF for a reason.&lt;br /&gt;&lt;br /&gt;I'm trying to implement this in ATF at the moment. However, running the compiler in a transparent way is a tricky thing. Which compiler do you execute? Which flags do you need to pass? How do you provide a portable-enough interface for the callers?&lt;br /&gt;&lt;br /&gt;The approach I have in mind involves caching the same compiler and flags used to build ATF itself and using those as defaults anywhere ATF needs to run the compiler itself. Then, make ATF provide some helper check functions that call the compiler for specific purposes and hide all the required logic inside them. That should work, I expect. Any better ideas?&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-6226640212762863520?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/6226640212762863520/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=17885055&amp;postID=6226640212762863520' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/6226640212762863520'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/6226640212762863520'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2009/03/making-atf-compiler-aware.html' title='Making ATF &quot;compiler-aware&quot;'/><author><name>Julio Merino</name><uri>http://www.blogger.com/profile/08233346614736256024</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='11711662837553049744'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-8416455013608697521</id><published>2009-03-02T14:40:00.004+01:00</published><updated>2009-03-02T15:11:51.885+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='c++'/><title type='text'>Debug messages without using the C++ preprocessor</title><content type='html'>If you are a frequent C/C++ programmer, you know how annoying a code plagued of preprocessor conditionals can be: they hide build problems quite often either because of, for example, trivial syntax errors or unused/undefined variables.&lt;br /&gt;&lt;br /&gt;I was recently given some C++ code to rewrite^Wclean up and one of the things I did not like was a macro called &lt;tt&gt;DPRINT&lt;/tt&gt; alongside with its use of &lt;tt&gt;fprintf&lt;/tt&gt;. Why? First because this is C++, so you should be using iostreams. Second because by using iostreams you do not have to think about the correct printf-formatter for every type you need to print. And third because it obviously relied on the preprocessor and, how not, debug builds were already broken.&lt;br /&gt;&lt;br /&gt;I wanted to come up with an approach to print debug messages that involved the preprocessor as less as possible. This application (a simulator) needs to be extremely efficient in non-debug builds, so leaving calls to printf all around that internally translated to noops at &lt;tt&gt;runtime&lt;/tt&gt; wasn't a nice option because some serious overhead would still be left. So, if you don't use the preprocessor, how can you achieve this? Simple: current compilers have very good optimizers so you can rely on them to do the right thing for release builds.&lt;br /&gt;&lt;br /&gt;The approach I use is as follows: I define a custom &lt;tt&gt;debug_stream&lt;/tt&gt; class that contains a reference to a &lt;tt&gt;std::ostream&lt;/tt&gt; object. Then, I provide a custom &lt;tt&gt;operator&amp;lt;&amp;lt;&lt;/tt&gt; that delegates the insertion to the output stream. Here is the only place where the preprocessor is involved: a small conditional is used to omit the delegation in release builds:&lt;pre&gt;template&amp;lt; typename T &amp;gt;&lt;br /&gt;inline&lt;br /&gt;debug_stream&amp;&lt;br /&gt;operator&lt;&lt;(debug_stream&amp; d, const T&amp; t)&lt;br /&gt;{&lt;br /&gt;#if !defined(NDEBUG)&lt;br /&gt;    d.get() &amp;lt;&amp;lt; t;&lt;br /&gt;#endif // !defined(NDEBUG)&lt;br /&gt;    return d;&lt;br /&gt;}&lt;/pre&gt;There is also a global instance of a &lt;tt&gt;debug_stream&lt;/tt&gt; called &lt;tt&gt;debug&lt;/tt&gt;. With this in mind, I can later print debugging messages anywhere in the code as follows:&lt;pre&gt;debug &lt;&lt; "This is a debug message!\n";&lt;/pre&gt;So how does this not introduce any overhead in release builds?&lt;br /&gt;&lt;br /&gt;In release builds, &lt;tt&gt;operator&amp;lt;&amp;lt;&lt;/tt&gt; is effectively a noop. It does nothing. As long as the compiler can determine this, it will strip out the calls to the insertion operator.&lt;br /&gt;&lt;br /&gt;But there is an important caveat. This approach requires you to be extremely careful in what you insert in the stream. Any object you construct as part of the insertion or any function you call may have side effects. Therefore, the compiler must generate the call to the code anyway because it cannot predict what its effects will be. How do you avoid that? There are two approaches. The first one involves defining everything involved in the debug call as inline or static; the trick is to make the compiler &lt;i&gt;see&lt;/i&gt; all the code involved and thus be able to strip it out after seeing it has no side effects. The second approach is simply to &lt;i&gt;avoid&lt;/i&gt; such object constructions or function calls completely. Debug-specific code should not have side effects, or otherwise you risk having different application behavior in debug and release builds! Not nice at all.&lt;br /&gt;&lt;br /&gt;A last note: the above is just a proof of concept. The code we have right now is more complex than what I showed above as it supports debug classes, the selection of which classes to print at runtime and prefixes every line with the class name. All of this requires several inline magic to get things right but it seems to be working just fine now :-)&lt;br /&gt;&lt;br /&gt;So, the conclusion: in most situations, &lt;b&gt;you do not need to use the preprocessor&lt;/b&gt;. Find a way around it and your developers will be happier. Really.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-8416455013608697521?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/8416455013608697521/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=17885055&amp;postID=8416455013608697521' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/8416455013608697521'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/8416455013608697521'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2009/03/debug-messages-without-using-c.html' title='Debug messages without using the C++ preprocessor'/><author><name>Julio Merino</name><uri>http://www.blogger.com/profile/08233346614736256024</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='11711662837553049744'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-8525327239297766482</id><published>2009-01-22T12:05:00.003+01:00</published><updated>2009-01-22T12:15:11.021+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='netbsd'/><title type='text'>userconf support for the boot loader</title><content type='html'>I have a machine at work, a Dell Optiplex 745, that cannot boot GENERIC NetBSD kernels.  There is a problem in one of the uhci/ehci, bge or azalia drivers that causes a lockup at boot time because of a shared interrupt problem.  Disabling ehci or azalia from the kernel lets the machine boot.  In order to do that, there are two options: either you rebuild your kernel without the offending driver, or you boot into the userconf prompt with -c and, from there, manually disable the driver at each boot.  None of the options are quite convincing.&lt;br /&gt;&lt;br /&gt;Of course, disabling a faulty driver is not the correct solution, but the workaround is useful on its own.  I've just added a &lt;tt&gt;userconf&lt;/tt&gt; command to the boot loader and its configuration file -- &lt;tt&gt;/boot&lt;/tt&gt; and &lt;tt&gt;/boot.cfg&lt;/tt&gt; respectively -- so that the end user can pass random userconf commands to the kernel in an automated way.  userconf is a kernel feature that lets you change the parameters of builtin drivers and enable/disable them before the hardware detection routines are run.&lt;br /&gt;&lt;br /&gt;With this new feature in the boot loader, you can customize a GENERIC kernel without having to rebuild it!  Yes, modules could help here too, but we are not there yet for hardware drivers.  Note that OpenBSD has had a similar feature for a while with &lt;tt&gt;config -e&lt;/tt&gt;, but they actually modify the kernel binary.&lt;br /&gt;&lt;br /&gt;You can check the patch out and comment about it in &lt;a href="http://mail-index.netbsd.org/tech-kern/2009/01/22/msg004081.html"&gt;my post to tech-kern&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-8525327239297766482?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/8525327239297766482/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=17885055&amp;postID=8525327239297766482' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/8525327239297766482'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/8525327239297766482'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2009/01/userconf-support-for-boot-loader.html' title='userconf support for the boot loader'/><author><name>Julio Merino</name><uri>http://www.blogger.com/profile/08233346614736256024</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='11711662837553049744'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-6329902342984575652</id><published>2009-01-18T21:01:00.003+01:00</published><updated>2009-01-18T21:08:54.928+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='soc'/><category scheme='http://www.blogger.com/atom/ns#' term='atf'/><category scheme='http://www.blogger.com/atom/ns#' term='netbsd'/><title type='text'>ATF 0.6 released</title><content type='html'>I am very happy to announce the availability of the &lt;a href="http://www.netbsd.org/~jmmv/atf/news.html#20090118-atf-0-6-released"&gt;0.6 release&lt;/a&gt; of &lt;a href="http://www.netbsd.org/~jmmv/atf/"&gt;ATF&lt;/a&gt;.  I have to apologize for this taking so long because the code has been mostly-ready for a while.  However, doing the actual release procedure is painful.  Testing the code in many different configurations to make sure it works, preparing the release files, uploading them, announcing the new release on multiple sites... not something I like doing often.&lt;br /&gt;&lt;br /&gt;Doing some late reviews, I have to admit that the code has some rough edges, but these could not delay 0.6 any more.  The reason is that this release will unblock the &lt;a href="http://netbsd-soc.sourceforge.net/projects/atfify/"&gt;NetBSD-SoC atfify&lt;/a&gt; project, making it possible to finally integrate all the work done in it into the main NetBSD source tree.&lt;br /&gt;&lt;br /&gt;Explicit thanks go to Lukasz Strzygowski.  He was not supposed to contribute to ATF during his Summer of Code 2008 project, but he did, and he actually provided very valuable code.&lt;br /&gt;&lt;br /&gt;The next step is to update the NetBSD source tree to ATF 0.6.  I have extensive local changes for this in my working copy, but I'm very tired at the moment.  I think I'll postpone their commit until tomorrow so that I don't screw up something badly.&lt;br /&gt;&lt;br /&gt;Enjoy it and I'm looking for your feedback on the new stuff!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-6329902342984575652?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/6329902342984575652/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=17885055&amp;postID=6329902342984575652' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/6329902342984575652'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/6329902342984575652'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2009/01/atf-06-released.html' title='ATF 0.6 released'/><author><name>Julio Merino</name><uri>http://www.blogger.com/profile/08233346614736256024</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='11711662837553049744'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry></feed>