/*
 *  Copyright 2012 OpenSourceResearchInstitute.org
 *  Licensed under GNU General Public License version 2
 *
 * Author: seanhalle@yahoo.com
 * 
 */

#ifndef _PR_H
#define	_PR_H
#define _GNU_SOURCE

#include "DynArray/DynArray.h"
#include "Hash_impl/PrivateHash.h"
#include "Histogram/Histogram.h"
#include "Queue_impl/PrivateQueue.h"

#include "PR_primitive_data_types.h"
#include "Services_Offered_by_PR/Memory_Handling/vmalloc.h"

#include <pthread.h>
#include <sys/time.h>

//=================  Defines: included from separate files  =================
//
// Note: ALL defines are in other files, none are in here
//
#include "Defines/PR_defs.h"


//================================ Typedefs =================================
//
#include "PR__structs.h"

//============================ HW Dependent Fns ================================

#include "HW_Dependent_Primitives/PR__HW_measurement.h"
#include "HW_Dependent_Primitives/PR__primitives.h"


//=============================  Global Vars ================================

volatile TopEnv      *_PRTopEnv __align_to_cacheline__;

   //these are global, but only used for startup and shutdown
pthread_t       coreCtlrThdHandles[ NUM_CORES ]; //pthread's virt-procr state
ThdParams      *coreCtlrThdParams [ NUM_CORES ];

pthread_mutex_t suspendLock;
pthread_cond_t  suspendCond;

//=========================  Function Prototypes  ===========================
/* MEANING OF   WL  PI  SS  int PROS
 * These indicate which places the function is safe to use.  They stand for:
 * 
 * WL   Wrapper Library -- wrapper lib code should only use these
 * PI   Plugin          -- plugin code should only use these
 * SS   Startup and Shutdown -- designates these relate to startup & shutdown
 * int32internal to PR -- should not be used in wrapper lib or plugin
 * PROS means "OS functions for applications to use"
 * 
 * PR_int__ functions touch internal PR data structs and are only safe
 *  to be used inside the master lock.  However, occasionally, they appear
 * in wrapper-lib or plugin code.  In those cases, very careful analysis
 * has been done to be sure no concurrency issues could arise.
 * 
 * PR_WL__ functions are all safe for use outside the master lock.
 * 
 * PR_OS are only safe for applications to use -- they're like a second
 * language mixed in -- but they can't be used inside plugin code, and
 * aren't meant for use in wrapper libraries, because they are themselves
 * wrapper-library calls!
 */

inline bool32 masterFunction( AnimSlot  *slot );

//============== include internally used fn prototypes ================

//include fn prototypes used internally in the proto-runtime implementation
#include "PR__int.h"

//include fn prototypes used by plugin
#include "PR__PI.h"

//include fn prototype used by wrapper library
#include "PR__WL.h"

//=================================
#define implement_me() printf("Unimpl Fn: \n%s \n%s : %d\n", __FILE__, __FUNCTION__, __LINE__)
//#define fix_me printf("Fix me at: \n%s \n%s : %s\n", __FILE__, __FUNCTION__, __LINE__)


//========================= Services =======================
#include "Services_Offered_by_PR/Measurement_and_Stats/probes.h"
#include "Services_Offered_by_PR/Services_Language/PRServ.h"
//#include  "Services_Offered_by_PR/Services_Language/libPRServ.h"

//================================================
#endif	/* _PR_H */

