summaryrefslogtreecommitdiff
path: root/sys/src/libc
AgeCommit message (Collapse)Author
2020-12-29libc/arm: open #c/sysstat file with OCEXEC (internal file descriptor)cinap_lenrek
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-19libc: implement getppid() reading /proc/$pid/ppid instead of /dev/ppidcinap_lenrek
The devcons driver is really the wrong place to serve per process information.
2020-12-09backout OCEXEC changes when potentially opening /srv filescinap_lenrek
Opening a /srv file sets the close-on-exec flag on the shared channel breaking the exportfs openmount() hack. The devsrv tries to prevent posting a channel with the close-on-exec or remove-on-close flags. but nothing currently prevents this poisoning on open. Until this gets fixed in eigther exportfs or devsrv, i'll back out the changes that could have potential side effects like this.
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-24tm2sec: clear new fields in tmOri Bernstein
Old users of the time APIs would hand-craft time structs without first zeroing all the members. When this got into tmnorm(), we would try to access the new members, and things would go off the rails. This makes tm2sec() clear the new fields before passing them to the new APIs, so that the hand-crafted structs remain valid.
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.
2020-05-17libc/arm64: work arround linker bug for cas()cinap_lenrek
at the _cas0 label, the linker would generate spurious stack adjustment before the return: atexitdont+0x84 0x000000000003614c CLREX $0xf atexitdont+0x88 0x0000000000036150 MOVW R31,R0 atexitdont+0x8c 0x0000000000036154 MOV (SP)16!,R30 <- ???????????? atexitdont+0x90 0x0000000000036158 RETURN the work arround is to move the code into its own cas0 text symbol. this fixes impossible cwfs crashes in srvi().
2019-06-16Add test for pow.cOri Bernstein
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-09libc: fix return value for arm64 memset() and memove()cinap_lenrek
2019-05-09libc: use MOVP instruction for arm64 memmove() and memset()cinap_lenrek
2019-05-09libc: provide arm64 assembly versions for memmove() and memset()cinap_lenrek
just a first approximation, uses unaligned 8 byte loads and stores. MOVP not yet implemented by the linker. no ZVA cache magic yet.
2019-05-05libc: fix NaN check precedence bug in modf() (thanks BurnZeZ)cinap_lenrek
2019-05-03libc: initial arm64 supportcinap_lenrek
2018-09-26libc: add procsetname()cinap_lenrek
2018-09-26libc: return number of bytes produced for idn2utf() and utf2idn()cinap_lenrek
2018-09-25libc: add utf2idn() and idn2utf() functions to deal with internationalized ↵cinap_lenrek
domain names
2018-04-14libc: allow /net/cs to specify local address for dial()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-28libc: improve alignment of QLp structure on amd64, cosmeticscinap_lenrek
the QLp structure used to occupy 24 bytes on amd64. with some rearranging the fields we can get it to 16 bytes, saving 8K in the data section for the 1024 preallocated structs in the ql arena. the rest of the changes are of cosmetic nature: - getqlp() zeros the next pointer, so there is no need to set it when queueing the entry. - always explicitely compare pointers to nil. - delete unused code from ape's qlock.c
2017-10-26libc: wunlock() part 2cinap_lenrek
the initial issue was that wunlock() would wakeup readers while holding the spinlock causing deadlock in libthread programs where rendezvous() would do a thread switch within the same process which then can acquire the RWLock again. the first fix tried to prevent holding the spinlock, waking up one reader at a time with releasing an re-acquiering the spinlock. this violates the invariant that readers can only wakup writers in runlock() when multiple readers where queued at the time of wunlock(). at the first wakeup, q->head != nil so runlock() would find a reader queued on runlock() when it expected a writer. this (hopefully last) fix unlinks *all* the reader QLp's atomically and in order while holding the spinlock and then traverses the dequeued chain of QLp structures again to call rendezvous() so the invariant described above holds.
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-06-26libc: native _addv() and _subv() routines for armcinap_lenrek
2016-05-04retire the dec alpha portcinap_lenrek
2016-04-13libc: fix out of bounds access in dirpackage(), simplifycinap_lenrek
- dirpackage() was not checking if the stat entry lies within the buffer. fixed. - simplify dirpackage(), as we process all the bytes from the buffer, we do not need to track "ss" here as its the same as "ts". - zero Dir* array pointer early in dirread() and dirreadall() and avoid calling dirpackage on <= buffer length.
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
2016-01-07introduce signed intptr and %z format modifier for formating uintptr and intptrcinap_lenrek
2015-10-04libc: add _uv2d()/uv2f() and _vas*d() functions to vlrt.ccinap_lenrek
on 32 bit archs, implement 64 bit vasop with floatingpoint right hand side. also added is uvlong->double conversion function.
2015-09-06libc: remove privfree(), simplify privalloc()cinap_lenrek
2015-08-25fix fuckupglenda
2015-08-25import E script from bell labsmischief
2015-08-25libc: import more endianness fixes (thanks cherry9)mischief
from https://bitbucket.org/cherry9/plan9-loongson/
2015-08-10libc: fix wunlock() libthread deadlockcinap_lenrek
when wunlock() was used by threads running within the same proc, the wunlock() can deadlock as it keeps holding the RWLock.lock spinlock while indirectly calling _threadrendezvous(). when _threadrendezvous() switches to another thread in the same proc, then that thread can hang at rlock()/wlock()/runlock() again waiting for wunlock() to release the spinlock which will never happen as lock() does not schedule threads. wunlock() is changed to release the spinlock during rendezvous wakeup of readers. note that this is a bit dangerous as more readers might queue concurrently now which means that if we cannot keep up with the wakeups, we might keep on waking readers forever. that will be another patch for the future.
2015-08-09libc: fix spim endiannessmischief