aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/perf_counter/Makefile2
-rw-r--r--Documentation/perf_counter/builtin-help.c2
-rw-r--r--Documentation/perf_counter/builtin-record.c38
-rw-r--r--Documentation/perf_counter/builtin-report.c103
-rw-r--r--Documentation/perf_counter/builtin-stat.c3
-rw-r--r--Documentation/perf_counter/builtin-top.c2
-rw-r--r--Documentation/perf_counter/util/abspath.c2
-rw-r--r--Documentation/perf_counter/util/cache.h2
-rw-r--r--Documentation/perf_counter/util/util.h2
9 files changed, 82 insertions, 74 deletions
diff --git a/Documentation/perf_counter/Makefile b/Documentation/perf_counter/Makefile
index 10c13a6f2bc9..efb05892db69 100644
--- a/Documentation/perf_counter/Makefile
+++ b/Documentation/perf_counter/Makefile
@@ -159,7 +159,7 @@ uname_V := $(shell sh -c 'uname -v 2>/dev/null || echo not')
159 159
160# CFLAGS and LDFLAGS are for the users to override from the command line. 160# CFLAGS and LDFLAGS are for the users to override from the command line.
161 161
162CFLAGS = -ggdb3 -Wall 162CFLAGS = -ggdb3 -Wall -Werror -Wstrict-prototypes -Wmissing-declarations -Wmissing-prototypes -std=gnu99 -Wdeclaration-after-statement
163LDFLAGS = -lpthread -lrt -lelf 163LDFLAGS = -lpthread -lrt -lelf
164ALL_CFLAGS = $(CFLAGS) 164ALL_CFLAGS = $(CFLAGS)
165ALL_LDFLAGS = $(LDFLAGS) 165ALL_LDFLAGS = $(LDFLAGS)
diff --git a/Documentation/perf_counter/builtin-help.c b/Documentation/perf_counter/builtin-help.c
index 6616de0ef053..d2bd3177b98c 100644
--- a/Documentation/perf_counter/builtin-help.c
+++ b/Documentation/perf_counter/builtin-help.c
@@ -399,7 +399,7 @@ static void get_html_page_path(struct strbuf *page_path, const char *page)
399 * HTML. 399 * HTML.
400 */ 400 */
401#ifndef open_html 401#ifndef open_html
402void open_html(const char *path) 402static void open_html(const char *path)
403{ 403{
404 execl_perf_cmd("web--browse", "-c", "help.browser", path, NULL); 404 execl_perf_cmd("web--browse", "-c", "help.browser", path, NULL);
405} 405}
diff --git a/Documentation/perf_counter/builtin-record.c b/Documentation/perf_counter/builtin-record.c
index ec2b787b23bd..68abfdf71d39 100644
--- a/Documentation/perf_counter/builtin-record.c
+++ b/Documentation/perf_counter/builtin-record.c
@@ -1,6 +1,7 @@
1 1
2 2
3#include "perf.h" 3#include "perf.h"
4#include "builtin.h"
4#include "util/util.h" 5#include "util/util.h"
5#include "util/parse-options.h" 6#include "util/parse-options.h"
6#include "util/parse-events.h" 7#include "util/parse-events.h"
@@ -144,26 +145,32 @@ static int nr_poll;
144static int nr_cpu; 145static int nr_cpu;
145 146
146struct mmap_event { 147struct mmap_event {
147 struct perf_event_header header; 148 struct perf_event_header header;
148 __u32 pid, tid; 149 __u32 pid;
149 __u64 start; 150 __u32 tid;
150 __u64 len; 151 __u64 start;
151 __u64 pgoff; 152 __u64 len;
152 char filename[PATH_MAX]; 153 __u64 pgoff;
154 char filename[PATH_MAX];
153}; 155};
156
154struct comm_event { 157struct comm_event {
155 struct perf_event_header header; 158 struct perf_event_header header;
156 __u32 pid,tid; 159 __u32 pid;
157 char comm[16]; 160 __u32 tid;
161 char comm[16];
158}; 162};
159 163
160static pid_t pid_synthesize_comm_event(pid_t pid) 164static pid_t pid_synthesize_comm_event(pid_t pid)
161{ 165{
166 struct comm_event comm_ev;
162 char filename[PATH_MAX]; 167 char filename[PATH_MAX];
168 pid_t spid, ppid;
163 char bf[BUFSIZ]; 169 char bf[BUFSIZ];
164 struct comm_event comm_ev; 170 int fd, nr, ret;
171 char comm[18];
165 size_t size; 172 size_t size;
166 int fd; 173 char state;
167 174
168 snprintf(filename, sizeof(filename), "/proc/%d/stat", pid); 175 snprintf(filename, sizeof(filename), "/proc/%d/stat", pid);
169 176
@@ -178,12 +185,8 @@ static pid_t pid_synthesize_comm_event(pid_t pid)
178 } 185 }
179 close(fd); 186 close(fd);
180 187
181 pid_t spid, ppid;
182 char state;
183 char comm[18];
184
185 memset(&comm_ev, 0, sizeof(comm_ev)); 188 memset(&comm_ev, 0, sizeof(comm_ev));
186 int nr = sscanf(bf, "%d %s %c %d %d ", 189 nr = sscanf(bf, "%d %s %c %d %d ",
187 &spid, comm, &state, &ppid, &comm_ev.pid); 190 &spid, comm, &state, &ppid, &comm_ev.pid);
188 if (nr != 5) { 191 if (nr != 5) {
189 fprintf(stderr, "couldn't get COMM and pgid, malformed %s\n", 192 fprintf(stderr, "couldn't get COMM and pgid, malformed %s\n",
@@ -198,7 +201,8 @@ static pid_t pid_synthesize_comm_event(pid_t pid)
198 memcpy(comm_ev.comm, comm + 1, size); 201 memcpy(comm_ev.comm, comm + 1, size);
199 size = ALIGN(size, sizeof(uint64_t)); 202 size = ALIGN(size, sizeof(uint64_t));
200 comm_ev.header.size = sizeof(comm_ev) - (sizeof(comm_ev.comm) - size); 203 comm_ev.header.size = sizeof(comm_ev) - (sizeof(comm_ev.comm) - size);
201 int ret = write(output, &comm_ev, comm_ev.header.size); 204
205 ret = write(output, &comm_ev, comm_ev.header.size);
202 if (ret < 0) { 206 if (ret < 0) {
203 perror("failed to write"); 207 perror("failed to write");
204 exit(-1); 208 exit(-1);
diff --git a/Documentation/perf_counter/builtin-report.c b/Documentation/perf_counter/builtin-report.c
index 2d65d9c12aad..7f1255dcd222 100644
--- a/Documentation/perf_counter/builtin-report.c
+++ b/Documentation/perf_counter/builtin-report.c
@@ -1,4 +1,5 @@
1#include "util/util.h" 1#include "util/util.h"
2#include "builtin.h"
2 3
3#include <libelf.h> 4#include <libelf.h>
4#include <gelf.h> 5#include <gelf.h>
@@ -22,7 +23,7 @@ static int input;
22static int show_mask = SHOW_KERNEL | SHOW_USER | SHOW_HV; 23static int show_mask = SHOW_KERNEL | SHOW_USER | SHOW_HV;
23 24
24static int dump_trace = 0; 25static int dump_trace = 0;
25static int verbose; 26static int verbose;
26 27
27static unsigned long page_size; 28static unsigned long page_size;
28static unsigned long mmap_window = 32; 29static unsigned long mmap_window = 32;
@@ -60,10 +61,10 @@ typedef union event_union {
60} event_t; 61} event_t;
61 62
62struct symbol { 63struct symbol {
63 struct rb_node rb_node; 64 struct rb_node rb_node;
64 uint64_t start; 65 __u64 start;
65 uint64_t end; 66 __u64 end;
66 char name[0]; 67 char name[0];
67}; 68};
68 69
69static struct symbol *symbol__new(uint64_t start, uint64_t len, const char *name) 70static struct symbol *symbol__new(uint64_t start, uint64_t len, const char *name)
@@ -86,7 +87,7 @@ static void symbol__delete(struct symbol *self)
86 87
87static size_t symbol__fprintf(struct symbol *self, FILE *fp) 88static size_t symbol__fprintf(struct symbol *self, FILE *fp)
88{ 89{
89 return fprintf(fp, " %lx-%lx %s\n", 90 return fprintf(fp, " %llx-%llx %s\n",
90 self->start, self->end, self->name); 91 self->start, self->end, self->name);
91} 92}
92 93
@@ -147,10 +148,12 @@ static void dso__insert_symbol(struct dso *self, struct symbol *sym)
147 148
148static struct symbol *dso__find_symbol(struct dso *self, uint64_t ip) 149static struct symbol *dso__find_symbol(struct dso *self, uint64_t ip)
149{ 150{
151 struct rb_node *n;
152
150 if (self == NULL) 153 if (self == NULL)
151 return NULL; 154 return NULL;
152 155
153 struct rb_node *n = self->syms.rb_node; 156 n = self->syms.rb_node;
154 157
155 while (n) { 158 while (n) {
156 struct symbol *s = rb_entry(n, struct symbol, rb_node); 159 struct symbol *s = rb_entry(n, struct symbol, rb_node);
@@ -221,33 +224,42 @@ static Elf_Scn *elf_section_by_name(Elf *elf, GElf_Ehdr *ep,
221 224
222static int dso__load(struct dso *self) 225static int dso__load(struct dso *self)
223{ 226{
224 int fd = open(self->name, O_RDONLY), err = -1; 227 Elf_Data *symstrs;
228 uint32_t nr_syms;
229 int fd, err = -1;
230 uint32_t index;
231 GElf_Ehdr ehdr;
232 GElf_Shdr shdr;
233 Elf_Data *syms;
234 GElf_Sym sym;
235 Elf_Scn *sec;
236 Elf *elf;
225 237
238
239 fd = open(self->name, O_RDONLY);
226 if (fd == -1) 240 if (fd == -1)
227 return -1; 241 return -1;
228 242
229 Elf *elf = elf_begin(fd, ELF_C_READ_MMAP, NULL); 243 elf = elf_begin(fd, ELF_C_READ_MMAP, NULL);
230 if (elf == NULL) { 244 if (elf == NULL) {
231 fprintf(stderr, "%s: cannot read %s ELF file.\n", 245 fprintf(stderr, "%s: cannot read %s ELF file.\n",
232 __func__, self->name); 246 __func__, self->name);
233 goto out_close; 247 goto out_close;
234 } 248 }
235 249
236 GElf_Ehdr ehdr;
237 if (gelf_getehdr(elf, &ehdr) == NULL) { 250 if (gelf_getehdr(elf, &ehdr) == NULL) {
238 fprintf(stderr, "%s: cannot get elf header.\n", __func__); 251 fprintf(stderr, "%s: cannot get elf header.\n", __func__);
239 goto out_elf_end; 252 goto out_elf_end;
240 } 253 }
241 254
242 GElf_Shdr shdr; 255 sec = elf_section_by_name(elf, &ehdr, &shdr, ".symtab", NULL);
243 Elf_Scn *sec = elf_section_by_name(elf, &ehdr, &shdr, ".symtab", NULL);
244 if (sec == NULL) 256 if (sec == NULL)
245 sec = elf_section_by_name(elf, &ehdr, &shdr, ".dynsym", NULL); 257 sec = elf_section_by_name(elf, &ehdr, &shdr, ".dynsym", NULL);
246 258
247 if (sec == NULL) 259 if (sec == NULL)
248 goto out_elf_end; 260 goto out_elf_end;
249 261
250 Elf_Data *syms = elf_getdata(sec, NULL); 262 syms = elf_getdata(sec, NULL);
251 if (syms == NULL) 263 if (syms == NULL)
252 goto out_elf_end; 264 goto out_elf_end;
253 265
@@ -255,14 +267,12 @@ static int dso__load(struct dso *self)
255 if (sec == NULL) 267 if (sec == NULL)
256 goto out_elf_end; 268 goto out_elf_end;
257 269
258 Elf_Data *symstrs = elf_getdata(sec, NULL); 270 symstrs = elf_getdata(sec, NULL);
259 if (symstrs == NULL) 271 if (symstrs == NULL)
260 goto out_elf_end; 272 goto out_elf_end;
261 273
262 const uint32_t nr_syms = shdr.sh_size / shdr.sh_entsize; 274 nr_syms = shdr.sh_size / shdr.sh_entsize;
263 275
264 GElf_Sym sym;
265 uint32_t index;
266 elf_symtab__for_each_symbol(syms, nr_syms, index, sym) { 276 elf_symtab__for_each_symbol(syms, nr_syms, index, sym) {
267 struct symbol *f; 277 struct symbol *f;
268 278
@@ -342,7 +352,7 @@ out_delete_dso:
342 return NULL; 352 return NULL;
343} 353}
344 354
345void dsos__fprintf(FILE *fp) 355static void dsos__fprintf(FILE *fp)
346{ 356{
347 struct dso *pos; 357 struct dso *pos;
348 358
@@ -365,7 +375,7 @@ static int hex(char ch)
365 * While we find nice hex chars, build a long_val. 375 * While we find nice hex chars, build a long_val.
366 * Return number of chars processed. 376 * Return number of chars processed.
367 */ 377 */
368int hex2long(char *ptr, unsigned long *long_val) 378static int hex2long(char *ptr, unsigned long *long_val)
369{ 379{
370 const char *p = ptr; 380 const char *p = ptr;
371 *long_val = 0; 381 *long_val = 0;
@@ -493,12 +503,6 @@ out_delete:
493 return NULL; 503 return NULL;
494} 504}
495 505
496static size_t map__fprintf(struct map *self, FILE *fp)
497{
498 return fprintf(fp, " %lx-%lx %lx %s\n",
499 self->start, self->end, self->pgoff, self->dso->name);
500}
501
502struct thread; 506struct thread;
503 507
504static const char *thread__name(struct thread *self, char *bf, size_t size); 508static const char *thread__name(struct thread *self, char *bf, size_t size);
@@ -531,11 +535,6 @@ static struct symhist *symhist__new(struct symbol *sym, uint64_t ip,
531 return self; 535 return self;
532} 536}
533 537
534void symhist__delete(struct symhist *self)
535{
536 free(self);
537}
538
539static void symhist__inc(struct symhist *self) 538static void symhist__inc(struct symhist *self)
540{ 539{
541 ++self->count; 540 ++self->count;
@@ -608,6 +607,8 @@ static int thread__symbol_incnew(struct thread *self, struct symbol *sym,
608 struct symhist *sh; 607 struct symhist *sh;
609 608
610 while (*p != NULL) { 609 while (*p != NULL) {
610 uint64_t start;
611
611 parent = *p; 612 parent = *p;
612 sh = rb_entry(parent, struct symhist, rb_node); 613 sh = rb_entry(parent, struct symhist, rb_node);
613 614
@@ -617,7 +618,7 @@ static int thread__symbol_incnew(struct thread *self, struct symbol *sym,
617 } 618 }
618 619
619 /* Handle unresolved symbols too */ 620 /* Handle unresolved symbols too */
620 const uint64_t start = !sh->sym ? sh->ip : sh->sym->start; 621 start = !sh->sym ? sh->ip : sh->sym->start;
621 622
622 if (ip < start) 623 if (ip < start)
623 p = &(*p)->rb_left; 624 p = &(*p)->rb_left;
@@ -639,17 +640,6 @@ static int thread__set_comm(struct thread *self, const char *comm)
639 return self->comm ? 0 : -ENOMEM; 640 return self->comm ? 0 : -ENOMEM;
640} 641}
641 642
642size_t thread__maps_fprintf(struct thread *self, FILE *fp)
643{
644 struct map *pos;
645 size_t ret = 0;
646
647 list_for_each_entry(pos, &self->maps, node)
648 ret += map__fprintf(pos, fp);
649
650 return ret;
651}
652
653static size_t thread__fprintf(struct thread *self, FILE *fp) 643static size_t thread__fprintf(struct thread *self, FILE *fp)
654{ 644{
655 int ret = fprintf(fp, "thread: %d %s\n", self->pid, self->comm); 645 int ret = fprintf(fp, "thread: %d %s\n", self->pid, self->comm);
@@ -657,13 +647,14 @@ static size_t thread__fprintf(struct thread *self, FILE *fp)
657 647
658 for (nd = rb_first(&self->symhists); nd; nd = rb_next(nd)) { 648 for (nd = rb_first(&self->symhists); nd; nd = rb_next(nd)) {
659 struct symhist *pos = rb_entry(nd, struct symhist, rb_node); 649 struct symhist *pos = rb_entry(nd, struct symhist, rb_node);
650
660 ret += symhist__fprintf(pos, 0, fp); 651 ret += symhist__fprintf(pos, 0, fp);
661 } 652 }
662 653
663 return ret; 654 return ret;
664} 655}
665 656
666static struct rb_root threads = RB_ROOT; 657static struct rb_root threads;
667 658
668static struct thread *threads__findnew(pid_t pid) 659static struct thread *threads__findnew(pid_t pid)
669{ 660{
@@ -699,11 +690,11 @@ static void thread__insert_map(struct thread *self, struct map *map)
699 690
700static struct map *thread__find_map(struct thread *self, uint64_t ip) 691static struct map *thread__find_map(struct thread *self, uint64_t ip)
701{ 692{
693 struct map *pos;
694
702 if (self == NULL) 695 if (self == NULL)
703 return NULL; 696 return NULL;
704 697
705 struct map *pos;
706
707 list_for_each_entry(pos, &self->maps, node) 698 list_for_each_entry(pos, &self->maps, node)
708 if (ip >= pos->start && ip <= pos->end) 699 if (ip >= pos->start && ip <= pos->end)
709 return pos; 700 return pos;
@@ -711,7 +702,7 @@ static struct map *thread__find_map(struct thread *self, uint64_t ip)
711 return NULL; 702 return NULL;
712} 703}
713 704
714void threads__fprintf(FILE *fp) 705static void threads__fprintf(FILE *fp)
715{ 706{
716 struct rb_node *nd; 707 struct rb_node *nd;
717 for (nd = rb_first(&threads); nd; nd = rb_next(nd)) { 708 for (nd = rb_first(&threads); nd; nd = rb_next(nd)) {
@@ -720,7 +711,7 @@ void threads__fprintf(FILE *fp)
720 } 711 }
721} 712}
722 713
723static struct rb_root global_symhists = RB_ROOT; 714static struct rb_root global_symhists;
724 715
725static void threads__insert_symhist(struct symhist *sh) 716static void threads__insert_symhist(struct symhist *sh)
726{ 717{
@@ -852,7 +843,7 @@ more:
852 (void *)(long)(event->header.size), 843 (void *)(long)(event->header.size),
853 event->header.misc, 844 event->header.misc,
854 event->ip.pid, 845 event->ip.pid,
855 (void *)event->ip.ip); 846 (void *)(long)ip);
856 } 847 }
857 848
858 if (thread == NULL) { 849 if (thread == NULL) {
@@ -866,9 +857,12 @@ more:
866 level = 'k'; 857 level = 'k';
867 dso = kernel_dso; 858 dso = kernel_dso;
868 } else if (event->header.misc & PERF_EVENT_MISC_USER) { 859 } else if (event->header.misc & PERF_EVENT_MISC_USER) {
860 struct map *map;
861
869 show = SHOW_USER; 862 show = SHOW_USER;
870 level = '.'; 863 level = '.';
871 struct map *map = thread__find_map(thread, ip); 864
865 map = thread__find_map(thread, ip);
872 if (map != NULL) { 866 if (map != NULL) {
873 dso = map->dso; 867 dso = map->dso;
874 ip -= map->start + map->pgoff; 868 ip -= map->start + map->pgoff;
@@ -896,9 +890,9 @@ more:
896 fprintf(stderr, "%p [%p]: PERF_EVENT_MMAP: [%p(%p) @ %p]: %s\n", 890 fprintf(stderr, "%p [%p]: PERF_EVENT_MMAP: [%p(%p) @ %p]: %s\n",
897 (void *)(offset + head), 891 (void *)(offset + head),
898 (void *)(long)(event->header.size), 892 (void *)(long)(event->header.size),
899 (void *)event->mmap.start, 893 (void *)(long)event->mmap.start,
900 (void *)event->mmap.len, 894 (void *)(long)event->mmap.len,
901 (void *)event->mmap.pgoff, 895 (void *)(long)event->mmap.pgoff,
902 event->mmap.filename); 896 event->mmap.filename);
903 } 897 }
904 if (thread == NULL || map == NULL) { 898 if (thread == NULL || map == NULL) {
@@ -964,6 +958,11 @@ done:
964 return 0; 958 return 0;
965 } 959 }
966 960
961 if (verbose >= 2) {
962 dsos__fprintf(stdout);
963 threads__fprintf(stdout);
964 }
965
967 threads__sort_symhists(); 966 threads__sort_symhists();
968 threads__symhists_fprintf(total, stdout); 967 threads__symhists_fprintf(total, stdout);
969 968
diff --git a/Documentation/perf_counter/builtin-stat.c b/Documentation/perf_counter/builtin-stat.c
index e7cb9412212b..ce661e2fa8dd 100644
--- a/Documentation/perf_counter/builtin-stat.c
+++ b/Documentation/perf_counter/builtin-stat.c
@@ -30,6 +30,7 @@
30 */ 30 */
31 31
32#include "perf.h" 32#include "perf.h"
33#include "builtin.h"
33#include "util/util.h" 34#include "util/util.h"
34#include "util/parse-options.h" 35#include "util/parse-options.h"
35#include "util/parse-events.h" 36#include "util/parse-events.h"
@@ -108,7 +109,7 @@ static void create_perfstat_counter(int counter)
108 } 109 }
109} 110}
110 111
111int do_perfstat(int argc, const char **argv) 112static int do_perfstat(int argc, const char **argv)
112{ 113{
113 unsigned long long t0, t1; 114 unsigned long long t0, t1;
114 int counter; 115 int counter;
diff --git a/Documentation/perf_counter/builtin-top.c b/Documentation/perf_counter/builtin-top.c
index 6b1c66f99e4d..a890872638c1 100644
--- a/Documentation/perf_counter/builtin-top.c
+++ b/Documentation/perf_counter/builtin-top.c
@@ -42,8 +42,8 @@
42 * Released under the GPL v2. (and only v2, not any later version) 42 * Released under the GPL v2. (and only v2, not any later version)
43 */ 43 */
44 44
45
46#include "perf.h" 45#include "perf.h"
46#include "builtin.h"
47#include "util/util.h" 47#include "util/util.h"
48#include "util/util.h" 48#include "util/util.h"
49#include "util/parse-options.h" 49#include "util/parse-options.h"
diff --git a/Documentation/perf_counter/util/abspath.c b/Documentation/perf_counter/util/abspath.c
index 649f34f83365..61d33b81fc97 100644
--- a/Documentation/perf_counter/util/abspath.c
+++ b/Documentation/perf_counter/util/abspath.c
@@ -5,7 +5,7 @@
5 * symlink to a directory, we do not want to say it is a directory when 5 * symlink to a directory, we do not want to say it is a directory when
6 * dealing with tracked content in the working tree. 6 * dealing with tracked content in the working tree.
7 */ 7 */
8int is_directory(const char *path) 8static int is_directory(const char *path)
9{ 9{
10 struct stat st; 10 struct stat st;
11 return (!stat(path, &st) && S_ISDIR(st.st_mode)); 11 return (!stat(path, &st) && S_ISDIR(st.st_mode));
diff --git a/Documentation/perf_counter/util/cache.h b/Documentation/perf_counter/util/cache.h
index 71080512fa86..393d6146d13b 100644
--- a/Documentation/perf_counter/util/cache.h
+++ b/Documentation/perf_counter/util/cache.h
@@ -104,6 +104,8 @@ char *strip_path_suffix(const char *path, const char *suffix);
104 104
105extern char *mkpath(const char *fmt, ...) __attribute__((format (printf, 1, 2))); 105extern char *mkpath(const char *fmt, ...) __attribute__((format (printf, 1, 2)));
106extern char *perf_path(const char *fmt, ...) __attribute__((format (printf, 1, 2))); 106extern char *perf_path(const char *fmt, ...) __attribute__((format (printf, 1, 2)));
107/* perf_mkstemp() - create tmp file honoring TMPDIR variable */
108extern int perf_mkstemp(char *path, size_t len, const char *template);
107 109
108extern char *mksnpath(char *buf, size_t n, const char *fmt, ...) 110extern char *mksnpath(char *buf, size_t n, const char *fmt, ...)
109 __attribute__((format (printf, 3, 4))); 111 __attribute__((format (printf, 3, 4)));
diff --git a/Documentation/perf_counter/util/util.h b/Documentation/perf_counter/util/util.h
index 36e40c38e093..76590a16c271 100644
--- a/Documentation/perf_counter/util/util.h
+++ b/Documentation/perf_counter/util/util.h
@@ -309,6 +309,8 @@ extern ssize_t xread(int fd, void *buf, size_t len);
309extern ssize_t xwrite(int fd, const void *buf, size_t len); 309extern ssize_t xwrite(int fd, const void *buf, size_t len);
310extern int xdup(int fd); 310extern int xdup(int fd);
311extern FILE *xfdopen(int fd, const char *mode); 311extern FILE *xfdopen(int fd, const char *mode);
312extern int xmkstemp(char *template);
313
312static inline size_t xsize_t(off_t len) 314static inline size_t xsize_t(off_t len)
313{ 315{
314 return (size_t)len; 316 return (size_t)len;