Thursday, December 30, 2010

SSE built-in functions in GCC

int __builtin_ia32_comieq (v4sf, v4sf)
int __builtin_ia32_comineq (v4sf, v4sf)
int __builtin_ia32_comilt (v4sf, v4sf)
int __builtin_ia32_comile (v4sf, v4sf)
int __builtin_ia32_comigt (v4sf, v4sf)
int __builtin_ia32_comige (v4sf, v4sf)
int __builtin_ia32_ucomieq (v4sf, v4sf)
int __builtin_ia32_ucomineq (v4sf, v4sf)
int __builtin_ia32_ucomilt (v4sf, v4sf)
int __builtin_ia32_ucomile (v4sf, v4sf)
int __builtin_ia32_ucomigt (v4sf, v4sf)
int __builtin_ia32_ucomige (v4sf, v4sf)
v4sf __builtin_ia32_addps (v4sf, v4sf)
v4sf __builtin_ia32_subps (v4sf, v4sf)
v4sf __builtin_ia32_mulps (v4sf, v4sf)
v4sf __builtin_ia32_divps (v4sf, v4sf)
v4sf __builtin_ia32_addss (v4sf, v4sf)
v4sf __builtin_ia32_subss (v4sf, v4sf)
v4sf __builtin_ia32_mulss (v4sf, v4sf)
v4sf __builtin_ia32_divss (v4sf, v4sf)
v4si __builtin_ia32_cmpeqps (v4sf, v4sf)
v4si __builtin_ia32_cmpltps (v4sf, v4sf)
v4si __builtin_ia32_cmpleps (v4sf, v4sf)
v4si __builtin_ia32_cmpgtps (v4sf, v4sf)
v4si __builtin_ia32_cmpgeps (v4sf, v4sf)
v4si __builtin_ia32_cmpunordps (v4sf, v4sf)
v4si __builtin_ia32_cmpneqps (v4sf, v4sf)
v4si __builtin_ia32_cmpnltps (v4sf, v4sf)
v4si __builtin_ia32_cmpnleps (v4sf, v4sf)
v4si __builtin_ia32_cmpngtps (v4sf, v4sf)
v4si __builtin_ia32_cmpngeps (v4sf, v4sf)
v4si __builtin_ia32_cmpordps (v4sf, v4sf)
v4si __builtin_ia32_cmpeqss (v4sf, v4sf)
v4si __builtin_ia32_cmpltss (v4sf, v4sf)
v4si __builtin_ia32_cmpless (v4sf, v4sf)
v4si __builtin_ia32_cmpunordss (v4sf, v4sf)
v4si __builtin_ia32_cmpneqss (v4sf, v4sf)
v4si __builtin_ia32_cmpnlts (v4sf, v4sf)
v4si __builtin_ia32_cmpnless (v4sf, v4sf)
v4si __builtin_ia32_cmpordss (v4sf, v4sf)
v4sf __builtin_ia32_maxps (v4sf, v4sf)
v4sf __builtin_ia32_maxss (v4sf, v4sf)
v4sf __builtin_ia32_minps (v4sf, v4sf)
v4sf __builtin_ia32_minss (v4sf, v4sf)
v4sf __builtin_ia32_andps (v4sf, v4sf)
v4sf __builtin_ia32_andnps (v4sf, v4sf)
v4sf __builtin_ia32_orps (v4sf, v4sf)
v4sf __builtin_ia32_xorps (v4sf, v4sf)
v4sf __builtin_ia32_movss (v4sf, v4sf)
v4sf __builtin_ia32_movhlps (v4sf, v4sf)
v4sf __builtin_ia32_movlhps (v4sf, v4sf)
v4sf __builtin_ia32_unpckhps (v4sf, v4sf)
v4sf __builtin_ia32_unpcklps (v4sf, v4sf)
v4sf __builtin_ia32_cvtpi2ps (v4sf, v2si)
v4sf __builtin_ia32_cvtsi2ss (v4sf, int)
v2si __builtin_ia32_cvtps2pi (v4sf)
int __builtin_ia32_cvtss2si (v4sf)
v2si __builtin_ia32_cvttps2pi (v4sf)
int __builtin_ia32_cvttss2si (v4sf)
v4sf __builtin_ia32_rcpps (v4sf)
v4sf __builtin_ia32_rsqrtps (v4sf)
v4sf __builtin_ia32_sqrtps (v4sf)
v4sf __builtin_ia32_rcpss (v4sf)
v4sf __builtin_ia32_rsqrtss (v4sf)
v4sf __builtin_ia32_sqrtss (v4sf)
v4sf __builtin_ia32_shufps (v4sf, v4sf, int)
void __builtin_ia32_movntps (float *, v4sf)
int __builtin_ia32_movmskps (v4sf)

The following built-in functions are available when -msse is used.

v4sf __builtin_ia32_loadaps (float *)
Generates the movaps machine instruction as a load from memory. 
void __builtin_ia32_storeaps (float *, v4sf)
Generates the movaps machine instruction as a store to memory. 
v4sf __builtin_ia32_loadups (float *)
Generates the movups machine instruction as a load from memory. 
void __builtin_ia32_storeups (float *, v4sf)
Generates the movups machine instruction as a store to memory. 
v4sf __builtin_ia32_loadsss (float *)
Generates the movss machine instruction as a load from memory. 
void __builtin_ia32_storess (float *, v4sf)
Generates the movss machine instruction as a store to memory. 
v4sf __builtin_ia32_loadhps (v4sf, v2si *)
Generates the movhps machine instruction as a load from memory. 
v4sf __builtin_ia32_loadlps (v4sf, v2si *)
Generates the movlps machine instruction as a load from memory 
void __builtin_ia32_storehps (v4sf, v2si *)
Generates the movhps machine instruction as a store to memory. 
void __builtin_ia32_storelps (v4sf, v2si *)
Generates the movlps machine instruction as a store to memory.

Wednesday, December 29, 2010

Vector Addition using SIMD

#include 

#define VECTOR_SIZE         4
typedef float v4sf __attribute__ ((vector_size(sizeof(float)*VECTOR_SIZE))); // vector of four singl
e floats

typedef union f4vector
{
    v4sf    v;
    float   f[VECTOR_SIZE];
} f4vector;


void print_vector (f4vector *v)
{
    printf("%f,%f,%f,%f\n", v->f[0], v->f[1], v->f[2], v->f[3]);
}

int main()
{
    union f4vector a, b, c;

    a.v = (v4sf){1., 2., 3., 4.};
    b.v = (v4sf){5., 6., 7., 8.};
    c.v = a.v + b.v;

    print_vector(&a);
    print_vector(&b);
    print_vector(&c);
}

Compile with the following command:
gcc -ggdb -mtune=pentium3 -march=pentium3 -c -O3 -ffast-math -mfpmath=sse -msse5 sse.c

To test, just link the object code to binary:

gcc -lm sse.o -o sse

$ ./sse
1.000000,2.000000,3.000000,4.000000
5.000000,6.000000,7.000000,8.000000
6.000000,8.000000,10.000000,12.000000

The assembled code:

$ objdump -dS ./sse.o | grep -2 c.v | tail -8
  7c:   0f 58 c1                addps  %xmm1,%xmm0
  7f:   0f 29 45 c8             movaps %xmm0,-0x38(%ebp)
--
 120:   f2 0f 11 44 24 04       movsd  %xmm0,0x4(%esp)
 126:   e8 00 00 00 00          call   12b <_main+0xdb>
        c.v = a.v + b.v;

        print_vector(&a);

As we can see, it's very optimized where adding 4 components of vector a and b is done in one SSE instruction (addps) instead of multiple instructions if we don't use -msse and -mfpmath=sse



How fast is the program?

$ time ./sse
1.000000,2.000000,3.000000,4.000000
5.000000,6.000000,7.000000,8.000000
6.000000,8.000000,10.000000,12.000000

real    0m0.109s
user    0m0.046s
sys     0m0.030s

Thursday, December 23, 2010

Mac OSX Lion: Another Windows remake?

