summaryrefslogtreecommitdiffstats
path: root/src/util.c
Commit message (Collapse)AuthorAgeFilesLines
* Add JEMALLOC_FORMAT_PRINTF().Jason Evans2015-07-221-3/+3
| | | | | | Replace JEMALLOC_ATTR(format(printf, ...). with JEMALLOC_FORMAT_PRINTF(), so that configuration feature tests can omit the attribute if it would cause extraneous compilation warnings.
* Use the error code given to buferror on WindowsMike Hommey2015-03-131-1/+1
| | | | | | | | a14bce85 made buferror not take an error code, and make the Windows code path for buferror use GetLastError, while the alternative code paths used errno. Then 2a83ed02 made buferror take an error code again, and while it changed the non-Windows code paths to use that error code, the Windows code path was not changed accordingly.
* util.c: strerror_r returns char* only on glibcFelix Janda2015-02-031-1/+1
|
* Convert to uniform style: cond == false --> !condJason Evans2014-10-031-6/+6
|
* Fix -Wsometimes-uninitialized warningsChris Peterson2014-06-021-1/+3
|
* Fix -Wsign-compare warningsChris Peterson2014-06-021-2/+2
|
* Test and fix malloc_printf("%%").Jason Evans2014-01-221-7/+6
|
* Add util unit tests, and fix discovered bugs.Jason Evans2014-01-071-28/+36
| | | | | | | | | | | | | Add unit tests for pow2_ceil(), malloc_strtoumax(), and malloc_snprintf(). Fix numerous bugs in malloc_strotumax() error handling/reporting. These bugs could have caused application-visible issues for some seldom used (0X... and 0... prefixes) or malformed MALLOC_CONF or mallctl() argument strings, but otherwise they had no impact. Fix numerous bugs in malloc_snprintf(). These bugs were not exercised by existing malloc_*printf() calls, so they had no impact.
* Normalize #define whitespace.Jason Evans2013-12-091-1/+1
| | | | Consistently use a tab rather than a space following #define.
* Refactor tests.Jason Evans2013-12-091-3/+3
| | | | | | | Refactor tests to use explicit testing assertions, rather than diff'ing test output. This makes the test code a bit shorter, more explicitly encodes testing intent, and makes test failure diagnosis more straightforward.
* Prefer not_reached() over assert(false) where appropriate.Jason Evans2013-10-211-1/+1
|
* Remove unused variable and branch (reported by clang-analzyer)Corey Richardson2012-10-081-5/+0
|
* Allow je_malloc_message to be overridden when linking staticallyMike Hommey2012-05-021-4/+7
| | | | | | | | | | | | | If an application wants to override je_malloc_message, it is better to define the symbol locally than to change its value in main(), which might be too late for various reasons. Due to je_malloc_message being initialized in util.c, statically linking jemalloc with an application defining je_malloc_message fails due to "multiple definition of" the symbol. Defining it without a value (like je_malloc_conf) makes it more easily overridable.
* Make malloc_write() non-inline.Jason Evans2012-05-021-0/+11
| | | | | Make malloc_write() non-inline, in order to resolve its dependency on je_malloc_write().
* Replace JEMALLOC_ATTR with various different macros when it makes senseMike Hommey2012-05-011-4/+3
| | | | | | Theses newly added macros will be used to implement the equivalent under MSVC. Also, move the definitions to headers, where they make more sense, and for some, are even more useful there (e.g. malloc).
* Use Get/SetLastError on Win32Mike Hommey2012-04-301-7/+8
| | | | | | | | | Using errno on win32 doesn't quite work, because the value set in a shared library can't be read from e.g. an executable calling the function setting errno. At the same time, since buferror always uses errno/GetLastError, don't pass it.
* Remove leftovers from the vsnprintf check in malloc_vsnprintfMike Hommey2012-04-221-4/+0
| | | | | Commit 4eeb52f removed vsnprintf validation, but left a now unused va_copy. It so happens that MSVC doesn't support va_copy.
* Add support for MingwMike Hommey2012-04-221-1/+6
|
* Fix malloc_vsnprintf handling of %o, %u and %xMike Hommey2012-04-191-4/+16
| | | | | | These flags take unsigned values, but they were fed with signed values taken with va_arg, and that led to sign extension in cases where the corresponding value has the most significant bit set.
* Rename labels.Jason Evans2012-04-101-12/+12
| | | | | | | Rename labels from FOO to label_foo in order to avoid system macro definitions, in particular OUT and ERROR on mingw. Reported by Mike Hommey.
* Remove vsnprintf() and strtoumax() validation.Jason Evans2012-04-021-27/+0
| | | | | | | | | | Remove code that validates malloc_vsnprintf() and malloc_strtoumax() against their namesakes. The validation code has adequately served its usefulness at this point, and it isn't worth dealing with the different formatting for %p with glibc versus other implementations for NULL pointers ("(nil)" vs. "0x0"). Reported by Mike Hommey.
* Add a SYS_write definition on systems where it is not defined in headersMike Hommey2012-03-301-0/+10
| | | | | Namely, in the Android NDK headers, SYS_write is not defined; but __NR_write is.
* Port to FreeBSD.Jason Evans2012-02-031-9/+127
| | | | | | | | | | | | | | | | | | | | | | | | Use FreeBSD-specific functions (_pthread_mutex_init_calloc_cb(), _malloc_{pre,post}fork()) to avoid bootstrapping issues due to allocation in libc and libthr. Add malloc_strtoumax() and use it instead of strtoul(). Disable validation code in malloc_vsnprintf() and malloc_strtoumax() until jemalloc is initialized. This is necessary because locale initialization causes allocation for both vsnprintf() and strtoumax(). Force the lazy-lock feature on in order to avoid pthread_self(), because it causes allocation. Use syscall(SYS_write, ...) rather than write(...), because libthr wraps write() and causes allocation. Without this workaround, it would not be possible to print error messages in malloc_conf_init() without substantially reworking bootstrapping. Fix choose_arena_hard() to look at how many threads are assigned to the candidate choice, rather than checking whether the arena is uninitialized. This bug potentially caused more arenas to be initialized than necessary.
* Add JEMALLOC_CC_SILENCE_INIT().Jason Evans2012-03-231-4/+4
| | | | | Add JEMALLOC_CC_SILENCE_INIT(), which provides succinct syntax for initializing a variable to avoid a spurious compiler warning.
* Implement tsd.Jason Evans2012-03-231-26/+7
| | | | | | | | | | | | | Implement tsd, which is a TLS/TSD abstraction that uses one or both internally. Modify bootstrapping such that no tsd's are utilized until allocation is safe. Remove malloc_[v]tprintf(), and use malloc_snprintf() instead. Fix %p argument size handling in malloc_vsnprintf(). Fix a long-standing statistics-related bug in the "thread.arena" mallctl that could cause crashes due to linked list corruption.
* Modify malloc_vsnprintf() validation code.Jason Evans2012-03-131-4/+3
| | | | | | Modify malloc_vsnprintf() validation code to verify that output is identical to vsnprintf() output, even if both outputs are truncated due to buffer exhaustion.
* Remove extra '}'.Jason Evans2012-03-121-1/+0
|
* Implement malloc_vsnprintf().Jason Evans2012-03-081-0/+539
Implement malloc_vsnprintf() (a subset of vsnprintf(3)) as well as several other printing functions based on it, so that formatted printing can be relied upon without concern for inducing a dependency on floating point runtime support. Replace malloc_write() calls with malloc_*printf() where doing so simplifies the code. Add name mangling for library-private symbols in the data and BSS sections. Adjust CONF_HANDLE_*() macros in malloc_conf_init() to expose all opt_* variable use to cpp so that proper mangling occurs.