@@ -20,8 +20,6 @@ lazy_static! {
20
20
static ref INITIALIZED : Mutex <bool > = Mutex :: new( false ) ;
21
21
}
22
22
23
- type RuntimePtr = * mut c_void ;
24
-
25
23
/// Initializes the SVM library.
26
24
#[ must_use]
27
25
#[ no_mangle]
@@ -59,7 +57,7 @@ pub unsafe extern "C" fn svm_free_result(_result: svm_result_t) {}
59
57
#[ must_use]
60
58
#[ no_mangle]
61
59
pub unsafe extern "C" fn svm_runtime_create (
62
- runtime_ptr : * mut RuntimePtr ,
60
+ runtime_ptr : * mut * mut c_void ,
63
61
path : * const u8 ,
64
62
path_len : u32 ,
65
63
) -> svm_result_t {
@@ -111,7 +109,7 @@ pub unsafe extern "C" fn svm_runtime_create(
111
109
///
112
110
#[ must_use]
113
111
#[ no_mangle]
114
- pub extern "C" fn svm_runtime_destroy ( runtime : RuntimePtr ) -> svm_result_t {
112
+ pub extern "C" fn svm_runtime_destroy ( runtime : * mut c_void ) -> svm_result_t {
115
113
if RUNTIME_TRACKER . free ( runtime) . is_some ( ) {
116
114
svm_result_t:: OK
117
115
} else {
@@ -150,7 +148,7 @@ pub extern "C" fn svm_runtimes_count() -> u64 {
150
148
#[ must_use]
151
149
#[ no_mangle]
152
150
pub unsafe extern "C" fn svm_validate_deploy (
153
- runtime : RuntimePtr ,
151
+ runtime : * mut c_void ,
154
152
message : * const u8 ,
155
153
message_size : u32 ,
156
154
) -> svm_result_t {
@@ -189,7 +187,7 @@ pub unsafe extern "C" fn svm_validate_deploy(
189
187
#[ must_use]
190
188
#[ no_mangle]
191
189
pub unsafe extern "C" fn svm_validate_spawn (
192
- runtime : RuntimePtr ,
190
+ runtime : * mut c_void ,
193
191
message : * const u8 ,
194
192
message_size : u32 ,
195
193
) -> svm_result_t {
@@ -222,7 +220,7 @@ pub unsafe extern "C" fn svm_validate_spawn(
222
220
#[ must_use]
223
221
#[ no_mangle]
224
222
pub unsafe extern "C" fn svm_validate_call (
225
- runtime : RuntimePtr ,
223
+ runtime : * mut c_void ,
226
224
message : * const u8 ,
227
225
message_size : u32 ,
228
226
) -> svm_result_t {
@@ -265,7 +263,7 @@ pub unsafe extern "C" fn svm_validate_call(
265
263
#[ must_use]
266
264
#[ no_mangle]
267
265
pub unsafe extern "C" fn svm_deploy (
268
- runtime : RuntimePtr ,
266
+ runtime : * mut c_void ,
269
267
envelope : * const u8 ,
270
268
message : * const u8 ,
271
269
message_size : u32 ,
@@ -312,7 +310,7 @@ pub unsafe extern "C" fn svm_deploy(
312
310
#[ must_use]
313
311
#[ no_mangle]
314
312
pub unsafe extern "C" fn svm_spawn (
315
- runtime : RuntimePtr ,
313
+ runtime : * mut c_void ,
316
314
envelope : * const u8 ,
317
315
message : * const u8 ,
318
316
message_size : u32 ,
@@ -363,7 +361,7 @@ pub unsafe extern "C" fn svm_spawn(
363
361
#[ must_use]
364
362
#[ no_mangle]
365
363
pub unsafe extern "C" fn svm_verify (
366
- runtime : RuntimePtr ,
364
+ runtime : * mut c_void ,
367
365
envelope : * const u8 ,
368
366
message : * const u8 ,
369
367
message_size : u32 ,
@@ -411,7 +409,7 @@ pub unsafe extern "C" fn svm_verify(
411
409
#[ must_use]
412
410
#[ no_mangle]
413
411
pub unsafe extern "C" fn svm_call (
414
- runtime : RuntimePtr ,
412
+ runtime : * mut c_void ,
415
413
envelope : * const u8 ,
416
414
message : * const u8 ,
417
415
message_size : u32 ,
@@ -448,7 +446,7 @@ pub unsafe extern "C" fn svm_call(
448
446
///
449
447
#[ must_use]
450
448
#[ no_mangle]
451
- pub unsafe extern "C" fn svm_uncommitted_changes ( runtime_ptr : RuntimePtr ) -> svm_result_t {
449
+ pub unsafe extern "C" fn svm_uncommitted_changes ( runtime_ptr : * mut c_void ) -> svm_result_t {
452
450
catch_unwind_or_fail ( || {
453
451
let runtime = get_runtime ( runtime_ptr) ;
454
452
if runtime. has_uncommitted_changes ( ) ? {
@@ -463,7 +461,7 @@ pub unsafe extern "C" fn svm_uncommitted_changes(runtime_ptr: RuntimePtr) -> svm
463
461
#[ must_use]
464
462
#[ no_mangle]
465
463
pub unsafe extern "C" fn svm_layer_info (
466
- runtime_ptr : RuntimePtr ,
464
+ runtime_ptr : * mut c_void ,
467
465
hash : * mut u8 ,
468
466
layer : * mut u64 ,
469
467
) -> svm_result_t {
@@ -481,7 +479,7 @@ pub unsafe extern "C" fn svm_layer_info(
481
479
/// Undos all changes after the given layer.
482
480
#[ must_use]
483
481
#[ no_mangle]
484
- pub unsafe extern "C" fn svm_rewind ( runtime_ptr : RuntimePtr , layer_id : u64 ) -> svm_result_t {
482
+ pub unsafe extern "C" fn svm_rewind ( runtime_ptr : * mut c_void , layer_id : u64 ) -> svm_result_t {
485
483
catch_unwind_or_fail ( || {
486
484
get_runtime ( runtime_ptr) . rewind ( Layer ( layer_id) ) ?;
487
485
svm_result_t:: OK
@@ -491,7 +489,7 @@ pub unsafe extern "C" fn svm_rewind(runtime_ptr: RuntimePtr, layer_id: u64) -> s
491
489
/// Commits all written data to persistent storage.
492
490
#[ must_use]
493
491
#[ no_mangle]
494
- pub unsafe extern "C" fn svm_commit ( runtime_ptr : RuntimePtr ) -> svm_result_t {
492
+ pub unsafe extern "C" fn svm_commit ( runtime_ptr : * mut c_void ) -> svm_result_t {
495
493
catch_unwind_or_fail ( || {
496
494
get_runtime ( runtime_ptr) . commit ( ) ?;
497
495
svm_result_t:: OK
@@ -523,7 +521,7 @@ impl svm_account {
523
521
#[ must_use]
524
522
#[ no_mangle]
525
523
pub unsafe extern "C" fn svm_get_account (
526
- runtime_ptr : RuntimePtr ,
524
+ runtime_ptr : * mut c_void ,
527
525
account_addr : * const u8 ,
528
526
account : * mut svm_account ,
529
527
) -> svm_result_t {
@@ -548,7 +546,7 @@ pub unsafe extern "C" fn svm_get_account(
548
546
#[ no_mangle]
549
547
#[ must_use]
550
548
pub unsafe extern "C" fn svm_create_account (
551
- runtime_ptr : RuntimePtr ,
549
+ runtime_ptr : * mut c_void ,
552
550
addr : * const u8 ,
553
551
balance : u64 ,
554
552
counter_upper_bits : u64 ,
@@ -568,7 +566,7 @@ pub unsafe extern "C" fn svm_create_account(
568
566
#[ no_mangle]
569
567
#[ must_use]
570
568
pub unsafe extern "C" fn svm_increase_balance (
571
- runtime_ptr : RuntimePtr ,
569
+ runtime_ptr : * mut c_void ,
572
570
addr : * const u8 ,
573
571
additional_balance : u64 ,
574
572
) -> svm_result_t {
@@ -605,7 +603,7 @@ pub unsafe extern "C" fn svm_transfer(
605
603
}
606
604
607
605
unsafe fn svm_runtime_action < F , C > (
608
- runtime_ptr : RuntimePtr ,
606
+ runtime_ptr : * mut c_void ,
609
607
envelope : * const u8 ,
610
608
message : * const u8 ,
611
609
message_size : u32 ,
@@ -632,7 +630,7 @@ where
632
630
}
633
631
634
632
unsafe fn svm_validate < F > (
635
- runtime_ptr : RuntimePtr ,
633
+ runtime_ptr : * mut c_void ,
636
634
message : * const u8 ,
637
635
message_size : u32 ,
638
636
validate_f : F ,
@@ -658,7 +656,7 @@ where
658
656
} )
659
657
}
660
658
661
- unsafe fn get_runtime ( runtime_ptr : RuntimePtr ) -> & ' static mut Runtime {
659
+ unsafe fn get_runtime ( runtime_ptr : * mut c_void ) -> & ' static mut Runtime {
662
660
RUNTIME_TRACKER
663
661
. get ( runtime_ptr)
664
662
. expect ( "The given runtime pointer doesn't point to a valid runtime." )
0 commit comments