Imported Upstream version 4.0.0~alpha1

Former-commit-id: 806294f5ded97629b74c85c09952f2a74fe182d9
This commit is contained in:
Jo Shields
2015-04-07 09:35:12 +01:00
parent 283343f570
commit 3c1f479b9d
22469 changed files with 2931443 additions and 869343 deletions

View File

@@ -26,7 +26,6 @@ MPH_C_SOURCE = \
# Source code which helps implement POSIX and other related Unix standards,
# and *may* be portable between Unix platforms.
MPH_UNIX_SOURCE = \
fakepoll.h \
dirent.c \
fcntl.c \
fstab.c \
@@ -159,7 +158,7 @@ refresh:
--rename-member=st_mtime=st_mtime_ \
--rename-namespace=Mono.Unix.Native=Mono.Posix \
--library=MonoPosixHelper \
$(mcs_topdir)/class/lib/net_2_0/Mono.Posix.dll map
$(mcs_topdir)/class/lib/net_4_5/Mono.Posix.dll map
# Useful if mono is compiled with --enable-shared=no
patch-libtool:

View File

@@ -134,17 +134,16 @@ am__DEPENDENCIES_1 =
libMonoPosixHelper_la_DEPENDENCIES = $(am__DEPENDENCIES_2) \
$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
am__libMonoPosixHelper_la_SOURCES_DIST = errno.c map.c map.h mph.h \
signal.c stdio.c string.c stdlib.c fakepoll.h dirent.c fcntl.c \
fstab.c grp.c macros.c nl.c nl.h old-map.c old-map.h pwd.c \
serial.c sys-mman.c sys-sendfile.c sys-stat.c sys-statvfs.c \
sys-time.c sys-uio.c sys-utsname.c sys-wait.c sys-xattr.c \
syslog.c time.c unistd.c utime.c x-struct-str.c zlib-helper.c \
adler32.c compress.c crc32.c uncompr.c deflate.c trees.c \
zutil.c inflate.c infback.c inftrees.c inffast.c crc32.h \
deflate.h inffast.h inffixed.h inflate.h inftrees.h trees.h \
zconf.h zlib.h zutil.h minizip/crypt.h minizip/ioapi.c \
minizip/ioapi.h minizip/unzip.c minizip/unzip.h minizip/zip.c \
minizip/zip.h
signal.c stdio.c string.c stdlib.c dirent.c fcntl.c fstab.c \
grp.c macros.c nl.c nl.h old-map.c old-map.h pwd.c serial.c \
sys-mman.c sys-sendfile.c sys-stat.c sys-statvfs.c sys-time.c \
sys-uio.c sys-utsname.c sys-wait.c sys-xattr.c syslog.c time.c \
unistd.c utime.c x-struct-str.c zlib-helper.c adler32.c \
compress.c crc32.c uncompr.c deflate.c trees.c zutil.c \
inflate.c infback.c inftrees.c inffast.c crc32.h deflate.h \
inffast.h inffixed.h inflate.h inftrees.h trees.h zconf.h \
zlib.h zutil.h minizip/crypt.h minizip/ioapi.c minizip/ioapi.h \
minizip/unzip.c minizip/unzip.h minizip/zip.c minizip/zip.h
am__objects_1 = errno.lo map.lo signal.lo stdio.lo string.lo stdlib.lo
am__objects_2 = dirent.lo fcntl.lo fstab.lo grp.lo macros.lo nl.lo \
old-map.lo pwd.lo serial.lo sys-mman.lo sys-sendfile.lo \
@@ -269,6 +268,7 @@ CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DISABLE_PERF_EVENTS = @DISABLE_PERF_EVENTS@
DISABLE_SHARED_HANDLES = @DISABLE_SHARED_HANDLES@
DLLTOOL = @DLLTOOL@
DOLT_BASH = @DOLT_BASH@
@@ -352,12 +352,15 @@ RANLIB = @RANLIB@
SED = @SED@
SET_MAKE = @SET_MAKE@
SGEN_DEFINES = @SGEN_DEFINES@
SHARED_CFLAGS = @SHARED_CFLAGS@
SHELL = @SHELL@
SQLITE = @SQLITE@
SQLITE3 = @SQLITE3@
STRIP = @STRIP@
USE_NLS = @USE_NLS@
VERSION = @VERSION@
VTUNE_CFLAGS = @VTUNE_CFLAGS@
VTUNE_LIBS = @VTUNE_LIBS@
WERROR_CFLAGS = @WERROR_CFLAGS@
X11 = @X11@
XATTR_LIB = @XATTR_LIB@
@@ -469,7 +472,6 @@ MPH_C_SOURCE = \
# Source code which helps implement POSIX and other related Unix standards,
# and *may* be portable between Unix platforms.
MPH_UNIX_SOURCE = \
fakepoll.h \
dirent.c \
fcntl.c \
fstab.c \
@@ -977,7 +979,7 @@ refresh:
--rename-member=st_mtime=st_mtime_ \
--rename-namespace=Mono.Unix.Native=Mono.Posix \
--library=MonoPosixHelper \
$(mcs_topdir)/class/lib/net_2_0/Mono.Posix.dll map
$(mcs_topdir)/class/lib/net_4_5/Mono.Posix.dll map
# Useful if mono is compiled with --enable-shared=no
patch-libtool:

