summaryrefslogtreecommitdiffstats
path: root/build-root/emacs-lisp
diff options
context:
space:
mode:
Diffstat (limited to 'build-root/emacs-lisp')
-rwxr-xr-xbuild-root/emacs-lisp/fix-coding-style.el82
1 files changed, 58 insertions, 24 deletions
diff --git a/build-root/emacs-lisp/fix-coding-style.el b/build-root/emacs-lisp/fix-coding-style.el
index 3c927970104..579f9c53558 100755
--- a/build-root/emacs-lisp/fix-coding-style.el
+++ b/build-root/emacs-lisp/fix-coding-style.el
@@ -1,21 +1,41 @@
#!/usr/bin/emacs --script
-;; Insert style boilerplate
+;; Insert style boilerplate if it's not already there
;;
;; Breaking the string in half keeps emacs
;; from trying to interpret the local variable
;; settings e.g. when it reads the lisp source code
(defun insert-style-boilerplate () (interactive)
- (save-excursion (goto-char (point-max))
- (insert "
+ (save-excursion
+ (goto-char (point-min))
+ (if (eq nil (search-forward "coding-style-patch-verification"
+ (point-max) t))
+ (let ((junk 0)) (goto-char (point-max))
+ (insert "
/*
* fd.io coding-style-patch-verification: ON
*
* Local Var" "iables:
* eval: (c-set-style \"gnu\")
* End:
- */")))
+ */")))))
+
+;; (cons xxx <list>) means insert xxx at the head of <list>
+;; Build a sorted list of *INDENT-OFF* lines, by searching
+;; backwards. The initial (setq indent-offset-list nil)
+;; results in (cdr <last-cell>) nil, which makes it a proper list
+
+(defun find-indent-offs () (interactive)
+ (save-excursion
+ (if (boundp 'indent-offset-list)
+ (makunbound 'indent-offset-list))
+ (setq indent-offset-list nil)
+ (goto-char (point-max))
+ (while (search-backward "*INDENT-OFF*" (point-min) t)
+ (move-beginning-of-line nil)
+ (setq indent-offset-list (cons (point) indent-offset-list))
+ (previous-line))))
;; Insert indent-off ... indent-on brackets around
;; a certain xxx_foreach macro, etc. which "indent"
@@ -23,20 +43,31 @@
;; are few examples (fortunately).
(defun fix-initializer (what) (interactive)
+ (find-indent-offs)
(save-excursion
(goto-char (point-min))
(while (search-forward-regexp what (point-max) t)
(move-beginning-of-line nil)
- (open-line 1)
- (c-indent-line-or-region)
- (insert "/* *INDENT-OFF* */")
- (search-forward "{")
- (backward-char)
- (forward-sexp)
- (move-end-of-line nil)
- (newline 1)
- (c-indent-line-or-region)
- (insert "/* *INDENT-ON* */"))))
+ (previous-line)
+ (let ((index 0)(pointval 0))
+ (while (and (< pointval (point))(elt indent-offset-list index))
+ (setq pointval (elt indent-offset-list index))
+ (setq index (1+ index)))
+ (if (not (eq pointval (point)))
+ (let ((junk 0))
+ (next-line)
+ (open-line 1)
+ (c-indent-line-or-region)
+ (insert "/* *INDENT-OFF* */")
+ (search-forward "{")
+ (backward-char)
+ (forward-sexp)
+ (move-end-of-line nil)
+ (newline 1)
+ (c-indent-line-or-region)
+ (insert "/* *INDENT-ON* */")
+ (find-indent-offs))
+ (search-forward "*INDENT-ON*"))))))
(defun fix-pool-foreach () (interactive)
(fix-initializer "pool_foreach *("))
@@ -98,8 +129,9 @@
(fix-reply-macro2)
(fix-vnet-device-class)
(fix-vnet-hw-interface-class)
- (insert-style-boilerplate))
-
+ (insert-style-boilerplate)
+ (if (boundp 'indent-offset-list)
+ (makunbound 'indent-offset-list)))
;; When run as a script, this sexp
;; walks the list of files supplied on the command line.
@@ -108,14 +140,16 @@
;; or M-x load-file the file, so we won't accidentally
;; evaluate (save-buffers-kill-emacs)...
-(let ((index 0))
- (if (elt argv index)
- (while (elt argv index)
- (message "Processing %s..." (elt argv index))
- (find-file (elt argv index))
+(let ((file-index 0))
+ (if (elt argv file-index)
+ (while (elt argv file-index)
+ (find-file (elt argv file-index))
(fd-io-styleify)
- (setq index (1+ index))))
- (if (> index 0)
- (save-buffers-kill-emacs t)))
+ (message "Done %s..." (elt argv file-index))
+ (setq file-index (1+ file-index))))
+ (if (> file-index 0)
+ (let ((junk 0))
+ (message "Save and quit...")
+ (save-buffers-kill-emacs t))))
{ color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */ }
/*
 * Copyright (c) 2012 Cisco and/or its affiliates.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at:
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef SRC_VPPINFRA_FLOWHASH_24_16_H_
#define SRC_VPPINFRA_FLOWHASH_24_16_H_

#ifdef __included_flowhash_template_h__
#undef __included_flowhash_template_h__
#endif

#include <vppinfra/clib.h>
#include <vppinfra/xxhash.h>
#include <vppinfra/crc32.h>

typedef struct {
  u64 as_u64[3];
} flowhash_skey_24_16_t;

typedef struct {
  u64 as_u64[3];
} flowhash_lkey_24_16_t;

typedef struct {
  u64 as_u64[2];
} flowhash_value_24_16_t;

#define FLOWHASH_TYPE _24_16
#include <vppinfra/flowhash_template.h>
#undef FLOWHASH_TYPE

static_always_inline
u32 flowhash_hash_24_16(flowhash_lkey_24_16_t *k)
{
#ifdef clib_crc32c_uses_intrinsics
  return clib_crc32c ((u8 *) &k->as_u64[0], 24);
#else
  u64 val = 0;
  val ^= k->as_u64[0];
  val ^= k->as_u64[1];
  val ^= k->as_u64[2];
  return (u32)clib_xxhash (val);
#endif
}

static_always_inline
u8 flowhash_cmp_key_24_16(flowhash_skey_24_16_t *a,
                          flowhash_lkey_24_16_t *b)
{
  u8 val = 0;
  val |= (a->as_u64[0] != b->as_u64[0]);
  val |= (a->as_u64[1] != b->as_u64[1]);
  val |= (a->as_u64[2] != b->as_u64[2]);
  return val;
}

static_always_inline
void flowhash_cpy_key_24_16(flowhash_skey_24_16_t *dst,
        	                    flowhash_lkey_24_16_t *src)
{
  dst->as_u64[0] = src->as_u64[0];
  dst->as_u64[1] = src->as_u64[1];
  dst->as_u64[2] = src->as_u64[2];
}

#endif /* SRC_VPPINFRA_FLOWHASH_24_16_H_ */