Unused slabs which get recycled are no longer reinitialized from scratch if their chunk size matches what the allocator needed. If the chunk size matches, the list of available chunks is left unchanged, and just the various counters are reset.
Added __get_slab_stats() function.
Added support for global __slab_purge_threshold tuning variable.
Added a short test program for the slab allocator.
The malloc-test program was linked against the wrong object file in GNUmakefile.68k. Fixed.
Added more consistency checking to the slab allocator, which is built if DEBUG is defined in "stdlib_slab.c".
Memory allocations are no longer guaranteed to be aligned to 64 bit word boundaries. In fact, this has not even worked reliably in the past 10 years.
Memory allocation request sizes are now rounded to multiples of 32 bit words (the size of an address pointer) instead to the size of a 64 bit word.
Reduced the memory footprint of the memory allocation management data structures by reusing the most significant bit of the memory allocation size. This allows many more allocations to fit into the 32 byte chunk slabs, but limits the maximum memory allocation size to a little less than 2 GBytes.
Added integer overflow checks to the memory management code.
Reduced the memory management overhead further. This cuts an additional 8 bytes per allocation, unless neither the slab allocator nor memory pools are available. With this reduction the slab allocator is able to use 16 byte chunks, which cover memory allocation requests of 1..8 bytes.
Fixed a bug caused by returning an allocation back to a slab which passed the wrong pointer.
If the first slab in the list of slabs which share the same chunk size has no more room, it means that all other slabs following it have no room either. This speeds up the test to find a slab with free space, which can now abort and directly proceed to allocate memory for a new slab.
If an empty slab's decay count hits zero, it is moved to the front of the empty slab list to be reclaimed more quickly.
Allocations made from the slab now carry a pointer back to the slab which they are a part of. This speeds up deallocation but has the downside of making the smallest usable slab chunk size 64 bytes, which is double what used to be the minimum before.
The maximum slab size is now 2^17 bytes (= 131072). If you request a slab size larger than this, you will get slab sizes of 131072 bytes instead.
Enabling the memory management debugging code no longer produces compiler errors.
Added a slab allocator which replaces the use of memory pools or the plain AllocMem() operations, respectively. In order to activate the slab allocator, choose a slab size (e.g. 2048 bytes or 4096 bytes) and declare a global variable like this:
ULONG __slab_max_size = 2048;
Memory allocations smaller than the slab size will be made from "slabs", i.e. large chunks of memory of the given size. Larger allocations will be managed separately.
- Added llrint() function contributed by Henning Nielsen Lund. Thank you
very much!
- <unistd.h> now also include <stdio.h>, so that the SEEK_SET, etc. macros
are defined for lseek() to use.
- Added a wrapper function which handles the thread-safe stdio stream
resolution.
- In tcflush() a break signal can no longer cause the read flush loop
to be quit with two semaphores still locked.
- In __obtain_daemon_message() the test to verify if the bsdsocket.library API
would support the server API functionality checked the wrong feature. Fixed.
- Switched over the fd->fd_DefaultFile references to fd->fd_Socket where
sockets are used rather than file handles.
- Added functions which modify the callback function and the userdata pointer
stored in a low level unbuffered file/socket data structure. These function
perform the proper locking and are thus safe to use in a thread-safe environment.
- The low level unbuffered file/socket now has a public equivalent, which
is defined (along with the typedefs and flags) in <sys/clib2_io.h>. Functions
for tinkering with it are still to come.
- The math kernel code no longer uses its own private scalbn() function.
- Added a function prototype for the _exit() function. Note that _exit() is
not an ISO 'C' function.
- Corrected the getopt() function prototype, as prompted by Henning Nielsen Lund.
- The printf() family no longer adds a 0 or 0x prefix if the alternate
conversion modifier is present for the %o and %x conversions and the
value to be converted is 0 already. Put another way, printf("%#x %#o",0,0);
now prints "0 0". This required another change so that %p always includes
the 0x prefix even if the pointer involved is a NULL pointer.
- readlink() no longer sort-of-works for files and directories. It now only
works for soft linked objects and returns an error for everything else.
This is based upon a fix by Peter Bengtsson. Thank you very much!
- Moved the lstat() local Lock() function into its own separate file.
- uname() now returns correct and robust information for OS version
numbers > 36. This integrates a fix by Peter Bengtsson. Thank you
very much!
- Moved the crtbegin.o/crtend.o files out of the link libraries. Moving
them in was intended to work as a fix for the shared library build, but
now it seems that this has to be done at the link stage through the
GCC specs file...
- Integrated a fix for __rem_pio2() which affects sin(), tan() and cos(),
contributed by Steven Solie. Thank you very much!
- The internal 'struct fd' file descriptor table entry data structure
now has a user data field entry.
- Rearranged the contents of the 'struct fd' file descriptor table entry
data structure in preparation for making it public. Also added a version
field so that user code can handle changes to it gracefully. The default
file is no longer a BCPL pointer to a file handle by default, but
both a BPTR and a socket identifier, wrapped into a union.
- Added experimental tilde expansion in Unix path names. This still needs
some more work.
- __get_default_file() called __fd_unlock() without having called
__fd_lock() first. Ouch.
- Removed an unnecessary pair of __fd_lock()..__fd_unlock() calls from
ttyname_r().
- The libunix.a unlink() function is now reentrant, or at least thread-safe.
- You can now make unlink() stop after a failed deletion attempt which
failed because the object to be deleted was reported as being "in use".
The libunix.a variant defaults to report the deletion to have succeeded
under these circumstances and later tries to delete the files marked
for deletion. See <dos.h> for a brief documentation of how to change
the behaviour.
- basename() and dirname() can no longer return NULL. They truncate the
resulting path name instead. This is done so because some code that
calls basename() or dirname() does not check if the function's return
value is NULL.
- The SetOwner() fall-back code for Kickstart 2.04 was passing the wrong
parameters to the file system. The first (dp_Arg1) should have been
zero. Ouch.
- basename() is not supposed to modify the string it is passed and should
return a pointer to a string which can be modified. Now it does. Same
thing for dirname().
- asctime_r() now returns NULL if the buffer is too short to hold even a single
byte of data.
- ttyname() now calls ttyname_r(). Also, the libunix.a version of ttyname_r()
will produce "/CONSOLE" rather than "CONSOLE:".
git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@15173 87f5fb63-7c3d-0410-a384-fd976d0f7a62
to add it to libunix.a rather than keeping it in a separate libtermios.a
library.
git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@14971 87f5fb63-7c3d-0410-a384-fd976d0f7a62
- Floating point output in hexadecimal notation can now show a sign
in front of the hex prefix string.
git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@14945 87f5fb63-7c3d-0410-a384-fd976d0f7a62
so far as used by the the __convert_time() function and the conversion
code in strftime().
- Also changed the algorithm used by strftime() to produce the week numbers
(the '%U' and '%W' format specifiers). The new method is much simpler
than the old one.
- Made the code that converts a 'time_t' value into the 'struct DateStamp',
as used by strftime() and utime(), into its own function. This also
fixes a bug in the code strftime() would use which was completely
unaware of the local time zone settings.
git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@14815 87f5fb63-7c3d-0410-a384-fd976d0f7a62
the OS4 header files, but not of the older header file distributions.
git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@14804 87f5fb63-7c3d-0410-a384-fd976d0f7a62
- Added asctime_r(), ctime_r(), gmtime_r(), localtime_r() and strtok_r().
- Added stubs for the Rexx Variables Interface code that used to
be part of amiga.lib. While comparable functionality is available
in rexxsyslib.library V45, the new stubs might be helpful during
porting. Care must be taken since these functions don't work
exactly like the originals.
- Integrated strlcpy() and strlcat() which are intended to be safer
replacements for strncpy() and strncat().
- The program's task priority is now configurable through an external
variable '__priority'.
- The process name to be used when detaching can be configured through
the new '__process_name' variable.
- The minimum required operating system version can be configured
through the new '__minimum_os_lib_version' variable; a matching
error message can be provided through the new '__minimum_os_lib_error'
variable.
- The default console window specification can be overriden through
the new '__stdio_window_specification' variable.
- The socket initialization code did not set up a reference to the
'h_errno' variable correctly. This had the effect of making name
and address resolution errors trash the 'errno' variable instead
and leaving 'h_errno' always set to 0. Fixed.
- For sockets, ioctl() and fcntl() now interact on the FIONBIO/FIOASYNC
requests (ioctl) and the O_NOBLOCK/O_ASYNC flags (fcntl).
- popen() now accepts "rb" and "wb" as mode parameters. However, "r+",
"w+" and variants thereof are still unsupported due to the
unidirectional pipe support in the standard "PIPE:" device.
git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@14777 87f5fb63-7c3d-0410-a384-fd976d0f7a62
- Cleaned up the OS4 build makefile, losing redundant libraries,
adding more startup object code and ultimatively making the whole
rebuild logic work again: if code changes and dependencies are
set up correctly, it will now get rebuilt. Previously, such
changes went unnoticed and you had to rebuild the entire library
from scratch.
- Added stubs for CreatePort(), DeletePort(), CreateTask(), DeleteTask()
and NewList() which have equivalents in exec.library V50 but for which
it might be useful if ported code didn't have to reference these
explicitly.
- mktemp() was broken in libunix.a with Unix path semantics enabled.
This was because the name template was translated and translated
back again, overwriting the translation buffer. This, funny enough,
broke Samba's printing feature. Fixed by translating the name only
before each test for "uniqueness" is made. The new code also handles
empty "" templates gracefully, which was a problem with both the
"standard" and the Unix path semantics flavour.
Why is it that I find bugs like this always after having just
released another library update?
git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@14769 87f5fb63-7c3d-0410-a384-fd976d0f7a62
- Changed the error abort condition for the %s conversion of the
scanf() family. It now matches the abort conditions for all other
conversions and no longer ignores whether any other parameters were
converted before. This was a quirk in the older implementation.
- The scanf() family now accepts %E and %G in place of %f and %X in
place of %x.
- Simplified the common code that fopen(), freopen() and fdopen()
share and which has to figure out by looking at a file access
mode specification which parameters should be used.
- Dropped error detection in the scanf() family. The EOF has to be
good enough. Also, ungetc() failure still leads to error handling.
git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@14765 87f5fb63-7c3d-0410-a384-fd976d0f7a62
- The scanf() family now always returns the number of assignments made
unless an error occured or an EOF was hit during conversion before the
first assignment could be made.
- strtok() did not terminate properly if the last token in the string
did not end with a separator character but with a '\0' byte. Fixed.
- The directory scanning functions opendir/closedir did not get the global
directory data tracking data structure initialized which later led to
Enforcer hits and maybe trashed memory. Fixed.
git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@14761 87f5fb63-7c3d-0410-a384-fd976d0f7a62
- The printf() family now produces no output at all for %e, %f and %g if the
floating point support code is disabled. Previously, a minimum field width
specification could take effect, printing a series of 0 or blank space
characters where no output should have been produced.
git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@14756 87f5fb63-7c3d-0410-a384-fd976d0f7a62
- The scanf() family no longer assumes that a leading '0' indicates that the
following digits form an octal number if the conversion type has been
specified as already '%x' already.
git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@14752 87f5fb63-7c3d-0410-a384-fd976d0f7a62
- The OS4 version had floating point math support code enabled in all
libraries and not just "libm.a". Fixed.
git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@14750 87f5fb63-7c3d-0410-a384-fd976d0f7a62
- Moved the locale initialization/cleanup code into constructors
and destructors.
- The socket cleanup function is now a destructor.
- The math cleanup function is now a destructor.
- The wildcard cleanup function is now a destructor.
- The stdio cleanup function is now a destructor.
- The stack extension cleanup function is now a destructor.
- The code that cleans up after the program's current directory
was changed is now a destructor function.
- Moved the initialization/cleanup code for unlink() into constructors
and destructors.
- Moved the initialization/cleanup code for usergroup.library into
constructors and destructors.
- Added usleep(), and created wrapper code that both sleep() and
usleep() can use.
- Added strtoll() and strtoull(), with further changes to <limits.h>
and <stdlib.h>.
git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@14737 87f5fb63-7c3d-0410-a384-fd976d0f7a62
- <stdarg.h> now tries to use the compiler supplied, machine specific
<stdarg.h> file and also includes the OS4-specifc <sys/amigaos-va.h>
file, if necessary.
- Added another test to <sys/time.h> to check if the "timeval" definition is
already in place. If it is, <exec/types.h> will not be included.
- <sys/time.h> can be made to define the timeval data structure locally if
the __USE_CLIB2_TIMEVAL preprocessor symbol is defined. In this case no
<exec/types.h> or <devices/timer.h> file will be read.
- The sprintf() family did not properly handle empty strings as format
specifications. This would result in a necessary buffer flush action
getting skipped, which consequently did not put the string termination
character into the output buffer.
git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@14723 87f5fb63-7c3d-0410-a384-fd976d0f7a62
- The parameters of atan2() were swapped. Fixed.
- Merged fdlibm 5.3 changes with __kernel_tan(), __exp() and __pow()
functions.
git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@14718 87f5fb63-7c3d-0410-a384-fd976d0f7a62
- The <assert.h> header file was missing the C++ 'extern "C" { .. }'
declarations.
- Added a new function __get_default_file() which allows direct access
to the low level file handle/socket descriptor associated with a
file descriptor.
git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@14716 87f5fb63-7c3d-0410-a384-fd976d0f7a62
- acos() now returns 0 for a domain error.
- asin() now returns 0 for a domain error.
- atan2() now returns 0 for a domain error.
- fmod() now returns x if y == 0 and sets a
domain error.
- sqrt() now returns 0 for a domain error.
- Added NaN and +Inf constants to the math library
initialization code which could come in handy later.
git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@14713 87f5fb63-7c3d-0410-a384-fd976d0f7a62
- Added "math_hypot.c"
- The 68k build makefile now builds the vfprintf/vfscanf functions
with %lld/%llu support.
- Split the release notes file into changes and actual release notes,
which may overlap but differ in technical content.
git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@14711 87f5fb63-7c3d-0410-a384-fd976d0f7a62
- Added "math_logb.c", and it appears to work, too.
git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@14706 87f5fb63-7c3d-0410-a384-fd976d0f7a62
- Since the 'long double' data type is not really supported by the GCC
versions we use (and not supported by SAS/C either) building the
library with support code for it is now a configurable option. Unless
enabled, 'long double' is now treated like 'double'.
- Reworked the HUGE_VAL definition which previously would default to
Infinity. The new code properly defines this to the largest
representable floating point number. The 'great' thing about the
HUGE_VAL definition in this library is that it's a reference to
a binary constant initialized by the library startup code. So any
application checking for HUGE_VAL merely needs to be relinked
rather than recompiled.
git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@14703 87f5fb63-7c3d-0410-a384-fd976d0f7a62
- Ditched __is_infinity() and __is_not_a_number(), brought them back
as isinf() and isnan().
- Updated code and header files to state exactly which ISO 'C' version
is meant by the "The following is not part of the ISO 'C' standard."
warning.
- Integrated rint() and rintf().
git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@14700 87f5fb63-7c3d-0410-a384-fd976d0f7a62
methods for accessing the low level representation of the IEEE 754
numbers they work on.
git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@14692 87f5fb63-7c3d-0410-a384-fd976d0f7a62
- Added h_strerror() function to libnet.a; there's a global 'h_errno'
variable available, too.
- <signal.h> now defines a type 'sig_t'.
- <unistd.h> now allows the 'fd_set' type to be referenced as
'struct fd_set', too.
git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@14690 87f5fb63-7c3d-0410-a384-fd976d0f7a62