Commit graph

231 commits

Author SHA1 Message Date
Ori Bernstein c1c904776c ape/limits.h: fix typo in (U)LLONG_MAX
Fix missing 'L' in the size suffix, so we were overflowing the
maximum size.
2020-09-21 11:43:31 -07: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 46faca54ed stdio.h: correct return type of putc
The putc macro is specified as returning an int, but our
type conversion rules turned it into a uint. Put in the
appropriate cast to make the type what we want.
2020-08-10 19:36:09 -07:00
Ori Bernstein 56e869ac70 libc: new date apis
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-08-09 18:58:44 -07:00
Ori Bernstein 2d59d75e3a stdio: fix warnings, make code more standard
Masking with _IO_CHMASK after the assignment causes a warning.
We're better off masking before, but casting the assignment to
prevent sign extension.
2020-07-19 14:14:14 -07:00
Ori Bernstein 1987cc69c8 stdio, ape/stdio: fix order of operations in putc
When calling putc, we need to return either EOF
or the character returned. To distinguish the
two, we need to avoid sign extending 0xff. The
code attempted to do this, but the order of
operations was wrong, so we ended up masking,
setting a character, and then sign extending
the character.

This fixes things so we mask after assignment.
2020-07-11 13:28:58 -07:00
cinap_lenrek febe84af75 libc: revert date change again. this is getting ridicuoulus.
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-15 00:12:57 +02:00
Ori Bernstein 8b3efcfc4e libc, seconds: new time and date apis (try 2)
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-14 09:33:32 -07:00
cinap_lenrek f380851ddb libc: reverting previous change until ori can fix it 2020-06-14 04:47:22 +02:00
Ori Bernstein e2ee991490 libc, seconds: new time and date apis.
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-06-13 12:38:49 -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 f860f25f05 Add stdbool.h to ape
in accordance with c99:7.16. Used by perl, trivial enough
that I feel ok with adding it before the port is fully done.
2020-05-17 08:18:49 -07: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 5749900573 bring stdint.h closer to spec
C99 requires that if intXX_t types are defined, int_fastxx_t and
int_leastxx_t types are defined as well. We define all three to
be identical (intXX_t == int_fastXX_t == int_leastXX_t).
2020-05-06 15:39:12 -07:00
Ori Bernstein d935bb25d2 use #error when missing define
This makes it easier to figure out what's going wrong when
we forget to define _POSIX_SOURCE.
2020-05-01 13:29:08 -07:00
Ori Bernstein 8ebe958ddf add missing header change (thanks qwx) 2020-04-26 09:03:42 -07:00
BurnZeZ 11025d6f4a lib9p: fix re-use of root Qid when using createfile(); remove unused dirqidgen 2020-03-29 17:39:30 +00:00
Ori Bernstein 2f67e21393 turn ptrdiff_t into a 64 bit type
while technically a 32 bit ptrdiff_t is in spec on
systems with 64 bit ponters as long as we guarantee
that individual objects are small enough, this can
confuse legitimate code, so lets fix this.
2020-03-24 14:45:15 -07:00
Ori Bernstein 0e1fec841e add intmax_t/uintmax_t as required by c99 7.18.1.5 2020-03-24 14:41:31 -07:00
cinap_lenrek e9e55a21f6 lib9p: implement automatic remove-on-close cleanup in postsharesrv(), remove postfd() and sharefd() functions
with the latest changes to shr(3), we can use ORCLOSE on
the control file to get the mount in the share automatically
removed when the server exits or something goes wrong during
postsharesrv().

do not expose postfd() and sharefd() functions. they where
undocumented and leak the control file descriptors.
2020-03-08 22:00:23 +01:00
cinap_lenrek 225c359bea lib9p: get rid of Srv.nopipe and Srv.leavefdsopen hacks
it is unclear how Srv.nopipe flag should work inside
postmountserv(). if a server wants to serve on stdio
descriptors, he can just call srv() after initializing
Srv.infd and Srv.outfd.

