From 573bf5ee783c51b4dfe385e195233a8df2175d09 Mon Sep 17 00:00:00 2001 From: schulz Date: Sun, 26 Mar 2017 19:33:16 +0000 Subject: [PATCH] clean the code a little by reducing amout of places where gcc decides to put ud2 instruction (e.g. when a pointer is used without checking if not NULL)... git-svn-id: https://svn.aros.org/svn/aros/trunk/AROS@54306 fb15a70f-31f2-0310-bbcc-cdcc74a49acc --- arch/all-pc/exec/platform_init.c | 15 ++++--- arch/all-pc/kernel/kernel_scheduler.c | 85 ++++++++++++++++++----------------- arch/x86_64-pc/kernel/kernel_cpu.c | 81 +++++++++++++++++---------------- rom/exec/allocmem.c | 2 +- rom/exec/alloctaskstorageslot.c | 5 ++- rom/exec/alloctrap.c | 81 +++++++++++++++++---------------- rom/exec/childorphan.c | 67 ++++++++++++++------------- rom/exec/childstatus.c | 53 +++++++++++----------- rom/exec/childwait.c | 2 +- rom/exec/freesignal.c | 5 ++- rom/exec/freetrap.c | 16 ++++--- rom/exec/getparenttaskstorageslot.c | 2 +- rom/exec/gettaskstorageslot.c | 2 +- rom/exec/newaddtask.c | 10 +++-- rom/exec/savetaskstorage.c | 3 +- rom/exec/setsignal.c | 21 +++++---- rom/exec/settaskstorageslot.c | 3 +- rom/exec/systemalert.c | 2 +- 18 files changed, 243 insertions(+), 212 deletions(-) diff --git a/arch/all-pc/exec/platform_init.c b/arch/all-pc/exec/platform_init.c index 6018bf7862..aa99f911de 100644 --- a/arch/all-pc/exec/platform_init.c +++ b/arch/all-pc/exec/platform_init.c @@ -52,16 +52,19 @@ AROS_UFH3(void, Exec_TaskSpinLockFailFunc, struct IntETask *thisET; DSPIN(bug("[Exec:X86] %s()\n", __func__)); - thisET = GetIntETask(spinTask); - if (thisET) + if (spinTask) { - DSPIN(bug("[Exec:X86] %s: Setting task @ 0x%p to spinning...\n", __func__, spinTask)); + thisET = GetIntETask(spinTask); + if (thisET) + { + DSPIN(bug("[Exec:X86] %s: Setting task @ 0x%p to spinning...\n", __func__, spinTask)); - /* tell the scheduler that the task is waiting on a spinlock */ - spinTask->tc_State = TS_SPIN; + /* tell the scheduler that the task is waiting on a spinlock */ + spinTask->tc_State = TS_SPIN; - thisET->iet_SpinLock = spinLock; + thisET->iet_SpinLock = spinLock; + } } DSPIN(bug("[Exec:X86] %s: Forcing Reschedule...\n", __func__)); diff --git a/arch/all-pc/kernel/kernel_scheduler.c b/arch/all-pc/kernel/kernel_scheduler.c index 5a57b92fb6..e48beb4470 100644 --- a/arch/all-pc/kernel/kernel_scheduler.c +++ b/arch/all-pc/kernel/kernel_scheduler.c @@ -73,66 +73,69 @@ BOOL core_Schedule(void) FLAG_SCHEDSWITCH_CLEAR; - if ( + if (task) + { + if ( #if defined(__AROSEXEC_SMP__) - (task->tc_State == TS_TOMBSTONED) || + (task->tc_State == TS_TOMBSTONED) || #endif - (task->tc_State == TS_REMOVED)) - { - /* always let finalising tasks finish... */ - corereschedule = FALSE; + (task->tc_State == TS_REMOVED)) + { + /* always let finalising tasks finish... */ + corereschedule = FALSE; #if defined(__AROSEXEC_SMP__) || (DEBUG > 0) - bug("[Kernel:%03u] core_Schedule: letting finalising task run..\n", cpuNo); + bug("[Kernel:%03u] core_Schedule: letting finalising task run..\n", cpuNo); #endif - } - else if (!(task->tc_Flags & TF_EXCEPT)) - { + } + else if (!(task->tc_Flags & TF_EXCEPT)) + { #if defined(__AROSEXEC_SMP__) - KrnSpinLock(&PrivExecBase(SysBase)->TaskReadySpinLock, NULL, - SPINLOCK_MODE_READ); + KrnSpinLock(&PrivExecBase(SysBase)->TaskReadySpinLock, NULL, + SPINLOCK_MODE_READ); #endif - /* Is the TaskReady empty? If yes, then the running task is the only one. Let it work */ - if (IsListEmpty(&SysBase->TaskReady)) - corereschedule = FALSE; - else - { - struct Task *nexttask; - /* - If there are tasks ready for this cpu that have equal or lower priority, - and the current task has used its alloted time - reschedule so they can run - */ - for (nexttask = (struct Task *)GetHead(&SysBase->TaskReady); nexttask != NULL; nexttask = (struct Task *)GetSucc(nexttask)) + /* Is the TaskReady empty? If yes, then the running task is the only one. Let it work */ + if (IsListEmpty(&SysBase->TaskReady)) + corereschedule = FALSE; + else { -#if defined(__AROSEXEC_SMP__) - if (!(PrivExecBase(SysBase)->IntFlags & EXECF_CPUAffinity) || (core_APIC_CPUInMask(cpuNo, GetIntETask(nexttask)->iet_CpuAffinity))) + struct Task *nexttask; + /* + If there are tasks ready for this cpu that have equal or lower priority, + and the current task has used its alloted time - reschedule so they can run + */ + for (nexttask = (struct Task *)GetHead(&SysBase->TaskReady); nexttask != NULL; nexttask = (struct Task *)GetSucc(nexttask)) { +#if defined(__AROSEXEC_SMP__) + if (!(PrivExecBase(SysBase)->IntFlags & EXECF_CPUAffinity) || (GetIntETask(nexttask) && core_APIC_CPUInMask(cpuNo, GetIntETask(nexttask)->iet_CpuAffinity))) + { #endif - if ( + if ( #if defined(__AROSEXEC_SMP__) - (task->tc_State != TS_SPIN) && + (task->tc_State != TS_SPIN) && #endif - (nexttask->tc_Node.ln_Pri <= task->tc_Node.ln_Pri)) - { - /* If the running task did not used it's whole quantum yet, let it work */ - if (!FLAG_SCHEDQUANTUM_ISSET) - corereschedule = FALSE; - } - break; + (nexttask->tc_Node.ln_Pri <= task->tc_Node.ln_Pri)) + { + /* If the running task did not used it's whole quantum yet, let it work */ + if (!FLAG_SCHEDQUANTUM_ISSET) + corereschedule = FALSE; + } + break; #if defined(__AROSEXEC_SMP__) - } + } #endif + } } - } #if defined(__AROSEXEC_SMP__) - KrnSpinUnLock(&PrivExecBase(SysBase)->TaskReadySpinLock); + KrnSpinUnLock(&PrivExecBase(SysBase)->TaskReadySpinLock); #endif - } + } #if defined(__AROSEXEC_SMP__) - if ((!corereschedule) && (task->tc_State == TS_SPIN)) - task->tc_State = TS_RUN; + if ((!corereschedule) && (task->tc_State == TS_SPIN)) + task->tc_State = TS_RUN; #endif + } DSCHED ( @@ -288,7 +291,7 @@ struct Task *core_Dispatch(void) for (newtask = (struct Task *)GetHead(&SysBase->TaskReady); newtask != NULL; newtask = (struct Task *)GetSucc(newtask)) { #if defined(__AROSEXEC_SMP__) - if (!(PrivExecBase(SysBase)->IntFlags & EXECF_CPUAffinity) || (core_APIC_CPUInMask(cpuNo, GetIntETask(newtask)->iet_CpuAffinity))) + if (!(PrivExecBase(SysBase)->IntFlags & EXECF_CPUAffinity) || (GetIntETask(newtask) && core_APIC_CPUInMask(cpuNo, GetIntETask(newtask)->iet_CpuAffinity))) { #endif REMOVE(&newtask->tc_Node); diff --git a/arch/x86_64-pc/kernel/kernel_cpu.c b/arch/x86_64-pc/kernel/kernel_cpu.c index b749d33688..f60facf531 100644 --- a/arch/x86_64-pc/kernel/kernel_cpu.c +++ b/arch/x86_64-pc/kernel/kernel_cpu.c @@ -122,54 +122,57 @@ void cpu_Switch(struct ExceptionContext *regs) task = GET_THIS_TASK; - timeCur = RDTSC(); - - ctx = task->tc_UnionETask.tc_ETask->et_RegFrame; - - /* - * Copy current task's context into the ETask structure. Note that context on stack - * misses SSE data pointer. - */ - CopyMemQuick(regs, ctx, sizeof(struct ExceptionContext) - sizeof(struct FPXContext *)); - - /* - * Copy the fpu, mmx, xmm state - * TODO: Change to the lazy saving of the XMM state!!!! - */ - asm volatile("fxsave (%0)"::"r"(ctx->FXData)); + if (task) + { + timeCur = RDTSC(); - /* We have the complete data now */ - ctx->Flags = ECF_SEGMENTS | ECF_FPX; + ctx = task->tc_UnionETask.tc_ETask->et_RegFrame; - /* Set task's tc_SPReg */ - task->tc_SPReg = (APTR)regs->rsp; + /* + * Copy current task's context into the ETask structure. Note that context on stack + * misses SSE data pointer. + */ + CopyMemQuick(regs, ctx, sizeof(struct ExceptionContext) - sizeof(struct FPXContext *)); - if (apicData && apicData->cores[cpunum].cpu_TimerFreq && timeCur) - { /* - if (timeCur < IntETask(task->tc_UnionETask.tc_ETask)->iet_private1) - timeCur = IntETask(task->tc_UnionETask.tc_ETask)->iet_private1 - timeCur; - else - timeCur = IntETask(task->tc_UnionETask.tc_ETask)->iet_private1 + apicData->cores[cpunum].cpu_TimerFreq - timeCur; + * Copy the fpu, mmx, xmm state + * TODO: Change to the lazy saving of the XMM state!!!! */ - timeCur -= IntETask(task->tc_UnionETask.tc_ETask)->iet_private1; - - /* Increase CPU Usage cycles */ - IntETask(task->tc_UnionETask.tc_ETask)->iet_private2 += timeCur; + asm volatile("fxsave (%0)"::"r"(ctx->FXData)); - // Convert TSC cycles into nanoseconds - timeCur = (timeCur * 1000000000) / apicData->cores[cpunum].cpu_TSCFreq; + /* We have the complete data now */ + ctx->Flags = ECF_SEGMENTS | ECF_FPX; - /* Update the task's CPU time */ - timeSpec.tv_sec = timeCur / 1000000000; - timeSpec.tv_nsec = timeCur % 1000000000; + /* Set task's tc_SPReg */ + task->tc_SPReg = (APTR)regs->rsp; - IntETask(task->tc_UnionETask.tc_ETask)->iet_CpuTime.tv_nsec += timeSpec.tv_nsec; - IntETask(task->tc_UnionETask.tc_ETask)->iet_CpuTime.tv_sec += timeSpec.tv_sec; - while(IntETask(task->tc_UnionETask.tc_ETask)->iet_CpuTime.tv_nsec >= 1000000000) + if (apicData && apicData->cores[cpunum].cpu_TimerFreq && timeCur) { - IntETask(task->tc_UnionETask.tc_ETask)->iet_CpuTime.tv_nsec -= 1000000000; - IntETask(task->tc_UnionETask.tc_ETask)->iet_CpuTime.tv_sec++; + /* + if (timeCur < IntETask(task->tc_UnionETask.tc_ETask)->iet_private1) + timeCur = IntETask(task->tc_UnionETask.tc_ETask)->iet_private1 - timeCur; + else + timeCur = IntETask(task->tc_UnionETask.tc_ETask)->iet_private1 + apicData->cores[cpunum].cpu_TimerFreq - timeCur; + */ + timeCur -= IntETask(task->tc_UnionETask.tc_ETask)->iet_private1; + + /* Increase CPU Usage cycles */ + IntETask(task->tc_UnionETask.tc_ETask)->iet_private2 += timeCur; + + // Convert TSC cycles into nanoseconds + timeCur = (timeCur * 1000000000) / apicData->cores[cpunum].cpu_TSCFreq; + + /* Update the task's CPU time */ + timeSpec.tv_sec = timeCur / 1000000000; + timeSpec.tv_nsec = timeCur % 1000000000; + + IntETask(task->tc_UnionETask.tc_ETask)->iet_CpuTime.tv_nsec += timeSpec.tv_nsec; + IntETask(task->tc_UnionETask.tc_ETask)->iet_CpuTime.tv_sec += timeSpec.tv_sec; + while(IntETask(task->tc_UnionETask.tc_ETask)->iet_CpuTime.tv_nsec >= 1000000000) + { + IntETask(task->tc_UnionETask.tc_ETask)->iet_CpuTime.tv_nsec -= 1000000000; + IntETask(task->tc_UnionETask.tc_ETask)->iet_CpuTime.tv_sec++; + } } } core_Switch(); diff --git a/rom/exec/allocmem.c b/rom/exec/allocmem.c index 6b4bdebc0b..cba1503d95 100644 --- a/rom/exec/allocmem.c +++ b/rom/exec/allocmem.c @@ -124,7 +124,7 @@ if (res == NULL) { struct Process *process = (struct Process *)GET_THIS_TASK; - if (process->pr_Task.tc_Node.ln_Type == NT_PROCESS) + if (process && process->pr_Task.tc_Node.ln_Type == NT_PROCESS) process->pr_Result2 = ERROR_NO_FREE_STORE; } diff --git a/rom/exec/alloctaskstorageslot.c b/rom/exec/alloctaskstorageslot.c index 1b02a2f6fd..092aaa9af1 100644 --- a/rom/exec/alloctaskstorageslot.c +++ b/rom/exec/alloctaskstorageslot.c @@ -48,7 +48,7 @@ struct Task *ThisTask = GET_THIS_TASK; struct TaskStorageFreeSlot *tsfs; LONG slot; - struct IntETask *iet = GetIntETask(ThisTask); + struct IntETask *iet = ThisTask ? GetIntETask(ThisTask) : NULL; if (!iet) return 0; @@ -57,7 +57,10 @@ tsfs = (struct TaskStorageFreeSlot *) GetHead(&PrivExecBase(SysBase)->TaskStorageSlots); if (!tsfs) + { Alert(AT_DeadEnd|AN_MemoryInsane); + __builtin_unreachable(); + } slot = tsfs->FreeSlot; diff --git a/rom/exec/alloctrap.c b/rom/exec/alloctrap.c index bd7db87baa..76afd2ae1d 100644 --- a/rom/exec/alloctrap.c +++ b/rom/exec/alloctrap.c @@ -45,47 +45,50 @@ UWORD mask; UWORD mask1; - mask = GetTrapAlloc(ThisTask); - - /* Will any trap do? */ - if(trapNum < 0) + if (ThisTask) { - /* - * To get the last nonzero bit in a number I use a&~a+1: - * Given a number that ends with a row of zeros xxxx1000 - * I first toggle all bits in that number XXXX0111 - * then add 1 to toggle all but the last 0 again XXXX1000 - * and AND this with the original number 00001000 - * - * And since ~a+1=-a I can use a&-a instead. - * - * And to get the last zero bit I finally use ~a&-~a. - */ - mask1 = ~mask & - ~mask; - - /* Is the bit already allocated? */ - if(mask1 == 0) - return -1; - - /* And get the bit number */ - trapNum = (mask1 & 0xff00 ? 8 : 0) + (mask1 & 0xf0f0 ? 4 : 0) + - (mask1 & 0xcccc ? 2 : 0) + (mask1 & 0xaaaa ? 1 : 0); + mask = GetTrapAlloc(ThisTask); + + /* Will any trap do? */ + if(trapNum < 0) + { + /* + * To get the last nonzero bit in a number I use a&~a+1: + * Given a number that ends with a row of zeros xxxx1000 + * I first toggle all bits in that number XXXX0111 + * then add 1 to toggle all but the last 0 again XXXX1000 + * and AND this with the original number 00001000 + * + * And since ~a+1=-a I can use a&-a instead. + * + * And to get the last zero bit I finally use ~a&-~a. + */ + mask1 = ~mask & - ~mask; + + /* Is the bit already allocated? */ + if(mask1 == 0) + return -1; + + /* And get the bit number */ + trapNum = (mask1 & 0xff00 ? 8 : 0) + (mask1 & 0xf0f0 ? 4 : 0) + + (mask1 & 0xcccc ? 2 : 0) + (mask1 & 0xaaaa ? 1 : 0); + } + else + { + mask1 = 1 << trapNum; + + /* If trap bit is already allocated, return. */ + if(mask & mask1) + return -1; + } + + if (ThisTask->tc_Flags & TF_ETASK) { + struct ETask *et = ThisTask->tc_UnionETask.tc_ETask; + + et->et_TrapAlloc |= mask1; + } else + ThisTask->tc_TrapAlloc |= mask1; } - else - { - mask1 = 1 << trapNum; - - /* If trap bit is already allocated, return. */ - if(mask & mask1) - return -1; - } - - if (ThisTask->tc_Flags & TF_ETASK) { - struct ETask *et = ThisTask->tc_UnionETask.tc_ETask; - - et->et_TrapAlloc |= mask1; - } else - ThisTask->tc_TrapAlloc |= mask1; return trapNum; AROS_LIBFUNC_EXIT diff --git a/rom/exec/childorphan.c b/rom/exec/childorphan.c index bb9e4d832b..3ba2e6653b 100644 --- a/rom/exec/childorphan.c +++ b/rom/exec/childorphan.c @@ -57,40 +57,43 @@ struct Task *ThisTask = GET_THIS_TASK; struct ETask *et, *child; - et = GetETask(ThisTask); - if (et == NULL) - return CHILD_NOTNEW; - - if (tid == 0L) - { - Forbid(); - ForeachNode(&et->et_Children, child) + if (ThisTask) { - /* - Don't need to Remove(), because I'll blow away the entire - list at the end of the loop. - */ - child->et_Parent = NULL; + et = GetETask(ThisTask); + if (et == NULL) + return CHILD_NOTNEW; + + if (tid == 0L) + { + Forbid(); + ForeachNode(&et->et_Children, child) + { + /* + Don't need to Remove(), because I'll blow away the entire + list at the end of the loop. + */ + child->et_Parent = NULL; + } + NEWLIST(&et->et_Children); + Permit(); + } + else + { + Forbid(); + child = FindChild(tid); + if (child != NULL) + { + child->et_Parent = NULL; + Remove((struct Node *)child); + } + else + { + Permit(); + return CHILD_NOTFOUND; + } + Permit(); + } } - NEWLIST(&et->et_Children); - Permit(); - } - else - { - Forbid(); - child = FindChild(tid); - if (child != NULL) - { - child->et_Parent = NULL; - Remove((struct Node *)child); - } - else - { - Permit(); - return CHILD_NOTFOUND; - } - Permit(); - } return 0; AROS_LIBFUNC_EXIT diff --git a/rom/exec/childstatus.c b/rom/exec/childstatus.c index 0ec593f8de..d23a83ce4d 100644 --- a/rom/exec/childstatus.c +++ b/rom/exec/childstatus.c @@ -52,39 +52,42 @@ struct ETask *child; ULONG status = CHILD_NOTFOUND; - if ((ThisTask->tc_Flags & TF_ETASK) == 0) - return CHILD_NOTNEW; + if (ThisTask) + { + if ((ThisTask->tc_Flags & TF_ETASK) == 0) + return CHILD_NOTNEW; - et = ThisTask->tc_UnionETask.tc_ETask; + et = ThisTask->tc_UnionETask.tc_ETask; - /* Sigh... */ - Forbid(); + /* Sigh... */ + Forbid(); - /* Search through the running tasks list */ - ForeachNode(&et->et_Children, child) - { - if (child->et_UniqueID == tid) - { - status = CHILD_ACTIVE; - break; - } - } + /* Search through the running tasks list */ + ForeachNode(&et->et_Children, child) + { + if (child->et_UniqueID == tid) + { + status = CHILD_ACTIVE; + break; + } + } #if defined(__AROSEXEC_SMP__) - EXEC_SPINLOCK_LOCK(&et->et_TaskMsgPort.mp_SpinLock, NULL, SPINLOCK_MODE_READ); + EXEC_SPINLOCK_LOCK(&et->et_TaskMsgPort.mp_SpinLock, NULL, SPINLOCK_MODE_READ); #endif - ForeachNode(&et->et_TaskMsgPort.mp_MsgList, child) - { - if (child->et_UniqueID == tid) - { - status = CHILD_EXITED; - break; - } - } + ForeachNode(&et->et_TaskMsgPort.mp_MsgList, child) + { + if (child->et_UniqueID == tid) + { + status = CHILD_EXITED; + break; + } + } #if defined(__AROSEXEC_SMP__) - EXEC_SPINLOCK_UNLOCK(&et->et_TaskMsgPort.mp_SpinLock); + EXEC_SPINLOCK_UNLOCK(&et->et_TaskMsgPort.mp_SpinLock); #endif - Permit(); + Permit(); + } return status; AROS_LIBFUNC_EXIT diff --git a/rom/exec/childwait.c b/rom/exec/childwait.c index ad21dd8799..d07effedae 100644 --- a/rom/exec/childwait.c +++ b/rom/exec/childwait.c @@ -76,7 +76,7 @@ Firstly, are we a new-style Task? */ - if ((ThisTask->tc_Flags & TF_ETASK) == 0) + if (!ThisTask || (ThisTask->tc_Flags & TF_ETASK) == 0) return CHILD_NOTNEW; et = ThisTask->tc_UnionETask.tc_ETask; diff --git a/rom/exec/freesignal.c b/rom/exec/freesignal.c index f504829769..b40e814434 100644 --- a/rom/exec/freesignal.c +++ b/rom/exec/freesignal.c @@ -52,8 +52,9 @@ /* No more atomic problem - i beleive THIS is atomic. - sonic */ struct Task *me = GET_THIS_TASK; - /* Clear the bit */ - me->tc_SigAlloc &= ~(1<tc_SigAlloc &= ~(1 << signalNum); } AROS_LIBFUNC_EXIT } /* FreeSignal() */ diff --git a/rom/exec/freetrap.c b/rom/exec/freetrap.c index c791f10e30..1cb85a3766 100644 --- a/rom/exec/freetrap.c +++ b/rom/exec/freetrap.c @@ -45,13 +45,15 @@ { /* No more atomic problem - i beleive THIS is atomic. - sonic */ struct Task *me = GET_THIS_TASK; - - if (me->tc_Flags & TF_ETASK) { - struct ETask *et = me->tc_UnionETask.tc_ETask; - - et->et_TrapAlloc &= ~(1<tc_TrapAlloc &= ~(1<tc_Flags & TF_ETASK) { + struct ETask *et = me->tc_UnionETask.tc_ETask; + + et->et_TrapAlloc &= ~(1<tc_TrapAlloc &= ~(1<IntFlags & EXECF_CPUAffinity) || (KrnCPUInMask(cpunum, IntETask(task->tc_UnionETask.tc_ETask)->iet_CpuAffinity)))) + (!(PrivExecBase(SysBase)->IntFlags & EXECF_CPUAffinity) || (IntETask(task->tc_UnionETask.tc_ETask) && KrnCPUInMask(cpunum, IntETask(task->tc_UnionETask.tc_ETask)->iet_CpuAffinity)))) { parent = GET_THIS_TASK; if ( #endif - task->tc_Node.ln_Pri > parent->tc_Node.ln_Pri && + parent && task->tc_Node.ln_Pri > parent->tc_Node.ln_Pri && parent->tc_State == TS_RUN) { DADDTASK("NewAddTask: Rescheduling...\n"); @@ -256,14 +256,16 @@ { //bug("[Exec] AddTask: CPU #%d not in mask [%08x:%08x]\n", cpunum, KrnGetCPUMask(cpunum), IntETask(task->tc_UnionETask.tc_ETask)->iet_CpuAffinity); DADDTASK("NewAddTask: CPU #%d not in mask\n", cpunum); - KrnScheduleCPU(IntETask(task->tc_UnionETask.tc_ETask)->iet_CpuAffinity); + if (IntETask(task->tc_UnionETask.tc_ETask)) + KrnScheduleCPU(IntETask(task->tc_UnionETask.tc_ETask)->iet_CpuAffinity); } else { bug("[Exec] NewAddTask: Unable to Launch on the selected CPU\n"); // TODO: Free up all the task data .. krnSysCallReschedTask(task, TS_REMOVED); - KrnDeleteContext(GetETask(task)->et_RegFrame); + if (GetETask(task)) + KrnDeleteContext(GetETask(task)->et_RegFrame); CleanupETask(task); task = NULL; } diff --git a/rom/exec/savetaskstorage.c b/rom/exec/savetaskstorage.c index 7afc5fa44c..58eb04b521 100644 --- a/rom/exec/savetaskstorage.c +++ b/rom/exec/savetaskstorage.c @@ -49,7 +49,8 @@ { AROS_LIBFUNC_INIT - struct ETask *et = GetETask(GET_THIS_TASK); + struct Task *ThisTask = GET_THIS_TASK; + struct ETask *et = ThisTask ? GetETask(ThisTask) : NULL; IPTR *taskstorage, *tsout; IPTR slots; diff --git a/rom/exec/setsignal.c b/rom/exec/setsignal.c index 534b613c98..29c461ac58 100644 --- a/rom/exec/setsignal.c +++ b/rom/exec/setsignal.c @@ -57,19 +57,22 @@ struct Task *thisTask = GET_THIS_TASK; ULONG *sig; - ULONG old; + ULONG old = 0; - /* Protect the signal mask against access by other tasks. */ - Disable(); + if (thisTask) + { + /* Protect the signal mask against access by other tasks. */ + Disable(); - /* Get address */ - sig = &thisTask->tc_SigRecvd; + /* Get address */ + sig = &thisTask->tc_SigRecvd; - /* Change only the bits in 'mask' */ - old = *sig; - *sig = (old & ~signalSet) | (newSignals & signalSet); + /* Change only the bits in 'mask' */ + old = *sig; + *sig = (old & ~signalSet) | (newSignals & signalSet); - Enable(); + Enable(); + } return old; AROS_LIBFUNC_EXIT diff --git a/rom/exec/settaskstorageslot.c b/rom/exec/settaskstorageslot.c index 0917f095b0..37ad985e45 100644 --- a/rom/exec/settaskstorageslot.c +++ b/rom/exec/settaskstorageslot.c @@ -49,7 +49,8 @@ { AROS_LIBFUNC_INIT - struct ETask *et = GetETask(GET_THIS_TASK); + struct Task *ThisTask = GET_THIS_TASK; + struct ETask *et = ThisTask ? GetETask(ThisTask) : NULL; IPTR *ts; D(bug("SetTaskStorage: %p: Set TaskStorageSlot %d to %p\n", et, id, (APTR)value);) diff --git a/rom/exec/systemalert.c b/rom/exec/systemalert.c index 55ac879126..5cc18ced49 100644 --- a/rom/exec/systemalert.c +++ b/rom/exec/systemalert.c @@ -49,7 +49,7 @@ void Exec_SystemAlert(ULONG alertNum, APTR location, APTR stack, UBYTE type, APT struct Task * t = (struct Task*)PrivExecBase(SysBase)->SAT.sat_Params[1]; ULONG alertNum = PrivExecBase(SysBase)->SAT.sat_Params[0]; - struct IntETask * iet = GetIntETask(t); + struct IntETask * iet = t ? GetIntETask(t) : NULL; Alert_DisplayKrnAlert(t, alertNum | AT_DeadEnd, iet->iet_AlertLocation, iet->iet_AlertStack, iet->iet_AlertType, (APTR)&iet->iet_AlertData, SysBase); -- 2.11.4.GIT