#ident "kit/share/stubs.c: Copyright (c) MIPS Technologies, Inc. All rights reserved."

/*
 * Unpublished work (c) MIPS Technologies, Inc.  All rights reserved.
 * Unpublished rights reserved under the copyright laws of the United
 * States of America and other countries.
 * 
 * This code is confidential and proprietary to MIPS Technologies,
 * Inc. ("MIPS Technologies") and may be disclosed only as permitted in
 * writing by MIPS Technologies. Any copying, reproducing, modifying,
 * use or disclosure of this code (in whole or in part) that is not
 * expressly permitted in writing by MIPS Technologies is strictly
 * prohibited. At a minimum, this code is protected under trade secret,
 * unfair competition, and copyright laws. Violations thereof may result
 * in criminal penalties and fines.
 * 
 * MIPS Technologies reserves the right to change this code to improve
 * function, design or otherwise. MIPS Technologies does not assume any
 * liability arising out of the application or use of this code, or of
 * any error or omission in such code.  Any warranties, whether express,
 * statutory, implied or otherwise, including but not limited to the
 * implied warranties of merchantability or fitness for a particular
 * purpose, are excluded.  Except as expressly provided in any written
 * license agreement from MIPS Technologies, the furnishing of this
 * code does not give recipient any license to any intellectual property
 * rights, including any patent rights, that cover this code.
 * 
 * This code shall not be exported, reexported, transferred, or released,
 * directly or indirectly, in violation of the law of any country or
 * international law, regulation, treaty, Executive Order, statute,
 * amendments or supplements thereto.  Should a conflict arise regarding
 * the export, reexport, transfer, or release of this code, the laws of
 * the United States of America shall be the governing law.
 * 
 * This code may only be disclosed to the United States government
 * ("Government"), or to Government users, with prior written consent
 * from MIPS Technologies.  This code constitutes one or more of the
 * following: commercial computer software, commercial computer software
 * documentation or other commercial items.  If the user of this code,
 * or any related documentation of any kind, including related technical
 * data or manuals, is an agency, department, or other entity of the
 * Government, the use, duplication, reproduction, release, modification,
 * disclosure, or transfer of this code, or any related documentation
 * of any kind, is restricted in accordance with Federal Acquisition
 * Regulation 12.212 for civilian agencies and Defense Federal Acquisition
 * Regulation Supplement 227.7202 for military agencies.  The use of this
 * code by the Government is further restricted in accordance with the
 * terms of the license agreement(s) and/or applicable contract terms
 * and conditions covering this code from MIPS Technologies.
 * 
 * 
 */

/* 
 * Pthreads stubs 
 */

#include <sys/cdefs.h>
#include <pthread.h>
#include <libc_thread.h>

#pragma weak __isthreaded
int __isthreaded = 0;

WEAK_ALIAS(pthread_mutex_init);
WEAK_PROTOTYPE(pthread_mutex_init);
int
WEAK_NAME(pthread_mutex_init) (pthread_mutex_t *mx,
			       const pthread_mutexattr_t *mxa)
{
  return 0;
}

WEAK_ALIAS(pthread_mutex_destroy);
WEAK_PROTOTYPE(pthread_mutex_destroy);
int
WEAK_NAME(pthread_mutex_destroy) (pthread_mutex_t *mx)
{
  return 0;
}

WEAK_ALIAS(pthread_mutex_lock);
WEAK_PROTOTYPE(pthread_mutex_lock);
int
WEAK_NAME(pthread_mutex_lock) (pthread_mutex_t *mx)
{
  return 0;
}

WEAK_ALIAS(pthread_mutex_trylock);
WEAK_PROTOTYPE(pthread_mutex_trylock);
int
WEAK_NAME(pthread_mutex_trylock) (pthread_mutex_t *mx)
{
  return 0;
}

WEAK_ALIAS(pthread_mutex_unlock);
WEAK_PROTOTYPE(pthread_mutex_unlock);
int
WEAK_NAME(pthread_mutex_unlock) (pthread_mutex_t *mx)
{
  return 0;
}

WEAK_ALIAS(pthread_mutex_setname_np);
WEAK_PROTOTYPE(pthread_mutex_setname_np);
int
WEAK_NAME(pthread_mutex_setname_np) (pthread_mutex_t *mx, const char *name)
{
  return 0;
}

