lua-users home
lua-l archive

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

> For the record, here are the libc functions that the Lua core uses:
> setjmp		frexp		pow		strcpy		time
> abort		localeconv	snprintf	strlen
> abs		longjmp		strchr		strpbrk
> floor		memcmp		strcmp		strspn
> fmod		memcpy		strcoll		strtod

Also for the record, I have done a small "guide" about how to avoid
(or not) the above functions in the core.

* The following functions are easy to implement in ISO C:

- abs
- memcmp
- memcpy
- strchr
- strcmp
- strcoll   (can be replaced by strcmp if we ignore locales)
- strcpy
- strlen
- strpbrk
- strspn

* The following functions can be replaced by something else through macros:

- fmod (used only in 'luai_nummod' for the '%' operator)
- frexp (used only in 'l_hashfloat' to produce a hash for a floating-point
  for the hashing of strings)
- localeconv (used only in 'lua_getlocaledecpoint', which could evaluate
  always to some fixed decimal point)
- pow (used only in 'luai_numpow' for the '^' operator)
- time (used only in 'luai_makeseed' to produce an initial "random" seed

* The following functions probably can be implemented in assembler:

- abort
- longjmp/setjmp (essential!)

* The following functions should be provided somehow (and may be
difficult to implement correctly):

- floor
- snprintf: used in very controlled ways, with exactly one format
  item in each use; the kernel needs '%p' (easy), '%d' (easy), and
  '%g' (not trivial)
- strtod

-- Roberto