impl Future for Something { type Item = (); type Error = Never; fn poll(&mut self, _cx: &mut Context) -> Poll<Self::Item, Self::Error> { // } }
require "./lib_dpdk" def hello_thread(arg : Void*) : LibC::Int LibC.printf("Hello from lcore: %d\n", LibDpdk.per_lcore__lcore_id) 0 end fun main(argc : Int32, argv : UInt8**) : Int32 Crystal.main do LibDpdk.rte_eal_init(argc, argv) LibDpdk.rte_eal_mp_remote_launch(->hello_thread, nil, LibDpdk::RteRmtCallMasterT::CallMaster) LibDpdk.rte_eal_mp_wait_lcore end end % sudo crystal run src/hello.cr EAL:
Crystal bindings to DPDK, development in progress. Hello World (examples/hello.cr) require "../src/dpdk" class Hello < Dpdk def hello_thread printf("Hello from lcore: %d\n", rte_lcore_id) end def main(argc, argv) rte_eal_init(argc, argv) rte_eal_mp_remote_launch(hello_thread) rte_eal_mp_wait_lcore end end Hello.run Requirements Crystal (0.24.1) Recent Clang (5.0) or GCC, make and coreutils Working
require "../src/lib/base" module IpBlockingMethods private macro target_addresses? src = pkt.u32(IP_SRC_OFS) blocking_ips.any? { |x| x == src } end private macro process_per_type mark_drop_and_next if ipv4? && target_addresses? end end module ProcessPacketsMethods private macro process_each_packets each_packet do process_per_type end end end module MainMethods macro main_loop until @quit_signal rt
Crystal コンパイラを改造してチューニングしたら、5万行ぐらいから百数行ぐらいになった!!ヤった! Hello Crystal DPDK to LLVM IR (100ish lines) require "../src/dpdk" class Hello < Dpdk def hello_thread printf("Hello from lcore: %d\n", rte_lcore_id) end def main(argc, argv) rte_eal_init(argc, argv) rte_eal_mp_remote_launch(hello_thread) rte_eal_mp_wait_lcore end end Hello.run # # Run the program # # sudo build/hello % sudo build/hello EAL: Det
Static binaries on OSX is a hard issue, but Go achieved by using syscall directly. There is syscall package on Crystal too. Basic code is as following. ... str = "Hello, World!\n" syscall(WRITE, 1_u64, str.to_unsafe, str.size.to_u64) syscall(EXIT) % objdump -d hello hello: file format Mach-O 64-bit x86-64 Disassembly of section __TEXT,__text: __text: 1f60: 48 89 35 99 00 00 00 movq %rsi, 153(%rip)
自己紹介 Qiita初めてです。13年前から日本にいますが、日本生まれではないです。 よろしくお願いします。 はじめに マストドンのインスタンスのログイン情報が必須になります。LOGIN_EMAIL、LOGIN_PASSWORDに入れ替えてください。 デモ用としてpawooのAPIを使用しています。 環境 OSX/Linux golangインストールされてGOPATHなどが通っている状態 前準備 go get github.com/mattn/go-mastodon ClientIDとClientSecretを新規で作りたい場合は以下のスクリプトを実行し、発行された内容と入れ替える。 MASTODON_HOST=https://pawoo.net CLIENT_NAME=test curl -X POST -sS "${MASTODON_HOST}/api/v1/apps" \ -F "c
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く