* Re:sigcontext on Linux-ppc in user space, another hack.
@ 2001-01-25 20:31 jekacur
2001-01-25 23:04 ` Roman Zippel
0 siblings, 1 reply; 3+ messages in thread
From: jekacur @ 2001-01-25 20:31 UTC (permalink / raw)
To: khendricks, linux-kernel, linuxppc-dev
It appears you can just use the siginfo_t * as the struct sigcontext *
!!!!!!
ie
void *signal_handler(int signo, siginfo_t *siginfoptr, struct sigcontext
*scp)
{
scp = (struct sigcontext_struct *)siginfoptr;
/* the rest of your code, here */
}
John Kacur/Toronto/IBM@IBMCA
jekacur@ca.ibm.com
(416) 448-2584 (phone)
778-2584 (tie line)
"Kevin B. Hendricks" <khendricks@ivey.uwo.ca> on 01/25/2001 02:02:20 PM
Please respond to khendricks@ivey.uwo.ca
To: John Kacur/Toronto/IBM@IBMCA
cc:
Subject: Re: [Fwd: sigcontext on Linux-ppc in user space]
Hi,
Just in case this helps, here is what I did to accomplish the same thing
in the green_threads jdk. It definitely is not portable.
Kevin
Inside the signal handler:
#elif defined(__linux__) && defined(__powerpc__)
/* get the value of r1 (the stack pointer) */
long * p;
struct sigcontext_struct * scp;
__asm__ ( "addi %0,1,0" : "=r" (p) : /* no inputs */ );
/* follow it back up the chain */
p = *p;
/* from here the sigcontext struct is 64 bytes away */
p = p + 16;
scp = (struct sigcontext_struct *)p;
On Thursday, January 25, 2001, at 01:50 PM, jekacur@ca.ibm.com wrote:
>
> Ok, actually the segfault was for a more complicated function, but the
> simplified example still gives the wrong answer. i.e scp should point to
a
> struct sigcontext and scp->signal should be 10 in the sample program.
>
> John Kacur/Toronto/IBM@IBMCA
> jekacur@ca.ibm.com
> (416) 448-2584 (phone)
> 778-2584 (tie line)
>
>
> "Kevin B. Hendricks" <khendricks@ivey.uwo.ca> on 01/25/2001 01:10:40 PM
>
> Please respond to khendricks@ivey.uwo.ca
>
> To: John Kacur/Toronto/IBM@IBMCA
> cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.linuxppc.org
> Subject: Re: [Fwd: sigcontext on Linux-ppc in user space]
>
>
> Hi,
>
> Here is what I get from running it on my system (ppc linux with 2.2.15
> kernel with some mods and glibc-2.1.3).
>
> But no segfault.
>
> Kevin
>
>
> [kbhend@localhost ~]$ gcc -O2 -ojunk junk.c
> [kbhend@localhost ~]$ ./junk
> SIGUSR1 = 10
> scp = 7fffe9a4
> scp->signal = 0
> [kbhend@localhost ~]$
>
>
>
>
> On Thursday, January 25, 2001, at 10:09 AM, jekacur@ca.ibm.com wrote:
>
> > #include <stdio.h>
> > #include <signal.h>
> >
> > /* Function Prototypes */
> > void install_sigusr1_handler(void);
> > void sigusr_handler(int , siginfo_t *, struct sigcontext * scp);
> >
> > int main(void)
> > {
> > install_sigusr1_handler();
> > printf("SIGUSR1 = %d\n", SIGUSR1);
> > raise(SIGUSR1);
> > exit(0);
> > }
> >
> > void install_sigusr1_handler(void)
> > {
> > struct sigaction newAct;
> >
> > if (sigemptyset(&newAct.sa_mask) != 0) {
> > fprintf(stderr, "Warning, sigemptyset failed.\n");
> > }
> >
> > newAct.sa_flags = 0;
> > newAct.sa_flags |= SA_SIGINFO | SA_RESTART;
> >
> > newAct.sa_sigaction = (void
> > (*)(int,siginfo_t*,void*))sigusr_handler;
> >
> > if (sigaction(SIGUSR1, &newAct, NULL) != 0) {
> > fprintf(stderr, "Couldn't install SIGUSR1 handler.\n");
> > fprintf(stderr, "Exiting.\n");
> > exit(1);
> > }
> > }
> >
> > void sigusr_handler(int signo, siginfo_t *siginfp, struct sigcontext *
> scp)
> > {
> > printf("scp = %08x\n", scp);
> > printf("scp->signal = %d\n", scp->signal);
> > }
> >
> >
>
>
>
>
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/
^ permalink raw reply [flat|nested] 3+ messages in thread* Re:sigcontext on Linux-ppc in user space, another hack.
2001-01-25 20:31 Re:sigcontext on Linux-ppc in user space, another hack jekacur
@ 2001-01-25 23:04 ` Roman Zippel
2001-01-26 1:05 ` Kevin B. Hendricks
0 siblings, 1 reply; 3+ messages in thread
From: Roman Zippel @ 2001-01-25 23:04 UTC (permalink / raw)
To: jekacur; +Cc: khendricks, linuxppc-dev
Hi,
On Thu, 25 Jan 2001 jekacur@ca.ibm.com wrote:
>
> It appears you can just use the siginfo_t * as the struct sigcontext *
> !!!!!!
> ie
> void *signal_handler(int signo, siginfo_t *siginfoptr, struct sigcontext
> *scp)
> {
> scp = (struct sigcontext_struct *)siginfoptr;
> /* the rest of your code, here */
> }
Please ignore the last patch!
Anyway, in the code example the last argument is not a sigcontext
structure but an ucontext_t structure, which is defined in <ucontext.h>.
bye, Roman
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
^ permalink raw reply [flat|nested] 3+ messages in thread* Re:sigcontext on Linux-ppc in user space, another hack.
2001-01-25 23:04 ` Roman Zippel
@ 2001-01-26 1:05 ` Kevin B. Hendricks
0 siblings, 0 replies; 3+ messages in thread
From: Kevin B. Hendricks @ 2001-01-26 1:05 UTC (permalink / raw)
To: Roman Zippel, jekacur; +Cc: khendricks, linuxppc-dev
Hi,
> Please ignore the last patch!
> Anyway, in the code example the last argument is not a sigcontext
> structure but an ucontext_t structure, which is defined in <ucontext.h>.
Yes.
Here is the revised sample program and it works:
[root@localhost kbhend]# ./junk
SIGUSR1 = 10
uc = 7ffff794
uc->uc_mcontext.signal = 10
[root@localhost kbhend]# cat junk.c
#include <stdio.h>
#include <signal.h>
#include <ucontext.h>
/* Function Prototypes */
void install_sigusr1_handler(void);
void sigusr_handler(int , siginfo_t *, struct ucontext * uc);
int main(void)
{
install_sigusr1_handler();
printf("SIGUSR1 = %d\n", SIGUSR1);
raise(SIGUSR1);
exit(0);
}
void install_sigusr1_handler(void)
{
struct sigaction newAct;
if (sigemptyset(&newAct.sa_mask) != 0) {
fprintf(stderr, "Warning, sigemptyset failed.\n");
}
newAct.sa_flags = 0;
newAct.sa_flags |= SA_SIGINFO | SA_RESTART;
newAct.sa_sigaction = (void
(*)(int,siginfo_t*,void*))sigusr_handler;
if (sigaction(SIGUSR1, &newAct, NULL) != 0) {
fprintf(stderr, "Couldn't install SIGUSR1 handler.\n");
fprintf(stderr, "Exiting.\n");
exit(1);
}
}
void sigusr_handler(int signo, siginfo_t *siginfp, struct ucontext * uc)
{
printf("uc = %08x\n", uc);
printf("uc->uc_mcontext.signal = %d\n", uc->uc_mcontext.signal);
}
[[root@localhost kbhend]# cat junk.c
#include <stdio.h>
#include <signal.h>
#include <ucontext.h>
/* Function Prototypes */
void install_sigusr1_handler(void);
void sigusr_handler(int , siginfo_t *, struct ucontext * uc);
int main(void)
{
install_sigusr1_handler();
printf("SIGUSR1 = %d\n", SIGUSR1);
raise(SIGUSR1);
exit(0);
}
void install_sigusr1_handler(void)
{
struct sigaction newAct;
if (sigemptyset(&newAct.sa_mask) != 0) {
fprintf(stderr, "Warning, sigemptyset failed.\n");
}
newAct.sa_flags = 0;
newAct.sa_flags |= SA_SIGINFO | SA_RESTART;
newAct.sa_sigaction = (void
(*)(int,siginfo_t*,void*))sigusr_handler;
if (sigaction(SIGUSR1, &newAct, NULL) != 0) {
fprintf(stderr, "Couldn't install SIGUSR1 handler.\n");
fprintf(stderr, "Exiting.\n");
exit(1);
}
}
void sigusr_handler(int signo, siginfo_t *siginfp, struct ucontext * uc)
{
printf("uc = %08x\n", uc);
printf("uc->uc_mcontext.signal = %d\n", uc->uc_mcontext.signal);
}
[root@localhost kbhend]# ./junk
SIGUSR1 = 10
uc = 7ffff794
uc->uc_mcontext.signal = 10
So no patch needed.
Thanks for finding that.
Kevin
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2001-01-26 1:05 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-01-25 20:31 Re:sigcontext on Linux-ppc in user space, another hack jekacur
2001-01-25 23:04 ` Roman Zippel
2001-01-26 1:05 ` Kevin B. Hendricks
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.