ALT Linux Team development discussions
 help / color / mirror / Atom feed
* [devel] glibc-kernheaders TCGETS2
@ 2008-03-18 22:58 Alexey Tourbin
  2008-03-18 23:12 ` Dmitry V. Levin
  0 siblings, 1 reply; 3+ messages in thread
From: Alexey Tourbin @ 2008-03-18 22:58 UTC (permalink / raw)
  To: devel

[-- Attachment #1: Type: text/plain, Size: 3718 bytes --]

У меня перестал собираться перл, не может вычислить некоторые константы
для ioctl в сгенерированном сишном коде.

$ cat /tmp/.private/at/bhap6ejYVA.c
#include <stdio.h>
#include <sys/ioctl.h>
int main() {
printf("TCGETS %ld\n", (long)(TCGETS));
printf("TCGETS2 %ld\n", (long)(TCGETS2));
return 0;
}
$ gcc /tmp/.private/at/bhap6ejYVA.c
/tmp/.private/at/bhap6ejYVA.c: In function 'main':
/tmp/.private/at/bhap6ejYVA.c:5: error: invalid application of 'sizeof' to incomplete type 'struct termios2' 
/tmp/.private/at/bhap6ejYVA.c:5: error: array type has incomplete element type
/tmp/.private/at/bhap6ejYVA.c:5: error: invalid application of 'sizeof' to incomplete type 'struct termios2' 
/tmp/.private/at/bhap6ejYVA.c:5: error: invalid application of 'sizeof' to incomplete type 'struct termios2' 
$

Воспроизводится это так:

$ pwd
/home/at/git.alt/perl/ext/ph
$ diff -u h2ph.pl{-,}
--- h2ph.pl-    2008-03-18 21:06:25 +0300
+++ h2ph.pl     2008-03-19 01:55:18 +0300
@@ -24,7 +24,7 @@
 sub get_values ($$) {
     my @include = @{ +shift };
     my @names = @{ +shift };
-    my $src = File::Temp->new(SUFFIX=>'.c');
+    my $src = File::Temp->new(SUFFIX=>'.c',UNLINK=>0);
     print $src "#include <stdio.h>\n";
     for (@include) {
        print $src "#include <$_>\n";
$ perl ioctl_ph.PL 
/tmp/.private/at/S5LyD2gyrT.c: In function 'main':
/tmp/.private/at/S5LyD2gyrT.c:67: error: invalid application of 'sizeof' to incomplete type 'struct termios2' 
/tmp/.private/at/S5LyD2gyrT.c:67: error: array type has incomplete element type
/tmp/.private/at/S5LyD2gyrT.c:67: error: invalid application of 'sizeof' to incomplete type 'struct termios2' 
/tmp/.private/at/S5LyD2gyrT.c:67: error: invalid application of 'sizeof' to incomplete type 'struct termios2' 
/tmp/.private/at/S5LyD2gyrT.c:74: error: invalid application of 'sizeof' to incomplete type 'struct termios2' 
/tmp/.private/at/S5LyD2gyrT.c:74: error: array type has incomplete element type
/tmp/.private/at/S5LyD2gyrT.c:74: error: invalid application of 'sizeof' to incomplete type 'struct termios2' 
/tmp/.private/at/S5LyD2gyrT.c:74: error: invalid application of 'sizeof' to incomplete type 'struct termios2' 
/tmp/.private/at/S5LyD2gyrT.c:76: error: invalid application of 'sizeof' to incomplete type 'struct termios2' 
/tmp/.private/at/S5LyD2gyrT.c:76: error: array type has incomplete element type
/tmp/.private/at/S5LyD2gyrT.c:76: error: invalid application of 'sizeof' to incomplete type 'struct termios2' 
/tmp/.private/at/S5LyD2gyrT.c:76: error: invalid application of 'sizeof' to incomplete type 'struct termios2' 
/tmp/.private/at/S5LyD2gyrT.c:78: error: invalid application of 'sizeof' to incomplete type 'struct termios2' 
/tmp/.private/at/S5LyD2gyrT.c:78: error: array type has incomplete element type
/tmp/.private/at/S5LyD2gyrT.c:78: error: invalid application of 'sizeof' to incomplete type 'struct termios2' 
/tmp/.private/at/S5LyD2gyrT.c:78: error: invalid application of 'sizeof' to incomplete type 'struct termios2' 
failed: gcc -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 -D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -fno-strict-aliasing -pipe -I/usr/local/include -I/usr/include/gdbm -o /tmp/.private/at/2jww_OC3PH /tmp/.private/at/S5LyD2gyrT.c -Wl,-O1 -L/usr/local/lib -ldl -lm -lpthread -lc -lcrypt at ./h2ph.pl line 39.
$ sed -n -e 67p -e 74p -e 76p -e 78p /tmp/.private/at/S5LyD2gyrT.c
printf("TCGETS2 %ld\n", (long)(TCGETS2));
printf("TCSETS2 %ld\n", (long)(TCSETS2));
printf("TCSETSF2 %ld\n", (long)(TCSETSF2));
printf("TCSETSW2 %ld\n", (long)(TCSETSW2));
$

[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [devel] glibc-kernheaders TCGETS2
  2008-03-18 22:58 [devel] glibc-kernheaders TCGETS2 Alexey Tourbin
@ 2008-03-18 23:12 ` Dmitry V. Levin
  2008-03-18 23:38   ` Alexey Tourbin
  0 siblings, 1 reply; 3+ messages in thread
From: Dmitry V. Levin @ 2008-03-18 23:12 UTC (permalink / raw)
  To: ALT Devel discussion list; +Cc: Kirill A. Shutemov

[-- Attachment #1: Type: text/plain, Size: 1373 bytes --]

On Wed, Mar 19, 2008 at 01:58:50AM +0300, Alexey Tourbin wrote:
> У меня перестал собираться перл, не может вычислить некоторые константы
> для ioctl в сгенерированном сишном коде.

Это багрепорт на свежий glibc-kernheaders.

> $ cat /tmp/.private/at/bhap6ejYVA.c
> #include <stdio.h>
> #include <sys/ioctl.h>
> int main() {
> printf("TCGETS %ld\n", (long)(TCGETS));
> printf("TCGETS2 %ld\n", (long)(TCGETS2));
> return 0;
> }

TCGETS2 раньше не было.

> $ gcc /tmp/.private/at/bhap6ejYVA.c
> /tmp/.private/at/bhap6ejYVA.c: In function 'main':
> /tmp/.private/at/bhap6ejYVA.c:5: error: invalid application of 'sizeof' to incomplete type 'struct termios2' 
> /tmp/.private/at/bhap6ejYVA.c:5: error: array type has incomplete element type
> /tmp/.private/at/bhap6ejYVA.c:5: error: invalid application of 'sizeof' to incomplete type 'struct termios2' 
> /tmp/.private/at/bhap6ejYVA.c:5: error: invalid application of 'sizeof' to incomplete type 'struct termios2' 

struct termios2 определено в другом файле (asm/termbits.h);
там же есть определение struct termios, которое, разумеется,
конфликтует с определением из bits/termios.h:

$ printf '#include <termios.h>\n#include <asm/termbits.h>\n' |gcc -c -Wall -xc - >/dev/null 
In file included from <stdin>:2:
/usr/include/asm/termbits.h:11: error: redefinition of 'struct termios'


-- 
ldv

[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [devel] glibc-kernheaders TCGETS2
  2008-03-18 23:12 ` Dmitry V. Levin
