fpc/rtl/linux/termiosproc.inc
pierre f0eedd5d71 Merge of revisions 39726 39732 39734 39735 39736 39801 39806 39807 40002 40014 40358 40363 40392 40397 40481 40537 from trunk to fixes_3_2
------------------------------------------------------------------------
r39726 | pierre | 2018-09-10 13:30:42 +0000 (Mon, 10 Sep 2018) | 1 line

 pass -D__I8086_SMARTLINK_SECTIONS__ to nasm if FPCOPT contains -dTEST_I8086_SMARTLINK_SECTIONS
------------------------------------------------------------------------
--- Merging r39726 into '.':
U    rtl/msdos/Makefile
U    rtl/msdos/Makefile.fpc
--- Recording mergeinfo for merge of r39726 into '.':
 U   .
------------------------------------------------------------------------
r39732 | pierre | 2018-09-11 08:02:48 +0000 (Tue, 11 Sep 2018) | 1 line

 Add FPC_SOFT_FPUX80 and FPC_SOFT_FPU128 define handling
------------------------------------------------------------------------
--- Merging r39732 into '.':
U    rtl/linux/system.pp
--- Recording mergeinfo for merge of r39732 into '.':
 G   .
------------------------------------------------------------------------
r39734 | pierre | 2018-09-11 13:08:51 +0000 (Tue, 11 Sep 2018) | 1 line

 Increase default trace size to 16
------------------------------------------------------------------------
--- Merging r39734 into '.':
U    rtl/inc/heaptrc.pp
--- Recording mergeinfo for merge of r39734 into '.':
 G   .
------------------------------------------------------------------------
r39735 | pierre | 2018-09-11 13:10:59 +0000 (Tue, 11 Sep 2018) | 1 line

 Avoid wrap on 32-bit system for StackTop calculation
------------------------------------------------------------------------
--- Merging r39735 into '.':
U    rtl/inc/system.inc
--- Recording mergeinfo for merge of r39735 into '.':
 G   .
------------------------------------------------------------------------
r39736 | pierre | 2018-09-11 13:13:50 +0000 (Tue, 11 Sep 2018) | 5 lines

  * Add PAGESIZE local constant.
  + Set LAST_PAGE_GENERATES_SIGNAL macro for linux powerpc/powerpc64.
  + Use page_size for StackBottom computation.
  + Use LAST_PAGE_GENERATES_SIGNAL in StackBottom computation.

------------------------------------------------------------------------
--- Merging r39736 into '.':
G    rtl/linux/system.pp
--- Recording mergeinfo for merge of r39736 into '.':
 G   .
