Search Results: "will"

5 February 2008

Jaldhar Vyas: Let Me Show You My Hegemons

New Jersey is one of the states holding presidential primaries on this Super Tuesday and since you asked, I voted for John McCain. The chief reason for my vote is of course the war against Islamic terrorism. Now that we are finally gaining the upper hand in Iraq, we can't afford to elect someone who will fail to see victory through. Mind you this isn't necessarily a reason not to vote Democrat. The anti-war wing of that party has been thoroughly marginalized. Hillary atleast has a commendable reputation for viciousness. Even Obama has made some encouraging remarks (ok that was probably a red herring but I have the audacity to hope you see.) But while the Democrats do not take the anti-war crowd seriously, they do depend on them for a great deal of their funding. A Democratic president might feel the need to throw them some bones inadvertantly screwing up things in the process. On the Republican side, Huckabee might leave tactical planning to Jesus. Romney would toe the line but there is no sign that he has any original thoughts on the matter. While I continue to support the President, it must be admitted that this whole war is stretching out as long as it is because mistakes were made. We need options beyond "staying the course" and "cutting and running" and McCain a military hero and early supporter of the surge could be the one to find them. The other big issue is supreme court appointments. One, possibly two justices may need to be replaced in the next four years. We need to ensure that the court does not veer leftward again as it will inevitably do during a Democratic administration. Here there is a big split in the Conservative establishment. Ideologues consider McCain to be insufficiently pure and worry he will end up appointing another Souter or O'Connor (both appointed by Republicans it should be noted.) Pragmatists point out that McCain is viewed more favorably than Romney or Huckabee amongst the independent and moderate voters who will be crucial to victory and that even the slight chance of a bad choice is better than the certainty of a bad choice if Clinton or Obama get to make it. Social issues are important to many Republican voters and in this area too there is some grumbling about McCain being too liberal. Some have even suggested that if McCain beats Huckabee or Romney, a Democratic victory and four years out of power would be preferable in order to bring the GOP back to the straight and narrow. Although this contingent is loud I frankly don't think they have the influence people think (As evidenced by the actual performance of Huckabee or previous champion Fred Thompson.) When push comes to shove, they will rally behind the party candidate especially if McCain makes a bona fide social conservative (Huckabee himself?) his vice-president. On economic issues, the president's job is to not interfere and let business run itself. I don't see any of the Republican candidates being much different in this regard. Or the Democrats for that matter. [Careful readers will have noticed I have avoided mentioning Ron Paul. Paulestinians, consider this carte blanche to send me your long, rambling, incoherent screeds about how Dr. Paul has the answers to everything. Because God knows I haven't read enough of them lately.] Update: Kevin asks what I think about the candidates in terms of "geek" issues such as net neutrality, DMCA etc. IMO there is not a whole lot of difference between the major candidates on these issues. Republicans one would think would be more beholden to corporations in general. Democrats on the other hand have a closer association with the media who are behind many of the sillier IP laws. Overall, I don't think it ought to be much of a factor in choosing the president even for Free Software types. Rather we should focus on the legislative branch (in Congress as well as the states) which holds the real power here and in the court of public opinion.

Aigars Mahinovs: Super bowl XLII

No Debian content here. Just like last year I decided to watch one of the largest sport events in the USA - the final game of the National Football League Super Bowl XLII (roman numerals are different for the sake of it :P ). I came to like the Japanese take on American football, so I watched the Superbowl last year and was appalled at the lack of any entertainment value in the game. I was told that it was one the worst Super bowls ever, so I gave it another try. Just like last year the American football looks to be very lawyer-friendly: bundles of complex rules and exceptions. The game could have been much simpler. Like for example, a lot of rues come from the fact that the game timer almost never stops. It is good for TV companies as they can plan their broadcast times better, but horrible for the stop-go game like the American football is. Just stopping the timer on every point the ball is stopped like they do in final seconds would cut out a lot of rules. Playclock and all. Rules on use of timeouts and stuff. Of course the game time would need to be adjusted down a bit. Now you have 4×15 minutes of ‘game’ where at most 20 minutes of that is in action. That game time is a lie - most of the time people are just standing around. Terminology irks me quite a lot. Why is it a “1st down” when there have been two “1st down”s just a few minutes ago? Something along the lines of “down counter reset” would be much clearer. And what is cryptic “1st & 10″ doing in the middle of the screen? It would have been much clearer if that info would be split: “Downs: 1/4″ and a measuring arrow between the ball and the yellow line with “10yd” written on it. And then there is an obscured “two in two” or “two for two” or “two in O” phrases which apparently means the same as “two 1st downs out of two tries” in the context. Can’t the commentators be a bit more elaborate and actually say the units of measurement? “Giants strength first tonight”? How about “in the lead”, English anyone? The camera placing editing is just horrible - the camera direction is switching all the time and that is confusing as hell. In normal football when professional camera teams are working, you always get all the shots from one side and even one general angle. If for clarity reasons a camera shot from other side is needed (usually in a replay) they always say that the image is from the reverse side in large letters on the screen. Here a lot of close-up shots were all over the place and even rotated around inside one shot! That might look fancy, but is just crappy camera work and editing. Then commentators start talking walls of numbers and walls of names. Unless you know by hearth who plays at what position, there is no way to understand what those people are saying. Than is just sloppy commentary. Is FOX incompetent in all possible ways? Then again the funky rules came into play just at the end of the first quarter - I have no idea why the ball was moved to the end line. Apparently the defender did or didn’t something. Did not see anything worth penalizing the team like that at all. They dropped the term ‘pass interference’ later on. Isn’t interfering with the pass the whole point of the defense play in this game??? Lawyer game, I’m telling you. And later on, pulling on guys arm while he is catching and being tackled apparently is just fine. And holding is illegal??? On the big penalty on the Giants the judge could have just said that the ball is out of bounds. Giving a 10yd penalty for such a minor thing is just ridiculous. The halftime show was kind of meh. Staged to extreme, but no soul nor sense. And what were all those people doing on the field? Isn’t that bad for the grass? And the commercials .. Average at best. Horrible at worst. For example a government commercial saying parents to protect their prescription medicine to .. help out your neighborhood drug dealer??? Oh and does anyone still doubt that media is controlled by republicans after that Coke commercial where the democrat is portrayed as bald and ugly and the republican is portrayed as the nice guy going for the compromise. And then they both Segway into the sunset? Brainwashing and prejudice embedded in a Coke commercial !?! WTF is going on in USA !? The 12-man-on-the-field penalty in the 3rd quarter is another legalese bullshit in the game. It is clear that the extra player had no effect on the game so it is just ridiculous for the judge to penalize the team for that. A couple small penalties were given for Patriots as well, judge bias was not as prevalent as last year. The camerawork stayed the same through the game - confusing, flashy and sloppy. Other cameras are in the shot line all the time. The game however did compensate for that all. The 4th quarter was very nice and exiting. I had no idea of the teams before the game, but I did like the Giants more - they just seemed to have more will and soul in their game. So I rooted for them since the 2nd quarter and it was very satisfying to see them win the game in the final seconds. Summary: good game, great final quarter, horrible coverage and crappy sideshows (adverts and halftime show).

4 February 2008

Matthew Palmer: What Time Is It There, Anyway?

As Internet-connected people, we tend to interact with a lot of people who aren't necessarily geographically co-located. Hence today's cool little program I found: gworldclock. You pick an arbitrary number of timezones to have in your list, and the current time in all of them is displayed in a neat list, quietly ticking away regularly. Small? Yes. Trivial? Getting close to it. Really Useful? You betcha. It also has a very tidy 'rendezvous' mode, where you choose a time, a timezone (from your list of selected timezones) and it shows the corresponding time in all of your other chosen timezones. Again, something that 20 minutes of coding will probably produce, but the whole point of this open source thing is not having to re-invent the wheel... The 'g' does indicate a GTK application, but there is a kworldclock for people who wouldn't be seen dead with a GTK application on their desktop, and a console-only version, tzclock, for anyone who lives the text-mode life.

Russell Coker: Party for U18s at LCA 2009

This year at Linux.Conf.Au there was a student party sponsored by Google. The party was held in a bar and lots of free drinks were provided. This was fine for the university students, but for school kids it was obviously lacking. Some people point out that it’s “quite legal” to run a party that excludes children, the point however is whether it’s desirable to exclude them. Also the concept of a state where laws dictate all aspects of your life to a degree such that obeying the law is the only possibility is fortunately restricted to science fiction. Another common fallacy is when people point out that we should be grateful for Google’s sponsorship. As far as I am aware Google doesn’t insist on any particular conditions for sponsoring a party. If the conference organisers were to request a party at a more child-friendly venue (for example a restaurant - which if licensed could serve alcohol to adults who desire it) then I doubt that Google would refuse. Being grateful for Google’s sponsorship is entirely unrelated to the issue of whether their sponsorship money was spent in the best possible manner. My interest in this topic started at LCA 2007 when I heard complaints from young delegates who were excluded from the Google party. This year the Google party (a different event from the “Google student party”) allowed everyone to attend and issued coloured wrist-bands to indicate whether the person had shown suitable ID to be served alcohol. The Google party was inviting for all and I believe that it was a significant improvement over last year (more attention was paid to serving food than alcohol). I have suggested that at future events some tables be reserved for people who aren’t drinking. As a general rule people enjoy being around people who have consumed a similar type and quantity of mind-altering substances (something I learned from my friends in Amsterdam). There is of course demand for serious drinking, and it seems impossible to satisfy people who want to do serious drinking at the same party as people who won’t or can’t drink at all. If there is not going to be an official party that is suitable for U18s then I’ll arrange it and pay for it myself. The consensus of opinion seems to be that less than six U18s are not worth catering for (one of the common objections to my suggestions is that there may be only four or five U18s). I can pay for a party for that many people which (in terms of food and non-alcoholic drinks) compares well with whatever Google might offer for the drinkers. The rough idea is that U18s will have free food and non-alcoholic drinks. The venue will be some suitable restaurant (is there a Pizza hut or similar near the next LCA?). The party will be open to parents and delegates who are >18 and don’t plan to drink (but I’m sorry I can’t afford to shout you). Opportunities to learn about cool Linux stuff will abound (I expect that a number of knowledgable Linux people who can teach some interesting things will be interested in attending). If I’m paying then children who aren’t delegates will also be welcome to attend, but their parents would have to pay for their food/drink. But this is merely a matter of budget, if it was to be an official event or there were other sponsors then this might not be the case. What I would like right now is expressions of interest from young people who plan to attend the conference and from parents (who plan to attend the conference or whose children will attend). If it looks like there will be a suitably large number of people interested in this then the conference organisers may decide to make it an official event. Also comments from adults who would prefer an alcohol free event (whether it be due to medical reasons, religion, or choice) would be of interest. It’s all about the number of people who will attend.

Julian Andres Klode: Experiences with git and pristine-tar


In the last days, I used git very often. It was almost the first time I really used it, but I quickly understand the basic commands. As some of you may know, the readahead-list package is now maintained in a git repo in the collab-maint project. I decided to use git instead of bzr (which I used for everything before), because of its speed and because I wanted to learn more about git, how it works. I used git-import-dsc to import the first revision, and used debdiffs from 1 to 2 and from 2 to 3 to import the next revisions. Afterwards, I run git-import-orig on the new upstream tarball, which I downloaded and recompressed. Then, I did the packaging changes, added them using ‘git add changed-file‘ and committed them using git commit. After I had done this, I read Planet Debian and saw Joey Hess’s post about the new features of pristine-tar 0.5, i.e. the integration with git. Running Ubuntu at the moment, I fetched the source package, built it and installed it. I then opened a shell in my git repo and ran pristine-tar commit path-to-orig upstream/0.20050517.0220 to import the delta for the first tarball. Afterwards I did it for the second tarball. Because I use git-buildpackage to build the package and Joey said he would like to see support for pristine-tar in git-buildpackage, I then wrote a patch for the programs in git-buildpackage to import and export the orig.tar.gz when needed. The patch can be seen in gitweb, and the maintainer responded in Bug#463580 will integrate the patch with some minor modifications.
Both git and pristine-tar are great works, and it makes it so easy to maintain the readahead-list package. The combination of git, git-buildpackage and pristine-tar is the most powerful I ever used to maintain a Debian package, especially when you are not upstream.

Julian Andres Klode: uploads and machine-readable copyright


Two days ago, zobel uploaded some of my package updates for me. One of them was ndisgtk 0.8.1, which adds more translations and fixes some problems. I intent to create a 0.9 release soon, with support for PolicyKit. I will upload the release candidate of this version to Debian experimental and Ubuntu Hardy. The other upload was readahead-list 1:1.20060421.1016-1, which I found on the Gentoo mirrors, but not where previous releases were located. This is OK, because the upstream author is a Gentoo developer and uploaded this tarball himself. I already requested to sync this release into Ubuntu Hardy, to reduce the diff between both distributions. In both uploads, I changed the format of debian/copyright to match http://wiki.debian.org/Proposals/CopyrightFormat. I will also change my other packages in their next uploads, and hope that other maintainers also use the new format, especially for NEW packages. I some cases (especially when you are upstream + packager), this format is also shorter.

Julian Andres Klode: Debian Maintainer


Since yesterday, I am a Debian maintainer. This will help me and my sponsors, which have to do less now. I can now upload new versions of my packages if the version in unstable contains the “Dm-Upload-Allowed” field in the dsc (and only if the package is not NEW). For more information about the Concept of Debian Maintainers, see http://wiki.debian.org/Maintainers I’m very happy about this, as it makes my life easier. But this does not mean that I don’t want to be a DD anymore. A DD is able to vote, to sponsor packages, to upload NEW packages, and many more things. (BTW: I’m currently at T&S step)

Pierre Habouzit: New git and CLI

Yes Junichi, this new release explicitely deprecates dashed form of git commands, as they will probably go away from the $PATH for many good reasons: So we gave our users a pretty good timeframe to adapt their scripts, hence the deprecation notice. Also note that best practices about scripting are now documented in the gitcli(5) man page I wrote.

Daniel Baumann: My misc developement news (Januar 2008)

In the past I was not blogging small things if they were not worth a full blog entry on their own (or if I did not have the time to make up a full entry of it :). Inspired by the example of Raphaël Hertzog <hertzog@debian.org> with "News for Debian developers" for <debian-devel-announce@lists.debian.org>, I am intending to do the same on a monthly basis about my own Debian related work. This first entry about January 2008 also covers a few things from the last month of 2007. General News Package News Team News

3 February 2008

Jonathan McDowell: Inaugural all-Island Conference on Free and Open Source Software, Belfast

My. That's a mouthful of a title. I went to this event on Friday, which was run by OpenIsland. I don't really think I was the target audience; I'm already a convert and aware of the opportunities which Free Software offers. However, there were a few bits of interest to me. Brian Doran, director of the Southern Regional College talked about including discussion of Open Source in their computer related courses. He didn't commit to more use in the colleges' IT infrastructure (and indeed Netcraft reports the website as being hosted by a Win2k3/IIS combo), but it's still a significant step forward IMO - rather than just being spoon fed MS based product people will hopefully be encouraged to think about the options available and evaluate them on their merits. We'll see if it pans out in practice. Also notable was Reg Empey, NI Minister for Employment and Learning, giving a speech involving Open Source. It got hijacked into discussion about how they were going to invest in higher education in NI and fund more PHDs in a targeted manor, but I still think the fact that a member of the NI Assembly got up and used the words Open Source (or possibly Free and Open Source Software; I can't remember exactly which speaker used that once a sentence) is quite incredible. Whether or not he's fully aware of it, someone on his staff must have done some research, and decided that it was something government was prepared to think about, or at the very least not boycott. During the day I realised that I'm prejudiced towards Free Software. I'm not sure if this is a good thing or not. I will, in general, accept slightly less functionality as long as the Free option fulfils my primary needs. And I've got used to hanging around with people who also work this way, or at the very least consider Free Software on a level playing field with proprietary stuff. I was reminded that a lot of people work the other way; either they're not aware of the Free alternatives, or they view them with a natural suspicion. So it was really good to see people standing up and talking about how they'd built their businesses on Free Software, and even better, about how they were pushing back upstream fixes/features they'd needed as part of their business. I don't know if anyone in the audience was converted, but it's certainly the sort of thing I like to see - it's important to appreciate that as well as Free Software being a great resource, it's also often beneficial to share any changes you make from a business point of view, as it tends to make things easier for you in the long run. Hopefully the conference did some good in terms of making people aware of Free Software (well, mostly Open Source was talked about, but both got mentioned). I wasn't convinced that there was a need, but having talked to various people I think it's just that I have got used to being surrounded by converts and perhaps lost sight of the fact that there are still plenty of people out there who aren't yet giving Free Software a chance. There are plans for this to be an annual event, so I look forward to the next one (and I think there will be various more targeted meetings over the next year too; I know there was considerable interest in covering the use of Free Software in health).

