Planet GNU

Aggregation of development blogs from the GNU Project

July 08, 2011

FSF Blogs

Introducing the systems team summer intern

I was first introduced to free software three years ago in the introductory computer science course at Grinnell College, Iowa. The quality of a wide range of programs installed on the GNU/Linux machines made such a strong impression on me that I immediately became an avid user of free software. At first, however, I did not quite comprehend the advantages of free software beyond its immediate usefulness — I merely saw that there were plenty of useful programs available at no cost. Gradually I have come to understand the free software philosophy, and now appreciate that the usefulness is a consequence of freedom, which is at the essence of the free software movement.

This internship gives me a very unique chance to contribute back to the free software community in return for all the benefits free software has brought me thus far.

Upon my arrival at the end of May, I immediately plunged into learning more about Xen and Puppet, two very important free software tools we use to organize our network at the FSF. Later this summer, I hope to harness Puppet's power to deal with more repetitive tasks such as user account creation, which will save time for tasks which cannot be automated. In the meantime, however, I am in the process of updating the FSF shop so that it will run on the latest version of Satchmo (a Django application for creating and customizing online stores).

After the fairly smooth installation of the necessary dependencies of Django and Satchmo on the development virtual machine, migrating data from our current database to the new database has proved to be the greatest challenge in this process. Fortunately, I have been able to rely on the guidance and advice of my mentors -- Ward, Peabo and Bernie, each of whom has provided me with valuable support in navigating the intricacies of this project. Once the data migration is complete, I will only need to make a few customizations and configurations to get our new instance of the FSF Shop up and running. At the end of this arduous process, the experience of both customers and administrators of the FSF Shop will be visibly improved.

I am looking forward to the second half of my internship with much anticipation and with readiness to tackle the challenges that await me in the following weeks.

by mattl at July 08, 2011 09:41 PM

Introducing the Compliance Lab's summer intern

Hi! My name is William Theaker; I'm a college student from Connecticut interested in free software and copyright law. This summer I will be interning with the FSF; I will be working on various free software licensing issues by answering questions about licensing, investigating possible GPL violations, and working on my biggest project this summer, organizing the drafting archives for the GPLv3. My first interaction with free software was when I started using “Linux” in 2003, though I was unaware of the actual origins of the software in my computer. What I referred to as “Linux” is, in fact, GNU/Linux. Linux is not an operating system unto itself, but rather another free component of a fully functioning GNU system, made useful by the GNU core libraries, shell utilities, and vital system components comprising a full operating system as defined by POSIX.

Despite my early misunderstanding of free software, as I began to learn more I found myself extremely impressed by the clever logic and the democratic values on which the community was founded. When Richard Stallman launched the free software movement in the 1980s, he also wrote what would become the GNU General Public License (GPL), which uses copyright in a novel way to ensure that the freedoms of users are retained when they use and distribute the software. The GPL's strong emphasis on copyleft—the assurance that free software cannot be published under a proprietary license—caused it to become the world's most popular free software license. By using copyright law in a novel way, the GPL ensures that the freedoms of end users are retained during distribution. Before the 2005 announcement of the first draft of the GPLv3, the GPL had remained unchanged for over 15 years. The creation of a new license was one of the most exciting times in the free software world, underscoring the level of community involvement that sustains the free software movement.

GPLv3 and its drafting process were innovative in many ways. It marked the first time a copyright license was created with extensive input from the public, as well as the first time a free software license worked to address “tivoization”—limiting devices that run free software from running user modifications. Developers, lawyers, and free software advocates dedicated thousands of hours to editing and discussing the GPL, bringing to light issues that were not addressed in previous versions. Thanks to the hard work of these tireless volunteers, flaws in the drafts were identified and addressed, strengthening the ability for the GPL to promote freedom while still remaining flexible to the introduction of new technologies and distribution methods such as BitTorrent. GPLv3 emerged from this process with robust measures to support and protect free software from threats such as software patents.

One of the best aspects of the free software movement is the fact that anyone can join to help promote software freedom, and the GPLv3 drafting process allowed people who don't usually write code to contribute to crafting a document that will define the free software movement for years to come. While the GPLv3 drafting process was a fascinating time for free software, thanks to the movement's decentralized nature it was not the only opportunity to get involved. Anyone has the ability to help the cause of software freedom, whether by designing new artwork for free software projects, developing code, providing support or documentation, or donating to a free software project that they find important.

Many documents about GPLv3 came out of the drafting process, including the thousands of comments on the drafts of the various licenses. These documents provide a wealth of information that has the potential to be useful to software projects looking to modify their licenses, legal scholars interested in copyleft, cultural anthropologists, and free software advocates. Unfortunately they have not been organized into a centralized repository, which is my project for the summer. I've already completed a manifest of all the documents and materials involved in the drafting process, and will be working to produce a Web-facing archive that includes all of the comments and discussions on the GPLv3 drafts. I look forward to continuing my work on this project and can't wait to delve into the archives this summer.

If you have ideas for this project, you can reach me via our licensing address at licensing@fsf.org.

by brett at July 08, 2011 07:05 PM

July 07, 2011

GNU SRC Build Report

GNU SRC Build Report 2011-07-03-2240

This is the weekly build report for all packages in the GNU Source Release Collection.

There are 245 packages defined, 142 succeeded, 103 failed.

The build generated 835 errors, 10271 warnings.

More details in the full build report. Please send patches to bug-gsrc@gnu.org.

by bug-gsrc@gnu.org at July 07, 2011 08:00 PM

FSF Events

Software Libre en la Ética y en la Práctica

Richard Stallman hablará sobre las metas y la filosofía del movimiento del Software Libre, y el estado y la historia del sistema operativo GNU, el cual junto con el núcleo Linux, es actualmente utilizado por decenas de millones de personas en todo el mundo.

by jrasata at July 07, 2011 04:15 PM

El software libre en la práctica y la ética

Richard Stallman hablará sobre las metas y la filosofía del movimiento del Software Libre, y el estado y la historia del sistema operativo GNU, el cual junto con el núcleo Linux, es actualmente utilizado por decenas de millones de personas en todo el mundo.

by jrasata at July 07, 2011 03:57 PM

For a Free Digital Society

Activities directed at ``including'' more people in the use of digital technology are predicated on the assumption that such inclusion is invariably a good thing. It appears so, when judged solely by immediate practical convenience. However, if we also judge in terms of human rights, whether digital inclusion is good or bad depends on what kind of digital world we are to be included in. If we wish to work towards digital inclusion as a goal, it behooves us to make sure it is the good kind.

by jrasata at July 07, 2011 03:35 PM

Copyright vs. Community

Copyright developed in the age of the printing press, and was designed to fit with the system of centralized copying imposed by the printing press. But the copyright system does not fit well with computer networks, and only draconian punishments can enforce it.

The global corporations that profit from copyright are lobbying for draconian punishments, and to increase their copyright powers, while suppressing public access to technology. But if we seriously hope to serve the only legitimate purpose of copyright--to promote progress, for the benefit of the public--then we must make changes in the other direction.

by jrasata at July 07, 2011 03:28 PM

The GNU General Public License. What we've changed in version 3, and why

