Skip to content

Commit

Permalink
[libcrystax] Fix bug #1004
Browse files Browse the repository at this point in the history
Add own implementation of termios functions, including tcdrain().

Signed-off-by: Dmitry Moskalchuk <dm@crystax.net>
  • Loading branch information
dmsck committed Jul 23, 2015
1 parent e3f4580 commit 19e4513
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 11 deletions.
3 changes: 3 additions & 0 deletions sources/crystax/bin/gen-bionic-sources
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,9 @@ g.add "libc/arch-x86_64/syscalls/fcntl.S", fixup: "redefine_fcntl"
g.add "libc/bionic/sysconf.cpp"
g.add "libc/bionic/sysinfo.cpp"

# termios
g.add "libc/bionic/termios.cpp"

# pipe2
g.add "libc/arch-arm/syscalls/pipe2.S"
g.add "libc/arch-arm64/syscalls/pipe2.S"
Expand Down
58 changes: 58 additions & 0 deletions sources/crystax/include/termios.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* Copyright (c) 2011-2015 CrystaX .NET.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY CrystaX .NET ''AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CrystaX .NET OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of CrystaX .NET.
*/

#ifndef __CRYSTAX_INCLUDE_TERMIOS_H_4BB725BB15A04872B58EBC8A4F9321F0
#define __CRYSTAX_INCLUDE_TERMIOS_H_4BB725BB15A04872B58EBC8A4F9321F0

#include <crystax/id.h>

#include <sys/cdefs.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <linux/termios.h>

__BEGIN_DECLS

speed_t cfgetispeed(const struct termios*);
speed_t cfgetospeed(const struct termios*);
void cfmakeraw(struct termios*);
int cfsetispeed(struct termios*, speed_t);
int cfsetospeed(struct termios*, speed_t);
int cfsetspeed(struct termios*, speed_t);
int tcdrain(int);
int tcflow(int, int);
int tcflush(int, int);
int tcgetattr(int, struct termios*);
pid_t tcgetsid(int);
int tcsendbreak(int, int);
int tcsetattr(int, int, const struct termios*);

__END_DECLS

#endif /* __CRYSTAX_INCLUDE_TERMIOS_H_4BB725BB15A04872B58EBC8A4F9321F0 */
11 changes: 0 additions & 11 deletions tests/build/crystax-test-posix-interfaces/jni/termios.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,6 @@ void termios_check_fields(struct termios *s)
s->c_cc[0] = (cc_t)0;
}

#if __ANDROID__
/* WARNING!!! These functions not defined in Android, so we define empty stubs here */

int tcdrain(int c)
{
(void)c;
return -1;
}

#endif /* __ANDROID__ */

void termios_check_functions(struct termios *t, const struct termios *ct)
{
(void)cfgetispeed(ct);
Expand Down

0 comments on commit 19e4513

Please sign in to comment.