Matthew Garrett

Hello! I am in San Francisco. Offers of beer, entertainment and marriage will be given appropriate consideration. Interestingly, moving from Melbourne to here seems to have left me back on GMT, which I'm sure isn't quite what I want.

My LCA presentation isn't up yet. I seem to have this effect on technology.

David Welton: Rails and Hype

Yoav Shapira wonders about the "rails backlash": http://yoavs.blogspot.com/2008/02/railsshudder.html I'm a big fan of Rails, and of course I realize that it has some flaws and is certainly not the optimal choice for all situations, but I don't buy into the bashing. Sure, Rails was hyped, but there is no way that it could have possible reached the level of popularity it has on hype alone. We're not talking about multi-million dollar marketing budgets commanded by the likes of Sun or Microsoft, but about a video and some nice dressings by DHH and 37signals. A small group like that just doesn't have the resources to push something like Rails as far as it's gone without some substance to back it up. Look at all the imitation. People realize that the basic idea is good, and even though the basic idea is nothing phenomenal, it hadn't really been done before. What is this idea? Take a bunch of components, and good (if not always the absolute best) practices, and integrate them nicely. Database, templating, testing, a clean application structure, ajax/javascript integration, with some code generation, all done with a language that's flexible enough to do all of the above pretty well. All those things existed, but Rails did a great job of tying them all together. And that's been imitated far and wide. That seems to indicate that, even though the imitators may change and improve bits and pieces, they're quite smitten with the idea itself. So much that they've dedicated a lot of time and effort to reproduce it. That's quite a tribute. Look at the adoption. Moving to a new language/platform is a big step, not one to be taken lightly, and for people with lots of existing code in some other language, perhaps simply not possible. Hype will take things only so far, but Rails has been taken up by a large number of people who certainly didn't do so because it was the safe, easy path to take. Perhaps some of those people have found that Rails really wasn't for them, but that's pretty normal. No one said it was perfect. However, when you look at what it takes to make people jump ship from what they know, and are comfortable with, you realize that it really must have been that much better to make people go out on a limb. Furthermore, it's easy to point out the failings and drawbacks of something after the fact, but much more difficult to do creative, innovative work of your own. Compounding that is the fact that criticizing others' work is often an easy and effective way of looking smart; there's an interesting study referenced here http://bobsutton.typepad.com/my_weblog/2006/08/brilliant_but_c.html that talks about this effect. It's something I've come to dislike over the years. Our field is so new, so dynamic, and so immature, that it's usually pretty easy to take a look at something and say that it "sucks". It is much harder to write something of your own and put it out there, knowing full well that lots of people who have never done much of anything will jump on it and bemoan its "copious failings". That's not to say that it's impolite to criticize, but - do it constructively please. Imagine that you were there in the same room, talking to the person who wrote the code in question. You would still say you don't like it, but you'd probably be much more polite and helpful in your commentary. I hope so, at least.

