Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

frameworks/wasm: Add kvdb missing interface in frameworks #5

Merged
merged 1 commit into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions kvdb/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# ##############################################################################
# apps/frameworks/chre/CMakeLists.txt
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you 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.
#
# ##############################################################################

if(CONFIG_KVDB AND CONFIG_INTERPRETERS_WAMR_EXTERNAL_MODULE_REGISTRY)

target_sources(apps PRIVATE kvdb.c)
# register WAMR mod
nuttx_add_wamrmod(MODS kvdb)
endif()
23 changes: 23 additions & 0 deletions kvdb/Make.defs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
############################################################################
# apps/frameworks/runtimes/wasm/chre/Make.defs
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you 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.
#
############################################################################

ifeq ($(CONFIG_KVDB)$(CONFIG_INTERPRETERS_WAMR_EXTERNAL_MODULE_REGISTRY),yy)
CONFIGURED_APPS += $(APPDIR)/frameworks/runtimes/wasm/kvdb
endif
35 changes: 35 additions & 0 deletions kvdb/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
############################################################################
# apps/frameworks/wasm/chre/Makefile
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you 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 $(APPDIR)/Make.defs

CSRCS += kvdb.c

# To delete the Kconfig file, an empty preconfig needs to be added.
preconfig::

# Set WAMR_MODULE_NAME and include Module.mk to add this module to the list of
# builtin modules for the WAMR runtime. WAMR_MODULE_NAME must be unique across all
# modules in system.

WAMR_MODULE_NAME = kvdb

include $(APPDIR)/interpreters/wamr/Module.mk
include $(APPDIR)/Application.mk
53 changes: 53 additions & 0 deletions kvdb/kvdb.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* Copyright (C) 2024 Xiaomi Corperation
*
* 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.
*/

/****************************************************************************
* Included Files
****************************************************************************/

#include <stdint.h>
#include <sys/param.h>

#include "kvdb.h"
#include "wasm_export.h"

/****************************************************************************
* Private Functions
****************************************************************************/

static int property_set_buffer_wrapper(wasm_exec_env_t env,
const char* key,
const void* value,
size_t size)
{
return property_set_buffer(key, value, size);
}

static NativeSymbol g_kvdb_symbols[] = {
EXPORT_WASM_API_WITH_SIG2(property_set_buffer, "($*i)i"),
};

/****************************************************************************
* Public Functions
****************************************************************************/

bool wamr_module_kvdb_register(void)
{
/* Add frameworks section init hook here */

return wasm_runtime_register_natives("env", g_kvdb_symbols,
nitems(g_kvdb_symbols));
}
Loading