typedef int v4si __attribute__ ((vector_size(16)));
typedef int RGBA[4];
void diff(const RGBA & a, const RGBA & b, RGBA & out) {
#if 0
for(int i = 0; i < 4; ++i)
out[i] = a[i] - b[i];
for(int i = 0; i < 4; ++i) {
int v = out[i];
if (v < 0) v =0;
if (v > 255) v = 255;
out[i] = v;
}
#else
v4si va = *(v4si*)a;//{a[0], a[1], a[2], a[3]};
v4si vb = *(v4si*)b;//{b[0], b[1], b[2], b[3]};
v4si vr;
vr = __builtin_ia32_psubd128(va, vb);
*(v4si*)(&out[0]) = vr;
#endif
}
Thursday, December 29, 2011
Wednesday, December 28, 2011
Integer division optimization
The idea is to replace division with multiplication and bit shift.
Found it interesting (GCC does it for you, but FPC not):
http://www.codeproject.com/KB/cs/FindMulShift.aspx
http://libdivide.com/
Found it interesting (GCC does it for you, but FPC not):
http://www.codeproject.com/KB/cs/FindMulShift.aspx
http://libdivide.com/
Thursday, December 22, 2011
Memory Leaks
Nice article on the topic: http://www.delphibasics.co.uk/Article.asp?Name=Memory
By the way, Pascal's manner of declaring variables in a single place ('var section') seems unproductive for C/C++ fans but it is very helpful in tracking resources (class references) -- look for the known block in a function and check if all of the references are properly freed on return.
By the way, Pascal's manner of declaring variables in a single place ('var section') seems unproductive for C/C++ fans but it is very helpful in tracking resources (class references) -- look for the known block in a function and check if all of the references are properly freed on return.
Saturday, December 17, 2011
Lazarus problem solution for Ubuntu 11.10
"
Lazarus applications have problems to run on latest Ubuntu 11.10 where the reason is new Taskbar menu and scrollbar.
To get application running like on older Ubuntu we have to remove some functionality from Ubuntu using by this command:
sudo apt-get remove appmenu-gtk3 appmenu-gtk appmenu-qt
liboverlay-scrollbar-0.2-0 "
http://62.166.198.202/view.php?id=20520
To get application running like on older Ubuntu we have to remove some functionality from Ubuntu using by this command:
sudo apt-get remove appmenu-gtk3 appmenu-gtk appmenu-qt
liboverlay-scrollbar-0.2-0 "
http://62.166.198.202/view.php?id=20520
Monday, December 12, 2011
LG Optimus One P500 factory menu
Working solution for GPS problem for LG P500 Optimus after update to Gingerbread lies in hidden menu which can be opened with 3845#*500# combination in Dialer. Then choose GPS Test > gpsApp Main Menu > Settings > GPS Type and choose Standalone instead of A-GPS (as shown on picture).
http://muj.trus.cz/post/9622985470/working-solution-for-gps-problem-for-lg-p500
http://muj.trus.cz/post/9622985470/working-solution-for-gps-problem-for-lg-p500
Sunday, December 11, 2011
FreePascal experience
Tried FPC 2.4.4 recently, what I must say, Lazarus and console fpide are unusable under Ubuntu 11.10 and MacOSX -- crash all the time, no debugger support and strange GUI bugs, although I have not tried them under Windows.
However, the big POSITIVE side is that the compiler (FPC) is a lightning fast one and easy to install at any platform. It's even faster than javac. I'm really impressed. And GDB understands well pascal programs, tried to debug and it's amazingly feature rich. The language is plain simple and you can easily program in any decent text editor. I really enjoyed playing around with it. The generated applications are lightweight like in good old times, native, fast, not so hungry for memory and cpu resources. Also FPCMAKE is a good tool if you plan to develop a more or less complex application.
FPDOC tool is not what I like to use (it requires documentation not in the source comments but in a separate xml file), better to pick pasdoc (http://pasdoc.sipsolutions.net/) for those who used to javadoc and doxygen.
As for the Pascal programs I've used -- they are not pretty stable, I think it's the fault of the poor memory management strategy applied. It's better to use reference-counting techniques like in GNUstep/Cocoa than TComponent's sole ownership and dangling pointers.
Playing with the compiler I have tried to implement a base class to do that counting and one more to track weak references. It was a success, so it's not the language fault but the programmers who use it, because my solution looks good and I plan to publish a library on GitHub if I ever program in FP.
One more deficiency is the lack of Unicode strings support in OS calls, e.g. for file names on Windows. Although it's no problem under Linux and/or MacOSX.
Generally FPC is a great tool, and there are a lot of useful libraries to make life easy.
However, the big POSITIVE side is that the compiler (FPC) is a lightning fast one and easy to install at any platform. It's even faster than javac. I'm really impressed. And GDB understands well pascal programs, tried to debug and it's amazingly feature rich. The language is plain simple and you can easily program in any decent text editor. I really enjoyed playing around with it. The generated applications are lightweight like in good old times, native, fast, not so hungry for memory and cpu resources. Also FPCMAKE is a good tool if you plan to develop a more or less complex application.
FPDOC tool is not what I like to use (it requires documentation not in the source comments but in a separate xml file), better to pick pasdoc (http://pasdoc.sipsolutions.net/) for those who used to javadoc and doxygen.
As for the Pascal programs I've used -- they are not pretty stable, I think it's the fault of the poor memory management strategy applied. It's better to use reference-counting techniques like in GNUstep/Cocoa than TComponent's sole ownership and dangling pointers.
Playing with the compiler I have tried to implement a base class to do that counting and one more to track weak references. It was a success, so it's not the language fault but the programmers who use it, because my solution looks good and I plan to publish a library on GitHub if I ever program in FP.
One more deficiency is the lack of Unicode strings support in OS calls, e.g. for file names on Windows. Although it's no problem under Linux and/or MacOSX.
Generally FPC is a great tool, and there are a lot of useful libraries to make life easy.
jEdit performance workaround
Runs slow on my Ubuntu, but if I make
jEdit global options -> Appearance -> Show the systray icon to OFF.
it runs as fast as native. Strange bug on Gnome 3.
jEdit global options -> Appearance -> Show the systray icon to OFF.
it runs as fast as native. Strange bug on Gnome 3.
Wednesday, December 7, 2011
D language status, LDC2
https://github.com/ldc-developers/ldc
http://www.digitalmars.com/d/archives/digitalmars/D/State_of_LDC_148791.html
http://www.digitalmars.com/d/archives/digitalmars/D/State_of_LDC_148791.html
Sunday, December 4, 2011
FreePascal status
Unicode is supported by LCL (Lazarus) via UTF-8. There are several functions to convert from system encoding strings (codepage on Windows) to utf-8 strings.
http://wiki.freepascal.org/LCL_Unicode_Support
According to the docs, fpc supports MacOSX 32 and 64-bit, iOS targets.http://wiki.freepascal.org/LCL_Unicode_Support
http://wiki.freepascal.org/LCL_Unicode_Support
According to the docs, fpc supports MacOSX 32 and 64-bit, iOS targets.http://wiki.freepascal.org/LCL_Unicode_Support
Sunday, November 6, 2011
Digitalmars D version 2 a fresh look
A few years ago I spotted the D language and was quite impressed by it, although the division of standard library, the development of a new 2.0 version and the stale state of many libraries stopped from active usage of it.
Now a lot of things changed, the 2.0 version is more or less stable and there's a GNU D compiler for this version and it's actively developed/supported, and even planned to be maintained as one of the GNU Compiler Collection. I wish it come true.
Having reviewed the specs for the D 2.0 I should admit that the language is engineered VERY thoroughly, with many features I was missing in Java and C++, it's clean and rich at the same time.
At first I was planning to use LDC compiler for D 1.0 because failed to compile GDC for MacOSX, but then I decided to start coding something useful for Linux only to study the language, and probably later there will be a viable implementation for MacOSX. The official implementation (DMD) can compile only 32-bit binaries for MacOSX, that's why I'm concerned on alternative implementations like GDC, LDC2...
Here's the link to the site:
http://www.d-programming-language.org
http://www.digitalmars.com
Now a lot of things changed, the 2.0 version is more or less stable and there's a GNU D compiler for this version and it's actively developed/supported, and even planned to be maintained as one of the GNU Compiler Collection. I wish it come true.
Having reviewed the specs for the D 2.0 I should admit that the language is engineered VERY thoroughly, with many features I was missing in Java and C++, it's clean and rich at the same time.
At first I was planning to use LDC compiler for D 1.0 because failed to compile GDC for MacOSX, but then I decided to start coding something useful for Linux only to study the language, and probably later there will be a viable implementation for MacOSX. The official implementation (DMD) can compile only 32-bit binaries for MacOSX, that's why I'm concerned on alternative implementations like GDC, LDC2...
Here's the link to the site:
http://www.d-programming-language.org
http://www.digitalmars.com
Wednesday, November 2, 2011
LDC under ubuntu 11.10 one more try
Installed through apt llvm-2.9, downloaded trunk LDC, executed ccmake, and added -ldl to LIBCONFIG_LDFLAGS. Successfully built!
Build tango, and adjusted /usr/local/etc/ldc.conf:
// This configuration file uses libconfig.
// See http://www.hyperrealm.com/libconfig/ for syntax details.
// Special macros:
// %%ldcbinarypath%%
// - is replaced with the path to the directory holding the ldc executable
// The default group is required
default:
{
// 'switches' holds array of string that are appends to the command line
// arguments before they are parsed.
switches = [
"-I/usr/local/include/d",
"-I/usr/local/include/d/tango/core/vendor",
"-L-L/usr/local/lib",
"-L-ltango-ldc",
"-d-version=Tango",
"-defaultlib=tango-ldc",
"-debuglib=tango-ldc"
];
};
Build tango, and adjusted /usr/local/etc/ldc.conf:
// This configuration file uses libconfig.
// See http://www.hyperrealm.com/libconfig/ for syntax details.
// Special macros:
// %%ldcbinarypath%%
// - is replaced with the path to the directory holding the ldc executable
// The default group is required
default:
{
// 'switches' holds array of string that are appends to the command line
// arguments before they are parsed.
switches = [
"-I/usr/local/include/d",
"-I/usr/local/include/d/tango/core/vendor",
"-L-L/usr/local/lib",
"-L-ltango-ldc",
"-d-version=Tango",
"-defaultlib=tango-ldc",
"-debuglib=tango-ldc"
];
};
Tuesday, November 1, 2011
LDC under Ubuntu 11.10
Install llvm 2.9 from repo, ccmake, specify path to llvm-config tool: /usr/lib/llvm-2.9/bin/llvm-config, finally was unable to build from sources. :(
Monday, October 31, 2011
D programming under MacOS X 10.6, LDC
See http://dsource.org/projects/ldc/wiki/OSXBuildInstructions
Macports to install llvm package (2.9). Then get the latest LDC (tip) from bitbucket mercurial repo, ccmake, adjust paths to match those of MacPorts (/opt/local).
Then build and install tango, as described in the link above.
Edit ldc.conf
switches = [
"-I/opt/local/include/d",
"-I/opt/local/include/d/tango/core/vendor",
"-L-L%%ldcbinarypath%%/../lib",
"-L-ltango",
"-d-version=Tango",
"-defaultlib=tango-ldc",
"-debuglib=tango-ldc"
];
Macports to install llvm package (2.9). Then get the latest LDC (tip) from bitbucket mercurial repo, ccmake, adjust paths to match those of MacPorts (/opt/local).
Then build and install tango, as described in the link above.
Edit ldc.conf
switches = [
"-I/opt/local/include/d",
"-I/opt/local/include/d/tango/core/vendor",
"-L-L%%ldcbinarypath%%/../lib",
"-L-ltango",
"-d-version=Tango",
"-defaultlib=tango-ldc",
"-debuglib=tango-ldc"
];
Thursday, January 27, 2011
LDC under MacOSX
Can't build it yet but the information I gathered is as follows:
Setup
Building LDC
Building Tango
Links
Setup
sudo port install llvm
sudo port install llvm-devel
sudo port install mercurial
sudo port install ruby
sudo port install cmake
hg clone -r 0.9.2 https://bitbucket.org/lindquist/ldc
svn co http://svn.dsource.org/projects/tango/tags/releases/0.99.9 tango
Building LDC
cmake -DCMAKE_BUILD_TYPE=Release -DDEFAULT_TARGET="x86_64-apple-darwin10" ../ldc
make -j2
Building Tango
Links
https://bitbucket.org/lindquist/ldc
http://www.dsource.org/projects/tango
http://dsource.org/projects/ldc/wiki/BuildInstructionsTangoTrunk
Wednesday, January 26, 2011
Subscribe to:
Posts (Atom)