51f88950eb
Copied the changes which introduced ENOTSUP to <errno.h> and the related strerror_r() function.
2025-07-08 14:27:43 +02:00
f9d1222bd7
Fix for wrong address alignment rounding
...
The original V39/V40 amiga.lib puddle creation code did not round up, it rounded off.
2023-10-11 09:15:28 +02:00
d37909e409
Documented why bypassing the read/write buffer is only attempted if there is at least a full buffer worth of data to be read or written.
2023-09-14 09:52:21 +02:00
f5631d8bda
The inner loop of the read operation already fills the buffer as far as it can go. No need to drop into "continue;".
2023-09-11 17:36:32 +02:00
9a9ae7d6fd
The SIGABRT handler can no longer invoke abort() recursively.
2023-09-10 11:45:38 +02:00
64ab8643b5
The size of a slab entry is now calculated inside a single local function, rather than calculated differently in different parts of stdlib_slab.c. This change made it easier to simplify the implementation.
2023-09-10 11:17:00 +02:00
f7fd63acb4
Indentation fix.
2023-09-10 11:15:25 +02:00
8bd7403ae3
The 'struct MemoryNode' is now so larger than the smallest usable allocation size is now 16 bytes.
2023-09-10 11:15:15 +02:00
5efacb1a2b
Fix for unnecessary compiler warnings.
2023-09-10 11:14:32 +02:00
7207c96a6f
Made the slab allocator work with libunix.a again.
2023-09-09 18:36:09 +02:00
21bc996705
Fixed to make use of the aligned slab address when verifying that the slab node is present in the slab. The requested slab size is now properly rounded up to a power of 2 and will always be limited to a valid range.
2023-09-09 18:35:31 +02:00
438fd5bbd2
Fixed the MemoryNode padding, which was short of a 32 bit word.
2023-09-09 18:33:38 +02:00
101846e423
If the memory management system constructor fails, it now prints some diagnostic debug output.
2023-09-09 18:32:50 +02:00
fba7f7da9b
Small type corrections.
2023-09-09 12:55:13 +02:00
115099698a
Added an assertion to verify that the first free chunk on the slab's list is really always available.
2023-09-09 12:55:01 +02:00
4f3d0c981c
If the memory debug option is active, realloc() can no longer damage the trailing guard area.
2023-09-09 12:54:16 +02:00
96af3a1165
Reformatted, so that it might be a bit more readable.
2023-09-08 17:20:51 +02:00
6cabff4bbb
Added the missing semicolon;
2023-09-08 17:20:16 +02:00
71708e84ce
The memory debugging code now places the the damage detection areas which bracket the allocation area so that the originally requested allocation size is used, not the rounded-up size. Debug output in memory node checking no longer counts the non-breaking space character as unprintable.
2023-09-08 16:11:01 +02:00
3d70b18c23
Simplified how the slab allocator, the memory pool or AllocMem() are being used. Added robust integer overflow detection. Allocation sizes are now padded to a multiple of MEM_BLOCKSIZE. Repaired how the plain AllocMem() allocations are managed. alloca() cleanup is disabled during the stdlib_memory_exit destructor's work. The stdlib_memory_init constructor is more robust and now insists that exec.library V39+ uses memory pools.
2023-09-08 16:08:45 +02:00
842acf2eaa
Updated to properly use the MemoryNode changes.
2023-09-08 16:05:29 +02:00
b9463f442b
Added notes on calloc() being safe to use under certain circumstances if the number of elements or the element size happens to be 0. In effect, malloc() will decide what is going to happen.
2023-09-08 16:04:53 +02:00
7ceeb4f8ed
If alloca() would end up returning a NULL pointer, it now invokes the default alloca trap function, which calls abort(). You can override this, if you need to.
2023-09-08 16:03:47 +02:00
fc8051f724
Modifed the MemoryNode so that its size will always be a multiple of MEM_BLOCKSIZE. The SlabSingleAllocation is now always a multiple of MEM_BLOCKSIZE, too. Tracking whether a MemoryNode is not supposed to be freed is now accomplished through dedicated flag instead of repurposing the allocation size field.
2023-09-08 16:02:37 +02:00
64ba9b5389
Added the __addition_overflows() function prototype, which is used by code which checks for unsigned 32 bit integer sums exceeding the range of an unsigned 32 bit integer.
2023-09-08 16:00:38 +02:00
1286b86f07
Added more robust integer overflow detection. Slab memory is now allocated so that its address starts on a MEM_BLOCKSIZE boundary.
2023-09-08 15:59:19 +02:00
8101b43fc5
Tpyo correction
2023-09-08 15:52:06 +02:00
efaffd9182
Typo corection
2023-09-08 15:51:13 +02:00
6197531c90
Added integer overflow checking for the element_size and count parameters.
2023-09-06 13:28:48 +02:00
b94937ff38
Fixed the bug which broke both fgets() and gets(): copying data from the FILE buffer failed to bump the destination string pointer. Also added an abort check in order to avoid turning the memcpy() operation into an uninterruptable sequence.
2023-09-06 13:27:45 +02:00
2cb54d48a9
Added the common function which both fputs() and puts() share now.
2023-09-06 13:24:45 +02:00
a7389454bb
fputs() and puts() now share the same common code. Added abort checks in order to avoid turning the memcpy() operations into an uninterruptable sequence.
2023-09-06 13:24:15 +02:00
45d118101a
Added assertion test for the buffer alignment padding size.
2023-09-06 13:22:07 +02:00
e4a703000a
Reactivated memory debugging features. Added more robust integer overflow checking.
2023-09-06 13:21:13 +02:00
8a4a75e721
Optionally, the slab allocator can be built to deliver 64-bit aligned allocations by default. Also, the slab allocator is no longer enabled at build time.
2023-09-06 13:20:10 +02:00
4cb621d24d
Added documentation on side-effects caused by using MEMF_CLEAR
2022-03-30 09:33:25 +02:00
ff5826c54e
Small changes to the code documentation
...
The memory pools store puddles near head of the allocation list and the large allocations near the tail of the list.
Some hints added to point to side-effects which might apply to memory allocation operations.
2021-12-23 13:08:08 +01:00
b7ce13cbf8
Changed the internal data structures for slab allocations to yield 64-bit-aligned memory allocations. This can be tuned with the __MEM_ALLOCATIONS_64_BIT_ALIGNED preprocessor symbol.
2021-09-27 11:03:08 +02:00
e71249a15b
Removed the profile_profile.o file from the library to be be built. Added a comment explaining why this was necessary.
2021-09-27 11:00:54 +02:00
19323ec218
The aggressive loop optimization option can be disabled/enabled as needed through a variable.
2021-09-27 11:00:20 +02:00
cc8b81e7cc
Added a 'C' implementation for the memory pools functions
...
Data structures and behaviour should follow the original (well, "original and bug-fixed") implementation.
2021-06-22 15:15:29 +02:00
a7efdabefc
Rewritten to handle date ranges better which lie outside the expected time of day, day of month and month.
...
The 'struct tm' is now properly updated to reflect the time and date information which comes out of the number of seconds calculated.
A bug reported by Andreas Falkenhahn is resolved which had the effect of distorting the number of seconds calculated.
2020-07-06 12:01:35 +02:00
57774795af
Typo correction.
2020-02-27 12:15:30 +01:00
9d99542299
Fix for indentation error.
2020-02-27 12:15:17 +01:00
e02089e28a
Better handling of unbuffered mode for interactive streams
...
If the stream is unbuffered and turns out to be an interactive stream (e.g. stderr) then output will be made to follow the rules of line buffering to yield better readability of the output. Similar code exists with fputs(), for example.
2019-08-24 14:05:09 +02:00
2bcfec3e60
Optimizations for better write performance.
...
fwrite() now tries to fill the write buffer as far is possible and will only resort to using the __putc() macros when necessary. This should improve write performance by quite a bit.
If the write buffer happens to be empty and the number of bytes to write is at least as large as the write buffer, then fwrite() will directly call write(). This should improve write performance, too.
If the file is in unbuffered mode, fwrite() now always calls write(), bypassing the write buffer altogether.
2019-08-24 14:03:34 +02:00
4a01746be2
Optimizations for better write performance.
...
fputs() now works almost exactly like fwrite(), except that it's dealing with a NUL-terminated string.
2019-08-24 14:00:03 +02:00
914ef57844
Changed how size=0 plays out
...
Setting the buffer size to 0 had the effect of switching the buffering mode. This is a bad idea since it wasn't actually called for: this is what the 'bufmode' parameter is intended for. What happens now is that the default buffer size is used (BUFSIZ), which sort of follows what the BSD libc did: a zero buffer size delayed the allocation of a buffer until the first read/write access occured.
2019-08-24 13:58:04 +02:00
089ae11181
Improvements for better read performance.
...
gets() now tries to copy as much data from the read buffer as possible, and will fall back onto using the __getc() macro only if necessary. This should improve performance on long lines, or crash faster if the read buffer happens to be too short. This is probably wasted on gets(), but you never know...
2019-08-24 13:55:31 +02:00
ae13cd77fc
Optimizations for better read performance.
...
If the buffer mode is set to "no buffering" then fread() will always bypass the buffer and call read() instead.
If there is enough data waiting to be read from the buffer, fread() will now copy it directly, refilling the buffer as needed.
If the read buffer happens to be empty, buffering is enabled for the stream, and the number of bytes to read is at least as large as the buffer size, then fread() will directly call read(), which should improve performance significantly.
2019-08-24 13:53:48 +02:00