This file contains hidden or 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
| module GADTs ( | |
| Is (), | |
| is, | |
| rtol, | |
| ltor | |
| ) where | |
| import Unsafe.Coerce (unsafeCoerce) | |
| data Is a b = Is deriving (Show, Eq) |
This file contains hidden or 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
| use core::comm; | |
| use core::task; | |
| // Erlang style OOP | |
| pub struct Object { | |
| priv input : comm::Chan <Input> | |
| } |
This file contains hidden or 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
| // I heard that virtual calls can be faster than normal enum switching | |
| // so I made a simple but flawed prototype implementation of enums | |
| // with virtual calls. | |
| trait MyEnumVisitor { | |
| // Note that we can't have generic virtual functions (so that's | |
| // one problem with this scheme) | |
| fn onA (&self, uint); | |
| fn onB (&self); | |
| fn onC (&self); | |
| fn onD (&self); |
This file contains hidden or 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
| #include <stdio.h> | |
| // Uses GCC labels as values extension to implement enums | |
| // Can this approach be used by the Rust compiler? | |
| typedef struct { | |
| void * (* tag) (void **); | |
| union { | |
| int a; | |
| unsigned b; |
This file contains hidden or 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
| $ ltrace eglretrace drawer.trace > ~/root/ltrace.log | |
| __libc_start_main(0x4069f0, 2, 0x7fff92863338, 0x5cf460 <unfinished ...> | |
| _ZNSt8ios_base4InitC1Ev(0x838c98, 0x7fff92863338, 0x7fff92863350, 3) = 0 | |
| __cxa_atexit(0x405f90, 0x838c98, 0x838618, 6) = 0 | |
| _ZNSt8ios_base4InitC1Ev(0x838db1, 0x7fff92863338, 0x7fff92863350, 4) = 2 | |
| __cxa_atexit(0x405f90, 0x838db1, 0x838618, 4) = 0 | |
| __cxa_atexit(0x40aaa0, 0x838d90, 0x838618, 5) = 0 | |
| __cxa_atexit(0x40aaa0, 0x838d80, 0x838618, 6) = 0 | |
| __cxa_atexit(0x5c67f0, 0x838ce0, 0x838618, 7) = 0 | |
| __cxa_atexit(0x5c9180, 0x838cc0, 0x838618, 8) = 0 |
This file has been truncated, but you can view the full file.
This file contains hidden or 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
| <?xml version="1.0" standalone="no"?> | |
| <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> | |
| <svg version="1.1" width="1200" height="754" onload="init(evt)" viewBox="0 0 1200 754" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> | |
| <defs > | |
| <linearGradient id="background" y1="0" y2="1" x1="0" x2="0" > | |
| <stop stop-color="#eeeeee" offset="5%" /> | |
| <stop stop-color="#eeeeb0" offset="95%" /> | |
| </linearGradient> | |
| </defs> | |
| <style type="text/css"> |
This file contains hidden or 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
| pub fn exp(counter: usize, max_counter: usize, n: usize) -> usize { | |
| let floor = (counter * n) / max_counter; | |
| let ceil = 1 + (counter * n - 1) / max_counter; | |
| let floor_exp = 1 << floor; | |
| return floor_exp + (((1 << ceil) - floor_exp) * (counter * n - floor * max_counter)) / max_counter; | |
| } |
This file contains hidden or 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
| static inline void pause_times(unsigned spins){ | |
| unsigned iters = spins / 8U; | |
| switch (spins % 8U) { | |
| for (; iters > 0U; --iters) { | |
| case 7: _mm_pause(); | |
| case 6: _mm_pause(); | |
| case 5: _mm_pause(); | |
| case 4: _mm_pause(); | |
| case 3: _mm_pause(); | |
| case 2: _mm_pause(); |
This file contains hidden or 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
| use std::str; | |
| pub fn to_snakecase_ascii(a: &str) -> String { | |
| let bytes = a | |
| .as_bytes(); | |
| let len = bytes.len(); | |
| let ending_underscores = bytes | |
| .iter() |
This file contains hidden or 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
| public final class ContextCalls { | |
| private ContextCalls() { | |
| } | |
| @Retention(RetentionPolicy.CLASS) | |
| @Target({ElementType.METHOD}) | |
| @Indy( | |
| bootstrap = @Bootstrap(clazz = Bootstrapper.class, method = "bootstrap"), |