Refactor _PDCLIB_strtox_main to reduce parameters to 5#26
Refactor _PDCLIB_strtox_main to reduce parameters to 5#26choury wants to merge 1 commit intoDevSolar:masterfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This pull request refactors the internal _PDCLIB_strtox_main function to reduce its parameter count from 6 to 5 parameters to meet eBPF architecture constraints, which supports a maximum of 5 function arguments. The refactoring consolidates the overflow boundary parameters (limval and limdigit) into a single limit parameter, with the individual boundary values now computed inside the function.
Changes:
- Function signature updated to accept a single
limitparameter instead of separatelimvalandlimdigitparameters - All callers updated to pass the limit value, with division and modulo operations moved from call sites into the function
- Test cases updated to reflect the new parameter structure
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| include/pdclib/_PDCLIB_internal.h | Updated function declaration to remove limval and limdigit parameters, replaced with single limit parameter |
| functions/_PDCLIB/_PDCLIB_strtox_main.c | Modified implementation to compute limval and limdigit from limit parameter internally; updated test cases |
| functions/stdlib/strtoull.c | Updated caller to pass ULLONG_MAX as limit instead of pre-computed division/modulo values |
| functions/stdlib/strtoul.c | Updated caller to pass ULONG_MAX as limit instead of pre-computed division/modulo values |
| functions/stdlib/strtoll.c | Updated callers for both positive and negative cases; negative case now uses LLONG_MAX + 1 as limit |
| functions/stdlib/strtol.c | Updated callers for both positive and negative cases; negative case now uses LONG_MAX + 1 as limit |
| functions/inttypes/strtoumax.c | Updated caller to pass UINTMAX_MAX as limit instead of pre-computed division/modulo values |
| functions/inttypes/strtoimax.c | Updated callers for both positive and negative cases; negative case now uses INTMAX_MAX + 1 as limit |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| #ifndef REGTEST | ||
|
|
||
| _PDCLIB_uintmax_t _PDCLIB_strtox_main( const char ** p, unsigned int base, uintmax_t error, uintmax_t limval, int limdigit, char * sign ) | ||
| _PDCLIB_uintmax_t _PDCLIB_strtox_main( const char ** p, unsigned int base, uintmax_t error, uintmax_t limit, char * sign ) |
There was a problem hiding this comment.
The file header comment at line 1 needs to be updated to reflect the new function signature. It currently shows the old signature with 5 parameters (limval and limdigit as separate int parameters), but the function now takes 4 parameters after the base plus the sign pointer, with limit replacing limval and limdigit.
|
That's a nice improvement. I'll have a look at it within the week. |
I am currently porting several functions to the eBPF architecture, which supports a maximum of only 5 arguments per function call. To meet this constraint, I have refactored the internal _PDCLIB_strtox_main function to reduce its parameter count from 6 to 5 by consolidating the overflow boundary arguments into a single limit parameter.