Skip to content

Commit a8f871e

Browse files
committed
update zine to v0.10.2 and adjust github pages
1 parent 7481f81 commit a8f871e

File tree

8 files changed

+133
-55
lines changed

8 files changed

+133
-55
lines changed

.github/workflows/gh-pages.yml

Lines changed: 53 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,71 @@
1+
# adjusted from https://zine-ssg.io/docs/deploying/github-pages/
12
name: github pages
23

34
on:
45
push:
56
branches:
67
- master
8+
9+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
10+
permissions:
11+
contents: read
12+
pages: write
13+
id-token: write
14+
15+
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
16+
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
17+
concurrency:
18+
group: "pages"
19+
cancel-in-progress: false
20+
721
jobs:
822
deploy:
923
timeout-minutes: 20
1024
runs-on: "ubuntu-latest"
25+
environment:
26+
name: github-pages
27+
url: ${{ steps.deployment.outputs.page_url }}
28+
29+
# steps:
30+
# - name: Checkout
31+
# uses: actions/checkout@v4
32+
# with:
33+
# fetch-depth: 0 # Change if you need git info
34+
35+
# - name: Setup Zig
36+
# uses: mlugg/setup-zig@v1
37+
# with:
38+
# version: 0.14.0
39+
40+
# - name: Build
41+
# run: zig build --summary new
42+
43+
# - name: Deploy
44+
# uses: JamesIves/github-pages-deploy-action@v4
45+
# with:
46+
# folder: ./zig-out
47+
1148
steps:
12-
- name: Checkout
13-
uses: actions/checkout@v4
49+
- uses: actions/checkout@v4
1450
with:
1551
fetch-depth: 0 # Change if you need git info
1652

17-
- name: Setup Zig
18-
uses: mlugg/setup-zig@v1
53+
- name: Setup Zine
54+
uses: kristoff-it/setup-zine@v1
1955
with:
20-
version: 0.14.0
56+
version: v0.10.2
2157

22-
- name: Build
23-
run: zig build --summary new
58+
- name: Release
59+
run: zine release
2460

25-
- name: Deploy
26-
uses: JamesIves/github-pages-deploy-action@v4
61+
- name: Setup Pages
62+
uses: actions/configure-pages@v5
63+
64+
- name: Upload artifact
65+
uses: actions/upload-pages-artifact@v3
2766
with:
28-
folder: ./zig-out
67+
path: 'public'
68+
69+
- name: Deploy to GitHub Pages
70+
id: deployment
71+
uses: actions/deploy-pages@v4

README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
### Usage
22

3+
```
34
../zig-linux-x86_64-0.14.0/zig build serve
5+
zig build serve
6+
zine
7+
8+
zine release
9+
git diff --word-diff=color --no-index zig-out public
10+
```
411

512
### Markdown languages
613

@@ -24,3 +31,26 @@ So one has to workaround this via
2431
</pre>
2532
```
2633
or including sections into the item.
34+
35+
Work around unchecked references
36+
```
37+
content/articles/shennanigans_in_c.smd:16:5: error: unknown ref
38+
| - 1.[Pointer semantics](#pointer_semantics)
39+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
40+
```
41+
via
42+
```
43+
- 1.[Pointer semantics]($link.unsafeRef('pointer_semantics'))
44+
```
45+
46+
### Comments
47+
48+
- shtml
49+
```
50+
<!--<div :html="$page.content()"></div>-->
51+
```
52+
- smd
53+
```
54+
(empty line)
55+
[This is a comment]::
56+
```

build.zig

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,16 @@ const std = @import("std");
22
const zine = @import("zine");
33

44
pub fn build(b: *std.Build) !void {
5-
zine.website(b, .{
6-
.assets_dir_path = "assets",
7-
.content_dir_path = "content",
8-
.host_url = "https://matu3ba.github.io/",
9-
.layouts_dir_path = "layouts",
10-
.title = "Jans Website",
11-
});
5+
// zine.website(b, .{
6+
// .assets_dir_path = "assets",
7+
// .content_dir_path = "content",
8+
// .host_url = "https://matu3ba.github.io/",
9+
// .layouts_dir_path = "layouts",
10+
// .title = "Jans Website",
11+
// });
12+
b.getInstallStep().dependOn(&zine.website(b, .{}).step);
13+
14+
const serve = b.step("serve", "Start the Zine dev server");
15+
const run_zine = zine.serve(b, .{});
16+
serve.dependOn(&run_zine.step);
1217
}

build.zig.zon

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66

77
.dependencies = .{
88
.zine = .{
9-
.url = "git+https://github.com/kristoff-it/zine?ref=v0.9.0#e918b49937c071187a26b19132f707a5b53e381e",
10-
.hash = "1220066f645b5ef9f9080e48073942fd3434ad789ad9548496d48d60fab5467cde15",
9+
.url = "git+https://github.com/kristoff-it/zine?ref=v0.10.2#122be41ecc4f2f3a56ad3568dd5a8a0ad93de050",
10+
.hash = "1220e93519a9ac531a02b5f79bf69a11ab2bfffd28ff90e95fb486cd5a1c4ae54e62",
1111
},
1212
},
1313
.paths = .{"."},

content/articles/shennanigans_in_c.smd

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ This article focuses on some of the non-obvious and easy to make mistakes
1212
non-experienced C programmers are likely to make and are/can not completely
1313
be covered by tooling without going into edge cases relevant to performance
1414
and covering the most simple and conservative approach:
15-
- 1.[Pointer semantics](#pointer_semantics)
15+
- 1.[Pointer semantics]($link.unsafeRef('pointer_semantics'))
1616
- 2.[Sequence points](#seq_pts)
1717
- 3.[Bit-fields](#bitfields)
1818

@@ -57,17 +57,17 @@ abbreviated via macro `NULL`.
5757
[]($section.id("pointer_access_practice"))
5858
**Pointer access** in **practice**.
5959
- Provenance as regions pointer is allowed to point to for access.
60-
[provenance.c]($code.asset('./provenance.c').language('c'))
60+
[provenance.c]($code.asset('provenance.c').language('c'))
6161
- Copy around some bytes from not overlapping regions (otherwise use memmove).
62-
[copy_bytes.c]($code.asset('./copy_bytes.c').language('c'))
62+
[copy_bytes.c]($code.asset('copy_bytes.c').language('c'))
6363
- Correct alignment of pointers with temporary, when necessary.
64-
[correct_alignment.c]($code.asset('./correct_alignment.c').language('c'))
64+
[correct_alignment.c]($code.asset('correct_alignment.c').language('c'))
6565
- Ensure correct storage and padding size for pointers via sizeof.
66-
[storage_padding.c]($code.asset('./storage_padding.c').language('c'))
66+
[storage_padding.c]($code.asset('storage_padding.c').language('c'))
6767
- Allowed aliasing of pointers (type-based aliasing analysis)
68-
[allowed_aliasing.c]($code.asset('./allowed_aliasing.c').language('c'))
68+
[allowed_aliasing.c]($code.asset('allowed_aliasing.c').language('c'))
6969
- Non-allowed aliasing of pointers (type-based aliasing analysis)
70-
[non_allowed_aliasing.c]($code.asset('./non_allowed_aliasing.c').language('c'))
70+
[non_allowed_aliasing.c]($code.asset('non_allowed_aliasing.c').language('c'))
7171

7272
[]($section.id("pointer_exceptions"))
7373
**The Exceptions**
@@ -81,7 +81,7 @@ abbreviated via macro `NULL`.
8181
back. This also means that `sizeof (function pointer) == sizeof (void *)` must be uphold, which is not true for
8282
microcontrollers with separate address space for code and data or CHERI in mixed capability mode/hybrid compilation mode.
8383
Address space annotations are mandatory for this to work and it is unfortunate that standards do not reflect this as of 2024-04-28.
84-
[aliasing_exceptions_uniform_address_space.c]($code.asset('./aliasing_exceptions_uniform_address_space.c').language('c'))
84+
[aliasing_exceptions_uniform_address_space.c]($code.asset('aliasing_exceptions_uniform_address_space.c').language('c'))
8585

8686
[]($section.id("pointer_construction_requirements"))
8787
**Pointer construction requirements** are unspecified in all C standards with potentially some hints and nothing
@@ -154,12 +154,12 @@ Other more elaborative examples can be seen in the github gist "What is the Stri
154154

155155
[]($section.id("opaque"))
156156
Opaque type idiom.
157-
[opaque.h]($code.asset('./opaque.h').language('c'))
158-
[opaque.c]($code.asset('./opaque.c').language('c'))
157+
[opaque.h]($code.asset('opaque.h').language('c'))
158+
[opaque.c]($code.asset('opaque.c').language('c'))
159159

160160
[]($section.id("ptrintconv"))
161161
Pointer to integer and integer to pointer conversion.
162-
[ptrtoint_inttoptr.c]($code.asset('./ptrtoint_inttoptr.c').language('c'))
162+
[ptrtoint_inttoptr.c]($code.asset('ptrtoint_inttoptr.c').language('c'))
163163

164164
[]($section.id("lto"))
165165
Link time optimization (LTO) usage and problems. One can use `ptrtoint_inttoptr.c` with flags for strong LTO
@@ -172,24 +172,24 @@ compiler automatically do runtime selection of the best SIMD routine instead of
172172
is vectorized and one has to check for example via `clang -O3 -Rpass=loop-vectorize -Rpass-missed=loop-vectorize -Rpass-analysis=loop-vectorize`
173173
or `gcc -O3 -ftree-vectorizer-verbose=3` and use [clang extensions](https://clang.llvm.org/docs/LanguageExtensions.html)
174174
and [gcc extensions](https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html) like `__builtin_assume_aligned`.
175-
[extern_avx.h]($code.asset('./extern_avx.h').language('c'))
176-
[extern_avx.c]($code.asset('./extern_avx.c').language('c'))
177-
[memcpy_avx.c]($code.asset('./memcpy_avx.c').language('c'))
175+
[extern_avx.h]($code.asset('extern_avx.h').language('c'))
176+
[extern_avx.c]($code.asset('extern_avx.c').language('c'))
177+
[memcpy_avx.c]($code.asset('memcpy_avx.c').language('c'))
178178

179179
[]($section.id("cerberus"))
180180
Checking C code validity with Cerberus does not imply absence of compiler miscompilations.
181-
[cerberus_install.sh]($code.asset('./cerberus_install.sh').language('bash'))
182-
[extern_miscompilation.h]($code.asset('./extern_miscompilation.h').language('c'))
183-
[extern_miscompilation.c]($code.asset('./extern_miscompilation.c').language('c'))
184-
[ptr_provenance_miscompilation.c]($code.asset('./ptr_provenance_miscompilation.c').language('c'))
181+
[cerberus_install.sh]($code.asset('cerberus_install.sh').language('bash'))
182+
[extern_miscompilation.h]($code.asset('extern_miscompilation.h').language('c'))
183+
[extern_miscompilation.c]($code.asset('extern_miscompilation.c').language('c'))
184+
[ptr_provenance_miscompilation.c]($code.asset('ptr_provenance_miscompilation.c').language('c'))
185185

186186
[]($section.id("cheri"))
187187
CHERI usage is left as task for the reader. Useful links are `https://github.com/CTSRD-CHERI/cheribuild`,
188188
`https://github.com/CTSRD-CHERI/cheri-c-programming` and `https://github.com/capablevms/cheri-examples`.
189189

190190
[]($section.id("seq_pts"))
191191
**Sequence Points** in simple case and with storage lifetime extension.
192-
[sequence_points.c]($code.asset('./sequence_points.c').language('c'))
192+
[sequence_points.c]($code.asset('sequence_points.c').language('c'))
193193

194194
[]($section.id("bitfields"))
195195
**Bit-fields** should not be used unless for non-portable code regarding

content/articles/shennanigans_in_cpp.smd

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ has no static analysis to reduce transition efforts from C++.
4848
via iterator or use emplace, because there is no check for the elements
4949
existence or (typically raw C) values of members can remain undefined after
5050
object creation due to implicit default constructor.
51-
[hashmap_simple_ub.cpp]($code.asset('./hashmap_simple_ub.cpp').language('cpp'))
51+
[hashmap_simple_ub.cpp]($code.asset('hashmap_simple_ub.cpp').language('cpp'))
5252
- Providing const char * to a function with reference will use the stack-local
5353
memory instead of using a copy. If further, `c_str()` is used to emplace into a
5454
`std::map`, this leads to UB due to usage of invalid memory once the stack
@@ -61,18 +61,18 @@ has no static analysis to reduce transition efforts from C++.
6161
- There is no type safety in `reinterpret_cast` usage, which is worse than
6262
memcpy. However, the prevention of another temporary for portable code may be
6363
worth it.
64-
[reinterpret_cast_ts.cpp]($code.asset('./reinterpret_cast_ts.cpp').language('cpp'))
64+
[reinterpret_cast_ts.cpp]($code.asset('reinterpret_cast_ts.cpp').language('cpp'))
6565
- C++ conversion string to int is worse without boost, so use C's strtol.
6666
- Checking, if typename is a string is complex (even with C++17 extension).
67-
[is_typname_string.hpp]($code.asset('./is_typname_string.hpp').language('cpp'))
67+
[is_typname_string.hpp]($code.asset('is_typname_string.hpp').language('cpp'))
6868
- auto does verbatim replacement of the return type, which can hide a
6969
stack-local copy or move. Only use `auto` for well-known iterators, status
7070
tuples, shared pointers etc, but never for objects and object references.
7171
- Interoperating type safe with c strings is cumbersome.
72-
[cstr_interop.cpp]($code.asset('./cstr_interop.cpp').language('cpp'))
72+
[cstr_interop.cpp]($code.asset('cstr_interop.cpp').language('cpp'))
7373
- MSVC has no reliable relative paths as macro yet (see
7474
experimental:deterministic mode). Workaround to get filename by Andry.
75-
[msvc_rel_path.cpp]($code.asset('./msvc_rel_path.cpp').language('cpp'))
75+
[msvc_rel_path.cpp]($code.asset('msvc_rel_path.cpp').language('cpp'))
7676
- Destructors of virtual classes should have lifetime annotation, unless final
7777
class. Otherwise, debugging problems will be painful, because the intended
7878
object lifetimes become ambiguous on reading the code. Consider using clang
@@ -85,14 +85,14 @@ has no static analysis to reduce transition efforts from C++.
8585
- Streams do not enforce C abi and are overly complex for printing memory.
8686
Further (no example here), they need to extensions to offer non-blocking
8787
reads, writes and introspection.
88-
[streams_no_cabi.cpp]($code.asset('./streams_no_cabi.cpp').language('cpp'))
88+
[streams_no_cabi.cpp]($code.asset('streams_no_cabi.cpp').language('cpp'))
8989
- Incomplete type can not be instantiated in template:
9090
1. pull in all headers deps of headers
9191
2. class forward declares may create circular dependencies
9292
3. build each file individually
9393
4. might be a circular dependency during template usage
9494
- Missing virtual destructor for non-final methods in classes is technically UB.
95-
[missing_virt_destructor.cpp]($code.asset('./missing_virt_destructor.cpp').language('cpp'))
95+
[missing_virt_destructor.cpp]($code.asset('missing_virt_destructor.cpp').language('cpp'))
9696
- Why exceptions do not scale.
97-
[exceptions_dont_scale.cpp]($code.asset('./exceptions_dont_scale.cpp').language('cpp'))
97+
[exceptions_dont_scale.cpp]($code.asset('exceptions_dont_scale.cpp').language('cpp'))
9898
- `__STDC_VERSION__` is not necessary defined by C++ compilers.

content/articles/shennanigans_in_python.smd

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,22 +37,22 @@ Aside of these more fundamental limitations, here the [list of shennanigans](#li
3737
- `.strip()` is necessary after file read, because Python automatically adds
3838
`\n` and there is no way to read without newlines into a list.
3939
- Testing for subdictionaries with `dict` is unreadable, so such a method is missing
40-
[missing_dict_methods1.py]($code.asset('./missing_dict_methods1.py').language('python'))
40+
[missing_dict_methods1.py]($code.asset('missing_dict_methods1.py').language('python'))
4141
- `dict` has no method to check, if the fields of a dictionary are in another dictionary
42-
[missing_dict_methods2.py]($code.asset('./missing_dict_methods2.py').language('python'))
42+
[missing_dict_methods2.py]($code.asset('missing_dict_methods2.py').language('python'))
4343
- `dict` has no method to check, if all fields and values of a dictionary are in another dictionary
44-
[missing_dict_methods3.py]($code.asset('./missing_dict_methods3.py').language('python'))
44+
[missing_dict_methods3.py]($code.asset('missing_dict_methods3.py').language('python'))
4545
- Tuples and dicts are annoying to differentiate
46-
[tup_and_dicts.py]($code.asset('./tup_and_dicts.py').language('python'))
46+
[tup_and_dicts.py]($code.asset('tup_and_dicts.py').language('python'))
4747
- Stack trace formatting is inefficient and one can not use <code>gf</code> or <code>gF</code> vim shortcuts to jump to location
4848
function to write status + trace to variable.
49-
[stacktrace_fmt.py]($code.asset('./stacktrace_fmt.py').language('python'))
49+
[stacktrace_fmt.py]($code.asset('stacktrace_fmt.py').language('python'))
5050
- Mixed double quote (`"`) and single quote (`'`) strings are invalid json
51-
[invalid_json.py]($code.asset('./invalid_json.py').language('python'))
51+
[invalid_json.py]($code.asset('invalid_json.py').language('python'))
5252
- `os.kill()` does not call registered cleanup function
5353
`atexit.register(exit_cleanup)` by daemonized threads. Must store pids of
5454
child processes and clean them explicitly or signal main thread via
55-
[signal_main_thread.py]($code.asset('./signal_main_thread.py').language('python'))
55+
[signal_main_thread.py]($code.asset('signal_main_thread.py').language('python'))
5656
- [Socket timeout can cause file-like readline() method to lose data](https://github.com/python/cpython/issues/51571), workaround
5757
1. Read from Kernel structure and append chunk-wise to buffer from socket until stop event (via select).
5858
2. After each read, try to line a line from the buffer and remove the line on success (being utf-8 etc).
@@ -61,7 +61,7 @@ Aside of these more fundamental limitations, here the [list of shennanigans](#li
6161
- Generic module annotation is not allowed and mypy has no explicit docs for
6262
this. The following does not work and `module: object` is the closest we can
6363
get as simple annotation.
64-
[module_annotation.py]($code.asset('./module_annotation.py').language('python'))
64+
[module_annotation.py]($code.asset('module_annotation.py').language('python'))
6565
- There are no scheduling and watchdog methods, which makes Python thread
6666
scheduling very unreliable. Unlucky schedules may cause fatal delay for
6767
shuffling data between daemon thread and main thread. As example, an

content/articles/shennanigans_in_zig.smd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ As of ~~2024-04-04 (zig version 0.12.0-dev.3562+96bc8f17c)~~ 2024-07-01 (zig ver
2020
The rest of the language feels very smooth to me in contrast to the potential
2121
very flexible and cryptic syntax of C (see [preprocessor iceberg](https://github.com/JadLevesque/PPMP-Iceberg)).
2222
- Bottlenecks of array assignments not obvious via <code>@memcpy</code>:
23-
[perf_array_assignment.zig]($code.asset('./perf_array_assignment.zig').language('zig'))
23+
[perf_array_assignment.zig]($code.asset('perf_array_assignment.zig').language('zig'))
2424
- Signaling: Test runner allows no signaling to <code>qemu -g
2525
4242</code> (debugger mode). Qemu uses gdb server signaling,
2626
which means sending SIGKILL is necessary to kill

0 commit comments

Comments
 (0)