Mercurial > illumos > illumos-gate
view usr/src/lib/fm/topo/libtopo/common/mkerror.sh @ 3681:d93cfde2f771
6519375 refactored the mdesc code in cpu scheme, platform-cpu.so and chip.so into a single code base
6520142 sun4v motherboard/chip enums leaking memory
6520501 libtopo exports a set of errors associated with node methods
author | vn83148 |
---|---|
date | Mon, 19 Feb 2007 20:47:33 -0800 |
parents | 6338278a5e69 |
children | b986877655d2 |
line wrap: on
line source
#!/bin/sh # # 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 # or http://www.opensolaris.org/os/licensing. # 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 2007 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # #ident "@(#)mkerror.sh 1.1 06/02/11 SMI" #pragma ident "%Z%%M% %I% %E% SMI" input="`cat`" [ -z "$input" ] && exit 1 if [ $1 = "liberrors" ] ; then echo "\ /*\n\ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.\n\ * Use is subject to license terms.\n\ */\n\ \n\ #pragma ident\t\"@(#)mkerror.sh\t1.2\t05/06/08 SMI\"\n\ \n\ #include <strings.h> #include <topo_error.h> #include <topo_mod.h> \n\ static const char *const _topo_errstrs[] = {" pattern='^[ ]*ETOPO_[A-Z0-9_]*.*\* \(.*\) \*.*' replace=' "\1",' echo "$input" | sed -n "s/$pattern/$replace/p" || exit 1 echo "\ };\n\ \n\ static const int _topo_nerrstrs =\n\ sizeof (_topo_errstrs) / sizeof (_topo_errstrs[0]);\n\ \n\ int topo_hdl_errno(topo_hdl_t *thp) { return (thp->th_errno); } int topo_hdl_seterrno(topo_hdl_t *thp, int err) { thp->th_errno = err; return (-1); } const char * topo_hdl_errmsg(topo_hdl_t *thp) { return (topo_strerror(thp->th_errno)); }" elif [ $1 = "properrors" ] ; then echo "\ \n\ static const char *const _topo_properrstrs[] = {" pattern='^[ ]*ETOPO_PROP_[A-Z0-9_]*.*\* \(.*\) \*.*' replace=' "\1",' echo "$input" | sed -n "s/$pattern/$replace/p" || exit 1 echo "\ };\n\ \n\ static const int _topo_nproperrstrs =\n\ sizeof (_topo_properrstrs) / sizeof (_topo_properrstrs[0]);" elif [ $1 = "methoderrors" ] ; then echo "\ \n\ static const char *const _topo_methoderrstrs[] = {" pattern='^[ ]*ETOPO_METHOD_[A-Z0-9_]*.*\* \(.*\) \*.*' replace=' "\1",' echo "$input" | sed -n "s/$pattern/$replace/p" || exit 1 echo "\ };\n\ \n\ static const int _topo_nmethoderrstrs =\n\ sizeof (_topo_methoderrstrs) / sizeof (_topo_methoderrstrs[0]);" else echo "\ \n\ static const char *const _topo_moderrstrs[] = {" pattern='^[ ]*EMOD_[A-Z0-9_]*.*\* \(.*\) \*.*' replace=' "\1",' echo "$input" | sed -n "s/$pattern/$replace/p" || exit 1 echo "\ };\n\ static const int _topo_nmoderrstrs =\n\ sizeof (_topo_moderrstrs) / sizeof (_topo_moderrstrs[0]);\n\ \n\ int topo_mod_errno(topo_mod_t *mp) { return (mp->tm_errno); } int topo_mod_seterrno(topo_mod_t *mp, int err) { mp->tm_errno = err; return (-1); } const char * topo_mod_errmsg(topo_mod_t *mp) { return (topo_strerror(mp->tm_errno)); } const char * topo_strerror(int err) { const char *s; if (err >= ETOPO_UNKNOWN && (err - ETOPO_UNKNOWN) < _topo_nerrstrs) s = _topo_errstrs[err - ETOPO_UNKNOWN]; else if (err >= EMOD_UNKNOWN && (err - EMOD_UNKNOWN) < _topo_nmoderrstrs) s = _topo_moderrstrs[err - EMOD_UNKNOWN]; else if (err >= ETOPO_PROP_UNKNOWN && (err - ETOPO_PROP_UNKNOWN) < _topo_nproperrstrs) s = _topo_properrstrs[err - ETOPO_PROP_UNKNOWN]; else if (err >= ETOPO_METHOD_UNKNOWN && (err - ETOPO_METHOD_UNKNOWN) < _topo_nmethoderrstrs) s = _topo_methoderrstrs[err - ETOPO_METHOD_UNKNOWN]; else s = _topo_errstrs[0]; return (s); }" fi exit 0