- Timestamp:
- Mar 18, 2018 8:10:03 PM (7 years ago)
- Location:
- trunk/src/kmk
- Files:
-
- 2 added
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kmk/Makefile.kmk
r3154 r3156 54 54 TEMPLATE_BIN-KMK_CFLAGS.win.amd64 = $(TEMPLATE_BIN-THREADED_CFLAGS.win.amd64) -wd4244 -wd4267 55 55 TEMPLATE_BIN-KMK_CLEAN.win = $(TEMPLATE_BIN-KMK_DEPS.win) 56 TEMPLATE_BIN-KMK_DEFS.debug = $(TEMPLATE_BIN -KMK_DEPS.debug) MAKE_MAINTAINER_MODE56 TEMPLATE_BIN-KMK_DEFS.debug = $(TEMPLATE_BIN_DEFS.debug) MAKE_MAINTAINER_MODE 57 57 TEMPLATE_BIN-KMK_INCS = $(kmk_0_OUTDIR) . $(TEMPLATE_BIN-THREADED_INCS) 58 58 ifneq ($(KBUILD_TARGET),os2) … … 69 69 ifdef CONFIG_WITH_ALLOCCACHE_DEBUG 70 70 TEMPLATE_BIN-KMK_DEFS += CONFIG_WITH_ALLOCCACHE_DEBUG 71 endif 72 ifdef CONFIG_NEW_WIN_CHILDREN 73 TEMPLATE_BIN-KMK_DEFS.win = $(TEMPLATE_BIN_DEFS.win) CONFIG_NEW_WIN_CHILDREN 71 74 endif 72 75 # GCC sanitizers. … … 275 278 endif 276 279 280 ifndef CONFIG_NEW_WIN_CHILDREN 277 281 kmk_SOURCES.win = \ 278 282 w32/subproc/sub_proc.c 283 else 284 kmk_SOURCES.win = \ 285 w32/winchildren.c 286 endif 279 287 280 288 kmk_DEFS.freebsd.x86 = CONFIG_WITHOUT_THREADS … … 512 520 endif 513 521 522 ifndef CONFIG_NEW_WIN_CHILDREN 514 523 kmk_gmake_SOURCES.win = \ 515 524 w32/subproc/sub_proc.c 525 else 526 kmk_gmake_SOURCES.win = \ 527 w32/winchildren.c 528 endif 516 529 517 530 -
trunk/src/kmk/commands.c
r3140 r3156 24 24 #include <windows.h> 25 25 #include "w32err.h" 26 # ifdef CONFIG_NEW_WIN_CHILDREN 27 # include "w32/winchildren.h" 28 # endif 26 29 #endif 27 30 #ifdef CONFIG_WITH_LAZY_DEPS_VARS … … 765 768 for (c = children; c != 0; c = c->next) 766 769 if (!c->remote) 770 # if defined (CONFIG_NEW_WIN_CHILDREN) && defined (WINDOWS32) 771 MkWinChildKill (c->pid, SIGTERM, c); 772 # else 767 773 (void) kill (c->pid, SIGTERM); 774 # endif 768 775 } 769 776 -
trunk/src/kmk/function.c
r3145 r3156 29 29 #ifdef WINDOWS32 /* bird */ 30 30 # include "pathstuff.h" 31 # ifdef CONFIG_NEW_WIN_CHILDREN 32 # include "w32/winchildren.h" 33 # endif 31 34 #endif 32 35 … … 2295 2298 /*untested*/ 2296 2299 2300 # ifndef CONFIG_NEW_WIN_CHILDREN 2297 2301 #include <windows.h> 2298 2302 #include <io.h> 2299 2303 #include "sub_proc.h" 2300 2301 2304 2302 2305 int … … 2425 2428 } 2426 2429 } 2430 # endif /* !CONFIG_NEW_WIN_CHILDREN */ 2427 2431 #endif 2428 2432 … … 2578 2582 2579 2583 #elif defined(WINDOWS32) 2584 # ifdef CONFIG_NEW_WIN_CHILDREN 2585 pipedes[1] = -1; 2586 MkWinChildCreateWithStdOutPipe (command_argv, envp, errfd, &pid, &pipedes[0]); 2587 # else 2580 2588 windows32_openpipe (pipedes, errfd, &pid, command_argv, envp); 2589 # endif 2581 2590 /* Restore the value of just_print_flag. */ 2582 2591 just_print_flag = j_p_f; -
trunk/src/kmk/job.c
r3141 r3156 117 117 # include <io.h> 118 118 # include <process.h> 119 # include "sub_proc.h" 119 # ifdef CONFIG_NEW_WIN_CHILDREN 120 # include "w32/winchildren.h" 121 # else 122 # include "sub_proc.h" 123 # endif 120 124 # include "w32err.h" 121 125 # include "pathstuff.h" … … 262 266 263 267 #ifdef WINDOWS32 268 # ifndef CONFIG_NEW_WIN_CHILDREN /* (only used by commands.c) */ 264 269 /* 265 270 * The macro which references this function is defined in makeint.h. … … 270 275 return ((process_kill ((HANDLE)pid, sig) == TRUE) ? 0 : -1); 271 276 } 277 # endif /* !CONFIG_NEW_WIN_CHILDREN */ 272 278 273 279 /* This function creates a temporary file name with an extension specified … … 807 813 #endif /* _AMIGA */ 808 814 #ifdef WINDOWS32 815 # ifndef CONFIG_NEW_WIN_CHILDREN 809 816 { 810 817 HANDLE hPID; … … 869 876 pid = (pid_t) hPID; 870 877 } 878 # else /* CONFIG_NEW_WIN_CHILDREN */ 879 assert (!any_remote); 880 pid = 0; 881 coredump = exit_sig = exit_code = 0; 882 { 883 int rc = MkWinChildWait(block, &pid, &exit_code, &exit_sig, &coredump, &c); 884 if (rc != 0) 885 ON (fatal, NILF, _("MkWinChildWait: %u"), rc); 886 } 887 if (pid == 0) 888 { 889 /* No more children, stop. */ 890 reap_more = 0; 891 break; 892 } 893 894 /* If we have started jobs in this second, remove one. */ 895 if (job_counter) 896 --job_counter; 897 # endif /* CONFIG_NEW_WIN_CHILDREN */ 871 898 #endif /* WINDOWS32 */ 872 899 } … … 1656 1683 #ifdef WINDOWS32 1657 1684 { 1685 # ifndef CONFIG_NEW_WIN_CHILDREN 1658 1686 HANDLE hPID; 1659 1687 char* arg0; … … 1699 1727 goto error; 1700 1728 } 1729 # else /* CONFIG_NEW_WIN_CHILDREN */ 1730 struct variable *shell_var = lookup_variable("SHELL", 5); 1731 const char *shell_value = !shell_var ? NULL 1732 : !shell_var->recursive || strchr(shell_var->value, '$') == NULL 1733 ? shell_var->value : variable_expand (shell_var->value); 1734 int rc = MkWinChildCreate(argv, child->environment, shell_value, child, &child->pid); 1735 if (rc != 0) 1736 { 1737 int i; 1738 unblock_sigs (); 1739 fprintf (stderr, _("failed to launch process (rc=%d)\n"), rc); 1740 for (i = 0; argv[i]; i++) 1741 fprintf (stderr, "%s ", argv[i]); 1742 fprintf (stderr, "\n", argv[i]); 1743 goto error; 1744 } 1745 #endif /* CONFIG_NEW_WIN_CHILDREN */ 1701 1746 } 1702 1747 #endif /* WINDOWS32 */ … … 1771 1816 #endif 1772 1817 #ifdef WINDOWS32 1818 # ifndef CONFIG_NEW_WIN_CHILDREN 1773 1819 || (process_used_slots () >= MAXIMUM_WAIT_OBJECTS) 1820 # endif 1774 1821 #endif 1775 1822 )) … … 2193 2240 time_t now; 2194 2241 2195 #if def WINDOWS322242 #if defined(WINDOWS32) && !defined(CONFIG_NEW_WIN_CHILDREN) 2196 2243 /* sub_proc.c cannot wait for more than MAXIMUM_WAIT_OBJECTS children */ 2197 2244 if (process_used_slots () >= MAXIMUM_WAIT_OBJECTS) … … 2436 2483 2437 2484 2485 #if !defined(WINDOWS32) || !defined(CONFIG_NEW_WIN_CHILDREN) 2438 2486 #ifndef _AMIGA 2439 2487 /* Replace the current process with one running the command in ARGV, … … 2459 2507 #else 2460 2508 #ifdef WINDOWS32 2509 # ifndef CONFIG_NEW_WIN_CHILDREN 2461 2510 HANDLE hPID; 2462 2511 HANDLE hWaitPID; … … 2514 2563 /* return child's exit code as our exit code */ 2515 2564 exit (exit_code); 2516 2565 # else /* CONFIG_NEW_WIN_CHILDREN */ 2566 2567 # endif /* CONFIG_NEW_WIN_CHILDREN */ 2517 2568 #else /* !WINDOWS32 */ 2518 2569 … … 2648 2699 2649 2700 #endif /* On Amiga */ 2701 #endif /* !defined(WINDOWS32) || !defined(CONFIG_NEW_WIN_CHILDREN) */ 2650 2702 2651 2703 … … 2777 2829 2778 2830 const char *sh_chars; 2779 c onst char **sh_cmds;2831 char const * const * sh_cmds; /* kmk: +_sh +const*2 */ 2780 2832 #elif defined(__riscos__) 2781 2833 static const char *sh_chars = ""; … … 3330 3382 /* This is the start of a new recipe line. Skip whitespace 3331 3383 and prefix characters but not newlines. */ 3384 #ifndef CONFIG_WITH_COMMANDS_FUNC 3332 3385 while (ISBLANK (*f) || *f == '-' || *f == '@' || *f == '+') 3386 #else 3387 char ch; 3388 while (ISBLANK ((ch = *f)) || ch == '-' || ch == '@' || ch == '+' || ch == '%') 3389 #endif 3333 3390 ++f; 3334 3391 … … 3382 3439 /* This is the start of a new recipe line. Skip whitespace 3383 3440 and prefix characters but not newlines. */ 3441 #ifndef CONFIG_WITH_COMMANDS_FUNC 3384 3442 while (ISBLANK (*f) || *f == '-' || *f == '@' || *f == '+') 3443 #else 3444 char ch; 3445 while (ISBLANK ((ch = *f)) || ch == '-' || ch == '@' || ch == '+' || ch == '%') 3446 #endif 3385 3447 ++f; 3386 3448 -
trunk/src/kmk/job.h
r3140 r3156 147 147 #elif defined(__EMX__) 148 148 int exec_command (char **argv, char **envp); 149 #el se149 #elif !defined(WINDOWS32) || !defined(CONFIG_NEW_WIN_CHILDREN) 150 150 void exec_command (char **argv, char **envp) __attribute__ ((noreturn)); 151 151 #endif -
trunk/src/kmk/kmkbuiltin/kSubmit.c
r3140 r3156 51 51 #endif 52 52 #ifdef KBUILD_OS_WINDOWS 53 # include "sub_proc.h" 53 # ifndef CONFIG_NEW_WIN_CHILDREN 54 # include "sub_proc.h" 55 # else 56 # include "../w32/winchildren.h" 57 # endif 54 58 #endif 55 59 … … 933 937 if (rc == -1) 934 938 { 939 # ifndef CONFIG_NEW_WIN_CHILDREN 935 940 if (process_kmk_register_submit(pWorker->OverlappedRead.hEvent, (intptr_t)pWorker, pPidSpawned) == 0) 936 941 { /* likely */ } … … 942 947 goto l_again; 943 948 } 949 # else 950 if (MkWinChildCreateSubmit((intptr_t)pWorker->OverlappedRead.hEvent, pWorker, pPidSpawned) == 0) 951 { /* likely */ } 952 else 953 { 954 /* We need to do the waiting here because sub_proc.c has too much to do. */ 955 warnx("MkWinChildCreateSubmit failed!"); 956 WaitForSingleObject(pWorker->OverlappedRead.hEvent, INFINITE); 957 goto l_again; 958 } 959 # endif 944 960 } 945 961 else -
trunk/src/kmk/kmkbuiltin/redirect.c
r3145 r3156 70 70 #include "kmkbuiltin.h" 71 71 #ifdef KMK 72 # include "job.h" 73 # include "variable.h" 72 74 # ifdef KBUILD_OS_WINDOWS 73 # include "sub_proc.h" 75 # ifndef CONFIG_NEW_WIN_CHILDREN 76 # include "sub_proc.h" 77 # else 78 # include "../w32/winchildren.h" 79 # endif 74 80 # include "pathstuff.h" 75 81 # endif 76 # include "job.h"77 # include "variable.h"78 82 #endif 79 83 … … 888 892 if ((intptr_t)hProcess != -1) 889 893 { 894 # ifndef CONFIG_NEW_WIN_CHILDREN 890 895 if (process_kmk_register_redirect(hProcess, pPidSpawned) == 0) 896 # else 897 if (MkWinChildCreateRedirect((intptr_t)hProcess, pPidSpawned) == 0) 898 # endif 891 899 { 892 900 if (cVerbosity > 0) … … 896 904 { 897 905 DWORD dwTmp; 906 # ifndef CONFIG_NEW_WIN_CHILDREN 898 907 warn("sub_proc is out of slots, waiting for child..."); 908 # else 909 warn("MkWinChildCreateRedirect failed..."); 910 # endif 899 911 dwTmp = WaitForSingleObject(hProcess, INFINITE); 900 912 if (dwTmp != WAIT_OBJECT_0) -
trunk/src/kmk/main.c
r3155 r3156 38 38 # include <io.h> 39 39 # include "pathstuff.h" 40 # include "sub_proc.h" 40 # ifndef CONFIG_NEW_WIN_CHILDREN 41 # include "sub_proc.h" 42 # else 43 # include "w32/winchildren.h" 44 # endif 41 45 # include "w32err.h" 42 46 #endif … … 2203 2207 job_setup_complete: 2204 2208 2209 #if defined (WINDOWS32) && defined(CONFIG_NEW_WIN_CHILDREN) 2210 /* Initialize the windows child management. */ 2211 MkWinChildInit(job_slots); 2212 #endif 2213 2205 2214 /* The extra indirection through $(MAKE_COMMAND) is done 2206 2215 for hysterical raisins. */ … … 3120 3129 setrlimit (RLIMIT_STACK, &stack_limit); 3121 3130 #endif 3131 # if !defined(WINDOWS32) || !defined(CONFIG_NEW_WIN_CHILDREN) 3122 3132 exec_command ((char **)nargv, environ); 3133 # else 3134 MkWinChildReExecMake ((char **)nargv, environ); 3135 # endif 3123 3136 #endif 3124 3137 free (aargv); -
trunk/src/kmk/makeint.h
r3140 r3156 474 474 # include <malloc.h> 475 475 # define pipe(_p) _pipe((_p), 512, O_BINARY) 476 # ifndef CONFIG_NEW_WIN_CHILDREN /* (only used by commands.c) */ 476 477 # define kill(_pid,_sig) w32_kill((_pid),(_sig)) 478 # endif 477 479 /* MSVC and Watcom C don't have ftruncate. */ 478 480 # if defined(_MSC_VER) || defined(__WATCOMC__) … … 485 487 486 488 void sync_Path_environment (void); 489 # ifndef CONFIG_NEW_WIN_CHILDREN /* (only used by commands.c) */ 487 490 int w32_kill (pid_t pid, int sig); 491 # endif 488 492 int find_and_set_default_shell (const char *token); 489 493 -
trunk/src/kmk/output.c
r3140 r3156 37 37 # include <windows.h> 38 38 # include <io.h> 39 # include "sub_proc.h" 39 # ifndef CONFIG_NEW_WIN_CHILDREN 40 # include "sub_proc.h" 41 # else 42 # include "w32/winchildren.h" 43 # endif 40 44 #endif /* WINDOWS32 */ 41 45 -
trunk/src/kmk/read.c
r3145 r3156 33 33 #ifdef WINDOWS32 34 34 #include <windows.h> 35 #include "sub_proc.h" 35 # ifndef _MSC_VER 36 # ifndef CONFIG_NEW_WIN_CHILDREN 37 # include "sub_proc.h" 38 # else 39 # include "w32/winchildren.h" 40 # endif 41 # endif 36 42 #else /* !WINDOWS32 */ 37 43 #ifndef _AMIGA … … 423 429 } 424 430 431 #ifdef _MSC_VER 432 ENULLLOOP (ebuf.fp, fopen (filename, "rN")); /* N == noinherit */ 433 #else 425 434 ENULLLOOP (ebuf.fp, fopen (filename, "r")); 435 #endif 426 436 427 437 /* Save the error code so we print the right message later. */ … … 454 464 const char *included = concat (3, include_directories[i], 455 465 "/", filename); 466 #ifdef _MSC_VER 467 ebuf.fp = fopen (included, "rN"); /* N == noinherit */ 468 #else 456 469 ebuf.fp = fopen (included, "r"); 470 #endif 457 471 if (ebuf.fp) 458 472 { … … 496 510 /* Set close-on-exec to avoid leaking the makefile to children, such as 497 511 $(shell ...). */ 512 #ifndef _MSC_VER /* not necessary, see fopen calls above. */ 498 513 #ifdef HAVE_FILENO 499 514 CLOSE_ON_EXEC (fileno (ebuf.fp)); 515 #endif 500 516 #endif 501 517 -
trunk/src/kmk/w32/include/sub_proc.h
r3140 r3156 17 17 #ifndef SUB_PROC_H 18 18 #define SUB_PROC_H 19 #ifdef CONFIG_NEW_WIN_CHILDREN 20 # error "Just checking..." 21 #endif 19 22 20 23 /* -
trunk/src/kmk/w32/w32os.c
r3140 r3156 24 24 #include <io.h> 25 25 #include "pathstuff.h" 26 #include "sub_proc.h" 26 #ifndef CONFIG_NEW_WIN_CHILDREN 27 # include "sub_proc.h" 28 #else 29 # include "winchildren.h" 30 #endif 27 31 #include "w32err.h" 28 32 #include "os.h" … … 169 173 jobserver_acquire (int timeout) 170 174 { 175 #ifndef CONFIG_NEW_WIN_CHILDREN 171 176 HANDLE handles[MAXIMUM_WAIT_OBJECTS + 1]; /* bird: + 1 to prevent trashing the stack. */ 177 #else 178 HANDLE handles[2]; 179 #endif 172 180 DWORD dwHandleCount; 173 181 DWORD dwEvent; … … 176 184 handles[0] = jobserver_semaphore; 177 185 186 #ifndef CONFIG_NEW_WIN_CHILDREN 178 187 /* Build array of handles to wait for. */ 179 188 dwHandleCount = 1 + process_set_handles (&handles[1]); 189 #else 190 /* Add the completed children event as the 2nd one. */ 191 handles[1] = (HANDLE)MkWinChildGetCompleteEventHandle(); 192 dwHandleCount = 2; 193 #endif 180 194 181 195 dwEvent = WaitForMultipleObjects (
Note:
See TracChangeset
for help on using the changeset viewer.