1
0
mirror of https://github.com/UzixLS/picocom.git synced 2025-07-19 07:21:18 +03:00

Cleaned-up and reordered architecture conditionals + comments.

This commit is contained in:
Nick Patavalis
2015-08-20 00:47:58 +03:00
parent 46d2a20dcc
commit 495d142467

View File

@ -1,12 +1,12 @@
/*
* termbits2.c
*
* Stuff that we should include from kernel source, if we could.
* Included from termios2.h
* Stuff that we should include from kernel sources, if we could; but
* we can't. Included from "termios2.h"
*
* by Nick Patavalis (npat@efault.net)
*
* ATTENTION: Very linux-specific kludge!
* ATTENTION: Linux-specific kludge!
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@ -27,6 +27,10 @@
#ifndef TERMBITS2_H
#define TERMBITS2_H
#ifndef __linux__
#error "Linux specific code!"
#endif
/* We need tcflag_t, cc_t, speed_t, CBAUDEX, etc */
#include <termios.h>
@ -36,7 +40,7 @@
<linux-kernel>/arch/<arch>/include/uapi/asm/termbits.h
or <linux-kernel>/include/uapi/asm-generic/termbits.h
which is the same as:
which are the same as:
/usr/include/<arch>/asm/termbits.h
or /usr/include/asm-generic/termbits.h
@ -50,22 +54,31 @@
our "struct termios" here to be the libc version (as defined in
<termios.h>), because that's what our callers use. As a result we
cannot get the definion of "struct termios2" from the above header
files since this would also bring-in the clashing definition of the
files, since this would also bring-in the clashing definition of the
kernel version of "struct termios". If you have an idea for a better
way out of this mess, I would REALLY like to hear it.
*/
way out of this mess, I would REALLY like to hear it.
I hope that soon GLIBC will pick-up termios2 and all these will be
useless. Until then ...
ATTENTION: For most architectures "struct termios2" and the
associated constants we care about (NCCS, BOTHER, IBSHIFT) are the
same. For some there are small differences, and some architectures
do not support termios2 at all. I don't claim to have done a
thorough job figuring out the specifics for every architecture, so
your milleage may vary. In any case, if you want support for
something that's missing, just copy the relevant definitions from
the kernel header file in here, recompile, test, and send me a
patch. */
#if defined (__powerpc__) || defined (__alpha__)
#error "Architecure has no termios2"
#elif defined (__mips__)
/* K_NCCS *may* need to be ifdef'ed according to architecture. A quick
grep in the kernel sources (3.x) reveals that, most likely, only
the MIPS arch has a different NCCS value.
*/
#if defined __mips__
#define K_NCCS 23
#else
/* All others */
#define K_NCCS 19
#endif
struct termios2 {
tcflag_t c_iflag; /* input mode flags */
tcflag_t c_oflag; /* output mode flags */
@ -77,21 +90,29 @@ struct termios2 {
speed_t c_ospeed; /* output speed */
};
/* BOTHER needs to be ifdef'ed according to architecture. A quick grep
in the kernel sources (3.x) reveals that, most likely, only the
PowerPC arch has a different BOTHER value.
*/
#if defined __powerpc__
#define BOTHER 0037
#else
/* All others */
#define BOTHER CBAUDEX
#endif
/* AFAIK this is the same on all architectures */
#define BOTHER CBAUDEX
#define IBSHIFT 16
#else /* All others */
#define K_NCCS 19
struct termios2 {
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[K_NCCS]; /* control characters */
speed_t c_ispeed; /* input speed */
speed_t c_ospeed; /* output speed */
};
#define BOTHER CBAUDEX
#define IBSHIFT 16
#endif /* of architectures */
/***************************************************************************/
#endif /* of TERMBITS2_H */