mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-19 00:50:30 +00:00
Make improvements
- This change fixes a bug that allowed unbuffered printf() output (to streams like stderr) to be truncated. This regression was introduced some time between now and the last release. - POSIX specifies all functions as thread safe by default. This change works towards cleaning up our use of the @threadsafe / @threadunsafe documentation annotations to reflect that. The goal is (1) to use @threadunsafe to document functions which POSIX say needn't be thread safe, and (2) use @threadsafe to document functions that we chose to implement as thread safe even though POSIX didn't mandate it. - Tidy up the clock_gettime() implementation. We're now trying out a cleaner approach to system call support that aims to maintain the Linux errno convention as long as possible. This also fixes bugs that existed previously, where the vDSO errno wasn't being translated properly. The gettimeofday() system call is now a wrapper for clock_gettime(), which reduces bloat in apps that use both. - The recently-introduced improvements to the execute bit on Windows has had bugs fixed. access(X_OK) on a directory on Windows now succeeds. fstat() will now perform the MZ/#! ReadFile() operation correctly. - Windows.h is no longer included in libc/isystem/, because it confused PCRE's build system into thinking Cosmopolitan is a WIN32 platform. Cosmo's Windows.h polyfill was never even really that good, since it only defines a subset of the subset of WIN32 APIs that Cosmo defines. - The setlongerjmp() / longerjmp() APIs are removed. While they're nice APIs that are superior to the standardized setjmp / longjmp functions, they weren't superior enough to not be dead code in the monorepo. If you use these APIs, please file an issue and they'll be restored. - The .com appending magic has now been removed from APE Loader.
This commit is contained in:
parent
b99512ac58
commit
ff77f2a6af
226 changed files with 708 additions and 2657 deletions
|
@ -27,7 +27,6 @@
|
|||
* @return memory address, or NULL w/ errno
|
||||
* @throw EINVAL if !IS2POW(a)
|
||||
* @see pvalloc()
|
||||
* @threadsafe
|
||||
*/
|
||||
void *aligned_alloc(size_t a, size_t n) {
|
||||
if (IS2POW(a)) {
|
||||
|
|
|
@ -30,7 +30,6 @@ void *(*hook_calloc)(size_t, size_t) = dlcalloc;
|
|||
* @return rax is memory address, or NULL w/ errno
|
||||
* @note overreliance on memalign is a sure way to fragment space
|
||||
* @see dlcalloc()
|
||||
* @threadsafe
|
||||
*/
|
||||
void *calloc(size_t n, size_t itemsize) {
|
||||
return hook_calloc(n, itemsize);
|
||||
|
|
|
@ -31,7 +31,6 @@ void (*hook_free)(void *) = dlfree;
|
|||
*
|
||||
* @param p is allocation address, which may be NULL
|
||||
* @see dlfree()
|
||||
* @threadsafe
|
||||
*/
|
||||
void free(void *p) {
|
||||
hook_free(p);
|
||||
|
|
|
@ -115,7 +115,6 @@ void __defer(void *rbp, void *fn, void *arg) {
|
|||
* @warning do not realloc() with gc()'d pointer
|
||||
* @warning be careful about static keyword due to impact of inlining
|
||||
* @note you should use -fno-omit-frame-pointer
|
||||
* @threadsafe
|
||||
*/
|
||||
void *(_gc)(void *thing) {
|
||||
struct StackFrame *frame;
|
||||
|
@ -135,7 +134,6 @@ void *(_gc)(void *thing) {
|
|||
* @warning do not realloc() with gc()'d pointer
|
||||
* @warning be careful about static keyword due to impact of inlining
|
||||
* @note you should use -fno-omit-frame-pointer
|
||||
* @threadsafe
|
||||
*/
|
||||
void *(_defer)(void *fn, void *arg) {
|
||||
struct StackFrame *frame;
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
* that'll be returned.
|
||||
*
|
||||
* @return pointer that must be free()'d, or NULL w/ errno
|
||||
* @threadsafe
|
||||
*/
|
||||
char *get_current_dir_name(void) {
|
||||
const char *p;
|
||||
|
|
|
@ -36,7 +36,6 @@ void *(*hook_realloc_in_place)(void *, size_t) = dlrealloc_in_place;
|
|||
* @param n is number of bytes needed
|
||||
* @return rax is result, or NULL w/ errno
|
||||
* @see dlrealloc_in_place()
|
||||
* @threadsafe
|
||||
*/
|
||||
void *realloc_in_place(void *p, size_t n) {
|
||||
return hook_realloc_in_place(p, n);
|
||||
|
|
|
@ -41,7 +41,6 @@ void *(*hook_malloc)(size_t) = dlmalloc;
|
|||
*
|
||||
* @param rdi is number of bytes needed, coerced to 1+
|
||||
* @return new memory, or NULL w/ errno
|
||||
* @threadsafe
|
||||
*/
|
||||
void *malloc(size_t n) {
|
||||
return hook_malloc(n);
|
||||
|
|
|
@ -39,7 +39,6 @@ size_t (*hook_malloc_usable_size)(void *) = dlmalloc_usable_size;
|
|||
* @param p is address of allocation
|
||||
* @return total number of bytes
|
||||
* @see dlmalloc_usable_size()
|
||||
* @threadsafe
|
||||
*/
|
||||
size_t malloc_usable_size(void *p) {
|
||||
return hook_malloc_usable_size(p);
|
||||
|
|
|
@ -34,7 +34,6 @@ void *(*hook_memalign)(size_t, size_t) = dlmemalign;
|
|||
* @param bytes is number of bytes needed, coerced to 1+
|
||||
* @return rax is memory address, or NULL w/ errno
|
||||
* @see valloc(), pvalloc()
|
||||
* @threadsafe
|
||||
*/
|
||||
void *memalign(size_t align, size_t bytes) {
|
||||
return hook_memalign(align, bytes);
|
||||
|
|
|
@ -36,7 +36,6 @@
|
|||
* @return return 0 or EINVAL or ENOMEM w/o setting errno
|
||||
* @see memalign()
|
||||
* @returnserrno
|
||||
* @threadsafe
|
||||
*/
|
||||
errno_t posix_memalign(void **pp, size_t alignment, size_t bytes) {
|
||||
int e;
|
||||
|
|
|
@ -29,7 +29,6 @@
|
|||
* @param n number of bytes needed
|
||||
* @return memory address, or NULL w/ errno
|
||||
* @see valloc()
|
||||
* @threadsafe
|
||||
*/
|
||||
void *pvalloc(size_t n) {
|
||||
if (ckd_add(&n, n, FRAMESIZE - 1)) {
|
||||
|
|
|
@ -59,7 +59,6 @@ void *(*hook_realloc)(void *, size_t) = dlrealloc;
|
|||
* @param n is number of bytes needed
|
||||
* @return rax is result, or NULL w/ errno w/o free(p)
|
||||
* @see dlrealloc()
|
||||
* @threadsafe
|
||||
*/
|
||||
void *realloc(void *p, size_t n) {
|
||||
return hook_realloc(p, n);
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
* @param ptr may be NULL for malloc() behavior
|
||||
* @param nmemb may be 0 for free() behavior; shrinking is promised too
|
||||
* @return new address or NULL w/ errno and ptr is NOT free()'d
|
||||
* @threadsafe
|
||||
*/
|
||||
void *reallocarray(void *ptr, size_t nmemb, size_t itemsize) {
|
||||
size_t n;
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
* @param s is a NUL-terminated byte string
|
||||
* @return new string or NULL w/ errno
|
||||
* @error ENOMEM
|
||||
* @threadsafe
|
||||
*/
|
||||
char *strdup(const char *s) {
|
||||
size_t len = strlen(s);
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
* @param n if less than strlen(s) will truncate the string
|
||||
* @return new string or NULL w/ errno
|
||||
* @error ENOMEM
|
||||
* @threadsafe
|
||||
*/
|
||||
char *strndup(const char *s, size_t n) {
|
||||
char *s2;
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
* @param n number of bytes needed
|
||||
* @return memory address, or NULL w/ errno
|
||||
* @see pvalloc()
|
||||
* @threadsafe
|
||||
*/
|
||||
void *valloc(size_t n) {
|
||||
return memalign(FRAMESIZE, n);
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
|
||||
/**
|
||||
* Allocates copy of wide string.
|
||||
* @threadsafe
|
||||
*/
|
||||
wchar_t *wcsdup(const wchar_t *s) {
|
||||
size_t len = wcslen(s);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue