Code Monkey home page Code Monkey logo

shim-3ds's People

Contributors

azuremarker avatar fenrirwolf avatar ian-h-chamberlain avatar meziu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

shim-3ds's Issues

Support `CLOCK_MONOTONIC` in `clock_gettime`

From discussion starting at Meziu/rust-horizon#6 (comment)


Looking at the implementation of osGetTime (which is used by gettimeofday, which in turn is used by our clock_gettime impl for CLOCK_REALTIME), they appear to do some adjustment for clock drift in an attempt to get monotonic values, but I'm not sure if that implies the value from svcGetSystemTick() is not normally monotonic? There is also an epoch adjustment from 1900 to 1970 here for gettimeofday, but I don't think that would be strictly needed for a monotonic clock_gettime...

So maybe we could try our own impl that basically looks like this?

let now = svcGetSystemTick();
// Not sure if the math is quite right but you get the idea...
(*tp).tv_sec = now / SYSCLOCK_ARM11;
(*tp).tv_nsec = 1000 * (now - SYSCLOCK_ARM11*(*tp).tv_sec) / CPU_TICKS_PER_USEC;

I have to imagine that svcGetSystemTick() is monotonic, since I think it's supposed to be the number of clock cycles since boot, based on this docstring

Originally posted by @ian-h-chamberlain in Meziu/rust-horizon#6 (comment)


I can work on this soon but wanted to track it here, also wanted to wait for the discussion in #8 to be finalized so we can come up with a best practice for exposing libctru APIs through libc like this, since the error handling will probably be similar.

Move subprocess API stubs here instead of ctru-rs

I think this crate makes more sense for the stubs we have in ctru-rs' test runner:

https://github.com/rust3ds/ctru-rs/blob/master/ctru-rs/src/test_runner.rs#L82-L100

That particular case was a quick fix since nothing linked those symbols before we added extern crate test, but they could prove useful for other cases too.

Obviously this would result in duplicate symbols briefly so we would need to make the change simultaneously here and remove there for it to work.

Naming of this crate / repository

There's a few names rolling around in this crate at the moment:

  • rust-linker-fix-3ds is the name of the repo, which is a bit long
  • linker-fix-3ds is the name of the Cargo package (what would go on https://crates.io)
  • linker_fix_3ds is the name of the crate, although this doesn't matter much since most consumers would never use it directly (except maybe as extern crate)

I think it would be good to be consistent and use the same name everywhere. We already have a convention of using - rather than _ for these crates, so I think we should probably stick with that. Some options:

  • Simply linker-fix-3ds for https://crates.io as well as the repo name. This is the least amount of change from what we have
  • libc-3ds. I think this describes what the crate does reasonably well (fills out missing libc APIs) and is nice and short but easily searchable. Doesn't exist yet: https://crates.io/search?q=libc-3ds
    • libc-3ds-rs maybe if we want to make it super obviously Rust, but I think being in the rust3ds org is probably good enough to make that clear
  • ??? Open to other options

Drop `clock_gettime` implementation in favor of upstream

It looks like libctru has implemented the clock_gettime syscall now: devkitPro/libctru@813d28d

As much as I prefer to have things implemented in Rust, it's probably best if we defer stuff like this to the canonical implementation upstream and reduce the surface area of this crate. We'll have to wait for a new release of libctru (which means we probably also should document some minimum required version of libctru somewhere...)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.