summaryrefslogtreecommitdiff
path: root/sys/src/libc/port
AgeCommit message (Collapse)Author
2023-04-08libc: Add poolreset() functioncinap_lenrek
This is intended for the secrmem pool in the kernel, but could also be used for temporary pools to recover the memory used by the arenas.
2023-03-29libc: runecomp: move generated files to explicit regen ruleJacob Moody
While a previous commit attempted to address the issues of a ; cd /sys/src/ && mk nuke && mk install it seems that any kind of automatic detection for when to rebuild will blow up in someones face. I am moving this to an explicit virtual rule, the generated files are expected to be there.
2023-03-26libc: runecomp: commit generated data filesJacob Moody
While mkfiles will properly build them, if a user does ; cd /sys/src && mk nuke && mk install without libc there, you will not be able to build mkrunetype.c in order to generate these data files. Let's not make this more complicated.
2023-03-26libc: remove dangling runetype.cJacob Moody
2023-03-26runecomp(2)Jacob Moody
2023-03-09print, strtod: fix -0 and -NaN, respect verb flags when formattingSigrid Solveig Haflínudóttir
2023-01-06libc: coding style (from drawterm)cinap_lenrek
2022-11-03libc: address kencc warning in date.cJacob Moody
2022-10-29tmdate: provide better parse errorsOri Bernstein
it's often not obvious what date component caused an error when eyeballing a date format string and date; make the error message contain this information.
2022-05-22shorten strchr and runestrchrAmavect
2022-05-26tmparse: remove incorrect isalpha definitionMichael Forney
Checking the range of c|0x60 incorrectly classifies many characters as alphabetic (digits, control characters 0x01-0x20, and punctuation characters '!'-':'). This prevents tmparse from parsing dates with a timezone bounded by those characters (for example, "12:11:56 (PDT)"). Instead, just reuse the isalpha macro provided by ctype.h.
2022-01-10reduce: use if() to test for exit status of pipelinecinap_lenrek
The new rc's exit status will be '' for a successfull pipeline execution instead of '|'. This is a bit too tightly coupled, so just use if() statement instead, handling this in a portable way.
2021-08-11qsort: allow usize-sized arrays.Ori Bernstein
As part of the transition to 64 bit userspace APIs, we need to make our libc functions which take arrays all accept and deal with large sizes. This does the work for qsort.
2021-07-25libc: change usize to 64-bit for amd64 and arm64, make memory(2) functions ↵cinap_lenrek
use usize
2021-07-03libc: add encode(2) variants for custom alphabetsOri Bernstein
There are a number of alphabets in common use for base32 and base64 encoding, such as url-safe encodings. This adds support for passing a function to encode into arbitary alphabets.
2020-12-23libc: re-implement getuser() by stating /proc/$pid/statuscinap_lenrek
The idea is to avoid the magic files that contain per process information in devcons when possible. It will make it easier to deprecate them in the future.
2020-12-07libc: open internal file-descriptor with OCEXEC flagcinap_lenrek
2020-11-01libc: recurse on smaller half of arrayOri Bernstein
Our qsort has an optimization to recurse on one half of the array, and do a tail call on the other half. Unfortunately, the condition deciding which half of the array to recurse on was wrong, so we were recursing on the larger half of the array and iterating on the smaller half. This meant that if we picked the partition poorly, we were pessimizing our stack usage instead of optimizing it. This change reduces our stack usage from O(n) to O(log(n)) for poorly chosen pivots.
2020-09-22libc: ignore '?' in date format stringsOri Bernstein
Ignoring '?' when formatting date strings allows the format strings to be reused for parsing. This is convenient, since we don't need to duplicate the format strings.
2020-09-22libc: make yday 0-based, as docs suggestOri Bernstein
Tm.yday is docuemnted as being 0-based, and our new api should respect that. Fix the code so that this is true.
2020-09-01tmparse: put in local timezone hackOri Bernstein
Ctime is defined as printing a 3-character timezone name. The timezone name is ambiguous. For example, EST refers to both Australian and American eastern time. On top of that, we don't want to make the tzabbrev table exhaustive. So, we put in this hack: Before we consult the well known table of timezones, we check if the local time matches the timezone name. On top of that, tm2sec If you want unambiguous timezone parsing, use numeric timezone offsets (Z, ZZ formats).
2020-08-26tmparse: fix typoOri Bernstein
2020-08-26libc: tmparse should ignore leading whitespaceOri Bernstein
We almost always want to skip leading whitespace in time formats, so make tmparse just do it. This fixes upas mbox parsing, which leaves a leading whitespace at the start of the date.
2020-08-09libc: new date apisOri Bernstein
The current date and time APIs on Plan 9 are not good. They're inflexible, non-threadsafe, and don't expose timezone information. This commit adds new time APIs that allow parsing arbitrary dates, work from multiple threads, and can handle timezones effectively.
2020-06-15libc: revert date change again. this is getting ridicuoulus.cinap_lenrek
this breaks the sample from the seconds manpage, and overall produces funky results. this needs alot more testing. term% seconds '23 may 2011' seconds: tmparse: invalid date 23 may 2011 near 'may 2011' term% seconds '2019-01-01 00:00:00' -118370073600
2020-06-14libc, seconds: new time and date apis (try 2)Ori Bernstein
Redo date handling in libc almost entirely. This allows handling dates and times from outside your timezones, fixes timezone loading in multithreaded applications, and allows parsing and formatting using custom format strings. As a test of the APIs, we replace the formatting code in seconds(1), shrinking it massively. The last commit missed a few removals, and made it unnecessarily hard to do an update.
2020-06-14libc: reverting previous change until ori can fix itcinap_lenrek
2020-06-13libc, seconds: new time and date apis.Ori Bernstein
Redo date handling in libc almost entirely. This allows handling dates and times from outside your timezones, fixes timezone loading in multithreaded applications, and allows parsing and formatting using custom format strings. As a test of the APIs, we replace the formatting code in seconds(1), shrinking it massively.
2019-06-16Handle NaN and Inf edge cases as specified by posix, instead of barfing.Ori Bernstein
We're not a posix system, but the posix spec is a good reference for what we should do. Thanks Geoff for the inspiration for this patch.
2019-05-05libc: fix NaN check precedence bug in modf() (thanks BurnZeZ)cinap_lenrek
2017-12-31libc: constant time implementation for encode(2) routines, fix base32cinap_lenrek
the string encoding functions touch secret key material in a bunch of places (devtls, devcap), so make sure we do not leak information by cache timing side channels, making the encoding and decoding routines constant time. we also expose the alphabets through encXchr()/decXchr() functions so caller can find the end of a encoded string before calling decode function (for libmp). the base32 encoding was broken in several ways. inputs lengths of len%5 == [2,3,4] had output truncated and it was using non-standard alphabet. documenting the alphabet change in the manpage.
2017-10-20libc: cleanup atexit and put exits() in its own compilation unitcinap_lenrek
this avoids having to pull in atexit() and its dependencies (lock(), unlock()) into every program. (as exits() is called by _main() from main9.s).
2016-11-05libc: move calloc() into its own compilation unitcinap_lenrek
move calloc() in its own compilation unit to avoid code duplication. also, calloc() is used rarely in plan9 programs.
2016-09-11libc: dont use floating point for portable umuldiv(), use 64 bit uvlongcinap_lenrek
2016-08-27libc: add poolisoverlap() and definitions for Pool *secrmemcinap_lenrek
2016-04-13libc: remove unneeded #include <auth.h> for crypt() and netcrypt()cinap_lenrek
2016-03-19libc: trailing whitespace cleanupBurnZeZ
2016-03-16libc: fix runestrecpy() return value (thanks spew)cinap_lenrek
2015-08-03libc: make atoi() not parse c-style octal and hex numberscinap_lenrek
interpreting octal breaks parsing of decimal numbers with leading zeros. the manpage listed this in the BUGS section, so we'r going to fix it as this just causes confusion as most callers of atoi() do not expect it.
2015-04-08pool: avoid triggering assert(b->magic != FREE_MAGIC) in blocksetsize() for ↵cinap_lenrek
mallocalignl() when we trim the front of a block with freefromfront(), the block magic of the back was not initialized which could sometimes trigger the assert in blocksetsize() to fail. fix is to just move the initialization of the magic field before the blocksetsize() call. the second b->magic = UNALLOC_MAGIC isnt really required but just done for consistency with the trim() code above.
2015-02-26pool: maintain Pool.curalloc for poolallocalign() and blockgrow()cinap_lenrek
blockgrow() and poolallocalign() change the size of allocated blocks which needs to be accounted for in Pool.curalloc.
2015-01-05pool: more strict checktree() for poolcheckcinap_lenrek
check that Free.next and Free.prev pointers are not nil. check that Free.left and Free.right are Poison in non-tree nodes. check that Free.left and Free.right are *not* Poison in tree nodes. change Poison to 0xffffffffcafebabe for 64bit machines.
2014-02-17prof: properly save and restore RARG for amd64cinap_lenrek
amd64 passes first argument in RARG (BP) register which has the be preserved duing _profin() and _profout() calls. to handle this we introduce _saveret() and _savearg(). _saveret() returns AX, _savearg() returns RARG (BP). for archs other and amd64, _saveret() and _savearg() are the same function, doing nothing. restoing works with dummy function: uintptr _restore(uintptr, uintptr ret) { return ret; } ... ret = _saveret(); arg = _savearg(); ... return _restore(arg, ret); as we pass arg as the first argument, RARG (BP) is restored.
2014-02-14libc: remove malloc.acid and pool.acidcinap_lenrek
2014-02-06pool: use uintptr for pool sizecinap_lenrek
note, arenas and blocks still use ulong for sizes. so we have to check for overflow when attempting to merge arenas.
2014-02-02malloctag: only store lower 32bit of malloc tag, fix getrealloctagcinap_lenrek
as erik quanstro suggests, theres not much of a point in storing the full 64bit pc as one cannot get a code segment bigger than 4G and amd64 makes it hard to use a pc that isnt 64bit sign extension of 32bit. instead, we only store ulong (as originally), but sign extend back when returning in getmalloctag() and getrealloctag(). getrealloctag() used to be broken. its now fixed.
2014-02-02mallocalign: make sure alignptr offset is modulo align when -offset > aligncinap_lenrek
2014-01-20malloc: change malloc and realloc tag types to uintptrcinap_lenrek
2013-12-17pool: update debug log format string for poolallocalign()cinap_lenrek
2013-10-17libc: updated acid files for 21 bit rune changecinap_lenrek