/* Copyright 2005 Chris Thomasson */


#include "ac_base.h"
#include <pthread.h>
#include <sched.h>
#include <stddef.h>
#include <assert.h>
#include <limits.h>
#include <errno.h>


#ifndef APPCORE_H
#define APPCORE_H


#ifdef __cplusplus
extern "C"
{
#endif




#if defined ( BUILDING_DLL ) || \
    defined ( APPCORE_EXPORTS ) || \
    defined ( APPCORE_WINCE_EXPORTS ) || \
    defined ( AC_BUILD_FORCE_EXPORT )

#   define AC_BUILD_DLL_EXPORT 
#   define AC_APIEXPORT AC_DECLSPEC_API_EXPORT
    
#else

#   define AC_BUILD_DLL_IMPORT 
#   define AC_APIEXPORT AC_DECLSPEC_API_IMPORT

#endif




#ifndef AC_SYS_APIEXPORT
#define AC_SYS_APIEXPORT extern
#endif


#define AC_CDECL AC_DECLSPEC_CALL_CDECL
#define AC_APIDECL AC_DECLSPEC_CALL_FAST_CALL


#ifndef AC_APIEXPORT
#define AC_APIEXPORT extern
#endif


#ifndef AC_SYS_APIEXPORT
#define AC_SYS_APIEXPORT extern
#endif




/*****  AppCore API  *****/
#define AC_ECORRUPTED (-666)
#define AC_INFINITE UINT_MAX


typedef struct ac_thread_ ac_thread_t;
typedef unsigned int ac_timeout_t;


typedef void ( AC_CDECL *ac_fp_dtor_t ) ( void* );




AC_APIEXPORT int AC_APIDECL
ac_sys_error
( int );


AC_APIEXPORT int AC_APIDECL
ac_startup
( void );


AC_APIEXPORT int AC_APIDECL
ac_shutdown
( void );


AC_APIEXPORT AC_DECLSPEC_MALLOC void* AC_CDECL
ac_malloc
( size_t );


AC_APIEXPORT void* AC_CDECL
ac_calloc
( size_t,
  size_t );


AC_APIEXPORT void* AC_APIDECL
ac_malloc_aligned
( void**, 
  size_t,
  size_t );


AC_APIEXPORT void* AC_APIDECL
ac_calloc_aligned
( void**, 
  size_t,
  size_t,
  size_t );


AC_APIEXPORT void AC_CDECL
ac_free
( void* );




#ifdef __cplusplus
}
#endif


#endif




/* i686 only, for now.  ;(...
   Luckly, the algorithms are portable to many different processors. =) */
#include "cpu/i686/ac_i686.h"