[libgfortran,patch] Wide char part 4, library support
FX
fxcoudert@gmail.com
Fri May 9 07:32:00 GMT 2008
This patch provides a character(kind=4) version of the functions in
intrinsics/string_intrinsics.c, as well as a few needed definitions
in libgfortran.h. gfc_char4_t is the name of the 32-bit character
type in the library (it's simply a GFC_UINTEGER_4, which we already
assume to be available on all targets). I added a
GFC_SIZE_OF_CHAR_KIND macro which expands to the size in bytes of a
character variable of a given kind (which, for the two types we
support, actually is the kind itself).
The new functions are suffixed with "_char4" (as "_c4" is already
used for complex). To avoid breaking libgfortran's ABI, I have not
renamed the default character kind functions with "_char1", though it
could be done next time we break compatibility if it's deemed useful.
To avoid code duplication, all the code in intrinsics/
string_intrinsics.c has been put into intrinsics/
string_intrinsics_inc.c, and the (relatively few) things that depend
on the character kind have been macroized: the type itself (and the
corresponding unsigned type), the function suffixes, the function
that performs memset(); by the way, I added a helper function to
replace memset() for wide characters: it's called (you guessed)
memset_char4. Also, various sizes (those in malloc() and memcpy())
have been multiplied by the size of the character type (sizeof
(CHARTYPE)).
Apart from that, really not much. Oh, I've changed the code in one
place where we did:
- *dest = internal_malloc_size (*len);
- memmove (*dest, src, *len);
There's no need to memmove() on a freshly allocated address, so I
changed that to memcpy().
Of course, you now wonder why doing the library before the rest of
the front-end. Well, it so happens that I actually have done the
front-end bits too, so I now almost have a feature-complete widechar
gfortran (except I/O, for which I'll need Jerry's or Janne's help),
and I could test these intrinsics and they behave fairly well so far.
But, the front-end patch still has a few bugs, so I submit this
easier and self-contained patch while I fix the last bugs in the
front-end.
Bootstrapped and regtested on x86_64-linux, OK to commit?
FX
--
François-Xavier Coudert
http://www.homepages.ucl.ac.uk/~uccafco/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: wide_char_part4.ChangeLog
Type: application/octet-stream
Size: 752 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20080509/4da7dedb/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: wide_char_part4.diff
Type: application/octet-stream
Size: 21588 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20080509/4da7dedb/attachment-0001.obj>
More information about the Fortran
mailing list