1 /* Copyright (c) 2017  SiFive Inc. All rights reserved.
2 
3    This copyrighted material is made available to anyone wishing to use,
4    modify, copy, or redistribute it subject to the terms and conditions
5    of the FreeBSD License.   This program is distributed in the hope that
6    it will be useful, but WITHOUT ANY WARRANTY expressed or implied,
7    including the implied warranties of MERCHANTABILITY or FITNESS FOR
8    A PARTICULAR PURPOSE.  A copy of this license is available at
9    http://www.opensource.org/licenses.
10 */
11 
12 #ifndef _SYS_STRING_H
13 #define _SYS_STRING_H
14 
__libc_detect_null(unsigned long w)15 static __inline unsigned long __libc_detect_null(unsigned long w)
16 {
17   unsigned long mask = 0x7f7f7f7f;
18   if (sizeof (long) == 8)
19     mask = ((mask << 16) << 16) | mask;
20   return ~(((w & mask) + mask) | w | mask);
21 }
22 
23 #endif
24