Commit graph

153 commits

Author SHA1 Message Date
Benjamin Riefenstahl e402fd8340 ape/bsd/bind.c, ape/bsd/listen.c: Use _syserrno. 2022-07-06 03:46:07 +00:00
Benjamin Riefenstahl e01e80c5e7 ape/bsd/listen.c: Drop "bind 0".
There does not seem to be a good reason for this.  The "bind" command
has no practical consequence.
2022-07-06 03:38:17 +00:00
Benjamin Riefenstahl 2ca5abbc2b ape/bsd/bind.c: Do not pretend that the port could be negative.
Ports are filtered through "htons" which returns an "unsigned short".
2022-06-11 12:34:31 +00:00
Benjamin Riefenstahl 25a0d57478 ape/bsd/bind.c, ape/bsd/listen.c: Set local IP.
Despite what the man pages say, local addresses can actually be set so
do that.
2022-06-10 20:39:28 +00:00
Benjamin Riefenstahl d618223086 ape/bsd/listen.c: Do not try to issue "announce *".
"port >= 0" is always true, because the port always gets filtered
through "htons" which returns "unsigned short", so we can just drop
the "else" branch here.

Anyway "announce 0" works fine with the Plan9 API, there is not need
for "announce *" here.
2022-06-10 20:22:39 +00:00
Benjamin Riefenstahl 9fc38d43d4 ape/bsd/bind.c: Do not issue "bind *".
Despite the documentation, "bind *" is invalid and gives the error
"bad numeric port" in devip.c:setladdrport.

"bind 0" OTOH is actually supported fine in the Plan9 API and has the
right sematics.
2022-06-10 16:02:13 +00:00
cinap_lenrek d4e89fe76a ape: fix wrong write size for _assert() 2022-03-14 11:16:11 +00:00
cinap_lenrek 85bfb0e9eb reduce: use if() to test for exit status of pipeline
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.
2022-01-10 02:01:11 +00:00
Benjamin Riefenstahl bf322dfbf3 ape/mkstemp: better options
Use O_EXCL and make the file descriptor writeable.  This is more
usefull and it conforms to Single Unix and other specs.
2021-12-10 20:44:26 +00:00
cinap_lenrek b34fc2a9cf ape: allow exporting rc functions in environ[] 2022-01-03 18:47:56 +00:00
Ori Bernstein 7b4e3be27e ape: add missing idn2utf, utf2idn to lib9
this fixes the libsec build under ape.
2021-10-31 04:42:34 +00:00
Ori Bernstein 6445a14f63 ape/lib9: expose fd2path (thanks phil9)
Fd2path is a useful call for the netsurf plan9 frontend,
so we should expose it.
2021-02-20 21:02:07 -08:00
Ori Bernstein 2d8adc7b88 ape/lib9: sync arm getfcr.s implementation
The arm assembler supports movw to handle
getfcr and setfcr now, no need to hack it
with macros; sync from plan9 libc.
2021-02-08 16:07:09 -08:00
Ori Bernstein bb250c4c3b ape/libm: implement log2 in libc 2021-01-30 09:19:57 -08:00
Ori Bernstein f76e28cb71 ape/libm: add back fmod, remove modf
We removed the wrong file. Put it back.
2021-01-23 20:03:07 -08:00
qwx 41f85d46f8 ape: update mkfile for removed fmod.c 2021-01-24 00:58:47 +01:00
cinap_lenrek 6d012d2df0 ape: apply infinite recursion in fmod() fix (thanks jxy and ality)
Apply changeset 2880:cab2b9d13a73 to ape's fmod() implementation.

Remove the unused math/fmod.c copy.
2021-01-23 15:53:56 +01:00
Ori Bernstein 1047b53efc ape/libap: fix _startbuf, check rfork return (thanks pixelherodev)
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.
2021-01-19 19:56:38 -08:00
cinap_lenrek a7a08647b6 ape: re-implement getlogin() by stating /proc/$pid/status 2020-12-23 02:32:13 +01:00
cinap_lenrek fc5070c600 libauth: add procsetuser() function to change user id of the calling process
Provide a central function to change the user id
of the calling process.

