summaryrefslogtreecommitdiff
path: root/sys/src/ape/lib/ap
AgeCommit message (Collapse)Author
2022-10-31ape: fix warning building mkstempOri Bernstein
mkstemp uses mktemp, which is only declared when including files with _BSD_SOURCE, so define _BSD_SOURCE before including the headers
2022-03-14ape: fix wrong write size for _assert()cinap_lenrek
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-10ape/mkstemp: better optionsBenjamin Riefenstahl
Use O_EXCL and make the file descriptor writeable. This is more usefull and it conforms to Single Unix and other specs.
2022-01-03ape: allow exporting rc functions in environ[]cinap_lenrek
2021-01-30ape/libm: implement log2 in libcOri Bernstein
2021-01-23ape/libm: add back fmod, remove modfOri Bernstein
We removed the wrong file. Put it back.
2021-01-24ape: update mkfile for removed fmod.cqwx
2021-01-23ape: apply infinite recursion in fmod() fix (thanks jxy and ality)cinap_lenrek
Apply changeset 2880:cab2b9d13a73 to ape's fmod() implementation. Remove the unused math/fmod.c copy.
2021-01-19ape/libap: fix _startbuf, check rfork return (thanks pixelherodev)Ori Bernstein
When _startbuf is invoked, it would crash on the second invocation if creating a mux segment failed. This is because the first attempt would assign the return value -1 to the global mux variable, and the second attempt would notice that the global mux was not nil, and would attempt to use it. This change only assigns to the global variable if the allocation of the segment was a success. While we're here, we should also check the return of the rfork call.
2020-12-23ape: re-implement getlogin() by stating /proc/$pid/statuscinap_lenrek
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-18strndup: don't assume buffer is terminatedOri Bernstein
Using strlen in strndup will walk past the first n bytes up to the terminator, which may not be present. This is not what we want. While we're here, do some cleanups.
2020-12-17libap: add strndupOri Bernstein
strndup is part of POSIX.1, so APE should provide it. This patch adds it, so need to patch it out of fewer programs going forward.
2020-08-29ape/ctype.h: add isblank, fix functions (thanks staalmannen)Ori Bernstein
Our ctype.h mistakenly ommitted isblank. Add it in. While we're here, the make the 'isfoo()' functions are broken: they're offsetting into the array, and don't work with negative character values. Sync the function bodies with the macros, and make them produce correct results.
2020-05-15Fix scans of more than one character in %[]Ori Bernstein
This got broken in d8e877a89dae, where we returned 0 on the first mismatch; we want to return 0 only when we consumed no characters.
2020-05-12[ape] add missing conversion flags for scanfOri Bernstein
We're missing type flags for: hh: char ll: vlong z: size_t t: ptrdiff_t j: intmax_t The lack of '%lld' was causing us to fail when parsing timezone files. This brings us in line with the specifiers in the C99 standard, section 7.19.6.2p11
2020-05-09fix '%[]' specifiers and '%n' (thanks phil9)Ori Bernstein
When a match() fails, we need to unget the character we tried to match against, rather than leaving it consumed. Also, we can't break out of a conversion before we reach the end of a format string, because things like the '%n' conversion do not consume anything, and should still be handled.
2020-03-09fix alignment in ape mallocOri Bernstein
We used to have a padding int in the structure after the next pointer, to align it to 16 bytes. On 64 bit architectures, the pointer was already 8 bits, so the padding misaligned things to 20 bytes. This fixes it so that we're explcit about the data alignment we want, instead of hoping that the various sizes line up.
2020-02-10remove C99_SPRINTF_EXTENSION define.Ori Bernstein
It's been 20 years since c99 came out. By now, if code hasn't been fixed, it's not going to be. Requiring this define just confuses porters.
2019-09-09ape: Add mkstemp to /sys/src/ape/lib/ap/gen/mkfileRoberto E. Vargas Caballero
2019-09-09Add mkstemp to stdlib.hRoberto E. Vargas Caballero
q
2019-06-24ape: reimplement rename() - fixing compiler warnings and handling more error ↵cinap_lenrek
cases handle empty filename, dot and dotdot. handle mismatching from/to directory/file type. cleanup destination file on error. error when attempting to copy non-empty directories. little test program: #include <unistd.h> #include <stdio.h> int main(int argc, char *argv[]) { if(argc != 3){ fprintf(stderr, "usage: %s old new\n", argv[0]); return 1; } if(rename(argv[1], argv[2])){ perror("rename"); return 1; } return 0; }
2019-06-23ape: revert rename() changecinap_lenrek
new implementation gets stuck in a infinite loop. backing this out for now.
2019-06-21Turn on warnings when building libap.Ori Bernstein
For ape, we never enabled warnings in cflags. Turning it on brings up a lot of warnings. Most are noise, but a few caught unused variables and trunctaions of pointers. to smaller integers (int, long). A few warnings remain.
2019-05-10ape: fix malloc to deal with more than 4GB of memory on 64 bit systemscinap_lenrek
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-03ape: initial support for arm64cinap_lenrek
2018-07-03ape: fix MAXSIGspew
2018-07-01ape: an implemenation of getitimer setitimerspew
2018-06-21ape: add strnlenspew
2018-06-20ape: provide bogus chroot implementationspew
2018-06-17ape: add some common fields for stat, grp and pwdspew
2018-05-24ape: floating point improvements (thanks spew)aiju
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
2016-11-27stdio: fix sclose() buffer overrun when terminating string, realloc() error ↵cinap_lenrek
handling (thanks porlock) theres a bug is in sclose() where it doesnt check if wp is beyond the buffer. also wp was not updated after realloc(). bug was reported by porlock on 9fans: Plan 9's implementation of the standard C functions snprintf and vsnprintf have a buffer overrun bug. If the buffer length equals the output length (without the terminating null), then one too many characters is written to the buffer. For example, snprintf(buf, 4, "ABCD"); will write 5 characters to buf.
2016-08-28ape: add d_stat struct in dirent struct allowing the avoidance of statscinap_lenrek
2016-05-04retire the dec alpha portcinap_lenrek
2016-05-04ape: return plan9 error strings from strerror()cinap_lenrek
when _syserrno() fails to map a plan9 error string to a unix error number, we copy the plan9 error string to the per process error buffer "plan9err" and set errno = EPLAN9. when strerror() is called with EPLAN9, it returns a pointer to the plan9err buffer.
2016-04-10ape: remove broken 9errstr.ccinap_lenrek
2016-04-10ape: add internal _NSEC() function and make gettimeofday() use itcinap_lenrek
2016-01-07ape/stdio: %z format is VLONG on amd64cinap_lenrek
2015-10-04ape: add missing _subv() function to 386/vlop.scinap_lenrek
2015-10-04ape: add machine specific code for spimcinap_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-08-08ape: fix build for objtype=spimcinap_lenrek
2015-08-04ape: implement altzone for tzset()cinap_lenrek
2015-08-04ape: fix mktime() againcinap_lenrek