Stdio: Convert file.c into a cmod.
Stdio.File: Removed some now obsolete code.
Stdio.Fd_ref: This class is now created via proxy_factory().
Stdio: query_mtu() is now guarded by IP_MTU. IP_MTU seems to be Linux-specific, and I haven't been able to find corresponding code for other OSes. Fixes build failures on multiple platforms.
Stdio: Added query_mtu() to Stdio.File and Stdio.UDP.
Documentation [Stdio.File]: Enabled some Autodoc markup.
Merge branch 'grubba/pty-handling' into 8.0 * grubba/pty-handling: I/O [NT]: Fixed typo. Stdio [NT]: Fixed compilation error when no struct termios. Diagnostics [NT]: Fixed multiple issues with FD_DEBUG. I/O [NT]: Enable some termios functions on NT. I/O [NT]: Implemented TIOCGWINSZ and TIOCSWINSZ ioctls. I/O: Make termios code dependent on presence of tcgetattr(). Stdio: Fix get_all_args() call to support Pike 8.0 and earlier. Stdio.File: Added tcdrain() and tcsetsize().
Merge branch 'grubba/pty-handling' * grubba/pty-handling: Diagnostics [NT]: Fixed multiple issues with FD_DEBUG. I/O [NT]: Enable some termios functions on NT. I/O [NT]: Implemented TIOCGWINSZ and TIOCSWINSZ ioctls. I/O: Make termios code dependent on presence of tcgetattr().
I/O [NT]: Enable some termios functions on NT. Fixes #10013.
I/O: Make termios code dependent on presence of tcgetattr(). Preparation for supporting some termios operations on NT. Preparation for #10013.
Merge branch 'grubba/pty-handling' * grubba/pty-handling: Stdio.File: Added tcdrain() and tcsetsize().
Stdio.File: Added tcdrain() and tcsetsize(). It is now possible to set the window size for a pty or other terminal. Also adds documentation for them as well as tcflush() and tcsendbreak(), and moves it and the documentation for tc{get,set}attr() from Stdio.File to Stdio.Fd. Also some fixes to make the code work on systems with <sys/termios.h> but no <termios.h>, and preparation to make some of it work on NT. Fixes some of #10013.
Merge branch 'grubba/pty-handling' into 8.0 * grubba/pty-handling: I/O [NT]: Fixed typo. Documentation [Stdio]: Added some more notes regarding PROP_TTY.
Merge branch 'grubba/pty-handling' * grubba/pty-handling: I/O [NT]: Fixed typo.
I/O [NT]: Fixed typo.
Documentation [Stdio]: Even more PROP_TTY doc.
Merge branch 'grubba/pty-handling' * grubba/pty-handling: Documentation [Stdio]: Added some more notes regarding PROP_TTY.
Documentation [Stdio]: Added some more notes regarding PROP_TTY.
Merge branch 'grubba/pty-handling' into 8.0 * grubba/pty-handling: I/O [NT]: Make Stdio.PROP_TTY indicate availability of ptys.
Merge branch 'grubba/pty-handling' * grubba/pty-handling: I/O [NT]: Make Stdio.PROP_TTY indicate availability of ptys.
I/O [NT]: Make Stdio.PROP_TTY indicate availability of ptys. Only provide Stdio.PROP_TTY on NT if OpenPseudoConsole() is available.
Merge branch 'grubba/pty-handling' into 8.0 * grubba/pty-handling: (23 commits) I/O [NT]: Fixed typo in FD_DEBUG code. I/O [NT]: Updated note. I/O [NT]: Added some notes about pty handling. I/O [NT]: More pty handling fixes. I/O [NT]: Keep track of processes using ConPTY slaves. I/O [NT]: Do not attempt to read too much data from ptys. I/O [NT]: Changed calling convention for close_pty(). I/O [NT]: debug_fd_openpty() now returns ENOTSUPP when no ConPTY. I/O [NT]: Fixed some issues with debug_fd_openpty(). Process [NT]: Fix process creation. I/O [NT]: More debug_fd_openpty() fixes: I/O [NT]: Fixed multiple isses with debug_fd_openpty(). I/O [NT]: Adjusted preprocessor conditionals. I/O [NT]: Fixed typo. I/O [NT]: Fixed some issues with debug_fd_openpty(). Process [NT]: Fixed some typos in recent commits. Process.create_process [NT]: First go at attempting to support ptys. I/O [NT]: Make Pike_NT_* available to the rest of Pike. Process[NT]: Switch to using STARTUPINFOEXW. I/O [NT]: Added debug_fd_openpty(). ...
Merge branch 'grubba/pty-handling' * grubba/pty-handling: Process.create_process [NT]: First go at attempting to support ptys. I/O [NT]: Make Pike_NT_* available to the rest of Pike. Process[NT]: Switch to using STARTUPINFOEXW. I/O [NT]: Added debug_fd_openpty(). I/O [NT]: Reading from the console on NT may fail with ENOMEM. I/O [NT]: Restructured debug_fd_read() somewhat. I/O: Added fd_*-wrapper for openpty().
I/O: Added fd_*-wrapper for openpty(). Preparation for supporting ptys on NT.
Merge branch 'grubba/pty-handling' into 8.0 * grubba/pty-handling: Process [NT]: Fixed typo in previous commit. Process [NT]: Support UTF-8 in create_process(). I/O [NT]: Added low_dwim_utf8_to_utf16(). I/O [NT]: Fixed some typos. I/O [NT]: Added dynamic lookup of symbols needed for pty handling. I/O [NT]: Added fallbacks for some stuff needed for pty handling. Build [Stdio]: Make systems without termios.h (ie NT) happy again. Stdio: Make Coverity happy. [CID 1457890] Stdio: Fixed some inverted tests in my_openpty(). Stdio: Removed extraneous and broken #include of <pty.h>. Stdio: Added support for PROP_TTY to pipe(). Stdio: Some pty-handling cleanup.
Merge branch 'grubba/fdlib' into grubba/pty-handling-new * grubba/fdlib: (55 commits) I/O [NT]: Use read-write locking for fd_busy and fd_to_{socket,handle()}. I/O [NT]: Fixed typo. I/O [NT]: Avoid blocking on read from pipes with data. Added some paranoia System [NT]: Normalize the drive letter explicitly in normalize_path(). System [NT]: More normalize_path() fixes. Configure [Solaris]: Fixed quoting level issue. System [NT]: Fixed trailing slashes from normalize_path(). I/O [Solaris]: Fix getcwd() on Solaris. I/O [NT]: Fixed a few warnings. I/O [NT]: Moved bulk of normalize_path() to fdlib. System [NT]: Update normalize_path() to use UTF8. I/O [NT]: Get rid of DO_NOT_WARN(). I/O [NT]: Added some more FD_DEBUG. I/O [NT]: Fixed typo in FD_DEBUG code. Build [NT]: Always use or own implementation of _dosmaperr(). Build [NT]: Improved support for MSVC 2010 (aka MSC 1600). I/O [NT]: Fixed deadlock. I/O [NT]: Updated FD_DEBUG diagnostics. I/O [NT]: Survive invalid UTF-16 surrogate pairs. ...
Build [Stdio]: Make systems without termios.h (ie NT) happy again.
Stdio: Make Coverity happy. [CID 1457890]
Stdio: Fixed some inverted tests in my_openpty().
Stdio: Removed extraneous and broken #include of <pty.h>. Fixes building on multiple architectures.
Stdio: Added support for PROP_TTY to pipe().
Stdio: Some pty-handling cleanup. Add wrappers emulating missing libc functions.
Merge branch 'grubba/fdlib' into grubba/pty-handling * grubba/fdlib: (55 commits) I/O [NT]: Use read-write locking for fd_busy and fd_to_{socket,handle()}. I/O [NT]: Fixed typo. I/O [NT]: Avoid blocking on read from pipes with data. Added some paranoia System [NT]: Normalize the drive letter explicitly in normalize_path(). System [NT]: More normalize_path() fixes. Configure [Solaris]: Fixed quoting level issue. System [NT]: Fixed trailing slashes from normalize_path(). I/O [Solaris]: Fix getcwd() on Solaris. I/O [NT]: Fixed a few warnings. I/O [NT]: Moved bulk of normalize_path() to fdlib. System [NT]: Update normalize_path() to use UTF8. I/O [NT]: Get rid of DO_NOT_WARN(). I/O [NT]: Added some more FD_DEBUG. I/O [NT]: Fixed typo in FD_DEBUG code. Build [NT]: Always use or own implementation of _dosmaperr(). Build [NT]: Improved support for MSVC 2010 (aka MSC 1600). I/O [NT]: Fixed deadlock. I/O [NT]: Updated FD_DEBUG diagnostics. I/O [NT]: Survive invalid UTF-16 surrogate pairs. ...
Merge branch 'grubba/pty-handling' * grubba/pty-handling: Stdio: Make Coverity happy. [CID 1457890] Stdio: Fixed some inverted tests in my_openpty().
Merge branch 'grubba/pty-handling' * grubba/pty-handling: Stdio: Removed extraneous and broken #include of <pty.h>.
Merge branch 'grubba/pty-handling' * grubba/pty-handling: Stdio: Added support for PROP_TTY to pipe(). Stdio: Some pty-handling cleanup.
Stdio.File: Support openat with a single argument. Also fixes: - Avoid a SEGV when supplied with a single argument. - Synchronise low level implementation with pike level by setting the default mask to 0777 everywhere.
Merge remote-tracking branch 'origin/master' into new_utf8
Merge commit '722771973bd' into patches/lyslyskom22891031 * commit '722771973bd': (6177 commits) Verify that callablep responses are aligned with reality. ...
Stdio: Silence compiler warnings At least GCC 8.2 does not seem to accept integers standing in for void* at any level with function pointers.
Merge commit '2470270f500c728d10b8895314d8d8b07016e37b' into grubba/typechecker-automap * commit '2470270f500c728d10b8895314d8d8b07016e37b': (18681 commits) Removed the old typechecker. ...
Documentation [Stdio.File]: Fixed some markup issues.
Merge branch 'buffer_mode_proposal_wip'
Stdio.File: update errno correctly
Stdio.File()->read: add optional offset argument and documentation
fixup! Stdio.File()->read: add optional offset argument and documentation
Stdio.File()->read(): advance buffer if possible This commit also removed Stdio.Buffer()->advance() because it is a bad API. It allows one to 'validate' uninitialized memory inside of Stdio.Buffer objects. Instead, we now try to advance the write offset in Buffer objects in Stdio.File()->read(), instead. This is done using a new internal API which can be extended to advance other buffer types in the future.
Stdio.File()->read(): support reading into buffer objects
Merge remote-tracking branch 'origin/8.1' into gobject-introspection
EFUNs: get_dir("") is now an alias for get_dir("."). This is a convenience when recursing with eg dirname(). Also removes a stray debug output.
Avoid sending function name to check_all_args
Simplify error messages and avoid sending function name to get_all_args
Revert "Stdio: Fix debug code." This actually triggers the Pike_fatal() from within the Stdio testsuite now, so apparently this was not quite the fix you were hoping for. This reverts commit 9271a86a1cd90b2dd969e2b929590695e244d4ab.
Revert "Stdio: Fix debug code." This actually triggers the Pike_fatal() from within the Stdio testsuite now, so apparently this was not quite the fix you were hoping for. This reverts commit 9a18f566167bf18256ee58c66c524a0b9e18863a.
Stdio: Fix debug code.
Merge branch 'grubba/fdlib' into 8.0 * grubba/fdlib: (36 commits) I/O [NT]: Updated FD_DEBUG diagnostics. I/O [NT]: Moved FD_SETSIZE definition to global.h. I/O [NT]: Use new low-level functions from Process. I/O [NT]: Added some assertions. I/O [NT]: Added serialization of access to fd handles. I/O [NT]: Use the new low-level functions. I/O [NT]: Added some low-level fd handling functions. Build [NT]: Fix typo of EACCES. I/O [NT]: Document some internal data structures. Stdio: Cleanup File()->truncate(). Configure: Moved tests for truncate64() and ftruncate64(). Stdio [NT]: Fixed warning on NT. Stdio [NT]: Added detection constant __HAVE_UTF8_FS__. I/O [NT]: Added note about the intent of fdlib. Stdio [NT]: Update get_dir() to accept/return UTF8. Stdio [NT]: Cleanup filesystem_stat(). Stdio [NT]: Clean up getcwd(). I/O [NT]: Added fd_get_current_dir_name(). Configure: Check for getwd() and get_current_dir_name(). Stdio [NT]: Clean up cd(). ...
Revert "Stdio.Fd: Avoid direct circular references." This reverts commit e21858ee3fee0ca3e8bc2bb55f2814b8fc9d79d2. This was quite a bit more complicated than expected...
Stdio.Fd: Avoid direct circular references.
Merge branch 'grubba/fdlib' into 8.1 * grubba/fdlib: Stdio: Cleanup File()->truncate(). Configure: Moved tests for truncate64() and ftruncate64().
Stdio: Cleanup File()->truncate(). File()->truncate() now always uses fd_ftruncate().
Merge branch 'grubba/fdlib' into 8.1 * grubba/fdlib: (25 commits) Stdio [NT]: Fixed warning on NT. Stdio [NT]: Added detection constant __HAVE_UTF8_FS__. I/O [NT]: Added note about the intent of fdlib. Stdio [NT]: Update get_dir() to accept/return UTF8. Stdio [NT]: Cleanup filesystem_stat(). Stdio [NT]: Clean up getcwd(). I/O [NT]: Added fd_get_current_dir_name(). Configure: Check for getwd() and get_current_dir_name(). Stdio [NT]: Clean up cd(). I/O [NT]: Added fd_chdir(). Stdio [NT]: Clean up mv(). I/O [NT]: Added fd_rename(). I/O [NT]: Added facility for dynamic lookup of library symbols. Stdio [NT]: Clean up mkdir(). I/O [NT]: Added fd_mkdir(). Configure: Moved API test of mkdir(). Stdio [NT]: Clean up rm(). I/O [NT]: Added fd_unlink(). I/O [NT]: Added fd_rmdir(). Stdio [NT]: Clean up file_truncate(). ...
Stdio [NT]: Fixed warning on NT.
Stdio [NT]: Added detection constant __HAVE_UTF8_FS__. This constant indicates that the filesystem APIs expect paths and filenames in UTF-8.
Stdio.File()->read(): access THIS only once This is purely for cleanup and to help the compiler a bit.
Stdio.File()->write: some refactoring and cleanup Moved shared code out of the different write variants.
Stdio.File()->write(): added support for buffer arguments This new API works like this: int write(Stdio.Buffer|System.Memory|String.Buffer|... buffer, void|int(0..) offset) will try to write data from the buffer at the given offset and return the number of bytes written.
Stdio.File()->write: add documentation for buffer variant
SIMPLE_BAD_ARG_ERROR -> SIMPLE_ARG_TYPE_ERROR
Merge commit '75c9d1806f1a69ca21c27a2c2fe1b4a6ea38e77e' into patches/pike63 * commit '75c9d1806f1a69ca21c27a2c2fe1b4a6ea38e77e': (19587 commits) ...
Merge branch '8.1' into peter/travis
Rip out final remains of OS2 and AmigaOS.
Trim stack after create.
Stdio.File: Don't preallocate huge read buffers. It is common for code to attempt to read huge (typically on the order of 2GB) amounts of data from sources which are expected to be much smaller. Don't fail the read() due to there being no memory for the huge buffer. Fixes multiple build failures.
Stdio.File(): allow reading more than 2GB at once * use size_t instead of int for the number of bytes to read * use flags to control the read behavior * in blocking mode the interpreter lock is only released and re-aquired once per call These changes apply both to read(2) and recvmsg(2).
Stdio.File(): close() fixes. Unify low level calls close_fd() and close_fd_quietly() to reduce code duplication. Fix error handling in close_fd() and do_close_fd(). POSIX says that fds are closed on all errors except EINTR, where it is unspecified. Don't complain about close(2) failing with EBADF if it previously failed with EINTR. Ignore close(2) failing with ECONNRESET. This happens on eg FreeBSD when there is still data pending to be sent and the peer has already closed the connection. Fix documentation for the return value of close(). Potential fix for testsuite failures on FreeBSD.
Remove AIX 3.2 workarounds.
Removed redundant exit code.
Use fast_clone_object instead of low_clone+call_c_initializers
Stdio: Fixed error handling in do_read() some more. Read data should not be thrown away due to a later error... Potential fix for Process.popen() returning zero in some circumstances.
file_read: fixed signal handling Release interpreter lock later and require it earlier to make sure that signals are handled correctly.
Stdio: Avoid using readdir_r(3C). readdir_r() has been marked as deprecated in current glibc, and is redundant in all modern libc's, where readdir(3C) is thread safe as long as the same DIR/dirfd is not used in several threads.
Break out sprintf-related stuff from stralloc.h to sprintf.h. Minor header file cleanup.
byte_buffer: added flags to control growth The way the buffer growth (exponential or not) can now be controlled by setting flags. Additionally there is a flag to toggle between standard realloc and mexec_realloc. This will be used to allocate space for generating machine code.
Stdio.File(): simplify do_recvmsg do_recvmsg() had two code paths, one for big reads using dynamic buffer, one for small reads which used a new string directly. Since we split string headers and data, this split is not needed anymore. We create pike strings from buffers directly without reallocation.
Stdio.File()->read: optimize buffer size This change makes sure that the read buffer size will always exactly be as big as the data we want to read. This usually saves one realloc().
Replace dynamic_buffer API everywhere This change should be purely cosmetic. It replaces the old dynamic_buffer API by the corresponding byte_buffer API everywhere. The wrapper definitions in dynamic_buffer.h will remain for now.
Stdio.File: simplified read()
dynamic_buffer: use new buffer internally The API of dynamic_buffer is now a slim swapper around the new buffer API. This changes many places where the dynamic_buffer internals were directly used.
Stdio: Survive setsockopt(SO_REUSEPORT) failing with EINVAL. The Linux emulation layer in MS Windows 10 behaves this way. Fixes [LysLysKOM 21915643].
Add a 'level' parameter to setsockopt(), and add more constants
Add set_nodelay() function to Stdio.File objects to control Nagling
Document the link between set_keepalive and setsockopt
Implement Stdio.File()->setsockopt()
Stdio: added getprotobyname()
Stdio: Added enums File{Mode,Property}Flags. Also adds corresponding documentation. Fixes some broken documentation references.
Removed PTRDIFF_T_TO_LONG
Stdio: Fixed support for second argument to set_buffer(). Fixes [CID 1353480].
Everyone have INT64 in C99-land.
Rewrite MAP_VARIABLE to PIKE_MAP_VARIABLE.
Since NO_PIKE_SHORTHAND doesn't do much anymore, it isn't needed anywhere.
Removed << on file object. Has been deprecated a while and not properly working always.
SIMPLE_TOO_FEW_ARGS_ERROR should be SIMPLE_WRONG_NUM_ARGS_ERROR since long ago. Replaced them and tighten up argument control in places.
SIMPLE_BAD_ARG_ERROR is only kept for compatibility, but we still had 500+ uses of it.
Build: Fixed quite a few warnings about unused arguments.
Don't clean up the stack in void functions.
dmalloc.h is included from global.h
sys/types.h is included from global.h
Use the existing PTRDIFF_T_TO_LONG
Removed Intel IA64 compiler specific DO_NOT_WARN.
Start using __builtin_unreachable
Static:ified a lot of strings. This is more or less all instances of push_text(static data here). Left to do: make_shared_X_string(static data here). :)
Removed trailing spaces.
Add constants for IP Type Of Service settings
Remove deprecated security system.
Stdio.File: Improved documentation of write(). Restructured and more details about behaviour in nonblocking mode.
Removed a few casts
Fixed some misfirings from Pers script.
Stdio: use -Os for file.c with gcc gcc -O3 generates extremely bloated code for functions in file.c, even though it makes no sense to unroll the loop around open(2).
Binary size: push_constant_text -> push_text when not time-critical. Especially in error handling, and code that does a lot of other string operations anyway the speed gain is not wort the 100+ bytes code size of each instance of push_constant_text This saves about 20K of code size (main pike binary), while not really changing the speed much. push_constant_text that seemed to be in at least pseudo-time-critical code was kept as they were. On a related note, push_constant_text(":") four times in a row creates four different string variables, for obvious reasons. Some of the remaining push_constant_text really should have a module/file local string variable, even though that is more bothersome to create. It might be nice to have this in .cmod files automatically.
memset takes void* as first argument, no casting needed.
Free takes void* and doesn't need any cast anymore.
mallocs nowdays return void*, so no need to case.
Stdio: Added File()->get_dir(). Added function for getting the directory contents relative to an open file.
undefined variable in debug mode
The query_X_callback functions are never added as functions in the low level file
Stdio.File: signed integers don't overflow in C checking for signed overflow using (r<<1) < r does not work. the purpose of these checks is a mystery to me, though.
Stdio.File: Fix grantpt() on Solaris (and others?) grantpt(3C) on Solaris is implemented as fork + exec of "/usr/lib/pt_chmod". Unfortunately the libc function doesn't bother clearing the FD_CLOEXEC flag before the exec, so the fd never got to the helper binary, which caused grantpt(3C) to fail with EPERM.
_Stdio: Don't use PIPE_CAPABILITIES if non-existing
Removed auto bignum checks.
Some tweaks that removes both _Stdio and files from the documentation.
Rewrite Locale.Charset to Charset
_Stdio: Fixed documentation to be more correct.
Doc fixes.
Move documentation to _Stdio.
files -> _Stdio with minimal changes.
Changed some identifiers from files to stdio.
Remove superfluous legacy compat support prior to 7.8.
malloc -> calloc
Stdio: Fix compilation issues on OSes without dirfd(3C). Some operating systems (like eg Solaris 10) do not have dirfd(3C). Fallback to indexing the DIR with dd_fd or d_fd to get the fd.
Stdio.Fd: Fixed minor race in write(). There were some (uncommon) cases where the backend poll flags weren't reset after a successful write.
Stdio.Buffer: output_to() et al now support functions. This reduces the need for proxy objects in higher level code using Stdio.Buffer internally. Also adds support for subtyped objects and multiple inheritance of Stdio.Fd et al.
Removed security system (on this branch)
Removed MAX_FD configure test It only returns the current max anyway, which is usually smaller than the max if you are running as root, and can also be changed at any time at runtime. Instead, use sysconf(_SC_OPEN_MAX) when available if needed, and as a last resort a hardcoded value (on Windows), but as a secondary change all uses except two was removed: o Stdio.get_all_active_fd - On systems without /dev/fd and /proc/self/fd. o On NT, the size of FD_SET is now set to a hardcoded value (64k). The rewrite of get_all_active_fd also speeds it up a lot. Not that it is a frequently used function.
Stdio.File: More race fixes in connect() [bug 7293 (#7293)]. It seems the backend on Linux sometimes may trigger before the connect(2) is done with POLLIN and a state where read(2) fails with ENOTCONN. Reduce the race condition by inhibiting backend callbacks on the fd during connect(2).
Fix warnings
Stdio.IOBuffer -> Stdio.Buffer (part 2)
Stdio.File: Fixed race condition in nonblocking connect(). Potential fix for [bug 7293 (#7293)].
Stdio.Fd: Map _errno. Make it possible to set the errno for a Stdio.File from Pike code. Also added some minimal documentation for the other mapped fields in Stdio.Fd, as well as moving the documentation for the low-level functions from Stdio.File to Stdio.Fd.
Stdio.File: Support UNDEFINED as the first argument to read().
Stdio.File: removed notify() This API has never been completed and does not work as advertised. Also, dnotify has has been superseded by inotify in 2005 which is supported as System.Inotify.
Added more direct mapping to seek. Also added SEEK_DATA and SEEK_HOLE support if they are supported by the OS (solaris, freebsd, linux). In order to keep compatibility the SEEK_<whatever> constants are actually strings. Deprecated the old seek( offset, multiplier, adder ) version of seek (which was, according to the documentation, obsolete before year 2000).
&x[0] -> x
Merge remote-tracking branch 'origin/8.0' into string_alloc Conflicts: src/stralloc.c
perror test is not used.
memcpy is C89 and 4.3BSD
memset is C89 and 4.3BSD
Add nodelay() function to Stdio.File objects to control Nagling
Moved __builtin.IOBuffer to Stdio.IOBuffer (for now)
Fixed an issue with the connect argument parsing
Added support for TCP_FASTOPEN (server and client) The server support is always enabled if possible, on the client side it is enabled if you pass an additional argument to connect (see the documentation).
More consistent use of error macros.
Consistent formatting of function name parameter to get_all_args
Merge branch '8.0' into per/rdrnd
Merge branch '8.0' into gobject-introspection
Merge remote-tracking branch 'origin/7.9' into pdf
Merge remote-tracking branch 'origin/7.9' into ba