gcc do_rewrite

do_rewrite:

/* Driver for profile rewrite sub-command. */

static int do_rewrite (int argc, char **argv) {   int opt;   int ret;   const char *output_dir = 0; #ifdef HAVE_LONG_LONG   long long normalize_val = 0; #else   int64_t normalize_val = 0; #endif   float scale = 0.0;   int numerator = 1;   int denominator = 1;   int do_scaling = 0;

  optind = 0;   while ((opt = getopt_long (argc, argv, "vo:s:n:", rewrite_options, NULL)) != -1)     {       switch (opt)         {         case 'v':           verbose = true;           gcov_set_verbose ();           break;         case 'o':           output_dir = optarg;           break;         case 'n':           if (!do_scaling) #if defined(HAVE_LONG_LONG)      normalize_val = strtoll (optarg, (char **)NULL, 10); #elif defined(INT64_T_IS_LONG)      normalize_val = strtol (optarg, (char **)NULL, 10); #else      sscanf (optarg, "%" SCNd64, &normalize_val); #endif           else             fnotice (stderr, "scaling cannot co-exist with normalization,"                 " skipping\n");           break;         case 's':           ret = 0;           do_scaling = 1;           if (strstr (optarg, "/"))             {               ret = sscanf (optarg, "%d/%d", &numerator, &denominator);               if (ret == 2)                 {                   if (numerator < 0 || denominator <= 0)                     {                       fnotice (stderr, "incorrect format in scaling, using 1/1\n");                       denominator = 1;                       numerator = 1;                     }                 }             }           if (ret != 2)             {               ret = sscanf (optarg, "%f", &scale);               if (ret != 1)                 fnotice (stderr, "incorrect format in scaling, using 1/1\n");               else                 denominator = 0;             }

          if (scale < 0.0)             fatal_error (input_location, "scale needs to be non-negative\n");

          if (normalize_val != 0)             {               fnotice (stderr, "normalization cannot co-exist with scaling\n");               normalize_val = 0;             }           break;         default:           rewrite_usage ();         }     }

  if (output_dir == NULL)     output_dir = "rewrite_profile";

  if (argc - optind == 1)     {       if (denominator > 0)         ret = profile_rewrite (argv[optind],  output_dir, 0, 0.0, numerator, denominator);       else         ret = profile_rewrite (argv[optind],  output_dir, normalize_val, scale, 0, 0);     }   else     rewrite_usage ();

  return ret; }

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值