- Timestamp:
- Sep 30, 2007, 8:23:59 AM (18 years ago)
- Location:
- trunk/src/kmk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kmk/Makefile.kmk
r1162 r1164 123 123 kmk_DEFS.x86 = CONFIG_WITH_OPTIMIZATION_HACKS 124 124 kmk_DEFS.amd64 = CONFIG_WITH_OPTIMIZATION_HACKS 125 kmk_DEFS.win .x86= CONFIG_NEW_WIN32_CTRL_EVENT125 kmk_DEFS.win = CONFIG_NEW_WIN32_CTRL_EVENT 126 126 127 127 kmk_SOURCES = \ -
trunk/src/kmk/job.c
r903 r1164 702 702 coredump = 0; 703 703 } 704 else if (!process_used_slots()) 705 { 706 /* The wait*() failed miserably. Punt. */ 707 errno = ECHILD; 708 pfatal_with_name ("wait"); 709 } 710 704 711 pid = (pid_t) hPID; 705 712 } -
trunk/src/kmk/main.c
r1140 r1164 950 950 #include <process.h> 951 951 static UINT g_tidMainThread = 0; 952 static int g_sigPending = 0; /* lazy bird */ 953 952 static int volatile g_sigPending = 0; /* lazy bird */ 953 # ifndef _M_IX86 954 static LONG volatile g_lTriggered = 0; 955 static CONTEXT g_Ctx; 956 # endif 957 958 # ifdef _M_IX86 954 959 static __declspec(naked) void dispatch_stub(void) 955 960 { … … 968 973 } 969 974 } 975 # else /* !_M_IX86 */ 976 static void dispatch_stub(void) 977 { 978 fflush(stdout); 979 /*fprintf(stderr, "dbg: raising %s on the main thread (%d)\n", g_sigPending == SIGINT ? "SIGINT" : "SIGBREAK", _getpid());*/ 980 raise(g_sigPending); 981 982 SetThreadContext(GetCurrentThread(), &g_Ctx); 983 fprintf(stderr, "fatal error: SetThreadContext failed with last error %d\n", GetLastError()); 984 for (;;) 985 exit(131); 986 } 987 # endif /* !_M_IX86 */ 970 988 971 989 static BOOL WINAPI ctrl_event(DWORD CtrlType) … … 975 993 CONTEXT Ctx; 976 994 995 #ifndef _M_IX86 996 /* only once. */ 997 if (InterlockedExchange(&g_lTriggered, 1)) 998 { 999 Sleep(1); 1000 return TRUE; 1001 } 1002 #endif 1003 977 1004 /* open the main thread and suspend it. */ 978 1005 hThread = OpenThread(THREAD_ALL_ACCESS, FALSE, g_tidMainThread); 979 1006 SuspendThread(hThread); 980 1007 981 /* Get the thread context and */ 1008 /* Get the thread context and if we've get a valid Esp, dispatch 1009 it on the main thread otherwise raise the signal in the 1010 ctrl-event thread (this). */ 982 1011 memset(&Ctx, 0, sizeof(Ctx)); 983 1012 Ctx.ContextFlags = CONTEXT_FULL; 984 GetThreadContext(hThread, &Ctx); 985 986 /* If we've got a valid Esp, dispatch it on the main thread 987 otherwise raise the signal in the ctrl-event thread (this). */ 988 if (Ctx.Esp >= 0x1000) 989 { 1013 if (GetThreadContext(hThread, &Ctx) 1014 #ifdef _M_IX86 1015 && Ctx.Esp >= 0x1000 1016 #else 1017 && Ctx.Rsp >= 0x1000 1018 #endif 1019 ) 1020 { 1021 #ifdef _M_IX86 990 1022 ((uintptr_t *)Ctx.Esp)[-1] = Ctx.Eip; 991 1023 Ctx.Esp -= sizeof(uintptr_t); 992 1024 Ctx.Eip = (uintptr_t)&dispatch_stub; 1025 #else 1026 g_Ctx = Ctx; 1027 Ctx.Rsp -= 0x20; 1028 Ctx.Rsp &= ~(uintptr_t)0xf; 1029 Ctx.Rip = (uintptr_t)&dispatch_stub; 1030 #endif 993 1031 994 1032 SetThreadContext(hThread, &Ctx); … … 1600 1638 #ifdef KMK 1601 1639 /* Check for [Mm]akefile.kup and change directory when found. 1602 Makefile.kmk overrides Makefile.kup but not plain Makefile. 1640 Makefile.kmk overrides Makefile.kup but not plain Makefile. 1603 1641 If no -C arguments were given, fake one to indicate chdir. */ 1604 1642 if (makefiles == 0)
Note:
See TracChangeset
for help on using the changeset viewer.