tsp-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Tsp-devel] New bb_ctl API, bb variable naming scheme


From: Frederik Deweerdt
Subject: [Tsp-devel] New bb_ctl API, bb variable naming scheme
Date: Thu, 1 Mar 2007 20:59:47 +0100

Hi,

While developing a BB code generator (that takes an XML as input
and creates the corresponding C structures and BB creation/publication
calls[1]), I stumbled upon an annoying limitation of the BB: the variable
names are limited to 150 characters[2].
Increasing the size of the "name" field was not a satisfactory solution
however, as that would make that particular BB lib/bin combination
incompatible with other BBs.
To work around this, I've introduced the following APIs:

/* multi-purpose BB controlling function */
int bb_ctl(S_BB_T *bb, int request, ...);
/* gets the name of the variable described by desc */
char *bb_get_varname(S_BB_DATADESCT_T *desc);
/* sets the name of the variable described by desc */
int bb_set_varname(S_BB_DATADESCT_T *desc, char *name);
/* returns the max length a name can have under the current scheme */
int bb_varname_max_len(S_BB_DATADESCT_T *desc);

The default implementation for these functions just works as the old code
did (with the notable exception that the result of bb_get_varname()
must now be freed), so by default, we still work with 150 characters
max for the BB's variable names.

bb_ctl may be used for other extensions, but in this particular case,
it can be used as follows:
bb_ctl(bb, BB_CTL_SET_NAMING_IN_BB, "sarray");
This will cause libbb to look for symbols named
bb_get_varname_sarray, bb_set_varname_sarray and
bb_varname_max_len_sarray. If it fails, it will try to load a libsarray.so
library, and retry to load the symbols. If this fails again, the default naming
scheme is kept, and a BB_NOK is returned.

If this succeeds, which will be the common case hopefully, the
bb_get_varname, bb_set_varname and bb_varname_max_len symbols will
be replaced by the new ones. Thus causing the BB to adopt a new name
storage scheme.
With the sarray scheme, now available in the CVS, the name resolution
works as follows (this is simplified, of course):

bb_read(name)
       -> bb_get_varname(name)
               -> bb_get_varname_sarray(name)
                       -> converts the name parameter
                       to a key and gets the name in
                       a char[1024] shared memory place.

You cannot change the naming in the middle of the life of the BB, the
bb_ctl call
must be done /before/ publishing any data.

Also, a new structure has been added to the BB which now looks like this:

-----------------
| BB descriptor |
-----------------
| DATA desc     |
| DATA desc     |
| DATA desc     |
| ....          |
-----------------
| naming sheme  | <-- default if NULL, "sarray" in our example
| ....          |
-----------------

The new structure at the bottom is 4096 bytes wide, and can be used for
further BB extensions.
As the naming scheme is stored in the BB, a bb_tools client doesn't need
to be explicitly told which scheme to use. bb_attach will check that
for him, and load the necessary libraries if needed
The code is backward compatible, as it doesn't look for this area if the
version of the BB is too old.
Any thoughts?

Fred

[1] See http://www.mail-archive.com/address@hidden/msg00654.html
for more details
[2] See http://www.mail-archive.com/address@hidden/msg00631.html
for more details




reply via email to

[Prev in Thread] Current Thread [Next in Thread]