Steve Kemp: Shout it out

Well I've had a busy weekend, but I'm sober now. I made a new release of xen-tools, which has a couple of minor bugfixes and not much else. I also released a new update for Debian of the xen-shell which fixes a couple of bashisms. Finally I've managed to sign up two new users to my anti-spam proxy. Hopefully they're very happy. In real news I painted about 1 square meter of my flat, (we're now into week three of painting a single room...), and replaced five light bulbs:
My eyes! The goggles do nothing!
Now I need to install a request tracking system (otrs2) and catch up on significantly outstanding RT status updates. I'm getting hopeless again. Maybe I should just give it all up and become a plumber. Plumbing is easy: Water goes downhill. The rest is just regulations and a willingness to get dirty...

Neil Williams: Delaying libqof2

As the Debian release timetable for Lenny is now clear and the soft freeze is only a few weeks hence, I've decided that I won't look for the libqof1 to libqof2 transition before Lenny. There just isn't time to complete the GDA backend in time.
Once 0.7.5 reaches testing in Debian (0.7.5-1), I'll make the upstream changes for libqof2 in CVS. This should also allow time for Ubuntu to release with the last version of libqof1.
pilot-qof and gpe-expenses CVS already has support for libqof2 but there's no need for a release just yet. I'll release after Lenny.

2 February 2008

Lucas Nussbaum: Human deadlocks

Given three groups of groups of people A, B, C, responsible for 3 queues Qa, Qb, Qc ; and an elements e which have to go through Qa, then Qb, then Qc. Possible solution: A, B, C, please prove your point! Now, let’s find a practical example to apply that … Any suggestions? :-)

