diff --git a/cpu/msp430_common/mspgcc-supplement.c b/cpu/msp430_common/mspgcc-supplement.c new file mode 100644 index 0000000000..e9c97886cb --- /dev/null +++ b/cpu/msp430_common/mspgcc-supplement.c @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2016 Eistec AB + * + * This file is subject to the terms and conditions of the GNU Lesser + * General Public License v2.1. See the file LICENSE in the top level + * directory for more details. + */ + +/** + * @ingroup cpu + * @{ + * + * @file + * @brief MSPGCC supplemental functions + * + * @author Joakim NohlgÄrd >= 1) { + if (x & mask) { + return i; + } + ++i; + } + return i; /* returns 16 if x == 0 */ +} + +/** + * @brief Count trailing zeros + * + * Naive implementation + */ +int __ctzhi2(UHItype x) +{ + int i = 0; + for (UHItype mask = 1; mask != 0; mask <<= 1) { + if (x & mask) { + return i; + } + ++i; + } + return i; /* returns 16 if x == 0 */ +} +#endif /* __MSPGCC__ */