1
0
mirror of https://github.com/adtools/clib2.git synced 2025-12-08 14:59:05 +00:00
Commit Graph

112 Commits

Author SHA1 Message Date
5617c0eacf Slab allocator update
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.
2016-11-27 15:53:40 +01:00
0c5b88d2d3 Slab allocator changes
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.
2016-11-22 11:07:38 +01:00
799ee705e8 New monitoring function for slab allocator
Added __get_slab_usage() function which can be used to query the slab allocator memory usage at runtime.
2016-11-19 15:49:21 +01:00
fbc8694c49 Added a slab allocator
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.
2016-11-18 17:22:21 +01:00
8051da3c9a Added a slab allocator
A slab-allocator can now be used as the back-end for all memory allocations by setting __slab_max_size to a value > 0. This controls the slab size used for allocations and should be a power of 2, such as 2048 or 4096 bytes.

This change still needs testing.
2016-11-17 11:45:59 +01:00
a665fffff1 - Removed the remains of all the stack extension and stack overflow/underflow
checking code. It never actually worked. The bit that does work is the stack
  usage measurement code, plus the bit that sets up the the custom stack
  according to local setting or by calling a query function.


git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@15212 87f5fb63-7c3d-0410-a384-fd976d0f7a62
2010-10-20 13:50:17 +00:00
6c50657673 - Added disk type definitions to mount_convertinfo.c and unistd_common_pathconf.c,
prompted by Thore Boeckelmann.


git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@15187 87f5fb63-7c3d-0410-a384-fd976d0f7a62
2008-04-16 07:38:10 +00:00
6801a4fcf0 - reverted the soft-float subdirectory changes as the problem was solved by
olaf in a different way so that libm.a never contains any hard float
  opcodes and instead libm881 contains them. so the separate soft-float
  directory are not required.


git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@15181 87f5fb63-7c3d-0410-a384-fd976d0f7a62
2008-03-11 07:41:27 +00:00
91ccaa5ba9 - Added "-msoft-float" to the non-FPU libm build rules, which ought to
resolve the issues with FPU code popping up in the mathieee#?.library
  software floating point code.


git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@15179 87f5fb63-7c3d-0410-a384-fd976d0f7a62
2008-03-10 16:31:56 +00:00
a41212e575 - Temporarily deactivated the separate -msoft-float builds.
git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@15177 87f5fb63-7c3d-0410-a384-fd976d0f7a62
2008-03-10 14:59:54 +00:00
2591e249d7 - [jlangner]: changed the GNUmakefile.68k to also build soft-float variants of all
our libraries. In addition the specs file now also respects the -msoft-float
  option at link time and sets the default link directory accordingly.


git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@15176 87f5fb63-7c3d-0410-a384-fd976d0f7a62
2008-03-04 16:25:35 +00:00
e5a2a2b451 - 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.


git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@15172 87f5fb63-7c3d-0410-a384-fd976d0f7a62
2007-01-06 10:09:49 +00:00
3a0324e4ff - 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.


git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@15170 87f5fb63-7c3d-0410-a384-fd976d0f7a62
2006-11-16 14:39:23 +00:00
70d1e4b7a3 - 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.


git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@15166 87f5fb63-7c3d-0410-a384-fd976d0f7a62
2006-11-15 09:17:04 +00:00
e789564429 - 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!


git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@15161 87f5fb63-7c3d-0410-a384-fd976d0f7a62
2006-11-13 09:25:28 +00:00
9984a37cb4 - Unlink 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.


git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@15155 87f5fb63-7c3d-0410-a384-fd976d0f7a62
2006-09-27 09:40:06 +00:00
aa3240972a *** empty log message ***
git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@15134 87f5fb63-7c3d-0410-a384-fd976d0f7a62
2006-09-17 17:36:42 +00:00
42dba39aef - Added a new callback function which can be used in programs which want
to avoid that the command line wildcard expansion takes place.


git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@15132 87f5fb63-7c3d-0410-a384-fd976d0f7a62
2006-09-15 06:58:17 +00:00
40d64e1413 - Added the missing fdim() and fdimf() functions to the build
makefiles. The OS4 build makefile was missing lrint() and
  lrintf(). Ouch.