This is mostly used by programs to become the none
user, followed by a call to newns().
2020-12-19 17:46:55 +01:00
cinap_lenrek 672cf179a1 libc: implement getppid() reading /proc/$pid/ppid instead of /dev/ppid
The devcons driver is really the wrong place to
serve per process information.
2020-12-19 15:15:38 +01:00
Ori Bernstein 2db3642b8d strndup: don't assume buffer is terminated
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-18 07:16:29 -08:00
Ori Bernstein 658c1b9f68 libap: add strndup
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-12-17 19:20:04 -08:00
Ori Bernstein ec533a1ad8 ape/ctype.h: add isblank, fix functions (thanks staalmannen)
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-08-29 11:09:20 -07:00
Ori Bernstein db6e26d55e libplumb: add missing mkfile 2020-06-09 12:23:24 -07:00
Ori Bernstein 702bb7a508 ape: add missing rerrstr.c 2020-06-05 18:52:22 -07:00
Ori Bernstein f08e95cd93 ape: make libplumb available under ape.
This adds the mkfiles and plumb.h to ape,
similar to how libdraw is made available.
This is used for ports such as netsurf.
2020-06-05 11:28:47 -07:00
Ori Bernstein 5cd7f7b0ec ape/libdraw: add missing eenter (thanks phil9) 2020-05-30 10:06:21 -07:00
Ori Bernstein 78aec6d5c6 Fix scans of more than one character in %[]
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-15 16:46:20 -07:00
cinap_lenrek 1c4c82277e ape: fix name clash, have to use _SLEEP syscall instead of ape sleep in plan9 code (thanks jamos)
this fixes etimer() from ape built libdraw as posix sleep() uses
seconds while plan9 uses miliseconds.
2020-05-13 00:17:07 +02:00
Ori Bernstein 73f38fc546 [ape] add missing conversion flags for scanf
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-12 10:48:33 -07:00
Ori Bernstein bfc8cdfff5 fix '%[]' specifiers and '%n' (thanks phil9)
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-05-09 15:10:39 -07:00
Ori Bernstein 698837e715 fix alignment in ape malloc
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-03-09 08:02:22 -07:00
cinap_lenrek 64640083de libsec: remove hash pickle functions, document ripemd160, cleanup sechash(2) manpage 2020-03-01 15:07:44 +01:00
Ori Bernstein 98374d6eea remove C99_SPRINTF_EXTENSION define.
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.
2020-02-10 19:26:39 -08:00
cinap_lenrek f8de863602 ape: don't hardcode list of ape library directories in /sys/src/ape/lib/mkfile
this change allows one to drop library directories (like
freetype) into /sys/src/ape/lib/ and have them built without
having to change the mkfile.
2019-09-16 16:21:40 +02:00
Roberto E. Vargas Caballero 42240127a7 ape: Add mkstemp to /sys/src/ape/lib/ap/gen/mkfile 2019-09-09 17:27:57 +01:00
Roberto E. Vargas Caballero e0720a48b0 Add mkstemp to stdlib.h
q
2019-09-09 15:58:39 +01:00
cinap_lenrek 6118d77858 ape: reimplement rename() - fixing compiler warnings and handling more error 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-24 20:09:04 +02:00
cinap_lenrek 7d3cc1c55a ape: revert rename() change
new implementation gets stuck in a infinite loop. backing
this out for now.
2019-06-23 22:35:14 +02:00
Ori Bernstein d4bc9052be Turn on warnings when building libap.
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-06-21 10:00:58 -07:00
cinap_lenrek addb36ee48 ape: fix malloc to deal with more than 4GB of memory on 64 bit systems 2019-05-10 12:10:02 +02:00
cinap_lenrek a375c9ac38 libc: fix return value for arm64 memset() and memove() 2019-05-09 12:40:03 +02:00
cinap_lenrek 57e0786595 libc: use MOVP instruction for arm64 memmove() and memset() 2019-05-09 11:40:54 +02:00
cinap_lenrek 4e7fbabfc9 libc: provide arm64 assembly versions for memmove() and memset()
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-09 02:32:09 +02:00
cinap_lenrek 2994fccbe1 ape: initial support for arm64 2019-05-03 21:06:46 +02:00
spew 77ca4e0056 ape: fix MAXSIG 2018-07-03 14:41:14 -04:00
spew ede15f38e5 ape: remove getitimer setitimer implemenations 2018-07-03 12:28:05 -04:00
spew 2e05af858e ape: improve setitimer 2018-07-01 23:35:23 -04:00
spew 91d0343627 ape: an implemenation of getitimer setitimer 2018-07-01 18:48:12 -04:00