-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add new externs for file append and cpu time (#1126)
* chore: add new externs for file append and cpu time
- Loading branch information
1 parent
ce65262
commit 382edfd
Showing
27 changed files
with
645 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
StandardLibrary/runtimes/go/ImplementationFromDafny-go/Time_/externs.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,44 @@ | ||
package _Time | ||
|
||
import ( | ||
"syscall" | ||
"time" | ||
|
||
"github.com/dafny-lang/DafnyRuntimeGo/v4/dafny" | ||
"github.com/dafny-lang/DafnyStandardLibGo/Wrappers" | ||
) | ||
|
||
var m__Time = CompanionStruct_Default___{} | ||
|
||
func (CompanionStruct_Default___) CurrentRelativeTimeMilli() int64 { | ||
return CurrentRelativeTimeMilli() | ||
} | ||
|
||
func (CompanionStruct_Default___) CurrentRelativeTime() int64 { | ||
return CurrentRelativeTime() | ||
} | ||
func CurrentRelativeTime() int64 { | ||
return int64(time.Now().Second()) | ||
} | ||
|
||
func (CompanionStruct_Default___) GetCurrentTimeStamp() Wrappers.Result { | ||
return GetCurrentTimeStamp() | ||
} | ||
|
||
func GetCurrentTimeStamp() Wrappers.Result { | ||
return Wrappers.Companion_Result_.Create_Success_(dafny.SeqOfChars([]dafny.Char(time.Now().Format("2006-01-02T15:04:05.000000Z"))...)) | ||
} | ||
|
||
func CurrentRelativeTimeMilli() int64 { | ||
return time.Now().UnixMilli() | ||
} | ||
|
||
func (CompanionStruct_Default___) GetProcessCpuTimeMillis() int64 { | ||
return GetProcessCpuTimeMillis() | ||
} | ||
|
||
func GetProcessCpuTimeMillis() int64 { | ||
usage := new(syscall.Rusage) | ||
syscall.Getrusage(syscall.RUSAGE_SELF, usage) | ||
return (usage.Utime.Nano() + usage.Stime.Nano()) / 1000000 | ||
} |
Oops, something went wrong.