xref: /original-bsd/usr.bin/pascal/libpc/PMFLUSH.c (revision 7bb83803)
1 /*-
2  * Copyright (c) 1979, 1993
3  *	The Regents of the University of California.  All rights reserved.
4  *
5  * %sccs.include.redist.c%
6  */
7 
8 #ifndef lint
9 static char sccsid[] = "@(#)PMFLUSH.c	8.1 (Berkeley) 06/06/93";
10 #endif /* not lint */
11 
12 #include "h00vars.h"
13 
PMFLUSH(cntrs,rtns,bufaddr)14 PMFLUSH(cntrs, rtns, bufaddr)
15 
16 	long cntrs;	/* total number of counters (stmt + routine) */
17 	long rtns;	/* number of func and proc counters */
18 	long *bufaddr;	/* address of count buffers */
19 {
20 	register FILE	*filep;
21 
22 	bufaddr[0] = 0426;
23 	time(&bufaddr[1]);
24 	bufaddr[2] = cntrs;
25 	bufaddr[3] = rtns;
26 	filep = fopen(PXPFILE, "w");
27 	if (filep == NULL)
28 		goto ioerr;
29 	fwrite(bufaddr, (int)(cntrs + 1), sizeof(long), filep);
30 	if (ferror(filep))
31 		goto ioerr;
32 	fclose(filep);
33 	if (!ferror(filep))
34 		return;
35 ioerr:
36 	perror(PXPFILE);
37 }
38