C2L(10.1) C2L(10.1)
NAME
c2l - C to limbo translator
SYNOPSIS
c2l [ option ... ] file
DESCRIPTION
c2l translates the named C file into limbo. The translated
code should be almost always syntactically correct but will
certainly never be semantically correct as certain con-
structs in C (strings for example) are almost impossible to
convert automatically into limbo. Otherwise it tries to do
a good job of translating the C constructs that have some
sort of equivalence in limbo. The C ? and : operators are
replaced where possible. C library calls are mapped to
calls to the limbo system module, maths module or the pro-
vided limbo libc modules. Some library calls, such as mal-
loc, are instead mapped directly into limbo wherever possi-
ble.
Once a translation has been made, running the limbo(1) com-
piler on the resulting output should pick out the areas
where hand editing is required.
c2l normally puts all mapped C code (plus that from included
files) into a single .b file.
The options to c2l are:
-p Use an ANSI preprocessor in place of the internal one.
-Dname=def
-Dname
Define the name to the preprocessor, as if by
`#define'. If no definition is given, the name is
defined as `1'.
-Idir
An `#include' file whose name does not begin with slash
or is enclosed in double quotes is always sought first
in the directory of the file argument. If this fails,
or the name is enclosed in <>, it is then sought in
directories named in -I options, then in /sys/include,
and finally in /$objtype/include.
-m Put the mapped code of any included .h files into it's
corresponding .m file instead of the .b file.
-i Send the mapped code of any included .h files to
/dev/null.
Page 1 Plan 9 (printed 10/26/25)
C2L(10.1) C2L(10.1)
-l Send the mapped code of any non-local included .h files
to /dev/null.
-v Outputs any warnings to standard error as well as put-
ting them in the output source.
-s Map C strings to nul terminated arrays of bytes in
limbo. This just about preserves the semantics of
strings and makes the process of hand editing much eas-
ier. It's useful as a first attempt at translation. In
this case the module /module/libc0.m is used in place
of the standard one /module/libc.m.
-S Map char* in C to string in limbo. Incompatible with
the -s option.
-M Indicates this file is the one with the C main program
in. Used with the -q option below when c2l does not
always know this until it's too late.
-q This reduces the number of passes that c2l makes over
the C code. It makes it faster but more liable to miss
some transformations. Cyclic data structures may not be
detected.
C2l runs the preprocessor on the C code before starting
translation. As a special case it will convert definitions
of constants into limbo constant declarations. It makes no
attempt to convert any definitions into function declara-
tions.
Identifier names that clash with limbo keywords have x
appended so, for example, a structure member called type
would become typex.
Warning messages preceded by the acronym TBA (to be
addressed) are issued for nul bytes in strings, function
pointers, ... as an argument, array indices in declarations,
use of void type, use of unions, bit fields, use of address
operator, negative array indices, element specifiers, ini-
tial values in limbo modules, labels, gotos and case state-
ment fall through.
The C types char and unsigned char are mapped to the limbo
byte type. The C types short, unsigned short, int, unsigned
int, long and unsigned long are mapped to the limbo int
type. The C types long long and unsigned long long are
mapped to the limbo big type. Finally the C types float and
double are mapped to the limbo real type.
Anonymous C structures and unions map to a name of the form
<module>_adt_<num> where module is the name of the module
Page 2 Plan 9 (printed 10/26/25)
C2L(10.1) C2L(10.1)
which is, in turn, derived from the file name. Anonymous
member names in strucures and unions have a name of the form
anon_<num>. Finally temporary variables generated by c2l
have a name of the form tmp_<num>. In all cases <num> is a
unique identifier.
SOURCE
/module/libc.m
/module/libc0.m
/appl/lib/libc.b
/appl/lib/libc0.b
Page 3 Plan 9 (printed 10/26/25)