Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

h2ph `extern inline' problems #7841

Closed
p5pRT opened this issue Mar 19, 2005 · 6 comments
Closed

h2ph `extern inline' problems #7841

p5pRT opened this issue Mar 19, 2005 · 6 comments

Comments

@p5pRT
Copy link

p5pRT commented Mar 19, 2005

Migrated from rt.perl.org#34493 (status was 'resolved')

Searchable as RT34493$

@p5pRT
Copy link
Author

p5pRT commented Mar 19, 2005

From at@altlinux.ru

Created by at@altlinux.org

Hello,

h2ph fails to convert the following simple header file.

$ cat asm/unistd.h
#ifndef _ASM_X86_64_UNISTD_H_
#define _ASM_X86_64_UNISTD_H_

extern inline long exit(int error_code)
{
  sys_exit(error_code);
}

#endif
$

Please note that its location under asm/ directory is essential.

$ h2ph -d . asm/unistd.h
asm/unistd.h -> asm/unistd.ph
$ perl -c asm/unistd.ph
Missing right curly or square bracket at asm/unistd.ph line 7, at end of line
syntax error at asm/unistd.ph line 7, at EOF
asm/unistd.ph had compilation errors.
$ cat asm/unistd.ph
require '_h2ph_pre.ph';

no warnings 'redefine';

