Changeset 3194 in kBuild
- Timestamp:
- Mar 27, 2018 2:05:17 PM (7 years ago)
- Location:
- trunk/src/kmk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kmk/job.h
r3156 r3194 68 68 /* Public functions emulated/provided in posixfcn.c. */ 69 69 int fcntl (intptr_t fd, int cmd, ...); 70 # ifdef CONFIG_NEW_WIN_CHILDREN 71 intptr_t create_mutex (char *mtxname, size_t size); 72 # else 70 73 intptr_t create_mutex (void); 74 # endif 71 75 int same_stream (FILE *f1, FILE *f2); 72 76 73 77 # define RECORD_SYNC_MUTEX(m) record_sync_mutex(m) 74 78 void record_sync_mutex (const char *str); 79 # ifdef CONFIG_NEW_WIN_CHILDREN 80 void prepare_mutex_handle_string (const char *mtxname); 81 # else 75 82 void prepare_mutex_handle_string (intptr_t hdl); 83 # endif 76 84 # else /* !WINDOWS32 */ 77 85 -
trunk/src/kmk/kmkbuiltin/kSubmit.c
r3192 r3194 1492 1492 if (pWorker) 1493 1493 { 1494 if (!pszExecutable) 1495 pszExecutable = argv[iArg]; 1494 /* Before we send off the job, we should dump pending output, since 1495 the kWorker process currently does not coordinate its output with 1496 the output.c mechanics. */ 1497 if (pCtx->pOut) 1498 output_dump(pCtx->pOut); 1496 1499 1497 1500 rcExit = kSubmitSendJobMessage(pCtx, pWorker, pvMsg, cbMsg, 0 /*fNoRespawning*/, cVerbosity); -
trunk/src/kmk/main.c
r3186 r3194 478 478 -O[TYPE], --output-sync[=TYPE]\n\ 479 479 Synchronize output of parallel jobs by TYPE.\n"), 480 #elif defined(KBUILD_OS_WINDOWS) 481 N_("\ 482 -O[TYPE], --output-sync[=TYPE]\n\ 483 Synchronize output of parallel jobs by TYPE:\n\ 484 none = no synchronization.\n\ 485 line = receip line output\n\ 486 target = entire receip output (default)\n\ 487 recurse = entire recursive invocation\n"), 480 488 #else 481 489 N_("\ … … 730 738 of each job stay together. */ 731 739 740 #if defined(KMK) && defined(KBUILD_OS_WINDOWS) 741 int output_sync = OUTPUT_SYNC_TARGET; 742 #else 732 743 int output_sync = OUTPUT_SYNC_NONE; 744 #endif 733 745 734 746 /* Nonzero if the "--trace" option was given. */ … … 1112 1124 command-line argument. */ 1113 1125 void 1126 # ifdef CONFIG_NEW_WIN_CHILDREN 1127 prepare_mutex_handle_string (const char *mtxname) 1128 { 1129 if (!sync_mutex) 1130 { 1131 sync_mutex = xstrdup(mtxname); 1132 define_makeflags (1, 0); 1133 } 1134 } 1135 # else 1114 1136 prepare_mutex_handle_string (sync_handle_t handle) 1115 1137 { … … 1123 1145 } 1124 1146 } 1147 # endif 1125 1148 1126 1149 #endif /* NO_OUTPUT_SYNC */ -
trunk/src/kmk/output.c
r3193 r3194 94 94 void *sem = acquire_semaphore (); 95 95 96 # ifndef KMK /* this drives me bananas. */ 96 97 /* Log the working directory for this dump. */ 97 98 if (print_directory_flag && output_sync != OUTPUT_SYNC_RECURSE) 98 99 traced = log_working_directory (1); 100 # endif 99 101 100 102 /* Work the out and err sequences in parallel. */ … … 124 126 fflush(prevdst); 125 127 prevdst = dst; 126 # ifdef KBUILD_OS_WINDOWS128 # ifdef KBUILD_OS_WINDOWS 127 129 maybe_con_fwrite (src, len, 1, dst); 128 # else130 # else 129 131 fwrite (src, len, 1, dst); 130 # endif132 # endif 131 133 } 132 134 if (prevdst) 133 135 fflush (prevdst); 134 136 137 # ifndef KMK /* this drives me bananas. */ 135 138 if (traced) 136 139 log_working_directory (0); 140 # endif 137 141 138 142 /* Exit the critical section. */ … … 599 603 600 604 #ifdef WINDOWS32 605 # ifdef CONFIG_NEW_WIN_CHILDREN 606 if (STREAM_OK (stdout)) 607 { 608 if (STREAM_OK (stderr)) 609 { 610 char mtxname[256]; 611 sync_handle = create_mutex (mtxname, sizeof (mtxname)); 612 if (sync_handle != -1) 613 { 614 prepare_mutex_handle_string (mtxname); 615 return same_stream (stdout, stderr); 616 } 617 perror_with_name ("output-sync suppressed: ", "create_mutex"); 618 } 619 else 620 perror_with_name ("output-sync suppressed: ", "stderr"); 621 } 622 else 623 perror_with_name ("output-sync suppressed: ", "stdout"); 624 output_sync = OUTPUT_SYNC_NONE; 625 626 # else /* !CONFIG_NEW_WIN_CHILDREN */ 601 627 if ((!STREAM_OK (stdout) && !STREAM_OK (stderr)) 602 628 || (sync_handle = create_mutex ()) == -1) … … 610 636 prepare_mutex_handle_string (sync_handle); 611 637 } 638 # endif /* !CONFIG_NEW_WIN_CHILDREN */ 612 639 613 640 #else … … 1032 1059 #endif 1033 1060 1061 #ifndef KMK 1034 1062 /* If we're not syncing this output per-line or per-target, make sure we emit 1035 1063 the "Entering..." message where appropriate. */ 1036 1064 if (output_sync == OUTPUT_SYNC_NONE || output_sync == OUTPUT_SYNC_RECURSE) 1065 #else 1066 /* Indiscriminately output "Entering..." and "Leaving..." message for each 1067 command line or target is plain annoying! And when there is no recursion 1068 it's actually inappropriate. Haven't got a simple way of detecting that, 1069 so back to the old behavior for now. [bird] */ 1070 #endif 1037 1071 if (! stdio_traced && print_directory_flag) 1038 1072 stdio_traced = log_working_directory (1); -
trunk/src/kmk/w32/compat/posixfcn.c
r3140 r3194 154 154 record_sync_mutex (const char *str) 155 155 { 156 #ifdef CONFIG_NEW_WIN_CHILDREN 157 HANDLE hmtx = OpenMutexA(SYNCHRONIZE, FALSE /*fInheritable*/, str); 158 if (hmtx) 159 mutex_handle = (intptr_t)hmtx; 160 else 161 { 162 mutex_handle = -1; 163 errno = ENOENT; 164 } 165 #else 156 166 char *endp; 157 167 intptr_t hmutex = strtol (str, &endp, 16); … … 164 174 errno = EINVAL; 165 175 } 176 #endif 166 177 } 167 178 168 179 /* Create a new mutex or reuse one created by our parent. */ 169 180 intptr_t 181 #ifdef CONFIG_NEW_WIN_CHILDREN 182 create_mutex (char *mtxname, size_t size) 183 #else 170 184 create_mutex (void) 171 { 185 #endif 186 { 187 #ifndef CONFIG_NEW_WIN_CHILDREN 172 188 SECURITY_ATTRIBUTES secattr; 189 #endif 173 190 intptr_t hmutex = -1; 174 191 … … 176 193 that. */ 177 194 if (mutex_handle > 0) 178 return mutex_handle; 179 195 { 196 #ifdef CONFIG_NEW_WIN_CHILDREN 197 mtxname[0] = '\0'; 198 #endif 199 return mutex_handle; 200 } 201 202 #ifdef CONFIG_NEW_WIN_CHILDREN 203 /* We're the top-level Make. Child Make processes will open our mutex, since 204 children does not inherit any handles other than the three standard ones. */ 205 snprintf(mtxname, size, "Make-output-%u-%u-%u", GetCurrentProcessId(), 206 GetCurrentThreadId(), GetTickCount()); 207 hmutex = (intptr_t)CreateMutexA (NULL, FALSE /*Locked*/, mtxname); 208 #else 180 209 /* We are the top-level Make, and we want the handle to be inherited 181 210 by our child processes. */ … … 185 214 186 215 hmutex = (intptr_t)CreateMutex (&secattr, FALSE, NULL); 216 #endif 187 217 if (!hmutex) 188 218 {
Note:
See TracChangeset
for help on using the changeset viewer.