Fix windows link error and clear windows warnings (#2463)

- Fix windows wamrc link error: aot_generate_tempfile_name undefined.
- Clear windows compile warnings.
- And rename folder `samples/bh_atomic` and `samples/mem_allocator` to
  `samples/bh-atomic` and `samples/mem-allocator`.
This commit is contained in:
Wenyong Huang
2023-08-14 19:04:49 +08:00
committed by GitHub
parent e360b7a919
commit 923e8d6471
7 changed files with 46 additions and 18 deletions

View File

@ -0,0 +1,20 @@
# Copyright (C) 2023 Midokura Japan KK. All rights reserved.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
cmake_minimum_required(VERSION 3.0)
project(bh_atomic)
string (TOLOWER ${CMAKE_HOST_SYSTEM_NAME} WAMR_BUILD_PLATFORM)
if(APPLE)
add_definitions(-DBH_PLATFORM_DARWIN)
endif()
set(WAMR_BUILD_INTERP 1)
set(WAMR_BUILD_LIBC_BUILTIN 0)
set(WAMR_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../..)
include(${WAMR_ROOT_DIR}/build-scripts/runtime_lib.cmake)
add_executable(bh_atomic main.c)
target_link_libraries(bh_atomic)

42
samples/bh-atomic/main.c Normal file
View File

@ -0,0 +1,42 @@
/*
* Copyright (C) 2023 Midokura Japan KK. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#include <assert.h>
#include "bh_platform.h"
#include "bh_atomic.h"
int
main(int argc, char **argv)
{
bh_atomic_32_t v;
uint32 o;
v = 0x00ff00ff;
o = BH_ATOMIC_32_LOAD(v);
assert(o == 0x00ff00ff);
v = 0x00ff00ff;
o = BH_ATOMIC_32_FETCH_OR(v, 0xffff0000);
assert(o == 0x00ff00ff);
assert(v == 0xffff00ff);
v = 0x00ff00ff;
o = BH_ATOMIC_32_FETCH_AND(v, 0xffff0000);
assert(o == 0x00ff00ff);
assert(v == 0x00ff0000);
v = 0x00ff00ff;
o = BH_ATOMIC_32_FETCH_ADD(v, 0x10101);
assert(o == 0x00ff00ff);
assert(v == 0x00ff00ff + 0x10101);
v = 0x00ff00ff;
o = BH_ATOMIC_32_FETCH_SUB(v, 0x10101);
assert(o == 0x00ff00ff);
assert(v == 0x00ff00ff - 0x10101);
return 0;
}