Ejemplo n.º 1
0
int _args_main()
{
#pragma diag_suppress 1107,173
    register ARGS *pargs = (ARGS*)_symval(&__c_args__);
#pragma diag_default 1107,173
   register int    argc = 0;
   register char **argv = 0;

   /*------------------------------------------------------------------------*/
   /* For those targets that support table driven exception handling,        */
   /* initialize the global data structure here before main() to prepare     */
   /* for the first exception, especially from new().                        */
   /*------------------------------------------------------------------------*/
#if defined(__TI_TABLE_DRIVEN_EXCEPTIONS)
    __tdeh_init();
#endif
   
   if (_symval(&__c_args__) != NO_C_ARGS) 
   { argc = pargs->argc; argv = pargs->argv; }
  
   return main(argc, argv);
}
Ejemplo n.º 2
0
void _output_path_profile_info()
{
    far char *prof_array_addr;
    int prof_out_file;
    int i;      
    unsigned int pdsize = _symval(&__TI_prof_data_size);
    int file_exists = 0;
    char fil_name[32];

    /*------------------------------------------------------------------------*/
    /* Set the filename to default file name                                  */
    /*------------------------------------------------------------------------*/
    char *filename = "pprofout.pdat";

    /*------------------------------------------------------------------------*/
    /* We expect a device called PPHNDL to be registered.                     */
    /*------------------------------------------------------------------------*/
    strcpy(fil_name, PPROF_HANDLER_NAME);
    strcat(fil_name, ":");
    strcat(fil_name, filename);
    filename = fil_name;

    /*------------------------------------------------------------------------*/
    /* See if the file exists                                                 */
    /*------------------------------------------------------------------------*/
    prof_out_file = open(filename, O_RDONLY, 0);

    if (prof_out_file != -1) file_exists = 1;

    close(prof_out_file);

    /*------------------------------------------------------------------------*/
    /* Open the profile output file in append mode                            */
    /*------------------------------------------------------------------------*/
    prof_out_file = open(filename, O_BINARY|O_APPEND|O_CREAT|O_RDWR, 0);

    /*------------------------------------------------------------------------*/
    /* If open fails for any reason, return                                   */
    /*------------------------------------------------------------------------*/
    if (prof_out_file == -1)
    {
        /*--------------------------------------------------------------------*/
        /* We cannot print out error messages due to the problem of           */
        /* linking-in unneeded RTS routines                                   */
        /*--------------------------------------------------------------------*/
        return;
    }

    /*------------------------------------------------------------------------*/
    /* Do nothing if profile data section is empty                            */
    /*------------------------------------------------------------------------*/
    if (_symval(&__TI_prof_data_start) == (unsigned) -1) return;

    if (_symval(&__TI_prof_data_size) ==  (unsigned) -1) return;

    /*------------------------------------------------------------------------*/
    /* Write the header first                                                 */
    /*------------------------------------------------------------------------*/
    dump_pprof_header(prof_out_file, pdsize, file_exists);

    prof_array_addr = (char*)_symval(&__TI_prof_data_start);

#define MIN(a, b) ( (a) < (b) ? (a) : (b))

    for (i = 0; i < pdsize; i += BUFSIZ)
    {
        int cnt = MIN(pdsize - i, BUFSIZ);
        write(prof_out_file, prof_array_addr + i, cnt);
    }

    close(prof_out_file);

}