aboutsummaryrefslogtreecommitdiff
path: root/src/lib9
Commit message (Collapse)AuthorAgeFilesLines
* all: remove need for `-fcommon`Dan Cross2025-07-251-0/+1
| | | | | | | | | | Use `extern` where appropriate so that we can remove `-fcommon` on macOS and others. On macOS, `-fcommon` generates a number of linker warnings. I've tested building on macOS, Linux, FreeBSD, NetBSD, OpenBSD and illumos. I am not in a position to test on AIX or other more esoteric platforms, however.
* lib9: skip buggy S_ISCHR check in disksize on OpenBSDRuss Cox2024-06-151-2/+0
| | | | The portable code is already checking S_ISCHR anyway.
* lib9: pass $PLAN9_TARGET via CPP for get9root fallback valueSören Tempel2022-07-272-2/+4
| | | | | Allows this function to always return the proper path in situations where the $PLAN9 environment variable is not set, i.e. a rc login shell.
* all: update for new MIT licenseRuss Cox2021-03-234-41/+4
| | | | | | | | | | | | | | | | | | | | | | | | On March 23, 2021, Nokia transferred the copyrights in the Plan 9 software to the Plan 9 Foundation, which relicensed them under the MIT license. This commit updates the Plan 9 from User Space license to reflect the new base license. The vast majority of the contributions beyond the base Plan 9 set were by me, many of them explicitly under an MIT license. Those are all under the new MIT license now as well. The port of mk to Unix was taken from Inferno via Vita Nuova and had been made available under GPL, but Vita Nuova has relicensed Inferno under the MIT license as well, to match the new Plan 9 license. Michael Teichgraber contributed src/lib9/zoneinfo.c explicitly under the Lucent Public License but has agreed to change the contribution to the MIT license now used in the rest of the distribution. There remain a few exceptions, most notably fonts. See the root LICENSE file for full details. The only mention of the Lucent Public License in the whole tree now is in the LICENSE file, explaining the history.
* lib9: reject postnote with special pidsRuss Cox2021-01-141-0/+5
|
* lib9: avoid unportable use of d_namlen in dirreadRuss Cox2020-05-181-2/+1
| | | | Fixes #395.
* lib9: use opendir/readdir to read directoriesRuss Cox2020-05-171-183/+187
| | | | | | | | | | | | | getdirentries(2) has been deprecated on macOS since 10.5 (ten releases ago). Using it requires disabling 64-bit inodes, but that in turn makes binaries incompatible with some dynamic libraries, most notably ASAN. At some point getdirentries(2) will actually be removed. For both these reasons, switch to opendir/readdir. A little clunky since we have to keep the DIR* hidden away to preserve the int fd interfaces, but it lets us remove a bunch of OS-specific code too.
* lib9: move seek into open.cRuss Cox2020-05-173-10/+6
| | | | More preparation for opendir.
* lib9: add closeRuss Cox2020-05-171-0/+7
| | | | More preparation for opendir.
* lib9: merge create, open, dirread into open.cRuss Cox2020-05-174-284/+270
| | | | Preparation for using opendir.
* fmt: adjust GCC version checkKurt H Maier2020-05-081-2/+2
| | | | atomics were added in GCC 4.9: https://gcc.gnu.org/gcc-4.9/changes.html
* all: fix #includes for AIX, add a few AIX "implementation" filesBen Huntsman2020-05-071-0/+2
|
* fmt: disable use of stdatomic on AIX XL C and old GCCRuss Cox2020-05-071-0/+21
| | | | | | C11 is apparently too new for these systems. Fixes #55.
* malloc: remove lockingDan Cross2020-01-162-31/+3
| | | | | | | | | | | | | | | | | The issue manifests in fork: POSIX fork mandates that a fork'd process is created with a single thread. If a multithreaded program forks, and some thread was in malloc() when the fork() happened, then in the child the lock will be held but there will be no thread to release it. We assume the system malloc() must already know how to deal with this and is thread-safe, but it won't know about our custom spinlock. Judging that this is no longer necessary (the lock code was added 15 years ago) we remove it. Signed-off-by: Dan Cross <cross@gajendra.net>
* lib9: putenv wraps POSIX setenv, not legacy putenvDan Cross2020-01-161-7/+1
| | | | | | | POSIX setenv does everything that p9putenv's body, so just delegate to that. Signed-off-by: Dan Cross <cross@gajendra.net>
* lib9: make formatting lock-free againRuss Cox2020-01-144-124/+83
| | | | | | | | First use of <stdatomic.h>. We will see if any supported systems don't have it yet. (C11 was so last decade.) Fixes #338.
* lib9: do not fetch disk size for character devicesRuss Cox2020-01-131-1/+1
| | | | | | | | | Real disk devices should be block devices anyway. One user reported the disksize check causing a system reboot during vac of a tree with an "interesting" device. Fixes #103.
* lib9: rm unused _p9translate.cRuss Cox2020-01-131-46/+0
| | | | Fixes #238.
* lib9/fmt: avoid racy access to installed fmt formatsRuss Cox2020-01-134-22/+55
|
* lib9: fix memory leak in dial of regular file (#284)jvd232020-01-131-1/+3
|
* lib9: make a p9frexp function wrapping system frexpRuss Cox2020-01-122-0/+10
| | | | | | Under certain conditions it looks like frexp gets #defined to something else on macOS during system headers, which then breaks the declaration in libc.h.
* all: fix or silence various gcc warningsRuss Cox2020-01-122-8/+6
| | | | | As usual, gcc finds some real problems but also reports a ton of noise. Fix the problems and quiet the noise.
* Trivial changes: whitespace and modes.Dan Cross2020-01-1069-128/+83
| | | | | | | | | Remote whitespace at the ends of lines. Remove blank lines from the ends of files. Change modes on source files so that they are not executable. Signed-off-by: Dan Cross <cross@gajendra.net>
* lib9: add getcallerpc.c (fixes build)Russ Cox2020-01-081-0/+13
|
* lib9, libndb: exclude terminating null from strncpy boundNeven Sajko2020-01-071-1/+1
| | | | | | | GCC pointed this out with some "warning: ‘strncpy’ specified bound NUM equals destination size [-Wstringop-truncation]" warnings. Change-Id: Id8408b165f6e4ae82c96a77599d89f658d979b32
* lib9: remove getcallerpc implementationsRuss Cox2020-01-078-55/+1
| | | | | | | | These make no sense and are not really needed at all. Add a best-effort attempt to get at the gcc/clang macro in lib9.h, but if it fails, no big deal. Fixes #324.
* lib9: import frand function from Plan 9David du Colombier2017-09-012-0/+18
| | | | Fixes #15.
* lib9: fix needsrcquoteRuss Cox2017-06-191-1/+1
| | | | | | | | | | | As written, it is passing a rune to strchr, which likely ignores all but the bottom 8 bits of the rune. Long-standing Plan 9 bug too. Fixes #87. Change-Id: I6a833373b308bed8760d6989972c7f77b4ef3838 Reviewed-on: https://plan9port-review.googlesource.com/2921 Reviewed-by: Russ Cox <rsc@swtch.com>
* include: define _DEFAULT_SOURCEDavid du Colombier2016-11-201-0/+1
| | | | | | | | | | | Since glibc 2.20, the _BSD_SOURCE and _SVID_SOURCE macros are deprecated in favor of the _DEFAULT_SOURCE macro. See https://sourceware.org/glibc/wiki/Release/2.20#Packaging_Changes Change-Id: I18dd6a698f3f5aa51d1e45bf53b031bb061e17e8 Reviewed-on: https://plan9port-review.googlesource.com/1500 Reviewed-by: David du Colombier <0intro@gmail.com>
* all: linux/arm64 portAram Hăvărneanu2015-06-031-0/+8
| | | | | | | | Really trivial port. Change-Id: Ib2e3ad48df555ca4bd9339ddf79a832be895bd95 Reviewed-on: https://plan9port-review.googlesource.com/1030 Reviewed-by: Russ Cox <rsc@google.com>
* all: linux/mips portAram Hăvărneanu2015-06-031-0/+8
| | | | | | Change-Id: I0af67bc44c7bb62a8e5a47eac597367f521f1c11 Reviewed-on: https://plan9port-review.googlesource.com/1210 Reviewed-by: Russ Cox <rsc@google.com>
* all: fix openbsd buildAram Hăvărneanu2015-06-031-2/+2
| | | | | | | Change-Id: I6eaeebc9b6a4d78ce07efe7680ba8f2eff16462f Reviewed-on: https://plan9port-review.googlesource.com/1230 Reviewed-by: Minux Ma <minux@golang.org> Reviewed-by: Russ Cox <rsc@google.com>
* all: DragonFly port.Shenghou Ma2014-02-271-5/+11
| | | | | | | | Fix compilation problems, libdraw still doesn't work right yet. LGTM=rsc R=rsc https://codereview.appspot.com/67820046
* fix clang warnings reported by Tuncer AyazRuss Cox2012-10-211-7/+5
| | | | | R=rsc http://codereview.appspot.com/6744054
* lib9: fix Mac warningRuss Cox2012-10-201-1/+8
| | | | | R=rsc http://codereview.appspot.com/6749053
* lib9/p9dialparse: fix segfault on gethostbynameDavid du Colombier2012-09-111-1/+1
| | | | | | | | In some situations, gethostbyname can return an empty address list. R=rsc http://codereview.appspot.com/6443097
* lib9: remove ss_len manipulation in _p9dialparseRuss Cox2012-09-081-3/+0
| | | | | | | Not all systems have ss_len, and we've never set it before. R=rsc http://codereview.appspot.com/6497102
* lib9: fix announce on OS XRuss Cox2012-09-081-5/+7
| | | | | R=rsc http://codereview.appspot.com/6495109
* lib9/dial: fix addrlen in connect() and bind()David du Colombier2012-09-042-7/+35
| | | | | | | | | On some systems, the third argument of connect() and bind() is expected to be the length of the address family instead of the length of the sockaddr structure. R=rsc http://codereview.appspot.com/6489072
* lib9/getnetconn: add support for IPv6David du Colombier2012-08-031-0/+27
| | | | | R=rsc http://codereview.appspot.com/6457077
* lib9: fix openbsd buildDavid du Colombier2012-06-272-1/+2
| | | | | | | | Fix build error and warning on OpenBSD 5.1, as reported by Dimitri Sokolyuk. R=rsc http://codereview.appspot.com/6350044
* lib9/dial: add support for IPv6David du Colombier2012-06-023-100/+86
| | | | | | | | | | | | | | | | | | | | | | | | | | | The function p9dialparse() returns the host as a sockaddr_storage structure instead of a u32int, to be able to handle both IPv4 and IPv6 addresses. Because the sockaddr_storage structure also handle port numbers and Unix path names, there is no longer need to set them in the calling functions. However, these values are still returned for convenience. The sockaddr_in and sockaddr_un structures have been replaced by sockaddr_storage to handle Unix, IPv4 and IPv6 sockets. Names and addresses are resolved using either gethostbyname() or getaddrinfo() functions. The getaddrinfo() function is documented in RFC2553 and standardized since POSIX.1-2001. It supports both IPv4 and IPv6 addresses. The gethostbyname() function is deprecated since POSIX.1-2008. However, some libc implementations don't handle getaddrinfo() properly, thus we preferred to try gethostbyname() first. I've tried to preserve most of the old code logic to prevent from surprising or unwanted behavior. R=rsc http://codereview.appspot.com/6255068
* lib9: fix local addr in dialJani Lahtinen2011-08-161-1/+1
| | | | | | R=rsc CC=plan9port.codebot http://codereview.appspot.com/4826049
* build: OS X 64-bit buildRuss Cox2011-08-021-1/+1
| | | | | R=rsc http://codereview.appspot.com/4838047
* lib9: restore SIGCHLD handler in rforkRuss Cox2011-05-011-6/+5
| | | | | R=rsc http://codereview.appspot.com/4436071
* delete 9P2000.uRuss Cox2010-12-074-133/+8
| | | | | | | thanks to Erik Quanstrom R=rsc http://codereview.appspot.com/3469042
* lib9: add <sys/dkio.h> for OpenBSDRuss Cox2010-07-111-0/+1
| | | | | | R=, rsc CC= http://codereview.appspot.com/1762045
* more type-punned pointersRuss Cox2010-03-101-1/+1
| | | | | R=rsc http://codereview.appspot.com/376045
* fix type-punned pointer warnings from gccRuss Cox2010-03-103-3/+5
| | | | | R=rsc http://codereview.appspot.com/396042
* lib9: do not include st_dev in qid.pathRuss Cox2009-09-241-1/+8
| | | | http://codereview.appspot.com/123050