2 * Copyright (c) 2005 SilverStorm Technologies. All rights reserved.
4 * This software is available to you under the OpenIB.org BSD license
7 * Redistribution and use in source and binary forms, with or
8 * without modification, are permitted provided that the following
11 * - Redistributions of source code must retain the above
12 * copyright notice, this list of conditions and the following
15 * - Redistributions in binary form must reproduce the above
16 * copyright notice, this list of conditions and the following
17 * disclaimer in the documentation and/or other materials
18 * provided with the distribution.
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
24 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
25 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
26 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
34 /* Nth element of the table contains the index of the first set bit of N; 8 - for N=0 */
35 char g_set_bit_tbl[256];
37 /* Nth element of the table contains the index of the first 0 bit of N; 8 - for N=255 */
38 char g_clr_bit_tbl[256];
43 for (i=0; i<256; ++i) {
44 g_set_bit_tbl[i] = (char)(_ffs_raw(&i,0) - 1);
45 g_clr_bit_tbl[i] = (char)(_ffz_raw(&i,0) - 1);
47 g_set_bit_tbl[0] = g_clr_bit_tbl[255] = 8;