uu_misc.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include "libuutil_common.h"
#include <assert.h>
#include <errno.h>
#include <libintl.h>
#include <pthread.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <thread.h>
#include <unistd.h>
#if !defined(TEXT_DOMAIN)
#define TEXT_DOMAIN "SYS_TEST"
#endif
static pthread_key_t uu_error_key;
static int uu_error_key_setup;
/* LINTED static unused */
static const char *uu_panic_format;
/* LINTED static unused */
static va_list uu_panic_args;
static pthread_t uu_panic_thread;
static uint32_t _uu_main_error;
void
{
int error;
if (thr_main() != 0) {
return;
}
if (uu_error_key_setup == 0) {
(void) pthread_mutex_lock(&uu_key_lock);
if (uu_error_key_setup == 0) {
if (error != 0)
uu_error_key_setup = -1;
else
uu_error_key_setup = 1;
}
(void) pthread_mutex_unlock(&uu_key_lock);
}
if (uu_error_key_setup > 0)
(void) pthread_setspecific(uu_error_key,
}
uu_error(void)
{
if (thr_main() != 0)
return (_uu_main_error);
if (uu_error_key_setup < 0)
return (UU_ERROR_UNKNOWN);
else if (uu_error_key_setup == 0)
return (UU_ERROR_NONE);
else
}
const char *
{
const char *str;
switch (code) {
case UU_ERROR_NONE:
break;
break;
case UU_ERROR_UNKNOWN_FLAG:
break;
case UU_ERROR_NO_MEMORY:
break;
case UU_ERROR_CALLBACK_FAILED:
break;
case UU_ERROR_NOT_SUPPORTED:
break;
case UU_ERROR_EMPTY:
break;
case UU_ERROR_UNDERFLOW:
break;
case UU_ERROR_OVERFLOW:
break;
case UU_ERROR_INVALID_CHAR:
"Value contains unexpected character");
break;
case UU_ERROR_INVALID_DIGIT:
"Value contains digit not in base");
break;
case UU_ERROR_SYSTEM:
break;
case UU_ERROR_UNKNOWN:
break;
default:
break;
}
return (str);
}
void
{
(void) pthread_mutex_lock(&uu_panic_lock);
if (uu_panic_thread == 0) {
}
(void) pthread_mutex_unlock(&uu_panic_lock);
if (uu_panic_thread == pthread_self())
abort();
else
for (;;)
(void) pause();
}
int
{
/*NOTREACHED*/
return (0);
}
static void
uu_lockup(void)
{
(void) pthread_mutex_lock(&uu_panic_lock);
(void) pthread_mutex_lock(&uu_key_lock);
}
static void
uu_release(void)
{
(void) pthread_mutex_unlock(&uu_panic_lock);
(void) pthread_mutex_unlock(&uu_key_lock);
}
static void
uu_release_child(void)
{
uu_panic_thread = 0;
uu_release();
}
static void
uu_init(void)
{
}