2022-10-25 19:30:28 +00:00
|
|
|
#ifndef COMPILER_COMPILERTOOLS_H
|
|
|
|
#define COMPILER_COMPILERTOOLS_H
|
|
|
|
|
|
|
|
#include "compiler/common.h"
|
|
|
|
|
|
|
|
extern void CompilerGetPString(short index, unsigned char *string);
|
|
|
|
extern void CompilerGetCString(short index, char *string);
|
|
|
|
extern unsigned char *CTool_CtoPstr(char *cstr);
|
|
|
|
|
|
|
|
typedef struct HeapBlock {
|
|
|
|
struct HeapBlock *next;
|
|
|
|
Handle blockhandle;
|
|
|
|
SInt32 blocksize;
|
|
|
|
SInt32 blockfree;
|
|
|
|
} HeapBlock;
|
|
|
|
|
|
|
|
typedef struct HeapMem {
|
|
|
|
HeapBlock *blocks;
|
|
|
|
/// The minimum size for a new block
|
|
|
|
SInt32 allocsize;
|
|
|
|
HeapBlock *curblock;
|
|
|
|
char *curfreep;
|
|
|
|
SInt32 curfree;
|
|
|
|
} HeapMem;
|
|
|
|
|
|
|
|
typedef struct _HeapInfo {
|
|
|
|
/// The amount of blocks in this heap
|
|
|
|
SInt32 blocks;
|
|
|
|
/// The value of allocsize for the heap
|
|
|
|
SInt32 allocsize;
|
|
|
|
/// The total amount of bytes across all blocks
|
|
|
|
SInt32 total_size;
|
|
|
|
/// The amount of free bytes across all blocks
|
|
|
|
SInt32 total_free;
|
|
|
|
/// The average size of a block
|
|
|
|
SInt32 average_block_size;
|
|
|
|
/// The average amount of free space in a block
|
|
|
|
SInt32 average_block_free;
|
|
|
|
/// The amount of bytes in the largest contiguous section of free space
|
|
|
|
SInt32 largest_free_block;
|
|
|
|
} HeapInfo;
|
|
|
|
|
2022-12-29 12:32:55 +00:00
|
|
|
struct GList {
|
2022-10-25 19:30:28 +00:00
|
|
|
char **data;
|
|
|
|
SInt32 size;
|
|
|
|
SInt32 hndlsize;
|
|
|
|
SInt32 growsize;
|
2022-12-29 12:32:55 +00:00
|
|
|
};
|
2022-10-25 19:30:28 +00:00
|
|
|
|
|
|
|
extern long hash_name_id;
|
|
|
|
extern HashNameNode **name_hash_nodes;
|
|
|
|
extern void (*GListErrorProc)();
|
|
|
|
|
|
|
|
extern short InitGList(GList *gl, SInt32 size);
|
|
|
|
extern void FreeGList(GList *gl);
|
|
|
|
extern void LockGList(GList *gl);
|
|
|
|
extern void UnlockGList(GList *gl);
|
|
|
|
extern void ShrinkGList(GList *gl);
|
|
|
|
extern void AppendGListData(GList *gl, const void *data, SInt32 size);
|
|
|
|
extern void AppendGListNoData(GList *gl, SInt32 size);
|
|
|
|
extern void AppendGListByte(GList *gl, SInt8 thebyte);
|
|
|
|
extern void AppendGListWord(GList *gl, SInt16 theword);
|
|
|
|
extern void AppendGListTargetEndianWord(GList *gl, SInt16 theword);
|
|
|
|
extern void AppendGListLong(GList *gl, SInt32 theword);
|
|
|
|
extern void AppendGListTargetEndianLong(GList *gl, SInt32 theword);
|
|
|
|
extern void AppendGListID(GList *gl, const char *name);
|
|
|
|
extern void AppendGListName(GList *gl, const char *name);
|
|
|
|
extern void RemoveGListData(GList *gl, SInt32 size);
|
|
|
|
extern SInt16 GetGListByte(GList *gl);
|
|
|
|
extern SInt16 GetGListWord(GList *gl);
|
|
|
|
extern SInt32 GetGListLong(GList *gl);
|
|
|
|
extern short GetGListID(GList *gl, char *name);
|
|
|
|
extern void GetGListData(GList *gl, char *where, SInt32 size);
|
|
|
|
|
|
|
|
extern SInt16 CHash(const char *string);
|
|
|
|
extern HashNameNode *GetHashNameNode(const char *name);
|
|
|
|
extern HashNameNode *GetHashNameNodeHash(const char *name, SInt16 hashval);
|
|
|
|
extern HashNameNode *GetHashNameNodeHash2(const char *name, SInt16 hashval);
|
|
|
|
extern HashNameNode *GetHashNameNodeExport(const char *name);
|
|
|
|
extern SInt32 GetHashNameNodeExportID(HashNameNode *node);
|
|
|
|
extern HashNameNode *GetHashNameNodeByID(SInt32 id);
|
|
|
|
extern void NameHashExportReset();
|
|
|
|
extern void NameHashWriteNameTable(GList *glist);
|
|
|
|
extern void NameHashWriteTargetEndianNameTable(GList *glist);
|
|
|
|
extern void InitNameHash();
|
|
|
|
|
|
|
|
typedef void (*heaperror_t)();
|
|
|
|
|
|
|
|
extern SInt32 CTool_TotalHeapSize();
|
|
|
|
extern void CTool_GetHeapInfo(HeapInfo *result, unsigned char heapID);
|
|
|
|
extern short initheaps(heaperror_t heaperrorproc);
|
|
|
|
extern short initgheap(heaperror_t heaperrorproc);
|
|
|
|
extern heaperror_t getheaperror();
|
|
|
|
extern void setheaperror(heaperror_t heaperrorproc);
|
|
|
|
extern void releaseheaps();
|
|
|
|
extern void releasegheap();
|
|
|
|
extern void releaseoheap();
|
|
|
|
extern void *galloc(SInt32 s);
|
|
|
|
extern void *lalloc(SInt32 s);
|
|
|
|
extern void *aalloc(SInt32 s);
|
|
|
|
extern void *oalloc(SInt32 s);
|
|
|
|
extern void *balloc(SInt32 s);
|
|
|
|
|
|
|
|
extern void locklheap();
|
|
|
|
extern void unlocklheap();
|
|
|
|
extern void freelheap();
|
|
|
|
extern void freeaheap();
|
|
|
|
extern void freeoheap();
|
|
|
|
extern void freebheap();
|
|
|
|
|
|
|
|
extern char *ScanHex(char *string, UInt32 *result, Boolean *overflow);
|
|
|
|
extern char *ScanOct(char *string, UInt32 *result, Boolean *overflow);
|
|
|
|
extern char *ScanDec(char *string, UInt32 *result, Boolean *overflow);
|
|
|
|
|
|
|
|
extern void OldUnmangle(char *name, char *out, Boolean full);
|
|
|
|
|
|
|
|
extern short hash(char *a);
|
|
|
|
extern void memclr(void *ptr, SInt32 size);
|
|
|
|
extern void memclrw(void *ptr, SInt32 size);
|
|
|
|
extern void CToLowercase(char *a, char *b);
|
|
|
|
extern short getbit(SInt32 l);
|
2022-12-29 12:32:55 +00:00
|
|
|
#ifdef ENDIAN_CONVERSION
|
|
|
|
extern UInt16 CTool_EndianConvertWord16(UInt16 theword);
|
|
|
|
extern UInt32 CTool_EndianConvertWord32(UInt32 theword);
|
|
|
|
extern void CTool_EndianConvertMem(UInt8 *data, short len);
|
|
|
|
extern UInt32 CTool_EndianReadWord32(void *ptr);
|
|
|
|
#else
|
|
|
|
#define CTool_EndianConvertWord32(value) value
|
|
|
|
#define CTool_EndianConvertWord16(value) value
|
|
|
|
#define CTool_EndianConvertMem(data, len) ((void)0)
|
|
|
|
#define CTool_EndianReadWord32(ptr) (*((UInt32 *) (ptr)))
|
|
|
|
#endif
|
2022-10-25 19:30:28 +00:00
|
|
|
extern void CTool_EndianConvertWord64(CInt64 ci, char *result);
|
|
|
|
extern UInt16 CTool_EndianConvertInPlaceWord16Ptr(UInt16 *x);
|
|
|
|
extern UInt32 CTool_EndianConvertInPlaceWord32Ptr(UInt32 *x);
|
|
|
|
extern void CTool_EndianConvertVector128(); // not correct but idc
|
|
|
|
extern HashNameNode *CTool_GetPathName(const FSSpec *fss, SInt32 *moddateptr);
|
|
|
|
extern int strcat_safe(char *dest, const char *src, SInt32 len);
|
|
|
|
|
|
|
|
#endif
|