Saturday, July 2, 2022

New release of Ada for Slackware 15.0

Finally, after many years of inavtivity, a new release is out for Slacware 15.0.

Major changes of this release: contains the Alire; the GNATStudio is using the binary GNAT Studio Continuous Release 20220512, I failed to build it from source due to lots of dependcies and stuck in the Ada langguare server; a build script that boostrap gprbuild and build/install all the basic packages (XMLAda, GTKAda, Florist, AUnit, GNATCOLL, etc).

Thursday, February 3, 2022

Sunday, October 17, 2021

Feed from AdaCore's blog not working properly

I have been subscribed to AadCore's blog feed for some time. Its feed content was OK for some time, and suddently does not work any more (also for some time already, I just did not have time to tackle the problem). I could not get any new feed, altough I could see new blog entries posted. With both feed readers Liferea and Thunderbird, I could not get it display any feed.

After invesitigation, I found the feed respone content is not conform to the standard, it contains a new line at the start of the feed, and has javascript block at the end of the response.

When doing further investigation with Liferea, I found that it supports a very useful feature, a conversion filter. After try and error, I formuate a sed filter commands that could remove all those invalid entries in the source:

sed  -e '1d'  -e 's/<\/rss>.*$/<\/rss>/' -e '/<\/rss>/q'
The first script removes the first line, the 2nd script remvoes all characters after </rss> in the same line, the 3rd scripte stops when encounter </rss>, effectively remove all contents after the matching line.

Friday, November 27, 2020

Mystery crash in an SDL2 application (solved)

I am developing an application in SDL2. It works OK most of the time. But once in a while, it will crash while just going to refresh the screen with new content with SDL_RenderPresent(). The backtrace from gdb shows:

#0  0x00007ffff73a1c7b in raise () from /lib64/libc.so.6
#1  0x00007ffff7382548 in abort () from /lib64/libc.so.6       
#2  0x00007ffff35a682b in ?? () from /usr/lib64/xorg/modules/dri/iris_dri.so
#3  0x00007ffff40a5886 in ?? () from /usr/lib64/xorg/modules/dri/iris_dri.so
#4  0x00007ffff35c29e9 in ?? () from /usr/lib64/xorg/modules/dri/iris_dri.so
#5  0x00007ffff35b6d2b in ?? () from /usr/lib64/xorg/modules/dri/iris_dri.so
#6  0x00007ffff4ef99e0 in glPrimitiveBoundingBox () from /usr/lib64/libGLX_mesa.so.0
#7  0x00007ffff4eecad1 in ?? () from /usr/lib64/libGLX_mesa.so.0
#8  0x00007ffff7ef6283 in ?? () from /usr/lib64/libSDL2-2.0.so.0
#9  0x0000000000415f42 in refresh_display (ctx=0x7fffffffd370) at gui/main.c:1077
#10 0x0000000000413c79 in main_loop_handler (ctx=0x7fffffffd370) at gui/main.c:362
#11 0x0000000000413b22 in main (argc=1, argv=0x7fffffffdd58) at gui/main.c:323

I searched around the web with SDL2 crashing during SDL_RenderPresent(). Most of them points to some form of memory corruption causing that, but I have double check my code with various tools and manual inspection, there is no memory corruption. Then I came across this article "Rock solid frame rates with SDL2", it mentioned a function SDL_SetSwapInterval() which will delay SDL_RenderPresent() from swapping the render buffers till the swap interval (wait for vsync). This seems match what I suspected that the buffer is updated on the wrong time and causing the crash.

There is just a little problem, there is no more SDL_SetSwapInterval() any more, in stead it become SDL_GL_SetSwapInterval(). I added in the oneline call SDL_GL_SetSwapInterval(1), and vala, so far all tests do not show the crash anymore.

Thursday, July 9, 2020

WebAssmebly passing string from C to JavaScript

Recently, I am working on a project that involves WebAssembly. In the project I would need to call out a JavaScript function with a C string char *string as parameter.

I could not get the string in JavaScript function, searching on the internet does not result in any useful information. None of the solutions I found are elegant. Then I realized I had used the WebSocket APIs from Emscripten, which is passing the URL as a C string to the underline JavaScript support function. How does it do that? I digged out the source of it and found in function emscripten_websocket_new, it is using UTF8ToString to convert the C string to a JavaScript String. UTF8ToString is Emscripten's runtime function, I could not call it directly from my JavaScript function.

According to the preamble.js document, I would need to use -s 'EXTRA_EXPORTED_RUNTIME_METHODS=["UTF8ToString"]' on the linker command to export the function and use it as Module.UTF8ToString. Problem solved.

Below are sample code that demonstrate the usage:
JavaScirpt function:

function processing_string_from_c(ptr, len) {
    var text = Module.UTF8ToString(ptr, len);
    ....
}
In the C code:
 char *string;
 ...
 EM_ASM({process_string_from_c($0, $1);}, string, strlen(string));
 ...
And in the linker line, remember to use
-s 'EXTRA_EXPORTED_RUNTIME_METHODS=["UTF8ToString"]'
P.S. In the latest release of emscripten, the export functions become global scope. So calls would be UTF8ToString() directly.

Wednesday, July 25, 2018

Slackware Creator Patrick Volkerding needs help

It was sad to know that Patrick (The creator/maintainer of Slackware) is on financial crisis.

It is unfortunate that he do not get his share of income from the store, and now he is

I mean, I'm sitting here in a house with a giant hole in the roof, a broken door sealed with duct tape, and a failed air conditioning condenser that I can't afford to fix, my wife has been driving on a spare tire for weeks, my teeth need serious attention again, and I only just got a machine here with UEFI for the first time (bought a used machine... really out of my budget but it had to be done).

The Slackware community is eager to help and for the time being Patrick gave his PayPal account link before he could setup a proper channel for donation.

Patrick Volkerding's Paypal account: https://www.paypal.me/volkerdi

And please donate if you like Slackware and willing to help.

Patrick has a cafepress account for Official Licensed Slackware Store. Confirmed by Patrick.

Friday, February 2, 2018

Why people think bitcoin has value, I still don't understand?

I still don't understand why people will value Bitcoin or any derivative coins.

When I first heard about the name of Bitcoin when it was first come out, my instinct think of it has absolutely no value besides wasting resources to calculate those blocks.

The so call decentralize nature of it only has value on the eyes criminal for money launching. Each and every transaction need to be kept in the bitcoin network and it is growing bigger and bigger. That is causing Transaction are getting longer and longer

Even with today's value of USD$8K per bitcoin, I still see no value of it.