thread-identification-routines-20010212
[openafs.git] / src / lwp / lwp.c
index aa1de78..2c8358e 100644 (file)
@@ -342,10 +342,16 @@ int LWP_CreateProcess(ep, stacksize, priority, parm, name, pid)
        savecontext(Create_Process_Part2, &temp2->context,
                    stackptr+stacksize-16); /* 16 = 2 * jmp_buf_type*/
 #else
+#if defined(AFS_SPARC64_LINUX20_ENV) || defined(AFS_SPARC_LINUX20_ENV)
+       savecontext(Create_Process_Part2, &temp2->context,
+                   stackptr+stacksize-0x40); /* lomgjmp does something
+                                                with %fp + 0x38 */
+#else
        savecontext(Create_Process_Part2, &temp2->context,
                    stackptr+stacksize-sizeof(void *));
 #endif
 #endif
+#endif
        /* End of gross hack */
 
        Set_LWP_RC();
@@ -439,6 +445,15 @@ int LWP_CurrentProcess(pid)        /* returns pid of current process */
        return LWP_EINIT;
 }
 
+PROCESS LWP_ThreadId()
+{
+    Debug(0, ("Entered ThreadId"))
+    if (lwp_init)
+        return lwp_cpptr;
+    else
+        return (PROCESS) 0;
+}
+
 #define LWPANCHOR (*lwp_init)
 
 int LWP_DestroyProcess(pid)            /* destroy a lightweight process */
@@ -463,10 +478,15 @@ int LWP_DestroyProcess(pid)               /* destroy a lightweight process */
            savecontext(Dispatcher, &(temp -> context),
                        &(LWPANCHOR.dsptchstack[(sizeof LWPANCHOR.dsptchstack)-8]));
 #else
+#if defined(AFS_SPARC64_LINUX20_ENV) || defined(AFS_SPARC_LINUX20_ENV)
+           savecontext(Dispatcher, &(temp -> context),
+                       &(LWPANCHOR.dsptchstack[(sizeof LWPANCHOR.dsptchstack)-0x40]));
+#else
            savecontext(Dispatcher, &(temp -> context),
                        &(LWPANCHOR.dsptchstack[(sizeof LWPANCHOR.dsptchstack)-sizeof(void *)]));
 #endif
 #endif
+#endif
        }
        return LWP_SUCCESS;
     } else
@@ -914,7 +934,7 @@ static void Initialize_PCB(temp, priority, stack, stacksize, ep, parm, name)
     temp -> misc = NULL;       /* currently unused */
     temp -> next = NULL;
     temp -> prev = NULL;
-    temp -> lwp_rused = NULL;
+    temp -> lwp_rused = 0;
     temp -> level = 1;         /* non-preemptable */
 }