Remove unused files and update license header of some files (#138)

This commit is contained in:
wenyongh 2019-11-11 20:38:49 -06:00 committed by GitHub
parent b0b0789dca
commit be15c08cf3
26 changed files with 44 additions and 1375 deletions

View File

@ -178,7 +178,7 @@
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "{}"
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright {yyyy} {name of copyright owner}
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.

View File

@ -1,17 +0,0 @@
# Copyright (C) 2019 Intel Corporation. All rights reserved.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
include_directories (.
include
platform/include
platform/${PLATFORM}
../classlib/include
utils/coap/er-coap
utils/coap/extension
../external/iwasm/include)
file (GLOB_RECURSE source_all ../../app-manager/*.c)
add_library (appmgrlib ${source_all})

View File

@ -1,7 +1,7 @@
/*
* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
EXPORT_WASM_API(wasm_open_connection),
EXPORT_WASM_API(wasm_close_connection),

View File

@ -1,7 +1,7 @@
/*
* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
/* button */
EXPORT_WASM_API(wasm_btn_native_call),

View File

@ -1,7 +1,7 @@
/*
* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
EXPORT_WASM_API(wasm_sensor_open),
EXPORT_WASM_API(wasm_sensor_config),

View File

@ -1,78 +0,0 @@
/*
* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
/**
* @file errcode.h
* @date Wed Feb 29 18:58:30 2012
*
* @brief Host-visible error code definition
*/
#ifndef BEIHAI_ERRCODE_H
#define BEIHAI_ERRCODE_H
/**
* Responses to all remote requests from host to Beihai runtime has a
* return error code, which is used to indicate the processing result:
* successful or any error occurs. The following definitions include
* all those error codes that may be returned to host.
*/
enum {
BHE_SUCCESS = 0x000, /* Successful */
/* General errors: 0x100 */
BHE_OUT_OF_MEMORY = 0x101, /* Out of memory */
BHE_BAD_PARAMETER = 0x102, /* Bad parameters to native */
BHE_INSUFFICIENT_BUFFER = 0x103,
BHE_MUTEX_INIT_FAIL = 0x104,
BHE_COND_INIT_FAIL = 0x105, /* Cond init fail is not return to
* host now, it may be used later.
*/
BHE_WD_TIMEOUT = 0x106, /* Watchdog time out */
/* Communication: 0x200 */
BHE_MAILBOX_NOT_FOUND = 0x201, /* Mailbox not found */
BHE_MSG_QUEUE_IS_FULL = 0x202, /* Message queue is full */
BHE_MAILBOX_DENIED = 0x203, /* Mailbox is denied by firewall */
/* Applet manager: 0x300 */
BHE_LOAD_JEFF_FAIL = 0x303, /* JEFF file load fail, OOM or file
* format error not distinct by
* current JEFF loading
* process (bool jeff_loader_load).
*/
BHE_PACKAGE_NOT_FOUND = 0x304, /* Request operation on a package,
* but it does not exist.
*/
BHE_EXIST_LIVE_SESSION = 0x305, /* Uninstall package fail because of
* live session exist.
*/
BHE_VM_INSTANCE_INIT_FAIL = 0x306, /* VM instance init fail when create
* session.
*/
BHE_QUERY_PROP_NOT_SUPPORT = 0x307, /* Query applet property that Beihai
* does not support.
*/
BHE_INVALID_BPK_FILE = 0x308, /* Incorrect Beihai package format */
BHE_VM_INSTNACE_NOT_FOUND = 0x312, /* VM instance not found */
BHE_STARTING_JDWP_FAIL = 0x313, /* JDWP agent starting fail */
BHE_GROUP_CHECK_FAIL = 0x314, /* Group access checking fail*/
/* Applet instance: 0x400 */
BHE_UNCAUGHT_EXCEPTION = 0x401, /* uncaught exception */
BHE_APPLET_BAD_PARAMETER = 0x402, /* Bad parameters to applet */
BHE_APPLET_SMALL_BUFFER = 0x403, /* Small response buffer */
/*TODO: Should be removed these UI error code when integrate with ME 9 */
/* UI: 0x500 */
BHE_UI_EXCEPTION = 0x501,
BHE_UI_ILLEGAL_USE = 0x502,
BHE_UI_ILLEGAL_PARAMETER = 0x503,
BHE_UI_NOT_INITIALIZED = 0x504,
BHE_UI_NOT_SUPPORTED = 0x505,
BHE_UI_OUT_OF_RESOURCES = 0x506
};
#endif

View File

@ -1,149 +0,0 @@
/*
* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#ifndef _KORP_TYPES_H
#define _KORP_TYPES_H
#include "bh_platform.h"
/* all types used in kORP should be explicit sized */
typedef struct _korp_object korp_object;
typedef unsigned int obj_info;
typedef korp_object* ref;
#define BYTES_OF_OBJ_INFO 4
#define BYTES_OF_REF 4
/* don't change the number, it's hardcoded in kORP */
enum _korp_array_type {
ARRAY_UINT8 = 0, /* bytes_of_uint8 = 1 << ARRAY_UINT8 */
ARRAY_UINT16 = 1, /* bytes_of_uint16 = 1 << ARRAY_UINT16 */
ARRAY_UINT32 = 2, /* bytes_of_uint32 = 1 << ARRAY_UINT32 */
ARRAY_UINT64 = 3, /* bytes_of_uint64 = 1 << ARRAY_UINT64 */
ARRAY_BOOLEAN = 4,
ARRAY_CHAR = 5,
ARRAY_FLOAT = 6,
ARRAY_DOUBLE = 7,
ARRAY_BYTE = 8,
ARRAY_SHORT = 9,
ARRAY_INT = 10,
ARRAY_LONG = 11,
ARRAY_REF = 12 /* for calculation */
};
enum _korp_java_type {
JAVA_TYPE_WRONG = 0,
JAVA_TYPE_BYTE = 'B',
JAVA_TYPE_CHAR = 'C',
JAVA_TYPE_DOUBLE = 'D',
JAVA_TYPE_FLOAT = 'F',
JAVA_TYPE_INT = 'I',
JAVA_TYPE_LONG = 'J',
JAVA_TYPE_SHORT = 'S',
JAVA_TYPE_BOOLEAN = 'Z',
JAVA_TYPE_CLASS = 'L',
JAVA_TYPE_ARRAY = '[',
JAVA_TYPE_VOID = 'V',
JAVA_TYPE_STRING = '$' /* for TAG_String const value */
};
enum korp_modifier_type {
MOD_PUBLIC = 0x0001, /* Class Field Method */
MOD_PRIVATE = 0x0002, /* Field Method */
MOD_PROTECTED = 0x0004, /* Field Method */
MOD_STATIC = 0x0008, /* Field Method */
MOD_FINAL = 0x0010, /* Class Field Method */
MOD_SUPER = 0x0020, /* Class */
MOD_SYNCHRONIZED = 0x0020, /* Method */
MOD_VOLATILE = 0x0040, /* Field */
MOD_TRANSIENT = 0x0080, /* Field */
MOD_NATIVE = 0x0100, /* Method */
MOD_INTERFACE = 0x0200, /* Class */
MOD_ABSTRACT = 0x0400, /* Class Method */
MOD_STRICT = 0x0800 /* Method */
};
/* object header, used to access object info */
struct _korp_object {
obj_info header; /* object header (I) */
};
#define HASH_TABLE_SIZE 359
#ifndef NULL
#define NULL (void*)0
#endif
#define KORP_ERROR (-1)
#ifndef __cplusplus
#define true 1
#define false 0
#define inline __inline
#endif
/* forwarded declarations */
typedef struct _korp_string_pool korp_string_pool;
typedef struct _korp_class_table korp_class_table;
typedef enum _korp_loader_exception {
LD_OK = 0,
LD_NoClassDefFoundError,
LD_ClassFormatError,
LD_ClassCircularityError,
LD_IncompatibleClassChangeError,
LD_AbstractMethodError, /* occurs during preparation */
LD_IllegalAccessError,
LD_InstantiationError,
LD_NoSuchFieldError,
LD_NoSuchMethodError,
LD_UnsatisfiedLinkError,
LD_VerifyError
} korp_loader_exception;
typedef enum _korp_java_type korp_java_type;
typedef enum _korp_array_type korp_array_type;
/* typedef struct _korp_thread korp_thread; */
typedef struct _korp_method korp_method;
typedef struct _korp_field korp_field;
typedef struct _korp_class korp_class;
typedef struct _korp_string korp_string;
typedef struct _korp_package korp_package;
typedef struct _korp_class_loader korp_class_loader;
typedef struct _korp_ref_array korp_ref_array;
typedef struct _korp_entry korp_entry;
typedef struct _korp_preloaded korp_preloaded;
typedef struct _korp_env korp_env;
typedef struct _korp_java_array korp_java_array;
typedef struct _korp_uint8_array korp_uint8_array;
typedef struct _korp_vm_thread_list korp_vm_thread_list;
#define korp_uint8 korp_uint32
#define korp_uint16 korp_uint32
#define korp_boolean korp_uint32
#define korp_char korp_uint32
#define korp_short korp_uint32
#define korp_int korp_uint32
#define korp_float korp_uint32
#define korp_long korp_uint64
#define korp_double korp_uint64
#define korp_boolean_array korp_uint8_array
#define korp_char_array korp_uint8_array
#define korp_short_array korp_uint16_array
#define korp_int_array korp_uint32_array
#define korp_float_array korp_uint32_array
#define korp_double_array korp_uint64_array
#define korp_long_array korp_uint64_array
#define korp_code korp_uint8_array
#endif /* #ifndef _KORP_TYPES_H */

View File

@ -1,18 +1,7 @@
/*
* INTEL CONFIDENTIAL
*
* Copyright 2017-2018 Intel Corporation
*
* This software and the related documents are Intel copyrighted materials,
* and your use of them is governed by the express license under which they
* were provided to you (License). Unless the License provides otherwise, you
* may not use, modify, copy, publish, distribute, disclose or transmit this
* software or the related documents without Intel's prior written permission.
*
* This software and the related documents are provided as is, with no express
* or implied warranties, other than those that are expressly stated in the
* License.
*/
* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#include "bh_thread.h"
#include "bh_assert.h"

View File

@ -1,58 +0,0 @@
/*
* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#include "bh_platform.h"
#include "bh_assert.h"
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#ifdef BH_TEST
#include <setjmp.h>
#endif
#ifdef BH_TEST
/* for exception throwing */
jmp_buf bh_test_jb;
#endif
void bh_assert_internal(int v, const char *file_name, int line_number,
const char *expr_string)
{
if (v)
return;
if (!file_name)
file_name = "NULL FILENAME";
if (!expr_string)
expr_string = "NULL EXPR_STRING";
printf("\nASSERTION FAILED: %s, at FILE=%s, LINE=%d\n", expr_string,
file_name, line_number);
#ifdef BH_TEST
longjmp(bh_test_jb, 1);
#endif
abort();
}
void bh_debug_internal(const char *file_name, int line_number, const char *fmt,
...)
{
#ifndef JEFF_TEST_VERIFIER
va_list args;
va_start(args, fmt);
bh_assert(file_name);
printf("\nDebug info FILE=%s, LINE=%d: ", file_name, line_number);
vprintf(fmt, args);
va_end(args);
printf("\n");
#endif
}

View File

@ -1,70 +0,0 @@
/*
* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#include "bh_definition.h"
#include "bh_platform.h"
int bh_return(int ret)
{
return ret;
}
#define RSIZE_MAX 0x7FFFFFFF
int b_memcpy_s(void * s1, unsigned int s1max, const void * s2, unsigned int n)
{
char *dest = (char*) s1;
char *src = (char*) s2;
if (n == 0) {
return 0;
}
if (s1 == NULL || s1max > RSIZE_MAX) {
return -1;
}
if (s2 == NULL || n > s1max) {
memset(dest, 0, s1max);
return -1;
}
memcpy(dest, src, n);
return 0;
}
int b_strcat_s(char * s1, size_t s1max, const char * s2)
{
if (NULL
== s1|| NULL == s2 || s1max < (strlen(s1) + strlen(s2) + 1) || s1max > RSIZE_MAX) {
return -1;
}
strcat(s1, s2);
return 0;
}
int b_strcpy_s(char * s1, size_t s1max, const char * s2)
{
if (NULL
== s1|| NULL == s2 || s1max < (strlen(s2) + 1) || s1max > RSIZE_MAX) {
return -1;
}
strcpy(s1, s2);
return 0;
}
int fopen_s(FILE ** pFile, const char *filename, const char *mode)
{
if (NULL == pFile || NULL == filename || NULL == mode) {
return -1;
}
*pFile = fopen(filename, mode);
if (NULL == *pFile)
return -1;
return 0;
}

View File

@ -1,106 +0,0 @@
/*
* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#ifndef _BH_PLATFORM_H
#define _BH_PLATFORM_H
#include "bh_config.h"
#include "bh_types.h"
#include <inttypes.h>
#include <stdbool.h>
typedef uint64_t uint64;
typedef int64_t int64;
extern void DEBUGME(void);
#define DIE do{bh_debug("Die here\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); DEBUGME(void); while(1);}while(0)
#define BH_PLATFORM "Linux"
/* NEED qsort */
#include <stdarg.h>
#include <ctype.h>
#include <pthread.h>
#include <limits.h>
#include <semaphore.h>
#include <errno.h>
#define _STACK_SIZE_ADJUSTMENT (32 * 1024)
/* Stack size of applet manager thread. */
#define BH_APPLET_MANAGER_THREAD_STACK_SIZE (8 * 1024 + _STACK_SIZE_ADJUSTMENT)
/* Stack size of HMC thread. */
#define BH_HMC_THREAD_STACK_SIZE (4 * 1024 + _STACK_SIZE_ADJUSTMENT)
/* Stack size of watchdog thread. */
#define BH_WATCHDOG_THREAD_SIZE (4 * 1024 + _STACK_SIZE_ADJUSTMENT)
/* Stack size of applet threads's native part. */
#define BH_APPLET_PRESERVED_STACK_SIZE (8 * 1024 + _STACK_SIZE_ADJUSTMENT)
/* Stack size of remote invoke listen thread. */
#define BH_REMOTE_INVOKE_THREAD_STACK_SIZE (4 * 1024 + _STACK_SIZE_ADJUSTMENT)
/* Stack size of remote post listen thread. */
#define BH_REMOTE_POST_THREAD_STACK_SIZE (4 * 1024 + _STACK_SIZE_ADJUSTMENT)
/* Maximal recursion depth of interpreter. */
#define BH_MAX_INTERP_RECURSION_DEPTH 8
#define BH_ROUTINE_MODIFIER
#define BHT_TIMEDOUT ETIMEDOUT
#define INVALID_THREAD_ID 0xFFffFFff
#define INVALID_SEM_ID SEM_FAILED
typedef pthread_t korp_tid;
typedef pthread_mutex_t korp_mutex;
typedef sem_t korp_sem;
typedef pthread_cond_t korp_cond;
typedef void* (*thread_start_routine_t)(void*);
#include <time.h>
#include <string.h>
/* The following operations declared in string.h may be defined as
macros on Linux, so don't declare them as functions here. */
/* memset */
/* memcpy */
/* memmove */
/* #include <stdio.h> */
/* Unit test framework is based on C++, where the declaration of
snprintf is different. */
#ifndef __cplusplus
int snprintf(char *buffer, size_t count, const char *format, ...);
#endif
/* #include <math.h> */
double fmod(double x, double y);
float fmodf(float x, float y);
/* Definitions for applet debugging */
#define APPLET_DEBUG_LISTEN_PORT 8000
#define BH_SOCKET_INVALID_SOCK -1
#define BH_WAIT_FOREVER 0xFFFFFFFF
typedef int bh_socket_t;
#ifndef NULL
# define NULL ((void*) 0)
#endif
extern int b_memcpy_s(void * s1, unsigned int s1max, const void * s2,
unsigned int n);
extern int strcat_s(char * s1, size_t s1max, const char * s2);
extern int strcpy_s(char * s1, size_t s1max, const char * s2);
#include <stdio.h>
extern int fopen_s(FILE ** pFile, const char *filename, const char *mode);
#endif

View File

@ -1,30 +0,0 @@
/*
* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#include "bh_platform.h"
#include <stdio.h>
void bh_log_emit(const char *fmt, va_list ap)
{
vprintf(fmt, ap);
fflush(stdout);
}
int bh_fprintf(FILE *stream, const char *fmt, ...)
{
va_list ap;
int ret;
va_start(ap, fmt);
ret = vfprintf(stream ? stream : stdout, fmt, ap);
va_end(ap);
return ret;
}
int bh_fflush(void *stream)
{
return fflush(stream ? stream : stdout);
}

View File

@ -1,139 +0,0 @@
/*
* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#include "bh_thread.h"
#include "bh_assert.h"
#include "bh_log.h"
#include "bh_memory.h"
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
static korp_mutex thread_list_lock;
static pthread_key_t thread_local_storage_key[BH_MAX_TLS_NUM];
int _vm_thread_sys_init()
{
unsigned i;
for (i = 0; i < BH_MAX_TLS_NUM; i++)
pthread_key_create(&thread_local_storage_key[i], NULL);
return vm_mutex_init(&thread_list_lock);
}
korp_tid _vm_self_thread()
{
return (korp_tid) pthread_self();
}
void *_vm_tls_get(unsigned idx)
{
bh_assert(idx < BH_MAX_TLS_NUM);
return pthread_getspecific(thread_local_storage_key[idx]);
}
int _vm_tls_put(unsigned idx, void * tls)
{
bh_assert(idx < BH_MAX_TLS_NUM);
pthread_setspecific(thread_local_storage_key[idx], tls);
return BHT_OK;
}
int _vm_mutex_init(korp_mutex *mutex)
{
return pthread_mutex_init(mutex, NULL) == 0 ? BHT_OK : BHT_ERROR;
}
int _vm_recursive_mutex_init(korp_mutex *mutex)
{
int ret;
pthread_mutexattr_t mattr;
bh_assert(mutex);
ret = pthread_mutexattr_init(&mattr);
if (ret)
return BHT_ERROR;
pthread_mutexattr_settype(&mattr, PTHREAD_MUTEX_RECURSIVE_NP);
ret = pthread_mutex_init(mutex, &mattr);
pthread_mutexattr_destroy(&mattr);
return ret == 0 ? BHT_OK : BHT_ERROR;
}
int _vm_mutex_destroy(korp_mutex *mutex)
{
int ret;
bh_assert(mutex);
ret = pthread_mutex_destroy(mutex);
return ret == 0 ? BHT_OK : BHT_ERROR;
}
/* Returned error (EINVAL, EAGAIN and EDEADLK) from
locking the mutex indicates some logic error present in
the program somewhere.
Don't try to recover error for an existing unknown error.*/
void vm_mutex_lock(korp_mutex *mutex)
{
int ret;
bh_assert(mutex);
ret = pthread_mutex_lock(mutex);
if (0 != ret) {
LOG_FATAL("vm mutex lock failed (ret=%d)!\n", ret);
exit(-1);
}
}
int vm_mutex_trylock(korp_mutex *mutex)
{
int ret;
bh_assert(mutex);
ret = pthread_mutex_trylock(mutex);
return ret == 0 ? BHT_OK : BHT_ERROR;
}
/* Returned error (EINVAL, EAGAIN and EPERM) from
unlocking the mutex indicates some logic error present
in the program somewhere.
Don't try to recover error for an existing unknown error.*/
void vm_mutex_unlock(korp_mutex *mutex)
{
int ret;
bh_assert(mutex);
ret = pthread_mutex_unlock(mutex);
if (0 != ret) {
LOG_FATAL("vm mutex unlock failed (ret=%d)!\n", ret);
exit(-1);
}
}
int _vm_cond_init(korp_cond *cond)
{
bh_assert(cond);
if (pthread_cond_init(cond, NULL) != BHT_OK)
return BHT_ERROR;
return BHT_OK;
}
int _vm_cond_destroy(korp_cond *cond)
{
bh_assert(cond);
if (pthread_cond_destroy(cond) != BHT_OK)
return BHT_ERROR;
return BHT_OK;
}

View File

@ -1,60 +0,0 @@
/*
* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#include "bh_time.h"
#include <unistd.h>
#include <stdio.h>
//#include <sys/timeb.h>
#include <time.h>
/*
* This function returns milliseconds per tick.
* @return milliseconds per tick.
*/
uint64 _bh_time_get_tick_millisecond()
{
return sysconf(_SC_CLK_TCK);
}
/*
* This function returns milliseconds after boot.
* @return milliseconds after boot.
*/
uint64 _bh_time_get_boot_millisecond()
{
struct timespec ts;
if (clock_gettime(CLOCK_MONOTONIC, &ts) != 0) {
return 0;
}
return ((uint64) ts.tv_sec) * 1000 + ts.tv_nsec / (1000 * 1000);
}
/*
* This function returns GMT time milliseconds since from 1970.1.1, AKA UNIX time.
* @return milliseconds since from 1970.1.1.
*/
uint64 _bh_time_get_millisecond_from_1970()
{
struct timeval tv;
gettimeofday(&tv, NULL);
uint64 millisecondsSinceEpoch = (uint64_t)(tv.tv_sec) * 1000
+ (uint64_t)(tv.tv_usec) / 1000;
return millisecondsSinceEpoch;
}
size_t _bh_time_strftime(char *s, size_t max, const char *format, int64 time)
{
time_t time_sec = time / 1000;
struct tm *ltp;
ltp = localtime(&time_sec);
if (ltp == NULL) {
return 0;
}
return strftime(s, max, format, ltp);
}

View File

@ -1,30 +0,0 @@
/*
* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#ifndef _BH_DEFINITION_H
#define _BH_DEFINITION_H
#include "bh_config.h"
typedef enum {
BH_FAILED = -100,
BH_UNKOWN = -99,
BH_MAGIC_UNMATCH = -12,
BH_UNIMPLEMENTED = -11,
BH_INTR = -10,
BH_CLOSED = -9,
BH_BUFFER_OVERFLOW = -8, /* TODO: no used error, should remove*/
BH_NOT_SUPPORTED = -7,
BH_WEAR_OUT_VIOLATION = -6,
BH_NOT_FOUND = -5,
BH_INVALID_PARAMS = -4,
BH_ACCESS_DENIED = -3,
BH_OUT_OF_MEMORY = -2,
BH_INVALID = -1,
BH_SUCCESS = 0,
BH_TIMEOUT = 2
} bh_status;
#endif

View File

@ -1,56 +0,0 @@
/*
* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#include "bh_platform.h"
#include "bh_assert.h"
#include <stdarg.h>
#ifdef BH_TEST
#include <setjmp.h>
#endif
#ifdef BH_TEST
/* for exception throwing */
jmp_buf bh_test_jb;
#endif
void bh_assert_internal(int v, const char *file_name, int line_number,
const char *expr_string)
{
if (v)
return;
if (!file_name)
file_name = "NULL FILENAME";
if (!expr_string)
expr_string = "NULL EXPR_STRING";
printf("\nASSERTION FAILED: %s, at FILE=%s, LINE=%d\n", expr_string,
file_name, line_number);
#ifdef BH_TEST
longjmp(bh_test_jb, 1);
#endif
abort();
}
void bh_debug_internal(const char *file_name, int line_number, const char *fmt,
...)
{
#ifndef JEFF_TEST_VERIFIER
va_list args;
va_start(args, fmt);
bh_assert(file_name);
printf("\nDebug info FILE=%s, LINE=%d: ", file_name, line_number);
vprintf(fmt, args);
va_end(args);
printf("\n");
#endif
}

View File

@ -1,11 +0,0 @@
/*
* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#include "bh_definition.h"
int bh_return(int ret)
{
return ret;
}

View File

@ -1,82 +0,0 @@
/*
* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#ifndef _BH_PLATFORM_H
#define _BH_PLATFORM_H
#include "bh_config.h"
#include "bh_types.h"
#ifndef NVALGRIND
#define NVALGRIND
#endif
/* Reserve bytes on applet stack for native functions called from
* Java methods to avoid undetectable stack overflow.
*/
#ifndef APPLET_PRESERVED_STACK_SIZE
#define APPLET_PRESERVED_STACK_SIZE (16 * BH_KB)
#endif
typedef unsigned __int64 uint64;
typedef __int64 int64;
extern void DEBUGME(void);
#define DIE do{bh_debug("Die here\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); DEBUGME(void); while(1);}while(0)
#ifndef BH_INVALID_HANDLE
#define BH_INVALID_HANDLE NULL
#endif
#define BH_PLATFORM "AMULET"
#include <stdarg.h>
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define _STACK_SIZE_ADJUSTMENT (32 * 1024)
/* Stack size of applet manager thread. */
#define BH_APPLET_MANAGER_THREAD_STACK_SIZE (8 * 1024 + _STACK_SIZE_ADJUSTMENT)
/* Stack size of HMC thread. */
#define BH_HMC_THREAD_STACK_SIZE (4 * 1024 + _STACK_SIZE_ADJUSTMENT)
/* Stack size of watchdog thread. */
#define BH_WATCHDOG_THREAD_SIZE (4 * 1024 + _STACK_SIZE_ADJUSTMENT)
/* Stack size of applet threads's native part. */
#define BH_APPLET_PRESERVED_STACK_SIZE (8 * 1024 + _STACK_SIZE_ADJUSTMENT)
/* Maximal recursion depth of interpreter. */
#define BH_MAX_INTERP_RECURSION_DEPTH 8
#define wa_malloc bh_malloc
#define wa_free bh_free
#define snprintf _snprintf
#define BH_ROUTINE_MODIFIER __stdcall
typedef void *korp_tid;
#define INVALID_THREAD_ID 0
typedef void *korp_mutex;
typedef void *korp_sem;
typedef struct {
korp_sem s;
unsigned waiting_count;
} korp_cond;
typedef void* (BH_ROUTINE_MODIFIER *thread_start_routine_t)(void*);
#endif

View File

@ -1,28 +0,0 @@
/*
* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#include <stdio.h>
#include "bh_platform.h"
void bh_log_emit(const char *fmt, va_list ap)
{
vprintf(fmt, ap);
fflush(stdout);
}
int bh_fprintf(FILE *stream, const char *fmt, ...)
{
int ret;
va_list ap;
va_start(ap, fmt);
ret = vfprintf(stream ? stream : stdout, fmt, ap);
va_end(ap);
return ret;
}
int bh_fflush(void *stream)
{
return fflush(stream ? stream : stdout);
}

View File

@ -1,331 +0,0 @@
/*
* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#include "bh_thread.h"
#include "bh_assert.h"
#include "bh_log.h"
#include "bh_memory.h"
#include <windows.h>
#include <process.h>
#ifdef _DEBUG
#define THREAD_STACK_ADJUSTMENT (32 * 1024)
#else
#define THREAD_STACK_ADJUSTMENT 0
#endif
static korp_mutex thread_list_lock;
static DWORD tls_indexes[BH_MAX_TLS_NUM];
typedef struct {
int zero_padding;
thread_start_routine_t start;
void* stack;
void* args;
int stack_size;
} vm_thread_block;
static DWORD tb_index;
int _vm_thread_sys_init()
{
unsigned int i;
for (i = 0; i < BH_MAX_TLS_NUM; i++) {
tls_indexes[i] = TlsAlloc();
if (tls_indexes[i] == TLS_OUT_OF_INDEXES)
return BHT_ERROR;
}
tb_index = TlsAlloc();
if (tb_index == TLS_OUT_OF_INDEXES)
return BHT_ERROR;
return vm_mutex_init(&thread_list_lock);
}
static unsigned int BH_ROUTINE_MODIFIER beihai_starter(void* arg)
{
vm_thread_block* tb = (vm_thread_block*) arg;
TlsSetValue(tb_index, tb);
tb->stack = (void *) &arg;
tb->start(tb->args);
return 0;
}
int _vm_thread_create(korp_tid *tid, thread_start_routine_t start, void *arg,
unsigned int stack_size)
{
unsigned int default_stack_size = 20 * 1024;
vm_thread_block* tb;
bh_assert(tid);
bh_assert(start);
if (stack_size == 0)
stack_size = default_stack_size;
#ifdef _DEBUG
stack_size = THREAD_STACK_ADJUSTMENT + stack_size*3;
#endif
tb = (vm_thread_block*) bh_malloc(sizeof(*tb));
if (tb == NULL)
return BHT_ERROR;
memset(tb, 0, sizeof(*tb));
tb->start = start;
tb->stack_size = stack_size;
tb->args = arg;
*tid = (korp_tid) _beginthreadex(NULL, stack_size, beihai_starter,
(void*) tb, 0, NULL);
/* TODO: to deal with the handle; how to close it? */
return (*tid == INVALID_THREAD_ID) ? BHT_ERROR : BHT_OK;
}
korp_tid _vm_self_thread()
{
return (korp_tid) GetCurrentThread();
}
void vm_thread_exit(void *code)
{
vm_thread_block *tb = (vm_thread_block*) TlsGetValue(tb_index);
bh_free(tb);
_endthreadex((unsigned int) code);
}
void* vm_get_stackaddr()
{
vm_thread_block *tb = (vm_thread_block*) TlsGetValue(tb_index);
return (char *) tb->stack + THREAD_STACK_ADJUSTMENT - tb->stack_size;
}
void *_vm_tls_get(unsigned idx)
{
bh_assert(idx < BH_MAX_TLS_NUM);
return TlsGetValue(tls_indexes[idx]);
}
int _vm_tls_put(unsigned idx, void *tls)
{
BOOL r;
bh_assert(idx < BH_MAX_TLS_NUM);
r = TlsSetValue(tls_indexes[idx], tls);
return (r == FALSE) ? BHT_ERROR : BHT_OK;
}
int _vm_mutex_init(korp_mutex *mutex)
{
bh_assert(mutex);
*mutex = CreateMutex(NULL, FALSE, NULL);
return (*mutex == 0) ? BHT_ERROR : BHT_OK;
}
int _vm_mutex_destroy(korp_mutex *mutex)
{
return BHT_OK;
}
/* Returned error (e.g. ERROR_INVALID_HANDLE) from
locking the mutex indicates some logic error present in
the program somewhere.
Don't try to recover error for an existing unknown error.*/
void vm_mutex_lock(korp_mutex *mutex)
{
DWORD ret;
bh_assert(mutex);
ret = WaitForSingleObject(*mutex, INFINITE);
if (WAIT_FAILED == ret) {
LOG_FATAL("vm mutex lock failed (ret=%d)!\n", GetLastError());
exit(-1);
}
}
int vm_mutex_trylock(korp_mutex *mutex)
{
DWORD ret;
bh_assert(mutex);
ret = WaitForSingleObject(*mutex, 0);
if (WAIT_FAILED == ret) {
LOG_FATAL("vm mutex lock failed (ret=%d)!\n", GetLastError());
exit(-1);
}
return ret == WAIT_OBJECT_0 ? BHT_OK : BHT_ERROR;
}
/* Returned error (e.g. ERROR_INVALID_HANDLE) from
unlocking the mutex indicates some logic error present
in the program somewhere.
Don't try to recover error for an existing unknown error.*/
void vm_mutex_unlock(korp_mutex *mutex)
{
BOOL ret;
bh_assert(mutex);
ret = ReleaseMutex(*mutex);
if (FALSE == ret) {
LOG_FATAL("vm mutex unlock failed (ret=%d)!\n", GetLastError());
exit(-1);
}
}
#define BH_SEM_COUNT_MAX 0xFFFF
int _vm_sem_init(korp_sem *sem, unsigned int count)
{
bh_assert(sem);
bh_assert(count <= BH_SEM_COUNT_MAX);
*sem = CreateSemaphore(NULL, count, BH_SEM_COUNT_MAX, NULL);
return (*sem == NULL) ? BHT_ERROR : BHT_OK;
}
int _vm_sem_destroy(korp_sem *sem)
{
return BHT_OK;
}
int _vm_sem_P(korp_sem *sem)
{
DWORD r;
bh_assert(sem);
r = WaitForSingleObject(*sem, INFINITE);
return (r == WAIT_FAILED) ? BHT_ERROR : BHT_OK;
}
int _vm_sem_reltimedP(korp_sem *sem, int mills)
{
DWORD r;
bh_assert(sem);
if (mills == BHT_WAIT_FOREVER)
mills = INFINITE;
r = WaitForSingleObject(*sem, (unsigned int) mills);
switch (r) {
case WAIT_OBJECT_0:
return BHT_OK;
case WAIT_TIMEOUT:
return BHT_TIMEDOUT;
default:
return BHT_ERROR;
}
}
int _vm_sem_V(korp_sem *sem)
{
BOOL r;
bh_assert(sem);
r = ReleaseSemaphore(*sem, 1, NULL);
return (r == FALSE) ? BHT_ERROR : BHT_OK;
}
int _vm_cond_init(korp_cond *cond)
{
bh_assert(cond);
cond->waiting_count = 0;
return vm_sem_init(&cond->s, 0);
}
int _vm_cond_destroy(korp_cond *cond)
{
bh_assert(cond);
return vm_sem_destroy(&cond->s);
}
int _vm_cond_wait(korp_cond *cond, korp_mutex *mutex)
{
bh_assert(cond);
bh_assert(mutex);
cond->waiting_count++;
vm_mutex_unlock(mutex);
if (vm_sem_P(&cond->s) != BHT_OK)
return BHT_ERROR;
vm_mutex_lock(mutex);
cond->waiting_count--;
return BHT_OK;
}
int _vm_cond_reltimedwait(korp_cond *cond, korp_mutex *mutex, int mills)
{
int r;
bh_assert(cond);
bh_assert(mutex);
cond->waiting_count++;
vm_mutex_unlock(mutex);
r = vm_sem_reltimedP(&cond->s, mills);
if ((r != BHT_OK) && (r != BHT_TIMEDOUT))
return BHT_ERROR;
vm_mutex_lock(mutex);
cond->waiting_count--;
return r;
}
int _vm_cond_signal(korp_cond *cond)
{
bh_assert(cond);
if (cond->waiting_count == 0)
return BHT_OK;
if (vm_sem_V(&cond->s) != BHT_OK)
return BHT_ERROR;
return BHT_OK;
}
int _vm_cond_broadcast(korp_cond *cond)
{
/* FIXME: use pthread's API to implement this and above
functions. */
unsigned count = cond->waiting_count;
for (; count > 0; count--)
vm_sem_V(&cond->s);
return BHT_OK;
}
int _vm_thread_cancel(korp_tid thread)
{
/* FIXME: implement this with Windows API. */
return 0;
}
int _vm_thread_join(korp_tid thread, void **value_ptr)
{
/* FIXME: implement this with Windows API. */
return 0;
}
int _vm_thread_detach(korp_tid thread)
{
/* FIXME: implement this with Windows API. */
return 0;
}

