Skip to content
Snippets Groups Projects
  1. Sep 18, 2018
  2. Aug 24, 2018
  3. Aug 22, 2018
  4. Aug 16, 2018
  5. Aug 15, 2018
  6. Aug 14, 2018
  7. Aug 13, 2018
  8. Aug 07, 2018
    • bors's avatar
      Auto merge of #1050 - MegatonHammer:master, r=alexcrichton · 9be97c96
      bors authored
      Add libc definitions for Megaton-Hammer, a Switch Homebrew toolchain
      
      I'm working on a pure-rust toolchain to write homebrew for the Nintendo Switch called [Megaton-Hammer](http://github.com/megatonhammer/megaton-hammer). I'm hoping to get those definitions upstreamed to simplify my life :).
      
      This toolchain does not depend on a C compiler or a libc (it reimplements everything in rust) - but given many crates in the Rust ecosystem rely on the libc crate for the definition of various common types, this is what I came up with.
      
      I was wondering what a good target triple would be ? I currently gate the implementation behind `target_os = "switch"`, but if this goes upstream I figure that might cause trouble for people using the Nintendo SDK (they might already be using `target_os = "switch"` for some things). Would it be better to go with `target_env = "megatonhammer"`?
      9be97c96
    • bors's avatar
      Auto merge of #1058 - jakllsch:netbsd-283b36ac-fab0-4e5f-b620-4325f8cedc80, r=alexcrichton · fc8db960
      bors authored
      NetBSD: add basic types for aarch64
      fc8db960
  9. Aug 06, 2018
  10. Aug 05, 2018
  11. Aug 02, 2018
  12. Aug 01, 2018
    • bors's avatar
      Auto merge of #1053 - papertigers:illumos-epoll-event, r=alexcrichton · 8318a3ec
      bors authored
      illumos epoll_event struct should be packed
      
      While attempting to run `cargo test` within the mio crate on illumos I noticed a number of the tests fail. Digging into the various epoll calls I discovered that the epoll_event struct was misaligned due to extra padding. The fix is to pack the epoll_event struct with the same compiler setting that the linux variant is using.
      
      A simple rust example that demonstrates the issue:
      ```rust
      extern crate libc;
      use libc::epoll_event;
      use std::mem;
      fn main() {
          println!("{}", mem::size_of::<u64>());
          println!("{}", mem::size_of::<epoll_event>());
      }
      ```
      Running the above code on Linux results in:
      ```
      8
      12
      ```
      while on illumos it currently results in:
      ```
      8
      16
      ```
      Looking at the `test_close_on_drop` test from mio I traced the `epoll_ctl`
      calls and saw the following:
      ```
      [root@rustdev ~/src/mio]# dtrace -wn 'pid$target::epoll_ctl:entry {this->ev = arg3; printf("%d\n", arg2); print((struct epoll_event *)this->ev); stop()}' -c "/root/src/mio/target/debug/deps/test-109e1422fb40f621 test_close_on_drop"
      dtrace: description 'pid$target::epoll_ctl:entry ' matched 1 probe
      dtrace: allowing destructive actions
      running 1 test
      CPU     ID                    FUNCTION:NAME
        6  92874                  epoll_ctl:entry 4
      struct epoll_event * 0xfffffc7fee7feda8
      test test_close_on_drop::test_close_on_drop ... test test_close_on_drop::test_close_on_drop has been running for over 60 seconds
        6  92874                  epoll_ctl:entry 6
      struct epoll_event * 0xfffffc7fee7fee18
      ^[[A  6  92874                  epoll_ctl:entry 7
      struct epoll_event * 0xfffffc7fee7fee18
      ```
      I dumped each of the epoll_event's with mdb:
      ```
      [root@rustdev ~/src/mio]# mdb -Fp 219856
      Loading modules: [ libumem.so.1 libc.so.1 ]
      > 0xfffffc7fee7feda8::print
      mdb: no symbol information for 0xfffffc7fee7feda8: no symbol corresponds to address
      > 0xfffffc7fee7feda8::print struct epoll_event
      {
          events = 0x80000001
          data = {
              ptr = 0xfffffffffffffc7f
              fd = 0xfffffc7f
              u32 = 0xfffffc7f
              u64 = 0xfffffffffffffc7f
          }
      }
      >
      [root@rustdev ~/src/mio]# prun 219856
      [root@rustdev ~/src/mio]# mdb -Fp 219856
      Loading modules: [ libumem.so.1 libc.so.1 ]
      > 0xfffffc7fee7fee18::print struct epoll_event
      {
          events = 0x80000001
          data = {
              ptr = 0
              fd = 0
              u32 = 0
              u64 = 0
          }
      }
      >
      [root@rustdev ~/src/mio]# prun 219856
      [root@rustdev ~/src/mio]# mdb -Fp 2198
      Loading modules: [ libumem.so.1 libc.so.1 ]
      > 0xfffffc7fee7fee18::print struct epoll_event
      {
          events = 0x80000004
          data = {
              ptr = 0x100000000
              fd = 0
              u32 = 0
              u64 = 0x100000000
          }
      }
      ```
      The output from the last two `epoll_event`'s represent `Token(0)` the Client and `Token(1)` from the mio test. The first one however is from `AWAKEN` which is defined as `usize::MAX`.  This value should be 18446744073709551615. However if we convert the hex value we see something else:
      ```
      > 0xfffffffffffffc7f=E
                      18446744073709550719
      ```
      Because of the extra 4 bytes of padding currently present in the illumos `epoll_event` definition the low order bits are picking up some junk from other memory.
      
      All of the poll-related mio tests pass with this change. Two other tests are still failing, which appears to be caused by an OS bug, not a problem with mio or libc.
      8318a3ec
    • bors's avatar
      Auto merge of #1048 - ColinFinck:master, r=alexcrichton · 7b45a7cb
      bors authored
      Add libc definitions for HermitCore (https://hermitcore.org)
      
      HermitCore is based on lwIP, newlib, and pthread-embedded.
      Some definitions are similar to other targets using newlib, however some are different enough to justify an own "hermit" port and not base on the existing "newlib" port.
      7b45a7cb
    • Alex Crichton's avatar
      Merge pull request #1051 from alexcrichton/fix-apple · 50904771
      Alex Crichton authored
      Fix OSX builders on CI
      Unverified
      50904771
    • Alex Crichton's avatar
      Allow iOS to fail · e6bc44b5
      Alex Crichton authored
      e6bc44b5
    • Alex Crichton's avatar
      Fix OSX builders on CI · 83f78df8
      Alex Crichton authored
      Looks like Travis has moved on from our old images, so we're forced to
      update.
      83f78df8
    • debris's avatar
      change exchangedata param c_long -> c_ulong · e131bd1b
      debris authored
      e131bd1b
    • debris's avatar
      3d5c968b
    • debris's avatar
      Merge branch 'master' into exchangedata · 019f429e
      debris authored
      019f429e
    • Mike Zeller's avatar
      illumos epoll_event struct should be packed · d213c3ac
      Mike Zeller authored
      d213c3ac
  13. Jul 31, 2018
    • Colin Finck's avatar
      Fix coding style. · 086bdf96
      Colin Finck authored
      086bdf96
    • bors's avatar
      Auto merge of #1049 - alecmocatta:master, r=alexcrichton · e1ebfafc
      bors authored
      Add the FIO* consts for *-apple-*
      
      Previously only FIONREAD was implemented for x86_64 apple. The constant is shared between i{3..6}86 and x86_64, so I've moved it into the shared module rather than the 64 bit specific one.
      
      They're defined like this in sys/filio.h:
      ```
      #define FIOCLEX	     _IO('f', 1)        /* set close on exec on fd */
      #define FIONCLEX     _IO('f', 2)        /* remove close on exec */
      #define FIONREAD    _IOR('f', 127, int) /* get # bytes to read */
      #define FIONBIO     _IOW('f', 126, int) /* set/clear non-blocking i/o */
      #define FIOASYNC    _IOW('f', 125, int) /* set/clear async i/o */
      #define FIOSETOWN   _IOW('f', 124, int) /* set owner */
      #define FIOGETOWN   _IOR('f', 123, int) /* get owner */
      #define FIODTYPE    _IOR('f', 122, int) /* get d_type */
      ```
      
      Rather than decipher the C macros I got the values like so:
      ```
      #include <stdio.h>
      #include <sys/ioctl.h>
      
      int main() {
      	printf("pub const FIOCLEX: ::c_uint = 0x%x;\n", FIOCLEX);
      	printf("pub const FIONCLEX: ::c_uint = 0x%x;\n", FIONCLEX);
      	printf("pub const FIONREAD: ::c_ulong = 0x%lx;\n", FIONREAD);
      	printf("pub const FIONBIO: ::c_ulong = 0x%lx;\n", FIONBIO);
      	printf("pub const FIOASYNC: ::c_ulong = 0x%lx;\n", FIOASYNC);
      	printf("pub const FIOSETOWN: ::c_ulong = 0x%lx;\n", FIOSETOWN);
      	printf("pub const FIOGETOWN: ::c_ulong = 0x%lx;\n", FIOGETOWN);
      	printf("pub const FIODTYPE: ::c_ulong = 0x%lx;\n", FIODTYPE);
      }
      
      $ gcc --target=i686-apple-darwin -o x x.c && file ./x && ./x
      ./x: Mach-O executable i386
      pub const FIOCLEX: ::c_uint = 0x20006601;
      pub const FIONCLEX: ::c_uint = 0x20006602;
      pub const FIONREAD: ::c_ulong = 0x4004667f;
      pub const FIONBIO: ::c_ulong = 0x8004667e;
      pub const FIOASYNC: ::c_ulong = 0x8004667d;
      pub const FIOSETOWN: ::c_ulong = 0x8004667c;
      pub const FIOGETOWN: ::c_ulong = 0x4004667b;
      pub const FIODTYPE: ::c_ulong = 0x4004667a;
      
      $ gcc --target=x86_64-apple-darwin -o x x.c && file ./x && ./x
      ./x: Mach-O 64-bit executable x86_64
      pub const FIOCLEX: ::c_uint = 0x20006601;
      pub const FIONCLEX: ::c_uint = 0x20006602;
      pub const FIONREAD: ::c_ulong = 0x4004667f;
      pub const FIONBIO: ::c_ulong = 0x8004667e;
      pub const FIOASYNC: ::c_ulong = 0x8004667d;
      pub const FIOSETOWN: ::c_ulong = 0x8004667c;
      pub const FIOGETOWN: ::c_ulong = 0x4004667b;
      pub const FIODTYPE: ::c_ulong = 0x4004667a;
      ```
      
      I'm just awaiting an XCode install to check they're the same on arm.
      e1ebfafc
Loading