1
- //! ABI definitions for symbols exported by risc0-zkvm-platform.
2
-
3
- // Included here so we don't have to depend on risc0-zkvm-platform.
4
- //
5
- // FIXME: Should we move this to the "libc" crate? It seems like other
6
- // architectures put a lot of this kind of stuff there. But there's
7
- // currently no risc0 fork of the libc crate, so we'd either have to
8
- // fork it or upstream it.
1
+ //! ABI definitions for symbols exported by <_>-zkvm targets.
2
+ //!
3
+ //! Ideally, these should be the minimum viable symbols to support the std-lib.
9
4
10
5
#![ allow( dead_code) ]
11
6
pub const DIGEST_WORDS : usize = 8 ;
@@ -15,9 +10,12 @@ pub mod fileno {
15
10
pub const STDIN : u32 = 0 ;
16
11
pub const STDOUT : u32 = 1 ;
17
12
pub const STDERR : u32 = 2 ;
13
+
14
+ #[ cfg( target_vendor = "risc0" ) ]
18
15
pub const JOURNAL : u32 = 3 ;
19
16
}
20
17
18
+ #[ cfg( target_vendor = "risc0" ) ]
21
19
unsafe extern "C" {
22
20
// Wrappers around syscalls provided by risc0-zkvm-platform:
23
21
pub fn sys_halt ( ) ;
@@ -53,3 +51,27 @@ unsafe extern "C" {
53
51
pub fn sys_alloc_words ( nwords : usize ) -> * mut u32 ;
54
52
pub fn sys_alloc_aligned ( nwords : usize , align : usize ) -> * mut u8 ;
55
53
}
54
+
55
+ #[ cfg( target_os = "succinct-zkvm" ) ]
56
+ unsafe extern "C" {
57
+ pub fn sys_halt ( ) ;
58
+ pub fn sys_rand ( recv_buf : * mut u8 , words : usize ) ;
59
+ pub fn sys_panic ( msg_ptr : * const u8 , len : usize ) -> !;
60
+ pub fn sys_write ( fd : u32 , write_buf : * const u8 , nbytes : usize ) ;
61
+ pub fn sys_getenv (
62
+ recv_buf : * mut u32 ,
63
+ words : usize ,
64
+ varname : * const u8 ,
65
+ varname_len : usize ,
66
+ ) -> usize ;
67
+ pub fn sys_argv ( out_words : * mut u32 , out_nwords : usize , arg_index : usize ) -> usize ;
68
+ pub fn sys_alloc_aligned ( nwords : usize , align : usize ) -> * mut u8 ;
69
+ }
70
+
71
+ #[ cfg( target_os = "succinct-zkvm" ) ]
72
+ // Note: sys_read is not implemented for succinct.
73
+ // However, it is a function used in the standard library, so we need to
74
+ // implement it.
75
+ pub unsafe extern "C" fn sys_read ( _: u32 , _: * mut u8 , _: usize ) -> usize {
76
+ panic ! ( "sys_read not implemented for succinct" ) ;
77
+ }
0 commit comments