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 <linux/module.h> | |
| #include <linux/skbuff.h> | |
| #include <net/cfg80211.h> | |
| #include <linux/mutex.h> | |
| #include <linux/workqueue.h> | |
| #define WIPHY_NAME "owl" /* Our WireLess */ | |
| #define NDEV_NAME WIPHY_NAME "%d" |
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
| /* simrupt: A device that simulates interrupts */ | |
| #include <linux/cdev.h> | |
| #include <linux/circ_buf.h> | |
| #include <linux/init.h> | |
| #include <linux/interrupt.h> | |
| #include <linux/kfifo.h> | |
| #include <linux/module.h> | |
| #include <linux/slab.h> | |
| #include <linux/workqueue.h> |
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 <inttypes.h> | |
| #include <sys/time.h> | |
| enum { | |
| EV_READ = (1 << 0), | |
| EV_WRITE = (1 << 1), | |
| EV_TIMEOUT_ONESHOT = (1 << 2), | |
| EV_TIMEOUT_PERIODIC = (1 << 3), | |
| EV_SIGNAL = (1 << 4), | |
| EV_CLOEXEC = (1 << 0), |
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
| /* Simple port forwarder */ | |
| #define _GNU_SOURCE 1 | |
| #include <assert.h> | |
| #include <errno.h> | |
| #include <fcntl.h> | |
| #include <limits.h> | |
| #include <netdb.h> | |
| #include <stdbool.h> | |
| #include <stdio.h> |
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 <assert.h> | |
| #include <fcntl.h> | |
| #include <limits.h> | |
| #include <semaphore.h> | |
| #include <signal.h> | |
| #include <stdbool.h> | |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <string.h> | |
| #include <sys/mman.h> |
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> | |
| static void test() { puts(__func__); } | |
| int main() { | |
| typedef void (*callback_t)(void); | |
| callback_t cb = &test; | |
| (*cb)(); | |
| } |
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> | |
| #define NUM 10000 | |
| int main() { | |
| float sum = 0.0f; | |
| for (int i = 0; i < NUM; i++) sum += i + 1; | |
| printf("Sum: %f\n", sum); | |
| return 0; | |
| } |
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
| import atexit | |
| import ctypes | |
| import os | |
| import shlex | |
| import sys | |
| import tempfile | |
| CMD_C_TO_SO = '{compiler} -shared -o {output} {input} {libraries}' |
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
| # Execute an executable under gdb, printing a call stack if we get a crash. | |
| gdb -return-child-result -quiet -batch \ | |
| -ex "set env MALLOC_CHECK_=3" \ | |
| -ex "set print thread-events off" \ | |
| -ex run \ | |
| -ex "thread apply all backtrace full" \ | |
| -ex "quit" \ | |
| $* |
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 <stddef.h> | |
| #include <stdint.h> | |
| #include <limits.h> | |
| #define ALIGN (sizeof(size_t)) | |
| #define ONES ((size_t)-1/UCHAR_MAX) | |
| #define HIGHS (ONES * (UCHAR_MAX/2+1)) | |
| #define HASZERO(x) ((x)-ONES & ~(x) & HIGHS) | |
| #define SS (sizeof(size_t)) |