kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
* How to understand the comment of macro *compute_indices*?
@ 2020-07-13 23:54 carver
  2020-07-14  2:21 ` Valdis Klētnieks
  0 siblings, 1 reply; 2+ messages in thread
From: carver @ 2020-07-13 23:54 UTC (permalink / raw)
  To: kernelnewbies

Hello,

Macro *compute_indices* in arch/arm64/kernel/head.S have a comment
as shown below:
	mov     \istart, \ptrs
	mul     \istart, \istart, \count
	add     \iend, \iend, \istart   // iend += (count - 1) * ptrs

I am wondering whether this comment should be change to 
"iend += count * ptrs".

Or am I misunderstanding this code?

Thanks

-Lio

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: How to understand the comment of macro *compute_indices*?
  2020-07-13 23:54 How to understand the comment of macro *compute_indices*? carver
@ 2020-07-14  2:21 ` Valdis Klētnieks
  0 siblings, 0 replies; 2+ messages in thread
From: Valdis Klētnieks @ 2020-07-14  2:21 UTC (permalink / raw)
  To: carver; +Cc: kernelnewbies


[-- Attachment #1.1: Type: text/plain, Size: 687 bytes --]

On Tue, 14 Jul 2020 07:54:04 +0800, carver said:
> Hello,
>
> Macro *compute_indices* in arch/arm64/kernel/head.S have a comment
> as shown below:
> 	mov     \istart, \ptrs
> 	mul     \istart, \istart, \count
> 	add     \iend, \iend, \istart   // iend += (count - 1) * ptrs
>
> I am wondering whether this comment should be change to
> "iend += count * ptrs".

Examine the uses of the macro, and see where they expect the result
to be pointing if there is exactly one entry. (Hint - what's the address of
the first entry of a C array, and what's the next location after the array,
and how would the corresponding C code for iterating across the array
have as the termination condition?)

[-- Attachment #1.2: Type: application/pgp-signature, Size: 832 bytes --]

[-- Attachment #2: Type: text/plain, Size: 170 bytes --]

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-07-14  2:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-13 23:54 How to understand the comment of macro *compute_indices*? carver
2020-07-14  2:21 ` Valdis Klētnieks

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).