Commit Graph

95 Commits

Author SHA1 Message Date
christos b4744953f9 Hook for jemalloc 2019-03-04 17:30:33 +00:00
snj 9d37d7200a add strfmon_l man page links 2018-01-05 20:51:13 +00:00
joerg e5678be828 Implement __cxa_thread_atexit and __cxa_thread_atexit_impl. This
functions are used for destructors of thread_local objects.

If a pending destructor exists, prevent unloading of shared objects.
Introduce __dl_cxa_refcount interface for this purpose. When the last
reference is gone and the object has been dlclose'd before, the
unloading is finalized.

Ideally, __cxa_thread_atexit_impl wouldn't exist, but libstdc++ insists
on providing __cxa_thread_atexit as direct wrapper without further
patching.
2017-07-11 15:21:31 +00:00
msaitoh 43e79b977e Add malloc.conf.5 (link to jemalloc.3). 2016-04-01 12:37:48 +00:00
nros b16a5c9dec Add the C11 function aligned_alloc to libc. 2015-11-07 16:21:42 +00:00
christos 35d355f3ea - new test for strtoi
- namespace protection for strto{i,u}
- separate manpages for strto{i,u} from the ones for strto{u,}l
From: Kamil Rytarowski
2015-05-01 14:17:56 +00:00
joerg c9baa5968d Introduce reallocarr(3) for easy (re)allocation of memory with overflow
checks. Compared to OpenBSD's reallocarray, makes it easier to avoid memory
leaks on allocation failures and it doesn't depend on malloc(0) != NULL
for correct error checking. Compared to plain realloc, it also avoids
the problem of intermediate integer overflows. The trade-off is the use
of void * to side step C type system with regard to generic pointer to
pointer.
2015-02-17 20:29:20 +00:00
christos 7347edd333 Revert addition to reallocarray to the malloc man page, but keep
the examples.  Add separate manual page to reallocarray explaining
what are the problems with it.
2015-02-05 20:02:28 +00:00
christos a582ce5979 Add and use reallocarray() to prevent a multiplication overflow in allocation.
Reported by Guido Vranken, thanks!
2015-02-05 16:04:35 +00:00
christos 566fb07644 man page for strtonum.3 2015-01-18 17:59:36 +00:00
christos 40195068d4 Add strtonum implemented as a wrapper of strtoi. 2015-01-16 18:41:33 +00:00
christos fbb651a269 strtoi and strtou additions 2015-01-16 18:37:21 +00:00
pooka dc3c2e9560 Add two more Makefile conditionals required for RUMPRUN=yes
* do not build _errno.c (different thread/tls handling)
 * do not build either phk- or jemalloc (different backing page allocation)

Somehow I missed these in the previous commit, but now libc built with
RUMPRUN=yes works also with rumprun-posix, so there's reasonably high
confidence that I didn't miss anything anymore.
2014-12-10 16:55:54 +00:00
christos 842ee049dd Our hdestroy implementation was non-conformant because it freed the key of
each entry. Add a new function hdestroy1 that allows the user to control
what gets freed. Pointed out by Pedro Giffuni at FreeBSD.
2014-07-20 13:34:17 +00:00
christos eabc0dd171 add ptsname_r 2014-01-08 02:15:42 +00:00
lneto c4a02e0a12 changed lua_Number to int64_t 2013-12-02 04:39:10 +00:00
christos f5c1f2146c add {at_,}quick_exit(3) from FreeBSD 2013-04-26 18:29:55 +00:00
christos 05845f985a add re-entrant versions of the hash functions based on the GNU api. 2011-09-14 23:33:51 +00:00
jruoho b29fd93227 Collect also the division functions to single place, div(3). 2011-04-13 07:12:52 +00:00
jruoho 19606f522d Collect abs(3), labs(3), llabs(3), and imaxabs(3) to a single small page. 2011-04-13 06:56:50 +00:00
tron fbf4aa1699 Improve and simplify implementation of *env(3) functions:
- Use RB tree to keep track of memory allocated via setenv(3) as
  suggested by Enami Tsugutomo in private e-mail.
  This simplifies the code a lot as we no longer need to keep the size
  of "environ" in sync with an array of allocated environment variables.
  It also makes it possible to free environment variables in unsetenv(3)
  if something has changed the order of the "environ" array.
- Fix a bug in getenv(3) and getenv_r(3) which would return bogus
  results e.g. for " getenv("A=B") " if an environment variable "A"
  with value "B=C" exists.
- Clean up the internal functions:
  - Don't expose the read/write lock for the environment to other parts
    of "libc". Provide locking functions instead.
  - Use "bool" to report success or failure.
  - Use "ssize_t" or "size_t" instead of "int" for indexes.
  - Provide internal functions with simpler interfaces e.g. don't
    combine return values and reference arguments.
  - Don't copy "environ" into an allocated block unless we really need
    to grow it.

Code reviewed by Joerg Sonnenberger and Christos Zoulas, tested by
Joerg Sonnenberger and me. These changes also fix problems in
zsh 4.3.* and pam_ssh according to Joerg.
2010-11-14 18:11:42 +00:00
jruoho 26e9ae259a Split the implementation details of malloc(3) to a separate jemalloc(3)
manual page. This way malloc(3) can follow the standard terse format used
elsewhere in the libc, while additional details can be added to jemalloc(3).

