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.
lib-src/update-game-score.exe.manifest: New file.
lib-src/Makefile.in (UPDATE_MANIFEST): New variable.
(SCRIPTS): Add $(UPDATE_MANIFEST).
configure.ac: Define and substitute UPDATE_MANIFEST.
Rely on add-function instead.
* lisp/loadup.el: Preload nadvice.
* lisp/isearch.el (isearch-filter-predicates): Rename it back to
isearch-filter-predicate.
(isearch-message-prefix): Use advice-function-mapc and advice
properties to get the isearch-message-prefix.
(isearch-search, isearch-lazy-highlight-search): Revert to funcall
instead of run-hook-with-args-until-failure.
(isearch-filter-visible): Not obsolete any more.
* lisp/replace.el (perform-replace): Revert to funcall
instead of run-hook-with-args-until-failure.
* lisp/wdired.el (wdired-change-to-wdired-mode): Use add-function.
* lisp/dired-aux.el (dired-isearch-filenames-mode): Rename from
dired-isearch-filenames-toggle; make it into a proper minor mode.
Use add/remove-function.
(dired-isearch-filenames-setup, dired-isearch-filenames-end):
Call the minor-mode rather than add/remove-hook.
(dired-isearch-filter-filenames):
Remove isearch-message-prefix property.
* lisp/info.el (Info--search-loop): New function, extracted from Info-search.
Funcall isearch-filter-predicate instead of
run-hook-with-args-until-failure isearch-filter-predicates.
(Info-search): Use it.
(Info-mode): Use isearch-filter-predicate instead of
isearch-filter-predicates.
* src/lisp.mk (lisp): Add nadvice.elc.
* lib-src/makefile.w32-in (lisp2): Add nadvice.elc.
Fixes: debbugs:14714
lib-src/update-game-score.c (read_score): Try reading a character before
probing the stream for EOF. Initialize score->score to zero,
before reading and accumulating the score.
(read_scores): Fix logic that determines which value to return.
Close the input stream when finished reading the scores (avoids
failures in overwriting the file with a new one on MS-Windows,
since a file that is open cannot be deleted).
lib-src/ntlib.h (rename): Don't undefine.
lib-src/ntlib.c (sys_rename): New function, needed for
update-game-score.
Gnulib's emulation of mkostemp doesn't have races that Emacs's does.
* configure.ac (mkostemp): Remove check for this function;
gnulib does the check now.
(mkstemp): Remove check for this no-longer-used function.
* lib/mkostemp.c, lib/secure_getenv.c, lib/tempname.c, lib/tempname.h:
* m4/mkostemp.m4, m4/secure_getenv.m4, m4/tempname.m4:
New files, copied from Gnulib.
* lib/gnulib.mk, m4/gnulib-comp.m4: Regenerate.
* admin/merge-gnulib (GNULIB_MODULES): Add mkostemp.
* lib-src/movemail.c (main):
* lib-src/update-game-score.c (write_scores):
Use mkostemp (which now works on all platforms, due to changes
in the portability layer) rather than mktemp (which has a race)
or mkstemp (which we no longer bother with).
* src/callproc.c (create_temp_file):
* src/filelock.c (create_lock_file):
Assume mkostemp, since it's now provided by Gnulib.
Fixes: debbugs:15015
* lib-src/ebrowse.c (USAGE): Remove macro with too-long string literal ...
(usage_message): ... and replace it with this new static constant
containing multiple literals. All uses changed.
* lib-src/emacsclient.c (print_help_and_exit):
Rewrite to avoid string literals longer than the C89 limits.
(start_daemon_and_retry_set_socket):
Rewrite to avoid non-constant array initializer.
* lib-src/make-docfile.c (enum global_type): Omit trailing comma.
* src/bytecode.c (BYTE_CODE_THREADED): Do not define if __STRICT_ANSI__.
(B__dummy__): New dummy symbol, to pacify C89.
* src/dbusbind.c (XD_DEBUG_MESSAGE): Omit debugging on C89 hosts, since
they can't grok varargs macros.
* src/dispnew.c (add_window_display_history)
(add_frame_display_history):
* src/print.c (print_object):
* src/xdisp.c (debug_method_add):
Use %p printf format only for void pointers.
* src/emacs.c (usage_message): New constant, replacing ...
(USAGE1, USAGE2, USAGE3): Remove; they were too long for C89.
(main): Adjust to usage reorg.
* src/fns.c (syms_of_fns):
* src/profiler.c (syms_of_profiler):
Don't use non-constant struct initializers.
* src/gnutls.h (gnutls_initstage_t):
* src/lisp.h (enum Lisp_Fwd_Type):
* src/lread.c (lisp_file_lexically_bound_p):
* src/xsettings.c (anonymous enum):
Remove trailing comma.
* src/xsettings.c (apply_xft_settings): Use %f, not %lf; %lf is a C99ism.
* src/lisp.h (ENUM_BF): Use unsigned if pedantic.
(DEFUN_FUNCTION_INIT): New macro, that falls back on a cast if pre-C99.
(DEFUN): Use it.
* src/regex.c (const_re_char): New type, to pacify strict C89.
All uses of 'const re_char' replaced to use it.
* src/regex.h (_Restrict_): Rename from __restrict, to avoid clash
with glibc when strict C89. This change is imported from gnulib.
All uses changed.
(_Restrict_arr_): Rename from __restrict_arr, similarly.
* src/sysdep.c (time_from_jiffies) [!HAVE_LONG_LONG_INT]:
Omit GNU_LINUX implementation, since it requires long long.
* src/xterm.c (x_draw_underwave):
Do not assume the traditional order of struct's members.
(x_term_init): Rewrite to avoid the need for non-constant structure
initializers.
I missed these instances of 'static inline' in an earlier sweep.
* ebrowse.c (putstr):
* etags.c (hash):
* make-docfile.c (put_char): No longer inline.
* etags.c (hash): Prefer int to unsigned when either will do.
Fixes: debbugs:12541
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.
* configure.ac (nw): Remove obsolescent warnings.
These aren't needed for clang, or for gcc for that matter.
(emacs_cv_clang): New var, which tests for clang.
Omit warnings that clang is too picky about.
(GLIB_DISABLE_DEPRECATION_WARNINGS): Define this;
needed for Ubuntu 13.04 + clang + --enable-gcc-warnings.
* lib-src/etags.c: Omit unnecessary forward decls.
(print_version, print_help): Declare _Noreturn.
* lib-src/pop.c (socket_connection) [HAVE_GETADDRINFO]: Simplify.
* src/bytecode.c (exec_byte_code):
* src/regex.c:
Redo diagnostic pragmas to pacify clang, too.
* src/dbusbind.c (xd_retrieve_arg): Do not use uninitialized variable.
* src/editfns.c (Fencode_time):
* src/fileio.c (file_accessible_directory_p):
* src/font.c (font_unparse_xlfd):
Use '&"string"[index]' instead of '"string" + (index)'.
* src/undo.c (user_error): Remove; unused.
lib/Makefile.am: If building for MS-Windows, include
nt/gnulib.mk instead of lib/gnulib.mk.
configure.ac: Adapt to MSYS build on MS-Windows.
Makefile.in (NTDIR): New variable, for the MSYS build on
MS-Windows.
(SUBDIR): Add $(NTDIR).
(.PHONY): Add epaths-force-w32.
(msys_to_w32): New variable.
(epaths-force-w32, install-nt, uninstall-nt): New targets.
(lib-src src): Add $(NTLIB) to prerequisites.
(lib lib-src lisp leim nt): Add 'nt'.
(config.status): Use $(CFG).
(.PHONY): Add install-$(NTDIR) and uninstall-$(NTDIR).
(install, install-arch-dep): Add install-$(NTDIR).
(uninstall): Depend on uninstall-$(NTDIR).
(mostlyclean, clean, distclean, bootstrap-clean): Add 'nt'.
* GNUmakefile (CFG): New variable, uses mingw-cfg.site as
CONFIG_SITE for the MSYS build on MS-Windows.
(Makefile): Use $(CFG).
.bzrignore: Ignore *.res, *.tmp, and *.map. Remove
src/emacs.res.
etc/NEWS: Advertise the MSYS build on MS-Windows.
leim/Makefile.in (leim-list.el, check-declare): Use reveal-filename.
lib-src/update-game-score.c [WINDOWSNT]: Include "ntlib.h".
lib-src/ntlib.h (sleep): Update prototype.
(geteuid): Add prototype.
lib-src/ntlib.c (sleep): Now returns an unsigned value.
(getgid): New function.
lib-src/Makefile.in (CLIENTW, LIB_WSOCK32, LIBS_ECLIENT, NTLIB)
(CLIENTRES, WINDRES, NTINC, NTDEPS): New variables.
(INSTALLABLES): Add $(CLIENTW).
(LIBS_MOVE): Use $(LIB_WSOCK32).
($(DESTDIR)${archlibdir}): Use $(EXEEXT) on update-game-score.
(test-distrib${EXEEXT}): Use $(EXEEXT) on test-distrib.
(etags${EXEEXT}, ebrowse${EXEEXT}, ctags${EXEEXT})
(profile${EXEEXT}, make-docfile${EXEEXT}, movemail${EXEEXT})
(emacsclient${EXEEXT}, hexl${EXEEXT}, update-game-score${EXEEXT}):
Add $(NTLIB) to prerequisites. Use $(EXEEXT).
(pop.o): Add pop.h to prerequisites.
(emacsclientw${EXEEXT}, ntlib.o): New targets.
(emacsclient.res): New target.
lisp/subr.el (reveal-filename): New function.
lisp/loadup.el: Compute Emacs executable versions on MS-Windows,
where executables have the .exe extension. Add a hard link
emacs-XX.YY.ZZ.exe on MS-Windows.
lisp/Makefile.in (XARGS_LIMIT): New variable.
(custom-deps, finder-data, autoloads)
($(MH_E_DIR)/mh-loaddefs.el, $(TRAMP_DIR)/tramp-loaddefs.el)
($(CAL_DIR)/cal-loaddefs.el, $(CAL_DIR)/diary-loaddefs.el)
($(CAL_DIR)/hol-loaddefs.el): Use reveal-filename.
(compile-main): Limit xargs according to $(XARGS_LIMIT).
nt/msysconfig.sh: New file.
nt/mingw-cfg.site: New file.
nt/makefile.w32-in (LOCAL_FLAGS): Add -DOLD_PATHS=1.
nt/inc/unistd.h: Include pwd.h and sys/types.h.
nt/inc/sys/time.h (_TIMEVAL_DEFINED, timerisset, timercmp)
(timerclear): Define.
(gettimeofday): Adjust signature to be Posix compatible, by using
the 'restrict' keyword.
nt/inc/sys/stat.h (UTIME_NOW, UTIME_OMIT): Define.
(struct _stat, struct _stati64): Define.
nt/inc/sys/socket.h (timeval): Define only for MSVC.
(FD_SET, FD_CLR, FD_ISSET, fd_set): Redefine only if
EMACS_CONFIG_H is defined.
(timeval): Undefine only for MSVC.
nt/inc/ms-w32.h (HAVE___BUILTIN_UNWIND_INIT, restrict)
(HAVE_WINDOW_SYSTEM, HAVE_MENUS, EMACS_CONFIGURATION)
(EMACS_CONFIG_OPTIONS, HAVE_LONG_LONG_INT)
(HAVE_UNSIGNED_LONG_LONG_INT): Define only if not already defined.
(fileno): Move definition after including stdio.h.
(sigset_t): Guard typedef by _W64.
nt/gnulib.mk: New file.
nt/epaths.nt: New file.
nt/addpm.c [!OLD_PATHS]: Include src/epaths.h, instead of having a
copy of the file names there.
<env_vars> [!OLD_PATHS]: Use macros from epaths.h instead of
literal strings.
nt/Makefile.in: New file.
nt/INSTALL.MSYS: New file.
nt/INSTALL: Mention INSTALL.MSYS.
src/w32.c: Include epaths.h.
(init_environment): Use cmdproxy.exe without leading directories.
Support emacs.exe in src; point SHELL to cmdproxy in ../nt in that
case.
(gettimeofday): Adjust signature and return value to Posix
expectations.
src/unexw32.c (open_output_file): Delete the existing emacs.exe
before creating it, to break the hard link to the versioned
executable.
src/Makefile.in (EMACS_MANIFEST, CM_OBJ, TEMACS_POST_LINK)
(ADDSECTION, EMACS_HEAPSIZE, MINGW_TEMACS_POST_LINK)
(FIRSTFILE_OBJ): New variables.
(W32_RES): Rename to EMACSRES. All users changed.
(base_obj): Use $(CM_OBJ).
(ALLOBJS): Use $(FIRSTFILE_OBJ).
(emacs$(EXEEXT)): Depend on $(ADDSECTION).
(temacs$(EXEEXT)): Use $(TEMACS_POST_LINK), and move
$(W32_RES_LINK) before $(LIBES).
(emacs.res): Depend on $(EMACS_MANIFEST). Put emacs.rc in nt.
* lisp/loadup.el: Just use unversioned DOC.
* Makefile.in (install-doc): DOC file is not version specific any more.
* .bzrignore: Don't ignore DOC-* any more.
* admin/quick-install-emacs: Don't prune DOC-* files a any more.
* doc/lispref/loading.texi (Autoload):
* doc/lispref/help.texi (Documentation Basics, Accessing Documentation)
(Accessing Documentation, Accessing Documentation): DOC-* is now DOC.
* etc/.gitignore: Don't ignore DOC-* any more.
* lib-src/makefile.w32-in ($(DOC)): Use DOC rather than DOC-X.
* msdos/sed1x.inp: Don't rewrite DOC any more.
* nt/makefile.w32-in (clean, top-distclean): DOC-X doesn't exist any more.
* src/Makefile.in (bootstrap-clean): DOC-* doesn't exist any more.
* src/makefile.w32-in (DOC): Use just "DOC".
Added emacsclient.res support to lib-src/.
Fixed temacs and dumping commands in src/Makefile.in.
Miscellaneous fixes all over the place.
Not tried to build yet.
Reported by ׃scar Fuentes in
http://lists.gnu.org/archive/html/emacs-devel/2013-03/msg00699.html
and in
http://lists.gnu.org/archive/html/emacs-devel/2013-03/msg00707.html.
nt/inc/ms-w32.h (USE_NO_MINGW_SETJMP_TWO_ARGS) [_W64]: Define to 1.
For MinGW64, include sys/types.h and time.h.
nt/inc/sys/time.h (struct timeval) [!_W64]: Guard definition with _W64.
(struct timezone) [!_TIMEZONE_DEFINED]: Guard definition with
_TIMEZONE_DEFINED.
nt/addpm.c (_WIN32_IE) [_W64]: For MinGW64, don't define to 0x400.
nt/inc/sys/stat.h: Remove _CRTIMP from prototypes of fstat, stat,
lstat, and fstatat.
lib-src/ntlib.c (struct timespec) [!_TIMEZONE_DEFINED]: Define the
struct only if _TIMEZONE_DEFINED is not defined.
src/w32term.c (WCRANGE, GLYPHSET): Don't define if _W64 is defined.
src/w32.c (REPARSE_DATA_BUFFER): Guard with
MAXIMUM_REPARSE_DATA_BUFFER_SIZE being defined.
* admin/CPP-DEFINES (BSD_SYSTEM, HAVE_FSYNC): Remove.
* admin/merge-gnulib (GNULIB_MODULES): Add fsync, fdatasync.
* configure.ac (BSD_SYSTEM, BSD_SYSTEM_AHB): Remove; no longer needed.
(fsync): Remove check; now done by gnulib.
* lib/fdatasync.c, lib/fsync.c, m4/fdatasync.m4, m4/fsync.m4:
New files, from gnulib.
* lib/gnulib.mk, m4/gnulib-comp.m4: Regenerate.
* lib-src/Makefile.in (LIB_FDATASYNC): New macro.
(emacsclient${EXEEXT}): Use it.
* lib-src/emacsclient.c (main): Use fdatasync, not fsync, since we don't
care about metadata. Keep trying if interrupted.
* lib-src/movemail.c (main, popmail): Don't worry about BSD_SYSTEM, since
fsync is available everywhere (or there is a substitute). Don't
report an error if fsync returns EINVAL.
* nt/inc/ms-w32.h (fdatasync): New macro, suggested by Eli Zaretskii.
* src/Makefile.in (LIB_FDATASYNC): New macro.
(LIBES): Use it.
* src/conf_post.h (BSD_SYSTEM, BSD_SYSTEM_AHB): Remove; no longer needed.
* src/fileio.c (Fwrite_region, write_region_inhibit_fsync):
Don't worry about HAVE_FSYNC, since a substitute fsync is
available if the system lacks one.
(Fwrite_regin): Retry fsync if interrupted.
Fixes: debbugs:13944