Skip to content

Instantly share code, notes, and snippets.

View luqmana's full-sized avatar

Luqman Aden luqmana

View GitHub Profile

Or what the hell do #![no_start], #![no_main], #[lang = "start"], #[start], and #[main] do?

Crate Attributes:

#![no_start]

Disable automatically linking in the native crate and thus the default start lang item.

Which means you'll probably need one of: #![no_main], #![lang = “start”] or #[start] instead

> % rustc hello.rs --target=psp -lpspdebug -lpspdisplay -lpspge -lm -lc -lpspuser -lgcc
> % psp-fixup-imports hello && psp-prxgen hello hello.prx
#!/usr/sbin/dtrace -s
dtrace:::BEGIN
{
}
/* The link we're interested in. */
uint32 linkid;
string linkname;
#![allow(dead_code)]
use std::os::fd::AsRawFd;
extern "C" {
pub fn ioctl(fildes: i32, request: i32, ...) -> i32;
}
const VNIC_IOC_INFO: i32 = 0x1710003;
#!/bin/bash
set -eux
if [[ "$EUID" -ne 0 ]]; then
echo "Run as root"
exit
fi
# Physical link over which to simulate the Chelsio links
PHYSICAL_LINK="$(dladm show-phys -p -o LINK | head -1)"
#!/bin/bash
ip tuntap add dev wintestnet mode tap 2>/dev/null
ip link set dev wintestnet master vmbr 2>/dev/null
ip link set dev wintestnet up 2>/dev/null
# Edit these
WIN_IMAGE=/oxide/VMs/IMGs/windows.img
OVMF_PATH=/oxide/VMs/OVMF_CODE.fd
WIN_ISO=/lfs/ISOs/OSs/en_windows_10_business_editions_version_2004_updated_nov_2020_x64_dvd_29ee42db.iso
import builtins
import math
class BetterList(builtins.list):
def __getitem__(self, k):
if isinstance(k, slice):
if k.start == None and k.step == None:
if k.stop == 0.0:
if math.copysign(1.0, k.stop) == -1.0:
return self
[package]
name = "foo"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
@luqmana
luqmana / Rust Inline Asm.md
Last active February 1, 2022 03:29
How to use inline assembly in Rust.
fn main() {
    unsafe {
        do str::as_c_str(~"The answer is %d.\n") |c| {
            let a = 42;
            asm!("mov $0, %rdi\n\t\
                  mov $1, %rsi\n\t\
                  xorl %eax, %eax\n\t\
                  call _printf"
                 :
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.