View File

@ -1,90 +0,0 @@
/*
* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#include <stdio.h>
#include "bh_time.h"
#include <time.h>
#include <sys/timeb.h>
/* Since GetTickCount64 is not supported on Windows XP, use a temporary method
* to solve the issue. However, GetTickCount return a DWORD value and overflow
* may happen (http://msdn.microsoft.com/en-us/library/ms724408(v=vs.85).aspx).
*
* TODO: Implement GetTickCount64 on Windows XP by self or check overflow issues.
*/
#if (WINVER >= 0x0600)
extern uint64 __stdcall GetTickCount64(void);
#else
extern uint32 __stdcall GetTickCount(void);
#endif
/*
* This function returns milliseconds per tick.
* @return milliseconds per tick.
*/
uint64 _bh_time_get_tick_millisecond()
{
return 5;
}
/*
* This function returns milliseconds after boot.
* @return milliseconds after boot.
*/
uint64 _bh_time_get_boot_millisecond()
{
/* Since GetTickCount64 is not supported on Windows XP, use a temporary method
* to solve the issue. However, GetTickCount return a DWORD value and overflow
* may happen (http://msdn.microsoft.com/en-us/library/ms724408(v=vs.85).aspx).
*
* TODO: Implement GetTickCount64 on Windows XP by self or check overflow issues.
*/
#if (WINVER >= 0x0600)
return GetTickCount64();
#else
return GetTickCount();
#endif
}
/*
* This function returns GMT time milliseconds since from 1970.1.1, AKA UNIX time.
* @return milliseconds since from 1970.1.1.
*/
uint64 _bh_time_get_millisecond_from_1970()
{
struct timeb tp;
ftime(&tp);
return ((uint64) tp.time) * 1000 + tp.millitm
- (tp.dstflag == 0 ? 0 : 60 * 60 * 1000) + tp.timezone * 60 * 1000;
}
size_t bh_time_strftime(char *s, size_t max, const char *format, int64 time)
{
time_t time_sec = time / 1000;
struct timeb tp;
struct tm local_time;
if (NULL == s)
return 0;
ftime(&tp);
time_sec -= tp.timezone * 60;
if (localtime_s(&local_time, &time_sec) != 0)
return 0;
return strftime(s, max, format, &local_time);
}
int bh_time_get(uint8 *timeoff_info, int16 timeoff_info_len, uint32* time)
{
return BH_UNIMPLEMENTED;
}
int bh_time_set(uint32 ntp, uint8 *timeoff_info)
{
return BH_UNIMPLEMENTED;
}

View File

@ -1,6 +1,9 @@
<!-- /* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/ -->
<!--
/* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
-->
{% load static %}
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
@ -136,6 +139,3 @@ var search_node ={{search_node|safe}};/*THe queried app node*/
</html>

View File

@ -1,6 +1,9 @@
<!-- /* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/ -->
<!--
/* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
-->
{% load static %}
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

View File

@ -1,3 +1,9 @@
<!--
/* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
-->
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">

View File

@ -1,6 +1,9 @@
<!-- /* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/ -->
<!--
/* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
-->
{% load static %}
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

View File

@ -1,6 +1,9 @@
<!-- /* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/ -->
<!--
/* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
-->
{% load static %}
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">