/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (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
*/
/*
*/
#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>
#include <ctype.h>
#if !defined(TEXT_DOMAIN)
#endif
/*
* All of the old code under !defined(PTHREAD_ONCE_KEY_NP)
* is here to enable the building of a native version of
* libuutil.so when the build machine has not yet been upgraded
* to a version of libc that provides pthread_key_create_once_np().
* It should all be deleted when solaris_nevada ships.
* The code is not MT-safe in a relaxed memory model.
*/
#if defined(PTHREAD_ONCE_KEY_NP)
#else /* PTHREAD_ONCE_KEY_NP */
#endif /* PTHREAD_ONCE_KEY_NP */
static int uu_error_key_setup = 0;
/* LINTED static unused */
static const char *uu_panic_format;
/* LINTED static unused */
void
{
if (thr_main() != 0) {
return;
}
#if defined(PTHREAD_ONCE_KEY_NP)
uu_error_key_setup = -1;
else
uu_error_key_setup = 1;
#else /* PTHREAD_ONCE_KEY_NP */
if (uu_error_key_setup == 0) {
(void) pthread_mutex_lock(&uu_key_lock);
if (uu_error_key_setup == 0) {
uu_error_key_setup = -1;
else
uu_error_key_setup = 1;
}
(void) pthread_mutex_unlock(&uu_key_lock);
}
#endif /* PTHREAD_ONCE_KEY_NP */
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) /* can't happen? */
return (UU_ERROR_UNKNOWN);
/*
* Because UU_ERROR_NONE == 0, if uu_set_error() was
* never called, then this will return UU_ERROR_NONE:
*/
}
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);
#if !defined(PTHREAD_ONCE_KEY_NP)
(void) pthread_mutex_lock(&uu_key_lock);
#endif
}
static void
uu_release(void)
{
(void) pthread_mutex_unlock(&uu_panic_lock);
#if !defined(PTHREAD_ONCE_KEY_NP)
(void) pthread_mutex_unlock(&uu_key_lock);
#endif
}
static void
uu_release_child(void)
{
uu_panic_thread = 0;
uu_release();
}
static void
uu_init(void)
{
}
/*
* Dump a block of memory in hex+ascii, for debugging
*/
void
{
const unsigned char *p = buf;
int i;
for (i = 0; i < len; i += 16) {
int j;
for (j = 0; j < 16 && i + j < len; j++) {
}
for (; j < 16; j++) {
}
for (j = 0; j < 16 && i + j < len; j++) {
isprint(p[i + j]) ? p[i + j] : '.');
}
}
}