Opened 10 years ago

Last modified 8 years ago

#1128 new defect

stty termios struct, add feature test for speed attributes

Reported by: hanDerPeder Owned by: Alex Shinn
Priority: major Milestone: someday
Component: extensions Version: 4.9.x
Keywords: stty termios Cc: peder@…
Estimated difficulty: hard

Description

the stty egg fails to compile on android because of missing fields.

in android bionic termios is defined like this:

struct termio { 
  unsigned short c_iflag;	 /* input mode flags */ 
  unsigned short c_oflag;	 /* output mode flags */ 
  unsigned short c_cflag;	 /* control mode flags */ 
  unsigned short c_lflag;	 /* local mode flags */ 
  unsigned char c_line;	         /* line discipline */ 
  unsigned char c_cc[NCC];	 /* control characters */ 
};

while on linux (x86) it's:

struct termios 
{ 
  tcflag_t c_iflag;	 /* input mode flags */ 
  tcflag_t c_oflag;	 /* output mode flags */ 
  tcflag_t c_cflag;	 /* control mode flags */ 
  tcflag_t c_lflag;	 /* local mode flags */ 
  cc_t c_line;	         /* line discipline */ 
  cc_t c_cc[NCCS];	 /* control characters */ 
  speed_t c_ispeed;	 /* input speed */ 
  speed_t c_ospeed;	 /* output speed */ 
  #define _HAVE_STRUCT_TERMIOS_C_ISPEED 1 
  #define _HAVE_STRUCT_TERMIOS_C_OSPEED 1 
};

The attached patch adds feature tests for c_ispeed and c_ospeed. Have tested on my workstation (arch linux x86) and embedded android (arm).

My first time using feature-test so if you have any feedback please let me know. If it looks okay, please merge.

Regards,
Peder Refsnes

Attachments (1)

stty_termios_bionic.patch (4.0 KB) - added by hanDerPeder 10 years ago.

Download all attachments as: .zip

Change History (6)

Changed 10 years ago by hanDerPeder

Attachment: stty_termios_bionic.patch added

comment:1 Changed 10 years ago by Mario Domenech Goulart

Hi,

I haven't tested your patch, but I have a feeling

(run (./stty-features > stty-config.scm))

is not very cross-build-friendly, since it would attempt to determine features when running on the host system, while you actually want to determine target features. Does that sound right?

comment:2 in reply to:  1 Changed 10 years ago by hanDerPeder

Replying to mario:

Hi,

I haven't tested your patch, but I have a feeling

(run (./stty-features > stty-config.scm))

is not very cross-build-friendly, since it would attempt to determine features when running on the host system, while you actually want to determine target features. Does that sound right?

I've been using it with cross-chicken, seems to work fine. I took the line you're referring to straight from the example section of the feature-test page so might not be the best way of doing it.

comment:3 Changed 10 years ago by Mario Domenech Goulart

I just tested your patch on Yocto, cross-compiling stty from x86-64 to ARM and it breaks, unfortunately:

| sh: ./stty-features: cannot execute binary file
| 
| Error: shell command failed with nonzero exit status 32256:
| 
|   ./stty-features > stty-config.scm

The problem is:

$ file stty-features
stty-features: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.16, not stripped

You can't run an ARM binary on x86-64.

Maybe you can take a look at crypt's .setup file. It has some tricks to handle cross-build environments.

comment:4 Changed 10 years ago by hanDerPeder

I see the problem, but I'm not sure how the crypt eggs approach (don't auto-detect when cross compiling) helps here.

Seems this was a bit more complicated than I had anticipated, do you have any suggestions how I should approach this?

To me it seems one way would be to create a host binary that can feature test against the target environment, but again, not sure how I would go about doing this.

comment:5 Changed 8 years ago by sjamaan

Estimated difficulty: hard
Note: See TracTickets for help on using tickets.