GCC-Builtins

 view release on metacpan or  search on metacpan

sbin/build-gcc-builtins-package.pl  view on Meta::CPAN


#ifndef __has_builtin
#error "Your compiler does not support builtin functions, note this is a naive and lame test."
#endif

typedef __int128 int128_t;
typedef unsigned __int128 uint128_t;

MODULE = GCC::Builtins  PACKAGE = GCC::Builtins
PROTOTYPES: ENABLE

 # The following XS code has been automatically generated:

EOP

my $T_CONTENTS =<<'EOP';
#!perl
use 5.006;
use strict;
use warnings;
use Test::More;

our $VERSION = '0.06';

use GCC::Builtins qw/:all/;

<% test_func_run %>
<% test_func_is_ok %>

done_testing();
EOP

# Copy here expected results, all are covered anyway
# Some versions complain that expected was Inf but 'inf' was returned
my %T_EXPECTED_RESULTS = (
	'FUNCTION' => 'XS_GCC__Builtins_FUNCTION',
	'bswap16' => '512',
	'bswap32' => '33554432',
	'bswap64' => '144115188075855872',
	'clrsb' => '29',
	'clrsbl' => '61',
	'clrsbll' => '61',
	'clz' => '30',
	'clzl' => '62',
	'clzll' => '62',
	'ctz' => '1',
	'ctzl' => '1',
	'ctzll' => '1',
	'ffs' => '2',
	'ffsl' => '2',
	'ffsll' => '2',
	'huge_val' => 'Inf',
	'huge_valf' => 'Inf',
	'huge_vall' => 'Inf',
	'inf' => 'Inf',
	'infd32' => 'Inf',
	'infd64' => 'Inf',
	'infd128' => 'Inf',
	'inff' => 'Inf',
	'infl' => 'Inf',
	'nan' => 'NaN',
	'nanl' => 'NaN',
	'nanf' => 'NaN',
	'parity' => '1',
	'parityl' => '1',
	'parityll' => '1',
	'popcount' => '1',
	'popcountl' => '1',
	'popcountll' => '1',
	'powi' => '6.5536',
	'powil' => '4',
	'powif' => '6.55359983444214',
);

# add some types to the typemap
my %TYPEMAP;
for my $atype (sort keys %CTYPES){
	my $mapsto;
	if( $atype =~ /^int_(.+?)_t/ ){
		$mapsto = 'T_IV';
	} elsif( $atype =~ /^int(\d+)_t/ ){
		$mapsto = 'T_IV';
	} elsif( $atype =~ /^uint(\d+)_t/ ){
		$mapsto = 'T_UV';
	} elsif( $atype =~ /^uint_.+?_t/ ){
		$mapsto = 'T_UV';
	} elsif( $atype =~ /^int(:?max|fast)_t/ ){
		$mapsto = 'T_IV';
	} elsif( $atype =~ /^uint(:?max|fast)_t/ ){
		$mapsto = 'T_UV';
	} elsif( $atype =~ /^int\d+_t/ ){
		$mapsto = 'T_IV';
	} elsif( $atype =~ /^uint\d+_t/ ){
		$mapsto = 'T_UV';
	} elsif( $atype =~ /^int(:?ptr)_t/ ){
		$mapsto = 'T_PTR';
	} else {
		#die "unhandled type '$atype', fix me";
		next;
	}
	$TYPEMAP{$atype} = $mapsto;
}
for my $am ('const'){
	for my $at ('void'){
		my $al = $am.' '.$at.' *'; $al =~ s/^\s+//;
		$TYPEMAP{$al} = 'T_PTR';
	}
}
for my $am ('_Decimal'){
	for my $at ('32', '64', '128'){
		my $al = $am.$at;
		$TYPEMAP{$al} = 'T_DOUBLE';
	}
}
$TYPEMAP{'long double'} = 'T_DOUBLE';
$TYPEMAP{'long long'} = 'T_LONG';
$TYPEMAP{'unsigned long long'} = 'T_U_LONG';

my ($content, $FH);
if( defined($GCC_Builtins_HTML_filename)
 && (-f $GCC_Builtins_HTML_filename)
){
	open($FH, '<', $GCC_Builtins_HTML_filename) or die "error, failed to open input file '$GCC_Builtins_HTML_filename': $!";



( run in 1.465 second using v1.01-cache-2.11-cpan-0fb53d1c279 )