- execve() now checks if an abort signal arrives while it's trying
  to read the first line of a script, or looking for an executable
  on an assignment path.


git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@15123 87f5fb63-7c3d-0410-a384-fd976d0f7a62
2006-08-06 08:31:06 +00:00
62d0c2dc81 - execve() no longer directly calls exit(), but a function which can be
replaced by the user. If that function __execve_exit() does not call
  exit but just returns to the caller without doing anything, execve()
  will return the caller with the return code of the RunCommand()
  function.


git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@15122 87f5fb63-7c3d-0410-a384-fd976d0f7a62
2006-08-06 08:15:42 +00:00
85122893ff - Added the POSIX exec() family functions, based upon code contributed
by Henning Nielsen Lund. Thank you very much!

- atoll() no longer sets 'errno' directly but now calls __set_errno()
  instead.


git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@15116 87f5fb63-7c3d-0410-a384-fd976d0f7a62
2006-08-02 08:00:30 +00:00
8633c3a77b - The default configuration options for execvp() are now configurable at
link time.


git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@15112 87f5fb63-7c3d-0410-a384-fd976d0f7a62
2006-08-01 17:01:14 +00:00
5f42fb06f9 - Added the exec() family functions to the makefiles and the <unistd.h>
header file.


git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@15111 87f5fb63-7c3d-0410-a384-fd976d0f7a62
2006-08-01 16:41:02 +00:00
e2cadc9ea5 - Added pathconf() and fpathconf() as contributed by Peter Bengtsson. Thank you very much!
git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@15108 87f5fb63-7c3d-0410-a384-fd976d0f7a62
2006-07-28 14:37:28 +00:00
bde4d37a64 - Added sysinfo() as contributed by Peter Bengtsson. Thank you very much!
git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@15107 87f5fb63-7c3d-0410-a384-fd976d0f7a62
2006-07-28 14:02:32 +00:00
c3d55e94ec - Added ftime(), ulimit(), getrlimit() and setrlimit() as contributed by
Peter Bengtsson. Thank you very much!


git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@15106 87f5fb63-7c3d-0410-a384-fd976d0f7a62
2006-07-28 13:36:17 +00:00
a1dc5e8e6e - Added ftime(), as contributed by Peter Bengtsson. Thank you very much!
- Added the missing S_ISSOCKET() macro to <sys/stat.h>. Note that this
  is not actually a POSIX feature.

