svx_c.h (1316B)
1 /* Copyright (C) 2018, 2020-2025 |Méso|Star> (contact@meso-star.com) 2 * Copyright (C) 2018 Université Paul Sabatier 3 * 4 * This program is free software: you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation, either version 3 of the License, or 7 * (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program. If not, see <http://www.gnu.org/licenses/>. */ 16 17 #ifndef SVX_C_H 18 #define SVX_C_H 19 20 #include "svx.h" 21 #include <rsys/rsys.h> 22 23 /* Count the number of bits set to 1 */ 24 static FINLINE int 25 popcount(const uint8_t x) 26 { 27 int n = x - ((x >> 1) & 0x55); 28 n = (n & 0x33) + ((n >> 2) & 0x33); 29 n = (n + (n >> 4)) & 0x0f; 30 return (n * 0x0101) >> 8; 31 } 32 33 static INLINE int 34 check_svx_voxel_desc(const struct svx_voxel_desc* desc) 35 { 36 return desc 37 && desc->get 38 && desc->merge 39 && desc->challenge_merge 40 && desc->size > 0 41 && desc->size <= SVX_MAX_SIZEOF_VOXEL; 42 } 43 44 #endif /* SVX_C_H */ 45