Note HISTORY and AUTHORS in jemalloc(3), and add some reading material to
SEE ALSO.
2010-05-03 05:01:53 +00:00
dsl 10ad5ffa71 Add the 'abs', 'div' and 'erand48' sources to stdlib/Makefile.inc.
Change the arch files only include the .S files.
This adds imaxdiv() to some archs where it was missing.
2009-07-31 20:39:59 +00:00
joerg d6e219476b Add a fast, platform independent hash function to libc.
The algorithm used is the Jenkins hash.  The name (mi_vector_hash)
reflects the nature of the hash function.
Add glue for libc ATF tests and include a test case to make sure that
(mis)alignment and endianess are handled correctly.

Bump libc minor to 169.
2009-07-20 17:03:36 +00:00
mrg 2f0d0e12bf define and use LIBCDIR in terms of .CURDIR. fixes compat/lib/libc build. 2008-10-26 07:43:07 +00:00
joerg 245e086321 Unify the implementation of strto{l,ul,ll,ull,imax,umax,q,uq} into one
version for signed and one version for unsigned data types.

Add a check for supported bases and set errno (userland) or panic
(kernel, libsa) otherwise.

Make strto{ll,ull,imax,umax} normal symbols and just keep the underscore
versions as strong alias.

Obtained from DragonFly, based on the wide char version from Citrus.
Reviewed by christos@
2008-08-20 12:42:26 +00:00
matt cac8e44915 Add C99 functions imaxabs and imaxdiv. 2008-08-04 21:29:27 +00:00
christos f6cecc05cf Sync phk malloc.c with the latest one from FreeBSD. This gives us the
same api as jemalloc by:

    - adding posix_memalign()
    - moving calloc in the same file
    - renaming malloc_options -> _malloc_options
2007-11-28 21:55:14 +00:00
ad 95182011ed Enable posix_memalign(). 2007-11-19 14:48:41 +00:00
ad 9b64888c5d Use jemalloc as the default allocator unless USE_JEMALLOC=no. 2007-10-06 01:09:07 +00:00
drochner f81322cf18 build erand48_ieee754.c on everything but vax 2006-03-22 22:03:58 +00:00
kleink bc89c06cbf Add strtof(3) and strtold(3); welcome libc 12.137. 2006-03-15 17:35:17 +00:00
kleink 3cd8501c1e Drop in gdtoa as a replacement for dtoa, strtod() from stdlib/strtod.c. 2006-01-25 15:43:01 +00:00
christos 6eaa70365b Kill _Exit; breaks build on cygwin and this implementation "is not exactly
equivalent to calling _exit".
2006-01-20 22:02:07 +00:00
christos cc85a7cfd9 add getenv_r and ttyname_r 2005-09-25 20:08:01 +00:00
christos 5b84b3983f compat core reorg. 2005-09-13 01:44:08 +00:00
drochner e866f2794b Move insque/remque/lsearch/lfind from libcompat to libc,
they are in XPG4-UNIX, XSH5.0, mentioned in SUSv3 etc.
Minimal update of the manpages. (more needed)
2005-07-06 14:43:24 +00:00
christos ada3b096d0 Add FreeBSD's strfmon(3). From Rui Paulo. No bump this time. Take advantage
of the getpwent_r bump.
2005-04-03 20:09:29 +00:00
yamt 91ee88d04d actually add _Exit. 2004-08-05 00:17:02 +00:00
christos 892ad9caae unix/98 pty functions and manual pages. 2004-05-27 02:58:48 +00:00
kleink aa92e94d2a Observed in other places: move __unsetenv13.c near unsetenv.c, only
group name space wrappers separately.
2003-04-07 17:18:20 +00:00
drochner 22b67837d4 compile unsetenv(3) into libc or you'll mess up your system 2003-04-07 16:22:43 +00:00
lukem 6ca5b5bb68 add strsuftoll(3) and strsuftollx(3) - parse a string for a number
with an optional suffix, product (two numbers separated by `x'), and
provide range checking
2002-11-29 12:58:14 +00:00
kleink fe3c9ceaf7 * Move definitions of exact-width integer types from <machine/types.h>
to <sys/types.h> and <sys/stdint.h>.
* Add a new C99 <stdint.h> header, which provides integer types of
  explicit width, related limits and integer constant macros.
* Extend <inttypes.h> to provide <stdint.h> definitions and format
  macros for printf() and scanf().
* Add C99 strtoimax() and strtoumax() functions.
* Use the latter within scanf().
* Add C99 %j, %t and %z printf()/scanf() conversions for
  intmax_t, pointer-type and size_t arguments.
2001-04-28 15:41:28 +00:00
msaitoh 36db62c9dc add hcreate.3 2001-02-16 12:25:09 +00:00
cgd 579369d368 build new hsearch() code 2001-02-14 05:44:29 +00:00
lukem b8d674b457 link sradixsort(3) -> radixsort(3) 2001-01-08 14:06:09 +00:00
itojun 408f4697a6 first import of citrus LC_CTYPE locale. singlebyte only at this moment.
shot-term TODO:
- enable multibyte locales.  this includes loadable locale modules
  (#ifdef DLRUNE).
- populate LC_CTYPE definition files.
- other functions such as iconv()
- make libc functions more friendly with multibyte.
- multilingualize other LC_xx
- torture tests

XXX don't forget to "make depend" when you rebuild libc, multibyte.c is
moved from lib/libc/stdlib to lib/libc/locale.
2000-12-21 11:29:47 +00:00
christos 6dfafca13a New getopt_long from Thomas Klausner and Dieter Baron 2000-04-02 20:27:58 +00:00
kleink 31f60ab101 No longer need internal names for strtoq() and strtouq(). 2000-03-08 20:17:19 +00:00