- Added fmin(), fminf(), fmax() and fmaxf() to the build makefiles.
  Somehow I must have forgotten about them :-(


git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@15105 87f5fb63-7c3d-0410-a384-fd976d0f7a62
2006-07-28 13:19:12 +00:00
601caa5708 - Added the global variable __expand_wildcard_args which can be used
to disable wildcard pattern expansion of command line parameters when
  linked against "libunix.a". Note that this has no effect on the "regular"
  libc.a behaviour.


git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@15100 87f5fb63-7c3d-0410-a384-fd976d0f7a62
2006-05-04 08:01:47 +00:00
91b4f288f9 - The default break signal mask (SIGBREAKF_CTRL_C) is no longer
hard-coded. You can override it at link time with a different
  variable value for __break_signal_mask. This may have to be
  augmented by an API for changing the value.


git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@15094 87f5fb63-7c3d-0410-a384-fd976d0f7a62
2006-04-05 08:39:46 +00:00
55ab845de0 - Disabled the thread-safe build.
git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@15093 87f5fb63-7c3d-0410-a384-fd976d0f7a62
2006-04-05 08:24:32 +00:00
184a2ada87 - Corrected the lock variable name.
git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@15092 87f5fb63-7c3d-0410-a384-fd976d0f7a62
2006-04-05 08:19:11 +00:00
2e227506e5 - Added a wait_select() function which works very much like the
bsdsocket.library/WaitSelect() function.


git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@15091 87f5fb63-7c3d-0410-a384-fd976d0f7a62
2006-04-05 07:53:30 +00:00
98d26f36ac - Added lockf() support, as supplied by Henning Nielsen Lund.
Thank you very much!

- symlink() now also works for absolute and relative links, and is
  part of "libunix.a". This patch was supplied by Henning Nielsen Lund.
  Thank you very much!


git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@15081 87f5fb63-7c3d-0410-a384-fd976d0f7a62
2006-01-29 09:17:00 +00:00
ca30ee62a2 - The __main() stub function expected by the 68k GCC build is no
longer part of "stdlib_main.c". This helps the C++ support, since the
  __main symbol definition no longer clashes with the definition in
  "libgcc.a".


git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@15076 87f5fb63-7c3d-0410-a384-fd976d0f7a62
2005-12-31 12:23:54 +00:00
67ff2ca833 - Added another function called __reset_max_mem_stats() which will reset the
counters for "maximum amount of memory used" and "maximum number of chunks
  allocated" to the current figures for these values.

- Fixed the alloca() declaration in <stdlib.h> so that software which keys
  off the fact whether or not the alloca preprocessor symbol is defined
  will do the right thing.

- Added an optional call-back function which can be called if alloca()
  is about to return NULL, which some software does not consider.
  Rather than letting such software drop into an illegal memory access
  or worse, that call-back function will be invoked instead, which can
  print an error message and eventually call abort().


git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@15073 87f5fb63-7c3d-0410-a384-fd976d0f7a62
2005-11-28 09:53:51 +00:00
797fcb89a1 - Fixed the header files I broke by mistake.
- You can now request that your program uses the clib2 alloca() function
  rather than the built-in compiler alloca().

- alloca() is now part of libunix.a, too.


git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@15072 87f5fb63-7c3d-0410-a384-fd976d0f7a62
2005-11-27 10:28:16 +00:00
1153e58366 - In libunix.a malloc(), calloc() and realloc() no longer treat a
request to allocate 0 bytes as an error, returning NULL. They all
  return a pointer sized memory chunk (= four bytes) initialized to
  NULL (= 0) instead.

- The alloca() implementation which allocates memory from the system
  rather than the local stack frame is thread-safe now. It also
  interacts with the realloc(), calloc(), free() and malloc() functions
  in that the alloca() cleanup routine is called once alloca() has
  done its job. If all the memory allocated through alloca() has been
  released no further calls to the cleanup function will be made.

- In the thread-safe library, realloc() permitted two different overlapping
  calls to succeed in trying to reallocate the same chunk of memory due to
  a race condition. Fixed.


git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@15070 87f5fb63-7c3d-0410-a384-fd976d0f7a62
2005-11-27 09:26:55 +00:00
0459ea1fc9 - In libunix.a malloc(), calloc() and realloc() no longer treat a
request to allocate 0 bytes as an error, returning NULL. They all
  return a 1 byte memory chunk initialized to 0 instead.


git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@15064 87f5fb63-7c3d-0410-a384-fd976d0f7a62
2005-11-20 17:00:22 +00:00
5578c6a39e - Added <fenv.h> for C99, and the (yet unimplemented) functions
feclearexcept(), fegetenv(), fegetexceptflag(), fegetround(),
  feholdexcept(), feraiseexcept(), fesetenv(), fesetexceptflag(),
  fetestexcept(), fetestround() and feupdateenv().

- Replaced the old pow() implementation. However, powf() may need to
  be changed to set a domain error.


git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@15062 87f5fb63-7c3d-0410-a384-fd976d0f7a62
2005-11-19 17:11:22 +00:00
99e9ebfc15 - Moved the code which rebinds the standard I/O streams to the server
socket into a separate function which can be overridden by user code.


git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@15051 87f5fb63-7c3d-0410-a384-fd976d0f7a62
2005-10-20 07:19:16 +00:00
63c08cfe0e - The network startup code no longer checks for the presence of a possible
daemon startup message by default. You now have to enable this feature
  by declaring a global variable called "__check_daemon_startup" which is
  described in <dos.h>.


git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@15050 87f5fb63-7c3d-0410-a384-fd976d0f7a62
2005-10-20 06:50:32 +00:00
090753282b - Added __set_h_errno() and __get_h_errno() functions.
- The thread-safe library now tries to enable bsdsocket.library base
  sharing and attempts to make the TCP/IP stack call the local
  __set_errno() and __set_h_errno(), so that any Process calling
  the library functions will get a chance to see proper error
  codes. Whether any of these features could be enabled can be tested
  through two global variables __can_share_socket_library_base and
  __thread_safe_errno_h_errno which are defined in <dos.h>. Note that
  for both features to work you will need the Roadshow bsdsocket.library
  version 4.275 or higher.


git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@15048 87f5fb63-7c3d-0410-a384-fd976d0f7a62
2005-10-17 13:54:25 +00:00
3480ec40b3 - Updated the build files so that atanh() and atanhf() are built for the
respective math libraries.


git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@15046 87f5fb63-7c3d-0410-a384-fd976d0f7a62
2005-10-16 09:14:28 +00:00
acafd14bc2 - Removed <sys/clib2_net.h> and every reference to it.
git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@15042 87f5fb63-7c3d-0410-a384-fd976d0f7a62
2005-10-11 11:24:53 +00:00
cb1f1a4a10 - Removed the various workarounds associated with <unistd.h>, required
for building code that references the networking API. It is now possible,
  provided you build your code with an existing TCP/IP API header file
  set (such as from the "Roadshow" SDK) without running into data type
  or function prototype declaration conflicts. I have added local versions
  of <arpa/inet.h>, <netinet/in.h>, <netdb.h>, <sys/filio.h>, <sys/ioccom.h>,
  <sys/ioctl.h>, <sys/select.h> and <sys/socket.h> and updated <unistd.h>,
  <pwd.h> and <grp.h> accordingly. Note that some of the function prototypes
  will conflict with the bsdsocket.library/usergroup.library API, which is
  why you can disable the declarations through the __NO_NET_API preprocessor
  symbol: if defined, none of the function prototypes will be defined.


git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@15036 87f5fb63-7c3d-0410-a384-fd976d0f7a62
2005-10-09 12:32:18 +00:00
1d1d340ae1 - The 68020/030/040/060 library version now supports 64 bit integers
in the printf(), scanf(), atoll(), strtoll() and strtoull() functions.


git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@15021 87f5fb63-7c3d-0410-a384-fd976d0f7a62
2005-08-27 12:12:50 +00:00
132aaa8293 - The socket/usergroup API function and data type definitions that used to
be defined in <unistd.h> have been moved into a separate header file
  <sys/clib2_net.h> which, for backwards compatibility, can be include
  from within <unistd.h> if the preprocessor symbol __USE_CLIB2_NETLIB
  is defined early on. Eventually, <sys/clib2_net.h> should be removed
  from the general header files and become a local library build header
  file altogether. Note that in this case you would have to build your
  own software using common TCP/IP SDK header files.


git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@15011 87f5fb63-7c3d-0410-a384-fd976d0f7a62
2005-07-12 13:35:58 +00:00
ebf5d63bc6 - Moved all the constructor code out of "stdlib_init_exit.c" and into the
files which initialize global data, such as the new "stdlib_program_name.c"
  and "stdlib_malloc.c".

- Until I can find a way to invoke it from within the library, the
  __machine_test() function is no longer invoked.

- Tagged global data with NOCOMMON attributes.

- Added the __lib_init() and __lib_exit() functions, which are part of the
  thread-safe library and which can be used to hook up clib2 with standard
  Amiga shared library/device code. Some documentation on how to use them
  can be found in the <dos.h> header file.


git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@14999 87f5fb63-7c3d-0410-a384-fd976d0f7a62
2005-07-03 10:36:48 +00:00
3d58795d0f - Repaired the pattern matching code which expands command line arguments:
it no longer requires that any parameters are quoted and it is automatically
  enabled if you link against libunix.a, without libc.a standing a chance to
  accidentally override it.


git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@14990 87f5fb63-7c3d-0410-a384-fd976d0f7a62
2005-06-26 10:23:05 +00:00
17e3b3b0e2 - Implemented exp2()/exp2f() and log2()/log2f() as suggested by
Henning Nielsen Lund. Thank you very much!


git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@14988 87f5fb63-7c3d-0410-a384-fd976d0f7a62
2005-06-26 09:06:12 +00:00