Saturday, July 2, 2022

New release of Ada for Slackware 15.0

Finally, after many years of inactivity, 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 laundering. 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.

Wednesday, October 4, 2017

New Ada for Slackware released

Finally, long after released of GNAT GPL 2017 and GCC in 7.x series in Slackware-current, I got some time to work on the Ada environment for Slackware and got a working version of GPS.

The new release is at GitHub

Friday, May 19, 2017

Thursday, May 4, 2017

GCC 7.1 is out

GCC 7.1 was released on May 2.

I tried it out and recompiled all my Ada related builds, finally I got a stable GPS that does not crash after opening a project file. It still crashed on me, maybe I should revert to an older version?

I have updated my build scripts ada-4-slackware on gitHub. There is still some problems with ASIS 2016, some API changed for the new compiler, will update the build script once got time.

Thursday, April 20, 2017

A strange 3D building from Google earth

As Google just release a new version of Google earth, I tried it on my phone with "I'm feeling Lucky" button ^_^, it lead me to the "Montparnasse Tower", the 3D view is strange on the north-west facing, there is a swirling hole in the upper part of the building.
You could find it by searching "Montparnasse Tower" or go to this link Montparnasse Tower from Chrome.

Friday, January 20, 2017

Tangerine Bonus Orange Key


Your Free Orange Key

48455197S1

Enroll Now

This is my orange key, when you signed up for a new account, please use it as a reference so that both of us could get some bonus from Tangerine.

Monday, January 16, 2017

iPad not charging and a simple solution

I got an iPad that is not charging, connect the power cable does not show any indication of charging, and power keeps draining.  Search around the web, it seems it is quite common.

I follow a few advises from the search:

  1. Use compressed air to clean the input socket.
  2. Force a restart.
  3. Switch outlets or ports.
  4. Switch cables.
  5. Restore in iTunes

None of it working.  But, during test of stage 5, I actually got the iPad charged in recovery mode. And it only works in recovery mode when connecting to a computer, it won't work when charging from an power adapter.

That makes me thinking, why could it be charged under recovery mode but not normal operation? Hardware seems working, is it a software issue? But I have fully restored the iPad with no success. I search the web again, and found this one: Simple solution if your iPhone or iPad is not charging. It seems simple, and I took a toothpick and start picking the input socket, it does not have lots of lint coming out, just a little bit of dirt. And it works!

Wednesday, November 30, 2016

ZSTD - A new compression tool

I has some personal interest in compression. Recently, I found this new compression tool: ZStd. It compresses much faster than gzip with better compression ratio.

For a not so scientific benchmark ^_^, to compress linux-4.4.34.tar (648867840 bytes) kernel, time reports the following:

time zstd linux-4.4.34.tar
real    0m5.157s
user    0m4.116s
sys     0m0.534s

time gzip -k linux-4.4.34.tar
real    0m21.255s
user    0m20.891s
sys     0m0.175s

time xz  -k linux-4.4.34.tar
real    4m21.785s
user    4m21.430s
sys     0m0.265s

648867840  linux-4.4.34.tar
132581836  linux-4.4.34.tar.zst (20.43%)    5.157s
137210920  linux-4.4.34.tar.gz  (21.15%)   21.255s
 90543184  linux-4.4.34.tar.xz  (13.95%) 4m21.785s

It took zstd much less time to compress with slightly better compression than gzip. For a better benchmark, please refer to the zstd's home page.

There is a SlackBuilds package maintain by me for Slackware also.

Tuesday, September 13, 2016

Ada programming environment based on GCC 6.2 and GNAT GPL 2016 in Slackware64 14.2

New release of Slackware and new version of GNAT GPL 2016 prompt me to update the Ada programming environment under Slackware.

First, I was trying to use the stock 5.3 compiler, but encounter gnat compiler error when compiling gprbuild. So has to use the FSF GCC 6.2 as the based.

The FSF GCC compiler

At the writing, the latest release of GCC is 6.2.0. First I update the build script to matched what's in the current tree. I have changed the build directory to a fixed location to avoid the random location in the original script. As it is needed for gnat_util build, a fixed location is easier for the script to find the right files. Built and install without problem.

GNAT Environment package

