[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: missing features.h



> -----Original Message-----
> From: Hans-Peter Nilsson [mailto:hans-peter.nilsson@xxxxxxx.com]
> Sent: woensdag 23 oktober 2002 19:34
> To: mailinglists@xxxxxxx.nl
> Cc: dev-etrax@xxxxxxx.com
> Subject: Re: missing features.h
>
>
> > From: Pieter Grimmerink <mailinglists@xxxxxxx.nl>
> > Date: Wed, 23 Oct 2002 12:28:10 +0200
>
> > On my workstation, features.h defines __USE_MISC for me (when I specify
> > _BSD_SOURCE).
> >
> > and features.h is included by almost every header in
> /usr/include, so as long
> > as I specify _BSD_SOURCE, I can use CRTSCTS when including <termios.h>
> >
> > Now with cris, the include files that replace files in
> /usr/include do not
> > include features.h,
>
> No, features.h *is* included.  If not, I'm surprised __USE_MISC
> has any effect.

Well, this is the piece that defines CRTSCTS, in
/usr/include/bits/termios.h:

#ifdef __USE_MISC
# define CIBAUD     002003600000    /* input baud rate (not used) */
# define CRTSCTS  020000000000      /* flow control */
#endif

So just specifying __USE_MISC *does* work.

> Don't use __USE_MISC.  Use _BSD_SOURCE or _GNU_SOURCE.

I use _BSD_SOURCE, and because __USE_MISC is not defined eventually,
I can only conclude features.h is not included, since features.h contains:

#if defined _BSD_SOURCE || defined _SVID_SOURCE
# define __USE_MISC  1
#endif

BTW, I don't see how _GNU_SOURCE should cause __USE_MISC to be defined,
just _BSD_SOURCE and _SVID_SOURCE do the job it seems to me.

> Did you install glibc correctly?

I installed the cris-dist-1.22 rpm, I guess glibc is included?
(at least, everything seems to work apart from my __USE_MISC ;-)

> An example program would help understanding what's wrong.

This (below) should do (specify -D_BSD_SOURCE and -D_XOPEN_SOURCE=500 in
CFLAGS)
Everything works except CRTSCTS.

Thanks and best regards,

Pieter


#include <fcntl.h>
#include <termios.h>

int main(int /*argc*/, char */*argv[]*/)
{
  int fd;
  struct termios term;

  fd = open("/dev/ttyS0",O_RDWR | O_NOCTTY);
  if (fd < 0) return;

  tcgetattr(fd, &term);

  term.c_lflag &= ~(ICANON | ECHO | ISIG | XCASE);
  term.c_cflag |= (CLOCAL | CREAD);

  term.c_cflag &= ~CRTSCTS;
  term.c_iflag &= ~(INPCK | ISTRIP | IUCLC); //don't use parity, dont strip
to
  term.c_iflag &= ~(IXON | IXOFF | IXANY);
  term.c_cflag &= ~CSIZE;
  term.c_cflag |= CS8;
  term.c_oflag &= ~OPOST;
  term.c_cc[VMIN] = 1;
  term.c_cc[VTIME] = 0;

  cfsetispeed(&term,B115200);
  cfsetospeed(&term,B115200);

  tcsetattr(fd,TCSANOW,&term);
}