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