mirror of
https://github.com/ctm/syn68k.git
synced 2024-12-03 14:49:38 +00:00
40 lines
697 B
C
40 lines
697 B
C
|
#include "readprofile.h"
|
||
|
#include "syn68k_public.h"
|
||
|
#include <stdio.h>
|
||
|
#include <stdlib.h>
|
||
|
|
||
|
unsigned long instruction_count[65536];
|
||
|
|
||
|
void
|
||
|
read_profile (const char *filename)
|
||
|
{
|
||
|
FILE *fp;
|
||
|
|
||
|
fp = fopen (filename, "rb");
|
||
|
if (fp == NULL)
|
||
|
{
|
||
|
perror ("Unable to open file");
|
||
|
exit (-1);
|
||
|
}
|
||
|
|
||
|
/* Read in the data. */
|
||
|
if (fread (instruction_count, sizeof (unsigned long), 65536, fp) != 65536)
|
||
|
{
|
||
|
fprintf (stderr, "Premature end of file!\n");
|
||
|
exit (-3);
|
||
|
}
|
||
|
|
||
|
/* Byte swap if necessary. */
|
||
|
#ifdef LITTLEENDIAN
|
||
|
{
|
||
|
unsigned long *p = instruction_count;
|
||
|
int i;
|
||
|
|
||
|
for (i = 65535; i >= 0; p++, i--)
|
||
|
*p = SWAPUL (*p);
|
||
|
}
|
||
|
#endif
|
||
|
|
||
|
fclose (fp);
|
||
|
}
|