Friday, October 28, 2011

Duff's Device.. Worth A Thought...Power of C..




register n = (count + 7) / 8;      /* count > 0 assumed */

   switch (count % 8)
   {
   case 0:        do {  *to = *from++;
   case 7:              *to = *from++;
   case 6:              *to = *from++;
   case 5:              *to = *from++;
   case 4:              *to = *from++;
   case 3:              *to = *from++;
   case 2:              *to = *from++;
   case 1:              *to = *from++;
                      } while (--n > 0);
   }


What it does is exactly same as:

send(to, from, count)
 register short *to, *from;
 register count;
 {
  do
   *to = *from++;
  while(--count>0);
 }

Dont worry about '*to' same pointer. it was originally coded for serial copying to one output port.

Details: http://drdobbs.com/web-development/184406208


Monday, October 17, 2011

Daily job.. few commands/things to jot down

1. To logout a user using terminal:
>skill -KILL -u

2. If stuck with the error while logging in.. as " An error occurred while loading or saving configuration information for gnome-session. Some of your configuration settings may not work properly"


do  in home directory :  "rm -rf .gnome .gnome2 .gconf .gconfd .metacity"