view include/std.h @ 102:14d96c95dd56

Moved the malloc debugging code to the dynamic program file The malloc debugging code should not be in the library, it is now solely in the program that exists to debug the functions I added a few TODOs to std.c
author Jonathan Pevarnek <pevarnj@gmail.com>
date Sun, 29 May 2011 19:35:17 -0400
parents 191e99dffd6c
children d971d4288a5a
line wrap: on
line source

#include <die.h>

#ifndef __STD_H
#define __STD_H

#define assert(x) do { if(!(x)) die(); } while (0)

//min and max function definitions
#define __fxn(TYPE) \
	static inline TYPE Max_##TYPE(TYPE a, TYPE b) { return (a>b) ? a : b; } \
	static inline TYPE Min_##TYPE(TYPE a, TYPE b) { return (a>b) ? b : a; } 
	__fxn(int)
	__fxn(u64)
	__fxn(u32)
#undef __fxn

void init_all(u64 __memsize);

double abs(double num);

char* ftoa(double x, char *a, unsigned int prec);
char* itoa(long long n, char *a, unsigned short base);
s64 atoi(char *a);
double atof(char *a);

void sPrint(char *a);
char* sGet(char *a, unsigned int n);


//MALLOC CODE

struct HEADER{
	struct HEADER *next;
	size_t size;
};
typedef struct HEADER Header;

typedef Header blockUnit;

void malloc_init(size_t memSize);
void* malloc(size_t size);
void free(void *ptr);

#endif