------------------------------------------------------------------------
r39801 | pierre | 2018-09-24 22:20:30 +0000 (Mon, 24 Sep 2018) | 1 line

 define iconv_is_in_libc by default for netbsd OS (can be disabled by adding -dDISABLE_ICONV_LIBC option
------------------------------------------------------------------------
--- Merging r39801 into '.':
U    rtl/unix/cwstring.pp
--- Recording mergeinfo for merge of r39801 into '.':
 G   .
------------------------------------------------------------------------
r39806 | pierre | 2018-09-26 09:25:54 +0000 (Wed, 26 Sep 2018) | 1 line

 Rename Result parameter to _Result to avoid compilation error for ppcjvm
------------------------------------------------------------------------
--- Merging r39806 into '.':
U    packages/jni/src/jni.pas
--- Recording mergeinfo for merge of r39806 into '.':
 G   .
------------------------------------------------------------------------
r39807 | pierre | 2018-09-26 09:27:33 +0000 (Wed, 26 Sep 2018) | 1 line

 Explicitly also disable java OS target
------------------------------------------------------------------------
--- Merging r39807 into '.':
U    packages/sdl/fpmake.pp
--- Recording mergeinfo for merge of r39807 into '.':
 G   .
------------------------------------------------------------------------
r40002 | pierre | 2018-10-20 22:30:20 +0000 (Sat, 20 Oct 2018) | 1 line

 Add explicit typecast to avoid range ccheck error
------------------------------------------------------------------------
--- Merging r40002 into '.':
U    rtl/linux/termiosproc.inc
--- Recording mergeinfo for merge of r40002 into '.':
 G   .
------------------------------------------------------------------------
r40014 | pierre | 2018-10-22 21:14:59 +0000 (Mon, 22 Oct 2018) | 1 line

 Add missing unicode related units to netware OS
------------------------------------------------------------------------
--- Merging r40014 into '.':
U    rtl/netware/Makefile
U    rtl/netware/Makefile.fpc
--- Recording mergeinfo for merge of r40014 into '.':
 G   .
------------------------------------------------------------------------
r40358 | pierre | 2018-11-20 22:02:59 +0000 (Tue, 20 Nov 2018) | 1 line

 Add classes unit
------------------------------------------------------------------------
--- Merging r40358 into '.':
U    rtl/watcom/Makefile
U    rtl/watcom/Makefile.fpc
--- Recording mergeinfo for merge of r40358 into '.':
 G   .
------------------------------------------------------------------------
r40363 | pierre | 2018-11-23 13:29:01 +0000 (Fri, 23 Nov 2018) | 1 line

 Also disable fpdoc and pas2jni utils packages for targets not supporting fcl-process package
------------------------------------------------------------------------
--- Merging r40363 into '.':
U    utils/pas2jni/fpmake.pp
U    utils/fpdoc/fpmake.pp
--- Recording mergeinfo for merge of r40363 into '.':
 G   .
------------------------------------------------------------------------
r40392 | pierre | 2018-11-29 14:23:44 +0000 (Thu, 29 Nov 2018) | 1 line

 Fix delete of gdbver.inc generated file after gdbint unit compilation when called from packages level
------------------------------------------------------------------------
--- Merging r40392 into '.':
U    packages/gdbint/fpmake.pp
--- Recording mergeinfo for merge of r40392 into '.':
 G   .
------------------------------------------------------------------------
r40397 | pierre | 2018-11-29 16:55:07 +0000 (Thu, 29 Nov 2018) | 1 line

 Fix cleaning of unicode utils package in fpmake
------------------------------------------------------------------------
--- Merging r40397 into '.':
U    utils/unicode/fpmake.pp
--- Recording mergeinfo for merge of r40397 into '.':
 G   .
------------------------------------------------------------------------
r40481 | pierre | 2018-12-06 17:06:45 +0000 (Thu, 06 Dec 2018) | 1 line

 Fix compilation of installer for win32 target
------------------------------------------------------------------------
--- Merging r40481 into '.':
U    installer/Makefile
U    installer/Makefile.fpc
U    packages/ide/Makefile.fpc
U    packages/ide/Makefile
--- Recording mergeinfo for merge of r40481 into '.':
 G   .
------------------------------------------------------------------------
r40537 | pierre | 2018-12-13 10:21:58 +0000 (Thu, 13 Dec 2018) | 1 line

Always accept empty string as meaning zero is TryRomanToInt, fixes intermittent errors in tromantoint test
------------------------------------------------------------------------
--- Merging r40537 into '.':
U    packages/rtl-objpas/src/inc/strutils.pp
U    tests/test/units/strutils/tromantoint.pp
--- Recording mergeinfo for merge of r40537 into '.':
 G   .

git-svn-id: branches/fixes_3_2@40618 -
2018-12-23 14:44:32 +00:00

221 lines
5.1 KiB
PHP

{
}
{******************************************************************************
IOCtl and Termios calls
******************************************************************************}
{$ifndef FPC_USE_LIBC}
Function TCGetAttr(fd:cint;var tios:TermIOS):cint; inline;
begin
TCGetAttr:=fpIOCtl(fd,TCGETS,@tios);
end;
Function TCSetAttr(fd:cint;OptAct:cint;const tios:TermIOS):cint;
var
nr:culong;
begin
case OptAct of
TCSANOW : nr:=TCSETS;
TCSADRAIN : nr:=TCSETSW;
TCSAFLUSH : nr:=TCSETSF;
else
begin
fpsetErrNo(ESysEINVAL);
TCSetAttr:=-1;
exit;
end;
end;
TCSetAttr:=fpIOCtl(fd,nr,@Tios);
end;
Procedure CFSetISpeed(var tios:TermIOS;speed:Cardinal); inline;
begin
tios.c_cflag:=(tios.c_cflag and (not CBAUD)) or speed;
end;
Procedure CFSetOSpeed(var tios:TermIOS;speed:Cardinal); inline;
begin
CFSetISpeed(tios,speed);
end;
{ checked against glibc 2.3.3 (FK) }
Procedure CFMakeRaw(var tios:TermIOS);
begin
with tios do
begin
c_iflag:=c_iflag and (not (IGNBRK or BRKINT or PARMRK or ISTRIP or
INLCR or IGNCR or ICRNL or IXON));
c_oflag:=c_oflag and (not OPOST);
c_lflag:=c_lflag and (not (ECHO or ECHONL or ICANON or ISIG or IEXTEN));
c_cflag:=(c_cflag and (not (CSIZE or PARENB))) or CS8;
c_cc[VMIN]:=1;
c_cc[VTIME]:=0;
end;
end;
Function TCSendBreak(fd,duration:cint):cint; inline;
begin
TCSendBreak:=fpIOCtl(fd,TCSBRK,pointer(ptrint(duration)));
end;
Function TCSetPGrp(fd,id:cint):cint; inline;
begin
TCSetPGrp:=fpIOCtl(fd,TIOCtlRequest(TIOCSPGRP),pointer(ptrint(id)));
end;
Function TCGetPGrp(fd:cint;var id:cint):cint; inline;
begin
TCGetPGrp:=fpIOCtl(fd,TIOCGPGRP,@id);
end;
Function TCDrain(fd:cint):cint; inline;
begin
TCDrain:=fpIOCtl(fd,TCSBRK,pointer(1));
end;
Function TCFlow(fd,act:cint):cint; inline;
begin
TCFlow:=fpIOCtl(fd,TCXONC,pointer(ptrint(act)));
end;
Function TCFlush(fd,qsel:cint):cint; inline;
begin
TCFlush:=fpIOCtl(fd,TCFLSH,pointer(ptrint(qsel)));
end;
Function IsATTY (Handle:cint):cint;
{
Check if the filehandle described by 'handle' is a TTY (Terminal)
}
var
t : Termios;
begin
if TCGetAttr(Handle,t)=0 then
IsAtty:=1
else
IsAtty:=0;
end;
Function IsATTY(var f: text):cint; inline;
{
Idem as previous, only now for text variables.
}
begin
IsATTY:=IsaTTY(textrec(f).handle);
end;
{$else}
// We plan to use FPC_USE_LIBC for Debian/kFreeBSD. This means that we need
// to avoid IOCTLs, since those go to the kernel and need to be FreeBSD specific.
// -> reroute as much as possible to libc.
function real_tcsendbreak(fd,duration: cint): cint; cdecl; external name 'tcsendbreak';
function real_tcdrain(fd: cint): cint; cdecl; external name 'tcdrain';
function real_tcflow(fd,act:cint): cint; cdecl; external name 'tcflow';
function real_tcflush(fd,qsel: cint): cint; cdecl; external name 'tcflush';
Function real_TCSetAttr(fd:cint;OptAct:cint;constref tios:TermIOS):cint; cdecl; external name 'tcsetattr';
Function real_TCGetAttr(fd:cint;var tios:TermIOS):cint; cdecl; external name 'tcgetattr';
function real_tcgetpgrp(fd:cint):pid_t; cdecl; external name 'tcgetpgrp';
function real_tcsetpgrp(fd: cint; pgrp: pid_t): cint; cdecl; external name 'tcsetpgrp';
Function TCGetAttr(fd:cint;var tios:TermIOS):cint; inline;
begin
TCGetAttr:=real_tcgetattr(fd,tios);
end;
Function TCSetAttr(fd:cint;OptAct:cint;const tios:TermIOS):cint;
begin
TCSetAttr:=Real_TCSetAttr(fd,OptAct,tios);
end;
Procedure CFSetISpeed(var tios:TermIOS;speed:Cardinal); inline;
begin
tios.c_cflag:=(tios.c_cflag and (not CBAUD)) or speed;
end;
Procedure CFSetOSpeed(var tios:TermIOS;speed:Cardinal); inline;
begin
CFSetISpeed(tios,speed);
end;
{ checked against glibc 2.3.3 (FK) }
Procedure CFMakeRaw(var tios:TermIOS);
begin
with tios do
begin
c_iflag:=c_iflag and (not (IGNBRK or BRKINT or PARMRK or ISTRIP or
INLCR or IGNCR or ICRNL or IXON));
c_oflag:=c_oflag and (not OPOST);
c_lflag:=c_lflag and (not (ECHO or ECHONL or ICANON or ISIG or IEXTEN));
c_cflag:=(c_cflag and (not (CSIZE or PARENB))) or CS8;
c_cc[VMIN]:=1;
c_cc[VTIME]:=0;
end;
end;
Function TCSendBreak(fd,duration:cint):cint; inline;
begin
TCSendBreak:=real_tcsendbreak(fd,duration);
end;
Function TCSetPGrp(fd,id:cint):cint; inline;
begin
TCSetPGrp:=real_tcsetpgrp(fd,id);;
end;
Function TCGetPGrp(fd:cint;var id:cint):cint; inline;
begin
id:=real_tcgetpgrp(fd);
tcgetpgrp:=id;
end;
Function TCDrain(fd:cint):cint; inline;
begin
TCDrain:=real_TCDrain(fd);
end;
Function TCFlow(fd,act:cint):cint; inline;
begin
TCFlow:=real_tcflow(fd,act);
end;
Function TCFlush(fd,qsel:cint):cint; inline;
begin
TCFlush:=real_tcflush(fd,qsel);
end;
Function IsATTY (Handle:cint):cint;
{
Check if the filehandle described by 'handle' is a TTY (Terminal)
}
var
t : Termios;
begin
if TCGetAttr(Handle,t)=0 then
IsAtty:=1
else
IsAtty:=0;
end;
Function IsATTY(var f: text):cint; inline;
{
Idem as previous, only now for text variables.
}
begin
IsATTY:=IsaTTY(textrec(f).handle);
end;
{$endif}