[refactor] replace system libc with local libc
This commit is contained in:
parent
27447f528c
commit
f0cf9ffcf8
290
bsp/bsp_common/platform/syscalls.c
Normal file
290
bsp/bsp_common/platform/syscalls.c
Normal file
@ -0,0 +1,290 @@
|
|||||||
|
#include <reent.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include "drv_mmheap.h"
|
||||||
|
#include "drv_device.h"
|
||||||
|
|
||||||
|
#ifdef CONF_VFS_ENABLE
|
||||||
|
#include <vfs.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Reentrant versions of system calls. */
|
||||||
|
|
||||||
|
/* global errno in RT-Thread */
|
||||||
|
static volatile int _sys_errno = 0;
|
||||||
|
|
||||||
|
#ifndef _REENT_ONLY
|
||||||
|
int *__errno()
|
||||||
|
{
|
||||||
|
// #if (configUSE_POSIX_ERRNO == 1)
|
||||||
|
// {
|
||||||
|
// extern int FreeRTOS_errno;
|
||||||
|
|
||||||
|
// return &FreeRTOS_errno;
|
||||||
|
// }
|
||||||
|
// #endif
|
||||||
|
return (int *)&_sys_errno;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int _getpid_r(struct _reent *ptr)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int _execve_r(struct _reent *ptr, const char *name, char *const *argv, char *const *env)
|
||||||
|
{
|
||||||
|
/* return "not supported" */
|
||||||
|
ptr->_errno = -ENOSYS;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int _fcntl_r(struct _reent *ptr, int fd, int cmd, int arg)
|
||||||
|
{
|
||||||
|
/* return "not supported" */
|
||||||
|
ptr->_errno = -ENOSYS;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int _fork_r(struct _reent *ptr)
|
||||||
|
{
|
||||||
|
/* return "not supported" */
|
||||||
|
ptr->_errno = -ENOSYS;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int _fstat_r(struct _reent *ptr, int fd, struct stat *pstat)
|
||||||
|
{
|
||||||
|
/* return "not supported" */
|
||||||
|
ptr->_errno = -ENOSYS;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int _isatty_r(struct _reent *ptr, int fd)
|
||||||
|
{
|
||||||
|
/* return "not supported" */
|
||||||
|
ptr->_errno = -ENOSYS;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int _kill_r(struct _reent *ptr, int pid, int sig)
|
||||||
|
{
|
||||||
|
/* return "not supported" */
|
||||||
|
ptr->_errno = -ENOSYS;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int _link_r(struct _reent *ptr, const char *old, const char *new)
|
||||||
|
{
|
||||||
|
/* return "not supported" */
|
||||||
|
ptr->_errno = -ENOSYS;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
_off_t _lseek_r(struct _reent *ptr, int fd, _off_t pos, int whence)
|
||||||
|
{
|
||||||
|
#ifndef CONF_VFS_ENABLE
|
||||||
|
/* return "not supported" */
|
||||||
|
ptr->_errno = -ENOSYS;
|
||||||
|
return -1;
|
||||||
|
#else
|
||||||
|
_off_t rc;
|
||||||
|
|
||||||
|
rc = aos_lseek(fd, pos, whence);
|
||||||
|
return rc;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
int _mkdir_r(struct _reent *ptr, const char *name, int mode)
|
||||||
|
{
|
||||||
|
#ifndef CONF_VFS_ENABLE
|
||||||
|
/* return "not supported" */
|
||||||
|
ptr->_errno = -ENOSYS;
|
||||||
|
return -1;
|
||||||
|
#else
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
rc = aos_mkdir(name);
|
||||||
|
return rc;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
int _open_r(struct _reent *ptr, const char *file, int flags, int mode)
|
||||||
|
{
|
||||||
|
#ifndef CONF_VFS_ENABLE
|
||||||
|
/* return "not supported" */
|
||||||
|
ptr->_errno = -ENOSYS;
|
||||||
|
return -1;
|
||||||
|
#else
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
rc = aos_open(file, flags);
|
||||||
|
return rc;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
int _close_r(struct _reent *ptr, int fd)
|
||||||
|
{
|
||||||
|
#ifndef CONF_VFS_ENABLE
|
||||||
|
/* return "not supported" */
|
||||||
|
ptr->_errno = -ENOSYS;
|
||||||
|
return -1;
|
||||||
|
#else
|
||||||
|
return aos_close(fd);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
_ssize_t _read_r(struct _reent *ptr, int fd, void *buf, size_t nbytes)
|
||||||
|
{
|
||||||
|
#ifndef CONF_VFS_ENABLE
|
||||||
|
/* return "not supported" */
|
||||||
|
ptr->_errno = -ENOSYS;
|
||||||
|
return -1;
|
||||||
|
#else
|
||||||
|
_ssize_t rc;
|
||||||
|
|
||||||
|
rc = aos_read(fd, buf, nbytes);
|
||||||
|
return rc;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
int _rename_r(struct _reent *ptr, const char *old, const char *new)
|
||||||
|
{
|
||||||
|
#ifndef CONF_VFS_ENABLE
|
||||||
|
/* return "not supported" */
|
||||||
|
ptr->_errno = -ENOSYS;
|
||||||
|
return -1;
|
||||||
|
#else
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
rc = aos_rename(old, new);
|
||||||
|
return rc;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
int _stat_r(struct _reent *ptr, const char *file, struct stat *pstat)
|
||||||
|
{
|
||||||
|
#ifndef CONF_VFS_ENABLE
|
||||||
|
/* return "not supported" */
|
||||||
|
ptr->_errno = -ENOSYS;
|
||||||
|
return -1;
|
||||||
|
#else
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
rc = aos_stat(file, pstat);
|
||||||
|
return rc;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
int _unlink_r(struct _reent *ptr, const char *file)
|
||||||
|
{
|
||||||
|
#ifndef CONF_VFS_ENABLE
|
||||||
|
/* return "not supported" */
|
||||||
|
ptr->_errno = -ENOSYS;
|
||||||
|
return -1;
|
||||||
|
#else
|
||||||
|
return aos_unlink(file);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
int _wait_r(struct _reent *ptr, int *status)
|
||||||
|
{
|
||||||
|
/* return "not supported" */
|
||||||
|
ptr->_errno = -ENOSYS;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
_ssize_t _write_r(struct _reent *ptr, int fd, const void *buf, size_t nbytes)
|
||||||
|
{
|
||||||
|
#ifndef CONF_VFS_ENABLE
|
||||||
|
struct device *uart = device_find("debug_log");
|
||||||
|
if ((STDOUT_FILENO == fd) || (STDERR_FILENO == fd)) {
|
||||||
|
device_write(uart, 0, (uint8_t *)buf, nbytes);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
#else
|
||||||
|
_ssize_t rc;
|
||||||
|
|
||||||
|
rc = aos_write(fd, buf, nbytes);
|
||||||
|
return rc;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void *_malloc_r(struct _reent *ptr, size_t size)
|
||||||
|
{
|
||||||
|
void *result;
|
||||||
|
|
||||||
|
result = (void *)mmheap_alloc(size);
|
||||||
|
if (result == NULL) {
|
||||||
|
ptr->_errno = -ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
void *_realloc_r(struct _reent *ptr, void *old, size_t newlen)
|
||||||
|
{
|
||||||
|
void *result;
|
||||||
|
|
||||||
|
result = (void *)mmheap_realloc(old, newlen);
|
||||||
|
if (result == NULL) {
|
||||||
|
ptr->_errno = -ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
void *_calloc_r(struct _reent *ptr, size_t size, size_t len)
|
||||||
|
{
|
||||||
|
void *result;
|
||||||
|
|
||||||
|
result = (void *)mmheap_calloc(size, len);
|
||||||
|
if (result == NULL) {
|
||||||
|
ptr->_errno = -ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
void _free_r(struct _reent *ptr, void *addr)
|
||||||
|
{
|
||||||
|
mmheap_free(addr);
|
||||||
|
}
|
||||||
|
|
||||||
|
void *_sbrk_r(struct _reent *ptr, ptrdiff_t incr)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* for exit() and abort() */
|
||||||
|
void __attribute__((noreturn))
|
||||||
|
_exit(int status)
|
||||||
|
{
|
||||||
|
while (1) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _system(const char *s)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void __libc_init_array(void)
|
||||||
|
{
|
||||||
|
/* we not use __libc init_aray to initialize C++ objects */
|
||||||
|
}
|
||||||
|
|
||||||
|
mode_t umask(mode_t mask)
|
||||||
|
{
|
||||||
|
return 022;
|
||||||
|
}
|
||||||
|
|
||||||
|
int flock(int fd, int operation)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
These functions are implemented and replaced by the 'common/time.c' file
|
||||||
|
int _gettimeofday_r(struct _reent *ptr, struct timeval *__tp, void *__tzp);
|
||||||
|
_CLOCK_T_ _times_r(struct _reent *ptr, struct tms *ptms);
|
||||||
|
*/
|
@ -1,12 +1,12 @@
|
|||||||
################# Add global include #################
|
################# Add global include #################
|
||||||
list(APPEND ADD_INCLUDE
|
list(APPEND ADD_INCLUDE
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/libc/inc"
|
# "${CMAKE_CURRENT_SOURCE_DIR}/libc/inc"
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/ring_buffer"
|
"${CMAKE_CURRENT_SOURCE_DIR}/ring_buffer"
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/soft_crc"
|
"${CMAKE_CURRENT_SOURCE_DIR}/soft_crc"
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/memheap"
|
"${CMAKE_CURRENT_SOURCE_DIR}/memheap"
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/libc/inc/arm_gcc"
|
# "${CMAKE_CURRENT_SOURCE_DIR}/libc/inc/arm_gcc"
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/libc/inc/bits"
|
# "${CMAKE_CURRENT_SOURCE_DIR}/libc/inc/bits"
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/libc/inc/sys"
|
# "${CMAKE_CURRENT_SOURCE_DIR}/libc/inc/sys"
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/misc"
|
"${CMAKE_CURRENT_SOURCE_DIR}/misc"
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/list"
|
"${CMAKE_CURRENT_SOURCE_DIR}/list"
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/device"
|
"${CMAKE_CURRENT_SOURCE_DIR}/device"
|
||||||
@ -21,7 +21,7 @@ list(APPEND ADD_INCLUDE
|
|||||||
|
|
||||||
############## Add current dir source files ###########
|
############## Add current dir source files ###########
|
||||||
file(GLOB_RECURSE sources
|
file(GLOB_RECURSE sources
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/libc/src/*.c"
|
# "${CMAKE_CURRENT_SOURCE_DIR}/libc/src/*.c"
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/ring_buffer/*.c"
|
"${CMAKE_CURRENT_SOURCE_DIR}/ring_buffer/*.c"
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/soft_crc/*.c"
|
"${CMAKE_CURRENT_SOURCE_DIR}/soft_crc/*.c"
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/memheap/*.c"
|
"${CMAKE_CURRENT_SOURCE_DIR}/memheap/*.c"
|
||||||
|
@ -1,62 +0,0 @@
|
|||||||
Some files are derived from files copyrighted by the Regents of The
|
|
||||||
University of California, and are available under the following
|
|
||||||
license:
|
|
||||||
|
|
||||||
Note: The advertising clause in the license appearing on BSD Unix
|
|
||||||
files was officially rescinded by the Director of the Office of
|
|
||||||
Technology Licensing of the University of California on July 22
|
|
||||||
1999. He states that clause 3 is "hereby deleted in its entirety."
|
|
||||||
|
|
||||||
* Copyright (c)
|
|
||||||
* The Regents of the University of California. All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* 3. All advertising materials mentioning features or use of this software
|
|
||||||
* must display the following acknowledgement:
|
|
||||||
* This product includes software developed by the University of
|
|
||||||
* California, Berkeley and its contributors.
|
|
||||||
* 4. Neither the name of the University nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
|
|
||||||
-----
|
|
||||||
|
|
||||||
For all remaining files, the following license applies:
|
|
||||||
|
|
||||||
* 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:
|
|
||||||
*
|
|
||||||
* Any copyright notice(s) 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.
|
|
@ -1,8 +0,0 @@
|
|||||||
This is a subset of klibc (http://www.kernel.org/pub/linux/libs/klibc/)
|
|
||||||
which is itself a subset of standard C library functions.
|
|
||||||
|
|
||||||
The provided functions are those which can be safely used in the SDK
|
|
||||||
environment.
|
|
||||||
|
|
||||||
The included code was extracted from klibc version 1.5.15 without any
|
|
||||||
of the GPL licensed parts. See the LICENSE file for details.
|
|
@ -1,27 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
#ifndef _COMPAT_ATTRIBUTE_H_
|
|
||||||
#define _COMPAT_ATTRIBUTE_H_
|
|
||||||
|
|
||||||
#define __DEPRECATED__(x) __attribute__((deprecated(x)))
|
|
||||||
#define __PACKED__ __attribute__((packed))
|
|
||||||
|
|
||||||
#define __PACKED_START__
|
|
||||||
#define __PACKED_END__ __PACKED__
|
|
||||||
|
|
||||||
#define __UNUSED__ __attribute__((unused))
|
|
||||||
#define __MAY_ALIAS__ __attribute__((may_alias))
|
|
||||||
|
|
||||||
#define __ALIGNED__(y) __attribute__((aligned(y)))
|
|
||||||
#define __SECTION__(y) __attribute__((section(#y)))
|
|
||||||
|
|
||||||
#define __FORCED_INLINE__ inline __attribute__((always_inline))
|
|
||||||
#define __NOINLINE__ __attribute__((noinline))
|
|
||||||
|
|
||||||
#define __WEAK__ __attribute__((weak))
|
|
||||||
#define __INTERRUPT__ __attribute__((interrupt))
|
|
||||||
#define __USED__ __attribute__((used))
|
|
||||||
#define __NAKED__ __attribute__((naked))
|
|
||||||
|
|
||||||
#define __VISIBILITY__ __attribute__((visibility("default")))
|
|
||||||
#endif /* _COMPAT_ATTRIBUTE_H_ */
|
|
@ -1,5 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
#ifndef _COMPAT_COMPILER_H_
|
|
||||||
#define _COMPAT_COMPILER_H_
|
|
||||||
#endif /* _COMPAT_COMPILER_H_ */
|
|
@ -1,8 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
#ifndef _COMPAT_ERRNO_H_
|
|
||||||
#define _COMPAT_ERRNO_H_
|
|
||||||
|
|
||||||
#include <errno.h>
|
|
||||||
|
|
||||||
#endif /* _COMPAT_ERRNO_H_ */
|
|
@ -1,6 +0,0 @@
|
|||||||
#ifndef _COMPAT_PARAM_H
|
|
||||||
#define _COMPAT_PARAM_H
|
|
||||||
|
|
||||||
#include <sys/param.h> /* need this to define BSD */
|
|
||||||
|
|
||||||
#endif /* _COMPAT_PARAM_H */
|
|
@ -1,8 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
#ifndef _COMPAT_TIME_H_
|
|
||||||
#define _COMPAT_TIME_H_
|
|
||||||
|
|
||||||
#include <sys/time.h>
|
|
||||||
|
|
||||||
#endif /* _COMPAT_TIME_H_ */
|
|
@ -1,28 +0,0 @@
|
|||||||
|
|
||||||
namespace std _GLIBCXX_VISIBILITY(default)
|
|
||||||
{
|
|
||||||
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|
||||||
|
|
||||||
/// @brief Base class for ctype.
|
|
||||||
struct ctype_base {
|
|
||||||
// Non-standard typedefs.
|
|
||||||
typedef const int *__to_type;
|
|
||||||
|
|
||||||
// NB: Offsets into ctype<char>::_M_table force a particular size
|
|
||||||
// on the mask type. Because of this, we don't use an enum.
|
|
||||||
typedef char mask;
|
|
||||||
static const mask upper = _U;
|
|
||||||
static const mask lower = _L;
|
|
||||||
static const mask alpha = _U | _L;
|
|
||||||
static const mask digit = _N;
|
|
||||||
static const mask xdigit = _X | _N;
|
|
||||||
static const mask space = _S;
|
|
||||||
static const mask print = _P | _U | _L | _N | _B;
|
|
||||||
static const mask graph = _P | _U | _L | _N;
|
|
||||||
static const mask cntrl = _C;
|
|
||||||
static const mask punct = _P;
|
|
||||||
static const mask alnum = _U | _L | _N;
|
|
||||||
};
|
|
||||||
|
|
||||||
_GLIBCXX_END_NAMESPACE_VERSION
|
|
||||||
} // namespace )
|
|
@ -1,140 +0,0 @@
|
|||||||
/*
|
|
||||||
* ctype.h
|
|
||||||
*
|
|
||||||
* This assumes ISO 8859-1, being a reasonable superset of ASCII.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _CTYPE_H
|
|
||||||
#define _CTYPE_H
|
|
||||||
|
|
||||||
#include <extern.h>
|
|
||||||
#include <libc_compiler.h>
|
|
||||||
|
|
||||||
#define _U (1 << 0)
|
|
||||||
#define _L (1 << 1)
|
|
||||||
#define _N (1 << 2)
|
|
||||||
#define _S (1 << 3)
|
|
||||||
#define _P (1 << 4)
|
|
||||||
#define _C (1 << 5)
|
|
||||||
#define _X (1 << 6)
|
|
||||||
#define _B (1 << 7)
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This relies on the following definitions:
|
|
||||||
*
|
|
||||||
* cntrl = !print
|
|
||||||
* alpha = upper|lower
|
|
||||||
* graph = punct|alpha|digit
|
|
||||||
* blank = '\t' || ' ' (per POSIX requirement)
|
|
||||||
*/
|
|
||||||
enum {
|
|
||||||
__ctype_upper = _U,
|
|
||||||
__ctype_lower = _L,
|
|
||||||
__ctype_digit = _N,
|
|
||||||
__ctype_xdigit = _S,
|
|
||||||
__ctype_space = _P,
|
|
||||||
__ctype_print = _C,
|
|
||||||
__ctype_punct = _X,
|
|
||||||
__ctype_cntrl = _B
|
|
||||||
};
|
|
||||||
|
|
||||||
__extern int isalnum(int);
|
|
||||||
__extern int isalpha(int);
|
|
||||||
__extern int isascii(int);
|
|
||||||
__extern int isblank(int);
|
|
||||||
__extern int iscntrl(int);
|
|
||||||
__extern int isdigit(int);
|
|
||||||
__extern int isgraph(int);
|
|
||||||
__extern int islower(int);
|
|
||||||
__extern int isprint(int);
|
|
||||||
__extern int ispunct(int);
|
|
||||||
__extern int isspace(int);
|
|
||||||
__extern int isupper(int);
|
|
||||||
__extern int isxdigit(int);
|
|
||||||
__extern int toupper(int);
|
|
||||||
__extern int tolower(int);
|
|
||||||
|
|
||||||
extern const unsigned char __ctypes[];
|
|
||||||
|
|
||||||
__must_inline int __ctype_isalnum(int __c)
|
|
||||||
{
|
|
||||||
return __ctypes[__c + 1] &
|
|
||||||
(__ctype_upper | __ctype_lower | __ctype_digit);
|
|
||||||
}
|
|
||||||
|
|
||||||
__must_inline int __ctype_isalpha(int __c)
|
|
||||||
{
|
|
||||||
return __ctypes[__c + 1] & (__ctype_upper | __ctype_lower);
|
|
||||||
}
|
|
||||||
|
|
||||||
__must_inline int __ctype_isascii(int __c)
|
|
||||||
{
|
|
||||||
return !(__c & ~0x7f);
|
|
||||||
}
|
|
||||||
|
|
||||||
__must_inline int __ctype_isblank(int __c)
|
|
||||||
{
|
|
||||||
return (__c == '\t') || (__c == ' ');
|
|
||||||
}
|
|
||||||
|
|
||||||
__must_inline int __ctype_iscntrl(int __c)
|
|
||||||
{
|
|
||||||
return __ctypes[__c + 1] & __ctype_cntrl;
|
|
||||||
}
|
|
||||||
|
|
||||||
__must_inline int __ctype_isdigit(int __c)
|
|
||||||
{
|
|
||||||
return ((unsigned)__c - '0') <= 9;
|
|
||||||
}
|
|
||||||
|
|
||||||
__must_inline int __ctype_isgraph(int __c)
|
|
||||||
{
|
|
||||||
return __ctypes[__c + 1] &
|
|
||||||
(__ctype_upper | __ctype_lower | __ctype_digit | __ctype_punct);
|
|
||||||
}
|
|
||||||
|
|
||||||
__must_inline int __ctype_islower(int __c)
|
|
||||||
{
|
|
||||||
return __ctypes[__c + 1] & __ctype_lower;
|
|
||||||
}
|
|
||||||
|
|
||||||
__must_inline int __ctype_isprint(int __c)
|
|
||||||
{
|
|
||||||
return __ctypes[__c + 1] & __ctype_print;
|
|
||||||
}
|
|
||||||
|
|
||||||
__must_inline int __ctype_ispunct(int __c)
|
|
||||||
{
|
|
||||||
return __ctypes[__c + 1] & __ctype_punct;
|
|
||||||
}
|
|
||||||
|
|
||||||
__must_inline int __ctype_isspace(int __c)
|
|
||||||
{
|
|
||||||
return __ctypes[__c + 1] & __ctype_space;
|
|
||||||
}
|
|
||||||
|
|
||||||
__must_inline int __ctype_isupper(int __c)
|
|
||||||
{
|
|
||||||
return __ctypes[__c + 1] & __ctype_upper;
|
|
||||||
}
|
|
||||||
|
|
||||||
__must_inline int __ctype_isxdigit(int __c)
|
|
||||||
{
|
|
||||||
return __ctypes[__c + 1] & __ctype_xdigit;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Note: this is decimal, not hex, to avoid accidental promotion to unsigned */
|
|
||||||
#define _toupper(__c) ((__c) & ~32)
|
|
||||||
#define _tolower(__c) ((__c) | 32)
|
|
||||||
|
|
||||||
__must_inline int __ctype_toupper(int __c)
|
|
||||||
{
|
|
||||||
return __ctype_islower(__c) ? _toupper(__c) : __c;
|
|
||||||
}
|
|
||||||
|
|
||||||
__must_inline int __ctype_tolower(int __c)
|
|
||||||
{
|
|
||||||
return __ctype_isupper(__c) ? _tolower(__c) : __c;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* _CTYPE_H */
|
|
@ -1,16 +0,0 @@
|
|||||||
/*
|
|
||||||
* klibc/extern.h
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _EXTERN_H
|
|
||||||
#define _EXTERN_H
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
#define __extern extern "C"
|
|
||||||
#else
|
|
||||||
#define __extern extern
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define __alias(x) __attribute__((weak, alias(x)))
|
|
||||||
|
|
||||||
#endif /* _EXTERN_H */
|
|
@ -1,15 +0,0 @@
|
|||||||
#ifndef _FNMATCH_H
|
|
||||||
#define _FNMATCH_H
|
|
||||||
|
|
||||||
#include <extern.h>
|
|
||||||
|
|
||||||
#define FNM_NOMATCH 1
|
|
||||||
|
|
||||||
#define FNM_PATHNAME 1
|
|
||||||
#define FNM_FILE_NAME FNM_PATHNAME
|
|
||||||
#define FNM_NOESCAPE 2
|
|
||||||
#define FNM_PERIOD 4
|
|
||||||
|
|
||||||
__extern int fnmatch(const char *, const char *, int);
|
|
||||||
|
|
||||||
#endif /* _FNMATCH_H */
|
|
@ -1,227 +0,0 @@
|
|||||||
/*
|
|
||||||
* inttypes.h
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _INTTYPES_H
|
|
||||||
#define _INTTYPES_H
|
|
||||||
|
|
||||||
#include <extern.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <stddef.h>
|
|
||||||
#include <compat_compiler.h>
|
|
||||||
|
|
||||||
static __inline intmax_t imaxabs(intmax_t __n)
|
|
||||||
{
|
|
||||||
return (__n < (intmax_t)0) ? -__n : __n;
|
|
||||||
}
|
|
||||||
|
|
||||||
__extern intmax_t strtoimax(const char *, char **, int);
|
|
||||||
__extern uintmax_t strtoumax(const char *, char **, int);
|
|
||||||
|
|
||||||
/* extensions */
|
|
||||||
__extern intmax_t strntoimax(const char *, char **, int, size_t);
|
|
||||||
__extern uintmax_t strntoumax(const char *, char **, int, size_t);
|
|
||||||
|
|
||||||
#if !defined(__cplusplus) || defined(__STDC_FORMAT_MACROS)
|
|
||||||
|
|
||||||
#define PRId8 "d"
|
|
||||||
#define PRId16 "d"
|
|
||||||
#define PRId32 "d"
|
|
||||||
#define PRId64 __PRI64_RANK "d"
|
|
||||||
|
|
||||||
#define PRIdLEAST8 "d"
|
|
||||||
#define PRIdLEAST16 "d"
|
|
||||||
#define PRIdLEAST32 "d"
|
|
||||||
#define PRIdLEAST64 __PRI64_RANK "d"
|
|
||||||
|
|
||||||
#define PRIdFAST8 "d"
|
|
||||||
#define PRIdFAST16 __PRIFAST_RANK "d"
|
|
||||||
#define PRIdFAST32 __PRIFAST_RANK "d"
|
|
||||||
#define PRIdFAST64 __PRI64_RANK "d"
|
|
||||||
|
|
||||||
#define PRIdMAX __PRI64_RANK "d"
|
|
||||||
#define PRIdPTR __PRIPTR_RANK "d"
|
|
||||||
|
|
||||||
#define PRIi8 "i"
|
|
||||||
#define PRIi16 "i"
|
|
||||||
#define PRIi32 "i"
|
|
||||||
#define PRIi64 __PRI64_RANK "i"
|
|
||||||
|
|
||||||
#define PRIiLEAST8 "i"
|
|
||||||
#define PRIiLEAST16 "i"
|
|
||||||
#define PRIiLEAST32 "i"
|
|
||||||
#define PRIiLEAST64 __PRI64_RANK "i"
|
|
||||||
|
|
||||||
#define PRIiFAST8 "i"
|
|
||||||
#define PRIiFAST16 __PRIFAST_RANK "i"
|
|
||||||
#define PRIiFAST32 __PRIFAST_RANK "i"
|
|
||||||
#define PRIiFAST64 __PRI64_RANK "i"
|
|
||||||
|
|
||||||
#define PRIiMAX __PRI64_RANK "i"
|
|
||||||
#define PRIiPTR __PRIPTR_RANK "i"
|
|
||||||
|
|
||||||
#define PRIo8 "o"
|
|
||||||
#define PRIo16 "o"
|
|
||||||
#define PRIo32 "o"
|
|
||||||
#define PRIo64 __PRI64_RANK "o"
|
|
||||||
|
|
||||||
#define PRIoLEAST8 "o"
|
|
||||||
#define PRIoLEAST16 "o"
|
|
||||||
#define PRIoLEAST32 "o"
|
|
||||||
#define PRIoLEAST64 __PRI64_RANK "o"
|
|
||||||
|
|
||||||
#define PRIoFAST8 "o"
|
|
||||||
#define PRIoFAST16 __PRIFAST_RANK "o"
|
|
||||||
#define PRIoFAST32 __PRIFAST_RANK "o"
|
|
||||||
#define PRIoFAST64 __PRI64_RANK "o"
|
|
||||||
|
|
||||||
#define PRIoMAX __PRI64_RANK "o"
|
|
||||||
#define PRIoPTR __PRIPTR_RANK "o"
|
|
||||||
|
|
||||||
#define PRIu8 "u"
|
|
||||||
#define PRIu16 "u"
|
|
||||||
#define PRIu32 "u"
|
|
||||||
#define PRIu64 __PRI64_RANK "u"
|
|
||||||
|
|
||||||
#define PRIuLEAST8 "u"
|
|
||||||
#define PRIuLEAST16 "u"
|
|
||||||
#define PRIuLEAST32 "u"
|
|
||||||
#define PRIuLEAST64 __PRI64_RANK "u"
|
|
||||||
|
|
||||||
#define PRIuFAST8 "u"
|
|
||||||
#define PRIuFAST16 __PRIFAST_RANK "u"
|
|
||||||
#define PRIuFAST32 __PRIFAST_RANK "u"
|
|
||||||
#define PRIuFAST64 __PRI64_RANK "u"
|
|
||||||
|
|
||||||
#define PRIuMAX __PRI64_RANK "u"
|
|
||||||
#define PRIuPTR __PRIPTR_RANK "u"
|
|
||||||
|
|
||||||
#define PRIx8 "x"
|
|
||||||
#define PRIx16 "x"
|
|
||||||
#define PRIx32 "x"
|
|
||||||
#define PRIx64 __PRI64_RANK "x"
|
|
||||||
|
|
||||||
#define PRIxLEAST8 "x"
|
|
||||||
#define PRIxLEAST16 "x"
|
|
||||||
#define PRIxLEAST32 "x"
|
|
||||||
#define PRIxLEAST64 __PRI64_RANK "x"
|
|
||||||
|
|
||||||
#define PRIxFAST8 "x"
|
|
||||||
#define PRIxFAST16 __PRIFAST_RANK "x"
|
|
||||||
#define PRIxFAST32 __PRIFAST_RANK "x"
|
|
||||||
#define PRIxFAST64 __PRI64_RANK "x"
|
|
||||||
|
|
||||||
#define PRIxMAX __PRI64_RANK "x"
|
|
||||||
#define PRIxPTR __PRIPTR_RANK "x"
|
|
||||||
|
|
||||||
#define PRIX8 "X"
|
|
||||||
#define PRIX16 "X"
|
|
||||||
#define PRIX32 "X"
|
|
||||||
#define PRIX64 __PRI64_RANK "X"
|
|
||||||
|
|
||||||
#define PRIXLEAST8 "X"
|
|
||||||
#define PRIXLEAST16 "X"
|
|
||||||
#define PRIXLEAST32 "X"
|
|
||||||
#define PRIXLEAST64 __PRI64_RANK "X"
|
|
||||||
|
|
||||||
#define PRIXFAST8 "X"
|
|
||||||
#define PRIXFAST16 __PRIFAST_RANK "X"
|
|
||||||
#define PRIXFAST32 __PRIFAST_RANK "X"
|
|
||||||
#define PRIXFAST64 __PRI64_RANK "X"
|
|
||||||
|
|
||||||
#define PRIXMAX __PRI64_RANK "X"
|
|
||||||
#define PRIXPTR __PRIPTR_RANK "X"
|
|
||||||
|
|
||||||
#define SCNd8 "hhd"
|
|
||||||
#define SCNd16 "hd"
|
|
||||||
#define SCNd32 "d"
|
|
||||||
#define SCNd64 __PRI64_RANK "d"
|
|
||||||
|
|
||||||
#define SCNdLEAST8 "hhd"
|
|
||||||
#define SCNdLEAST16 "hd"
|
|
||||||
#define SCNdLEAST32 "d"
|
|
||||||
#define SCNdLEAST64 __PRI64_RANK "d"
|
|
||||||
|
|
||||||
#define SCNdFAST8 "hhd"
|
|
||||||
#define SCNdFAST16 __PRIFAST_RANK "d"
|
|
||||||
#define SCNdFAST32 __PRIFAST_RANK "d"
|
|
||||||
#define SCNdFAST64 __PRI64_RANK "d"
|
|
||||||
|
|
||||||
#define SCNdMAX __PRI64_RANK "d"
|
|
||||||
#define SCNdPTR __PRIPTR_RANK "d"
|
|
||||||
|
|
||||||
#define SCNi8 "hhi"
|
|
||||||
#define SCNi16 "hi"
|
|
||||||
#define SCNi32 "i"
|
|
||||||
#define SCNi64 __PRI64_RANK "i"
|
|
||||||
|
|
||||||
#define SCNiLEAST8 "hhi"
|
|
||||||
#define SCNiLEAST16 "hi"
|
|
||||||
#define SCNiLEAST32 "i"
|
|
||||||
#define SCNiLEAST64 __PRI64_RANK "i"
|
|
||||||
|
|
||||||
#define SCNiFAST8 "hhi"
|
|
||||||
#define SCNiFAST16 __PRIFAST_RANK "i"
|
|
||||||
#define SCNiFAST32 __PRIFAST_RANK "i"
|
|
||||||
#define SCNiFAST64 __PRI64_RANK "i"
|
|
||||||
|
|
||||||
#define SCNiMAX __PRI64_RANK "i"
|
|
||||||
#define SCNiPTR __PRIPTR_RANK "i"
|
|
||||||
|
|
||||||
#define SCNo8 "hho"
|
|
||||||
#define SCNo16 "ho"
|
|
||||||
#define SCNo32 "o"
|
|
||||||
#define SCNo64 __PRI64_RANK "o"
|
|
||||||
|
|
||||||
#define SCNoLEAST8 "hho"
|
|
||||||
#define SCNoLEAST16 "ho"
|
|
||||||
#define SCNoLEAST32 "o"
|
|
||||||
#define SCNoLEAST64 __PRI64_RANK "o"
|
|
||||||
|
|
||||||
#define SCNoFAST8 "hho"
|
|
||||||
#define SCNoFAST16 __PRIFAST_RANK "o"
|
|
||||||
#define SCNoFAST32 __PRIFAST_RANK "o"
|
|
||||||
#define SCNoFAST64 __PRI64_RANK "o"
|
|
||||||
|
|
||||||
#define SCNoMAX __PRI64_RANK "o"
|
|
||||||
#define SCNoPTR __PRIPTR_RANK "o"
|
|
||||||
|
|
||||||
#define SCNu8 "hhu"
|
|
||||||
#define SCNu16 "hu"
|
|
||||||
#define SCNu32 "u"
|
|
||||||
#define SCNu64 __PRI64_RANK "u"
|
|
||||||
|
|
||||||
#define SCNuLEAST8 "hhu"
|
|
||||||
#define SCNuLEAST16 "hu"
|
|
||||||
#define SCNuLEAST32 "u"
|
|
||||||
#define SCNuLEAST64 __PRI64_RANK "u"
|
|
||||||
|
|
||||||
#define SCNuFAST8 "hhu"
|
|
||||||
#define SCNuFAST16 __PRIFAST_RANK "u"
|
|
||||||
#define SCNuFAST32 __PRIFAST_RANK "u"
|
|
||||||
#define SCNuFAST64 __PRI64_RANK "u"
|
|
||||||
|
|
||||||
#define SCNuMAX __PRI64_RANK "u"
|
|
||||||
#define SCNuPTR __PRIPTR_RANK "u"
|
|
||||||
|
|
||||||
#define SCNx8 "hhx"
|
|
||||||
#define SCNx16 "hx"
|
|
||||||
#define SCNx32 "x"
|
|
||||||
#define SCNx64 __PRI64_RANK "x"
|
|
||||||
|
|
||||||
#define SCNxLEAST8 "hhx"
|
|
||||||
#define SCNxLEAST16 "hx"
|
|
||||||
#define SCNxLEAST32 "x"
|
|
||||||
#define SCNxLEAST64 __PRI64_RANK "x"
|
|
||||||
|
|
||||||
#define SCNxFAST8 "hhx"
|
|
||||||
#define SCNxFAST16 __PRIFAST_RANK "x"
|
|
||||||
#define SCNxFAST32 __PRIFAST_RANK "x"
|
|
||||||
#define SCNxFAST64 __PRI64_RANK "x"
|
|
||||||
|
|
||||||
#define SCNxMAX __PRI64_RANK "x"
|
|
||||||
#define SCNxPTR __PRIPTR_RANK "x"
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* _INTTYPES_H */
|
|
@ -1,109 +0,0 @@
|
|||||||
/*
|
|
||||||
* libc compiler.h
|
|
||||||
*
|
|
||||||
* Various compiler features
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _LIBC_COMPILER_H
|
|
||||||
#define _LIBC_COMPILER_H
|
|
||||||
|
|
||||||
/* Specific calling conventions */
|
|
||||||
/* __cdecl is used when we want varadic and non-varadic functions to have
|
|
||||||
the same binary calling convention. */
|
|
||||||
#ifdef __i386__
|
|
||||||
#ifdef __GNUC__
|
|
||||||
#define __cdecl __attribute__((cdecl, regparm(0)))
|
|
||||||
#else
|
|
||||||
/* Most other C compilers have __cdecl as a keyword */
|
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
#define __cdecl /* Meaningless on non-i386 */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* How to declare a function that *must* be inlined */
|
|
||||||
/* Use "extern inline" even in the gcc3+ case to avoid warnings in ctype.h */
|
|
||||||
#ifdef __GNUC__
|
|
||||||
#if __GNUC__ >= 3
|
|
||||||
#ifdef __GNUC_STDC_INLINE__
|
|
||||||
#define __must_inline extern __inline__ \
|
|
||||||
__attribute__((__gnu_inline__, __always_inline__))
|
|
||||||
#else
|
|
||||||
#define __must_inline extern __inline__ __attribute__((__always_inline__))
|
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
#define __must_inline extern __inline__
|
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
#define __must_inline __inline /* Just hope this works... */
|
|
||||||
#define __inline inline
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* How to declare a function that does not return */
|
|
||||||
#ifdef __GNUC__
|
|
||||||
#define __noreturn void __attribute__((noreturn))
|
|
||||||
#else
|
|
||||||
#define __noreturn void
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* "const" function:
|
|
||||||
|
|
||||||
Many functions do not examine any values except their arguments,
|
|
||||||
and have no effects except the return value. Basically this is
|
|
||||||
just slightly more strict class than the `pure' attribute above,
|
|
||||||
since function is not allowed to read global memory.
|
|
||||||
|
|
||||||
Note that a function that has pointer arguments and examines the
|
|
||||||
data pointed to must _not_ be declared `const'. Likewise, a
|
|
||||||
function that calls a non-`const' function usually must not be
|
|
||||||
`const'. It does not make sense for a `const' function to return
|
|
||||||
`void'.
|
|
||||||
*/
|
|
||||||
#ifdef __GNUC__
|
|
||||||
#define __constfunc __attribute__((const))
|
|
||||||
#else
|
|
||||||
#define __constfunc
|
|
||||||
#endif
|
|
||||||
#undef __attribute_const__
|
|
||||||
#define __attribute_const__ __constfunc
|
|
||||||
|
|
||||||
/* "pure" function:
|
|
||||||
|
|
||||||
Many functions have no effects except the return value and their
|
|
||||||
return value depends only on the parameters and/or global
|
|
||||||
variables. Such a function can be subject to common subexpression
|
|
||||||
elimination and loop optimization just as an arithmetic operator
|
|
||||||
would be. These functions should be declared with the attribute
|
|
||||||
`pure'.
|
|
||||||
*/
|
|
||||||
#ifdef __GNUC__
|
|
||||||
#define __purefunc __attribute__((pure))
|
|
||||||
#else
|
|
||||||
#define __purefunc
|
|
||||||
#endif
|
|
||||||
#undef __attribute_pure__
|
|
||||||
#define __attribute_pure__ __purefunc
|
|
||||||
|
|
||||||
/* Format attribute */
|
|
||||||
#ifdef __GNUC__
|
|
||||||
#define __formatfunc(t, f, a) __attribute__((format(t, f, a)))
|
|
||||||
#else
|
|
||||||
#define __formatfunc(t, f, a)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* malloc() function (returns unaliased pointer) */
|
|
||||||
#if defined(__GNUC__) && (__GNUC__ >= 3)
|
|
||||||
#define __mallocfunc __attribute__((malloc))
|
|
||||||
#else
|
|
||||||
#define __mallocfunc
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* likely/unlikely */
|
|
||||||
#if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95))
|
|
||||||
#define __likely(x) __builtin_expect(!!(x), 1)
|
|
||||||
#define __unlikely(x) __builtin_expect(!!(x), 0)
|
|
||||||
#else
|
|
||||||
#define __likely(x) (!!(x))
|
|
||||||
#define __unlikely(x) (!!(x))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,51 +0,0 @@
|
|||||||
/*
|
|
||||||
* limits.h
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _LIMITS_H
|
|
||||||
#define _LIMITS_H
|
|
||||||
|
|
||||||
#define CHAR_BIT 8
|
|
||||||
#define SHRT_BIT 16
|
|
||||||
#define INT_BIT 32
|
|
||||||
#define LONGLONG_BIT 64
|
|
||||||
|
|
||||||
#define SCHAR_MIN (-128)
|
|
||||||
#define SCHAR_MAX 127
|
|
||||||
#define UCHAR_MAX 255
|
|
||||||
|
|
||||||
#ifdef __CHAR_UNSIGNED__
|
|
||||||
#define CHAR_MIN 0
|
|
||||||
#define CHAR_MAX UCHAR_MAX
|
|
||||||
#else
|
|
||||||
#define CHAR_MIN SCHAR_MIN
|
|
||||||
#define CHAR_MAX SCHAR_MAX
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define SHRT_MIN (-32768)
|
|
||||||
#define SHRT_MAX 32767
|
|
||||||
#define USHRT_MAX 65535
|
|
||||||
|
|
||||||
#define INT_MIN (-2147483647 - 1)
|
|
||||||
#define INT_MAX 2147483647
|
|
||||||
#define UINT_MAX 4294967295U
|
|
||||||
|
|
||||||
#if __riscv_xlen == 64
|
|
||||||
#define LONG_BIT 64
|
|
||||||
|
|
||||||
#define LONG_MIN (-9223372036854775807LL - 1)
|
|
||||||
#define LONG_MAX 9223372036854775807LL
|
|
||||||
#define ULONG_MAX 18446744073709551615ULL
|
|
||||||
#else
|
|
||||||
#define LONG_BIT 32
|
|
||||||
|
|
||||||
#define LONG_MIN (-2147483647L - 1)
|
|
||||||
#define LONG_MAX 2147483647L
|
|
||||||
#define ULONG_MAX 4294967295UL
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define LONGLONG_MIN (-9223372036854775807LL - 1)
|
|
||||||
#define LONGLONG_MAX 9223372036854775807LL
|
|
||||||
#define ULONGLONG_MAX 18446744073709551615ULL
|
|
||||||
|
|
||||||
#endif /* _LIMITS_H */
|
|
@ -1,14 +0,0 @@
|
|||||||
/*
|
|
||||||
* stdarg.h
|
|
||||||
*
|
|
||||||
* This is just a wrapper for the gcc one, but defines va_copy()
|
|
||||||
* even if gcc doesn't.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Note: the _STDARG_H macro belongs to the gcc header... */
|
|
||||||
#include_next <stdarg.h>
|
|
||||||
|
|
||||||
/* Older gcc considers this an extension, so it's double underbar only */
|
|
||||||
#ifndef va_copy
|
|
||||||
#define va_copy(d, s) __va_copy(d, s)
|
|
||||||
#endif
|
|
@ -1,14 +0,0 @@
|
|||||||
/*
|
|
||||||
* stdbool.h
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _STDBOOL_H
|
|
||||||
#define _STDBOOL_H
|
|
||||||
|
|
||||||
#ifndef __cplusplus
|
|
||||||
#define bool _Bool
|
|
||||||
#define true 1
|
|
||||||
#define false 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* _STDBOOL_H */
|
|
@ -1,29 +0,0 @@
|
|||||||
/*
|
|
||||||
* stddef.h
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _STDDEF_H
|
|
||||||
#define _STDDEF_H
|
|
||||||
|
|
||||||
#define _SIZE_T
|
|
||||||
typedef unsigned long size_t;
|
|
||||||
|
|
||||||
#define _PTRDIFF_T
|
|
||||||
typedef signed int ptrdiff_t;
|
|
||||||
|
|
||||||
#ifndef __ICCARM__
|
|
||||||
#define _WINT_T
|
|
||||||
typedef signed int wint_t;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#undef NULL
|
|
||||||
#ifdef __cplusplus
|
|
||||||
#define NULL 0
|
|
||||||
#else
|
|
||||||
#define NULL ((void *)0)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#undef offsetof
|
|
||||||
#define offsetof(t, m) ((size_t) & ((t *)0)->m)
|
|
||||||
|
|
||||||
#endif /* _STDDEF_H */
|
|
@ -1,165 +0,0 @@
|
|||||||
/*
|
|
||||||
* stdint.h
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _STDINT_H
|
|
||||||
#define _STDINT_H
|
|
||||||
|
|
||||||
typedef signed char int8_t;
|
|
||||||
typedef short int int16_t;
|
|
||||||
typedef int int32_t;
|
|
||||||
typedef long long int int64_t;
|
|
||||||
|
|
||||||
typedef unsigned char uint8_t;
|
|
||||||
typedef unsigned short int uint16_t;
|
|
||||||
typedef unsigned int uint32_t;
|
|
||||||
typedef unsigned long long int uint64_t;
|
|
||||||
|
|
||||||
typedef int int_fast16_t;
|
|
||||||
typedef int int_fast32_t;
|
|
||||||
|
|
||||||
typedef unsigned int uint_fast16_t;
|
|
||||||
typedef unsigned int uint_fast32_t;
|
|
||||||
|
|
||||||
#if __riscv_xlen == 32
|
|
||||||
typedef int intptr_t;
|
|
||||||
typedef unsigned int uintptr_t;
|
|
||||||
|
|
||||||
#undef __INT64_C
|
|
||||||
#define __INT64_C(c) c##LL
|
|
||||||
#undef __UINT64_C
|
|
||||||
#define __UINT64_C(c) c##ULL
|
|
||||||
#elif __riscv_xlen == 64
|
|
||||||
typedef long long intptr_t;
|
|
||||||
typedef unsigned long long uintptr_t;
|
|
||||||
#else
|
|
||||||
#error "unsupported __riscv_xlen"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define __PRI64_RANK "ll"
|
|
||||||
#define __PRIFAST_RANK ""
|
|
||||||
#define __PRIPTR_RANK ""
|
|
||||||
typedef int8_t int_least8_t;
|
|
||||||
typedef int16_t int_least16_t;
|
|
||||||
typedef int32_t int_least32_t;
|
|
||||||
typedef int64_t int_least64_t;
|
|
||||||
|
|
||||||
typedef uint8_t uint_least8_t;
|
|
||||||
typedef uint16_t uint_least16_t;
|
|
||||||
typedef uint32_t uint_least32_t;
|
|
||||||
typedef uint64_t uint_least64_t;
|
|
||||||
|
|
||||||
typedef int8_t int_fast8_t;
|
|
||||||
typedef int64_t int_fast64_t;
|
|
||||||
|
|
||||||
typedef uint8_t uint_fast8_t;
|
|
||||||
typedef uint64_t uint_fast64_t;
|
|
||||||
|
|
||||||
typedef int64_t intmax_t;
|
|
||||||
typedef uint64_t uintmax_t;
|
|
||||||
|
|
||||||
#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS)
|
|
||||||
|
|
||||||
#define INT8_MIN (-128)
|
|
||||||
#define INT16_MIN (-32768)
|
|
||||||
#define INT32_MIN (-2147483647 - 1)
|
|
||||||
#define INT64_MIN (__INT64_C(-9223372036854775807) - 1)
|
|
||||||
|
|
||||||
#define INT8_MAX (127)
|
|
||||||
#define INT16_MAX (32767)
|
|
||||||
#define INT32_MAX (2147483647)
|
|
||||||
#define INT64_MAX (__INT64_C(9223372036854775807))
|
|
||||||
|
|
||||||
#define UINT8_MAX (255U)
|
|
||||||
#define UINT16_MAX (65535U)
|
|
||||||
#define UINT32_MAX (4294967295U)
|
|
||||||
#define UINT64_MAX (__UINT64_C(18446744073709551615))
|
|
||||||
|
|
||||||
#define INT_LEAST8_MIN INT8_MIN
|
|
||||||
#define INT_LEAST16_MIN INT16_MIN
|
|
||||||
#define INT_LEAST32_MIN INT32_MIN
|
|
||||||
#define INT_LEAST64_MIN INT64_MIN
|
|
||||||
|
|
||||||
#define INT_LEAST8_MAX INT8_MAX
|
|
||||||
#define INT_LEAST16_MAX INT16_MAX
|
|
||||||
#define INT_LEAST32_MAX INT32_MAX
|
|
||||||
#define INT_LEAST64_MAX INT64_MAX
|
|
||||||
|
|
||||||
#define UINT_LEAST8_MAX UINT8_MAX
|
|
||||||
#define UINT_LEAST16_MAX UINT16_MAX
|
|
||||||
#define UINT_LEAST32_MAX UINT32_MAX
|
|
||||||
#define UINT_LEAST64_MAX UINT64_MAX
|
|
||||||
|
|
||||||
#define INT_FAST8_MIN INT8_MIN
|
|
||||||
#define INT_FAST64_MIN INT64_MIN
|
|
||||||
|
|
||||||
#define INT_FAST8_MAX INT8_MAX
|
|
||||||
#define INT_FAST64_MAX INT64_MAX
|
|
||||||
|
|
||||||
#define UINT_FAST8_MAX UINT8_MAX
|
|
||||||
#define UINT_FAST64_MAX UINT64_MAX
|
|
||||||
|
|
||||||
#define INTMAX_MIN INT64_MIN
|
|
||||||
#define INTMAX_MAX INT64_MAX
|
|
||||||
#define UINTMAX_MAX UINT64_MAX
|
|
||||||
|
|
||||||
#define INT_FAST16_MIN INT32_MIN
|
|
||||||
#define INT_FAST32_MIN INT32_MIN
|
|
||||||
#define INT_FAST16_MAX INT32_MAX
|
|
||||||
#define INT_FAST32_MAX INT32_MAX
|
|
||||||
#define UINT_FAST16_MAX UINT32_MAX
|
|
||||||
#define UINT_FAST32_MAX UINT32_MAX
|
|
||||||
|
|
||||||
#define INTPTR_MIN INT32_MIN
|
|
||||||
#define INTPTR_MAX INT32_MAX
|
|
||||||
#define UINTPTR_MAX UINT32_MAX
|
|
||||||
|
|
||||||
#define PTRDIFF_MIN INT32_MIN
|
|
||||||
#define PTRDIFF_MAX INT32_MAX
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS)
|
|
||||||
|
|
||||||
#define INT8_C(c) c
|
|
||||||
#define INT16_C(c) c
|
|
||||||
#define INT32_C(c) c
|
|
||||||
#define INT64_C(c) __INT64_C(c)
|
|
||||||
|
|
||||||
#define UINT8_C(c) c##U
|
|
||||||
#define UINT16_C(c) c##U
|
|
||||||
#define UINT32_C(c) c##U
|
|
||||||
#define UINT64_C(c) __UINT64_C(c)
|
|
||||||
|
|
||||||
#define INT_LEAST8_C(c) INT8_C(c)
|
|
||||||
#define INT_LEAST16_C(c) INT16_C(c)
|
|
||||||
#define INT_LEAST32_C(c) INT32_C(c)
|
|
||||||
#define INT_LEAST64_C(c) INT64_C(c)
|
|
||||||
|
|
||||||
#define UINT_LEAST8_C(c) UINT8_C(c)
|
|
||||||
#define UINT_LEAST16_C(c) UINT16_C(c)
|
|
||||||
#define UINT_LEAST32_C(c) UINT32_C(c)
|
|
||||||
#define UINT_LEAST64_C(c) UINT64_C(c)
|
|
||||||
|
|
||||||
#define INT_FAST8_C(c) INT8_C(c)
|
|
||||||
#define INT_FAST64_C(c) INT64_C(c)
|
|
||||||
|
|
||||||
#define UINT_FAST8_C(c) UINT8_C(c)
|
|
||||||
#define UINT_FAST64_C(c) UINT64_C(c)
|
|
||||||
|
|
||||||
#define INTMAX_C(c) INT64_C(c)
|
|
||||||
#define UINTMAX_C(c) UINT64_C(c)
|
|
||||||
|
|
||||||
#define INT_FAST16_C(c) INT32_C(c)
|
|
||||||
#define INT_FAST32_C(c) INT32_C(c)
|
|
||||||
|
|
||||||
#define UINT_FAST16_C(c) UINT32_C(c)
|
|
||||||
#define UINT_FAST32_C(c) UINT32_C(c)
|
|
||||||
|
|
||||||
#define INTPTR_C(c) INT32_C(c)
|
|
||||||
#define UINTPTR_C(c) UINT32_C(c)
|
|
||||||
#define PTRDIFF_C(c) INT32_C(c)
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* _STDINT_H */
|
|
@ -1,24 +0,0 @@
|
|||||||
/*
|
|
||||||
* stdio.h
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _STDIO_H
|
|
||||||
#define _STDIO_H
|
|
||||||
|
|
||||||
#include <extern.h>
|
|
||||||
#include <stdarg.h>
|
|
||||||
#include <stddef.h>
|
|
||||||
|
|
||||||
/* The actual IO functions are not included. */
|
|
||||||
#if __riscv_xlen == 64
|
|
||||||
#include_next <stdio.h>
|
|
||||||
#else
|
|
||||||
__extern int sprintf(char *, const char *, ...);
|
|
||||||
__extern int vsprintf(char *, const char *, va_list);
|
|
||||||
__extern int snprintf(char *__restrict, size_t, const char *__restrict, ...);
|
|
||||||
__extern int vsnprintf(char *, size_t, const char *, va_list);
|
|
||||||
__extern int sscanf(const char *, const char *, ...);
|
|
||||||
__extern int vsscanf(const char *, const char *, va_list);
|
|
||||||
#endif /* __riscv_xlen == 64 */
|
|
||||||
|
|
||||||
#endif /* _STDIO_H */
|
|
@ -1,62 +0,0 @@
|
|||||||
/*
|
|
||||||
* stdlib.h
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _STDLIB_H
|
|
||||||
#define _STDLIB_H
|
|
||||||
|
|
||||||
#include <extern.h>
|
|
||||||
#include <libc_compiler.h>
|
|
||||||
#include <stddef.h>
|
|
||||||
|
|
||||||
#define EXIT_FAILURE 1
|
|
||||||
#define EXIT_SUCCESS 0
|
|
||||||
|
|
||||||
static __inline int abs(int __n)
|
|
||||||
{
|
|
||||||
return (__n < 0) ? -__n : __n;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if __riscv_xlen == 64
|
|
||||||
#include_next <stdio.h>
|
|
||||||
__extern long jrand48(unsigned short *);
|
|
||||||
#else
|
|
||||||
__extern int atoi(const char *);
|
|
||||||
__extern double atof(const char *);
|
|
||||||
__extern long atol(const char *);
|
|
||||||
__extern long long atoll(const char *);
|
|
||||||
static __inline long labs(long __n)
|
|
||||||
{
|
|
||||||
return (__n < 0L) ? -__n : __n;
|
|
||||||
}
|
|
||||||
|
|
||||||
static __inline long long llabs(long long __n)
|
|
||||||
{
|
|
||||||
return (__n < 0LL) ? -__n : __n;
|
|
||||||
}
|
|
||||||
|
|
||||||
__extern long strtol(const char *, char **, int);
|
|
||||||
__extern long long strtoll(const char *, char **, int);
|
|
||||||
__extern unsigned long strtoul(const char *, char **, int);
|
|
||||||
__extern unsigned long long strtoull(const char *, char **, int);
|
|
||||||
|
|
||||||
typedef int (*__comparefunc_t)(const void *, const void *);
|
|
||||||
__extern void *bsearch(const void *, const void *, size_t, size_t,
|
|
||||||
__comparefunc_t);
|
|
||||||
__extern void qsort(void *, size_t, size_t, __comparefunc_t);
|
|
||||||
|
|
||||||
__extern long jrand48(unsigned short *);
|
|
||||||
__extern long mrand48(void);
|
|
||||||
__extern long nrand48(unsigned short *);
|
|
||||||
__extern long lrand48(void);
|
|
||||||
__extern unsigned short *seed48(unsigned short *);
|
|
||||||
__extern void srand48(long);
|
|
||||||
|
|
||||||
#define RAND_MAX 0x7fffffff
|
|
||||||
__extern int rand(void);
|
|
||||||
__extern void srand(unsigned int __s);
|
|
||||||
__extern long random(void);
|
|
||||||
__extern void srandom(unsigned int __s);
|
|
||||||
#endif /* __riscv_xlen == 64 */
|
|
||||||
|
|
||||||
#endif /* _STDLIB_H */
|
|
@ -1,52 +0,0 @@
|
|||||||
/*
|
|
||||||
* string.h
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _STRING_H
|
|
||||||
#define _STRING_H
|
|
||||||
|
|
||||||
#include <extern.h>
|
|
||||||
#include <stddef.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
#if __riscv_xlen == 64
|
|
||||||
__extern void memswap(void *m1, void *m2, size_t n);
|
|
||||||
__extern void *memmem(const void *haystack, size_t n, const void *needle, size_t m);
|
|
||||||
__extern char *strtok_r(char *, const char *, char **);
|
|
||||||
__extern char *strsep(char **, const char *);
|
|
||||||
#include_next <string.h>
|
|
||||||
#else
|
|
||||||
__extern void *memccpy(void *, const void *, int, size_t);
|
|
||||||
__extern void *memchr(const void *, int, size_t);
|
|
||||||
__extern void *memrchr(const void *, int, size_t);
|
|
||||||
__extern int memcmp(const void *, const void *, size_t);
|
|
||||||
__extern void *memcpy(void *, const void *, size_t);
|
|
||||||
__extern void *memmove(void *, const void *, size_t);
|
|
||||||
__extern void *memset(void *, int, size_t);
|
|
||||||
__extern void *memmem(const void *, size_t, const void *, size_t);
|
|
||||||
__extern void memswap(void *, void *, size_t);
|
|
||||||
__extern void bzero(void *, size_t);
|
|
||||||
__extern int strcasecmp(const char *, const char *);
|
|
||||||
__extern int strncasecmp(const char *, const char *, size_t);
|
|
||||||
__extern char *strcat(char *, const char *);
|
|
||||||
__extern char *strchr(const char *, int);
|
|
||||||
__extern char *strrchr(const char *, int);
|
|
||||||
__extern int strcmp(const char *, const char *);
|
|
||||||
__extern char *strcpy(char *, const char *);
|
|
||||||
__extern size_t strcspn(const char *, const char *);
|
|
||||||
__extern size_t strlen(const char *);
|
|
||||||
__extern size_t strnlen(const char *, size_t);
|
|
||||||
__extern char *strncat(char *, const char *, size_t);
|
|
||||||
__extern size_t strlcat(char *, const char *, size_t);
|
|
||||||
__extern int strncmp(const char *, const char *, size_t);
|
|
||||||
__extern char *strncpy(char *, const char *, size_t);
|
|
||||||
__extern size_t strlcpy(char *, const char *, size_t);
|
|
||||||
__extern char *strpbrk(const char *, const char *);
|
|
||||||
__extern char *strsep(char **, const char *);
|
|
||||||
__extern size_t strspn(const char *, const char *);
|
|
||||||
__extern char *strstr(const char *, const char *);
|
|
||||||
__extern char *strtok(char *, const char *);
|
|
||||||
__extern char *strtok_r(char *, const char *, char **);
|
|
||||||
char *index(const char *s, int c);
|
|
||||||
#endif /* __riscv_xlen == 64 */
|
|
||||||
|
|
||||||
#endif /* _STRING_H */
|
|
@ -1,97 +0,0 @@
|
|||||||
/*
|
|
||||||
* sys/types.h
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _SYS_TYPES_H
|
|
||||||
#define _SYS_TYPES_H
|
|
||||||
|
|
||||||
#include <stddef.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#define _SSIZE_T
|
|
||||||
typedef ptrdiff_t ssize_t;
|
|
||||||
|
|
||||||
#undef NULL
|
|
||||||
#if defined(__cplusplus)
|
|
||||||
#define NULL 0
|
|
||||||
#else
|
|
||||||
#define NULL ((void *)0)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef int daddr_t;
|
|
||||||
typedef char *caddr_t;
|
|
||||||
|
|
||||||
/* BSD */
|
|
||||||
typedef unsigned char u_char;
|
|
||||||
typedef unsigned short u_short;
|
|
||||||
typedef unsigned int u_int;
|
|
||||||
typedef unsigned long u_long;
|
|
||||||
|
|
||||||
/* SysV */
|
|
||||||
typedef unsigned char unchar;
|
|
||||||
typedef unsigned short ushort;
|
|
||||||
typedef unsigned int uint;
|
|
||||||
typedef unsigned long ulong;
|
|
||||||
|
|
||||||
/* More BSD */
|
|
||||||
typedef uint8_t u_int8_t;
|
|
||||||
typedef uint16_t u_int16_t;
|
|
||||||
typedef uint32_t u_int32_t;
|
|
||||||
typedef uint64_t u_int64_t;
|
|
||||||
|
|
||||||
/* Time related */
|
|
||||||
typedef signed int sbintime_t;
|
|
||||||
|
|
||||||
/* Required by cyassl build */
|
|
||||||
typedef long off_t;
|
|
||||||
typedef short dev_t;
|
|
||||||
typedef unsigned short ino_t;
|
|
||||||
typedef unsigned short nlink_t;
|
|
||||||
typedef unsigned short uid_t;
|
|
||||||
typedef unsigned short mode_t;
|
|
||||||
typedef unsigned short gid_t;
|
|
||||||
typedef signed char pid_t;
|
|
||||||
typedef unsigned long useconds_t;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Some headers seem to require this...
|
|
||||||
*/
|
|
||||||
#ifndef BITS_PER_LONG
|
|
||||||
#define BITS_PER_LONG 32
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The following FD_SET macros were added to solve the issue where the
|
|
||||||
* lwip/sockets.h saw different sys/types.h files when built, and when its
|
|
||||||
* header files sys/sockets file was included by the SDK.
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* Select uses bit masks of file descriptors in longs.
|
|
||||||
* These macros manipulate such bit fields (the filesystem macros use chars).
|
|
||||||
* FD_SETSIZE may be defined by the user, but the default here
|
|
||||||
* should be >= NOFILE (param.h).
|
|
||||||
*/
|
|
||||||
#ifndef FD_SET
|
|
||||||
#ifndef FD_SETSIZE
|
|
||||||
#define FD_SETSIZE 64
|
|
||||||
#endif
|
|
||||||
#define FD_SET(n, p) ((p)->fd_bits[(n) / 8] |= (1 << ((n)&7)))
|
|
||||||
#define FD_CLR(n, p) ((p)->fd_bits[(n) / 8] &= ~(1 << ((n)&7)))
|
|
||||||
#define FD_ISSET(n, p) ((p)->fd_bits[(n) / 8] & (1 << ((n)&7)))
|
|
||||||
#define FD_ZERO(p) memset((void *)(p), 0, sizeof(*(p)))
|
|
||||||
|
|
||||||
typedef struct fd_set {
|
|
||||||
unsigned char fd_bits[(FD_SETSIZE + 7) / 8];
|
|
||||||
} fd_set;
|
|
||||||
#endif /* FD_SET */
|
|
||||||
|
|
||||||
#ifndef __ICCARM__
|
|
||||||
/* wmsdk: Added from sys/times.h and machine/types.h */
|
|
||||||
#define _CLOCK_T_ unsigned long /* clock() */
|
|
||||||
#ifndef __clock_t_defined
|
|
||||||
typedef _CLOCK_T_ clock_t;
|
|
||||||
#define __clock_t_defined
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* _SYS_TYPES_H */
|
|
@ -1,103 +0,0 @@
|
|||||||
/*
|
|
||||||
* Derived from:
|
|
||||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* atof.c
|
|
||||||
*
|
|
||||||
* The atof() function
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stddef.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <ctype.h>
|
|
||||||
#include <inttypes.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
static inline int digitval(int ch)
|
|
||||||
{
|
|
||||||
if (ch >= '0' && ch <= '9') {
|
|
||||||
return ch - '0';
|
|
||||||
} else if (ch >= 'A' && ch <= 'Z') {
|
|
||||||
return ch - 'A' + 10;
|
|
||||||
} else if (ch >= 'a' && ch <= 'z') {
|
|
||||||
return ch - 'a' + 10;
|
|
||||||
} else {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
double strntof(const char *nptr, char **endptr, int base, size_t n)
|
|
||||||
{
|
|
||||||
int minus = 0;
|
|
||||||
double v = 0.0, m = 0.0, divisor = 1.0;
|
|
||||||
int d;
|
|
||||||
|
|
||||||
while (n && isspace((unsigned char)*nptr)) {
|
|
||||||
nptr++;
|
|
||||||
n--;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Single optional + or - */
|
|
||||||
if (n) {
|
|
||||||
char c = *nptr;
|
|
||||||
|
|
||||||
if (c == '-' || c == '+') {
|
|
||||||
minus = (c == '-');
|
|
||||||
nptr++;
|
|
||||||
n--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (base == 0) {
|
|
||||||
if (n >= 2 && nptr[0] == '0' &&
|
|
||||||
(nptr[1] == 'x' || nptr[1] == 'X')) {
|
|
||||||
n -= 2;
|
|
||||||
nptr += 2;
|
|
||||||
base = 16;
|
|
||||||
} else if (n >= 1 && nptr[0] == '0') {
|
|
||||||
n--;
|
|
||||||
nptr++;
|
|
||||||
base = 8;
|
|
||||||
} else {
|
|
||||||
base = 10;
|
|
||||||
}
|
|
||||||
} else if (base == 16) {
|
|
||||||
if (n >= 2 && nptr[0] == '0' &&
|
|
||||||
(nptr[1] == 'x' || nptr[1] == 'X')) {
|
|
||||||
n -= 2;
|
|
||||||
nptr += 2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
while (n && (d = digitval(*nptr)) >= 0 && d < base) {
|
|
||||||
v = v * base + d;
|
|
||||||
n--;
|
|
||||||
nptr++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (*nptr == '.') {
|
|
||||||
n--;
|
|
||||||
nptr++;
|
|
||||||
|
|
||||||
while (n && (d = digitval(*nptr)) >= 0 && d < base) {
|
|
||||||
m = m * base + d;
|
|
||||||
n--;
|
|
||||||
nptr++;
|
|
||||||
divisor *= 10.0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (endptr) {
|
|
||||||
*endptr = (char *)nptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
v = v + (m / divisor);
|
|
||||||
|
|
||||||
return minus ? -v : v;
|
|
||||||
}
|
|
||||||
|
|
||||||
double atof(const char *nptr)
|
|
||||||
{
|
|
||||||
return strntof(nptr, NULL, 0, strlen(nptr));
|
|
||||||
}
|
|
@ -1,7 +0,0 @@
|
|||||||
/*
|
|
||||||
* Derived from:
|
|
||||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
|
||||||
*/
|
|
||||||
#define TYPE int
|
|
||||||
#define NAME atoi
|
|
||||||
#include "atox.c"
|
|
@ -1,7 +0,0 @@
|
|||||||
/*
|
|
||||||
* Derived from:
|
|
||||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
|
||||||
*/
|
|
||||||
#define TYPE long
|
|
||||||
#define NAME atol
|
|
||||||
#include "atox.c"
|
|
@ -1,3 +0,0 @@
|
|||||||
#define TYPE long long
|
|
||||||
#define NAME atoll
|
|
||||||
#include "atox.c"
|
|
@ -1,19 +0,0 @@
|
|||||||
/*
|
|
||||||
* Derived from:
|
|
||||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* atox.c
|
|
||||||
*
|
|
||||||
* atoi(), atol(), atoll()
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <inttypes.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
//#include <wmlibc.h>
|
|
||||||
|
|
||||||
TYPE NAME(const char *nptr)
|
|
||||||
{
|
|
||||||
return (TYPE)strntoumax(nptr, (char **)NULL, 10, ~(size_t)0);
|
|
||||||
}
|
|
@ -1,33 +0,0 @@
|
|||||||
/*
|
|
||||||
* Derived from:
|
|
||||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* bsearch.c
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
void *bsearch(const void *key, const void *base, size_t nmemb,
|
|
||||||
size_t size, int (*cmp)(const void *, const void *))
|
|
||||||
{
|
|
||||||
while (nmemb) {
|
|
||||||
size_t mididx = nmemb / 2;
|
|
||||||
const void *midobj = (const unsigned char *)base +
|
|
||||||
mididx * size;
|
|
||||||
int diff = cmp(key, midobj);
|
|
||||||
|
|
||||||
if (diff == 0) {
|
|
||||||
return (void *)midobj;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (diff > 0) {
|
|
||||||
base = (const unsigned char *)midobj + size;
|
|
||||||
nmemb -= mididx + 1;
|
|
||||||
} else {
|
|
||||||
nmemb = mididx;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
@ -1,26 +0,0 @@
|
|||||||
/*
|
|
||||||
* Derived from:
|
|
||||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
|
||||||
*/
|
|
||||||
//#include <stdio.h>
|
|
||||||
|
|
||||||
void __assert_func(const char *file, int line,
|
|
||||||
const char *func, const char *failedexpr)
|
|
||||||
{
|
|
||||||
#if 0
|
|
||||||
printf("assertion \"%s\" failed: file \"%s\", line %d%s%s\n",
|
|
||||||
failedexpr, file, line, func ? ", function: " : "",
|
|
||||||
func ? func : "");
|
|
||||||
|
|
||||||
/* Ensure that nothing runs after this */
|
|
||||||
while(1)
|
|
||||||
;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
float strtof(const char *nptr, char **endptr)
|
|
||||||
{
|
|
||||||
// printf("Float print not supported yet!\r\n");
|
|
||||||
return 0;
|
|
||||||
}
|
|
@ -1,6 +0,0 @@
|
|||||||
/*
|
|
||||||
* Derived from:
|
|
||||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
|
||||||
*/
|
|
||||||
#include "ctypefunc.h"
|
|
||||||
CTYPEFUNC(isalnum)
|
|
@ -1,6 +0,0 @@
|
|||||||
/*
|
|
||||||
* Derived from:
|
|
||||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
|
||||||
*/
|
|
||||||
#include "ctypefunc.h"
|
|
||||||
CTYPEFUNC(isalpha)
|
|
@ -1,6 +0,0 @@
|
|||||||
/*
|
|
||||||
* Derived from:
|
|
||||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
|
||||||
*/
|
|
||||||
#include "ctypefunc.h"
|
|
||||||
CTYPEFUNC(isascii)
|
|
@ -1,6 +0,0 @@
|
|||||||
/*
|
|
||||||
* Derived from:
|
|
||||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
|
||||||
*/
|
|
||||||
#include "ctypefunc.h"
|
|
||||||
CTYPEFUNC(isblank)
|
|
@ -1,6 +0,0 @@
|
|||||||
/*
|
|
||||||
* Derived from:
|
|
||||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
|
||||||
*/
|
|
||||||
#include "ctypefunc.h"
|
|
||||||
CTYPEFUNC(iscntrl)
|
|
@ -1,6 +0,0 @@
|
|||||||
/*
|
|
||||||
* Derived from:
|
|
||||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
|
||||||
*/
|
|
||||||
#include "ctypefunc.h"
|
|
||||||
CTYPEFUNC(isdigit)
|
|
@ -1,6 +0,0 @@
|
|||||||
/*
|
|
||||||
* Derived from:
|
|
||||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
|
||||||
*/
|
|
||||||
#include "ctypefunc.h"
|
|
||||||
CTYPEFUNC(isgraph)
|
|
@ -1,6 +0,0 @@
|
|||||||
/*
|
|
||||||
* Derived from:
|
|
||||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
|
||||||
*/
|
|
||||||
#include "ctypefunc.h"
|
|
||||||
CTYPEFUNC(islower)
|
|
@ -1,6 +0,0 @@
|
|||||||
/*
|
|
||||||
* Derived from:
|
|
||||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
|
||||||
*/
|
|
||||||
#include "ctypefunc.h"
|
|
||||||
CTYPEFUNC(isprint)
|
|
@ -1,6 +0,0 @@
|
|||||||
/*
|
|
||||||
* Derived from:
|
|
||||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
|
||||||
*/
|
|
||||||
#include "ctypefunc.h"
|
|
||||||
CTYPEFUNC(ispunct)
|
|
@ -1,6 +0,0 @@
|
|||||||
/*
|
|
||||||
* Derived from:
|
|
||||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
|
||||||
*/
|
|
||||||
#include "ctypefunc.h"
|
|
||||||
CTYPEFUNC(isspace)
|
|
@ -1,6 +0,0 @@
|
|||||||
/*
|
|
||||||
* Derived from:
|
|
||||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
|
||||||
*/
|
|
||||||
#include "ctypefunc.h"
|
|
||||||
CTYPEFUNC(isupper)
|
|
@ -1,6 +0,0 @@
|
|||||||
/*
|
|
||||||
* Derived from:
|
|
||||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
|
||||||
*/
|
|
||||||
#include "ctypefunc.h"
|
|
||||||
CTYPEFUNC(isxdigit)
|
|
@ -1,6 +0,0 @@
|
|||||||
/*
|
|
||||||
* Derived from:
|
|
||||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
|
||||||
*/
|
|
||||||
#include "ctypefunc.h"
|
|
||||||
CTYPEFUNC(tolower)
|
|
@ -1,6 +0,0 @@
|
|||||||
/*
|
|
||||||
* Derived from:
|
|
||||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
|
||||||
*/
|
|
||||||
#include "ctypefunc.h"
|
|
||||||
CTYPEFUNC(toupper)
|
|
@ -1,14 +0,0 @@
|
|||||||
/*
|
|
||||||
* ctype/ctype.h
|
|
||||||
*
|
|
||||||
* Common header for out-of-line ctype functions
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define __CTYPE_NO_INLINE
|
|
||||||
#include <ctype.h>
|
|
||||||
|
|
||||||
#define CTYPEFUNC(X) \
|
|
||||||
int X(int c) \
|
|
||||||
{ \
|
|
||||||
return __ctype_##X(c); \
|
|
||||||
}
|
|
@ -1,288 +0,0 @@
|
|||||||
/*
|
|
||||||
* Derived from:
|
|
||||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* ctypes.c
|
|
||||||
*
|
|
||||||
* This is the array that defines <ctype.h> classes.
|
|
||||||
* This assumes ISO 8859-1.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <ctype.h>
|
|
||||||
|
|
||||||
const unsigned char __ctypes[257] = {
|
|
||||||
0, /* EOF */
|
|
||||||
|
|
||||||
__ctype_cntrl, /* control character */
|
|
||||||
__ctype_cntrl, /* control character */
|
|
||||||
__ctype_cntrl, /* control character */
|
|
||||||
__ctype_cntrl, /* control character */
|
|
||||||
__ctype_cntrl, /* control character */
|
|
||||||
__ctype_cntrl, /* control character */
|
|
||||||
__ctype_cntrl, /* control character */
|
|
||||||
__ctype_cntrl, /* control character */
|
|
||||||
__ctype_cntrl | __ctype_space, /* BS */
|
|
||||||
__ctype_cntrl | __ctype_space, /* TAB */
|
|
||||||
__ctype_cntrl | __ctype_space, /* LF */
|
|
||||||
__ctype_cntrl | __ctype_space, /* VT */
|
|
||||||
__ctype_cntrl | __ctype_space, /* FF */
|
|
||||||
__ctype_cntrl | __ctype_space, /* CR */
|
|
||||||
__ctype_cntrl, /* control character */
|
|
||||||
|
|
||||||
__ctype_cntrl, /* control character */
|
|
||||||
__ctype_cntrl, /* control character */
|
|
||||||
__ctype_cntrl, /* control character */
|
|
||||||
__ctype_cntrl, /* control character */
|
|
||||||
__ctype_cntrl, /* control character */
|
|
||||||
__ctype_cntrl, /* control character */
|
|
||||||
__ctype_cntrl, /* control character */
|
|
||||||
__ctype_cntrl, /* control character */
|
|
||||||
__ctype_cntrl, /* control character */
|
|
||||||
__ctype_cntrl, /* control character */
|
|
||||||
__ctype_cntrl, /* control character */
|
|
||||||
__ctype_cntrl, /* control character */
|
|
||||||
__ctype_cntrl, /* control character */
|
|
||||||
__ctype_cntrl, /* control character */
|
|
||||||
__ctype_cntrl, /* control character */
|
|
||||||
__ctype_cntrl, /* control character */
|
|
||||||
__ctype_cntrl, /* control character */
|
|
||||||
|
|
||||||
__ctype_print | __ctype_space, /* space */
|
|
||||||
__ctype_print | __ctype_punct, /* punctuation */
|
|
||||||
__ctype_print | __ctype_punct, /* punctuation */
|
|
||||||
__ctype_print | __ctype_punct, /* punctuation */
|
|
||||||
__ctype_print | __ctype_punct, /* punctuation */
|
|
||||||
__ctype_print | __ctype_punct, /* punctuation */
|
|
||||||
__ctype_print | __ctype_punct, /* punctuation */
|
|
||||||
__ctype_print | __ctype_punct, /* punctuation */
|
|
||||||
__ctype_print | __ctype_punct, /* punctuation */
|
|
||||||
__ctype_print | __ctype_punct, /* punctuation */
|
|
||||||
__ctype_print | __ctype_punct, /* punctuation */
|
|
||||||
__ctype_print | __ctype_punct, /* punctuation */
|
|
||||||
__ctype_print | __ctype_punct, /* punctuation */
|
|
||||||
__ctype_print | __ctype_punct, /* punctuation */
|
|
||||||
__ctype_print | __ctype_punct, /* punctuation */
|
|
||||||
__ctype_print | __ctype_punct, /* punctuation */
|
|
||||||
|
|
||||||
__ctype_print | __ctype_digit | __ctype_xdigit, /* digit */
|
|
||||||
__ctype_print | __ctype_digit | __ctype_xdigit, /* digit */
|
|
||||||
__ctype_print | __ctype_digit | __ctype_xdigit, /* digit */
|
|
||||||
__ctype_print | __ctype_digit | __ctype_xdigit, /* digit */
|
|
||||||
__ctype_print | __ctype_digit | __ctype_xdigit, /* digit */
|
|
||||||
__ctype_print | __ctype_digit | __ctype_xdigit, /* digit */
|
|
||||||
__ctype_print | __ctype_digit | __ctype_xdigit, /* digit */
|
|
||||||
__ctype_print | __ctype_digit | __ctype_xdigit, /* digit */
|
|
||||||
__ctype_print | __ctype_digit | __ctype_xdigit, /* digit */
|
|
||||||
__ctype_print | __ctype_digit | __ctype_xdigit, /* digit */
|
|
||||||
__ctype_print | __ctype_punct, /* punctuation */
|
|
||||||
__ctype_print | __ctype_punct, /* punctuation */
|
|
||||||
__ctype_print | __ctype_punct, /* punctuation */
|
|
||||||
__ctype_print | __ctype_punct, /* punctuation */
|
|
||||||
__ctype_print | __ctype_punct, /* punctuation */
|
|
||||||
__ctype_print | __ctype_punct, /* punctuation */
|
|
||||||
|
|
||||||
__ctype_print | __ctype_punct, /* punctuation */
|
|
||||||
__ctype_print | __ctype_upper | __ctype_xdigit, /* A-F */
|
|
||||||
__ctype_print | __ctype_upper | __ctype_xdigit, /* A-F */
|
|
||||||
__ctype_print | __ctype_upper | __ctype_xdigit, /* A-F */
|
|
||||||
__ctype_print | __ctype_upper | __ctype_xdigit, /* A-F */
|
|
||||||
__ctype_print | __ctype_upper | __ctype_xdigit, /* A-F */
|
|
||||||
__ctype_print | __ctype_upper | __ctype_xdigit, /* A-F */
|
|
||||||
__ctype_print | __ctype_upper, /* G-Z */
|
|
||||||
__ctype_print | __ctype_upper, /* G-Z */
|
|
||||||
__ctype_print | __ctype_upper, /* G-Z */
|
|
||||||
__ctype_print | __ctype_upper, /* G-Z */
|
|
||||||
__ctype_print | __ctype_upper, /* G-Z */
|
|
||||||
__ctype_print | __ctype_upper, /* G-Z */
|
|
||||||
__ctype_print | __ctype_upper, /* G-Z */
|
|
||||||
__ctype_print | __ctype_upper, /* G-Z */
|
|
||||||
__ctype_print | __ctype_upper, /* G-Z */
|
|
||||||
|
|
||||||
__ctype_print | __ctype_upper, /* G-Z */
|
|
||||||
__ctype_print | __ctype_upper, /* G-Z */
|
|
||||||
__ctype_print | __ctype_upper, /* G-Z */
|
|
||||||
__ctype_print | __ctype_upper, /* G-Z */
|
|
||||||
__ctype_print | __ctype_upper, /* G-Z */
|
|
||||||
__ctype_print | __ctype_upper, /* G-Z */
|
|
||||||
__ctype_print | __ctype_upper, /* G-Z */
|
|
||||||
__ctype_print | __ctype_upper, /* G-Z */
|
|
||||||
__ctype_print | __ctype_upper, /* G-Z */
|
|
||||||
__ctype_print | __ctype_upper, /* G-Z */
|
|
||||||
__ctype_print | __ctype_upper, /* G-Z */
|
|
||||||
__ctype_print | __ctype_punct, /* punctuation */
|
|
||||||
__ctype_print | __ctype_punct, /* punctuation */
|
|
||||||
__ctype_print | __ctype_punct, /* punctuation */
|
|
||||||
__ctype_print | __ctype_punct, /* punctuation */
|
|
||||||
__ctype_print | __ctype_punct, /* punctuation */
|
|
||||||
|
|
||||||
__ctype_print | __ctype_punct, /* punctuation */
|
|
||||||
__ctype_print | __ctype_lower | __ctype_xdigit, /* a-f */
|
|
||||||
__ctype_print | __ctype_lower | __ctype_xdigit, /* a-f */
|
|
||||||
__ctype_print | __ctype_lower | __ctype_xdigit, /* a-f */
|
|
||||||
__ctype_print | __ctype_lower | __ctype_xdigit, /* a-f */
|
|
||||||
__ctype_print | __ctype_lower | __ctype_xdigit, /* a-f */
|
|
||||||
__ctype_print | __ctype_lower | __ctype_xdigit, /* a-f */
|
|
||||||
__ctype_print | __ctype_lower, /* g-z */
|
|
||||||
__ctype_print | __ctype_lower, /* g-z */
|
|
||||||
__ctype_print | __ctype_lower, /* g-z */
|
|
||||||
__ctype_print | __ctype_lower, /* g-z */
|
|
||||||
__ctype_print | __ctype_lower, /* g-z */
|
|
||||||
__ctype_print | __ctype_lower, /* g-z */
|
|
||||||
__ctype_print | __ctype_lower, /* g-z */
|
|
||||||
__ctype_print | __ctype_lower, /* g-z */
|
|
||||||
__ctype_print | __ctype_lower, /* g-z */
|
|
||||||
|
|
||||||
__ctype_print | __ctype_lower, /* g-z */
|
|
||||||
__ctype_print | __ctype_lower, /* g-z */
|
|
||||||
__ctype_print | __ctype_lower, /* g-z */
|
|
||||||
__ctype_print | __ctype_lower, /* g-z */
|
|
||||||
__ctype_print | __ctype_lower, /* g-z */
|
|
||||||
__ctype_print | __ctype_lower, /* g-z */
|
|
||||||
__ctype_print | __ctype_lower, /* g-z */
|
|
||||||
__ctype_print | __ctype_lower, /* g-z */
|
|
||||||
__ctype_print | __ctype_lower, /* g-z */
|
|
||||||
__ctype_print | __ctype_lower, /* g-z */
|
|
||||||
__ctype_print | __ctype_lower, /* g-z */
|
|
||||||
__ctype_print | __ctype_punct, /* punctuation */
|
|
||||||
__ctype_print | __ctype_punct, /* punctuation */
|
|
||||||
__ctype_print | __ctype_punct, /* punctuation */
|
|
||||||
__ctype_print | __ctype_punct, /* punctuation */
|
|
||||||
__ctype_cntrl, /* control character */
|
|
||||||
|
|
||||||
__ctype_cntrl, /* control character */
|
|
||||||
__ctype_cntrl, /* control character */
|
|
||||||
__ctype_cntrl, /* control character */
|
|
||||||
__ctype_cntrl, /* control character */
|
|
||||||
__ctype_cntrl, /* control character */
|
|
||||||
__ctype_cntrl, /* control character */
|
|
||||||
__ctype_cntrl, /* control character */
|
|
||||||
__ctype_cntrl, /* control character */
|
|
||||||
__ctype_cntrl, /* control character */
|
|
||||||
__ctype_cntrl, /* control character */
|
|
||||||
__ctype_cntrl, /* control character */
|
|
||||||
__ctype_cntrl, /* control character */
|
|
||||||
__ctype_cntrl, /* control character */
|
|
||||||
__ctype_cntrl, /* control character */
|
|
||||||
__ctype_cntrl, /* control character */
|
|
||||||
__ctype_cntrl, /* control character */
|
|
||||||
|
|
||||||
__ctype_cntrl, /* control character */
|
|
||||||
__ctype_cntrl, /* control character */
|
|
||||||
__ctype_cntrl, /* control character */
|
|
||||||
__ctype_cntrl, /* control character */
|
|
||||||
__ctype_cntrl, /* control character */
|
|
||||||
__ctype_cntrl, /* control character */
|
|
||||||
__ctype_cntrl, /* control character */
|
|
||||||
__ctype_cntrl, /* control character */
|
|
||||||
__ctype_cntrl, /* control character */
|
|
||||||
__ctype_cntrl, /* control character */
|
|
||||||
__ctype_cntrl, /* control character */
|
|
||||||
__ctype_cntrl, /* control character */
|
|
||||||
__ctype_cntrl, /* control character */
|
|
||||||
__ctype_cntrl, /* control character */
|
|
||||||
__ctype_cntrl, /* control character */
|
|
||||||
__ctype_cntrl, /* control character */
|
|
||||||
|
|
||||||
__ctype_print | __ctype_space, /* NBSP */
|
|
||||||
__ctype_print | __ctype_punct, /* punctuation */
|
|
||||||
__ctype_print | __ctype_punct, /* punctuation */
|
|
||||||
__ctype_print | __ctype_punct, /* punctuation */
|
|
||||||
__ctype_print | __ctype_punct, /* punctuation */
|
|
||||||
__ctype_print | __ctype_punct, /* punctuation */
|
|
||||||
__ctype_print | __ctype_punct, /* punctuation */
|
|
||||||
__ctype_print | __ctype_punct, /* punctuation */
|
|
||||||
__ctype_print | __ctype_punct, /* punctuation */
|
|
||||||
__ctype_print | __ctype_punct, /* punctuation */
|
|
||||||
__ctype_print | __ctype_punct, /* punctuation */
|
|
||||||
__ctype_print | __ctype_punct, /* punctuation */
|
|
||||||
__ctype_print | __ctype_punct, /* punctuation */
|
|
||||||
__ctype_print | __ctype_punct, /* punctuation */
|
|
||||||
__ctype_print | __ctype_punct, /* punctuation */
|
|
||||||
__ctype_print | __ctype_punct, /* punctuation */
|
|
||||||
|
|
||||||
__ctype_print | __ctype_punct, /* punctuation */
|
|
||||||
__ctype_print | __ctype_punct, /* punctuation */
|
|
||||||
__ctype_print | __ctype_punct, /* punctuation */
|
|
||||||
__ctype_print | __ctype_punct, /* punctuation */
|
|
||||||
__ctype_print | __ctype_punct, /* punctuation */
|
|
||||||
__ctype_print | __ctype_punct, /* punctuation */
|
|
||||||
__ctype_print | __ctype_punct, /* punctuation */
|
|
||||||
__ctype_print | __ctype_punct, /* punctuation */
|
|
||||||
__ctype_print | __ctype_punct, /* punctuation */
|
|
||||||
__ctype_print | __ctype_punct, /* punctuation */
|
|
||||||
__ctype_print | __ctype_punct, /* punctuation */
|
|
||||||
__ctype_print | __ctype_punct, /* punctuation */
|
|
||||||
__ctype_print | __ctype_punct, /* punctuation */
|
|
||||||
__ctype_print | __ctype_punct, /* punctuation */
|
|
||||||
__ctype_print | __ctype_punct, /* punctuation */
|
|
||||||
__ctype_print | __ctype_punct, /* punctuation */
|
|
||||||
|
|
||||||
__ctype_print | __ctype_upper, /* upper accented */
|
|
||||||
__ctype_print | __ctype_upper, /* upper accented */
|
|
||||||
__ctype_print | __ctype_upper, /* upper accented */
|
|
||||||
__ctype_print | __ctype_upper, /* upper accented */
|
|
||||||
__ctype_print | __ctype_upper, /* upper accented */
|
|
||||||
__ctype_print | __ctype_upper, /* upper accented */
|
|
||||||
__ctype_print | __ctype_upper, /* upper accented */
|
|
||||||
__ctype_print | __ctype_upper, /* upper accented */
|
|
||||||
__ctype_print | __ctype_upper, /* upper accented */
|
|
||||||
__ctype_print | __ctype_upper, /* upper accented */
|
|
||||||
__ctype_print | __ctype_upper, /* upper accented */
|
|
||||||
__ctype_print | __ctype_upper, /* upper accented */
|
|
||||||
__ctype_print | __ctype_upper, /* upper accented */
|
|
||||||
__ctype_print | __ctype_upper, /* upper accented */
|
|
||||||
__ctype_print | __ctype_upper, /* upper accented */
|
|
||||||
__ctype_print | __ctype_upper, /* upper accented */
|
|
||||||
|
|
||||||
__ctype_print | __ctype_upper, /* upper accented */
|
|
||||||
__ctype_print | __ctype_upper, /* upper accented */
|
|
||||||
__ctype_print | __ctype_upper, /* upper accented */
|
|
||||||
__ctype_print | __ctype_upper, /* upper accented */
|
|
||||||
__ctype_print | __ctype_upper, /* upper accented */
|
|
||||||
__ctype_print | __ctype_upper, /* upper accented */
|
|
||||||
__ctype_print | __ctype_upper, /* upper accented */
|
|
||||||
__ctype_print | __ctype_punct, /* punctuation */
|
|
||||||
__ctype_print | __ctype_upper, /* upper accented */
|
|
||||||
__ctype_print | __ctype_upper, /* upper accented */
|
|
||||||
__ctype_print | __ctype_upper, /* upper accented */
|
|
||||||
__ctype_print | __ctype_upper, /* upper accented */
|
|
||||||
__ctype_print | __ctype_upper, /* upper accented */
|
|
||||||
__ctype_print | __ctype_upper, /* upper accented */
|
|
||||||
__ctype_print | __ctype_upper, /* upper accented */
|
|
||||||
__ctype_print | __ctype_lower, /* lower accented */
|
|
||||||
|
|
||||||
__ctype_print | __ctype_lower, /* lower accented */
|
|
||||||
__ctype_print | __ctype_lower, /* lower accented */
|
|
||||||
__ctype_print | __ctype_lower, /* lower accented */
|
|
||||||
__ctype_print | __ctype_lower, /* lower accented */
|
|
||||||
__ctype_print | __ctype_lower, /* lower accented */
|
|
||||||
__ctype_print | __ctype_lower, /* lower accented */
|
|
||||||
__ctype_print | __ctype_lower, /* lower accented */
|
|
||||||
__ctype_print | __ctype_lower, /* lower accented */
|
|
||||||
__ctype_print | __ctype_lower, /* lower accented */
|
|
||||||
__ctype_print | __ctype_lower, /* lower accented */
|
|
||||||
__ctype_print | __ctype_lower, /* lower accented */
|
|
||||||
__ctype_print | __ctype_lower, /* lower accented */
|
|
||||||
__ctype_print | __ctype_lower, /* lower accented */
|
|
||||||
__ctype_print | __ctype_lower, /* lower accented */
|
|
||||||
__ctype_print | __ctype_lower, /* lower accented */
|
|
||||||
__ctype_print | __ctype_lower, /* lower accented */
|
|
||||||
|
|
||||||
__ctype_print | __ctype_lower, /* lower accented */
|
|
||||||
__ctype_print | __ctype_lower, /* lower accented */
|
|
||||||
__ctype_print | __ctype_lower, /* lower accented */
|
|
||||||
__ctype_print | __ctype_lower, /* lower accented */
|
|
||||||
__ctype_print | __ctype_lower, /* lower accented */
|
|
||||||
__ctype_print | __ctype_lower, /* lower accented */
|
|
||||||
__ctype_print | __ctype_lower, /* lower accented */
|
|
||||||
__ctype_print | __ctype_punct, /* punctuation */
|
|
||||||
__ctype_print | __ctype_lower, /* lower accented */
|
|
||||||
__ctype_print | __ctype_lower, /* lower accented */
|
|
||||||
__ctype_print | __ctype_lower, /* lower accented */
|
|
||||||
__ctype_print | __ctype_lower, /* lower accented */
|
|
||||||
__ctype_print | __ctype_lower, /* lower accented */
|
|
||||||
__ctype_print | __ctype_lower, /* lower accented */
|
|
||||||
__ctype_print | __ctype_lower, /* lower accented */
|
|
||||||
__ctype_print | __ctype_lower, /* lower accented */
|
|
||||||
};
|
|
@ -1,97 +0,0 @@
|
|||||||
/*
|
|
||||||
* Derived from:
|
|
||||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* fnmatch.c
|
|
||||||
*
|
|
||||||
* Original implementation by Kay Sievers, modified by H. Peter Anvin.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <fnmatch.h>
|
|
||||||
|
|
||||||
int fnmatch(const char *p, const char *s, int flags)
|
|
||||||
{
|
|
||||||
if (flags & FNM_PATHNAME && *s == '/') {
|
|
||||||
return (*p != '/') || fnmatch(p + 1, s + 1, flags);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (flags & FNM_PERIOD && *s == '.') {
|
|
||||||
return (*p != '.') || fnmatch(p + 1, s + 1, flags);
|
|
||||||
}
|
|
||||||
|
|
||||||
flags &= ~FNM_PERIOD; /* Only applies at beginning */
|
|
||||||
|
|
||||||
if (!(flags & FNM_NOESCAPE) && *p == '\\') {
|
|
||||||
p++;
|
|
||||||
return (*p != *s) || fnmatch(p + 1, s + 1, flags);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (*s == '\0') {
|
|
||||||
while (*p == '*') {
|
|
||||||
p++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (*p != '\0');
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (*p) {
|
|
||||||
case '[': {
|
|
||||||
int not_mark = 0;
|
|
||||||
p++;
|
|
||||||
|
|
||||||
if (*p == '!') {
|
|
||||||
not_mark = 1;
|
|
||||||
p++;
|
|
||||||
}
|
|
||||||
|
|
||||||
while ((*p != '\0') && (*p != ']')) {
|
|
||||||
int match = 0;
|
|
||||||
|
|
||||||
if (p[1] == '-') {
|
|
||||||
if ((*s >= *p) && (*s <= p[2])) {
|
|
||||||
match = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
p += 3;
|
|
||||||
} else {
|
|
||||||
match = (*p == *s);
|
|
||||||
p++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (match ^ not_mark) {
|
|
||||||
while ((*p != '\0') && (*p != ']')) {
|
|
||||||
p++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (*p == ']') {
|
|
||||||
return fnmatch(p + 1, s + 1, flags);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} break;
|
|
||||||
|
|
||||||
case '*':
|
|
||||||
if (fnmatch(p, s + 1, flags)) {
|
|
||||||
return fnmatch(p + 1, s, flags);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
case '\0':
|
|
||||||
if (*s == '\0') {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
if ((*p == *s) || (*p == '?')) {
|
|
||||||
return fnmatch(p + 1, s + 1, flags);
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
@ -1,28 +0,0 @@
|
|||||||
/*
|
|
||||||
* Derived from:
|
|
||||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* jrand48.c
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
long jrand48(unsigned short xsubi[3])
|
|
||||||
{
|
|
||||||
uint64_t x;
|
|
||||||
|
|
||||||
/* The xsubi[] array is littleendian by spec */
|
|
||||||
x = (uint64_t)(uint16_t)xsubi[0] +
|
|
||||||
((uint64_t)(uint16_t)xsubi[1] << 16) +
|
|
||||||
((uint64_t)(uint16_t)xsubi[2] << 32);
|
|
||||||
|
|
||||||
x = (0x5deece66dULL * x) + 0xb;
|
|
||||||
|
|
||||||
xsubi[0] = (unsigned short)(uint16_t)x;
|
|
||||||
xsubi[1] = (unsigned short)(uint16_t)(x >> 16);
|
|
||||||
xsubi[2] = (unsigned short)(uint16_t)(x >> 32);
|
|
||||||
|
|
||||||
return (long)(int32_t)(x >> 16);
|
|
||||||
}
|
|
@ -1,27 +0,0 @@
|
|||||||
/*
|
|
||||||
* Derived from:
|
|
||||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* lrand48.c
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
unsigned short __rand48_seed[3]; /* Common with mrand48.c, srand48.c */
|
|
||||||
|
|
||||||
long lrand48(void)
|
|
||||||
{
|
|
||||||
return (uint32_t)jrand48(__rand48_seed) >> 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int rand(void)
|
|
||||||
{
|
|
||||||
return (int)lrand48();
|
|
||||||
}
|
|
||||||
|
|
||||||
long random(void)
|
|
||||||
{
|
|
||||||
return lrand48();
|
|
||||||
}
|
|
@ -1,29 +0,0 @@
|
|||||||
/*
|
|
||||||
* Derived from:
|
|
||||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* memccpy.c
|
|
||||||
*
|
|
||||||
* memccpy()
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stddef.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
void *memccpy(void *dst, const void *src, int c, size_t n)
|
|
||||||
{
|
|
||||||
char *q = (char *)dst;
|
|
||||||
const char *p = (char *)src;
|
|
||||||
char ch;
|
|
||||||
|
|
||||||
while (n--) {
|
|
||||||
*q++ = ch = *p++;
|
|
||||||
|
|
||||||
if (ch == (char)c) {
|
|
||||||
return q;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL; /* No instance of "c" found */
|
|
||||||
}
|
|
@ -1,25 +0,0 @@
|
|||||||
/*
|
|
||||||
* Derived from:
|
|
||||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* memchr.c
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stddef.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
void *memchr(const void *s, int c, size_t n)
|
|
||||||
{
|
|
||||||
const unsigned char *sp = (unsigned char *)s;
|
|
||||||
|
|
||||||
while (n--) {
|
|
||||||
if (*sp == (unsigned char)c) {
|
|
||||||
return (void *)sp;
|
|
||||||
}
|
|
||||||
|
|
||||||
sp++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
@ -1,25 +0,0 @@
|
|||||||
/*
|
|
||||||
* Derived from:
|
|
||||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* memcmp.c
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
int memcmp(const void *s1, const void *s2, size_t n)
|
|
||||||
{
|
|
||||||
const unsigned char *c1 = (unsigned char *)s1, *c2 = (unsigned char *)s2;
|
|
||||||
int d = 0;
|
|
||||||
|
|
||||||
while (n--) {
|
|
||||||
d = (int)*c1++ - (int)*c2++;
|
|
||||||
|
|
||||||
if (d) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return d;
|
|
||||||
}
|
|
@ -1,18 +0,0 @@
|
|||||||
/*
|
|
||||||
* memcpy.c
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
void *memcpy(void *dst, const void *src, size_t n)
|
|
||||||
{
|
|
||||||
const char *p = (char *)src;
|
|
||||||
char *q = (char *)dst;
|
|
||||||
|
|
||||||
while (n--) {
|
|
||||||
*q++ = *p++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return dst;
|
|
||||||
}
|
|
@ -1,61 +0,0 @@
|
|||||||
/*
|
|
||||||
* Derived from:
|
|
||||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* memmem.c
|
|
||||||
*
|
|
||||||
* Find a byte string inside a longer byte string
|
|
||||||
*
|
|
||||||
* This uses the "Not So Naive" algorithm, a very simple but
|
|
||||||
* usually effective algorithm, see:
|
|
||||||
*
|
|
||||||
* http://www-igm.univ-mlv.fr/~lecroq/string/
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
void *memmem(const void *haystack, size_t n, const void *needle, size_t m)
|
|
||||||
{
|
|
||||||
const unsigned char *y = (const unsigned char *)haystack;
|
|
||||||
const unsigned char *x = (const unsigned char *)needle;
|
|
||||||
|
|
||||||
size_t j, k, l;
|
|
||||||
|
|
||||||
if (m > n || !m || !n) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (1 != m) {
|
|
||||||
if (x[0] == x[1]) {
|
|
||||||
k = 2;
|
|
||||||
l = 1;
|
|
||||||
} else {
|
|
||||||
k = 1;
|
|
||||||
l = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
j = 0;
|
|
||||||
|
|
||||||
while (j <= n - m) {
|
|
||||||
if (x[1] != y[j + 1]) {
|
|
||||||
j += k;
|
|
||||||
} else {
|
|
||||||
if (!memcmp(x + 2, y + j + 2, m - 2) && x[0] == y[j]) {
|
|
||||||
return (void *)&y[j];
|
|
||||||
}
|
|
||||||
|
|
||||||
j += l;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
do {
|
|
||||||
if (*y == *x) {
|
|
||||||
return (void *)y;
|
|
||||||
}
|
|
||||||
|
|
||||||
y++;
|
|
||||||
} while (--n);
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
@ -1,25 +0,0 @@
|
|||||||
/*
|
|
||||||
* Derived from:
|
|
||||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* memrchr.c
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stddef.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
void *memrchr(const void *s, int c, size_t n)
|
|
||||||
{
|
|
||||||
const unsigned char *sp = (const unsigned char *)s + n - 1;
|
|
||||||
|
|
||||||
while (n--) {
|
|
||||||
if (*sp == (unsigned char)c) {
|
|
||||||
return (void *)sp;
|
|
||||||
}
|
|
||||||
|
|
||||||
sp--;
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
@ -1,19 +0,0 @@
|
|||||||
/*
|
|
||||||
* memset.c
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
void *memset(void *dst, int c, size_t n)
|
|
||||||
{
|
|
||||||
char *q = (char *)dst;
|
|
||||||
|
|
||||||
while (n--) {
|
|
||||||
*q++ = c;
|
|
||||||
__asm volatile("" ::
|
|
||||||
: "memory");
|
|
||||||
}
|
|
||||||
|
|
||||||
return dst;
|
|
||||||
}
|
|
@ -1,28 +0,0 @@
|
|||||||
/*
|
|
||||||
* Derived from:
|
|
||||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* memswap()
|
|
||||||
*
|
|
||||||
* Swaps the contents of two nonoverlapping memory areas.
|
|
||||||
* This really could be done faster...
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
void memswap(void *m1, void *m2, size_t n)
|
|
||||||
{
|
|
||||||
char *p = (char *)m1;
|
|
||||||
char *q = (char *)m2;
|
|
||||||
char tmp;
|
|
||||||
|
|
||||||
while (n--) {
|
|
||||||
tmp = *p;
|
|
||||||
*p = *q;
|
|
||||||
*q = tmp;
|
|
||||||
|
|
||||||
p++;
|
|
||||||
q++;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,18 +0,0 @@
|
|||||||
/*
|
|
||||||
* Derived from:
|
|
||||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* mrand48.c
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
/* Common with lrand48.c, srand48.c */
|
|
||||||
extern unsigned short __rand48_seed[3];
|
|
||||||
|
|
||||||
long mrand48(void)
|
|
||||||
{
|
|
||||||
return jrand48(__rand48_seed);
|
|
||||||
}
|
|
@ -1,15 +0,0 @@
|
|||||||
/*
|
|
||||||
* Derived from:
|
|
||||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* nrand48.c
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
long nrand48(unsigned short xsubi[3])
|
|
||||||
{
|
|
||||||
return (long)((uint32_t)jrand48(xsubi) >> 1);
|
|
||||||
}
|
|
@ -1,58 +0,0 @@
|
|||||||
/*
|
|
||||||
* Derived from:
|
|
||||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* qsort.c
|
|
||||||
*
|
|
||||||
* This is actually combsort. It's an O(n log n) algorithm with
|
|
||||||
* simplicity/small code size being its main virtue.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stddef.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
//#include <wmlibc.h>
|
|
||||||
|
|
||||||
static __inline size_t newgap(size_t gap)
|
|
||||||
{
|
|
||||||
gap = (gap * 10) / 13;
|
|
||||||
|
|
||||||
if (gap == 9 || gap == 10) {
|
|
||||||
gap = 11;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (gap < 1) {
|
|
||||||
gap = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return gap;
|
|
||||||
}
|
|
||||||
|
|
||||||
void qsort(void *base, size_t nmemb, size_t size,
|
|
||||||
int (*compar)(const void *, const void *))
|
|
||||||
{
|
|
||||||
size_t gap = nmemb;
|
|
||||||
size_t i, j;
|
|
||||||
char *p1, *p2;
|
|
||||||
int swapped;
|
|
||||||
|
|
||||||
if (!nmemb) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
do {
|
|
||||||
gap = newgap(gap);
|
|
||||||
swapped = 0;
|
|
||||||
|
|
||||||
for (i = 0, p1 = (char *)base; i < nmemb - gap; i++, p1 += size) {
|
|
||||||
j = i + gap;
|
|
||||||
|
|
||||||
if (compar(p1, p2 = (char *)base + j * size) > 0) {
|
|
||||||
memswap(p1, p2, size);
|
|
||||||
swapped = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} while (gap > 1 || swapped);
|
|
||||||
}
|
|
@ -1,22 +0,0 @@
|
|||||||
/*
|
|
||||||
* Derived from:
|
|
||||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* seed48.c
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
extern unsigned short __rand48_seed[3];
|
|
||||||
|
|
||||||
unsigned short *seed48(unsigned short int xsubi[3])
|
|
||||||
{
|
|
||||||
static unsigned short oldseed[3];
|
|
||||||
memcpy(oldseed, __rand48_seed, sizeof __rand48_seed);
|
|
||||||
memcpy(__rand48_seed, xsubi, sizeof __rand48_seed);
|
|
||||||
|
|
||||||
return oldseed;
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
/*
|
|
||||||
* Derived from:
|
|
||||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* snprintf.c
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdarg.h>
|
|
||||||
|
|
||||||
int snprintf(char *buffer, size_t n, const char *format, ...)
|
|
||||||
{
|
|
||||||
va_list ap;
|
|
||||||
int rv;
|
|
||||||
|
|
||||||
va_start(ap, format);
|
|
||||||
rv = vsnprintf(buffer, n, format, ap);
|
|
||||||
va_end(ap);
|
|
||||||
return rv;
|
|
||||||
}
|
|
@ -1,22 +0,0 @@
|
|||||||
/*
|
|
||||||
* Derived from:
|
|
||||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* sprintf.c
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdarg.h>
|
|
||||||
|
|
||||||
int sprintf(char *buffer, const char *format, ...)
|
|
||||||
{
|
|
||||||
va_list ap;
|
|
||||||
int rv;
|
|
||||||
|
|
||||||
va_start(ap, format);
|
|
||||||
rv = vsnprintf(buffer, (~(unsigned int)0) >> 1, format, ap);
|
|
||||||
va_end(ap);
|
|
||||||
|
|
||||||
return rv;
|
|
||||||
}
|
|
@ -1,30 +0,0 @@
|
|||||||
/*
|
|
||||||
* Derived from:
|
|
||||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* srand48.c
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
/* Common with mrand48.c, lrand48.c */
|
|
||||||
extern unsigned short __rand48_seed[3];
|
|
||||||
|
|
||||||
void srand48(long seedval)
|
|
||||||
{
|
|
||||||
__rand48_seed[0] = 0x330e;
|
|
||||||
__rand48_seed[1] = (unsigned short)seedval;
|
|
||||||
__rand48_seed[2] = (unsigned short)((uint32_t)seedval >> 16);
|
|
||||||
}
|
|
||||||
|
|
||||||
void srand(unsigned int __s)
|
|
||||||
{
|
|
||||||
srand48(__s);
|
|
||||||
}
|
|
||||||
|
|
||||||
void srandom(unsigned int __s)
|
|
||||||
{
|
|
||||||
srand48(__s);
|
|
||||||
}
|
|
@ -1,22 +0,0 @@
|
|||||||
/*
|
|
||||||
* Derived from:
|
|
||||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* sscanf()
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdarg.h>
|
|
||||||
|
|
||||||
int sscanf(const char *str, const char *format, ...)
|
|
||||||
{
|
|
||||||
va_list ap;
|
|
||||||
int rv;
|
|
||||||
|
|
||||||
va_start(ap, format);
|
|
||||||
rv = vsscanf(str, format, ap);
|
|
||||||
va_end(ap);
|
|
||||||
|
|
||||||
return rv;
|
|
||||||
}
|
|
@ -1,31 +0,0 @@
|
|||||||
/*
|
|
||||||
* Derived from:
|
|
||||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
|
||||||
*
|
|
||||||
* This functions implement WMSDK specific memory allocator routines.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <malloc.h>
|
|
||||||
|
|
||||||
#ifndef BFLB_IN_BENCHMARK
|
|
||||||
void *malloc(size_t size)
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void free(void *ptr)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void *calloc(size_t nmemb, size_t size)
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void *realloc(void *ptr, size_t size)
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
@ -1,30 +0,0 @@
|
|||||||
/*
|
|
||||||
* Derived from:
|
|
||||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* strcasecmp.c
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
#include <ctype.h>
|
|
||||||
|
|
||||||
int strcasecmp(const char *s1, const char *s2)
|
|
||||||
{
|
|
||||||
const unsigned char *c1 = (const unsigned char *)s1;
|
|
||||||
const unsigned char *c2 = (const unsigned char *)s2;
|
|
||||||
unsigned char ch;
|
|
||||||
int d = 0;
|
|
||||||
|
|
||||||
while (1) {
|
|
||||||
/* toupper() expects an unsigned char (implicitly cast to int)
|
|
||||||
as input, and returns an int, which is exactly what we want. */
|
|
||||||
d = toupper(ch = *c1++) - toupper(*c2++);
|
|
||||||
|
|
||||||
if (d || !ch) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return d;
|
|
||||||
}
|
|
@ -1,15 +0,0 @@
|
|||||||
/*
|
|
||||||
* Derived from:
|
|
||||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* strcat.c
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
char *strcat(char *dst, const char *src)
|
|
||||||
{
|
|
||||||
strcpy(strchr(dst, '\0'), src);
|
|
||||||
return dst;
|
|
||||||
}
|
|
@ -1,24 +0,0 @@
|
|||||||
/*
|
|
||||||
* Derived from:
|
|
||||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* strchr.c
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
#include <compat_attribute.h>
|
|
||||||
|
|
||||||
__WEAK__
|
|
||||||
char *strchr(const char *s, int c)
|
|
||||||
{
|
|
||||||
while (*s != (char)c) {
|
|
||||||
if (!*s) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
s++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (char *)s;
|
|
||||||
}
|
|
@ -1,31 +0,0 @@
|
|||||||
/*
|
|
||||||
* Derived from:
|
|
||||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* strcmp.c
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#ifdef BFLB_IN_BENCHMARK
|
|
||||||
int bflb_strcmp(const char *s1, const char *s2)
|
|
||||||
#else
|
|
||||||
int strcmp(const char *s1, const char *s2)
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
const unsigned char *c1 = (const unsigned char *)s1;
|
|
||||||
const unsigned char *c2 = (const unsigned char *)s2;
|
|
||||||
unsigned char ch;
|
|
||||||
int d = 0;
|
|
||||||
|
|
||||||
while (1) {
|
|
||||||
d = (int)(ch = *c1++) - (int)*c2++;
|
|
||||||
|
|
||||||
if (d || !ch) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return d;
|
|
||||||
}
|
|
@ -1,24 +0,0 @@
|
|||||||
/*
|
|
||||||
* Derived from:
|
|
||||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* strcpy.c
|
|
||||||
*
|
|
||||||
* strcpy()
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
char *strcpy(char *dst, const char *src)
|
|
||||||
{
|
|
||||||
char *q = dst;
|
|
||||||
const char *p = src;
|
|
||||||
char ch;
|
|
||||||
|
|
||||||
do {
|
|
||||||
*q++ = ch = *p++;
|
|
||||||
} while (ch);
|
|
||||||
|
|
||||||
return dst;
|
|
||||||
}
|
|
@ -1,16 +0,0 @@
|
|||||||
/*
|
|
||||||
* Derived from:
|
|
||||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* strcspn
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include "strxspn.h"
|
|
||||||
|
|
||||||
size_t strcspn(const char *s, const char *reject)
|
|
||||||
{
|
|
||||||
return __strxspn(s, reject, 1);
|
|
||||||
}
|
|
@ -1,37 +0,0 @@
|
|||||||
/*
|
|
||||||
* Derived from:
|
|
||||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* strlcat.c
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
size_t strlcat(char *dst, const char *src, size_t size)
|
|
||||||
{
|
|
||||||
size_t bytes = 0;
|
|
||||||
char *q = dst;
|
|
||||||
const char *p = src;
|
|
||||||
char ch;
|
|
||||||
|
|
||||||
while (bytes < size && *q) {
|
|
||||||
q++;
|
|
||||||
bytes++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bytes == size) {
|
|
||||||
return (bytes + strlen(src));
|
|
||||||
}
|
|
||||||
|
|
||||||
while ((ch = *p++)) {
|
|
||||||
if (bytes + 1 < size) {
|
|
||||||
*q++ = ch;
|
|
||||||
}
|
|
||||||
|
|
||||||
bytes++;
|
|
||||||
}
|
|
||||||
|
|
||||||
*q = '\0';
|
|
||||||
return bytes;
|
|
||||||
}
|
|
@ -1,32 +0,0 @@
|
|||||||
/*
|
|
||||||
* Derived from:
|
|
||||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* strlcpy.c
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
size_t strlcpy(char *dst, const char *src, size_t size)
|
|
||||||
{
|
|
||||||
size_t bytes = 0;
|
|
||||||
char *q = dst;
|
|
||||||
const char *p = src;
|
|
||||||
char ch;
|
|
||||||
|
|
||||||
while ((ch = *p++)) {
|
|
||||||
if (bytes + 1 < size) {
|
|
||||||
*q++ = ch;
|
|
||||||
}
|
|
||||||
|
|
||||||
bytes++;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If size == 0 there is no space for a final null... */
|
|
||||||
if (size) {
|
|
||||||
*q = '\0';
|
|
||||||
}
|
|
||||||
|
|
||||||
return bytes;
|
|
||||||
}
|
|
@ -1,20 +0,0 @@
|
|||||||
/*
|
|
||||||
* Derived from:
|
|
||||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* strlen()
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
size_t strlen(const char *s)
|
|
||||||
{
|
|
||||||
const char *ss = s;
|
|
||||||
|
|
||||||
while (*ss) {
|
|
||||||
ss++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ss - s;
|
|
||||||
}
|
|
@ -1,30 +0,0 @@
|
|||||||
/*
|
|
||||||
* Derived from:
|
|
||||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* strncasecmp.c
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
#include <ctype.h>
|
|
||||||
|
|
||||||
int strncasecmp(const char *s1, const char *s2, size_t n)
|
|
||||||
{
|
|
||||||
const unsigned char *c1 = (const unsigned char *)s1;
|
|
||||||
const unsigned char *c2 = (const unsigned char *)s2;
|
|
||||||
unsigned char ch;
|
|
||||||
int d = 0;
|
|
||||||
|
|
||||||
while (n--) {
|
|
||||||
/* toupper() expects an unsigned char (implicitly cast to int)
|
|
||||||
as input, and returns an int, which is exactly what we want. */
|
|
||||||
d = toupper(ch = *c1++) - toupper(*c2++);
|
|
||||||
|
|
||||||
if (d || !ch) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return d;
|
|
||||||
}
|
|
@ -1,28 +0,0 @@
|
|||||||
/*
|
|
||||||
* Derived from:
|
|
||||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* strncat.c
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
char *strncat(char *dst, const char *src, size_t n)
|
|
||||||
{
|
|
||||||
char *q = strchr(dst, '\0');
|
|
||||||
const char *p = src;
|
|
||||||
char ch;
|
|
||||||
|
|
||||||
while (n--) {
|
|
||||||
*q++ = ch = *p++;
|
|
||||||
|
|
||||||
if (!ch) {
|
|
||||||
return dst;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
*q = '\0';
|
|
||||||
|
|
||||||
return dst;
|
|
||||||
}
|
|
@ -1,27 +0,0 @@
|
|||||||
/*
|
|
||||||
* Derived from:
|
|
||||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* strncmp.c
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
int strncmp(const char *s1, const char *s2, size_t n)
|
|
||||||
{
|
|
||||||
const unsigned char *c1 = (const unsigned char *)s1;
|
|
||||||
const unsigned char *c2 = (const unsigned char *)s2;
|
|
||||||
unsigned char ch;
|
|
||||||
int d = 0;
|
|
||||||
|
|
||||||
while (n--) {
|
|
||||||
d = (int)(ch = *c1++) - (int)*c2++;
|
|
||||||
|
|
||||||
if (d || !ch) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return d;
|
|
||||||
}
|
|
@ -1,30 +0,0 @@
|
|||||||
/*
|
|
||||||
* Derived from:
|
|
||||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* strncpy.c
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
char *strncpy(char *dst, const char *src, size_t n)
|
|
||||||
{
|
|
||||||
char *q = dst;
|
|
||||||
const char *p = src;
|
|
||||||
char ch;
|
|
||||||
|
|
||||||
while (n) {
|
|
||||||
n--;
|
|
||||||
*q++ = ch = *p++;
|
|
||||||
|
|
||||||
if (!ch) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* The specs say strncpy() fills the entire buffer with NUL. Sigh. */
|
|
||||||
memset(q, 0, n);
|
|
||||||
|
|
||||||
return dst;
|
|
||||||
}
|
|
@ -1,23 +0,0 @@
|
|||||||
/*
|
|
||||||
* Derived from:
|
|
||||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* strnlen()
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
size_t strnlen(const char *s, size_t maxlen)
|
|
||||||
{
|
|
||||||
const char *ss = s;
|
|
||||||
|
|
||||||
/* Important: the maxlen test must precede the reference through ss;
|
|
||||||
since the byte beyond the maximum may segfault */
|
|
||||||
while ((maxlen > 0) && *ss) {
|
|
||||||
ss++;
|
|
||||||
maxlen--;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ss - s;
|
|
||||||
}
|
|
@ -1,18 +0,0 @@
|
|||||||
/*
|
|
||||||
* Derived from:
|
|
||||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* strntoimax.c
|
|
||||||
*
|
|
||||||
* strntoimax()
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stddef.h>
|
|
||||||
#include <inttypes.h>
|
|
||||||
//#include <wmlibc.h>
|
|
||||||
|
|
||||||
intmax_t strntoimax(const char *nptr, char **endptr, int base, size_t n)
|
|
||||||
{
|
|
||||||
return (intmax_t)strntoumax(nptr, endptr, base, n);
|
|
||||||
}
|
|
@ -1,83 +0,0 @@
|
|||||||
/*
|
|
||||||
* Derived from:
|
|
||||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* strntoumax.c
|
|
||||||
*
|
|
||||||
* The strntoumax() function and associated
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stddef.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <ctype.h>
|
|
||||||
#include <inttypes.h>
|
|
||||||
|
|
||||||
static __inline int digitval(int ch)
|
|
||||||
{
|
|
||||||
if (ch >= '0' && ch <= '9') {
|
|
||||||
return ch - '0';
|
|
||||||
} else if (ch >= 'A' && ch <= 'Z') {
|
|
||||||
return ch - 'A' + 10;
|
|
||||||
} else if (ch >= 'a' && ch <= 'z') {
|
|
||||||
return ch - 'a' + 10;
|
|
||||||
} else {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
uintmax_t strntoumax(const char *nptr, char **endptr, int base, size_t n)
|
|
||||||
{
|
|
||||||
int minus = 0;
|
|
||||||
uintmax_t v = 0;
|
|
||||||
int d;
|
|
||||||
|
|
||||||
while (n && isspace((unsigned char)*nptr)) {
|
|
||||||
nptr++;
|
|
||||||
n--;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Single optional + or - */
|
|
||||||
if (n) {
|
|
||||||
char c = *nptr;
|
|
||||||
|
|
||||||
if (c == '-' || c == '+') {
|
|
||||||
minus = (c == '-');
|
|
||||||
nptr++;
|
|
||||||
n--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (base == 0) {
|
|
||||||
if (n >= 2 && nptr[0] == '0' &&
|
|
||||||
(nptr[1] == 'x' || nptr[1] == 'X')) {
|
|
||||||
n -= 2;
|
|
||||||
nptr += 2;
|
|
||||||
base = 16;
|
|
||||||
} else if (n >= 1 && nptr[0] == '0') {
|
|
||||||
n--;
|
|
||||||
nptr++;
|
|
||||||
base = 8;
|
|
||||||
} else {
|
|
||||||
base = 10;
|
|
||||||
}
|
|
||||||
} else if (base == 16) {
|
|
||||||
if (n >= 2 && nptr[0] == '0' &&
|
|
||||||
(nptr[1] == 'x' || nptr[1] == 'X')) {
|
|
||||||
n -= 2;
|
|
||||||
nptr += 2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
while (n && (d = digitval(*nptr)) >= 0 && d < base) {
|
|
||||||
v = v * base + d;
|
|
||||||
n--;
|
|
||||||
nptr++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (endptr) {
|
|
||||||
*endptr = (char *)nptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
return minus ? -v : v;
|
|
||||||
}
|
|
@ -1,18 +0,0 @@
|
|||||||
/*
|
|
||||||
* Derived from:
|
|
||||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* strpbrk
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include "strxspn.h"
|
|
||||||
|
|
||||||
char *strpbrk(const char *s, const char *accept)
|
|
||||||
{
|
|
||||||
const char *ss = s + __strxspn(s, accept, 1);
|
|
||||||
|
|
||||||
return *ss ? (char *)ss : NULL;
|
|
||||||
}
|
|
@ -1,24 +0,0 @@
|
|||||||
/*
|
|
||||||
* Derived from:
|
|
||||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* strrchr.c
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
char *strrchr(const char *s, int c)
|
|
||||||
{
|
|
||||||
const char *found = NULL;
|
|
||||||
|
|
||||||
while (*s) {
|
|
||||||
if (*s == (char)c) {
|
|
||||||
found = s;
|
|
||||||
}
|
|
||||||
|
|
||||||
s++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (char *)found;
|
|
||||||
}
|
|
@ -1,28 +0,0 @@
|
|||||||
/*
|
|
||||||
* Derived from:
|
|
||||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* strsep.c
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
char *strsep(char **stringp, const char *delim)
|
|
||||||
{
|
|
||||||
char *s = *stringp;
|
|
||||||
char *e;
|
|
||||||
|
|
||||||
if (!s) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
e = strpbrk(s, delim);
|
|
||||||
|
|
||||||
if (e) {
|
|
||||||
*e++ = '\0';
|
|
||||||
}
|
|
||||||
|
|
||||||
*stringp = e;
|
|
||||||
return s;
|
|
||||||
}
|
|
@ -1,16 +0,0 @@
|
|||||||
/*
|
|
||||||
* Derived from:
|
|
||||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* strspn
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include "strxspn.h"
|
|
||||||
|
|
||||||
size_t strspn(const char *s, const char *accept)
|
|
||||||
{
|
|
||||||
return __strxspn(s, accept, 0);
|
|
||||||
}
|
|
@ -1,16 +0,0 @@
|
|||||||
/*
|
|
||||||
* Derived from:
|
|
||||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* strstr.c
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
//#include <wmlibc.h>
|
|
||||||
|
|
||||||
char *strstr(const char *haystack, const char *needle)
|
|
||||||
{
|
|
||||||
return (char *)memmem(haystack, strlen(haystack), needle,
|
|
||||||
strlen(needle));
|
|
||||||
}
|
|
@ -1,7 +0,0 @@
|
|||||||
/*
|
|
||||||
* Derived from:
|
|
||||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
|
||||||
*/
|
|
||||||
#define TYPE intmax_t
|
|
||||||
#define NAME strtoimax
|
|
||||||
#include "strtox.c"
|
|
@ -1,16 +0,0 @@
|
|||||||
/*
|
|
||||||
* Derived from:
|
|
||||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* strtok.c
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
char *strtok(char *s, const char *delim)
|
|
||||||
{
|
|
||||||
static char *holder;
|
|
||||||
|
|
||||||
return strtok_r(s, delim, &holder);
|
|
||||||
}
|
|
@ -1,18 +0,0 @@
|
|||||||
/*
|
|
||||||
* Derived from:
|
|
||||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
|
||||||
*/
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
char *strtok_r(char *s, const char *delim, char **holder)
|
|
||||||
{
|
|
||||||
if (s) {
|
|
||||||
*holder = s;
|
|
||||||
}
|
|
||||||
|
|
||||||
do {
|
|
||||||
s = strsep(holder, delim);
|
|
||||||
} while (s && !*s);
|
|
||||||
|
|
||||||
return s;
|
|
||||||
}
|
|
@ -1,7 +0,0 @@
|
|||||||
/*
|
|
||||||
* Derived from:
|
|
||||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
|
||||||
*/
|
|
||||||
#define TYPE signed long
|
|
||||||
#define NAME strtol
|
|
||||||
#include "strtox.c"
|
|
@ -1,7 +0,0 @@
|
|||||||
/*
|
|
||||||
* Derived from:
|
|
||||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
|
||||||
*/
|
|
||||||
#define TYPE signed long long
|
|
||||||
#define NAME strtoll
|
|
||||||
#include "strtox.c"
|
|
@ -1,7 +0,0 @@
|
|||||||
/*
|
|
||||||
* Derived from:
|
|
||||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
|
||||||
*/
|
|
||||||
#define TYPE unsigned long
|
|
||||||
#define NAME strtoul
|
|
||||||
#include "strtox.c"
|
|
@ -1,7 +0,0 @@
|
|||||||
/*
|
|
||||||
* Derived from:
|
|
||||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
|
||||||
*/
|
|
||||||
#define TYPE unsigned long long
|
|
||||||
#define NAME strtoull
|
|
||||||
#include "strtox.c"
|
|
@ -1,7 +0,0 @@
|
|||||||
/*
|
|
||||||
* Derived from:
|
|
||||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
|
||||||
*/
|
|
||||||
#define TYPE uintmax_t
|
|
||||||
#define NAME strtoumax
|
|
||||||
#include "strtox.c"
|
|
@ -1,19 +0,0 @@
|
|||||||
/*
|
|
||||||
* Derived from:
|
|
||||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* strtox.c
|
|
||||||
*
|
|
||||||
* strto...() functions, by macro definition
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stddef.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <inttypes.h>
|
|
||||||
#include <gcc.h>
|
|
||||||
|
|
||||||
WEAK TYPE NAME(const char *nptr, char **endptr, int base)
|
|
||||||
{
|
|
||||||
return (TYPE)strntoumax(nptr, endptr, base, ~(size_t)0);
|
|
||||||
}
|
|
@ -1,36 +0,0 @@
|
|||||||
/*
|
|
||||||
* Derived from:
|
|
||||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* strpbrk
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
#include <stddef.h>
|
|
||||||
#include <inttypes.h>
|
|
||||||
#include <limits.h>
|
|
||||||
#include "strxspn.h"
|
|
||||||
|
|
||||||
size_t __strxspn(const char *s, const char *map, int parity)
|
|
||||||
{
|
|
||||||
char matchmap[UCHAR_MAX + 1];
|
|
||||||
size_t n = 0;
|
|
||||||
|
|
||||||
/* Create bitmap */
|
|
||||||
memset(matchmap, 0, sizeof matchmap);
|
|
||||||
|
|
||||||
while (*map) {
|
|
||||||
matchmap[(unsigned char)*map++] = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Make sure the null character never matches */
|
|
||||||
matchmap[0] = parity;
|
|
||||||
|
|
||||||
/* Calculate span length */
|
|
||||||
while (matchmap[(unsigned char)*s++] ^ parity) {
|
|
||||||
n++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return n;
|
|
||||||
}
|
|
@ -1,12 +0,0 @@
|
|||||||
/*
|
|
||||||
* strxspn.h
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef STRXSPN_H
|
|
||||||
#define STRXSPN_H
|
|
||||||
|
|
||||||
#include <stddef.h>
|
|
||||||
|
|
||||||
extern size_t __strxspn(const char *s, const char *map, int parity);
|
|
||||||
|
|
||||||
#endif
|
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user