Kernel Newbies archive on lore.kernel.org
 help / color / 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, back to index

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

Kernel Newbies archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/kernelnewbies/0 kernelnewbies/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 kernelnewbies kernelnewbies/ https://lore.kernel.org/kernelnewbies \
		kernelnewbies@kernelnewbies.org
	public-inbox-index kernelnewbies

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernelnewbies.kernelnewbies


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git