Skip to content

Commit 678c404

Browse files
committed
Address PR comments
Signed-off-by: Jorge Prendes <jorge.prendes@gmail.com>
1 parent 968eab6 commit 678c404

18 files changed

Lines changed: 179 additions & 198 deletions

File tree

Cargo.lock

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Justfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ PWD := replace(justfile_dir(), "\\", "/")
1111
# * include the stubs required by hyperlight-js-runtime
1212
# * define __wasi__ as this disables threading support in quickjs
1313
export HYPERLIGHT_CFLAGS := \
14-
"-I" + PWD + "/src/hyperlight-js-runtime/stubs/include " + \
14+
"-I" + PWD + "/src/hyperlight-js-runtime/include " + \
1515
"-D__wasi__=1 "
1616

1717
# On Windows, use Ninja generator for CMake to avoid aws-lc-sys build issues with Visual Studio generator
1818
export CMAKE_GENERATOR := if os() == "windows" { "Ninja" } else { "" }
1919

2020
ensure-tools:
21-
cargo install cargo-hyperlight --locked --version 0.1.7
21+
cargo install cargo-hyperlight --locked
2222

2323
# Check if npm is installed, install automatically if missing (Linux)
2424
[private]

src/hyperlight-js-runtime/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ tempfile = "3.26"
4444

4545
[build-dependencies]
4646
bindgen = "0.72"
47-
glob = "0.3"
4847

4948
[features]
5049
default = []

src/hyperlight-js-runtime/build.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
2828
.clang_arg("-D_POSIX_C_SOURCE=200809L");
2929

3030
bindings = bindings.header_contents(
31-
"libc_stubs.h",
31+
"libc.h",
3232
"
3333
#pragma once
3434
#include <errno.h>
@@ -37,11 +37,13 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
3737
",
3838
);
3939

40-
println!("cargo:rerun-if-changed=stubs/include/stdio.h");
41-
println!("cargo:rerun-if-changed=stubs/include/time.h");
40+
println!("cargo:rerun-if-changed=include");
41+
println!("cargo:rerun-if-changed=include/stdio.h");
42+
println!("cargo:rerun-if-changed=include/time.h");
43+
println!("cargo:rerun-if-changed=include/unistd.h");
4244

4345
// Write the generated bindings to an output file.
44-
let out_path = PathBuf::from(env::var("OUT_DIR")?).join("libc_stubs.rs");
46+
let out_path = PathBuf::from(env::var("OUT_DIR")?).join("libc.rs");
4547
bindings.generate()?.write_to_file(out_path)?;
4648

4749
Ok(())
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
Copyright 2026 The Hyperlight Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
#pragma once
17+
18+
#include "printf.h"
19+
#include_next "stdio.h"
20+
21+
#define stdout NULL
22+
23+
int putchar(int c);
24+
25+
#define vfprintf(f, ...) vprintf(__VA_ARGS__)
26+
#define fprintf(f, ...) printf(__VA_ARGS__)
27+
#define fputc(c, f) putc((char)(c), f)
28+
29+
int fflush(FILE *f);
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
Copyright 2026 The Hyperlight Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
#pragma once
17+
18+
#include_next "time.h"
19+
20+
#include <sys/time.h>
21+
#include <sys/types.h>
22+
#include <errno.h>
23+
24+
#define CLOCK_REALTIME 0
25+
#define CLOCK_MONOTONIC 1
26+
27+
int clock_gettime(clockid_t clk_id, struct timespec *tp);
28+
struct tm *localtime_r(const time_t *timer, struct tm *tm);
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/*
2+
Copyright 2026 The Hyperlight Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/

src/hyperlight-js-runtime/src/libc.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,8 @@ mod bindings {
2323
clippy::upper_case_acronyms,
2424
clippy::ptr_offset_with_cast
2525
)]
26-
include!(concat!(env!("OUT_DIR"), "/libc_stubs.rs"));
26+
include!(concat!(env!("OUT_DIR"), "/libc.rs"));
2727
}
2828

29-
#[allow(unused_imports)] // not used in native.rs
30-
pub(crate) use core::ffi::*;
31-
32-
#[allow(unused_imports)] // not used in native.rs
3329
pub(crate) use bindings::*;
30+
pub(crate) use core::ffi::*;

src/hyperlight-js-runtime/src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ limitations under the License.
1616
#![cfg_attr(hyperlight, no_std)]
1717
#![cfg_attr(hyperlight, no_main)]
1818

19+
#[cfg(hyperlight)]
1920
mod libc;
2021

2122
#[cfg(hyperlight)]

src/hyperlight-js-runtime/src/main/stubs/io.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ extern "C" fn putchar(c: libc::c_int) -> libc::c_int {
2222
// force a flush of the internal buffer in the hyperlight putchar implementation
2323
unsafe { libc::_putchar(0) };
2424
}
25-
(c as libc::c_char) as libc::c_int
25+
(c as u8) as libc::c_int
2626
}
2727

2828
#[unsafe(no_mangle)]

0 commit comments

Comments
 (0)