there's an #Emscripten #Docker image you can use to compile C to #Wasm with commands like docker run --rm -v "$PWD":/src -u "$(id -u):$(id -g)" emscripten/emsdk emcc hello.c -o hello.js
#RISC-V #CFI control-flow integrity extension Zicfisslp for #security against ROP (return-oriented programming) etc.
#Web-workers can transfer so-called "transferable objects" to other “agents” in the “cluster” without copying them by listing them in an array passed as a second argument to postMessage; the ArrayBuffer in .buffer of typed arrays like Uint8Array is such a transferable object, as are things like MessagePort, AudioData, and WritableStream. Agents are web workers or the DOM execution context. #JS #wasm #browsers
Messaging #Web-workers is fast #performance even without transferable objects, but the test code here is broken #browsers
#Emscripten has a thing called "Asyncify" to compile your C into explicit continuation-passing style so you can do things like emscripten_sleep and a blocking emscripten_wget.
#Emscripten supports writing #JS functions in your C with EM_JS. If the arguments are int32_t, double, or NUL-terminated C strings, it translates them for you automatically, but pointers are treated as integers the JS can index HEAP8, HEAPU8, HEAP32, etc., with. String return values get malloced. There's also EM_ASM for inline JS, which has some trouble with commas that can be worked around with extra parens. EM_ASM_INT, EM_ASM_PTR, etc., also permit return values.
#Emscripten has an emscripten_run_script function to eval arbitrary #JS generated by the C it compiled! Unless -sDYNAMIC_EXECUTION=0 is set.
#Emscripten has an emscripten_set_main_loop function you're supposed to run in order to get #JS to call your C code from requestAnimationFrame or periodically.
#Emscripten has an emscripten_hide_mouse function for hiding the OS mouse cursor, but I guess nothing that can warp the hidden cursor like for mouselook in Minetest.
#Emscripten has an asynchronous emscripten_dlopen function to dynamically load a library from an URL.
the main reference for #Emscripten's "Asyncify" setup, which automatically determines the color of each C function (Promise-colored or synchronous), typically adding 50% overhead
#Emscripten exports Module.ccall and Module.cwrap functions to #JS for calling into #Wasm code.
This is the guide for calling #JS from C (#Wasm) using EM_JS, EM_ASM, etc. Apparently with EM_ASM you are not supposed to use doublequotes!
A different way to enable C compiled with #Emscripten to call #JS is to add JS functions to library.js or LibraryManager.library and pass your JS to emcc with the option --js-library. This seems like a potentially cleaner way to handlle the JS/C split for APIs that have to cross the boundary.
This is where the #Emscripten docs explain how to read #wasm memory from #JS with Module.HEAPU8.set(myTypedArray, ptr) or getValue(ptr, type) or setValue(ptr, value, type).
"WAjic" is a simplified alternative to #Emscripten which, like Emscripten, generates #wasm from C with LLVM 8.0.0 or greater with clang -target wasm32 foo.c -o foo.wasm and a lot of other options. Also apparently #Node 8 and newer support wasm. WAjic is written in Node. The main missing feature seems to be setjmp.
Explanation of #Web-workers in #JS. Normally it's like const w = new Worker('worker.js'), where worker.js defines an onmessage callback which can use a postMessage global to send back too its creator, who can handle it by setting w.onmessage to the appropriate callback. There's a synchronous, blocking importScripts in the worker that takes URLs oof libraries to load. Runtime errors invoke onerror. #browsers
oh apparently #Web-workers can also use addEventListener on their global scope to listen for message events, and also when you create one you can call that on it
apparently you can create #Web-workers from localhost HTTP URLs, but not file:// URLs, and in I guess Chromium not data: URLs, but you can create Blob URLs in #JS. If HTTP or HTTPS, the MIME type has to be text/javascript. #browsers
a #PDP-11 core in VHDL. #retrocomputing
Jens #Gustedt’s "Modern C" #ebook is #CC BY-NC-ND and is reputedly the best current #C book
Maxime Coste explains #Kakoune's #UX design. “I have been working, for the last 5 years, on a new modal editor called Kakoune. It first started as a reimplementation of Vim (the most popular vi clone) whose source code is quite dated. But, I soon realized that we could improve a lot on vi editing model.” The page has a bunch of tiny looping WebP videos to demonstrate particular UI features, which I think are silent. It feels close enough to vi to be almost usable without an extensive training period, and its multiple selection stuff seems better. #editors