This package contains startup scripts to setup Ada project path environment variable ADA_PROJECT_PATH and GPR_PROJECT_PATH. They will be installed into /etc/profile.d by the doinst.sh.

Also soft link of the GNAT Ada run time libraries are also created in doinst.sh.

XMLAda

For XMLAda GPL 2016, the default build process is making use of gprbuild, which depends on XMLAda. I followed what was done on Arch Linux and created a custom Makefile.SlackBuild. But I installed the package with the following scheme, similar to what GNAT GPL 2016 is doing but with sub-directories for each sub-module:
 usr/include/xmlada
             |- input
             |- unicode
             ...
 usr/lib64/xmlada
           |- input
           |  |- static
           |  `- relocatable
           |- unicode
           |  |- static
           |  `- relocatable
           ...
The document build requires Sphinx, as SlackBuilds.orgprovides all necessary build scripts, it is a matter of installing the relevant packages and dependencies.

GPRBuild

The 2016 version of gprbuild required gprbuild itself. So Similar to XMLAda, a custom Makefile was borrowed from the Arch Linux project and modified to suite the needs of Slackware. A patch was developed for the gprinstall program, so that its default library subdir and library soft link subdir points to lib64 under Slackware64. A gpr library is also created, as it is needed by a few other programs

GNAT_UTIL

The GNAT Util Libraryprovides access to GNAT compiler internals for AdaCore utilities. The latest release is 5.1.0, it is used for our GCC 6.2.0. The build went well.

GTKAda

It does not build very well at the first few builds, it keeps installing libs into /usr/lib in stead of /usr/lib64 on 64-bit system. It seems the generate file still insist on the lib's path. So more sed commands are added to change the lib path to lib64 on 64-bit system. After that, it built without problem with proper installation path.

Aunit

Aunit's build script has no big change from the previous version, except for the version bump.

GNATColl

I used version 16.1 from GitHub. GNATColl compiled OK, with minor problem with lib's installation path, similar to the problem in GtkAda. I always got gpr.gpr problem when compiling GPS, latter I found that not sure why, the installing process of gnatcoll will install a copy of the gpr.gpr project file and related object file and source into its own directory structure with some modification to gpr.gpr and causing error on the project file. I have to manually remove all gpr related files and directories and entries in the manifests file. Then GPS will compile with correct project file.

GPS

After fixing the gprbuild, gpr and gnatcoll libraries, GPS compile without problem. When running GPS, it gave python script warning about pep8 and jedi, after install those two from SlackBuilds.org, everything is working fine.

Florist

No trouble when compile and install florist.

Asis

Asis has no problem to compile and install after fixed the gprbuild install path.

Gnatmem and Ahven

Gnatmem (need to compile the binutils for Slackware 14.2 and use the build tree) and Aheven gave no trouble when compiled for the 2016 version.

All build scripts are available at GitHub.

Sunday, June 19, 2016

How to mount NTFS filesystem on OS X

I have a Dell backup drive and would like to backup some of my files on OS X to it. But unfortunately it is formatted as NTFS, by default it is mounted read only on OS X.

Searching around, I found someone mention about the NTFS-3G, that is the tool I am using for Linux. It seems the fastest access is NTFS for Mac from Tuxera.com, it is also the sponsor of the open source project NTFS-3G. At first, I try to see if I could order it, but it has a price tag of $36.33, well, if it were below the $10 mark I will buy it, this price is a little pricy.

Next I try to find if any ntfs-3g binary package is available, the latest I could find is from 2010, a little bit out dated. Then I came across this OSXFuse's project wiki about NTFS-3G. I install the latest 3.4 OSXFUSE. Then the package manager "Homebrew".

Follow the procedure from the wiki, I issue the command

brew install homebrew/fuse/ntfs-3g
Then it starts to download and compiling ... After a few minutes, I got ntfs-3g install.

Then I try the commands from a command shell.

mkdir /Volumes/ntfs 
ntfs-3g /dev/disk1s1 /Volumes/ntfs
Hooray, I got a writable NTFS disk mounted! I did not try to replace the system's mount_ntfs for automount NTFS to read/write. The current form works for me.

PS. Of course, in order to compile all related programs, you need to have Xcode installed.

Thursday, March 24, 2016

