summaryrefslogtreecommitdiff
path: root/sys/src/libc
AgeCommit message (Collapse)Author
2023-05-09libc/arm64: sqrt() in assemblySigrid Solveig Haflínudóttir
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-03-08sys/src/libc/spim/mkfile: use port/lock.c and spim/tas.sadventuresin9
2023-03-08sys/src/libc/mips/tas.s: _tas() for spimadventuresin9
2023-03-06/sys/src/libc/mips/tas.s: remove _tas() problem elsewhereadventuresin9
2023-03-06/sys/src/libc/mips/tas.s: add _tas()adventuresin9
2023-02-22libc: fix strchr() for little endian mips (thanks adventuresin9)cinap_lenrek
adventuresin9 wrote: I finally found the time to get the kernel working for the Mediatek mt7688. Just the uart works now, so I still need to do the ethernet and hopefully wifi and other stuff. But it boots all the way to the bootargs ask, and then running !rc lets you run rc in paqfs. https://github.com/adventuresin9/9front-mt7688 I had a heck of a time getting it to work at first, till I tracked down an issue in strlen, that comes from the strchr code. Lots of stuff broke, and this bug also meant error messages wouldn't print properly. running this on the mt7688; int n1, n2, n3, n4, n5, n6; char *a1, *a2, *a3, *a4, *a5, *a6; a1 = "\0"; a2 = "A"; a3 = "AA"; a4 = "AAA"; a5 = "AAAA"; a6 = "AAAAA"; n1 = strlen(a1); n2 = strlen(a2); n3 = strlen(a3); n4 = strlen(a4); n5 = strlen(a5); n6 = strlen(a6); iprint("STRLEN %d %d %d %d %d %d\n", n1, n2, n3, n4, n5, n6); would get ; STRLEN 0 1 1 2 1 6 and now it gets; STRLEN 0 1 2 3 4 5
2023-02-19mkfiles: add 'mk test' supportOri Bernstein
9front has several tests scattered throughout the source, as well as more tests in an external 'regress' repository. Many of these tests are broken, because there is no easy way to build and track all of them. This pulls in several tests from different sources, deletes the broken tests, tests with missing data, and adds a single command that can be run from the root of the src directory to test our system. The hope is that as we develop new code, we add more tests, and eventually start running the tests on every commit. Please enter the commit message for your changes. Lines starting
2023-01-06libc: coding style (from drawterm)cinap_lenrek
2022-12-30libc: fix 32-bit arch vlong->double conversion (thans cosa)cinap_lenrek
Cosa wrote: While trying to run kvik's lu9 on ARM, I found that when converting LLONG_MIN to a double on 32bit systems, the result is wrong (positive instead of negative). Given the following test program: void main() { vlong min = LLONG_MIN; double dmin = min; print("minint %lld\n", min); print("minint as double %f\n", dmin); if (dmin > 0.0) { exits("int min as double turned positive"); } exits(0); } The output on x86_64 will be: minint -9223372036854775808 minint as double -9223372036854776400.000000 But on arm or 386 (and I expect also spim, 68000, mips, 68020, sparc, power, since they all use the same _v2d): minint -9223372036854775808 minint as double 9223372036854776400.000000 And the value turned positive in the conversion. The function used for the cast to double is (in /sys/src/libc/arm/vlrt.c): double _v2d(Vlong x) { if(x.hi & SIGN(32)) { if(x.lo) { x.lo = -x.lo; x.hi = ~x.hi; } else x.hi = -x.hi; return -((long)x.hi*4294967296. + x.lo); } return (long)x.hi*4294967296. + x.lo; } If I understand correctly, the issue is that where it tries to flip the sign for x.hi (x.hi = -x.hi), 0x80000000 has no positive, thus stays the same (it stays negative). Then when we get to the negative return, we get a positive out. What came to my mind then, is that in the case that there is no x.lo, we can keep the x.hi sign and cast directly, thus: double _v2d(Vlong x) {     if(!x.lo) {         return (long)x.hi*4294967296.;     }     if(x.hi & SIGN(32)) {         x.lo = -x.lo;         x.hi = ~x.hi;         return -((long)x.hi*4294967296. + x.lo);     }     return (long)x.hi*4294967296. + x.lo; } This looks correct to me, but I don't trust myself to not make mistakes in such critical code, so I would like some feedback on the change. Happy new year in advance, cosa
2022-12-25libsec: use /net/tls instead of #a/tlscinap_lenrek
Namespace files have been updated and the tls device is now available under /net.
2022-12-23libc: use /fd instead of #d in iounit()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-12-13devssl, cpu, import, oexportfs: deleteOri Bernstein
SSL is implemented by devssl. It's extremely obsolete by now, and is not used anywhere but cpu, import, and oexportfs. This change strips out the devssl bits, but does not (yet) remove the code from libsec.
2021-10-31libc: idn2utf()/utf2idn(): check for < 1 buffer, can't insert terminating NUL.cinap_lenrek
2021-10-31libc: fix overflow of domain component rune buffer for idn2utf()cinap_lenrek
If the source string has a run of more than 256 runes without a "." dot, we'd overflow the runebuffer in idn2utf(). The utf2idn() routine had a check in the while loop, but that is actually wrong too, as it would insert a dot and restart the loop in the middle of a domain component. Just error out if a domain component is too long.
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: use usize for sbrk() incrementcinap_lenrek
2021-07-25libc: change usize to 64-bit for amd64 and arm64, make memory(2) functions ↵cinap_lenrek
use usize
2021-07-23arm64: use generic timer virtual counter for cycles()cinap_lenrek
We used to use performance cycle counter for cycles(), but it is kind of useless in userspace as each core has its own counter and hence not comparable between cores. Also, the cycle counter stops counting when the cores are idle. Most callers expect cycles() to return a high resolution timestamp instead, so do the best we can do here and enable the userspace generic timer virtual counter.
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-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.