File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1111 * \{
1212 * \file
1313 * \author Kaspar Schleiser <kaspar.schleiser@fu-berlin.de>
14+ * \author Martin Lenders <mlenders@inf.fu-berlin.de>
1415 * \}
1516 */
1617
@@ -39,29 +40,3 @@ number_of_highest_bit(unsigned v)
3940
4041 return r ;
4142}
42- /*---------------------------------------------------------------------------*/
43- unsigned
44- number_of_lowest_bit (register unsigned v )
45- {
46- register unsigned r = 0 ;
47-
48- while ((v & 0x01 ) == 0 ) {
49- v >>= 1 ;
50- r ++ ;
51- };
52-
53- return r ;
54- }
55- /*---------------------------------------------------------------------------*/
56- unsigned
57- number_of_bits_set (unsigned v )
58- {
59- unsigned c ; // c accumulates the total bits set in v
60-
61- for (c = 0 ; v ; c ++ ) {
62- v &= v - 1 ; // clear the least significant bit set
63- }
64-
65- return c ;
66- }
67-
Original file line number Diff line number Diff line change 1313 * @file
1414 * @author Freie Universität Berlin, Computer Systems & Telematics
1515 * @author Kaspar Schleiser <kaspar.schleiser@fu-berlin.de>
16+ * @author Martin Lenders <mlenders@inf.fu-berlin.de>
1617 */
1718
1819#ifndef BITARITHM_H_
@@ -78,22 +79,17 @@ unsigned number_of_highest_bit(unsigned v);
7879
7980/**
8081 * @brief Returns the number of the lowest '1' bit in a value
81- * @param[in] v Input value - must be unequal to '0', otherwise the
82- * function will produce an infinite loop
83- * @return Bit Number
84- *
85- * Source: http://graphics.stanford.edu/~seander/bithacks.html#IntegerLogObvious
82+ * @param[in] v Input value
83+ * @return Bit Number, 0 for least significant bit, -1 if input is 0
8684 */
87- unsigned number_of_lowest_bit (register unsigned v );
85+ #define number_of_lowest_bit (v ) (__builtin_ffs(v)-1)
8886
8987/**
9088 * @brief Returns the number of bits set in a value
9189 * @param[in] v Input value
9290 * @return Number of set bits
93- *
94- * Source: http://graphics.stanford.edu/~seander/bithacks.html#IntegerLogObvious
9591 */
96- unsigned number_of_bits_set (unsigned v );
92+ #define number_of_bits_set (v ) (__builtin_popcount(v))
9793
9894/**
9995 * @}
Original file line number Diff line number Diff line change 1+ /**
2+ * Copyright (C) 2013 INRIA.
3+ *
4+ * This file subject to the terms and conditions of the GNU Lesser General
5+ * Public License. See the file LICENSE in the top level directory for more
6+ * details.
7+ */
8+
9+ /**
10+ * @addtogroup posix
11+ * @{
12+ * @file
13+ * @brief POSIX-like IO
14+ *
15+ * @author Freie Universität Berlin
16+ * @author Kaspar Schleiser <kaspar@schleiser.de>
17+ * @author Stephan Zeisberg <zeisberg@mi.fu-berlin.de>
18+ * @author Oliver Hahm <oleg@hobbykeller.org>
19+ * @author Martin Lenders <mlenders@inf.fu-berlin.de>
20+ */
121#ifndef __READ_H
222#define __READ_H
323
@@ -15,5 +35,7 @@ int posix_open(int pid, int flags);
1535int posix_close (int pid );
1636int posix_read (int pid , char * buffer , int bufsize );
1737int posix_write (int pid , char * buffer , int bufsize );
18-
38+ /**
39+ * @}
40+ */
1941#endif /* __READ_H */
You can’t perform that action at this time.
0 commit comments