Mercurial > hg > cdb
annotate testzero.c @ 13:0a35d8de4296
support profiling with gprof
| author | Henry S. Thompson <ht@inf.ed.ac.uk> |
|---|---|
| date | Fri, 07 Feb 2025 14:43:27 +0000 |
| parents | 3bfef1f22a97 |
| children |
| rev | line source |
|---|---|
|
0
2cb46628feec
from cdb-0.75 per http://cr.yp.to/cdb.html,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
1 #include "uint32.h" |
|
2cb46628feec
from cdb-0.75 per http://cr.yp.to/cdb.html,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
2 #include "scan.h" |
|
2cb46628feec
from cdb-0.75 per http://cr.yp.to/cdb.html,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
3 #include "strerr.h" |
|
2cb46628feec
from cdb-0.75 per http://cr.yp.to/cdb.html,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
4 #include "cdb_make.h" |
|
2cb46628feec
from cdb-0.75 per http://cr.yp.to/cdb.html,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
5 |
|
2cb46628feec
from cdb-0.75 per http://cr.yp.to/cdb.html,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
6 #define FATAL "testzero: fatal: " |
|
2cb46628feec
from cdb-0.75 per http://cr.yp.to/cdb.html,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
7 |
|
2cb46628feec
from cdb-0.75 per http://cr.yp.to/cdb.html,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
8 void die_write(void) |
|
2cb46628feec
from cdb-0.75 per http://cr.yp.to/cdb.html,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
9 { |
|
2cb46628feec
from cdb-0.75 per http://cr.yp.to/cdb.html,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
10 strerr_die2sys(111,FATAL,"unable to write: "); |
|
2cb46628feec
from cdb-0.75 per http://cr.yp.to/cdb.html,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
11 } |
|
2cb46628feec
from cdb-0.75 per http://cr.yp.to/cdb.html,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
12 |
|
2cb46628feec
from cdb-0.75 per http://cr.yp.to/cdb.html,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
13 static char key[4]; |
|
2cb46628feec
from cdb-0.75 per http://cr.yp.to/cdb.html,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
14 static char data[65536]; |
|
2cb46628feec
from cdb-0.75 per http://cr.yp.to/cdb.html,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
15 struct cdb_make c; |
|
2cb46628feec
from cdb-0.75 per http://cr.yp.to/cdb.html,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
16 |
|
10
3bfef1f22a97
trivial changes to get rid of compile-time warnings
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
0
diff
changeset
|
17 int main(int argc,char **argv) |
|
0
2cb46628feec
from cdb-0.75 per http://cr.yp.to/cdb.html,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
18 { |
|
2cb46628feec
from cdb-0.75 per http://cr.yp.to/cdb.html,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
19 int fd; |
|
2cb46628feec
from cdb-0.75 per http://cr.yp.to/cdb.html,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
20 unsigned long loop; |
|
2cb46628feec
from cdb-0.75 per http://cr.yp.to/cdb.html,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
21 |
|
2cb46628feec
from cdb-0.75 per http://cr.yp.to/cdb.html,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
22 if (!*argv) _exit(0); |
|
2cb46628feec
from cdb-0.75 per http://cr.yp.to/cdb.html,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
23 if (!*++argv) _exit(0); |
|
2cb46628feec
from cdb-0.75 per http://cr.yp.to/cdb.html,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
24 scan_ulong(*argv,&loop); |
|
2cb46628feec
from cdb-0.75 per http://cr.yp.to/cdb.html,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
25 |
|
2cb46628feec
from cdb-0.75 per http://cr.yp.to/cdb.html,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
26 if (cdb_make_start(&c,1) == -1) die_write(); |
|
2cb46628feec
from cdb-0.75 per http://cr.yp.to/cdb.html,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
27 |
|
2cb46628feec
from cdb-0.75 per http://cr.yp.to/cdb.html,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
28 while (loop) { |
|
2cb46628feec
from cdb-0.75 per http://cr.yp.to/cdb.html,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
29 uint32_pack(key,--loop); |
|
2cb46628feec
from cdb-0.75 per http://cr.yp.to/cdb.html,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
30 if (cdb_make_add(&c,key,4,data,sizeof data) == -1) die_write(); |
|
2cb46628feec
from cdb-0.75 per http://cr.yp.to/cdb.html,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
31 } |
|
2cb46628feec
from cdb-0.75 per http://cr.yp.to/cdb.html,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
32 |
|
2cb46628feec
from cdb-0.75 per http://cr.yp.to/cdb.html,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
33 if (cdb_make_finish(&c) == -1) die_write(); |
|
2cb46628feec
from cdb-0.75 per http://cr.yp.to/cdb.html,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
34 _exit(0); |
|
2cb46628feec
from cdb-0.75 per http://cr.yp.to/cdb.html,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
35 } |