Richard Stallman wrote the first GNU General Public License in 1989, and version 3 which was completed in 2007. He will discuss the philosophy of the GNU GPL, the changes made in version 3, and the reasons for those changes.

by jrasata at July 07, 2011 01:56 PM

GNUnet News

July 06, 2011

Smalltalk development blog

OsmoST SIP

Intro

The last couple of days, to some degree weeks I was implementing a SIP stack for GNU Smalltalk to be used in my Smalltalk GSM project. The first time I encountered SIP was around 2001 when we were excited to run a SIP Phone on our Linux powered iPAQs (Linphone on Opie).

For Smalltalk I started with looking at SipStack by Frank Shearar (who was very responsive to questions regarding his code and SIP in general). The main problem was that his stack was incomplete and as usual it is difficult to pick things up without knowing SIP and not knowing where the code was heading.

Grammar

I began with mapping the BNF SIP Grammar to rules for the PetitParser parsing framework. I have shortened some rules (e.g. because the generic rule is a catch-all one and I don't need the specialized form yet).

Complexity

The next big task was to deal with the concepts of a SIP Dialog, a SIP Session, a SIP Transaction and getting the relationship of these entities right. E.g. to place a call one creates an unconfirmed Dialog, prepares the INVITE Transaction and passes it to the transport layer. During this transaction one can get a reply that leads to a confirmation of the dialog. In fact one can end up with multiple confirmed dialogs (called forking, the target phones start ringing in multiple places and can be picked up multiple times as well). To make matters worse some answers need to be sent sent within the same transaction, some open a new one. My code seems to work now but there are some things I don't do properly (e.g. routing). I have documented this and if I have a need for those I will address them.

Processes

In the last couple of years I was mostly dealing with a single select IO model, coming to Smalltalk makes me use Processes to read and write from sockets. My basic model is to have a RX Process to use Socket>>#next and a TX process that will do SharedQueue>>#next and then Socket>>#nextPutAll. But with having multiple processes one is required to do proper locking, e.g. have a simple locking hierarchy (first pick the lock of the CallAgent, then the lock of a Dialog/Session). This all works nicely until I reached the point that I have two sub systems talking to each other.

For setting up a call I might have one leg coming from GSM and use the MGCP Protocol, the other leg might be SIP. To hang-up I will need to inform the other leg of the call about it, but this means I will need to have a locking hierarchy that first takes all locks of the left leg of a call, then all locks of the right one which in turns means me I need to dispatch messages without any locks being held. Now besides having RX from maybe a couple of different Processes, I also deal with timeouts that will come from different Processes as well.

Central dispatch

To put an end to this (and the complications in the code) I created a simple queue that will BlockClosure>>#value a block from a central dispatch process, this way I have serialized everything and can mostly ignore locking. I hope that Smalltalk VMs will have a nice M:N Process model in the future and that my code will evolve into having different dispatchers running on these N native processes.

Using the code

st> PackageLoader fileInPackage: #OsmoSIP.
st> transport :=SIPUdpTransport startOn: '172.16.254.55' port: 5061.
st> useragent := SIPUserAgent createOn: transport.
st> transport start. "Starts the RX/TX process"

st> call := SIPCall fromUser: 'sip:1000@on-waves.com'
host: '172.16.1.72' port: 5060 to: 'sip:9198@172.16.1.72' on: useragent.
st> call createCall: 'SomeSDP file'.
st> call cancel. "E.g. before it is connected"
st> call hangup. "E.g. when the call is connected."
st> call terminate. "End the call somehow.."

by Holger Hans Peter Freyther at July 06, 2011 07:52 PM

July 05, 2011

FSF Events

The GNU General Public License. What we've changed in version 3, and why

Richard Stallman wrote the first GNU General Public License in 1989, and version 3 which was completed in 2007. He will discuss the philosophy of the GNU GPL, the changes made in version 3, and the reasons for those changes.

by jrasata at July 05, 2011 09:38 PM

The Danger of Software Patents

Richard Stallman will explain how software patents obstruct software development. Software patents are patents that cover software ideas. They restrict the development of software, so that every design decision brings a risk of getting sued. Patents in other fields restrict factories, but software patents restrict every computer user. Economic research shows that they even retard progress.

by jrasata at July 05, 2011 09:31 PM

The Free Software Movement

Richard Stallman will speak about the goals and philosophy of the Free Software Movement, and the status and history of the GNU operating system, which in combination with the kernel Linux is now used by tens of millions of users world-wide.

by jrasata at July 05, 2011 09:26 PM

What Makes Digital Inclusion Good or Bad?

Activities directed at ``including'' more people in the use of digital technology are predicated on the assumption that such inclusion is invariably a good thing. It appears so, when judged solely by immediate practical convenience. However, if we also judge in terms of human rights, whether digital inclusion is good or bad depends on what kind of digital world we are to be included in. If we wish to work towards digital inclusion as a goal, it behooves us to make sure it is the good kind.

by jrasata at July 05, 2011 09:22 PM

Free Software and Your Freedom

The Free Software Movement campaigns for computer users' freedom to cooperate and control their own computing. The Free Software Movement developed the GNU operating system, typically used together with the kernel Linux, specifically to make these freedoms possible.

by jrasata at July 05, 2011 09:11 PM

Copyright vs. Community

Copyright developed in the age of the printing press, and was designed to fit with the system of centralized copying imposed by the printing press. But the copyright system does not fit well with computer networks, and only draconian punishments can enforce it.

The global corporations that profit from copyright are lobbying for draconian punishments, and to increase their copyright powers, while suppressing public access to technology. But if we seriously hope to serve the only legitimate purpose of copyright--to promote progress, for the benefit of the public--then we must make changes in the other direction.

by jrasata at July 05, 2011 09:04 PM

Andy Wingo

v8: a tale of two compilers

Regular readers will have noticed my fascination with the V8 JavaScript implementation. It is indeed an impressive piece of engineering.

When V8 was originally announced, Lars Bak wrote:

I hope the web community will adopt the code and the ideas we have developed to advance the performance of JavaScript. Raising the performance bar of JavaScript is important for continued innovation of web applications.

How right he was! V8 has succeeded admirably, not only in adoption, but also in "raising the performance bar" among all JavaScript implementations.

But as William Gibson says, "The future is already here — it's just not very evenly distributed." Many parts of V8 are not documented at all, and perhaps understandably, given the pace at which things are changing. So as I'm getting up to speed with V8 for my work with Igalia, I've been trying to document the interesting things that I find, so that all JavaScript implementations can learn and improve.

And indeed, with my selfish Guile hat on, this study in V8 is giving me lots of ideas and motivation. So perhaps V8's new motto should be, "shaming the world into faster code, one compiler at a time".

compiler the first: full-codegen

V8 compiles all JavaScript to native code. V8 has two compilers: one that runs fast and produces generic code, and one that doesn't run as fast but does try to produce optimized code.

The quick-and-simple compiler is known internally as the "full-codegen" compiler. It takes as its input the abstract syntax tree (AST) of a function, walks over the nodes in the AST, and emits calls to a macroassembler directly. Here's a picture:

The boxes represent the flow of data in the compilation process. There's only two boxes because, as we said, it's a simple compiler. All local variables are stored either on the stack or on the heap, not in registers. Any variable referenced by a nested function is stored on the heap, in the context object associated with the function in which the variable was defined.

The compiler will emit loads and stores to pull these values into registers to actually do the work. The top of the stack of temporaries is cached in a register. Complicated cases are handled by emitting calls to runtime procedures. The compiler does track the context in which an expression is being evaluated, so that tests can just jump directly to the consequent blocks, instead of pushing a value, testing if it's zero or not, then branching. Small integer arithmetic is usually inlined. And that's all there is!

Actually I should mention one important optimization that is done even with the full-codegen compiler, and that is inline caching. See the Hölzle, Chambers, and Ungar paper I link to there for all of the details. Inline caches are used for assignments, unary and binary operations, function calls, property accesses, and comparisons.

The inline caches also serve as sources of type information, used by the optimizing compiler. In the case of some statement types, like assignments, the only purpose of the IC is to record type information.Ed.: see the comments for a correction.

Here are some links to the source:

ast.h
The abstract syntax tree. Note that though the comment says that ASTs are allocated in separate zones, for constant-time deallocation, in practice the AST is kept around as long as the JavaScript functions are alive, for use as input to the optimizing compiler. Zone allocation is more of a win for the optimizing compiler, which produces more ephemeral garbage. Ed.: Vyacheslav Egorov writes in to say that what V8 keeps around is actually the function source, not the AST. It re-parses as needed. Makes sense. I recall Lars Bak saying in a video that source is the most compact IR there is, and indeed maybe that is the case.
full-codegen.h
full-codegen.cc
full-codegen-ia32.cc
The full-codegen compiler. Most of the meat of the full-codegen compiler is in the target-specific directory (4257 lines vs 769+1323 lines). Currently supported targets are ia32, x64, arm, and mips.

type feedback

The first time V8 sees a function, it parses it to the AST but doesn't actually do anything with it. It only runs the full-codegen compiler when the function is first run. How's that for lazy! But after things have started up, it kicks off a profiler thread to see how things are going, and what functions are hot.

This lazy, sit-back-and-watch approach gives V8 time to record the type information flowing through it. So by the time it has decided that a function is hot, and could use a little more help, it has type information to give to the compiler.

Runtime type feedback information is recorded by and stored in the inline caches (ICs). Type feedback information is expressed internally as an 8-bit value constructed in such a way that it can detect a hierarchy of types, with a simple bitmask. At this point the best I can do is show the artwork in the source:

//         Unknown
//           |   \____________
//           |                |
//      Primitive       Non-primitive
//           |   \_______     |
//           |           |    |
//        Number       String |
//         /   \         |    |
//    Double  Integer32  |   /
//        |      |      /   /
//        |     Smi    /   /
//        |      |    / __/
//        Uninitialized.

Everytime an IC stub sees a new kind of value, it computes the type of that value, and bitwise-ands it with the old type. The initial type value is uninitialized. So if an IC only sees integers in the Smi (small integer) range, the recorded type will indicate that. But as soon as it sees a double value, the type becomes Number; and if it then sees an object, the type becomes Unknown. A non-primitive IC will necessarily store the map of the receiver type in the IC, for dispatch purposes. Type feedback can parse the IC stub to get at this map, when needed. Ed.: more corrections. Thanks, Vyacheslav.

Type feedback information is associated with a particular AST node (the assignment, property load, etc.). An integer identifier for the node is serialized into the IC so that when V8 decides that a function is hot, it can parse out the recorded type information from the full-codegen code, and associate it with the AST node.

Now, this process is a bit complicated. It needs support up and down in your compiler stack. You need to have inline caches. Your inline caches need to have support for the type information, both for operands and for the result. You need to be able to walk this data to find the values. Then you need to link it back to the AST, so that when you pass the AST to your optimizing compiler, the compiler is able to ask the right questions.

The concrete strategy that V8 takes is to parse the data into a TypeFeedbackOracle object, associating information with particular AST nodes. Then V8 visits all of the AST nodes with this oracle, and the nodes themselves parse out the data that they might find useful from the oracle.

In the end one is able to, for example, ask a Property node if it is monomorphic, and in any case what are the receiver types at that node. It seems that this works well for V8, because it reduces the number of moving parts in the optimizing compiler, given that it doesn't need to have the TypeFeedbackOracle itself.

So, source links.

type-info.h
The TypeInfo 8-bit data type, and the TypeFeedbackOracle declaration. I have to admit, I really like the use of C++ within V8. It's a nasty tool, but they wield it well.
type-info.cc
The implementation of TypeFeedbackOracle. See ProcessTarget down at the bottom of the file for where the bulk of the work happens.

Also check the ast.h link before to see see how type feedback ties into the AST itself.

crankshaft = type feedback + hydrogen + lithium

Once V8 has identified that a function is hot and has collected some type feedback information, it tries to run the augmented AST through an optimizing compiler. This optimizing compiler is called Crankshaft in the marketing materials, though that name rarely appears in the source itself.

Instead, in the source, Crankshaft consists of the Hydrogen high-level intermediate representation (IR), the Lithium low-level IR, and their associated compilers. Like this:

(You probably caught on from my heavy-handed repetition above, but I believe that the names Hydrogen and Lithium come from High- and Low-level, respectively.)

It depends on your background, but you might have seen a diagram like that before:

Indeed I believe that Crankshaft was highly influenced by the changes that Sun introduced into the Hotspot Client compiler in Java 6. Let me quote from an illuminating 2008 paper by Kotzmann et al, Design of the HotSpot Client Compiler for Java 6:

First, a high-level intermediate representation (HIR) of the compiled method is built via an abstract interpretation of the bytecodes. It consists of a control-flow graph (CFG), whose basic blocks are singly linked lists of instructions. The HIR is in static single- assignment (SSA) form, which means that for every variable there is just a single point in the program where a value is assigned to it. An instruction that loads or computes a value represents both the operation and its result, so that operands can be represented as pointers to previous instructions. Both during and after generation of the HIR, several optimizations are performed, such as constant folding, value numbering, method inlining, and null check elimination. They benefit from the simple structure of the HIR and the SSA form.

The back end of the compiler translates the optimized HIR into a low-level intermediate representation (LIR). The LIR is conceptually similar to machine code, but still mostly platform-independent. In contrast to HIR instructions, LIR operations operate on virtual registers instead of references to previous instructions. The LIR facilitates various low-level optimizations and is the input for the linear scan register allocator, which maps virtual registers to physical ones.

This statement describes Crankshaft very neatly, and the rest of section 2 of that paper applies in a general sense. Of course there are some differences. Crankshaft starts with the AST, not bytecodes. The HotSpot client runtime does not use type-feedback to help its compiler, as it is less necessary for Java, though it would still be helpful. Crankshaft doesn't do very much with exception handlers.

But the similarities are such that V8 can actually produce traces that can be read by c1visualizer (docs), a program used to visualize the internals of the HotSpot client compiler. (The client compiler appears to be known internally as c1; the server compiler appears to be opto).

in our next installment

This post is getting quite long. I'm going to have to send my mom some flowers or something, because I'm sure she does check these things out, and it must be brain-numbing to slog through. Another paragraph? When will he stop?

So if you, dear reader, find yourself in this category, you're in good company, because my mom is a lovely lady.

But if you're a compiler geek, I think I have at least couple more articles to write on Crankshaft before I can get back to other hacks. Specifically, we'll go into the optimizations that Crankshaft does on the Hydrogen IR, and take a look on how it does the translation to Lithium. But until then, happy hacking!

by Andy Wingo at July 05, 2011 02:31 PM

July 04, 2011

FSF Events

Software libero per la tue libertá

The Free Software Movement campaigns for computer users' freedom to cooperate and control their own computing. The Free Software Movement developed the GNU operating system, typically used together with the kernel Linux, specifically to make these freedoms possible.

This talk will be in English with simultaneous translation.

by jrasata at July 04, 2011 01:43 PM

Andy Wingo

guile 2.0.2: building the guildhall

Hey tubes, we made another Guile release!

what is guile

Guile is the GNU extension language. It's an implementation of Scheme. It's pretty fun to hack in, and on!

guile 2.0.2: even faster!

Here I'd like to highlight the thing that I really like about this release: performance. Relative to 2.0.1:

  • The VM is 20% faster

  • Compiled .go files are half the size

  • Startup time is down from 16.2 milliseconds to 11.7 milliseconds (on my machine)

  • Base memory use down from 3.8 MB of private dirty memory to 2.9MB (measured on a guile -c '(sleep 100)')

In short, thundercats are totally on the loose! See the release announcement for all the details.

where we're going

It's hard to tell sometimes where this jalopy is headed. Sometimes the vehicle just drives itself, like the recent speed improvements, which were totally unplanned.

But that said, there are a few stops we want to make on this journey, in the near- and mid-term. Let's take a look.

2.0: building the guildhall

On the 2.0 branch, the current stable series, the big feature that we'd like to land soon will be a CPAN-like repository of installable Scheme modules.

We agonized over the name for a while. It needs to be short and memorable, so it can be used as a command-line tool. (The Git experience is pretty definitive here.) At the same time it needs to be linked to Guile, and follow some sort of theme.

What we've done now is to take our guile-tools script runner (equivalent to the git wrapper) and rename it to guild. Currently it's mostly used for compiling files, as in guild compile -o foo.go foo.scm, but in the future we want to use it as a part of this system for Guile wizards and journeyfolk to band together to share code---to form a guild, so to speak.

And so the package archive itself will be the "guild hall" (or "guildhall"). We'll see if we can get guildhall.gnu.org, as a place to host the packages.

As far as code, protocol, and formats go, we are looking at porting Andreas Rottmann's Dorodango Scheme package manager to be Guile-specific, with guild commands. So guild update, guild upgrade, guild install xml-rpc, etc.

Dorodango is basically a port of Debian's apt to Scheme. It even has ports of the same dependency resolution algorithms, which is fun. It also allows for multiple sources, so we can have our Guile guildhall archive, but also have support for portable R6RS Scheme archives from Dorodango.

2.2: bit mucking

Guile is getting pretty good now, but there is more to be done before it is as cheap to run a program written in Scheme as it is to run a program written in C.

The first thing that we will do to help this is to switch to ELF as the format of our compiled code. We will do this on all platforms, and even before we do native compilation. The bytecode will simply be stored in an ELF section. This will also allow us to statically allocate more data, decreasing memory usage and increasing locality. Also our debugging information is currently interspersed with code -- not in the execution path, mind you, but it does make the memory profile of the code look more like emmental than comté cheese. Moving debug info out to a separate section will help with that.

ELF will also add flexibility. We can add sections to express dependencies of compiled code on source code. We can strip debug info and other things from compiled code. We can link multiple modules into one file, to avoid stat penalties on startup.

In addition ELF will allow us to add native code, in a separate section. Of course we have to actually produce native code, so that's the next big thing for Guile 2.2. The plan is to write an ahead-of-time code generator for x86 and x86-64 systems, while keeping the bytecode interpreter as well. Then once we know what we want, we can go and talk to the GCC folks and see if our use case can be supported there.

Anyway, that's the plan. I expect 2.2 to take another year or so. By the time we have native compilation, I hope also our Elisp implementation will be significantly faster than the one in Emacs, so it will really become attractive to people to finish the work that we have done to make the switch there.

by Andy Wingo at July 04, 2011 09:47 AM

July 03, 2011

gnutelephony @ GNU planet

Automake and cmake revisited

One reason I had for awhile considered cmake so strongly in GNU Telephony is that I choose to experiment with using Qt to build applications, and at the time I thought it rather difficult to build QT applications under autconf/automake. A week ago I revisited this question on my own, and found I was actually wrong about this.

My interest in using Qt actually was from the period immediately prior to when Elop joined Nokia as CEO and then, much like Belluzo did to SGI, proceeded defraud the shareholders, employees, and customers of Nokia for the exclusive benefit of Microsoft and one presumes for his own personal gain. However, whatever his personal, and what I do happen to believe as being purely sociopathic, motives may be, it is very clear that Qt itself, with the help of the KDE foundation, and even MeeGO which I am less interested in, but even that, with the help of many others, would and do continue to survive and even thrive, and it matters not whether Nokia continues as part of that process or not in the future. This is just one real tangible benefit of freedom, that tools which you learn and use cannot be then taken away by either arbitrary or criminal actions. There are of course many other benefits to true software freedom as well.

But moving past the question of Nokia for the moment, much of the information I originally found about using Qt with automake was either incomplete or in some cases even incorrect. This was made in my case more complex because I also use qrc resource and qt designer ui files, all of which, like is done with headers with moc, also have to be preprocessed. Some of these also actually produce headers rather than source files.

One resource suggested that one can create a nodist_appname_HEADERS = .. entry, and I found this to be unsupported, at least in the version of automake I was using. However, when I saw this, what I did figured out instead was that I can use “BUILT_SOURCES” to do the same thing, and this answered the question of how to stage the construction of headers correctly from Qt ui templates in automake. What I ended up with is something like this (from the most relevant parts…):

BUILT_SOURCES = ui_options.h ui_mapped.h

noinst_HEADERS = switchview.h options.ui mapped.ui switchview.qrc \
error.png info.png switchview_down.png switchview_live.png warning.png

nodist_switchview_SOURCES = moc_switchview.cpp qrc_switchview.cpp
switchview_SOURCES = switchview.cpp events.cpp mapped.cpp options.cpp \
startup.cpp

ui_options.h: options.ui
@UIC@ -o $@ $<

ui_mapped.h: mapped.ui
@UIC@ -o $@ $<

moc_switchview.cpp: switchview.h
@MOC@ -o $@ $<

qrc_switchview.cpp: switchview.qrc
@RCC@ -o $@ $

I could of course used pattern rules for the transform of headers through moc, ui to ui_headers, and qrc files, but I decided not to since that would make the result depend on gnu make, and in fact automake warns about this. Explicitly writing the make rules for the individual transforms kept it more generic.

This is actually not more complicated than supporting Qt in cmake or even with qmake, and retains real benefits of using automake, whether one wants to use anjuta as an ide, support cross-compiling cleanly the way autotools does, or os targets and pathname transforms. Finally we have again a build system that only depends on native tools commonly found on posix systems.

We will of course continue to fully support and maintain cmake builds in GNU Telephony, for there are certain use cases where cmake does offer clear benefits for some of our users. But I will want to make sure going forward we do fully support automake and autotools as well. It is not so bad continuing to maintain both for I have found they each do clearly meet different needs and hence to some degree are complimentary.

Having made it possible to build the switchview desktop client fully with autotools, we are now ready to distribute switchview as part of that next release of GNU SIP Witch (what will be 1.1.0). Switchview was developed as a very early part of the transition to using sipwitch for delivering GNU Free Call services, for it represents a model implementation of desktop integration of the sipwitch service daemon, and hence is meant to help others in implementing GFC clients, as well as being a tool to enable monitoring of sipwitch activity when that is used as desktop SIP mediation service.

by dyfet at July 03, 2011 06:15 PM

GNU Hurd development blog

2011-q2

A quarter of the Hurd, Q2 of 2011: Graphical Installer, GSoC, and Debian. Details.

Jérémie Koenig started working on his Google Summer of Code project: bringing not only Java to the Hurd, but also fixing or adding missing parts in the Hurd's components along the way. For example, he already contributed a set of signal handling improvements.

Samuel Thibault created the first Debian GNU/Hurd CD set with a graphical installer. You can dowload it at the usual place for Debian CD images.

Amongst others, Samuel also tracked down and fixed a port leak in file_reparent. This one got visible on the Debian package builder machine.

On the organizational side, there is now a real plan to release a Hurd variant of Debian with their next major release, Wheezy. Expected towards the end of 2012 or beginning of 2013, the Hurd-specific bits of that release effort's process are being tracked on http://wiki.debian.org/Debian_GNU/Hurd. There is still a lot of work left to be done, but -- as everyone knows -- a real goal as well as a bit of pressure might help to actually get it done. If you want to lend a helping hand in order to make this happen, porting packages is a great way to get started and do something useful at the same time.

Tanguy le Carrour offered to sponsor some Hurd work, and followed up on his offer by adding to the Hurd bounties that Thomas Schwinge had set up over at on FOSS Factory -- claim them if you can! It's not (not yet?) comparable to a Google Summer of Code student's salary, but a step into the right direction. So, if you have more money than time and want the Hurd to advance, why don't you join Tanguy?

At the end of August, Hurd folks will be meeting at the GNU Hackers Meeting in Paris. Samuel Thibault will be giving a talk (GNU/Hurd, aka. Extensibility from the Ground), and -- amongs others -- Jérémie Koenig will be there too, ready to answer all the questions about his Java/Hurd Google Summer of Code work.

July 03, 2011 05:30 PM

gnulib @ Savannah

New features

Recently added new major features:

  • 2011-06-21 Reliable error reporting through strerror_r, strerror, perror.
  • 2011-06-12 The 'acl' module now supports the ACLs of HP-UX 11.11 and newer.
  • Improvements for multiple invocations of gnulib-tool in the scope of the same configure.ac:
    • 2011-06-08 New option --witness-c-macro.
    • 2011-05-29 Multiple gnulib generated .h files of the same name can be combined.
  • 2011-05-16 The documentation now lists the target platforms:

http://www.gnu.org/software/gnulib/manual/html_node/Target-Platforms.html

  • 2011-04-21 'passfd': A new module for passing file descriptors along Unix domain sockets.
  • 2011-04-05 New Makefile rules are added to generated Makefile.ams, so that stale generated .h files are either regenerated or removed, whichever is appropriate.
  • 2011-01-26 It is now possible to write unit tests that test against memory leaks.

by Bruno Haible at July 03, 2011 01:25 PM

July 02, 2011

Greg Casamento

Building clang for use with GNUstep

1) Build using the instructions here: http://clang.llvm.org/get_started.html