unless(defined(&_ASM_X86_64_UNISTD_H_)) {
  eval 'sub _ASM_X86_64_UNISTD_H_ () {1;}' unless defined(&_ASM_X86_64_UNISTD_H_);
1;
$

--
Alexey Tourbin
ALT Linux Team

Perl Info

Flags:
    category=utilities
    severity=low

Site configuration information for perl v5.8.6:

Configured by ALT Linux Team at Fri Mar 11 15:59:16 MSK 2005.

Summary of my perl5 (revision 5 version 8 subversion 6) configuration:
  Platform:
    osname=linux, osvers=2.4.20-alt7-up, archname=i386-linux-thread-multi
    uname='linux solemn.turbinal.org 2.4.20-alt7-up #1 fri mar 14 14:57:05 msk 2003 i686 unknown unknown gnulinux '
    config_args='-de -rs -Darchname=i386-linux -Dd_dosuid -Ud_csh -Dlibswanted=dl m c crypt db ndbm gdbm -Duseshrplib -Dlibperl=libperl.so.5.8 -Dcc=gcc -Doptimize=-pipe -Wall -Os -march=i686 -D_GNU_SOURCE -momit-leaf-frame-pointer -Dcccdlflags=-fPIC -DPIC -Dccdlflags=-rdynamic -Wl,-O1 -Dlddlflags=-shared -Wl,-O1 -Dldflags=-Wl,-O1 -Dprefix=/usr -Dprivlib=/usr/lib/perl5 -Darchlib=/usr/lib/perl5/i386-linux -Dvendorprefix=/usr -Dvendorlib=/usr/lib/perl5/vendor_perl -Dvendorarch=/usr/lib/perl5/vendor_perl/i386-linux -Dman1dir=/usr/share/man/man1 -Dman3dir=/usr/share/man/man3 -Dvendorman1dir=/usr/share/man/man1 -Dvendorman3dir=/usr/share/man/man3 -Dsiteprefix=/usr/local -Dsitelib=/usr/local/lib/perl5/site_perl/5.8.6 -Dsitearch=/usr/local/lib/perl5/site_perl/5.8.6/i386-linux -Dsiteman1dir=/usr/local/man/man1 -Dsite_man3dir=/usr/local/man/man3 -Dcf_by=ALT Linux Team -Dcf_email=qa@altlinux.org -Dmyhostname=localhost -Dperladmin=root@localhost -Dmyuname=Linux 2.4.20-alt7-up i686 -Dnewmyuname=Linux 2.4.20-alt7-up i686 -Dinc_version_list=5.8.5/i386-linux 5.8.4/i386-linux 5.8.3/i386-linux 5.8.2/i386-linux 5.8.1/i386-linux 5.8.0/i386-linux 5.8.5 5.8.4 5.8.3 5.8.2 5.8.1 5.8.0 5.6.1 5.6.0 -Dpager=/usr/bin/less -isR -Di_shadow -Di_syslog -Dusethreads -Duseithreads -Duselargefiles -Di_db -Di_gdbm -Di_ndbm -Di_sdbm -Ui_odbm'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=define use5005threads=undef useithreads=define usemultiplicity=define
    useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=undef use64bitall=undef uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='gcc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm',
    optimize='-pipe -Wall -Os -march=i686 -D_GNU_SOURCE -momit-leaf-frame-pointer',
    cppflags='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -fno-strict-aliasing -pipe -I/usr/local/include -I/usr/include/gdbm'
    ccversion='', gccversion='3.3.3 20040412 (ALT Linux, build 3.3.3-alt5)', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=4, prototype=define
  Linker and Libraries:
    ld='gcc', ldflags ='-Wl,-O1 -L/usr/local/lib64 -L/usr/local/lib'
    libpth=/usr/local/lib64 /usr/local/lib /lib64 /usr/lib64 /lib /usr/lib
    libs=-ldl -lm -lpthread -lc -lcrypt -ldb -lgdbm
    perllibs=-ldl -lm -lpthread -lc -lcrypt
    libc=/lib/libc-2.3.3.so, so=so, useshrplib=true, libperl=libperl.so.5.8
    gnulibc_version='2.3.3'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic -Wl,-O1'
    cccdlflags='-fPIC -DPIC', lddlflags='-shared -Wl,-O1 -L/usr/local/lib64 -L/usr/local/lib'

Locally applied patches:
    


@INC for perl v5.8.6:
    /etc/perl5
    /usr/lib/perl5/i386-linux
    /usr/lib/perl5
    /usr/local/lib/perl5/site_perl/5.8.6/i386-linux
    /usr/local/lib/perl5/site_perl/5.8.6
    /usr/local/lib/perl5/site_perl/5.8.4/i386-linux
    /usr/local/lib/perl5/site_perl/5.8.2/i386-linux
    /usr/local/lib/perl5/site_perl/5.8.1/i386-linux
    /usr/local/lib/perl5/site_perl/5.8.4
    /usr/local/lib/perl5/site_perl/5.8.2
    /usr/local/lib/perl5/site_perl/5.8.1
    /usr/local/lib/perl5/site_perl/5.6.1
    /usr/local/lib/perl5/site_perl
    /usr/lib/perl5/vendor_perl/i386-linux
    /usr/lib/perl5/vendor_perl
    /usr/lib/perl5/vendor_perl
    .


Environment for perl v5.8.6:
    HOME=/home/at
    LANG=C
    LANGUAGE (unset)
    LC_COLLATE=ru_RU.CP1251
    LC_CTYPE=ru_RU.CP1251
    LC_MESSAGES=C
    LC_MONETARY=ru_RU.CP1251
    LC_NUMERIC=ru_RU.CP1251
    LC_TIME=C
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/home/at/bin:/bin:/usr/bin:/usr/X11R6/bin:/usr/local/bin:/usr/games:/sbin:/usr/sbin:/usr/local/sbin:/usr/lib/qt3/bin
    PERL_BADLANG (unset)
    SHELL=/bin/zsh

@p5pRT
Copy link
Author

p5pRT commented Mar 19, 2005

From at@altlinux.ru

On Sat, Mar 19, 2005 at 12​:24​:37PM -0000, Alexey Tourbin wrote​:

h2ph fails to convert the following simple header file.

$ cat asm/unistd.h
#ifndef _ASM_X86_64_UNISTD_H_
#define _ASM_X86_64_UNISTD_H_

extern inline long exit(int error_code)
{
sys_exit(error_code);
}

#endif
$

Please note that its location under asm/ directory is essential.

And even the following simple header file suffers wrong conversion​:

$ cat test.h
#ifndef TEST_H
#define TEST_H
#ifdef __LANGUAGE_PASCAL__
#endif
#endif
$

Note that asm/ location is unrelated for this time.

$ h2ph -d . test.h
test.h -> test.ph
$ perl -c test.ph
Missing right curly or square bracket at test.ph line 7, at end of line
syntax error at test.ph line 7, at EOF
test.ph had compilation errors.
$ cat test.ph
require '_h2ph_pre.ph';

no warnings 'redefine';

unless(defined(&TEST_H)) {
  eval 'sub TEST_H () {1;}' unless defined(&TEST_H);
1;
$

The problem seems to be inside next_line()​:

  READ​: while (not eof IN) {
  $in .= <IN>;
  chomp $in;
  next unless length $in;

  while (length $in) {
  ...
  if ($in =~ /^\#ifdef __LANGUAGE_PASCAL__/) {
  # Tru64 disassembler.h evilness​: mixed C and Pascal.
  while (<IN>) {
  last if /^\#endif/;
  }
  next READ;
  }
  if ($in =~ /^extern inline / && # Inlined assembler.
  $^O eq 'linux' && $file =~ m!(?​:^|/)asm/[^/]+\.h$!) {
  while (<IN>) {
  last if /^}/;
  }
  next READ;
  }

The problem is that $in varialbe is not reset and "if" conditons hold
true till the end of file. Here is a patch (which has not been tested
yet, but seems to be reasonable offhand).

Inline Patch
--- perl-5.9.2.24046/utils/h2ph.PL-	2005-01-30 15:19:00 +0000
+++ perl-5.9.2.24046/utils/h2ph.PL	2005-03-19 13:32:26 +0000
@@ -556,6 +556,7 @@ sub next_line
 		while (<IN>) {
 		    last if /^\#endif/; 
 		}
+		$in = "";
 		next READ;
 	    }
 	    if ($in =~ /^extern inline / && # Inlined assembler.
@@ -563,6 +564,7 @@ sub next_line
  		while (<IN>) {
 		    last if /^}/; 
 		}
+		$in = "";
 		next READ;
 	    }
             if ($in =~ s/\\$//) {                           # \-newline

End of patch

$ h2ph -d . asm/unistd.h
asm/unistd.h -> asm/unistd.ph
$ perl -c asm/unistd.ph
Missing right curly or square bracket at asm/unistd.ph line 7, at end of line
syntax error at asm/unistd.ph line 7, at EOF
asm/unistd.ph had compilation errors.
$ cat asm/unistd.ph
require '_h2ph_pre.ph';

no warnings 'redefine';

unless(defined(&_ASM_X86_64_UNISTD_H_)) {
eval 'sub _ASM_X86_64_UNISTD_H_ () {1;}' unless defined(&_ASM_X86_64_UNISTD_H_);
1;
$

--
Alexey Tourbin
ALT Linux Team

@p5pRT
Copy link
Author

p5pRT commented Mar 19, 2005

From at@altlinux.ru

On Sat, Mar 19, 2005 at 04​:37​:12PM +0300, Alexey Tourbin wrote​:

The problem is that $in varialbe is not reset and "if" conditons hold
true till the end of file. Here is a patch (which has not been tested
yet, but seems to be reasonable offhand).

Here is a test that fails with the existing h2ph and passes with my
proposed change to h2ph. (It is only about Tru64 Pascal; unfortunatelly,
there's no easy way to test /^extern inline/ constructs as the desired
effect depends on file location.)

PS​: please fix my English wherever applicable.

Inline Patch
--- perl-5.9.2.24046/t/lib/h2ph.h-	2003-03-13 22:07:49 +0000
+++ perl-5.9.2.24046/t/lib/h2ph.h	2005-03-19 14:08:07 +0000
@@ -56,6 +56,11 @@
 #    define WHATEVER 1000
 #endif
 
+/* Test passing through the alien constructs (perlbug #34493) */
+#ifdef __LANGUAGE_PASCAL__
+function Tru64_Pascal(n: Integer): Integer;
+#endif
+
 /* 
  * Test #include, #import and #include_next
  * #include_next is difficult to test, it really depends on the actual
End of patch

@p5pRT
Copy link
Author

p5pRT commented Mar 21, 2005

From @rgs

Alexey Tourbin wrote​:

On Sat, Mar 19, 2005 at 04​:37​:12PM +0300, Alexey Tourbin wrote​:

The problem is that $in varialbe is not reset and "if" conditons hold
true till the end of file. Here is a patch (which has not been tested
yet, but seems to be reasonable offhand).

Here is a test that fails with the existing h2ph and passes with my
proposed change to h2ph. (It is only about Tru64 Pascal; unfortunatelly,
there's no easy way to test /^extern inline/ constructs as the desired
effect depends on file location.)

Thanks, both applied as #24054 to bleadperl.

@p5pRT
Copy link
Author

p5pRT commented Mar 21, 2005

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Mar 21, 2005

@rgs - Status changed from 'open' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant