Quantcast
Channel: c – Gea-Suan Lin's BLOG
Browsing all 52 articles
Browse latest View live

在 FreeBSD 上練習 Objective C…

一樣用 gcc 就可以練習了,首先要先裝 lang/gnustep-base: cd /usr/ports/lang/gnustep-base; sudo make install clean 裝好後 compile 的兩個階段要對 gcc 加上不同的參數: -I/usr/local/GNUstep/System/Library/Headers 以及:...

View Article



Image may be NSFW.
Clik here to view.

推薦《An Introduction to Programming in Go》這本書…

書的資料: An Introduction to Programming in Go. Copyright © 2012 by Caleb Doxsey ISBN: 978-1478355823 以及網站:「An Introduction to Programming in Go」。有平裝實體書版本,也有電子 Kindle 版,網站上有 PDF 可以下載,或是直接 HTML 觀看。我是看完...

View Article

FreeBSD 將在 10.0 時將預設編譯器從 GCC 換成 clang

FreeBSD 預定在今年十一月將 amd64 與 i386 版本的 C 與 C++ 預設編譯器從 GCC 4.2.1 換成 clang,也就是下一個 major release (10.0) 就會是預設編譯器:「Clang as default compiler November 4th」。 自從 GCC 決定要換成 GPLv3...

View Article

了解 C 語言的數字資料型態…

在「Deep C: Understanding the Design of C Integer Types」這篇文章裡面以 C99 為參考文件,說明 C 語言的資料型態 (尤其是數字的部份)。 裡面引用了規個書的文件,說明「為什麼」數字資料型態會長這樣: To help ensure that no code explosion occurs for what appears to be a...

View Article

用 C Macro 實作的紅黑樹…

用 C Macro 實作的紅黑樹 (Red-black tree) 很經典,不過每次都忘記怎麼用… XD 紅黑樹是平衡二元搜尋樹的一種,除了二元搜尋樹有的結構外,節點的資訊多了顏色。然後利用顏色達到平衡的特性。 先定義單一節點的資料結構: struct element { char *key; int value1; char *value2; RB_ENTRY(element) meta; };...

View Article


ESR 解釋 C 的 Compiler 對 Structure Packing 的處理…

