This is an automated email from the ASF dual-hosted git repository. bcall pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/master by this push: new 44caf60 Remove Bitops - apparently not used anywhere and should be replaced by std::bitset anyway. 44caf60 is described below commit 44caf60aa2d2fc69992b34d72712a7cf19201b15 Author: Alan M. Carroll <a...@apache.org> AuthorDate: Wed Sep 26 13:35:48 2018 -0500 Remove Bitops - apparently not used anywhere and should be replaced by std::bitset anyway. --- include/tscore/Bitops.h | 272 ------------------------------------------------ src/tscore/Bitops.cc | 42 -------- src/tscore/Makefile.am | 2 - 3 files changed, 316 deletions(-) diff --git a/include/tscore/Bitops.h b/include/tscore/Bitops.h deleted file mode 100644 index 45bfb43..0000000 --- a/include/tscore/Bitops.h +++ /dev/null @@ -1,272 +0,0 @@ -/** @file - - Utility functions for efficient bit operations - - @section license License - - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you 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. - */ - -#pragma once - -#include <strings.h> - -/** - Find First (bit) Set. Index starts at 1. - - @return zero for zero arg. - -*/ -static inline int -ink_ffs(int n) -{ - return ffs(n); -} - -/** - Returns the index of the first bit (least significant bit), set "1" - for each char in the range (start end). - - @param start pointer to the first character. - @param end pointer to the location after the last character. - @param p (if not null) returns the location of the first char that - has a bit set. - @return index of the first bit set in the first character that has a - bit turned on. Zero if all bits are zero. - -*/ -static inline int -bitops_first_set(unsigned char *start, unsigned char *end, unsigned char **p) -{ - extern unsigned char bit_table[]; - - int idx; - - idx = 0; - while (start != end) { - idx = bit_table[*start]; - if (idx) { - break; - } - start += 1; - } - - if (p) { - *p = start; - } - - return idx; -} - -/** - Returns the index of the first bit (least significant bit), unset "0" - for each char in the range (start end). - - @param start pointer to the first character. - @param end pointer to the location after the last character. - @param p (if not null) returns the location of the first char that - has a bit unset. - @return index of the first bit set in the first character that has a - bit turned off. Zero if all bits are 1. - -*/ -static inline int -bitops_first_unset(unsigned char *start, unsigned char *end, unsigned char **p) -{ - extern unsigned char bit_table[]; - - int idx; - - idx = 0; - while (start != end) { - idx = bit_table[~(*start)]; - if (idx) { - break; - } - start += 1; - } - - if (p) { - *p = start; - } - - return idx; -} - -/** - Returns the index of the first bit (least significant bit), set "1" - for each char in the range (start end). - - @param start pointer to the first character. - @param end pointer to the location after the last character. - @param offset - @return index of the first bit set in the first character that has a - bit turned on. Zero if all bits are zero. - -*/ -static inline int -bitops_next_set(unsigned char *start, unsigned char *end, int offset) -{ - extern unsigned char bit_table[]; - - unsigned char *p; - unsigned char c; - size_t idx; - int t; - - idx = 0; - p = start + offset / 8; - t = (offset % 8) + 1; - - while (p != end) { - idx = bit_table[*p]; - if (idx) { - c = *p; - while (idx && (idx <= (size_t)t)) { - c &= ~(1 << (idx - 1)); - idx = bit_table[c]; - } - - if (idx) { - break; - } - } - p += 1; - t = 0; - } - - if (idx) { - idx -= 1; - idx += (p - start) * 8; - } else { - idx = (size_t)-1; - } - - return (int)idx; -} - -static inline int -bitops_next_unset(unsigned char *start, unsigned char *end, int offset) -{ - extern unsigned char bit_table[]; - - unsigned char *p; - unsigned char c; - size_t idx; - int t; - - idx = 0; - p = start + offset / 8; - t = (offset % 8) + 1; - - while (p != end) { - c = ~(*p); - idx = bit_table[c]; - if (idx) { - while (idx && (idx <= (size_t)t)) { - c &= ~(1 << (idx - 1)); - idx = bit_table[c]; - } - - if (idx) { - break; - } - } - p += 1; - t = 0; - } - - if (idx) { - idx -= 1; - idx += (p - start) * 8; - } else { - idx = (size_t)-1; - } - - return (int)idx; -} - -static inline int -bitops_count(unsigned char *start, unsigned char *end) -{ - extern unsigned char bit_count_table[]; - - int count; - - count = 0; - while (start != end) { - count += bit_count_table[*start++]; - } - - return count; -} - -static inline void -bitops_union(unsigned char *s1, unsigned char *s2, int len) -{ - int i; - - if (!s1 || !s2) { - return; - } - - for (i = 0; i < len; i++) { - s1[i] |= s2[i]; - } -} - -static inline unsigned char -bitops_set(unsigned char val, int bit) -{ - return (val | (1 << bit)); -} - -static inline void -bitops_set(unsigned char *val, int bit) -{ - int pos = bit >> 3; - int idx = bit & 0x7; - val[pos] |= (1 << idx); -} - -static inline unsigned char -bitops_unset(unsigned char val, int bit) -{ - return (val & ~(1 << bit)); -} - -static inline void -bitops_unset(unsigned char *val, int bit) -{ - int pos = bit >> 3; - int idx = bit & 0x7; - val[pos] &= ~(1 << idx); -} - -static inline int -bitops_isset(unsigned char val, int bit) -{ - return ((val & (1 << bit)) != 0); -} - -static inline int -bitops_isset(unsigned char *val, int bit) -{ - int pos = bit / 8; - int idx = bit % 8; - return ((val[pos] & (1 << idx)) != 0); -} diff --git a/src/tscore/Bitops.cc b/src/tscore/Bitops.cc deleted file mode 100644 index d734677..0000000 --- a/src/tscore/Bitops.cc +++ /dev/null @@ -1,42 +0,0 @@ -/** @file - - A brief file description - - @section license License - - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you 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. - */ - -#include "tscore/Bitops.h" - -unsigned char bit_table[256] = { - 0, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, 5, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, 6, 1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5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, 1, - 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, - 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, - 6, 4, 5, 5, 6, 5, 6, 6, 7, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8, -}; diff --git a/src/tscore/Makefile.am b/src/tscore/Makefile.am index 10993b1..2221bb7 100644 --- a/src/tscore/Makefile.am +++ b/src/tscore/Makefile.am @@ -58,8 +58,6 @@ libtscore_la_SOURCES = \ ArgParser.h \ BaseLogFile.cc \ BaseLogFile.h \ - Bitops.cc \ - Bitops.h \ BufferWriter.h \ BufferWriterForward.h \ BufferWriterFormat.cc \