with Text_IO; use Text_IO; with Basic_Integer_Types; with Non_Local_Jump; with System; use type Basic_Integer_Types.Unsigned_32; package body Context is Jmp_Buff : aliased Non_Local_Jump.Jmp_Context; pragma Volatile (Jmp_Buff); TCB : System.Address := System.Null_Address; pragma Volatile (TCB); function Pthread_Self return System.Address; pragma Import (C, Pthread_Self, "pthread_self"); function Execute_Work(Work : Work_Acc) return Integer is begin Put_Line ("Start work"); TCB := Pthread_Self; Non_Local_Jump.Save_Context(Jmp_Buff'Access); if Non_Local_Jump.After_Jump (Jmp_Buff'Access) = 0 then Put_Line ("---Not After Jump---"); Work.all; return 0; else Put_Line ("---After Jump---"); return 1; end if; end Execute_Work; procedure Restore_Work is begin Non_Local_Jump.Restore_Context (TCB, Jmp_Buff'Access); end Restore_Work; end Context;