Apple has just updated its website and now it announces that they plan to release another Mac OS-X named "Lion".  A sneak peak to the features, some of the features are not really "wow" me and even seems too-old to be a breakthrough.  For example, "LauchPad".  Windows xx has had it for long time as "Desktop icons".  Another one is "Mission Control" which the similar feature has been in Windows 7 for awhile.

Unfortunately, Apple has not revealed all the features they plan to put in OS-X.  Not sure if the upgrade worth the cost of upgrade (well, if it is only $25 upgrade I'll just go ahead and upgrade mine).

Sunday, November 14, 2010

Downsampling MP3 file

#!/usr/bin/tclsh

set ffmpeg [exec which ffmpeg]
puts "ffmpeg  = $ffmpeg"
if { [llength $argv] < 2 } {
    puts "\n$argv0  n bps\n"
    exit -1
}
set fi [lindex $argv 0]
set br [lindex $argv 1]
puts "$fi"
puts "target $br bps"

if { [regexp -all {(.*)\.([mM][pP]3)} $fi a b c] } {
    set fo "${b}_${br}bps.$c"
    puts "$fi ==> $fo, ext=$c, new bitrate=$br"
    set id3 [exec id3v2 -l $fi]
    set id3par ""
    if { [regexp -line {TIT2.*: (.*)\n} $id3 dummy title c] } { puts Title=$title }
    if { [regexp -line {TPE1.*: (.*)\n} $id3 dummy singer c] } { puts singer=$singer }
    if { [regexp -line {TALB.*: (.*)\n} $id3 dummy album c] } { puts album=$album }
    if { [regexp -line {TYER.*: (.*)\n} $id3 dummy year c] } { puts year=$year }
    if { [regexp -line {TCON.*\(([0-9]+)\)\n} $id3 dummy genre c] } { puts genre=$genre }
    set cmd "$ffmpeg -threads 16 -y -ab $br -i $fi $fo"
    if {![file exists $fo]} {
        if { [catch { set res [eval exec $cmd] fid }] } {
            #puts stderr "Could not execute $cmd"
            if {[info exists fid] } { puts stderr $fid" }
            #exit 1
        }
    }
    if {[info exists title]} { append idpar " --TIT2 \"$title\"" }
    if {[info exists singer]} { append idpar " --TPE1 \"$singer\"" }
    if {[info exists album]} { append idpar " --TALB \"$album\"" }
    if {[info exists year]} { append idpar " --TYER \"$year\"" }
    if {[info exists genre]} { append idpar " --TCON \"$genre\"" }
    set cmd "id3v2 $idpar $fo"
    puts $cmd
    if { [file exists $fo]} {
        eval exec $cmd
    }
} else {
    puts "Not an MP3 file"
}


PAM Security explained

PAM Security: http://articles.techrepublic.com.com/5100-10878_11-1055269.html

Login restriction/Limitation based on time schedue

This is how to limit a user (in this case, his name is "Joko") to access computer during weekdays and weekends at certain time duration.

  1. Edit file
    /etc/pam.d/common-account
    and add a line "account required pam_time.so"
  2. Edit file
    /etc/security/time.conf
    and add the following lines to the end of file.

#services  ttys users   times
#
# allow Joko to use computer during weekdays 3 pm-8:30pm OR weekends 9:00am - 9:00pm
* ; * ; joko; Wk1500-2030 | Wk0900-2100

This will not allow joko to login during weekdays before 3 pm or after 8:30 pm or weekends outside 9 am - 9 pm. To disallow certain service, replace '*' in the first entry with a PAM service name (e.g, login, etc.). Files in /etc/pam.d reflect the service names.

On my computer, the following files are the service names can be used:

-rw-r--r-- 1 root root 217 2010-07-05 04:57 atd
-rw-r--r-- 1 root root 167 2010-07-05 06:44 chage
-rw-r--r-- 1 root root 218 2010-07-05 06:44 chfn
-rw-r--r-- 1 root root 218 2010-07-05 06:44 chsh
lrwxrwxrwx 1 root root  17 2010-09-13 10:39 common-account -> common-account-pc
-rw-r--r-- 1 root root 378 2010-07-05 05:15 common-account.pam-config-backup
-rw-r--r-- 1 root root 446 2010-11-14 09:01 common-account-pc
lrwxrwxrwx 1 root root  14 2010-09-13 10:39 common-auth -> common-auth-pc
-rw-r--r-- 1 root root 448 2010-07-05 05:15 common-auth.pam-config-backup
-rw-r--r-- 1 root root 557 2010-11-14 09:01 common-auth-pc
lrwxrwxrwx 1 root root  18 2010-09-13 10:39 common-password -> common-password-pc
-rw-r--r-- 1 root root 855 2010-07-05 05:15 common-password.pam-config-backup
-rw-r--r-- 1 root root 506 2010-11-14 09:01 common-password-pc
lrwxrwxrwx 1 root root  17 2010-09-13 10:39 common-session -> common-session-pc
-rw-r--r-- 1 root root 435 2010-07-05 05:15 common-session.pam-config-backup
-rw-r--r-- 1 root root 573 2010-11-14 09:01 common-session-pc
-rw-r--r-- 1 root root 287 2010-07-05 04:56 crond
-rw-r--r-- 1 root root  56 2010-09-15 13:49 cups
-rw-r--r-- 1 root root 204 2010-07-05 16:24 gdm
-rw-r--r-- 1 root root 206 2010-07-05 16:24 gdm-autologin
-rw-r--r-- 1 root root 239 2010-07-05 08:06 gnomesu-pam
-rw-r--r-- 1 root root 216 2010-07-28 09:45 init
-rw-r--r-- 1 root root 419 2010-07-05 22:36 login
-rw-r--r-- 1 root root 251 2010-07-05 05:15 other
-rw-r--r-- 1 root root 133 2010-07-05 06:44 passwd
-rw-r--r-- 1 root root 165 2010-07-05 06:18 polkit
-rw-r--r-- 1 root root 165 2010-07-05 07:10 polkit-1
-rw-r--r-- 1 root root 173 2010-07-05 14:34 ppp
-rw-r--r-- 1 root root 481 2010-07-05 05:32 remote
-rw-r--r-- 1 root root 165 2010-09-15 14:14 samba
-rw-r--r-- 1 root root 209 2010-07-05 06:44 shadow
-rw-r--r-- 1 root root 165 2010-09-14 07:07 smtp
-rw-r--r-- 1 root root 268 2010-07-05 14:41 sshd
-rw-r--r-- 1 root root 239 2010-07-05 05:00 su
-rw-r--r-- 1 root root 203 2010-09-07 06:01 sudo
-rw-r--r-- 1 root root 239 2010-07-05 05:00 su-l
-rw-r--r-- 1 root root 172 2010-07-05 06:44 useradd
-rw-r--r-- 1 root root 569 2010-07-05 05:58 vsftpd
-rw-r--r-- 1 root root 241 2010-07-29 04:36 wxconsole
-rw-r--r-- 1 root root 204 2008-09-03 08:45 xdm
-rw-r--r-- 1 root root 166 2008-09-03 08:45 xdm-np
-rw-r--r-- 1 root root 265 2010-08-23 16:44 xen-api

A good solution to limit use of computer from kids during school days!

Monday, November 8, 2010

My First Objective-C

List.h:

#import <objc/Object.h>

@interface List : Object                          // List is a subclass of the superclass Object
{
    int list[100];                                // These are instance variables.
    int size;
}


/* Public methods */
- free;
- (int) addEntry: (int) num;
- print;

/* Private methods */
/* Other programs should not use these methods. */

- resetSize;

@end


List.m:

#import "List.h"

@implementation List

+ new                                           // factory method
{
    self = [super new];
    [self resetSize];
    return self;
}


- free
{
    return [super free];
}


- (int) addEntry: (int) num
{
    list[size++] = num;
    return size;
}


- print
{
    int i;

    printf("\n");
    for (i = 0; i < size; ++i)
        printf ("%i ", list[i]);
        puts("");
    return self;                                // Always return self
                                                                                                // if n
othing else makes sense.
}


- resetSize
{
    size = 0;
    return self;
}
Stack.h:
#import <objc/Object.h>

typedef struct StackLink {
        struct StackLink        *next;
        //void                  *data;
        int                     data;
} StackLink;


@interface Stack : Object
{
        StackLink *top;
    unsigned int size;
}

- free;
- push: (int) anInt;
- addEntry: (int) anInt;
- (int) pop;
- (unsigned int) size;

@end
Stack.m:
#import "Stack.h"
#import <stdlib.h>

@implementation Stack

#define NULL_LINK (StackLink *) 0

+ new
{
    self = [super new];
    top = NULL_LINK; //(StackLink *) 0;
    return self;
}


- free
{
    StackLink *next;

    while (top != NULL_LINK)
    {
        next = top->next;
        free ((char *) top);
        top = next;
    }
    return [super free];
}


- push: (int) value
{
    StackLink *newLink;

    newLink = (StackLink *) malloc (sizeof (StackLink));
    if (newLink == 0)
    {
        fprintf(stderr, "Out of memory\n");
        return nil;
    }
    newLink->data = value;
    newLink->next = top;
    top = newLink;
    size++;

    return self;
}


- addEntry: (int) value
{
        return [self push: value];
}

- (int) pop
{
    int value;
    StackLink *topLink;

    if (0 != size)
    {
        topLink = top;
        top = top->next;
        value = topLink->data;
        free (topLink);
        size--;
    }
    else
    {
        value = 0;
    }
    return value;
}


- (unsigned int) size
{
    return size;
}

- print
{
        StackLink *startLink;
        int i = size;

        startLink = top;

        while (startLink) {
                printf("Stack[%d] = %d\n", i, startLink->data);
                startLink = startLink->next;
                i--;
        }
        return self;
}

@end
main.m:
#import <objc/Object.h>
#import "List.h"
#import "Stack.h"

//int main(int argc, char *argv[])

void perform (id obj)
{
        [obj addEntry: 5];
        [obj print];
        [obj addEntry: 6];
        [obj addEntry: 3];
        [obj print];
}

main()
{
        id list;

        list = [List new];
        perform(list);
        [list free];

        id stack;
        stack = [Stack new];
        perform(stack);
        [stack free];
        printf("\n");
        return 0;
}

Makefile:
.SUFFIXES: .o .m

.m.o:
        $(CC) -c $(CFLAGS) $< -o $@

# Macros

CC=gcc

#CFLAGS=-Wall -Wno-import -mtune=core2 -mfpmath=sse -ffast-math -msse3 -fobjc-exceptions
CFLAGS=-Wno-import -mtune=core2 -g

LDFLAGS=-lobjc
SRCS=main.m List.m Stack.m
OBJS=$(SRCS:.m=.o)
EXECUTABLE=main

.PHONY: all

all: $(EXECUTABLE)

$(EXECUTABLE): $(OBJS)
        $(CC) $(LDFLAGS) -o $@ $(OBJS)

#$(OBJS): $(SRCS)
#       echo "$(CC) -c $(CFLAGS) $< -o $@"

clean:
        rm -f *.o $(EXECUTABLE)

TAGS: $(SRCS)
        ctags -R $(SRCS)

Tuesday, November 2, 2010

MiniDuckSimulator.java


import java.io.Console;

/**
 * @author mlutfi
 *
 */
public class MiniDuckSimulator {

 /**
  * @param args
  */
 public static void main(String[] args) {
  // TODO Auto-generated method stub
  Duck mallard = new MallardDuck();
  mallard.display();
  mallard.performQuack();
  mallard.performFly();
  
  Duck model = new ModelDuck();
  model.display();
  model.performFly();
  model.setFlyBehavior(new FlyRocketPowered());
  model.performFly();
 }
}

Sunday, October 31, 2010

How to block certain inbound IP addresses

Create a file /etc/iptables/blockip.sh:

#!/bin/bash
# Simple iptables IP/subnet block script
# -------------------------------------------------------------------------
IPT=`which iptables`
SPAMLIST="spamlist"
SPAMDROPMSG="SPAM LIST DROP"
BADIPS=$(egrep -v -e "^#|^$" /etc/iptables/blocked.ips)

# create a new iptables list
$IPT -N $SPAMLIST

for ipblock in $BADIPS
do
   $IPT -A $SPAMLIST -s $ipblock -j LOG --log-prefix "$SPAMDROPMSG"
   $IPT -A $SPAMLIST -s $ipblock -j DROP
done

$IPT -I INPUT -j $SPAMLIST
$IPT -I OUTPUT -j $SPAMLIST
$IPT -I FORWARD -j $SPAMLIST

Create a file /etc/iptables/blocked.ips:

put IP addresses here! (one per line)


edit file /etc/boot.local and add this line:

/etc/iptables/blockip.sh

Saturday, October 30, 2010

Error in compiling QEMU-XEN

The following errors occurs when I did "make tool". For some reason, the file "cpu.h" in subdir
+ test -d git://xenbits.xensource.com/qemu-xen-4.0-testing.git
+ '[' '!' -d ioemu-remote ']'
+ rm -f ioemu-dir
+ ln -sf ioemu-remote ioemu-dir
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c: In function `kvm_arch_init_vcpu':
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:47:5: warning: implicit declaration of function `cpu_x86_cpuid'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c: In function `kvm_has_msr_star':
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:159:49: error: `MSR_STAR' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:159:49: note: each undeclared identifier is reported only once for each function it appears in
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c: In function `set_seg':
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:219:27: error: `DESC_TYPE_SHIFT' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:220:29: error: `DESC_P_MASK' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:222:25: error: `DESC_B_SHIFT' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:223:23: error: `DESC_S_MASK' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:224:24: error: `DESC_L_SHIFT' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:225:23: error: `DESC_G_MASK' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:226:25: error: `DESC_AVL_MASK' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c: In function `get_seg':
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:236:16: error: `DESC_TYPE_SHIFT' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:237:20: error: `DESC_P_MASK' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:238:17: error: `DESC_DPL_SHIFT' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:239:16: error: `DESC_B_SHIFT' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:240:14: error: `DESC_S_MASK' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:241:15: error: `DESC_L_SHIFT' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:242:14: error: `DESC_G_MASK' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:243:16: error: `DESC_AVL_MASK' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c: In function `kvm_getput_regs':
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:265:35: error: `CPUX86State' has no member named `regs'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:265:42: error: `R_EAX' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:266:35: error: `CPUX86State' has no member named `regs'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:266:42: error: `R_EBX' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:267:35: error: `CPUX86State' has no member named `regs'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:267:42: error: `R_ECX' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:268:35: error: `CPUX86State' has no member named `regs'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:268:42: error: `R_EDX' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:269:35: error: `CPUX86State' has no member named `regs'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:269:42: error: `R_ESI' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:270:35: error: `CPUX86State' has no member named `regs'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:270:42: error: `R_EDI' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:271:35: error: `CPUX86State' has no member named `regs'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:271:42: error: `R_ESP' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:272:35: error: `CPUX86State' has no member named `regs'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:272:42: error: `R_EBP' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:284:38: error: `CPUX86State' has no member named `eflags'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:285:35: error: `CPUX86State' has no member named `eip'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c: In function `kvm_put_fpu':
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:299:18: error: `CPUX86State' has no member named `fpus'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:300:20: error: `CPUX86State' has no member named `fpstt'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:301:18: error: `CPUX86State' has no member named `fpuc'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:303:19: error: `CPUX86State' has no member named `fptags'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:304:24: error: `CPUX86State' has no member named `fpregs'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:304:44: error: `CPUX86State' has no member named `fpregs'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:305:24: error: `CPUX86State' has no member named `xmm_regs'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:305:46: error: `CPUX86State' has no member named `xmm_regs'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:306:20: error: `CPUX86State' has no member named `mxcsr'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c: In function `kvm_put_sregs':
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:316:15: error: `CPUX86State' has no member named `interrupt_bitmap'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:319:13: error: `CPUX86State' has no member named `eflags'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:319:24: error: `VM_MASK' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:320:35: error: `CPUX86State' has no member named `segs'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:320:42: error: `R_CS' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:321:35: error: `CPUX86State' has no member named `segs'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:321:42: error: `R_DS' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:322:35: error: `CPUX86State' has no member named `segs'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:322:42: error: `R_ES' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:323:35: error: `CPUX86State' has no member named `segs'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:323:42: error: `R_FS' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:324:35: error: `CPUX86State' has no member named `segs'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:324:42: error: `R_GS' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:325:35: error: `CPUX86State' has no member named `segs'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:325:42: error: `R_SS' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:327:29: error: `CPUX86State' has no member named `segs'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:328:29: error: `CPUX86State' has no member named `segs'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:329:29: error: `CPUX86State' has no member named `segs'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:330:29: error: `CPUX86State' has no member named `segs'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:331:29: error: `CPUX86State' has no member named `segs'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:332:29: error: `CPUX86State' has no member named `segs'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:334:13: error: `CPUX86State' has no member named `cr'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:334:23: error: `CR0_PE_MASK' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:342:28: error: `CPUX86State' has no member named `tr'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:343:29: error: `CPUX86State' has no member named `ldt'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:345:26: error: `CPUX86State' has no member named `idt'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:346:25: error: `CPUX86State' has no member named `idt'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:347:26: error: `CPUX86State' has no member named `gdt'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:348:25: error: `CPUX86State' has no member named `gdt'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:350:20: error: `CPUX86State' has no member named `cr'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:351:20: error: `CPUX86State' has no member named `cr'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:352:20: error: `CPUX86State' has no member named `cr'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:353:20: error: `CPUX86State' has no member named `cr'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:355:5: warning: implicit declaration of function `cpu_get_apic_tpr'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:356:5: warning: implicit declaration of function `cpu_get_apic_base'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:358:21: error: `CPUX86State' has no member named `efer'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c: In function `kvm_put_msrs':
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:379:35: error: `MSR_IA32_SYSENTER_CS' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:379:60: error: `CPUX86State' has no member named `sysenter_cs'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:380:35: error: `MSR_IA32_SYSENTER_ESP' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:380:61: error: `CPUX86State' has no member named `sysenter_esp'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:381:35: error: `MSR_IA32_SYSENTER_EIP' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:381:61: error: `CPUX86State' has no member named `sysenter_eip'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:383:32: error: `MSR_STAR' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:383:45: error: `CPUX86State' has no member named `star'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:384:35: error: `MSR_IA32_TSC' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:384:52: error: `CPUX86State' has no member named `tsc'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c: In function `kvm_get_fpu':
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:408:8: error: `CPUX86State' has no member named `fpstt'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:409:8: error: `CPUX86State' has no member named `fpus'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:410:8: error: `CPUX86State' has no member named `fpuc'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:412:5: error: `CPUX86State' has no member named `fptags'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:413:15: error: `CPUX86State' has no member named `fpregs'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:413:44: error: `CPUX86State' has no member named `fpregs'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:414:15: error: `CPUX86State' has no member named `xmm_regs'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:414:46: error: `CPUX86State' has no member named `xmm_regs'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:415:8: error: `CPUX86State' has no member named `mxcsr'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c: In function `kvm_get_sregs': 
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:430:15: error: `CPUX86State' has no member named `interrupt_bitmap'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:434:17: error: `CPUX86State' has no member named `segs'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:434:24: error: `R_CS' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:435:17: error: `CPUX86State' has no member named `segs'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:435:24: error: `R_DS' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:436:17: error: `CPUX86State' has no member named `segs'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:436:24: error: `R_ES' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:437:17: error: `CPUX86State' has no member named `segs'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:437:24: error: `R_FS' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:438:17: error: `CPUX86State' has no member named `segs'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:438:24: error: `R_GS' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:439:17: error: `CPUX86State' has no member named `segs'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:439:24: error: `R_SS' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:441:17: error: `CPUX86State' has no member named `tr'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:442:17: error: `CPUX86State' has no member named `ldt'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:444:8: error: `CPUX86State' has no member named `idt'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:445:8: error: `CPUX86State' has no member named `idt'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:446:8: error: `CPUX86State' has no member named `gdt'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:447:8: error: `CPUX86State' has no member named `gdt'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:449:8: error: `CPUX86State' has no member named `cr'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:450:8: error: `CPUX86State' has no member named `cr'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:451:8: error: `CPUX86State' has no member named `cr'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:452:8: error: `CPUX86State' has no member named `cr'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:454:5: warning: implicit declaration of function `cpu_set_apic_base'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:456:8: error: `CPUX86State' has no member named `efer'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:467:18: error: `CPUX86State' has no member named `segs'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:467:40: error: `DESC_DPL_SHIFT' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:467:58: error: `HF_CPL_MASK' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:468:19: error: `CPUX86State' has no member named `cr'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:468:29: error: `CR0_PE_MASK' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:468:46: error: `HF_PE_SHIFT' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:468:60: error: `CR0_PE_SHIFT' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:469:19: error: `CPUX86State' has no member named `cr'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:469:31: error: `HF_MP_SHIFT' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:469:45: error: `CR0_MP_SHIFT' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:470:7: error: `HF_MP_MASK' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:470:20: error: `HF_EM_MASK' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:470:33: error: `HF_TS_MASK' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:471:19: error: `CPUX86State' has no member named `eflags'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:471:31: error: `HF_TF_MASK' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:471:44: error: `HF_VM_MASK' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:471:57: error: `HF_IOPL_MASK' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:472:19: error: `CPUX86State' has no member named `cr'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:472:29: error: `CR4_OSFXSR_MASK' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:473:7: error: `HF_OSFXSR_SHIFT' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:473:25: error: `CR4_OSFXSR_SHIFT'  undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:475:12: error: `CPUX86State' has no member named `efer'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:475:21: error: `MSR_EFER_LMA' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:476:19: error: `HF_LMA_MASK' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:479:39: error: `CPUX86State' has no member named `segs'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:479:60: error: `DESC_L_MASK' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:480:19: error: `HF_CS32_MASK' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:480:34: error: `HF_SS32_MASK' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:480:49: error: `HF_CS64_MASK' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:482:23: error: `CPUX86State' has no member named `segs'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:482:44: error: `DESC_B_MASK' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:483:4: error: `DESC_B_SHIFT' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:483:19: error: `HF_CS32_SHIFT' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:484:23: error: `CPUX86State' has no member named `segs'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:485:19: error: `HF_SS32_SHIFT' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:486:18: error: `CPUX86State' has no member named `cr'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:487:24: error: `CPUX86State' has no member named `eflags'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:487:35: error: `VM_MASK' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:489:27: error: `HF_ADDSEG_MASK' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:491:32: error: `CPUX86State' has no member named `segs'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:492:36: error: `CPUX86State' has no member named `segs'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:493:36: error: `CPUX86State' has no member named `segs'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:494:21: error: `HF_ADDSEG_SHIFT' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:497:8: error: `CPUX86State' has no member named `hflags'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:497:23: error: `CPUX86State' has no member named `hflags'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:497:34: error: `HF_PE_MASK' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:497:34: error: `HF_OSFXSR_MASK' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c: In function `kvm_get_msrs':
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:512:23: error: `MSR_IA32_SYSENTER_CS' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:513:23: error: `MSR_IA32_SYSENTER_ESP' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:514:23: error: `MSR_IA32_SYSENTER_EIP' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:516:20: error: `MSR_STAR' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:517:23: error: `MSR_IA32_TSC' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:533:16: error: `CPUX86State' has no member named `sysenter_cs'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:536:16: error: `CPUX86State' has no member named `sysenter_esp'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:539:16: error: `CPUX86State' has no member named `sysenter_eip'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:542:16: error: `CPUX86State' has no member named `star'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:559:16: error: `CPUX86State' has no member named `tsc'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c: In function `kvm_arch_pre_run':
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:618:13: error: `CPUX86State' has no member named `eflags'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:618:24: error: `IF_MASK' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c: In function `kvm_arch_post_run':
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:650:12: error: `CPUX86State' has no member named `eflags'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:650:24: error: `IF_MASK' undeclared (first use in this function)
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:652:12: error: `CPUX86State' has no member named `eflags'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:654:5: warning: implicit declaration of function `cpu_set_apic_tpr'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c: In function `kvm_handle_halt':
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:663:15: error: `CPUX86State' has no member named `eflags'
/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c:663:26: error: `IF_MASK' undeclared (first use in this function)
make[3]: *** [kvm.o] Error 1
make[2]: *** [subdir-i386-dm] Error 2
make[1]: *** [subdir-all-ioemu-dir] Error 2
make: *** [subdirs-all] Error 2
'

Quick fix: goto dir "target-i386" and perform:

myname@linux-bvhg:~/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386> gcc -I. -I.. -I/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386 -I/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir -MMD -MT kvm.o -MP -DNEED_CPU_H -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -I/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/tcg -I/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/tcg/x86_64 -I/home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/fpu  -DHAS_AUDIO -DHAS_AUDIO_CHOICE -DHAS_AUDIO -I/home/myname/src/xen-4.0-testing.hg//tools/libxc -I/home/myname/src/xen-4.0-testing.hg//tools/xenstore -I/home/myname/src/xen-4.0-testing.hg//tools/include -I/home/myname/src/xen-4.0-testing.hg//tools/blktap/lib -mtune=core2 -msse3 -O2 -m64 -mfpmath=sse -ffast-math -O2 -fomit-frame-pointer -m64 
 -fno-strict-aliasing -std=gnu99 -Wall -Wstrict-prototypes -Wno-unused-value -Wdeclaration-after-statement  -D__XEN_TOOLS__ -MMD -MF .subdirs-all.d  -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE  -O2 -fomit-frame-pointer -m64 -fno-strict-aliasing -std=gnu99 -Wall  -Wstrict-prototypes -Wno-unused-value -Wdeclaration-after-statement  -D__XEN_TOOLS__ -MMD -MF .ioemu-dir-find.d  -D_LARGEFILE_SOURCE -D_LARGEFILE64 _SOURCE  -O2 -g -fno-strict-aliasing -Wall -Wundef -W endif-labels -Wwrite-strings -Wmissing-prototypes -Wstrict-prototypes -Wredundant-decls -O2 -fomit-frame-pointer -m64 -fno-strict-aliasing -std=gnu99 -Wall -Wstrict-prototypes -Wno-unused-value -Wdeclaration-after-statement  -D__XEN_TOOLS__ -MMD -MF .kvm.o.d  -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE  -Wno-unused -Wno-declaration-after-statement -Wno-pointer-sign  -DCONFIG_PASSTHROUGH  -I../hw  -m64 -Wno-unused -Wno-declaration-after-statement -Wno-pointer-sign  -DCONFIG_PASSTHROUGH   -c -o kvm.o /home/myname/src/xen-4.0-testing.hg/tools/ioemu-dir/target-i386/kvm.c

Xen Installation & Compilation


Installation from source

Xen 4.0 source code mercurial (hg) repository and changelog: http://xenbits.xen.org/xen-4.0-testing.hg
You can get Xen 4.0 with mercurial using the following command:
hg clone http://xenbits.xen.org/xen-4.0-testing.hg
Note that this will give you the LATEST version in xen-4.0-testing.hg repository! It might be a release candidate for next release or just some developer snapshot. See the changelog above for current status. You can also get a specific 'tag' from the repository like this:
hg clone -r RELEASE-4.0.1 http://xenbits.xen.org/xen-4.0-testing.hg
Alternatively you can download the Xen 4.0.x source tarball from http://www.xen.org/products/xen_source.html . Note that if you're planning to use Xen 4.0.0 tarball please see the Known Issues below for a note about supported pvops dom0 kernel versions.
NOTE!! during the Xen build process outbound git-protocol needs to be open in your network firewall! Xen build scripts need to access git:// repositories on git.kernel.org and xenbits.xen.org. Some people have reported issues accessing the remote repositories - these problems are most often caused by a broken Internet connection, broken firewall, or a broken NAT router you use.
This example will only build the new Xen 4.0 hypervisor and tools. This method does NOT download or build a (dom0) kernel from the xen.git repository. "make tools" part will download the xen qemu-dm ioemu for hvm guests from xenbits git repository and tools tarballs (unless you've already downloaded them yourself before building).
cd xen-4.0-testing.hg 
make xen 
make tools 
make stubdom
When the compilation process finishes you'll have the Xen hypervisor/tools binaries in "dist/" directory ready for installation:
make install-xen 
make install-tools 
make install-stubdom
And then compile your chosen new dom0 kernel, or use your existing dom0 kernel. Also update grub.conf to use the newly installed Xen 4.0 hypervisor.
See XenDom0Kernels wiki page for information about all the available Xen Dom0 capable kernels, and XenParavirtOps wiki page for more detailed information about Xen pvops dom0 kernels.
You can also compile Xen 4.0 together with the new default pvops dom0 kernel (Linux 2.6.32.x in Xen 4.0.1 and newer versions). This method downloads the kernel sources from xen.git repository during the build process:
make world
This will download the latest pvops dom0 kernel 2.6.32.x from Jeremy's xen.git repository during the build process. See the XenParavirtOps wiki page for more information about different pvops dom0 kernel versions. Also see the Known Issues below for supported pvops dom0 kernel versions.
NOTE about the old Xenlinux linux-2.6.18-xen kernels:
make kernels KERNELS="linux-2.6-xen0 linux-2.6-xenU"

Xen compilation

When I was trying to compile Xen-4.0.1, I got these messages:

make[1]: Entering directory `/xen-4.0-testing.hg/xen'
make -f Rules.mk _install
make[2]: Entering directory `/xen-4.0-testing.hg/xen'
make -C tools
make[3]: Entering directory `/xen-4.0-testing.hg/xen/tools'
[ -d figlet ] && make -C figlet
make[4]: Entering directory `/xen-4.0-testing.hg/xen/tools/figlet'
make[4]: `figlet' is up to date.
make[4]: Leaving directory `/xen-4.0-testing.hg/xen/tools/figlet'
make symbols
make[4]: Entering directory `/xen-4.0-testing.hg/xen/tools'
make[4]: `symbols' is up to date.
make[4]: Leaving directory `/xen-4.0-testing.hg/xen/tools'
make[3]: Leaving directory `/xen-4.0-testing.hg/xen/tools'
make -f /xen-4.0-testing.hg/xen/Rules.mk include/xen/compile.h
make[3]: Entering directory `/xen-4.0-testing.hg/xen'
 __  __            _  _    ___   ____              _                   
 \ \/ /___ _ __   | || |  / _ \ |___ \    _ __ ___/ |   _ __  _ __ ___ 
  \  // _ \ '_ \  | || |_| | | |  __) |__| '__/ __| |__| '_ \| '__/ _ \
  /  \  __/ | | | |__   _| |_| | / __/|__| | | (__| |__| |_) | | |  __/
 /_/\_\___|_| |_|    |_|(_)___(_)_____|  |_|  \___|_|  | .__/|_|  \___|
                                                       |_|             
make[3]: Leaving directory `/xen-4.0-testing.hg/xen'
[ -e include/asm ] || ln -sf asm-x86 include/asm
make -f /xen-4.0-testing.hg/xen/Rules.mk -C include
make[3]: Entering directory `/xen-4.0-testing.hg/xen/include'
make[3]: Nothing to be done for `all'.
make[3]: Leaving directory `/xen-4.0-testing.hg/xen/include'
make -f /xen-4.0-testing.hg/xen/Rules.mk -C arch/x86 asm-offsets.s
make[3]: Entering directory `/xen-4.0-testing.hg/xen/arch/x86'
make[3]: `asm-offsets.s' is up to date.
make[3]: Leaving directory `/xen-4.0-testing.hg/xen/arch/x86'
make -f /xen-4.0-testing.hg/xen/Rules.mk include/asm-x86/asm-offsets.h
make[3]: Entering directory `/xen-4.0-testing.hg/xen'
make[3]: `include/asm-x86/asm-offsets.h' is up to date.
make[3]: Leaving directory `/xen-4.0-testing.hg/xen'
make -f /xen-4.0-testing.hg/xen/Rules.mk -C arch/x86 /xen-4.0-testing.hg/xen/xen
make[3]: Entering directory `/xen-4.0-testing.hg/xen/arch/x86'
make -f /xen-4.0-testing.hg/xen/Rules.mk -C /xen-4.0-testing.hg/xen/arch/x86/boot built_in.o
make[4]: Entering directory `/xen-4.0-testing.hg/xen/arch/x86/boot'
RELOC=0x7c000 XEN_BITSPERLONG=64 make -f build32.mk reloc.S
make[5]: Entering directory `/xen-4.0-testing.hg/xen/arch/x86/boot'
make[5]: *** ../../../../.config: Is a directory.  Stop.
make[5]: Leaving directory `/xen-4.0-testing.hg/xen/arch/x86/boot'
make[4]: *** [reloc.S] Error 2
make[4]: Leaving directory `/xen-4.0-testing.hg/xen/arch/x86/boot'
make[3]: *** [/xen-4.0-testing.hg/xen/arch/x86/boot/built_in.o] Error 2
make[3]: Leaving directory `/xen-4.0-testing.hg/xen/arch/x86'
make[2]: *** [/xen-4.0-testing.hg/xen/xen] Error 2
make[2]: Leaving directory `/xen-4.0-testing.hg/xen'
make[1]: *** [install] Error 2
make[1]: Leaving directory `/xen-4.0-testing.hg/xen'
make: *** [install-xen] Error 2

The message showed me that it was expecting the .config exist in the root folder. I copied the file from /usr/src/linux (kernel source) and recompile. it worked!

USB plug-in rule for TI MSP-EXP43xx LaunchPad Kit

Content of file /etc/udev/rules.d/udev/46-TI_launchpad.rules:

ATTRS{idVendor}=="0451", ATTRS{idProduct}=="2036", MODE="0660", GROUP="plugdev"
ATTRS{idVendor}=="0451", ATTRS{idProduct}=="F432", MODE="0660", GROUP="plugdev"

Friday, October 29, 2010

Script to remove tailing "(00)" in filenames

#!/usr/bin/tclsh

foreach f [glob *.*] {
    if {[regexp -all -nocase {(.*)\.(.*)} $f dummy fullname ext] } {
        if { [regexp -all -nocase {(.*)\(00\)} $fullname dummy name ] } {
             set cmd "file rename -force \"$f\" \"$name.$ext\""
             puts $cmd
             eval $cmd
        }
    }
}

Thursday, October 28, 2010

To find function declaration in static library

The following command finds a reference to function "gtk_widget_get_pango_context" in static library libwxOil.a:

linux-bvhg:~/> nm -l -C libwxOil.a  | grep gtk_widget_get_pango_context
                 U gtk_widget_get_pango_context(_GtkWidget*)  /home/myname/src/XaraLX/wxOil/ftfonts.cpp:868

GLIB and wxWidget Class conflict

When compiling XaraLX, there is a conflict between GLIB-2.0 and  wxWidget 2.8 as shown below:

/usr/local/include/glib-2.0/gio/giotypes.h:127:47: error: conflicting declaration `typedef struct _GSocket GSocket'
/usr/include/wx-2.8/wx/unix/gsockunx.h:41:1: error: `class GSocket' has a previous declaration as `class GSocket'

The quick solution is to modify <XaraLX directory>/wxOil/ftfonts.cpp.  Edit this file and change from:

#ifdef __WXGTK20__
#include <gtk/gtk.h>
extern GtkWidget *wxGetRootWindow();
#endif

to:

#ifdef __WXGTK20__
//#include <gtk/gtk.h>
extern PangoContext *gtk_widget_get_pango_context    (GtkWidget   *widget);
extern GtkWidget *wxGetRootWindow();
#endif

Microsoft is officially all out to promote Windows 7 mobile

Check this out:

http://create.msdn.com/en-US/home/about/how_it_works_create
http://www.microsoft.com/downloads/en/details.aspx?FamilyID=04704acf-a63a-4f97-952c-8b51b34b00ce&displaylang=en
https://microsoft.promo.eprize.com/windowsphone7/

Thursday, October 14, 2010

To find dependency in Linux dynamic object file/library

linux-bvhg:~> objdump -x `which ffmpeg`

/usr/local/bin/ffmpeg:     file format elf64-x86-64
/usr/local/bin/ffmpeg
architecture: i386:x86-64, flags 0x00000112:
EXEC_P, HAS_SYMS, D_PAGED
start address 0x0000000000405360

Program Header:
PHDR off    0x0000000000000040 vaddr 0x0000000000400040 paddr 0x0000000000400040 align 2**3
filesz 0x00000000000001f8 memsz 0x00000000000001f8 flags r-x
INTERP off    0x0000000000000238 vaddr 0x0000000000400238 paddr 0x0000000000400238 align 2**0
filesz 0x000000000000001c memsz 0x000000000000001c flags r--
LOAD off    0x0000000000000000 vaddr 0x0000000000400000 paddr 0x0000000000400000 align 2**21
filesz 0x0000000000017124 memsz 0x0000000000017124 flags r-x
LOAD off    0x00000000000179c8 vaddr 0x00000000006179c8 paddr 0x00000000006179c8 align 2**21
filesz 0x0000000000001e18 memsz 0x00000000000038a0 flags rw-
DYNAMIC off    0x0000000000018d10 vaddr 0x0000000000618d10 paddr 0x0000000000618d10 align 2**3
filesz 0x0000000000000240 memsz 0x0000000000000240 flags rw-
NOTE off    0x0000000000000254 vaddr 0x0000000000400254 paddr 0x0000000000400254 align 2**2
filesz 0x000000000000005c memsz 0x000000000000005c flags r--
EH_FRAME off    0x0000000000015db0 vaddr 0x0000000000415db0 paddr 0x0000000000415db0 align 2**2
filesz 0x0000000000000304 memsz 0x0000000000000304 flags r--
STACK off    0x0000000000000000 vaddr 0x0000000000000000 paddr 0x0000000000000000 align 2**3
filesz 0x0000000000000000 memsz 0x0000000000000000 flags rw-
RELRO off    0x00000000000179c8 vaddr 0x00000000006179c8 paddr 0x00000000006179c8 align 2**0
filesz 0x0000000000001638 memsz 0x0000000000001638 flags r--

Dynamic Section:
NEEDED               libavdevice.so.52
NEEDED               libavfilter.so.1
NEEDED               libavformat.so.52
NEEDED               libavcodec.so.52
NEEDED               libpostproc.so.51
NEEDED               libswscale.so.0
NEEDED               libavcore.so.0
NEEDED               libavutil.so.50
NEEDED               libpthread.so.0
NEEDED               libm.so.6
NEEDED               libc.so.6
INIT                 0x0000000000404670
FINI                 0x00000000004124e8
HASH                 0x00000000004002b0
GNU_HASH             0x0000000000400960
STRTAB               0x0000000000401f48
SYMTAB               0x00000000004009d0
STRSZ                0x0000000000000f0d
SYMENT               0x0000000000000018
DEBUG                0x0000000000000000
PLTGOT               0x0000000000618fe8
PLTRELSZ             0x0000000000001320
PLTREL               0x0000000000000007
JMPREL               0x0000000000403350
RELA                 0x00000000004031a0
RELASZ               0x00000000000001b0
RELAENT              0x0000000000000018
VERNEED              0x0000000000403020
VERNEEDNUM           0x000000000000000b
VERSYM               0x0000000000402e56

Version References:
required from libpostproc.so.51:
0x0826df11 0x00 14 LIBPOSTPROC_51
required from libavcore.so.0:
0x0a34bd40 0x00 12 LIBAVCORE_0
required from libm.so.6:
0x09691a75 0x00 11 GLIBC_2.2.5
required from libavfilter.so.1:
0x0ececed1 0x00 10 LIBAVFILTER_1
required from libavdevice.so.52:
0x07b11f22 0x00 09 LIBAVDEVICE_52
required from libavcodec.so.52:
0x035ff8b2 0x00 08 LIBAVCODEC_52
required from libavutil.so.50:
0x0f818430 0x00 07 LIBAVUTIL_50
required from libswscale.so.0:
0x027973e0 0x00 05 LIBSWSCALE_0
required from libavformat.so.52:
0x0c7032c2 0x00 04 LIBAVFORMAT_52
required from libpthread.so.0:
0x09691a75 0x00 03 GLIBC_2.2.5
required from libc.so.6:
0x0d696917 0x00 13 GLIBC_2.7
0x0d696913 0x00 06 GLIBC_2.3
0x09691a75 0x00 02 GLIBC_2.2.5

Sections:
Idx Name          Size      VMA               LMA               File off  Algn
0 .interp       0000001c  0000000000400238  0000000000400238  00000238  2**0
CONTENTS, ALLOC, LOAD, READONLY, DATA
1 .note.ABI-tag 00000020  0000000000400254  0000000000400254  00000254  2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
2 .note.SuSE    00000018  0000000000400274  0000000000400274  00000274  2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
3 .note.gnu.build-id 00000024  000000000040028c  000000000040028c  0000028c  2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
4 .hash         000006b0  00000000004002b0  00000000004002b0  000002b0  2**3
CONTENTS, ALLOC, LOAD, READONLY, DATA
5 .gnu.hash     0000006c  0000000000400960  0000000000400960  00000960  2**3
CONTENTS, ALLOC, LOAD, READONLY, DATA
6 .dynsym       00001578  00000000004009d0  00000000004009d0  000009d0  2**3
CONTENTS, ALLOC, LOAD, READONLY, DATA
7 .dynstr       00000f0d  0000000000401f48  0000000000401f48  00001f48  2**0
CONTENTS, ALLOC, LOAD, READONLY, DATA
8 .gnu.version  000001ca  0000000000402e56  0000000000402e56  00002e56  2**1
CONTENTS, ALLOC, LOAD, READONLY, DATA
9 .gnu.version_r 00000180  0000000000403020  0000000000403020  00003020  2**3
CONTENTS, ALLOC, LOAD, READONLY, DATA
10 .rela.dyn     000001b0  00000000004031a0  00000000004031a0  000031a0  2**3
CONTENTS, ALLOC, LOAD, READONLY, DATA
11 .rela.plt     00001320  0000000000403350  0000000000403350  00003350  2**3
CONTENTS, ALLOC, LOAD, READONLY, DATA
12 .init         00000018  0000000000404670  0000000000404670  00004670  2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
13 .plt          00000cd0  0000000000404688  0000000000404688  00004688  2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
14 .text         0000d188  0000000000405360  0000000000405360  00005360  2**4
CONTENTS, ALLOC, LOAD, READONLY, CODE
15 .fini         0000000e  00000000004124e8  00000000004124e8  000124e8  2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
16 .rodata       000038b0  0000000000412500  0000000000412500  00012500  2**4
CONTENTS, ALLOC, LOAD, READONLY, DATA
17 .eh_frame_hdr 00000304  0000000000415db0  0000000000415db0  00015db0  2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
18 .eh_frame     0000106c  00000000004160b8  00000000004160b8  000160b8  2**3
CONTENTS, ALLOC, LOAD, READONLY, DATA
19 .ctors        00000010  00000000006179c8  00000000006179c8  000179c8  2**3
CONTENTS, ALLOC, LOAD, DATA
20 .dtors        00000010  00000000006179d8  00000000006179d8  000179d8  2**3
CONTENTS, ALLOC, LOAD, DATA
21 .jcr          00000008  00000000006179e8  00000000006179e8  000179e8  2**3
CONTENTS, ALLOC, LOAD, DATA
22 .data.rel.ro  00001310  0000000000617a00  0000000000617a00  00017a00  2**5
CONTENTS, ALLOC, LOAD, DATA
23 .dynamic      00000240  0000000000618d10  0000000000618d10  00018d10  2**3
CONTENTS, ALLOC, LOAD, DATA
24 .got          00000098  0000000000618f50  0000000000618f50  00018f50  2**3
CONTENTS, ALLOC, LOAD, DATA
25 .got.plt      00000678  0000000000618fe8  0000000000618fe8  00018fe8  2**3
CONTENTS, ALLOC, LOAD, DATA
26 .data         00000180  0000000000619660  0000000000619660  00019660  2**5
CONTENTS, ALLOC, LOAD, DATA
27 .bss          00001a88  00000000006197e0  00000000006197e0  000197e0  2**5
ALLOC
28 .comment.SUSE.OPTs 00000006  0000000000000000  0000000000000000  000197e0  2**0
CONTENTS, READONLY
29 .comment      00000042  0000000000000000  0000000000000000  000197e6  2**0
CONTENTS, READONLY
SYMBOL TABLE:
no symbols


Tuesday, October 12, 2010

To test Prime Number

#include <stdio.h>


typedef enum {
    FALSE = 0,
    TRUE = 1
} BOOL;

char *boolstr[] = {"FALSE", "TRUE"};

BOOL is_even(unsigned int k)
{
    if (k % 2) return FALSE;
    return TRUE;
}

BOOL is_prime(unsigned long k, unsigned long *divisor)
{
    unsigned long testnum,testlimit;
    BOOL ret = FALSE;

    if (k == 1) return FALSE; // 1 is neigher prime neither composite
    if (k == 2) return TRUE;
    if (is_even(k)) return FALSE; // even numbers are never prime, except 2
    testlimit = k;
    testnum = 3;
    while (testnum < testlimit) {
        //printf("highest prime divisor=%lu\n",*divisor);
        if ( (k % testnum) == 0)
        {
            *divisor = testnum;
            printf("div=%lu\n", *divisor);
            return FALSE; //return TRUE;
            // k is not prime as it is divisable by l

        }
        testlimit = k/testnum;
        testnum += 2;

    }
    return TRUE;
}


int main()
{
    unsigned long k,divisor;

    divisor=1;
    printf("Enter an integer: ");
    scanf("%lu", &k);
    printf("k=%lu is even? %s\n", k, boolstr[is_even(k)]);
    if (is_prime(k, &divisor))
    {
        printf("k=%lu is prime? %s\n", k, boolstr[TRUE]);
    }
    else
    {
        printf("%lu is NOT prime\n", k);
        //printf("highest prime divisor = %lu\n", divisor);
    }
}

Tuesday, October 5, 2010

3D Entertainment

While 3D televisions are more available in the stores, their price is still high and not many people are getting into it.  Perhaps because there is still few BD 3Dd movies.  But now 3D camcoders are going into the market.  We will see if this change how people buy LCD TVs.

Today, when I went to Costco, the 42" 120 Hz LED 3D TV is already below $2000.

Monday, October 4, 2010

Power consumption and Cost saving of Using Ooma (revised)

After awhile, I observed that this Ooma + router consume less power when the temperature is lower.  In the previous blog, I said the average power when its idling is 27 W @ 25 C, but in the early morning when temperature is lower (at about 20 C), the idling power is only 14 W and 17 W when the handset is off-hook.

Sunday, October 3, 2010

Power consumption and Cost saving of Using Ooma

Devices measured:


  1. Ooma hub
  2. Linksys WRT54g wireless router
  3. Traditional wired phoneset connected to Ooma


Power-meter: Kill-A-Watt EZ

Result:

  • System idle: 27 watt
  • Phone is off hook (dial tone): 30 Watt
  • Phone is dialing: 30 Watt
  • During talk: 30 Watt
  • Check voice mail tru the hub: 28 Watt


How much the electricity cost we pay monthly?
For Northern California, PGE has a chart describing the rate.  The average KWH rate for residential seasonal schedule E-8 is $0.22832 (this is just an average, the actual calculation depends on the tier/how much we consume electricity above its baseline).  So, the maximum KWH for Oma in a day is: 30 Watt * 24 hours = 720 WH = 0.72 KWH.  In a month (30 days) = 21.6 KWH or it costs = $4.32

If we don't subscribe to Ooma premier service, there is no additional cost, so it is the actual monthly cost we pay.  If we subscribe to annual Ooma premier service which $119.99/year, we end up paying: $119.99/12 + $4.32 =  $14.32 (rounded up) per month.

As a comparison, when I subscribed to AT&T landline local service (local unlimited), I paid (total, including all the fees and taxes) $27.15.  This did not include caller-ID and all other features.  It was just bare minimum.  With Ooma premier, besides we get caller-ID, we also get two lines, call forwarding (or simultaneous ringing to another number), broadband voice mail (with MP3 file can be sent to email we specified), and other features.  AT&T could have charged those features for additional $15 or more.

Now, how much we save by using Ooma?  OK, first we need to take to the account the broadband portion used for Ooma.  For example, I pay AT&T U-Verse 10 Mbps/1 Mbps (downstream/upstream) $45 a month.  In average, Ooma uses a fractional bandwidth, which is about 256 Kbps.  The max fraction of cost (hypothetically) is then = 0.256/10 * $45/month = $1.152, or about $1.2/month.  Assume we use Ooma premier, the total monthly cost is then $14.32 + 1.2 = $15.52/month.  The saving is = $27.15 - $15.52 =  $11.63/month.


The price of Ooma hub (including one Ooma scout) is $219.99 (at www.ooma.com) +sales tax (which is 9.25% in my area) or $240.34.  The number of months to recover the cost using the amount of money we save above is then $240.34/$11.63 = 20.66 months, or say 21 months (1.75 years).  After that, the saving we collect is going to our pocket.  If you decide not to use Ooma more than 1.75 years, you won't save any.

Note: the calculation above does not include power consumption of Ooma scout, but I surely is smaller than the hub's.

Wednesday, September 29, 2010

ReadyNAS Duo Internals

This very cool NAS Box runs a version of Linux (I think Debian):

nas-D0-E9-23:/c/home/admin# uname -a
Linux nas-D0-E9-23 2.6.17.8ReadyNAS #1 Tue Jun 9 13:59:28 PDT 2009 padre unknown

nas-D0-E9-23:/c/home/admin# cat /proc/cpuinfo
cpu : Infrant Technologics, Inc. - neon version: 0
fpu : Softfpu
ncpus probed : 1
ncpus active : 1
BogoMips : 186.36
MMU : version: 0
LP : HW.FW version: 0.1
FPGA : fpga000000-0 Configuration: 0
AHB arbitraion : 7
CPU id : 0
Switch : 0
ASIC : IT3107

nas-D0-E9-23:/c/home/admin# lspci
0000:00:17.0 USB Controller: VIA Technologies, Inc. VT82xxxxx UHCI USB 1.1 Controller (rev 62)
0000:00:17.1 USB Controller: VIA Technologies, Inc. VT82xxxxx UHCI USB 1.1 Controller (rev 62)
0000:00:17.2 USB Controller: VIA Technologies, Inc. USB 2.0 (rev 65)

nas-D0-E9-23:/proc# fdisk -l /dev/hdc

Disk /dev/hdc: 999.9 GB, 999991611392 bytes
255 heads, 63 sectors/track, 121575 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x00000000

Device Boot Start End Blocks Id System
/dev/hdc1 1 255 2048000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/hdc2 255 287 256000 82 Linux swap / Solaris
Partition 2 does not end on cylinder boundary.
/dev/hdc3 287 121575 974242116 5 Extended
/dev/hdc5 287 121575 974242115+ 8e Linux LVM

Compared to my HP desktop machine, this NAS Box is away slower:

processor       : 1
vendor_id       : GenuineIntel
cpu family      : 6
model           : 15
model name      : Intel(R) Core(TM)2 Quad CPU    Q6600  @ 2.40GHz
stepping        : 11
cpu MHz         : 1600.000
cache size      : 4096 KB
physical id     : 0
siblings        : 4
core id         : 1
cpu cores       : 4
apicid          : 1
initial apicid  : 1
fpu             : yes
fpu_exception   : yes
cpuid level     : 10
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dt
s acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx lm constant_tsc arch_perfmon pebs bts rep_good aper
fmperf pni dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm lahf_lm tpr_shadow vnmi flexpriori
ty
bogomips        : 12479.54
clflush size    : 64
cache_alignment : 64
address sizes   : 36 bits physical, 48 bits virtual
power management:

Despite the fact, I love this new toy!

Sunday, September 26, 2010

Useful status line in vi

:set statusline=%F%m%r%h%w\ [FORMAT=%{&ff}]\ [TYPE=%Y]\ [ASCII=\%03.3b]\ [HEX=\%02.2B]\ [POS=%04l,%04v][%p%%]\ [LEN=%L]

Tuesday, September 14, 2010

Cool Real gauge measuring your PC performance:





Google Graph

Cool way to draw gauges via Google Graph API:
http://code.google.com/apis/visualization/documentation/gallery/gauge.html

Saturday, July 17, 2010

Array of Strings

// strtok.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

char *SkipChars(char *buf, const char charToSkip)
{
    char *p = buf;
    while (p && (*p) && (*p == charToSkip)) p++;
    return p;
}


char *SkipString(char *buf, const char *str)
{
    char *p;
    p = strstr(buf, str);
    if (p) {
        p += strlen(str);
    }
    return p;
}


char *GetToken(char *buf, char *tok, int toksize)
{
char *start;
int i = 0;

start = SkipChars(buf, ' ');
while (start && (*start != 0) && (*start != ' ') && (i < toksize)) {
tok[i++] = *start;
start++;
}
tok[i] = 0;
return start;
}


int ParseLine(char *buf, char delim, char **toks, int tokSize, int n)
{
    char *start, *item;
    int i = 0;

    if ((!buf) || (!toks)) return NULL;
    start = SkipChars(buf, delim);
if (*start==0) return NULL;
while (start && (*start) && (i<n)) {
  /* convert to first-major pointer */
item = ((char *)&toks[0] + tokSize*i);
start = GetToken(start, (char *)item, tokSize);
i++;
}
    return i;
}

char *GetStringVal(char *buf, char *key, char *val, int valSize)
{
char *p = SkipString(buf, key);
if (p) {
p = GetToken(p, val, valSize);
}
return val;
}

const char desc[] = "This is just an example for skipstring function";
char res[] = "Mac             Type      Interface\n"
             "1111.2222.3333  S         fe0/0\n"
             "aabc.ddef.8754  S         fe0/0\n"
             "553a.4455.6789  D         fe0/1\n"
             "Total Macs 0\n";
char set[] = "mac-learning alarm 90 clear 60";


#define TOKEN_LEN 80
int _tmain(int argc, _TCHAR* argv[])
{
    int i,balance,len;
    char *p, *q, **pp;
    char token[100];
char tokens[3][TOKEN_LEN] = {"saya", "makan", "nasi"};

#if 0
    /* Program entry point */
    if (argc) {
        for( i=0; i<argc; i++) {
            printf("argv[%d] = %s\n", i, argv[i]);
            p = SkipChars(argv[i], ' ');
            p = SkipChars(p, '"');
            while (p) {
                if (balance) balance=0;
                 end = SkipChars(p, '"');
                 if (end) {
                    balance = 1;
                    len = end-p;
                    strncpy(token, p, len);
                    token[len] = 0;
                    printf("token=%s\n", token);
                    p = end;
                    printf("p = %s\n", p);
                }
                if ((!balance) || (!len))
                    break;
            }
        }
    }
    printf("original string: %s\n", desc);
    p = SkipString((char*)&desc[0], "an example for ");
    if (p) {
        printf("After SkipString: %s\n", p);
    }
#endif
    p = SkipString((char *)res, "Interface\n");
    if (p) {
        p = strtok(p, "\n");
        //printf("original p=%s\n", p);
        while (p) {
            if (strstr(p, "Total Mac")) break;
            printf("\n\n--------------------------------------\n");
printf("address of tokens[0][0] = %X\n", &tokens[0][0]);
//printf("q = %X\n", q);
            len = ParseLine(p, ' ', (char **)&tokens, TOKEN_LEN, 3);
for(i=0; i<len; i++) {
printf("token%d = %s\n", i+1, tokens[i]);
}
            printf("%s\n", p);
            printf("--------------------------------------\n");
            p = strtok(NULL, "\n");
        }
    }
printf("alarm=%s\n", GetStringVal(set, "alarm", token, sizeof(token)));
printf("clear=%s\n", GetStringVal(set, "clear", token, sizeof(token)));
return 0;
}