/* mt/cb/mt_cb.h */

/* Copyright (C) 1998-2000, RSA Security Development Pty Ltd.
 *
 * This file shall only be used to demonstrate how to interface to an
 * RSA Security Development Pty Ltd licensed development product.
 *
 * You have a royalty-free right to use, reproduce and distribute this 
 * demonstration file, provided that you agree that RSA Security 
 * Development Pty Ltd has no warranty, implied or otherwise, or
 * liability for this demonstration file.
 *
 */

#ifndef HEADER_MT_CB_MT_CB_H
#define HEADER_MT_CB_MT_CB_H

#ifndef THREAD_STACK_SIZE
#ifdef PLATFORM_SOLARIS
/* We need at least 38k for the usparc asm routine */
#define THREAD_STACK_SIZE       (56*1024)
#else /* ! PLATFORM_SOLARIS */

/* 16k stack for each thread should be sufficient */
#define THREAD_STACK_SIZE       (16*1024)
#endif
#endif

#ifndef MAX_THREAD_NUMBER
#define MAX_THREAD_NUMBER	256
#endif

/* remove the following define if you want the lock trace code
 * compiled out - which removes all fprintf(stderr,...) calls
 */
#define APP_LOCK_TRACE
	
#ifdef WIN32
#include "mt_win32.h"
#endif
#ifdef SOLARIS
#include "mt_sol.h"
#else
#if defined(PTHREAD) || defined(LINUX) || defined(OSX)
#include "mt_pth.h"
#endif
#ifdef VXWORKS
#include "mt_vxw.h"
#endif
#endif
#ifdef FREEBSD
#include "mt_pth.h"
#endif
int APP_locking_cb_add(void);
int APP_locking_cb_delete(void);

int APP_thread_initialize(int thread_number);
int APP_thread_create(void (*func)(void *arg),void *func_arg,
                                APP_THREAD_ID *tid);
int APP_thread_finalize(int thread_number);

/* fwd decl of the callbacks registered */
int APPCB_locking_cb(int mode, int lockid, char *file, int line);
unsigned long APPCB_thread_id();

/* code for trace, stats display */
int APP_thread_trace(int val);
int APP_thread_show_stats(void);

#endif /* HEADER_MT_CB_MT_CB_H */