WEAK_ALIAS(pthread_mutexattr_init);
WEAK_PROTOTYPE(pthread_mutexattr_init);
int
WEAK_NAME(pthread_mutexattr_init) (pthread_mutexattr_t *mxa)
{
  return 0;
}

WEAK_ALIAS(pthread_mutexattr_destroy);
WEAK_PROTOTYPE(pthread_mutexattr_destroy);
int
WEAK_NAME(pthread_mutexattr_destroy) (pthread_mutexattr_t *mxa)
{
  return 0;
}

WEAK_ALIAS(pthread_mutexattr_setname_np);
WEAK_PROTOTYPE(pthread_mutexattr_setname_np);
int
WEAK_NAME(pthread_mutexattr_setname_np) (pthread_mutexattr_t *mxa, 
					  const char *name)
{
  return 0;
}

WEAK_ALIAS(pthread_mutexattr_settype_np);
WEAK_PROTOTYPE(pthread_mutexattr_settype_np);
int
WEAK_NAME(pthread_mutexattr_settype_np) (pthread_mutexattr_t *mxa, int type)
{
  return 0;
}

WEAK_ALIAS(pthread_sysconf_np);
WEAK_PROTOTYPE(pthread_sysconf_np);
long
WEAK_NAME(pthread_sysconf_np) (int name)
{
    return -1;
}

WEAK_ALIAS(pthread_sigdisable_np);
WEAK_PROTOTYPE(pthread_sigdisable_np);
void
WEAK_NAME(pthread_sigdisable_np) (pthread_sigstate_np_t *state) 
{
}


WEAK_ALIAS(pthread_sigrestore_np);
WEAK_PROTOTYPE(pthread_sigrestore_np);
void
WEAK_NAME(pthread_sigrestore_np) (const pthread_sigstate_np_t *state) 
{
}

WEAK_ALIAS(_pthread_cleanup_push);
WEAK_PROTOTYPE(_pthread_cleanup_push);
void
WEAK_NAME(_pthread_cleanup_push) (struct _pthread_handler_rec *rec)
{
}

WEAK_ALIAS(_pthread_cleanup_pop);
WEAK_PROTOTYPE(_pthread_cleanup_pop);
void
WEAK_NAME(_pthread_cleanup_pop) (struct _pthread_handler_rec *rec)
{
}

WEAK_ALIAS(_pthread_cleanup_push_defer);
WEAK_PROTOTYPE(_pthread_cleanup_push_defer);
void
WEAK_NAME(_pthread_cleanup_push_defer) (struct _pthread_handler_rec *rec)
{
}

WEAK_ALIAS(_pthread_cleanup_pop_restore);
WEAK_PROTOTYPE(_pthread_cleanup_pop_restore);
void
WEAK_NAME(_pthread_cleanup_pop_restore) (struct _pthread_handler_rec *rec)
{
}

#include <stdio.h>

__weak_alias(_pthread_once, WEAK_NAME(pthread_once));
WEAK_ALIAS(pthread_once);
WEAK_PROTOTYPE(pthread_once);
int
WEAK_NAME(pthread_once) (pthread_once_t *once, void (*fn)(void))
{
    if (once->state == PTHREAD_ONCE_NEVER) {
	once->state = PTHREAD_ONCE_DONE;
	(*fn) ();
    }
    return 0;
}

WEAK_ALIAS(pthread_key_create);
WEAK_PROTOTYPE(pthread_key_create);
int
WEAK_NAME(pthread_key_create) (pthread_key_t *keyp, void (*dtor)(void *))
{ 
    return -1;
}

WEAK_ALIAS(pthread_setspecific);
WEAK_PROTOTYPE(pthread_setspecific);
int
WEAK_NAME(pthread_setspecific) (pthread_key_t key, const void *val)
{
    return -1;
}

WEAK_ALIAS(pthread_getspecific);
WEAK_PROTOTYPE(pthread_getspecific);
void * 
WEAK_NAME(pthread_getspecific) (pthread_key_t key)
{
    return NULL;
}


WEAK_ALIAS(_libc_private_storage);
WEAK_PROTOTYPE(_libc_private_storage);
void *
WEAK_NAME(_libc_private_storage)(struct _thread_private_key_struct *key,
				 void *storage, size_t size, void *err)
{
    return storage;
}

#include <unistd.h>


#include <errno.h>


#include <sys/wait.h>

