1*56b2bdd1SGireesh Nagabhushana /* 2*56b2bdd1SGireesh Nagabhushana * This file and its contents are supplied under the terms of the 3*56b2bdd1SGireesh Nagabhushana * Common Development and Distribution License ("CDDL"), version 1.0. 4*56b2bdd1SGireesh Nagabhushana * You may only use this file in accordance with the terms of version 5*56b2bdd1SGireesh Nagabhushana * 1.0 of the CDDL. 6*56b2bdd1SGireesh Nagabhushana * 7*56b2bdd1SGireesh Nagabhushana * A full copy of the text of the CDDL should have accompanied this 8*56b2bdd1SGireesh Nagabhushana * source. A copy of the CDDL is also available via the Internet at 9*56b2bdd1SGireesh Nagabhushana * http://www.illumos.org/license/CDDL. 10*56b2bdd1SGireesh Nagabhushana */ 11*56b2bdd1SGireesh Nagabhushana 12*56b2bdd1SGireesh Nagabhushana /* 13*56b2bdd1SGireesh Nagabhushana * This file is part of the Chelsio T4 support code. 14*56b2bdd1SGireesh Nagabhushana * 15*56b2bdd1SGireesh Nagabhushana * Copyright (C) 2010-2013 Chelsio Communications. All rights reserved. 16*56b2bdd1SGireesh Nagabhushana * 17*56b2bdd1SGireesh Nagabhushana * This program is distributed in the hope that it will be useful, but WITHOUT 18*56b2bdd1SGireesh Nagabhushana * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 19*56b2bdd1SGireesh Nagabhushana * FITNESS FOR A PARTICULAR PURPOSE. See the LICENSE file included in this 20*56b2bdd1SGireesh Nagabhushana * release for licensing terms and conditions. 21*56b2bdd1SGireesh Nagabhushana */ 22*56b2bdd1SGireesh Nagabhushana 23*56b2bdd1SGireesh Nagabhushana #include "common.h" 24*56b2bdd1SGireesh Nagabhushana #include "osdep.h" 25*56b2bdd1SGireesh Nagabhushana 26*56b2bdd1SGireesh Nagabhushana int ilog2(long x)27*56b2bdd1SGireesh Nagabhushanailog2(long x) 28*56b2bdd1SGireesh Nagabhushana { 29*56b2bdd1SGireesh Nagabhushana return (ddi_fls(x) - 1); 30*56b2bdd1SGireesh Nagabhushana } 31*56b2bdd1SGireesh Nagabhushana 32*56b2bdd1SGireesh Nagabhushana unsigned char * strstrip(unsigned char * s)33*56b2bdd1SGireesh Nagabhushanastrstrip(unsigned char *s) 34*56b2bdd1SGireesh Nagabhushana { 35*56b2bdd1SGireesh Nagabhushana unsigned char c, *r, *trim_at; 36*56b2bdd1SGireesh Nagabhushana 37*56b2bdd1SGireesh Nagabhushana while (isspace(*s)) 38*56b2bdd1SGireesh Nagabhushana s++; 39*56b2bdd1SGireesh Nagabhushana r = trim_at = s; 40*56b2bdd1SGireesh Nagabhushana 41*56b2bdd1SGireesh Nagabhushana while ((c = *s++) != 0) { 42*56b2bdd1SGireesh Nagabhushana if (!isspace(c)) 43*56b2bdd1SGireesh Nagabhushana trim_at = s; 44*56b2bdd1SGireesh Nagabhushana } 45*56b2bdd1SGireesh Nagabhushana *trim_at = 0; 46*56b2bdd1SGireesh Nagabhushana 47*56b2bdd1SGireesh Nagabhushana return (r); 48*56b2bdd1SGireesh Nagabhushana } 49