The Srv.leavefdsopen hack can be removed now that acme
win has been fixed.
2020-03-07 20:19:14 +01:00
cinap_lenrek 2f976d8b56 libsec: move AES XTS function prototypes to AES definition section in the header file 2020-03-01 16:02:56 +01: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
Roberto E. Vargas Caballero 5e9d8a7b18 Add toascii() to ape 2019-09-09 16:00:06 +01:00
Roberto E. Vargas Caballero e0720a48b0 Add mkstemp to stdlib.h
q
2019-09-09 15:58:39 +01:00
Ori Bernstein ff9ce8210a Include integer limits from generic stdint.h in system-specific stdint.h 2019-09-06 18:01:52 -07:00
Ori Bernstein c09546ccea Add missing UINTsz_MIN defines to ape stdint.h 2019-09-06 16:33:11 -07:00
David du Colombier 27824a6c0b sys/src/libventi: define VtEntryNoArchive constant 2019-09-06 11:55:35 -07:00
David du Colombier cb091e7539 sys/src/libventi: implement vtsha1 and vtsha1check functions 2019-09-06 11:55:18 -07:00
David du Colombier 63ae9ed53a sys/src/libventi: implement vtreconn and vtredial functions 2019-09-06 11:54:44 -07:00
cinap_lenrek 85216d3d95 auth/rsa2asn1: implement private key export with -a flag (thanks kvik)
kvik writes:

I needed to convert the RSA private key that was laying around in
secstore into a format understood by UNIX® tools like SSH.

With asn12rsa(8) we can go from the ASN.1/DER to Plan 9 format, but not
back - so I wrote the libsec function asn1encodeRSApriv(2) and used it in
rsa2asn1(8) by adding the -a flag which causes the full private key to be
encoded and output.
2019-08-30 07:34:35 +02:00
cinap_lenrek 4b4d68487c stdio: fix putc(), plan9 version 2019-06-20 00:04:58 +02:00
cinap_lenrek ef1bcc7338 ape: fix stdio putc() macro, avoiding "result of operation not used" warning
moving _IO_CHMASK masking on the right hand side fixes it.
2019-06-19 23:59:25 +02:00
Ori Bernstein ceed9b8853 Sand edges down on GBIT64()/PBIT64() macros.
Now, you can safely use them in unbraced if statements, and
with char*s.
2019-05-06 17:26:38 -07:00
cinap_lenrek 4f0bfe0fb8 dtracy: avoid dmachlock() race
between being commited to a machno and having acquired the lock, the
scheduler could come in an schedule us on a different processor. the
solution is to have dtmachlock() take a special -1 argument to mean
"current mach" and return the actual mach number after the lock has
been acquired and interrupts being disabled.
2019-03-30 09:17:46 +01:00
cinap_lenrek 0af11f97b5 libip: replace v4parsecidr() with new parseipandmask()
we want to accept V4 subnets in CIDR notation consistently which
means we need to interpret the mask in context of the IP address.
so parseipmask() now has an additional v4 flag argument which
offsets the prefixlength by 96 so a /24 will be interpreted
as a /120.

parseipandmask() is the new function which handles this automatically
depending on the ip address type.

v4parsecidr() is now obsolete.
2019-02-11 23:26:57 +01:00
aiju c7304ea03c dtracy: get rid of DTName struct, support more than three parts in a probe name, wildcard matching 2018-12-13 10:42:49 +00:00
aiju 40d6302b5f forgotten files 2018-12-11 09:20:34 +00:00
aiju ca851bbb5e dtracy: call dtptrigger with a struct pointer rather than a list of arguments; put return value in arg9 2018-12-09 21:43:22 +00:00
aiju 58fa29447b dtracy: add support for aggregations 2018-12-08 15:07:53 +00:00
mischief cb7375dcbc ape: declare gethostname 2018-12-02 03:30:22 -08:00
aiju e15b1b8930 add dtracy.h 2018-11-10 20:01:19 +00:00
mischief 6df3f7bf38 libmp: declare mpfactorial 2018-11-04 11:37:02 -08:00
cinap_lenrek 19166f2cf3 libc: add procsetname() 2018-09-26 14:56:23 +02:00
cinap_lenrek 311e3b51c6 libc: return number of bytes produced for idn2utf() and utf2idn() 2018-09-26 14:32:17 +02:00
cinap_lenrek dfec09c436 libc: add utf2idn() and idn2utf() functions to deal with internationalized domain names 2018-09-25 20:14:25 +02:00
cinap_lenrek a4e444f430 libndb: make ndbipinfo() walk ipnet for all matching entries, concatenate and dedup result 2018-09-16 12:39:47 +02:00
spew 91d0343627 ape: an implemenation of getitimer setitimer 2018-07-01 18:48:12 -04:00
spew 55c122d59f ape: add strnlen 2018-06-21 11:56:37 -04:00