arch detail

arch detail

Monday, September 08, 2008

C++ Irritation

In C++ (compiled with g++), the following will use foo's copy constructor:


foo f;
foo g = f;


Whereas I had really imagined it would use the default constructor, followed by the operator= function if present.

In other news, I am working on interesting stuff but haven't spoken about it yet. See CIL, the C Intermediate Language for a really interesting approach to compiler IR: It uses (a subset of) C as an intermediate language for C.

Monday, June 09, 2008

Followup on Ubuntu/SATA issues

I promised to inform the world if I solved my Ubuntu problems using a PCI-SATA adapter and my old SATA disk (My PCI-SATA ubuntu misadventures).

Unfortunately, I haven't. Even using the SATA disk *not* as the boot disk, any significant I/O causes the whole system to freeze - no Ctl-Alt-Backspace or Ctl-Alt-Delete response. So it seems the mundane is true: Ubuntu really doesn't support my hardware.

I've upgraded to 8.04 on my laptop, though, and will soon follow suite on that desktop machine. Maybe I'll be in luck.

Wednesday, June 04, 2008

output of Unix/Linux/*nix time (/usr/bin/time) into a file

I've encountered this problem before:

$ time somecommand arguments 2>&1 >> some_file.txt

real 0m0.001s
user 0m0.001s
sys 0m0.000s


And it drives me crazy. Why doesn't the program 'time' write its output to the, erm, 'normal' stdout or stderr, the ones I'm redirecting? Supposedly, you can use

 time -o outfile.txt somecommand arguments 
(or -a for append) to get the desired effect, but only on GNU time. And inexplicably, this doesn't work on most systems I've used.

Of course, if you Google for anything along the lines of 'time redirect i/o' you'll get a million matches to shell script tutorials saying "this time, we'll use I/O redirection..."

Eventually, I realized that Googling for "/usr/bin/time I/O redirect" got some useful results.

Well, if you're using non-GNU time, and you're using bash or sh (who knows, maybe even csh works this way?), you can do this:

$ ( time command arguments ) 2>> time.out > command.out


Which is a big ol' ugly hack, but it works.





UPDATE:


So the venerable aaron has informed me that I wasn't getting /usr/bin/time, I was getting the bash builtin command 'time' - hence

$env time
/usr/bin/time


and yet the command 'time' does not behave as expected. I should have seen that one coming. The obvious workaround is to explicitly call /usr/bin/time instead of time.

This strikes me as particularly frustrating as bash is a GNU project, and yet it's builtin 'time' does not behave like the 'real' GNU time, but ah well.

Monday, May 26, 2008

Great, doomsaying article on IPv4/v6

Here is a great article about IPv4, why it's dangerous, why it's here to stay, and what we can expect for the future of the Internet. Basically, we shouldn't expect a sane free market for trading around free pools of IPv4 addresses, we can expect hacks upon hacks and most likely all kinds of monetary horrors. Imagine what happens when moveOn.org has to apply for a batch of addresses owned by Halliburton.

Sunday, May 18, 2008

Most useful command-line utility

$your-package-manager install cowsay
$ fortune | cowsay
________________________________________
/ The difference between a Miracle and a \
| Fact is exactly the difference between |
| a mermaid and a seal. |
| |
\ -- Mark Twain /
----------------------------------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||

Wednesday, April 23, 2008

PCI-SATA/Ubuntu misadventures

So, I finally decided it was time to drop the Windows/Cakewalk life for good and install UbuntuStudio (well, Ubuntu, then later upgrade to UbuntuStudio) on my Athlon XP+ recording machine.

I had this brilliant idea to put / onto a SATA disk, both because I had one laying around and because it would be better for recording and pretty much any other media-centric task. Unfortunately, my motherboard does not support SATA!

So for <$40 I got a PCI-SATA adapter (VIA chipset). Happily, my Ubuntu LiveCD detected the attached SATA disk and was more than happy to install on it.

(correction to the above: I had sporadic freezes, but managed several successful installs. However, I do think faulty SATA or PCI-SATA adapter drivers were responsible. running "tail -f /var/log/messages" I was able to see many odd messages; not positive if updated drivers will fix this or it will become a persistent problem.)

Unfortunately, on attempting to boot into the newly-installed environment, I got an ever-so-helpful numeric error from GRUB, in this case, "Error 21". I tried re-running grub-install and editing my /boot/grub/menu.lst on the newly-created system, suspecting that my BIOS might be renumbering my drives when it tried to boot from the MBR of the SATA disk. No dice. At some point I managed to move from "Error 21" in GRUB to a straight "HARD DRIVE BOOT ERROR" from my BIOS.

I heard quite a few suggestions, but really, the Internet has not been much help on this one. I suspected GRUB itself was the problem.

So I tried using SuperGrub, which is basically just GRUB with lots of fancy features and burnable to CD (or copy-able to floppy, or to USB stick, and so on).

Running in SuperGrub, I was able to discover that though grub-install and the grub shell could happily find my SATA disk when running inside of a GNU/Linux LiveCD environment, GRUB itself had no idea. It was totally unable to see the SATA disk. So apparently what happened was that BIOS boots off the MBR, GRUB gets control of the system, and then, well, nothing. GRUB can't find its own files.

So, as a result, I had to do something ugly: I put /boot on a spare IDE disk I had lying around (one which, admittedly, I don't 100% trust, as it had a CRC error once or twice) and put / on the SATA disk. Ubuntu's installer went very nicely from there. Not particularly elegant, but it is effective.

I'm now happily writing you from Ubuntu. It's much faster than my Gentoo machine, but I don't know why; Firefox (even on Windows) was always faster on my Athlon XP+ 3500 than my Gentoo P4 (1.8 GHz), either because of my inability to intelligently manage libraries/drivers on Gentoo, or because the P4 is held back by its weak floating point unit. The SATA certainly doesn't seem to hurt, either; I boot in record time and applications open with wonderful snappiness.

In conclusion: SATA is great, but don't try to rely on it as a boot disk if you're connected via a PCI-SATA card adapter.