Now on revision 110201. ------------------------------------------------------------ revno: 110201 author: Wilson Snyder committer: Chong Yidong branch nick: trunk timestamp: Wed 2012-09-26 11:32:51 +0800 message: Synch verilog-mode.el to latest upstream version. * verilog-mode.el (verilog-auto-ascii-enum, verilog-auto-inout) (verilog-auto-input, verilog-auto-insert-lisp) (verilog-auto-output, verilog-auto-output-every, verilog-auto-reg) (verilog-auto-reg-input, verilog-auto-tieoff, verilog-auto-undef) (verilog-auto-unused, verilog-auto-wire) (verilog-forward-or-insert-line): Fix AUTOs with no trailing newline. Reported by Andrew Jones. (verilog-auto-inst) Support expanding $clog2 in AUTOINST. Reported by Brad Dobbie. (verilog-batch-delete-trailing-whitespace): Create verilog-batch-delete-trailing-whitespace. Reported by Brad Dobbie. (verilog-auto-inout-param): Support AUTOINOUTPARAM for copying parameters from another module. Reported by Dan Katz. (verilog-auto, verilog-auto-assign-modport) (verilog-auto-inout-modport): Add AUTOASSIGNMODPORT and AUTOINOUTMODPORT for UVM interface module shell generation. Reported by Brad Dobbie. (verilog-auto-inst-interfaced-ports): Make default nil, as more standard behavior. (verilog-auto): Fix AUTO parameters with parenthesis arguments. Reported by Matt Martin. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2012-09-25 08:20:05 +0000 +++ lisp/ChangeLog 2012-09-26 03:32:51 +0000 @@ -1,3 +1,28 @@ +2012-09-25 Wilson Snyder + + * verilog-mode.el (verilog-auto-ascii-enum, verilog-auto-inout) + (verilog-auto-input, verilog-auto-insert-lisp) + (verilog-auto-output, verilog-auto-output-every, verilog-auto-reg) + (verilog-auto-reg-input, verilog-auto-tieoff, verilog-auto-undef) + (verilog-auto-unused, verilog-auto-wire) + (verilog-forward-or-insert-line): Fix AUTOs with no trailing + newline. Reported by Andrew Jones. + (verilog-auto-inst) Support expanding $clog2 in AUTOINST. + Reported by Brad Dobbie. + (verilog-batch-delete-trailing-whitespace): Create + verilog-batch-delete-trailing-whitespace. Reported by Brad + Dobbie. + (verilog-auto-inout-param): Support AUTOINOUTPARAM for copying + parameters from another module. Reported by Dan Katz. + (verilog-auto, verilog-auto-assign-modport) + (verilog-auto-inout-modport): Add AUTOASSIGNMODPORT and + AUTOINOUTMODPORT for UVM interface module shell generation. + Reported by Brad Dobbie. + (verilog-auto-inst-interfaced-ports): Make default nil, as more + standard behavior. + (verilog-auto): Fix AUTO parameters with parenthesis arguments. + Reported by Matt Martin. + 2012-09-25 Martin Rudalics * window.el (window--resize-child-windows): When resizing child === modified file 'lisp/progmodes/verilog-mode.el' --- lisp/progmodes/verilog-mode.el 2012-09-17 05:41:04 +0000 +++ lisp/progmodes/verilog-mode.el 2012-09-26 03:32:51 +0000 @@ -123,11 +123,11 @@ ;;; Code: ;; This variable will always hold the version number of the mode -(defconst verilog-mode-version "800" +(defconst verilog-mode-version (substring "$$Revision: 820 $$" 12 -3) "Version of this Verilog mode.") -(defconst verilog-mode-release-date "2012-04-23-GNU" +(defconst verilog-mode-release-date (substring "$$Date: 2012-09-17 20:43:10 -0400 (Mon, 17 Sep 2012) $$" 8 -3) "Release date of this Verilog mode.") -(defconst verilog-mode-release-emacs t +(defconst verilog-mode-release-emacs nil "If non-nil, this version of Verilog mode was released with Emacs itself.") (defun verilog-version () @@ -1127,7 +1127,7 @@ :type 'integer) (put 'verilog-auto-inst-column 'safe-local-variable 'integerp) -(defcustom verilog-auto-inst-interfaced-ports t +(defcustom verilog-auto-inst-interfaced-ports nil "Non-nil means include interfaced ports in AUTOINST expansions." :group 'verilog-mode-auto :type 'boolean) @@ -1431,12 +1431,18 @@ :help "Help on AUTOARG - declaring module port list"] ["AUTOASCIIENUM" (describe-function 'verilog-auto-ascii-enum) :help "Help on AUTOASCIIENUM - creating ASCII for enumerations"] + ["AUTOASSIGNMODPORT" (describe-function 'verilog-auto-assign-modport) + :help "Help on AUTOASSIGNMODPORT - creating assignments to/from modports"] ["AUTOINOUTCOMP" (describe-function 'verilog-auto-inout-comp) :help "Help on AUTOINOUTCOMP - copying complemented i/o from another file"] ["AUTOINOUTIN" (describe-function 'verilog-auto-inout-in) - :help "Help on AUTOINOUTCOMP - copying i/o from another file as all inputs"] + :help "Help on AUTOINOUTIN - copying i/o from another file as all inputs"] + ["AUTOINOUTMODPORT" (describe-function 'verilog-auto-inout-modport) + :help "Help on AUTOINOUTMODPORT - copying i/o from an interface modport"] ["AUTOINOUTMODULE" (describe-function 'verilog-auto-inout-module) :help "Help on AUTOINOUTMODULE - copying i/o from another file"] + ["AUTOINOUTPARAM" (describe-function 'verilog-auto-inout-param) + :help "Help on AUTOINOUTPARAM - copying parameters from another file"] ["AUTOINSERTLISP" (describe-function 'verilog-auto-insert-lisp) :help "Help on AUTOINSERTLISP - insert text from a lisp function"] ["AUTOINOUT" (describe-function 'verilog-auto-inout) @@ -1706,12 +1712,19 @@ ;;(verilog-re-search-backward-substr "-end" "get-end-of" nil t) ;;-end (test bait) (defun verilog-delete-trailing-whitespace () - "Delete trailing spaces or tabs, but not newlines nor linefeeds." + "Delete trailing spaces or tabs, but not newlines nor linefeeds. +Also add missing final newline. + +To call this from the command line, see \\[verilog-batch-diff-auto]. + +To call on \\[verilog-auto], set `verilog-auto-delete-trailing-whitespace'." ;; Similar to `delete-trailing-whitespace' but that's not present in XEmacs (save-excursion (goto-char (point-min)) (while (re-search-forward "[ \t]+$" nil t) ;; Not syntactic WS as no formfeed - (replace-match "" nil nil)))) + (replace-match "" nil nil)) + (goto-char (point-max)) + (unless (bolp) (insert "\n")))) (defvar compile-command) @@ -5128,6 +5141,15 @@ (error "Use verilog-batch-delete-auto only with --batch")) ;; Otherwise we'd mess up buffer modes (verilog-batch-execute-func `verilog-delete-auto)) +(defun verilog-batch-delete-trailing-whitespace () + "For use with --batch, perform whitespace deletion as a stand-alone tool. +This sets up the appropriate Verilog mode environment, removes +whitespace with \\[verilog-delete-trailing-whitespace] on all +command-line files, and saves the buffers." + (unless noninteractive + (error "Use verilog-batch-delete-trailing-whitepace only with --batch")) ;; Otherwise we'd mess up buffer modes + (verilog-batch-execute-func `verilog-delete-trailing-whitespace)) + (defun verilog-batch-diff-auto () "For use with --batch, perform automatic differences as a stand-alone tool. This sets up the appropriate Verilog mode environment, expand automatics @@ -7479,6 +7501,19 @@ (defsubst verilog-alw-get-uses-delayed (sigs) (aref sigs 0)) +(defsubst verilog-modport-new (name clockings decls) + (list name clockings decls)) +(defsubst verilog-modport-name (sig) + (car sig)) +(defsubst verilog-modport-clockings (sig) + (nth 1 sig)) ;; Returns list of names +(defsubst verilog-modport-clockings-add (sig val) + (setcar (nthcdr 1 sig) (cons val (nth 1 sig)))) +(defsubst verilog-modport-decls (sig) + (nth 2 sig)) ;; Returns verilog-decls-* structure +(defsubst verilog-modport-decls-set (sig val) + (setcar (nthcdr 2 sig) val)) + (defsubst verilog-modi-new (name fob pt type) (vector name fob pt type)) (defsubst verilog-modi-name (modi) @@ -7496,8 +7531,15 @@ ;; Signal reading for given module ;; Note these all take modi's - as returned from verilog-modi-current -(defsubst verilog-decls-new (out inout in vars unuseds assigns consts gparams interfaces) - (vector out inout in vars unuseds assigns consts gparams interfaces)) +(defsubst verilog-decls-new (out inout in vars modports assigns consts gparams interfaces) + (vector out inout in vars modports assigns consts gparams interfaces)) +(defsubst verilog-decls-append (a b) + (cond ((not a) b) ((not b) a) + (t (vector (append (aref a 0) (aref b 0)) (append (aref a 1) (aref b 1)) + (append (aref a 2) (aref b 2)) (append (aref a 3) (aref b 3)) + (append (aref a 4) (aref b 4)) (append (aref a 5) (aref b 5)) + (append (aref a 6) (aref b 6)) (append (aref a 7) (aref b 7)) + (append (aref a 8) (aref b 8)))))) (defsubst verilog-decls-get-outputs (decls) (aref decls 0)) (defsubst verilog-decls-get-inouts (decls) @@ -7506,8 +7548,8 @@ (aref decls 2)) (defsubst verilog-decls-get-vars (decls) (aref decls 3)) -;;(defsubst verilog-decls-get-unused (decls) -;; (aref decls 4)) +(defsubst verilog-decls-get-modports (decls) ;; Also for clocking blocks; contains another verilog-decls struct + (aref decls 4)) ;; Returns verilog-modport* structure (defsubst verilog-decls-get-assigns (decls) (aref decls 5)) (defsubst verilog-decls-get-consts (decls) @@ -7517,6 +7559,7 @@ (defsubst verilog-decls-get-interfaces (decls) (aref decls 8)) + (defsubst verilog-subdecls-new (out inout in intf intfd) (vector out inout in intf intfd)) (defsubst verilog-subdecls-get-outputs (subdecls) @@ -7535,6 +7578,36 @@ (mapcar (lambda (name) (verilog-sig-new name nil nil nil nil nil nil nil nil)) signame-list)) +(defun verilog-signals-in (in-list not-list) + "Return list of signals in IN-LIST that are also in NOT-LIST. +Also remove any duplicates in IN-LIST. +Signals must be in standard (base vector) form." + ;; This function is hot, so implemented as O(1) + (cond ((eval-when-compile (fboundp 'make-hash-table)) + (let ((ht (make-hash-table :test 'equal :rehash-size 4.0)) + (ht-not (make-hash-table :test 'equal :rehash-size 4.0)) + out-list) + (while not-list + (puthash (car (car not-list)) t ht-not) + (setq not-list (cdr not-list))) + (while in-list + (when (and (gethash (verilog-sig-name (car in-list)) ht-not) + (not (gethash (verilog-sig-name (car in-list)) ht))) + (setq out-list (cons (car in-list) out-list)) + (puthash (verilog-sig-name (car in-list)) t ht)) + (setq in-list (cdr in-list))) + (nreverse out-list))) + ;; Slower Fallback if no hash tables (pre Emacs 21.1/XEmacs 21.4) + (t + (let (out-list) + (while in-list + (if (and (assoc (verilog-sig-name (car in-list)) not-list) + (not (assoc (verilog-sig-name (car in-list)) out-list))) + (setq out-list (cons (car in-list) out-list))) + (setq in-list (cdr in-list))) + (nreverse out-list))))) +;;(verilog-signals-in '(("A" "") ("B" "") ("DEL" "[2:3]")) '(("DEL" "") ("C" ""))) + (defun verilog-signals-not-in (in-list not-list) "Return list of signals in IN-LIST that aren't also in NOT-LIST. Also remove any duplicates in IN-LIST. @@ -7556,8 +7629,8 @@ (t (let (out-list) (while in-list - (if (not (or (assoc (verilog-sig-name (car in-list)) not-list) - (assoc (verilog-sig-name (car in-list)) out-list))) + (if (and (not (assoc (verilog-sig-name (car in-list)) not-list)) + (not (assoc (verilog-sig-name (car in-list)) out-list))) (setq out-list (cons (car in-list) out-list))) (setq in-list (cdr in-list))) (nreverse out-list))))) @@ -7702,30 +7775,35 @@ ;; Dumping ;; -(defun verilog-decls-princ (decls) +(defun verilog-decls-princ (decls &optional header prefix) "For debug, dump the `verilog-read-decls' structure DECLS." - (verilog-signals-princ (verilog-decls-get-outputs decls) - "Outputs:\n" " ") - (verilog-signals-princ (verilog-decls-get-inouts decls) - "Inout:\n" " ") - (verilog-signals-princ (verilog-decls-get-inputs decls) - "Inputs:\n" " ") - (verilog-signals-princ (verilog-decls-get-vars decls) - "Vars:\n" " ") - (verilog-signals-princ (verilog-decls-get-assigns decls) - "Assigns:\n" " ") - (verilog-signals-princ (verilog-decls-get-consts decls) - "Consts:\n" " ") - (verilog-signals-princ (verilog-decls-get-gparams decls) - "Gparams:\n" " ") - (verilog-signals-princ (verilog-decls-get-interfaces decls) - "Interfaces:\n" " ") - (princ "\n")) + (when decls + (if header (princ header)) + (setq prefix (or prefix "")) + (verilog-signals-princ (verilog-decls-get-outputs decls) + (concat prefix "Outputs:\n") (concat prefix " ")) + (verilog-signals-princ (verilog-decls-get-inouts decls) + (concat prefix "Inout:\n") (concat prefix " ")) + (verilog-signals-princ (verilog-decls-get-inputs decls) + (concat prefix "Inputs:\n") (concat prefix " ")) + (verilog-signals-princ (verilog-decls-get-vars decls) + (concat prefix "Vars:\n") (concat prefix " ")) + (verilog-signals-princ (verilog-decls-get-assigns decls) + (concat prefix "Assigns:\n") (concat prefix " ")) + (verilog-signals-princ (verilog-decls-get-consts decls) + (concat prefix "Consts:\n") (concat prefix " ")) + (verilog-signals-princ (verilog-decls-get-gparams decls) + (concat prefix "Gparams:\n") (concat prefix " ")) + (verilog-signals-princ (verilog-decls-get-interfaces decls) + (concat prefix "Interfaces:\n") (concat prefix " ")) + (verilog-modport-princ (verilog-decls-get-modports decls) + (concat prefix "Modports:\n") (concat prefix " ")) + (princ "\n"))) (defun verilog-signals-princ (signals &optional header prefix) "For debug, dump internal SIGNALS structures, with HEADER and PREFIX." (when signals - (princ header) + (if header (princ header)) (while signals (let ((sig (car signals))) (setq signals (cdr signals)) @@ -7741,6 +7819,21 @@ (princ " modp=") (princ (verilog-sig-modport sig)) (princ "\n"))))) +(defun verilog-modport-princ (modports &optional header prefix) + "For debug, dump internal MODPORT structures, with HEADER and PREFIX." + (when modports + (if header (princ header)) + (while modports + (let ((sig (car modports))) + (setq modports (cdr modports)) + (princ prefix) + (princ "\"") (princ (verilog-modport-name sig)) (princ "\"") + (princ " clockings=") (princ (verilog-modport-clockings sig)) + (princ "\n") + (verilog-decls-princ (verilog-modport-decls sig) + (concat prefix " syms:\n") + (concat prefix " ")))))) + ;; ;; Port/Wire/Etc Reading ;; @@ -7851,11 +7944,12 @@ Return an array of [outputs inouts inputs wire reg assign const]." (let ((end-mod-point (or (verilog-get-end-of-defun t) (point-max))) (functask 0) (paren 0) (sig-paren 0) (v2kargs-ok t) - in-modport ptype ign-prop + in-modport in-clocking ptype ign-prop sigs-in sigs-out sigs-inout sigs-var sigs-assign sigs-const - sigs-gparam sigs-intf + sigs-gparam sigs-intf sigs-modports vec expect-signal keywd newsig rvalue enum io signed typedefed multidim - modport) + modport + varstack tmp) (save-excursion (verilog-beg-of-defun-quick) (setq sigs-const (verilog-read-auto-constants (point) end-mod-point)) @@ -7881,6 +7975,17 @@ (or (re-search-forward "[^\\]\"" nil t) ;; don't forward-char first, since we look for a non backslash first (error "%s: Unmatched quotes, at char %d" (verilog-point-text) (point)))) ((eq ?\; (following-char)) + (when (and in-modport (not (eq in-modport t))) ;; end of a modport declaration + (verilog-modport-decls-set + in-modport + (verilog-decls-new sigs-out sigs-inout sigs-in + nil nil nil nil nil nil)) + ;; Pop from varstack to restore state to pre-clocking + (setq tmp (car varstack) + varstack (cdr varstack) + sigs-out (aref tmp 0) + sigs-inout (aref tmp 1) + sigs-in (aref tmp 2))) (setq vec nil io nil expect-signal nil newsig nil paren 0 rvalue nil v2kargs-ok nil in-modport nil ign-prop nil) (forward-char 1)) @@ -7974,15 +8079,17 @@ (setq signed keywd)) ((member keywd '("assert" "assume" "cover" "expect" "restrict")) (setq ign-prop t)) - ((member keywd '("class" "clocking" "covergroup" "function" + ((member keywd '("class" "covergroup" "function" "property" "randsequence" "sequence" "task")) (unless ign-prop (setq functask (1+ functask)))) - ((member keywd '("endclass" "endclocking" "endgroup" "endfunction" + ((member keywd '("endclass" "endgroup" "endfunction" "endproperty" "endsequence" "endtask")) (setq functask (1- functask))) ((equal keywd "modport") (setq in-modport t)) + ((equal keywd "clocking") + (setq in-clocking t)) ((equal keywd "type") (setq ptype t)) ;; Ifdef? Ignore name of define @@ -8008,11 +8115,47 @@ (goto-char (match-end 0)) (when (not rvalue) (setq expect-signal nil))) + ;; "modport " + ((and (eq in-modport t) + (not (member keywd verilog-keywords))) + (setq in-modport (verilog-modport-new keywd nil nil)) + (setq sigs-modports (cons in-modport sigs-modports)) + ;; Push old sig values to stack and point to new signal list + (setq varstack (cons (vector sigs-out sigs-inout sigs-in) + varstack)) + (setq sigs-in nil sigs-inout nil sigs-out nil)) + ;; "modport x (clocking )" + ((and in-modport in-clocking) + (verilog-modport-clockings-add in-modport keywd) + (setq in-clocking nil)) + ;; endclocking + ((and in-clocking + (equal keywd "endclocking")) + (unless (eq in-clocking t) + (verilog-modport-decls-set + in-clocking + (verilog-decls-new sigs-out sigs-inout sigs-in + nil nil nil nil nil nil)) + ;; Pop from varstack to restore state to pre-clocking + (setq tmp (car varstack) + varstack (cdr varstack) + sigs-out (aref tmp 0) + sigs-inout (aref tmp 1) + sigs-in (aref tmp 2))) + (setq in-clocking nil)) + ;; "clocking " + ((and (eq in-clocking t) + (not (member keywd verilog-keywords))) + (setq in-clocking (verilog-modport-new keywd nil nil)) + (setq sigs-modports (cons in-clocking sigs-modports)) + ;; Push old sig values to stack and point to new signal list + (setq varstack (cons (vector sigs-out sigs-inout sigs-in) + varstack)) + (setq sigs-in nil sigs-inout nil sigs-out nil)) ;; New signal, maybe? ((and expect-signal (not rvalue) (eq functask 0) - (not in-modport) (not (member keywd verilog-keywords))) ;; Add new signal to expect-signal's variable (setq newsig (verilog-sig-new keywd vec nil nil enum signed typedefed multidim modport)) @@ -8022,15 +8165,17 @@ (forward-char 1))) (skip-syntax-forward " ")) ;; Return arguments - (verilog-decls-new (nreverse sigs-out) - (nreverse sigs-inout) - (nreverse sigs-in) - (nreverse sigs-var) - nil - (nreverse sigs-assign) - (nreverse sigs-const) - (nreverse sigs-gparam) - (nreverse sigs-intf))))) + (setq tmp (verilog-decls-new (nreverse sigs-out) + (nreverse sigs-inout) + (nreverse sigs-in) + (nreverse sigs-var) + (nreverse sigs-modports) + (nreverse sigs-assign) + (nreverse sigs-const) + (nreverse sigs-gparam) + (nreverse sigs-intf))) + ;;(if dbg (verilog-decls-princ tmp)) + tmp))) (defvar verilog-read-sub-decls-in-interfaced nil "For `verilog-read-sub-decls', process next signal as under interfaced block.") @@ -9352,12 +9497,12 @@ ;;(message "verilog-modi-lookup: HIT %S" modi) modi) ;; Miss - (t (let* ((realmod (verilog-symbol-detick module t)) - (orig-filenames (verilog-module-filenames realmod current)) + (t (let* ((realname (verilog-symbol-detick module t)) + (orig-filenames (verilog-module-filenames realname current)) (filenames orig-filenames) mif) (while (and filenames (not mif)) - (if (not (setq mif (verilog-module-inside-filename-p realmod (car filenames)))) + (if (not (setq mif (verilog-module-inside-filename-p realname (car filenames)))) (setq filenames (cdr filenames)))) ;; mif has correct form to become later elements of modi (cond (mif (setq modi mif)) @@ -9365,8 +9510,8 @@ (or ignore-error (error (concat (verilog-point-text) ": Can't locate " module " module definition" - (if (not (equal module realmod)) - (concat " (Expanded macro to " realmod ")") + (if (not (equal module realname)) + (concat " (Expanded macro to " realname ")") "") "\n Check the verilog-library-directories variable." "\n I looked in (if not listed, doesn't exist):\n\t" @@ -9465,6 +9610,45 @@ (progn ,@body))) +(defun verilog-modi-modport-lookup-one (modi name &optional ignore-error) + "Given a MODI, return the declarations related to the given modport NAME." + ;; Recursive routine - see below + (let* ((realname (verilog-symbol-detick name t)) + (modport (assoc name (verilog-decls-get-modports (verilog-modi-get-decls modi))))) + (or modport ignore-error + (error (concat (verilog-point-text) + ": Can't locate " name " modport definition" + (if (not (equal name realname)) + (concat " (Expanded macro to " realname ")") + "")))) + (let* ((decls (verilog-modport-decls modport)) + (clks (verilog-modport-clockings modport))) + ;; Now expand any clocking's + (while clks + (setq decls (verilog-decls-append + decls + (verilog-modi-modport-lookup-one modi (car clks) ignore-error))) + (setq clks (cdr clks))) + decls))) + +(defun verilog-modi-modport-lookup (modi name-re &optional ignore-error) + "Given a MODI, return the declarations related to the given modport NAME-RE. +If the modport points to any clocking blocks, expand the signals to include +those clocking block's signals." + ;; Recursive routine - see below + (let* ((mod-decls (verilog-modi-get-decls modi)) + (clks (verilog-decls-get-modports mod-decls)) + (name-re (concat "^" name-re "$")) + (decls (verilog-decls-new nil nil nil nil nil nil nil nil nil))) + ;; Pull in all modports + (while clks + (when (string-match name-re (verilog-modport-name (car clks))) + (setq decls (verilog-decls-append + decls + (verilog-modi-modport-lookup-one modi (verilog-modport-name (car clks)) ignore-error)))) + (setq clks (cdr clks))) + decls)) + (defun verilog-signals-matching-enum (in-list enum) "Return all signals in IN-LIST matching the given ENUM." (let (out-list) @@ -9544,6 +9728,13 @@ (verilog-decls-get-inouts decls) (verilog-decls-get-inputs decls))) +(defun verilog-decls-get-iovars (decls) + (append + (verilog-decls-get-vars decls) + (verilog-decls-get-outputs decls) + (verilog-decls-get-inouts decls) + (verilog-decls-get-inputs decls))) + (defsubst verilog-modi-cache-add-outputs (modi sig-list) (verilog-modi-cache-add modi 'verilog-read-decls 0 sig-list)) (defsubst verilog-modi-cache-add-inouts (modi sig-list) @@ -9552,6 +9743,8 @@ (verilog-modi-cache-add modi 'verilog-read-decls 2 sig-list)) (defsubst verilog-modi-cache-add-vars (modi sig-list) (verilog-modi-cache-add modi 'verilog-read-decls 3 sig-list)) +(defsubst verilog-modi-cache-add-gparams (modi sig-list) + (verilog-modi-cache-add modi 'verilog-read-decls 7 sig-list)) ;; @@ -9608,6 +9801,8 @@ (when verilog-auto-declare-nettype (verilog-modi-cache-add-vars modi sigs))) ((equal direction "interface")) + ((equal direction "parameter") + (verilog-modi-cache-add-gparams modi sigs)) (t (error "Unsupported verilog-insert-definition direction: %s" direction)))) (or dont-sort @@ -9654,6 +9849,11 @@ stuff (cdr stuff))))) ;;(let ((indent-pt 10)) (verilog-insert-indent "hello\n" "addon" "there\n")) +(defun verilog-forward-or-insert-line () + "Move forward a line, unless at EOB, then insert a newline." + (if (eobp) (insert "\n") + (forward-line))) + (defun verilog-repair-open-comma () "Insert comma if previous argument is other than an open parenthesis or endif." ;; We can't just search backward for ) as it might be inside another expression. @@ -9741,6 +9941,17 @@ "\\([])}:*+-]\\)") out) (setq out (replace-match "\\1\\2\\3" nil nil out))) + (while (string-match + (concat "\\([[({:*+-]\\)" ; - must be last + "\\$clog2\\s *(\\<\\([0-9]+\\))" + "\\([])}:*+-]\\)") + out) + (setq out (replace-match + (concat + (match-string 1 out) + (int-to-string (verilog-clog2 (string-to-number (match-string 2 out)))) + (match-string 3 out)) + nil nil out))) ;; For precedence do * before +/- (while (string-match (concat "\\([[({:*+-]\\)" @@ -9777,6 +9988,7 @@ post) nil nil out)) ))) out))) + ;;(verilog-simplify-range-expression "[1:3]") ;; 1 ;;(verilog-simplify-range-expression "[(1):3]") ;; 1 ;;(verilog-simplify-range-expression "[(((16)+1)+1+(1+1))]") ;;20 @@ -9785,6 +9997,14 @@ ;;(verilog-simplify-range-expression "[(FOO*4+1-1)]") ;; FOO*4+0 ;;(verilog-simplify-range-expression "[(func(BAR))]") ;; func(BAR) ;;(verilog-simplify-range-expression "[FOO-1+1-1+1]") ;; FOO-0 +;;(verilog-simplify-range-expression "[$clog2(2)]") ;; 1 +;;(verilog-simplify-range-expression "[$clog2(7)]") ;; 3 + +(defun verilog-clog2 (value) + "Compute $clog2 - ceiling log2 of VALUE." + (if (< value 1) + 0 + (ceiling (/ (log value) (log 2))))) (defun verilog-typedef-name-p (variable-name) "Return true if the VARIABLE-NAME is a type definition." @@ -10348,6 +10568,86 @@ (insert "\n")) (indent-to verilog-indent-level-declaration)))) +(defun verilog-auto-assign-modport () + "Expand AUTOASSIGNMODPORT statements, as part of \\[verilog-auto]. +Take input/output/inout statements from the specified interface +and modport and use to build assignments into the modport, for +making verification modules that connect to UVM interfaces. + + The first parameter is the name of an interface. + + The second parameter is a regexp of modports to read from in + that interface. + + The third parameter is the instance name to use to dot reference into. + + The optional fourth parameter is a regular expression, and only + signals matching the regular expression will be included. + +Limitations: + + Interface names must be resolvable to filenames. See `verilog-auto-inst'. + + Inouts are not supported, as assignments must be unidirectional. + + If a signal is part of the interface header and in both a + modport and the interface itself, it will not be listed. (As + this would result in a syntax error when the connections are + made.) + +See the example in `verilog-auto-inout-modport'." + (save-excursion + (let* ((params (verilog-read-auto-params 3 4)) + (submod (nth 0 params)) + (modport-re (nth 1 params)) + (inst-name (nth 2 params)) + (regexp (nth 3 params)) + direction-re submodi) ;; direction argument not supported until requested + ;; Lookup position, etc of co-module + ;; Note this may raise an error + (when (setq submodi (verilog-modi-lookup submod t)) + (let* ((indent-pt (current-indentation)) + (modi (verilog-modi-current)) + (submoddecls (verilog-modi-get-decls submodi)) + (submodportdecls (verilog-modi-modport-lookup submodi modport-re)) + (sig-list-i (verilog-signals-in ;; Decls doesn't have data types, must resolve + (verilog-decls-get-vars submoddecls) + (verilog-signals-not-in + (verilog-decls-get-inputs submodportdecls) + (verilog-decls-get-ports submoddecls)))) + (sig-list-o (verilog-signals-in ;; Decls doesn't have data types, must resolve + (verilog-decls-get-vars submoddecls) + (verilog-signals-not-in + (verilog-decls-get-outputs submodportdecls) + (verilog-decls-get-ports submoddecls))))) + (forward-line 1) + (setq sig-list-i (verilog-signals-edit-wire-reg + (verilog-signals-matching-dir-re + (verilog-signals-matching-regexp sig-list-i regexp) + "input" direction-re)) + sig-list-o (verilog-signals-edit-wire-reg + (verilog-signals-matching-dir-re + (verilog-signals-matching-regexp sig-list-o regexp) + "output" direction-re))) + (setq sig-list-i (sort (copy-alist sig-list-i) `verilog-signals-sort-compare)) + (setq sig-list-o (sort (copy-alist sig-list-o) `verilog-signals-sort-compare)) + (when (or sig-list-i sig-list-o) + (verilog-insert-indent "// Beginning of automatic assignments from modport\n") + ;; Don't sort them so an upper AUTOINST will match the main module + (let ((sigs sig-list-o)) + (while sigs + (verilog-insert-indent "assign " (verilog-sig-name (car sigs)) + " = " inst-name + "." (verilog-sig-name (car sigs)) ";\n") + (setq sigs (cdr sigs)))) + (let ((sigs sig-list-i)) + (while sigs + (verilog-insert-indent "assign " inst-name + "." (verilog-sig-name (car sigs)) + " = " (verilog-sig-name (car sigs)) ";\n") + (setq sigs (cdr sigs)))) + (verilog-insert-indent "// End of automatics\n"))))))) + (defun verilog-auto-inst-port-map (port-st) nil) @@ -11067,8 +11367,8 @@ (verilog-subdecls-get-interfaced modsubdecls) (verilog-subdecls-get-outputs modsubdecls) (verilog-subdecls-get-inouts modsubdecls))))) - (forward-line 1) (when sig-list + (verilog-forward-or-insert-line) (verilog-insert-indent "// Beginning of automatic regs (for this module's undeclared outputs)\n") (verilog-insert-definition modi sig-list "reg" indent-pt nil) (verilog-insert-indent "// End of automatics\n"))))) @@ -11122,8 +11422,8 @@ (verilog-subdecls-get-inouts modsubdecls)) (append (verilog-decls-get-signals moddecls) (verilog-decls-get-assigns moddecls)))))) - (forward-line 1) (when sig-list + (verilog-forward-or-insert-line) (verilog-insert-indent "// Beginning of automatic reg inputs (for undeclared instantiated-module inputs)\n") (verilog-insert-definition modi sig-list "reg" indent-pt nil) (verilog-insert-indent "// End of automatics\n"))))) @@ -11210,8 +11510,8 @@ (append (verilog-subdecls-get-outputs modsubdecls) (verilog-subdecls-get-inouts modsubdecls)) (verilog-decls-get-signals moddecls))))) - (forward-line 1) (when sig-list + (verilog-forward-or-insert-line) (verilog-insert-indent "// Beginning of automatic wires (for undeclared instantiated-module outputs)\n") (verilog-insert-definition modi sig-list "wire" indent-pt nil) (verilog-insert-indent "// End of automatics\n") @@ -11221,7 +11521,7 @@ ;; syntax-ppss which is broken when change hooks are disabled. )))) -(defun verilog-auto-output (&optional with-params) +(defun verilog-auto-output () "Expand AUTOOUTPUT statements, as part of \\[verilog-auto]. Make output statements for any output signal from an /*AUTOINST*/ that isn't an input to another AUTOINST. This is useful for modules which @@ -11273,8 +11573,8 @@ (save-excursion ;; Point must be at insertion point. (let* ((indent-pt (current-indentation)) - (regexp (and with-params - (nth 0 (verilog-read-auto-params 1)))) + (params (verilog-read-auto-params 0 1)) + (regexp (nth 0 params)) (v2k (verilog-in-paren-quick)) (modi (verilog-modi-current)) (moddecls (verilog-modi-get-decls modi)) @@ -11290,7 +11590,7 @@ sig-list regexp))) (setq sig-list (verilog-signals-not-matching-regexp sig-list verilog-auto-output-ignore-regexp)) - (forward-line 1) + (verilog-forward-or-insert-line) (when v2k (verilog-repair-open-comma)) (when sig-list (verilog-insert-indent "// Beginning of automatic outputs (from unused autoinst outputs)\n") @@ -11340,7 +11640,7 @@ (verilog-signals-not-in (verilog-decls-get-signals moddecls) (verilog-decls-get-ports moddecls))))) - (forward-line 1) + (verilog-forward-or-insert-line) (when v2k (verilog-repair-open-comma)) (when sig-list (verilog-insert-indent "// Beginning of automatic outputs (every signal)\n") @@ -11348,7 +11648,7 @@ (verilog-insert-indent "// End of automatics\n")) (when v2k (verilog-repair-close-comma))))) -(defun verilog-auto-input (&optional with-params) +(defun verilog-auto-input () "Expand AUTOINPUT statements, as part of \\[verilog-auto]. Make input statements for any input signal into an /*AUTOINST*/ that isn't declared elsewhere inside the module. This is useful for modules which @@ -11399,8 +11699,8 @@ /*AUTOINPUT(\"^i\")*/" (save-excursion (let* ((indent-pt (current-indentation)) - (regexp (and with-params - (nth 0 (verilog-read-auto-params 1)))) + (params (verilog-read-auto-params 0 1)) + (regexp (nth 0 params)) (v2k (verilog-in-paren-quick)) (modi (verilog-modi-current)) (moddecls (verilog-modi-get-decls modi)) @@ -11420,7 +11720,7 @@ sig-list regexp))) (setq sig-list (verilog-signals-not-matching-regexp sig-list verilog-auto-input-ignore-regexp)) - (forward-line 1) + (verilog-forward-or-insert-line) (when v2k (verilog-repair-open-comma)) (when sig-list (verilog-insert-indent "// Beginning of automatic inputs (from unused autoinst inputs)\n") @@ -11428,7 +11728,7 @@ (verilog-insert-indent "// End of automatics\n")) (when v2k (verilog-repair-close-comma))))) -(defun verilog-auto-inout (&optional with-params) +(defun verilog-auto-inout () "Expand AUTOINOUT statements, as part of \\[verilog-auto]. Make inout statements for any inout signal in an /*AUTOINST*/ that isn't declared elsewhere inside the module. @@ -11479,8 +11779,8 @@ (save-excursion ;; Point must be at insertion point. (let* ((indent-pt (current-indentation)) - (regexp (and with-params - (nth 0 (verilog-read-auto-params 1)))) + (params (verilog-read-auto-params 0 1)) + (regexp (nth 0 params)) (v2k (verilog-in-paren-quick)) (modi (verilog-modi-current)) (moddecls (verilog-modi-get-decls modi)) @@ -11497,7 +11797,7 @@ sig-list regexp))) (setq sig-list (verilog-signals-not-matching-regexp sig-list verilog-auto-inout-ignore-regexp)) - (forward-line 1) + (verilog-forward-or-insert-line) (when v2k (verilog-repair-open-comma)) (when sig-list (verilog-insert-indent "// Beginning of automatic inouts (from unused autoinst inouts)\n") @@ -11739,6 +12039,225 @@ /*AUTOINOUTCOMP(\"ExampMain\",\"^i\")*/" (verilog-auto-inout-module nil t)) +(defun verilog-auto-inout-param () + "Expand AUTOINOUTPARAM statements, as part of \\[verilog-auto]. +Take input/output/inout statements from the specified module and insert +into the current module. This is useful for making null templates and +shell modules which need to have identical I/O with another module. +Any I/O which are already defined in this module will not be redefined. +For the complement of this function, see `verilog-auto-inout-comp', +and to make monitors with all inputs, see `verilog-auto-inout-in'. + +Limitations: + If placed inside the parenthesis of a module declaration, it creates + Verilog 2001 style, else uses Verilog 1995 style. + + Concatenation and outputting partial buses is not supported. + + Module names must be resolvable to filenames. See `verilog-auto-inst'. + + Signals are not inserted in the same order as in the original module, + though they will appear to be in the same order to an AUTOINST + instantiating either module. + + Signals declared as \"output reg\" or \"output wire\" etc will + lose the wire/reg declaration so that shell modules may + generate those outputs differently. However, \"output logic\" + is propagated. + +An example: + + module ExampShell (/*AUTOARG*/); + /*AUTOINOUTMODULE(\"ExampMain\")*/ + endmodule + + module ExampMain (i,o,io); + input i; + output o; + inout io; + endmodule + +Typing \\[verilog-auto] will make this into: + + module ExampShell (/*AUTOARG*/i,o,io); + /*AUTOINOUTMODULE(\"ExampMain\")*/ + // Beginning of automatic in/out/inouts (from specific module) + output o; + inout io; + input i; + // End of automatics + endmodule + +You may also provide an optional regular expression, in which case only +signals matching the regular expression will be included. For example the +same expansion will result from only extracting signals starting with i: + + /*AUTOINOUTMODULE(\"ExampMain\",\"^i\")*/ + +You may also provide an optional second regular expression, in +which case only signals which have that pin direction and data +type will be included. This matches against everything before +the signal name in the declaration, for example against +\"input\" (single bit), \"output logic\" (direction and type) or +\"output [1:0]\" (direction and implicit type). You also +probably want to skip spaces in your regexp. + +For example, the below will result in matching the output \"o\" +against the previous example's module: + + /*AUTOINOUTMODULE(\"ExampMain\",\"\",\"^output.*\")*/ + +You may also provide an optional third regular expression, in +which case any parameter names that match the given regexp will +be included. Including parameters is off by default. To include +all signals and parameters, use: + + /*AUTOINOUTMODULE(\"ExampMain\",\".*\",\".*\",\".*\")*/" + (save-excursion + (let* ((params (verilog-read-auto-params 1 2)) + (submod (nth 0 params)) + (regexp (nth 1 params)) + submodi) + ;; Lookup position, etc of co-module + ;; Note this may raise an error + (when (setq submodi (verilog-modi-lookup submod t)) + (let* ((indent-pt (current-indentation)) + (v2k (verilog-in-paren-quick)) + (modi (verilog-modi-current)) + (moddecls (verilog-modi-get-decls modi)) + (submoddecls (verilog-modi-get-decls submodi)) + (sig-list-p (verilog-signals-not-in + (verilog-decls-get-gparams submoddecls) + (append (verilog-decls-get-gparams moddecls))))) + (forward-line 1) + (setq sig-list-p (verilog-signals-matching-regexp sig-list-p regexp)) + (when v2k (verilog-repair-open-comma)) + (when sig-list-p + (verilog-insert-indent "// Beginning of automatic parameters (from specific module)\n") + ;; Don't sort them so an upper AUTOINST will match the main module + (verilog-insert-definition modi sig-list-p "parameter" indent-pt v2k t) + (verilog-insert-indent "// End of automatics\n")) + (when v2k (verilog-repair-close-comma))))))) + +(defun verilog-auto-inout-modport () + "Expand AUTOINOUTMODPORT statements, as part of \\[verilog-auto]. +Take input/output/inout statements from the specified interface +and modport and insert into the current module. This is useful +for making verification modules that connect to UVM interfaces. + + The first parameter is the name of an interface. + + The second parameter is a regexp of modports to read from in + that interface. + + The optional third parameter is a regular expression, and only + signals matching the regular expression will be included. + +Limitations: + If placed inside the parenthesis of a module declaration, it creates + Verilog 2001 style, else uses Verilog 1995 style. + + Interface names must be resolvable to filenames. See `verilog-auto-inst'. + +As with other autos, any inputs/outputs declared in the module +will suppress the AUTO from redeclarating an inputs/outputs by +the same name. + +An example: + + interface ExampIf + ( input logic clk ); + logic req_val; + logic [7:0] req_dat; + clocking mon_clkblk @(posedge clk); + input req_val; + input req_dat; + endclocking + modport mp(clocking mon_clkblk); + endinterface + + module ExampMain + ( input clk, + /*AUTOINOUTMODPORT(\"ExampIf\" \"mp\")*/ + // Beginning of automatic in/out/inouts (from modport) + input [7:0] req_dat, + input req_val + // End of automatics + ); + /*AUTOASSIGNMODPORT(\"ExampIf\" \"mp\")*/ + endmodule + +Typing \\[verilog-auto] will make this into: + + ... + module ExampMain + ( input clk, + /*AUTOINOUTMODPORT(\"ExampIf\" \"mp\")*/ + // Beginning of automatic in/out/inouts (from modport) + input req_dat, + input req_val + // End of automatics + ); + +If the modport is part of a UVM monitor/driver class, this +creates a wrapper module that may be used to instantiate the +driver/monitor using AUTOINST in the testbench." + (save-excursion + (let* ((params (verilog-read-auto-params 2 3)) + (submod (nth 0 params)) + (modport-re (nth 1 params)) + (regexp (nth 2 params)) + direction-re submodi) ;; direction argument not supported until requested + ;; Lookup position, etc of co-module + ;; Note this may raise an error + (when (setq submodi (verilog-modi-lookup submod t)) + (let* ((indent-pt (current-indentation)) + (v2k (verilog-in-paren-quick)) + (modi (verilog-modi-current)) + (moddecls (verilog-modi-get-decls modi)) + (submoddecls (verilog-modi-get-decls submodi)) + (submodportdecls (verilog-modi-modport-lookup submodi modport-re)) + (sig-list-i (verilog-signals-in ;; Decls doesn't have data types, must resolve + (verilog-decls-get-vars submoddecls) + (verilog-signals-not-in + (verilog-decls-get-inputs submodportdecls) + (append (verilog-decls-get-ports submoddecls) + (verilog-decls-get-ports moddecls))))) + (sig-list-o (verilog-signals-in ;; Decls doesn't have data types, must resolve + (verilog-decls-get-vars submoddecls) + (verilog-signals-not-in + (verilog-decls-get-outputs submodportdecls) + (append (verilog-decls-get-ports submoddecls) + (verilog-decls-get-ports moddecls))))) + (sig-list-io (verilog-signals-in ;; Decls doesn't have data types, must resolve + (verilog-decls-get-vars submoddecls) + (verilog-signals-not-in + (verilog-decls-get-inouts submodportdecls) + (append (verilog-decls-get-ports submoddecls) + (verilog-decls-get-ports moddecls)))))) + (forward-line 1) + (setq sig-list-i (verilog-signals-edit-wire-reg + (verilog-signals-matching-dir-re + (verilog-signals-matching-regexp sig-list-i regexp) + "input" direction-re)) + sig-list-o (verilog-signals-edit-wire-reg + (verilog-signals-matching-dir-re + (verilog-signals-matching-regexp sig-list-o regexp) + "output" direction-re)) + sig-list-io (verilog-signals-edit-wire-reg + (verilog-signals-matching-dir-re + (verilog-signals-matching-regexp sig-list-io regexp) + "inout" direction-re))) + (when v2k (verilog-repair-open-comma)) + (when (or sig-list-i sig-list-o sig-list-io) + (verilog-insert-indent "// Beginning of automatic in/out/inouts (from modport)\n") + ;; Don't sort them so an upper AUTOINST will match the main module + (verilog-insert-definition modi sig-list-o "output" indent-pt v2k t) + (verilog-insert-definition modi sig-list-io "inout" indent-pt v2k t) + (verilog-insert-definition modi sig-list-i "input" indent-pt v2k t) + (verilog-insert-indent "// End of automatics\n")) + (when v2k (verilog-repair-close-comma))))))) + (defun verilog-auto-insert-lisp () "Expand AUTOINSERTLISP statements, as part of \\[verilog-auto]. The Lisp code provided is called, and the Lisp code calls @@ -11789,7 +12308,7 @@ (backward-sexp 1) ;; Inside comment (point))) ;; Beginning paren (cmd (buffer-substring-no-properties cmd-beg-pt cmd-end-pt))) - (forward-line 1) + (verilog-forward-or-insert-line) ;; Some commands don't move point (like insert-file) so we always ;; add the begin/end comments, then delete it if not needed (verilog-insert-indent "// Beginning of automatic insert lisp\n") @@ -12042,6 +12561,7 @@ An example of making a stub for another module: module ExampStub (/*AUTOINST*/); + /*AUTOINOUTPARAM(\"Foo\")*/ /*AUTOINOUTMODULE(\"Foo\")*/ /*AUTOTIEOFF*/ // verilator lint_off UNUSED @@ -12054,6 +12574,7 @@ Typing \\[verilog-auto] will make this into: module ExampStub (/*AUTOINST*/...); + /*AUTOINOUTPARAM(\"Foo\")*/ /*AUTOINOUTMODULE(\"Foo\")*/ // Beginning of autotieoff output [2:0] foo; @@ -12084,7 +12605,7 @@ (setq sig-list (verilog-signals-not-matching-regexp sig-list verilog-auto-tieoff-ignore-regexp)) (when sig-list - (forward-line 1) + (verilog-forward-or-insert-line) (verilog-insert-indent "// Beginning of automatic tieoffs (for this module's unterminated outputs)\n") (setq sig-list (sort (copy-alist sig-list) `verilog-signals-sort-compare)) (verilog-modi-cache-add-vars modi sig-list) ; Before we trash list @@ -12161,7 +12682,7 @@ ;; Insert (setq defs (sort defs 'string<)) (when defs - (forward-line 1) + (verilog-forward-or-insert-line) (verilog-insert-indent "// Beginning of automatic undefs\n") (while defs (verilog-insert-indent "`undef " (car defs) "\n") @@ -12198,6 +12719,7 @@ An example of making a stub for another module: module ExampStub (/*AUTOINST*/); + /*AUTOINOUTPARAM(\"Examp\")*/ /*AUTOINOUTMODULE(\"Examp\")*/ /*AUTOTIEOFF*/ // verilator lint_off UNUSED @@ -12236,7 +12758,7 @@ (setq sig-list (verilog-signals-not-matching-regexp sig-list verilog-auto-unused-ignore-regexp)) (when sig-list - (forward-line 1) + (verilog-forward-or-insert-line) (verilog-insert-indent "// Beginning of automatic unused inputs\n") (setq sig-list (sort (copy-alist sig-list) `verilog-signals-sort-compare)) (while sig-list @@ -12335,10 +12857,7 @@ ;; (sig-list-consts (append (verilog-decls-get-consts moddecls) (verilog-decls-get-gparams moddecls))) - (sig-list-all (append (verilog-decls-get-vars moddecls) - (verilog-decls-get-outputs moddecls) - (verilog-decls-get-inouts moddecls) - (verilog-decls-get-inputs moddecls))) + (sig-list-all (verilog-decls-get-iovars moddecls)) ;; (undecode-sig (or (assoc undecode-name sig-list-all) (error "%s: Signal %s not found in design" (verilog-point-text) undecode-name))) @@ -12371,7 +12890,7 @@ elim-regexp))) tmp-sigs (cdr tmp-sigs)))) ;; - (forward-line 1) + (verilog-forward-or-insert-line) (verilog-insert-indent "// Beginning of automatic ASCII enum decoding\n") (let ((decode-sig-list (list (list ascii-name (format "[%d:0]" (- (* ascii-chars 8) 1)) (concat "Decode of " undecode-name) nil nil)))) @@ -12506,9 +13025,12 @@ Using \\[describe-function], see also: `verilog-auto-arg' for AUTOARG module instantiations `verilog-auto-ascii-enum' for AUTOASCIIENUM enumeration decoding + `verilog-auto-assign-modport' for AUTOASSIGNMODPORT assignment to/from modport `verilog-auto-inout-comp' for AUTOINOUTCOMP copy complemented i/o `verilog-auto-inout-in' for AUTOINOUTIN inputs for all i/o + `verilog-auto-inout-modport' for AUTOINOUTMODPORT i/o from an interface modport `verilog-auto-inout-module' for AUTOINOUTMODULE copying i/o from elsewhere + `verilog-auto-inout-param' for AUTOINOUTPARAM copying params from elsewhere `verilog-auto-inout' for AUTOINOUT making hierarchy inouts `verilog-auto-input' for AUTOINPUT making hierarchy inputs `verilog-auto-insert-lisp' for AUTOINSERTLISP insert code from lisp function @@ -12598,27 +13120,24 @@ (verilog-auto-re-search-do "/\\*\\(AUTOSENSE\\|AS\\)\\*/" 'verilog-auto-sense) (verilog-auto-re-search-do "/\\*AUTORESET\\*/" 'verilog-auto-reset) ;; Must be done before autoin/out as creates a reg - (verilog-auto-re-search-do "/\\*AUTOASCIIENUM([^)]*)\\*/" 'verilog-auto-ascii-enum) + (verilog-auto-re-search-do "/\\*AUTOASCIIENUM(.*?)\\*/" 'verilog-auto-ascii-enum) ;; ;; first in/outs from other files - (verilog-auto-re-search-do "/\\*AUTOINOUTMODULE([^)]*)\\*/" 'verilog-auto-inout-module) - (verilog-auto-re-search-do "/\\*AUTOINOUTCOMP([^)]*)\\*/" 'verilog-auto-inout-comp) - (verilog-auto-re-search-do "/\\*AUTOINOUTIN([^)]*)\\*/" 'verilog-auto-inout-in) + (verilog-auto-re-search-do "/\\*AUTOINOUTMODPORT(.*?)\\*/" 'verilog-auto-inout-modport) + (verilog-auto-re-search-do "/\\*AUTOINOUTMODULE(.*?)\\*/" 'verilog-auto-inout-module) + (verilog-auto-re-search-do "/\\*AUTOINOUTCOMP(.*?)\\*/" 'verilog-auto-inout-comp) + (verilog-auto-re-search-do "/\\*AUTOINOUTIN(.*?)\\*/" 'verilog-auto-inout-in) + (verilog-auto-re-search-do "/\\*AUTOINOUTPARAM(.*?)\\*/" 'verilog-auto-inout-param) ;; next in/outs which need previous sucked inputs first - (verilog-auto-re-search-do "/\\*AUTOOUTPUT\\((\"[^\"]*\")\\)\\*/" - (lambda () (verilog-auto-output t))) - (verilog-auto-re-search-do "/\\*AUTOOUTPUT\\*/" 'verilog-auto-output) - (verilog-auto-re-search-do "/\\*AUTOINPUT\\((\"[^\"]*\")\\)\\*/" - (lambda () (verilog-auto-input t))) - (verilog-auto-re-search-do "/\\*AUTOINPUT\\*/" 'verilog-auto-input) - (verilog-auto-re-search-do "/\\*AUTOINOUT\\((\"[^\"]*\")\\)\\*/" - (lambda () (verilog-auto-inout t))) - (verilog-auto-re-search-do "/\\*AUTOINOUT\\*/" 'verilog-auto-inout) + (verilog-auto-re-search-do "/\\*AUTOOUTPUT\\((.*?)\\)?\\*/" 'verilog-auto-output) + (verilog-auto-re-search-do "/\\*AUTOINPUT\\((.*?)\\)?\\*/" 'verilog-auto-input) + (verilog-auto-re-search-do "/\\*AUTOINOUT\\((.*?)\\)?\\*/" 'verilog-auto-inout) ;; Then tie off those in/outs (verilog-auto-re-search-do "/\\*AUTOTIEOFF\\*/" 'verilog-auto-tieoff) ;; These can be anywhere after AUTOINSERTLISP - (verilog-auto-re-search-do "/\\*AUTOUNDEF\\((\"[^\"]*\")\\)?\\*/" 'verilog-auto-undef) + (verilog-auto-re-search-do "/\\*AUTOUNDEF\\((.*?)\\)?\\*/" 'verilog-auto-undef) ;; Wires/regs must be after inputs/outputs + (verilog-auto-re-search-do "/\\*AUTOASSIGNMODPORT(.*?)\\*/" 'verilog-auto-assign-modport) (verilog-auto-re-search-do "/\\*AUTOLOGIC\\*/" 'verilog-auto-logic) (verilog-auto-re-search-do "/\\*AUTOWIRE\\*/" 'verilog-auto-wire) (verilog-auto-re-search-do "/\\*AUTOREG\\*/" 'verilog-auto-reg) @@ -12696,7 +13215,7 @@ ;; ;; Place the templates into Verilog Mode. They may be inserted under any key. ;; C-c C-t will be the default. If you use templates a lot, you -;; may want to consider moving the binding to another key in your .emacs +;; may want to consider moving the binding to another key in your init ;; file. ;; ;; Note \C-c and letter are reserved for users ------------------------------------------------------------ revno: 110200 committer: Katsumi Yamaoka branch nick: trunk timestamp: Tue 2012-09-25 23:57:37 +0000 message: gnus-art.el (gnus-article-browse-delete-temp-files): Fix previous commit diff: === modified file 'lisp/gnus/gnus-art.el' --- lisp/gnus/gnus-art.el 2012-09-25 23:39:44 +0000 +++ lisp/gnus/gnus-art.el 2012-09-25 23:57:37 +0000 @@ -2759,14 +2759,12 @@ (progn (or how (setq how gnus-article-browse-delete-temp)) (if (eq how 'ask) - (let* ((files (length gnus-article-browse-html-temp-list)) - (ans (gnus-y-or-n-p - (if (= files 1) - "Delete the temporary HTML file? " - (format - "Delete all %s temporary HTML files? " - files))))) - (or ans + (let ((files (length gnus-article-browse-html-temp-list))) + (or (gnus-y-or-n-p + (if (= files 1) + "Delete the temporary HTML file? " + (format "Delete all %s temporary HTML files? " + files))) (setq gnus-article-browse-html-temp-list nil))) how))) (dolist (file gnus-article-browse-html-temp-list) ------------------------------------------------------------ revno: 110199 committer: Katsumi Yamaoka branch nick: trunk timestamp: Tue 2012-09-25 23:39:44 +0000 message: gnus-art.el (gnus-article-browse-delete-temp-files): Never ask again a user about whether to delete files if once a user answered as n diff: === modified file 'lisp/gnus/ChangeLog' --- lisp/gnus/ChangeLog 2012-09-17 11:41:39 +0000 +++ lisp/gnus/ChangeLog 2012-09-25 23:39:44 +0000 @@ -1,3 +1,8 @@ +2012-09-25 Katsumi Yamaoka + + * gnus-art.el (gnus-article-browse-delete-temp-files): Never ask again + a user about whether to delete temp files if once a user answered as n. + 2012-09-17 Richard Stallman * message.el (message-in-body-p): Don't set mark or modify buffer. === modified file 'lisp/gnus/gnus-art.el' --- lisp/gnus/gnus-art.el 2012-09-13 11:14:30 +0000 +++ lisp/gnus/gnus-art.el 2012-09-25 23:39:44 +0000 @@ -2759,12 +2759,15 @@ (progn (or how (setq how gnus-article-browse-delete-temp)) (if (eq how 'ask) - (let ((files (length gnus-article-browse-html-temp-list))) - (gnus-y-or-n-p - (if (= files 1) - "Delete the temporary HTML file? " - (format "Delete all %s temporary HTML files? " - files)))) + (let* ((files (length gnus-article-browse-html-temp-list)) + (ans (gnus-y-or-n-p + (if (= files 1) + "Delete the temporary HTML file? " + (format + "Delete all %s temporary HTML files? " + files))))) + (or ans + (setq gnus-article-browse-html-temp-list nil))) how))) (dolist (file gnus-article-browse-html-temp-list) (cond ((file-directory-p file) ------------------------------------------------------------ revno: 110198 committer: Juanma Barranquero branch nick: trunk timestamp: Wed 2012-09-26 00:07:22 +0200 message: src/makefile.w32-in ($(BLD)/callproc.$(O)): Update dependencies. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2012-09-25 19:18:05 +0000 +++ src/ChangeLog 2012-09-25 22:07:22 +0000 @@ -1,3 +1,7 @@ +2012-09-25 Juanma Barranquero + + * makefile.w32-in ($(BLD)/callproc.$(O)): Update dependencies. + 2012-09-25 Paul Eggert Prefer POSIX timers if available. === modified file 'src/makefile.w32-in' --- src/makefile.w32-in 2012-09-23 18:03:48 +0000 +++ src/makefile.w32-in 2012-09-25 22:07:22 +0000 @@ -561,6 +561,7 @@ $(SRC)/commands.h \ $(SRC)/composite.h \ $(SRC)/epaths.h \ + $(SRC)/syswait.h \ $(SRC)/w32.h \ $(NT_INC)/sys/file.h \ $(NT_INC)/unistd.h \ ------------------------------------------------------------ revno: 110197 committer: Paul Eggert branch nick: trunk timestamp: Tue 2012-09-25 12:18:05 -0700 message: Prefer POSIX timers if available. They avoid a race if the timer is too close to the current time. * atimer.c (alarm_timer, alarm_timer_ok) [SIGEV_SIGNAL]: New static vars. (set_alarm) [SIGEV_SIGNAL]: Use POSIX timers if available. (init_atimer) [SIGEV_SIGAL]: Initialize them. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2012-09-25 12:44:13 +0000 +++ src/ChangeLog 2012-09-25 19:18:05 +0000 @@ -1,3 +1,11 @@ +2012-09-25 Paul Eggert + + Prefer POSIX timers if available. + They avoid a race if the timer is too close to the current time. + * atimer.c (alarm_timer, alarm_timer_ok) [SIGEV_SIGNAL]: New static vars. + (set_alarm) [SIGEV_SIGNAL]: Use POSIX timers if available. + (init_atimer) [SIGEV_SIGAL]: Initialize them. + 2012-09-25 Eli Zaretskii * coding.c (CHAR_STRING_ADVANCE_NO_UNIFY): Make it an alias of === modified file 'src/atimer.c' --- src/atimer.c 2012-09-23 08:44:20 +0000 +++ src/atimer.c 2012-09-25 19:18:05 +0000 @@ -40,6 +40,13 @@ static struct atimer *atimers; +/* The alarm timer and whether it was properly initialized, if + POSIX timers are available. */ +#ifdef SIGEV_SIGNAL +static timer_t alarm_timer; +static bool alarm_timer_ok; +#endif + /* Block/unblock SIGALRM. */ static void @@ -287,14 +294,25 @@ #ifdef HAVE_SETITIMER struct itimerval it; #endif - - /* Determine s/us till the next timer is ripe. */ - EMACS_TIME now = current_emacs_time (); - - /* Don't set the interval to 0; this disables the timer. */ - EMACS_TIME interval = (EMACS_TIME_LE (atimers->expiration, now) - ? make_emacs_time (0, 1000 * 1000) - : sub_emacs_time (atimers->expiration, now)); + EMACS_TIME now, interval; + +#ifdef SIGEV_SIGNAL + if (alarm_timer_ok) + { + struct itimerspec ispec; + ispec.it_value = atimers->expiration; + ispec.it_interval.tv_sec = ispec.it_interval.tv_nsec = 0; + if (timer_settime (alarm_timer, 0, &ispec, 0) == 0) + return; + } +#endif + + /* Determine interval till the next timer is ripe. + Don't set the interval to 0; this disables the timer. */ + now = current_emacs_time (); + interval = (EMACS_TIME_LE (atimers->expiration, now) + ? make_emacs_time (0, 1000 * 1000) + : sub_emacs_time (atimers->expiration, now)); #ifdef HAVE_SETITIMER @@ -398,6 +416,13 @@ init_atimer (void) { struct sigaction action; +#ifdef SIGEV_SIGNAL + struct sigevent sigev; + sigev.sigev_notify = SIGEV_SIGNAL; + sigev.sigev_signo = SIGALRM; + sigev.sigev_value.sival_ptr = &alarm_timer; + alarm_timer_ok = timer_create (CLOCK_REALTIME, &sigev, &alarm_timer) == 0; +#endif free_atimers = stopped_atimers = atimers = NULL; /* pending_signals is initialized in init_keyboard.*/ emacs_sigaction_init (&action, handle_alarm_signal); ------------------------------------------------------------ revno: 110196 committer: Eli Zaretskii branch nick: trunk timestamp: Tue 2012-09-25 14:44:13 +0200 message: Followup to not using maybe_unify_char in processing buffers and strings. src/coding.c (CHAR_STRING_ADVANCE_NO_UNIFY): Make it an alias of CHAR_STRING_ADVANCE. (STRING_CHAR_ADVANCE_NO_UNIFY): Make it an alias of STRING_CHAR_ADVANCE. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2012-09-25 11:57:30 +0000 +++ src/ChangeLog 2012-09-25 12:44:13 +0000 @@ -1,3 +1,10 @@ +2012-09-25 Eli Zaretskii + + * coding.c (CHAR_STRING_ADVANCE_NO_UNIFY): Make it an alias of + CHAR_STRING_ADVANCE. + (STRING_CHAR_ADVANCE_NO_UNIFY): Make it an alias of + STRING_CHAR_ADVANCE. + 2012-09-25 Juanma Barranquero Move Vlibrary_cache to emacs.c and reset before dumping. === modified file 'src/coding.c' --- src/coding.c 2012-09-15 07:06:56 +0000 +++ src/coding.c 2012-09-25 12:44:13 +0000 @@ -920,65 +920,18 @@ /* Store multibyte form of the character C in P, and advance P to the - end of the multibyte form. This is like CHAR_STRING_ADVANCE but it - never calls MAYBE_UNIFY_CHAR. */ - -#define CHAR_STRING_ADVANCE_NO_UNIFY(c, p) \ - do { \ - if ((c) <= MAX_1_BYTE_CHAR) \ - *(p)++ = (c); \ - else if ((c) <= MAX_2_BYTE_CHAR) \ - *(p)++ = (0xC0 | ((c) >> 6)), \ - *(p)++ = (0x80 | ((c) & 0x3F)); \ - else if ((c) <= MAX_3_BYTE_CHAR) \ - *(p)++ = (0xE0 | ((c) >> 12)), \ - *(p)++ = (0x80 | (((c) >> 6) & 0x3F)), \ - *(p)++ = (0x80 | ((c) & 0x3F)); \ - else if ((c) <= MAX_4_BYTE_CHAR) \ - *(p)++ = (0xF0 | (c >> 18)), \ - *(p)++ = (0x80 | ((c >> 12) & 0x3F)), \ - *(p)++ = (0x80 | ((c >> 6) & 0x3F)), \ - *(p)++ = (0x80 | (c & 0x3F)); \ - else if ((c) <= MAX_5_BYTE_CHAR) \ - *(p)++ = 0xF8, \ - *(p)++ = (0x80 | ((c >> 18) & 0x0F)), \ - *(p)++ = (0x80 | ((c >> 12) & 0x3F)), \ - *(p)++ = (0x80 | ((c >> 6) & 0x3F)), \ - *(p)++ = (0x80 | (c & 0x3F)); \ - else \ - (p) += BYTE8_STRING ((c) - 0x3FFF80, p); \ - } while (0) - + end of the multibyte form. This used to be like CHAR_STRING_ADVANCE + without ever calling MAYBE_UNIFY_CHAR, but nowadays we don't call + MAYBE_UNIFY_CHAR in CHAR_STRING_ADVANCE. */ + +#define CHAR_STRING_ADVANCE_NO_UNIFY(c, p) CHAR_STRING_ADVANCE(c, p) /* Return the character code of character whose multibyte form is at - P, and advance P to the end of the multibyte form. This is like - STRING_CHAR_ADVANCE, but it never calls MAYBE_UNIFY_CHAR. */ - -#define STRING_CHAR_ADVANCE_NO_UNIFY(p) \ - (!((p)[0] & 0x80) \ - ? *(p)++ \ - : ! ((p)[0] & 0x20) \ - ? ((p) += 2, \ - ((((p)[-2] & 0x1F) << 6) \ - | ((p)[-1] & 0x3F) \ - | ((unsigned char) ((p)[-2]) < 0xC2 ? 0x3FFF80 : 0))) \ - : ! ((p)[0] & 0x10) \ - ? ((p) += 3, \ - ((((p)[-3] & 0x0F) << 12) \ - | (((p)[-2] & 0x3F) << 6) \ - | ((p)[-1] & 0x3F))) \ - : ! ((p)[0] & 0x08) \ - ? ((p) += 4, \ - ((((p)[-4] & 0xF) << 18) \ - | (((p)[-3] & 0x3F) << 12) \ - | (((p)[-2] & 0x3F) << 6) \ - | ((p)[-1] & 0x3F))) \ - : ((p) += 5, \ - ((((p)[-4] & 0x3F) << 18) \ - | (((p)[-3] & 0x3F) << 12) \ - | (((p)[-2] & 0x3F) << 6) \ - | ((p)[-1] & 0x3F)))) - + P, and advance P to the end of the multibyte form. This used to be + like STRING_CHAR_ADVANCE without ever calling MAYBE_UNIFY_CHAR, but + nowadays STRING_CHAR_ADVANCE doesn't call MAYBE_UNIFY_CHAR. */ + +#define STRING_CHAR_ADVANCE_NO_UNIFY(p) STRING_CHAR_ADVANCE(p) /* Set coding->source from coding->src_object. */ ------------------------------------------------------------ revno: 110195 committer: Juanma Barranquero branch nick: trunk timestamp: Tue 2012-09-25 13:57:30 +0200 message: Move Vlibrary_cache to emacs.c and reset before dumping. * src/lisp.h (reset_image_types): Declare. [WINDOWSNT] (Vlibrary_cache): Declare. * src/image.c (reset_image_types): New function. * src/emacs.c [WINDOWSNT] (Vlibrary_cache): Move from w32.c. (syms_of_emacs) [WINDOWSNT] : Initialize and staticpro. (Fdump_emacs): Reset Vlibrary_cache and image_types. * src/w32.c (Vlibrary_cache): Do not define; moved to emacs.c (globals_of_w32) : Do not initialize. * src/w32.h (Vlibrary_cache): Do not declare. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2012-09-25 11:50:01 +0000 +++ src/ChangeLog 2012-09-25 11:57:30 +0000 @@ -1,3 +1,21 @@ +2012-09-25 Juanma Barranquero + + Move Vlibrary_cache to emacs.c and reset before dumping. + + * lisp.h (reset_image_types): Declare. + [WINDOWSNT] (Vlibrary_cache): Declare. + + * image.c (reset_image_types): New function. + + * emacs.c [WINDOWSNT] (Vlibrary_cache): Move from w32.c. + (syms_of_emacs) [WINDOWSNT] : Initialize and staticpro. + (Fdump_emacs): Reset Vlibrary_cache and image_types. + + * w32.c (Vlibrary_cache): Do not define; moved to emacs.c + (globals_of_w32) : Do not initialize. + + * w32.h (Vlibrary_cache): Do not declare. + 2012-09-25 Eli Zaretskii * w32proc.c (sys_signal): Handle all signals defined by the === modified file 'src/emacs.c' --- src/emacs.c 2012-09-25 11:50:01 +0000 +++ src/emacs.c 2012-09-25 11:57:30 +0000 @@ -96,6 +96,11 @@ /* Empty lisp strings. To avoid having to build any others. */ Lisp_Object empty_unibyte_string, empty_multibyte_string; +#ifdef WINDOWSNT +/* Cache for externally loaded libraries. */ +Lisp_Object Vlibrary_cache; +#endif + /* Set after Emacs has started up the first time. Prevents reinitialization of the Lisp world and keymaps on subsequent starts. */ @@ -2025,6 +2030,13 @@ free (malloc_state_ptr); #endif +#ifdef WINDOWSNT + Vlibrary_cache = Qnil; +#endif +#ifdef HAVE_WINDOW_SYSTEM + reset_image_types (); +#endif + Vpurify_flag = tem; return unbind_to (count, Qnil); @@ -2357,6 +2369,11 @@ Vdynamic_library_alist = Qnil; Fput (intern_c_string ("dynamic-library-alist"), Qrisky_local_variable, Qt); +#ifdef WINDOWSNT + Vlibrary_cache = Qnil; + staticpro (&Vlibrary_cache); +#endif + /* Make sure IS_DAEMON starts up as false. */ daemon_pipe[1] = 0; } === modified file 'src/image.c' --- src/image.c 2012-09-24 21:38:23 +0000 +++ src/image.c 2012-09-25 11:57:30 +0000 @@ -8831,12 +8831,24 @@ return NULL; } +/* Reset image_types before dumping. + Called from Fdump_emacs. */ + +void +reset_image_types (void) +{ + while (image_types) + { + struct image_type *next = image_types->next; + xfree (image_types); + image_types = next; + } +} + void syms_of_image (void) { - /* Initialize this only once, since that's what we do with Vimage_types - and they are supposed to be in sync. Initializing here gives correct - operation on GNU/Linux of calling dump-emacs after loading some images. */ + /* Initialize this only once; it will be reset before dumping. */ image_types = NULL; /* Must be defined now because we're going to update it below, while === modified file 'src/lisp.h' --- src/lisp.h 2012-09-24 21:38:23 +0000 +++ src/lisp.h 2012-09-25 11:57:30 +0000 @@ -2731,6 +2731,7 @@ extern Lisp_Object QCascent, QCmargin, QCrelief; extern Lisp_Object QCconversion; extern int x_bitmap_mask (struct frame *, ptrdiff_t); +extern void reset_image_types (void); extern void syms_of_image (void); /* Defined in insdel.c. */ @@ -3284,6 +3285,9 @@ extern Lisp_Object Qfile_name_handler_alist; extern _Noreturn void terminate_due_to_signal (int, int); extern Lisp_Object Qkill_emacs; +#ifdef WINDOWSNT +extern Lisp_Object Vlibrary_cache; +#endif #if HAVE_SETLOCALE void fixup_locale (void); void synchronize_system_messages_locale (void); === modified file 'src/w32.c' --- src/w32.c 2012-09-25 11:50:01 +0000 +++ src/w32.c 2012-09-25 11:57:30 +0000 @@ -6521,10 +6521,6 @@ -/* Delayed loading of libraries. */ - -Lisp_Object Vlibrary_cache; - /* Try loading LIBRARY_ID from the file(s) specified in Vdynamic_library_alist. If the library is loaded successfully, return the handle of the DLL, and record the filename in the @@ -6769,9 +6765,6 @@ DEFSYM (QCloaded_from, ":loaded-from"); - Vlibrary_cache = Qnil; - staticpro (&Vlibrary_cache); - g_b_init_is_windows_9x = 0; g_b_init_open_process_token = 0; g_b_init_get_token_information = 0; === modified file 'src/w32.h' --- src/w32.h 2012-09-25 11:50:01 +0000 +++ src/w32.h 2012-09-25 11:57:30 +0000 @@ -145,7 +145,7 @@ extern int _sys_read_ahead (int fd); extern int _sys_wait_accept (int fd); -extern Lisp_Object Vlibrary_cache, QCloaded_from; +extern Lisp_Object QCloaded_from; extern HMODULE w32_delayed_load (Lisp_Object); #ifdef HAVE_GNUTLS ------------------------------------------------------------ revno: 110194 committer: Eli Zaretskii branch nick: trunk timestamp: Tue 2012-09-25 13:50:01 +0200 message: Fix handling of fatal signals and exceptions on MS-Windows. src/w32proc.c (sys_signal): Handle all signals defined by the MS-Windows runtime, not just SIGCHLD. Actually install the signal handlers for signals supported by Windows. Don't override term_ntproc as the handler for SIGABRT. (sigaction): Rewrite to call sys_signal instead of duplicating its code. (sys_kill): Improve commentary. src/w32.c (term_ntproc): Accept (and ignore) one argument, for consistency with a signature of a signal handler. All callers changed. (init_ntproc): Accept an argument DUMPING. If dumping, don't install term_ntproc as a signal handler for SIGABRT, as that should be done by the dumped Emacs. src/w32.h (init_ntproc, term_ntproc): Adjust prototypes. src/w32select.c (term_w32select): Protect against repeated invocation by setting clipboard_owner to NULL after calling DestroyWindow. src/emacs.c (shut_down_emacs, main): Adapt the calls to init_ntproc and term_ntproc to their modified signatures. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2012-09-25 07:01:52 +0000 +++ src/ChangeLog 2012-09-25 11:50:01 +0000 @@ -1,5 +1,29 @@ 2012-09-25 Eli Zaretskii + * w32proc.c (sys_signal): Handle all signals defined by the + MS-Windows runtime, not just SIGCHLD. Actually install the signal + handlers for signals supported by Windows. Don't override + term_ntproc as the handler for SIGABRT. + (sigaction): Rewrite to call sys_signal instead of duplicating its + code. + (sys_kill): Improve commentary. + + * w32.c (term_ntproc): Accept (and ignore) one argument, for + consistency with a signature of a signal handler. All callers + changed. + (init_ntproc): Accept an argument DUMPING. If dumping, don't + install term_ntproc as a signal handler for SIGABRT, as that + should be done by the dumped Emacs. + + * w32.h (init_ntproc, term_ntproc): Adjust prototypes. + + * w32select.c (term_w32select): Protect against repeated + invocation by setting clipboard_owner to NULL after calling + DestroyWindow. + + * emacs.c (shut_down_emacs, main): Adapt the calls to init_ntproc + and term_ntproc to their modified signatures. + * character.c (char_string, string_char): Remove calls to MAYBE_UNIFY_CHAR. See the discussion starting at http://lists.gnu.org/archive/html/emacs-devel/2012-09/msg00433.html === modified file 'src/emacs.c' --- src/emacs.c 2012-09-23 17:05:14 +0000 +++ src/emacs.c 2012-09-25 11:50:01 +0000 @@ -1258,7 +1258,7 @@ globals_of_w32 (); /* Initialize environment from registry settings. */ init_environment (argv); - init_ntproc (); /* must precede init_editfns. */ + init_ntproc (dumping); /* must precede init_editfns. */ #endif /* Initialize and GC-protect Vinitial_environment and @@ -1906,7 +1906,7 @@ ignore_sigio (); #ifdef WINDOWSNT - term_ntproc (); + term_ntproc (0); #endif /* Do this only if terminating normally, we want glyph matrices === modified file 'src/w32.c' --- src/w32.c 2012-09-23 09:16:57 +0000 +++ src/w32.c 2012-09-25 11:50:01 +0000 @@ -6624,8 +6624,9 @@ } void -term_ntproc (void) +term_ntproc (int ignored) { + (void)ignored; /* shutdown the socket interface if necessary */ term_winsock (); @@ -6633,7 +6634,7 @@ } void -init_ntproc (void) +init_ntproc (int dumping) { /* Initialize the socket interface now if available and requested by the user by defining PRELOAD_WINSOCK; otherwise loading will be @@ -6710,7 +6711,8 @@ /* unfortunately, atexit depends on implementation of malloc */ /* atexit (term_ntproc); */ - signal (SIGABRT, term_ntproc); + if (!dumping) + signal (SIGABRT, term_ntproc); /* determine which drives are fixed, for GetCachedVolumeInformation */ { === modified file 'src/w32.h' --- src/w32.h 2012-09-23 09:16:57 +0000 +++ src/w32.h 2012-09-25 11:50:01 +0000 @@ -127,8 +127,8 @@ /* Return the string resource associated with KEY of type TYPE. */ extern LPBYTE w32_get_resource (char * key, LPDWORD type); -extern void init_ntproc (void); -extern void term_ntproc (void); +extern void init_ntproc (int); +extern void term_ntproc (int); extern void globals_of_w32 (void); extern void syms_of_w32term (void); extern void syms_of_w32fns (void); === modified file 'src/w32proc.c' --- src/w32proc.c 2012-09-23 17:34:30 +0000 +++ src/w32proc.c 2012-09-25 11:50:01 +0000 @@ -86,19 +86,34 @@ /* Signal handlers...SIG_DFL == 0 so this is initialized correctly. */ static signal_handler sig_handlers[NSIG]; -/* Fake signal implementation to record the SIGCHLD handler. */ +/* Improve on the CRT 'signal' implementation so that we could record + the SIGCHLD handler. */ signal_handler sys_signal (int sig, signal_handler handler) { signal_handler old; - if (sig != SIGCHLD) + /* SIGCHLD is needed for supporting subprocesses, see sys_kill + below. All the others are the only ones supported by the MS + runtime. */ + if (!(sig == SIGCHLD || sig == SIGSEGV || sig == SIGILL + || sig == SIGFPE || sig == SIGABRT || sig == SIGTERM)) { errno = EINVAL; return SIG_ERR; } old = sig_handlers[sig]; - sig_handlers[sig] = handler; + /* SIGABRT is treated specially because w32.c installs term_ntproc + as its handler, so we don't want to override that afterwards. + Aborting Emacs works specially anyway: either by calling + emacs_abort directly or through terminate_due_to_signal, which + calls emacs_abort through emacs_raise. */ + if (!(sig == SIGABRT && old == term_ntproc)) + { + sig_handlers[sig] = handler; + if (sig != SIGCHLD) + signal (sig, handler); + } return old; } @@ -106,23 +121,26 @@ int sigaction (int sig, const struct sigaction *act, struct sigaction *oact) { - signal_handler old; + signal_handler old = SIG_DFL; + int retval = 0; - if (sig != SIGCHLD) - { - errno = EINVAL; - return -1; - } - old = sig_handlers[sig]; if (act) - sig_handlers[sig] = act->sa_handler; + old = sys_signal (sig, act->sa_handler); + else if (oact) + old = sig_handlers[sig]; + + if (old == SIG_ERR) + { + errno = EINVAL; + retval = -1; + } if (oact) { oact->sa_handler = old; oact->sa_flags = 0; oact->sa_mask = empty_mask; } - return 0; + return retval; } /* Defined in which conflicts with the local copy */ @@ -1420,6 +1438,7 @@ return TRUE; } +/* Emulate 'kill', but only for other processes. */ int sys_kill (int pid, int sig) { @@ -1438,6 +1457,11 @@ cp = find_child_pid (pid); if (cp == NULL) { + /* We were passed a PID of something other than our subprocess. + If that is our own PID, we will send to ourself a message to + close the selected frame, which does not necessarily + terminates Emacs. But then we are not supposed to call + sys_kill with our own PID. */ proc_hand = OpenProcess (PROCESS_TERMINATE, 0, pid); if (proc_hand == NULL) { === modified file 'src/w32select.c' --- src/w32select.c 2012-09-23 08:44:20 +0000 +++ src/w32select.c 2012-09-25 11:50:01 +0000 @@ -474,7 +474,10 @@ { /* This is needed to trigger WM_RENDERALLFORMATS. */ if (clipboard_owner != NULL) - DestroyWindow (clipboard_owner); + { + DestroyWindow (clipboard_owner); + clipboard_owner = NULL; + } } static void ------------------------------------------------------------ revno: 110193 committer: martin rudalics branch nick: trunk timestamp: Tue 2012-09-25 10:20:05 +0200 message: Improve resizing of minibuffer windows (Bug#12419). * window.el (window--resize-child-windows): When resizing child windows proportionally, process them in reverse order to preserve the "when splitting a window the new one gets the odd line" behavior. (window--resize-root-window-vertically): When resizing the minibuffer window try to affect only windows at the bottom of the frame. (Bug#12419) diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2012-09-25 05:33:43 +0000 +++ lisp/ChangeLog 2012-09-25 08:20:05 +0000 @@ -1,3 +1,13 @@ +2012-09-25 Martin Rudalics + + * window.el (window--resize-child-windows): When resizing child + windows proportionally, process them in reverse order to + preserve the "when splitting a window the new one gets the odd + line" behavior. + (window--resize-root-window-vertically): When resizing the + minibuffer window try to affect only windows at the bottom of the + frame. (Bug#12419) + 2012-09-25 Chong Yidong * subr.el (declare): Doc fix. === modified file 'lisp/window.el' --- lisp/window.el 2012-09-22 12:56:08 +0000 +++ lisp/window.el 2012-09-25 08:20:05 +0000 @@ -2079,9 +2079,9 @@ Return the symbol `normalized' if new normal sizes have been already set by this routine." (let* ((first (window-child parent)) - (sub first) + (last (window-last-child parent)) (parent-total (+ (window-total-size parent horizontal) delta)) - best-window best-value) + sub best-window best-value) (if (and edge (memq trail '(before after)) (progn @@ -2125,7 +2125,7 @@ ;; normal sizes have been already set. 'normalized) ;; Resize all windows proportionally. - (setq sub first) + (setq sub last) (while sub (cond ((or (window--resize-child-windows-skip-p sub) @@ -2154,14 +2154,14 @@ parent-total) (window-normal-size sub horizontal))))) - (setq sub (window-right sub))) + (setq sub (window-left sub))) (cond ((< delta 0) ;; Shrink windows by delta. (setq best-window t) (while (and best-window (not (zerop delta))) - (setq sub first) + (setq sub last) (setq best-window nil) (setq best-value most-negative-fixnum) (while sub @@ -2171,7 +2171,7 @@ (setq best-window sub) (setq best-value (cdr (window-new-normal sub)))) - (setq sub (window-right sub))) + (setq sub (window-left sub))) (when best-window (setq delta (1+ delta))) @@ -2188,7 +2188,7 @@ ;; Enlarge windows by delta. (setq best-window t) (while (and best-window (not (zerop delta))) - (setq sub first) + (setq sub last) (setq best-window nil) (setq best-value most-positive-fixnum) (while sub @@ -2197,7 +2197,7 @@ (setq best-window sub) (setq best-value (window-new-normal sub))) - (setq sub (window-right sub))) + (setq sub (window-left sub))) (when best-window (setq delta (1- delta))) @@ -2209,7 +2209,7 @@ (window-normal-size best-window horizontal)))))) (when best-window - (setq sub first) + (setq sub last) (while sub (when (or (consp (window-new-normal sub)) (numberp (window-new-normal sub))) @@ -2227,7 +2227,7 @@ ;; recursively even if it's size does not change. (window--resize-this-window sub delta horizontal ignore nil trail edge)))) - (setq sub (window-right sub))))))) + (setq sub (window-left sub))))))) (defun window--resize-siblings (window delta &optional horizontal ignore trail edge) "Resize other windows when WINDOW is resized vertically by DELTA lines. @@ -2406,27 +2406,33 @@ This function is only called by the minibuffer window resizing routines. It resizes windows proportionally and never deletes any windows." - (when (numberp delta) - (let (ignore) - (cond - ((< delta 0) - (setq delta (window-sizable window delta))) - ((> delta 0) - (unless (window-sizable window delta) - (setq ignore t)))) - - (window--resize-reset (window-frame window)) - ;; Ideally, we would resize just the last window in a combination - ;; but that's not feasible for the following reason: If we grow - ;; the minibuffer window and the last window cannot be shrunk any - ;; more, we shrink another window instead. But if we then shrink - ;; the minibuffer window again, the last window might get enlarged - ;; and the state after shrinking is not the state before growing. - ;; So, in practice, we'd need a history variable to record how to - ;; proceed. But I'm not sure how such a variable could work with - ;; repeated minibuffer window growing steps. - (window--resize-this-window window delta nil ignore t) - delta))) + (let ((frame (window-frame window)) + ignore) + (cond + ((not (numberp delta)) + (setq delta 0)) + ((zerop delta)) + ((< delta 0) + (setq delta (window-sizable window delta)) + (window--resize-reset frame) + ;; When shrinking the root window, emulate an edge drag in order + ;; to not resize other windows if we can avoid it (Bug#12419). + (window--resize-this-window + window delta nil ignore t 'before + (+ (window-top-line window) (window-total-size window))) + ;; Don't record new normal sizes to make sure that shrinking back + ;; proportionally works as intended. + (walk-window-tree + (lambda (window) (set-window-new-normal window 'ignore)) frame t)) + ((> delta 0) + (window--resize-reset frame) + (unless (window-sizable window delta) + (setq ignore t)) + ;; When growing the root window, resize proportionally. This + ;; should give windows back their original sizes (hopefully). + (window--resize-this-window window delta nil ignore t))) + ;; Return the possibly adjusted DELTA. + delta)) (defun adjust-window-trailing-edge (window delta &optional horizontal) "Move WINDOW's bottom edge by DELTA lines. ------------------------------------------------------------ revno: 110192 committer: Eli Zaretskii branch nick: trunk timestamp: Tue 2012-09-25 09:01:52 +0200 message: Don't call MAYBE_UNIFY_CHAR while processing buffers and strings. src/character.c (char_string, string_char): Remove calls to MAYBE_UNIFY_CHAR. See the discussion starting at http://lists.gnu.org/archive/html/emacs-devel/2012-09/msg00433.html for the details. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2012-09-25 04:13:02 +0000 +++ src/ChangeLog 2012-09-25 07:01:52 +0000 @@ -1,3 +1,10 @@ +2012-09-25 Eli Zaretskii + + * character.c (char_string, string_char): Remove calls to + MAYBE_UNIFY_CHAR. See the discussion starting at + http://lists.gnu.org/archive/html/emacs-devel/2012-09/msg00433.html + for the details. + 2012-09-25 Chong Yidong * xdisp.c (mode_line_inverse_video): Delete obsolete variable. === modified file 'src/character.c' --- src/character.c 2012-09-15 07:06:56 +0000 +++ src/character.c 2012-09-25 07:01:52 +0000 @@ -126,8 +126,6 @@ c &= ~CHAR_MODIFIER_MASK; } - MAYBE_UNIFY_CHAR (c); - if (c <= MAX_3_BYTE_CHAR) { bytes = CHAR_STRING (c, p); @@ -195,8 +193,6 @@ p += 5; } - MAYBE_UNIFY_CHAR (c); - if (len) *len = p - saved_p; if (advanced) ------------------------------------------------------------ revno: 110191 committer: Chong Yidong branch nick: trunk timestamp: Tue 2012-09-25 13:33:43 +0800 message: Minor fixes for the function obsolescence feature. * lisp/help-fns.el (help-fns--obsolete): Handle macros properly. * lisp/subr.el (declare): Doc fix. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2012-09-25 04:13:02 +0000 +++ lisp/ChangeLog 2012-09-25 05:33:43 +0000 @@ -1,5 +1,11 @@ 2012-09-25 Chong Yidong + * subr.el (declare): Doc fix. + + * help-fns.el (help-fns--obsolete): Handle macros properly. + +2012-09-25 Chong Yidong + * bookmark.el (bookmark-jump-noselect): Use a declare form to mark this function obsolete. === modified file 'lisp/help-fns.el' --- lisp/help-fns.el 2012-09-11 13:43:06 +0000 +++ lisp/help-fns.el 2012-09-25 05:33:43 +0000 @@ -488,13 +488,17 @@ (insert "'.\n")))) (defun help-fns--obsolete (function) - (let* ((obsolete (and - ;; `function' might be a lambda construct. - (symbolp function) - (get function 'byte-obsolete-info))) + ;; Ignore lambda constructs, keyboard macros, etc. + (let* ((obsolete (and (symbolp function) + (get function 'byte-obsolete-info))) (use (car obsolete))) (when obsolete - (insert "\nThis function is obsolete") + (insert "\nThis " + (if (eq (car-safe (symbol-function 'with-current-buffer)) + 'macro) + "macro" + "function") + " is obsolete") (when (nth 2 obsolete) (insert (format " since %s" (nth 2 obsolete)))) (insert (cond ((stringp use) (concat ";\n" use)) @@ -611,7 +615,7 @@ (fill-region-as-paragraph (save-excursion (goto-char pt1) (forward-line 0) (point)) (point))) (terpri)(terpri) - + (let* ((doc-raw (condition-case err (documentation function t) (error (format "No Doc! %S" err)))) === modified file 'lisp/subr.el' --- lisp/subr.el 2012-09-25 04:13:02 +0000 +++ lisp/subr.el 2012-09-25 05:33:43 +0000 @@ -271,9 +271,14 @@ ,@(cdr (cdr spec)))))) (defmacro declare (&rest _specs) - "Do not evaluate any arguments and return nil. -Treated as a declaration when used at the right place in a -`defmacro' form. \(See Info anchor `(elisp)Definition of declare'.)" + "Do not evaluate any arguments, and return nil. +If a `declare' form appears as the first form in the body of a +`defun' or `defmacro' form, SPECS specifies various additional +information about the function or macro; these go into effect +during the evaluation of the `defun' or `defmacro' form. + +The possible values of SPECS are specified by +`defun-declarations-alist' and `macro-declarations-alist'." ;; FIXME: edebug spec should pay attention to defun-declarations-alist. nil) ))