
/* 
 * stdlib.h replaces malloc.h and contains some more standard functions
 * from xdlibs; it is an ANSI compatible header file.
 * See chapter stdlib in xdlibs.txt.
 *
 * IT IS INCLUDED by stdio.h, so have to include it only
 * if you don't use stdio.h
 * -jerry-
 */

#ifndef STDLIB
#define	STDLIB	"XDLIBS"

#ifndef TYPES_H
#include <types.h>
#endif
#ifndef STDDEF_H
#include <stddef.h>
#endif

/* some compatibility macros are included */
#define sync()			/* sync() not possible, no operation */

extern	double	atof(const char *s);
extern	int		atoi(const char *s);
extern	long	atol(const char *s);
// missing ??:
//extern  long    strtod(char *number, char **nptr, int base);
extern  long    strtol(char *number, char **nptr, int base);
extern  unsigned long   strtoul(char *number, char **nptr, int base);

extern	int		rand();
//extern	void	srand();
#define srand(seed) 		/* no random seeding required */

extern	void	*calloc(size_t nobj, size_t size);
extern	void	*malloc(size_t size);
extern	void	*realloc(void *p, size_t size);
extern	void	free(void *p);

extern	void	abort();
extern	void	exit(int status);
extern	void	atexit( void (*fnc)());

extern	int		system(const char *s);
extern	char	*getenv(const char *name);

extern	void	*bsearch( void *key, void *base, int num, size_t size,
							int (*cmp)(void * keyval, void *datum) );
extern	void	qsort( void *base, int num, size_t size,
							int (*cmp)(void * keyval, void *datum) );


#define	abs(x)		((x)<0?(-(x)):(x))
#define lbas(x)	abs(x)
//div and ldiv are missing??

#endif