@ 2008-03-18 23:38   ` Alexey Tourbin
  0 siblings, 0 replies; 3+ messages in thread
From: Alexey Tourbin @ 2008-03-18 23:38 UTC (permalink / raw)
  To: ALT Devel discussion list

[-- Attachment #1: Type: text/plain, Size: 1961 bytes --]

On Wed, Mar 19, 2008 at 02:12:37AM +0300, Dmitry V. Levin wrote:
> On Wed, Mar 19, 2008 at 01:58:50AM +0300, Alexey Tourbin wrote:
> > У меня перестал собираться перл, не может вычислить некоторые константы
> > для ioctl в сгенерированном сишном коде.
> Это багрепорт на свежий glibc-kernheaders.

По привычке пишу в список, хотя в данном случае, наверное, следовало
бы в багзиллу.

> > $ cat /tmp/.private/at/bhap6ejYVA.c
> > #include <stdio.h>
> > #include <sys/ioctl.h>
> > int main() {
> > printf("TCGETS %ld\n", (long)(TCGETS));
> > printf("TCGETS2 %ld\n", (long)(TCGETS2));
> > return 0;
> > }
> 
> TCGETS2 раньше не было.

Это я сделал генерат сишного кода для целочисленных констант, который
заменяет старый генератор перлового кода h2ph, который вообще ужас что
генерировал.

На высоком уровне это выглядит очень просто:

gen_h2ph(
    include => "sys/ioctl.h",
    regexp => qr/^FIO|^TC|^TIO|^SIO/,
    output => "ioctl.ph",
);

Он работает в два прохода: сначала выгребает константы через 'cpp -dD',
а потом генерирует сишную программу, которая печатает эти константы.
Примерно вот такая идея:

$ cpp -dD - <<<'#include <sys/ioctl.h>' |sed -n '/^#define TC/p'
#define TCGETS 0x5401
#define TCSETS 0x5402
#define TCSETSW 0x5403
#define TCSETSF 0x5404
#define TCGETA 0x5405
#define TCSETA 0x5406
#define TCSETAW 0x5407
#define TCSETAF 0x5408
#define TCSBRK 0x5409
#define TCXONC 0x540A
#define TCFLSH 0x540B
#define TCSBRKP 0x5425
#define TCGETS2 _IOR('T',0x2A, struct termios2)
#define TCSETS2 _IOW('T',0x2B, struct termios2)
#define TCSETSW2 _IOW('T',0x2C, struct termios2)
#define TCSETSF2 _IOW('T',0x2D, struct termios2)
$

Соответственно мы считаем что все ^TC константы должны раскрываться
в целочисленное значение на стадии компиляции сишного генерата.
Это позволяет создать абсолютно корректный файл
/usr/lib/perl5/*/ioctl.ph
без крамольной конвертации сишных хедеров в перловый код.

[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-03-18 23:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-03-18 22:58 [devel] glibc-kernheaders TCGETS2 Alexey Tourbin
2008-03-18 23:12 ` Dmitry V. Levin
2008-03-18 23:38   ` Alexey Tourbin

ALT Linux Team development discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://lore.altlinux.org/devel/0 devel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 devel devel/ http://lore.altlinux.org/devel \
		devel@altlinux.org devel@altlinux.ru devel@lists.altlinux.org devel@lists.altlinux.ru devel@linux.iplabs.ru mandrake-russian@linuxteam.iplabs.ru sisyphus@linuxteam.iplabs.ru
	public-inbox-index devel

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://lore.altlinux.org/org.altlinux.lists.devel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git