提交 1ebc07fa 编写于 作者: H haotuo

Add ohos ident flag for x86_64 library compile and fix x86 compile error

fixed 3a9781c4 from https://gitee.com/shawshank506/third_party_musl/pulls/572
fixed x86 compile from :https://gitee.com/openharmony/third_party_musl/pulls/667

Change-Id: Ib980b4d783087a48cd1d8e008726dbcc5db7e317
Signed-off-by: Nhaotuo <haotuo@huawei.com>
上级 da950515
...@@ -2131,6 +2131,8 @@ musl_src_porting_file = [ ...@@ -2131,6 +2131,8 @@ musl_src_porting_file = [
"src/time/gettimeofday.c", "src/time/gettimeofday.c",
"src/time/time.c", "src/time/time.c",
"src/stdio/__fdopen.c", "src/stdio/__fdopen.c",
"src/linux/cache.c",
"src/sched/sched_getcpu.c",
] ]
musl_inc_hook_files = [ musl_inc_hook_files = [
......
.include "crtbrand.s"
.section .init
.global _init
_init:
push %rax
.section .fini
.global _fini
_fini:
push %rax
/* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <errno.h>
#include "syscall.h"
#include "atomic.h"
#ifdef SYS_cacheflush
int _flush_cache(void *addr, int len, int op)
{
return syscall(SYS_cacheflush, addr, len, op);
}
weak_alias(_flush_cache, cacheflush);
#endif
#ifdef SYS_cachectl
int __cachectl(void *addr, int len, int op)
{
return syscall(SYS_cachectl, addr, len, op);
}
weak_alias(__cachectl, cachectl);
#endif
#ifdef SYS_riscv_flush_icache
#define VDSO_FLUSH_ICACHE_SYM "__vdso_flush_icache"
#define VDSO_FLUSH_ICACHE_VER "LINUX_4.5"
static void *volatile vdso_func;
static int flush_icache_init(void *start, void *end, unsigned long int flags)
{
__get_vdso_info();
void *p = __get_vdso_addr(VDSO_FLUSH_ICACHE_VER, VDSO_FLUSH_ICACHE_SYM);
int (*f)(void *, void *, unsigned long int) =
(int (*)(void *, void *, unsigned long int))p;
a_cas_p(&vdso_func, (void *)flush_icache_init, p);
return f ? f(start, end, flags) : -ENOSYS;
}
static void *volatile vdso_func = (void *)flush_icache_init;
int __riscv_flush_icache(void *start, void *end, unsigned long int flags)
{
int (*f)(void *, void *, unsigned long int) =
(int (*)(void *, void *, unsigned long int))vdso_func;
if (f) {
int r = f(start, end, flags);
if (!r) return r;
if (r != -ENOSYS) return __syscall_ret(r);
}
}
weak_alias(__riscv_flush_icache, riscv_flush_icache);
#endif
/* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#define _GNU_SOURCE
#include <errno.h>
#include <sched.h>
#include "syscall.h"
#include "atomic.h"
#ifdef VDSO_GETCPU_SYM
static void *volatile vdso_func;
typedef long (*getcpu_f)(unsigned *, unsigned *, void *);
static long getcpu_init(unsigned *cpu, unsigned *node, void *unused)
{
__get_vdso_info();
void *p = __get_vdso_addr(VDSO_GETCPU_VER, VDSO_GETCPU_SYM);
getcpu_f f = (getcpu_f)p;
a_cas_p(&vdso_func, (void *)getcpu_init, p);
return f ? f(cpu, node, unused) : -ENOSYS;
}
static void *volatile vdso_func = (void *)getcpu_init;
#endif
int sched_getcpu(void)
{
int r;
unsigned cpu;
#ifdef VDSO_GETCPU_SYM
getcpu_f f = (getcpu_f)vdso_func;
if (f) {
r = f(&cpu, 0, 0);
if (!r) return cpu;
if (r != -ENOSYS) return __syscall_ret(r);
}
#endif
r = __syscall(SYS_getcpu, &cpu, 0, 0);
if (!r) return cpu;
return __syscall_ret(r);
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册