代码高亮基于 syntaxlight 实现
// 注释信息
#include <linux/init.h>
#include <linux/module.h>
static int major = 237;
static int minor = 0;
static dev_t devno;
static int hello_open (struct inode *inode, struct file *filep)
{
printk("hello_open()\n");
return 0;
}
static int hello_release (struct inode *inode, struct file *filep)
{
printk("hello_release()\n");
return 0;
}
#define KMAX_LEN 32
char kbuf[KMAX_LEN+1] = "kernel";
//write(fd,buff,40);
static ssize_t hello_write (struct file *filep, const char __user *buf, size_t size, loff_t *pos)
{
int error;
if(size > KMAX_LEN)
{
size = KMAX_LEN;
}
memset(kbuf,0,sizeof(kbuf));
if(copy_from_user(kbuf, buf, size))
{
error = -EFAULT;
return error;
}
printk("%s\n",kbuf);
return size;
}
Agsym_t *sym = agattr(g,AGNODE,"shape","box");
char *str = agxget(n,sym);
agxset(n,sym,"hexagon");
typedef struct mynode_s {
Agrec_t h;
int count;
} mynode_t;
mynode_t *data;
Agnode_t *n;
n = agnode(g, "mynodename", TRUE);
data = (mynode_t *)agbindrec(n, "mynode_t", sizeof(mynode_t), FALSE);
data->count = 1;
int setup(void* BIOS) {
long __res;
__asm__ volatile("int $0x80" : "=a"(__res) : "0"(0), "b"((long)(BIOS)));
if (__res >= 0) return (int)__res;
errno = -__res;
return -1;
}
static int __init dummy_numa_init(void)
{
printk(KERN_INFO "%s\n",
numa_off ? "NUMA turned off" : "No NUMA configuration found");
/* max_pfn是e820探测到的最大物理内存页,其初始化是max_pfn = e820__end_of_ram_pfn() */
printk(KERN_INFO "Faking a node at [mem %#018Lx-%#018Lx]\n",
0LLU, PFN_PHYS(max_pfn) - 1);
/* 一个nodemask_t是 位图, 最多支持MAX_NUMNODES个node
* 这里将node 0置位
*/
node_set(0, numa_nodes_parsed);
/* 将node 0的起始和结束地址记录起来 */
numa_add_memblk(0, 0, PFN_PHYS(max_pfn));
return 0;
}
int __init numa_add_memblk(int nid, u64 start, u64 end)
{
return numa_add_memblk_to(nid, start, end, &numa_meminfo);
}
// arch/x86/mm/numa_internal.h
struct numa_meminfo {
int nr_blks;
struct numa_memblk blk[NR_NODE_MEMBLKS];
};
struct numa_memblk {
u64 start;
u64 end;
int nid;
};
static int __init numa_add_memblk_to(int nid, u64 start, u64 end,
struct numa_meminfo *mi)
{
/* ignore zero length blks */
if (start == end)
return 0;
/* whine about and ignore invalid blks */
if (start > end || nid < 0 || nid >= MAX_NUMNODES) {
pr_warn("Warning: invalid memblk node %d [mem %#010Lx-%#010Lx]\n",
nid, start, end - 1);
return 0;
}
if (mi->nr_blks >= NR_NODE_MEMBLKS) {
pr_err("too many memblk ranges\n");
return -EINVAL;
}
mi->blk[mi->nr_blks].start = start;
mi->blk[mi->nr_blks].end = end;
mi->blk[mi->nr_blks].nid = nid;
mi->nr_blks++;
return 0;
}
// arch/x86/kernel/setup.c | setup_arch
// arch/x86/mm/numa_64.c | initmem_init
// arch/x86/mm/numa.c | x86_numa_init
// arch/x86/mm/numa.c | numa_init
void __init x86_numa_init(void)
{
if (!numa_off) {
#ifdef CONFIG_ACPI_NUMA
if (!numa_init(x86_acpi_numa_init))
return;
#endif
#ifdef CONFIG_AMD_NUMA
if (!numa_init(amd_numa_init))
return;
#endif
}
numa_init(dummy_numa_init);
}
import argparse
import os
import shutil
class Markdown:
def __init__(self) -> None:
# print("Activate MarkdownParser")
self.tabsize = 4
self.build_parser()
def build_parser(self):
self.preprocess_parser = buildPreprocessParser(self.tabsize)
self.block_parser = buildBlockParser()
self.tree_parser = buildTreeParser()
self.export_processor = buildExportProcessor()
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**",
"/usr/src/linux-headers-4.15.0-142-generic/include",
"/home/lzx/Driver/linux-3.14-fs4412/include",
"/usr/src/linux-headers-4.15.0-142-generic/arch/x86/include",
"/usr/src/linux-headers-4.15.0-142/include/uapi",
"/usr/src/linux-headers-4.15.0-142-generic/arch/x86/include/generated"
],
"defines": [
"__KERNEL__",
"__GNUC__"
],
"compilerPath": "/usr/bin/gcc",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "linux-gcc-x64",
"compilerArgs": []
}
],
"version": 4
}
git commit -m "[perf] : change css in index.css"
#!/bin/bash
# Simple script to list version numbers of critical development tools
export LC_ALL=C
bash --version | head -n1 | cut -d" " -f2-4
MYSH=$(readlink -f /bin/sh)
echo "/bin/sh -> $MYSH"
echo $MYSH | grep -q bash || echo "ERROR: /bin/sh does not point to bash"
unset MYSH
echo -n "Binutils: "; ld --version | head -n1 | cut -d" " -f3-
bison --version | head -n1
if [ -h /usr/bin/yacc ]; then
echo "/usr/bin/yacc -> `readlink -f /usr/bin/yacc`";
elif [ -x /usr/bin/yacc ]; then
echo yacc is `/usr/bin/yacc --version | head -n1`
else
echo "yacc not found"
fi
echo -n "Coreutils: "; chown --version | head -n1 | cut -d")" -f2
diff --version | head -n1
find --version | head -n1
gawk --version | head -n1
if [ -h /usr/bin/awk ]; then
echo "/usr/bin/awk -> `readlink -f /usr/bin/awk`";
elif [ -x /usr/bin/awk ]; then
echo awk is `/usr/bin/awk --version | head -n1`
else
echo "awk not found"
fi
gcc --version | head -n1
g++ --version | head -n1
grep --version | head -n1
gzip --version | head -n1
cat /proc/version
m4 --version | head -n1
make --version | head -n1
patch --version | head -n1
echo Perl `perl -V:version`
python3 --version
sed --version | head -n1
tar --version | head -n1
makeinfo --version | head -n1 # texinfo version
xz --version | head -n1
echo 'int main(){}' > dummy.c && g++ -o dummy dummy.c
if [ -x dummy ]
then echo "g++ compilation OK";
else echo "g++ compilation failed"; fi
rm -f dummy.c dummy
<toml> ::= <expression> ( <CRLF> <expression> )*
<expression> ::= (<pair> | <table>)?
<pair> ::= <path> '=' <value>
<path> ::= (<ID> | <STRING>) ( '.' (<ID> | <STRING>)) *
<table> ::= <table_header> <CRLF> <table_entry>
| <table_array_header> <CRLF> <table_entry>
<table_header> ::= '[' <path> ']'
<table_array_header> ::= '[' '[' <path> ']' ']'
<table_entry> ::= (<pair>)? ( <CRLF> <pair> )*
<value> ::= <STRING> | <NUMBER> | <DATE> | true | false | <array> | <inline_table>
<array> ::= '[' ( <value> (',' <value> )* ','?)? ']'
<inline_table> ::= '{' ( <pair> (',' <pair>)* ','?)? '}'
function factorial(n)
if n <= 0 then
return 1
else
return n * factorial(n - 1)
end
end
local result = factorial(5)
print("Factorial of 5:", result)
local a = 10
function modifyGlobal()
a = 20
end
function accessGlobal()
print("Global a:", a)
end
modifyGlobal()
accessGlobal()
local largeNumber = 2^100
print("Large number:", largeNumber)
local largeTable = {}
for i = 1, 10^6 do
largeTable[i] = i
end
print("Large table length:", #largeTable)
local longString = ""
for i = 1, 10^5 do
longString = longString .. tostring(i)
end
print("Length of longString:", #longString)
local nestedTable = {
a = 1,
b = {
c = 2,
d = {
e = 3
}
}
}
print("Value of nestedTable.b.d.e:", nestedTable.b.d.e)
function multipleReturns()
return 1, 2, 3
end
local a, b, c = multipleReturns()
print("Values:", a, b, c)
local mixedTable = {
"first",
"second",
key1 = "value1",
key2 = "value2",
key3 = {
key1 = function ()
end,
key2 = 1
}
}
print("Value at index 2:", mixedTable[2])
print("Value of key 'key1':", mixedTable.key1)
print(mixedTable.key3.key1)
print(mixedTable.key3.key2)
print(mixedTable.key3:asd())
local value = 42
if value then
print("Value is truthy")
else
print("Value is falsy")
end
# This is a TOML document
title = "TOML Example"
title1adb = 100
[owner]
name = "Tom Preston-Werner"
dob = 1979-05-27T07:32:00-08:00
[database]
enabled = true
ports = [ 8000, 8001, 8002 ]
data = [ ["delta", "phi"], [3.14] ]
temp_targets = { cpu = 79.5, case = 72.0 }
[servers]
[servers.alpha]
ip = "10.0.0.1"
role = "frontend"
[servers.beta]
ip = "10.0.0.2"
role = "backend"
<?xml version="1.0" encoding="ISO-8859-1"?>
<article>
<title>Introduction to XML Parsing</title>
<author>Jane Smith</author>
<content>
XML parsing is a fundamental skill for working with structured data. It involves extracting information from XML documents and processing it.
</content>
<comments>
<comment>
<author>John Doe</author>
<date>2023-07-05</date>
<text>Great article! I learned a lot.</text>
</comment>
<comment>
<author>Jane Smith</author>
<date>2023-07-07</date>
<!-- <text>Thank you, John! I'm glad you found it helpful.</text> -->
</comment>
</comments>
</article>