2) Once that's done, download the latest version of Hans Boehm's garbage collector here: http://www.hpl.hp.com/personal/Hans_Boehm/gc/

3) Untar, Build and install boehm-gc.... it should be gc-7.1.tar.gz
    build it with clang like so:
              ./configure CC=clang LD=gcc && make CC=clang LD=gcc
          make install

4) Build gnustep-make like so and install it:

              ./configure CC=clang LD=gcc && make CC=clang LD=gcc
          make install

5) Build libobj2 and install it:
              make CC=clang CXX=clang++ LD=gcc
         make install
              
5) Build base, gui and back and install them:
         ./configure CC=clang CXX=clang++ LD=gcc && make CC=clang CXX=clang++ LD=gcc messages=yes
         su
         . /usr/GNUstep/System/Library/Makefiles/GNUstep.sh && make GNUSTEP_INSTALLATION_DOMAIN=SYSTEM install

That should be all there is too it.  Not much, but a few little details which might serve to make it enough of a pain to discourage some people.

by GregC (noreply@blogger.com) at July 02, 2011 06:09 PM

GNUCash News

Announcement: GnuCash Documentation 2.4.1 Release

GnuCash Documentation 2.4.1 released

The GnuCash documentation team proudly announces release 2.4.1 of the GnuCash help manual and concepts guide. This documentation is intended for the 2.4 series of GnuCash.

