ac88567a7a5bb7f01cf22cf366bc9d6203e24d7aHyon Kim * CDDL HEADER START
ac88567a7a5bb7f01cf22cf366bc9d6203e24d7aHyon Kim * The contents of this file are subject to the terms of the
ac88567a7a5bb7f01cf22cf366bc9d6203e24d7aHyon Kim * Common Development and Distribution License (the "License").
ac88567a7a5bb7f01cf22cf366bc9d6203e24d7aHyon Kim * You may not use this file except in compliance with the License.
ac88567a7a5bb7f01cf22cf366bc9d6203e24d7aHyon Kim * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
ac88567a7a5bb7f01cf22cf366bc9d6203e24d7aHyon Kim * See the License for the specific language governing permissions
ac88567a7a5bb7f01cf22cf366bc9d6203e24d7aHyon Kim * and limitations under the License.
ac88567a7a5bb7f01cf22cf366bc9d6203e24d7aHyon Kim * When distributing Covered Code, include this CDDL HEADER in each
ac88567a7a5bb7f01cf22cf366bc9d6203e24d7aHyon Kim * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
ac88567a7a5bb7f01cf22cf366bc9d6203e24d7aHyon Kim * If applicable, add the following below this CDDL HEADER, with the
ac88567a7a5bb7f01cf22cf366bc9d6203e24d7aHyon Kim * fields enclosed by brackets "[]" replaced with your own identifying
ac88567a7a5bb7f01cf22cf366bc9d6203e24d7aHyon Kim * information: Portions Copyright [yyyy] [name of copyright owner]
ac88567a7a5bb7f01cf22cf366bc9d6203e24d7aHyon Kim * CDDL HEADER END
ac88567a7a5bb7f01cf22cf366bc9d6203e24d7aHyon Kim * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
ac88567a7a5bb7f01cf22cf366bc9d6203e24d7aHyon Kimsmp_assert(const char *expr, const char *file, int line)
ac88567a7a5bb7f01cf22cf366bc9d6203e24d7aHyon Kim "ABORT: \"%s\", line %d: assertion failed: %s\n", file, line, expr);
ac88567a7a5bb7f01cf22cf366bc9d6203e24d7aHyon Kim "ABORT: \"%s\", line %d: assertion failed: %s\n", file, line, expr);
ac88567a7a5bb7f01cf22cf366bc9d6203e24d7aHyon Kim /*NOTREACHED*/
ac88567a7a5bb7f01cf22cf366bc9d6203e24d7aHyon Kim return (0);
ac88567a7a5bb7f01cf22cf366bc9d6203e24d7aHyon Kim return (-1);
ac88567a7a5bb7f01cf22cf366bc9d6203e24d7aHyon Kim * Internal routine for setting both _smp_errno and _smp_errmsg. We save
ac88567a7a5bb7f01cf22cf366bc9d6203e24d7aHyon Kim * and restore the UNIX errno across this routing so the caller can use either
ac88567a7a5bb7f01cf22cf366bc9d6203e24d7aHyon Kim * smp_set_errno(), smp_error(), or smp_verror() without this value changing.
ac88567a7a5bb7f01cf22cf366bc9d6203e24d7aHyon Kimsmp_verror(smp_errno_t err, const char *fmt, va_list ap)
ac88567a7a5bb7f01cf22cf366bc9d6203e24d7aHyon Kim * To allow the existing error message to itself be used in an error
ac88567a7a5bb7f01cf22cf366bc9d6203e24d7aHyon Kim * message, we put the new error message into a buffer on the stack,
ac88567a7a5bb7f01cf22cf366bc9d6203e24d7aHyon Kim * and then copy it into lsh_errmsg. We also need to set the errno,
ac88567a7a5bb7f01cf22cf366bc9d6203e24d7aHyon Kim * but because the call to smp_set_errno() is destructive to
ac88567a7a5bb7f01cf22cf366bc9d6203e24d7aHyon Kim * lsh_errmsg, we do this after we print into our temporary buffer
ac88567a7a5bb7f01cf22cf366bc9d6203e24d7aHyon Kim * (in case _smp_errmsg is part of the error message) and before we
ac88567a7a5bb7f01cf22cf366bc9d6203e24d7aHyon Kim * copy the temporary buffer on to _smp_errmsg (to prevent our new
ac88567a7a5bb7f01cf22cf366bc9d6203e24d7aHyon Kim * message from being nuked by the call to smp_set_errno()).
ac88567a7a5bb7f01cf22cf366bc9d6203e24d7aHyon Kim (void) vsnprintf(errmsg, sizeof (_smp_errmsg), fmt, ap);
ac88567a7a5bb7f01cf22cf366bc9d6203e24d7aHyon Kim return (-1);
ac88567a7a5bb7f01cf22cf366bc9d6203e24d7aHyon Kimconst char *
ac88567a7a5bb7f01cf22cf366bc9d6203e24d7aHyon Kim (void) strlcpy(_smp_errmsg, smp_strerror(_smp_errno),
ac88567a7a5bb7f01cf22cf366bc9d6203e24d7aHyon Kim/*ARGSUSED*/
ac88567a7a5bb7f01cf22cf366bc9d6203e24d7aHyon Kim if (size == 0) {
ac88567a7a5bb7f01cf22cf366bc9d6203e24d7aHyon Kim * Trim any leading and/or trailing spaces from the fixed-length string
ac88567a7a5bb7f01cf22cf366bc9d6203e24d7aHyon Kim * argument and return a newly-allocated copy of it.
ac88567a7a5bb7f01cf22cf366bc9d6203e24d7aHyon Kim const char *p;
ac88567a7a5bb7f01cf22cf366bc9d6203e24d7aHyon Kim for (str = p + len - 1; str > p && isspace(*str); str--, len--)
ac88567a7a5bb7f01cf22cf366bc9d6203e24d7aHyon Kim return (r);
ac88567a7a5bb7f01cf22cf366bc9d6203e24d7aHyon Kim "library version %d does not match requested version %d",
ac88567a7a5bb7f01cf22cf366bc9d6203e24d7aHyon Kim return (0);