ESR (Eric S. Raymond) 寫了一篇 C Compiler 對 struct 實際如何佔用記憶體空間的說明:「The Lost Art of C Structure Packing」,全文在「The Lost Art of C Structure Packing」。 以前都學過也都還記得,但沒用就不容易想起來… 以文章裡的例子用這個 struct 說明: struct { char...

View Article

C 語言的 extern 與 static…

把十年多的 BBS source code porting 到 Ubuntu 上,被迫要用 GCC 4.6 而一路找出來的… 在 BBS 內有這樣的資料結構要處理: typedef struct p { struct p *pointer; } P; static P p1 = { &p2 }; static P p2 = { &p1 }; 兩個要互指,但在指定 p1 時 p2...

View Article

Go 的 self-boot 計畫

Go 的 self-boot 計畫,也就是用 Go compiler 編 Go compiler:「Russ Cox – porting the Go compiler from C to Go」。 其中提到: The goal is to convert *their* C code (not all C code). They want generated code to be...

View Article


C 對 Go Channel 的實做

在「Pure C implementation of Go channels.」這邊看到有人在 C 語言裡面實做 Go 的 Channel,包括了 Unbuffered 與 Buffered 版本。 看起來是支援 multithreading 的:「Add missing pthread_cond_destroy in chan init cleanup」、「Add -lpthread to...

View Article


Google 將之前買下 Skybox 公司的工具放出來 (MapReduce for C)

在 Zite 上看到的,Google 把之前買下的 Skybox 所開發的工具 MapReduce for C (MR4C) 放出來:「Google open sources a MapReduce framework for C/C++」。 MR4C 的程式碼放在 GitHub 上,以 Apache License Version 2.0 授權放出來:「google/mr4c」。

View Article

MILL:在 C 裡面實作 Go-style 的 concurrency

看到「Go-style concurrency in C」這個專案,在 C 上實作 Go-style 的 concurrency,包括了 channel 的設計。原始程式碼可以在 GitHub 上的「sustrik/mill」看到。 在「mill.c」可以看到實作細節,另外也可以看到 yield() 的設計。 不過目前還很早期,請小心服用: This is a proof of concept...

View Article

Image may be NSFW.
Clik here to view.

Go 1.5 的進展

Andrew Gerrand 在「The State of Go - Where we are in May 2015」這份投影片裡面提到了不少 1.5 的改變與改善,預定在今年八月釋出。 首先是全部都改用 Go 寫,不再需要 C 語言的協助了: The gc tool chain has been converted from C to Go. 而效能上的改善最大的是 GC 的部份:...

View Article

Image may be NSFW.
Clik here to view.

Facebook 推出靜態分析工具:Facebook Infer

Facebook 推出了靜態分析工具 Facebook Infer,可以事先找出 Android 與 iOS 上的 bug:Open-sourcing Facebook Infer: Identify bugs before you ship。 從官方給的操作動畫中就可以看出來怎麼跑了。目前看起來支援三種程式語言,C、Objective-C、Java: Facebook Infer is a...

View Article


Google 工程師在 Amazon 上對 Type C USB 線的評論

先前提到「Google 工程師在 Amazon 上留下對 USB-C 線的精彩評價...」,後來這位工程師 Benson Leung 寫了更多的評價出來,在「Amazon.com: Profile for Benson Leung」這邊可以看到。 可以看到大量的線被打了兩顆星,不過還是少數有幾條線測過了: USB Type C cable (USB-C) to USB3.0 Type A:...

View Article

Android NDK 宣佈向 Clang 靠攏...

在 Hacker News Daily 上看到 Android NDK 宣佈向 Clang 靠過去的消息:「Changelog for NDK Build 2490520」。 Android NDK 做為效能的加速手段而使用到 C 或是 C++,所以會使用對應的 compiler suite: The NDK is a toolset that allows you to implement...

View Article


因為一條 USB 線燒了三個設備...

Benson Leung 花了不少時間在測試 USB 線 (「Google 工程師在 Amazon 上留下對 USB-C 線的精彩評價...」與「Google 工程師在 Amazon 上對 Type C USB 線的評論」),而前陣子他測到一條超棒的 USB 線,把他三個測試設備都燒壞了:(出自這邊) Surjtech's A-to-C cable seriously damaged a...

View Article

在 C 裡 Concurrency 的 Library

看到「libdill: Structured Concurrency for C」這個東西,在 C 裡實作了兩個不同種類的 concurrency,一個是 proc (process-based) 一個是 go (corouting-based)。 支援的 function 算是蠻清晰的,範例也很清楚: #include <libdill.h> #include...

View Article


OpenBSD 將 ACME Client (Let's Encrypt Client) 納入系統

看到 OpenBSD 直接把 ACME 協定的 client 放進系統內,而 ACME 也就是 Let's Encrypt 所使用的協定:「Let's Encrypt client imported into -current」: CVSROOT: /cvs Module name: src Changes by: florian@cvs.openbsd.org 2016/08/31...

View Article

Tor 在考慮使用 Rust 改寫

不過也不確定是不是愚人節消息就是了:「[tor-dev] Tor in a safer language: Network team update from Amsterdam」。 Tor 考慮使用 Rust 改寫,目前已經完成的部份,以及接下來的規劃: What has already been done: - Rust in Tor build - Putting together...

View Article

Image may be NSFW.
Clik here to view.

各家 glob 的效能...

在「Glob Matching Can Be Simple And Fast Too」這邊看到在分析 (a.*)nb 這樣的 pattern 的效能 (像是 a.*a.*a.*b 這樣的東西),第一波先測 shell,結果發現有趣的現象: 那個 csh 是怎麼了 XDDD Looking at the source code, it doesn’t attempt to perform glob...

View Article
Browsing all 52 articles
Browse latest View live




Latest Images