Google's hterm: HTML5 terminal emulator

Google's hterm is a nice terminal emulator. I would like to use the hterm part only and do some remote telnet session test (I used libtelnet for the back-end server). But I encountered some usage problems.

First, you could not build a functional hterm script with the github repository, you will need to checkout the full repository from https://chromium.googlesource.com/apps/libapps/ and build from there.

Second, the embedded document is lagging. After following the description in the document, the terminal could be displayed without problem, but there is no input at all. The call back function register to the io.onVTKeystroke() never get called. After digging through other part of the libapps repository for hterm's usage, I found term.installKeyboard() function of the hterm terminal instance need to be called after the term.decorate() call. After that input event could be received.

Third, I haven't found a way to make it acknowledge IME input. Cut and paste utf8 encoded characters causing it to output escaped utf8 stream (utf8 encoded of an utf8 stream).

Friday, November 13, 2015

Running i3 under HiDPI display

I recently got a MacbookPro (early 2015) with retina display for work.  I installed a fresh Slackware64-current on to it with rEFInd as the boot loader.  The process was quite smooth, I used a USB boot image then network install (with a thunderbolt gigabyte adapter).  Some devices/functions are not fully functional but usable for me. Console font is using the kernel built in SUN12x22 font with kernel option "fbcon:font=SUN12x22".

Since this laptop has a 2560x1600 on a 13" display, roughly 227DI, my old setting for i3 did not work well, although I already using xft font for status bar display.  After a few search, I found out xorg server always set DPI 96, that is a bad move in my opinion, as it makes previous valid DPI calculation wrong and still wrong for those cases that the calculation do not fit.  And I have to add a line
xrandr --fbmm 286x179
in .xinitrc file in order to let i3 pick up the correct DPI setting.  OK, now the i3 status bar display fine.  The default dmenu I initially installed does not support xft font, so it looks really small.  Luckily there is a dmenu2 which merged the xft patched.  Remove the old dmenu package and install the dmenu2 package, then add the font parameter to the dmenu_run command in i3's config Latest dmenu works with xft font now. Everything works fine.

I have the following settings in my .Xresources file.
Xft.dpi : 227
Xft.antialias: false
Xft.rgba: rgb

URxvt.scrollstyle: xterm
URxvt.background: black
URxvt.foreground: gray
URxvt.preeditType: Root
URxvt.scrollBar_right: true
URxvt.jumpScroll: true
URxvt.perl-ext-common:  tabbed
URxvt.tabbed.tabbar-fg: 2
URxvt.tabbed.tabbar-bg: 0
URxvt.tabbed.tab-fg:    3
URxvt.tabbed.tab-bg:    0
URxvt.termName: rxvt
URxvt.geometry: 83x27
urxvt.font: xft:DejaVuSansMono:size=8

Xpdf*fontList: -adobe-helvetica-bold-r-normal--0-0-0-0-p-0-iso8859-1
Xpdf.initialZoom: 200

Xcursor.size: 64

With the following, the width should be $((11*COLUMNS+13)) pixels;
! in contrast, the fixed = 6x13 bitmap font is typically used on a
! low-definition screen, giving a width of $((6*COLUMNS+13)) pixels.
XTerm*faceName:  Monospace
XTerm*faceSize:  10
! For xterm menus. This font is large enough, but a bit ugly.
XTerm*font:  -adobe-helvetica-bold-r-normal--0-0-0-0-p-0-iso8859-1
My default terminal is rxvt-unicode, so it works fine. You may notice I have turn antialias off, the font looks sharp, you may see zigzag when looking really close, but for 227DPI, it's very clear without it already.  Most of the document on line regarding GTK+3's HiDPI support is by setting
export GDK_SCALE=2
export GDK_DPI_SCALE=05
I found the program behave a little strange when this kind of scaling in effect.  Font is a little blur than none scale one. For the Gnat Programing Studio (GPS), with the scaling effect, the menu display strangely:
compare with the one without scaling:
I am not sure whether its GTK3' fault or GPS's fault.  I would hope for a GDK_IMAGE_SCALE and only scale image, maybe that will work better.


P.S. After upgrade to kernel 4.4, all the special keys (fn+Fx) works as expected (with pommed-light)