dotgnu-pnet-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Dotgnu-pnet-commits] CVS: pnet/cscc cscc.c,1.30,1.31


From: Rhys Weatherley <address@hidden>
Subject: [Dotgnu-pnet-commits] CVS: pnet/cscc cscc.c,1.30,1.31
Date: Sat, 08 Feb 2003 19:56:28 -0500

Update of /cvsroot/dotgnu-pnet/pnet/cscc
In directory subversions:/tmp/cvs-serv15600/cscc

Modified Files:
        cscc.c 
Log Message:


Pipe the assembly code output of language plugins directly into the
assembler if it is possible to do so, to avoid unnecessary
on-disk temporary files.


Index: cscc.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/cscc/cscc.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -C2 -r1.30 -r1.31
*** cscc.c      28 Dec 2002 05:07:51 -0000      1.30
--- cscc.c      9 Feb 2003 00:56:26 -0000       1.31
***************
*** 924,953 ****
  
  /*
-  * Execute a child process and wait for it to exit.
-  * Returns the status code.
-  */
- static int ExecChild(char **argv, const char *filename)
- {
-       int status;
- 
-       /* Dump the command-line if we are in verbose mode */
-       DumpCmdLine(argv);
- 
-       /* Use the system-specifc process spawn routine */
-       status = ILSpawnProcess(argv);
-       if(status < 0)
-       {
-               return 1;
-       }
-       else
-       {
-               return status;
-       }
- }
- 
- /*
   * Import the assembler code from "libILAsm".
   */
! int ILAsmMain(int argc, char *argv[]);
  
  /*
--- 924,930 ----
  
  /*
   * Import the assembler code from "libILAsm".
   */
! int ILAsmMain(int argc, char *argv[], FILE *newStdin);
  
  /*
***************
*** 1004,1009 ****
  
        /* Execute the assembler */
        ILCmdLineSuppressSlash();
!       status = ILAsmMain(cmdline_size - 1, cmdline);
        ILFree(cmdline);
        if(status != 0)
--- 981,987 ----
  
        /* Execute the assembler */
+       DumpCmdLine(cmdline);
        ILCmdLineSuppressSlash();
!       status = ILAsmMain(cmdline_size - 1, cmdline, 0);
        ILFree(cmdline);
        if(status != 0)
***************
*** 1027,1030 ****
--- 1005,1013 ----
        char *obj_output;
        int saveAsm;
+       int outputIndex = -1;
+       FILE *newStdin = 0;
+       int pipePid = 0;
+       int canPipe;
+       char **pluginCmdline = 0;
  
        /* Build the command-line for the plug-in */
***************
*** 1187,1190 ****
--- 1170,1174 ----
        {
                AddArgument(&cmdline, &cmdline_size, "-o");
+               outputIndex = cmdline_size;
                if(assemble_flag)
                {
***************
*** 1248,1254 ****
        AddArgument(&cmdline, &cmdline_size, 0);
  
!       /* Execute the plugin */
!       status = ExecChild(cmdline, filename);
!       ILFree(cmdline);
        if(status != 0)
        {
--- 1232,1293 ----
        AddArgument(&cmdline, &cmdline_size, 0);
  
!       /* Determine if we need to save the assembly stream */
!       saveAsm = CCStringListContains(extension_flags, num_extension_flags,
!                                                              "save-asm");
! 
!       /* Determine if we might be able to pipe the output into the assembler 
*/
!       canPipe = 1;
!       if(assemble_flag || preprocess_flag || saveAsm)
!       {
!               canPipe = 0;
!       }
!       if(CCStringListContains(extension_flags, num_extension_flags,
!                                                       "syntax-check"))
!       {
!               canPipe = 0;
!       }
! 
!       /* Execute the plugin, using a pipe if possible */
!       if(canPipe)
!       {
!               cmdline[outputIndex] = "-";
!               DumpCmdLine(cmdline);
!               status = ILSpawnProcessWithPipe(cmdline, (void **)&newStdin);
!               cmdline[outputIndex] = asm_output;
!               if(status < 0)
!               {
!                       /* Failed to spawn the process */
!                       status = 1;
!                       ILFree(cmdline);
!               }
!               else if(!status)
!               {
!                       /* This platform does not support pipes: fall back */
!                       status = ILSpawnProcess(cmdline);
!                       if(status < 0)
!                       {
!                               status = 1;
!                       }
!                       ILFree(cmdline);
!               }
!               else
!               {
!                       /* We won't have an on-disk assembly output file */
!                       asm_output = 0;
!                       pipePid = status;
!                       status = 0;
!                       pluginCmdline = cmdline;
!               }
!       }
!       else
!       {
!               DumpCmdLine(cmdline);
!               status = ILSpawnProcess(cmdline);
!               if(status < 0)
!               {
!                       status = 1;
!               }
!               ILFree(cmdline);
!       }
        if(status != 0)
        {
***************
*** 1269,1273 ****
                                                        "syntax-check"))
        {
!               ILDeleteFile(asm_output);
                return 0;
        }
--- 1308,1315 ----
                                                        "syntax-check"))
        {
!               if(asm_output != 0)
!               {
!                       ILDeleteFile(asm_output);
!               }
                return 0;
        }
***************
*** 1307,1322 ****
        }
        AddArgument(&cmdline, &cmdline_size, "--");
!       AddArgument(&cmdline, &cmdline_size, asm_output);
        AddArgument(&cmdline, &cmdline_size, 0);
  
        /* Execute the assembler */
!       saveAsm = CCStringListContains(extension_flags, num_extension_flags,
!                                                              "save-asm");
        ILCmdLineSuppressSlash();
!       status = ILAsmMain(cmdline_size - 1, cmdline);
        ILFree(cmdline);
        if(status != 0)
        {
!               if(!saveAsm)
                {
                        ILDeleteFile(asm_output);
--- 1349,1383 ----
        }
        AddArgument(&cmdline, &cmdline_size, "--");
!       if(newStdin)
!       {
!               /* Use the pipe output of the plugin as the assembler's input */
!               AddArgument(&cmdline, &cmdline_size, "-");
!       }
!       else
!       {
!               AddArgument(&cmdline, &cmdline_size, asm_output);
!       }
        AddArgument(&cmdline, &cmdline_size, 0);
  
        /* Execute the assembler */
!       DumpCmdLine(cmdline);
        ILCmdLineSuppressSlash();
!       status = ILAsmMain(cmdline_size - 1, cmdline, newStdin);
        ILFree(cmdline);
+       if(newStdin)
+       {
+               /* Close the pipe to the language plugin */
+               int newStatus;
+               fclose(newStdin);
+               newStatus = ILSpawnProcessWaitForExit(pipePid, cmdline);
+               ILFree(pluginCmdline);
+               if(status == 0)
+               {
+                       status = newStatus;
+               }
+       }
        if(status != 0)
        {
!               if(!saveAsm && asm_output)
                {
                        ILDeleteFile(asm_output);
***************
*** 1325,1329 ****
                return status;
        }
!       if(!saveAsm)
        {
                ILDeleteFile(asm_output);
--- 1386,1390 ----
                return status;
        }
!       if(!saveAsm && asm_output)
        {
                ILDeleteFile(asm_output);





reply via email to

[Prev in Thread] Current Thread [Next in Thread]