Author Archives: Norayr Chilingarian

About Norayr Chilingarian

I don’t write here most of the time. It is an effort to translate each time my Armenian blog entries. I hardly can maintain two (0 1 ) diaspora profiles.

Whatever, I like Peter Matthias’s Oberon/Linux Revival project.

Today I have added a patch to OLR’s XCompiler, which I before have added to voc.

If there is CASE statement sequence, and no ELSE, and neither of possibilities is true, then trap happens. This caused me a lot of headache to figure out why this or that code crashes. Thus I have added a warning to Vishap, in order to find such cases.

This is how crash happens under oberon system.

And this is how it works now.

und so weiter. (:

on Ukraine crisis

Okay, I would like to paste here some of my comments in the closed discussion thread. It started by someone who was blaming US in starting a war in the region. Obviously I can only paste my own comments, so you may only guess what other’s were saying.

not a single drop of blood was shed in Ukraine (because of ethnicity) before Russia began to “defend” Russians there.

Ukraine did not need a war. And war would not happen, if not Russia. Russia needed a war because it does not want Ukraine to leave. And they did everything they can afford in order to keep them or prevent them from moving towards civilization, or at least make their lives harder.

>the troubles in Ukraine and elsewhere are most likely to have been fomented by the western powers, specifically USA and britain

If it were, I don’t care, because it’s for Ukraine’s good.. Please, try to look to this situation from the Ukrainian point of view, not American and not Russian.

They are pissed of of people like Yanukovich, thieves, and corruption. You may say there is corruption in the West. Certainly, but not to this extent.

This people want to live like people in Belgium or Finland. They don’t want to live in a place where everything is banned, and you can be put to jail for many years for a couple of words, which some court(which of course is not independent) may accept as “gay propaganda”, “insult of religious feelings”, etc. They don’t want to live in a union, (eurasian) where shorts(or pants?) with laces are banned. They don’t want to live in a Union where one and only one history textbook is allowed, which praises Stalin’s regime. etc, etc, etc.

So Russia has nothing to suggest to Ukraine. Except brute force.

Now abount Russian fears, like NATO. First, USA, Russia and Britain forced Ukraine to refuse from it’s nuclear power, by guaranteeing it’s territorial wholeness. USA and Britain did not do that, Russia annexed Crimea.

Instead of this, Putin could just leave the Ukraine to do what they want. Because it’s not his businness what INDEPENDENT Ukraine wants to do. He can ask them, beg them to not have NATO there. He can use other variants. But not doing his dirty tricks.

I define Ukrainian movement as liberation and anti-imperialistic movement. You hate US. US did a lot of dirty things too. But west is very good for Ukraine now. West may mean they won’t have faked elections anymore, they will have independent court, they won’t have one guy ruling and pressuring the country, they will have real freedom of speech.

This is what you have, to much more extent than they have. And that’s why you think they can have it. Or do you think it’s easy to live in Yanukovich’s Ukraine, Putin’s Russia, or Sargsian’s Armenia? It sucks!

We here can see the example of Georgia, our neighbour country. Saakashvili was pro US president. Georgia have paid with it’s territories for that. But! Guess what? They don’t have bribes anymore! You know, they have perfect police! I remember their police like 10 years ago, and now it’s completely different! It’s unbelievable that policeman can take bribe! There are no bribes on low level at all. I guess there are at the high level, at the level of government. But regular citizens are now much more safe from the despotism of the government. And you know, many say – it’s in the nation’s mentality, the nation, these people cannot live the other way. And Saakashvili have proved, that they can! We can! It’s not ideal, of course. And that’s why people did not like Saakashvili. There are many reasons. But he failed in elections! He failed! So those who were calling him a dictator now need to swallow their tongs. Because dictators never fail during elections, they fake elections.

Some people here say – you want Armenia to be closer to Europe? Look how Greece suffers! You know, I would like Armenia to suffer like Greece! It’s like unbelievably cool for us now. It’s just happiness.

>It looks that way to me as well. Like NATO and the “free world” is attempting to back Russia into a corner.

That’s very good for us! Please do that, back Russia into the corner, so it can leave us alone! Russia exports gas, corruption, and obscurantism. If not they, we would build a good country, instead of this. Seriously. And we started very well, unless Russians made an overturn here by sending killer group into our parliament and killing influential and independent politicians. You live in US, you see which dirty tricks US does. Russia is worse for us.

Look, we are in blockade by Turkey and Azerbaijan, right? We could settle this up like 15 years ago. Russia does not need it. They sell weapons to Azerbaijan for trillions of dollars, and they sell weapons to us. They enrich and enrich their military bases in Armenia. I guess I live in the most militarized place in the world.

So we can get cheap gas from Iran. You have tried to build a pipeline. Russia banned that, first they did not allow to build the pipeline with enough diameter, then they forced the puppet state to give the pipe to them. They forced the puppet state to give to them everything, just everything we own. They now behave like Armenia is just one of the Russian provinces, and Putin even have said that, “it’s not different from Kaliningrad oblast”, he said. That’s very sad, because they suck the last blood out of this country. Third of the population just left, imagine, 30% of population left the country because of the conditions. But if not Russia, we could settle all conflicts, and just live and develop.

I am afraid, Russia must collapse, in order to become a normal country. Because they will always tolerate dictators because of the fear that they will collapse. And they have to, because where is Russia? There are Chechnya, there are Tatars, Ingushes, etc, etc!

And yes! Look what they have made in Chechnya! They just eliminated population there, Russians and Chechens, does not matter. They were killing just everyone during the war. Because Chechens wanted to be independent. So Russians don’t allow their regions to gain independence and turn cities into ash in that case, but they support separatism in Ukraine! Is it better than US does? It worse in this case, because Ukraine can become a normal country like Czech Republic or Poland instead of living in Soviet shit just because Russians want to control more land, and call it “safety”. Go **** yourself with your safety, we don’t care!

Besides, Russia had shown, that it’s the best thing what post soviet country can do for it’s safety, is to join NATO. To be safe from Russia. Alas, it’s not that easy.

Okay, I can hear you. Now I would like to apologize for behaving somehow emotional, and some illiteracy. that’s caused by lack of time to review and edit the text.

Now, I agree, that saying “it’s for their own good’ indeed does not remind me anything good. The first association is Russian pre-maidan propaganda “Ukraine, you are going to the Europe, where everyone engaged in incest, if they are not gay”. (((:

Now, lets try to clarify which is Russian influence, and which is USA influence in this case.

First of all, Ukraine gets approached by Europe guys – “come to play with us”. Okay, Ukraine wants to go to play with them. By saying Ukraine we mean the part which is ok that there are gays in the company. The Russian speaking part does not show any sign of being disturbed. After all, EU is not only about sexual minorities, as Russian propaganda states, but also about ethnic minorities, and joining EU to some extent means not only to have laws confirming equal rights of lgbt people, but also signing papers like European charter for Regional or Minority Languages. Ukraine had to ratify the paper sooner or later. Which means rights of Russian speaking people would be protected.

Also, we can fix now, that Russian speaking people are not getting killed in Dnepropetrovsk, in Kiev, in Lvov. They are getting killed in the regions where Putin decided to “defend” them, because of the war, he started.

What is Russian reaction to Ukraine trying to play the game with Europe? He was trying to pressure Yanukovich in order to cancel the deal, and evertually succeeded in that. It’s not that hard to pressure corrupted authorities. However, when Yanukovich was elected, he have promised to the people that Ukraine will continue to move towards European integration.

Now, let’s not discuss if it’s good or bad for Ukraine (I believe it’s good, not perfect, but good, and that does not matter in this context).

But we may fix now that movement towards EU was a desire of majority of the people. Yanukovich was elected (indeed, was elected), he won Timoshenko during fair elections, which Timoshenko ensured. So Timoshenko did not fake elections, let’s also fix that. That means she’s a really democratic leader, she left.

I have no doubts that Yanukovich would fake next elections in order to continue to rob the people and implement promises he made to Putin. Anyway.

We have fixed the desire of the people and movement of pretty pro Russian president, who came from Donetsk (where is war now) towards EU.

Now, which was Russian influence? First of all, anti-maidan propaganda. Next, they were publicly saying that Yanukovich must not be a coward and must make violence against maidan. When Yanucovich run away, of course to Russia, they annexed Crimea. Afterwards, they made troubles in Donetsk and Luhansk regions. So the influence of Russians was first to prevent Ukrainian movement towards Europe, and later, to make Ukraine feel bad for that decision by cutting it’s parts and promoting the war.

Which is USA influence in this case? USA is supporting the desire of Ukrainian people. Of course not because USA has strong love toward that people. It has it’s own reasons. But now it actually trying to help (not hard enough, as I think) to Ukraine to move where Ukraine wants.

So now we can see that Russia shows aggression and violence, because they don’t like Ukrainian choice, and US shows support because they like Ukrainian choice. I would judge US in other case, but it supports Ukrainian choice.

Now, I may agree that US and EU may be were pushing too hard the Ukraine from their side too, by not taking into consideration the presence and possible reaction of the hooligan guy in Russia. I think that’s because they are not good in politics, they did not expect Russia to interfere in such cruel way. They were saying – don’t impede Ukraine from going where it wants. That’s all. But they had to remember what happened in Georgia in 2008. So after that I had no doubts that Russia will take Crimea. No doubts at all. While Europe and America seemed to be surprised.

So in this game, Russia plays much worser role, than USA or Europe. Because USA and Europe support people of Ukraine (and of course their own interests, this time they overlap with what Ukraine wants), while Russia goes against will of Ukrainian people. So it plays the role of the bad guy, while US plays the role of the good guy here. We remember that it’s a role, but we cannot say its unfair now. It’s like when you know that this policeman is taking bribes usually, and we cannot trust him, but this time he defends your interests because he also is an interested party. So in this case he is making his job and we cannot blame him. That’s it.

story about educational expo in Yerevan

I was able to attend educational expo yesterday. It was my first time I went to Mergelian institute. Eventually, I saw a Kochar’s sculpture. I think they could find a better place for her.
There was an escalator in the building, but only one, for moving up. For other direction there was staircase.

Many pavilions, mostly boring. Upon entering, there was immediately noticeable crowd near Instigate’s pavilion. They were sharing one with Armtab. Armtab took very small space, so the most space was taken by Instigate.

Everything was presented by children. Very enthusiastic, inspired kids. They were telling about their projects. I fired up n900′s FCamera.

Cutter, Linux CNC:
Ինսթիգեյթ, linux cnc

3d printer Bzez A. As far as I get, it’s a RepRap fork:

ռեփռափ, եռաչափ տպիչ, Բզեզ Ա

արաքս ու բզեզ ա

Aghves, the Scratch fork. First went to flash, but Aghves stays with native.

աղուէս, կրիայ

Alas, n900′s battery drained soon, and I have borrowed friend’s galaxy. As you can make sure, quality of photos is not good anymore.

աղուէս, կրիայ

աղուէս, կրիայ

«Berdzor A» and «Aygestan 1» computers՝

«Բերձոր Ա» եւ «Այգեստան 1» կարգիչները

They were designed for Armenian Kashatagh district Berdzor city kids, and Askeran district Aygestan city kids:

Բերձոր Ա տեխնիկական տուեալներ

made in Armenia



Գուգարք Ա

Kids were telling that they want to suggest Gugark to Ucom, instead of some other hardware they use. They were very inspired when telling about their projects and future improvements

Գուգարք Գ

As you can notice, white balance of galaxy is wrong. This is jpeg, it’s hard to get something from it, excuse me.

On this monitor there were videos shot from copters. In Armenia.


and the copter itself:


Alas, there were no Artin & Varoujan pavilion. They have cool boards of local production.
When I was shooting Armtab prototype, they turned it on, so I can see the screen. That was Vostan Desktop Environment.

Արմթաբ, Ոստան

Այ կրակ, այ փետ, այ կնիկ, այ աստուած, այ հեռախօս, ո՞վ է ստեղծել՝


Very fast about the rest. PhisMath school had a very cool small robot, made by kids. I mean, indeed made by kids. They were talking with each other about their mistakes in PWM programming.

On the contrary, to the Ayb school kids, who never can explain what they have “done”. Instead of that they have very high level of complacent. Yep, it’s Ayb. They had a best pavilion, designed by Storaket. That was a wise decision, to order it from Storaket, they were outstanding mostly because of that. Though, as you may have noticed, I am not a fun of that school.

այբի տաղաւարը, ստորակետի դիզայնը

There was another crowd near the pavilion, when they were showing chemistry experiment. That was good, so that people don’t think that there is only IT nowadays. By the way, their IT was also present – some ugly robots, who can invade the world, if wake up. (: And those robots, I suppose weren’t made by kids.


At least this one participated Armrobotics competition, I have seen him there, and it wasn’t from Ayb school. tut-tut!


There were also robots at Quant’s pavilion. But I didn’t want to shoot them, just Lego Mindstorms. I cannot percept Lego as robotics, it’s like spherical robotics in space, not the real one, without many different problems designer can have in real life. And they had this:



About the rest – many Russian universities advertisements. One – French, Two – German. Near the building girls were giving out advertisements, proudly saying “Russian education”, like that’s a good thing to have. I have returned those papers, and made a mistake. I had to get some more, and put to trash, so less people get it.

This is vulgar girl presenting Rossotrudnichestvo. When I started shooting her, she hastily concealed flowers from the table.



Police. When they noticed that I am shooting, the guy put down the balloon.


Art academy pavilion was free. May be that’s a conceptual peace of art:
գեղարուեստի ակադեմիա


Guys presenting AUA gave me a card. There were “Facebook” with large friendly letters, like it’s a Facebook card. It turned out – like us on FB. Okay, and what if I don’t have FB account? Then probably I am not modern. (:

When we were wenting ount, there were a grandfather with granddaughter.
- You will see, dear, what some pupils have done in their schools, what kind of interesting projects…



flashing openmoko gta-02 with leo2moko firmware

There was an announcement in openmoko community mailing list, called First small steps towards free GSM firmware.

I am very pleased to announce that after many years of searching, I have finally found a copy of TI’s firmware deliverable package for their Leonardo development board, i.e., for their Calypso/Iota/Rita chipset reference platform. It is the package which TI must have given to all of their chipset customers including Nokia, Motorola, Compal, FIC/Openmoko, LG, BenQ and many others, and which was used by all of these companies as the starting point for making their unique proprietary firmwares.

The news are, we don’t only have a firmware source, which can be flashed(though it may be illegal in some countries) but we have also completely free and legal loader tools for flashing that firmware. Before, openmoko users had to use proprietary TI tool for that.

So, I decided to try, and here are my notes on how to build and install leo2moko firmware.

Instead of dealing with crosscompilers, I prefer to build the firmware and loader tools right on device. I use SHR distribution on my GTA-02 Openmoko Neo Freerunner.

==install compiler and dev tools on openmoko==

opkg install gcc
opkg install gcc-symlinks
opkg install libc6-dev
opkg install binutils
opkg install make 
opkg install coreutils

It is good to sync time before building:

/etc/init.d/fsotdld restart

or in newer distributions

systemctl restart fsotdld.service

download the flasher source:



mkdir loadtools
cd loadtools

tar jxvf ../loadtools-r1.tar.bz2

edit makefile, as suggested in readme, set CFLAGS to

CFLAGS= -O2 -march=armv4t -mtune=arm920t -DGTA0x_AP_BUILD



then make it

make install

these three binaries are now installed in /usr/local/bin

fc-iram fc-loadtool fc-xram

==build firmware==
skip this step if you want to flash already precompiled firmware

unfortunately it’s impossible to build the firmware with free compiler yet, so we need to use windows only tools from TI. Fortunately, tools are possible to run with wine under GNU/Linux box. The environment heavily relies on traditional Unix tools, ported to windows. It would be much easier to deal just with those tools natively.

So, get these files: – the source – build tools

gcc -o nowhine nowhine.c
cp nowhine /usr/local/bin

nowhine is a simple utility which strips unnecessary whining messages from whine. you can use it as wine wrapper.

There is a build script, you will find when unpack tarballs. It will run build process and compile the firmware.

==already precompiled firmware==
wget — already built firmware.


need to kill some daemons running in the openmoko, before flashing:

killall fsodeviced
killall fsoaudiod
killall fsousaged
killall fsodatad
killall fsonetworkd
killall fsogsmd
killall phonefsod
killall phoneuid
killall frameworkd
s3c24xx-gpio b7=0

fc-loadtool -h gta02 /dev/ttySAC0

You should see a bunch of messages followed by a loadtool> prompt.

when you reach that prompt, enter this command:

flash dump2bin my-flashdump.bin

This is a backup of your current calibration data. It may be necessary if something will go wrong with the flash. Transfer it to pc, back it up.

flash erase 0 0x300000
flash program-m0 gsm-fw.m0



This is also very interesting project, on how to read and write gsm device filesystem.

openmoko firmware screenshot

story about slavery

comment from here by marc :

Media is “the old prophet of doom”. Now we have even more aggressive and dangerous ones – usually all of the closed-source, non-free, non-collaborative internet media, social networking sites and news sites. Boycott the hell out of them and they’ll die natural death.

Once it was all about “the tubes”, now it’s about the TRADE. They feed you with their crap, and you’re paying them with your data, your life and your time. However, can we even call it a TRADE, when it’s not even realized by one of the sides of this harmful “transaction”?

Don’t let them fool you.

other comments good too (:

#comment #media #cite #quote #internet #social #trade #slavery #freedom
#քաղվածք #մեկնաբանություն #մեջբերում #համացանց #առեւտուր #ստրկություն #ազատություն

story about Soviet Georgia

I would like to make some quotes from the book I am reading now.


On publishing this book, I did not consider its relevance in today’s current political climate, rather, I naively believed that after the USSR disintegration, the Soviet past of Georgia would become nothing but a bitter memory. I was wrong. As it turned out, the past can come back to haunt you, especially if we ourselves cannot move from it.

The space pioneer superpower failed to produce such a simple piece of clothing as jeans. What can be more innocent than a pair of jeans? But because they couldn’t produce them, they just banned them.
The banned jeans became sweeter than the forbidden fruit.

In those days every pair of jeans was believed to be American, and as the Soviet propaganda was particularly set to destroying American values, many thought the happiness lay where jeans were abundant.
There was a grain of truth in such a belief because the Soviet state denied its citizens the basic civil rights, the right of property among them. One could truly be free only in one’s grave or rather, the authorities stopped worrying about your freedom and rights when you were safely put under the earth…. … There might have been other reasons, but the fact is that a grave was the only property people owed. Such political attitude marked the start of altering Georgian taste for the worse. For centuries, the traditional Georgian graveyards were simple and modest, while in the Soviet times the graves became ovely decorated, adorned with marble tables and benches, statues, bikes and even cars. The Soviet Georgians were confident in one thing only – the grave belonged to them, so they were taken care of and zealosly protected. People built and decorated them as they’d do if they had real estate property. The authorities turned a blind eye to the graveyard eccentricities. The Soviet regime principles didn’t extend to the Georgian graveyards.

The Georgian authorities demonstrated more respect to the dead than to the living. However, there was one prerequisite for a guaranteed grave – one had to die ones’ natural death. If one was executed for crime, the dead convict would certainly be buried but he or she wouldn’t have a proper grave. Starting from 1920s, thousands of executed convicts found their eternal resting place in various unmarked stretches of land across the country. Very often the diggers assigned to the job of preparing a deep hole (not a grave) weren’t able to identify with certainty the places, especially that there were no landmarks to guide them and the work was usually done in the small hours, in complete darkness.

When the men opened the coffin lid, Gega’s mother turned away, waiting for their reaction. The men, deeply stunned, looked at the corpse which was difficult to identify due to the lapsed time. But it was Natia Megrelishvili who said with conviction: ‘This isn’t Gega. This is Soso, it’s his jeans, there’s the sun drawn on them.’ The others looked at the open coffin again and only now discovered the deceased was wearing the jeans, unaffected by the time and the soil. The jeans looked new and there was a shining sun drawn above the right knee.

In the 1960′s and 70′s they didn’t execute professors and scientists anymore, but in return for their lives, they forced them to cooperate with the Soviet authorities. Most of them did cooperate with the government, since otherwise none of them would have been able to travel abroad and attend a single scientific conference. Such cooperation with authorities, at first glance, was nothing special, and sometimes nothing was requested in return for their foreign trips, but this was only at first glance. In reality the main thing was taken away from them – freedom of speech and the right to have their own opinion. They couldn’t express their political views openly and had to support the government in all crucial cases (in every single one, for that matter). That’s what really happened – together with the Soviet government most Soviet scientists obediently created one big Soviet lie. Of course there also were exceptions – those who didn’t want privileges, apartments and cars given by the government (or the government didn’t with to encourage them). But there were very few of them – mostly they sat in the kitchens of their council flats. They would work, eat and drink and express negative opinions regarding the Soviet #regime only there, in the safety of their tiny kitchens. True, some – including academics – were in jail (and not kitchen), but those were known as dissidents.

Thanks to his provincial zeal, in the beginning of the 1970′s, Shevarnadze became the top person in Soviet Georgia (after beating his local competitors) and very soon, very easily, managed to charm the Soviet Georgian intelligentsia. However, the latter was more an “accomplishment” of the Soviet intelligentsia rather than that of the First Secretary, since for dozens of years, the intellectual abilities of the Soviet intelligentsia had also been deteriorating (alongside the morals).

und so weiter

story about left shift

I was tinkering with Ofront, making changes here and there in order to run it on x86_64.
By doing this I met a strange warning issued by gcc when it was compiling Console.c file.

Console.c: In function ‘Console_Int’:
Console.c:57:2: warning: left shift count >= width of type [enabled by default]

So, Console.c is generated from Console.Mod. And the Int function of Console module writes integer to the console.
This is how it looks:

    VAR s: ARRAY 32 OF CHAR; i1, k: LONGINT;
      IF SIZE(LONGINT) = 8 THEN s := "8085774586302733229"; k := 19
      ELSE s := "8463847412"; k := 10
      i1 := ABS(i);
      s[0] := CHR(i1 MOD 10 + ORD("0")); i1 := i1 DIV 10; k := 1;
      WHILE i1 > 0 DO s[k] := CHR(i1 MOD 10 + ORD("0")); i1 := i1 DIV 10; INC(k) END
    END ;
    IF i < 0 THEN s[k] := "-"; INC(k) END ;
    WHILE n > k DO Char(" "); DEC(n) END ;
    WHILE k > 0 DO  DEC(k); Char(s[k]) END
  END Int;

The error is issued in the line:


which is translated as following in case of x86_64:

if (i == __LSHL(1, 63, LONGINT)) {

On x86 it gets translated as:

if (i == __LSHL(1, 31, LONGINT)) {

Okay, and it does not issue an error on 32 bit platform, Why?

Probably, need to look into how the _LSHL macro is written. That’s in SYSTEM.h

#define __LSHL(x, n, t) ((t)((unsigned)(x)<<(n)))

Okay, what do we see. It casts the number as unsigned, then shifts it. Obviously, the cast is necessary in order to use the sign bit.

Now let's swerve to the question why do they to do this?
And what special in this "8085774586302733229" number? Or in this: "8463847412"? If you fed this number to the Worlfram alpha saas, it does not give a clue.
The clue gives the lower part of the script, it writes the number from right to left.

WHILE k > 0 DO  DEC(k); Char(s[k]) END

Let's reverse this number and look at it as binary.

noch@SAL9000 ~ $ echo 'obase=2; 2147483648' | bc

wow. This is it. We would get it by shifting 1 to the left.
But why do they shift it?
What is LONGINT on 32 bit platform? It is a number in range from -2^31 .. 2^31 -1.
And the number 2147483648 is 2^31.
So they do it in order to be able to print the number 2^31! Only for that!
Obviously, in case of x86_64 that's the number 9,223,372,036,854,775,808

Okay, let's tinker further. We want to be able to print it, why not?

So why C compiler (I use gcc) does not issue
the warning in case of 32 bits but issues in case of 64?

Because of the macro, probably. Let's write a simple C text to check.

#include "stdio.h"
#define __LSHL(x, n, t) ((t)((unsigned)(x)<<(n)))

int main()
   long i;

   i=__LSHL(1, sizeof(long)*8-1, long);

   printf ("%lu\n",i);
return 0;



$ gcc -o test0 test0.c
test0.c: In function ‘main’:
test0.c:9:4: warning: left shift count >= width of type [enabled by default]

The problem is in the cast. If we do (unsigned) then it casts it to unsigned int, not unsigned long.
Let's change the macro to

#define __LSHL(x, n, t) ((t)((unsigned t)(x)<<(n)))

Now it compiles without warnings and run.

$ gcc -o test0 test0.c
$ ./test0

However, compiler fails to compile it when we make the same change in SYSTEM.h

Console.c: In function ‘Console_Int’:
Console.c:56:11: error: expected ‘)’ before ‘LONGINT’

Let's emulate the case exactly. We need to add LONGINT typedef

#include "stdio.h"
typedef long LONGINT;
#define __LSHL(x, n, t) ((t)((unsigned t)(x)<<(n)))

int main()
   long i;

   i=__LSHL(1, sizeof(LONGINT)*8-1, LONGINT);

   printf ("%lu\n",i);
return 0;


It does not compile!

noch@SAL9000 /tmp $ gcc -o test1 test1.c
test1.c: In function ‘main’:
test1.c:10:6: error: expected ‘)’ before ‘LONGINT’

We clearly see that in the macro there are three arguments which _LSHL expects but for some strange reason gcc expects the closing parentheses after the second argument.
However we can compile it with g++ - it understands this typedef issue

noch@SAL9000 /tmp $ cp test1.c test1.cpp
noch@SAL9000 /tmp $ g++ -o test1 test1.cpp
noch@SAL9000 /tmp $ ./test1
noch@SAL9000 /tmp $

Okay. What can be done here?
We can do

typedef unsigned long ULONGINT;

and then change macro like this:

#define __LSHL(x, n, t) ((t)((ULONGINT)(x)<<(n)))

So the file looks like

#include "stdio.h"
typedef long LONGINT;
typedef unsigned long ULONGINT;
#define __LSHL(x, n, t) ((t)((ULONGINT)(x)<<(n)))
//#define __LSHL(x, n, t) ((t)((unsigned t)(x)<<(n)))

int main()
   long i;

   i=__LSHL(1, sizeof(LONGINT)*8-1, LONGINT);

   printf ("%lu\n",i);
return 0;


now, and it compiles

$ gcc -o test test.c
$ ./test

But this is not what we want.
The good solution would be to replace a macro with a function, which can be debugged, and which won't give such an error. But it is not possible to pass a type as an argument in plain C without a macro. It may be possible by using templates, in C++, but we use C.
May be there is a need to change Ofront in a way it would generate a different function call.
Another solution is to use define instead of typedef.

#include "stdio.h"
//typedef long LONGINT;
#define LONGINT long

//typedef unsigned long ULONGINT;
//#define __LSHL(x, n, t) ((t)((ULONGINT)(x)<<(n)))
#define __LSHL(x, n, t) ((t)((unsigned t)(x)<<(n)))

int main()
   long i;

   i=__LSHL(1, sizeof(LONGINT)*8-1, LONGINT);

   printf ("%lu\n",i);
return 0;


Test runs

$ gcc -o test test.c
$ ./test

For now the solution is to replace typedef with define in SYSTEM.h and use (unsigned t) cast in the macro.

und so weiter