Joerg Jaspert: DebConf8 Call for papers and registration opened

Finally I was able to open the registration for DebConf8 and send the Call for Papers. For the full details please read the whole mail. We had a lot of work in the last few weeks to make this possible, as we set us the goal “We will keep all data entered last year, people won’t have to enter that again”. And we made it! It wasn’t all that easy to do, as we switched from the old 0.2.10 version of Pentabarf to the more recent, completly rewritten 0.3.9 release of it. Which had a completly new database schema, making the database upgrade a fun task, having had a lot of changes for our own data… After Mark and Stephen finished the database it was my task to get all the changes to the interface back which we had done. Which took about a week longer than I expected it, unfortunately delaying the CfP about 4 days. But hey, the new code is way better now. The actual difference between us and plain upstream is about 30% of that with 0.2.10. Which is nice. Of course we still miss a few things, but those aren’t important for the CfP and will be readded soon. Some of those features also will be sent (and most possibly merged) upstream. A big thanks go to Mark (mhy) Hymers and Stephen (sgran) Gran who did the database upgrade (keeping all our own data in it!) and to upstream who did help me out multiple times to get this running. (Yes, this stuff is also the reason why NEW got that huge again. No worries, I will fix that this weekend, shouldn’t take more than one or two “NEW-sessions”).

