mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: John Weber <weber@nyc.rr.com>
To: Robert Love <rml@tech9.net>
Cc: linux-kernel@vger.kernel.org
Subject: Re: 2.5.4 Compile Error
Date: Mon, 11 Feb 2002 01:36:27 -0500	[thread overview]
Message-ID: <3C67666B.2060507@nyc.rr.com> (raw)
In-Reply-To: <3C674CFA.2030107@nyc.rr.com>	<3C6750CD.46575DAA@mandrakesoft.com>  <3C675E6B.4010605@nyc.rr.com> <1013408447.806.409.camel@phantasy>

Robert Love wrote:
> On Mon, 2002-02-11 at 01:02, John Weber wrote:
> 
> 
>>The function thread_saved_pc() is a mystery to me.  It is declared with 
>>a return type of unsigned long, and yet return this:
>>
>>((unsigned long *)tsk->thread->esp)[3]
>>
>>This is confusing to me in many ways:
>>- the "thread" member of task struct is not a pointer
>>- esp is of type unsigned long, so I don't understand the cast, and
>>I certainly don't understand the [3] here.
>>
>>Can anyone explain this code to me?
>>
> 
> The problem is an interdependency between processor.h and sched.h.
> 
> The old code was the same, except it did
> 
> 	t->esp
> 
> where t was a thread_struct, instead of what we do now
> 
> 	t->thread->esp
> 
> where t is a task_struct.  And thus whereby before we passed
> 
> 	p->thread
>

I understand all this, but thread is not a pointer.
So shouldn't it be t->thread.esp ?

> as the argument, now you pass just `p'.  I.e., its the same net-affect. 
> The error is because the function needs access to both task_struct (in
> sched.h) and thread_struct (in processor.h) but the two are interrelated
> so we can't include them in each other.

Hmm... OK.

> The contents of esp is a memory address, so typecasting it to (unsigned
> long *) is OK.
> 
> As for the [3], p[3] is the same as
> 	*(p+3)
> ie,
> 	*(p+sizeof(p))
> so that is legal.

*(p + (3*sizeof(p))) ?

I understand the syntax, but I don't understand why one would want to 
return the address of something 3 longs away.  What is this function
supposed to be doing?




  reply	other threads:[~2002-02-11  6:38 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-02-11  4:47 John Weber
2002-02-11  5:04 ` Jeff Garzik
2002-02-11  6:02   ` John Weber
2002-02-11  6:29     ` Andrew Morton
2002-02-11  6:33     ` David S. Miller
2002-02-11  6:48       ` Andrew Morton
2002-02-11  6:52       ` David S. Miller
2002-02-11  6:20   ` Robert Love
2002-02-11  6:36     ` John Weber [this message]
2002-02-11  6:50     ` Robert Love
2002-02-11 15:50     ` Pascal Schmidt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3C67666B.2060507@nyc.rr.com \
    --to=weber@nyc.rr.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rml@tech9.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®