On 06/30/2017 08:02 AM, ali saeedi wrote: > Hello > what does the following code do? > 'unsigned long page = BIT_WORD(start >> TARGET_PAGE_BITS)' ?
I've noticed you've been asking a lot of questions (each as a new thread, rather than replying to previous answers), that seem like you are not trying very hard to read the code and find an answer for yourself. Rather than just answer you, I'm going to try to teach you how to read the source and answer the question yourself. You may also get better answers to your future questions if you ask in the form of "this code is confusing me, I think it means this, based on what I read at xyz, but would like confirmation or correction" (showing WHAT you have already researched) rather than just "what does this code do" (and making it feel like you are off-loading the research work onto others). First, figure out what BIT_WORD does: $ git grep 'define BIT_WORD' That should have only one hit, in include/qemu/bitops.h. Reading it in context doesn't have any more comments, but it looks like it is computing the number of bits that are available in a word, and looks like it is defining a word to be the type most efficiently operated on for the current ABI (a long is 32 bits on a 32-bit OS, and 64 bits on a 64-bit OS). It also looks like you are scaling a start address by the number of bits in a target page. So it probably means you are computing the index for which page 'start' occurs on (depending on values, it might mean that 'start == 0x0' is page 0, 'start == 0x10000' is page 1, and so on), where start is initially in the form of the number of bits per page. -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
signature.asc
Description: OpenPGP digital signature