Aigars Mahinovs: Using FUSE encfs in a graphical way

If you want to use encfs module from FUSE to encrypt some of your files and do not want to go into the command line to mount and unmount that encrypted folder, here is what you do: Add a line such as this to your /etc/fstab:
encfs#/home/aigarius/.crypt/ /home/aigarius/crypt fuse rw,user,noauto 0 0
Where ‘/home/aigarius/.crypt’ is the folder where you have created an encrypted folder (with “encfs /home/aigarius/.crypt /home/aigarius/crypt” command) and ‘/home/aigarius/crypt’ being the place where you want to mount to see the decrypted files. After you boot into Gnome, you go to Places->Computer, right-click on ‘crypt’ drive icon and select “Mount”. It will prompt you for the passwrd and mount the folder. Unmounting will disconnect it. Enjoy.

1 February 2008

Chris Lamb: Happy Mailman day, Sun!

To: Chris Lamb <chris@chris-lamb.co.uk>
Cc: web-discuss@openjdk.java.net
From: Tim Bell <tim.Bell@Sun.COM>
Date: Fri, 01 Feb 2008 08:42:14 -0800
Subject: Re: "Mailman day”
Hi Chris:
> It is somewhat of a tradition in the free software world to wish each
> other a “Happy Mailman Day” at the beginning of each month.
>
> However, the OpenJDK mailing lists seem to send the reminders about the
> middle of the month. Could this be changed?  
That was when I got around to turning on the reminders.  I’m glad to hear
someone noticed.  All of the internal feedback on this so far has been
negative.
I will change the cron job to the first of the month.
>  (In addition, the mailman@openjdk.java.net email address listed at the
>  top of http ://mail.openjdk.java.net/mailman/listinfo bounces.)
Good to know.  I will check that out.
Cheers - Tim Bell
Yay!

Ian Wienand: Compare and Swap with PIC

Our Dear Leader Sam Hocevar has previously blogged about PIC and inline ASM. Today I came across a sort of extension to this problem. Consider the following code, which implements a double word compare and swap using the x86 cmpxchg8b instruction (for a bonus you can lock it to make it atomic).
#include <stdio.h>
typedef struct double_word_t  
	int a;
	int b;
  double_word;
/* atomically compare old and mem, if they are the same then copy new
   back to mem */
int compare_and_swap(double_word *mem,
		     double_word old,
		     double_word new)  
	char result;
	__asm__ __volatile__("lock; cmpxchg8b %0; setz %1;"
			     : "=m"(*mem), "=q"(result)
			     : "m"(*mem), "d" (old.b), "a" (old.a),
			       "c" (new.b), "b" (new.a)
			     : "memory");
	return (int)result;
 
int main(void)
 
	double_word w =  .a = 0, .b = 0 ;
	double_word old =  .a = 17, .b = 42 ;
	double_word new =  .a = 12, .b = 13 ;
	/* old != w, therefore nothing happens */
	compare_and_swap(&w, old, new);
	printf("Should fail -> (%d,%d)\n", w.a, w.b);
	/* old == w, therefore w = new */
	old.a = 0; old.b = 0;
	compare_and_swap(&w, old, new);
	printf("Should work  -> (%d,%d)\n", w.a, w.b);
	return 0;
 
This type of CAS can be used to implement lock-free algorithms (I've previously blogged about that sort of thing). The problem is that the cmpxchg8b uses the ebx register, i.e. pseudo code looks like:
if(EDX:EAX == Destination)  
    ZF = 1;
    Destination = ECX:EBX;
 
else  
    ZF = 0;
    EDX:EAX = Destination;
 
PIC code reserves ebx for internal use, so if you try to compile that with -fPIC you will get an error about not being able to allocate ebx. A first attempt to create a PIC friendly version would simply save and restore ebx and not gcc anything about it, something like:
  __asm__ __volatile__("pushl %%ebx;"   /* save ebx used for PIC GOT ptr */
		       "movl %6,%%ebx;" /* move new_val2 to %ebx */
		       "lock; cmpxchg8b %0; setz %1;"
		       "pop %%ebx;"     /* restore %ebx */
	    	       : "=m"(*mem), "=q"(result)
		       : "m"(*mem), "d" (old.b), "a" (old.a),
		         "c" (new.b), "m" (new.a) : "memory");
Unfortunately, this isn't a generic solution. It works fine with the PIC case, because gcc will not allocate ebx for anything else. But in the non-PIC case, there is a chance that ebx will be used for addr. This would cause a probably fairly tricky bug to track down! The solution is to use the #if __PIC__ directive to either tell gcc you're clobbering ebx in the non-PIC case, or just keep two versions around; one that saves and restores ebx for PIC and one that doesn't.

31 January 2008

Simon Richter: I can't get no sleep

Not being able to sleep sucks. It is now 6 AM, and if I wanted to get up as planned, I have less than two hours. Since I can't concentrate at all with that little sleep, I guess I will make it at least four hours. Still, tomorrow will suck, especially as I will be dealing with crypto code.

Next.

Previous.