1. 29 Aug, 2013 1 commit
    • Eli Zaretskii's avatar
      A possible fix for bug #14333 with hanging at exit on MS-Windows. · 3f940c5a
      Eli Zaretskii authored
       src/w32.c (term_winsock): Call release_listen_threads before calling
       WSACleanup.
       (_sys_wait_accept): Wait for accept event in a loop with a finite
       timeout, instead of waiting indefinitely.  Will hopefully avoid
       hanging during exit because WSACleanup deadlocks waiting for the
       event object to be released.
       src/w32proc.c (release_listen_threads): New function, signals all
       the reader threads that listen for connections to stop waiting.
       src/w32.h (release_listen_threads): Add prototype.
      3f940c5a
  2. 27 Aug, 2013 1 commit
    • Paul Eggert's avatar
      Simplify EMACS_TIME-related code. · 43aac990
      Paul Eggert authored
      This portability layer is no longer needed, since Emacs has been
      using struct timespec as a portability layer for some time.
      Merge from gnulib, incorporating:
      2013-08-27 timespec: new convenience constants and function
      * src/atimer.h, src/buffer.h, src/dispextern.h, src/xgselect.h:
      Include <time.h> rather than "systime.h"; that's all that's needed now.
      * src/dispnew.c: Include <timespec.h> rather than "systime.h";
      that's all that's needed now.
      * src/systime.h (EMACS_TIME): Remove.  All uses changed to struct timespec.
      (EMACS_TIME_RESOLUTION): Remove.  All uses changed to
      TIMESPEC_RESOLUTION.
      (LOG10_EMACS_TIME_RESOLUTION): Remove.  All uses changed to
      LOG10_TIMESPEC_RESOLUTION.
      (EMACS_SECS, emacs_secs_addr): Remove.  All uses changed to tv_sec.
      (EMACS_NSECS): Remove.  All uses changed to tv_nsec.
      (make_emacs_time): Remove.  All used changed to make_timespec.
      (invalid_timespec): Rename from invalid_emacs_time.  All uses changed.
      (current_timespec): Rename from current_emacs_time.  All uses changed.
      (add_emacs_time): Remove.  All uses changed to timespec_add.
      (sub_emacs_time): Remove.  All uses change dot timespec_sub.
      (EMACS_TIME_SIGN): Remove.  All uses changed to timespec_sign.
      (timespec_valid_p): Rename from EMACS_TIME_VALID_P.  All uses changed.
      (EMACS_TIME_FROM_DOUBLE): Remove.  All uses changed to dtotimespec.
      (EMACS_TIME_TO_DOUBLE): Remove.  All uses changed to timespectod.
      (current_timespec): Rename from current_emacs_time.  All uses changed.
      (EMACS_TIME_EQ, EMACS_TIME_LT, EMACS_TIME_LE): Remove.  All uses
      changed to timespec_cmp.
      * src/xgselect.c: Include <timespec.h>, since our .h files don't.
      43aac990
  3. 24 Aug, 2013 1 commit
  4. 09 Aug, 2013 2 commits
  5. 04 Aug, 2013 2 commits
    • Eli Zaretskii's avatar
      Minor fix of the last commit. · 484ab239
      Eli Zaretskii authored
      484ab239
    • Eli Zaretskii's avatar
      Implement mkostemp for MS-Windows. · 63f5c6c2
      Eli Zaretskii authored
       nt/mingw-cfg.site (ac_cv_func_mkostemp): New var with value of "yes".
       nt/inc/ms-w32.h (mkostemp): Declare prototype.
       nt/config.nt (HAVE_MKOSTEMP): Define to 1.
      
       src/w32.c (mkostemp): New function.
       (mktemp): Remove, no longer used.  Most of the code reused in mkostemp.
      
      Fixes: debbugs:15015
      63f5c6c2
  6. 16 Jul, 2013 1 commit
    • Paul Eggert's avatar
      Be simpler and more consistent about reporting I/O errors. · 4e604a5d
      Paul Eggert authored
      * fileio.c (Fcopy_file, Finsert_file_contents, Fwrite_region):
      Say "Read error" and "Write error", rather than "I/O error", or
      "IO error reading", or "IO error writing", when a read or write
      error occurs.
      * process.c (Fmake_network_process, wait_reading_process_output)
      (send_process, Fprocess_send_eof, wait_reading_process_output):
      Capitalize diagnostics consistently.  Put "failed foo" at the
      start of the diagnostic, so that we don't capitalize the
      function name "foo".  Consistently say "failed" for such
      diagnostics.
      * sysdep.c, w32.c (serial_open): Now accepts Lisp string, not C string.
      All callers changed.  This is so it can use report_file_error.
      * sysdep.c (serial_open, serial_configure): Capitalize I/O
      diagnostics consistently as above.
      4e604a5d
  7. 07 Jul, 2013 2 commits
    • Eli Zaretskii's avatar
      MS-Windows followup for 2013-07-07T18:00:14Z!eggert@cs.ucla.edu. · 1d442672
      Eli Zaretskii authored
       nt/inc/sys/socket.h (F_SETFD, O_CLOEXEC, F_DUPFD_CLOEXEC)
       (FD_CLOEXEC): New macros.
      
       src/w32.c (sys_dup): Declare prototype.
      
       src/filelock.c:
       src/emacs.c:
       src/callproc.c [WINDOWSNT]: Include sys/socket.h.
      1d442672
    • Paul Eggert's avatar
      Make file descriptors close-on-exec when possible. · 067428c1
      Paul Eggert authored
      This simplifies Emacs a bit, since it no longer needs to worry
      about closing file descriptors by hand in some cases.
      It also fixes some unlikely races.  Not all such races, as
      libraries often open files internally without setting
      close-on-exec, but it's an improvement.
      * admin/merge-gnulib (GNULIB_MODULES): Add fcntl, pipe2.
      (GNULIB_TOOL_FLAGS): Avoid binary-io, close.  Do not avoid fcntl.
      * configure.ac (mkostemp): New function to check for.
      (PTY_OPEN): Pass O_CLOEXEC to posix_openpt.
      * lib/fcntl.c, lib/getdtablesize.c, lib/pipe2.c, m4/fcntl.m4:
      * m4/getdtablesize.m4, m4/pipe2.m4: New files, taken from gnulib.
      * lib/gnulib.mk, m4/gnulib-comp.m4: Regenerate.
      * nt/gnulib.mk: Remove empty gl_GNULIB_ENABLED_verify section;
      otherwise, gnulib-tool complains given close-on-exec changes.
      * nt/inc/ms-w32.h (pipe): Remove.
      * nt/mingw-cfg.site (ac_cv_func_fcntl, gl_cv_func_fcntl_f_dupfd_cloexec)
      (gl_cv_func_fcntl_f_dupfd_works, ac_cv_func_pipe2): New vars.
      * src/alloc.c (valid_pointer_p) [!WINDOWSNT]:
      * src/callproc.c (Fcall_process) [!MSDOS]:
      * src/emacs.c (main) [!DOS_NT]:
      * src/nsterm.m (ns_term_init):
      * src/process.c (create_process):
      Use 'pipe2' with O_CLOEXEC instead of 'pipe'.
      * src/emacs.c (Fcall_process_region) [HAVE_MKOSTEMP]:
      * src/filelock.c (create_lock_file) [HAVE_MKOSTEMP]:
      Prefer mkostemp with O_CLOEXEC to mkstemp.
      * src/callproc.c (relocate_fd) [!WINDOWSNT]:
      * src/emacs.c (main): Use F_DUPFD_CLOEXEC, not plain F_DUPFD.
      No need to use fcntl (..., F_SETFD, FD_CLOEXEC), since we're
      now using pipe2.
      * src/filelock.c (create_lock_file) [! HAVE_MKOSTEMP]:
      Make the resulting file descriptor close-on-exec.
      * src/lisp.h, src/lread.c, src/process.c (close_load_descs, close_process_descs):
      * src/lread.c (load_descriptor_list, load_descriptor_unwind):
      Remove; no longer needed.  All uses removed.
      * src/process.c (SOCK_CLOEXEC): Define to 0 if not supplied by system.
      (close_on_exec, accept4, process_socket) [!SOCK_CLOEXEC]:
      New functions.
      (socket) [!SOCK_CLOEXEC]: Supply a substitute.
      (Fmake_network_process, Fnetwork_interface_list):
      (Fnetwork_interface_info, server_accept_connection):
      Make newly-created socket close-on-exec.
      * src/sysdep.c (emacs_open, emacs_fopen):
      Make new-created descriptor close-on-exec.
      * src/w32.c (fcntl): Support F_DUPFD_CLOEXEC well enough for Emacs.
      * src/w32.c, src/w32.h (pipe2): Rename from 'pipe', with new flags arg.
      
      Fixes: debbugs:14803
      067428c1
  8. 21 Jun, 2013 1 commit
    • Paul Eggert's avatar
      Use C99-style flexible array members if available. · fbe9e0b9
      Paul Eggert authored
      This avoids some subtle aliasing issues, which typically
      aren't a problem with GCC but may be a problem elsewhere.
      * lib-src/ebrowse.c (struct member, struct alias, struct sym):
      Use FLEXIBLE_ARRAY_MEMBER.
      (add_sym, add_member, make_namespace, register_namespace_alias):
      Use offsetof (struct, flex_array_member), not sizeof (struct), as
      that ports better to pre-C99 non-GCC.
      * src/alloc.c (sdata): New typedef, replacing the old struct sdata.
      It is a struct if GC_CHECK_STRING_BYTES, a union otherwise.
      In either case, it uses a flexible array member rather than
      the old struct hack.  All uses changed.
      (SDATA_NBYTES, sweep_strings) [!GC_CHECK_STRING_BYTES]:
      Adjust to sdata reorganization.
      * src/alloc.c (VBLOCK_BYTES_MIN, allocate_vectorlike, Fgarbage_collect):
      Use offsetof (struct, flex_array_member), not sizeof (struct), as
      that ports better to pre-C99 non-GCC.
      * src/chartab.c (Fmake_char_table, make_sub_char_table, copy_char_table):
      Use CHAR_TABLE_STANDARD_SLOTS rather than its definition,
      as the latter has changed.
      * src/conf_post.h (FLEXIBLE_ARRAY_MEMBER): Move here from w32.c,
      and port better to pre-C99 GCC.
      * src/image.c (struct xpm_cached_color):
      * src/lisp.h (struct Lisp_Vector, struct Lisp_Bool_Vector)
      (struct Lisp_Char_Table, struct Lisp_Sub_Char_Table):
      Use FLEXIBLE_ARRAY_MEMBER.
      * src/lisp.h (string_bytes) [GC_CHECK_STRING_BYTES]:
      Move decl to top level so it gets checked against implementation.
      (CHAR_TABLE_STANDARD_SLOTS): Adjust to struct Lisp_Char_Table change.
      * src/w32.c (FLEXIBLE_ARRAY_MEMBER): Move to conf_post.h.
      fbe9e0b9
  9. 03 Jun, 2013 1 commit
  10. 15 Apr, 2013 1 commit
  11. 01 Apr, 2013 1 commit
  12. 30 Mar, 2013 1 commit
  13. 28 Mar, 2013 2 commits
  14. 27 Mar, 2013 1 commit
  15. 26 Mar, 2013 4 commits
  16. 07 Mar, 2013 1 commit
    • Dmitry Antipov's avatar
      * lisp.h (list2i, list3i): New functions. · 3de717bd
      Dmitry Antipov authored
      (list4i): Move from window.c and make LISP_INLINE.
      * editfns.c (make_lisp_time):
      * fns.c (Flocale_info):
      * keyboard.c (parse_modifiers):
      * xterm.c (x_ewmh_activate_frame): Use list2i.
      * instel.c (signal_after_change):
      * nsfns.m (Fx_server_version, Fxw_color_values):
      * w32fns.c (Fxw_color_values, Fx_server_version):
      * xfns.c (Fxw_color_values, Fx_server_version): Use list3i.
      * fileio.c (Fvisited_file_modtime):
      * nsfns.m (Fns_display_usable_bounds):
      * w32.c (ltime): Use list4i.
      3de717bd
  17. 05 Mar, 2013 1 commit
    • Paul Eggert's avatar
      FILE's lock is now always .#FILE and may be a regular file. · 70743157
      Paul Eggert authored
      * etc/NEWS: Document this.
      * nt/inc/unistd.h (O_NOFOLLOW): New macro.
      * src/filelock.c: Include <c-ctype.h>.
      (MAX_LFINFO): New top-level constant.
      (lock_info_type): Remove members pid, boot_time.  Add members at,
      dot, colon.  Change user member to be the entire buffer, not a
      pointer.  This allows us to handle the case where a foreign
      pid or boot time exceeds the local range.  All uses changed.
      (LINKS_MIGHT_NOT_WORK): New constant.
      (FREE_LOCK_INFO): Remove, as the pieces no longer need freeing.
      (defined_WINDOWSNT): Remove.
      (MAKE_LOCK_NAME, file_in_lock_file_name):
      Always use .#FILE (not .#-FILE) for the file lock,
      even if it is a regular file.
      (rename_lock_file): New function.
      (create_lock_file): Use it.
      (create_lock_file, read_lock_data):
      Prefer a symbolic link for the lock file, falling back on a
      regular file if symlinks don't work.  Do not try to create
      symlinks on MS-Windows, due to security hassles.  Stick with
      POSIXish functions (open, read, write, close, fchmod, readlink, symlink,
      link, rename, unlink, mkstemp) when creating locks, as a GNUish
      host may be using a Windowsish file system, and cannot use
      MS-Windows-only system calls.  Fall back on mktemp if mkstemp
      doesn't work.  Don't fail merely because of a symlink-contents
      length limit in the current file system; fall back on regular
      files.  Increase the symlink contents length limit to 8 KiB, this
      should be big enough for any real use and doesn't crunch the
      stack.
      (create_lock_file, lock_file_1, read_lock_data):
      Simplify allocation of lock file buffers now that they fit in 8 KiB.
      (lock_file_1): Return error number, not bool.  All callers changed.
      (ELOOP): New macro, if not already defined.
      (read_lock_data): Return size of lock file contents, not Lisp object.
      All callers changed.  Handle a race condition if some other process
      replaces a regular-file lock with a symlink lock or vice versa,
      while we're trying to read the lock.
      (current_lock_owner): Parse contents more carefully, to help avoid
      confusing a regular-file lock with some other application's use
      of the file.  Check for lock file contents being too long, or
      not parsing correctly.
      (current_lock_owner, lock_file):
      Allow foreign pid and boot times that exceed the local range.
      (current_lock_owner, lock_if_free, lock_file):
      Simplify allocation of lock file contents.
      * src/w32.c (sys_rename_replace): New function, containing most of
      the contents of the old sys_rename.
      (sys_rename): Use it.
      (fchmod): New dummy function.
      * src/w32.h (sys_rename_replace, fchmod): New decls.
      
      Fixes: debbugs:13807
      70743157
  18. 27 Feb, 2013 1 commit
  19. 25 Feb, 2013 1 commit
    • Eli Zaretskii's avatar
      Implement CLASH_DETECTION for MS-Windows. · 343a2aef
      Eli Zaretskii authored
       src/filelock.c [WINDOWSNT]: Include w32.h.
       (MAKE_LOCK_NAME): Don't use 'lock', it clashes with MS runtime
       function of that name.  Up-case the macro arguments.
       (IS_LOCK_FILE): New macro.
       (fill_in_lock_file_name): Use IS_LOCK_FILE instead of S_ISLNK.
       (create_lock_file): New function, with body extracted from
       lock_file_1.
       [WINDOWSNT]: Implement lock files by writing a regular file with
       the lock information as its contents.
       (read_lock_data): New function, on Posix platforms just calls
       emacs_readlinkat.
       [WINDOWSNT]: Read the lock info from the file.
       (current_lock_owner): Call read_lock_data instead of calling
       emacs_readlinkat directly.
       (lock_file) [WINDOWSNT]: Run the file name through
       dostounix_filename.
       src/w32proc.c (sys_kill): Support the case of SIG = 0, in which case
       just check if the process by that PID exists.
       src/w32.c (sys_open): Don't reset the _O_CREAT flag if _O_EXCL is
       also present, as doing so will fail to error out if the file
       already exists.
       src/makefile.w32-in ($(BLD)/filelock.$(O)): Depend on src/w32.h.
      
       nt/inc/ms-w32.h (BOOT_TIME_FILE): Define.
       nt/config.nt (CLASH_DETECTION): Define to 1.
      
       lisp/emacs-lisp/bytecomp.el (byte-recompile-directory): Reject files
       that match "\`\.#", to avoid compiling lock files, even if they
       are readable (as they are on MS-Windows).
      
       doc/emacs/files.texi (Interlocking): Don't refer to symlinks as the
       exclusive means of locking files.
      
       etc/NEWS: Mention support for lock files on MS-Windows.
      343a2aef
  20. 22 Feb, 2013 1 commit
  21. 16 Feb, 2013 2 commits
  22. 15 Feb, 2013 1 commit
    • Eli Zaretskii's avatar
      Improve error reporting as part of solving bug #13546 on MS-Windows. · bcf7fe2a
      Eli Zaretskii authored
       src/w32.c (sys_socket, sys_bind, sys_connect, sys_gethostname)
       (sys_gethostbyname, sys_getservbyname, sys_getpeername)
       (sys_shutdown, sys_setsockopt, sys_listen, sys_getsockname)
       (sys_accept, sys_recvfrom, sys_sendto, fcntl): In case of failure,
       make sure errno is set to an appropriate value.  (Bug#13546)
       (socket_to_fd): Add assertion against indexing fd_info[] with a
       value that is out of bounds.
       (sys_accept): If fd is negative, do not set up the child_process
       structure for reading.
      bcf7fe2a
  23. 13 Feb, 2013 1 commit
  24. 02 Feb, 2013 2 commits
    • Eli Zaretskii's avatar
      Avoid encoding file names run through dostounix_filename on MS-Windows. · e7ac588e
      Eli Zaretskii authored
       src/w32.c (normalize_filename): Accept an additional argument
       MULTIBYTE; if non-zero, traverse the file name by bytes and don't
       downcase it even if w32-downcase-file-names is non-nil.
       (dostounix_filename): Accept an additional argument MULTIBYTE and
       pass it to normalize_filename.
       (emacs_root_dir): Adjust.
       src/msdos.h (dostounix_filename): Adjust prototype.
       src/w32.h (dostounix_filename): Adjust prototype.
       src/msdos.c (dostounix_filename): Accept an additional argument and
       ignore it.
       (init_environment): Adjust callers of dostounix_filename.
       src/fileio.c (Ffile_name_directory, file_name_as_directory)
       (directory_file_name, Fexpand_file_name)
       (Fsubstitute_in_file_name): [DOS_NT] Adjust call to
       dostounix_filename.
       [WINDOWSNT]: Downcase file names if w32-downcase-file-names is
       non-nil.
       (Fsubstitute_in_file_name): [DOS_NT] Don't downcase environment
       variables, as egetenv is case-insensitive for DOS_NT.
       src/dired.c (file_name_completion): Don't call Fdirectory_file_name
       with an encoded file name.
       src/w32proc.c (Fw32_short_file_name, Fw32_long_file_name): Adjust
       calls to dostounix_filename.
       src/w32fns.c (Fx_file_dialog): Adjust call to dostounix_filename.
       src/unexw32.c (unexec): Adjust call to dostounix_filename.
       src/termcap.c (tgetent) [MSDOS]: Adjust call to dostounix_filename.
       src/emacs.c (decode_env_path) [DOS_NT]: Adjust call to
       dostounix_filename.
       src/callproc.c (Fcall_process) [MSDOS]: Adjust call to
       dostounix_filename.
      e7ac588e
    • Paul Eggert's avatar
      Spelling fixes. · d9c287e5
      Paul Eggert authored
      d9c287e5
  25. 01 Feb, 2013 1 commit
    • Paul Eggert's avatar
      Use fdopendir, fstatat and readlinkat, for efficiency. · 8654f9d7
      Paul Eggert authored
      On my host, this speeds up directory-files-and-attributes by a
      factor of 3, when applied to Emacs's src directory.
      These functions are standardized by POSIX and are common these
      days; fall back on a (slower) gnulib implementation if the host
      is too old to supply them.
      * .bzrignore: Add lib/dirent.h.
      * lib/Makefile.am (libgnu_a_SOURCES): Add openat-die.c, save-cwd.c.
      * lib/careadlinkat.c, lib/careadlinkat.h: Merge from gnulib,
      incorporating: 2013-01-29 careadlinkat: do not provide careadlinkatcwd.
      * lib/gnulib.mk, m4/gnulib-comp.m4: Regenerate.
      * lib/dirent.in.h, lib/fdopendir.c, lib/fstatat.c, lib/openat-priv.h:
      * lib/openat-proc.c, lib/openat.h, m4/dirent_h.m4, m4/fdopendir.m4:
      * m4/fstatat.m4: New files, from gnulib.
      * lib/openat-die.c, lib/save-cwd.c, lib/save-cwd.h: New files.
      These last three are specific to Emacs and are not copied from gnulib.
      They are simpler than the gnulib versions and are tuned for Emacs.
      * admin/merge-gnulib (GNULIB_MODULES): Add fdopendir, fstatat, readlinkat.
      (GNULIB_TOOL_FLAGS): Do not avoid at-internal, openat-h.
      Avoid dup, open, opendir.
      * nt/inc/sys/stat.h (fstatat):
      * nt/inc/unistd.h (readlinkat): New decls.
      * src/conf_post.h (GNULIB_SUPPORT_ONLY_AT_FDCWD): Remove.
      * src/dired.c: Include <fcntl.h>.
      (open_directory): New function, which uses open and fdopendir
      rather than opendir.  DOS_NT platforms still use opendir, though.
      (directory_files_internal, file_name_completion): Use it.
      (file_attributes): New function, with most of the old Ffile_attributes.
      (directory_files_internal, Ffile_attributes): Use it.
      (file_attributes, file_name_completion_stat): First arg is now fd,
      not dir name.  All uses changed.  Use fstatat rather than lstat +
      stat.
      (file_attributes): Use emacs_readlinkat rather than Ffile_symlink_p.
      * src/fileio.c: Include <allocator.h>, <careadlinkat.h>.
      (emacs_readlinkat): New function, with much of the old
      Ffile_symlink_p, but with an fd argument for speed.
      It uses readlinkat rather than careadlinkatcwd, so that it
      need not assume the working directory.
      (Ffile_symlink_p): Use it.
      * src/filelock.c (current_lock_owner): Use emacs_readlinkat
      rather than emacs_readlink.
      * src/lisp.h (emacs_readlinkat): New decl.
      (READLINK_BUFSIZE, emacs_readlink): Remove.
      * src/sysdep.c: Do not include <allocator.h>, <careadlinkat.h>.
      (emacs_norealloc_allocator, emacs_readlink): Remove.
      This stuff is moved to fileio.c.
      * src/w32.c (fstatat, readlinkat): New functions.
      (careadlinkat): Don't check that fd == AT_FDCWD.
      (careadlinkatcwd): Remove; no longer needed.
      
      Fixes: debbugs:13539
      8654f9d7
  26. 28 Jan, 2013 1 commit
  27. 27 Jan, 2013 1 commit
  28. 26 Jan, 2013 1 commit
  29. 25 Jan, 2013 3 commits