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

544 Commits

Author SHA1 Message Date
29e02775fb Cleaned up the build rules, added missing files 2016-12-04 11:11:53 +01:00
5cb27db203 Slab allocator is exercised much more 2016-12-04 11:11:28 +01:00
4fc1b13945 Added a rogue malloc/free pair 2016-12-04 11:11:05 +01:00
8beaabac4f Removed unused local variable 2016-12-04 11:10:46 +01:00
271572ed56 Fixed so that it builds correctly with SAS/C again 2016-12-04 11:10:33 +01:00
e0feef8932 Moved __CXV54 into sas_cxv.asm
sas_cxv54.asm is no longer needed.
2016-12-04 11:10:13 +01:00
07259ed7eb This is needed when building with math=ieee option 2016-12-04 11:09:24 +01:00
3203fcf96a Removed unused result variable 2016-12-04 11:08:54 +01:00
bfba44bf83 Rewritten to use setjmp()/longjmp()
Also contains new code which prints the number of times a slab was reused.
2016-12-04 11:08:41 +01:00
35434bdedc Updated to build correctly with SAS/C again 2016-12-04 11:07:40 +01:00
17ba18c731 Added code which temporarily disables profiling 2016-12-04 11:06:50 +01:00
78a8c7655e Added __decay_unused_slabs() 2016-12-04 11:05:50 +01:00
184a127860 Added stdlib_decay_unused_slabs() 2016-12-04 11:05:30 +01:00
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.
V1_212 V2_212
2016-11-27 15:53:40 +01:00
ac710b333e Accidentally omitted from version 1.211 2016-11-24 09:45:35 +01:00
d2acae7cd7 Slab allocator update
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.
V1_211
2016-11-23 16:37:46 +01:00
f8cf752e6a Merge branch 'master' of https://github.com/adtools/clib2 V1_210 2016-11-22 11:07:46 +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
1ea8953bd3 Added __get_slab_allocations() function
__get_slab_allocations() which will report information about each memory allocation made by the slab allocator which does not come from a slab.
2016-11-22 11:06:29 +01:00
ff908f8a02 Added a malloc test program 2016-11-22 10:54:58 +01:00
525e193113 added missing .codeclimate.yml and .travis.yml 2016-11-22 10:52:01 +01:00
2df2393b81 minor tweak 2016-11-22 10:50:03 +01:00
ecd40943e2 added Travis-CI and CodeClimate code check support. 2016-11-22 10:46:01 +01:00
7e201fea06 Maximum slab size limited, debug mode errors fixed
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.
V1_209
2016-11-21 12:27:40 +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.
V1_208
2016-11-19 15:49:21 +01:00
3425e33cf9 New functions and data structures for slab allocator 2016-11-19 15:48:51 +01:00
ef66e530b7 This was missing from the previous commit :-( 2016-11-19 13:08:27 +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.
V1_207
2016-11-18 17:22:21 +01:00
eb223f269d simple_sprintf build again
simple_sprintf needs libgcc.a to build correctly.
2016-11-18 17:20:58 +01:00
025b183b5a Unused slabs are getting purged after adding a new slab
If a new slab is allocated, or an empty slab is reused, the list of empty slabs is now purged, if possible. Empty slabs which cannot be immediately purged "decay" and will be collected the next time a new slab is allocated or an empty slab is reused.

If a chunk is allocated and the slab which the chunk came from is fully utilized, the slab is moved to the end of its list. This should avoid searching this slab for free space before all other slabs of the same chunk size have been tested first. Slabs with free space are always placed closer to the head of the list.
2016-11-17 13:14:13 +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
ac6d131dc3 Made the call to GetProgramName() work again
Added '#include <dos/obsolete.h>' in order to make the call to GetProgramName() work again. No functional changes.
2016-09-11 10:33:37 +02:00
bb82ad015d Ignore object and library files 2016-09-11 09:22:34 +02:00
e403edd04a Added missing #include <dos/obsolete.h>
Changes in the naming of certain dos.library functions in the
V53 header files are now accounted for. This also affects
unistd/stat/utime code which uses the same header file.
2015-09-30 11:23:04 +02:00
c149db9037 - The contents of the math_fmodf.c and math_modff.c did not match the names of the respective files. In fact, the contents of these files were swapped. 2015-07-24 14:08:57 +02:00
34487c68b4 Added the missing '#include <dos/obsolete.h>', required for the OS4 build. 2015-07-18 10:02:03 +02:00
a1b46cb3d4 Added the missing library revision information pertaining to clib2 1.206. 2015-07-18 10:01:10 +02:00
75f1d5a57e Updated/amended missing copyright information 2015-06-11 13:19:07 +02:00
2bc44bb0f2 Still more typo corrections and repairs 2015-06-11 13:01:23 +02:00
ac03cbb272 Typo corrections and repairs 2015-06-11 12:44:28 +02:00
fd33c09c41 - Added a markdown version of the documentation/README.html file.
git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@15307 87f5fb63-7c3d-0410-a384-fd976d0f7a62
2015-06-10 17:39:55 +00:00
2310605f10 - Removed the "executable" properties from those files which are not executable scripts
git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@15306 87f5fb63-7c3d-0410-a384-fd976d0f7a62
2015-06-10 13:22:53 +00:00
7f0f7929ba - Updated copyright text and contact information
- Replaced ISO Latin 1 code #160 with a plain blank space (ASCII code #32) where necessary


git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@15305 87f5fb63-7c3d-0410-a384-fd976d0f7a62
2015-06-10 13:13:40 +00:00
3a63fb9ff8 git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@15217 87f5fb63-7c3d-0410-a384-fd976d0f7a62 2015-06-04 09:34:11 +00:00
718574aae5 m.lib 1.206 (24.4.2015)
- The fscanf() family failed to parse and convert %f parameters correctly
  if the respective number did not begin with a digit, but a decimal
  point. Hence ".7" would not be processed, but "0.7" would.

c.lib 1.206 (24.4.2015)

- Reworked the __putc() and putc() macros to reference the 'c' input
  parameter only once, and to be free of side-effects when tinkering
  with the buffer position.

- isatty() had the __fd_lock() call in the wrong place, which could have
  led to cleanup problems later.

- The close action in the stdio, socket and termios hook code now
  also zaps the fd pointer itself after cleaning up the file descriptor
  table entry.

- 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@15215 87f5fb63-7c3d-0410-a384-fd976d0f7a62
2015-04-24 14:00:23 +00:00
bdfdd84e38 - Bumped math library versions, due to vfscanf() changes.
git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@15214 87f5fb63-7c3d-0410-a384-fd976d0f7a62
2015-04-24 13:56:39 +00:00
eeb4e5d7aa - Floating point numbers which do not begin with a digit, but with a decimal point, are now processed correctly.
git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@15213 87f5fb63-7c3d-0410-a384-fd976d0f7a62
2015-04-24 13:00:12 +00: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
a436ebdad1 - Reworked the __putc() and putc() macros to reference the 'c' input
parameter only once, and to be free of side-effects when tinkering
  with the buffer position.

- isatty() had the __fd_lock() call in the wrong place, which could have
  led to cleanup problems later.

- The close action in the stdio, socket and termios hook code now
  also zaps the fd pointer itself after cleaning up the file descriptor
  table entry.


git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@15211 87f5fb63-7c3d-0410-a384-fd976d0f7a62
2010-10-20 13:12:59 +00:00
81e66075e2 - The fputc() and __putc() macros were not entirely free of side-effects. Ouch.
git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@15210 87f5fb63-7c3d-0410-a384-fd976d0f7a62
2010-10-19 09:35:16 +00:00