Replace COSMO define with _COSMO_SOURCE

This change might cause ABI breakages for /opt/cosmos. It's needed to
help us better conform to header declaration practices.
This commit is contained in:
Justine Tunney 2023-08-13 20:31:27 -07:00
parent a033b65a33
commit c776a32f75
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
238 changed files with 858 additions and 1069 deletions

View file

@ -1297,29 +1297,6 @@ void* dlmemalign(size_t alignment, size_t bytes) {
return internal_memalign(gm, alignment, bytes);
}
int dlposix_memalign(void** pp, size_t alignment, size_t bytes) {
void* mem = 0;
if (alignment == MALLOC_ALIGNMENT)
mem = dlmalloc(bytes);
else {
size_t d = alignment / sizeof(void*);
size_t r = alignment % sizeof(void*);
if (r != 0 || d == 0 || (d & (d-SIZE_T_ONE)) != 0)
return EINVAL;
else if (bytes <= MAX_REQUEST - alignment) {
if (alignment < MIN_CHUNK_SIZE)
alignment = MIN_CHUNK_SIZE;
mem = internal_memalign(gm, alignment, bytes);
}
}
if (!mem) {
return ENOMEM;
} else {
*pp = mem;
return 0;
}
}
#if USE_LOCKS
void dlmalloc_atfork(void) {
bzero(&gm->mutex, sizeof(gm->mutex));

View file

@ -1,5 +1,30 @@
#ifndef COSMOPOLITAN_THIRD_PARTY_DLMALLOC_DLMALLOC_H_
#define COSMOPOLITAN_THIRD_PARTY_DLMALLOC_DLMALLOC_H_
#define dlbulk_free __dlbulk_free
#define dlcalloc __dlcalloc
#define dlfree __dlfree
#define dlindependent_calloc __dlindependent_calloc
#define dlindependent_comalloc __dlindependent_comalloc
#define dlmallinfo __dlmallinfo
#define dlmalloc __dlmalloc
#define dlmalloc_abort __dlmalloc_abort
#define dlmalloc_atfork __dlmalloc_atfork
#define dlmalloc_footprint __dlmalloc_footprint
#define dlmalloc_footprint_limit __dlmalloc_footprint_limit
#define dlmalloc_inspect_all __dlmalloc_inspect_all
#define dlmalloc_max_footprint __dlmalloc_max_footprint
#define dlmalloc_set_footprint_limit __dlmalloc_set_footprint_limit
#define dlmalloc_stats __dlmalloc_stats
#define dlmalloc_trim __dlmalloc_trim
#define dlmalloc_usable_size __dlmalloc_usable_size
#define dlmallopt __dlmallopt
#define dlmallopt __dlmallopt
#define dlmemalign __dlmemalign
#define dlrealloc __dlrealloc
#define dlrealloc_in_place __dlrealloc_in_place
#define dlrealloc_in_place __dlrealloc_in_place
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
@ -88,16 +113,6 @@ void* dlrealloc_in_place(void*, size_t);
*/
void* dlmemalign(size_t, size_t);
/*
int posix_memalign(void** pp, size_t alignment, size_t n);
Allocates a chunk of n bytes, aligned in accord with the alignment
argument. Differs from memalign only in that it (1) assigns the
allocated memory to *pp rather than returning it, (2) fails and
returns EINVAL if the alignment is not a power of two (3) fails and
returns ENOMEM if memory cannot be allocated.
*/
int dlposix_memalign(void**, size_t, size_t);
/*
mallopt(int parameter_number, int parameter_value)
Sets tunable parameters The format is to provide a

View file

@ -21,6 +21,7 @@
#include "libc/log/log.h"
#include "libc/runtime/runtime.h"
#include "libc/str/str.h"
#include "third_party/dlmalloc/dlmalloc.h"
#define MESSAGE "dlmalloc_abort()\n"