summaryrefslogtreecommitdiffstats
path: root/include/qemu/bitops.h
Commit message (Collapse)AuthorAgeFilesLines
* bitmap: add atomic set functionsStefan Hajnoczi2015-06-051-0/+14
| | | | | | | | | | | | | | | | | | Use atomic_or() for atomic bitmaps where several threads may set bits at the same time. This avoids the race condition between threads loading an element, bitwise ORing, and then storing the element. When setting all bits in a word we can avoid atomic ops and instead just use an smp_mb() at the end. Most bitmap users don't need atomicity so introduce new functions. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Message-Id: <1417519399-3166-2-git-send-email-stefanha@redhat.com> [Avoid barrier in the single word case, use full barrier instead of write. - Paolo] Reviewed-by: Fam Zheng <famz@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* bitops : fix coding styleChih-Min Chao2015-04-301-30/+31
| | | | | | | | don't mix tab and space. The rule is 4 spaces Signed-off-by: Chih-Min Chao <cmchao@gmail.com> Reviewed-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
* bitops.h: sextract64() return type should be int64_t, not uint64_tPeter Maydell2015-03-111-1/+1
| | | | | | | | | | | The documentation for sextract64() claims that the return type is an int64_t, but the code itself disagrees. Fix the return type to conform to the documentation and to bring it into line with sextract32(), which returns int32_t. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Richard Henderson <rth@twiddle.net> Message-id: 1423231328-15662-1-git-send-email-peter.maydell@linaro.org
* bitops.h: Don't include qemu-common.hEduardo Habkost2014-11-021-1/+3
| | | | | | | | | | This removes the following circular dependency: bitops.h -> qemu-common.h -> target-i386/cpu.h -> target-i386/cpu-qom.h -> qom/cpu.h -> qdev-core.h -> bitmap.h -> bitops.h. Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
* bitops: provide an inline implementation of find_first_bitAurelien Jarno2014-06-181-1/+11
| | | | | | | | | | | | | | find_first_bit has started to be used heavily in TCG code. The current implementation based on find_next_bit is not optimal and can't be optimized be the compiler if the bit array has a fixed size, which is the case most of the time. This new implementation does not use find_next_bit and is yet small enough to be inlined. Cc: Corentin Chary <corentin.chary@gmail.com> Reviewed-by: Richard Henderson <rth@twiddle.net> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
* bitmap: use long as indexJuan Quintela2014-01-131-7/+7
| | | | | | | | | | Move index and size fields from int to long. We need that for migration. long is 64 bits on sane architectures, and 32bits should be enough on all the 32bits architectures. Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Orit Wasserman <owasserm@redhat.com>
* bitops: Add rotate functions (rol8, ror8, ...)Stefan Weil2013-09-251-0/+80
| | | | | | | These functions were copies from include/linux/bitopts.h. Signed-off-by: Stefan Weil <sw@weilnetz.de> Reviewed-by: Richard Henderson <rth@twiddle.net>
* bitops: Provide sextract32() and sextract64()Peter Maydell2013-07-221-0/+50
| | | | | | | | | | | | | | | A common operation in instruction decoding is to take a field from an instruction that represents a signed integer in some arbitrary number of bits, and sign extend it into a C signed integer type for manipulation. Provide new functions sextract32() and sextract64() which perform this operation; they are like the existing extract32() and extract64() except that the field is sign-extended into the returned result. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Richard Henderson <rth@twiddle.net> Message-id: 1372419632-5521-2-git-send-email-peter.maydell@linaro.org Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* bitops: Remove routines redundant with host-utilsRichard Henderson2013-02-161-48/+0
| | | | | | Signed-off-by: Richard Henderson <rth@twiddle.net> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* bitops: Write bitops_flsl in terms of clzlRichard Henderson2013-02-161-28/+1
| | | | | | Signed-off-by: Richard Henderson <rth@twiddle.net> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* bitops: unify bitops_ffsl with the one in host-utils.h, call it bitops_ctzlPaolo Bonzini2013-02-021-33/+22
| | | | | | | | | | | | | | | | | | We had two copies of a ffs function for longs with subtly different semantics and, for the one in bitops.h, a confusing name: the result was off-by-one compared to the library function ffsl. Unify the functions into one, and solve the name problem by calling the 0-based functions "bitops_ctzl" and "bitops_ctol" respectively. This also fixes the build on platforms with ffsl, including Mac OS X and Windows. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Tested-by: Andreas Färber <afaerber@suse.de> Tested-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* misc: move include files to include/qemu/Paolo Bonzini2012-12-191-0/+362
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
OpenPOWER on IntegriCloud