commit cf1d7034445e7896c34f88256e5d7f2674a4f7ee (HEAD, refs/remotes/origin/master) Author: Eli Zaretskii Date: Sat Dec 26 10:23:04 2020 +0200 Fix messages with plural forms in todo-mode.el * lisp/calendar/todo-mode.el (todo-move-item, todo-item-undone) (todo-category-completions): Use 'ngettext' instead of hard-coding plural forms by hand. diff --git a/lisp/calendar/todo-mode.el b/lisp/calendar/todo-mode.el index 3975a9ba6a..637df85f5d 100644 --- a/lisp/calendar/todo-mode.el +++ b/lisp/calendar/todo-mode.el @@ -2745,9 +2745,10 @@ section in the category moved to." (setq ov (make-overlay (save-excursion (todo-item-start)) (save-excursion (todo-item-end)))) (overlay-put ov 'face 'todo-search)) - (let* ((pl (if (and marked (> (cdr marked) 1)) "s" "")) - (cat+file (todo-read-category (concat "Move item" pl - " to category: ") + (let* ((num (if (not marked) 1 (cdr marked))) + (cat+file (todo-read-category + (ngettext "Move item to category: " + "Move items to category: " num) nil file))) (while (and (equal (car cat+file) cat1) (equal (cdr cat+file) file1)) @@ -2974,7 +2975,7 @@ comments without asking." (interactive) (let* ((cat (todo-current-category)) (marked (assoc cat todo-categories-with-marks)) - (pl (if (and marked (> (cdr marked) 1)) "s" ""))) + (num (if (not marked) 1 (cdr marked)))) (when (or marked (todo-done-item-p)) (let ((buffer-read-only) (opoint (point)) @@ -2982,6 +2983,9 @@ comments without asking." (first 'first) (item-count 0) (diary-count 0) + (omit-prompt (ngettext "Omit comment from restored item? " + "Omit comments from restored items? " + num)) start end item ov npoint undone) (and marked (goto-char (point-min))) (catch 'done @@ -3013,10 +3017,7 @@ comments without asking." (if (eq first 'first) (setq first (if (eq todo-undo-item-omit-comment 'ask) - (when (todo-y-or-n-p - (concat "Omit comment" pl - " from restored item" - pl "? ")) + (when (todo-y-or-n-p omit-prompt) 'omit) (when todo-undo-item-omit-comment 'omit))) t) @@ -5782,11 +5783,13 @@ have been removed." (delete f todo-category-completions-files)) (push f deleted))) (when deleted - (let ((pl (> (length deleted) 1)) + (let ((ndeleted (length deleted)) (names (mapconcat (lambda (f) (concat "\"" f "\"")) deleted ", "))) - (message (concat "File" (if pl "s" "") " %s ha" (if pl "ve" "s") - " been deleted and removed from\n" - "the list of category completion files") + (message (concat + (ngettext "File %s has been deleted and removed from\n" + "Files %s have been deleted and removed from\n" + ndeleted) + "the list of category completion files") names)) (put 'todo-category-completions-files 'custom-type `(set ,@(todo--files-type-list))) commit 60bfa84e41449020d1122a1d18b7c11cb73211f3 Author: Paul Eggert Date: Fri Dec 25 19:16:27 2020 -0800 Fix issues with lib/malloc out-of-dir builds Problem reported by Mattias Engdegård in: https://lists.gnu.org/r/emacs-devel/2020-12/msg01626.html * configure.ac: If the scratch_buffer module is enabled, create lib/malloc and (if doing dependencies) lib/deps/malloc. * lib/Makefile.in (DEPFLAGS) [AUTO_DEPEND]: No longer any need to squash lib dependencies into a single directory. (clean): Also remove */*.o and $(DEPDIR)/*/*.d, to clean out malloc/*.o and deps/malloc/*.d. Just remove *.d files in dependencies so that rm does not complain about not being able to remove deps/malloc. (extraclean): Also remove malloc, if it is empty. diff --git a/configure.ac b/configure.ac index 888b415148..bf768441fe 100644 --- a/configure.ac +++ b/configure.ac @@ -5878,6 +5878,12 @@ if test $AUTO_DEPEND = yes; then AS_MKDIR_P([$dir/deps]) done fi +if $gl_gnulib_enabled_scratch_buffer; then + AS_MKDIR_P([lib/malloc]) + if test $AUTO_DEPEND = yes; then + AS_MKDIR_P([lib/deps/malloc]) + fi +fi AC_OUTPUT diff --git a/lib/Makefile.in b/lib/Makefile.in index a280b7a331..e6b1ae6a9a 100644 --- a/lib/Makefile.in +++ b/lib/Makefile.in @@ -67,7 +67,7 @@ endif DEPDIR = deps ifeq ($(AUTO_DEPEND),yes) - DEPFLAGS = -MMD -MF $(DEPDIR)/$(*F).d -MP + DEPFLAGS = -MMD -MF $(DEPDIR)/$*.d -MP -include $(ALLOBJS:%.o=$(DEPDIR)/%.d) else DEPFLAGS = @@ -118,7 +118,7 @@ TAGS: $(ETAGS) $(tagsfiles) .PHONY: $(ETAGS) tags clean: - rm -f ./*.[ao] ./*-t \#* $(DEPDIR)/* + rm -f ./*.[ao] ./*/*.o ./*-t \#* $(DEPDIR)/*.d $(DEPDIR)/*/*.d mostlyclean: clean rm -f $(filter-out %-t,$(MOSTLYCLEANFILES)) distclean bootstrap-clean: mostlyclean @@ -127,7 +127,7 @@ distclean bootstrap-clean: mostlyclean maintainer-clean: distclean rm -f TAGS gnulib.mk extraclean: distclean - -rmdir sys 2>/dev/null + -rmdir malloc sys 2>/dev/null .PHONY: mostlyclean clean distclean bootstrap-clean maintainer-clean commit a63855cd21aefee993b622241993043a31894c0c Author: Lars Ingebrigtsen Date: Sat Dec 26 03:59:35 2020 +0100 Kill the scdaemon after doing the mml-sec tests * test/lisp/gnus/mml-sec-tests.el (mml-sec-test--kill-gpg-agent): Kill the scdaemon, too (bug#43358). diff --git a/test/lisp/gnus/mml-sec-tests.el b/test/lisp/gnus/mml-sec-tests.el index a144e2e4ff..e3a8c81cc6 100644 --- a/test/lisp/gnus/mml-sec-tests.el +++ b/test/lisp/gnus/mml-sec-tests.el @@ -884,7 +884,8 @@ So the second decryption fails." (dolist (pid (list-system-processes)) (let ((atts (process-attributes pid))) (when (and (equal (cdr (assq 'user atts)) (user-login-name)) - (equal (cdr (assq 'comm atts)) "gpg-agent") + (or (equal (cdr (assq 'comm atts)) "gpg-agent") + (equal (cdr (assq 'comm atts)) "scdaemon")) (string-match (concat "homedir.*" (regexp-quote (directory-file-name commit 90e40099debaa876273ae560ed8e66985719dd0c Author: Lars Ingebrigtsen Date: Sat Dec 26 00:57:01 2020 +0100 Fix infloop in memory-report * lisp/emacs-lisp/memory-report.el (memory-report--object-size-1): Fix infloop on circular lists. diff --git a/lisp/emacs-lisp/memory-report.el b/lisp/emacs-lisp/memory-report.el index b532ddc56c..332749987c 100644 --- a/lisp/emacs-lisp/memory-report.el +++ b/lisp/emacs-lisp/memory-report.el @@ -204,7 +204,9 @@ by counted more than once." (cl-incf total (memory-report--object-size counted (car value)))) (if (cdr value) (if (consp (cdr value)) - (setq value (cdr value)) + (if (gethash (cdr value) counted) + (setq value nil) + (setq value (cdr value))) (cl-incf total (memory-report--object-size counted (cdr value))) (setq value nil)) (setq value nil))) commit d18b1c8c7583b981d4f3d687e49e82250d51634f Author: Lars Ingebrigtsen Date: Fri Dec 25 22:44:56 2020 +0100 Fix package reloading problems on systems with symlinks * lisp/emacs-lisp/package.el (package--files-load-history): We're comparing the truenames, so ensure that we've using that everywhere. This fixes problems when there's symlinks in the paths. diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el index 0170e61e12..bc450b09d0 100644 --- a/lisp/emacs-lisp/package.el +++ b/lisp/emacs-lisp/package.el @@ -830,7 +830,7 @@ correspond to previously loaded files (those returned by (mapcar (lambda (x) (let ((f (car x))) (and (stringp f) - (file-name-sans-extension f)))) + (file-name-sans-extension (file-truename f))))) load-history))) (defun package--list-of-conflicts (dir history) commit 443a53874b8cca1b382509fde1f0f8f70f56e916 Author: Lars Ingebrigtsen Date: Fri Dec 25 22:29:42 2020 +0100 Refactor package--list-loaded-files for easier debuggability * lisp/emacs-lisp/package.el (package--files-load-history) (package--list-of-conflicts): Factor out from... (package--list-loaded-files): ... this function for easier debuggability. diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el index fa93ffd0cc..0170e61e12 100644 --- a/lisp/emacs-lisp/package.el +++ b/lisp/emacs-lisp/package.el @@ -825,40 +825,45 @@ correspond to previously loaded files (those returned by (declare-function find-library-name "find-func" (library)) +(defun package--files-load-history () + (delq nil + (mapcar (lambda (x) + (let ((f (car x))) + (and (stringp f) + (file-name-sans-extension f)))) + load-history))) + +(defun package--list-of-conflicts (dir history) + (delq + nil + (mapcar + (lambda (x) (let* ((file (file-relative-name x dir)) + ;; Previously loaded file, if any. + (previous + (ignore-errors + (file-name-sans-extension + (file-truename (find-library-name file))))) + (pos (when previous (member previous history)))) + ;; Return (RELATIVE-FILENAME . HISTORY-POSITION) + (when pos + (cons (file-name-sans-extension file) (length pos))))) + (directory-files-recursively dir "\\`[^\\.].*\\.el\\'")))) + (defun package--list-loaded-files (dir) "Recursively list all files in DIR which correspond to loaded features. Returns the `file-name-sans-extension' of each file, relative to DIR, sorted by most recently loaded last." - (let* ((history (delq nil - (mapcar (lambda (x) - (let ((f (car x))) - (and (stringp f) - (file-name-sans-extension f)))) - load-history))) + (let* ((history (package--files-load-history)) (dir (file-truename dir)) ;; List all files that have already been loaded. - (list-of-conflicts - (delq - nil - (mapcar - (lambda (x) (let* ((file (file-relative-name x dir)) - ;; Previously loaded file, if any. - (previous - (ignore-errors - (file-name-sans-extension - (file-truename (find-library-name file))))) - (pos (when previous (member previous history)))) - ;; Return (RELATIVE-FILENAME . HISTORY-POSITION) - (when pos - (cons (file-name-sans-extension file) (length pos))))) - (directory-files-recursively dir "\\`[^\\.].*\\.el\\'"))))) + (list-of-conflicts (package--list-of-conflicts dir history))) ;; Turn the list of (FILENAME . POS) back into a list of features. Files in ;; subdirectories are returned relative to DIR (so not actually features). (let ((default-directory (file-name-as-directory dir))) (mapcar (lambda (x) (file-truename (car x))) - (sort list-of-conflicts - ;; Sort the files by ascending HISTORY-POSITION. - (lambda (x y) (< (cdr x) (cdr y)))))))) + (sort list-of-conflicts + ;; Sort the files by ascending HISTORY-POSITION. + (lambda (x y) (< (cdr x) (cdr y)))))))) ;;;; `package-activate' ;; This function activates a newer version of a package if an older commit e1eabc8ee114a171107e892a3ad1437a9d18069e Author: Lars Ingebrigtsen Date: Fri Dec 25 21:19:37 2020 +0100 Disable some semantic tests on systems without g++ * test/lisp/cedet/semantic-utest-ia.el: Disable g++ tests on systems without g++. diff --git a/test/lisp/cedet/semantic-utest-ia.el b/test/lisp/cedet/semantic-utest-ia.el index c99ef97b50..ea1a779098 100644 --- a/test/lisp/cedet/semantic-utest-ia.el +++ b/test/lisp/cedet/semantic-utest-ia.el @@ -86,6 +86,7 @@ (should-not (semantic-ia-utest tst)))) (ert-deftest semantic-utest-ia-nsp.cpp () + (skip-unless (executable-find "g++")) (let ((tst (expand-file-name "testnsp.cpp" semantic-utest-test-directory))) (should (file-exists-p tst)) (should-not (semantic-ia-utest tst)))) @@ -96,6 +97,7 @@ (should-not (semantic-ia-utest tst)))) (ert-deftest semantic-utest-ia-namespace.cpp () + (skip-unless (executable-find "g++")) (let ((tst (expand-file-name "testnsp.cpp" semantic-utest-test-directory))) (should (file-exists-p tst)) (should-not (semantic-ia-utest tst)))) commit c9fb3474c9d596675d3ae53d7db59264424c7eb3 Author: Lars Ingebrigtsen Date: Fri Dec 25 21:09:31 2020 +0100 Skip some mml tests that rely on CMS if that's not installed diff --git a/test/lisp/gnus/mml-sec-tests.el b/test/lisp/gnus/mml-sec-tests.el index 20d8e03c38..a144e2e4ff 100644 --- a/test/lisp/gnus/mml-sec-tests.el +++ b/test/lisp/gnus/mml-sec-tests.el @@ -432,6 +432,7 @@ In both cases, the first key is customized for signing and encryption." (ert-deftest mml-secure-select-preferred-keys-4 () "Multiple keys can be recorded per recipient or signature." (skip-unless (test-conf)) + (skip-unless (ignore-errors (epg-find-configuration 'CMS))) (mml-secure-test-fixture (lambda () (let ((pcontext (epg-make-context 'OpenPGP)) @@ -590,6 +591,7 @@ In this test, the single matching key is chosen automatically." "Encrypt message; then decrypt and test for expected result. In this test, the encryption key needs to fixed among multiple ones." (skip-unless (test-conf)) + (skip-unless (ignore-errors (epg-find-configuration 'CMS))) ;; sub@example.org with multiple candidate keys, ;; fixture customizes preferred ones. (mml-secure-test-key-fixture @@ -603,6 +605,7 @@ In this test, the encryption key needs to fixed among multiple ones." "Encrypt message; then decrypt and test for expected result. In this test, encrypt-to-self variables are set to t." (skip-unless (test-conf)) + (skip-unless (ignore-errors (epg-find-configuration 'CMS))) ;; sub@example.org with multiple candidate keys, ;; fixture customizes preferred ones. (mml-secure-test-key-fixture @@ -745,6 +748,7 @@ Use sign-with-sender and encrypt-to-self." (ert-deftest mml-secure-sign-verify-1 () "Sign message with sender; then verify and test for expected result." (skip-unless (test-conf)) + (skip-unless (ignore-errors (epg-find-configuration 'CMS))) (mml-secure-test-key-fixture (lambda () (dolist (method (sign-standards) nil) commit 00b8fdf29b83092a830f85e73084382c3a166ed3 Author: Lars Ingebrigtsen Date: Fri Dec 25 20:56:22 2020 +0100 Fix gpg-agent killing in mml-sec-tests * test/lisp/gnus/mml-sec-tests.el (mml-sec-test--kill-gpg-agent): Identify the gpg-agent more successfully after the resource dir makeover. diff --git a/test/lisp/gnus/mml-sec-tests.el b/test/lisp/gnus/mml-sec-tests.el index a6002b4d51..20d8e03c38 100644 --- a/test/lisp/gnus/mml-sec-tests.el +++ b/test/lisp/gnus/mml-sec-tests.el @@ -883,7 +883,8 @@ So the second decryption fails." (equal (cdr (assq 'comm atts)) "gpg-agent") (string-match (concat "homedir.*" - (regexp-quote (ert-resource-directory))) + (regexp-quote (directory-file-name + (ert-resource-directory)))) (cdr (assq 'args atts)))) (call-process "kill" nil nil nil (format "%d" pid)))))) commit 90ec81f5b243b6b7b3ebe2de394b20e8078ebc96 Merge: 47799cc02b b242bbb073 Author: Glenn Morris Date: Fri Dec 25 10:36:48 2020 -0800 Merge from origin/emacs-27 b242bbb073 (origin/emacs-27) ; lisp/org/org.el: Fix Version header. e0fc939c5f Add more details to the "word processor" section fda9b3e83a * src/Makefile.in (DO_CODESIGN): Fix expected architecture... commit 47799cc02b887c82ac386391fcf6c522f13943d0 Merge: 2e20749e57 6bf22c933d Author: Glenn Morris Date: Fri Dec 25 10:36:48 2020 -0800 ; Merge from origin/emacs-27 The following commit was skipped: 6bf22c933d Codesign the executable on recene MacOS systems commit 2e20749e57164982df962c8f373e98bb40dd7d19 Merge: 1ca6add75f 5d46593568 Author: Glenn Morris Date: Fri Dec 25 10:36:48 2020 -0800 Merge from origin/emacs-27 5d46593568 Support build of Emacs on ARM Macos machines 7f8793e5f1 Update to Org 9.4.4 7b3367a0b5 * lisp/so-long.el: Decrease use of passive voice. a90836c638 * doc/misc/efaq.texi (New in Emacs 27): Add section. 711fe70dd8 * doc/misc/efaq.texi (Latest version of Emacs): Bump version. 52b30834fb * lisp/face-remap.el (face-remap-set-base): Doc fix. (Bug... b3fe0ac62e Correct argument order in comment commit b242bbb073b501f7a4d4569c2d70cde522abbea3 (refs/remotes/origin/emacs-27) Author: Glenn Morris Date: Fri Dec 25 10:36:25 2020 -0800 ; lisp/org/org.el: Fix Version header. This is flagged by the single org test that exists in Emacs. diff --git a/lisp/org/org.el b/lisp/org/org.el index 1f7e434cef..06e516539e 100644 --- a/lisp/org/org.el +++ b/lisp/org/org.el @@ -8,7 +8,7 @@ ;; Keywords: outlines, hypermedia, calendar, wp ;; Homepage: https://orgmode.org -;; Version: 9.4.3 +;; Version: 9.4.4 ;; This file is part of GNU Emacs. ;; commit 1ca6add75f81eac83dc7e11ec771c86f14be6a8e Author: Michael Albinus Date: Fri Dec 25 18:45:29 2020 +0100 Tag another Tramp test :unstable on emba * test/lisp/net/tramp-tests.el (tramp-test31-interrupt-process) (tramp-test43-asynchronous-requests): Tag them :unstable on emba. diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el index fd0c4d6f4b..c875662793 100644 --- a/test/lisp/net/tramp-tests.el +++ b/test/lisp/net/tramp-tests.el @@ -6255,7 +6255,8 @@ This is needed in timer functions as well as process filters and sentinels." "Check parallel asynchronous requests. Such requests could arrive from timers, process filters and process sentinels. They shall not disturb each other." - :tags '(:expensive-test) + :tags (if (getenv "EMACS_EMBA_CI") + '(:expensive-test :unstable) '(:expensive-test)) (skip-unless (tramp--test-enabled)) ;; Prior Emacs 27, `shell-file-name' was hard coded as "/bin/sh" for ;; remote processes in Emacs. That doesn't work for tramp-adb.el. commit e497a013f71ab89d2524631cd63a74b02c01b022 Author: Michael Albinus Date: Fri Dec 25 17:05:36 2020 +0100 Tag Tramp test :unstable * test/lisp/net/tramp-tests.el (tramp-test31-interrupt-process): Tag it :unstable on emba. diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el index 9dd98037a0..fd0c4d6f4b 100644 --- a/test/lisp/net/tramp-tests.el +++ b/test/lisp/net/tramp-tests.el @@ -4663,7 +4663,8 @@ If UNSTABLE is non-nil, the test is tagged as `:unstable'." (ert-deftest tramp-test31-interrupt-process () "Check `interrupt-process'." - :tags '(:expensive-test) + :tags (if (getenv "EMACS_EMBA_CI") + '(:expensive-test :unstable) '(:expensive-test)) (skip-unless (tramp--test-enabled)) (skip-unless (tramp--test-sh-p)) (skip-unless (not (tramp--test-crypt-p))) commit 3649160f618e7ec36dcca7be3212b3572c03de38 Author: Eli Zaretskii Date: Fri Dec 25 16:11:49 2020 +0200 ; * etc/NEWS: Announce the last change. diff --git a/etc/NEWS b/etc/NEWS index b65f184bc8..a320acb5fa 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -2235,6 +2235,15 @@ do not support the old calling conventions any longer. don't contain any NUL bytes. This avoids subtle bugs caused by silently using only the part of the filename until the first NUL byte. +** New coding-systems for EBCDIC variants. +New coding-systems 'ibm256', 'ibm273', 'ibm274', 'ibm277', 'ibm278', +'ibm280', 'ibm281', 'ibm284', 'ibm285', 'ibm290', 'ibm297'. These are +variants of the EBCDIC encoding tailored to some European and Japanese +locales. They are also available as aliases 'ebcdic-cp-*' (e.g., +'ebcdic-cp-fi' for the Finnish variant 'ibm278'), and 'cp2xx' (e.g., +'cp278' for 'ibm278'). There are also new charsets 'ibm2xx' to +support these coding-systems. + * Changes in Emacs 28.1 on Non-Free Operating Systems commit a9413dd2d12b4ecf1c76c805a24f46e830e1da3d Author: Eli Zaretskii Date: Fri Dec 25 15:58:15 2020 +0200 Fix last change * lisp/international/mule-conf.el (ebcdic-int1, cp256, cp273) (ebcdic-be, cp274, ebcdic-br, cp275, ebcdic-cp-dk, ebcdic-cp-no) (cp277, ebcdic-cp-fi, ebcdic-cp-se, cp278, ebcdic-cp-it, cp280) (ebcdic-jp-e, cp281, ebcdic-cp-es, cp284, ebcdic-cp-gb, cp285) (ebcdic-jp-kana, cp290, ebcdic-cp-fr, cp297): Remove charset aliases, they are not really needed. * lisp/language/english.el (ibm275): Move from here... * lisp/language/european.el (ibm275): ...to here. diff --git a/lisp/international/mule-conf.el b/lisp/international/mule-conf.el index dd6d0326d7..3b436864f8 100644 --- a/lisp/international/mule-conf.el +++ b/lisp/international/mule-conf.el @@ -1081,8 +1081,6 @@ :code-space [0 255] :mime-charset 'ibm256 :map "IBM256") -(define-charset-alias 'ebcdic-int1 'ibm256) -(define-charset-alias 'cp256 'ibm256) (define-charset 'ibm273 "Austrian / German version of EBCDIC" @@ -1090,7 +1088,6 @@ :code-space [0 255] :mime-charset 'ibm273 :map "IBM273") -(define-charset-alias 'cp273 'ibm273) (define-charset 'ibm274 "Belgian version of EBCDIC" @@ -1098,8 +1095,6 @@ :code-space [0 255] :mime-charset 'ibm274 :map "IBM274") -(define-charset-alias 'ebcdic-be 'ibm274) -(define-charset-alias 'cp274 'ibm274) (define-charset 'ibm275 "Brazilian version of EBCDIC" @@ -1107,8 +1102,6 @@ :code-space [0 255] :mime-charset 'ibm275 :map "IBM275") -(define-charset-alias 'ebcdic-br 'ibm275) -(define-charset-alias 'cp275 'ibm275) (define-charset 'ibm277 "Danish / Norwegian version of EBCDIC" @@ -1116,9 +1109,6 @@ :code-space [0 255] :mime-charset 'ibm277 :map "IBM277") -(define-charset-alias 'ebcdic-cp-dk 'ibm277) -(define-charset-alias 'ebcdic-cp-no 'ibm277) -(define-charset-alias 'cp277 'ibm277) (define-charset 'ibm278 "Finnish / Swedish version of EBCDIC" @@ -1126,9 +1116,6 @@ :code-space [0 255] :mime-charset 'ibm278 :map "IBM278") -(define-charset-alias 'ebcdic-cp-fi 'ibm278) -(define-charset-alias 'ebcdic-cp-se 'ibm278) -(define-charset-alias 'cp278 'ibm278) (define-charset 'ibm280 "Italian version of EBCDIC" @@ -1136,8 +1123,6 @@ :code-space [0 255] :mime-charset 'ibm270 :map "IBM280") -(define-charset-alias 'ebcdic-cp-it 'ibm280) -(define-charset-alias 'cp280 'ibm280) (define-charset 'ibm281 "Japanese-E version of EBCDIC" @@ -1145,8 +1130,6 @@ :code-space [0 255] :mime-charset 'ibm281 :map "IBM281") -(define-charset-alias 'ebcdic-jp-e 'ibm281) -(define-charset-alias 'cp281 'ibm281) (define-charset 'ibm284 "Spanish version of EBCDIC" @@ -1154,8 +1137,6 @@ :code-space [0 255] :mime-charset 'ibm284 :map "IBM284") -(define-charset-alias 'ebcdic-cp-es 'ibm284) -(define-charset-alias 'cp284 'ibm284) (define-charset 'ibm285 "UK english version of EBCDIC" @@ -1163,8 +1144,6 @@ :code-space [0 255] :mime-charset 'ibm285 :map "IBM285") -(define-charset-alias 'ebcdic-cp-gb 'ibm285) ;; how this differs from ebcdic-uk? -(define-charset-alias 'cp285 'ibm285) (define-charset 'ibm290 "Japanese katakana version of EBCDIC" @@ -1172,8 +1151,6 @@ :code-space [0 255] :mime-charset 'ibm290 :map "IBM290") -(define-charset-alias 'ebcdic-jp-kana 'ibm290) -(define-charset-alias 'cp290 'ibm290) (define-charset 'ibm297 "French version of EBCDIC" @@ -1181,8 +1158,6 @@ :code-space [0 255] :mime-charset 'ibm297 :map "IBM297") -(define-charset-alias 'ebcdic-cp-fr 'ibm297) -(define-charset-alias 'cp297 'ibm297) (define-charset 'ibm1047 ;; Says groff: diff --git a/lisp/language/english.el b/lisp/language/english.el index d5254effa9..b7af84c8f7 100644 --- a/lisp/language/english.el +++ b/lisp/language/english.el @@ -70,14 +70,6 @@ Nothing special is needed to handle English.") (define-coding-system-alias 'ebcdic-int 'ibm038) (define-coding-system-alias 'cp038 'ibm038) -(define-coding-system 'ibm275 - "Brazilian version of EBCDIC" - :coding-type 'charset - :charset-list '(ibm275) - :mnemonic ?*) -(define-coding-system-alias 'ebcdic-br 'ibm275) -(define-coding-system-alias 'cp275 'ibm275) - ;; Make "ASCII" an alias of "English" language environment. (set-language-info-alist "ASCII" (cdr (assoc "English" language-info-alist))) diff --git a/lisp/language/european.el b/lisp/language/european.el index 99f062215f..1f9a15333b 100644 --- a/lisp/language/european.el +++ b/lisp/language/european.el @@ -347,6 +347,14 @@ Latin-9 is sometimes nicknamed `Latin-0'.")) (define-coding-system-alias 'ebcdic-be 'ibm274) (define-coding-system-alias 'cp274 'ibm274) +(define-coding-system 'ibm275 + "Brazilian version of EBCDIC" + :coding-type 'charset + :charset-list '(ibm275) + :mnemonic ?*) +(define-coding-system-alias 'ebcdic-br 'ibm275) +(define-coding-system-alias 'cp275 'ibm275) + (define-coding-system 'ibm277 "Danish / Norwegian version of EBCDIC" :coding-type 'charset commit c3c1863d9504dd04ca6d5f169de2d0348ea78d62 Author: Timo Myyrä Date: Thu Dec 24 17:29:49 2020 +0200 Add support for more EBCDIC code pages IBM2XX There was already charset file present in etc/charsets for IBM2XX character sets but there wasn't definitions for them in Emacs. Add character set and coding system definitions for them. * lisp/language/japanese.el (ibm281, ibm290): * lisp/language/european.el (ibm256, ibm273, ibm274, ibm277) (ibm278, ibm280, ibm284, ibm285, ibm297): * lisp/language/english.el (ibm275): New coding systems. * lisp/international/mule-conf.el (ibm256, ibm273, ibm274) (ibm275, ibm277, ibm278, ibm280, ibm281, ibm284, ibm285, ibm290) (ibm297): New charsets. diff --git a/lisp/international/mule-conf.el b/lisp/international/mule-conf.el index 99449ad359..dd6d0326d7 100644 --- a/lisp/international/mule-conf.el +++ b/lisp/international/mule-conf.el @@ -1075,6 +1075,115 @@ (define-charset-alias 'ebcdic-int 'ibm038) (define-charset-alias 'cp038 'ibm038) +(define-charset 'ibm256 + "Netherlands version of EBCDIC" + :short-name "IBM256" + :code-space [0 255] + :mime-charset 'ibm256 + :map "IBM256") +(define-charset-alias 'ebcdic-int1 'ibm256) +(define-charset-alias 'cp256 'ibm256) + +(define-charset 'ibm273 + "Austrian / German version of EBCDIC" + :short-name "IBM273" + :code-space [0 255] + :mime-charset 'ibm273 + :map "IBM273") +(define-charset-alias 'cp273 'ibm273) + +(define-charset 'ibm274 + "Belgian version of EBCDIC" + :short-name "IBM274" + :code-space [0 255] + :mime-charset 'ibm274 + :map "IBM274") +(define-charset-alias 'ebcdic-be 'ibm274) +(define-charset-alias 'cp274 'ibm274) + +(define-charset 'ibm275 + "Brazilian version of EBCDIC" + :short-name "IBM275" + :code-space [0 255] + :mime-charset 'ibm275 + :map "IBM275") +(define-charset-alias 'ebcdic-br 'ibm275) +(define-charset-alias 'cp275 'ibm275) + +(define-charset 'ibm277 + "Danish / Norwegian version of EBCDIC" + :short-name "IBM277" + :code-space [0 255] + :mime-charset 'ibm277 + :map "IBM277") +(define-charset-alias 'ebcdic-cp-dk 'ibm277) +(define-charset-alias 'ebcdic-cp-no 'ibm277) +(define-charset-alias 'cp277 'ibm277) + +(define-charset 'ibm278 + "Finnish / Swedish version of EBCDIC" + :short-name "IBM278" + :code-space [0 255] + :mime-charset 'ibm278 + :map "IBM278") +(define-charset-alias 'ebcdic-cp-fi 'ibm278) +(define-charset-alias 'ebcdic-cp-se 'ibm278) +(define-charset-alias 'cp278 'ibm278) + +(define-charset 'ibm280 + "Italian version of EBCDIC" + :short-name "IBM280" + :code-space [0 255] + :mime-charset 'ibm270 + :map "IBM280") +(define-charset-alias 'ebcdic-cp-it 'ibm280) +(define-charset-alias 'cp280 'ibm280) + +(define-charset 'ibm281 + "Japanese-E version of EBCDIC" + :short-name "IBM281" + :code-space [0 255] + :mime-charset 'ibm281 + :map "IBM281") +(define-charset-alias 'ebcdic-jp-e 'ibm281) +(define-charset-alias 'cp281 'ibm281) + +(define-charset 'ibm284 + "Spanish version of EBCDIC" + :short-name "IBM284" + :code-space [0 255] + :mime-charset 'ibm284 + :map "IBM284") +(define-charset-alias 'ebcdic-cp-es 'ibm284) +(define-charset-alias 'cp284 'ibm284) + +(define-charset 'ibm285 + "UK english version of EBCDIC" + :short-name "IBM285" + :code-space [0 255] + :mime-charset 'ibm285 + :map "IBM285") +(define-charset-alias 'ebcdic-cp-gb 'ibm285) ;; how this differs from ebcdic-uk? +(define-charset-alias 'cp285 'ibm285) + +(define-charset 'ibm290 + "Japanese katakana version of EBCDIC" + :short-name "IBM290" + :code-space [0 255] + :mime-charset 'ibm290 + :map "IBM290") +(define-charset-alias 'ebcdic-jp-kana 'ibm290) +(define-charset-alias 'cp290 'ibm290) + +(define-charset 'ibm297 + "French version of EBCDIC" + :short-name "IBM297" + :code-space [0 255] + :mime-charset 'ibm297 + :map "IBM297") +(define-charset-alias 'ebcdic-cp-fr 'ibm297) +(define-charset-alias 'cp297 'ibm297) + (define-charset 'ibm1047 ;; Says groff: "IBM1047, `EBCDIC Latin 1/Open Systems' used by OS/390 Unix." diff --git a/lisp/language/english.el b/lisp/language/english.el index b7af84c8f7..d5254effa9 100644 --- a/lisp/language/english.el +++ b/lisp/language/english.el @@ -70,6 +70,14 @@ Nothing special is needed to handle English.") (define-coding-system-alias 'ebcdic-int 'ibm038) (define-coding-system-alias 'cp038 'ibm038) +(define-coding-system 'ibm275 + "Brazilian version of EBCDIC" + :coding-type 'charset + :charset-list '(ibm275) + :mnemonic ?*) +(define-coding-system-alias 'ebcdic-br 'ibm275) +(define-coding-system-alias 'cp275 'ibm275) + ;; Make "ASCII" an alias of "English" language environment. (set-language-info-alist "ASCII" (cdr (assoc "English" language-info-alist))) diff --git a/lisp/language/european.el b/lisp/language/european.el index 713a0fdb34..99f062215f 100644 --- a/lisp/language/european.el +++ b/lisp/language/european.el @@ -324,6 +324,79 @@ Latin-9 is sometimes nicknamed `Latin-0'.")) :mime-charset 'windows-1257) (define-coding-system-alias 'cp1257 'windows-1257) +(define-coding-system 'ibm256 + "Netherlands version of EBCDIC" + :coding-type 'charset + :charset-list '(ibm256) + :mnemonic ?*) +(define-coding-system-alias 'ebcdic-int1 'ibm256) +(define-coding-system-alias 'cp256 'ibm256) + +(define-coding-system 'ibm273 + "Austrian / German version of EBCDIC" + :coding-type 'charset + :charset-list '(ibm273) + :mnemonic ?*) +(define-coding-system-alias 'cp273 'ibm273) + +(define-coding-system 'ibm274 + "Belgian version of EBCDIC" + :coding-type 'charset + :charset-list '(ibm274) + :mnemonic ?*) +(define-coding-system-alias 'ebcdic-be 'ibm274) +(define-coding-system-alias 'cp274 'ibm274) + +(define-coding-system 'ibm277 + "Danish / Norwegian version of EBCDIC" + :coding-type 'charset + :charset-list '(ibm277) + :mnemonic ?*) +(define-coding-system-alias 'ebcdic-cp-dk 'ibm277) +(define-coding-system-alias 'ebcdic-cp-no 'ibm277) +(define-coding-system-alias 'cp277 'ibm277) + +(define-coding-system 'ibm278 + "Finnish / Swedish version of EBCDIC" + :coding-type 'charset + :charset-list '(ibm278) + :mnemonic ?*) +(define-coding-system-alias 'ebcdic-cp-fi 'ibm278) +(define-coding-system-alias 'ebcdic-cp-se 'ibm278) +(define-coding-system-alias 'cp278 'ibm278) + +(define-coding-system 'ibm280 + "Italian version of EBCDIC" + :coding-type 'charset + :charset-list '(ibm280) + :mnemonic ?*) +(define-coding-system-alias 'ebcdic-cp-it 'ibm280) +(define-coding-system-alias 'cp280 'ibm280) + +(define-coding-system 'ibm284 + "Spanish version of EBCDIC" + :coding-type 'charset + :charset-list '(ibm284) + :mnemonic ?*) +(define-coding-system-alias 'ebcdic-cp-es 'ibm284) +(define-coding-system-alias 'cp284 'ibm284) + +(define-coding-system 'ibm285 + "UK english version of EBCDIC" + :coding-type 'charset + :charset-list '(ibm285) + :mnemonic ?*) +(define-coding-system-alias 'ebcdic-cp-gb 'ibm285) +(define-coding-system-alias 'cp285 'ibm285) + +(define-coding-system 'ibm297 + "French version of EBCDIC" + :coding-type 'charset + :charset-list '(ibm297) + :mnemonic ?*) +(define-coding-system-alias 'ebcdic-cp-fr 'ibm297) +(define-coding-system-alias 'cp297 'ibm297) + (define-coding-system 'cp775 "DOS codepage 775 (PC Baltic, MS-DOS Baltic Rim)" :coding-type 'charset diff --git a/lisp/language/japanese.el b/lisp/language/japanese.el index 9a99245dfd..a517b4ea8e 100644 --- a/lisp/language/japanese.el +++ b/lisp/language/japanese.el @@ -188,6 +188,22 @@ eucJP-ms is defined in ." (define-coding-system-alias 'shift_jis-2004 'japanese-shift-jis-2004) +(define-coding-system 'ibm281 + "Japanese-E version of EBCDIC" + :coding-type 'charset + :charset-list '(ibm281) + :mnemonic ?*) +(define-coding-system-alias 'ebcdic-jp-e 'ibm281) +(define-coding-system-alias 'cp281 'ibm281) + +(define-coding-system 'ibm290 + "Japanese katakana version of EBCDIC" + :coding-type 'charset + :charset-list '(ibm290) + :mnemonic ?*) +(define-coding-system-alias 'ebcdic-jp-kana 'ibm290) +(define-coding-system-alias 'cp290 'ibm290) + (set-language-info-alist "Japanese" '((setup-function . setup-japanese-environment-internal) (exit-function . use-default-char-width-table) commit 64513abf3eb5f845f56250ff8dc0ab8a9d193956 Author: Eli Zaretskii Date: Fri Dec 25 15:17:19 2020 +0200 Don't compile Gnulib's 'free' on MinGW * nt/mingw-cfg.site (gl_cv_func_free_preserves_errno): Set to "yes" to avoid compiling Gnulib's free.c in the MinGW build. diff --git a/nt/mingw-cfg.site b/nt/mingw-cfg.site index a9ca20cb15..9630077487 100644 --- a/nt/mingw-cfg.site +++ b/nt/mingw-cfg.site @@ -158,3 +158,7 @@ gl_cv_func_copy_file_range=yes # We don't want to build Emacs so it depends on bcrypt.dll, since then # it will refuse to start on systems where that DLL is absent. gl_cv_lib_assume_bcrypt=no +# Don't build the Gnulib free.c: it is not needed, since the w32 +# implementation of 'free' doesn't touch errno, and it emits a +# compilation warning. +gl_cv_func_free_preserves_errno=yes commit ecf84a22ee002112c265b028263f1db81e3271e1 Author: Eli Zaretskii Date: Fri Dec 25 14:51:20 2020 +0200 Revert "Import posix_spawn from Gnulib." This reverts commit 3ba34141da77a24c251ee6530f3f72a366fe556e. It breaks the MinGW build and should be first tested on a branch. diff --git a/.gitignore b/.gitignore index f9c0fae4f6..bf7e934981 100644 --- a/.gitignore +++ b/.gitignore @@ -65,9 +65,7 @@ lib/ieee754.h lib/inttypes.h lib/libgnu.a lib/limits.h -lib/sched.h lib/signal.h -lib/spawn.h lib/std*.h !lib/std*.in.h !lib/stdio-impl.h diff --git a/admin/merge-gnulib b/admin/merge-gnulib index f1ed2da69e..880dc5eef5 100755 --- a/admin/merge-gnulib +++ b/admin/merge-gnulib @@ -39,14 +39,7 @@ GNULIB_MODULES=' getloadavg getopt-gnu getrandom gettime gettimeofday gitlog-to-changelog ieee754-h ignore-value intprops largefile libgmp lstat manywarnings memmem-simple mempcpy memrchr minmax mkostemp mktime nstrftime - pathmax pipe2 - posix_spawn posix_spawn_file_actions_addchdir - posix_spawn_file_actions_adddup2 posix_spawn_file_actions_destroy - posix_spawn_file_actions_init - posix_spawnattr_destroy posix_spawnattr_init - posix_spawnattr_setflags posix_spawnattr_setpgroup - posix_spawnattr_setsigdefault posix_spawnattr_setsigmask - pselect pthread_sigmask + pathmax pipe2 pselect pthread_sigmask qcopy-acl readlink readlinkat regex sig2str sigdescr_np socklen stat-time std-gnu11 stdalign stddef stdio stpcpy strnlen strtoimax symlink sys_stat sys_time diff --git a/lib/gnulib.mk.in b/lib/gnulib.mk.in index 209c7eef29..a37f9278a3 100644 --- a/lib/gnulib.mk.in +++ b/lib/gnulib.mk.in @@ -130,17 +130,6 @@ # nstrftime \ # pathmax \ # pipe2 \ -# posix_spawn \ -# posix_spawn_file_actions_addchdir \ -# posix_spawn_file_actions_adddup2 \ -# posix_spawn_file_actions_destroy \ -# posix_spawn_file_actions_init \ -# posix_spawnattr_destroy \ -# posix_spawnattr_init \ -# posix_spawnattr_setflags \ -# posix_spawnattr_setpgroup \ -# posix_spawnattr_setsigdefault \ -# posix_spawnattr_setsigmask \ # pselect \ # pthread_sigmask \ # qcopy-acl \ @@ -404,29 +393,6 @@ GNULIB_PIPE2 = @GNULIB_PIPE2@ GNULIB_POPEN = @GNULIB_POPEN@ GNULIB_POSIX_MEMALIGN = @GNULIB_POSIX_MEMALIGN@ GNULIB_POSIX_OPENPT = @GNULIB_POSIX_OPENPT@ -GNULIB_POSIX_SPAWN = @GNULIB_POSIX_SPAWN@ -GNULIB_POSIX_SPAWNATTR_DESTROY = @GNULIB_POSIX_SPAWNATTR_DESTROY@ -GNULIB_POSIX_SPAWNATTR_GETFLAGS = @GNULIB_POSIX_SPAWNATTR_GETFLAGS@ -GNULIB_POSIX_SPAWNATTR_GETPGROUP = @GNULIB_POSIX_SPAWNATTR_GETPGROUP@ -GNULIB_POSIX_SPAWNATTR_GETSCHEDPARAM = @GNULIB_POSIX_SPAWNATTR_GETSCHEDPARAM@ -GNULIB_POSIX_SPAWNATTR_GETSCHEDPOLICY = @GNULIB_POSIX_SPAWNATTR_GETSCHEDPOLICY@ -GNULIB_POSIX_SPAWNATTR_GETSIGDEFAULT = @GNULIB_POSIX_SPAWNATTR_GETSIGDEFAULT@ -GNULIB_POSIX_SPAWNATTR_GETSIGMASK = @GNULIB_POSIX_SPAWNATTR_GETSIGMASK@ -GNULIB_POSIX_SPAWNATTR_INIT = @GNULIB_POSIX_SPAWNATTR_INIT@ -GNULIB_POSIX_SPAWNATTR_SETFLAGS = @GNULIB_POSIX_SPAWNATTR_SETFLAGS@ -GNULIB_POSIX_SPAWNATTR_SETPGROUP = @GNULIB_POSIX_SPAWNATTR_SETPGROUP@ -GNULIB_POSIX_SPAWNATTR_SETSCHEDPARAM = @GNULIB_POSIX_SPAWNATTR_SETSCHEDPARAM@ -GNULIB_POSIX_SPAWNATTR_SETSCHEDPOLICY = @GNULIB_POSIX_SPAWNATTR_SETSCHEDPOLICY@ -GNULIB_POSIX_SPAWNATTR_SETSIGDEFAULT = @GNULIB_POSIX_SPAWNATTR_SETSIGDEFAULT@ -GNULIB_POSIX_SPAWNATTR_SETSIGMASK = @GNULIB_POSIX_SPAWNATTR_SETSIGMASK@ -GNULIB_POSIX_SPAWNP = @GNULIB_POSIX_SPAWNP@ -GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR = @GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR@ -GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE = @GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE@ -GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2 = @GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2@ -GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR = @GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR@ -GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN = @GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN@ -GNULIB_POSIX_SPAWN_FILE_ACTIONS_DESTROY = @GNULIB_POSIX_SPAWN_FILE_ACTIONS_DESTROY@ -GNULIB_POSIX_SPAWN_FILE_ACTIONS_INIT = @GNULIB_POSIX_SPAWN_FILE_ACTIONS_INIT@ GNULIB_PREAD = @GNULIB_PREAD@ GNULIB_PRINTF = @GNULIB_PRINTF@ GNULIB_PRINTF_POSIX = @GNULIB_PRINTF_POSIX@ @@ -459,7 +425,6 @@ GNULIB_RMDIR = @GNULIB_RMDIR@ GNULIB_RPMATCH = @GNULIB_RPMATCH@ GNULIB_SCANDIR = @GNULIB_SCANDIR@ GNULIB_SCANF = @GNULIB_SCANF@ -GNULIB_SCHED_YIELD = @GNULIB_SCHED_YIELD@ GNULIB_SECURE_GETENV = @GNULIB_SECURE_GETENV@ GNULIB_SELECT = @GNULIB_SELECT@ GNULIB_SETENV = @GNULIB_SETENV@ @@ -669,11 +634,6 @@ HAVE_POPEN = @HAVE_POPEN@ HAVE_POSIX_MEMALIGN = @HAVE_POSIX_MEMALIGN@ HAVE_POSIX_OPENPT = @HAVE_POSIX_OPENPT@ HAVE_POSIX_SIGNALBLOCKING = @HAVE_POSIX_SIGNALBLOCKING@ -HAVE_POSIX_SPAWN = @HAVE_POSIX_SPAWN@ -HAVE_POSIX_SPAWNATTR_T = @HAVE_POSIX_SPAWNATTR_T@ -HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR = @HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR@ -HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR = @HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR@ -HAVE_POSIX_SPAWN_FILE_ACTIONS_T = @HAVE_POSIX_SPAWN_FILE_ACTIONS_T@ HAVE_PREAD = @HAVE_PREAD@ HAVE_PSELECT = @HAVE_PSELECT@ HAVE_PTHREAD_SIGMASK = @HAVE_PTHREAD_SIGMASK@ @@ -695,8 +655,6 @@ HAVE_RENAMEAT = @HAVE_RENAMEAT@ HAVE_REWINDDIR = @HAVE_REWINDDIR@ HAVE_RPMATCH = @HAVE_RPMATCH@ HAVE_SCANDIR = @HAVE_SCANDIR@ -HAVE_SCHED_H = @HAVE_SCHED_H@ -HAVE_SCHED_YIELD = @HAVE_SCHED_YIELD@ HAVE_SECURE_GETENV = @HAVE_SECURE_GETENV@ HAVE_SETENV = @HAVE_SETENV@ HAVE_SETHOSTNAME = @HAVE_SETHOSTNAME@ @@ -711,7 +669,6 @@ HAVE_SIGNED_WCHAR_T = @HAVE_SIGNED_WCHAR_T@ HAVE_SIGNED_WINT_T = @HAVE_SIGNED_WINT_T@ HAVE_SIGSET_T = @HAVE_SIGSET_T@ HAVE_SLEEP = @HAVE_SLEEP@ -HAVE_SPAWN_H = @HAVE_SPAWN_H@ HAVE_STDINT_H = @HAVE_STDINT_H@ HAVE_STPCPY = @HAVE_STPCPY@ HAVE_STPNCPY = @HAVE_STPNCPY@ @@ -726,7 +683,6 @@ HAVE_STRTOLD = @HAVE_STRTOLD@ HAVE_STRTOLL = @HAVE_STRTOLL@ HAVE_STRTOULL = @HAVE_STRTOULL@ HAVE_STRUCT_RANDOM_DATA = @HAVE_STRUCT_RANDOM_DATA@ -HAVE_STRUCT_SCHED_PARAM = @HAVE_STRUCT_SCHED_PARAM@ HAVE_STRUCT_SIGACTION_SA_SIGACTION = @HAVE_STRUCT_SIGACTION_SA_SIGACTION@ HAVE_STRUCT_TIMEVAL = @HAVE_STRUCT_TIMEVAL@ HAVE_STRVERSCMP = @HAVE_STRVERSCMP@ @@ -826,7 +782,6 @@ LIB_EACCESS = @LIB_EACCESS@ LIB_EXECINFO = @LIB_EXECINFO@ LIB_GETRANDOM = @LIB_GETRANDOM@ LIB_MATH = @LIB_MATH@ -LIB_POSIX_SPAWN = @LIB_POSIX_SPAWN@ LIB_PTHREAD = @LIB_PTHREAD@ LIB_PTHREAD_SIGMASK = @LIB_PTHREAD_SIGMASK@ LIB_TIMER_TIME = @LIB_TIMER_TIME@ @@ -850,9 +805,7 @@ NEXT_AS_FIRST_DIRECTIVE_FCNTL_H = @NEXT_AS_FIRST_DIRECTIVE_FCNTL_H@ NEXT_AS_FIRST_DIRECTIVE_GETOPT_H = @NEXT_AS_FIRST_DIRECTIVE_GETOPT_H@ NEXT_AS_FIRST_DIRECTIVE_INTTYPES_H = @NEXT_AS_FIRST_DIRECTIVE_INTTYPES_H@ NEXT_AS_FIRST_DIRECTIVE_LIMITS_H = @NEXT_AS_FIRST_DIRECTIVE_LIMITS_H@ -NEXT_AS_FIRST_DIRECTIVE_SCHED_H = @NEXT_AS_FIRST_DIRECTIVE_SCHED_H@ NEXT_AS_FIRST_DIRECTIVE_SIGNAL_H = @NEXT_AS_FIRST_DIRECTIVE_SIGNAL_H@ -NEXT_AS_FIRST_DIRECTIVE_SPAWN_H = @NEXT_AS_FIRST_DIRECTIVE_SPAWN_H@ NEXT_AS_FIRST_DIRECTIVE_STDDEF_H = @NEXT_AS_FIRST_DIRECTIVE_STDDEF_H@ NEXT_AS_FIRST_DIRECTIVE_STDINT_H = @NEXT_AS_FIRST_DIRECTIVE_STDINT_H@ NEXT_AS_FIRST_DIRECTIVE_STDIO_H = @NEXT_AS_FIRST_DIRECTIVE_STDIO_H@ @@ -871,9 +824,7 @@ NEXT_FCNTL_H = @NEXT_FCNTL_H@ NEXT_GETOPT_H = @NEXT_GETOPT_H@ NEXT_INTTYPES_H = @NEXT_INTTYPES_H@ NEXT_LIMITS_H = @NEXT_LIMITS_H@ -NEXT_SCHED_H = @NEXT_SCHED_H@ NEXT_SIGNAL_H = @NEXT_SIGNAL_H@ -NEXT_SPAWN_H = @NEXT_SPAWN_H@ NEXT_STDDEF_H = @NEXT_STDDEF_H@ NEXT_STDINT_H = @NEXT_STDINT_H@ NEXT_STDIO_H = @NEXT_STDIO_H@ @@ -995,12 +946,6 @@ REPLACE_OPENDIR = @REPLACE_OPENDIR@ REPLACE_PERROR = @REPLACE_PERROR@ REPLACE_POPEN = @REPLACE_POPEN@ REPLACE_POSIX_MEMALIGN = @REPLACE_POSIX_MEMALIGN@ -REPLACE_POSIX_SPAWN = @REPLACE_POSIX_SPAWN@ -REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR = @REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR@ -REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE = @REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE@ -REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2 = @REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2@ -REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR = @REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR@ -REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN = @REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN@ REPLACE_PREAD = @REPLACE_PREAD@ REPLACE_PRINTF = @REPLACE_PRINTF@ REPLACE_PSELECT = @REPLACE_PSELECT@ @@ -1022,7 +967,6 @@ REPLACE_REMOVE = @REPLACE_REMOVE@ REPLACE_RENAME = @REPLACE_RENAME@ REPLACE_RENAMEAT = @REPLACE_RENAMEAT@ REPLACE_RMDIR = @REPLACE_RMDIR@ -REPLACE_SCHED_YIELD = @REPLACE_SCHED_YIELD@ REPLACE_SELECT = @REPLACE_SELECT@ REPLACE_SETENV = @REPLACE_SETENV@ REPLACE_SETSTATE = @REPLACE_SETSTATE@ @@ -1164,13 +1108,11 @@ gamegroup = @gamegroup@ gameuser = @gameuser@ gl_GNULIB_ENABLED_03e0aaad4cb89ca757653bd367a6ccb7 = @gl_GNULIB_ENABLED_03e0aaad4cb89ca757653bd367a6ccb7@ gl_GNULIB_ENABLED_260941c0e5dc67ec9e87d1fb321c300b = @gl_GNULIB_ENABLED_260941c0e5dc67ec9e87d1fb321c300b@ -gl_GNULIB_ENABLED_332607f759618fb73dfc3076748afea7 = @gl_GNULIB_ENABLED_332607f759618fb73dfc3076748afea7@ gl_GNULIB_ENABLED_5264294aa0a5557541b53c8c741f7f31 = @gl_GNULIB_ENABLED_5264294aa0a5557541b53c8c741f7f31@ gl_GNULIB_ENABLED_6099e9737f757db36c47fa9d9f02e88c = @gl_GNULIB_ENABLED_6099e9737f757db36c47fa9d9f02e88c@ gl_GNULIB_ENABLED_682e609604ccaac6be382e4ee3a4eaec = @gl_GNULIB_ENABLED_682e609604ccaac6be382e4ee3a4eaec@ gl_GNULIB_ENABLED_a9786850e999ae65a836a6041e8e5ed1 = @gl_GNULIB_ENABLED_a9786850e999ae65a836a6041e8e5ed1@ gl_GNULIB_ENABLED_be453cec5eecf5731a274f2de7f2db36 = @gl_GNULIB_ENABLED_be453cec5eecf5731a274f2de7f2db36@ -gl_GNULIB_ENABLED_cdeb0f2aaf9d280baa6526bfa1b07f70 = @gl_GNULIB_ENABLED_cdeb0f2aaf9d280baa6526bfa1b07f70@ gl_GNULIB_ENABLED_cloexec = @gl_GNULIB_ENABLED_cloexec@ gl_GNULIB_ENABLED_dirfd = @gl_GNULIB_ENABLED_dirfd@ gl_GNULIB_ENABLED_ef07dc4b3077c11ea9cef586db4e5955 = @gl_GNULIB_ENABLED_ef07dc4b3077c11ea9cef586db4e5955@ @@ -1182,7 +1124,6 @@ gl_GNULIB_ENABLED_lchmod = @gl_GNULIB_ENABLED_lchmod@ gl_GNULIB_ENABLED_open = @gl_GNULIB_ENABLED_open@ gl_GNULIB_ENABLED_rawmemchr = @gl_GNULIB_ENABLED_rawmemchr@ gl_GNULIB_ENABLED_scratch_buffer = @gl_GNULIB_ENABLED_scratch_buffer@ -gl_GNULIB_ENABLED_strchrnul = @gl_GNULIB_ENABLED_strchrnul@ gl_GNULIB_ENABLED_strtoll = @gl_GNULIB_ENABLED_strtoll@ gl_GNULIB_ENABLED_utimens = @gl_GNULIB_ENABLED_utimens@ gl_LIBOBJS = @gl_LIBOBJS@ @@ -2329,140 +2270,6 @@ libgnu_a_SOURCES += pipe2.c endif ## end gnulib module pipe2 -## begin gnulib module posix_spawn -ifeq (,$(OMIT_GNULIB_MODULE_posix_spawn)) - - -EXTRA_DIST += spawn.c - -EXTRA_libgnu_a_SOURCES += spawn.c - -endif -## end gnulib module posix_spawn - -## begin gnulib module posix_spawn-internal -ifeq (,$(OMIT_GNULIB_MODULE_posix_spawn-internal)) - -ifneq (,$(gl_GNULIB_ENABLED_332607f759618fb73dfc3076748afea7)) - -endif -EXTRA_DIST += spawn_int.h spawni.c - -EXTRA_libgnu_a_SOURCES += spawni.c - -endif -## end gnulib module posix_spawn-internal - -## begin gnulib module posix_spawn_file_actions_addchdir -ifeq (,$(OMIT_GNULIB_MODULE_posix_spawn_file_actions_addchdir)) - - -EXTRA_DIST += spawn_faction_addchdir.c spawn_int.h - -EXTRA_libgnu_a_SOURCES += spawn_faction_addchdir.c - -endif -## end gnulib module posix_spawn_file_actions_addchdir - -## begin gnulib module posix_spawn_file_actions_adddup2 -ifeq (,$(OMIT_GNULIB_MODULE_posix_spawn_file_actions_adddup2)) - - -EXTRA_DIST += spawn_faction_adddup2.c spawn_int.h - -EXTRA_libgnu_a_SOURCES += spawn_faction_adddup2.c - -endif -## end gnulib module posix_spawn_file_actions_adddup2 - -## begin gnulib module posix_spawn_file_actions_destroy -ifeq (,$(OMIT_GNULIB_MODULE_posix_spawn_file_actions_destroy)) - - -EXTRA_DIST += spawn_faction_destroy.c - -EXTRA_libgnu_a_SOURCES += spawn_faction_destroy.c - -endif -## end gnulib module posix_spawn_file_actions_destroy - -## begin gnulib module posix_spawn_file_actions_init -ifeq (,$(OMIT_GNULIB_MODULE_posix_spawn_file_actions_init)) - - -EXTRA_DIST += spawn_faction_init.c spawn_int.h - -EXTRA_libgnu_a_SOURCES += spawn_faction_init.c - -endif -## end gnulib module posix_spawn_file_actions_init - -## begin gnulib module posix_spawnattr_destroy -ifeq (,$(OMIT_GNULIB_MODULE_posix_spawnattr_destroy)) - - -EXTRA_DIST += spawnattr_destroy.c - -EXTRA_libgnu_a_SOURCES += spawnattr_destroy.c - -endif -## end gnulib module posix_spawnattr_destroy - -## begin gnulib module posix_spawnattr_init -ifeq (,$(OMIT_GNULIB_MODULE_posix_spawnattr_init)) - - -EXTRA_DIST += spawnattr_init.c - -EXTRA_libgnu_a_SOURCES += spawnattr_init.c - -endif -## end gnulib module posix_spawnattr_init - -## begin gnulib module posix_spawnattr_setflags -ifeq (,$(OMIT_GNULIB_MODULE_posix_spawnattr_setflags)) - - -EXTRA_DIST += spawnattr_setflags.c - -EXTRA_libgnu_a_SOURCES += spawnattr_setflags.c - -endif -## end gnulib module posix_spawnattr_setflags - -## begin gnulib module posix_spawnattr_setpgroup -ifeq (,$(OMIT_GNULIB_MODULE_posix_spawnattr_setpgroup)) - - -EXTRA_DIST += spawnattr_setpgroup.c - -EXTRA_libgnu_a_SOURCES += spawnattr_setpgroup.c - -endif -## end gnulib module posix_spawnattr_setpgroup - -## begin gnulib module posix_spawnattr_setsigdefault -ifeq (,$(OMIT_GNULIB_MODULE_posix_spawnattr_setsigdefault)) - - -EXTRA_DIST += spawnattr_setdefault.c - -EXTRA_libgnu_a_SOURCES += spawnattr_setdefault.c - -endif -## end gnulib module posix_spawnattr_setsigdefault - -## begin gnulib module posix_spawnattr_setsigmask -ifeq (,$(OMIT_GNULIB_MODULE_posix_spawnattr_setsigmask)) - - -EXTRA_DIST += spawnattr_setsigmask.c - -EXTRA_libgnu_a_SOURCES += spawnattr_setsigmask.c - -endif -## end gnulib module posix_spawnattr_setsigmask - ## begin gnulib module pselect ifeq (,$(OMIT_GNULIB_MODULE_pselect)) @@ -2550,39 +2357,6 @@ EXTRA_DIST += root-uid.h endif ## end gnulib module root-uid -## begin gnulib module sched -ifeq (,$(OMIT_GNULIB_MODULE_sched)) - -BUILT_SOURCES += sched.h - -# We need the following in order to create a replacement for when -# the system doesn't have one. -sched.h: sched.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H) - $(AM_V_GEN)rm -f $@-t $@ && \ - { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ - sed -e 's|@''GUARD_PREFIX''@|GL|g' \ - -e 's|@''HAVE_SCHED_H''@|$(HAVE_SCHED_H)|g' \ - -e 's|@''HAVE_SYS_CDEFS_H''@|$(HAVE_SYS_CDEFS_H)|g' \ - -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ - -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ - -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ - -e 's|@''NEXT_SCHED_H''@|$(NEXT_SCHED_H)|g' \ - -e 's|@''HAVE_STRUCT_SCHED_PARAM''@|$(HAVE_STRUCT_SCHED_PARAM)|g' \ - -e 's/@''GNULIB_SCHED_YIELD''@/$(GNULIB_SCHED_YIELD)/g' \ - -e 's|@''HAVE_SCHED_YIELD''@|$(HAVE_SCHED_YIELD)|g' \ - -e 's|@''REPLACE_SCHED_YIELD''@|$(REPLACE_SCHED_YIELD)|g' \ - -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ - -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \ - < $(srcdir)/sched.in.h; \ - } > $@-t && \ - mv $@-t $@ -MOSTLYCLEANFILES += sched.h sched.h-t - -EXTRA_DIST += sched.in.h - -endif -## end gnulib module sched - ## begin gnulib module scratch_buffer ifeq (,$(OMIT_GNULIB_MODULE_scratch_buffer)) @@ -2717,69 +2491,6 @@ EXTRA_DIST += warn-on-use.h endif ## end gnulib module snippet/warn-on-use -## begin gnulib module spawn -ifeq (,$(OMIT_GNULIB_MODULE_spawn)) - -BUILT_SOURCES += spawn.h - -# We need the following in order to create a replacement for when -# the system doesn't have one. -spawn.h: spawn.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) - $(AM_V_GEN)rm -f $@-t $@ && \ - { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ - sed -e 's|@''GUARD_PREFIX''@|GL|g' \ - -e 's|@''HAVE_SPAWN_H''@|$(HAVE_SPAWN_H)|g' \ - -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ - -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ - -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ - -e 's|@''NEXT_SPAWN_H''@|$(NEXT_SPAWN_H)|g' \ - -e 's/@''GNULIB_POSIX_SPAWN''@/$(GNULIB_POSIX_SPAWN)/g' \ - -e 's/@''GNULIB_POSIX_SPAWNP''@/$(GNULIB_POSIX_SPAWNP)/g' \ - -e 's/@''GNULIB_POSIX_SPAWN_FILE_ACTIONS_INIT''@/$(GNULIB_POSIX_SPAWN_FILE_ACTIONS_INIT)/g' \ - -e 's/@''GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR''@/$(GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR)/g' \ - -e 's/@''GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE''@/$(GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE)/g' \ - -e 's/@''GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2''@/$(GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2)/g' \ - -e 's/@''GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR''@/$(GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR)/g' \ - -e 's/@''GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN''@/$(GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN)/g' \ - -e 's/@''GNULIB_POSIX_SPAWN_FILE_ACTIONS_DESTROY''@/$(GNULIB_POSIX_SPAWN_FILE_ACTIONS_DESTROY)/g' \ - -e 's/@''GNULIB_POSIX_SPAWNATTR_INIT''@/$(GNULIB_POSIX_SPAWNATTR_INIT)/g' \ - -e 's/@''GNULIB_POSIX_SPAWNATTR_GETFLAGS''@/$(GNULIB_POSIX_SPAWNATTR_GETFLAGS)/g' \ - -e 's/@''GNULIB_POSIX_SPAWNATTR_SETFLAGS''@/$(GNULIB_POSIX_SPAWNATTR_SETFLAGS)/g' \ - -e 's/@''GNULIB_POSIX_SPAWNATTR_GETPGROUP''@/$(GNULIB_POSIX_SPAWNATTR_GETPGROUP)/g' \ - -e 's/@''GNULIB_POSIX_SPAWNATTR_SETPGROUP''@/$(GNULIB_POSIX_SPAWNATTR_SETPGROUP)/g' \ - -e 's/@''GNULIB_POSIX_SPAWNATTR_GETSCHEDPARAM''@/$(GNULIB_POSIX_SPAWNATTR_GETSCHEDPARAM)/g' \ - -e 's/@''GNULIB_POSIX_SPAWNATTR_SETSCHEDPARAM''@/$(GNULIB_POSIX_SPAWNATTR_SETSCHEDPARAM)/g' \ - -e 's/@''GNULIB_POSIX_SPAWNATTR_GETSCHEDPOLICY''@/$(GNULIB_POSIX_SPAWNATTR_GETSCHEDPOLICY)/g' \ - -e 's/@''GNULIB_POSIX_SPAWNATTR_SETSCHEDPOLICY''@/$(GNULIB_POSIX_SPAWNATTR_SETSCHEDPOLICY)/g' \ - -e 's/@''GNULIB_POSIX_SPAWNATTR_GETSIGDEFAULT''@/$(GNULIB_POSIX_SPAWNATTR_GETSIGDEFAULT)/g' \ - -e 's/@''GNULIB_POSIX_SPAWNATTR_SETSIGDEFAULT''@/$(GNULIB_POSIX_SPAWNATTR_SETSIGDEFAULT)/g' \ - -e 's/@''GNULIB_POSIX_SPAWNATTR_GETSIGMASK''@/$(GNULIB_POSIX_SPAWNATTR_GETSIGMASK)/g' \ - -e 's/@''GNULIB_POSIX_SPAWNATTR_SETSIGMASK''@/$(GNULIB_POSIX_SPAWNATTR_SETSIGMASK)/g' \ - -e 's/@''GNULIB_POSIX_SPAWNATTR_DESTROY''@/$(GNULIB_POSIX_SPAWNATTR_DESTROY)/g' \ - -e 's|@''HAVE_POSIX_SPAWN''@|$(HAVE_POSIX_SPAWN)|g' \ - -e 's|@''HAVE_POSIX_SPAWNATTR_T''@|$(HAVE_POSIX_SPAWNATTR_T)|g' \ - -e 's|@''HAVE_POSIX_SPAWN_FILE_ACTIONS_T''@|$(HAVE_POSIX_SPAWN_FILE_ACTIONS_T)|g' \ - -e 's|@''HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR''@|$(HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR)|g' \ - -e 's|@''HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR''@|$(HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR)|g' \ - -e 's|@''REPLACE_POSIX_SPAWN''@|$(REPLACE_POSIX_SPAWN)|g' \ - -e 's|@''REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR''@|$(REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR)|g' \ - -e 's|@''REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE''@|$(REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE)|g' \ - -e 's|@''REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2''@|$(REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2)|g' \ - -e 's|@''REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR''@|$(REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR)|g' \ - -e 's|@''REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN''@|$(REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN)|g' \ - -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ - -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ - -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \ - < $(srcdir)/spawn.in.h; \ - } > $@-t && \ - mv $@-t $@ -MOSTLYCLEANFILES += spawn.h spawn.h-t - -EXTRA_DIST += spawn.in.h - -endif -## end gnulib module spawn - ## begin gnulib module stat-time ifeq (,$(OMIT_GNULIB_MODULE_stat-time)) @@ -3174,19 +2885,6 @@ EXTRA_libgnu_a_SOURCES += stpcpy.c endif ## end gnulib module stpcpy -## begin gnulib module strchrnul -ifeq (,$(OMIT_GNULIB_MODULE_strchrnul)) - -ifneq (,$(gl_GNULIB_ENABLED_strchrnul)) - -endif -EXTRA_DIST += strchrnul.c strchrnul.valgrind - -EXTRA_libgnu_a_SOURCES += strchrnul.c - -endif -## end gnulib module strchrnul - ## begin gnulib module string ifeq (,$(OMIT_GNULIB_MODULE_string)) diff --git a/lib/sched.in.h b/lib/sched.in.h deleted file mode 100644 index 4ee9defe82..0000000000 --- a/lib/sched.in.h +++ /dev/null @@ -1,99 +0,0 @@ -/* A GNU-like . - Copyright (C) 2008-2020 Free Software Foundation, Inc. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -#ifndef _@GUARD_PREFIX@_SCHED_H - -#if __GNUC__ >= 3 -@PRAGMA_SYSTEM_HEADER@ -#endif -@PRAGMA_COLUMNS@ - -/* The include_next requires a split double-inclusion guard. */ -#if @HAVE_SCHED_H@ -# if @HAVE_SYS_CDEFS_H@ -# include -# endif -# @INCLUDE_NEXT@ @NEXT_SCHED_H@ -#endif - -#ifndef _@GUARD_PREFIX@_SCHED_H -#define _@GUARD_PREFIX@_SCHED_H - -/* Get pid_t. - This is needed on glibc 2.11 (see - glibc bug ) - and Mac OS X 10.5. */ -#include - -#ifdef __KLIBC__ -/* On OS/2 kLIBC, struct sched_param is in spawn.h. */ -# include -#endif - -#ifdef __VMS -/* On OpenVMS, struct sched_param is in . */ -# include -#endif - -/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ - -/* The definition of _GL_WARN_ON_USE is copied here. */ - -#if !@HAVE_STRUCT_SCHED_PARAM@ - -# if !GNULIB_defined_struct_sched_param -struct sched_param -{ - int sched_priority; -}; -# define GNULIB_defined_struct_sched_param 1 -# endif - -#endif - -#if !(defined SCHED_FIFO && defined SCHED_RR && defined SCHED_OTHER) -# define SCHED_FIFO 1 -# define SCHED_RR 2 -# define SCHED_OTHER 0 -#endif - -#if @GNULIB_SCHED_YIELD@ -# if @REPLACE_SCHED_YIELD@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef sched_yield -# define sched_yield rpl_sched_yield -# endif -_GL_FUNCDECL_RPL (sched_yield, int, (void)); -_GL_CXXALIAS_RPL (sched_yield, int, (void)); -# else -# if !@HAVE_SCHED_YIELD@ -_GL_FUNCDECL_SYS (sched_yield, int, (void)); -# endif -_GL_CXXALIAS_SYS (sched_yield, int, (void)); -# endif -# if __GLIBC__ >= 2 -_GL_CXXALIASWARN (sched_yield); -# endif -#elif defined GNULIB_POSIXCHECK -# undef sched_yield -# if HAVE_RAW_DECL_SCHED_YIELD -_GL_WARN_ON_USE (sched_yield, "sched_yield is not portable - " - "use gnulib module sched_yield for portability"); -# endif -#endif - -#endif /* _@GUARD_PREFIX@_SCHED_H */ -#endif /* _@GUARD_PREFIX@_SCHED_H */ diff --git a/lib/spawn.c b/lib/spawn.c deleted file mode 100644 index b658453a10..0000000000 --- a/lib/spawn.c +++ /dev/null @@ -1,34 +0,0 @@ -/* Copyright (C) 2000, 2009-2020 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -#include - -/* Specification. */ -#include - -#include "spawn_int.h" - -/* Spawn a new process executing PATH with the attributes describes in *ATTRP. - Before running the process perform the actions described in FILE-ACTIONS. */ -int -posix_spawn (pid_t *pid, const char *path, - const posix_spawn_file_actions_t *file_actions, - const posix_spawnattr_t *attrp, char *const argv[], - char *const envp[]) -{ - return __spawni (pid, path, file_actions, attrp, - (const char * const *) argv, (const char * const *) envp, 0); -} diff --git a/lib/spawn.in.h b/lib/spawn.in.h deleted file mode 100644 index 537fac7dbc..0000000000 --- a/lib/spawn.in.h +++ /dev/null @@ -1,974 +0,0 @@ -/* Definitions for POSIX spawn interface. - Copyright (C) 2000, 2003-2004, 2008-2020 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -#ifndef _@GUARD_PREFIX@_SPAWN_H - -#if __GNUC__ >= 3 -@PRAGMA_SYSTEM_HEADER@ -#endif -@PRAGMA_COLUMNS@ - -/* The include_next requires a split double-inclusion guard. */ -#if @HAVE_SPAWN_H@ -# @INCLUDE_NEXT@ @NEXT_SPAWN_H@ -#endif - -#ifndef _@GUARD_PREFIX@_SPAWN_H -#define _@GUARD_PREFIX@_SPAWN_H - -/* Get definitions of 'struct sched_param' and 'sigset_t'. - But avoid namespace pollution on glibc systems. */ -#if !(defined __GLIBC__ && !defined __UCLIBC__) -# include -# include -#endif - -#include - -#ifndef __THROW -# define __THROW -#endif - -/* For plain 'restrict', use glibc's __restrict if defined. - Otherwise, GCC 2.95 and later have "__restrict"; C99 compilers have - "restrict", and "configure" may have defined "restrict". - Other compilers use __restrict, __restrict__, and _Restrict, and - 'configure' might #define 'restrict' to those words, so pick a - different name. */ -#ifndef _Restrict_ -# if defined __restrict \ - || 2 < __GNUC__ + (95 <= __GNUC_MINOR__) \ - || __clang_major__ >= 3 -# define _Restrict_ __restrict -# elif 199901L <= __STDC_VERSION__ || defined restrict -# define _Restrict_ restrict -# else -# define _Restrict_ -# endif -#endif -/* For the ISO C99 syntax - array_name[restrict] - use glibc's __restrict_arr if available. - Otherwise, GCC 3.1 and clang support this syntax (but not in C++ mode). - Other ISO C99 compilers support it as well. */ -#ifndef _Restrict_arr_ -# ifdef __restrict_arr -# define _Restrict_arr_ __restrict_arr -# elif ((199901L <= __STDC_VERSION__ \ - || 3 < __GNUC__ + (1 <= __GNUC_MINOR__) \ - || __clang_major__ >= 3) \ - && !defined __cplusplus) -# define _Restrict_arr_ _Restrict_ -# else -# define _Restrict_arr_ -# endif -#endif - -/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ - -/* The definition of _GL_ARG_NONNULL is copied here. */ - -/* The definition of _GL_WARN_ON_USE is copied here. */ - - -/* Data structure to contain attributes for thread creation. */ -#if @REPLACE_POSIX_SPAWN@ || (@HAVE_POSIX_SPAWNATTR_T@ && !@HAVE_POSIX_SPAWN@) -# define posix_spawnattr_t rpl_posix_spawnattr_t -#endif -#if @REPLACE_POSIX_SPAWN@ || !@HAVE_POSIX_SPAWNATTR_T@ || !@HAVE_POSIX_SPAWN@ -# if !GNULIB_defined_posix_spawnattr_t -typedef struct -{ - short int _flags; - pid_t _pgrp; - sigset_t _sd; - sigset_t _ss; - struct sched_param _sp; - int _policy; - int __pad[16]; -} posix_spawnattr_t; -# define GNULIB_defined_posix_spawnattr_t 1 -# endif -#endif - - -/* Data structure to contain information about the actions to be - performed in the new process with respect to file descriptors. */ -#if @REPLACE_POSIX_SPAWN@ || (@HAVE_POSIX_SPAWN_FILE_ACTIONS_T@ && !@HAVE_POSIX_SPAWN@) -# define posix_spawn_file_actions_t rpl_posix_spawn_file_actions_t -#endif -#if @REPLACE_POSIX_SPAWN@ || !@HAVE_POSIX_SPAWN_FILE_ACTIONS_T@ || !@HAVE_POSIX_SPAWN@ -# if !GNULIB_defined_posix_spawn_file_actions_t -typedef struct -{ - int _allocated; - int _used; - struct __spawn_action *_actions; - int __pad[16]; -} posix_spawn_file_actions_t; -# define GNULIB_defined_posix_spawn_file_actions_t 1 -# endif -#endif - - -/* Flags to be set in the 'posix_spawnattr_t'. */ -#if @HAVE_POSIX_SPAWN@ -/* Use the values from the system, but provide the missing ones. */ -# ifndef POSIX_SPAWN_SETSCHEDPARAM -# define POSIX_SPAWN_SETSCHEDPARAM 0 -# endif -# ifndef POSIX_SPAWN_SETSCHEDULER -# define POSIX_SPAWN_SETSCHEDULER 0 -# endif -#else -# if @REPLACE_POSIX_SPAWN@ -/* Use the values from the system, for better compatibility. */ -/* But this implementation does not support AIX extensions. */ -# undef POSIX_SPAWN_FORK_HANDLERS -# else -# define POSIX_SPAWN_RESETIDS 0x01 -# define POSIX_SPAWN_SETPGROUP 0x02 -# define POSIX_SPAWN_SETSIGDEF 0x04 -# define POSIX_SPAWN_SETSIGMASK 0x08 -# define POSIX_SPAWN_SETSCHEDPARAM 0x10 -# define POSIX_SPAWN_SETSCHEDULER 0x20 -# endif -#endif -/* A GNU extension. Use the next free bit position. */ -#ifndef POSIX_SPAWN_USEVFORK -# define POSIX_SPAWN_USEVFORK \ - ((POSIX_SPAWN_RESETIDS | (POSIX_SPAWN_RESETIDS - 1) \ - | POSIX_SPAWN_SETPGROUP | (POSIX_SPAWN_SETPGROUP - 1) \ - | POSIX_SPAWN_SETSIGDEF | (POSIX_SPAWN_SETSIGDEF - 1) \ - | POSIX_SPAWN_SETSIGMASK | (POSIX_SPAWN_SETSIGMASK - 1) \ - | POSIX_SPAWN_SETSCHEDPARAM \ - | (POSIX_SPAWN_SETSCHEDPARAM > 0 ? POSIX_SPAWN_SETSCHEDPARAM - 1 : 0) \ - | POSIX_SPAWN_SETSCHEDULER \ - | (POSIX_SPAWN_SETSCHEDULER > 0 ? POSIX_SPAWN_SETSCHEDULER - 1 : 0)) \ - + 1) -#endif -#if !GNULIB_defined_verify_POSIX_SPAWN_USEVFORK_no_overlap -typedef int verify_POSIX_SPAWN_USEVFORK_no_overlap - [(((POSIX_SPAWN_RESETIDS | POSIX_SPAWN_SETPGROUP - | POSIX_SPAWN_SETSIGDEF | POSIX_SPAWN_SETSIGMASK - | POSIX_SPAWN_SETSCHEDPARAM | POSIX_SPAWN_SETSCHEDULER) - & POSIX_SPAWN_USEVFORK) - == 0) - ? 1 : -1]; -# define GNULIB_defined_verify_POSIX_SPAWN_USEVFORK_no_overlap 1 -#endif - - -#if @GNULIB_POSIX_SPAWN@ -/* Spawn a new process executing PATH with the attributes describes in *ATTRP. - Before running the process perform the actions described in FILE-ACTIONS. - - This function is a possible cancellation points and therefore not - marked with __THROW. */ -# if @REPLACE_POSIX_SPAWN@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# define posix_spawn rpl_posix_spawn -# endif -_GL_FUNCDECL_RPL (posix_spawn, int, - (pid_t *_Restrict_ __pid, - const char *_Restrict_ __path, - const posix_spawn_file_actions_t *_Restrict_ __file_actions, - const posix_spawnattr_t *_Restrict_ __attrp, - char *const argv[_Restrict_arr_], - char *const envp[_Restrict_arr_]) - _GL_ARG_NONNULL ((2, 5, 6))); -_GL_CXXALIAS_RPL (posix_spawn, int, - (pid_t *_Restrict_ __pid, - const char *_Restrict_ __path, - const posix_spawn_file_actions_t *_Restrict_ __file_actions, - const posix_spawnattr_t *_Restrict_ __attrp, - char *const argv[_Restrict_arr_], - char *const envp[_Restrict_arr_])); -# else -# if !@HAVE_POSIX_SPAWN@ -_GL_FUNCDECL_SYS (posix_spawn, int, - (pid_t *_Restrict_ __pid, - const char *_Restrict_ __path, - const posix_spawn_file_actions_t *_Restrict_ __file_actions, - const posix_spawnattr_t *_Restrict_ __attrp, - char *const argv[_Restrict_arr_], - char *const envp[_Restrict_arr_]) - _GL_ARG_NONNULL ((2, 5, 6))); -# endif -_GL_CXXALIAS_SYS (posix_spawn, int, - (pid_t *_Restrict_ __pid, - const char *_Restrict_ __path, - const posix_spawn_file_actions_t *_Restrict_ __file_actions, - const posix_spawnattr_t *_Restrict_ __attrp, - char *const argv[_Restrict_arr_], - char *const envp[_Restrict_arr_])); -# endif -_GL_CXXALIASWARN (posix_spawn); -#elif defined GNULIB_POSIXCHECK -# undef posix_spawn -# if HAVE_RAW_DECL_POSIX_SPAWN -_GL_WARN_ON_USE (posix_spawn, "posix_spawn is unportable - " - "use gnulib module posix_spawn for portability"); -# endif -#endif - -#if @GNULIB_POSIX_SPAWNP@ -/* Similar to 'posix_spawn' but search for FILE in the PATH. - - This function is a possible cancellation points and therefore not - marked with __THROW. */ -# if @REPLACE_POSIX_SPAWN@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# define posix_spawnp rpl_posix_spawnp -# endif -_GL_FUNCDECL_RPL (posix_spawnp, int, - (pid_t *__pid, const char *__file, - const posix_spawn_file_actions_t *__file_actions, - const posix_spawnattr_t *__attrp, - char *const argv[], char *const envp[]) - _GL_ARG_NONNULL ((2, 5, 6))); -_GL_CXXALIAS_RPL (posix_spawnp, int, - (pid_t *__pid, const char *__file, - const posix_spawn_file_actions_t *__file_actions, - const posix_spawnattr_t *__attrp, - char *const argv[], char *const envp[])); -# else -# if !@HAVE_POSIX_SPAWN@ -_GL_FUNCDECL_SYS (posix_spawnp, int, - (pid_t *__pid, const char *__file, - const posix_spawn_file_actions_t *__file_actions, - const posix_spawnattr_t *__attrp, - char *const argv[], char *const envp[]) - _GL_ARG_NONNULL ((2, 5, 6))); -# endif -_GL_CXXALIAS_SYS (posix_spawnp, int, - (pid_t *__pid, const char *__file, - const posix_spawn_file_actions_t *__file_actions, - const posix_spawnattr_t *__attrp, - char *const argv[], char *const envp[])); -# endif -_GL_CXXALIASWARN (posix_spawnp); -#elif defined GNULIB_POSIXCHECK -# undef posix_spawnp -# if HAVE_RAW_DECL_POSIX_SPAWNP -_GL_WARN_ON_USE (posix_spawnp, "posix_spawnp is unportable - " - "use gnulib module posix_spawnp for portability"); -# endif -#endif - - -#if @GNULIB_POSIX_SPAWNATTR_INIT@ -/* Initialize data structure with attributes for 'spawn' to default values. */ -# if @REPLACE_POSIX_SPAWN@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# define posix_spawnattr_init rpl_posix_spawnattr_init -# endif -_GL_FUNCDECL_RPL (posix_spawnattr_init, int, (posix_spawnattr_t *__attr) - __THROW _GL_ARG_NONNULL ((1))); -_GL_CXXALIAS_RPL (posix_spawnattr_init, int, (posix_spawnattr_t *__attr)); -# else -# if !@HAVE_POSIX_SPAWN@ -_GL_FUNCDECL_SYS (posix_spawnattr_init, int, (posix_spawnattr_t *__attr) - __THROW _GL_ARG_NONNULL ((1))); -# endif -_GL_CXXALIAS_SYS (posix_spawnattr_init, int, (posix_spawnattr_t *__attr)); -# endif -_GL_CXXALIASWARN (posix_spawnattr_init); -#elif defined GNULIB_POSIXCHECK -# undef posix_spawnattr_init -# if HAVE_RAW_DECL_POSIX_SPAWNATTR_INIT -_GL_WARN_ON_USE (posix_spawnattr_init, "posix_spawnattr_init is unportable - " - "use gnulib module posix_spawnattr_init for portability"); -# endif -#endif - -#if @GNULIB_POSIX_SPAWNATTR_DESTROY@ -/* Free resources associated with ATTR. */ -# if @REPLACE_POSIX_SPAWN@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# define posix_spawnattr_destroy rpl_posix_spawnattr_destroy -# endif -_GL_FUNCDECL_RPL (posix_spawnattr_destroy, int, (posix_spawnattr_t *__attr) - __THROW _GL_ARG_NONNULL ((1))); -_GL_CXXALIAS_RPL (posix_spawnattr_destroy, int, (posix_spawnattr_t *__attr)); -# else -# if !@HAVE_POSIX_SPAWN@ -_GL_FUNCDECL_SYS (posix_spawnattr_destroy, int, (posix_spawnattr_t *__attr) - __THROW _GL_ARG_NONNULL ((1))); -# endif -_GL_CXXALIAS_SYS (posix_spawnattr_destroy, int, (posix_spawnattr_t *__attr)); -# endif -_GL_CXXALIASWARN (posix_spawnattr_destroy); -#elif defined GNULIB_POSIXCHECK -# undef posix_spawnattr_destroy -# if HAVE_RAW_DECL_POSIX_SPAWNATTR_DESTROY -_GL_WARN_ON_USE (posix_spawnattr_destroy, - "posix_spawnattr_destroy is unportable - " - "use gnulib module posix_spawnattr_destroy for portability"); -# endif -#endif - -#if @GNULIB_POSIX_SPAWNATTR_GETSIGDEFAULT@ -/* Store signal mask for signals with default handling from ATTR in - SIGDEFAULT. */ -# if @REPLACE_POSIX_SPAWN@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# define posix_spawnattr_getsigdefault rpl_posix_spawnattr_getsigdefault -# endif -_GL_FUNCDECL_RPL (posix_spawnattr_getsigdefault, int, - (const posix_spawnattr_t *_Restrict_ __attr, - sigset_t *_Restrict_ __sigdefault) - __THROW _GL_ARG_NONNULL ((1, 2))); -_GL_CXXALIAS_RPL (posix_spawnattr_getsigdefault, int, - (const posix_spawnattr_t *_Restrict_ __attr, - sigset_t *_Restrict_ __sigdefault)); -# else -# if !@HAVE_POSIX_SPAWN@ -_GL_FUNCDECL_SYS (posix_spawnattr_getsigdefault, int, - (const posix_spawnattr_t *_Restrict_ __attr, - sigset_t *_Restrict_ __sigdefault) - __THROW _GL_ARG_NONNULL ((1, 2))); -# endif -_GL_CXXALIAS_SYS (posix_spawnattr_getsigdefault, int, - (const posix_spawnattr_t *_Restrict_ __attr, - sigset_t *_Restrict_ __sigdefault)); -# endif -_GL_CXXALIASWARN (posix_spawnattr_getsigdefault); -#elif defined GNULIB_POSIXCHECK -# undef posix_spawnattr_getsigdefault -# if HAVE_RAW_DECL_POSIX_SPAWNATTR_GETSIGDEFAULT -_GL_WARN_ON_USE (posix_spawnattr_getsigdefault, - "posix_spawnattr_getsigdefault is unportable - " - "use gnulib module posix_spawnattr_getsigdefault for portability"); -# endif -#endif - -#if @GNULIB_POSIX_SPAWNATTR_SETSIGDEFAULT@ -/* Set signal mask for signals with default handling in ATTR to SIGDEFAULT. */ -# if @REPLACE_POSIX_SPAWN@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# define posix_spawnattr_setsigdefault rpl_posix_spawnattr_setsigdefault -# endif -_GL_FUNCDECL_RPL (posix_spawnattr_setsigdefault, int, - (posix_spawnattr_t *_Restrict_ __attr, - const sigset_t *_Restrict_ __sigdefault) - __THROW _GL_ARG_NONNULL ((1, 2))); -_GL_CXXALIAS_RPL (posix_spawnattr_setsigdefault, int, - (posix_spawnattr_t *_Restrict_ __attr, - const sigset_t *_Restrict_ __sigdefault)); -# else -# if !@HAVE_POSIX_SPAWN@ -_GL_FUNCDECL_SYS (posix_spawnattr_setsigdefault, int, - (posix_spawnattr_t *_Restrict_ __attr, - const sigset_t *_Restrict_ __sigdefault) - __THROW _GL_ARG_NONNULL ((1, 2))); -# endif -_GL_CXXALIAS_SYS (posix_spawnattr_setsigdefault, int, - (posix_spawnattr_t *_Restrict_ __attr, - const sigset_t *_Restrict_ __sigdefault)); -# endif -_GL_CXXALIASWARN (posix_spawnattr_setsigdefault); -#elif defined GNULIB_POSIXCHECK -# undef posix_spawnattr_setsigdefault -# if HAVE_RAW_DECL_POSIX_SPAWNATTR_SETSIGDEFAULT -_GL_WARN_ON_USE (posix_spawnattr_setsigdefault, - "posix_spawnattr_setsigdefault is unportable - " - "use gnulib module posix_spawnattr_setsigdefault for portability"); -# endif -#endif - -#if @GNULIB_POSIX_SPAWNATTR_GETSIGMASK@ -/* Store signal mask for the new process from ATTR in SIGMASK. */ -# if @REPLACE_POSIX_SPAWN@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# define posix_spawnattr_getsigmask rpl_posix_spawnattr_getsigmask -# endif -_GL_FUNCDECL_RPL (posix_spawnattr_getsigmask, int, - (const posix_spawnattr_t *_Restrict_ __attr, - sigset_t *_Restrict_ __sigmask) - __THROW _GL_ARG_NONNULL ((1, 2))); -_GL_CXXALIAS_RPL (posix_spawnattr_getsigmask, int, - (const posix_spawnattr_t *_Restrict_ __attr, - sigset_t *_Restrict_ __sigmask)); -# else -# if !@HAVE_POSIX_SPAWN@ -_GL_FUNCDECL_SYS (posix_spawnattr_getsigmask, int, - (const posix_spawnattr_t *_Restrict_ __attr, - sigset_t *_Restrict_ __sigmask) - __THROW _GL_ARG_NONNULL ((1, 2))); -# endif -_GL_CXXALIAS_SYS (posix_spawnattr_getsigmask, int, - (const posix_spawnattr_t *_Restrict_ __attr, - sigset_t *_Restrict_ __sigmask)); -# endif -_GL_CXXALIASWARN (posix_spawnattr_getsigmask); -#elif defined GNULIB_POSIXCHECK -# undef posix_spawnattr_getsigmask -# if HAVE_RAW_DECL_POSIX_SPAWNATTR_GETSIGMASK -_GL_WARN_ON_USE (posix_spawnattr_getsigmask, - "posix_spawnattr_getsigmask is unportable - " - "use gnulib module posix_spawnattr_getsigmask for portability"); -# endif -#endif - -#if @GNULIB_POSIX_SPAWNATTR_SETSIGMASK@ -/* Set signal mask for the new process in ATTR to SIGMASK. */ -# if @REPLACE_POSIX_SPAWN@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# define posix_spawnattr_setsigmask rpl_posix_spawnattr_setsigmask -# endif -_GL_FUNCDECL_RPL (posix_spawnattr_setsigmask, int, - (posix_spawnattr_t *_Restrict_ __attr, - const sigset_t *_Restrict_ __sigmask) - __THROW _GL_ARG_NONNULL ((1, 2))); -_GL_CXXALIAS_RPL (posix_spawnattr_setsigmask, int, - (posix_spawnattr_t *_Restrict_ __attr, - const sigset_t *_Restrict_ __sigmask)); -# else -# if !@HAVE_POSIX_SPAWN@ -_GL_FUNCDECL_SYS (posix_spawnattr_setsigmask, int, - (posix_spawnattr_t *_Restrict_ __attr, - const sigset_t *_Restrict_ __sigmask) - __THROW _GL_ARG_NONNULL ((1, 2))); -# endif -_GL_CXXALIAS_SYS (posix_spawnattr_setsigmask, int, - (posix_spawnattr_t *_Restrict_ __attr, - const sigset_t *_Restrict_ __sigmask)); -# endif -_GL_CXXALIASWARN (posix_spawnattr_setsigmask); -#elif defined GNULIB_POSIXCHECK -# undef posix_spawnattr_setsigmask -# if HAVE_RAW_DECL_POSIX_SPAWNATTR_SETSIGMASK -_GL_WARN_ON_USE (posix_spawnattr_setsigmask, - "posix_spawnattr_setsigmask is unportable - " - "use gnulib module posix_spawnattr_setsigmask for portability"); -# endif -#endif - -#if @GNULIB_POSIX_SPAWNATTR_GETFLAGS@ -/* Get flag word from the attribute structure. */ -# if @REPLACE_POSIX_SPAWN@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# define posix_spawnattr_getflags rpl_posix_spawnattr_getflags -# endif -_GL_FUNCDECL_RPL (posix_spawnattr_getflags, int, - (const posix_spawnattr_t *_Restrict_ __attr, - short int *_Restrict_ __flags) - __THROW _GL_ARG_NONNULL ((1, 2))); -_GL_CXXALIAS_RPL (posix_spawnattr_getflags, int, - (const posix_spawnattr_t *_Restrict_ __attr, - short int *_Restrict_ __flags)); -# else -# if !@HAVE_POSIX_SPAWN@ -_GL_FUNCDECL_SYS (posix_spawnattr_getflags, int, - (const posix_spawnattr_t *_Restrict_ __attr, - short int *_Restrict_ __flags) - __THROW _GL_ARG_NONNULL ((1, 2))); -# endif -_GL_CXXALIAS_SYS (posix_spawnattr_getflags, int, - (const posix_spawnattr_t *_Restrict_ __attr, - short int *_Restrict_ __flags)); -# endif -_GL_CXXALIASWARN (posix_spawnattr_getflags); -#elif defined GNULIB_POSIXCHECK -# undef posix_spawnattr_getflags -# if HAVE_RAW_DECL_POSIX_SPAWNATTR_GETFLAGS -_GL_WARN_ON_USE (posix_spawnattr_getflags, - "posix_spawnattr_getflags is unportable - " - "use gnulib module posix_spawnattr_getflags for portability"); -# endif -#endif - -#if @GNULIB_POSIX_SPAWNATTR_SETFLAGS@ -/* Store flags in the attribute structure. */ -# if @REPLACE_POSIX_SPAWN@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# define posix_spawnattr_setflags rpl_posix_spawnattr_setflags -# endif -_GL_FUNCDECL_RPL (posix_spawnattr_setflags, int, - (posix_spawnattr_t *__attr, short int __flags) - __THROW _GL_ARG_NONNULL ((1))); -_GL_CXXALIAS_RPL (posix_spawnattr_setflags, int, - (posix_spawnattr_t *__attr, short int __flags)); -# else -# if !@HAVE_POSIX_SPAWN@ -_GL_FUNCDECL_SYS (posix_spawnattr_setflags, int, - (posix_spawnattr_t *__attr, short int __flags) - __THROW _GL_ARG_NONNULL ((1))); -# endif -_GL_CXXALIAS_SYS (posix_spawnattr_setflags, int, - (posix_spawnattr_t *__attr, short int __flags)); -# endif -_GL_CXXALIASWARN (posix_spawnattr_setflags); -#elif defined GNULIB_POSIXCHECK -# undef posix_spawnattr_setflags -# if HAVE_RAW_DECL_POSIX_SPAWNATTR_SETFLAGS -_GL_WARN_ON_USE (posix_spawnattr_setflags, - "posix_spawnattr_setflags is unportable - " - "use gnulib module posix_spawnattr_setflags for portability"); -# endif -#endif - -#if @GNULIB_POSIX_SPAWNATTR_GETPGROUP@ -/* Get process group ID from the attribute structure. */ -# if @REPLACE_POSIX_SPAWN@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# define posix_spawnattr_getpgroup rpl_posix_spawnattr_getpgroup -# endif -_GL_FUNCDECL_RPL (posix_spawnattr_getpgroup, int, - (const posix_spawnattr_t *_Restrict_ __attr, - pid_t *_Restrict_ __pgroup) - __THROW _GL_ARG_NONNULL ((1, 2))); -_GL_CXXALIAS_RPL (posix_spawnattr_getpgroup, int, - (const posix_spawnattr_t *_Restrict_ __attr, - pid_t *_Restrict_ __pgroup)); -# else -# if !@HAVE_POSIX_SPAWN@ -_GL_FUNCDECL_SYS (posix_spawnattr_getpgroup, int, - (const posix_spawnattr_t *_Restrict_ __attr, - pid_t *_Restrict_ __pgroup) - __THROW _GL_ARG_NONNULL ((1, 2))); -# endif -_GL_CXXALIAS_SYS (posix_spawnattr_getpgroup, int, - (const posix_spawnattr_t *_Restrict_ __attr, - pid_t *_Restrict_ __pgroup)); -# endif -_GL_CXXALIASWARN (posix_spawnattr_getpgroup); -#elif defined GNULIB_POSIXCHECK -# undef posix_spawnattr_getpgroup -# if HAVE_RAW_DECL_POSIX_SPAWNATTR_GETPGROUP -_GL_WARN_ON_USE (posix_spawnattr_getpgroup, - "posix_spawnattr_getpgroup is unportable - " - "use gnulib module posix_spawnattr_getpgroup for portability"); -# endif -#endif - -#if @GNULIB_POSIX_SPAWNATTR_SETPGROUP@ -/* Store process group ID in the attribute structure. */ -# if @REPLACE_POSIX_SPAWN@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# define posix_spawnattr_setpgroup rpl_posix_spawnattr_setpgroup -# endif -_GL_FUNCDECL_RPL (posix_spawnattr_setpgroup, int, - (posix_spawnattr_t *__attr, pid_t __pgroup) - __THROW _GL_ARG_NONNULL ((1))); -_GL_CXXALIAS_RPL (posix_spawnattr_setpgroup, int, - (posix_spawnattr_t *__attr, pid_t __pgroup)); -# else -# if !@HAVE_POSIX_SPAWN@ -_GL_FUNCDECL_SYS (posix_spawnattr_setpgroup, int, - (posix_spawnattr_t *__attr, pid_t __pgroup) - __THROW _GL_ARG_NONNULL ((1))); -# endif -_GL_CXXALIAS_SYS (posix_spawnattr_setpgroup, int, - (posix_spawnattr_t *__attr, pid_t __pgroup)); -# endif -_GL_CXXALIASWARN (posix_spawnattr_setpgroup); -#elif defined GNULIB_POSIXCHECK -# undef posix_spawnattr_setpgroup -# if HAVE_RAW_DECL_POSIX_SPAWNATTR_SETPGROUP -_GL_WARN_ON_USE (posix_spawnattr_setpgroup, - "posix_spawnattr_setpgroup is unportable - " - "use gnulib module posix_spawnattr_setpgroup for portability"); -# endif -#endif - -#if @GNULIB_POSIX_SPAWNATTR_GETSCHEDPOLICY@ -/* Get scheduling policy from the attribute structure. */ -# if @REPLACE_POSIX_SPAWN@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# define posix_spawnattr_getschedpolicy rpl_posix_spawnattr_getschedpolicy -# endif -_GL_FUNCDECL_RPL (posix_spawnattr_getschedpolicy, int, - (const posix_spawnattr_t *_Restrict_ __attr, - int *_Restrict_ __schedpolicy) - __THROW _GL_ARG_NONNULL ((1, 2))); -_GL_CXXALIAS_RPL (posix_spawnattr_getschedpolicy, int, - (const posix_spawnattr_t *_Restrict_ __attr, - int *_Restrict_ __schedpolicy)); -# else -# if !@HAVE_POSIX_SPAWN@ || POSIX_SPAWN_SETSCHEDULER == 0 -_GL_FUNCDECL_SYS (posix_spawnattr_getschedpolicy, int, - (const posix_spawnattr_t *_Restrict_ __attr, - int *_Restrict_ __schedpolicy) - __THROW _GL_ARG_NONNULL ((1, 2))); -# endif -_GL_CXXALIAS_SYS (posix_spawnattr_getschedpolicy, int, - (const posix_spawnattr_t *_Restrict_ __attr, - int *_Restrict_ __schedpolicy)); -# endif -# if __GLIBC__ >= 2 -_GL_CXXALIASWARN (posix_spawnattr_getschedpolicy); -# endif -#elif defined GNULIB_POSIXCHECK -# undef posix_spawnattr_getschedpolicy -# if HAVE_RAW_DECL_POSIX_SPAWNATTR_GETSCHEDPOLICY -_GL_WARN_ON_USE (posix_spawnattr_getschedpolicy, - "posix_spawnattr_getschedpolicy is unportable - " - "use gnulib module posix_spawnattr_getschedpolicy for portability"); -# endif -#endif - -#if @GNULIB_POSIX_SPAWNATTR_SETSCHEDPOLICY@ -/* Store scheduling policy in the attribute structure. */ -# if @REPLACE_POSIX_SPAWN@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# define posix_spawnattr_setschedpolicy rpl_posix_spawnattr_setschedpolicy -# endif -_GL_FUNCDECL_RPL (posix_spawnattr_setschedpolicy, int, - (posix_spawnattr_t *__attr, int __schedpolicy) - __THROW _GL_ARG_NONNULL ((1))); -_GL_CXXALIAS_RPL (posix_spawnattr_setschedpolicy, int, - (posix_spawnattr_t *__attr, int __schedpolicy)); -# else -# if !@HAVE_POSIX_SPAWN@ || POSIX_SPAWN_SETSCHEDULER == 0 -_GL_FUNCDECL_SYS (posix_spawnattr_setschedpolicy, int, - (posix_spawnattr_t *__attr, int __schedpolicy) - __THROW _GL_ARG_NONNULL ((1))); -# endif -_GL_CXXALIAS_SYS (posix_spawnattr_setschedpolicy, int, - (posix_spawnattr_t *__attr, int __schedpolicy)); -# endif -# if __GLIBC__ >= 2 -_GL_CXXALIASWARN (posix_spawnattr_setschedpolicy); -# endif -#elif defined GNULIB_POSIXCHECK -# undef posix_spawnattr_setschedpolicy -# if HAVE_RAW_DECL_POSIX_SPAWNATTR_SETSCHEDPOLICY -_GL_WARN_ON_USE (posix_spawnattr_setschedpolicy, - "posix_spawnattr_setschedpolicy is unportable - " - "use gnulib module posix_spawnattr_setschedpolicy for portability"); -# endif -#endif - -#if @GNULIB_POSIX_SPAWNATTR_GETSCHEDPARAM@ -/* Get scheduling parameters from the attribute structure. */ -# if @REPLACE_POSIX_SPAWN@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# define posix_spawnattr_getschedparam rpl_posix_spawnattr_getschedparam -# endif -_GL_FUNCDECL_RPL (posix_spawnattr_getschedparam, int, - (const posix_spawnattr_t *_Restrict_ __attr, - struct sched_param *_Restrict_ __schedparam) - __THROW _GL_ARG_NONNULL ((1, 2))); -_GL_CXXALIAS_RPL (posix_spawnattr_getschedparam, int, - (const posix_spawnattr_t *_Restrict_ __attr, - struct sched_param *_Restrict_ __schedparam)); -# else -# if !@HAVE_POSIX_SPAWN@ || POSIX_SPAWN_SETSCHEDPARAM == 0 -_GL_FUNCDECL_SYS (posix_spawnattr_getschedparam, int, - (const posix_spawnattr_t *_Restrict_ __attr, - struct sched_param *_Restrict_ __schedparam) - __THROW _GL_ARG_NONNULL ((1, 2))); -# endif -_GL_CXXALIAS_SYS (posix_spawnattr_getschedparam, int, - (const posix_spawnattr_t *_Restrict_ __attr, - struct sched_param *_Restrict_ __schedparam)); -# endif -# if __GLIBC__ >= 2 -_GL_CXXALIASWARN (posix_spawnattr_getschedparam); -# endif -#elif defined GNULIB_POSIXCHECK -# undef posix_spawnattr_getschedparam -# if HAVE_RAW_DECL_POSIX_SPAWNATTR_GETSCHEDPARAM -_GL_WARN_ON_USE (posix_spawnattr_getschedparam, - "posix_spawnattr_getschedparam is unportable - " - "use gnulib module posix_spawnattr_getschedparam for portability"); -# endif -#endif - -#if @GNULIB_POSIX_SPAWNATTR_SETSCHEDPARAM@ -/* Store scheduling parameters in the attribute structure. */ -# if @REPLACE_POSIX_SPAWN@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# define posix_spawnattr_setschedparam rpl_posix_spawnattr_setschedparam -# endif -_GL_FUNCDECL_RPL (posix_spawnattr_setschedparam, int, - (posix_spawnattr_t *_Restrict_ __attr, - const struct sched_param *_Restrict_ __schedparam) - __THROW _GL_ARG_NONNULL ((1, 2))); -_GL_CXXALIAS_RPL (posix_spawnattr_setschedparam, int, - (posix_spawnattr_t *_Restrict_ __attr, - const struct sched_param *_Restrict_ __schedparam)); -# else -# if !@HAVE_POSIX_SPAWN@ || POSIX_SPAWN_SETSCHEDPARAM == 0 -_GL_FUNCDECL_SYS (posix_spawnattr_setschedparam, int, - (posix_spawnattr_t *_Restrict_ __attr, - const struct sched_param *_Restrict_ __schedparam) - __THROW _GL_ARG_NONNULL ((1, 2))); -# endif -_GL_CXXALIAS_SYS (posix_spawnattr_setschedparam, int, - (posix_spawnattr_t *_Restrict_ __attr, - const struct sched_param *_Restrict_ __schedparam)); -# endif -# if __GLIBC__ >= 2 -_GL_CXXALIASWARN (posix_spawnattr_setschedparam); -# endif -#elif defined GNULIB_POSIXCHECK -# undef posix_spawnattr_setschedparam -# if HAVE_RAW_DECL_POSIX_SPAWNATTR_SETSCHEDPARAM -_GL_WARN_ON_USE (posix_spawnattr_setschedparam, - "posix_spawnattr_setschedparam is unportable - " - "use gnulib module posix_spawnattr_setschedparam for portability"); -# endif -#endif - - -#if @GNULIB_POSIX_SPAWN_FILE_ACTIONS_INIT@ -/* Initialize data structure for file attribute for 'spawn' call. */ -# if @REPLACE_POSIX_SPAWN@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# define posix_spawn_file_actions_init rpl_posix_spawn_file_actions_init -# endif -_GL_FUNCDECL_RPL (posix_spawn_file_actions_init, int, - (posix_spawn_file_actions_t *__file_actions) - __THROW _GL_ARG_NONNULL ((1))); -_GL_CXXALIAS_RPL (posix_spawn_file_actions_init, int, - (posix_spawn_file_actions_t *__file_actions)); -# else -# if !@HAVE_POSIX_SPAWN@ -_GL_FUNCDECL_SYS (posix_spawn_file_actions_init, int, - (posix_spawn_file_actions_t *__file_actions) - __THROW _GL_ARG_NONNULL ((1))); -# endif -_GL_CXXALIAS_SYS (posix_spawn_file_actions_init, int, - (posix_spawn_file_actions_t *__file_actions)); -# endif -_GL_CXXALIASWARN (posix_spawn_file_actions_init); -#elif defined GNULIB_POSIXCHECK -# undef posix_spawn_file_actions_init -# if HAVE_RAW_DECL_POSIX_SPAWN_FILE_ACTIONS_INIT -_GL_WARN_ON_USE (posix_spawn_file_actions_init, - "posix_spawn_file_actions_init is unportable - " - "use gnulib module posix_spawn_file_actions_init for portability"); -# endif -#endif - -#if @GNULIB_POSIX_SPAWN_FILE_ACTIONS_DESTROY@ -/* Free resources associated with FILE-ACTIONS. */ -# if @REPLACE_POSIX_SPAWN@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# define posix_spawn_file_actions_destroy rpl_posix_spawn_file_actions_destroy -# endif -_GL_FUNCDECL_RPL (posix_spawn_file_actions_destroy, int, - (posix_spawn_file_actions_t *__file_actions) - __THROW _GL_ARG_NONNULL ((1))); -_GL_CXXALIAS_RPL (posix_spawn_file_actions_destroy, int, - (posix_spawn_file_actions_t *__file_actions)); -# else -# if !@HAVE_POSIX_SPAWN@ -_GL_FUNCDECL_SYS (posix_spawn_file_actions_destroy, int, - (posix_spawn_file_actions_t *__file_actions) - __THROW _GL_ARG_NONNULL ((1))); -# endif -_GL_CXXALIAS_SYS (posix_spawn_file_actions_destroy, int, - (posix_spawn_file_actions_t *__file_actions)); -# endif -_GL_CXXALIASWARN (posix_spawn_file_actions_destroy); -#elif defined GNULIB_POSIXCHECK -# undef posix_spawn_file_actions_destroy -# if HAVE_RAW_DECL_POSIX_SPAWN_FILE_ACTIONS_DESTROY -_GL_WARN_ON_USE (posix_spawn_file_actions_destroy, - "posix_spawn_file_actions_destroy is unportable - " - "use gnulib module posix_spawn_file_actions_destroy for portability"); -# endif -#endif - -#if @GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN@ -/* Add an action to FILE-ACTIONS which tells the implementation to call - 'open' for the given file during the 'spawn' call. */ -# if @REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# define posix_spawn_file_actions_addopen rpl_posix_spawn_file_actions_addopen -# endif -_GL_FUNCDECL_RPL (posix_spawn_file_actions_addopen, int, - (posix_spawn_file_actions_t *_Restrict_ __file_actions, - int __fd, - const char *_Restrict_ __path, int __oflag, mode_t __mode) - __THROW _GL_ARG_NONNULL ((1, 3))); -_GL_CXXALIAS_RPL (posix_spawn_file_actions_addopen, int, - (posix_spawn_file_actions_t *_Restrict_ __file_actions, - int __fd, - const char *_Restrict_ __path, int __oflag, mode_t __mode)); -# else -# if !@HAVE_POSIX_SPAWN@ -_GL_FUNCDECL_SYS (posix_spawn_file_actions_addopen, int, - (posix_spawn_file_actions_t *_Restrict_ __file_actions, - int __fd, - const char *_Restrict_ __path, int __oflag, mode_t __mode) - __THROW _GL_ARG_NONNULL ((1, 3))); -# endif -_GL_CXXALIAS_SYS (posix_spawn_file_actions_addopen, int, - (posix_spawn_file_actions_t *_Restrict_ __file_actions, - int __fd, - const char *_Restrict_ __path, int __oflag, mode_t __mode)); -# endif -# if __GLIBC__ >= 2 -_GL_CXXALIASWARN (posix_spawn_file_actions_addopen); -# endif -#elif defined GNULIB_POSIXCHECK -# undef posix_spawn_file_actions_addopen -# if HAVE_RAW_DECL_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN -_GL_WARN_ON_USE (posix_spawn_file_actions_addopen, - "posix_spawn_file_actions_addopen is unportable - " - "use gnulib module posix_spawn_file_actions_addopen for portability"); -# endif -#endif - -#if @GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE@ -/* Add an action to FILE-ACTIONS which tells the implementation to call - 'close' for the given file descriptor during the 'spawn' call. */ -# if @REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# define posix_spawn_file_actions_addclose rpl_posix_spawn_file_actions_addclose -# endif -_GL_FUNCDECL_RPL (posix_spawn_file_actions_addclose, int, - (posix_spawn_file_actions_t *__file_actions, int __fd) - __THROW _GL_ARG_NONNULL ((1))); -_GL_CXXALIAS_RPL (posix_spawn_file_actions_addclose, int, - (posix_spawn_file_actions_t *__file_actions, int __fd)); -# else -# if !@HAVE_POSIX_SPAWN@ -_GL_FUNCDECL_SYS (posix_spawn_file_actions_addclose, int, - (posix_spawn_file_actions_t *__file_actions, int __fd) - __THROW _GL_ARG_NONNULL ((1))); -# endif -_GL_CXXALIAS_SYS (posix_spawn_file_actions_addclose, int, - (posix_spawn_file_actions_t *__file_actions, int __fd)); -# endif -# if __GLIBC__ >= 2 -_GL_CXXALIASWARN (posix_spawn_file_actions_addclose); -# endif -#elif defined GNULIB_POSIXCHECK -# undef posix_spawn_file_actions_addclose -# if HAVE_RAW_DECL_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE -_GL_WARN_ON_USE (posix_spawn_file_actions_addclose, - "posix_spawn_file_actions_addclose is unportable - " - "use gnulib module posix_spawn_file_actions_addclose for portability"); -# endif -#endif - -#if @GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2@ -/* Add an action to FILE-ACTIONS which tells the implementation to call - 'dup2' for the given file descriptors during the 'spawn' call. */ -# if @REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# define posix_spawn_file_actions_adddup2 rpl_posix_spawn_file_actions_adddup2 -# endif -_GL_FUNCDECL_RPL (posix_spawn_file_actions_adddup2, int, - (posix_spawn_file_actions_t *__file_actions, - int __fd, int __newfd) - __THROW _GL_ARG_NONNULL ((1))); -_GL_CXXALIAS_RPL (posix_spawn_file_actions_adddup2, int, - (posix_spawn_file_actions_t *__file_actions, - int __fd, int __newfd)); -# else -# if !@HAVE_POSIX_SPAWN@ -_GL_FUNCDECL_SYS (posix_spawn_file_actions_adddup2, int, - (posix_spawn_file_actions_t *__file_actions, - int __fd, int __newfd) - __THROW _GL_ARG_NONNULL ((1))); -# endif -_GL_CXXALIAS_SYS (posix_spawn_file_actions_adddup2, int, - (posix_spawn_file_actions_t *__file_actions, - int __fd, int __newfd)); -# endif -# if __GLIBC__ >= 2 -_GL_CXXALIASWARN (posix_spawn_file_actions_adddup2); -# endif -#elif defined GNULIB_POSIXCHECK -# undef posix_spawn_file_actions_adddup2 -# if HAVE_RAW_DECL_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2 -_GL_WARN_ON_USE (posix_spawn_file_actions_adddup2, - "posix_spawn_file_actions_adddup2 is unportable - " - "use gnulib module posix_spawn_file_actions_adddup2 for portability"); -# endif -#endif - -#if @GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR@ -/* Add an action to FILE-ACTIONS which tells the implementation to call - 'chdir' to the given directory during the 'spawn' call. */ -# if @REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# define posix_spawn_file_actions_addchdir rpl_posix_spawn_file_actions_addchdir -# endif -_GL_FUNCDECL_RPL (posix_spawn_file_actions_addchdir, int, - (posix_spawn_file_actions_t *_Restrict_ __file_actions, - const char *_Restrict_ __path) - __THROW _GL_ARG_NONNULL ((1, 2))); -_GL_CXXALIAS_RPL (posix_spawn_file_actions_addchdir, int, - (posix_spawn_file_actions_t *_Restrict_ __file_actions, - const char *_Restrict_ __path)); -# else -# if !@HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR@ -_GL_FUNCDECL_SYS (posix_spawn_file_actions_addchdir, int, - (posix_spawn_file_actions_t *_Restrict_ __file_actions, - const char *_Restrict_ __path) - __THROW _GL_ARG_NONNULL ((1, 2))); -# endif -_GL_CXXALIAS_SYS (posix_spawn_file_actions_addchdir, int, - (posix_spawn_file_actions_t *_Restrict_ __file_actions, - const char *_Restrict_ __path)); -# endif -_GL_CXXALIASWARN (posix_spawn_file_actions_addchdir); -#elif defined GNULIB_POSIXCHECK -# undef posix_spawn_file_actions_addchdir -# if HAVE_RAW_DECL_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR -_GL_WARN_ON_USE (posix_spawn_file_actions_addchdir, - "posix_spawn_file_actions_addchdir is unportable - " - "use gnulib module posix_spawn_file_actions_addchdir for portability"); -# endif -#endif - -#if @GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR@ -/* Add an action to FILE-ACTIONS which tells the implementation to call - 'fchdir' to the given directory during the 'spawn' call. */ -# if @REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# define posix_spawn_file_actions_addfchdir rpl_posix_spawn_file_actions_addfchdir -# endif -_GL_FUNCDECL_RPL (posix_spawn_file_actions_addfchdir, int, - (posix_spawn_file_actions_t *_Restrict_ __file_actions, - int __fd) - __THROW _GL_ARG_NONNULL ((1))); -_GL_CXXALIAS_RPL (posix_spawn_file_actions_addfchdir, int, - (posix_spawn_file_actions_t *_Restrict_ __file_actions, - int __fd)); -# else -# if !@HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR@ -_GL_FUNCDECL_SYS (posix_spawn_file_actions_addfchdir, int, - (posix_spawn_file_actions_t *_Restrict_ __file_actions, - int __fd) - __THROW _GL_ARG_NONNULL ((1))); -# endif -_GL_CXXALIAS_SYS (posix_spawn_file_actions_addfchdir, int, - (posix_spawn_file_actions_t *_Restrict_ __file_actions, - int __fd)); -# endif -_GL_CXXALIASWARN (posix_spawn_file_actions_addfchdir); -#elif defined GNULIB_POSIXCHECK -# undef posix_spawn_file_actions_addfchdir -# if HAVE_RAW_DECL_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR -_GL_WARN_ON_USE (posix_spawn_file_actions_addfchdir, - "posix_spawn_file_actions_addfchdir is unportable - " - "use gnulib module posix_spawn_file_actions_addfchdir for portability"); -# endif -#endif - - -#endif /* _@GUARD_PREFIX@_SPAWN_H */ -#endif /* _@GUARD_PREFIX@_SPAWN_H */ diff --git a/lib/spawn_faction_addchdir.c b/lib/spawn_faction_addchdir.c deleted file mode 100644 index 8fb6cb0f7d..0000000000 --- a/lib/spawn_faction_addchdir.c +++ /dev/null @@ -1,70 +0,0 @@ -/* Copyright (C) 2018-2020 Free Software Foundation, Inc. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -#include - -/* Specification. */ -#include - -#include -#include -#include - -#if REPLACE_POSIX_SPAWN -# include "spawn_int.h" -#endif - -/* Add an action to FILE-ACTIONS which tells the implementation to call - 'chdir' to the given directory during the 'spawn' call. */ -int -posix_spawn_file_actions_addchdir (posix_spawn_file_actions_t *file_actions, - const char *path) -#undef posix_spawn_file_actions_addchdir -{ -#if !REPLACE_POSIX_SPAWN - return posix_spawn_file_actions_addchdir_np (file_actions, path); -#else - { - /* Copy PATH, because the caller may free it before calling posix_spawn() - or posix_spawnp(). */ - char *path_copy = strdup (path); - if (path_copy == NULL) - return ENOMEM; - - /* Allocate more memory if needed. */ - if (file_actions->_used == file_actions->_allocated - && __posix_spawn_file_actions_realloc (file_actions) != 0) - { - /* This can only mean we ran out of memory. */ - free (path_copy); - return ENOMEM; - } - - { - struct __spawn_action *rec; - - /* Add the new value. */ - rec = &file_actions->_actions[file_actions->_used]; - rec->tag = spawn_do_chdir; - rec->action.chdir_action.path = path_copy; - - /* Account for the new entry. */ - ++file_actions->_used; - - return 0; - } - } -#endif -} diff --git a/lib/spawn_faction_adddup2.c b/lib/spawn_faction_adddup2.c deleted file mode 100644 index c00b0b4966..0000000000 --- a/lib/spawn_faction_adddup2.c +++ /dev/null @@ -1,70 +0,0 @@ -/* Copyright (C) 2000, 2009-2020 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -#include - -/* Specification. */ -#include - -#include -#include - -#if !_LIBC -# define __sysconf(open_max) getdtablesize () -#endif - -#if REPLACE_POSIX_SPAWN -# include "spawn_int.h" -#endif - -/* Add an action to FILE-ACTIONS which tells the implementation to call - 'dup2' for the given file descriptors during the 'spawn' call. */ -int -posix_spawn_file_actions_adddup2 (posix_spawn_file_actions_t *file_actions, - int fd, int newfd) -#undef posix_spawn_file_actions_adddup2 -{ - int maxfd = __sysconf (_SC_OPEN_MAX); - - /* Test for the validity of the file descriptor. */ - if (fd < 0 || newfd < 0 || fd >= maxfd || newfd >= maxfd) - return EBADF; - -#if !REPLACE_POSIX_SPAWN - return posix_spawn_file_actions_adddup2 (file_actions, fd, newfd); -#else - /* Allocate more memory if needed. */ - if (file_actions->_used == file_actions->_allocated - && __posix_spawn_file_actions_realloc (file_actions) != 0) - /* This can only mean we ran out of memory. */ - return ENOMEM; - - { - struct __spawn_action *rec; - - /* Add the new value. */ - rec = &file_actions->_actions[file_actions->_used]; - rec->tag = spawn_do_dup2; - rec->action.dup2_action.fd = fd; - rec->action.dup2_action.newfd = newfd; - - /* Account for the new entry. */ - ++file_actions->_used; - - return 0; - } -#endif -} diff --git a/lib/spawn_faction_destroy.c b/lib/spawn_faction_destroy.c deleted file mode 100644 index e9985f4a0d..0000000000 --- a/lib/spawn_faction_destroy.c +++ /dev/null @@ -1,61 +0,0 @@ -/* Copyright (C) 2000, 2009-2020 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -#include - -/* Specification. */ -#include - -#include - -#if REPLACE_POSIX_SPAWN -# include "spawn_int.h" -#endif - -/* Initialize data structure for file attribute for 'spawn' call. */ -int -posix_spawn_file_actions_destroy (posix_spawn_file_actions_t *file_actions) -#undef posix_spawn_file_actions_destroy -{ -#if !REPLACE_POSIX_SPAWN - return posix_spawn_file_actions_destroy (file_actions); -#else - int i; - - /* Free the paths in the open actions. */ - for (i = 0; i < file_actions->_used; ++i) - { - struct __spawn_action *sa = &file_actions->_actions[i]; - switch (sa->tag) - { - case spawn_do_open: - free (sa->action.open_action.path); - break; - case spawn_do_chdir: - free (sa->action.chdir_action.path); - break; - default: - /* No cleanup required. */ - break; - } - } - - /* Free the array of actions. */ - free (file_actions->_actions); - - return 0; -#endif -} diff --git a/lib/spawn_faction_init.c b/lib/spawn_faction_init.c deleted file mode 100644 index 135605fb8c..0000000000 --- a/lib/spawn_faction_init.c +++ /dev/null @@ -1,56 +0,0 @@ -/* Copyright (C) 2000, 2009-2020 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -#include - -/* Specification. */ -#include - -#include -#include -#include - -#include "spawn_int.h" - - -/* Function used to increase the size of the allocated array. This - function is called from the 'add'-functions. */ -int -__posix_spawn_file_actions_realloc (posix_spawn_file_actions_t *file_actions) -{ - int newalloc = file_actions->_allocated + 8; - void *newmem = realloc (file_actions->_actions, - newalloc * sizeof (struct __spawn_action)); - - if (newmem == NULL) - /* Not enough memory. */ - return ENOMEM; - - file_actions->_actions = (struct __spawn_action *) newmem; - file_actions->_allocated = newalloc; - - return 0; -} - - -/* Initialize data structure for file attribute for 'spawn' call. */ -int -posix_spawn_file_actions_init (posix_spawn_file_actions_t *file_actions) -{ - /* Simply clear all the elements. */ - memset (file_actions, '\0', sizeof (*file_actions)); - return 0; -} diff --git a/lib/spawn_int.h b/lib/spawn_int.h deleted file mode 100644 index 60a94ddd55..0000000000 --- a/lib/spawn_int.h +++ /dev/null @@ -1,72 +0,0 @@ -/* Copyright (C) 2000, 2008-2020 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -#include - -/* Data structure to contain the action information. */ -struct __spawn_action -{ - enum - { - spawn_do_close, - spawn_do_dup2, - spawn_do_open, - spawn_do_chdir, - spawn_do_fchdir - } tag; - - union - { - struct - { - int fd; - } close_action; - struct - { - int fd; - int newfd; - } dup2_action; - struct - { - int fd; - char *path; - int oflag; - mode_t mode; - } open_action; - struct - { - char *path; - } chdir_action; - struct - { - int fd; - } fchdir_action; - } action; -}; - -#if !_LIBC -# define __posix_spawn_file_actions_realloc gl_posix_spawn_file_actions_realloc -#endif -extern int __posix_spawn_file_actions_realloc (posix_spawn_file_actions_t * - file_actions); - -#if !_LIBC -# define __spawni gl_posix_spawn_internal -#endif -extern int __spawni (pid_t *pid, const char *path, - const posix_spawn_file_actions_t *file_actions, - const posix_spawnattr_t *attrp, const char *const argv[], - const char *const envp[], int use_path); diff --git a/lib/spawnattr_destroy.c b/lib/spawnattr_destroy.c deleted file mode 100644 index 22a7d5a61a..0000000000 --- a/lib/spawnattr_destroy.c +++ /dev/null @@ -1,28 +0,0 @@ -/* Copyright (C) 2000, 2009-2020 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -#include - -/* Specification. */ -#include - -/* Initialize data structure for file attribute for 'spawn' call. */ -int -posix_spawnattr_destroy (posix_spawnattr_t *attr) -{ - /* Nothing to do in the moment. */ - return 0; -} diff --git a/lib/spawnattr_init.c b/lib/spawnattr_init.c deleted file mode 100644 index 99674488f8..0000000000 --- a/lib/spawnattr_init.c +++ /dev/null @@ -1,33 +0,0 @@ -/* Copyright (C) 2000, 2009-2020 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -#include - -/* Specification. */ -#include - -#include - -/* Initialize data structure for file attribute for 'spawn' call. */ -int -posix_spawnattr_init (posix_spawnattr_t *attr) -{ - /* All elements have to be initialized to the default values which - is generally zero. */ - memset (attr, '\0', sizeof (*attr)); - - return 0; -} diff --git a/lib/spawnattr_setdefault.c b/lib/spawnattr_setdefault.c deleted file mode 100644 index 01c29e9484..0000000000 --- a/lib/spawnattr_setdefault.c +++ /dev/null @@ -1,33 +0,0 @@ -/* Copyright (C) 2000, 2009-2020 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -#include - -/* Specification. */ -#include - -#include - -/* Set signal mask for signals with default handling in ATTR to SIGDEFAULT. */ -int -posix_spawnattr_setsigdefault (posix_spawnattr_t *attr, - const sigset_t *sigdefault) -{ - /* Copy the sigset_t data to the user buffer. */ - memcpy (&attr->_sd, sigdefault, sizeof (sigset_t)); - - return 0; -} diff --git a/lib/spawnattr_setflags.c b/lib/spawnattr_setflags.c deleted file mode 100644 index 084d5bcea4..0000000000 --- a/lib/spawnattr_setflags.c +++ /dev/null @@ -1,45 +0,0 @@ -/* Copyright (C) 2000, 2004, 2009-2020 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -#include - -/* Specification. */ -#include - -#include -#include - -#define ALL_FLAGS (POSIX_SPAWN_RESETIDS \ - | POSIX_SPAWN_SETPGROUP \ - | POSIX_SPAWN_SETSIGDEF \ - | POSIX_SPAWN_SETSIGMASK \ - | POSIX_SPAWN_SETSCHEDPARAM \ - | POSIX_SPAWN_SETSCHEDULER \ - | POSIX_SPAWN_USEVFORK) - -/* Store flags in the attribute structure. */ -int -posix_spawnattr_setflags (posix_spawnattr_t *attr, short int flags) -{ - /* Check no invalid bits are set. */ - if (flags & ~ALL_FLAGS) - return EINVAL; - - /* Store the flag word. */ - attr->_flags = flags; - - return 0; -} diff --git a/lib/spawnattr_setpgroup.c b/lib/spawnattr_setpgroup.c deleted file mode 100644 index 479457ad23..0000000000 --- a/lib/spawnattr_setpgroup.c +++ /dev/null @@ -1,32 +0,0 @@ -/* Copyright (C) 2000, 2009-2020 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -#include - -/* Specification. */ -#include - -#include - -/* Store process group ID in the attribute structure. */ -int -posix_spawnattr_setpgroup (posix_spawnattr_t *attr, pid_t pgroup) -{ - /* Store the process group ID. */ - attr->_pgrp = pgroup; - - return 0; -} diff --git a/lib/spawnattr_setsigmask.c b/lib/spawnattr_setsigmask.c deleted file mode 100644 index 9b6f9ece38..0000000000 --- a/lib/spawnattr_setsigmask.c +++ /dev/null @@ -1,33 +0,0 @@ -/* Copyright (C) 2000, 2009-2020 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -#include - -/* Specification. */ -#include - -#include - -/* Set signal mask for the new process in ATTR to SIGMASK. */ -int -posix_spawnattr_setsigmask (posix_spawnattr_t *attr, - const sigset_t *sigmask) -{ - /* Copy the sigset_t data to the user buffer. */ - memcpy (&attr->_ss, sigmask, sizeof (sigset_t)); - - return 0; -} diff --git a/lib/spawni.c b/lib/spawni.c deleted file mode 100644 index 182d13ff24..0000000000 --- a/lib/spawni.c +++ /dev/null @@ -1,349 +0,0 @@ -/* Guts of POSIX spawn interface. Generic POSIX.1 version. - Copyright (C) 2000-2006, 2008-2020 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -#include - -/* Specification. */ -#include -#include "spawn_int.h" - -#include -#include - -#include -#ifndef O_LARGEFILE -# define O_LARGEFILE 0 -#endif - -#if _LIBC || HAVE_PATHS_H -# include -#else -# define _PATH_BSHELL BOURNE_SHELL -#endif - -#include -#include -#include -#include - -#if _LIBC -# include -#else -# define close_not_cancel close -# define open_not_cancel open -#endif - -#if _LIBC -# include -#else -# if !HAVE_SETEUID -# define seteuid(id) setresuid (-1, id, -1) -# endif -# if !HAVE_SETEGID -# define setegid(id) setresgid (-1, id, -1) -# endif -# define local_seteuid(id) seteuid (id) -# define local_setegid(id) setegid (id) -#endif - -#if _LIBC -# define alloca __alloca -# define execve __execve -# define dup2 __dup2 -# define fork __fork -# define getgid __getgid -# define getuid __getuid -# define sched_setparam __sched_setparam -# define sched_setscheduler __sched_setscheduler -# define setpgid __setpgid -# define sigaction __sigaction -# define sigismember __sigismember -# define sigprocmask __sigprocmask -# define strchrnul __strchrnul -# define vfork __vfork -#endif - - -/* The Unix standard contains a long explanation of the way to signal - an error after the fork() was successful. Since no new wait status - was wanted there is no way to signal an error using one of the - available methods. The committee chose to signal an error by a - normal program exit with the exit code 127. */ -#define SPAWN_ERROR 127 - - -#if defined _WIN32 && ! defined __CYGWIN__ - -/* Native Windows API. */ -int -__spawni (pid_t *pid, const char *file, - const posix_spawn_file_actions_t *file_actions, - const posix_spawnattr_t *attrp, const char *const argv[], - const char *const envp[], int use_path) -{ - /* Not yet implemented. */ - return ENOSYS; -} - -#else - - -/* Spawn a new process executing PATH with the attributes describes in *ATTRP. - Before running the process perform the actions described in FILE-ACTIONS. */ -int -__spawni (pid_t *pid, const char *file, - const posix_spawn_file_actions_t *file_actions, - const posix_spawnattr_t *attrp, const char *const argv[], - const char *const envp[], int use_path) -{ - pid_t new_pid; - char *path, *p, *name; - size_t len; - size_t pathlen; - - /* Do this once. */ - short int flags = attrp == NULL ? 0 : attrp->_flags; - - /* Avoid gcc warning - "variable 'flags' might be clobbered by 'longjmp' or 'vfork'" */ - (void) &flags; - - /* Generate the new process. */ -#if HAVE_VFORK - if ((flags & POSIX_SPAWN_USEVFORK) != 0 - /* If no major work is done, allow using vfork. Note that we - might perform the path searching. But this would be done by - a call to execvp(), too, and such a call must be OK according - to POSIX. */ - || ((flags & (POSIX_SPAWN_SETSIGMASK | POSIX_SPAWN_SETSIGDEF - | POSIX_SPAWN_SETSCHEDPARAM | POSIX_SPAWN_SETSCHEDULER - | POSIX_SPAWN_SETPGROUP | POSIX_SPAWN_RESETIDS)) == 0 - && file_actions == NULL)) - new_pid = vfork (); - else -#endif - new_pid = fork (); - - if (new_pid != 0) - { - if (new_pid < 0) - return errno; - - /* The call was successful. Store the PID if necessary. */ - if (pid != NULL) - *pid = new_pid; - - return 0; - } - - /* Set signal mask. */ - if ((flags & POSIX_SPAWN_SETSIGMASK) != 0 - && sigprocmask (SIG_SETMASK, &attrp->_ss, NULL) != 0) - _exit (SPAWN_ERROR); - - /* Set signal default action. */ - if ((flags & POSIX_SPAWN_SETSIGDEF) != 0) - { - /* We have to iterate over all signals. This could possibly be - done better but it requires system specific solutions since - the sigset_t data type can be very different on different - architectures. */ - int sig; - struct sigaction sa; - - memset (&sa, '\0', sizeof (sa)); - sa.sa_handler = SIG_DFL; - - for (sig = 1; sig <= NSIG; ++sig) - if (sigismember (&attrp->_sd, sig) != 0 - && sigaction (sig, &sa, NULL) != 0) - _exit (SPAWN_ERROR); - - } - -#if (_LIBC ? defined _POSIX_PRIORITY_SCHEDULING : HAVE_SCHED_SETPARAM && HAVE_SCHED_SETSCHEDULER) - /* Set the scheduling algorithm and parameters. */ - if ((flags & (POSIX_SPAWN_SETSCHEDPARAM | POSIX_SPAWN_SETSCHEDULER)) - == POSIX_SPAWN_SETSCHEDPARAM) - { - if (sched_setparam (0, &attrp->_sp) == -1) - _exit (SPAWN_ERROR); - } - else if ((flags & POSIX_SPAWN_SETSCHEDULER) != 0) - { - if (sched_setscheduler (0, attrp->_policy, - (flags & POSIX_SPAWN_SETSCHEDPARAM) != 0 - ? &attrp->_sp : NULL) == -1) - _exit (SPAWN_ERROR); - } -#endif - - /* Set the process group ID. */ - if ((flags & POSIX_SPAWN_SETPGROUP) != 0 - && setpgid (0, attrp->_pgrp) != 0) - _exit (SPAWN_ERROR); - - /* Set the effective user and group IDs. */ - if ((flags & POSIX_SPAWN_RESETIDS) != 0 - && (local_seteuid (getuid ()) != 0 - || local_setegid (getgid ()) != 0)) - _exit (SPAWN_ERROR); - - /* Execute the file actions. */ - if (file_actions != NULL) - { - int cnt; - - for (cnt = 0; cnt < file_actions->_used; ++cnt) - { - struct __spawn_action *action = &file_actions->_actions[cnt]; - - switch (action->tag) - { - case spawn_do_close: - if (close_not_cancel (action->action.close_action.fd) != 0) - /* Signal the error. */ - _exit (SPAWN_ERROR); - break; - - case spawn_do_open: - { - int new_fd = open_not_cancel (action->action.open_action.path, - action->action.open_action.oflag - | O_LARGEFILE, - action->action.open_action.mode); - - if (new_fd == -1) - /* The 'open' call failed. */ - _exit (SPAWN_ERROR); - - /* Make sure the desired file descriptor is used. */ - if (new_fd != action->action.open_action.fd) - { - if (dup2 (new_fd, action->action.open_action.fd) - != action->action.open_action.fd) - /* The 'dup2' call failed. */ - _exit (SPAWN_ERROR); - - if (close_not_cancel (new_fd) != 0) - /* The 'close' call failed. */ - _exit (SPAWN_ERROR); - } - } - break; - - case spawn_do_dup2: - if (dup2 (action->action.dup2_action.fd, - action->action.dup2_action.newfd) - != action->action.dup2_action.newfd) - /* The 'dup2' call failed. */ - _exit (SPAWN_ERROR); - break; - - case spawn_do_chdir: - if (chdir (action->action.chdir_action.path) < 0) - /* The 'chdir' call failed. */ - _exit (SPAWN_ERROR); - break; - - case spawn_do_fchdir: - if (fchdir (action->action.fchdir_action.fd) < 0) - /* The 'fchdir' call failed. */ - _exit (SPAWN_ERROR); - break; - } - } - } - - if (! use_path || strchr (file, '/') != NULL) - { - /* The FILE parameter is actually a path. */ - execve (file, (char * const *) argv, (char * const *) envp); - - /* Oh, oh. 'execve' returns. This is bad. */ - _exit (SPAWN_ERROR); - } - - /* We have to search for FILE on the path. */ - path = getenv ("PATH"); - if (path == NULL) - { -#if HAVE_CONFSTR - /* There is no 'PATH' in the environment. - The default search path is the current directory - followed by the path 'confstr' returns for '_CS_PATH'. */ - len = confstr (_CS_PATH, (char *) NULL, 0); - path = (char *) alloca (1 + len); - path[0] = ':'; - (void) confstr (_CS_PATH, path + 1, len); -#else - /* Pretend that the PATH contains only the current directory. */ - path = ""; -#endif - } - - len = strlen (file) + 1; - pathlen = strlen (path); - name = alloca (pathlen + len + 1); - /* Copy the file name at the top. */ - name = (char *) memcpy (name + pathlen + 1, file, len); - /* And add the slash. */ - *--name = '/'; - - p = path; - do - { - char *startp; - - path = p; - p = strchrnul (path, ':'); - - if (p == path) - /* Two adjacent colons, or a colon at the beginning or the end - of 'PATH' means to search the current directory. */ - startp = name + 1; - else - startp = (char *) memcpy (name - (p - path), path, p - path); - - /* Try to execute this name. If it works, execv will not return. */ - execve (startp, (char * const *) argv, (char * const *) envp); - - switch (errno) - { - case EACCES: - case ENOENT: - case ESTALE: - case ENOTDIR: - /* Those errors indicate the file is missing or not executable - by us, in which case we want to just try the next path - directory. */ - break; - - default: - /* Some other error means we found an executable file, but - something went wrong executing it; return the error to our - caller. */ - _exit (SPAWN_ERROR); - } - } - while (*p++ != '\0'); - - /* Return with an error. */ - _exit (SPAWN_ERROR); -} - -#endif diff --git a/lib/strchrnul.c b/lib/strchrnul.c deleted file mode 100644 index 858d66fab1..0000000000 --- a/lib/strchrnul.c +++ /dev/null @@ -1,142 +0,0 @@ -/* Searching in a string. - Copyright (C) 2003, 2007-2020 Free Software Foundation, Inc. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -#include - -/* Specification. */ -#include - -/* Find the first occurrence of C in S or the final NUL byte. */ -char * -strchrnul (const char *s, int c_in) -{ - /* On 32-bit hardware, choosing longword to be a 32-bit unsigned - long instead of a 64-bit uintmax_t tends to give better - performance. On 64-bit hardware, unsigned long is generally 64 - bits already. Change this typedef to experiment with - performance. */ - typedef unsigned long int longword; - - const unsigned char *char_ptr; - const longword *longword_ptr; - longword repeated_one; - longword repeated_c; - unsigned char c; - - c = (unsigned char) c_in; - if (!c) - return rawmemchr (s, 0); - - /* Handle the first few bytes by reading one byte at a time. - Do this until CHAR_PTR is aligned on a longword boundary. */ - for (char_ptr = (const unsigned char *) s; - (size_t) char_ptr % sizeof (longword) != 0; - ++char_ptr) - if (!*char_ptr || *char_ptr == c) - return (char *) char_ptr; - - longword_ptr = (const longword *) char_ptr; - - /* All these elucidatory comments refer to 4-byte longwords, - but the theory applies equally well to any size longwords. */ - - /* Compute auxiliary longword values: - repeated_one is a value which has a 1 in every byte. - repeated_c has c in every byte. */ - repeated_one = 0x01010101; - repeated_c = c | (c << 8); - repeated_c |= repeated_c << 16; - if (0xffffffffU < (longword) -1) - { - repeated_one |= repeated_one << 31 << 1; - repeated_c |= repeated_c << 31 << 1; - if (8 < sizeof (longword)) - { - size_t i; - - for (i = 64; i < sizeof (longword) * 8; i *= 2) - { - repeated_one |= repeated_one << i; - repeated_c |= repeated_c << i; - } - } - } - - /* Instead of the traditional loop which tests each byte, we will - test a longword at a time. The tricky part is testing if *any of - the four* bytes in the longword in question are equal to NUL or - c. We first use an xor with repeated_c. This reduces the task - to testing whether *any of the four* bytes in longword1 or - longword2 is zero. - - Let's consider longword1. We compute tmp = - ((longword1 - repeated_one) & ~longword1) & (repeated_one << 7). - That is, we perform the following operations: - 1. Subtract repeated_one. - 2. & ~longword1. - 3. & a mask consisting of 0x80 in every byte. - Consider what happens in each byte: - - If a byte of longword1 is zero, step 1 and 2 transform it into 0xff, - and step 3 transforms it into 0x80. A carry can also be propagated - to more significant bytes. - - If a byte of longword1 is nonzero, let its lowest 1 bit be at - position k (0 <= k <= 7); so the lowest k bits are 0. After step 1, - the byte ends in a single bit of value 0 and k bits of value 1. - After step 2, the result is just k bits of value 1: 2^k - 1. After - step 3, the result is 0. And no carry is produced. - So, if longword1 has only non-zero bytes, tmp is zero. - Whereas if longword1 has a zero byte, call j the position of the least - significant zero byte. Then the result has a zero at positions 0, ..., - j-1 and a 0x80 at position j. We cannot predict the result at the more - significant bytes (positions j+1..3), but it does not matter since we - already have a non-zero bit at position 8*j+7. - - The test whether any byte in longword1 or longword2 is zero is equivalent - to testing whether tmp1 is nonzero or tmp2 is nonzero. We can combine - this into a single test, whether (tmp1 | tmp2) is nonzero. - - This test can read more than one byte beyond the end of a string, - depending on where the terminating NUL is encountered. However, - this is considered safe since the initialization phase ensured - that the read will be aligned, therefore, the read will not cross - page boundaries and will not cause a fault. */ - - while (1) - { - longword longword1 = *longword_ptr ^ repeated_c; - longword longword2 = *longword_ptr; - - if (((((longword1 - repeated_one) & ~longword1) - | ((longword2 - repeated_one) & ~longword2)) - & (repeated_one << 7)) != 0) - break; - longword_ptr++; - } - - char_ptr = (const unsigned char *) longword_ptr; - - /* At this point, we know that one of the sizeof (longword) bytes - starting at char_ptr is == 0 or == c. On little-endian machines, - we could determine the first such byte without any further memory - accesses, just by looking at the tmp result from the last loop - iteration. But this does not work on big-endian machines. - Choose code that works in both cases. */ - - char_ptr = (unsigned char *) longword_ptr; - while (*char_ptr && (*char_ptr != c)) - char_ptr++; - return (char *) char_ptr; -} diff --git a/lib/strchrnul.valgrind b/lib/strchrnul.valgrind deleted file mode 100644 index a85608a7c7..0000000000 --- a/lib/strchrnul.valgrind +++ /dev/null @@ -1,28 +0,0 @@ -# Suppress a valgrind message about use of uninitialized memory in strchrnul(). - -# Copyright (C) 2008-2020 Free Software Foundation, Inc. -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -# This use is OK because it provides only a speedup. -{ - strchrnul-value4 - Memcheck:Value4 - fun:strchrnul -} -{ - strchrnul-value8 - Memcheck:Value8 - fun:strchrnul -} diff --git a/m4/gnulib-comp.m4 b/m4/gnulib-comp.m4 index e2a44efe62..0971636c33 100644 --- a/m4/gnulib-comp.m4 +++ b/m4/gnulib-comp.m4 @@ -139,18 +139,6 @@ AC_DEFUN([gl_EARLY], # Code from module openat-h: # Code from module pathmax: # Code from module pipe2: - # Code from module posix_spawn: - # Code from module posix_spawn-internal: - # Code from module posix_spawn_file_actions_addchdir: - # Code from module posix_spawn_file_actions_adddup2: - # Code from module posix_spawn_file_actions_destroy: - # Code from module posix_spawn_file_actions_init: - # Code from module posix_spawnattr_destroy: - # Code from module posix_spawnattr_init: - # Code from module posix_spawnattr_setflags: - # Code from module posix_spawnattr_setpgroup: - # Code from module posix_spawnattr_setsigdefault: - # Code from module posix_spawnattr_setsigmask: # Code from module pselect: # Code from module pthread_sigmask: # Code from module qcopy-acl: @@ -159,9 +147,7 @@ AC_DEFUN([gl_EARLY], # Code from module readlinkat: # Code from module regex: # Code from module root-uid: - # Code from module sched: # Code from module scratch_buffer: - # Code from module sh-filename: # Code from module sig2str: # Code from module sigdescr_np: # Code from module signal-h: @@ -170,7 +156,6 @@ AC_DEFUN([gl_EARLY], # Code from module snippet/c++defs: # Code from module snippet/warn-on-use: # Code from module socklen: - # Code from module spawn: # Code from module ssize_t: # Code from module stat-time: # Code from module std-gnu11: @@ -180,7 +165,6 @@ AC_DEFUN([gl_EARLY], # Code from module stdio: # Code from module stdlib: # Code from module stpcpy: - # Code from module strchrnul: # Code from module string: # Code from module strnlen: # Code from module strtoimax: @@ -419,61 +403,6 @@ AC_DEFUN([gl_INIT], gl_PATHMAX gl_FUNC_PIPE2 gl_UNISTD_MODULE_INDICATOR([pipe2]) - gl_POSIX_SPAWN - if test $HAVE_POSIX_SPAWN = 0 || test $REPLACE_POSIX_SPAWN = 1; then - AC_LIBOBJ([spawn]) - fi - gl_SPAWN_MODULE_INDICATOR([posix_spawn]) - gl_FUNC_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR - if test $HAVE_POSIX_SPAWN = 0 || test $REPLACE_POSIX_SPAWN = 1 || test $HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR = 0 || test $REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR = 1; then - AC_LIBOBJ([spawn_faction_addchdir]) - fi - gl_SPAWN_MODULE_INDICATOR([posix_spawn_file_actions_addchdir]) - gl_FUNC_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2 - if test $HAVE_POSIX_SPAWN = 0 || test $REPLACE_POSIX_SPAWN = 1 || test $REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2 = 1; then - AC_LIBOBJ([spawn_faction_adddup2]) - fi - gl_SPAWN_MODULE_INDICATOR([posix_spawn_file_actions_adddup2]) - gl_POSIX_SPAWN - if test $HAVE_POSIX_SPAWN = 0 || test $REPLACE_POSIX_SPAWN = 1; then - AC_LIBOBJ([spawn_faction_destroy]) - fi - gl_SPAWN_MODULE_INDICATOR([posix_spawn_file_actions_destroy]) - gl_POSIX_SPAWN - if test $HAVE_POSIX_SPAWN = 0 || test $REPLACE_POSIX_SPAWN = 1; then - AC_LIBOBJ([spawn_faction_init]) - fi - gl_SPAWN_MODULE_INDICATOR([posix_spawn_file_actions_init]) - gl_POSIX_SPAWN - if test $HAVE_POSIX_SPAWN = 0 || test $REPLACE_POSIX_SPAWN = 1; then - AC_LIBOBJ([spawnattr_destroy]) - fi - gl_SPAWN_MODULE_INDICATOR([posix_spawnattr_destroy]) - gl_POSIX_SPAWN - if test $HAVE_POSIX_SPAWN = 0 || test $REPLACE_POSIX_SPAWN = 1; then - AC_LIBOBJ([spawnattr_init]) - fi - gl_SPAWN_MODULE_INDICATOR([posix_spawnattr_init]) - gl_POSIX_SPAWN - if test $HAVE_POSIX_SPAWN = 0 || test $REPLACE_POSIX_SPAWN = 1; then - AC_LIBOBJ([spawnattr_setflags]) - fi - gl_SPAWN_MODULE_INDICATOR([posix_spawnattr_setflags]) - gl_POSIX_SPAWN - if test $HAVE_POSIX_SPAWN = 0 || test $REPLACE_POSIX_SPAWN = 1; then - AC_LIBOBJ([spawnattr_setpgroup]) - fi - gl_SPAWN_MODULE_INDICATOR([posix_spawnattr_setpgroup]) - gl_POSIX_SPAWN - if test $HAVE_POSIX_SPAWN = 0 || test $REPLACE_POSIX_SPAWN = 1; then - AC_LIBOBJ([spawnattr_setdefault]) - fi - gl_SPAWN_MODULE_INDICATOR([posix_spawnattr_setsigdefault]) - gl_POSIX_SPAWN - if test $HAVE_POSIX_SPAWN = 0 || test $REPLACE_POSIX_SPAWN = 1; then - AC_LIBOBJ([spawnattr_setsigmask]) - fi - gl_SPAWN_MODULE_INDICATOR([posix_spawnattr_setsigmask]) gl_FUNC_PSELECT if test $HAVE_PSELECT = 0 || test $REPLACE_PSELECT = 1; then AC_LIBOBJ([pselect]) @@ -501,7 +430,6 @@ AC_DEFUN([gl_INIT], AC_LIBOBJ([regex]) gl_PREREQ_REGEX fi - gl_SCHED_H gl_FUNC_SIG2STR if test $ac_cv_func_sig2str = no; then AC_LIBOBJ([sig2str]) @@ -514,7 +442,6 @@ AC_DEFUN([gl_INIT], gl_STRING_MODULE_INDICATOR([sigdescr_np]) gl_SIGNAL_H gl_TYPE_SOCKLEN_T - gl_SPAWN_H gt_TYPE_SSIZE_T gl_STAT_TIME gl_STAT_BIRTHTIME @@ -601,12 +528,9 @@ AC_DEFUN([gl_INIT], gl_gnulib_enabled_5264294aa0a5557541b53c8c741f7f31=false gl_gnulib_enabled_open=false gl_gnulib_enabled_03e0aaad4cb89ca757653bd367a6ccb7=false - gl_gnulib_enabled_332607f759618fb73dfc3076748afea7=false gl_gnulib_enabled_rawmemchr=false gl_gnulib_enabled_6099e9737f757db36c47fa9d9f02e88c=false gl_gnulib_enabled_scratch_buffer=false - gl_gnulib_enabled_cdeb0f2aaf9d280baa6526bfa1b07f70=false - gl_gnulib_enabled_strchrnul=false gl_gnulib_enabled_strtoll=false gl_gnulib_enabled_utimens=false gl_gnulib_enabled_682e609604ccaac6be382e4ee3a4eaec=false @@ -761,20 +685,6 @@ AC_DEFUN([gl_INIT], gl_gnulib_enabled_03e0aaad4cb89ca757653bd367a6ccb7=true fi } - func_gl_gnulib_m4code_332607f759618fb73dfc3076748afea7 () - { - if ! $gl_gnulib_enabled_332607f759618fb73dfc3076748afea7; then - gl_POSIX_SPAWN - if test $HAVE_POSIX_SPAWN = 0 || test $REPLACE_POSIX_SPAWN = 1; then - AC_LIBOBJ([spawni]) - gl_PREREQ_POSIX_SPAWN_INTERNAL - fi - gl_gnulib_enabled_332607f759618fb73dfc3076748afea7=true - func_gl_gnulib_m4code_open - func_gl_gnulib_m4code_cdeb0f2aaf9d280baa6526bfa1b07f70 - func_gl_gnulib_m4code_strchrnul - fi - } func_gl_gnulib_m4code_rawmemchr () { if ! $gl_gnulib_enabled_rawmemchr; then @@ -799,28 +709,6 @@ AC_DEFUN([gl_INIT], gl_gnulib_enabled_scratch_buffer=true fi } - func_gl_gnulib_m4code_cdeb0f2aaf9d280baa6526bfa1b07f70 () - { - if ! $gl_gnulib_enabled_cdeb0f2aaf9d280baa6526bfa1b07f70; then - gl_SH_FILENAME - gl_gnulib_enabled_cdeb0f2aaf9d280baa6526bfa1b07f70=true - fi - } - func_gl_gnulib_m4code_strchrnul () - { - if ! $gl_gnulib_enabled_strchrnul; then - gl_FUNC_STRCHRNUL - if test $HAVE_STRCHRNUL = 0 || test $REPLACE_STRCHRNUL = 1; then - AC_LIBOBJ([strchrnul]) - gl_PREREQ_STRCHRNUL - fi - gl_STRING_MODULE_INDICATOR([strchrnul]) - gl_gnulib_enabled_strchrnul=true - if test $HAVE_STRCHRNUL = 0 || test $REPLACE_STRCHRNUL = 1; then - func_gl_gnulib_m4code_rawmemchr - fi - fi - } func_gl_gnulib_m4code_strtoll () { if ! $gl_gnulib_enabled_strtoll; then @@ -903,12 +791,6 @@ AC_DEFUN([gl_INIT], if case $host_os in mingw*) false;; *) test $HAVE_GETRANDOM = 0 || test $REPLACE_GETRANDOM = 1;; esac; then func_gl_gnulib_m4code_open fi - if test $HAVE_POSIX_SPAWN = 0 || test $REPLACE_POSIX_SPAWN = 1; then - func_gl_gnulib_m4code_332607f759618fb73dfc3076748afea7 - fi - if test $HAVE_POSIX_SPAWN = 0 || test $REPLACE_POSIX_SPAWN = 1 || test $REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2 = 1; then - func_gl_gnulib_m4code_getdtablesize - fi if test $HAVE_READLINKAT = 0 || test $REPLACE_READLINKAT = 1; then func_gl_gnulib_m4code_260941c0e5dc67ec9e87d1fb321c300b fi @@ -948,12 +830,9 @@ AC_DEFUN([gl_INIT], AM_CONDITIONAL([gl_GNULIB_ENABLED_5264294aa0a5557541b53c8c741f7f31], [$gl_gnulib_enabled_5264294aa0a5557541b53c8c741f7f31]) AM_CONDITIONAL([gl_GNULIB_ENABLED_open], [$gl_gnulib_enabled_open]) AM_CONDITIONAL([gl_GNULIB_ENABLED_03e0aaad4cb89ca757653bd367a6ccb7], [$gl_gnulib_enabled_03e0aaad4cb89ca757653bd367a6ccb7]) - AM_CONDITIONAL([gl_GNULIB_ENABLED_332607f759618fb73dfc3076748afea7], [$gl_gnulib_enabled_332607f759618fb73dfc3076748afea7]) AM_CONDITIONAL([gl_GNULIB_ENABLED_rawmemchr], [$gl_gnulib_enabled_rawmemchr]) AM_CONDITIONAL([gl_GNULIB_ENABLED_6099e9737f757db36c47fa9d9f02e88c], [$gl_gnulib_enabled_6099e9737f757db36c47fa9d9f02e88c]) AM_CONDITIONAL([gl_GNULIB_ENABLED_scratch_buffer], [$gl_gnulib_enabled_scratch_buffer]) - AM_CONDITIONAL([gl_GNULIB_ENABLED_cdeb0f2aaf9d280baa6526bfa1b07f70], [$gl_gnulib_enabled_cdeb0f2aaf9d280baa6526bfa1b07f70]) - AM_CONDITIONAL([gl_GNULIB_ENABLED_strchrnul], [$gl_gnulib_enabled_strchrnul]) AM_CONDITIONAL([gl_GNULIB_ENABLED_strtoll], [$gl_gnulib_enabled_strtoll]) AM_CONDITIONAL([gl_GNULIB_ENABLED_utimens], [$gl_gnulib_enabled_utimens]) AM_CONDITIONAL([gl_GNULIB_ENABLED_682e609604ccaac6be382e4ee3a4eaec], [$gl_gnulib_enabled_682e609604ccaac6be382e4ee3a4eaec]) @@ -1234,7 +1113,6 @@ AC_DEFUN([gl_FILE_LIST], [ lib/regex_internal.h lib/regexec.c lib/root-uid.h - lib/sched.in.h lib/scratch_buffer.h lib/set-permissions.c lib/sha1.c @@ -1247,20 +1125,6 @@ AC_DEFUN([gl_FILE_LIST], [ lib/sig2str.h lib/sigdescr_np.c lib/signal.in.h - lib/spawn.c - lib/spawn.in.h - lib/spawn_faction_addchdir.c - lib/spawn_faction_adddup2.c - lib/spawn_faction_destroy.c - lib/spawn_faction_init.c - lib/spawn_int.h - lib/spawnattr_destroy.c - lib/spawnattr_init.c - lib/spawnattr_setdefault.c - lib/spawnattr_setflags.c - lib/spawnattr_setpgroup.c - lib/spawnattr_setsigmask.c - lib/spawni.c lib/stat-time.c lib/stat-time.h lib/stdalign.in.h @@ -1271,8 +1135,6 @@ AC_DEFUN([gl_FILE_LIST], [ lib/stdlib.in.h lib/stpcpy.c lib/str-two-way.h - lib/strchrnul.c - lib/strchrnul.valgrind lib/strftime.h lib/string.in.h lib/strnlen.c @@ -1386,16 +1248,12 @@ AC_DEFUN([gl_FILE_LIST], [ m4/pathmax.m4 m4/pid_t.m4 m4/pipe2.m4 - m4/posix_spawn.m4 - m4/posix_spawn_faction_addchdir.m4 m4/pselect.m4 m4/pthread_sigmask.m4 m4/rawmemchr.m4 m4/readlink.m4 m4/readlinkat.m4 m4/regex.m4 - m4/sched_h.m4 - m4/sh-filename.m4 m4/sha1.m4 m4/sha256.m4 m4/sha512.m4 @@ -1403,7 +1261,6 @@ AC_DEFUN([gl_FILE_LIST], [ m4/sigdescr_np.m4 m4/signal_h.m4 m4/socklen.m4 - m4/spawn_h.m4 m4/ssize_t.m4 m4/stat-time.m4 m4/std-gnu11.m4 @@ -1413,7 +1270,6 @@ AC_DEFUN([gl_FILE_LIST], [ m4/stdio_h.m4 m4/stdlib_h.m4 m4/stpcpy.m4 - m4/strchrnul.m4 m4/string_h.m4 m4/strnlen.m4 m4/strtoimax.m4 diff --git a/m4/posix_spawn.m4 b/m4/posix_spawn.m4 deleted file mode 100644 index 59e56fcb5f..0000000000 --- a/m4/posix_spawn.m4 +++ /dev/null @@ -1,678 +0,0 @@ -# posix_spawn.m4 serial 19 -dnl Copyright (C) 2008-2020 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -dnl Tests whether the entire posix_spawn facility is available. -AC_DEFUN([gl_POSIX_SPAWN], -[ - AC_REQUIRE([gl_POSIX_SPAWN_BODY]) -]) - -AC_DEFUN([gl_POSIX_SPAWN_BODY], -[ - AC_REQUIRE([gl_SPAWN_H_DEFAULTS]) - AC_REQUIRE([gl_HAVE_POSIX_SPAWN]) - dnl Assume that when the main function exists, all the others, - dnl except posix_spawnattr_{get,set}sched*, are available as well. - dnl AC_CHECK_FUNCS_ONCE([posix_spawnp]) - dnl AC_CHECK_FUNCS_ONCE([posix_spawn_file_actions_init]) - dnl AC_CHECK_FUNCS_ONCE([posix_spawn_file_actions_addclose]) - dnl AC_CHECK_FUNCS_ONCE([posix_spawn_file_actions_adddup2]) - dnl AC_CHECK_FUNCS_ONCE([posix_spawn_file_actions_addopen]) - dnl AC_CHECK_FUNCS_ONCE([posix_spawn_file_actions_destroy]) - dnl AC_CHECK_FUNCS_ONCE([posix_spawnattr_init]) - dnl AC_CHECK_FUNCS_ONCE([posix_spawnattr_getflags]) - dnl AC_CHECK_FUNCS_ONCE([posix_spawnattr_setflags]) - dnl AC_CHECK_FUNCS_ONCE([posix_spawnattr_getpgroup]) - dnl AC_CHECK_FUNCS_ONCE([posix_spawnattr_setpgroup]) - dnl AC_CHECK_FUNCS_ONCE([posix_spawnattr_getsigdefault]) - dnl AC_CHECK_FUNCS_ONCE([posix_spawnattr_setsigdefault]) - dnl AC_CHECK_FUNCS_ONCE([posix_spawnattr_getsigmask]) - dnl AC_CHECK_FUNCS_ONCE([posix_spawnattr_setsigmask]) - dnl AC_CHECK_FUNCS_ONCE([posix_spawnattr_destroy]) - if test $ac_cv_func_posix_spawn = yes; then - m4_ifdef([gl_FUNC_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR], - [dnl Module 'posix_spawn_file_actions_addchdir' is present. - AC_CHECK_FUNCS_ONCE([posix_spawn_file_actions_addchdir_np]) - if test $ac_cv_func_posix_spawn_file_actions_addchdir_np = no; then - dnl In order to implement the posix_spawn_file_actions_addchdir - dnl function, we need to replace the entire posix_spawn facility. - REPLACE_POSIX_SPAWN=1 - fi - ]) - m4_ifdef([gl_FUNC_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR], - [dnl Module 'posix_spawn_file_actions_addfchdir' is present. - AC_CHECK_FUNCS_ONCE([posix_spawn_file_actions_addfchdir_np]) - if test $ac_cv_func_posix_spawn_file_actions_addfchdir_np = no; then - dnl In order to implement the posix_spawn_file_actions_addfchdir - dnl function, we need to replace the entire posix_spawn facility. - REPLACE_POSIX_SPAWN=1 - fi - ]) - if test $REPLACE_POSIX_SPAWN = 0; then - gl_POSIX_SPAWN_WORKS - case "$gl_cv_func_posix_spawn_works" in - *yes) ;; - *) REPLACE_POSIX_SPAWN=1 ;; - esac - fi - if test $REPLACE_POSIX_SPAWN = 0; then - gl_POSIX_SPAWN_SECURE - case "$gl_cv_func_posix_spawn_secure_exec" in - *yes) ;; - *) REPLACE_POSIX_SPAWN=1 ;; - esac - case "$gl_cv_func_posix_spawnp_secure_exec" in - *yes) ;; - *) REPLACE_POSIX_SPAWN=1 ;; - esac - fi - if test $REPLACE_POSIX_SPAWN = 0; then - dnl Assume that these functions are available if POSIX_SPAWN_SETSCHEDULER - dnl evaluates to nonzero. - dnl AC_CHECK_FUNCS_ONCE([posix_spawnattr_getschedpolicy]) - dnl AC_CHECK_FUNCS_ONCE([posix_spawnattr_setschedpolicy]) - AC_CACHE_CHECK([whether posix_spawnattr_setschedpolicy is supported], - [gl_cv_func_spawnattr_setschedpolicy], - [AC_EGREP_CPP([POSIX scheduling supported], [ -#include -#if POSIX_SPAWN_SETSCHEDULER - POSIX scheduling supported -#endif -], - [gl_cv_func_spawnattr_setschedpolicy=yes], - [gl_cv_func_spawnattr_setschedpolicy=no]) - ]) - dnl Assume that these functions are available if POSIX_SPAWN_SETSCHEDPARAM - dnl evaluates to nonzero. - dnl AC_CHECK_FUNCS_ONCE([posix_spawnattr_getschedparam]) - dnl AC_CHECK_FUNCS_ONCE([posix_spawnattr_setschedparam]) - AC_CACHE_CHECK([whether posix_spawnattr_setschedparam is supported], - [gl_cv_func_spawnattr_setschedparam], - [AC_EGREP_CPP([POSIX scheduling supported], [ -#include -#if POSIX_SPAWN_SETSCHEDPARAM - POSIX scheduling supported -#endif -], - [gl_cv_func_spawnattr_setschedparam=yes], - [gl_cv_func_spawnattr_setschedparam=no]) - ]) - fi - fi - if test $ac_cv_func_posix_spawn != yes || test $REPLACE_POSIX_SPAWN = 1; then - AC_DEFINE([REPLACE_POSIX_SPAWN], [1], - [Define if gnulib uses its own posix_spawn and posix_spawnp functions.]) - fi -]) - -dnl Test whether posix_spawn actually works. -dnl posix_spawn on AIX 5.3..6.1 has two bugs: -dnl 1) When it fails to execute the program, the child process exits with -dnl exit() rather than _exit(), which causes the stdio buffers to be -dnl flushed. Reported by Rainer Tammer. -dnl 2) The posix_spawn_file_actions_addopen function does not support file -dnl names that contain a '*'. -dnl posix_spawn on AIX 5.3..6.1 has also a third bug: It does not work -dnl when POSIX threads are used. But we don't test against this bug here. -AC_DEFUN([gl_POSIX_SPAWN_WORKS], -[ - AC_REQUIRE([AC_PROG_CC]) - AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles - AC_CACHE_CHECK([whether posix_spawn works], [gl_cv_func_posix_spawn_works], - [if test $cross_compiling = no; then - AC_LINK_IFELSE([AC_LANG_SOURCE([[ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -]GL_MDA_DEFINES[ - -extern char **environ; - -#ifndef STDIN_FILENO -# define STDIN_FILENO 0 -#endif -#ifndef STDOUT_FILENO -# define STDOUT_FILENO 1 -#endif -#ifndef STDERR_FILENO -# define STDERR_FILENO 2 -#endif - -#ifndef WTERMSIG -# define WTERMSIG(x) ((x) & 0x7f) -#endif -#ifndef WIFEXITED -# define WIFEXITED(x) (WTERMSIG (x) == 0) -#endif -#ifndef WEXITSTATUS -# define WEXITSTATUS(x) (((x) >> 8) & 0xff) -#endif - -#define CHILD_PROGRAM_FILENAME "/non/exist/ent" - -static int -fd_safer (int fd) -{ - if (0 <= fd && fd <= 2) - { - int f = fd_safer (dup (fd)); - int e = errno; - close (fd); - errno = e; - fd = f; - } - - return fd; -} - -int -main () -{ - char *argv[2] = { CHILD_PROGRAM_FILENAME, NULL }; - int ofd[2]; - sigset_t blocked_signals; - sigset_t fatal_signal_set; - posix_spawn_file_actions_t actions; - bool actions_allocated; - posix_spawnattr_t attrs; - bool attrs_allocated; - int err; - pid_t child; - int status; - int exitstatus; - - setvbuf (stdout, NULL, _IOFBF, 0); - puts ("This should be seen only once."); - if (pipe (ofd) < 0 || (ofd[1] = fd_safer (ofd[1])) < 0) - { - perror ("cannot create pipe"); - exit (1); - } - sigprocmask (SIG_SETMASK, NULL, &blocked_signals); - sigemptyset (&fatal_signal_set); - sigaddset (&fatal_signal_set, SIGINT); - sigaddset (&fatal_signal_set, SIGTERM); - sigaddset (&fatal_signal_set, SIGHUP); - sigaddset (&fatal_signal_set, SIGPIPE); - sigprocmask (SIG_BLOCK, &fatal_signal_set, NULL); - actions_allocated = false; - attrs_allocated = false; - if ((err = posix_spawn_file_actions_init (&actions)) != 0 - || (actions_allocated = true, - (err = posix_spawn_file_actions_adddup2 (&actions, ofd[0], STDIN_FILENO)) != 0 - || (err = posix_spawn_file_actions_addclose (&actions, ofd[0])) != 0 - || (err = posix_spawn_file_actions_addclose (&actions, ofd[1])) != 0 - || (err = posix_spawnattr_init (&attrs)) != 0 - || (attrs_allocated = true, - (err = posix_spawnattr_setsigmask (&attrs, &blocked_signals)) != 0 - || (err = posix_spawnattr_setflags (&attrs, POSIX_SPAWN_SETSIGMASK)) != 0) - || (err = posix_spawnp (&child, CHILD_PROGRAM_FILENAME, &actions, &attrs, argv, environ)) != 0)) - { - if (actions_allocated) - posix_spawn_file_actions_destroy (&actions); - if (attrs_allocated) - posix_spawnattr_destroy (&attrs); - sigprocmask (SIG_UNBLOCK, &fatal_signal_set, NULL); - if (err == ENOENT) - return 0; - else - { - errno = err; - perror ("subprocess failed"); - exit (1); - } - } - posix_spawn_file_actions_destroy (&actions); - posix_spawnattr_destroy (&attrs); - sigprocmask (SIG_UNBLOCK, &fatal_signal_set, NULL); - close (ofd[0]); - close (ofd[1]); - status = 0; - while (waitpid (child, &status, 0) != child) - ; - if (!WIFEXITED (status)) - { - fprintf (stderr, "subprocess terminated with unexpected wait status %d\n", status); - exit (1); - } - exitstatus = WEXITSTATUS (status); - if (exitstatus != 127) - { - fprintf (stderr, "subprocess terminated with unexpected exit status %d\n", exitstatus); - exit (1); - } - return 0; -} -]])], - [if test -s conftest$ac_exeext \ - && ./conftest$ac_exeext > conftest.out \ - && echo 'This should be seen only once.' > conftest.ok \ - && cmp conftest.out conftest.ok >/dev/null 2>&1; then - gl_cv_func_posix_spawn_works=yes - else - gl_cv_func_posix_spawn_works=no - fi], - [gl_cv_func_posix_spawn_works=no]) - if test $gl_cv_func_posix_spawn_works = yes; then - AC_RUN_IFELSE([AC_LANG_SOURCE([[ -/* Test whether posix_spawn_file_actions_addopen supports filename arguments - that contain special characters such as '*'. */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -]GL_MDA_DEFINES[ - -extern char **environ; - -#ifndef STDIN_FILENO -# define STDIN_FILENO 0 -#endif -#ifndef STDOUT_FILENO -# define STDOUT_FILENO 1 -#endif -#ifndef STDERR_FILENO -# define STDERR_FILENO 2 -#endif - -#ifndef WTERMSIG -# define WTERMSIG(x) ((x) & 0x7f) -#endif -#ifndef WIFEXITED -# define WIFEXITED(x) (WTERMSIG (x) == 0) -#endif -#ifndef WEXITSTATUS -# define WEXITSTATUS(x) (((x) >> 8) & 0xff) -#endif - -#define CHILD_PROGRAM_FILENAME "conftest" -#define DATA_FILENAME "conftest%=*#?" - -static int -parent_main (void) -{ - FILE *fp; - char *argv[3] = { CHILD_PROGRAM_FILENAME, "-child", NULL }; - posix_spawn_file_actions_t actions; - bool actions_allocated; - int err; - pid_t child; - int status; - int exitstatus; - - /* Create a data file with specific contents. */ - fp = fopen (DATA_FILENAME, "wb"); - if (fp == NULL) - { - perror ("cannot create data file"); - return 1; - } - fwrite ("Halle Potta", 1, 11, fp); - if (fflush (fp) || fclose (fp)) - { - perror ("cannot prepare data file"); - return 2; - } - - /* Avoid reading from our stdin, as it could block. */ - freopen ("/dev/null", "rb", stdin); - - /* Test whether posix_spawn_file_actions_addopen with this file name - actually works, but spawning a child that reads from this file. */ - actions_allocated = false; - if ((err = posix_spawn_file_actions_init (&actions)) != 0 - || (actions_allocated = true, - (err = posix_spawn_file_actions_addopen (&actions, STDIN_FILENO, DATA_FILENAME, O_RDONLY, 0600)) != 0 - || (err = posix_spawn (&child, CHILD_PROGRAM_FILENAME, &actions, NULL, argv, environ)) != 0)) - { - if (actions_allocated) - posix_spawn_file_actions_destroy (&actions); - errno = err; - perror ("subprocess failed"); - return 3; - } - posix_spawn_file_actions_destroy (&actions); - status = 0; - while (waitpid (child, &status, 0) != child) - ; - if (!WIFEXITED (status)) - { - fprintf (stderr, "subprocess terminated with unexpected wait status %d\n", status); - return 4; - } - exitstatus = WEXITSTATUS (status); - if (exitstatus != 0) - { - fprintf (stderr, "subprocess terminated with unexpected exit status %d\n", exitstatus); - return 5; - } - return 0; -} - -static int -child_main (void) -{ - char buf[1024]; - - /* See if reading from STDIN_FILENO yields the expected contents. */ - if (fread (buf, 1, sizeof (buf), stdin) == 11 - && memcmp (buf, "Halle Potta", 11) == 0) - return 0; - else - return 8; -} - -static void -cleanup_then_die (int sig) -{ - /* Clean up data file. */ - unlink (DATA_FILENAME); - - /* Re-raise the signal and die from it. */ - signal (sig, SIG_DFL); - raise (sig); -} - -int -main (int argc, char *argv[]) -{ - int exitstatus; - - if (!(argc > 1 && strcmp (argv[1], "-child") == 0)) - { - /* This is the parent process. */ - signal (SIGINT, cleanup_then_die); - signal (SIGTERM, cleanup_then_die); - #ifdef SIGHUP - signal (SIGHUP, cleanup_then_die); - #endif - - exitstatus = parent_main (); - } - else - { - /* This is the child process. */ - - exitstatus = child_main (); - } - unlink (DATA_FILENAME); - return exitstatus; -} -]])], - [], - [gl_cv_func_posix_spawn_works=no]) - fi - else - case "$host_os" in - aix*) gl_cv_func_posix_spawn_works="guessing no";; - *) gl_cv_func_posix_spawn_works="guessing yes";; - esac - fi - ]) -]) - -dnl Test whether posix_spawn and posix_spawnp are secure. -AC_DEFUN([gl_POSIX_SPAWN_SECURE], -[ - AC_REQUIRE([AC_PROG_CC]) - AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles - dnl On many platforms, posix_spawn or posix_spawnp allow executing a - dnl script without a '#!' marker as a shell script. This is unsecure. - AC_CACHE_CHECK([whether posix_spawn rejects scripts without shebang], - [gl_cv_func_posix_spawn_secure_exec], - [echo ':' > conftest.scr - chmod a+x conftest.scr - AC_RUN_IFELSE([AC_LANG_SOURCE([[ - #include - #include - #include - #include - #include - int - main () - { - const char *prog_path = "./conftest.scr"; - const char *prog_argv[2] = { prog_path, NULL }; - const char *environment[2] = { "PATH=.", NULL }; - pid_t child; - int status; - int err = posix_spawn (&child, prog_path, NULL, NULL, - (char **) prog_argv, (char **) environment); - if (err == ENOEXEC) - return 0; - if (err != 0) - return 1; - status = 0; - while (waitpid (child, &status, 0) != child) - ; - if (!WIFEXITED (status)) - return 2; - if (WEXITSTATUS (status) != 127) - return 3; - return 0; - } - ]])], - [gl_cv_func_posix_spawn_secure_exec=yes], - [gl_cv_func_posix_spawn_secure_exec=no], - [case "$host_os" in - # Guess no on GNU/Hurd. - gnu*) - gl_cv_func_posix_spawn_secure_exec="guessing no" ;; - # Guess yes on all other platforms. - *) - gl_cv_func_posix_spawn_secure_exec="guessing yes" ;; - esac - ]) - rm -f conftest.scr - ]) - AC_CACHE_CHECK([whether posix_spawnp rejects scripts without shebang], - [gl_cv_func_posix_spawnp_secure_exec], - [echo ':' > conftest.scr - chmod a+x conftest.scr - AC_RUN_IFELSE([AC_LANG_SOURCE([[ - #include - #include - #include - #include - #include - int - main () - { - const char *prog_path = "./conftest.scr"; - const char *prog_argv[2] = { prog_path, NULL }; - const char *environment[2] = { "PATH=.", NULL }; - pid_t child; - int status; - int err = posix_spawnp (&child, prog_path, NULL, NULL, - (char **) prog_argv, (char **) environment); - if (err == ENOEXEC) - return 0; - if (err != 0) - return 1; - status = 0; - while (waitpid (child, &status, 0) != child) - ; - if (!WIFEXITED (status)) - return 2; - if (WEXITSTATUS (status) != 127) - return 3; - return 0; - } - ]])], - [gl_cv_func_posix_spawnp_secure_exec=yes], - [gl_cv_func_posix_spawnp_secure_exec=no], - [case "$host_os" in - # Guess yes on glibc systems (glibc >= 2.15 actually) except GNU/Hurd, - # musl libc, NetBSD. - *-gnu* | *-musl* | netbsd*) - gl_cv_func_posix_spawnp_secure_exec="guessing yes" ;; - # Guess no on GNU/Hurd, macOS, FreeBSD, OpenBSD, AIX, Solaris, Cygwin. - gnu* | darwin* | freebsd* | dragonfly* | openbsd* | aix* | solaris* | cygwin*) - gl_cv_func_posix_spawnp_secure_exec="guessing no" ;; - # If we don't know, obey --enable-cross-guesses. - *) - gl_cv_func_posix_spawnp_secure_exec="$gl_cross_guess_normal" ;; - esac - ]) - rm -f conftest.scr - ]) -]) - -# Prerequisites of lib/spawni.c. -AC_DEFUN([gl_PREREQ_POSIX_SPAWN_INTERNAL], -[ - AC_CHECK_HEADERS([paths.h]) - AC_CHECK_FUNCS([confstr sched_setparam sched_setscheduler setegid seteuid vfork]) -]) - -AC_DEFUN([gl_FUNC_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE], -[ - AC_REQUIRE([gl_SPAWN_H_DEFAULTS]) - AC_REQUIRE([AC_PROG_CC]) - AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles - gl_POSIX_SPAWN - if test $REPLACE_POSIX_SPAWN = 1; then - REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE=1 - else - dnl On musl libc and Solaris 11.0, posix_spawn_file_actions_addclose - dnl succeeds even if the fd argument is out of range. - AC_CACHE_CHECK([whether posix_spawn_file_actions_addclose works], - [gl_cv_func_posix_spawn_file_actions_addclose_works], - [AC_RUN_IFELSE( - [AC_LANG_SOURCE([[ -#include -int main () -{ - posix_spawn_file_actions_t actions; - if (posix_spawn_file_actions_init (&actions) != 0) - return 1; - if (posix_spawn_file_actions_addclose (&actions, 10000000) == 0) - return 2; - return 0; -}]])], - [gl_cv_func_posix_spawn_file_actions_addclose_works=yes], - [gl_cv_func_posix_spawn_file_actions_addclose_works=no], - [# Guess no on musl libc and Solaris, yes otherwise. - case "$host_os" in - *-musl*) gl_cv_func_posix_spawn_file_actions_addclose_works="guessing no" ;; - solaris*) gl_cv_func_posix_spawn_file_actions_addclose_works="guessing no" ;; - # Guess no on native Windows. - mingw*) gl_cv_func_posix_spawn_file_actions_addclose_works="guessing no" ;; - *) gl_cv_func_posix_spawn_file_actions_addclose_works="guessing yes" ;; - esac - ]) - ]) - case "$gl_cv_func_posix_spawn_file_actions_addclose_works" in - *yes) ;; - *) REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE=1 ;; - esac - fi -]) - -AC_DEFUN([gl_FUNC_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2], -[ - AC_REQUIRE([gl_SPAWN_H_DEFAULTS]) - AC_REQUIRE([AC_PROG_CC]) - AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles - gl_POSIX_SPAWN - if test $REPLACE_POSIX_SPAWN = 1; then - REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2=1 - else - dnl On musl libc and Solaris 11.0, posix_spawn_file_actions_adddup2 - dnl succeeds even if the fd argument is out of range. - AC_CACHE_CHECK([whether posix_spawn_file_actions_adddup2 works], - [gl_cv_func_posix_spawn_file_actions_adddup2_works], - [AC_RUN_IFELSE( - [AC_LANG_SOURCE([[ -#include -int main () -{ - posix_spawn_file_actions_t actions; - if (posix_spawn_file_actions_init (&actions) != 0) - return 1; - if (posix_spawn_file_actions_adddup2 (&actions, 10000000, 2) == 0) - return 2; - return 0; -}]])], - [gl_cv_func_posix_spawn_file_actions_adddup2_works=yes], - [gl_cv_func_posix_spawn_file_actions_adddup2_works=no], - [# Guess no on musl libc and Solaris, yes otherwise. - case "$host_os" in - *-musl*) gl_cv_func_posix_spawn_file_actions_adddup2_works="guessing no";; - solaris*) gl_cv_func_posix_spawn_file_actions_adddup2_works="guessing no";; - # Guess no on native Windows. - mingw*) gl_cv_func_posix_spawn_file_actions_adddup2_works="guessing no" ;; - *) gl_cv_func_posix_spawn_file_actions_adddup2_works="guessing yes";; - esac - ]) - ]) - case "$gl_cv_func_posix_spawn_file_actions_adddup2_works" in - *yes) ;; - *) REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2=1 ;; - esac - fi -]) - -AC_DEFUN([gl_FUNC_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN], -[ - AC_REQUIRE([gl_SPAWN_H_DEFAULTS]) - AC_REQUIRE([AC_PROG_CC]) - AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles - gl_POSIX_SPAWN - if test $REPLACE_POSIX_SPAWN = 1; then - REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN=1 - else - dnl On musl libc and Solaris 11.0, posix_spawn_file_actions_addopen - dnl succeeds even if the fd argument is out of range. - AC_CACHE_CHECK([whether posix_spawn_file_actions_addopen works], - [gl_cv_func_posix_spawn_file_actions_addopen_works], - [AC_RUN_IFELSE( - [AC_LANG_SOURCE([[ -#include -#include -int main () -{ - posix_spawn_file_actions_t actions; - if (posix_spawn_file_actions_init (&actions) != 0) - return 1; - if (posix_spawn_file_actions_addopen (&actions, 10000000, "foo", 0, O_RDONLY) - == 0) - return 2; - return 0; -}]])], - [gl_cv_func_posix_spawn_file_actions_addopen_works=yes], - [gl_cv_func_posix_spawn_file_actions_addopen_works=no], - [# Guess no on musl libc and Solaris, yes otherwise. - case "$host_os" in - *-musl*) gl_cv_func_posix_spawn_file_actions_addopen_works="guessing no";; - solaris*) gl_cv_func_posix_spawn_file_actions_addopen_works="guessing no";; - # Guess no on native Windows. - mingw*) gl_cv_func_posix_spawn_file_actions_addopen_works="guessing no" ;; - *) gl_cv_func_posix_spawn_file_actions_addopen_works="guessing yes";; - esac - ]) - ]) - case "$gl_cv_func_posix_spawn_file_actions_addopen_works" in - *yes) ;; - *) REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN=1 ;; - esac - fi -]) diff --git a/m4/posix_spawn_faction_addchdir.m4 b/m4/posix_spawn_faction_addchdir.m4 deleted file mode 100644 index 1ce7153d1d..0000000000 --- a/m4/posix_spawn_faction_addchdir.m4 +++ /dev/null @@ -1,20 +0,0 @@ -# posix_spawn_faction_addchdir.m4 serial 1 -dnl Copyright (C) 2018-2020 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -AC_DEFUN([gl_FUNC_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR], -[ - AC_REQUIRE([gl_SPAWN_H_DEFAULTS]) - AC_REQUIRE([AC_PROG_CC]) - gl_POSIX_SPAWN - AC_CHECK_FUNCS_ONCE([posix_spawn_file_actions_addchdir posix_spawn_file_actions_addchdir_np]) - if test $ac_cv_func_posix_spawn_file_actions_addchdir = yes; then - dnl This function is not yet standardized. Therefore override the - dnl system's implementation always. - REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR=1 - else - HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR=0 - fi -]) diff --git a/m4/sched_h.m4 b/m4/sched_h.m4 deleted file mode 100644 index af0c43de07..0000000000 --- a/m4/sched_h.m4 +++ /dev/null @@ -1,91 +0,0 @@ -# sched_h.m4 serial 12 -dnl Copyright (C) 2008-2020 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -dnl Written by Bruno Haible. - -AC_DEFUN([gl_SCHED_H], -[ - dnl Use AC_REQUIRE here, so that the default behavior below is expanded - dnl once only, before all statements that occur in other macros. - AC_REQUIRE([gl_SCHED_H_DEFAULTS]) - - AC_REQUIRE([AC_CANONICAL_HOST]) - - AC_CHECK_HEADERS_ONCE([sys/cdefs.h]) - AC_CHECK_HEADERS([sched.h], [], [], - [[#if HAVE_SYS_CDEFS_H - #include - #endif - ]]) - gl_NEXT_HEADERS([sched.h]) - - if test "$ac_cv_header_sched_h" = yes; then - HAVE_SCHED_H=1 - else - HAVE_SCHED_H=0 - fi - AC_SUBST([HAVE_SCHED_H]) - - if test "$HAVE_SCHED_H" = 1; then - AC_CHECK_TYPE([struct sched_param], - [HAVE_STRUCT_SCHED_PARAM=1], [HAVE_STRUCT_SCHED_PARAM=0], - [[#if HAVE_SYS_CDEFS_H - #include - #endif - #include - ]]) - else - HAVE_STRUCT_SCHED_PARAM=0 - case "$host_os" in - os2*) - dnl On OS/2 kLIBC, struct sched_param is in spawn.h. - AC_CHECK_TYPE([struct sched_param], - [HAVE_STRUCT_SCHED_PARAM=1], [], - [#include ]) - ;; - vms) - dnl On OpenVMS 7.2 or newer, struct sched_param is in pthread.h. - AC_CHECK_TYPE([struct sched_param], - [HAVE_STRUCT_SCHED_PARAM=1], [], - [#include ]) - ;; - esac - fi - AC_SUBST([HAVE_STRUCT_SCHED_PARAM]) - - if test "$ac_cv_header_sys_cdefs_h" = yes; then - HAVE_SYS_CDEFS_H=1 - else - HAVE_SYS_CDEFS_H=0 - fi - AC_SUBST([HAVE_SYS_CDEFS_H]) - - dnl Ensure the type pid_t gets defined. - AC_REQUIRE([AC_TYPE_PID_T]) - - dnl Check for declarations of anything we want to poison if the - dnl corresponding gnulib module is not in use, if it is not common - dnl enough to be declared everywhere. - gl_WARN_ON_USE_PREPARE([[#include - ]], [sched_yield]) -]) - -AC_DEFUN([gl_SCHED_MODULE_INDICATOR], -[ - dnl Use AC_REQUIRE here, so that the default settings are expanded once only. - AC_REQUIRE([gl_SCHED_H_DEFAULTS]) - gl_MODULE_INDICATOR_SET_VARIABLE([$1]) - dnl Define it also as a C macro, for the benefit of the unit tests. - gl_MODULE_INDICATOR_FOR_TESTS([$1]) -]) - -AC_DEFUN([gl_SCHED_H_DEFAULTS], -[ - GNULIB_SCHED_YIELD=0; AC_SUBST([GNULIB_SCHED_YIELD]) - dnl Assume proper GNU behavior unless another module says otherwise. - HAVE_SCHED_YIELD=1; AC_SUBST([HAVE_SCHED_YIELD]) - REPLACE_SCHED_YIELD=0; AC_SUBST([REPLACE_SCHED_YIELD]) -]) diff --git a/m4/sh-filename.m4 b/m4/sh-filename.m4 deleted file mode 100644 index f7b31548e0..0000000000 --- a/m4/sh-filename.m4 +++ /dev/null @@ -1,22 +0,0 @@ -# sh-filename.m4 serial 2 -dnl Copyright (C) 2018-2020 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -dnl From Bruno Haible. - -AC_DEFUN([gl_SH_FILENAME], -[ - AH_VERBATIM([SH_FILENAME], -[/* File name of the Bourne shell. */ -#if defined __CYGWIN__ || defined __ANDROID__ -/* Omit the directory part because - - For 32-bit Cygwin programs in a 64-bit Cygwin environment, the Cygwin - mounts are not visible. - - On Android, /bin/sh does not exist. It's /system/bin/sh instead. */ -# define BOURNE_SHELL "sh" -#else -# define BOURNE_SHELL "/bin/sh" -#endif]) -]) diff --git a/m4/spawn_h.m4 b/m4/spawn_h.m4 deleted file mode 100644 index 781f9f4965..0000000000 --- a/m4/spawn_h.m4 +++ /dev/null @@ -1,136 +0,0 @@ -# spawn_h.m4 serial 18 -dnl Copyright (C) 2008-2020 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -dnl Written by Bruno Haible. - -AC_DEFUN([gl_SPAWN_H], -[ - dnl Use AC_REQUIRE here, so that the default behavior below is expanded - dnl once only, before all statements that occur in other macros. - AC_REQUIRE([gl_SPAWN_H_DEFAULTS]) - - dnl is always overridden, because of GNULIB_POSIXCHECK. - gl_CHECK_NEXT_HEADERS([spawn.h]) - - if test $ac_cv_header_spawn_h = yes; then - HAVE_SPAWN_H=1 - AC_CHECK_TYPES([posix_spawnattr_t], [], [HAVE_POSIX_SPAWNATTR_T=0], [[ -#include - ]]) - AC_CHECK_TYPES([posix_spawn_file_actions_t], [], - [HAVE_POSIX_SPAWN_FILE_ACTIONS_T=0], [[ -#include - ]]) - else - HAVE_SPAWN_H=0 - HAVE_POSIX_SPAWNATTR_T=0 - HAVE_POSIX_SPAWN_FILE_ACTIONS_T=0 - fi - AC_SUBST([HAVE_SPAWN_H]) - - dnl Ensure the type pid_t gets defined. - AC_REQUIRE([AC_TYPE_PID_T]) - - dnl Ensure the type mode_t gets defined. - AC_REQUIRE([AC_TYPE_MODE_T]) - - AC_REQUIRE([gl_HAVE_POSIX_SPAWN]) - - AC_REQUIRE([AC_C_RESTRICT]) - - dnl Check for declarations of anything we want to poison if the - dnl corresponding gnulib module is not in use. - gl_WARN_ON_USE_PREPARE([[#include - ]], [posix_spawn posix_spawnp posix_spawnattr_init posix_spawnattr_destroy - posix_spawnattr_getsigdefault posix_spawnattr_setsigdefault - posix_spawnattr_getsigmask posix_spawnattr_setsigmask - posix_spawnattr_getflags posix_spawnattr_setflags - posix_spawnattr_getpgroup posix_spawnattr_setpgroup - posix_spawnattr_getschedpolicy posix_spawnattr_setschedpolicy - posix_spawnattr_getschedparam posix_spawnattr_setschedparam - posix_spawn_file_actions_init posix_spawn_file_actions_destroy - posix_spawn_file_actions_addopen posix_spawn_file_actions_addclose - posix_spawn_file_actions_adddup2 posix_spawn_file_actions_addchdir - posix_spawn_file_actions_addfchdir]) -]) - -dnl Checks whether the system has the functions posix_spawn. -dnl Sets ac_cv_func_posix_spawn and HAVE_POSIX_SPAWN. -AC_DEFUN([gl_HAVE_POSIX_SPAWN], -[ - dnl Use AC_REQUIRE here, so that the default behavior below is expanded - dnl once only, before all statements that occur in other macros. - AC_REQUIRE([gl_SPAWN_H_DEFAULTS]) - - LIB_POSIX_SPAWN= - AC_SUBST([LIB_POSIX_SPAWN]) - gl_saved_libs=$LIBS - AC_SEARCH_LIBS([posix_spawn], [rt], - [test "$ac_cv_search_posix_spawn" = "none required" || - LIB_POSIX_SPAWN=$ac_cv_search_posix_spawn]) - AC_CHECK_FUNCS([posix_spawn]) - LIBS=$gl_saved_libs - - if test $ac_cv_func_posix_spawn != yes; then - HAVE_POSIX_SPAWN=0 - fi -]) - -AC_DEFUN([gl_SPAWN_MODULE_INDICATOR], -[ - dnl Use AC_REQUIRE here, so that the default settings are expanded once only. - AC_REQUIRE([gl_SPAWN_H_DEFAULTS]) - gl_MODULE_INDICATOR_SET_VARIABLE([$1]) - dnl Define it also as a C macro, for the benefit of the unit tests. - gl_MODULE_INDICATOR_FOR_TESTS([$1]) -]) - -AC_DEFUN([gl_SPAWN_H_DEFAULTS], -[ - GNULIB_POSIX_SPAWN=0; AC_SUBST([GNULIB_POSIX_SPAWN]) - GNULIB_POSIX_SPAWNP=0; AC_SUBST([GNULIB_POSIX_SPAWNP]) - GNULIB_POSIX_SPAWN_FILE_ACTIONS_INIT=0; AC_SUBST([GNULIB_POSIX_SPAWN_FILE_ACTIONS_INIT]) - GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR=0; AC_SUBST([GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR]) - GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE=0; AC_SUBST([GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE]) - GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2=0; AC_SUBST([GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2]) - GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR=0; AC_SUBST([GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR]) - GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN=0; AC_SUBST([GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN]) - GNULIB_POSIX_SPAWN_FILE_ACTIONS_DESTROY=0; AC_SUBST([GNULIB_POSIX_SPAWN_FILE_ACTIONS_DESTROY]) - GNULIB_POSIX_SPAWNATTR_INIT=0; AC_SUBST([GNULIB_POSIX_SPAWNATTR_INIT]) - GNULIB_POSIX_SPAWNATTR_GETFLAGS=0; AC_SUBST([GNULIB_POSIX_SPAWNATTR_GETFLAGS]) - GNULIB_POSIX_SPAWNATTR_SETFLAGS=0; AC_SUBST([GNULIB_POSIX_SPAWNATTR_SETFLAGS]) - GNULIB_POSIX_SPAWNATTR_GETPGROUP=0; AC_SUBST([GNULIB_POSIX_SPAWNATTR_GETPGROUP]) - GNULIB_POSIX_SPAWNATTR_SETPGROUP=0; AC_SUBST([GNULIB_POSIX_SPAWNATTR_SETPGROUP]) - GNULIB_POSIX_SPAWNATTR_GETSCHEDPARAM=0; AC_SUBST([GNULIB_POSIX_SPAWNATTR_GETSCHEDPARAM]) - GNULIB_POSIX_SPAWNATTR_SETSCHEDPARAM=0; AC_SUBST([GNULIB_POSIX_SPAWNATTR_SETSCHEDPARAM]) - GNULIB_POSIX_SPAWNATTR_GETSCHEDPOLICY=0; AC_SUBST([GNULIB_POSIX_SPAWNATTR_GETSCHEDPOLICY]) - GNULIB_POSIX_SPAWNATTR_SETSCHEDPOLICY=0; AC_SUBST([GNULIB_POSIX_SPAWNATTR_SETSCHEDPOLICY]) - GNULIB_POSIX_SPAWNATTR_GETSIGDEFAULT=0; AC_SUBST([GNULIB_POSIX_SPAWNATTR_GETSIGDEFAULT]) - GNULIB_POSIX_SPAWNATTR_SETSIGDEFAULT=0; AC_SUBST([GNULIB_POSIX_SPAWNATTR_SETSIGDEFAULT]) - GNULIB_POSIX_SPAWNATTR_GETSIGMASK=0; AC_SUBST([GNULIB_POSIX_SPAWNATTR_GETSIGMASK]) - GNULIB_POSIX_SPAWNATTR_SETSIGMASK=0; AC_SUBST([GNULIB_POSIX_SPAWNATTR_SETSIGMASK]) - GNULIB_POSIX_SPAWNATTR_DESTROY=0; AC_SUBST([GNULIB_POSIX_SPAWNATTR_DESTROY]) - dnl Assume proper GNU behavior unless another module says otherwise. - HAVE_POSIX_SPAWN=1; AC_SUBST([HAVE_POSIX_SPAWN]) - HAVE_POSIX_SPAWNATTR_T=1; AC_SUBST([HAVE_POSIX_SPAWNATTR_T]) - HAVE_POSIX_SPAWN_FILE_ACTIONS_T=1; - AC_SUBST([HAVE_POSIX_SPAWN_FILE_ACTIONS_T]) - HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR=1; - AC_SUBST([HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR]) - HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR=1; - AC_SUBST([HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR]) - REPLACE_POSIX_SPAWN=0; AC_SUBST([REPLACE_POSIX_SPAWN]) - REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR=0; - AC_SUBST([REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR]) - REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE=0; - AC_SUBST([REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE]) - REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2=0; - AC_SUBST([REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2]) - REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR=0; - AC_SUBST([REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR]) - REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN=0; - AC_SUBST([REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN]) -]) diff --git a/m4/strchrnul.m4 b/m4/strchrnul.m4 deleted file mode 100644 index a18f0935a5..0000000000 --- a/m4/strchrnul.m4 +++ /dev/null @@ -1,50 +0,0 @@ -# strchrnul.m4 serial 9 -dnl Copyright (C) 2003, 2007, 2009-2020 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -AC_DEFUN([gl_FUNC_STRCHRNUL], -[ - dnl Persuade glibc to declare strchrnul(). - AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) - - AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS]) - AC_CHECK_FUNCS([strchrnul]) - if test $ac_cv_func_strchrnul = no; then - HAVE_STRCHRNUL=0 - else - AC_CACHE_CHECK([whether strchrnul works], - [gl_cv_func_strchrnul_works], - [AC_RUN_IFELSE([AC_LANG_PROGRAM([[ -#include /* for strchrnul */ -]], [[const char *buf = "a"; - return strchrnul (buf, 'b') != buf + 1; - ]])], - [gl_cv_func_strchrnul_works=yes], - [gl_cv_func_strchrnul_works=no], - [dnl Cygwin 1.7.9 introduced strchrnul, but it was broken until 1.7.10 - AC_EGREP_CPP([Lucky user], - [ -#if defined __CYGWIN__ - #include - #if CYGWIN_VERSION_DLL_COMBINED > CYGWIN_VERSION_DLL_MAKE_COMBINED (1007, 9) - Lucky user - #endif -#else - Lucky user -#endif - ], - [gl_cv_func_strchrnul_works="guessing yes"], - [gl_cv_func_strchrnul_works="guessing no"]) - ]) - ]) - case "$gl_cv_func_strchrnul_works" in - *yes) ;; - *) REPLACE_STRCHRNUL=1 ;; - esac - fi -]) - -# Prerequisites of lib/strchrnul.c. -AC_DEFUN([gl_PREREQ_STRCHRNUL], [:]) commit e387371497d313f05b94e3bf42fe6685184605d1 Author: Eli Zaretskii Date: Fri Dec 25 14:50:25 2020 +0200 Revert "Use posix_spawn if possible." This reverts commit 2c79a8f9210db01c86b0e5f236adeb0509519d30. It breaks the MinGW build in too many ways, and should be first tested on a branch. diff --git a/src/Makefile.in b/src/Makefile.in index aa93b604b0..39c0f12fe6 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -239,8 +239,6 @@ LCMS2_CFLAGS = @LCMS2_CFLAGS@ LIBZ = @LIBZ@ -LIB_POSIX_SPAWN = @LIB_POSIX_SPAWN@ - ## system-specific libs for dynamic modules, else empty LIBMODULES = @LIBMODULES@ ## dynlib.o emacs-module.o if modules enabled, else empty @@ -537,7 +535,7 @@ LIBES = $(LIBS) $(W32_LIBS) $(LIBS_GNUSTEP) $(LIBX_BASE) $(LIBIMAGE) \ $(FREETYPE_LIBS) $(FONTCONFIG_LIBS) $(HARFBUZZ_LIBS) $(LIBOTF_LIBS) $(M17N_FLT_LIBS) \ $(LIBGNUTLS_LIBS) $(LIB_PTHREAD) $(GETADDRINFO_A_LIBS) $(LCMS2_LIBS) \ $(NOTIFY_LIBS) $(LIB_MATH) $(LIBZ) $(LIBMODULES) $(LIBSYSTEMD_LIBS) \ - $(JSON_LIBS) $(LIBGMP) $(LIB_POSIX_SPAWN) + $(JSON_LIBS) $(LIBGMP) ## FORCE it so that admin/unidata can decide whether this file is ## up-to-date. Although since charprop depends on bootstrap-emacs, diff --git a/src/callproc.c b/src/callproc.c index a5056531e0..3ecd688027 100644 --- a/src/callproc.c +++ b/src/callproc.c @@ -27,7 +27,6 @@ along with GNU Emacs. If not, see . */ #include #include -#include #include "lisp.h" @@ -1229,156 +1228,12 @@ int emacs_spawn (pid_t *newpid, int std_in, int std_out, int std_err, char **argv, char **envp, const char *cwd, const char *pty) { - /* `posix_spawn' is available on all Unix systems, either natively - or through Gnulib. Gnulib defines `posix_spawn' on Windows as - well, but doesn't implement it yet. So we fall back to our own - code on Windows. Because Gnulib always defines `posix_spawn', we - don't need to use conditional compilation here. */ - -#ifdef DOS_NT - enum { can_use_posix_spawn = false }; -#else - enum { can_use_posix_spawn = true }; -#endif - - /* `posix_spawn' doesn't yet support setting up pseudoterminals, so - we fall back to `vfork' if we're supposed to use a - pseudoterminal. */ - - bool use_posix_spawn = can_use_posix_spawn && pty == NULL; - - posix_spawn_file_actions_t actions; - posix_spawnattr_t attributes; - - if (use_posix_spawn) - { - /* Initialize optional attributes before blocking. */ - bool destroy_actions = false; - bool destroy_attributes = false; - - int error = posix_spawn_file_actions_init (&actions); - if (error != 0) - goto posix_spawn_init_failed; - destroy_actions = true; - - error = posix_spawnattr_init (&attributes); - if (error != 0) - goto posix_spawn_init_failed; - destroy_attributes = true; - - error = posix_spawn_file_actions_adddup2 (&actions, std_in, - STDIN_FILENO); - if (error != 0) - goto posix_spawn_init_failed; - - error = posix_spawn_file_actions_adddup2 (&actions, std_out, - STDOUT_FILENO); - if (error != 0) - goto posix_spawn_init_failed; - - error = posix_spawn_file_actions_adddup2 (&actions, - std_err < 0 ? std_out - : std_err, - STDERR_FILENO); - if (error != 0) - goto posix_spawn_init_failed; - - error = posix_spawn_file_actions_addchdir (&actions, cwd); - if (error != 0) - goto posix_spawn_init_failed; - - error = posix_spawnattr_setflags (&attributes, - POSIX_SPAWN_SETPGROUP - | POSIX_SPAWN_SETSIGDEF - | POSIX_SPAWN_SETSIGMASK); - if (error != 0) - goto posix_spawn_init_failed; - - error = posix_spawnattr_setpgroup (&attributes, 0); - if (error != 0) - goto posix_spawn_init_failed; - - sigset_t sigdefault; - sigemptyset (&sigdefault); - -#ifdef DARWIN_OS - /* Work around a macOS bug, where SIGCHLD is apparently - delivered to a vforked child instead of to its parent. See: - https://lists.gnu.org/r/emacs-devel/2017-05/msg00342.html - */ - sigaddset (&sigdefault, SIGCHLD); -#endif - - sigaddset (&sigdefault, SIGINT); - sigaddset (&sigdefault, SIGQUIT); -#ifdef SIGPROF - sigaddset (&sigdefault, SIGPROF); -#endif - - /* Emacs ignores SIGPIPE, but the child should not. */ - sigaddset (&sigdefault, SIGPIPE); - /* Likewise for SIGPROF. */ -#ifdef SIGPROF - sigaddset (&sigdefault, SIGPROF); -#endif - - error - = posix_spawnattr_setsigdefault (&attributes, &sigdefault); - if (error != 0) - goto posix_spawn_init_failed; - - /* Stop blocking SIGCHLD in the child. */ - sigset_t oldset; - error = pthread_sigmask (SIG_SETMASK, NULL, &oldset); - if (error != 0) - goto posix_spawn_init_failed; - error = posix_spawnattr_setsigmask (&attributes, &oldset); - if (error != 0) - goto posix_spawn_init_failed; - - goto next; - - posix_spawn_init_failed: - if (destroy_actions) - posix_spawn_file_actions_destroy (&actions); - if (destroy_attributes) - posix_spawnattr_destroy (&attributes); - eassert (0 < error); - return error; - } - sigset_t oldset; int pid; - int vfork_error; - next: block_input (); block_child_signal (&oldset); - if (use_posix_spawn) - { - vfork_error = posix_spawn (&pid, argv[0], &actions, &attributes, - argv, envp); - if (vfork_error != 0) - pid = -1; - - int error = posix_spawn_file_actions_destroy (&actions); - if (error != 0) - { - errno = error; - emacs_perror ("posix_spawn_file_actions_destroy"); - } - - error = posix_spawnattr_destroy (&attributes); - if (error != 0) - { - errno = error; - emacs_perror ("posix_spawnattr_destroy"); - } - - goto fork_done; - } - #ifndef WINDOWSNT /* vfork, and prevent local vars from being clobbered by the vfork. */ pid_t *volatile newpid_volatile = newpid; @@ -1520,9 +1375,8 @@ emacs_spawn (pid_t *newpid, int std_in, int std_out, int std_err, /* Back in the parent process. */ - vfork_error = pid < 0 ? errno : 0; + int vfork_error = pid < 0 ? errno : 0; - fork_done: /* Stop blocking in the parent. */ unblock_child_signal (&oldset); unblock_input (); commit 2c79a8f9210db01c86b0e5f236adeb0509519d30 Author: Philipp Stephani Date: Fri Dec 25 11:39:09 2020 +0100 Use posix_spawn if possible. posix_spawn is less error-prone than vfork + execve, and can make better use of system-specific enhancements like 'clone' on Linux. Use it if we don't need to configure a pseudoterminal. * src/Makefile.in (LIB_POSIX_SPAWN): New variable. (LIBES): Use it. * src/callproc.c (emacs_spawn): Use posix_spawn on Unix-like system if we don't need to set up a pseudoterminal. diff --git a/src/Makefile.in b/src/Makefile.in index 39c0f12fe6..aa93b604b0 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -239,6 +239,8 @@ LCMS2_CFLAGS = @LCMS2_CFLAGS@ LIBZ = @LIBZ@ +LIB_POSIX_SPAWN = @LIB_POSIX_SPAWN@ + ## system-specific libs for dynamic modules, else empty LIBMODULES = @LIBMODULES@ ## dynlib.o emacs-module.o if modules enabled, else empty @@ -535,7 +537,7 @@ LIBES = $(LIBS) $(W32_LIBS) $(LIBS_GNUSTEP) $(LIBX_BASE) $(LIBIMAGE) \ $(FREETYPE_LIBS) $(FONTCONFIG_LIBS) $(HARFBUZZ_LIBS) $(LIBOTF_LIBS) $(M17N_FLT_LIBS) \ $(LIBGNUTLS_LIBS) $(LIB_PTHREAD) $(GETADDRINFO_A_LIBS) $(LCMS2_LIBS) \ $(NOTIFY_LIBS) $(LIB_MATH) $(LIBZ) $(LIBMODULES) $(LIBSYSTEMD_LIBS) \ - $(JSON_LIBS) $(LIBGMP) + $(JSON_LIBS) $(LIBGMP) $(LIB_POSIX_SPAWN) ## FORCE it so that admin/unidata can decide whether this file is ## up-to-date. Although since charprop depends on bootstrap-emacs, diff --git a/src/callproc.c b/src/callproc.c index 3ecd688027..a5056531e0 100644 --- a/src/callproc.c +++ b/src/callproc.c @@ -27,6 +27,7 @@ along with GNU Emacs. If not, see . */ #include #include +#include #include "lisp.h" @@ -1228,12 +1229,156 @@ int emacs_spawn (pid_t *newpid, int std_in, int std_out, int std_err, char **argv, char **envp, const char *cwd, const char *pty) { + /* `posix_spawn' is available on all Unix systems, either natively + or through Gnulib. Gnulib defines `posix_spawn' on Windows as + well, but doesn't implement it yet. So we fall back to our own + code on Windows. Because Gnulib always defines `posix_spawn', we + don't need to use conditional compilation here. */ + +#ifdef DOS_NT + enum { can_use_posix_spawn = false }; +#else + enum { can_use_posix_spawn = true }; +#endif + + /* `posix_spawn' doesn't yet support setting up pseudoterminals, so + we fall back to `vfork' if we're supposed to use a + pseudoterminal. */ + + bool use_posix_spawn = can_use_posix_spawn && pty == NULL; + + posix_spawn_file_actions_t actions; + posix_spawnattr_t attributes; + + if (use_posix_spawn) + { + /* Initialize optional attributes before blocking. */ + bool destroy_actions = false; + bool destroy_attributes = false; + + int error = posix_spawn_file_actions_init (&actions); + if (error != 0) + goto posix_spawn_init_failed; + destroy_actions = true; + + error = posix_spawnattr_init (&attributes); + if (error != 0) + goto posix_spawn_init_failed; + destroy_attributes = true; + + error = posix_spawn_file_actions_adddup2 (&actions, std_in, + STDIN_FILENO); + if (error != 0) + goto posix_spawn_init_failed; + + error = posix_spawn_file_actions_adddup2 (&actions, std_out, + STDOUT_FILENO); + if (error != 0) + goto posix_spawn_init_failed; + + error = posix_spawn_file_actions_adddup2 (&actions, + std_err < 0 ? std_out + : std_err, + STDERR_FILENO); + if (error != 0) + goto posix_spawn_init_failed; + + error = posix_spawn_file_actions_addchdir (&actions, cwd); + if (error != 0) + goto posix_spawn_init_failed; + + error = posix_spawnattr_setflags (&attributes, + POSIX_SPAWN_SETPGROUP + | POSIX_SPAWN_SETSIGDEF + | POSIX_SPAWN_SETSIGMASK); + if (error != 0) + goto posix_spawn_init_failed; + + error = posix_spawnattr_setpgroup (&attributes, 0); + if (error != 0) + goto posix_spawn_init_failed; + + sigset_t sigdefault; + sigemptyset (&sigdefault); + +#ifdef DARWIN_OS + /* Work around a macOS bug, where SIGCHLD is apparently + delivered to a vforked child instead of to its parent. See: + https://lists.gnu.org/r/emacs-devel/2017-05/msg00342.html + */ + sigaddset (&sigdefault, SIGCHLD); +#endif + + sigaddset (&sigdefault, SIGINT); + sigaddset (&sigdefault, SIGQUIT); +#ifdef SIGPROF + sigaddset (&sigdefault, SIGPROF); +#endif + + /* Emacs ignores SIGPIPE, but the child should not. */ + sigaddset (&sigdefault, SIGPIPE); + /* Likewise for SIGPROF. */ +#ifdef SIGPROF + sigaddset (&sigdefault, SIGPROF); +#endif + + error + = posix_spawnattr_setsigdefault (&attributes, &sigdefault); + if (error != 0) + goto posix_spawn_init_failed; + + /* Stop blocking SIGCHLD in the child. */ + sigset_t oldset; + error = pthread_sigmask (SIG_SETMASK, NULL, &oldset); + if (error != 0) + goto posix_spawn_init_failed; + error = posix_spawnattr_setsigmask (&attributes, &oldset); + if (error != 0) + goto posix_spawn_init_failed; + + goto next; + + posix_spawn_init_failed: + if (destroy_actions) + posix_spawn_file_actions_destroy (&actions); + if (destroy_attributes) + posix_spawnattr_destroy (&attributes); + eassert (0 < error); + return error; + } + sigset_t oldset; int pid; + int vfork_error; + next: block_input (); block_child_signal (&oldset); + if (use_posix_spawn) + { + vfork_error = posix_spawn (&pid, argv[0], &actions, &attributes, + argv, envp); + if (vfork_error != 0) + pid = -1; + + int error = posix_spawn_file_actions_destroy (&actions); + if (error != 0) + { + errno = error; + emacs_perror ("posix_spawn_file_actions_destroy"); + } + + error = posix_spawnattr_destroy (&attributes); + if (error != 0) + { + errno = error; + emacs_perror ("posix_spawnattr_destroy"); + } + + goto fork_done; + } + #ifndef WINDOWSNT /* vfork, and prevent local vars from being clobbered by the vfork. */ pid_t *volatile newpid_volatile = newpid; @@ -1375,8 +1520,9 @@ emacs_spawn (pid_t *newpid, int std_in, int std_out, int std_err, /* Back in the parent process. */ - int vfork_error = pid < 0 ? errno : 0; + vfork_error = pid < 0 ? errno : 0; + fork_done: /* Stop blocking in the parent. */ unblock_child_signal (&oldset); unblock_input (); commit 3ba34141da77a24c251ee6530f3f72a366fe556e Author: Philipp Stephani Date: Fri Dec 25 11:33:02 2020 +0100 Import posix_spawn from Gnulib. posix_spawn is less error-prone than vfork + exec, and can make use of system-specific optimizations like `clone' on Linux. Import Gnulib replacement so that we can use recent additions like `posix_spawn_file_actions_addchdir'. The only manual change are to admin/merge-gnulib and .gitignore. All other changes are due to rerunning merge-gnulib. * admin/merge-gnulib (GNULIB_MODULES): Add posix_spawn-related modules. * .gitignore: Add new generated files. diff --git a/.gitignore b/.gitignore index bf7e934981..f9c0fae4f6 100644 --- a/.gitignore +++ b/.gitignore @@ -65,7 +65,9 @@ lib/ieee754.h lib/inttypes.h lib/libgnu.a lib/limits.h +lib/sched.h lib/signal.h +lib/spawn.h lib/std*.h !lib/std*.in.h !lib/stdio-impl.h diff --git a/admin/merge-gnulib b/admin/merge-gnulib index 880dc5eef5..f1ed2da69e 100755 --- a/admin/merge-gnulib +++ b/admin/merge-gnulib @@ -39,7 +39,14 @@ GNULIB_MODULES=' getloadavg getopt-gnu getrandom gettime gettimeofday gitlog-to-changelog ieee754-h ignore-value intprops largefile libgmp lstat manywarnings memmem-simple mempcpy memrchr minmax mkostemp mktime nstrftime - pathmax pipe2 pselect pthread_sigmask + pathmax pipe2 + posix_spawn posix_spawn_file_actions_addchdir + posix_spawn_file_actions_adddup2 posix_spawn_file_actions_destroy + posix_spawn_file_actions_init + posix_spawnattr_destroy posix_spawnattr_init + posix_spawnattr_setflags posix_spawnattr_setpgroup + posix_spawnattr_setsigdefault posix_spawnattr_setsigmask + pselect pthread_sigmask qcopy-acl readlink readlinkat regex sig2str sigdescr_np socklen stat-time std-gnu11 stdalign stddef stdio stpcpy strnlen strtoimax symlink sys_stat sys_time diff --git a/lib/gnulib.mk.in b/lib/gnulib.mk.in index a37f9278a3..209c7eef29 100644 --- a/lib/gnulib.mk.in +++ b/lib/gnulib.mk.in @@ -130,6 +130,17 @@ # nstrftime \ # pathmax \ # pipe2 \ +# posix_spawn \ +# posix_spawn_file_actions_addchdir \ +# posix_spawn_file_actions_adddup2 \ +# posix_spawn_file_actions_destroy \ +# posix_spawn_file_actions_init \ +# posix_spawnattr_destroy \ +# posix_spawnattr_init \ +# posix_spawnattr_setflags \ +# posix_spawnattr_setpgroup \ +# posix_spawnattr_setsigdefault \ +# posix_spawnattr_setsigmask \ # pselect \ # pthread_sigmask \ # qcopy-acl \ @@ -393,6 +404,29 @@ GNULIB_PIPE2 = @GNULIB_PIPE2@ GNULIB_POPEN = @GNULIB_POPEN@ GNULIB_POSIX_MEMALIGN = @GNULIB_POSIX_MEMALIGN@ GNULIB_POSIX_OPENPT = @GNULIB_POSIX_OPENPT@ +GNULIB_POSIX_SPAWN = @GNULIB_POSIX_SPAWN@ +GNULIB_POSIX_SPAWNATTR_DESTROY = @GNULIB_POSIX_SPAWNATTR_DESTROY@ +GNULIB_POSIX_SPAWNATTR_GETFLAGS = @GNULIB_POSIX_SPAWNATTR_GETFLAGS@ +GNULIB_POSIX_SPAWNATTR_GETPGROUP = @GNULIB_POSIX_SPAWNATTR_GETPGROUP@ +GNULIB_POSIX_SPAWNATTR_GETSCHEDPARAM = @GNULIB_POSIX_SPAWNATTR_GETSCHEDPARAM@ +GNULIB_POSIX_SPAWNATTR_GETSCHEDPOLICY = @GNULIB_POSIX_SPAWNATTR_GETSCHEDPOLICY@ +GNULIB_POSIX_SPAWNATTR_GETSIGDEFAULT = @GNULIB_POSIX_SPAWNATTR_GETSIGDEFAULT@ +GNULIB_POSIX_SPAWNATTR_GETSIGMASK = @GNULIB_POSIX_SPAWNATTR_GETSIGMASK@ +GNULIB_POSIX_SPAWNATTR_INIT = @GNULIB_POSIX_SPAWNATTR_INIT@ +GNULIB_POSIX_SPAWNATTR_SETFLAGS = @GNULIB_POSIX_SPAWNATTR_SETFLAGS@ +GNULIB_POSIX_SPAWNATTR_SETPGROUP = @GNULIB_POSIX_SPAWNATTR_SETPGROUP@ +GNULIB_POSIX_SPAWNATTR_SETSCHEDPARAM = @GNULIB_POSIX_SPAWNATTR_SETSCHEDPARAM@ +GNULIB_POSIX_SPAWNATTR_SETSCHEDPOLICY = @GNULIB_POSIX_SPAWNATTR_SETSCHEDPOLICY@ +GNULIB_POSIX_SPAWNATTR_SETSIGDEFAULT = @GNULIB_POSIX_SPAWNATTR_SETSIGDEFAULT@ +GNULIB_POSIX_SPAWNATTR_SETSIGMASK = @GNULIB_POSIX_SPAWNATTR_SETSIGMASK@ +GNULIB_POSIX_SPAWNP = @GNULIB_POSIX_SPAWNP@ +GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR = @GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR@ +GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE = @GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE@ +GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2 = @GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2@ +GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR = @GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR@ +GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN = @GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN@ +GNULIB_POSIX_SPAWN_FILE_ACTIONS_DESTROY = @GNULIB_POSIX_SPAWN_FILE_ACTIONS_DESTROY@ +GNULIB_POSIX_SPAWN_FILE_ACTIONS_INIT = @GNULIB_POSIX_SPAWN_FILE_ACTIONS_INIT@ GNULIB_PREAD = @GNULIB_PREAD@ GNULIB_PRINTF = @GNULIB_PRINTF@ GNULIB_PRINTF_POSIX = @GNULIB_PRINTF_POSIX@ @@ -425,6 +459,7 @@ GNULIB_RMDIR = @GNULIB_RMDIR@ GNULIB_RPMATCH = @GNULIB_RPMATCH@ GNULIB_SCANDIR = @GNULIB_SCANDIR@ GNULIB_SCANF = @GNULIB_SCANF@ +GNULIB_SCHED_YIELD = @GNULIB_SCHED_YIELD@ GNULIB_SECURE_GETENV = @GNULIB_SECURE_GETENV@ GNULIB_SELECT = @GNULIB_SELECT@ GNULIB_SETENV = @GNULIB_SETENV@ @@ -634,6 +669,11 @@ HAVE_POPEN = @HAVE_POPEN@ HAVE_POSIX_MEMALIGN = @HAVE_POSIX_MEMALIGN@ HAVE_POSIX_OPENPT = @HAVE_POSIX_OPENPT@ HAVE_POSIX_SIGNALBLOCKING = @HAVE_POSIX_SIGNALBLOCKING@ +HAVE_POSIX_SPAWN = @HAVE_POSIX_SPAWN@ +HAVE_POSIX_SPAWNATTR_T = @HAVE_POSIX_SPAWNATTR_T@ +HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR = @HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR@ +HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR = @HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR@ +HAVE_POSIX_SPAWN_FILE_ACTIONS_T = @HAVE_POSIX_SPAWN_FILE_ACTIONS_T@ HAVE_PREAD = @HAVE_PREAD@ HAVE_PSELECT = @HAVE_PSELECT@ HAVE_PTHREAD_SIGMASK = @HAVE_PTHREAD_SIGMASK@ @@ -655,6 +695,8 @@ HAVE_RENAMEAT = @HAVE_RENAMEAT@ HAVE_REWINDDIR = @HAVE_REWINDDIR@ HAVE_RPMATCH = @HAVE_RPMATCH@ HAVE_SCANDIR = @HAVE_SCANDIR@ +HAVE_SCHED_H = @HAVE_SCHED_H@ +HAVE_SCHED_YIELD = @HAVE_SCHED_YIELD@ HAVE_SECURE_GETENV = @HAVE_SECURE_GETENV@ HAVE_SETENV = @HAVE_SETENV@ HAVE_SETHOSTNAME = @HAVE_SETHOSTNAME@ @@ -669,6 +711,7 @@ HAVE_SIGNED_WCHAR_T = @HAVE_SIGNED_WCHAR_T@ HAVE_SIGNED_WINT_T = @HAVE_SIGNED_WINT_T@ HAVE_SIGSET_T = @HAVE_SIGSET_T@ HAVE_SLEEP = @HAVE_SLEEP@ +HAVE_SPAWN_H = @HAVE_SPAWN_H@ HAVE_STDINT_H = @HAVE_STDINT_H@ HAVE_STPCPY = @HAVE_STPCPY@ HAVE_STPNCPY = @HAVE_STPNCPY@ @@ -683,6 +726,7 @@ HAVE_STRTOLD = @HAVE_STRTOLD@ HAVE_STRTOLL = @HAVE_STRTOLL@ HAVE_STRTOULL = @HAVE_STRTOULL@ HAVE_STRUCT_RANDOM_DATA = @HAVE_STRUCT_RANDOM_DATA@ +HAVE_STRUCT_SCHED_PARAM = @HAVE_STRUCT_SCHED_PARAM@ HAVE_STRUCT_SIGACTION_SA_SIGACTION = @HAVE_STRUCT_SIGACTION_SA_SIGACTION@ HAVE_STRUCT_TIMEVAL = @HAVE_STRUCT_TIMEVAL@ HAVE_STRVERSCMP = @HAVE_STRVERSCMP@ @@ -782,6 +826,7 @@ LIB_EACCESS = @LIB_EACCESS@ LIB_EXECINFO = @LIB_EXECINFO@ LIB_GETRANDOM = @LIB_GETRANDOM@ LIB_MATH = @LIB_MATH@ +LIB_POSIX_SPAWN = @LIB_POSIX_SPAWN@ LIB_PTHREAD = @LIB_PTHREAD@ LIB_PTHREAD_SIGMASK = @LIB_PTHREAD_SIGMASK@ LIB_TIMER_TIME = @LIB_TIMER_TIME@ @@ -805,7 +850,9 @@ NEXT_AS_FIRST_DIRECTIVE_FCNTL_H = @NEXT_AS_FIRST_DIRECTIVE_FCNTL_H@ NEXT_AS_FIRST_DIRECTIVE_GETOPT_H = @NEXT_AS_FIRST_DIRECTIVE_GETOPT_H@ NEXT_AS_FIRST_DIRECTIVE_INTTYPES_H = @NEXT_AS_FIRST_DIRECTIVE_INTTYPES_H@ NEXT_AS_FIRST_DIRECTIVE_LIMITS_H = @NEXT_AS_FIRST_DIRECTIVE_LIMITS_H@ +NEXT_AS_FIRST_DIRECTIVE_SCHED_H = @NEXT_AS_FIRST_DIRECTIVE_SCHED_H@ NEXT_AS_FIRST_DIRECTIVE_SIGNAL_H = @NEXT_AS_FIRST_DIRECTIVE_SIGNAL_H@ +NEXT_AS_FIRST_DIRECTIVE_SPAWN_H = @NEXT_AS_FIRST_DIRECTIVE_SPAWN_H@ NEXT_AS_FIRST_DIRECTIVE_STDDEF_H = @NEXT_AS_FIRST_DIRECTIVE_STDDEF_H@ NEXT_AS_FIRST_DIRECTIVE_STDINT_H = @NEXT_AS_FIRST_DIRECTIVE_STDINT_H@ NEXT_AS_FIRST_DIRECTIVE_STDIO_H = @NEXT_AS_FIRST_DIRECTIVE_STDIO_H@ @@ -824,7 +871,9 @@ NEXT_FCNTL_H = @NEXT_FCNTL_H@ NEXT_GETOPT_H = @NEXT_GETOPT_H@ NEXT_INTTYPES_H = @NEXT_INTTYPES_H@ NEXT_LIMITS_H = @NEXT_LIMITS_H@ +NEXT_SCHED_H = @NEXT_SCHED_H@ NEXT_SIGNAL_H = @NEXT_SIGNAL_H@ +NEXT_SPAWN_H = @NEXT_SPAWN_H@ NEXT_STDDEF_H = @NEXT_STDDEF_H@ NEXT_STDINT_H = @NEXT_STDINT_H@ NEXT_STDIO_H = @NEXT_STDIO_H@ @@ -946,6 +995,12 @@ REPLACE_OPENDIR = @REPLACE_OPENDIR@ REPLACE_PERROR = @REPLACE_PERROR@ REPLACE_POPEN = @REPLACE_POPEN@ REPLACE_POSIX_MEMALIGN = @REPLACE_POSIX_MEMALIGN@ +REPLACE_POSIX_SPAWN = @REPLACE_POSIX_SPAWN@ +REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR = @REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR@ +REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE = @REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE@ +REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2 = @REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2@ +REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR = @REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR@ +REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN = @REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN@ REPLACE_PREAD = @REPLACE_PREAD@ REPLACE_PRINTF = @REPLACE_PRINTF@ REPLACE_PSELECT = @REPLACE_PSELECT@ @@ -967,6 +1022,7 @@ REPLACE_REMOVE = @REPLACE_REMOVE@ REPLACE_RENAME = @REPLACE_RENAME@ REPLACE_RENAMEAT = @REPLACE_RENAMEAT@ REPLACE_RMDIR = @REPLACE_RMDIR@ +REPLACE_SCHED_YIELD = @REPLACE_SCHED_YIELD@ REPLACE_SELECT = @REPLACE_SELECT@ REPLACE_SETENV = @REPLACE_SETENV@ REPLACE_SETSTATE = @REPLACE_SETSTATE@ @@ -1108,11 +1164,13 @@ gamegroup = @gamegroup@ gameuser = @gameuser@ gl_GNULIB_ENABLED_03e0aaad4cb89ca757653bd367a6ccb7 = @gl_GNULIB_ENABLED_03e0aaad4cb89ca757653bd367a6ccb7@ gl_GNULIB_ENABLED_260941c0e5dc67ec9e87d1fb321c300b = @gl_GNULIB_ENABLED_260941c0e5dc67ec9e87d1fb321c300b@ +gl_GNULIB_ENABLED_332607f759618fb73dfc3076748afea7 = @gl_GNULIB_ENABLED_332607f759618fb73dfc3076748afea7@ gl_GNULIB_ENABLED_5264294aa0a5557541b53c8c741f7f31 = @gl_GNULIB_ENABLED_5264294aa0a5557541b53c8c741f7f31@ gl_GNULIB_ENABLED_6099e9737f757db36c47fa9d9f02e88c = @gl_GNULIB_ENABLED_6099e9737f757db36c47fa9d9f02e88c@ gl_GNULIB_ENABLED_682e609604ccaac6be382e4ee3a4eaec = @gl_GNULIB_ENABLED_682e609604ccaac6be382e4ee3a4eaec@ gl_GNULIB_ENABLED_a9786850e999ae65a836a6041e8e5ed1 = @gl_GNULIB_ENABLED_a9786850e999ae65a836a6041e8e5ed1@ gl_GNULIB_ENABLED_be453cec5eecf5731a274f2de7f2db36 = @gl_GNULIB_ENABLED_be453cec5eecf5731a274f2de7f2db36@ +gl_GNULIB_ENABLED_cdeb0f2aaf9d280baa6526bfa1b07f70 = @gl_GNULIB_ENABLED_cdeb0f2aaf9d280baa6526bfa1b07f70@ gl_GNULIB_ENABLED_cloexec = @gl_GNULIB_ENABLED_cloexec@ gl_GNULIB_ENABLED_dirfd = @gl_GNULIB_ENABLED_dirfd@ gl_GNULIB_ENABLED_ef07dc4b3077c11ea9cef586db4e5955 = @gl_GNULIB_ENABLED_ef07dc4b3077c11ea9cef586db4e5955@ @@ -1124,6 +1182,7 @@ gl_GNULIB_ENABLED_lchmod = @gl_GNULIB_ENABLED_lchmod@ gl_GNULIB_ENABLED_open = @gl_GNULIB_ENABLED_open@ gl_GNULIB_ENABLED_rawmemchr = @gl_GNULIB_ENABLED_rawmemchr@ gl_GNULIB_ENABLED_scratch_buffer = @gl_GNULIB_ENABLED_scratch_buffer@ +gl_GNULIB_ENABLED_strchrnul = @gl_GNULIB_ENABLED_strchrnul@ gl_GNULIB_ENABLED_strtoll = @gl_GNULIB_ENABLED_strtoll@ gl_GNULIB_ENABLED_utimens = @gl_GNULIB_ENABLED_utimens@ gl_LIBOBJS = @gl_LIBOBJS@ @@ -2270,6 +2329,140 @@ libgnu_a_SOURCES += pipe2.c endif ## end gnulib module pipe2 +## begin gnulib module posix_spawn +ifeq (,$(OMIT_GNULIB_MODULE_posix_spawn)) + + +EXTRA_DIST += spawn.c + +EXTRA_libgnu_a_SOURCES += spawn.c + +endif +## end gnulib module posix_spawn + +## begin gnulib module posix_spawn-internal +ifeq (,$(OMIT_GNULIB_MODULE_posix_spawn-internal)) + +ifneq (,$(gl_GNULIB_ENABLED_332607f759618fb73dfc3076748afea7)) + +endif +EXTRA_DIST += spawn_int.h spawni.c + +EXTRA_libgnu_a_SOURCES += spawni.c + +endif +## end gnulib module posix_spawn-internal + +## begin gnulib module posix_spawn_file_actions_addchdir +ifeq (,$(OMIT_GNULIB_MODULE_posix_spawn_file_actions_addchdir)) + + +EXTRA_DIST += spawn_faction_addchdir.c spawn_int.h + +EXTRA_libgnu_a_SOURCES += spawn_faction_addchdir.c + +endif +## end gnulib module posix_spawn_file_actions_addchdir + +## begin gnulib module posix_spawn_file_actions_adddup2 +ifeq (,$(OMIT_GNULIB_MODULE_posix_spawn_file_actions_adddup2)) + + +EXTRA_DIST += spawn_faction_adddup2.c spawn_int.h + +EXTRA_libgnu_a_SOURCES += spawn_faction_adddup2.c + +endif +## end gnulib module posix_spawn_file_actions_adddup2 + +## begin gnulib module posix_spawn_file_actions_destroy +ifeq (,$(OMIT_GNULIB_MODULE_posix_spawn_file_actions_destroy)) + + +EXTRA_DIST += spawn_faction_destroy.c + +EXTRA_libgnu_a_SOURCES += spawn_faction_destroy.c + +endif +## end gnulib module posix_spawn_file_actions_destroy + +## begin gnulib module posix_spawn_file_actions_init +ifeq (,$(OMIT_GNULIB_MODULE_posix_spawn_file_actions_init)) + + +EXTRA_DIST += spawn_faction_init.c spawn_int.h + +EXTRA_libgnu_a_SOURCES += spawn_faction_init.c + +endif +## end gnulib module posix_spawn_file_actions_init + +## begin gnulib module posix_spawnattr_destroy +ifeq (,$(OMIT_GNULIB_MODULE_posix_spawnattr_destroy)) + + +EXTRA_DIST += spawnattr_destroy.c + +EXTRA_libgnu_a_SOURCES += spawnattr_destroy.c + +endif +## end gnulib module posix_spawnattr_destroy + +## begin gnulib module posix_spawnattr_init +ifeq (,$(OMIT_GNULIB_MODULE_posix_spawnattr_init)) + + +EXTRA_DIST += spawnattr_init.c + +EXTRA_libgnu_a_SOURCES += spawnattr_init.c + +endif +## end gnulib module posix_spawnattr_init + +## begin gnulib module posix_spawnattr_setflags +ifeq (,$(OMIT_GNULIB_MODULE_posix_spawnattr_setflags)) + + +EXTRA_DIST += spawnattr_setflags.c + +EXTRA_libgnu_a_SOURCES += spawnattr_setflags.c + +endif +## end gnulib module posix_spawnattr_setflags + +## begin gnulib module posix_spawnattr_setpgroup +ifeq (,$(OMIT_GNULIB_MODULE_posix_spawnattr_setpgroup)) + + +EXTRA_DIST += spawnattr_setpgroup.c + +EXTRA_libgnu_a_SOURCES += spawnattr_setpgroup.c + +endif +## end gnulib module posix_spawnattr_setpgroup + +## begin gnulib module posix_spawnattr_setsigdefault +ifeq (,$(OMIT_GNULIB_MODULE_posix_spawnattr_setsigdefault)) + + +EXTRA_DIST += spawnattr_setdefault.c + +EXTRA_libgnu_a_SOURCES += spawnattr_setdefault.c + +endif +## end gnulib module posix_spawnattr_setsigdefault + +## begin gnulib module posix_spawnattr_setsigmask +ifeq (,$(OMIT_GNULIB_MODULE_posix_spawnattr_setsigmask)) + + +EXTRA_DIST += spawnattr_setsigmask.c + +EXTRA_libgnu_a_SOURCES += spawnattr_setsigmask.c + +endif +## end gnulib module posix_spawnattr_setsigmask + ## begin gnulib module pselect ifeq (,$(OMIT_GNULIB_MODULE_pselect)) @@ -2357,6 +2550,39 @@ EXTRA_DIST += root-uid.h endif ## end gnulib module root-uid +## begin gnulib module sched +ifeq (,$(OMIT_GNULIB_MODULE_sched)) + +BUILT_SOURCES += sched.h + +# We need the following in order to create a replacement for when +# the system doesn't have one. +sched.h: sched.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H) + $(AM_V_GEN)rm -f $@-t $@ && \ + { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ + sed -e 's|@''GUARD_PREFIX''@|GL|g' \ + -e 's|@''HAVE_SCHED_H''@|$(HAVE_SCHED_H)|g' \ + -e 's|@''HAVE_SYS_CDEFS_H''@|$(HAVE_SYS_CDEFS_H)|g' \ + -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ + -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ + -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ + -e 's|@''NEXT_SCHED_H''@|$(NEXT_SCHED_H)|g' \ + -e 's|@''HAVE_STRUCT_SCHED_PARAM''@|$(HAVE_STRUCT_SCHED_PARAM)|g' \ + -e 's/@''GNULIB_SCHED_YIELD''@/$(GNULIB_SCHED_YIELD)/g' \ + -e 's|@''HAVE_SCHED_YIELD''@|$(HAVE_SCHED_YIELD)|g' \ + -e 's|@''REPLACE_SCHED_YIELD''@|$(REPLACE_SCHED_YIELD)|g' \ + -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ + -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \ + < $(srcdir)/sched.in.h; \ + } > $@-t && \ + mv $@-t $@ +MOSTLYCLEANFILES += sched.h sched.h-t + +EXTRA_DIST += sched.in.h + +endif +## end gnulib module sched + ## begin gnulib module scratch_buffer ifeq (,$(OMIT_GNULIB_MODULE_scratch_buffer)) @@ -2491,6 +2717,69 @@ EXTRA_DIST += warn-on-use.h endif ## end gnulib module snippet/warn-on-use +## begin gnulib module spawn +ifeq (,$(OMIT_GNULIB_MODULE_spawn)) + +BUILT_SOURCES += spawn.h + +# We need the following in order to create a replacement for when +# the system doesn't have one. +spawn.h: spawn.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) + $(AM_V_GEN)rm -f $@-t $@ && \ + { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ + sed -e 's|@''GUARD_PREFIX''@|GL|g' \ + -e 's|@''HAVE_SPAWN_H''@|$(HAVE_SPAWN_H)|g' \ + -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ + -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ + -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ + -e 's|@''NEXT_SPAWN_H''@|$(NEXT_SPAWN_H)|g' \ + -e 's/@''GNULIB_POSIX_SPAWN''@/$(GNULIB_POSIX_SPAWN)/g' \ + -e 's/@''GNULIB_POSIX_SPAWNP''@/$(GNULIB_POSIX_SPAWNP)/g' \ + -e 's/@''GNULIB_POSIX_SPAWN_FILE_ACTIONS_INIT''@/$(GNULIB_POSIX_SPAWN_FILE_ACTIONS_INIT)/g' \ + -e 's/@''GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR''@/$(GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR)/g' \ + -e 's/@''GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE''@/$(GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE)/g' \ + -e 's/@''GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2''@/$(GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2)/g' \ + -e 's/@''GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR''@/$(GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR)/g' \ + -e 's/@''GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN''@/$(GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN)/g' \ + -e 's/@''GNULIB_POSIX_SPAWN_FILE_ACTIONS_DESTROY''@/$(GNULIB_POSIX_SPAWN_FILE_ACTIONS_DESTROY)/g' \ + -e 's/@''GNULIB_POSIX_SPAWNATTR_INIT''@/$(GNULIB_POSIX_SPAWNATTR_INIT)/g' \ + -e 's/@''GNULIB_POSIX_SPAWNATTR_GETFLAGS''@/$(GNULIB_POSIX_SPAWNATTR_GETFLAGS)/g' \ + -e 's/@''GNULIB_POSIX_SPAWNATTR_SETFLAGS''@/$(GNULIB_POSIX_SPAWNATTR_SETFLAGS)/g' \ + -e 's/@''GNULIB_POSIX_SPAWNATTR_GETPGROUP''@/$(GNULIB_POSIX_SPAWNATTR_GETPGROUP)/g' \ + -e 's/@''GNULIB_POSIX_SPAWNATTR_SETPGROUP''@/$(GNULIB_POSIX_SPAWNATTR_SETPGROUP)/g' \ + -e 's/@''GNULIB_POSIX_SPAWNATTR_GETSCHEDPARAM''@/$(GNULIB_POSIX_SPAWNATTR_GETSCHEDPARAM)/g' \ + -e 's/@''GNULIB_POSIX_SPAWNATTR_SETSCHEDPARAM''@/$(GNULIB_POSIX_SPAWNATTR_SETSCHEDPARAM)/g' \ + -e 's/@''GNULIB_POSIX_SPAWNATTR_GETSCHEDPOLICY''@/$(GNULIB_POSIX_SPAWNATTR_GETSCHEDPOLICY)/g' \ + -e 's/@''GNULIB_POSIX_SPAWNATTR_SETSCHEDPOLICY''@/$(GNULIB_POSIX_SPAWNATTR_SETSCHEDPOLICY)/g' \ + -e 's/@''GNULIB_POSIX_SPAWNATTR_GETSIGDEFAULT''@/$(GNULIB_POSIX_SPAWNATTR_GETSIGDEFAULT)/g' \ + -e 's/@''GNULIB_POSIX_SPAWNATTR_SETSIGDEFAULT''@/$(GNULIB_POSIX_SPAWNATTR_SETSIGDEFAULT)/g' \ + -e 's/@''GNULIB_POSIX_SPAWNATTR_GETSIGMASK''@/$(GNULIB_POSIX_SPAWNATTR_GETSIGMASK)/g' \ + -e 's/@''GNULIB_POSIX_SPAWNATTR_SETSIGMASK''@/$(GNULIB_POSIX_SPAWNATTR_SETSIGMASK)/g' \ + -e 's/@''GNULIB_POSIX_SPAWNATTR_DESTROY''@/$(GNULIB_POSIX_SPAWNATTR_DESTROY)/g' \ + -e 's|@''HAVE_POSIX_SPAWN''@|$(HAVE_POSIX_SPAWN)|g' \ + -e 's|@''HAVE_POSIX_SPAWNATTR_T''@|$(HAVE_POSIX_SPAWNATTR_T)|g' \ + -e 's|@''HAVE_POSIX_SPAWN_FILE_ACTIONS_T''@|$(HAVE_POSIX_SPAWN_FILE_ACTIONS_T)|g' \ + -e 's|@''HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR''@|$(HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR)|g' \ + -e 's|@''HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR''@|$(HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR)|g' \ + -e 's|@''REPLACE_POSIX_SPAWN''@|$(REPLACE_POSIX_SPAWN)|g' \ + -e 's|@''REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR''@|$(REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR)|g' \ + -e 's|@''REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE''@|$(REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE)|g' \ + -e 's|@''REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2''@|$(REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2)|g' \ + -e 's|@''REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR''@|$(REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR)|g' \ + -e 's|@''REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN''@|$(REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN)|g' \ + -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ + -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ + -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \ + < $(srcdir)/spawn.in.h; \ + } > $@-t && \ + mv $@-t $@ +MOSTLYCLEANFILES += spawn.h spawn.h-t + +EXTRA_DIST += spawn.in.h + +endif +## end gnulib module spawn + ## begin gnulib module stat-time ifeq (,$(OMIT_GNULIB_MODULE_stat-time)) @@ -2885,6 +3174,19 @@ EXTRA_libgnu_a_SOURCES += stpcpy.c endif ## end gnulib module stpcpy +## begin gnulib module strchrnul +ifeq (,$(OMIT_GNULIB_MODULE_strchrnul)) + +ifneq (,$(gl_GNULIB_ENABLED_strchrnul)) + +endif +EXTRA_DIST += strchrnul.c strchrnul.valgrind + +EXTRA_libgnu_a_SOURCES += strchrnul.c + +endif +## end gnulib module strchrnul + ## begin gnulib module string ifeq (,$(OMIT_GNULIB_MODULE_string)) diff --git a/lib/sched.in.h b/lib/sched.in.h new file mode 100644 index 0000000000..4ee9defe82 --- /dev/null +++ b/lib/sched.in.h @@ -0,0 +1,99 @@ +/* A GNU-like . + Copyright (C) 2008-2020 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#ifndef _@GUARD_PREFIX@_SCHED_H + +#if __GNUC__ >= 3 +@PRAGMA_SYSTEM_HEADER@ +#endif +@PRAGMA_COLUMNS@ + +/* The include_next requires a split double-inclusion guard. */ +#if @HAVE_SCHED_H@ +# if @HAVE_SYS_CDEFS_H@ +# include +# endif +# @INCLUDE_NEXT@ @NEXT_SCHED_H@ +#endif + +#ifndef _@GUARD_PREFIX@_SCHED_H +#define _@GUARD_PREFIX@_SCHED_H + +/* Get pid_t. + This is needed on glibc 2.11 (see + glibc bug ) + and Mac OS X 10.5. */ +#include + +#ifdef __KLIBC__ +/* On OS/2 kLIBC, struct sched_param is in spawn.h. */ +# include +#endif + +#ifdef __VMS +/* On OpenVMS, struct sched_param is in . */ +# include +#endif + +/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ + +/* The definition of _GL_WARN_ON_USE is copied here. */ + +#if !@HAVE_STRUCT_SCHED_PARAM@ + +# if !GNULIB_defined_struct_sched_param +struct sched_param +{ + int sched_priority; +}; +# define GNULIB_defined_struct_sched_param 1 +# endif + +#endif + +#if !(defined SCHED_FIFO && defined SCHED_RR && defined SCHED_OTHER) +# define SCHED_FIFO 1 +# define SCHED_RR 2 +# define SCHED_OTHER 0 +#endif + +#if @GNULIB_SCHED_YIELD@ +# if @REPLACE_SCHED_YIELD@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef sched_yield +# define sched_yield rpl_sched_yield +# endif +_GL_FUNCDECL_RPL (sched_yield, int, (void)); +_GL_CXXALIAS_RPL (sched_yield, int, (void)); +# else +# if !@HAVE_SCHED_YIELD@ +_GL_FUNCDECL_SYS (sched_yield, int, (void)); +# endif +_GL_CXXALIAS_SYS (sched_yield, int, (void)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (sched_yield); +# endif +#elif defined GNULIB_POSIXCHECK +# undef sched_yield +# if HAVE_RAW_DECL_SCHED_YIELD +_GL_WARN_ON_USE (sched_yield, "sched_yield is not portable - " + "use gnulib module sched_yield for portability"); +# endif +#endif + +#endif /* _@GUARD_PREFIX@_SCHED_H */ +#endif /* _@GUARD_PREFIX@_SCHED_H */ diff --git a/lib/spawn.c b/lib/spawn.c new file mode 100644 index 0000000000..b658453a10 --- /dev/null +++ b/lib/spawn.c @@ -0,0 +1,34 @@ +/* Copyright (C) 2000, 2009-2020 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include + +#include "spawn_int.h" + +/* Spawn a new process executing PATH with the attributes describes in *ATTRP. + Before running the process perform the actions described in FILE-ACTIONS. */ +int +posix_spawn (pid_t *pid, const char *path, + const posix_spawn_file_actions_t *file_actions, + const posix_spawnattr_t *attrp, char *const argv[], + char *const envp[]) +{ + return __spawni (pid, path, file_actions, attrp, + (const char * const *) argv, (const char * const *) envp, 0); +} diff --git a/lib/spawn.in.h b/lib/spawn.in.h new file mode 100644 index 0000000000..537fac7dbc --- /dev/null +++ b/lib/spawn.in.h @@ -0,0 +1,974 @@ +/* Definitions for POSIX spawn interface. + Copyright (C) 2000, 2003-2004, 2008-2020 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#ifndef _@GUARD_PREFIX@_SPAWN_H + +#if __GNUC__ >= 3 +@PRAGMA_SYSTEM_HEADER@ +#endif +@PRAGMA_COLUMNS@ + +/* The include_next requires a split double-inclusion guard. */ +#if @HAVE_SPAWN_H@ +# @INCLUDE_NEXT@ @NEXT_SPAWN_H@ +#endif + +#ifndef _@GUARD_PREFIX@_SPAWN_H +#define _@GUARD_PREFIX@_SPAWN_H + +/* Get definitions of 'struct sched_param' and 'sigset_t'. + But avoid namespace pollution on glibc systems. */ +#if !(defined __GLIBC__ && !defined __UCLIBC__) +# include +# include +#endif + +#include + +#ifndef __THROW +# define __THROW +#endif + +/* For plain 'restrict', use glibc's __restrict if defined. + Otherwise, GCC 2.95 and later have "__restrict"; C99 compilers have + "restrict", and "configure" may have defined "restrict". + Other compilers use __restrict, __restrict__, and _Restrict, and + 'configure' might #define 'restrict' to those words, so pick a + different name. */ +#ifndef _Restrict_ +# if defined __restrict \ + || 2 < __GNUC__ + (95 <= __GNUC_MINOR__) \ + || __clang_major__ >= 3 +# define _Restrict_ __restrict +# elif 199901L <= __STDC_VERSION__ || defined restrict +# define _Restrict_ restrict +# else +# define _Restrict_ +# endif +#endif +/* For the ISO C99 syntax + array_name[restrict] + use glibc's __restrict_arr if available. + Otherwise, GCC 3.1 and clang support this syntax (but not in C++ mode). + Other ISO C99 compilers support it as well. */ +#ifndef _Restrict_arr_ +# ifdef __restrict_arr +# define _Restrict_arr_ __restrict_arr +# elif ((199901L <= __STDC_VERSION__ \ + || 3 < __GNUC__ + (1 <= __GNUC_MINOR__) \ + || __clang_major__ >= 3) \ + && !defined __cplusplus) +# define _Restrict_arr_ _Restrict_ +# else +# define _Restrict_arr_ +# endif +#endif + +/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ + +/* The definition of _GL_ARG_NONNULL is copied here. */ + +/* The definition of _GL_WARN_ON_USE is copied here. */ + + +/* Data structure to contain attributes for thread creation. */ +#if @REPLACE_POSIX_SPAWN@ || (@HAVE_POSIX_SPAWNATTR_T@ && !@HAVE_POSIX_SPAWN@) +# define posix_spawnattr_t rpl_posix_spawnattr_t +#endif +#if @REPLACE_POSIX_SPAWN@ || !@HAVE_POSIX_SPAWNATTR_T@ || !@HAVE_POSIX_SPAWN@ +# if !GNULIB_defined_posix_spawnattr_t +typedef struct +{ + short int _flags; + pid_t _pgrp; + sigset_t _sd; + sigset_t _ss; + struct sched_param _sp; + int _policy; + int __pad[16]; +} posix_spawnattr_t; +# define GNULIB_defined_posix_spawnattr_t 1 +# endif +#endif + + +/* Data structure to contain information about the actions to be + performed in the new process with respect to file descriptors. */ +#if @REPLACE_POSIX_SPAWN@ || (@HAVE_POSIX_SPAWN_FILE_ACTIONS_T@ && !@HAVE_POSIX_SPAWN@) +# define posix_spawn_file_actions_t rpl_posix_spawn_file_actions_t +#endif +#if @REPLACE_POSIX_SPAWN@ || !@HAVE_POSIX_SPAWN_FILE_ACTIONS_T@ || !@HAVE_POSIX_SPAWN@ +# if !GNULIB_defined_posix_spawn_file_actions_t +typedef struct +{ + int _allocated; + int _used; + struct __spawn_action *_actions; + int __pad[16]; +} posix_spawn_file_actions_t; +# define GNULIB_defined_posix_spawn_file_actions_t 1 +# endif +#endif + + +/* Flags to be set in the 'posix_spawnattr_t'. */ +#if @HAVE_POSIX_SPAWN@ +/* Use the values from the system, but provide the missing ones. */ +# ifndef POSIX_SPAWN_SETSCHEDPARAM +# define POSIX_SPAWN_SETSCHEDPARAM 0 +# endif +# ifndef POSIX_SPAWN_SETSCHEDULER +# define POSIX_SPAWN_SETSCHEDULER 0 +# endif +#else +# if @REPLACE_POSIX_SPAWN@ +/* Use the values from the system, for better compatibility. */ +/* But this implementation does not support AIX extensions. */ +# undef POSIX_SPAWN_FORK_HANDLERS +# else +# define POSIX_SPAWN_RESETIDS 0x01 +# define POSIX_SPAWN_SETPGROUP 0x02 +# define POSIX_SPAWN_SETSIGDEF 0x04 +# define POSIX_SPAWN_SETSIGMASK 0x08 +# define POSIX_SPAWN_SETSCHEDPARAM 0x10 +# define POSIX_SPAWN_SETSCHEDULER 0x20 +# endif +#endif +/* A GNU extension. Use the next free bit position. */ +#ifndef POSIX_SPAWN_USEVFORK +# define POSIX_SPAWN_USEVFORK \ + ((POSIX_SPAWN_RESETIDS | (POSIX_SPAWN_RESETIDS - 1) \ + | POSIX_SPAWN_SETPGROUP | (POSIX_SPAWN_SETPGROUP - 1) \ + | POSIX_SPAWN_SETSIGDEF | (POSIX_SPAWN_SETSIGDEF - 1) \ + | POSIX_SPAWN_SETSIGMASK | (POSIX_SPAWN_SETSIGMASK - 1) \ + | POSIX_SPAWN_SETSCHEDPARAM \ + | (POSIX_SPAWN_SETSCHEDPARAM > 0 ? POSIX_SPAWN_SETSCHEDPARAM - 1 : 0) \ + | POSIX_SPAWN_SETSCHEDULER \ + | (POSIX_SPAWN_SETSCHEDULER > 0 ? POSIX_SPAWN_SETSCHEDULER - 1 : 0)) \ + + 1) +#endif +#if !GNULIB_defined_verify_POSIX_SPAWN_USEVFORK_no_overlap +typedef int verify_POSIX_SPAWN_USEVFORK_no_overlap + [(((POSIX_SPAWN_RESETIDS | POSIX_SPAWN_SETPGROUP + | POSIX_SPAWN_SETSIGDEF | POSIX_SPAWN_SETSIGMASK + | POSIX_SPAWN_SETSCHEDPARAM | POSIX_SPAWN_SETSCHEDULER) + & POSIX_SPAWN_USEVFORK) + == 0) + ? 1 : -1]; +# define GNULIB_defined_verify_POSIX_SPAWN_USEVFORK_no_overlap 1 +#endif + + +#if @GNULIB_POSIX_SPAWN@ +/* Spawn a new process executing PATH with the attributes describes in *ATTRP. + Before running the process perform the actions described in FILE-ACTIONS. + + This function is a possible cancellation points and therefore not + marked with __THROW. */ +# if @REPLACE_POSIX_SPAWN@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define posix_spawn rpl_posix_spawn +# endif +_GL_FUNCDECL_RPL (posix_spawn, int, + (pid_t *_Restrict_ __pid, + const char *_Restrict_ __path, + const posix_spawn_file_actions_t *_Restrict_ __file_actions, + const posix_spawnattr_t *_Restrict_ __attrp, + char *const argv[_Restrict_arr_], + char *const envp[_Restrict_arr_]) + _GL_ARG_NONNULL ((2, 5, 6))); +_GL_CXXALIAS_RPL (posix_spawn, int, + (pid_t *_Restrict_ __pid, + const char *_Restrict_ __path, + const posix_spawn_file_actions_t *_Restrict_ __file_actions, + const posix_spawnattr_t *_Restrict_ __attrp, + char *const argv[_Restrict_arr_], + char *const envp[_Restrict_arr_])); +# else +# if !@HAVE_POSIX_SPAWN@ +_GL_FUNCDECL_SYS (posix_spawn, int, + (pid_t *_Restrict_ __pid, + const char *_Restrict_ __path, + const posix_spawn_file_actions_t *_Restrict_ __file_actions, + const posix_spawnattr_t *_Restrict_ __attrp, + char *const argv[_Restrict_arr_], + char *const envp[_Restrict_arr_]) + _GL_ARG_NONNULL ((2, 5, 6))); +# endif +_GL_CXXALIAS_SYS (posix_spawn, int, + (pid_t *_Restrict_ __pid, + const char *_Restrict_ __path, + const posix_spawn_file_actions_t *_Restrict_ __file_actions, + const posix_spawnattr_t *_Restrict_ __attrp, + char *const argv[_Restrict_arr_], + char *const envp[_Restrict_arr_])); +# endif +_GL_CXXALIASWARN (posix_spawn); +#elif defined GNULIB_POSIXCHECK +# undef posix_spawn +# if HAVE_RAW_DECL_POSIX_SPAWN +_GL_WARN_ON_USE (posix_spawn, "posix_spawn is unportable - " + "use gnulib module posix_spawn for portability"); +# endif +#endif + +#if @GNULIB_POSIX_SPAWNP@ +/* Similar to 'posix_spawn' but search for FILE in the PATH. + + This function is a possible cancellation points and therefore not + marked with __THROW. */ +# if @REPLACE_POSIX_SPAWN@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define posix_spawnp rpl_posix_spawnp +# endif +_GL_FUNCDECL_RPL (posix_spawnp, int, + (pid_t *__pid, const char *__file, + const posix_spawn_file_actions_t *__file_actions, + const posix_spawnattr_t *__attrp, + char *const argv[], char *const envp[]) + _GL_ARG_NONNULL ((2, 5, 6))); +_GL_CXXALIAS_RPL (posix_spawnp, int, + (pid_t *__pid, const char *__file, + const posix_spawn_file_actions_t *__file_actions, + const posix_spawnattr_t *__attrp, + char *const argv[], char *const envp[])); +# else +# if !@HAVE_POSIX_SPAWN@ +_GL_FUNCDECL_SYS (posix_spawnp, int, + (pid_t *__pid, const char *__file, + const posix_spawn_file_actions_t *__file_actions, + const posix_spawnattr_t *__attrp, + char *const argv[], char *const envp[]) + _GL_ARG_NONNULL ((2, 5, 6))); +# endif +_GL_CXXALIAS_SYS (posix_spawnp, int, + (pid_t *__pid, const char *__file, + const posix_spawn_file_actions_t *__file_actions, + const posix_spawnattr_t *__attrp, + char *const argv[], char *const envp[])); +# endif +_GL_CXXALIASWARN (posix_spawnp); +#elif defined GNULIB_POSIXCHECK +# undef posix_spawnp +# if HAVE_RAW_DECL_POSIX_SPAWNP +_GL_WARN_ON_USE (posix_spawnp, "posix_spawnp is unportable - " + "use gnulib module posix_spawnp for portability"); +# endif +#endif + + +#if @GNULIB_POSIX_SPAWNATTR_INIT@ +/* Initialize data structure with attributes for 'spawn' to default values. */ +# if @REPLACE_POSIX_SPAWN@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define posix_spawnattr_init rpl_posix_spawnattr_init +# endif +_GL_FUNCDECL_RPL (posix_spawnattr_init, int, (posix_spawnattr_t *__attr) + __THROW _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (posix_spawnattr_init, int, (posix_spawnattr_t *__attr)); +# else +# if !@HAVE_POSIX_SPAWN@ +_GL_FUNCDECL_SYS (posix_spawnattr_init, int, (posix_spawnattr_t *__attr) + __THROW _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (posix_spawnattr_init, int, (posix_spawnattr_t *__attr)); +# endif +_GL_CXXALIASWARN (posix_spawnattr_init); +#elif defined GNULIB_POSIXCHECK +# undef posix_spawnattr_init +# if HAVE_RAW_DECL_POSIX_SPAWNATTR_INIT +_GL_WARN_ON_USE (posix_spawnattr_init, "posix_spawnattr_init is unportable - " + "use gnulib module posix_spawnattr_init for portability"); +# endif +#endif + +#if @GNULIB_POSIX_SPAWNATTR_DESTROY@ +/* Free resources associated with ATTR. */ +# if @REPLACE_POSIX_SPAWN@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define posix_spawnattr_destroy rpl_posix_spawnattr_destroy +# endif +_GL_FUNCDECL_RPL (posix_spawnattr_destroy, int, (posix_spawnattr_t *__attr) + __THROW _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (posix_spawnattr_destroy, int, (posix_spawnattr_t *__attr)); +# else +# if !@HAVE_POSIX_SPAWN@ +_GL_FUNCDECL_SYS (posix_spawnattr_destroy, int, (posix_spawnattr_t *__attr) + __THROW _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (posix_spawnattr_destroy, int, (posix_spawnattr_t *__attr)); +# endif +_GL_CXXALIASWARN (posix_spawnattr_destroy); +#elif defined GNULIB_POSIXCHECK +# undef posix_spawnattr_destroy +# if HAVE_RAW_DECL_POSIX_SPAWNATTR_DESTROY +_GL_WARN_ON_USE (posix_spawnattr_destroy, + "posix_spawnattr_destroy is unportable - " + "use gnulib module posix_spawnattr_destroy for portability"); +# endif +#endif + +#if @GNULIB_POSIX_SPAWNATTR_GETSIGDEFAULT@ +/* Store signal mask for signals with default handling from ATTR in + SIGDEFAULT. */ +# if @REPLACE_POSIX_SPAWN@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define posix_spawnattr_getsigdefault rpl_posix_spawnattr_getsigdefault +# endif +_GL_FUNCDECL_RPL (posix_spawnattr_getsigdefault, int, + (const posix_spawnattr_t *_Restrict_ __attr, + sigset_t *_Restrict_ __sigdefault) + __THROW _GL_ARG_NONNULL ((1, 2))); +_GL_CXXALIAS_RPL (posix_spawnattr_getsigdefault, int, + (const posix_spawnattr_t *_Restrict_ __attr, + sigset_t *_Restrict_ __sigdefault)); +# else +# if !@HAVE_POSIX_SPAWN@ +_GL_FUNCDECL_SYS (posix_spawnattr_getsigdefault, int, + (const posix_spawnattr_t *_Restrict_ __attr, + sigset_t *_Restrict_ __sigdefault) + __THROW _GL_ARG_NONNULL ((1, 2))); +# endif +_GL_CXXALIAS_SYS (posix_spawnattr_getsigdefault, int, + (const posix_spawnattr_t *_Restrict_ __attr, + sigset_t *_Restrict_ __sigdefault)); +# endif +_GL_CXXALIASWARN (posix_spawnattr_getsigdefault); +#elif defined GNULIB_POSIXCHECK +# undef posix_spawnattr_getsigdefault +# if HAVE_RAW_DECL_POSIX_SPAWNATTR_GETSIGDEFAULT +_GL_WARN_ON_USE (posix_spawnattr_getsigdefault, + "posix_spawnattr_getsigdefault is unportable - " + "use gnulib module posix_spawnattr_getsigdefault for portability"); +# endif +#endif + +#if @GNULIB_POSIX_SPAWNATTR_SETSIGDEFAULT@ +/* Set signal mask for signals with default handling in ATTR to SIGDEFAULT. */ +# if @REPLACE_POSIX_SPAWN@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define posix_spawnattr_setsigdefault rpl_posix_spawnattr_setsigdefault +# endif +_GL_FUNCDECL_RPL (posix_spawnattr_setsigdefault, int, + (posix_spawnattr_t *_Restrict_ __attr, + const sigset_t *_Restrict_ __sigdefault) + __THROW _GL_ARG_NONNULL ((1, 2))); +_GL_CXXALIAS_RPL (posix_spawnattr_setsigdefault, int, + (posix_spawnattr_t *_Restrict_ __attr, + const sigset_t *_Restrict_ __sigdefault)); +# else +# if !@HAVE_POSIX_SPAWN@ +_GL_FUNCDECL_SYS (posix_spawnattr_setsigdefault, int, + (posix_spawnattr_t *_Restrict_ __attr, + const sigset_t *_Restrict_ __sigdefault) + __THROW _GL_ARG_NONNULL ((1, 2))); +# endif +_GL_CXXALIAS_SYS (posix_spawnattr_setsigdefault, int, + (posix_spawnattr_t *_Restrict_ __attr, + const sigset_t *_Restrict_ __sigdefault)); +# endif +_GL_CXXALIASWARN (posix_spawnattr_setsigdefault); +#elif defined GNULIB_POSIXCHECK +# undef posix_spawnattr_setsigdefault +# if HAVE_RAW_DECL_POSIX_SPAWNATTR_SETSIGDEFAULT +_GL_WARN_ON_USE (posix_spawnattr_setsigdefault, + "posix_spawnattr_setsigdefault is unportable - " + "use gnulib module posix_spawnattr_setsigdefault for portability"); +# endif +#endif + +#if @GNULIB_POSIX_SPAWNATTR_GETSIGMASK@ +/* Store signal mask for the new process from ATTR in SIGMASK. */ +# if @REPLACE_POSIX_SPAWN@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define posix_spawnattr_getsigmask rpl_posix_spawnattr_getsigmask +# endif +_GL_FUNCDECL_RPL (posix_spawnattr_getsigmask, int, + (const posix_spawnattr_t *_Restrict_ __attr, + sigset_t *_Restrict_ __sigmask) + __THROW _GL_ARG_NONNULL ((1, 2))); +_GL_CXXALIAS_RPL (posix_spawnattr_getsigmask, int, + (const posix_spawnattr_t *_Restrict_ __attr, + sigset_t *_Restrict_ __sigmask)); +# else +# if !@HAVE_POSIX_SPAWN@ +_GL_FUNCDECL_SYS (posix_spawnattr_getsigmask, int, + (const posix_spawnattr_t *_Restrict_ __attr, + sigset_t *_Restrict_ __sigmask) + __THROW _GL_ARG_NONNULL ((1, 2))); +# endif +_GL_CXXALIAS_SYS (posix_spawnattr_getsigmask, int, + (const posix_spawnattr_t *_Restrict_ __attr, + sigset_t *_Restrict_ __sigmask)); +# endif +_GL_CXXALIASWARN (posix_spawnattr_getsigmask); +#elif defined GNULIB_POSIXCHECK +# undef posix_spawnattr_getsigmask +# if HAVE_RAW_DECL_POSIX_SPAWNATTR_GETSIGMASK +_GL_WARN_ON_USE (posix_spawnattr_getsigmask, + "posix_spawnattr_getsigmask is unportable - " + "use gnulib module posix_spawnattr_getsigmask for portability"); +# endif +#endif + +#if @GNULIB_POSIX_SPAWNATTR_SETSIGMASK@ +/* Set signal mask for the new process in ATTR to SIGMASK. */ +# if @REPLACE_POSIX_SPAWN@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define posix_spawnattr_setsigmask rpl_posix_spawnattr_setsigmask +# endif +_GL_FUNCDECL_RPL (posix_spawnattr_setsigmask, int, + (posix_spawnattr_t *_Restrict_ __attr, + const sigset_t *_Restrict_ __sigmask) + __THROW _GL_ARG_NONNULL ((1, 2))); +_GL_CXXALIAS_RPL (posix_spawnattr_setsigmask, int, + (posix_spawnattr_t *_Restrict_ __attr, + const sigset_t *_Restrict_ __sigmask)); +# else +# if !@HAVE_POSIX_SPAWN@ +_GL_FUNCDECL_SYS (posix_spawnattr_setsigmask, int, + (posix_spawnattr_t *_Restrict_ __attr, + const sigset_t *_Restrict_ __sigmask) + __THROW _GL_ARG_NONNULL ((1, 2))); +# endif +_GL_CXXALIAS_SYS (posix_spawnattr_setsigmask, int, + (posix_spawnattr_t *_Restrict_ __attr, + const sigset_t *_Restrict_ __sigmask)); +# endif +_GL_CXXALIASWARN (posix_spawnattr_setsigmask); +#elif defined GNULIB_POSIXCHECK +# undef posix_spawnattr_setsigmask +# if HAVE_RAW_DECL_POSIX_SPAWNATTR_SETSIGMASK +_GL_WARN_ON_USE (posix_spawnattr_setsigmask, + "posix_spawnattr_setsigmask is unportable - " + "use gnulib module posix_spawnattr_setsigmask for portability"); +# endif +#endif + +#if @GNULIB_POSIX_SPAWNATTR_GETFLAGS@ +/* Get flag word from the attribute structure. */ +# if @REPLACE_POSIX_SPAWN@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define posix_spawnattr_getflags rpl_posix_spawnattr_getflags +# endif +_GL_FUNCDECL_RPL (posix_spawnattr_getflags, int, + (const posix_spawnattr_t *_Restrict_ __attr, + short int *_Restrict_ __flags) + __THROW _GL_ARG_NONNULL ((1, 2))); +_GL_CXXALIAS_RPL (posix_spawnattr_getflags, int, + (const posix_spawnattr_t *_Restrict_ __attr, + short int *_Restrict_ __flags)); +# else +# if !@HAVE_POSIX_SPAWN@ +_GL_FUNCDECL_SYS (posix_spawnattr_getflags, int, + (const posix_spawnattr_t *_Restrict_ __attr, + short int *_Restrict_ __flags) + __THROW _GL_ARG_NONNULL ((1, 2))); +# endif +_GL_CXXALIAS_SYS (posix_spawnattr_getflags, int, + (const posix_spawnattr_t *_Restrict_ __attr, + short int *_Restrict_ __flags)); +# endif +_GL_CXXALIASWARN (posix_spawnattr_getflags); +#elif defined GNULIB_POSIXCHECK +# undef posix_spawnattr_getflags +# if HAVE_RAW_DECL_POSIX_SPAWNATTR_GETFLAGS +_GL_WARN_ON_USE (posix_spawnattr_getflags, + "posix_spawnattr_getflags is unportable - " + "use gnulib module posix_spawnattr_getflags for portability"); +# endif +#endif + +#if @GNULIB_POSIX_SPAWNATTR_SETFLAGS@ +/* Store flags in the attribute structure. */ +# if @REPLACE_POSIX_SPAWN@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define posix_spawnattr_setflags rpl_posix_spawnattr_setflags +# endif +_GL_FUNCDECL_RPL (posix_spawnattr_setflags, int, + (posix_spawnattr_t *__attr, short int __flags) + __THROW _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (posix_spawnattr_setflags, int, + (posix_spawnattr_t *__attr, short int __flags)); +# else +# if !@HAVE_POSIX_SPAWN@ +_GL_FUNCDECL_SYS (posix_spawnattr_setflags, int, + (posix_spawnattr_t *__attr, short int __flags) + __THROW _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (posix_spawnattr_setflags, int, + (posix_spawnattr_t *__attr, short int __flags)); +# endif +_GL_CXXALIASWARN (posix_spawnattr_setflags); +#elif defined GNULIB_POSIXCHECK +# undef posix_spawnattr_setflags +# if HAVE_RAW_DECL_POSIX_SPAWNATTR_SETFLAGS +_GL_WARN_ON_USE (posix_spawnattr_setflags, + "posix_spawnattr_setflags is unportable - " + "use gnulib module posix_spawnattr_setflags for portability"); +# endif +#endif + +#if @GNULIB_POSIX_SPAWNATTR_GETPGROUP@ +/* Get process group ID from the attribute structure. */ +# if @REPLACE_POSIX_SPAWN@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define posix_spawnattr_getpgroup rpl_posix_spawnattr_getpgroup +# endif +_GL_FUNCDECL_RPL (posix_spawnattr_getpgroup, int, + (const posix_spawnattr_t *_Restrict_ __attr, + pid_t *_Restrict_ __pgroup) + __THROW _GL_ARG_NONNULL ((1, 2))); +_GL_CXXALIAS_RPL (posix_spawnattr_getpgroup, int, + (const posix_spawnattr_t *_Restrict_ __attr, + pid_t *_Restrict_ __pgroup)); +# else +# if !@HAVE_POSIX_SPAWN@ +_GL_FUNCDECL_SYS (posix_spawnattr_getpgroup, int, + (const posix_spawnattr_t *_Restrict_ __attr, + pid_t *_Restrict_ __pgroup) + __THROW _GL_ARG_NONNULL ((1, 2))); +# endif +_GL_CXXALIAS_SYS (posix_spawnattr_getpgroup, int, + (const posix_spawnattr_t *_Restrict_ __attr, + pid_t *_Restrict_ __pgroup)); +# endif +_GL_CXXALIASWARN (posix_spawnattr_getpgroup); +#elif defined GNULIB_POSIXCHECK +# undef posix_spawnattr_getpgroup +# if HAVE_RAW_DECL_POSIX_SPAWNATTR_GETPGROUP +_GL_WARN_ON_USE (posix_spawnattr_getpgroup, + "posix_spawnattr_getpgroup is unportable - " + "use gnulib module posix_spawnattr_getpgroup for portability"); +# endif +#endif + +#if @GNULIB_POSIX_SPAWNATTR_SETPGROUP@ +/* Store process group ID in the attribute structure. */ +# if @REPLACE_POSIX_SPAWN@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define posix_spawnattr_setpgroup rpl_posix_spawnattr_setpgroup +# endif +_GL_FUNCDECL_RPL (posix_spawnattr_setpgroup, int, + (posix_spawnattr_t *__attr, pid_t __pgroup) + __THROW _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (posix_spawnattr_setpgroup, int, + (posix_spawnattr_t *__attr, pid_t __pgroup)); +# else +# if !@HAVE_POSIX_SPAWN@ +_GL_FUNCDECL_SYS (posix_spawnattr_setpgroup, int, + (posix_spawnattr_t *__attr, pid_t __pgroup) + __THROW _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (posix_spawnattr_setpgroup, int, + (posix_spawnattr_t *__attr, pid_t __pgroup)); +# endif +_GL_CXXALIASWARN (posix_spawnattr_setpgroup); +#elif defined GNULIB_POSIXCHECK +# undef posix_spawnattr_setpgroup +# if HAVE_RAW_DECL_POSIX_SPAWNATTR_SETPGROUP +_GL_WARN_ON_USE (posix_spawnattr_setpgroup, + "posix_spawnattr_setpgroup is unportable - " + "use gnulib module posix_spawnattr_setpgroup for portability"); +# endif +#endif + +#if @GNULIB_POSIX_SPAWNATTR_GETSCHEDPOLICY@ +/* Get scheduling policy from the attribute structure. */ +# if @REPLACE_POSIX_SPAWN@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define posix_spawnattr_getschedpolicy rpl_posix_spawnattr_getschedpolicy +# endif +_GL_FUNCDECL_RPL (posix_spawnattr_getschedpolicy, int, + (const posix_spawnattr_t *_Restrict_ __attr, + int *_Restrict_ __schedpolicy) + __THROW _GL_ARG_NONNULL ((1, 2))); +_GL_CXXALIAS_RPL (posix_spawnattr_getschedpolicy, int, + (const posix_spawnattr_t *_Restrict_ __attr, + int *_Restrict_ __schedpolicy)); +# else +# if !@HAVE_POSIX_SPAWN@ || POSIX_SPAWN_SETSCHEDULER == 0 +_GL_FUNCDECL_SYS (posix_spawnattr_getschedpolicy, int, + (const posix_spawnattr_t *_Restrict_ __attr, + int *_Restrict_ __schedpolicy) + __THROW _GL_ARG_NONNULL ((1, 2))); +# endif +_GL_CXXALIAS_SYS (posix_spawnattr_getschedpolicy, int, + (const posix_spawnattr_t *_Restrict_ __attr, + int *_Restrict_ __schedpolicy)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (posix_spawnattr_getschedpolicy); +# endif +#elif defined GNULIB_POSIXCHECK +# undef posix_spawnattr_getschedpolicy +# if HAVE_RAW_DECL_POSIX_SPAWNATTR_GETSCHEDPOLICY +_GL_WARN_ON_USE (posix_spawnattr_getschedpolicy, + "posix_spawnattr_getschedpolicy is unportable - " + "use gnulib module posix_spawnattr_getschedpolicy for portability"); +# endif +#endif + +#if @GNULIB_POSIX_SPAWNATTR_SETSCHEDPOLICY@ +/* Store scheduling policy in the attribute structure. */ +# if @REPLACE_POSIX_SPAWN@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define posix_spawnattr_setschedpolicy rpl_posix_spawnattr_setschedpolicy +# endif +_GL_FUNCDECL_RPL (posix_spawnattr_setschedpolicy, int, + (posix_spawnattr_t *__attr, int __schedpolicy) + __THROW _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (posix_spawnattr_setschedpolicy, int, + (posix_spawnattr_t *__attr, int __schedpolicy)); +# else +# if !@HAVE_POSIX_SPAWN@ || POSIX_SPAWN_SETSCHEDULER == 0 +_GL_FUNCDECL_SYS (posix_spawnattr_setschedpolicy, int, + (posix_spawnattr_t *__attr, int __schedpolicy) + __THROW _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (posix_spawnattr_setschedpolicy, int, + (posix_spawnattr_t *__attr, int __schedpolicy)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (posix_spawnattr_setschedpolicy); +# endif +#elif defined GNULIB_POSIXCHECK +# undef posix_spawnattr_setschedpolicy +# if HAVE_RAW_DECL_POSIX_SPAWNATTR_SETSCHEDPOLICY +_GL_WARN_ON_USE (posix_spawnattr_setschedpolicy, + "posix_spawnattr_setschedpolicy is unportable - " + "use gnulib module posix_spawnattr_setschedpolicy for portability"); +# endif +#endif + +#if @GNULIB_POSIX_SPAWNATTR_GETSCHEDPARAM@ +/* Get scheduling parameters from the attribute structure. */ +# if @REPLACE_POSIX_SPAWN@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define posix_spawnattr_getschedparam rpl_posix_spawnattr_getschedparam +# endif +_GL_FUNCDECL_RPL (posix_spawnattr_getschedparam, int, + (const posix_spawnattr_t *_Restrict_ __attr, + struct sched_param *_Restrict_ __schedparam) + __THROW _GL_ARG_NONNULL ((1, 2))); +_GL_CXXALIAS_RPL (posix_spawnattr_getschedparam, int, + (const posix_spawnattr_t *_Restrict_ __attr, + struct sched_param *_Restrict_ __schedparam)); +# else +# if !@HAVE_POSIX_SPAWN@ || POSIX_SPAWN_SETSCHEDPARAM == 0 +_GL_FUNCDECL_SYS (posix_spawnattr_getschedparam, int, + (const posix_spawnattr_t *_Restrict_ __attr, + struct sched_param *_Restrict_ __schedparam) + __THROW _GL_ARG_NONNULL ((1, 2))); +# endif +_GL_CXXALIAS_SYS (posix_spawnattr_getschedparam, int, + (const posix_spawnattr_t *_Restrict_ __attr, + struct sched_param *_Restrict_ __schedparam)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (posix_spawnattr_getschedparam); +# endif +#elif defined GNULIB_POSIXCHECK +# undef posix_spawnattr_getschedparam +# if HAVE_RAW_DECL_POSIX_SPAWNATTR_GETSCHEDPARAM +_GL_WARN_ON_USE (posix_spawnattr_getschedparam, + "posix_spawnattr_getschedparam is unportable - " + "use gnulib module posix_spawnattr_getschedparam for portability"); +# endif +#endif + +#if @GNULIB_POSIX_SPAWNATTR_SETSCHEDPARAM@ +/* Store scheduling parameters in the attribute structure. */ +# if @REPLACE_POSIX_SPAWN@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define posix_spawnattr_setschedparam rpl_posix_spawnattr_setschedparam +# endif +_GL_FUNCDECL_RPL (posix_spawnattr_setschedparam, int, + (posix_spawnattr_t *_Restrict_ __attr, + const struct sched_param *_Restrict_ __schedparam) + __THROW _GL_ARG_NONNULL ((1, 2))); +_GL_CXXALIAS_RPL (posix_spawnattr_setschedparam, int, + (posix_spawnattr_t *_Restrict_ __attr, + const struct sched_param *_Restrict_ __schedparam)); +# else +# if !@HAVE_POSIX_SPAWN@ || POSIX_SPAWN_SETSCHEDPARAM == 0 +_GL_FUNCDECL_SYS (posix_spawnattr_setschedparam, int, + (posix_spawnattr_t *_Restrict_ __attr, + const struct sched_param *_Restrict_ __schedparam) + __THROW _GL_ARG_NONNULL ((1, 2))); +# endif +_GL_CXXALIAS_SYS (posix_spawnattr_setschedparam, int, + (posix_spawnattr_t *_Restrict_ __attr, + const struct sched_param *_Restrict_ __schedparam)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (posix_spawnattr_setschedparam); +# endif +#elif defined GNULIB_POSIXCHECK +# undef posix_spawnattr_setschedparam +# if HAVE_RAW_DECL_POSIX_SPAWNATTR_SETSCHEDPARAM +_GL_WARN_ON_USE (posix_spawnattr_setschedparam, + "posix_spawnattr_setschedparam is unportable - " + "use gnulib module posix_spawnattr_setschedparam for portability"); +# endif +#endif + + +#if @GNULIB_POSIX_SPAWN_FILE_ACTIONS_INIT@ +/* Initialize data structure for file attribute for 'spawn' call. */ +# if @REPLACE_POSIX_SPAWN@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define posix_spawn_file_actions_init rpl_posix_spawn_file_actions_init +# endif +_GL_FUNCDECL_RPL (posix_spawn_file_actions_init, int, + (posix_spawn_file_actions_t *__file_actions) + __THROW _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (posix_spawn_file_actions_init, int, + (posix_spawn_file_actions_t *__file_actions)); +# else +# if !@HAVE_POSIX_SPAWN@ +_GL_FUNCDECL_SYS (posix_spawn_file_actions_init, int, + (posix_spawn_file_actions_t *__file_actions) + __THROW _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (posix_spawn_file_actions_init, int, + (posix_spawn_file_actions_t *__file_actions)); +# endif +_GL_CXXALIASWARN (posix_spawn_file_actions_init); +#elif defined GNULIB_POSIXCHECK +# undef posix_spawn_file_actions_init +# if HAVE_RAW_DECL_POSIX_SPAWN_FILE_ACTIONS_INIT +_GL_WARN_ON_USE (posix_spawn_file_actions_init, + "posix_spawn_file_actions_init is unportable - " + "use gnulib module posix_spawn_file_actions_init for portability"); +# endif +#endif + +#if @GNULIB_POSIX_SPAWN_FILE_ACTIONS_DESTROY@ +/* Free resources associated with FILE-ACTIONS. */ +# if @REPLACE_POSIX_SPAWN@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define posix_spawn_file_actions_destroy rpl_posix_spawn_file_actions_destroy +# endif +_GL_FUNCDECL_RPL (posix_spawn_file_actions_destroy, int, + (posix_spawn_file_actions_t *__file_actions) + __THROW _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (posix_spawn_file_actions_destroy, int, + (posix_spawn_file_actions_t *__file_actions)); +# else +# if !@HAVE_POSIX_SPAWN@ +_GL_FUNCDECL_SYS (posix_spawn_file_actions_destroy, int, + (posix_spawn_file_actions_t *__file_actions) + __THROW _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (posix_spawn_file_actions_destroy, int, + (posix_spawn_file_actions_t *__file_actions)); +# endif +_GL_CXXALIASWARN (posix_spawn_file_actions_destroy); +#elif defined GNULIB_POSIXCHECK +# undef posix_spawn_file_actions_destroy +# if HAVE_RAW_DECL_POSIX_SPAWN_FILE_ACTIONS_DESTROY +_GL_WARN_ON_USE (posix_spawn_file_actions_destroy, + "posix_spawn_file_actions_destroy is unportable - " + "use gnulib module posix_spawn_file_actions_destroy for portability"); +# endif +#endif + +#if @GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN@ +/* Add an action to FILE-ACTIONS which tells the implementation to call + 'open' for the given file during the 'spawn' call. */ +# if @REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define posix_spawn_file_actions_addopen rpl_posix_spawn_file_actions_addopen +# endif +_GL_FUNCDECL_RPL (posix_spawn_file_actions_addopen, int, + (posix_spawn_file_actions_t *_Restrict_ __file_actions, + int __fd, + const char *_Restrict_ __path, int __oflag, mode_t __mode) + __THROW _GL_ARG_NONNULL ((1, 3))); +_GL_CXXALIAS_RPL (posix_spawn_file_actions_addopen, int, + (posix_spawn_file_actions_t *_Restrict_ __file_actions, + int __fd, + const char *_Restrict_ __path, int __oflag, mode_t __mode)); +# else +# if !@HAVE_POSIX_SPAWN@ +_GL_FUNCDECL_SYS (posix_spawn_file_actions_addopen, int, + (posix_spawn_file_actions_t *_Restrict_ __file_actions, + int __fd, + const char *_Restrict_ __path, int __oflag, mode_t __mode) + __THROW _GL_ARG_NONNULL ((1, 3))); +# endif +_GL_CXXALIAS_SYS (posix_spawn_file_actions_addopen, int, + (posix_spawn_file_actions_t *_Restrict_ __file_actions, + int __fd, + const char *_Restrict_ __path, int __oflag, mode_t __mode)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (posix_spawn_file_actions_addopen); +# endif +#elif defined GNULIB_POSIXCHECK +# undef posix_spawn_file_actions_addopen +# if HAVE_RAW_DECL_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN +_GL_WARN_ON_USE (posix_spawn_file_actions_addopen, + "posix_spawn_file_actions_addopen is unportable - " + "use gnulib module posix_spawn_file_actions_addopen for portability"); +# endif +#endif + +#if @GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE@ +/* Add an action to FILE-ACTIONS which tells the implementation to call + 'close' for the given file descriptor during the 'spawn' call. */ +# if @REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define posix_spawn_file_actions_addclose rpl_posix_spawn_file_actions_addclose +# endif +_GL_FUNCDECL_RPL (posix_spawn_file_actions_addclose, int, + (posix_spawn_file_actions_t *__file_actions, int __fd) + __THROW _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (posix_spawn_file_actions_addclose, int, + (posix_spawn_file_actions_t *__file_actions, int __fd)); +# else +# if !@HAVE_POSIX_SPAWN@ +_GL_FUNCDECL_SYS (posix_spawn_file_actions_addclose, int, + (posix_spawn_file_actions_t *__file_actions, int __fd) + __THROW _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (posix_spawn_file_actions_addclose, int, + (posix_spawn_file_actions_t *__file_actions, int __fd)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (posix_spawn_file_actions_addclose); +# endif +#elif defined GNULIB_POSIXCHECK +# undef posix_spawn_file_actions_addclose +# if HAVE_RAW_DECL_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE +_GL_WARN_ON_USE (posix_spawn_file_actions_addclose, + "posix_spawn_file_actions_addclose is unportable - " + "use gnulib module posix_spawn_file_actions_addclose for portability"); +# endif +#endif + +#if @GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2@ +/* Add an action to FILE-ACTIONS which tells the implementation to call + 'dup2' for the given file descriptors during the 'spawn' call. */ +# if @REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define posix_spawn_file_actions_adddup2 rpl_posix_spawn_file_actions_adddup2 +# endif +_GL_FUNCDECL_RPL (posix_spawn_file_actions_adddup2, int, + (posix_spawn_file_actions_t *__file_actions, + int __fd, int __newfd) + __THROW _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (posix_spawn_file_actions_adddup2, int, + (posix_spawn_file_actions_t *__file_actions, + int __fd, int __newfd)); +# else +# if !@HAVE_POSIX_SPAWN@ +_GL_FUNCDECL_SYS (posix_spawn_file_actions_adddup2, int, + (posix_spawn_file_actions_t *__file_actions, + int __fd, int __newfd) + __THROW _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (posix_spawn_file_actions_adddup2, int, + (posix_spawn_file_actions_t *__file_actions, + int __fd, int __newfd)); +# endif +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN (posix_spawn_file_actions_adddup2); +# endif +#elif defined GNULIB_POSIXCHECK +# undef posix_spawn_file_actions_adddup2 +# if HAVE_RAW_DECL_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2 +_GL_WARN_ON_USE (posix_spawn_file_actions_adddup2, + "posix_spawn_file_actions_adddup2 is unportable - " + "use gnulib module posix_spawn_file_actions_adddup2 for portability"); +# endif +#endif + +#if @GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR@ +/* Add an action to FILE-ACTIONS which tells the implementation to call + 'chdir' to the given directory during the 'spawn' call. */ +# if @REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define posix_spawn_file_actions_addchdir rpl_posix_spawn_file_actions_addchdir +# endif +_GL_FUNCDECL_RPL (posix_spawn_file_actions_addchdir, int, + (posix_spawn_file_actions_t *_Restrict_ __file_actions, + const char *_Restrict_ __path) + __THROW _GL_ARG_NONNULL ((1, 2))); +_GL_CXXALIAS_RPL (posix_spawn_file_actions_addchdir, int, + (posix_spawn_file_actions_t *_Restrict_ __file_actions, + const char *_Restrict_ __path)); +# else +# if !@HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR@ +_GL_FUNCDECL_SYS (posix_spawn_file_actions_addchdir, int, + (posix_spawn_file_actions_t *_Restrict_ __file_actions, + const char *_Restrict_ __path) + __THROW _GL_ARG_NONNULL ((1, 2))); +# endif +_GL_CXXALIAS_SYS (posix_spawn_file_actions_addchdir, int, + (posix_spawn_file_actions_t *_Restrict_ __file_actions, + const char *_Restrict_ __path)); +# endif +_GL_CXXALIASWARN (posix_spawn_file_actions_addchdir); +#elif defined GNULIB_POSIXCHECK +# undef posix_spawn_file_actions_addchdir +# if HAVE_RAW_DECL_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR +_GL_WARN_ON_USE (posix_spawn_file_actions_addchdir, + "posix_spawn_file_actions_addchdir is unportable - " + "use gnulib module posix_spawn_file_actions_addchdir for portability"); +# endif +#endif + +#if @GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR@ +/* Add an action to FILE-ACTIONS which tells the implementation to call + 'fchdir' to the given directory during the 'spawn' call. */ +# if @REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define posix_spawn_file_actions_addfchdir rpl_posix_spawn_file_actions_addfchdir +# endif +_GL_FUNCDECL_RPL (posix_spawn_file_actions_addfchdir, int, + (posix_spawn_file_actions_t *_Restrict_ __file_actions, + int __fd) + __THROW _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (posix_spawn_file_actions_addfchdir, int, + (posix_spawn_file_actions_t *_Restrict_ __file_actions, + int __fd)); +# else +# if !@HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR@ +_GL_FUNCDECL_SYS (posix_spawn_file_actions_addfchdir, int, + (posix_spawn_file_actions_t *_Restrict_ __file_actions, + int __fd) + __THROW _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (posix_spawn_file_actions_addfchdir, int, + (posix_spawn_file_actions_t *_Restrict_ __file_actions, + int __fd)); +# endif +_GL_CXXALIASWARN (posix_spawn_file_actions_addfchdir); +#elif defined GNULIB_POSIXCHECK +# undef posix_spawn_file_actions_addfchdir +# if HAVE_RAW_DECL_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR +_GL_WARN_ON_USE (posix_spawn_file_actions_addfchdir, + "posix_spawn_file_actions_addfchdir is unportable - " + "use gnulib module posix_spawn_file_actions_addfchdir for portability"); +# endif +#endif + + +#endif /* _@GUARD_PREFIX@_SPAWN_H */ +#endif /* _@GUARD_PREFIX@_SPAWN_H */ diff --git a/lib/spawn_faction_addchdir.c b/lib/spawn_faction_addchdir.c new file mode 100644 index 0000000000..8fb6cb0f7d --- /dev/null +++ b/lib/spawn_faction_addchdir.c @@ -0,0 +1,70 @@ +/* Copyright (C) 2018-2020 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include + +#include +#include +#include + +#if REPLACE_POSIX_SPAWN +# include "spawn_int.h" +#endif + +/* Add an action to FILE-ACTIONS which tells the implementation to call + 'chdir' to the given directory during the 'spawn' call. */ +int +posix_spawn_file_actions_addchdir (posix_spawn_file_actions_t *file_actions, + const char *path) +#undef posix_spawn_file_actions_addchdir +{ +#if !REPLACE_POSIX_SPAWN + return posix_spawn_file_actions_addchdir_np (file_actions, path); +#else + { + /* Copy PATH, because the caller may free it before calling posix_spawn() + or posix_spawnp(). */ + char *path_copy = strdup (path); + if (path_copy == NULL) + return ENOMEM; + + /* Allocate more memory if needed. */ + if (file_actions->_used == file_actions->_allocated + && __posix_spawn_file_actions_realloc (file_actions) != 0) + { + /* This can only mean we ran out of memory. */ + free (path_copy); + return ENOMEM; + } + + { + struct __spawn_action *rec; + + /* Add the new value. */ + rec = &file_actions->_actions[file_actions->_used]; + rec->tag = spawn_do_chdir; + rec->action.chdir_action.path = path_copy; + + /* Account for the new entry. */ + ++file_actions->_used; + + return 0; + } + } +#endif +} diff --git a/lib/spawn_faction_adddup2.c b/lib/spawn_faction_adddup2.c new file mode 100644 index 0000000000..c00b0b4966 --- /dev/null +++ b/lib/spawn_faction_adddup2.c @@ -0,0 +1,70 @@ +/* Copyright (C) 2000, 2009-2020 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include + +#include +#include + +#if !_LIBC +# define __sysconf(open_max) getdtablesize () +#endif + +#if REPLACE_POSIX_SPAWN +# include "spawn_int.h" +#endif + +/* Add an action to FILE-ACTIONS which tells the implementation to call + 'dup2' for the given file descriptors during the 'spawn' call. */ +int +posix_spawn_file_actions_adddup2 (posix_spawn_file_actions_t *file_actions, + int fd, int newfd) +#undef posix_spawn_file_actions_adddup2 +{ + int maxfd = __sysconf (_SC_OPEN_MAX); + + /* Test for the validity of the file descriptor. */ + if (fd < 0 || newfd < 0 || fd >= maxfd || newfd >= maxfd) + return EBADF; + +#if !REPLACE_POSIX_SPAWN + return posix_spawn_file_actions_adddup2 (file_actions, fd, newfd); +#else + /* Allocate more memory if needed. */ + if (file_actions->_used == file_actions->_allocated + && __posix_spawn_file_actions_realloc (file_actions) != 0) + /* This can only mean we ran out of memory. */ + return ENOMEM; + + { + struct __spawn_action *rec; + + /* Add the new value. */ + rec = &file_actions->_actions[file_actions->_used]; + rec->tag = spawn_do_dup2; + rec->action.dup2_action.fd = fd; + rec->action.dup2_action.newfd = newfd; + + /* Account for the new entry. */ + ++file_actions->_used; + + return 0; + } +#endif +} diff --git a/lib/spawn_faction_destroy.c b/lib/spawn_faction_destroy.c new file mode 100644 index 0000000000..e9985f4a0d --- /dev/null +++ b/lib/spawn_faction_destroy.c @@ -0,0 +1,61 @@ +/* Copyright (C) 2000, 2009-2020 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include + +#include + +#if REPLACE_POSIX_SPAWN +# include "spawn_int.h" +#endif + +/* Initialize data structure for file attribute for 'spawn' call. */ +int +posix_spawn_file_actions_destroy (posix_spawn_file_actions_t *file_actions) +#undef posix_spawn_file_actions_destroy +{ +#if !REPLACE_POSIX_SPAWN + return posix_spawn_file_actions_destroy (file_actions); +#else + int i; + + /* Free the paths in the open actions. */ + for (i = 0; i < file_actions->_used; ++i) + { + struct __spawn_action *sa = &file_actions->_actions[i]; + switch (sa->tag) + { + case spawn_do_open: + free (sa->action.open_action.path); + break; + case spawn_do_chdir: + free (sa->action.chdir_action.path); + break; + default: + /* No cleanup required. */ + break; + } + } + + /* Free the array of actions. */ + free (file_actions->_actions); + + return 0; +#endif +} diff --git a/lib/spawn_faction_init.c b/lib/spawn_faction_init.c new file mode 100644 index 0000000000..135605fb8c --- /dev/null +++ b/lib/spawn_faction_init.c @@ -0,0 +1,56 @@ +/* Copyright (C) 2000, 2009-2020 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include + +#include +#include +#include + +#include "spawn_int.h" + + +/* Function used to increase the size of the allocated array. This + function is called from the 'add'-functions. */ +int +__posix_spawn_file_actions_realloc (posix_spawn_file_actions_t *file_actions) +{ + int newalloc = file_actions->_allocated + 8; + void *newmem = realloc (file_actions->_actions, + newalloc * sizeof (struct __spawn_action)); + + if (newmem == NULL) + /* Not enough memory. */ + return ENOMEM; + + file_actions->_actions = (struct __spawn_action *) newmem; + file_actions->_allocated = newalloc; + + return 0; +} + + +/* Initialize data structure for file attribute for 'spawn' call. */ +int +posix_spawn_file_actions_init (posix_spawn_file_actions_t *file_actions) +{ + /* Simply clear all the elements. */ + memset (file_actions, '\0', sizeof (*file_actions)); + return 0; +} diff --git a/lib/spawn_int.h b/lib/spawn_int.h new file mode 100644 index 0000000000..60a94ddd55 --- /dev/null +++ b/lib/spawn_int.h @@ -0,0 +1,72 @@ +/* Copyright (C) 2000, 2008-2020 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#include + +/* Data structure to contain the action information. */ +struct __spawn_action +{ + enum + { + spawn_do_close, + spawn_do_dup2, + spawn_do_open, + spawn_do_chdir, + spawn_do_fchdir + } tag; + + union + { + struct + { + int fd; + } close_action; + struct + { + int fd; + int newfd; + } dup2_action; + struct + { + int fd; + char *path; + int oflag; + mode_t mode; + } open_action; + struct + { + char *path; + } chdir_action; + struct + { + int fd; + } fchdir_action; + } action; +}; + +#if !_LIBC +# define __posix_spawn_file_actions_realloc gl_posix_spawn_file_actions_realloc +#endif +extern int __posix_spawn_file_actions_realloc (posix_spawn_file_actions_t * + file_actions); + +#if !_LIBC +# define __spawni gl_posix_spawn_internal +#endif +extern int __spawni (pid_t *pid, const char *path, + const posix_spawn_file_actions_t *file_actions, + const posix_spawnattr_t *attrp, const char *const argv[], + const char *const envp[], int use_path); diff --git a/lib/spawnattr_destroy.c b/lib/spawnattr_destroy.c new file mode 100644 index 0000000000..22a7d5a61a --- /dev/null +++ b/lib/spawnattr_destroy.c @@ -0,0 +1,28 @@ +/* Copyright (C) 2000, 2009-2020 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include + +/* Initialize data structure for file attribute for 'spawn' call. */ +int +posix_spawnattr_destroy (posix_spawnattr_t *attr) +{ + /* Nothing to do in the moment. */ + return 0; +} diff --git a/lib/spawnattr_init.c b/lib/spawnattr_init.c new file mode 100644 index 0000000000..99674488f8 --- /dev/null +++ b/lib/spawnattr_init.c @@ -0,0 +1,33 @@ +/* Copyright (C) 2000, 2009-2020 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include + +#include + +/* Initialize data structure for file attribute for 'spawn' call. */ +int +posix_spawnattr_init (posix_spawnattr_t *attr) +{ + /* All elements have to be initialized to the default values which + is generally zero. */ + memset (attr, '\0', sizeof (*attr)); + + return 0; +} diff --git a/lib/spawnattr_setdefault.c b/lib/spawnattr_setdefault.c new file mode 100644 index 0000000000..01c29e9484 --- /dev/null +++ b/lib/spawnattr_setdefault.c @@ -0,0 +1,33 @@ +/* Copyright (C) 2000, 2009-2020 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include + +#include + +/* Set signal mask for signals with default handling in ATTR to SIGDEFAULT. */ +int +posix_spawnattr_setsigdefault (posix_spawnattr_t *attr, + const sigset_t *sigdefault) +{ + /* Copy the sigset_t data to the user buffer. */ + memcpy (&attr->_sd, sigdefault, sizeof (sigset_t)); + + return 0; +} diff --git a/lib/spawnattr_setflags.c b/lib/spawnattr_setflags.c new file mode 100644 index 0000000000..084d5bcea4 --- /dev/null +++ b/lib/spawnattr_setflags.c @@ -0,0 +1,45 @@ +/* Copyright (C) 2000, 2004, 2009-2020 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include + +#include +#include + +#define ALL_FLAGS (POSIX_SPAWN_RESETIDS \ + | POSIX_SPAWN_SETPGROUP \ + | POSIX_SPAWN_SETSIGDEF \ + | POSIX_SPAWN_SETSIGMASK \ + | POSIX_SPAWN_SETSCHEDPARAM \ + | POSIX_SPAWN_SETSCHEDULER \ + | POSIX_SPAWN_USEVFORK) + +/* Store flags in the attribute structure. */ +int +posix_spawnattr_setflags (posix_spawnattr_t *attr, short int flags) +{ + /* Check no invalid bits are set. */ + if (flags & ~ALL_FLAGS) + return EINVAL; + + /* Store the flag word. */ + attr->_flags = flags; + + return 0; +} diff --git a/lib/spawnattr_setpgroup.c b/lib/spawnattr_setpgroup.c new file mode 100644 index 0000000000..479457ad23 --- /dev/null +++ b/lib/spawnattr_setpgroup.c @@ -0,0 +1,32 @@ +/* Copyright (C) 2000, 2009-2020 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include + +#include + +/* Store process group ID in the attribute structure. */ +int +posix_spawnattr_setpgroup (posix_spawnattr_t *attr, pid_t pgroup) +{ + /* Store the process group ID. */ + attr->_pgrp = pgroup; + + return 0; +} diff --git a/lib/spawnattr_setsigmask.c b/lib/spawnattr_setsigmask.c new file mode 100644 index 0000000000..9b6f9ece38 --- /dev/null +++ b/lib/spawnattr_setsigmask.c @@ -0,0 +1,33 @@ +/* Copyright (C) 2000, 2009-2020 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include + +#include + +/* Set signal mask for the new process in ATTR to SIGMASK. */ +int +posix_spawnattr_setsigmask (posix_spawnattr_t *attr, + const sigset_t *sigmask) +{ + /* Copy the sigset_t data to the user buffer. */ + memcpy (&attr->_ss, sigmask, sizeof (sigset_t)); + + return 0; +} diff --git a/lib/spawni.c b/lib/spawni.c new file mode 100644 index 0000000000..182d13ff24 --- /dev/null +++ b/lib/spawni.c @@ -0,0 +1,349 @@ +/* Guts of POSIX spawn interface. Generic POSIX.1 version. + Copyright (C) 2000-2006, 2008-2020 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include +#include "spawn_int.h" + +#include +#include + +#include +#ifndef O_LARGEFILE +# define O_LARGEFILE 0 +#endif + +#if _LIBC || HAVE_PATHS_H +# include +#else +# define _PATH_BSHELL BOURNE_SHELL +#endif + +#include +#include +#include +#include + +#if _LIBC +# include +#else +# define close_not_cancel close +# define open_not_cancel open +#endif + +#if _LIBC +# include +#else +# if !HAVE_SETEUID +# define seteuid(id) setresuid (-1, id, -1) +# endif +# if !HAVE_SETEGID +# define setegid(id) setresgid (-1, id, -1) +# endif +# define local_seteuid(id) seteuid (id) +# define local_setegid(id) setegid (id) +#endif + +#if _LIBC +# define alloca __alloca +# define execve __execve +# define dup2 __dup2 +# define fork __fork +# define getgid __getgid +# define getuid __getuid +# define sched_setparam __sched_setparam +# define sched_setscheduler __sched_setscheduler +# define setpgid __setpgid +# define sigaction __sigaction +# define sigismember __sigismember +# define sigprocmask __sigprocmask +# define strchrnul __strchrnul +# define vfork __vfork +#endif + + +/* The Unix standard contains a long explanation of the way to signal + an error after the fork() was successful. Since no new wait status + was wanted there is no way to signal an error using one of the + available methods. The committee chose to signal an error by a + normal program exit with the exit code 127. */ +#define SPAWN_ERROR 127 + + +#if defined _WIN32 && ! defined __CYGWIN__ + +/* Native Windows API. */ +int +__spawni (pid_t *pid, const char *file, + const posix_spawn_file_actions_t *file_actions, + const posix_spawnattr_t *attrp, const char *const argv[], + const char *const envp[], int use_path) +{ + /* Not yet implemented. */ + return ENOSYS; +} + +#else + + +/* Spawn a new process executing PATH with the attributes describes in *ATTRP. + Before running the process perform the actions described in FILE-ACTIONS. */ +int +__spawni (pid_t *pid, const char *file, + const posix_spawn_file_actions_t *file_actions, + const posix_spawnattr_t *attrp, const char *const argv[], + const char *const envp[], int use_path) +{ + pid_t new_pid; + char *path, *p, *name; + size_t len; + size_t pathlen; + + /* Do this once. */ + short int flags = attrp == NULL ? 0 : attrp->_flags; + + /* Avoid gcc warning + "variable 'flags' might be clobbered by 'longjmp' or 'vfork'" */ + (void) &flags; + + /* Generate the new process. */ +#if HAVE_VFORK + if ((flags & POSIX_SPAWN_USEVFORK) != 0 + /* If no major work is done, allow using vfork. Note that we + might perform the path searching. But this would be done by + a call to execvp(), too, and such a call must be OK according + to POSIX. */ + || ((flags & (POSIX_SPAWN_SETSIGMASK | POSIX_SPAWN_SETSIGDEF + | POSIX_SPAWN_SETSCHEDPARAM | POSIX_SPAWN_SETSCHEDULER + | POSIX_SPAWN_SETPGROUP | POSIX_SPAWN_RESETIDS)) == 0 + && file_actions == NULL)) + new_pid = vfork (); + else +#endif + new_pid = fork (); + + if (new_pid != 0) + { + if (new_pid < 0) + return errno; + + /* The call was successful. Store the PID if necessary. */ + if (pid != NULL) + *pid = new_pid; + + return 0; + } + + /* Set signal mask. */ + if ((flags & POSIX_SPAWN_SETSIGMASK) != 0 + && sigprocmask (SIG_SETMASK, &attrp->_ss, NULL) != 0) + _exit (SPAWN_ERROR); + + /* Set signal default action. */ + if ((flags & POSIX_SPAWN_SETSIGDEF) != 0) + { + /* We have to iterate over all signals. This could possibly be + done better but it requires system specific solutions since + the sigset_t data type can be very different on different + architectures. */ + int sig; + struct sigaction sa; + + memset (&sa, '\0', sizeof (sa)); + sa.sa_handler = SIG_DFL; + + for (sig = 1; sig <= NSIG; ++sig) + if (sigismember (&attrp->_sd, sig) != 0 + && sigaction (sig, &sa, NULL) != 0) + _exit (SPAWN_ERROR); + + } + +#if (_LIBC ? defined _POSIX_PRIORITY_SCHEDULING : HAVE_SCHED_SETPARAM && HAVE_SCHED_SETSCHEDULER) + /* Set the scheduling algorithm and parameters. */ + if ((flags & (POSIX_SPAWN_SETSCHEDPARAM | POSIX_SPAWN_SETSCHEDULER)) + == POSIX_SPAWN_SETSCHEDPARAM) + { + if (sched_setparam (0, &attrp->_sp) == -1) + _exit (SPAWN_ERROR); + } + else if ((flags & POSIX_SPAWN_SETSCHEDULER) != 0) + { + if (sched_setscheduler (0, attrp->_policy, + (flags & POSIX_SPAWN_SETSCHEDPARAM) != 0 + ? &attrp->_sp : NULL) == -1) + _exit (SPAWN_ERROR); + } +#endif + + /* Set the process group ID. */ + if ((flags & POSIX_SPAWN_SETPGROUP) != 0 + && setpgid (0, attrp->_pgrp) != 0) + _exit (SPAWN_ERROR); + + /* Set the effective user and group IDs. */ + if ((flags & POSIX_SPAWN_RESETIDS) != 0 + && (local_seteuid (getuid ()) != 0 + || local_setegid (getgid ()) != 0)) + _exit (SPAWN_ERROR); + + /* Execute the file actions. */ + if (file_actions != NULL) + { + int cnt; + + for (cnt = 0; cnt < file_actions->_used; ++cnt) + { + struct __spawn_action *action = &file_actions->_actions[cnt]; + + switch (action->tag) + { + case spawn_do_close: + if (close_not_cancel (action->action.close_action.fd) != 0) + /* Signal the error. */ + _exit (SPAWN_ERROR); + break; + + case spawn_do_open: + { + int new_fd = open_not_cancel (action->action.open_action.path, + action->action.open_action.oflag + | O_LARGEFILE, + action->action.open_action.mode); + + if (new_fd == -1) + /* The 'open' call failed. */ + _exit (SPAWN_ERROR); + + /* Make sure the desired file descriptor is used. */ + if (new_fd != action->action.open_action.fd) + { + if (dup2 (new_fd, action->action.open_action.fd) + != action->action.open_action.fd) + /* The 'dup2' call failed. */ + _exit (SPAWN_ERROR); + + if (close_not_cancel (new_fd) != 0) + /* The 'close' call failed. */ + _exit (SPAWN_ERROR); + } + } + break; + + case spawn_do_dup2: + if (dup2 (action->action.dup2_action.fd, + action->action.dup2_action.newfd) + != action->action.dup2_action.newfd) + /* The 'dup2' call failed. */ + _exit (SPAWN_ERROR); + break; + + case spawn_do_chdir: + if (chdir (action->action.chdir_action.path) < 0) + /* The 'chdir' call failed. */ + _exit (SPAWN_ERROR); + break; + + case spawn_do_fchdir: + if (fchdir (action->action.fchdir_action.fd) < 0) + /* The 'fchdir' call failed. */ + _exit (SPAWN_ERROR); + break; + } + } + } + + if (! use_path || strchr (file, '/') != NULL) + { + /* The FILE parameter is actually a path. */ + execve (file, (char * const *) argv, (char * const *) envp); + + /* Oh, oh. 'execve' returns. This is bad. */ + _exit (SPAWN_ERROR); + } + + /* We have to search for FILE on the path. */ + path = getenv ("PATH"); + if (path == NULL) + { +#if HAVE_CONFSTR + /* There is no 'PATH' in the environment. + The default search path is the current directory + followed by the path 'confstr' returns for '_CS_PATH'. */ + len = confstr (_CS_PATH, (char *) NULL, 0); + path = (char *) alloca (1 + len); + path[0] = ':'; + (void) confstr (_CS_PATH, path + 1, len); +#else + /* Pretend that the PATH contains only the current directory. */ + path = ""; +#endif + } + + len = strlen (file) + 1; + pathlen = strlen (path); + name = alloca (pathlen + len + 1); + /* Copy the file name at the top. */ + name = (char *) memcpy (name + pathlen + 1, file, len); + /* And add the slash. */ + *--name = '/'; + + p = path; + do + { + char *startp; + + path = p; + p = strchrnul (path, ':'); + + if (p == path) + /* Two adjacent colons, or a colon at the beginning or the end + of 'PATH' means to search the current directory. */ + startp = name + 1; + else + startp = (char *) memcpy (name - (p - path), path, p - path); + + /* Try to execute this name. If it works, execv will not return. */ + execve (startp, (char * const *) argv, (char * const *) envp); + + switch (errno) + { + case EACCES: + case ENOENT: + case ESTALE: + case ENOTDIR: + /* Those errors indicate the file is missing or not executable + by us, in which case we want to just try the next path + directory. */ + break; + + default: + /* Some other error means we found an executable file, but + something went wrong executing it; return the error to our + caller. */ + _exit (SPAWN_ERROR); + } + } + while (*p++ != '\0'); + + /* Return with an error. */ + _exit (SPAWN_ERROR); +} + +#endif diff --git a/lib/strchrnul.c b/lib/strchrnul.c new file mode 100644 index 0000000000..858d66fab1 --- /dev/null +++ b/lib/strchrnul.c @@ -0,0 +1,142 @@ +/* Searching in a string. + Copyright (C) 2003, 2007-2020 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include + +/* Find the first occurrence of C in S or the final NUL byte. */ +char * +strchrnul (const char *s, int c_in) +{ + /* On 32-bit hardware, choosing longword to be a 32-bit unsigned + long instead of a 64-bit uintmax_t tends to give better + performance. On 64-bit hardware, unsigned long is generally 64 + bits already. Change this typedef to experiment with + performance. */ + typedef unsigned long int longword; + + const unsigned char *char_ptr; + const longword *longword_ptr; + longword repeated_one; + longword repeated_c; + unsigned char c; + + c = (unsigned char) c_in; + if (!c) + return rawmemchr (s, 0); + + /* Handle the first few bytes by reading one byte at a time. + Do this until CHAR_PTR is aligned on a longword boundary. */ + for (char_ptr = (const unsigned char *) s; + (size_t) char_ptr % sizeof (longword) != 0; + ++char_ptr) + if (!*char_ptr || *char_ptr == c) + return (char *) char_ptr; + + longword_ptr = (const longword *) char_ptr; + + /* All these elucidatory comments refer to 4-byte longwords, + but the theory applies equally well to any size longwords. */ + + /* Compute auxiliary longword values: + repeated_one is a value which has a 1 in every byte. + repeated_c has c in every byte. */ + repeated_one = 0x01010101; + repeated_c = c | (c << 8); + repeated_c |= repeated_c << 16; + if (0xffffffffU < (longword) -1) + { + repeated_one |= repeated_one << 31 << 1; + repeated_c |= repeated_c << 31 << 1; + if (8 < sizeof (longword)) + { + size_t i; + + for (i = 64; i < sizeof (longword) * 8; i *= 2) + { + repeated_one |= repeated_one << i; + repeated_c |= repeated_c << i; + } + } + } + + /* Instead of the traditional loop which tests each byte, we will + test a longword at a time. The tricky part is testing if *any of + the four* bytes in the longword in question are equal to NUL or + c. We first use an xor with repeated_c. This reduces the task + to testing whether *any of the four* bytes in longword1 or + longword2 is zero. + + Let's consider longword1. We compute tmp = + ((longword1 - repeated_one) & ~longword1) & (repeated_one << 7). + That is, we perform the following operations: + 1. Subtract repeated_one. + 2. & ~longword1. + 3. & a mask consisting of 0x80 in every byte. + Consider what happens in each byte: + - If a byte of longword1 is zero, step 1 and 2 transform it into 0xff, + and step 3 transforms it into 0x80. A carry can also be propagated + to more significant bytes. + - If a byte of longword1 is nonzero, let its lowest 1 bit be at + position k (0 <= k <= 7); so the lowest k bits are 0. After step 1, + the byte ends in a single bit of value 0 and k bits of value 1. + After step 2, the result is just k bits of value 1: 2^k - 1. After + step 3, the result is 0. And no carry is produced. + So, if longword1 has only non-zero bytes, tmp is zero. + Whereas if longword1 has a zero byte, call j the position of the least + significant zero byte. Then the result has a zero at positions 0, ..., + j-1 and a 0x80 at position j. We cannot predict the result at the more + significant bytes (positions j+1..3), but it does not matter since we + already have a non-zero bit at position 8*j+7. + + The test whether any byte in longword1 or longword2 is zero is equivalent + to testing whether tmp1 is nonzero or tmp2 is nonzero. We can combine + this into a single test, whether (tmp1 | tmp2) is nonzero. + + This test can read more than one byte beyond the end of a string, + depending on where the terminating NUL is encountered. However, + this is considered safe since the initialization phase ensured + that the read will be aligned, therefore, the read will not cross + page boundaries and will not cause a fault. */ + + while (1) + { + longword longword1 = *longword_ptr ^ repeated_c; + longword longword2 = *longword_ptr; + + if (((((longword1 - repeated_one) & ~longword1) + | ((longword2 - repeated_one) & ~longword2)) + & (repeated_one << 7)) != 0) + break; + longword_ptr++; + } + + char_ptr = (const unsigned char *) longword_ptr; + + /* At this point, we know that one of the sizeof (longword) bytes + starting at char_ptr is == 0 or == c. On little-endian machines, + we could determine the first such byte without any further memory + accesses, just by looking at the tmp result from the last loop + iteration. But this does not work on big-endian machines. + Choose code that works in both cases. */ + + char_ptr = (unsigned char *) longword_ptr; + while (*char_ptr && (*char_ptr != c)) + char_ptr++; + return (char *) char_ptr; +} diff --git a/lib/strchrnul.valgrind b/lib/strchrnul.valgrind new file mode 100644 index 0000000000..a85608a7c7 --- /dev/null +++ b/lib/strchrnul.valgrind @@ -0,0 +1,28 @@ +# Suppress a valgrind message about use of uninitialized memory in strchrnul(). + +# Copyright (C) 2008-2020 Free Software Foundation, Inc. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# This use is OK because it provides only a speedup. +{ + strchrnul-value4 + Memcheck:Value4 + fun:strchrnul +} +{ + strchrnul-value8 + Memcheck:Value8 + fun:strchrnul +} diff --git a/m4/gnulib-comp.m4 b/m4/gnulib-comp.m4 index 0971636c33..e2a44efe62 100644 --- a/m4/gnulib-comp.m4 +++ b/m4/gnulib-comp.m4 @@ -139,6 +139,18 @@ AC_DEFUN([gl_EARLY], # Code from module openat-h: # Code from module pathmax: # Code from module pipe2: + # Code from module posix_spawn: + # Code from module posix_spawn-internal: + # Code from module posix_spawn_file_actions_addchdir: + # Code from module posix_spawn_file_actions_adddup2: + # Code from module posix_spawn_file_actions_destroy: + # Code from module posix_spawn_file_actions_init: + # Code from module posix_spawnattr_destroy: + # Code from module posix_spawnattr_init: + # Code from module posix_spawnattr_setflags: + # Code from module posix_spawnattr_setpgroup: + # Code from module posix_spawnattr_setsigdefault: + # Code from module posix_spawnattr_setsigmask: # Code from module pselect: # Code from module pthread_sigmask: # Code from module qcopy-acl: @@ -147,7 +159,9 @@ AC_DEFUN([gl_EARLY], # Code from module readlinkat: # Code from module regex: # Code from module root-uid: + # Code from module sched: # Code from module scratch_buffer: + # Code from module sh-filename: # Code from module sig2str: # Code from module sigdescr_np: # Code from module signal-h: @@ -156,6 +170,7 @@ AC_DEFUN([gl_EARLY], # Code from module snippet/c++defs: # Code from module snippet/warn-on-use: # Code from module socklen: + # Code from module spawn: # Code from module ssize_t: # Code from module stat-time: # Code from module std-gnu11: @@ -165,6 +180,7 @@ AC_DEFUN([gl_EARLY], # Code from module stdio: # Code from module stdlib: # Code from module stpcpy: + # Code from module strchrnul: # Code from module string: # Code from module strnlen: # Code from module strtoimax: @@ -403,6 +419,61 @@ AC_DEFUN([gl_INIT], gl_PATHMAX gl_FUNC_PIPE2 gl_UNISTD_MODULE_INDICATOR([pipe2]) + gl_POSIX_SPAWN + if test $HAVE_POSIX_SPAWN = 0 || test $REPLACE_POSIX_SPAWN = 1; then + AC_LIBOBJ([spawn]) + fi + gl_SPAWN_MODULE_INDICATOR([posix_spawn]) + gl_FUNC_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR + if test $HAVE_POSIX_SPAWN = 0 || test $REPLACE_POSIX_SPAWN = 1 || test $HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR = 0 || test $REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR = 1; then + AC_LIBOBJ([spawn_faction_addchdir]) + fi + gl_SPAWN_MODULE_INDICATOR([posix_spawn_file_actions_addchdir]) + gl_FUNC_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2 + if test $HAVE_POSIX_SPAWN = 0 || test $REPLACE_POSIX_SPAWN = 1 || test $REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2 = 1; then + AC_LIBOBJ([spawn_faction_adddup2]) + fi + gl_SPAWN_MODULE_INDICATOR([posix_spawn_file_actions_adddup2]) + gl_POSIX_SPAWN + if test $HAVE_POSIX_SPAWN = 0 || test $REPLACE_POSIX_SPAWN = 1; then + AC_LIBOBJ([spawn_faction_destroy]) + fi + gl_SPAWN_MODULE_INDICATOR([posix_spawn_file_actions_destroy]) + gl_POSIX_SPAWN + if test $HAVE_POSIX_SPAWN = 0 || test $REPLACE_POSIX_SPAWN = 1; then + AC_LIBOBJ([spawn_faction_init]) + fi + gl_SPAWN_MODULE_INDICATOR([posix_spawn_file_actions_init]) + gl_POSIX_SPAWN + if test $HAVE_POSIX_SPAWN = 0 || test $REPLACE_POSIX_SPAWN = 1; then + AC_LIBOBJ([spawnattr_destroy]) + fi + gl_SPAWN_MODULE_INDICATOR([posix_spawnattr_destroy]) + gl_POSIX_SPAWN + if test $HAVE_POSIX_SPAWN = 0 || test $REPLACE_POSIX_SPAWN = 1; then + AC_LIBOBJ([spawnattr_init]) + fi + gl_SPAWN_MODULE_INDICATOR([posix_spawnattr_init]) + gl_POSIX_SPAWN + if test $HAVE_POSIX_SPAWN = 0 || test $REPLACE_POSIX_SPAWN = 1; then + AC_LIBOBJ([spawnattr_setflags]) + fi + gl_SPAWN_MODULE_INDICATOR([posix_spawnattr_setflags]) + gl_POSIX_SPAWN + if test $HAVE_POSIX_SPAWN = 0 || test $REPLACE_POSIX_SPAWN = 1; then + AC_LIBOBJ([spawnattr_setpgroup]) + fi + gl_SPAWN_MODULE_INDICATOR([posix_spawnattr_setpgroup]) + gl_POSIX_SPAWN + if test $HAVE_POSIX_SPAWN = 0 || test $REPLACE_POSIX_SPAWN = 1; then + AC_LIBOBJ([spawnattr_setdefault]) + fi + gl_SPAWN_MODULE_INDICATOR([posix_spawnattr_setsigdefault]) + gl_POSIX_SPAWN + if test $HAVE_POSIX_SPAWN = 0 || test $REPLACE_POSIX_SPAWN = 1; then + AC_LIBOBJ([spawnattr_setsigmask]) + fi + gl_SPAWN_MODULE_INDICATOR([posix_spawnattr_setsigmask]) gl_FUNC_PSELECT if test $HAVE_PSELECT = 0 || test $REPLACE_PSELECT = 1; then AC_LIBOBJ([pselect]) @@ -430,6 +501,7 @@ AC_DEFUN([gl_INIT], AC_LIBOBJ([regex]) gl_PREREQ_REGEX fi + gl_SCHED_H gl_FUNC_SIG2STR if test $ac_cv_func_sig2str = no; then AC_LIBOBJ([sig2str]) @@ -442,6 +514,7 @@ AC_DEFUN([gl_INIT], gl_STRING_MODULE_INDICATOR([sigdescr_np]) gl_SIGNAL_H gl_TYPE_SOCKLEN_T + gl_SPAWN_H gt_TYPE_SSIZE_T gl_STAT_TIME gl_STAT_BIRTHTIME @@ -528,9 +601,12 @@ AC_DEFUN([gl_INIT], gl_gnulib_enabled_5264294aa0a5557541b53c8c741f7f31=false gl_gnulib_enabled_open=false gl_gnulib_enabled_03e0aaad4cb89ca757653bd367a6ccb7=false + gl_gnulib_enabled_332607f759618fb73dfc3076748afea7=false gl_gnulib_enabled_rawmemchr=false gl_gnulib_enabled_6099e9737f757db36c47fa9d9f02e88c=false gl_gnulib_enabled_scratch_buffer=false + gl_gnulib_enabled_cdeb0f2aaf9d280baa6526bfa1b07f70=false + gl_gnulib_enabled_strchrnul=false gl_gnulib_enabled_strtoll=false gl_gnulib_enabled_utimens=false gl_gnulib_enabled_682e609604ccaac6be382e4ee3a4eaec=false @@ -685,6 +761,20 @@ AC_DEFUN([gl_INIT], gl_gnulib_enabled_03e0aaad4cb89ca757653bd367a6ccb7=true fi } + func_gl_gnulib_m4code_332607f759618fb73dfc3076748afea7 () + { + if ! $gl_gnulib_enabled_332607f759618fb73dfc3076748afea7; then + gl_POSIX_SPAWN + if test $HAVE_POSIX_SPAWN = 0 || test $REPLACE_POSIX_SPAWN = 1; then + AC_LIBOBJ([spawni]) + gl_PREREQ_POSIX_SPAWN_INTERNAL + fi + gl_gnulib_enabled_332607f759618fb73dfc3076748afea7=true + func_gl_gnulib_m4code_open + func_gl_gnulib_m4code_cdeb0f2aaf9d280baa6526bfa1b07f70 + func_gl_gnulib_m4code_strchrnul + fi + } func_gl_gnulib_m4code_rawmemchr () { if ! $gl_gnulib_enabled_rawmemchr; then @@ -709,6 +799,28 @@ AC_DEFUN([gl_INIT], gl_gnulib_enabled_scratch_buffer=true fi } + func_gl_gnulib_m4code_cdeb0f2aaf9d280baa6526bfa1b07f70 () + { + if ! $gl_gnulib_enabled_cdeb0f2aaf9d280baa6526bfa1b07f70; then + gl_SH_FILENAME + gl_gnulib_enabled_cdeb0f2aaf9d280baa6526bfa1b07f70=true + fi + } + func_gl_gnulib_m4code_strchrnul () + { + if ! $gl_gnulib_enabled_strchrnul; then + gl_FUNC_STRCHRNUL + if test $HAVE_STRCHRNUL = 0 || test $REPLACE_STRCHRNUL = 1; then + AC_LIBOBJ([strchrnul]) + gl_PREREQ_STRCHRNUL + fi + gl_STRING_MODULE_INDICATOR([strchrnul]) + gl_gnulib_enabled_strchrnul=true + if test $HAVE_STRCHRNUL = 0 || test $REPLACE_STRCHRNUL = 1; then + func_gl_gnulib_m4code_rawmemchr + fi + fi + } func_gl_gnulib_m4code_strtoll () { if ! $gl_gnulib_enabled_strtoll; then @@ -791,6 +903,12 @@ AC_DEFUN([gl_INIT], if case $host_os in mingw*) false;; *) test $HAVE_GETRANDOM = 0 || test $REPLACE_GETRANDOM = 1;; esac; then func_gl_gnulib_m4code_open fi + if test $HAVE_POSIX_SPAWN = 0 || test $REPLACE_POSIX_SPAWN = 1; then + func_gl_gnulib_m4code_332607f759618fb73dfc3076748afea7 + fi + if test $HAVE_POSIX_SPAWN = 0 || test $REPLACE_POSIX_SPAWN = 1 || test $REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2 = 1; then + func_gl_gnulib_m4code_getdtablesize + fi if test $HAVE_READLINKAT = 0 || test $REPLACE_READLINKAT = 1; then func_gl_gnulib_m4code_260941c0e5dc67ec9e87d1fb321c300b fi @@ -830,9 +948,12 @@ AC_DEFUN([gl_INIT], AM_CONDITIONAL([gl_GNULIB_ENABLED_5264294aa0a5557541b53c8c741f7f31], [$gl_gnulib_enabled_5264294aa0a5557541b53c8c741f7f31]) AM_CONDITIONAL([gl_GNULIB_ENABLED_open], [$gl_gnulib_enabled_open]) AM_CONDITIONAL([gl_GNULIB_ENABLED_03e0aaad4cb89ca757653bd367a6ccb7], [$gl_gnulib_enabled_03e0aaad4cb89ca757653bd367a6ccb7]) + AM_CONDITIONAL([gl_GNULIB_ENABLED_332607f759618fb73dfc3076748afea7], [$gl_gnulib_enabled_332607f759618fb73dfc3076748afea7]) AM_CONDITIONAL([gl_GNULIB_ENABLED_rawmemchr], [$gl_gnulib_enabled_rawmemchr]) AM_CONDITIONAL([gl_GNULIB_ENABLED_6099e9737f757db36c47fa9d9f02e88c], [$gl_gnulib_enabled_6099e9737f757db36c47fa9d9f02e88c]) AM_CONDITIONAL([gl_GNULIB_ENABLED_scratch_buffer], [$gl_gnulib_enabled_scratch_buffer]) + AM_CONDITIONAL([gl_GNULIB_ENABLED_cdeb0f2aaf9d280baa6526bfa1b07f70], [$gl_gnulib_enabled_cdeb0f2aaf9d280baa6526bfa1b07f70]) + AM_CONDITIONAL([gl_GNULIB_ENABLED_strchrnul], [$gl_gnulib_enabled_strchrnul]) AM_CONDITIONAL([gl_GNULIB_ENABLED_strtoll], [$gl_gnulib_enabled_strtoll]) AM_CONDITIONAL([gl_GNULIB_ENABLED_utimens], [$gl_gnulib_enabled_utimens]) AM_CONDITIONAL([gl_GNULIB_ENABLED_682e609604ccaac6be382e4ee3a4eaec], [$gl_gnulib_enabled_682e609604ccaac6be382e4ee3a4eaec]) @@ -1113,6 +1234,7 @@ AC_DEFUN([gl_FILE_LIST], [ lib/regex_internal.h lib/regexec.c lib/root-uid.h + lib/sched.in.h lib/scratch_buffer.h lib/set-permissions.c lib/sha1.c @@ -1125,6 +1247,20 @@ AC_DEFUN([gl_FILE_LIST], [ lib/sig2str.h lib/sigdescr_np.c lib/signal.in.h + lib/spawn.c + lib/spawn.in.h + lib/spawn_faction_addchdir.c + lib/spawn_faction_adddup2.c + lib/spawn_faction_destroy.c + lib/spawn_faction_init.c + lib/spawn_int.h + lib/spawnattr_destroy.c + lib/spawnattr_init.c + lib/spawnattr_setdefault.c + lib/spawnattr_setflags.c + lib/spawnattr_setpgroup.c + lib/spawnattr_setsigmask.c + lib/spawni.c lib/stat-time.c lib/stat-time.h lib/stdalign.in.h @@ -1135,6 +1271,8 @@ AC_DEFUN([gl_FILE_LIST], [ lib/stdlib.in.h lib/stpcpy.c lib/str-two-way.h + lib/strchrnul.c + lib/strchrnul.valgrind lib/strftime.h lib/string.in.h lib/strnlen.c @@ -1248,12 +1386,16 @@ AC_DEFUN([gl_FILE_LIST], [ m4/pathmax.m4 m4/pid_t.m4 m4/pipe2.m4 + m4/posix_spawn.m4 + m4/posix_spawn_faction_addchdir.m4 m4/pselect.m4 m4/pthread_sigmask.m4 m4/rawmemchr.m4 m4/readlink.m4 m4/readlinkat.m4 m4/regex.m4 + m4/sched_h.m4 + m4/sh-filename.m4 m4/sha1.m4 m4/sha256.m4 m4/sha512.m4 @@ -1261,6 +1403,7 @@ AC_DEFUN([gl_FILE_LIST], [ m4/sigdescr_np.m4 m4/signal_h.m4 m4/socklen.m4 + m4/spawn_h.m4 m4/ssize_t.m4 m4/stat-time.m4 m4/std-gnu11.m4 @@ -1270,6 +1413,7 @@ AC_DEFUN([gl_FILE_LIST], [ m4/stdio_h.m4 m4/stdlib_h.m4 m4/stpcpy.m4 + m4/strchrnul.m4 m4/string_h.m4 m4/strnlen.m4 m4/strtoimax.m4 diff --git a/m4/posix_spawn.m4 b/m4/posix_spawn.m4 new file mode 100644 index 0000000000..59e56fcb5f --- /dev/null +++ b/m4/posix_spawn.m4 @@ -0,0 +1,678 @@ +# posix_spawn.m4 serial 19 +dnl Copyright (C) 2008-2020 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl Tests whether the entire posix_spawn facility is available. +AC_DEFUN([gl_POSIX_SPAWN], +[ + AC_REQUIRE([gl_POSIX_SPAWN_BODY]) +]) + +AC_DEFUN([gl_POSIX_SPAWN_BODY], +[ + AC_REQUIRE([gl_SPAWN_H_DEFAULTS]) + AC_REQUIRE([gl_HAVE_POSIX_SPAWN]) + dnl Assume that when the main function exists, all the others, + dnl except posix_spawnattr_{get,set}sched*, are available as well. + dnl AC_CHECK_FUNCS_ONCE([posix_spawnp]) + dnl AC_CHECK_FUNCS_ONCE([posix_spawn_file_actions_init]) + dnl AC_CHECK_FUNCS_ONCE([posix_spawn_file_actions_addclose]) + dnl AC_CHECK_FUNCS_ONCE([posix_spawn_file_actions_adddup2]) + dnl AC_CHECK_FUNCS_ONCE([posix_spawn_file_actions_addopen]) + dnl AC_CHECK_FUNCS_ONCE([posix_spawn_file_actions_destroy]) + dnl AC_CHECK_FUNCS_ONCE([posix_spawnattr_init]) + dnl AC_CHECK_FUNCS_ONCE([posix_spawnattr_getflags]) + dnl AC_CHECK_FUNCS_ONCE([posix_spawnattr_setflags]) + dnl AC_CHECK_FUNCS_ONCE([posix_spawnattr_getpgroup]) + dnl AC_CHECK_FUNCS_ONCE([posix_spawnattr_setpgroup]) + dnl AC_CHECK_FUNCS_ONCE([posix_spawnattr_getsigdefault]) + dnl AC_CHECK_FUNCS_ONCE([posix_spawnattr_setsigdefault]) + dnl AC_CHECK_FUNCS_ONCE([posix_spawnattr_getsigmask]) + dnl AC_CHECK_FUNCS_ONCE([posix_spawnattr_setsigmask]) + dnl AC_CHECK_FUNCS_ONCE([posix_spawnattr_destroy]) + if test $ac_cv_func_posix_spawn = yes; then + m4_ifdef([gl_FUNC_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR], + [dnl Module 'posix_spawn_file_actions_addchdir' is present. + AC_CHECK_FUNCS_ONCE([posix_spawn_file_actions_addchdir_np]) + if test $ac_cv_func_posix_spawn_file_actions_addchdir_np = no; then + dnl In order to implement the posix_spawn_file_actions_addchdir + dnl function, we need to replace the entire posix_spawn facility. + REPLACE_POSIX_SPAWN=1 + fi + ]) + m4_ifdef([gl_FUNC_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR], + [dnl Module 'posix_spawn_file_actions_addfchdir' is present. + AC_CHECK_FUNCS_ONCE([posix_spawn_file_actions_addfchdir_np]) + if test $ac_cv_func_posix_spawn_file_actions_addfchdir_np = no; then + dnl In order to implement the posix_spawn_file_actions_addfchdir + dnl function, we need to replace the entire posix_spawn facility. + REPLACE_POSIX_SPAWN=1 + fi + ]) + if test $REPLACE_POSIX_SPAWN = 0; then + gl_POSIX_SPAWN_WORKS + case "$gl_cv_func_posix_spawn_works" in + *yes) ;; + *) REPLACE_POSIX_SPAWN=1 ;; + esac + fi + if test $REPLACE_POSIX_SPAWN = 0; then + gl_POSIX_SPAWN_SECURE + case "$gl_cv_func_posix_spawn_secure_exec" in + *yes) ;; + *) REPLACE_POSIX_SPAWN=1 ;; + esac + case "$gl_cv_func_posix_spawnp_secure_exec" in + *yes) ;; + *) REPLACE_POSIX_SPAWN=1 ;; + esac + fi + if test $REPLACE_POSIX_SPAWN = 0; then + dnl Assume that these functions are available if POSIX_SPAWN_SETSCHEDULER + dnl evaluates to nonzero. + dnl AC_CHECK_FUNCS_ONCE([posix_spawnattr_getschedpolicy]) + dnl AC_CHECK_FUNCS_ONCE([posix_spawnattr_setschedpolicy]) + AC_CACHE_CHECK([whether posix_spawnattr_setschedpolicy is supported], + [gl_cv_func_spawnattr_setschedpolicy], + [AC_EGREP_CPP([POSIX scheduling supported], [ +#include +#if POSIX_SPAWN_SETSCHEDULER + POSIX scheduling supported +#endif +], + [gl_cv_func_spawnattr_setschedpolicy=yes], + [gl_cv_func_spawnattr_setschedpolicy=no]) + ]) + dnl Assume that these functions are available if POSIX_SPAWN_SETSCHEDPARAM + dnl evaluates to nonzero. + dnl AC_CHECK_FUNCS_ONCE([posix_spawnattr_getschedparam]) + dnl AC_CHECK_FUNCS_ONCE([posix_spawnattr_setschedparam]) + AC_CACHE_CHECK([whether posix_spawnattr_setschedparam is supported], + [gl_cv_func_spawnattr_setschedparam], + [AC_EGREP_CPP([POSIX scheduling supported], [ +#include +#if POSIX_SPAWN_SETSCHEDPARAM + POSIX scheduling supported +#endif +], + [gl_cv_func_spawnattr_setschedparam=yes], + [gl_cv_func_spawnattr_setschedparam=no]) + ]) + fi + fi + if test $ac_cv_func_posix_spawn != yes || test $REPLACE_POSIX_SPAWN = 1; then + AC_DEFINE([REPLACE_POSIX_SPAWN], [1], + [Define if gnulib uses its own posix_spawn and posix_spawnp functions.]) + fi +]) + +dnl Test whether posix_spawn actually works. +dnl posix_spawn on AIX 5.3..6.1 has two bugs: +dnl 1) When it fails to execute the program, the child process exits with +dnl exit() rather than _exit(), which causes the stdio buffers to be +dnl flushed. Reported by Rainer Tammer. +dnl 2) The posix_spawn_file_actions_addopen function does not support file +dnl names that contain a '*'. +dnl posix_spawn on AIX 5.3..6.1 has also a third bug: It does not work +dnl when POSIX threads are used. But we don't test against this bug here. +AC_DEFUN([gl_POSIX_SPAWN_WORKS], +[ + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + AC_CACHE_CHECK([whether posix_spawn works], [gl_cv_func_posix_spawn_works], + [if test $cross_compiling = no; then + AC_LINK_IFELSE([AC_LANG_SOURCE([[ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +]GL_MDA_DEFINES[ + +extern char **environ; + +#ifndef STDIN_FILENO +# define STDIN_FILENO 0 +#endif +#ifndef STDOUT_FILENO +# define STDOUT_FILENO 1 +#endif +#ifndef STDERR_FILENO +# define STDERR_FILENO 2 +#endif + +#ifndef WTERMSIG +# define WTERMSIG(x) ((x) & 0x7f) +#endif +#ifndef WIFEXITED +# define WIFEXITED(x) (WTERMSIG (x) == 0) +#endif +#ifndef WEXITSTATUS +# define WEXITSTATUS(x) (((x) >> 8) & 0xff) +#endif + +#define CHILD_PROGRAM_FILENAME "/non/exist/ent" + +static int +fd_safer (int fd) +{ + if (0 <= fd && fd <= 2) + { + int f = fd_safer (dup (fd)); + int e = errno; + close (fd); + errno = e; + fd = f; + } + + return fd; +} + +int +main () +{ + char *argv[2] = { CHILD_PROGRAM_FILENAME, NULL }; + int ofd[2]; + sigset_t blocked_signals; + sigset_t fatal_signal_set; + posix_spawn_file_actions_t actions; + bool actions_allocated; + posix_spawnattr_t attrs; + bool attrs_allocated; + int err; + pid_t child; + int status; + int exitstatus; + + setvbuf (stdout, NULL, _IOFBF, 0); + puts ("This should be seen only once."); + if (pipe (ofd) < 0 || (ofd[1] = fd_safer (ofd[1])) < 0) + { + perror ("cannot create pipe"); + exit (1); + } + sigprocmask (SIG_SETMASK, NULL, &blocked_signals); + sigemptyset (&fatal_signal_set); + sigaddset (&fatal_signal_set, SIGINT); + sigaddset (&fatal_signal_set, SIGTERM); + sigaddset (&fatal_signal_set, SIGHUP); + sigaddset (&fatal_signal_set, SIGPIPE); + sigprocmask (SIG_BLOCK, &fatal_signal_set, NULL); + actions_allocated = false; + attrs_allocated = false; + if ((err = posix_spawn_file_actions_init (&actions)) != 0 + || (actions_allocated = true, + (err = posix_spawn_file_actions_adddup2 (&actions, ofd[0], STDIN_FILENO)) != 0 + || (err = posix_spawn_file_actions_addclose (&actions, ofd[0])) != 0 + || (err = posix_spawn_file_actions_addclose (&actions, ofd[1])) != 0 + || (err = posix_spawnattr_init (&attrs)) != 0 + || (attrs_allocated = true, + (err = posix_spawnattr_setsigmask (&attrs, &blocked_signals)) != 0 + || (err = posix_spawnattr_setflags (&attrs, POSIX_SPAWN_SETSIGMASK)) != 0) + || (err = posix_spawnp (&child, CHILD_PROGRAM_FILENAME, &actions, &attrs, argv, environ)) != 0)) + { + if (actions_allocated) + posix_spawn_file_actions_destroy (&actions); + if (attrs_allocated) + posix_spawnattr_destroy (&attrs); + sigprocmask (SIG_UNBLOCK, &fatal_signal_set, NULL); + if (err == ENOENT) + return 0; + else + { + errno = err; + perror ("subprocess failed"); + exit (1); + } + } + posix_spawn_file_actions_destroy (&actions); + posix_spawnattr_destroy (&attrs); + sigprocmask (SIG_UNBLOCK, &fatal_signal_set, NULL); + close (ofd[0]); + close (ofd[1]); + status = 0; + while (waitpid (child, &status, 0) != child) + ; + if (!WIFEXITED (status)) + { + fprintf (stderr, "subprocess terminated with unexpected wait status %d\n", status); + exit (1); + } + exitstatus = WEXITSTATUS (status); + if (exitstatus != 127) + { + fprintf (stderr, "subprocess terminated with unexpected exit status %d\n", exitstatus); + exit (1); + } + return 0; +} +]])], + [if test -s conftest$ac_exeext \ + && ./conftest$ac_exeext > conftest.out \ + && echo 'This should be seen only once.' > conftest.ok \ + && cmp conftest.out conftest.ok >/dev/null 2>&1; then + gl_cv_func_posix_spawn_works=yes + else + gl_cv_func_posix_spawn_works=no + fi], + [gl_cv_func_posix_spawn_works=no]) + if test $gl_cv_func_posix_spawn_works = yes; then + AC_RUN_IFELSE([AC_LANG_SOURCE([[ +/* Test whether posix_spawn_file_actions_addopen supports filename arguments + that contain special characters such as '*'. */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +]GL_MDA_DEFINES[ + +extern char **environ; + +#ifndef STDIN_FILENO +# define STDIN_FILENO 0 +#endif +#ifndef STDOUT_FILENO +# define STDOUT_FILENO 1 +#endif +#ifndef STDERR_FILENO +# define STDERR_FILENO 2 +#endif + +#ifndef WTERMSIG +# define WTERMSIG(x) ((x) & 0x7f) +#endif +#ifndef WIFEXITED +# define WIFEXITED(x) (WTERMSIG (x) == 0) +#endif +#ifndef WEXITSTATUS +# define WEXITSTATUS(x) (((x) >> 8) & 0xff) +#endif + +#define CHILD_PROGRAM_FILENAME "conftest" +#define DATA_FILENAME "conftest%=*#?" + +static int +parent_main (void) +{ + FILE *fp; + char *argv[3] = { CHILD_PROGRAM_FILENAME, "-child", NULL }; + posix_spawn_file_actions_t actions; + bool actions_allocated; + int err; + pid_t child; + int status; + int exitstatus; + + /* Create a data file with specific contents. */ + fp = fopen (DATA_FILENAME, "wb"); + if (fp == NULL) + { + perror ("cannot create data file"); + return 1; + } + fwrite ("Halle Potta", 1, 11, fp); + if (fflush (fp) || fclose (fp)) + { + perror ("cannot prepare data file"); + return 2; + } + + /* Avoid reading from our stdin, as it could block. */ + freopen ("/dev/null", "rb", stdin); + + /* Test whether posix_spawn_file_actions_addopen with this file name + actually works, but spawning a child that reads from this file. */ + actions_allocated = false; + if ((err = posix_spawn_file_actions_init (&actions)) != 0 + || (actions_allocated = true, + (err = posix_spawn_file_actions_addopen (&actions, STDIN_FILENO, DATA_FILENAME, O_RDONLY, 0600)) != 0 + || (err = posix_spawn (&child, CHILD_PROGRAM_FILENAME, &actions, NULL, argv, environ)) != 0)) + { + if (actions_allocated) + posix_spawn_file_actions_destroy (&actions); + errno = err; + perror ("subprocess failed"); + return 3; + } + posix_spawn_file_actions_destroy (&actions); + status = 0; + while (waitpid (child, &status, 0) != child) + ; + if (!WIFEXITED (status)) + { + fprintf (stderr, "subprocess terminated with unexpected wait status %d\n", status); + return 4; + } + exitstatus = WEXITSTATUS (status); + if (exitstatus != 0) + { + fprintf (stderr, "subprocess terminated with unexpected exit status %d\n", exitstatus); + return 5; + } + return 0; +} + +static int +child_main (void) +{ + char buf[1024]; + + /* See if reading from STDIN_FILENO yields the expected contents. */ + if (fread (buf, 1, sizeof (buf), stdin) == 11 + && memcmp (buf, "Halle Potta", 11) == 0) + return 0; + else + return 8; +} + +static void +cleanup_then_die (int sig) +{ + /* Clean up data file. */ + unlink (DATA_FILENAME); + + /* Re-raise the signal and die from it. */ + signal (sig, SIG_DFL); + raise (sig); +} + +int +main (int argc, char *argv[]) +{ + int exitstatus; + + if (!(argc > 1 && strcmp (argv[1], "-child") == 0)) + { + /* This is the parent process. */ + signal (SIGINT, cleanup_then_die); + signal (SIGTERM, cleanup_then_die); + #ifdef SIGHUP + signal (SIGHUP, cleanup_then_die); + #endif + + exitstatus = parent_main (); + } + else + { + /* This is the child process. */ + + exitstatus = child_main (); + } + unlink (DATA_FILENAME); + return exitstatus; +} +]])], + [], + [gl_cv_func_posix_spawn_works=no]) + fi + else + case "$host_os" in + aix*) gl_cv_func_posix_spawn_works="guessing no";; + *) gl_cv_func_posix_spawn_works="guessing yes";; + esac + fi + ]) +]) + +dnl Test whether posix_spawn and posix_spawnp are secure. +AC_DEFUN([gl_POSIX_SPAWN_SECURE], +[ + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + dnl On many platforms, posix_spawn or posix_spawnp allow executing a + dnl script without a '#!' marker as a shell script. This is unsecure. + AC_CACHE_CHECK([whether posix_spawn rejects scripts without shebang], + [gl_cv_func_posix_spawn_secure_exec], + [echo ':' > conftest.scr + chmod a+x conftest.scr + AC_RUN_IFELSE([AC_LANG_SOURCE([[ + #include + #include + #include + #include + #include + int + main () + { + const char *prog_path = "./conftest.scr"; + const char *prog_argv[2] = { prog_path, NULL }; + const char *environment[2] = { "PATH=.", NULL }; + pid_t child; + int status; + int err = posix_spawn (&child, prog_path, NULL, NULL, + (char **) prog_argv, (char **) environment); + if (err == ENOEXEC) + return 0; + if (err != 0) + return 1; + status = 0; + while (waitpid (child, &status, 0) != child) + ; + if (!WIFEXITED (status)) + return 2; + if (WEXITSTATUS (status) != 127) + return 3; + return 0; + } + ]])], + [gl_cv_func_posix_spawn_secure_exec=yes], + [gl_cv_func_posix_spawn_secure_exec=no], + [case "$host_os" in + # Guess no on GNU/Hurd. + gnu*) + gl_cv_func_posix_spawn_secure_exec="guessing no" ;; + # Guess yes on all other platforms. + *) + gl_cv_func_posix_spawn_secure_exec="guessing yes" ;; + esac + ]) + rm -f conftest.scr + ]) + AC_CACHE_CHECK([whether posix_spawnp rejects scripts without shebang], + [gl_cv_func_posix_spawnp_secure_exec], + [echo ':' > conftest.scr + chmod a+x conftest.scr + AC_RUN_IFELSE([AC_LANG_SOURCE([[ + #include + #include + #include + #include + #include + int + main () + { + const char *prog_path = "./conftest.scr"; + const char *prog_argv[2] = { prog_path, NULL }; + const char *environment[2] = { "PATH=.", NULL }; + pid_t child; + int status; + int err = posix_spawnp (&child, prog_path, NULL, NULL, + (char **) prog_argv, (char **) environment); + if (err == ENOEXEC) + return 0; + if (err != 0) + return 1; + status = 0; + while (waitpid (child, &status, 0) != child) + ; + if (!WIFEXITED (status)) + return 2; + if (WEXITSTATUS (status) != 127) + return 3; + return 0; + } + ]])], + [gl_cv_func_posix_spawnp_secure_exec=yes], + [gl_cv_func_posix_spawnp_secure_exec=no], + [case "$host_os" in + # Guess yes on glibc systems (glibc >= 2.15 actually) except GNU/Hurd, + # musl libc, NetBSD. + *-gnu* | *-musl* | netbsd*) + gl_cv_func_posix_spawnp_secure_exec="guessing yes" ;; + # Guess no on GNU/Hurd, macOS, FreeBSD, OpenBSD, AIX, Solaris, Cygwin. + gnu* | darwin* | freebsd* | dragonfly* | openbsd* | aix* | solaris* | cygwin*) + gl_cv_func_posix_spawnp_secure_exec="guessing no" ;; + # If we don't know, obey --enable-cross-guesses. + *) + gl_cv_func_posix_spawnp_secure_exec="$gl_cross_guess_normal" ;; + esac + ]) + rm -f conftest.scr + ]) +]) + +# Prerequisites of lib/spawni.c. +AC_DEFUN([gl_PREREQ_POSIX_SPAWN_INTERNAL], +[ + AC_CHECK_HEADERS([paths.h]) + AC_CHECK_FUNCS([confstr sched_setparam sched_setscheduler setegid seteuid vfork]) +]) + +AC_DEFUN([gl_FUNC_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE], +[ + AC_REQUIRE([gl_SPAWN_H_DEFAULTS]) + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + gl_POSIX_SPAWN + if test $REPLACE_POSIX_SPAWN = 1; then + REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE=1 + else + dnl On musl libc and Solaris 11.0, posix_spawn_file_actions_addclose + dnl succeeds even if the fd argument is out of range. + AC_CACHE_CHECK([whether posix_spawn_file_actions_addclose works], + [gl_cv_func_posix_spawn_file_actions_addclose_works], + [AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +int main () +{ + posix_spawn_file_actions_t actions; + if (posix_spawn_file_actions_init (&actions) != 0) + return 1; + if (posix_spawn_file_actions_addclose (&actions, 10000000) == 0) + return 2; + return 0; +}]])], + [gl_cv_func_posix_spawn_file_actions_addclose_works=yes], + [gl_cv_func_posix_spawn_file_actions_addclose_works=no], + [# Guess no on musl libc and Solaris, yes otherwise. + case "$host_os" in + *-musl*) gl_cv_func_posix_spawn_file_actions_addclose_works="guessing no" ;; + solaris*) gl_cv_func_posix_spawn_file_actions_addclose_works="guessing no" ;; + # Guess no on native Windows. + mingw*) gl_cv_func_posix_spawn_file_actions_addclose_works="guessing no" ;; + *) gl_cv_func_posix_spawn_file_actions_addclose_works="guessing yes" ;; + esac + ]) + ]) + case "$gl_cv_func_posix_spawn_file_actions_addclose_works" in + *yes) ;; + *) REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE=1 ;; + esac + fi +]) + +AC_DEFUN([gl_FUNC_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2], +[ + AC_REQUIRE([gl_SPAWN_H_DEFAULTS]) + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + gl_POSIX_SPAWN + if test $REPLACE_POSIX_SPAWN = 1; then + REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2=1 + else + dnl On musl libc and Solaris 11.0, posix_spawn_file_actions_adddup2 + dnl succeeds even if the fd argument is out of range. + AC_CACHE_CHECK([whether posix_spawn_file_actions_adddup2 works], + [gl_cv_func_posix_spawn_file_actions_adddup2_works], + [AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +int main () +{ + posix_spawn_file_actions_t actions; + if (posix_spawn_file_actions_init (&actions) != 0) + return 1; + if (posix_spawn_file_actions_adddup2 (&actions, 10000000, 2) == 0) + return 2; + return 0; +}]])], + [gl_cv_func_posix_spawn_file_actions_adddup2_works=yes], + [gl_cv_func_posix_spawn_file_actions_adddup2_works=no], + [# Guess no on musl libc and Solaris, yes otherwise. + case "$host_os" in + *-musl*) gl_cv_func_posix_spawn_file_actions_adddup2_works="guessing no";; + solaris*) gl_cv_func_posix_spawn_file_actions_adddup2_works="guessing no";; + # Guess no on native Windows. + mingw*) gl_cv_func_posix_spawn_file_actions_adddup2_works="guessing no" ;; + *) gl_cv_func_posix_spawn_file_actions_adddup2_works="guessing yes";; + esac + ]) + ]) + case "$gl_cv_func_posix_spawn_file_actions_adddup2_works" in + *yes) ;; + *) REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2=1 ;; + esac + fi +]) + +AC_DEFUN([gl_FUNC_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN], +[ + AC_REQUIRE([gl_SPAWN_H_DEFAULTS]) + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + gl_POSIX_SPAWN + if test $REPLACE_POSIX_SPAWN = 1; then + REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN=1 + else + dnl On musl libc and Solaris 11.0, posix_spawn_file_actions_addopen + dnl succeeds even if the fd argument is out of range. + AC_CACHE_CHECK([whether posix_spawn_file_actions_addopen works], + [gl_cv_func_posix_spawn_file_actions_addopen_works], + [AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +#include +int main () +{ + posix_spawn_file_actions_t actions; + if (posix_spawn_file_actions_init (&actions) != 0) + return 1; + if (posix_spawn_file_actions_addopen (&actions, 10000000, "foo", 0, O_RDONLY) + == 0) + return 2; + return 0; +}]])], + [gl_cv_func_posix_spawn_file_actions_addopen_works=yes], + [gl_cv_func_posix_spawn_file_actions_addopen_works=no], + [# Guess no on musl libc and Solaris, yes otherwise. + case "$host_os" in + *-musl*) gl_cv_func_posix_spawn_file_actions_addopen_works="guessing no";; + solaris*) gl_cv_func_posix_spawn_file_actions_addopen_works="guessing no";; + # Guess no on native Windows. + mingw*) gl_cv_func_posix_spawn_file_actions_addopen_works="guessing no" ;; + *) gl_cv_func_posix_spawn_file_actions_addopen_works="guessing yes";; + esac + ]) + ]) + case "$gl_cv_func_posix_spawn_file_actions_addopen_works" in + *yes) ;; + *) REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN=1 ;; + esac + fi +]) diff --git a/m4/posix_spawn_faction_addchdir.m4 b/m4/posix_spawn_faction_addchdir.m4 new file mode 100644 index 0000000000..1ce7153d1d --- /dev/null +++ b/m4/posix_spawn_faction_addchdir.m4 @@ -0,0 +1,20 @@ +# posix_spawn_faction_addchdir.m4 serial 1 +dnl Copyright (C) 2018-2020 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR], +[ + AC_REQUIRE([gl_SPAWN_H_DEFAULTS]) + AC_REQUIRE([AC_PROG_CC]) + gl_POSIX_SPAWN + AC_CHECK_FUNCS_ONCE([posix_spawn_file_actions_addchdir posix_spawn_file_actions_addchdir_np]) + if test $ac_cv_func_posix_spawn_file_actions_addchdir = yes; then + dnl This function is not yet standardized. Therefore override the + dnl system's implementation always. + REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR=1 + else + HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR=0 + fi +]) diff --git a/m4/sched_h.m4 b/m4/sched_h.m4 new file mode 100644 index 0000000000..af0c43de07 --- /dev/null +++ b/m4/sched_h.m4 @@ -0,0 +1,91 @@ +# sched_h.m4 serial 12 +dnl Copyright (C) 2008-2020 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl Written by Bruno Haible. + +AC_DEFUN([gl_SCHED_H], +[ + dnl Use AC_REQUIRE here, so that the default behavior below is expanded + dnl once only, before all statements that occur in other macros. + AC_REQUIRE([gl_SCHED_H_DEFAULTS]) + + AC_REQUIRE([AC_CANONICAL_HOST]) + + AC_CHECK_HEADERS_ONCE([sys/cdefs.h]) + AC_CHECK_HEADERS([sched.h], [], [], + [[#if HAVE_SYS_CDEFS_H + #include + #endif + ]]) + gl_NEXT_HEADERS([sched.h]) + + if test "$ac_cv_header_sched_h" = yes; then + HAVE_SCHED_H=1 + else + HAVE_SCHED_H=0 + fi + AC_SUBST([HAVE_SCHED_H]) + + if test "$HAVE_SCHED_H" = 1; then + AC_CHECK_TYPE([struct sched_param], + [HAVE_STRUCT_SCHED_PARAM=1], [HAVE_STRUCT_SCHED_PARAM=0], + [[#if HAVE_SYS_CDEFS_H + #include + #endif + #include + ]]) + else + HAVE_STRUCT_SCHED_PARAM=0 + case "$host_os" in + os2*) + dnl On OS/2 kLIBC, struct sched_param is in spawn.h. + AC_CHECK_TYPE([struct sched_param], + [HAVE_STRUCT_SCHED_PARAM=1], [], + [#include ]) + ;; + vms) + dnl On OpenVMS 7.2 or newer, struct sched_param is in pthread.h. + AC_CHECK_TYPE([struct sched_param], + [HAVE_STRUCT_SCHED_PARAM=1], [], + [#include ]) + ;; + esac + fi + AC_SUBST([HAVE_STRUCT_SCHED_PARAM]) + + if test "$ac_cv_header_sys_cdefs_h" = yes; then + HAVE_SYS_CDEFS_H=1 + else + HAVE_SYS_CDEFS_H=0 + fi + AC_SUBST([HAVE_SYS_CDEFS_H]) + + dnl Ensure the type pid_t gets defined. + AC_REQUIRE([AC_TYPE_PID_T]) + + dnl Check for declarations of anything we want to poison if the + dnl corresponding gnulib module is not in use, if it is not common + dnl enough to be declared everywhere. + gl_WARN_ON_USE_PREPARE([[#include + ]], [sched_yield]) +]) + +AC_DEFUN([gl_SCHED_MODULE_INDICATOR], +[ + dnl Use AC_REQUIRE here, so that the default settings are expanded once only. + AC_REQUIRE([gl_SCHED_H_DEFAULTS]) + gl_MODULE_INDICATOR_SET_VARIABLE([$1]) + dnl Define it also as a C macro, for the benefit of the unit tests. + gl_MODULE_INDICATOR_FOR_TESTS([$1]) +]) + +AC_DEFUN([gl_SCHED_H_DEFAULTS], +[ + GNULIB_SCHED_YIELD=0; AC_SUBST([GNULIB_SCHED_YIELD]) + dnl Assume proper GNU behavior unless another module says otherwise. + HAVE_SCHED_YIELD=1; AC_SUBST([HAVE_SCHED_YIELD]) + REPLACE_SCHED_YIELD=0; AC_SUBST([REPLACE_SCHED_YIELD]) +]) diff --git a/m4/sh-filename.m4 b/m4/sh-filename.m4 new file mode 100644 index 0000000000..f7b31548e0 --- /dev/null +++ b/m4/sh-filename.m4 @@ -0,0 +1,22 @@ +# sh-filename.m4 serial 2 +dnl Copyright (C) 2018-2020 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Bruno Haible. + +AC_DEFUN([gl_SH_FILENAME], +[ + AH_VERBATIM([SH_FILENAME], +[/* File name of the Bourne shell. */ +#if defined __CYGWIN__ || defined __ANDROID__ +/* Omit the directory part because + - For 32-bit Cygwin programs in a 64-bit Cygwin environment, the Cygwin + mounts are not visible. + - On Android, /bin/sh does not exist. It's /system/bin/sh instead. */ +# define BOURNE_SHELL "sh" +#else +# define BOURNE_SHELL "/bin/sh" +#endif]) +]) diff --git a/m4/spawn_h.m4 b/m4/spawn_h.m4 new file mode 100644 index 0000000000..781f9f4965 --- /dev/null +++ b/m4/spawn_h.m4 @@ -0,0 +1,136 @@ +# spawn_h.m4 serial 18 +dnl Copyright (C) 2008-2020 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl Written by Bruno Haible. + +AC_DEFUN([gl_SPAWN_H], +[ + dnl Use AC_REQUIRE here, so that the default behavior below is expanded + dnl once only, before all statements that occur in other macros. + AC_REQUIRE([gl_SPAWN_H_DEFAULTS]) + + dnl is always overridden, because of GNULIB_POSIXCHECK. + gl_CHECK_NEXT_HEADERS([spawn.h]) + + if test $ac_cv_header_spawn_h = yes; then + HAVE_SPAWN_H=1 + AC_CHECK_TYPES([posix_spawnattr_t], [], [HAVE_POSIX_SPAWNATTR_T=0], [[ +#include + ]]) + AC_CHECK_TYPES([posix_spawn_file_actions_t], [], + [HAVE_POSIX_SPAWN_FILE_ACTIONS_T=0], [[ +#include + ]]) + else + HAVE_SPAWN_H=0 + HAVE_POSIX_SPAWNATTR_T=0 + HAVE_POSIX_SPAWN_FILE_ACTIONS_T=0 + fi + AC_SUBST([HAVE_SPAWN_H]) + + dnl Ensure the type pid_t gets defined. + AC_REQUIRE([AC_TYPE_PID_T]) + + dnl Ensure the type mode_t gets defined. + AC_REQUIRE([AC_TYPE_MODE_T]) + + AC_REQUIRE([gl_HAVE_POSIX_SPAWN]) + + AC_REQUIRE([AC_C_RESTRICT]) + + dnl Check for declarations of anything we want to poison if the + dnl corresponding gnulib module is not in use. + gl_WARN_ON_USE_PREPARE([[#include + ]], [posix_spawn posix_spawnp posix_spawnattr_init posix_spawnattr_destroy + posix_spawnattr_getsigdefault posix_spawnattr_setsigdefault + posix_spawnattr_getsigmask posix_spawnattr_setsigmask + posix_spawnattr_getflags posix_spawnattr_setflags + posix_spawnattr_getpgroup posix_spawnattr_setpgroup + posix_spawnattr_getschedpolicy posix_spawnattr_setschedpolicy + posix_spawnattr_getschedparam posix_spawnattr_setschedparam + posix_spawn_file_actions_init posix_spawn_file_actions_destroy + posix_spawn_file_actions_addopen posix_spawn_file_actions_addclose + posix_spawn_file_actions_adddup2 posix_spawn_file_actions_addchdir + posix_spawn_file_actions_addfchdir]) +]) + +dnl Checks whether the system has the functions posix_spawn. +dnl Sets ac_cv_func_posix_spawn and HAVE_POSIX_SPAWN. +AC_DEFUN([gl_HAVE_POSIX_SPAWN], +[ + dnl Use AC_REQUIRE here, so that the default behavior below is expanded + dnl once only, before all statements that occur in other macros. + AC_REQUIRE([gl_SPAWN_H_DEFAULTS]) + + LIB_POSIX_SPAWN= + AC_SUBST([LIB_POSIX_SPAWN]) + gl_saved_libs=$LIBS + AC_SEARCH_LIBS([posix_spawn], [rt], + [test "$ac_cv_search_posix_spawn" = "none required" || + LIB_POSIX_SPAWN=$ac_cv_search_posix_spawn]) + AC_CHECK_FUNCS([posix_spawn]) + LIBS=$gl_saved_libs + + if test $ac_cv_func_posix_spawn != yes; then + HAVE_POSIX_SPAWN=0 + fi +]) + +AC_DEFUN([gl_SPAWN_MODULE_INDICATOR], +[ + dnl Use AC_REQUIRE here, so that the default settings are expanded once only. + AC_REQUIRE([gl_SPAWN_H_DEFAULTS]) + gl_MODULE_INDICATOR_SET_VARIABLE([$1]) + dnl Define it also as a C macro, for the benefit of the unit tests. + gl_MODULE_INDICATOR_FOR_TESTS([$1]) +]) + +AC_DEFUN([gl_SPAWN_H_DEFAULTS], +[ + GNULIB_POSIX_SPAWN=0; AC_SUBST([GNULIB_POSIX_SPAWN]) + GNULIB_POSIX_SPAWNP=0; AC_SUBST([GNULIB_POSIX_SPAWNP]) + GNULIB_POSIX_SPAWN_FILE_ACTIONS_INIT=0; AC_SUBST([GNULIB_POSIX_SPAWN_FILE_ACTIONS_INIT]) + GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR=0; AC_SUBST([GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR]) + GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE=0; AC_SUBST([GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE]) + GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2=0; AC_SUBST([GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2]) + GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR=0; AC_SUBST([GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR]) + GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN=0; AC_SUBST([GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN]) + GNULIB_POSIX_SPAWN_FILE_ACTIONS_DESTROY=0; AC_SUBST([GNULIB_POSIX_SPAWN_FILE_ACTIONS_DESTROY]) + GNULIB_POSIX_SPAWNATTR_INIT=0; AC_SUBST([GNULIB_POSIX_SPAWNATTR_INIT]) + GNULIB_POSIX_SPAWNATTR_GETFLAGS=0; AC_SUBST([GNULIB_POSIX_SPAWNATTR_GETFLAGS]) + GNULIB_POSIX_SPAWNATTR_SETFLAGS=0; AC_SUBST([GNULIB_POSIX_SPAWNATTR_SETFLAGS]) + GNULIB_POSIX_SPAWNATTR_GETPGROUP=0; AC_SUBST([GNULIB_POSIX_SPAWNATTR_GETPGROUP]) + GNULIB_POSIX_SPAWNATTR_SETPGROUP=0; AC_SUBST([GNULIB_POSIX_SPAWNATTR_SETPGROUP]) + GNULIB_POSIX_SPAWNATTR_GETSCHEDPARAM=0; AC_SUBST([GNULIB_POSIX_SPAWNATTR_GETSCHEDPARAM]) + GNULIB_POSIX_SPAWNATTR_SETSCHEDPARAM=0; AC_SUBST([GNULIB_POSIX_SPAWNATTR_SETSCHEDPARAM]) + GNULIB_POSIX_SPAWNATTR_GETSCHEDPOLICY=0; AC_SUBST([GNULIB_POSIX_SPAWNATTR_GETSCHEDPOLICY]) + GNULIB_POSIX_SPAWNATTR_SETSCHEDPOLICY=0; AC_SUBST([GNULIB_POSIX_SPAWNATTR_SETSCHEDPOLICY]) + GNULIB_POSIX_SPAWNATTR_GETSIGDEFAULT=0; AC_SUBST([GNULIB_POSIX_SPAWNATTR_GETSIGDEFAULT]) + GNULIB_POSIX_SPAWNATTR_SETSIGDEFAULT=0; AC_SUBST([GNULIB_POSIX_SPAWNATTR_SETSIGDEFAULT]) + GNULIB_POSIX_SPAWNATTR_GETSIGMASK=0; AC_SUBST([GNULIB_POSIX_SPAWNATTR_GETSIGMASK]) + GNULIB_POSIX_SPAWNATTR_SETSIGMASK=0; AC_SUBST([GNULIB_POSIX_SPAWNATTR_SETSIGMASK]) + GNULIB_POSIX_SPAWNATTR_DESTROY=0; AC_SUBST([GNULIB_POSIX_SPAWNATTR_DESTROY]) + dnl Assume proper GNU behavior unless another module says otherwise. + HAVE_POSIX_SPAWN=1; AC_SUBST([HAVE_POSIX_SPAWN]) + HAVE_POSIX_SPAWNATTR_T=1; AC_SUBST([HAVE_POSIX_SPAWNATTR_T]) + HAVE_POSIX_SPAWN_FILE_ACTIONS_T=1; + AC_SUBST([HAVE_POSIX_SPAWN_FILE_ACTIONS_T]) + HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR=1; + AC_SUBST([HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR]) + HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR=1; + AC_SUBST([HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR]) + REPLACE_POSIX_SPAWN=0; AC_SUBST([REPLACE_POSIX_SPAWN]) + REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR=0; + AC_SUBST([REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR]) + REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE=0; + AC_SUBST([REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE]) + REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2=0; + AC_SUBST([REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2]) + REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR=0; + AC_SUBST([REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR]) + REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN=0; + AC_SUBST([REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN]) +]) diff --git a/m4/strchrnul.m4 b/m4/strchrnul.m4 new file mode 100644 index 0000000000..a18f0935a5 --- /dev/null +++ b/m4/strchrnul.m4 @@ -0,0 +1,50 @@ +# strchrnul.m4 serial 9 +dnl Copyright (C) 2003, 2007, 2009-2020 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_STRCHRNUL], +[ + dnl Persuade glibc to declare strchrnul(). + AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) + + AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS]) + AC_CHECK_FUNCS([strchrnul]) + if test $ac_cv_func_strchrnul = no; then + HAVE_STRCHRNUL=0 + else + AC_CACHE_CHECK([whether strchrnul works], + [gl_cv_func_strchrnul_works], + [AC_RUN_IFELSE([AC_LANG_PROGRAM([[ +#include /* for strchrnul */ +]], [[const char *buf = "a"; + return strchrnul (buf, 'b') != buf + 1; + ]])], + [gl_cv_func_strchrnul_works=yes], + [gl_cv_func_strchrnul_works=no], + [dnl Cygwin 1.7.9 introduced strchrnul, but it was broken until 1.7.10 + AC_EGREP_CPP([Lucky user], + [ +#if defined __CYGWIN__ + #include + #if CYGWIN_VERSION_DLL_COMBINED > CYGWIN_VERSION_DLL_MAKE_COMBINED (1007, 9) + Lucky user + #endif +#else + Lucky user +#endif + ], + [gl_cv_func_strchrnul_works="guessing yes"], + [gl_cv_func_strchrnul_works="guessing no"]) + ]) + ]) + case "$gl_cv_func_strchrnul_works" in + *yes) ;; + *) REPLACE_STRCHRNUL=1 ;; + esac + fi +]) + +# Prerequisites of lib/strchrnul.c. +AC_DEFUN([gl_PREREQ_STRCHRNUL], [:]) commit 42d58264db165d265cba68d6dbebc53a50738355 Author: Paul Eggert Date: Fri Dec 25 02:33:29 2020 -0800 Update Gnulib. All changes in this commit are autogenerated by running admin/merge-gnulib. diff --git a/build-aux/config.guess b/build-aux/config.guess index 699b3a10b2..7f74817797 100755 --- a/build-aux/config.guess +++ b/build-aux/config.guess @@ -2,7 +2,7 @@ # Attempt to guess a canonical system name. # Copyright 1992-2020 Free Software Foundation, Inc. -timestamp='2020-11-19' +timestamp='2020-12-22' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -996,6 +996,9 @@ EOF k1om:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; + loongarch32:Linux:*:* | loongarch64:Linux:*:* | loongarchx32:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; m32r*:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; diff --git a/lib/canonicalize-lgpl.c b/lib/canonicalize-lgpl.c index 584fce1cfa..650d510f2d 100644 --- a/lib/canonicalize-lgpl.c +++ b/lib/canonicalize-lgpl.c @@ -29,6 +29,7 @@ #include #include +#include #include #include #include @@ -36,23 +37,26 @@ #include #include +#include +#include +#include #include #ifdef _LIBC -# include # include -typedef ptrdiff_t idx_t; -# define IDX_MAX PTRDIFF_MAX -# define FILE_SYSTEM_PREFIX_LEN(name) 0 -# define IS_ABSOLUTE_FILE_NAME(name) ISSLASH(*(name)) -# define ISSLASH(c) ((c) == '/') -# define freea(p) ((void) (p)) +# include +# ifdef __ASSUME_FACCESSAT2 +# define FACCESSAT_NEVER_EOVERFLOWS __ASSUME_FACCESSAT2 +# else +# define FACCESSAT_NEVER_EOVERFLOWS true +# endif +# define GCC_LINT 1 +# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__)) #else # define __canonicalize_file_name canonicalize_file_name # define __realpath realpath -# include "idx.h" # include "pathmax.h" -# include "filename.h" +# define __faccessat faccessat # if defined _WIN32 && !defined __CYGWIN__ # define __getcwd _getcwd # elif HAVE_GETCWD @@ -77,22 +81,95 @@ typedef ptrdiff_t idx_t; # define __pathconf pathconf # define __rawmemchr rawmemchr # define __readlink readlink -# ifndef MAXSYMLINKS -# ifdef SYMLOOP_MAX -# define MAXSYMLINKS SYMLOOP_MAX -# else -# define MAXSYMLINKS 20 -# endif -# endif -# define __eloop_threshold() MAXSYMLINKS +# define __stat stat +#endif + +/* Suppress bogus GCC -Wmaybe-uninitialized warnings. */ +#if defined GCC_LINT || defined lint +# define IF_LINT(Code) Code +#else +# define IF_LINT(Code) /* empty */ #endif #ifndef DOUBLE_SLASH_IS_DISTINCT_ROOT -# define DOUBLE_SLASH_IS_DISTINCT_ROOT 0 +# define DOUBLE_SLASH_IS_DISTINCT_ROOT false +#endif +#ifndef FACCESSAT_NEVER_EOVERFLOWS +# define FACCESSAT_NEVER_EOVERFLOWS false #endif #if !FUNC_REALPATH_WORKS || defined _LIBC +/* Return true if FILE's existence can be shown, false (setting errno) + otherwise. Follow symbolic links. */ +static bool +file_accessible (char const *file) +{ +# if defined _LIBC || HAVE_FACCESSAT + int r = __faccessat (AT_FDCWD, file, F_OK, AT_EACCESS); +# else + struct stat st; + int r = __stat (file, &st); +# endif + + return ((!FACCESSAT_NEVER_EOVERFLOWS && r < 0 && errno == EOVERFLOW) + || r == 0); +} + +/* True if concatenating END as a suffix to a file name means that the + code needs to check that the file name is that of a searchable + directory, since the canonicalize_filename_mode_stk code won't + check this later anyway when it checks an ordinary file name + component within END. END must either be empty, or start with a + slash. */ + +static bool _GL_ATTRIBUTE_PURE +suffix_requires_dir_check (char const *end) +{ + /* If END does not start with a slash, the suffix is OK. */ + while (ISSLASH (*end)) + { + /* Two or more slashes act like a single slash. */ + do + end++; + while (ISSLASH (*end)); + + switch (*end++) + { + default: return false; /* An ordinary file name component is OK. */ + case '\0': return true; /* Trailing "/" is trouble. */ + case '.': break; /* Possibly "." or "..". */ + } + /* Trailing "/.", or "/.." even if not trailing, is trouble. */ + if (!*end || (*end == '.' && (!end[1] || ISSLASH (end[1])))) + return true; + } + + return false; +} + +/* Append this to a file name to test whether it is a searchable directory. + On POSIX platforms "/" suffices, but "/./" is sometimes needed on + macOS 10.13 , and should also work on + platforms like AIX 7.2 that need at least "/.". */ + +#if defined _LIBC || defined LSTAT_FOLLOWS_SLASHED_SYMLINK +static char const dir_suffix[] = "/"; +#else +static char const dir_suffix[] = "/./"; +#endif + +/* Return true if DIR is a searchable dir, false (setting errno) otherwise. + DIREND points to the NUL byte at the end of the DIR string. + Store garbage into DIREND[0 .. strlen (dir_suffix)]. */ + +static bool +dir_check (char *dir, char *dirend) +{ + strcpy (dirend, dir_suffix); + return file_accessible (dir); +} + static idx_t get_path_max (void) { @@ -111,19 +188,27 @@ get_path_max (void) return path_max < 0 ? 1024 : path_max <= IDX_MAX ? path_max : IDX_MAX; } -/* Return the canonical absolute name of file NAME. A canonical name - does not contain any ".", ".." components nor any repeated file name - separators ('/') or symlinks. All file name components must exist. If - RESOLVED is null, the result is malloc'd; otherwise, if the - canonical name is PATH_MAX chars or more, returns null with 'errno' - set to ENAMETOOLONG; if the name fits in fewer than PATH_MAX chars, - returns the name in RESOLVED. If the name cannot be resolved and - RESOLVED is non-NULL, it contains the name of the first component - that cannot be resolved. If the name can be resolved, RESOLVED - holds the same value as the value returned. */ - -char * -__realpath (const char *name, char *resolved) +/* Act like __realpath (see below), with an additional argument + rname_buf that can be used as temporary storage. + + If GCC_LINT is defined, do not inline this function with GCC 10.1 + and later, to avoid creating a pointer to the stack that GCC + -Wreturn-local-addr incorrectly complains about. See: + https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93644 + Although the noinline attribute can hurt performance a bit, no better way + to pacify GCC is known; even an explicit #pragma does not pacify GCC. + When the GCC bug is fixed this workaround should be limited to the + broken GCC versions. */ +#if __GNUC_PREREQ (10, 1) +# if defined GCC_LINT || defined lint +__attribute__ ((__noinline__)) +# elif __OPTIMIZE__ && !__NO_INLINE__ +# define GCC_BOGUS_WRETURN_LOCAL_ADDR +# endif +#endif +static char * +realpath_stk (const char *name, char *resolved, + struct scratch_buffer *rname_buf) { char *dest; char const *start; @@ -149,8 +234,6 @@ __realpath (const char *name, char *resolved) } struct scratch_buffer extra_buffer, link_buffer; - struct scratch_buffer rname_buffer; - struct scratch_buffer *rname_buf = &rname_buffer; scratch_buffer_init (&extra_buffer); scratch_buffer_init (&link_buffer); scratch_buffer_init (rname_buf); @@ -208,7 +291,9 @@ __realpath (const char *name, char *resolved) name ends in '/'. */ idx_t startlen = end - start; - if (startlen == 1 && start[0] == '.') + if (startlen == 0) + break; + else if (startlen == 1 && start[0] == '.') /* nothing */; else if (startlen == 2 && start[0] == '.' && start[1] == '.') { @@ -226,7 +311,8 @@ __realpath (const char *name, char *resolved) if (!ISSLASH (dest[-1])) *dest++ = '/'; - while (rname + rname_buf->length - dest <= startlen) + while (rname + rname_buf->length - dest + < startlen + sizeof dir_suffix) { idx_t dest_offset = dest - rname; if (!scratch_buffer_grow_preserve (rname_buf)) @@ -238,28 +324,19 @@ __realpath (const char *name, char *resolved) dest = __mempcpy (dest, start, startlen); *dest = '\0'; - /* If STARTLEN == 0, RNAME ends in '/'; use stat rather than - readlink, because readlink might fail with EINVAL without - checking whether RNAME sans '/' is valid. */ - struct stat st; - char *buf = NULL; + char *buf; ssize_t n; - if (startlen != 0) + while (true) { - while (true) - { - buf = link_buffer.data; - idx_t bufsize = link_buffer.length; - n = __readlink (rname, buf, bufsize - 1); - if (n < bufsize - 1) - break; - if (!scratch_buffer_grow (&link_buffer)) - goto error_nomem; - } - if (n < 0) - buf = NULL; + buf = link_buffer.data; + idx_t bufsize = link_buffer.length; + n = __readlink (rname, buf, bufsize - 1); + if (n < bufsize - 1) + break; + if (!scratch_buffer_grow (&link_buffer)) + goto error_nomem; } - if (buf) + if (0 <= n) { if (++num_links > __eloop_threshold ()) { @@ -270,7 +347,7 @@ __realpath (const char *name, char *resolved) buf[n] = '\0'; char *extra_buf = extra_buffer.data; - idx_t end_idx; + idx_t end_idx IF_LINT (= 0); if (end_in_extra_buffer) end_idx = end - extra_buf; idx_t len = strlen (end); @@ -315,8 +392,8 @@ __realpath (const char *name, char *resolved) dest++; } } - else if (! (startlen == 0 - ? stat (rname, &st) == 0 || errno == EOVERFLOW + else if (! (suffix_requires_dir_check (end) + ? dir_check (rname, dest) : errno == EINVAL)) goto error; } @@ -355,6 +432,28 @@ __realpath (const char *name, char *resolved) char *result = realloc (rname, rname_size); return result != NULL ? result : rname; } + +/* Return the canonical absolute name of file NAME. A canonical name + does not contain any ".", ".." components nor any repeated file name + separators ('/') or symlinks. All file name components must exist. If + RESOLVED is null, the result is malloc'd; otherwise, if the + canonical name is PATH_MAX chars or more, returns null with 'errno' + set to ENAMETOOLONG; if the name fits in fewer than PATH_MAX chars, + returns the name in RESOLVED. If the name cannot be resolved and + RESOLVED is non-NULL, it contains the name of the first component + that cannot be resolved. If the name can be resolved, RESOLVED + holds the same value as the value returned. */ + +char * +__realpath (const char *name, char *resolved) +{ + #ifdef GCC_BOGUS_WRETURN_LOCAL_ADDR + #warning "GCC might issue a bogus -Wreturn-local-addr warning here." + #warning "See ." + #endif + struct scratch_buffer rname_buffer; + return realpath_stk (name, resolved, &rname_buffer); +} libc_hidden_def (__realpath) versioned_symbol (libc, __realpath, realpath, GLIBC_2_3); #endif /* !FUNC_REALPATH_WORKS || defined _LIBC */ diff --git a/lib/careadlinkat.c b/lib/careadlinkat.c index 26fe84df55..6aaa712b9b 100644 --- a/lib/careadlinkat.c +++ b/lib/careadlinkat.c @@ -55,8 +55,7 @@ enum { STACK_BUF_SIZE = 1024 }; # if defined GCC_LINT || defined lint __attribute__ ((__noinline__)) # elif __OPTIMIZE__ && !__NO_INLINE__ -# warning "GCC might issue a bogus -Wreturn-local-addr warning here." -# warning "See ." +# define GCC_BOGUS_WRETURN_LOCAL_ADDR # endif #endif static char * @@ -180,10 +179,11 @@ careadlinkat (int fd, char const *filename, /* Allocate the initial buffer on the stack. This way, in the common case of a symlink of small size, we get away with a single small malloc instead of a big malloc followed by a - shrinking realloc. - - If GCC -Wreturn-local-addr warns about this buffer, the warning - is bogus; see readlink_stk. */ + shrinking realloc. */ + #ifdef GCC_BOGUS_WRETURN_LOCAL_ADDR + #warning "GCC might issue a bogus -Wreturn-local-addr warning here." + #warning "See ." + #endif char stack_buf[STACK_BUF_SIZE]; return readlink_stk (fd, filename, buffer, buffer_size, alloc, preadlinkat, stack_buf); diff --git a/lib/eloop-threshold.h b/lib/eloop-threshold.h new file mode 100644 index 0000000000..5953a4cc06 --- /dev/null +++ b/lib/eloop-threshold.h @@ -0,0 +1,83 @@ +/* Threshold at which to diagnose ELOOP. Generic version. + Copyright (C) 2012-2020 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public + License as published by the Free Software Foundation; either + version 3 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _ELOOP_THRESHOLD_H +#define _ELOOP_THRESHOLD_H 1 + +#include +#ifdef _LIBC +# include +# define _GL_ATTRIBUTE_CONST __attribute__ ((const)) +#else +# include +# include "minmax.h" +# define __sysconf sysconf +# if (!defined SYMLOOP_MAX \ + && ! (defined _SC_SYMLOOP_MAX && defined _POSIX_SYMLOOP_MAX)) +# define SYMLOOP_MAX 8 +# endif +#endif + +/* POSIX specifies SYMLOOP_MAX as the "Maximum number of symbolic + links that can be reliably traversed in the resolution of a + pathname in the absence of a loop." This makes it a minimum that + we should certainly accept. But it leaves open the possibility + that more might sometimes work--just not "reliably". + + For example, Linux implements a complex policy whereby there is a + small limit on the number of direct symlink traversals (a symlink + to a symlink to a symlink), but larger limit on the total number of + symlink traversals overall. Hence the SYMLOOP_MAX number should be + the small one, but the limit library functions enforce on users + should be the larger one. + + So, we use the larger of the reported SYMLOOP_MAX (if any) and our + own constant MIN_ELOOP_THRESHOLD, below. This constant should be + large enough that it never rules out a file name and directory tree + that the underlying system (i.e. calls to 'open' et al) would + resolve successfully. It should be small enough that actual loops + are detected without a huge number of iterations. */ + +#ifndef MIN_ELOOP_THRESHOLD +# define MIN_ELOOP_THRESHOLD 40 +#endif + +/* Return the maximum number of symlink traversals to permit + before diagnosing ELOOP. */ +static inline unsigned int _GL_ATTRIBUTE_CONST +__eloop_threshold (void) +{ +#ifdef SYMLOOP_MAX + const int symloop_max = SYMLOOP_MAX; +#else + /* The function is marked 'const' even though we use memory and + call a function, because sysconf is required to return the + same value in every call and so it must always be safe to + call __eloop_threshold exactly once and reuse the value. */ + static long int sysconf_symloop_max; + if (sysconf_symloop_max == 0) + sysconf_symloop_max = __sysconf (_SC_SYMLOOP_MAX); + const unsigned int symloop_max = (sysconf_symloop_max <= 0 + ? _POSIX_SYMLOOP_MAX + : sysconf_symloop_max); +#endif + + return MAX (symloop_max, MIN_ELOOP_THRESHOLD); +} + +#endif /* eloop-threshold.h */ diff --git a/lib/euidaccess.c b/lib/euidaccess.c index b352123ae1..a32e3366eb 100644 --- a/lib/euidaccess.c +++ b/lib/euidaccess.c @@ -107,7 +107,10 @@ euidaccess (const char *file, int mode) safe. */ if (mode == F_OK) - return stat (file, &stats); + { + int result = stat (file, &stats); + return result != 0 && errno == EOVERFLOW ? 0 : result; + } else { int result; @@ -142,8 +145,8 @@ euidaccess (const char *file, int mode) /* If we are not set-uid or set-gid, access does the same. */ return access (file, mode); - if (stat (file, &stats) != 0) - return -1; + if (stat (file, &stats) == -1) + return mode == F_OK && errno == EOVERFLOW ? 0 : -1; /* The super-user can read and write any file, and execute any file that anyone can execute. */ diff --git a/lib/faccessat.c b/lib/faccessat.c index 9f6a11bf6e..330c54a0be 100644 --- a/lib/faccessat.c +++ b/lib/faccessat.c @@ -32,6 +32,13 @@ #include #undef _GL_INCLUDING_UNISTD_H +#ifndef FACCESSAT_NEVER_EOVERFLOWS +# define FACCESSAT_NEVER_EOVERFLOWS 0 +#endif +#ifndef LSTAT_FOLLOWS_SLASHED_SYMLINK +# define LSTAT_FOLLOWS_SLASHED_SYMLINK 0 +#endif + #if HAVE_FACCESSAT static int orig_faccessat (int fd, char const *name, int mode, int flag) @@ -59,7 +66,12 @@ rpl_faccessat (int fd, char const *file, int mode, int flag) { int result = orig_faccessat (fd, file, mode, flag); - if (result == 0 && file[strlen (file) - 1] == '/') + if (result != 0) + { + if (!FACCESSAT_NEVER_EOVERFLOWS && mode == F_OK && errno == EOVERFLOW) + return 0; + } + else if (!LSTAT_FOLLOWS_SLASHED_SYMLINK && file[strlen (file) - 1] == '/') { struct stat st; result = fstatat (fd, file, &st, 0); diff --git a/lib/gnulib.mk.in b/lib/gnulib.mk.in index df533fa674..a37f9278a3 100644 --- a/lib/gnulib.mk.in +++ b/lib/gnulib.mk.in @@ -103,6 +103,7 @@ # filevercmp \ # flexmember \ # fpieee \ +# free-posix \ # fstatat \ # fsusage \ # fsync \ @@ -1528,6 +1529,17 @@ EXTRA_libgnu_a_SOURCES += dup2.c endif ## end gnulib module dup2 +## begin gnulib module eloop-threshold +ifeq (,$(OMIT_GNULIB_MODULE_eloop-threshold)) + +ifneq (,$(gl_GNULIB_ENABLED_925677f0343de64b89a9f0c790b4104c)) + +endif +EXTRA_DIST += eloop-threshold.h + +endif +## end gnulib module eloop-threshold + ## begin gnulib module errno ifeq (,$(OMIT_GNULIB_MODULE_errno)) @@ -1750,9 +1762,7 @@ endif ## begin gnulib module free-posix ifeq (,$(OMIT_GNULIB_MODULE_free-posix)) -ifneq (,$(gl_GNULIB_ENABLED_ef07dc4b3077c11ea9cef586db4e5955)) -endif EXTRA_DIST += free.c EXTRA_libgnu_a_SOURCES += free.c diff --git a/lib/mini-gmp.c b/lib/mini-gmp.c index 2e0301b008..d34fe525e4 100644 --- a/lib/mini-gmp.c +++ b/lib/mini-gmp.c @@ -32,7 +32,7 @@ see https://www.gnu.org/licenses/. */ /* NOTE: All functions in this file which are not declared in mini-gmp.h are internal, and are not intended to be compatible - neither with GMP nor with future versions of mini-gmp. */ + with GMP or with future versions of mini-gmp. */ /* Much of the material copied from GMP files, including: gmp-impl.h, longlong.h, mpn/generic/add_n.c, mpn/generic/addmul_1.c, @@ -1331,29 +1331,26 @@ mpn_set_str_bits (mp_ptr rp, const unsigned char *sp, size_t sn, unsigned bits) { mp_size_t rn; - size_t j; + mp_limb_t limb; unsigned shift; - for (j = sn, rn = 0, shift = 0; j-- > 0; ) + for (limb = 0, rn = 0, shift = 0; sn-- > 0; ) { - if (shift == 0) - { - rp[rn++] = sp[j]; - shift += bits; - } - else + limb |= (mp_limb_t) sp[sn] << shift; + shift += bits; + if (shift >= GMP_LIMB_BITS) { - rp[rn-1] |= (mp_limb_t) sp[j] << shift; - shift += bits; - if (shift >= GMP_LIMB_BITS) - { - shift -= GMP_LIMB_BITS; - if (shift > 0) - rp[rn++] = (mp_limb_t) sp[j] >> (bits - shift); - } + shift -= GMP_LIMB_BITS; + rp[rn++] = limb; + /* Next line is correct also if shift == 0, + bits == 8, and mp_limb_t == unsigned char. */ + limb = (unsigned int) sp[sn] >> (bits - shift); } } - rn = mpn_normalized_size (rp, rn); + if (limb != 0) + rp[rn++] = limb; + else + rn = mpn_normalized_size (rp, rn); return rn; } @@ -2723,7 +2720,7 @@ mpz_make_odd (mpz_t r) assert (r->_mp_size > 0); /* Count trailing zeros, equivalent to mpn_scan1, because we know that there is a 1 */ - shift = mpn_common_scan (r->_mp_d[0], 0, r->_mp_d, 0, 0); + shift = mpn_scan1 (r->_mp_d, 0); mpz_tdiv_q_2exp (r, r, shift); return shift; @@ -2780,9 +2777,13 @@ mpz_gcd (mpz_t g, const mpz_t u, const mpz_t v) if (tv->_mp_size == 1) { - mp_limb_t vl = tv->_mp_d[0]; - mp_limb_t ul = mpz_tdiv_ui (tu, vl); - mpz_set_ui (g, mpn_gcd_11 (ul, vl)); + mp_limb_t *gp; + + mpz_tdiv_r (tu, tu, tv); + gp = MPZ_REALLOC (g, 1); /* gp = mpz_limbs_modify (g, 1); */ + *gp = mpn_gcd_11 (tu->_mp_d[0], tv->_mp_d[0]); + + g->_mp_size = *gp != 0; /* mpz_limbs_finish (g, 1); */ break; } mpz_sub (tu, tu, tv); @@ -2871,7 +2872,6 @@ mpz_gcdext (mpz_t g, mpz_t s, mpz_t t, const mpz_t u, const mpz_t v) * s0 = 0, s1 = 2^vz */ - mpz_setbit (t0, uz); mpz_tdiv_qr (t1, tu, tu, tv); mpz_mul_2exp (t1, t1, uz); @@ -2882,8 +2882,7 @@ mpz_gcdext (mpz_t g, mpz_t s, mpz_t t, const mpz_t u, const mpz_t v) { mp_bitcnt_t shift; shift = mpz_make_odd (tu); - mpz_mul_2exp (t0, t0, shift); - mpz_mul_2exp (s0, s0, shift); + mpz_setbit (t0, uz + shift); power += shift; for (;;) @@ -2921,6 +2920,8 @@ mpz_gcdext (mpz_t g, mpz_t s, mpz_t t, const mpz_t u, const mpz_t v) power += shift; } } + else + mpz_setbit (t0, uz); /* Now tv = odd part of gcd, and -s0 and t0 are corresponding cofactors. */ @@ -3604,7 +3605,8 @@ mpz_probab_prime_p (const mpz_t n, int reps) /* Find q and k, where q is odd and n = 1 + 2**k * q. */ mpz_abs (nm1, n); nm1->_mp_d[0] -= 1; - k = mpz_scan1 (nm1, 0); + /* Count trailing zeros, equivalent to mpn_scan1, because we know that there is a 1 */ + k = mpn_scan1 (nm1->_mp_d, 0); mpz_tdiv_q_2exp (q, nm1, k); /* BPSW test */ @@ -4301,7 +4303,7 @@ mpz_get_str (char *sp, int base, const mpz_t u) ret: sp[sn] = '\0'; if (osn && osn != sn + 1) - sp = gmp_realloc(sp, osn, sn + 1); + sp = (char*) gmp_realloc (sp, osn, sn + 1); return sp; } @@ -4425,6 +4427,8 @@ mpz_out_str (FILE *stream, int base, const mpz_t x) size_t len, n; str = mpz_get_str (NULL, base, x); + if (!str) + return 0; len = strlen (str); n = fwrite (str, 1, len, stream); gmp_free (str, len + 1); diff --git a/lib/mini-gmp.h b/lib/mini-gmp.h index c00568c256..59a37e6494 100644 --- a/lib/mini-gmp.h +++ b/lib/mini-gmp.h @@ -1,6 +1,6 @@ /* mini-gmp, a minimalistic implementation of a GNU GMP subset. -Copyright 2011-2015, 2017, 2019 Free Software Foundation, Inc. +Copyright 2011-2015, 2017, 2019-2020 Free Software Foundation, Inc. This file is part of the GNU MP Library. @@ -295,7 +295,8 @@ int mpz_init_set_str (mpz_t, const char *, int); || defined (_MSL_STDIO_H) /* Metrowerks */ \ || defined (_STDIO_H_INCLUDED) /* QNX4 */ \ || defined (_ISO_STDIO_ISO_H) /* Sun C++ */ \ - || defined (__STDIO_LOADED) /* VMS */ + || defined (__STDIO_LOADED) /* VMS */ \ + || defined (__DEFINED_FILE) /* musl */ size_t mpz_out_str (FILE *, int, const mpz_t); #endif diff --git a/lib/symlink.c b/lib/symlink.c index e7dbd184a9..b1196b9ee8 100644 --- a/lib/symlink.c +++ b/lib/symlink.c @@ -36,7 +36,7 @@ rpl_symlink (char const *contents, char const *name) if (len && name[len - 1] == '/') { struct stat st; - if (lstat (name, &st) == 0) + if (lstat (name, &st) == 0 || errno == EOVERFLOW) errno = EEXIST; return -1; } diff --git a/m4/canonicalize.m4 b/m4/canonicalize.m4 index 14ea3e12fa..c8da4dfcb6 100644 --- a/m4/canonicalize.m4 +++ b/m4/canonicalize.m4 @@ -1,4 +1,4 @@ -# canonicalize.m4 serial 33 +# canonicalize.m4 serial 34 dnl Copyright (C) 2003-2007, 2009-2020 Free Software Foundation, Inc. @@ -11,7 +11,9 @@ dnl with or without modifications, as long as this notice is preserved. AC_DEFUN([gl_FUNC_CANONICALIZE_FILENAME_MODE], [ AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) - AC_CHECK_FUNCS_ONCE([canonicalize_file_name]) + AC_REQUIRE([gl_FUNC_FACCESSAT_EOVERFLOW]) + AC_REQUIRE([gl_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK]) + AC_CHECK_FUNCS_ONCE([canonicalize_file_name faccessat]) AC_REQUIRE([gl_DOUBLE_SLASH_ROOT]) AC_REQUIRE([gl_FUNC_REALPATH_WORKS]) if test $ac_cv_func_canonicalize_file_name = no; then @@ -56,7 +58,9 @@ AC_DEFUN([gl_CANONICALIZE_LGPL], AC_DEFUN([gl_CANONICALIZE_LGPL_SEPARATE], [ AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) - AC_CHECK_FUNCS_ONCE([canonicalize_file_name readlink]) + AC_REQUIRE([gl_FUNC_FACCESSAT_EOVERFLOW]) + AC_REQUIRE([gl_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK]) + AC_CHECK_FUNCS_ONCE([canonicalize_file_name faccessat]) dnl On native Windows, we use _getcwd(), regardless whether getcwd() is dnl available through the linker option '-loldnames'. diff --git a/m4/faccessat.m4 b/m4/faccessat.m4 index 7a8b979f8d..a4ad31a469 100644 --- a/m4/faccessat.m4 +++ b/m4/faccessat.m4 @@ -1,4 +1,4 @@ -# serial 8 +# serial 9 # See if we need to provide faccessat replacement. dnl Copyright (C) 2009-2020 Free Software Foundation, Inc. @@ -8,6 +8,31 @@ dnl with or without modifications, as long as this notice is preserved. # Written by Eric Blake. +AC_DEFUN([gl_FUNC_FACCESSAT_EOVERFLOW], +[ + AC_CHECK_FUNCS_ONCE([faccessat]) + if test "$ac_cv_func_faccessat" = yes; then + AC_CACHE_CHECK([whether faccessat works when stat would EOVERFLOW], + [gl_cv_func_faccessat_never_eoverflows], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([], + [[#ifdef __linux__ + #include + #if (! (KERNEL_VERSION (5, 8, 0) <= LINUX_VERSION_CODE \ + && 2 < (__GLIBC__ + (33 <= __GLIBC_MINOR__)))) + #error "faccessat might fail with EOVERFLOW" + #endif + #endif + ]])], + [gl_cv_func_faccessat_never_eoverflows=yes], + [gl_cv_func_faccessat_never_eoverflows=no])]) + if test "$gl_cv_func_faccessat_never_eoverflows" = yes; then + AC_DEFINE([FACCESSAT_NEVER_EOVERFLOWS], 1, + [Define to 1 if faccessat is EOVERFLOW-free.]) + fi + fi +]) + AC_DEFUN([gl_FUNC_FACCESSAT], [ AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) @@ -16,12 +41,14 @@ AC_DEFUN([gl_FUNC_FACCESSAT], dnl Persuade glibc to declare faccessat(). AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) + AC_REQUIRE([gl_FUNC_FACCESSAT_EOVERFLOW]) + AC_CHECK_FUNCS_ONCE([faccessat]) if test $ac_cv_func_faccessat = no; then HAVE_FACCESSAT=0 else - case "$gl_cv_func_lstat_dereferences_slashed_symlink" in - *yes) ;; + case $gl_cv_func_lstat_dereferences_slashed_symlink,$gl_cv_func_faccessat_never_eoverflows in + *yes,*yes) ;; *) REPLACE_FACCESSAT=1 ;; esac fi diff --git a/m4/gnulib-comp.m4 b/m4/gnulib-comp.m4 index beb9817d26..0971636c33 100644 --- a/m4/gnulib-comp.m4 +++ b/m4/gnulib-comp.m4 @@ -75,6 +75,7 @@ AC_DEFUN([gl_EARLY], # Code from module dtoastr: # Code from module dtotimespec: # Code from module dup2: + # Code from module eloop-threshold: # Code from module environ: # Code from module errno: # Code from module euidaccess: @@ -291,6 +292,12 @@ AC_DEFUN([gl_INIT], if test $gl_cv_func___fpending = no; then AC_LIBOBJ([fpending]) fi + gl_FUNC_FREE + if test $REPLACE_FREE = 1; then + AC_LIBOBJ([free]) + gl_PREREQ_FREE + fi + gl_STDLIB_MODULE_INDICATOR([free-posix]) gl_FUNC_FSTATAT if test $HAVE_FSTATAT = 0 || test $REPLACE_FSTATAT = 1; then AC_LIBOBJ([fstatat]) @@ -510,8 +517,8 @@ AC_DEFUN([gl_INIT], gl_gnulib_enabled_260941c0e5dc67ec9e87d1fb321c300b=false gl_gnulib_enabled_cloexec=false gl_gnulib_enabled_dirfd=false + gl_gnulib_enabled_925677f0343de64b89a9f0c790b4104c=false gl_gnulib_enabled_euidaccess=false - gl_gnulib_enabled_ef07dc4b3077c11ea9cef586db4e5955=false gl_gnulib_enabled_getdtablesize=false gl_gnulib_enabled_getgroups=false gl_gnulib_enabled_be453cec5eecf5731a274f2de7f2db36=false @@ -557,6 +564,12 @@ AC_DEFUN([gl_INIT], gl_gnulib_enabled_dirfd=true fi } + func_gl_gnulib_m4code_925677f0343de64b89a9f0c790b4104c () + { + if ! $gl_gnulib_enabled_925677f0343de64b89a9f0c790b4104c; then + gl_gnulib_enabled_925677f0343de64b89a9f0c790b4104c=true + fi + } func_gl_gnulib_m4code_euidaccess () { if ! $gl_gnulib_enabled_euidaccess; then @@ -573,18 +586,6 @@ AC_DEFUN([gl_INIT], func_gl_gnulib_m4code_6099e9737f757db36c47fa9d9f02e88c fi } - func_gl_gnulib_m4code_ef07dc4b3077c11ea9cef586db4e5955 () - { - if ! $gl_gnulib_enabled_ef07dc4b3077c11ea9cef586db4e5955; then - gl_FUNC_FREE - if test $REPLACE_FREE = 1; then - AC_LIBOBJ([free]) - gl_PREREQ_FREE - fi - gl_STDLIB_MODULE_INDICATOR([free-posix]) - gl_gnulib_enabled_ef07dc4b3077c11ea9cef586db4e5955=true - fi - } func_gl_gnulib_m4code_getdtablesize () { if ! $gl_gnulib_enabled_getdtablesize; then @@ -734,7 +735,7 @@ AC_DEFUN([gl_INIT], fi } if test $HAVE_CANONICALIZE_FILE_NAME = 0 || test $REPLACE_CANONICALIZE_FILE_NAME = 1; then - func_gl_gnulib_m4code_ef07dc4b3077c11ea9cef586db4e5955 + func_gl_gnulib_m4code_925677f0343de64b89a9f0c790b4104c fi if test $HAVE_CANONICALIZE_FILE_NAME = 0 || test $REPLACE_CANONICALIZE_FILE_NAME = 1; then func_gl_gnulib_m4code_idx @@ -818,8 +819,8 @@ AC_DEFUN([gl_INIT], AM_CONDITIONAL([gl_GNULIB_ENABLED_260941c0e5dc67ec9e87d1fb321c300b], [$gl_gnulib_enabled_260941c0e5dc67ec9e87d1fb321c300b]) AM_CONDITIONAL([gl_GNULIB_ENABLED_cloexec], [$gl_gnulib_enabled_cloexec]) AM_CONDITIONAL([gl_GNULIB_ENABLED_dirfd], [$gl_gnulib_enabled_dirfd]) + AM_CONDITIONAL([gl_GNULIB_ENABLED_925677f0343de64b89a9f0c790b4104c], [$gl_gnulib_enabled_925677f0343de64b89a9f0c790b4104c]) AM_CONDITIONAL([gl_GNULIB_ENABLED_euidaccess], [$gl_gnulib_enabled_euidaccess]) - AM_CONDITIONAL([gl_GNULIB_ENABLED_ef07dc4b3077c11ea9cef586db4e5955], [$gl_gnulib_enabled_ef07dc4b3077c11ea9cef586db4e5955]) AM_CONDITIONAL([gl_GNULIB_ENABLED_getdtablesize], [$gl_gnulib_enabled_getdtablesize]) AM_CONDITIONAL([gl_GNULIB_ENABLED_getgroups], [$gl_gnulib_enabled_getgroups]) AM_CONDITIONAL([gl_GNULIB_ENABLED_be453cec5eecf5731a274f2de7f2db36], [$gl_gnulib_enabled_be453cec5eecf5731a274f2de7f2db36]) @@ -1020,6 +1021,7 @@ AC_DEFUN([gl_FILE_LIST], [ lib/dtoastr.c lib/dtotimespec.c lib/dup2.c + lib/eloop-threshold.h lib/errno.in.h lib/euidaccess.c lib/execinfo.c commit 5880c7caab394eac55c44d4be42b2f45dbd9bc53 Author: Paul Eggert Date: Fri Dec 25 02:15:45 2020 -0800 Adjust test_module to recent Gnulib changes * test/Makefile.in ($(test_module)): Also compile lib/free.c if it is needed to define rpl_free. diff --git a/test/Makefile.in b/test/Makefile.in index 67d203df29..b6cf6493e3 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -268,6 +268,7 @@ $(test_module): $(test_module:${SO}=.c) ../src/emacs-module.h $(AM_V_CCLD)$(CC) -shared $(CPPFLAGS) $(MODULE_CFLAGS) $(LDFLAGS) \ -o $@ $< $(LIBGMP) \ $(and $(GMP_H),$(srcdir)/../lib/mini-gmp-gnulib.c) \ + $(if $(OMIT_GNULIB_MODULE_free-posix),,$(srcdir)/../lib/free.c) \ $(srcdir)/../lib/timespec.c $(srcdir)/../lib/gettime.c endif commit ec8a17e938c3ef213709ea6b6b3e565333a9c508 Author: Paul Eggert Date: Fri Dec 25 01:38:31 2020 -0800 Adjust to recent Gnulib changes The latest Gnulib merge brought in free-posix, which causes 'free' to preserve errno. This lets us simplify some Emacs code that calls 'free'. * admin/merge-gnulib (GNULIB_MODULES): Add free-posix. This module is pulled in by canonicalize-lgpl anyway, so we might as well rely on it. * lib-src/emacsclient.c (get_current_dir_name): Sync better with src/sysdep.c. * lib-src/etags.c (process_file_name, etags_mktmp): * lib-src/update-game-score.c (unlock_file): * src/fileio.c (file_accessible_directory_p): * src/sysdep.c (get_current_dir_name_or_unreachable): Simplify by assuming that 'free' preserves errno. * src/alloc.c (malloc_unblock_input): Preserve errno, so that xfree preserves errno. * src/sysdep.c (get_current_dir_name_or_unreachable): Simplify by using strdup instead of malloc+memcpy. No need for realloc (and the old code leaked memory anyway on failure); just use free+malloc. diff --git a/admin/merge-gnulib b/admin/merge-gnulib index 164300e1db..880dc5eef5 100755 --- a/admin/merge-gnulib +++ b/admin/merge-gnulib @@ -34,7 +34,8 @@ GNULIB_MODULES=' d-type diffseq double-slash-root dtoastr dtotimespec dup2 environ execinfo explicit_bzero faccessat fchmodat fcntl fcntl-h fdopendir - filemode filename filevercmp flexmember fpieee fstatat fsusage fsync futimens + filemode filename filevercmp flexmember fpieee + free-posix fstatat fsusage fsync futimens getloadavg getopt-gnu getrandom gettime gettimeofday gitlog-to-changelog ieee754-h ignore-value intprops largefile libgmp lstat manywarnings memmem-simple mempcpy memrchr minmax mkostemp mktime nstrftime diff --git a/lib-src/emacsclient.c b/lib-src/emacsclient.c index 871fa7a8d3..8d184e2817 100644 --- a/lib-src/emacsclient.c +++ b/lib-src/emacsclient.c @@ -251,7 +251,6 @@ get_current_dir_name (void) bufsize_max = min (bufsize_max, PATH_MAX); #endif - char *buf; struct stat dotstat, pwdstat; size_t pwdlen; /* If PWD is accurate, use it instead of calling getcwd. PWD is @@ -265,37 +264,23 @@ get_current_dir_name (void) && stat (".", &dotstat) == 0 && dotstat.st_ino == pwdstat.st_ino && dotstat.st_dev == pwdstat.st_dev) - { - buf = xmalloc (strlen (pwd) + 1); - strcpy (buf, pwd); - } + return strdup (pwd); else { - size_t buf_size = 1024; + ptrdiff_t buf_size = min (bufsize_max, 1024); for (;;) - { - int tmp_errno; - buf = malloc (buf_size); - if (! buf) - break; - if (getcwd (buf, buf_size) == buf) - break; - tmp_errno = errno; + { + char *buf = malloc (buf_size); + if (!buf) + return NULL; + if (getcwd (buf, buf_size) == buf) + return buf; free (buf); - if (tmp_errno != ERANGE) - { - errno = tmp_errno; - return NULL; - } - buf_size *= 2; - if (! buf_size) - { - errno = ENOMEM; - return NULL; - } - } + if (errno != ERANGE || buf_size == bufsize_max) + return NULL; + buf_size = buf_size <= bufsize_max / 2 ? 2 * buf_size : bufsize_max; + } } - return buf; } #endif diff --git a/lib-src/etags.c b/lib-src/etags.c index a1c6837e88..071892ee31 100644 --- a/lib-src/etags.c +++ b/lib-src/etags.c @@ -1643,19 +1643,10 @@ process_file_name (char *file, language *lang) char *cmd = concat (cmd1, "' > ", tmp_name); #endif free (cmd1); - int tmp_errno; - if (system (cmd) == -1) - { - inf = NULL; - tmp_errno = EINVAL; - } - else - { - inf = fopen (tmp_name, "r" FOPEN_BINARY); - tmp_errno = errno; - } + inf = (system (cmd) == -1 + ? NULL + : fopen (tmp_name, "r" FOPEN_BINARY)); free (cmd); - errno = tmp_errno; } if (!inf) @@ -7068,9 +7059,7 @@ etags_mktmp (void) int fd = mkostemp (templt, O_CLOEXEC); if (fd < 0 || close (fd) != 0) { - int temp_errno = errno; free (templt); - errno = temp_errno; templt = NULL; } #if defined (DOS_NT) diff --git a/lib-src/update-game-score.c b/lib-src/update-game-score.c index 93aa0393d9..fc6e72838e 100644 --- a/lib-src/update-game-score.c +++ b/lib-src/update-game-score.c @@ -499,9 +499,9 @@ unlock_file (const char *filename, void *state) char *lockpath = (char *) state; int saved_errno = errno; int ret = unlink (lockpath); - int unlink_errno = errno; + if (0 <= ret) + errno = saved_errno; free (lockpath); - errno = ret < 0 ? unlink_errno : saved_errno; return ret; } diff --git a/src/alloc.c b/src/alloc.c index adbfa1883c..0b387dd8c1 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -732,7 +732,11 @@ static void malloc_unblock_input (void) { if (block_input_in_memory_allocators) - unblock_input (); + { + int err = errno; + unblock_input (); + errno = err; + } } # define MALLOC_BLOCK_INPUT malloc_block_input () # define MALLOC_UNBLOCK_INPUT malloc_unblock_input () diff --git a/src/fileio.c b/src/fileio.c index 651e765fca..23b4523c94 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -3050,7 +3050,6 @@ file_accessible_directory_p (Lisp_Object file) ptrdiff_t len = SBYTES (file); char const *dir; bool ok; - int saved_errno; USE_SAFE_ALLOCA; /* Normally a file "FOO" is an accessible directory if "FOO/." exists. @@ -3075,9 +3074,7 @@ file_accessible_directory_p (Lisp_Object file) } ok = file_access_p (dir, F_OK); - saved_errno = errno; SAFE_FREE (); - errno = saved_errno; return ok; #endif /* !DOS_NT */ } diff --git a/src/sysdep.c b/src/sysdep.c index 29c88f5308..eeb9d18494 100644 --- a/src/sysdep.c +++ b/src/sysdep.c @@ -314,33 +314,21 @@ get_current_dir_name_or_unreachable (void) && emacs_fstatat (AT_FDCWD, ".", &dotstat, 0) == 0 && dotstat.st_ino == pwdstat.st_ino && dotstat.st_dev == pwdstat.st_dev) - { - char *buf = malloc (pwdlen + 1); - if (!buf) - return NULL; - return memcpy (buf, pwd, pwdlen + 1); - } + return strdup (pwd); else { ptrdiff_t buf_size = min (bufsize_max, 1024); - char *buf = malloc (buf_size); - if (!buf) - return NULL; for (;;) { + char *buf = malloc (buf_size); + if (!buf) + return NULL; if (getcwd (buf, buf_size) == buf) return buf; - int getcwd_errno = errno; - if (getcwd_errno != ERANGE || buf_size == bufsize_max) - { - free (buf); - errno = getcwd_errno; - return NULL; - } + free (buf); + if (errno != ERANGE || buf_size == bufsize_max) + return NULL; buf_size = buf_size <= bufsize_max / 2 ? 2 * buf_size : bufsize_max; - buf = realloc (buf, buf_size); - if (!buf) - return NULL; } } } commit b8b17038e140fe215a76f2e899c00b9b95614886 Author: Paul Eggert Date: Fri Dec 25 00:27:37 2020 -0800 Pacify gcc 10.2 -Wanalyzer-null-argument in gtkutil.c * src/gtkutil.c (xg_item_label_same_p): Simplify. Without this simplification, GCC (Ubuntu 10.2.0-13ubuntu1) -Wanalyzer-null-argument complains about use of NULL where non-null expected as argument of strcmp. diff --git a/src/gtkutil.c b/src/gtkutil.c index fafd94c0f7..807ee17fa3 100644 --- a/src/gtkutil.c +++ b/src/gtkutil.c @@ -2944,14 +2944,11 @@ xg_get_menu_item_label (GtkMenuItem *witem) static bool xg_item_label_same_p (GtkMenuItem *witem, const char *label) { - bool is_same = 0; char *utf8_label = get_utf8_string (label); const char *old_label = witem ? xg_get_menu_item_label (witem) : 0; - if (! old_label && ! utf8_label) - is_same = 1; - else if (old_label && utf8_label) - is_same = strcmp (utf8_label, old_label) == 0; + bool is_same = (!old_label == !utf8_label + && (!old_label || strcmp (utf8_label, old_label) == 0)); if (utf8_label) g_free (utf8_label); commit e0fc939c5f1f65cfd0ef18bb0498c41ece7cef25 Author: Eli Zaretskii Date: Fri Dec 25 10:30:02 2020 +0200 Add more details to the "word processor" section * etc/TODO (Emacs as word processor): Add more details based on recent discussions. diff --git a/etc/TODO b/etc/TODO index 5c6a210f2d..19f9f79bf4 100644 --- a/etc/TODO +++ b/etc/TODO @@ -242,6 +242,36 @@ https://lists.gnu.org/r/emacs-devel/2013-11/msg00515.html processing. That is why we added text properties and variable width fonts. However, more features are still needed to achieve this. +Specifically, a major mode with the following features and abilities +should be added to Emacs: + + . import / export MS Office documents + . import / export Open Document Format (.odt) files + . import / export RTF files + . export to a PDF file + . select a font and its size + . apply a bold / italic / underline / strikethrough effect + . superscripts / subscripts + . apply a left / center / right / justified effect + . change the font color and the background color + . pixel-level text fill, justification, and indentation (so that + variable-pitch fonts could be freely used) + . create a list + . insert and change a table + . insert a picture + . define / use / modify styles + . print preview / print, in a way that is similar to what's on screen + (e.g., wrt the place where lines wrap) + . use footnotes + . support for "track changes" markings, including those which come + from Office documents + . multiple columns + . change page headers and footers + . save all the properties and settings mentioned above with the text + to a file, so that they are restored when later visiting that file + +The existing Enriched mode can be used as a starting point. + ** Support ligatures out of the box For the list of frequently-used typographical ligatures, see commit fda9b3e83a434706c31ab1bee5c15511c0181d5a Author: Philipp Stephani Date: Wed Dec 23 19:15:56 2020 +0100 * src/Makefile.in (DO_CODESIGN): Fix expected architecture name. diff --git a/src/Makefile.in b/src/Makefile.in index cfd322a41f..eb6d2f0e91 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -339,7 +339,7 @@ HAVE_PDUMPER = @HAVE_PDUMPER@ ## ARM Macs require that all code have a valid signature. Since pump ## invalidates the signature, we must re-sign to fix it. -DO_CODESIGN=$(patsubst aarch64-apple-darwin%,yes,@configuration@) +DO_CODESIGN=$(patsubst arm-apple-darwin%,yes,@configuration@) # 'make' verbosity. AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ commit 6bf22c933df642f20969b17036f8da784276f588 Author: Itai Seggev Date: Tue Nov 24 06:52:27 2020 +0100 Codesign the executable on recene MacOS systems * src/Makefile.in (temacs$(EXEEXT)): Codesign the executable on recent (ARM) MacOS systems (bug#43878). Without this, building Emacs fails. Copyright-paperwork-exempt: yes diff --git a/src/Makefile.in b/src/Makefile.in index ab63b92627..cfd322a41f 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -337,6 +337,10 @@ DUMPING=@DUMPING@ CHECK_STRUCTS = @CHECK_STRUCTS@ HAVE_PDUMPER = @HAVE_PDUMPER@ +## ARM Macs require that all code have a valid signature. Since pump +## invalidates the signature, we must re-sign to fix it. +DO_CODESIGN=$(patsubst aarch64-apple-darwin%,yes,@configuration@) + # 'make' verbosity. AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ @@ -653,6 +657,9 @@ temacs$(EXEEXT): $(LIBXMENU) $(ALLOBJS) $(LIBEGNU_ARCHIVE) $(EMACSRES) \ $(ALLOBJS) $(LIBEGNU_ARCHIVE) $(W32_RES_LINK) $(LIBES) ifeq ($(HAVE_PDUMPER),yes) $(AM_V_at)$(MAKE_PDUMPER_FINGERPRINT) $@.tmp +ifeq ($(DO_CODESIGN),yes) + codesign -s - -f $@.tmp +endif endif $(AM_V_at)mv $@.tmp $@ $(MKDIR_P) $(etc) commit 5d46593568073b43fb0a901cbd7e019a1797cf93 Author: Lars Ingebrigtsen Date: Mon Sep 14 12:34:56 2020 +0200 Support build of Emacs on ARM Macos machines * configure.ac: Add support for aarch64-* on Macos (i.e., 64-bit ARM) (bug#43369). diff --git a/configure.ac b/configure.ac index e93a3331b7..c683e31f68 100644 --- a/configure.ac +++ b/configure.ac @@ -703,7 +703,7 @@ case "${canonical}" in *-apple-darwin* ) case "${canonical}" in *-apple-darwin[0-9].*) unported=yes ;; - i[3456]86-* | x86_64-* ) ;; + i[3456]86-* | x86_64-* | arm-* | aarch64-* ) ;; * ) unported=yes ;; esac opsys=darwin commit 7f8793e5f1c69cf9311479e69d18a62ae87e35ce Author: Bastien Guerry Date: Tue Dec 22 10:29:37 2020 +0100 Update to Org 9.4.4 diff --git a/lisp/org/org-agenda.el b/lisp/org/org-agenda.el index 83f30bf96a..2da6451523 100644 --- a/lisp/org/org-agenda.el +++ b/lisp/org/org-agenda.el @@ -10751,8 +10751,4 @@ when defining today." (provide 'org-agenda) -;; Local variables: -;; generated-autoload-file: "org-loaddefs.el" -;; End: - ;;; org-agenda.el ends here diff --git a/lisp/org/org-capture.el b/lisp/org/org-capture.el index a9a1181935..d3dc0ab3e7 100644 --- a/lisp/org/org-capture.el +++ b/lisp/org/org-capture.el @@ -1947,8 +1947,4 @@ Assume sexps have been marked with (provide 'org-capture) -;; Local variables: -;; generated-autoload-file: "org-loaddefs.el" -;; End: - ;;; org-capture.el ends here diff --git a/lisp/org/org-macs.el b/lisp/org/org-macs.el index 506fba8aaf..d397e3ed05 100644 --- a/lisp/org/org-macs.el +++ b/lisp/org/org-macs.el @@ -377,18 +377,25 @@ error when the user input is empty." 'org-time-stamp-inactive) (apply #'completing-read args))) -(defun org--mks-read-key (allowed-keys prompt) +(defun org--mks-read-key (allowed-keys prompt navigation-keys) "Read a key and ensure it is a member of ALLOWED-KEYS. +Enable keys to scroll the window if NAVIGATION-KEYS is set. TAB, SPC and RET are treated equivalently." - (let* ((key (char-to-string - (pcase (read-char-exclusive prompt) - ((or ?\s ?\t ?\r) ?\t) - (char char))))) - (if (member key allowed-keys) - key - (message "Invalid key: `%s'" key) - (sit-for 1) - (org--mks-read-key allowed-keys prompt)))) + (setq header-line-format (when navigation-keys "Use C-n, C-p, C-v, M-v to navigate.")) + (let ((char-key (read-char-exclusive prompt))) + (if (and navigation-keys (memq char-key '(14 16 22 134217846))) + (progn + (org-scroll char-key) + (org--mks-read-key allowed-keys prompt navigation-keys)) + (let ((key (char-to-string + (pcase char-key + ((or ?\s ?\t ?\r) ?\t) + (char char))))) + (if (member key allowed-keys) + key + (message "Invalid key: `%s'" key) + (sit-for 1) + (org--mks-read-key allowed-keys prompt navigation-keys)))))) (defun org-mks (table title &optional prompt specials) "Select a member of an alist with multiple keys. @@ -461,15 +468,13 @@ is selected, only the bare key is returned." ;; Display UI and let user select an entry or ;; a sub-level prefix. (goto-char (point-min)) - (setq header-line-format nil) (org-fit-window-to-buffer) - (unless (pos-visible-in-window-p (1- (point-max))) - (setq header-line-format "Use C-n, C-p or C-v to navigate.") - (setq allowed-keys (append allowed-keys '("\C-n" "\C-p" "\C-v")))) - (let ((pressed (org--mks-read-key allowed-keys prompt))) - (while (and (member pressed '("\C-n" "\C-p" "\C-v"))) - (org-scroll (string-to-char pressed)) - (setq pressed (org--mks-read-key allowed-keys prompt))) + (message "") ; With this line the prompt appears in + ; the minibuffer. Else keystrokes may + ; appear, which is spurious. + (let ((pressed (org--mks-read-key + allowed-keys prompt + (not (pos-visible-in-window-p (1- (point-max))))))) (setq current (concat current pressed)) (cond ((equal pressed "\C-g") (user-error "Abort")) diff --git a/lisp/org/org-version.el b/lisp/org/org-version.el index 479ca46085..25b3354bdd 100644 --- a/lisp/org/org-version.el +++ b/lisp/org/org-version.el @@ -5,13 +5,13 @@ (defun org-release () "The release version of Org. Inserted by installing Org mode or when a release is made." - (let ((org-release "9.4.3")) + (let ((org-release "9.4.4")) org-release)) ;;;###autoload (defun org-git-version () "The Git version of Org mode. Inserted by installing Org or when a release is made." - (let ((org-git-version "release_9.4.3")) + (let ((org-git-version "release_9.4.4")) org-git-version)) (provide 'org-version) commit 7b3367a0b5727170a7b3f1aca022b992174cd426 Author: Stefan Kangas Date: Mon Dec 21 18:44:40 2020 +0100 * lisp/so-long.el: Decrease use of passive voice. Suggested by Richard Stallman . diff --git a/lisp/so-long.el b/lisp/so-long.el index c800c7a143..ad0f6e2add 100644 --- a/lisp/so-long.el +++ b/lisp/so-long.el @@ -41,9 +41,9 @@ ;; simply aren't optimised (remotely) for this scenario, so performance can ;; suffer significantly. ;; -;; When such files are detected, the command `so-long' is automatically called, -;; overriding certain minor modes and variables with performance implications -;; (all configurable), in order to enhance performance in the buffer. +;; When so-long detects such a file, it calls the command `so-long', which +;; overrides certain minor modes and variables (you can configure the details) +;; to improve performance in the buffer. ;; ;; The default action enables the major mode `so-long-mode' in place of the mode ;; that Emacs selected. This ensures that the original major mode cannot affect commit a90836c6386f6b35c0d36c720a529292090cf690 Author: Stefan Kangas Date: Mon Dec 21 15:57:30 2020 +0100 * doc/misc/efaq.texi (New in Emacs 27): Add section. diff --git a/doc/misc/efaq.texi b/doc/misc/efaq.texi index 0fc91933f4..e9703e7519 100644 --- a/doc/misc/efaq.texi +++ b/doc/misc/efaq.texi @@ -901,6 +901,7 @@ status of its latest version. @menu * Origin of the term Emacs:: * Latest version of Emacs:: +* New in Emacs 27:: * New in Emacs 26:: * New in Emacs 25:: * New in Emacs 24:: @@ -970,6 +971,63 @@ Emacs, type @kbd{C-h C-n} (@kbd{M-x view-emacs-news}). As of Emacs 22, you can give this command a prefix argument to read about which features were new in older versions. +@node New in Emacs 27 +@section What is different about Emacs 27? +@cindex Differences between Emacs 26 and Emacs 27 +@cindex Emacs 27, new features in + +@itemize +@cindex bignum support +@item +Emacs now uses the GNU Multiple Precision (@acronym{GMP}) library to +support integers whose size is too large to support natively. The +integers supported natively are known as ``fixnums'', while the larger +ones are ``bignums''. All the arithmetic, comparison, and logical +(also known as ``bitwise'') operations where bignums make sense now +support both fixnums and bignums. + +@cindex HarfBuzz +@item +Emacs now uses HarfBuzz as its default shaping engine. + +@cindex JSON, native parsing +@item +Native support for @acronym{JSON} parsing that is much faster than +@file{json.el}. + +@item +Cairo drawing is no longer experimental. + +@cindex portable dumper +@item +Emacs now uses a ``portable dumper'' instead of unexec. This improves +compatibility with memory allocation on modern systems, and in +particular better supports the Address Space Layout Randomization +(@acronym{ASLR}) feature, a security technique used by most modern +operating systems. + +@cindex XDG convention +@item +Emacs can now use the @acronym{XDG} convention for init files. + +@cindex early init file +@item +Emacs can now be configured using an early init file. The primary +purpose is to allow customizing how the package system is initialized +given that initialization now happens before loading the regular init +file. + +@cindex tabs +@item +Built-in support for tabs (tab bar and tab line). + +@item +Support for resizing and rotating of images without ImageMagick. +@end itemize + +Consult the Emacs @file{NEWS} file (@kbd{C-h n}) for the full list of +changes in Emacs 27. + @node New in Emacs 26 @section What is different about Emacs 26? @cindex Differences between Emacs 25 and Emacs 26 commit 711fe70dd8bcee840ba9b91e85eac56b97850ada Author: Stefan Kangas Date: Mon Dec 21 15:43:05 2020 +0100 * doc/misc/efaq.texi (Latest version of Emacs): Bump version. diff --git a/doc/misc/efaq.texi b/doc/misc/efaq.texi index f948a489f4..0fc91933f4 100644 --- a/doc/misc/efaq.texi +++ b/doc/misc/efaq.texi @@ -951,7 +951,7 @@ conventions}). Emacs @value{EMACSVER} is the current version as of this writing. A version number with two components (e.g., @samp{24.5}) indicates a released version; three components indicate a development -version (e.g., @samp{27.0.50} is what will eventually become @samp{27.1}). +version (e.g., @samp{28.0.50} is what will eventually become @samp{28.1}). Emacs is under active development, hosted at @uref{https://savannah.gnu.org/projects/emacs/, Savannah}. commit 52b30834fb1cf7bb20ed08ec8dc7d2d9b8a770e6 Author: Eli Zaretskii Date: Sat Dec 19 20:54:11 2020 +0200 * lisp/face-remap.el (face-remap-set-base): Doc fix. (Bug#45264) diff --git a/lisp/face-remap.el b/lisp/face-remap.el index 028269a4b0..cfda6428c3 100644 --- a/lisp/face-remap.el +++ b/lisp/face-remap.el @@ -33,7 +33,7 @@ ;; ;; (face RELATIVE_SPECS_1 RELATIVE_SPECS_2 ... BASE_SPECS) ;; -;; The "specs" values are a lists of face names or face attribute-value +;; The "specs" values are lists of face names or face attribute-value ;; pairs, and are merged together, with earlier values taking precedence. ;; ;; The RELATIVE_SPECS_* values are added by `face-remap-add-relative' @@ -183,13 +183,13 @@ to apply on top of the normal definition of FACE." This causes the remappings specified by `face-remap-add-relative' to apply on top of the face specification given by SPECS. -The remaining arguments, SPECS, should form a list of faces. -Each list element should be either a face name or a property list +The remaining arguments, SPECS, specify the base of the remapping. +Each one of SPECS should be either a face name or a property list of face attribute/value pairs, like in a `face' text property. -If SPECS is empty, call `face-remap-reset-base' to use the normal -definition of FACE as the base remapping; note that this is -different from SPECS containing a single value nil, which means +If SPECS is empty or a single face `eq' to FACE, call `face-remap-reset-base' +to use the normal definition of FACE as the base remapping; note that +this is different from SPECS containing a single value nil, which means not to inherit from the global definition of FACE at all." (while (and (consp specs) (not (null (car specs))) (null (cdr specs))) (setq specs (car specs))) commit b3fe0ac62e97ea2e05fc2767989dbd7e83bc0e5c Author: Vasilij Schneidermann Date: Sat Dec 19 17:57:50 2020 +0100 Correct argument order in comment * etc/ETAGS.EBNF (position): Correct comment. diff --git a/etc/ETAGS.EBNF b/etc/ETAGS.EBNF index 80deb16218..04db4e3dc8 100644 --- a/etc/ETAGS.EBNF +++ b/etc/ETAGS.EBNF @@ -52,7 +52,7 @@ pattern ::= regstring /* a tag pattern */ tagname ::= regchar regstring /* a tag name */ -position ::= realposition | "," /* charpos,linepos */ +position ::= realposition | "," /* linepos,charpos */ realposition ::= "," unsint | unsint "," | unsint "," unsint