Colin Leroy-Mira
6604c5ce92
Make strndup smaller, safer, faster
...
First implementation was doing:
- strdup (without checking result!)
- strlen
- terminate
- realloc
New one does:
- malloc to shortest +1
- strncpy
- terminate
2025-07-05 12:11:40 +02:00
Bob Andrews
fd973cd544
Merge pull request #2769 from colinleroy/add-strndup
...
Add strndup
2025-07-04 17:01:28 +02:00
Colin Leroy-Mira
90e1ac374b
Add strndup
...
char* __fastcall__ strndup (const char* S, size_t maxlen);
2025-07-03 23:46:28 +02:00
Kugel Fuhr
59e7158512
Make the CPU_xxx constants from cpu.mac internal to the assembler and replace
...
cpu.mac by a file that just emits a warning when used.
2025-07-01 08:29:42 +02:00
Kugel Fuhr
c72126e68f
Changed most of the library sources to use .CAP instead of .CPU.
2025-07-01 08:04:00 +02:00
Bob Andrews
54a2410b5a
Merge pull request #2674 from GorillaSapiens/c_sp
...
rename "sp" to "c_sp", avoid conflict with 4510 opcodes
2025-06-24 17:44:13 +02:00
Gorilla Sapiens
0489098517
restore comment alignment
2025-06-22 21:34:41 +00:00
mrdudz
55742003d6
add some more comments
2025-06-17 21:40:04 +02:00
Gorilla Sapiens
b6f42f9ab2
changed "spc" to "c_sp"
2025-06-04 06:37:59 +00:00
Gorilla Sapiens
3d118dc6e5
rename "sp" to "spc", avoid conflict with 4510 opcodes
2025-06-04 02:06:40 +00:00
Bob Andrews
7621fb91f0
Merge pull request #2642 from GorillaSapiens/ca65_charset_translations
...
C style character translation in ca65
2025-05-24 17:23:19 +02:00
Colin Leroy-Mira
cfbfaa559c
Add ZX02 and LZSA (1,2) decompressors
2025-05-13 21:26:47 +02:00
Gorilla Sapiens
1b85ab6985
C style character translation in ca65
2025-05-06 03:02:18 +00:00
Bob Andrews
b1713e4c96
Merge pull request #2627 from colinleroy/add-lz4-C-ref
...
Add decompress_lz4 C implementation as comment
2025-05-02 20:23:09 +02:00
Colin Leroy-Mira
caa66aea95
Add decompress_lz4 C implementation as comment
...
For reference.
2025-04-07 21:01:05 +02:00
Stefan A. Haubenthal
774e275965
Fixed many comments
2025-03-24 20:52:55 +01:00
Colin Leroy-Mira
fb63a839bf
Optimize LZ4 decompressor
...
Use a walking out pointer instead of &out[written]. This
simplifies the code by 27 bytes and spares 15% cycles.
Tested with both the unit test and code uncompressing
10kB of data.
Renamed the labels for legibility.
2025-03-14 16:33:13 +01:00
Colin Leroy-Mira
adfb42bfa6
Rewrite rewind in assembly
2025-01-01 14:32:07 +01:00
Sidney Cadot
8ee93f7e5f
Fixed indentation inside comment.
2024-12-18 09:04:20 +01:00
Sidney Cadot
ceac9f87ba
Temporary fix for fgets() not using target-specific newline.
...
This patch provides a temporary fix for the issue where the fgets()
function did not use the target-specific newline character to
decide if it has reached the end of the line. It defaulted to the
value $0a, which is the newline character on only some targets.
The Atari, for example, has newline character $9b instead.
This patch is ugly, because the ca65 assembler that is used for
fgets doesn't currently accept C-type character escape sequences
as values. Ideally we'd be able to write:
cmp #'\n'
And this would end up being translated to a compare-immediate
to the target-specific newline character.
Since that is impossible, this patch substitutes the equivalent,
but ugly, code:
.byte $c9, "\n"
This works because $c9 is the opcode for cmp #imm, and the "\n"
string /is/ translated to the platform-specific newline character,
at least when the 'string_escapes' feature is enabled.
2024-12-18 07:44:52 +01:00
Stefan
0f6b427170
Update strftime.c
2024-12-09 18:37:02 +01:00
Kugel Fuhr
efa2020d93
Improved/fixed the time() function:
...
- When the underlying clock_gettime function returned an error, the value
returned via *timep was wrong.
- Reduced code size by 7 bytes.
- Don't suck in ldeaxi.
2024-09-12 09:14:57 +02:00
Bob Andrews
31a0d5cc40
Merge pull request #2503 from colinleroy/master
...
Optimize stpcpy's size and speed
2024-09-08 16:17:14 +02:00
coronax
838c8b48b7
Set the clock id to CLOCK_REALTIME when calling clock_gettime.
...
Previously, time() allocated stack space for the clock id argument, but didn't actually set a value.
2024-09-07 23:27:54 -05:00
Colin Leroy-Mira
55d3a6ea39
Optimize stpcpy's size and speed
2024-09-07 21:24:53 +02:00
Sven Michael Klose
aed94d2dae
Fix code style.
...
Have type, function name and argument declaration on a single line.
2024-07-16 01:33:48 +02:00
Sven Michael Klose
581b79e0b9
Add stpcpy().
...
Like strcpy() but returning pointer to ending zero of copied string.
2024-07-07 14:04:49 +02:00
Colin Leroy-Mira
a823d90082
Separated versions
2024-04-19 07:57:47 +02:00
Colin Leroy-Mira
71d82ab5d9
Use common naming scheme for tolowerdirect
2024-03-22 17:19:26 +01:00
Colin Leroy-Mira
0c681b42ef
Factorize to save 20 bytes
2024-03-19 18:07:17 +01:00
Colin Leroy-Mira
b5d259bafb
Implement strcasestr as part of strstr
2024-03-18 19:52:04 +01:00
Colin Leroy-Mira
82165c1a77
Implement strcasestr
2024-03-18 19:51:50 +01:00
Colin Leroy-Mira
1fab179cb4
a BIT of 65C02 optimisations
...
Use BIT immediate instead of AND when reloading A is required
afterwards.
Add an fread unit test as the optimisation touches fread.
Sprinkle a few zero page indexed while we're at it.
2024-02-02 19:45:49 +01:00
Colin Leroy-Mira
afd8ee627e
Remove useless branching code in fgets
2024-01-30 19:52:48 +01:00
Colin Leroy-Mira
2b97735d5d
Factorize file pointer check
2024-01-30 19:40:28 +01:00
Colin Leroy-Mira
1a5a7d67a7
Rewrite fputc in assembly
...
-36 bytes, -12% cycles
2024-01-30 17:19:13 +01:00
Colin Leroy-Mira
ba36071022
Rewrite fputs in assembly
...
-28 bytes, -1% cycles
2024-01-30 17:12:52 +01:00
Bob Andrews
8682095f9f
Merge pull request #2384 from colinleroy/asm-realloc
...
Rewrite realloc in asm
2024-01-27 00:28:17 +01:00
Colin Leroy-Mira
aa6f850b8d
Rewrite gets in assembler
...
+19 bytes if used alone, because it pulls in fgets, but as code is
factorized, -128 bytes in programs using both fgets and gets.
2024-01-26 20:29:17 +01:00
Colin Leroy-Mira
a8b870555e
Rewrite realloc in asm
...
-80 bytes, -39% cycles
2024-01-26 20:25:59 +01:00
Bob Andrews
65937684a0
Merge pull request #2380 from colinleroy/asm-fgetc
...
Rewrite fgetc in asm
2024-01-26 20:12:41 +01:00
Bob Andrews
ba6f9f5d3f
Merge pull request #2381 from colinleroy/asm-fgets
...
Rewrite fgets in asm
2024-01-26 19:36:57 +01:00
Colin Leroy-Mira
476591e8b7
Rewrite fgetc in asm
...
-82 bytes, -20% cycles
2024-01-25 09:13:39 +01:00
Bob Andrews
ee3a542539
Merge pull request #2383 from colinleroy/pmemalign-size-opt
...
Optimize -36 bytes out of posix_memalign
2024-01-24 21:26:50 +01:00
Bob Andrews
9ba270d97b
Merge pull request #2378 from colinleroy/fix-overflow-in-malloc-and-realloc
...
Fix malloc and realloc overflow
2024-01-24 21:15:31 +01:00
Colin Leroy-Mira
b87df9e1c6
Optimize -36 bytes out of posix_memalign
...
And add a unit test
2024-01-24 10:23:53 +01:00
Colin Leroy-Mira
1f820d0ae8
Rewrite fgets in asm
...
-104 bytes, -1% cycles
2024-01-24 10:16:26 +01:00
Colin Leroy-Mira
5d49fde788
add a return -1 helper
2024-01-24 09:58:09 +01:00
Colin Leroy-Mira
3e01ac9b04
Fix malloc and realloc overflow
...
If user requests a size >= 65532, adding the heap admin size
overflows size. Fixes #2358 .
2024-01-24 09:54:54 +01:00
Colin Leroy-Mira
10282a9b74
Rewrite asctime() in assembler (-7 bytes)
2024-01-18 09:09:38 +01:00