Re: [Qemu-devel] BIT_WORD(start >> TARGET_PAGE_BITS)
On Fri, Jun 30, 2017 at 2:02 PM, ali saeediwrote: > Hello > what does the following code do? > 'unsigned long page = BIT_WORD(start >> TARGET_PAGE_BITS)' ? > thanks a lot Aside from Eric's response, I want to mention that I've noticed your frequent questions too. A volunteer project like QEMU can only make progress if people "give" more than they "take". Each question you ask takes someone's time. Often the person responding searches the code base for you and then replies with the answer. If you keep demanding time and attention without giving back to QEMU then people notice this and they will stop responding. I'm not trying to attack you, just letting you know what I've often seen happen when someone wants more support than the volunteers are willing to give. This is an opportunity to do two things: 1. Learn to answer your own questions by reading the code, adding printfs, using a debugger, and other techniques. This will make you more independent and you'll be more productive. 2. Start contributing to QEMU by reviewing patches on the mailing list, helping users on #qemu IRC, etc. I'd be happy to discuss how to do these things in more detail. Stefan
Re: [Qemu-devel] BIT_WORD(start >> TARGET_PAGE_BITS)
thank you so much Eric Sorry for too questions I certainly follow your guide thanks a lot On Fri, Jun 30, 2017 at 5:49 PM, Eric Blakewrote: > 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 == 0x1' 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 > >
Re: [Qemu-devel] BIT_WORD(start >> TARGET_PAGE_BITS)
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 == 0x1' 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
[Qemu-devel] BIT_WORD(start >> TARGET_PAGE_BITS)
Hello what does the following code do? 'unsigned long page = BIT_WORD(start >> TARGET_PAGE_BITS)' ? thanks a lot