@@ -22,7 +22,7 @@
|
||||
|
||||
//--- Setup args --------------------------------------------------------------//
|
||||
|
||||
OBJ_GETTER(setupArgs, int argc, char** argv) {
|
||||
OBJ_GETTER(setupArgs, int argc, const char** argv) {
|
||||
// The count is one less, because we skip argv[0] which is the binary name.
|
||||
ObjHeader* result = AllocArrayInstance(theArrayTypeInfo, argc - 1, OBJ_RESULT);
|
||||
ArrayHeader* array = result->array();
|
||||
@@ -36,7 +36,7 @@ OBJ_GETTER(setupArgs, int argc, char** argv) {
|
||||
//--- main --------------------------------------------------------------------//
|
||||
extern "C" KInt Konan_start(const ObjHeader*);
|
||||
|
||||
extern "C" int Konan_main(int argc, char** argv) {
|
||||
extern "C" int Konan_main(int argc, const char** argv) {
|
||||
RuntimeState* state = InitRuntime();
|
||||
|
||||
if (state == nullptr) {
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright 2010-2017 JetBrains s.r.o.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef KOTLIN_KONAN_H
|
||||
#define KOTLIN_KONAN_H
|
||||
|
||||
// To embed Kotlin/Native into a C/C++ application this API could be used.
|
||||
// Compile Kotlin/Native application as usual, but supply -nomain kotlinc
|
||||
// switch, and provide bitcode with real entry point code as -nativelibrary
|
||||
// command line argument.
|
||||
extern "C" int Konan_main(int argc, const char** argv);
|
||||
|
||||
#endif // KOTLIN_KONAN_H
|
||||
@@ -87,7 +87,7 @@ struct MemoryState {
|
||||
namespace {
|
||||
|
||||
// TODO: remove this global.
|
||||
MemoryState* memoryState = nullptr;
|
||||
__thread MemoryState* memoryState = nullptr;
|
||||
|
||||
// TODO: use those allocators for STL containers as well.
|
||||
template <typename T>
|
||||
@@ -264,8 +264,6 @@ ContainerHeader* AllocContainer(size_t size) {
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void FreeContainer(ContainerHeader* header) {
|
||||
RuntimeAssert(!isPermanent(header), "this kind of container shalln't be freed");
|
||||
#if TRACE_MEMORY
|
||||
|
||||
@@ -17,12 +17,19 @@
|
||||
#include <locale.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "Memory.h"
|
||||
#include "Runtime.h"
|
||||
|
||||
struct RuntimeState {
|
||||
MemoryState* memoryState;
|
||||
};
|
||||
|
||||
typedef void (*Initializer)();
|
||||
struct InitNode {
|
||||
Initializer init;
|
||||
InitNode* next;
|
||||
};
|
||||
|
||||
namespace {
|
||||
|
||||
InitNode* initHeadNode = nullptr;
|
||||
@@ -42,7 +49,7 @@ void InitGlobalVariables() {
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void AppendToInitializersTail(struct InitNode *next) {
|
||||
void AppendToInitializersTail(InitNode *next) {
|
||||
// TODO: use RuntimeState.
|
||||
if (initHeadNode == nullptr) {
|
||||
initHeadNode = next;
|
||||
|
||||
@@ -17,25 +17,19 @@
|
||||
#ifndef RUNTIME_RUNTIME_H
|
||||
#define RUNTIME_RUNTIME_H
|
||||
|
||||
#include "Types.h"
|
||||
|
||||
struct RuntimeState;
|
||||
struct InitNode;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef void (*Initializer)();
|
||||
struct InitNode {
|
||||
Initializer init;
|
||||
struct InitNode* next;
|
||||
};
|
||||
|
||||
void AppendToInitializersTail(struct InitNode*);
|
||||
|
||||
RuntimeState* InitRuntime();
|
||||
void DeinitRuntime(RuntimeState* state);
|
||||
|
||||
// Appends given node to an initializer list.
|
||||
void AppendToInitializersTail(struct InitNode*);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user