mirror of
https://github.com/adtools/clib2.git
synced 2025-12-08 14:59:05 +00:00
Removed compiler warnings
git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@14979 87f5fb63-7c3d-0410-a384-fd976d0f7a62
This commit is contained in:
@@ -12,7 +12,11 @@
|
||||
#undef DebugPrintF
|
||||
#define dprintf(format, args...)((struct ExecIFace *)((*(struct ExecBase **)4)->MainInterface))->DebugPrintF("[%s] " format, __PRETTY_FUNCTION__ , ## args)
|
||||
|
||||
struct gmonparam _gmonparam = {kGmonProfOn};
|
||||
struct gmonparam _gmonparam =
|
||||
{
|
||||
state: kGmonProfOn
|
||||
};
|
||||
|
||||
static unsigned int s_scale;
|
||||
|
||||
void moncontrol(int);
|
||||
@@ -20,7 +24,7 @@ void monstartup(uint32, uint32);
|
||||
void moncleanup(void);
|
||||
void mongetpcs(uint32* lowpc, uint32 *highpc);
|
||||
|
||||
extern int profil(uint16 *buffer, uint32 bufSize,
|
||||
extern int profil(uint16 *buffer, uint32 bufSize,
|
||||
uint32 offset, uint32 scale);
|
||||
|
||||
void
|
||||
@@ -31,7 +35,7 @@ monstartup(uint32 low_pc, uint32 high_pc)
|
||||
struct gmonparam *p = &_gmonparam;
|
||||
dprintf("in monstartup)\n");
|
||||
/*
|
||||
* If we don't get proper lowpc and highpc, then
|
||||
* If we don't get proper lowpc and highpc, then
|
||||
* we'll try to get them from the elf handle.
|
||||
*/
|
||||
if (low_pc == 0 && high_pc == 0)
|
||||
@@ -43,44 +47,44 @@ monstartup(uint32 low_pc, uint32 high_pc)
|
||||
lowpc = low_pc;
|
||||
highpc = high_pc;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Round lowpc and highpc to multiples of the density
|
||||
* to prevent using floating point scaling
|
||||
*/
|
||||
p->lowpc = ROUNDDOWN(lowpc, HISTFRACTION * sizeof(HISTCOUNTER));
|
||||
p->highpc = ROUNDUP(highpc, HISTFRACTION * sizeof(HISTCOUNTER));
|
||||
|
||||
|
||||
/* Size of the text segment */
|
||||
p->textsize = p->highpc - p->lowpc;
|
||||
|
||||
/*
|
||||
|
||||
/*
|
||||
* Size of the histogram. Due to the nature of PowerPC code,
|
||||
* we can safely use a histogram fraction of at least 4, since
|
||||
* every instruction is exactly one word wide and always aligned.
|
||||
*/
|
||||
p->kcountsize = p->textsize / HISTFRACTION;
|
||||
|
||||
|
||||
/*
|
||||
* The hash table size
|
||||
*/
|
||||
p->hashfraction = HASHFRACTION;
|
||||
p->hashfraction = HASHFRACTION;
|
||||
p->fromssize = p->textsize / p->hashfraction;
|
||||
|
||||
|
||||
p->tolimit = p->textsize * ARCDENSITY / 100;
|
||||
if (p->tolimit < MINARCS)
|
||||
if (p->tolimit < MINARCS)
|
||||
p->tolimit = MINARCS;
|
||||
else if (p->tolimit > MAXARCS)
|
||||
p->tolimit = MAXARCS;
|
||||
|
||||
p->tossize = p->tolimit * sizeof(struct tostruct);
|
||||
|
||||
|
||||
dprintf("lowpc = %p, highpc = %p\n", lowpc, highpc);
|
||||
dprintf("textsize = %d\n", p->textsize);
|
||||
dprintf("kcountsize = %d\n", p->kcountsize);
|
||||
dprintf("fromssize = %d\n", p->fromssize);
|
||||
dprintf("tolimit = %d, tossize = %d\n", p->tolimit, p->tossize);
|
||||
|
||||
|
||||
cp = (uint8*)AllocMem(p->kcountsize + p->fromssize + p->tossize,
|
||||
MEMF_CLEAR);
|
||||
if (!cp)
|
||||
@@ -88,26 +92,26 @@ monstartup(uint32 low_pc, uint32 high_pc)
|
||||
p->state = kGmonProfError;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
p->memory = cp;
|
||||
p->tos = (struct tostruct *)cp;
|
||||
cp += p->tossize;
|
||||
|
||||
|
||||
p->kcount = (uint16 *)cp;
|
||||
cp += p->kcountsize;
|
||||
|
||||
|
||||
p->froms = (uint16 *)cp;
|
||||
|
||||
|
||||
p->tos[0].link = 0;
|
||||
|
||||
|
||||
/* Verify granularity for sampling */
|
||||
if (p->kcountsize < p->textsize)
|
||||
/* FIXME Avoid floating point */
|
||||
s_scale = ((float)p->kcountsize / p->textsize) * SCALE_1_TO_1;
|
||||
else
|
||||
s_scale = SCALE_1_TO_1;
|
||||
|
||||
s_scale >>= 1;
|
||||
|
||||
s_scale >>= 1;
|
||||
dprintf("Enabling monitor\n");
|
||||
moncontrol(1);
|
||||
}
|
||||
@@ -116,7 +120,7 @@ void
|
||||
moncontrol(int mode)
|
||||
{
|
||||
struct gmonparam *p = &_gmonparam;
|
||||
|
||||
|
||||
if (mode)
|
||||
{
|
||||
/* Start profiling. */
|
||||
@@ -145,7 +149,7 @@ moncleanup(void)
|
||||
struct gmonhdr gmonhdr, *hdr;
|
||||
#ifdef DEBUG
|
||||
FILE *log;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
moncontrol(0);
|
||||
|
||||
@@ -153,35 +157,35 @@ moncleanup(void)
|
||||
{
|
||||
fprintf(stderr, "WARNING: Overflow during profiling\n");
|
||||
}
|
||||
|
||||
|
||||
fd = Open("gmon.out", MODE_NEWFILE);
|
||||
if (!fd)
|
||||
{
|
||||
fprintf(stderr, "ERROR: could not open gmon.out\n");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
hdr = (struct gmonhdr *)&gmonhdr;
|
||||
|
||||
|
||||
hdr->lpc = 0; //p->lowpc;
|
||||
hdr->hpc = p->highpc - p->lowpc;
|
||||
hdr->ncnt = (int)p->kcountsize + sizeof(gmonhdr);
|
||||
hdr->version = GMONVERSION;
|
||||
hdr->profrate = 100; //FIXME:!!
|
||||
|
||||
|
||||
Write(fd, hdr, sizeof(*hdr));
|
||||
Write(fd, p->kcount, p->kcountsize);
|
||||
|
||||
|
||||
endfrom = p->fromssize / sizeof(*p->froms);
|
||||
|
||||
#ifdef DEBUG
|
||||
log = fopen("gmon.log", "w");
|
||||
#endif
|
||||
|
||||
|
||||
for (fromindex = 0; fromindex < endfrom; fromindex++)
|
||||
{
|
||||
if (p->froms[fromindex] == 0) continue;
|
||||
|
||||
|
||||
frompc = 0; /* FIXME: was p->lowpc; needs to be 0 and assumes
|
||||
-Ttext=0 on compile. Better idea? */
|
||||
frompc += fromindex * p->hashfraction * sizeof (*p->froms);
|
||||
@@ -189,10 +193,10 @@ moncleanup(void)
|
||||
toindex = p->tos[toindex].link)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
if (log) fprintf(log, "%p called from %p: %d times\n", frompc,
|
||||
p->tos[toindex].selfpc,
|
||||
if (log) fprintf(log, "%p called from %p: %d times\n", frompc,
|
||||
p->tos[toindex].selfpc,
|
||||
p->tos[toindex].count);
|
||||
#endif
|
||||
#endif
|
||||
rawarc.raw_frompc = frompc;
|
||||
rawarc.raw_selfpc = p->tos[toindex].selfpc;
|
||||
rawarc.raw_count = p->tos[toindex].count;
|
||||
@@ -202,9 +206,9 @@ moncleanup(void)
|
||||
|
||||
#ifdef DEBUG
|
||||
if (log) fclose(log);
|
||||
#endif
|
||||
#endif
|
||||
Close(fd);
|
||||
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
@@ -218,31 +222,31 @@ mongetpcs(uint32* lowpc, uint32 *highpc)
|
||||
uint32 i;
|
||||
Elf32_Shdr *shdr;
|
||||
uint32 numSections;
|
||||
|
||||
|
||||
*lowpc = 0;
|
||||
*highpc = 0;
|
||||
|
||||
|
||||
ElfBase = OpenLibrary("elf.library", 0L);
|
||||
if (!ElfBase) goto out;
|
||||
|
||||
|
||||
IElf = (struct ElfIFace *)GetInterface(ElfBase, "main", 1, NULL);
|
||||
if (!IElf) goto out;
|
||||
|
||||
|
||||
self = (struct Process *)FindTask(0);
|
||||
seglist = GetProcSegList(self);
|
||||
|
||||
|
||||
GetSegListInfoTags(seglist,
|
||||
GSLI_ElfHandle, &elfHandle,
|
||||
TAG_DONE);
|
||||
|
||||
|
||||
elfHandle = OpenElfTags(
|
||||
OET_ElfHandle, elfHandle,
|
||||
TAG_DONE);
|
||||
|
||||
|
||||
if (!elfHandle) goto out;
|
||||
|
||||
|
||||
GetElfAttrsTags(elfHandle, EAT_NumSections, &numSections, TAG_DONE);
|
||||
|
||||
|
||||
for (i = 0; i < numSections; i++)
|
||||
{
|
||||
shdr = GetSectionHeaderTags(elfHandle,
|
||||
@@ -269,6 +273,9 @@ out:
|
||||
|
||||
#include "macros.h"
|
||||
|
||||
int __profiler_init(void) __attribute__((constructor));
|
||||
void __profiler_exit(void) __attribute__((destructor));
|
||||
|
||||
int __profiler_init(void)
|
||||
{
|
||||
monstartup(0,0);
|
||||
@@ -278,4 +285,4 @@ int __profiler_init(void)
|
||||
void __profiler_exit(void)
|
||||
{
|
||||
moncleanup();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user