Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mu-impl-ref2
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
5
Issues
5
List
Board
Labels
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mu
mu-impl-ref2
Commits
e723c4be
Commit
e723c4be
authored
Jan 13, 2016
by
Kunshan Wang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
When run from C, log to stderr.
parent
816ca72b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
0 deletions
+39
-0
CInitiater.java
src/main/java/uvm/refimpl/nat/CInitiater.java
+39
-0
No files found.
src/main/java/uvm/refimpl/nat/CInitiater.java
View file @
e723c4be
package
uvm
.
refimpl
.
nat
;
import
java.io.ByteArrayOutputStream
;
import
org.slf4j.LoggerFactory
;
import
ch.qos.logback.classic.Logger
;
import
ch.qos.logback.classic.LoggerContext
;
import
ch.qos.logback.classic.encoder.PatternLayoutEncoder
;
import
ch.qos.logback.classic.spi.ILoggingEvent
;
import
ch.qos.logback.core.ConsoleAppender
;
import
uvm.refimpl.MicroVM
;
import
uvm.refimpl.MicroVM
$
;
/** Static functions for the convenient of C programs that start Mu via JNI. */
public
class
CInitiater
{
private
static
boolean
isLogConfigured
=
false
;
private
static
void
configureLog
()
{
if
(
isLogConfigured
)
{
return
;
}
isLogConfigured
=
true
;
LoggerContext
lc
=
(
LoggerContext
)
LoggerFactory
.
getILoggerFactory
();
lc
.
reset
();
ConsoleAppender
<
ILoggingEvent
>
ca
=
new
ConsoleAppender
<
ILoggingEvent
>();
ca
.
setContext
(
lc
);
ca
.
setName
(
"console"
);
ca
.
setTarget
(
"System.err"
);
PatternLayoutEncoder
pl
=
new
PatternLayoutEncoder
();
pl
.
setContext
(
lc
);
pl
.
setPattern
(
"%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n"
);
pl
.
start
();
ca
.
setEncoder
(
pl
);
ca
.
start
();
Logger
rootLogger
=
lc
.
getLogger
(
Logger
.
ROOT_LOGGER_NAME
);
rootLogger
.
addAppender
(
ca
);
}
/** Called by the native program, this function creates a Mu instance. */
static
long
mu_refimpl2_new
()
{
configureLog
();
MicroVM
mvm
=
new
MicroVM
(
MicroVM
$
.
MODULE
$
.
DEFAULT_HEAP_SIZE
(),
MicroVM
$
.
MODULE
$
.
DEFAULT_GLOBAL_SIZE
(),
MicroVM
$
.
MODULE
$
.
DEFAULT_STACK_SIZE
());
long
fak
=
NativeClientSupport
$
.
MODULE
$
.
exposeMicroVM
(
mvm
);
...
...
@@ -18,6 +56,7 @@ public class CInitiater {
* extra arguments.
*/
static
long
mu_refimpl2_new_ex
(
long
heap_size
,
long
global_size
,
long
stack_size
)
{
configureLog
();
MicroVM
mvm
=
new
MicroVM
(
heap_size
,
global_size
,
stack_size
);
long
fak
=
NativeClientSupport
$
.
MODULE
$
.
exposeMicroVM
(
mvm
);
return
fak
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment