#ifndef __stdlib_h
#define __stdlib_h
#pragma once

/*
 * Libraries and headers for PDC release 3.3 (C) 1989 Lionel Hummel.
 * PDC Software Distribution (C) 1989 Lionel Hummel and Paul Petersen.
 * PDC I/O Library (C) 1987 by J.A. Lydiatt.
 *
 * This code is freely redistributable upon the conditions that this
 * notice remains intact and that modified versions of this file not
 * be included as part of the PDC Software Distribution without the
 * express consent of the copyright holders.  No warrantee of any
 * kind is provided with this code.  For further information, contact:
 *
 *  PDC Software Distribution    Internet:                     BIX:
 *  P.O. Box 4006             or hummel@cs.uiuc.edu            lhummel
 *  Urbana, IL  61801-8801       petersen@uicsrd.csrd.uiuc.edu
 */

/* stdlib.h - Declarations for functions in the standard C library
 */

/* modified - ryb */

#ifndef __sys_stdtypes_h
#include <sys/stdtypes.h>
#endif

#ifndef NULL
#define NULL 0
#endif

#define EXIT_SUCCESS 0
#define EXIT_FAILURE 20

#define RAND_MAX 0x7fffffff

#if 0
#define MB_CUR_MAX
#endif

#ifndef _DF_SIZE_T
#define _DF_SIZE_T
typedef _TD_SIZE_T size_t;
#endif

#ifndef _DF_WCHAR_T
#define _DF_WCHAR_T
typedef _TD_WCHAR_T wchar_t;
#endif

typedef struct
{
  int quot;
  int rem;
} div_t;

typedef struct
{
  long quot;
  long rem;
} ldiv_t;

_VOLATILE void	 abort (void);
_CONST int	 abs (int);
int		 atexit (void (*)(void));
double		 atof (const char *);
int		 atoi (const char *);
long		 atol (const char *);
void		*bsearch (const void *, const void *, size_t, size_t,
			  int (*)(const void *, const void *));
void		*calloc (size_t, size_t);
_CONST div_t	 div (int, int);
_VOLATILE void	 exit (int);
void		 free (void *);
char		*getenv (const char *);
_CONST long	 labs (long);
_CONST ldiv_t	 ldiv (long, long);
void		*malloc (size_t);
void		*qsort (void *, size_t, size_t,
			int (*compar)(const void *, const void *));
int		 rand (void);
void		*realloc (void *, size_t);
void		 srand (unsigned int);
double		 strtod (const char *, char **);
long		 strtol (const char *, char **, int);
unsigned long	 strtoul (const char *, char **, int);
int		 system (const char *);

#if 0
/* Multi-byte and wide character operations. */
int		 mblen (const char *, size_t);
size_t		 mbstowcs (wchar_t *, const char *, size_t);
int		 mbtowc (wchar_t *, const char *, size_t);
int		 wctomb (char *, wchar_t);
size_t		 wctombs (char *, const wchar_t *, size_t);
#endif

#ifdef __GNUC__
#define abs(j) ({int _j = (j); _j < 0 ? -_j : _j; })
#define labs(j) ({long _j = (j); _j < 0 ? -_j : _j; })
#endif

#endif /* __stdlib_h */