View File

@@ -1,162 +0,0 @@
// fakepoll.h
// poll using select
// Warning: a call to this poll() takes about 4K of stack space.
// Greg Parker gparker-web@sealiesoftware.com December 2000
// This code is in the public domain and may be copied or modified without
// permission.
// Updated May 2002:
// * fix crash when an fd is less than 0
// * set errno=EINVAL if an fd is greater or equal to FD_SETSIZE
// * don't set POLLIN or POLLOUT in revents if it wasn't requested
// in events (only happens when an fd is in the poll set twice)
#ifndef _FAKE_POLL_H
#define _FAKE_POLL_H
#include <limits.h>
#define FD_SETSIZE OPEN_MAX
#include <sys/types.h>
#include <sys/time.h>
#include <unistd.h>
#include <stdlib.h>
typedef struct pollfd {
int fd; /* file desc to poll */
short events; /* events of interest on fd */
short revents; /* events that occurred on fd */
} pollfd_t;
// poll flags
#define POLLIN 0x0001
#define POLLOUT 0x0004
#define POLLERR 0x0008
// synonyms
#define POLLNORM POLLIN
#define POLLPRI POLLIN
#define POLLRDNORM POLLIN
#define POLLRDBAND POLLIN
#define POLLWRNORM POLLOUT
#define POLLWRBAND POLLOUT
// ignored
#define POLLHUP 0x0010
#define POLLNVAL 0x0020
static
inline int poll(struct pollfd *pollSet, int pollCount, int pollTimeout)
{
struct timeval tv;
struct timeval *tvp;
fd_set readFDs, writeFDs, exceptFDs;
fd_set *readp, *writep, *exceptp;
struct pollfd *pollEnd, *p;
int selected;
int result;
int maxFD;
if (!pollSet) {
pollEnd = NULL;
readp = NULL;
writep = NULL;
exceptp = NULL;
maxFD = 0;
}
else {
pollEnd = pollSet + pollCount;
readp = &readFDs;
writep = &writeFDs;
exceptp = &exceptFDs;
FD_ZERO(readp);
FD_ZERO(writep);
FD_ZERO(exceptp);
// Find the biggest fd in the poll set
maxFD = 0;
for (p = pollSet; p < pollEnd; p++) {
if (p->fd > maxFD) maxFD = p->fd;
}
if (maxFD >= FD_SETSIZE) {
// At least one fd is too big
errno = EINVAL;
return -1;
}
// Transcribe flags from the poll set to the fd sets
for (p = pollSet; p < pollEnd; p++) {
if (p->fd < 0) {
// Negative fd checks nothing and always reports zero
} else {
if (p->events & POLLIN) FD_SET(p->fd, readp);
if (p->events & POLLOUT) FD_SET(p->fd, writep);
if (p->events != 0) FD_SET(p->fd, exceptp);
// POLLERR is never set coming in; poll() always reports errors
// But don't report if we're not listening to anything at all.
}
}
}
// poll timeout is in milliseconds. Convert to struct timeval.
// poll timeout == -1 : wait forever : select timeout of NULL
// poll timeout == 0 : return immediately : select timeout of zero
if (pollTimeout >= 0) {
tv.tv_sec = pollTimeout / 1000;
tv.tv_usec = (pollTimeout % 1000) * 1000;
tvp = &tv;
} else {
tvp = NULL;
}
selected = select(maxFD+1, readp, writep, exceptp, tvp);
if (selected < 0) {
// Error during select
result = -1;
}
else if (selected > 0) {
// Select found something
// Transcribe result from fd sets to poll set.
// Also count the number of selected fds. poll returns the
// number of ready fds; select returns the number of bits set.
int polled = 0;
for (p = pollSet; p < pollEnd; p++) {
p->revents = 0;
if (p->fd < 0) {
// Negative fd always reports zero
} else {
if ((p->events & POLLIN) && FD_ISSET(p->fd, readp)) {
p->revents |= POLLIN;
}
if ((p->events & POLLOUT) && FD_ISSET(p->fd, writep)) {
p->revents |= POLLOUT;
}
if ((p->events != 0) && FD_ISSET(p->fd, exceptp)) {
p->revents |= POLLERR;
}
if (p->revents) polled++;
}
}
result = polled;
}
else {
// selected == 0, select timed out before anything happened
// Clear all result bits and return zero.
for (p = pollSet; p < pollEnd; p++) {
p->revents = 0;
}
result = 0;
}
return result;
}
#endif

View File

@@ -30,6 +30,22 @@ Mono_Posix_Syscall_fcntl (gint32 fd, gint32 cmd)
return fcntl (fd, cmd);
}
gint32
Mono_Posix_Syscall_fcntl_arg_int (gint32 fd, gint32 cmd, int arg)
{
if (Mono_Posix_FromFcntlCommand (cmd, &cmd) == -1)
return -1;
return fcntl (fd, cmd, arg);
}
gint32
Mono_Posix_Syscall_fcntl_arg_ptr (gint32 fd, gint32 cmd, void *arg)
{
if (Mono_Posix_FromFcntlCommand (cmd, &cmd) == -1)
return -1;
return fcntl (fd, cmd, arg);
}
gint32
Mono_Posix_Syscall_fcntl_arg (gint32 fd, gint32 cmd, gint64 arg)
{

View File

@@ -1 +1 @@
9049e3cc931aeb1082c95c99e3793b1c69582cf9
737c217727585521e981daf3f93ed8c7b5eb1f7b

View File

@@ -1 +1 @@
fa6786f0a771059db47f1979445223dc63db8f1d
9c170eac0dc5faf2d525c4e40aa2121080901830

View File

@@ -13,15 +13,18 @@
#include <fcntl.h>
#include <string.h>
#include <errno.h>
#if defined(__APPLE__)
#include "fakepoll.h"
#elif defined(HAVE_POLL_H)
#if defined(HAVE_POLL_H)
#include <poll.h>
#elif defined(HAVE_SYS_POLL_H)
#include <sys/poll.h>
#endif
#include <sys/ioctl.h>
/* This is for ASYNC_*, serial_struct on linux */
#if defined(HAVE_LINUX_SERIAL_H)
#include <linux/serial.h>
#endif
#include <glib.h>
/* This is for FIONREAD on solaris */
@@ -30,8 +33,13 @@
#endif
/* sys/time.h (for timeval) is required when using osx 10.3 (but not 10.4) */
#ifdef __APPLE__
/* IOKit is a private framework in iOS, so exclude there */
#if defined(__APPLE__) && !defined(HOST_IOS)
#include <sys/time.h>
#include <IOKit/IOKitLib.h>
#include <IOKit/serial/IOSerialKeys.h>
#include <IOKit/serial/ioss.h>
#include <IOKit/IOBSD.h>
#endif
/* This is a copy of System.IO.Ports.Handshake */
@@ -81,7 +89,7 @@ int write_serial (int fd, guchar *buffer, int offset, int count, in
int discard_buffer (int fd, gboolean input);
gint32 get_bytes_in_buffer (int fd, gboolean input);
gboolean is_baud_rate_legal (int baud_rate);
int setup_baud_rate (int baud_rate);
int setup_baud_rate (int baud_rate, gboolean *custom_baud_rate);
gboolean set_attributes (int fd, int baud_rate, MonoParity parity, int dataBits, MonoStopBits stopBits, MonoHandshake handshake);
MonoSerialSignal get_signals (int fd, gint32 *error);
gint32 set_signal (int fd, MonoSerialSignal signal, gboolean value);
@@ -175,11 +183,12 @@ get_bytes_in_buffer (int fd, gboolean input)
gboolean
is_baud_rate_legal (int baud_rate)
{
return setup_baud_rate (baud_rate) != -1;
gboolean ignore = FALSE;
return setup_baud_rate (baud_rate, &ignore) != -1;
}
int
setup_baud_rate (int baud_rate)
setup_baud_rate (int baud_rate, gboolean *custom_baud_rate)
{
switch (baud_rate)
{
@@ -246,9 +255,21 @@ setup_baud_rate (int baud_rate)
baud_rate = B75;
break;
case 50:
case 0:
default:
#ifdef B50
baud_rate = B50;
#else
baud_rate = -1;
break;
#endif
case 0:
#ifdef B0
baud_rate = B0;
#else
baud_rate = -1;
#endif
break;
default:
*custom_baud_rate = TRUE;
break;
}
return baud_rate;
@@ -258,6 +279,7 @@ gboolean
set_attributes (int fd, int baud_rate, MonoParity parity, int dataBits, MonoStopBits stopBits, MonoHandshake handshake)
{
struct termios newtio;
gboolean custom_baud_rate = FALSE;
if (tcgetattr (fd, &newtio) == -1)
return FALSE;
@@ -268,7 +290,7 @@ set_attributes (int fd, int baud_rate, MonoParity parity, int dataBits, MonoStop
newtio.c_iflag = IGNBRK;
/* setup baudrate */
baud_rate = setup_baud_rate (baud_rate);
baud_rate = setup_baud_rate (baud_rate, &custom_baud_rate);
/* char lenght */
newtio.c_cflag &= ~CSIZE;
@@ -357,16 +379,55 @@ set_attributes (int fd, int baud_rate, MonoParity parity, int dataBits, MonoStop
newtio.c_iflag |= IXOFF | IXON;
break;
}
if (cfsetospeed (&newtio, baud_rate) < 0 || cfsetispeed (&newtio, baud_rate) < 0 ||
tcsetattr (fd, TCSANOW, &newtio) < 0)
{
if (custom_baud_rate == FALSE) {
if (cfsetospeed (&newtio, baud_rate) < 0 || cfsetispeed (&newtio, baud_rate) < 0)
return FALSE;
} else {
#if __linux__ || (defined(__APPLE__) && !defined(HOST_IOS))
/* On Linux to set a custom baud rate, we must set the
* "standard" baud_rate to 38400. On Apple we set it purely
* so that tcsetattr has something to use (and report back later), but
* the Apple specific API is still opaque to these APIs, see:
* https://developer.apple.com/library/mac/samplecode/SerialPortSample/Listings/SerialPortSample_SerialPortSample_c.html#//apple_ref/doc/uid/DTS10000454-SerialPortSample_SerialPortSample_c-DontLinkElementID_4
*/
if (cfsetospeed (&newtio, B38400) < 0 || cfsetispeed (&newtio, B38400) < 0)
return FALSE;
#endif
}
if (tcsetattr (fd, TCSANOW, &newtio) < 0)
return FALSE;
if (custom_baud_rate == TRUE){
#if defined(HAVE_LINUX_SERIAL_H)
struct serial_struct ser;
if (ioctl (fd, TIOCGSERIAL, &ser) < 0)
{
return FALSE;
}
ser.custom_divisor = ser.baud_base / baud_rate;
ser.flags &= ~ASYNC_SPD_MASK;
ser.flags |= ASYNC_SPD_CUST;
if (ioctl (fd, TIOCSSERIAL, &ser) < 0)
{
return FALSE;
}
#elif defined(__APPLE__) && !defined(HOST_IOS)
speed_t speed = baud_rate;
if (ioctl(fd, IOSSIOSPEED, &speed) == -1)
return FALSE;
#else
/* Don't know how to set custom baud rate on this platform. */
return FALSE;
#endif
}
else
{
return TRUE;
}
}

View File

@@ -18,10 +18,10 @@
#ifndef HOST_WIN32
#include <sys/time.h>
#include <sys/types.h>
#if defined(__APPLE__)
#include "fakepoll.h"
#else
#if defined(HAVE_POLL_H)
#include <poll.h>
#elif defined(HAVE_SYS_POLL_H)
#include <sys/poll.h>
#endif
#include <unistd.h>
#include <stdlib.h>

View File

@@ -188,6 +188,9 @@ ReadZStream (ZStream *stream, guchar *buffer, gint length)
zs->avail_in = n;
}
if (zs->avail_in == 0 && zs->total_in == 0)
return Z_STREAM_END;
status = inflate (stream->stream, Z_SYNC_FLUSH);
if (status == Z_STREAM_END) {
stream->eof = TRUE;