Document: N1288
Date: 2008/03/12
Author: Franklin

As I understand it, there has been an attempt to add the concept of tasks or threads to ANSI C++ (and perhaps ANSI C also).

 

This being the case, I would like to have an operating system independent way to declare my task-local storage.  I am indifferent to whether the keyword is “task” or “thread” or something else entirely, but what I really want to be able to do is to say something like:

 
  task uint32_t errno;         // errno is at offset 0 in the task local storage

Why?  Numerous reasons:

  1. I want the math functions in my ANSI C and ANSI C++ libraries to be leaf functions to make the code both smaller and faster.  At the moment, many of them are NOT leaf functions, but solely because of errno – and since we target many different operating systems, I do not have a standard way to do what I want, so I must make reading and writing errno be a function call.
  2. I can declare static storage (locally named and persistent), extern storage (globally named and persistent), automatic storage (locally named and existing for the life of the function it is named in).  But I have no STANDARD way to declare per-task variables.
  3.  
       

Now of course there are problems.   Sometimes the EABI does not provide a defined way to allocate per-task storage.  Well, they never will unless the Standard Committees require them to find a way.  Same for Operating Systems.  But since the intent is clear, the use is clear, and the need is there, why not take the small step that will make it possible for everyone downstream to do the right thing?

 

Oh, and I know about locks, semaphores, and atomic operations.  That’s a different topic than being able to name and allocate task-local storage.