cross-plat-dev-utils/get_wordsize.pm
changeset 10 b2a53d442fd6
equal deleted inserted replaced
9:67f8bb81b054 10:b2a53d442fd6
       
     1 #!/usr/bin/perl
       
     2 # Copyright (c) 2010 Symbian Foundation Ltd
       
     3 # This component and the accompanying materials are made available
       
     4 # under the terms of the License "Eclipse Public License v1.0"
       
     5 # which accompanies this distribution, and is available
       
     6 # at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 #
       
     8 # Initial Contributors:
       
     9 # Mike Kinghan, mikek@symbian.org, for Symbian Foundation Ltd - initial contribution.
       
    10 
       
    11 # Subroutine to get the wordsize in bits of the host machine.
       
    12 
       
    13 use strict;
       
    14 use File::Path;
       
    15 use File::Spec;
       
    16 use check_os;
       
    17 use places;
       
    18 
       
    19 sub get_host_wordsize()
       
    20 {
       
    21 	if (os_is_windows()) {
       
    22 		print ">>> Only 32bit Windows supported\n";
       
    23 		return 32;
       
    24 	} 
       
    25 	my $source = "get_wordsize.c";
       
    26 	unless(-f "$source") {
       
    27 		die "*** Error: $source not found ***";
       
    28 	}
       
    29 	my $compile_cmd = "gcc -o get_wordsize $source";
       
    30 	print ">>> Excuting: $compile_cmd\n";
       
    31 	system($compile_cmd) >> 8 and die "*** Error: Could not compile $source ***";
       
    32 	my $get_wordsize = "\.\/get_wordsize";
       
    33 	print ">>> Excuting: $get_wordsize\n";
       
    34 	my $wordsize = `$get_wordsize`;
       
    35 	chomp $wordsize;
       
    36 	die "$!", if ($? >> 8);
       
    37 	$wordsize *= 8;
       
    38 	print ">>> Host system wordsize is $wordsize bits\n";
       
    39 	unlink("get_wordsize") or die $!;
       
    40 	return $wordsize;
       
    41 }
       
    42 
       
    43 1;
       
    44