9c6ee729d6
GitOrigin-RevId: 6cee3b5893090b0f5f0a06b4cf42ca4e60e5d222
53 lines
1.9 KiB
C
53 lines
1.9 KiB
C
/*
|
|
Copyright © 2005-2019 Rich Felker, et al.
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining
|
|
a copy of this software and associated documentation files (the
|
|
"Software"), to deal in the Software without restriction, including
|
|
without limitation the rights to use, copy, modify, merge, publish,
|
|
distribute, sublicense, and/or sell copies of the Software, and to
|
|
permit persons to whom the Software is furnished to do so, subject to
|
|
the following conditions:
|
|
|
|
The above copyright notice and this permission notice shall be
|
|
included in all copies or substantial portions of the Software.
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
*/
|
|
|
|
// Additional utilities from musl 1.1.24
|
|
|
|
// include/stdlib.h
|
|
#define WEXITSTATUS(s) (((s) & 0xff00) >> 8)
|
|
#define WTERMSIG(s) ((s) & 0x7f)
|
|
#define WIFEXITED(s) (!WTERMSIG(s))
|
|
#define WIFSIGNALED(s) (((s)&0xffff)-1U < 0xffu)
|
|
|
|
// include/sys/sysmacros.h
|
|
#define major(x) \
|
|
((unsigned)( (((x)>>31>>1) & 0xfffff000) | (((x)>>8) & 0x00000fff) ))
|
|
#define minor(x) \
|
|
((unsigned)( (((x)>>12) & 0xffffff00) | ((x) & 0x000000ff) ))
|
|
#define makedev(x,y) ( \
|
|
(((x)&0xfffff000ULL) << 32) | \
|
|
(((x)&0x00000fffULL) << 8) | \
|
|
(((y)&0xffffff00ULL) << 12) | \
|
|
(((y)&0x000000ffULL)) )
|
|
|
|
// src/misc/basename.c
|
|
#include <string.h>
|
|
char *basename(char *s)
|
|
{
|
|
size_t i;
|
|
if (!s || !*s) return ".";
|
|
i = strlen(s)-1;
|
|
for (; i&&s[i]=='/'; i--) s[i] = 0;
|
|
for (; i&&s[i-1]!='/'; i--);
|
|
return s+i;
|
|
}
|