提交 9ea63d56 编写于 作者: C Caoruihong

feat: add BUILD.gn and byteorder related posix apis for porting/liteos_m/kernel

add BUILD.gn for liteos_m kernel portings.
add new posix api: htonl, htons, ntohl, ntohs
Signed-off-by: NCaoruihong <crh.cao@huawei.com>
Change-Id: I3581032659bdc68e98a9470050549faf9f8cbcbb
上级 66ba9b70
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. 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. Neither the name of the copyright holder 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 COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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.
libc = "musl-c"
libm = "musl-m"
config("include") {
include_dirs = [
"include",
]
}
static_library(libc) {
sources = [
#"src/errno/strerror.c",
"src/internal/shgetc.c",
"src/internal/intscan.c",
"src/stdlib/atoi.c",
#"src/stdlib/strtol.c",
"src/stdlib/atol.c",
"src/stdlib/atoll.c",
"src/stdlib/abs.c",
"src/network/h_errno.c",
"src/network/htonl.c",
"src/network/htons.c",
"src/network/ntohl.c",
"src/network/ntohs.c",
"src/exit/abort.c",
"src/exit/assert.c",
"src/ctype/isascii.c",
"src/ctype/isxdigit.c",
"src/ctype/isdigit.c",
"src/ctype/isupper.c",
"src/ctype/isspace.c",
"src/ctype/isalnum.c",
"src/ctype/islower.c",
"src/ctype/tolower.c",
"src/ctype/toupper.c",
"src/ctype/isprint.c",
"src/misc/dirname.c",
"src/locale/__lctrans.c",
"src/locale/langinfo.c",
"src/locale/c_locale.c",
"src/stdio/fputs.c",
"src/stdio/__stdio_close.c",
"src/stdio/fflush.c",
"src/stdio/__toread.c",
"src/stdio/ofl_add.c",
"src/stdio/__stdio_seek.c",
"src/stdio/__uflow.c",
"src/stdio/ftell.c",
"src/stdio/__stdio_read.c",
"src/stdio/fwrite.c",
"src/stdio/fread.c",
"src/stdio/fclose.c",
"src/stdio/stderr.c",
"src/stdio/fileno.c",
"src/stdio/perror.c",
"src/stdio/__lockfile.c",
"src/stdio/fgets.c",
"src/stdio/clearerr.c",
"src/stdio/__stdio_write.c",
"src/stdio/__fmodeflags.c",
"src/stdio/__fdopen.c",
"src/stdio/ofl.c",
"src/stdio/fseek.c",
"src/stdio/__stdout_write.c",
"src/stdio/rewind.c",
"src/stdio/__towrite.c",
"src/stdio/feof.c",
"src/stdio/fopen.c",
"src/stdio/stdout.c",
"src/time/strptime.c",
"src/time/strftime.c",
"src/time/__year_to_secs.c",
"src/time/__month_to_secs.c",
"src/time/__tz.c",
"src/time/__tm_to_secs.c",
"src/prng/random.c",
"src/regex/regexec.c",
"src/regex/regcomp.c",
"src/regex/tre-mem.c",
"src/string/strrchr.c",
"src/string/memcmp.c",
"src/string/strcspn.c",
"src/string/strstr.c",
"src/string/strchrnul.c",
"src/string/strchr.c",
"src/string/memcpy.c",
"src/string/strncmp.c",
"src/string/strcasecmp.c",
"src/string/strcmp.c",
"src/string/strncasecmp.c",
"src/string/memchr.c",
"src/string/memrchr.c",
"src/string/strdup.c",
"src/string/wcslen.c",
"src/string/memset.c",
"src/string/strlen.c",
"src/string/wcschr.c",
]
include_dirs = [
"src/include",
"src/internal",
]
include_dirs += [
"//kernel/liteos_m/kernel/arch/include",
"//kernel/liteos_m/kernel/include",
"//kernel/liteos_m/utils",
]
public_configs = [ ":include" ]
}
static_library(libm) {
sources = [
"src/math/pow.c",
"src/math/log.c",
"src/math/sqrt.c",
"src/math/pow_data.c",
"src/math/log_data.c",
"src/math/exp_data.c",
"src/math/round.c",
]
include_dirs = [
"src/include",
"src/internal",
]
public_configs = [ ":include" ]
}
group("kernel") {
public_deps = [
":$libc",
":$libm",
]
}
#include <netinet/in.h>
#include <byteswap.h>
uint32_t htonl(uint32_t n)
{
union { int i; char c; } u = { 1 };
return u.c ? bswap_32(n) : n;
}
#include <netinet/in.h>
#include <byteswap.h>
uint16_t htons(uint16_t n)
{
union { int i; char c; } u = { 1 };
return u.c ? bswap_16(n) : n;
}
#include <netinet/in.h>
#include <byteswap.h>
uint32_t ntohl(uint32_t n)
{
union { int i; char c; } u = { 1 };
return u.c ? bswap_32(n) : n;
}
#include <netinet/in.h>
#include <byteswap.h>
uint16_t ntohs(uint16_t n)
{
union { int i; char c; } u = { 1 };
return u.c ? bswap_16(n) : n;
}
......@@ -34,4 +34,10 @@ int __fclose(FILE *f)
return r;
}
weak_alias(__fclose, fclose);
\ No newline at end of file
weak_alias(__fclose, fclose);
int __wrap_fclose(FILE *f)
{
return __fclose(f);
}
......@@ -46,3 +46,9 @@ int __fflush(FILE *f)
weak_alias(fflush, fflush_unlocked);
weak_alias(__fflush, fflush);
int __wrap_fflush(FILE *f)
{
return __fflush(f);
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册