Note: version 2.4.0 of the GnuCash Documentation was only partially released and had several issues. Hence it was never officially announced and should be skipped.

Reading the documentation online

An online version of the documentation is available on the Documentation page of the GnuCash website. The 2.4.1 documentation can be found under "GnuCash v2.4 (current stable release)" in multiple languages.

Getting GnuCash Documentation as pdf

An pdf version of the documentation available on the Documentation page of the GnuCash website. The 2.4.1 documentation will be found under "GnuCash v2.4 (current stable release)" in multiple languages.

Getting GnuCash Documentation as source code

If you want to compile the GnuCash Documentation 2.4.1 for yourself, the source code can be downloaded from:

Changes

Changes between the 2.2 series and 2.4.1 include

  • Bugs fixed
    • Bug #130920: Explain workaround for user-defined currencies.
    • Bug #535424: Update documentation for the Since Last Run assistant.
    • Bug #582547: Add account tree columns description.
    • Bug #588035: Correct keyboard shortcut for Actions > Split menu item.
    • Bug #621573: Simplify explanation of entering a split transaction and remove comment about register bug (no longer applicable).
    • Bug #627266: "Steps to enable On-line price updating" doesn't say to install Finance::Quote
    • Bug #627983: Quit or Cancel
    • Bug #627984: Documentation consistency: either don't use the term druid or at least explain it.
    • Bug #628745 - guide: Add What's New section for current stable series
    • Bug #630652: Expand and add GnuCash Other Assets
      Patch author: Tom Bullock (tbullock at nd dot edu)
    • Bug #632244: Removed the Preferences section from guide and updated on help.
    • Bug #633385: Restructure section 2.2 Data Entry Concepts to only include basic info on files, accounts, and transactions.
      Minor cosmetic edits to section 2.1.3 and a concept clarification to section 4.2.2.
      Author: David (sunfish62 at yahoo dot com)
      Input: Yawar Amin (yawar dot amin at gmail dot com) and Tom Bullock (tbullock at nd dot edu)
    • Bug #633586: Move the explanation of debits and credits from section 3.2.2 `Income and Expense Accounts' into section 2.1.3 `Double Entry', a more logical place.
      Get rid of historical info (easy to look up online), error checking features info (this isn't a sales pitch), and banks' reversed usage of debit and credit terms (a digression, not really relevant at this point).
    • Bug #634075: Replace all usage of the term `druid' with `assistant' in the GnuCash Guide.
      Author: Mike E (mikee at saxicola dot idps dot co dot uk)
    • Bug #635357: Document Save As and Open dialogs.
    • Bug #635360: Explain backup files from a 2.4 point of view.
    • Bug #635361: Update the new account screen description and minor changes to account basics chapter in help.
    • Bug #635363: Add description of auto completion for business features.
    • Bug #635365: Mention invoice post date default.
    • Bug #635365: New images for AR Payment and AP Payment
    • Bug #635365: documents the new dialog related to style sheets
    • Bug #635386: Document trading accounts GnuCash capabilities.
    • Bug #635982: Fix typos and grammatical errors.
      Author: Yasuaki Taniguchi (yasuakit at gmail dot com)
      Review: Yawar Amin (yawar dot amin at gmail dot com) and Cristian Marchi (cri79 at ngi dot it)
    • Bug #638500: Add a note about the source of the report being modified so that users can follow along.
    • Bug #639264: Add Information about Starting Balance in reconcile window and revise the entire section.
    • Bug #639999: 16.3 Current Assets miscalculation in 16.3.5 Wash/Suspense Account
      Patch by Chris Curtis.
    • Bug #644984: Update to 2.4 UI and workflow the guide section on scheduled transactions entering from the Scheduled transaction editor.
    • Bug #647735: Add instructions on how to change the GnuCash interface language.
    • Related to bug #635366: Add cross-links for the Tax Options menu.
    • Related to bug #635357: Remove QIF assistant description and move New Account Hierarchy setup description.
  • Translation updates
    • New and updated German version of guide document, by Juergen Hoewener.
    • Updated German help, by Holger Stöhr.
    • Much improved Italian version of the documentation, by Christan Marchi.
    • New Japanese version of the guide, by Yasuaki Taniguchi.
  • New or improved content
    • GnuCash Docs: Update GNOME documentation links, patch by Yawar Amin
    • Update help manual to reflect partial support of capital gains for US Income Tax reporting and TXF exporting for code 673.
    • New figure for Printing tab under Preferences.
    • Updated Preferences section to GnuCash 2.4 and minor changes for 2.4 release.
    • guide: Reword paragraphs about new file extension
      Mention new file extension chosen during 2.3 development. Also, two paragraphs in the `Basics' chapter talk about the new default .gnucash file format. Make the second refer to the first.
    • guide: Change/remove references to old versions
    • guide: Mention important changes in What's New section
    • guide: Explain concept behind What's New section.
    • Update Reports section of help manual to reflect enhanced tax report.
    • help & guide: Update date, series and version entity definitions to current release.
    • Update menu paths to 2.4 UI.
    • Updated help content to GnuCash 2.4, improved markup and tagging.
    • Update help to reflect changes introduced with bug #634357.
    • Add shortcut for Transfer command.
    • Reintroduce the show splash screen option.
    • Add description for File->Add Report item.
    • Fix mixed up account names, spotted by aikhan
    • Provide separate Finance::Quote instructions for each OS and clarify the ones for Linux.
    • Changed "Portfoloio View" to "Commodity View". A "portfolio" is a collection of investments, not a single investment. The register view in question applies to a single investment, and is used for all non-monetary commodities.
    • Update all references in the C guide & help files to also show the correct preferences menu path for Mac OS X in addition to the Gnome one.
    • guide:Remove sections on international preferences and currency support, and absorb them into earlier introduction and account setup sections.
    • Remove a note about bug #340041 that is fixed now.
    • Add information on python invoice import script Documenation created by Mike Evans
    • Lots of small fixes and tweaks to improve the quality of the content.
  • Markup releated changes
    • Delete guilabel tags below section titles with same wording (redundant).
      Delete note about debit and credit effects on asset accounts because it's effectively the same as note `More on Debits and Credits' at the end of Section 3.2.2 (Income and Expense Accounts).
      Replace GnuCash name with defined app entity.
      Use tip tags for tips.
      Use an xref tag for a reference.
    • Replace all uses of GnuCash with the app entity
    • Replace all usage of the words 'GnuCash' or 'Gnucash' with the 'app' entity
      Patch by Yawar Amin
    • Add <application> markup to &app; entity.
    • guide: Add single-quote entity definitions
    • Use &rsquo; entity instead of "'"
    • Define entities for current stable and unstable versions, patch by Yawar Amin
    • guide: Add entities for stable and unstable series
      Sometimes referring to the exact version in the documentation is a bit superfluous, and instead we just want to refer to general GnuCash release series (2.2, 2.3, 2.4, etc.) in which something happened.
    • Add mdash entity to enable the use of xml2po and add description for entities.
    • Add guibutton tag.
    • Generate html doc in UTF-8 instead of ISO-8859-1
    • Add figure tags and pgwide attribute to some screenshots
      The figure tags should go around all screenshots to have them show up in the list of figures.
      The pgwide attribute repositions the image in pdf documents. Large pictures still fit on the page thanks to this flag.
    • Use different accounting equation image for html or pdf rendering This is meant as an example of how the pdf images can be improved. This may not work well for screenshots though.
    • Improve figures and images for pdf printing and remove unused ones. Change ppi to 144 for all figures
    • Add hyperlink to GnuCash user list.
    • Add function attribute to Enter key tagging.
  • Other, non-visible changes
    • Remove old files that collide with existing ones in case-insensitive filesystems.
    • Add chapter getting-help to Makefile.
    • Merge branch 'bug633066' into HEAD
    • Remove redundant index.
    • Add gitignores.
    • Separate getting-help chapter to validate getting-started xml file.
    • Update the build system to a more recent xsl stylesheet, including ones required for pdf and htmlhelp (Windows)
    • Restore pdf creation for gnucash-guide and gnucash-help in all languages.
    • Update docbook specification from 4.1.2 to 4.4.
    • Migrate the Italian GnuCash guide to a po file based workflow.
    • Set svn:eol-style property for all XML files to LF to avoid CRLF/LF mixups.
    • More information on translation process
    • Several other small fixes and tweaks in the documentation build system

About the Program

GnuCash is a free, open source accounting program released under the GNU General Public License (GPL) and available for GNU/Linux, *BSD, Solaris, Mac OSX and Microsoft Windows. Programming on GnuCash began in 1997, and its first stable release was in 1998.

by GnuCash Developers (gnucash-devel@gnucash.org) at July 02, 2011 05:00 AM

Announcement: GnuCash Documentation 2.2.2 Release

GnuCash Documentation 2.2.2 released

The GnuCash documentation team proudly announces release 2.2.2 of the GnuCash help manual and concepts guide. This documentation is intended for the 2.2 series of GnuCash.

Note that this will be the last documentation release for the 2.2 series. All future documentation efforts will go into the 2.4 and unstable series.

Reading the documentation online

An online version of the documentation is available on the Documentation page of the GnuCash website. The 2.2.2 documentation will be found under "Older GnuCash Documentation", "GnuCash v2.2".

Getting GnuCash Documentation as source code

If you want to compile the GnuCash Documentation 2.2.2 for yourself, the source code can be downloaded from:

Changes

Changes between 2.2.1 and 2.2.2 include

  • Bugs fixed
    • Bug #588035: Correct keyboard shortcut for Actions > Split menu item.
    • Bug #621573: Simplify explanation of entering a split transaction and remove comment about register bug (no longer applicable).
    • Bug #627266: "Steps to enable On-line price updating" doesn't say to install Finance::Quote
    • Bug #630652: Expand and add GnuCash Other Assets
      Patch author: Tom Bullock (tbullock at nd dot edu)
    • Bug #632244: Removed the Preferences section from guide and updated on help. Keep old screenshots and source credits. Delete all references to new preferences such as Printing tab. Delete all references to new SQL backend and default .gnucash extension.
    • Bug #633066
    • Bug #633385: Restructure section 2.2 Data Entry Concepts to only include basic info on files, accounts, and transactions.
      Minor cosmetic edits to section 2.1.3 and a concept clarification to section 4.2.2.
      Author: David (sunfish62 at yahoo dot com)
      Input: Yawar Amin (yawar dot amin at gmail dot com) and Tom Bullock (tbullock at nd dot edu)
    • Bug #634075: Replace all usage of the term `druid' with `assistant' in the GnuCash Guide.
      Author: Mike E (mikee at saxicola dot idps dot co dot uk)
  • Translation updates
    • New and updated German version of guide document, by Juergen Hoewener.
  • New or improved content
    • guide: Explain concept behind What's New section
    • guide: Mention important changes in What's New section
    • guide: Mention platform support only for current stable version
    • guide: Change/remove references to old versions
    • New figure for Printing tab under Preferences.
    • Add Budgets and Other Assets chapters to the overview.
      Author: Tom Bullock (tbullock at nd dot edu)
    • Fix sequence of tenses grammar error
      Author: Tom Bullock (tbullock at nd dot edu)
    • Minor spelling and grammar fixes.
  • Internal, non-user visible changes
    • Add chapter getting-help to Makefile.
    • Separate getting-help chapter to validate getting-started xml file.
    • guide: Add entities for stable and unstable series
    • guide: Add single-quote entity definitions
    • Replace all usage of the words `GnuCash' or 'Gnucash' with the 'app' entity. Patch by Yawar Amin
    • Added <application> markup to GnuCash program name
    • Remove old file that collides with existing one in case-insensitive filesystems.
    • Delete guilabel tags below section titles with same wording (redundant).
      Delete note about debit and credit effects on asset accounts because it's
      effectively the same as note `More on Debits and Credits' at the end of Section 3.2.2 (Income and Expense Accounts).
      Replace GnuCash name with defined app entity.
      Use tip tags for tips.
      Use an xref tag for a reference.
    • GnuCash docs: merge revisions 19151,19307,19312-19313,19386,19455,19460,19472-19473,19479-19480,19482-19483 to 2.2 branch
    • guide: Remove 2.3+-specific info

About the Program

GnuCash is a free, open source accounting program released under the GNU General Public License (GPL) and available for GNU/Linux, *BSD, Solaris, Mac OSX and Microsoft Windows. Programming on GnuCash began in 1997, and its first stable release was in 1998.

by GnuCash Developers (gnucash-devel@gnucash.org) at July 02, 2011 05:00 AM

Announcement: GnuCash 2.4.7 Release

GnuCash 2.4.7 released

The GnuCash development team proudly announces GnuCash 2.4.7, the seventh bug fix release in a series of stable of the GnuCash Free Accounting Software. With this release series, GnuCash can use an SQL database using SQLite3, MySQL or PostgreSQL. It runs on GNU/Linux, *BSD, Solaris, Microsoft Windows and Mac OSX.

Getting GnuCash for Windows (Win32 binary)

The Gnucash 2.4.7 Win32 setup executable can be downloaded from Sourceforge. It will install everything needed to run GnuCash.

Mac OSX binary

The Gnucash 2.4.7 MacOSX package can be downloaded from Sourceforge as well.

Getting GnuCash as source code

If you want to compile GnuCash 2.4.7 for yourself, the source code can be downloaded from:

To compile GnuCash from the source code by yourself, you will need Gnome 2, guile, slib. In addition you will need swig if compiling from subversion.

Changes

Between 2.4.6 and 2.4.7, the following bugfixes were included:

  • [20804]Bug #653056: Fix menu accelerators not working, crash on save-while-quitting.
  • [20800] Bug #646541: new invoice line items default to invoice open date instead of current date This commit partially reverts the changes in r19134 so that customer invoices and employee vouchers default to the current date. Vendor bills still default to the invoice open date.
  • [20798] Fix report reload and options change that got broken by the previous commit.
  • [20796] Force custom url handlers to lowercase to deal with Webkit 1.4's case sensitivity. For more details, consult this Fedora bugreport: https://bugzilla.redhat.com/show_bug.cgi?id=712268
  • [20792] Bug #652257 - Memory leak in gnc-file.c Patch by Tim M
  • [20786] Bug #652435 - Fancy invoice export has <generic> tags in it preventing html validation Patch by Bert Claesen
  • [20785] Bug #652377 - XHTML 1.0 Transitional compliance for reports Patch by Tim M
  • [20784] Bug #632931 - Advanced Portfolio: new income column shows negative amount Patch by Sebastien Alborini
  • [20783] Bug #651889 - Using trading accounts, new non-expanded trading transaction shows inverted rates in exchange dialog When using trading accounts, the exchange rate dialog has a slightly different behavior. This patch fixes the behavior for transactions that are created in-line and are not expanded (single-line). It does not affect the expanded transactions or transactions created in the new transaction dialog. Patch by Mathieu De Zutter
  • [20782] Bug #651992 - Exported invoices do not render correctly in Firefox Patch by Bert Claesen
  • [20760]Bug #612562 - Transfer Funds dialog - 'Show Income/Expense' checkboxes are not working
  • [20750] Windows build: change default gtk theme to work around a number of problems in the Ms-Windows theme we used before. Particularly, this prevents the crash caused by bug #614636 and fixes the black notebook tabs that appeared after Phil upgraded webkit and many related gnome dependencies. The new default theme is "Nimbus" following a suggestion by Kim Wood on the mailing list.
  • [20746] Bug #652193 - Upcoming Scheduled Transactions Calendar Starting Month Error. Patch by Rich
  • [20745] Replace deprecated xml tag in chart of accounts templates

In 2.4.7, translations for Tamil language were updated, by AshokR from Transifex. See also https://www.transifex.net/projects/p/gnucash24/

About the Program

GnuCash is a free, open source accounting program released under the GNU General Public License (GPL) and available for GNU/Linux, *BSD, Solaris, Mac OSX and Microsoft Windows. Programming on GnuCash began in 1997, and its first stable release was in 1998.

by GnuCash Developers (gnucash-devel@gnucash.org) at July 02, 2011 05:00 AM

July 01, 2011

guile @ Savannah

GNU Guile 2.0.2 released

We are pleased to announce GNU Guile 2.0.2, the second maintenance release of the new 2.0.x stable series.

This release contains a few new features, optimizations, and bug fixes. More importantly, the `guile-tools' program has been renamed `guild'. "Its intended future use is for a CPAN-like system for Guile wizards and journeyfolk to band together to share code; hence the name", says Andy Wingo.

See the original announcement at http://lists.gnu.org/archive/html/guile-devel/2011-07/msg00017.html for details. Don't miss http://lists.gnu.org/archive/html/guile-devel/2011-06/msg00026.html for our plans to build the guildhall.

Join us now, share the software, and be a part of the guild!

by Ludovic Courtès at July 01, 2011 10:55 PM

Smalltalk development blog

Floating point to decimal conversion is not so easy

Russ Cox of Plan-9 and Go fame posted a blog entry titled Floating Point to Decimal Conversion is Easy. While he is usually right, I believe this time he isn't.

Floating point to decimal conversion is easy if you are okay with ugly results. A good conversion routine will print the shortest decimal representation of the floating-point number, that is, the shortest decimal number whose closest floating-point representation equals the original number. You do not want 0.30000000001, you want 0.3, because the number right above 0.3 is 0.30000000003 and 0.30000000001 does not provide any extra precision.

Otherwise, your users will complain. (And you need to make sure you got it right, otherwise they will complain even more).

Here is how GNU Smalltalk does it. I'm pretty sure it is correct, too.

Unlike the Go example in Russ Cox's article, GNU Smalltalk starts from an exact rational representation and relies on LargeIntegers. This is not a very efficient algorithm, but it is correct and optimal. Throughout the code, num will contain the error between the number to be printed (self, supposed positive) and the current partial representation (digits / weight; these variables are defined below.

       num := self asExactFraction.

The algorithm tracks the decimal representation of two adjacent floating point numbers, num and the immediately successive number:

       "Smallest number such that self + eps ~= eps"
       eps := 2 raisedToInteger: self exponent - self class precision + 1.

Note that eps is either an Integer, possibly large, or a Fraction. self exponent is the base-2 exponent of self, self class precision is the number of digits in the mantissa (53 for doubles).

The initial approximation is, well, 0. But the denominator, weight is computed from the beginning to be close to self:

       digits := 0.
       exponent := num floorLog: 10.
       weight := 10 raisedToInteger: exponent.

As we add digits to the approximation, the denominator will be reduced while remaining a power of 10. exponent and weight could be computed with a table or with binary search.

We run the decimal conversion until we find a different digit in num versus each of num - eps and num + eps. Along the way, we remember whether we found a digit that is not 9:

       allNines := true.
       sameDown := true.
       sameUp := true.

       [digit := num // weight.
       allNines := allNines and: [digit = 9].
       sameDown := sameDown and: [(num - eps) // weight = digit].
       sameUp := sameUp and: [(num + eps) // weight = digit].
       num := num - (digit * weight).
       prevWeight := weight.
       weight := weight / 10.
       sameDown or: [sameUp]] whileTrue.

Now we have a correct approximation, but perhaps not an optimal one. For simplicity, I'll accept a possible unoptimality in case of floating-point numbers that are integer and so big that num+0.5 cannot be represented exactly:

       eps isInteger ifTrue: [eps := eps / 2].

Without this line, round-to-even behavior of the decimal-to-binary conversion may cause bugs.

At this point num is the error that remains in the decimal representation. So, the error by tweaking the lowest significant digits in the decimal representation will be something like num - (NN * prevWeight) and num + (NN * prevWeight), respectively if you add or subtract NN from the lowest significant digit in the decimal representations.

adjust will contain what I wrote above as NN:

       adjust := 0.

The first improvement is to try rounding the last digit while not changing the meaning. Try rounding down:

       (digit <= 5 and: [num + (digit * prevWeight) < (eps / 2)])
           ifTrue: [adjust := digit negated].

so that e.g. 0.30000000001 will set adjust to -1 ("subtract 1", giving 0.3); and then up:

       (digit > 5 and: [num + ((digit - 10) * prevWeight) > (eps / -2)])
           ifTrue: [adjust := 10 - digit].

In this case 0.8999999996 will set adjust to 4 ("add 4", giving 0.9).

The second improvement is only done if the above didn't trigger. It tries adding 1, and see if that moves us closer to self. This is needed because digits are always found with //, which truncates the result rather than rounding it:

       (adjust = 0 and: [digit > 0]) ifTrue: [
           (num - prevWeight) abs < num ifTrue: [adjust := 1]].

The tweak is also skipped if the last digit is 0. In this case, the decimal representation we have may make the representation more precise but it would also make the result longer.

Now we can perform the adjustment (but be careful about moving the decimal point, if necessary, when rounding up!):

       digits := digits + adjust.
       (adjust > 0 and: [allNines])
           ifTrue: [allNines := false. exponent := exponent + 1].

Now we have converted self asExactFraction (a fraction from one whose denominator is a power of 2) to another fraction, whose denominator is a power of 10. digits is the numerator of this new fraction, while the denominator is 10exponent. Let's convert the numerator to a string in order to print it:

       digits := digits printString.

Keep the significant digits only, we convert it to a stream for easy iteration:

       precision := digits findLast: [:ch | ch ~= $0].
       digitStream := ReadStream 
                   on: digits
                   from: 1
                   to: precision.

GNU Smalltalk now chooses whether to print in exponential notation or not. For simplicity I will cover the exponential notation case only.

The destination stream at last comes into play; it's called aStream. Remember that we stripped all zeros above, so we'll handle it specially. First print the first character, which is the integer part:

       digitStream atEnd
           ifTrue: [aStream nextPut: $0].
           ifFalse: [aStream nextPut: digitStream next].

Then the decimal point and everything else:

       aStream nextPut: $..
       digitStream atEnd 
           ifTrue: [aStream nextPut: $0]
           ifFalse: [aStream nextPutAll: digitStream].

and finally the exponent letter:

       aStream
           nextPut: $e;
           print: exponent

That's it. It is not incredibly complex, but also not too optimized and full of off-by-one traps. So, good floating point to decimal conversion is not so easy!

by Paolo Bonzini at July 01, 2011 03:32 PM

June 30, 2011

FSF Events

John Sullivan at the GHGLUG in Hartford, CT

FSF executive director John Sullivan will be speaking about the FSF's work and philosophy at a meeting of the Greater Hartford GNU/Linux Users Group .

by johns at June 30, 2011 11:29 PM

GNU SRC Build Report

GNU SRC Build Report 2011-06-30-1404

This is the weekly build report for all packages in the GNU Source Release Collection.

There are 245 packages defined, 142 succeeded, 103 failed.

The build generated 836 errors, 10276 warnings.

Updated packages:

More details in the full build report. Please send patches to bug-gsrc@gnu.org.

by bug-gsrc@gnu.org at June 30, 2011 08:00 PM