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.
94
105#![ allow( dead_code) ]
116pub const DIGEST_WORDS : usize = 8 ;
@@ -15,9 +10,12 @@ pub mod fileno {
1510 pub const STDIN : u32 = 0 ;
1611 pub const STDOUT : u32 = 1 ;
1712 pub const STDERR : u32 = 2 ;
13+
14+ #[ cfg( target_vendor = "risc0" ) ]
1815 pub const JOURNAL : u32 = 3 ;
1916}
2017
18+ #[ cfg( target_vendor = "risc0" ) ]
2119unsafe extern "C" {
2220 // Wrappers around syscalls provided by risc0-zkvm-platform:
2321 pub fn sys_halt ( ) ;
@@ -53,3 +51,27 @@ unsafe extern "C" {
5351 pub fn sys_alloc_words ( nwords : usize ) -> * mut u32 ;
5452 pub fn sys_alloc_aligned ( nwords : usize , align : usize ) -> * mut u8 ;
5553}
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