Older blog entries for saju (starting at number 8)

The Leopard and The Tata Indicom Plug and Surf thinggy; a story.

Well actually not much of a story. I got my hands on a "Tata Indicom Plug and Surf thinggy". This is really a Sungil cdma usb modem using Qualcomm's mobile station modem (MSM) chipset. Darwin groks the msm chipset alright.

So I plugged in the modem into the USB port, pulled up "System Preferences", selected "Networking", filled in the account details - which should be same for all tata subscribers i.e dial #777, creds are internet/internet. Then I went to the "Advanced" menu section and changed the "Vendor" and "Modem" from "Apple" and "Apple Modem v34" to "Generic" and "Dialup Device". Hitting "Connect" should now get you online.

ps: i am posting this over the "tata indicom thinggy"

framework HELL

and what's with the java community and flashy library names ?

So I tried running Leenux on my shiny new dell d620 laptop. Since my linux skills suck and specifically since the 4th FC4 CD was fubar, I ditched the whole "put linux on my laptop" experiment and turned to FreeBSD.

fbsd 6.2 is lovely !. I used the 24 MB "boot" only iso image to get a install kernel on my box and performed the ports/packages install over the net. Very nice !

After spending a day configuring stuff I finally have the following working (or almost working..)

  • Video @1200x800 - thanks to 915resolution - which was in "ports" yeah
  • Sound ! - had to get the snd_hda.ko driver.
  • Skype !!!! - yeah baby - (linux abi ofcourse :D)
  • xmms for my lovely mp3's
  • mplayer for all those pron mpegs.
  • firefox with flash7 (linux binaries). The flash 9 crashes :( and there are no native flash binaries...
  • Java ! - yeah both the linux and native jdk
  • wired NIC - bge
  • USB - works like a charm
  • Wireless - if_wpi - maybe works maybe not - don't know - have to test yet - saw a bunch of mem align warnings on console though
  • fvwm2 -- mmm
  • acpi - well atleast I have it configured in my custom kernel

So - freebsd is going to stay on my new laptop from now on. Feeling happy!

2 Mar 2007 (updated 2 Mar 2007 at 15:17 UTC) »

char *a;

int **b;

b = &(int *)a;

The last line is ofcourse wrong, casting operation returns a value, & of a lvalue doesn't make any sense.

gcc catches this properly but icc 8.0 compiles this and the compiled code works.. Hmm...

"Skype is not compatible with system debuggers like SoftICE."

grrrrr.

http://www.google.com/search?hl=en&q=%22skype+is+not+compatible+with+system+debuggers+like+softice%22&btnG=Google+Search and the 4th link tells me how to workaround this.

I discovered "man 7 packet" last week and have been having a evil fun filled week disrupting the local network @work.

http://saju.pillai.googlepages.com/pong.c.txt spoof's an ARP packet. If the target of the spoof is a Win32 or WinXP box - interesting things happen - possibly including complete disruption of networking on the target box (I found that out the hard way)

No Malice. Just world peace.

14 Aug 2006 (updated 14 Aug 2006 at 05:54 UTC) »

Dynamic locks for openssl .. hmm are these even used ? I have 2 problems with locks and openssl

  1. No provision for passing user context between lock creation/locking/destroy callbacks
  2. Openssl doesn't care if the callback to lock actually succeded. The return type of the callback is void.

Actually I am struggling with (1) right now. As part of another project, I am writing Apache Portable Runtime (apr) ssl wrappers over openssl api's (well over some of them) and I would very much like to allocate memory for dynamic locks from a caller supplied pool but the openssl callback semantics for dyna locking don't allow this. Grrr

22 Mar 2006 (updated 14 Aug 2006 at 05:41 UTC) »

I have been working on a compiler in my free time that attempts to take a C like src file and targets the JVM platform. Ofcourse since I don't have the slightest clue about the JVM platform I spent sometime poking at the class file format. Here is a spinoff from that project .. http://saju.pillai.googlepages.com/kapi. Kapi is a java class file disassembler for Win32 that also produces useful src hints .. like the "good twin" of javap.

Also, I don't really hate Win32 - I just think it is retarded ..sometimes.

21 Mar 2006 (updated 21 Mar 2006 at 10:51 UTC) »

On byte swapping and endianess

I have seen various implementations of htonl(). Most of them look like ...
(x >> 24) | ((x & 0xff0000) >> 8) | (( x & 0xff00) << 8) | (x << 24);

Let's restrict ourselves to the M$ VC++ 6 32 bit machine and see what the compiler makes of that htonl() implementation..

F:\maya\misc>cl

Microsoft (R) 32-bit C/C++ Standard Compiler Version 12.00.8168 for 80x86
Copyright (C) Microsoft Corp 1984-1998. All rights reserved.

F:\maya\misc>cat htonl.c

int htonl(int x)
{
  return (x >> 24) | ((x & 0xff0000) >> 8) | (( x & 0xff00) << 8) | (x << 24);
}


Now we ask the compiler to show us the (un-optimised) assembly for this file

F:\maya\misc>cl /c /Fa htonl.c
F:\maya\misc>more htonl.asm
/** _snip_ **/
; File htonl.c
; Line 2
        push    ebp
        mov     ebp, esp
; Line 3
        mov         eax, DWORD PTR _x$[ebp]
        sar     eax, 24                                 ; 00000018H
        mov     ecx, DWORD PTR _x$[ebp]
        and     ecx, 16711680                           ; 00ff0000H
        sar     ecx, 8
        or      eax, ecx
        mov     edx, DWORD PTR _x$[ebp]
        and     edx, 65280                              ; 0000ff00H
        shl     edx, 8
        or      eax, edx
        mov     ecx, DWORD PTR _x$[ebp]
        shl     ecx, 24                                 ; 00000018H
        or      eax, ecx
; Line 4
        pop     ebp
        ret     0
_htonl  ENDP
_TEXT   ENDS
END

That seems like a lot of stuff for endianness conversion. Now let's see if a little bit of inline assembly can't fix this ..

F:\maya\misc>cat htonl.c
int htonl(int j)
{
  _asm
    {
      mov eax, j
      bswap eax
    }
}


And the assembly for this is ...

F:\maya\misc>more htonl.asm
/** snip **/
; File htonl.c
; Line 2
        push    ebp
        mov     ebp, esp
        push    ebx
        push    esi
        push    edi
; Line 5
        mov     eax, DWORD PTR _j$[ebp]
; Line 6
        bswap   eax
; Line 8
        pop     edi
        pop     esi
        pop     ebx
        pop     ebp
        ret     0
_htonl  ENDP
_TEXT   ENDS
END

So, the assembly is neater and smaller. If you ignore all the pushes and pop's need to make that inline assembly work, you will see that
the main brunt of the work is done by the *bswap* instruction which takes 1 to 3 cycles for all the dirty work.

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!