misc: use right include for fctnl.h and poll.h
[vpp.git] / src / tools / perftool / c2cpel.c
index 38e6fe5..b02c506 100644 (file)
@@ -1,4 +1,4 @@
-/* 
+/*
  *------------------------------------------------------------------
  * Copyright (c) 2006-2016 Cisco and/or its affiliates.
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -20,7 +20,6 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
-#include <sys/fcntl.h>
 #include <sys/mman.h>
 #include <unistd.h>
 #include <ctype.h>
@@ -28,6 +27,7 @@
 #include <vppinfra/vec.h>
 #include <vppinfra/hash.h>
 #include <vppinfra/elog.h>
+#include <vppinfra/mem.h>
 #include <pwd.h>
 #include <stdarg.h>
 #include <time.h>
@@ -71,7 +71,7 @@ void convert_clib_file(char *clib_file)
 
         /* Seconds since start of log */
         delta = e->time - starttime;
-        
+
         /* u64 nanoseconds since start of log */
         timestamp = delta * 1e9;
 
@@ -80,11 +80,11 @@ void convert_clib_file(char *clib_file)
         /* allocate an event instance */
         vec_add2(the_events, ep, 1);
         ep->timestamp = timestamp;
-        
+
         /* convert string event code to a real number */
-        t = vec_elt_at_index (em->event_types, e->type);
+        t = vec_elt_at_index (em->event_types, e->event_type);
 
-        /* 
+        /*
          * Construct a reasonable event name.
          * Truncate the format string at the first whitespace break
          * or printf format character.
@@ -104,7 +104,7 @@ void convert_clib_file(char *clib_file)
 
         ep->event_id = find_or_add_event(brief_event_name, "%s");
 
-        track_name = format (0, "%U%c", format_elog_track, em, e, 0);
+        track_name = format (0, "%U%c", format_elog_track_name, em, e, 0);
 
         ep->track_id = find_or_add_track (track_name);
 
@@ -156,6 +156,8 @@ int main (int argc, char **argv)
     char *outputfile = 0;
     FILE *ofp;
 
+    clib_mem_init_thread_safe (0, 256 << 20);
+
     if (argc < 3)
         goto usage;
 
@@ -186,17 +188,19 @@ int main (int argc, char **argv)
         continue;
 
     usage:
-        fformat(stderr, 
+        fformat(stderr,
                 "c2cpel [--input-file] <filename> --output-file <filename>\n");
         exit(1);
     }
 
     if (vec_len(inputfiles) == 0 || outputfile == 0)
         goto usage;
-        
+
     if (vec_len(inputfiles) > 1)
         goto usage;
 
+    clib_mem_init (0, ((uword)3<<30));
+
     cpel_util_init();
 
     convert_clib_file (inputfiles[0]);
@@ -206,12 +210,12 @@ int main (int argc, char **argv)
         clib_unix_warning ("couldn't create %s", outputfile);
         exit (1);
     }
-    
+
     alpha_sort_tracks();
     fixup_event_tracks();
 
     /*
-     * Four sections: string-table, event definitions, track defs, events. 
+     * Four sections: string-table, event definitions, track defs, events.
      */
     if (!write_cpel_header(ofp, 4)) {
         clib_warning ("Error writing cpel header to %s...\n", outputfile);
@@ -241,7 +245,7 @@ int main (int argc, char **argv)
         clib_warning ("Error writing events to %s...\n", outputfile);
         unlink(outputfile);
         exit(1);
-        
+
     }
     fclose(ofp);
     exit (0);