aboutsummaryrefslogtreecommitdiff
path: root/sys/compat/cloudabi
Commit message (Collapse)AuthorAgeFilesLines
* Include <sys/systm.h> to obtain the memcpy() prototype.Ed Schouten2017-03-241-0/+1
| | | | | | | | | | | | | I got a report of this source file not building on Raspberry Pi. It's interesting that this only fails for that target and not for others. Again, that's no reason not to include the right headers. PR: 217969 Reported by: Johannes Jost Meixner MFC after: 1 week Notes: svn path=/head/; revision=315892
* Make file descriptor passing for CloudABI's recvmsg() work.Ed Schouten2017-03-222-7/+81
| | | | | | | | | | | | Similar to the change for sendmsg(), create a pointer size independent implementation of recvmsg() and let cloudabi32 and cloudabi64 call into it. In case userspace requests one or more file descriptors, call kern_recvit() in such a way that we get the control message headers in an mbuf. Iterate over all of the headers and copy the file descriptors to userspace. Notes: svn path=/head/; revision=315736
* Make file descriptor passing work for CloudABI's sendmsg().Ed Schouten2017-03-222-0/+54
| | | | | | | | | | | | | Reduce the potential amount of code duplication between cloudabi32 and cloudabi64 by creating a cloudabi_sock_recv() utility function. The cloudabi32 and cloudabi64 modules will then only contain code to convert the iovecs to the native pointer size. In cloudabi_sock_recv(), we can now construct an SCM_RIGHTS cmsghdr in an mbuf and pass that on to kern_sendit(). Notes: svn path=/head/; revision=315700
* Rework r313352.Konstantin Belousov2017-02-131-14/+14
| | | | | | | | | | | | | | | Rename kern_vm_* functions to kern_*. Move the prototypes to syscallsubr.h. Also change Mach VM types to uintptr_t/size_t as needed, to avoid headers pollution. Requested by: alc, jhb Reviewed by: alc Sponsored by: The FreeBSD Foundation MFC after: 2 weeks Differential revision: https://reviews.freebsd.org/D9535 Notes: svn path=/head/; revision=313696
* Add kern_vm_mmap2(), kern_vm_mprotect(), kern_vm_msync(), kern_vm_munlock(),Edward Tomasz Napierala2017-02-061-54/+34
| | | | | | | | | | | | | kern_vm_munmap(), and kern_vm_madvise(), and use them in various compats instead of their sys_*() counterparts. Reviewed by: ed, dchagin, kib MFC after: 2 weeks Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D9378 Notes: svn path=/head/; revision=313352
* Add kern_listen(), kern_shutdown(), and kern_socket(), and use themEdward Tomasz Napierala2017-01-302-22/+9
| | | | | | | | | | | | | instead of their sys_*() counterparts in various compats. The svr4 is left untouched, because there's no point. Reviewed by: ed@, kib@ MFC after: 2 weeks Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D9367 Notes: svn path=/head/; revision=312988
* Add kern_lseek() and use it instead of sys_lseek() in various compats.Edward Tomasz Napierala2017-01-301-8/+5
| | | | | | | | | | | | I didn't touch svr4/, there's no point. Reviewed by: ed@, kib@ MFC after: 2 weeks Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D9366 Notes: svn path=/head/; revision=312987
* Revert crap accidentally committedBaptiste Daroussin2017-01-281-1/+0
| | | | Notes: svn path=/head/; revision=312927
* Revert r312923 a better approach will be taken laterBaptiste Daroussin2017-01-281-0/+1
| | | | Notes: svn path=/head/; revision=312926
* Catch up with changes to structure member names.Ed Schouten2017-01-175-33/+33
| | | | | | | Pointer/length pairs are now always named ${name} and ${name}_len. Notes: svn path=/head/; revision=312355
* cloudabi: use fget_cap instead of hand-rolling capability readMateusz Guzik2016-09-231-22/+10
| | | | | | | | | This has a side effect of unbreaking the build after r306272. Discussed with: ed Notes: svn path=/head/; revision=306282
* capsicum: propagate rights on accept(2)Mariusz Zaborski2016-09-221-1/+1
| | | | | | | | | | | | | Descriptor returned by accept(2) should inherits capabilities rights from the listening socket. PR: 201052 Reviewed by: emaste, jonathan Discussed with: many Differential Revision: https://reviews.freebsd.org/D7724 Notes: svn path=/head/; revision=306174
* Move the linker script from cloudabi64/ to cloudabi/.Ed Schouten2016-08-211-0/+51
| | | | | | | | It turns out that it works perfectly fine for generating 32-bits vDSOs as well. While there, get rid of the extraneous .s file extension. Notes: svn path=/head/; revision=304557
* Use memcpy() to copy 64-bit timestamps into the syscall return values.Ed Schouten2016-08-211-2/+2
| | | | | | | | | | On 32-bit platforms, our 64-bit timestamps need to be split up across two registers. A simple assignment to td_retval[0] will cause the top 32 bits to get lost. By using memcpy(), we will automatically either use 1 or 2 registers depending on the size of register_t. Notes: svn path=/head/; revision=304555
* Import the new automatically generated system call table for CloudABI.Ed Schouten2016-08-191-8/+0
| | | | | | | | | | | | | | | | | | Now that we've switched over to using the vDSO on CloudABI, it becomes a lot easier for us to phase out old features. System call numbering is no longer something that's part of the ABI. It's fully based on names. As long as the numbering used by the kernel and the vDSO is consistent (which it always is), it's all right. Let's put this to the test by removing a system call (thread_tcb_set()) that's already unused for quite some time now, but was only left intact to serve as a placeholder. Sync in the new system call table that uses alphabetic sorting of system calls. Obtained from: https://github.com/NuxiNL/cloudabi Notes: svn path=/head/; revision=304478
* Eliminate use of sys_fsync() and sys_fdatasync().Ed Schouten2016-08-151-8/+2
| | | | | | | | | | Make the kern_fsync() function public, so that it can be used by other parts of the kernel. Fix up existing consumers to make use of it. Requested by: kib Notes: svn path=/head/; revision=304185
* Let CloudABI use fdatasync() as well.Ed Schouten2016-08-151-3/+2
| | | | | | | | Now that FreeBSD supports fdatasync() natively, we can tidy up CloudABI's equivalent system call to use that instead. Notes: svn path=/head/; revision=304182
* Provide the CloudABI vDSO to its executables.Ed Schouten2016-08-102-0/+93
| | | | | | | | | | | | | | | | | | | CloudABI executables already provide support for passing in vDSOs. This functionality is used by the emulator for OS X to inject system call handlers. On FreeBSD, we could use it to optimize calls to gettimeofday(), etc. Though I don't have any plans to optimize any system calls right now, let's go ahead and already pass in a vDSO. This will allow us to simplify the executables, as the traditional "syscall" shims can be removed entirely. It also means that we gain more flexibility with regards to adding and removing system calls. Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D7438 Notes: svn path=/head/; revision=303941
* Add implementation of robust mutexes, hopefully close enough to theKonstantin Belousov2016-05-171-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | intention of the POSIX IEEE Std 1003.1TM-2008/Cor 1-2013. A robust mutex is guaranteed to be cleared by the system upon either thread or process owner termination while the mutex is held. The next mutex locker is then notified about inconsistent mutex state and can execute (or abandon) corrective actions. The patch mostly consists of small changes here and there, adding neccessary checks for the inconsistent and abandoned conditions into existing paths. Additionally, the thread exit handler was extended to iterate over the userspace-maintained list of owned robust mutexes, unlocking and marking as terminated each of them. The list of owned robust mutexes cannot be maintained atomically synchronous with the mutex lock state (it is possible in kernel, but is too expensive). Instead, for the duration of lock or unlock operation, the current mutex is remembered in a special slot that is also checked by the kernel at thread termination. Kernel must be aware about the per-thread location of the heads of robust mutex lists and the current active mutex slot. When a thread touches a robust mutex for the first time, a new umtx op syscall is issued which informs about location of lists heads. The umtx sleep queues for PP and PI mutexes are split between non-robust and robust. Somewhat unrelated changes in the patch: 1. Style. 2. The fix for proper tdfind() call use in umtxq_sleep_pi() for shared pi mutexes. 3. Removal of the userspace struct pthread_mutex m_owner field. 4. The sysctl kern.ipc.umtx_vnode_persistent is added, which controls the lifetime of the shared mutex associated with a vnode' page. Reviewed by: jilles (previous version, supposedly the objection was fixed) Discussed with: brooks, Martin Simmons <martin@lispworks.com> (some aspects) Tested by: pho Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=300043
* Sync in the latest CloudABI system call definitions.Ed Schouten2016-03-312-14/+14
| | | | | | | | | | | | | | | | | Some time ago I made a change to merge together the memory scope definitions used by mmap (MAP_{PRIVATE,SHARED}) and lock objects (PTHREAD_PROCESS_{PRIVATE,SHARED}). Though that sounded pretty smart back then, it's backfiring. In the case of mmap it's used with other flags in a bitmask, but for locking it's an enumeration. As our plan is to automatically generate bindings for other languages, that looks a bit sloppy. Change all of the locking functions to use separate flags instead. Obtained from: https://github.com/NuxiNL/cloudabi Notes: svn path=/head/; revision=297468
* Replace the CloudABI system call table by a machine generated version.Ed Schouten2016-03-2412-76/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The type definitions and constants that were used by COMPAT_CLOUDABI64 are a literal copy of some headers stored inside of CloudABI's C library, cloudlibc. What is annoying is that we can't make use of cloudlibc's system call list, as the format is completely different and doesn't provide enough information. It had to be synced in manually. We recently decided to solve this (and some other problems) by moving the ABI definitions into a separate file: https://github.com/NuxiNL/cloudabi/blob/master/cloudabi.txt This file is processed by a pile of Python scripts to generate the header files like before, documentation (markdown), but in our case more importantly: a FreeBSD system call table. This change discards the old files in sys/contrib/cloudabi and replaces them by the latest copies, which requires some minor changes here and there. Because cloudabi.txt also enforces consistent names of the system call arguments, we have to patch up a small number of system call implementations to use the new argument names. The new header files can also be included directly in FreeBSD kernel space without needing any includes/defines, so we can now remove cloudabi_syscalldefs.h and cloudabi64_syscalldefs.h. Patch up the sources to include the definitions directly from sys/contrib/cloudabi instead. Notes: svn path=/head/; revision=297247
* Call cap_rights_init() properly.Ed Schouten2016-02-241-1/+1
| | | | | | | | Even though or'ing the individual rights works in this specific case, it may not work in general. Pass them in as varargs. Notes: svn path=/head/; revision=295965
* Make handling of mmap()'s prot argument more strict.Ed Schouten2016-02-231-9/+27
| | | | | | | | | | | | - Make the system call fail if prot contains bits other than read, write and exec. - Similar to OpenBSD's W^X, don't allow write and exec to be set at the same time. I'd like to see for now what happens if we enforce this policy unconditionally. If it turns out that this is far too strict, we'll loosen this requirement. Notes: svn path=/head/; revision=295917
* fork: plug a use after free of the returned processMateusz Guzik2016-02-041-2/+0
| | | | | | | | | | | | | | | | | fork1 required its callers to pass a pointer to struct proc * which would be set to the new process (if any). procdesc and racct manipulation also used said pointer. However, the process could have exited prior to do_fork return and be automatically reaped, thus making this a use-after-free. Fix the problem by letting callers indicate whether they want the pid or the struct proc, return the process in stopped state for the latter case. Reviewed by: kib Notes: svn path=/head/; revision=295233
* fork: pass arguments to fork1 in a dedicated structureMateusz Guzik2016-02-041-1/+7
| | | | | | | Suggested by: kib Notes: svn path=/head/; revision=295232
* Properly format pointer size independent CloudABI system calls.Ed Schouten2015-10-081-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | CloudABI has approximately 50 system calls that do not depend on the pointer size of the system. As the ABI is pretty compact, it takes little effort to each truss(8) the formatting rules for these system calls. Start off by formatting pointer size independent system calls. Changes: - Make it possible to include the CloudABI system call definitions in FreeBSD userspace builds. Add ${root}/sys to the truss(8) Makefile so we can pull in <compat/cloudabi/cloudabi_syscalldefs.h>. - Refactoring: patch up amd64-cloudabi64.c to use the CLOUDABI_* constants instead of rolling our own table. - Add table entries for all of the system calls. - Add new generic formatting types (UInt, IntArray) that we'll be using to format unsigned integers and arrays of integers. - Add CloudABI specific formatting types. Approved by: jhb Differential Revision: https://reviews.freebsd.org/D3836 Notes: svn path=/head/; revision=289004
* Decompose linkat()/renameat() rights to source and target.Ed Schouten2015-08-271-4/+4
| | | | | | | | | | | | | | | To make it easier to understand how Capsicum interacts with linkat() and renameat(), rename the rights to CAP_{LINK,RENAME}AT_{SOURCE,TARGET}. This also addresses a shortcoming in Capsicum, where it isn't possible to disable linking to files stored in a directory. Creating hardlinks essentially makes it possible to access files with additional rights. Reviewed by: rwatson, wblock Differential Revision: https://reviews.freebsd.org/D3411 Notes: svn path=/head/; revision=287209
* Don't forget to invoke pre_execve() and post_execve().Ed Schouten2015-08-171-0/+5
| | | | | | | | CloudABI's proc_exec() was implemented before r282708 introduced pre_execve() and post_execve(). Sync up by adding these missing calls. Notes: svn path=/head/; revision=286844
* Use CAP_EVENT instead of CAP_PDWAIT.Ed Schouten2015-08-122-3/+4
| | | | | | | | | | | The cloudlibc pdwait() function ends up using FreeBSD's kqueue() in combination with EVFILT_PROCDESC. This depends on CAP_EVENT -- not CAP_PDWAIT. Obtained from: https://github.com/NuxiNL/freebsd Notes: svn path=/head/; revision=286661
* Fall back to O_RDONLY -- not O_WRONLY.Ed Schouten2015-08-111-1/+1
| | | | | | | | | If CloudABI processes open files with a set of requested rights that do not match any of the privileges granted by O_RDONLY, O_WRONLY or O_RDWR, we'd better fall back to O_RDONLY -- not O_WRONLY. Notes: svn path=/head/; revision=286633
* Properly convert the error number to CloudABI's indexing.Ed Schouten2015-08-111-1/+1
| | | | | | | | We currently return FreeBSD's errno value directly, which is of course not correct. Notes: svn path=/head/; revision=286632
* Make cap_rights_limit() work for CloudABI processes.Ed Schouten2015-08-111-0/+8
| | | | | | | | Call into the recently introduced kern_cap_rights_limit() function to restrict rights. Notes: svn path=/head/; revision=286619
* Add file_open(): the underlying system call of openat().Ed Schouten2015-08-063-3/+148
| | | | | | | | | | | | | | | | | | | | | | | | | | CloudABI purely operates on file descriptor rights (CAP_*). File descriptor access modes (O_ACCMODE) are emulated on top of rights. Instead of accepting the traditional flags argument, file_open() copies in an fdstat_t object that contains the initial rights the descriptor should have, but also file descriptor flags that should persist after opening (APPEND, NONBLOCK, *SYNC). Only flags that don't persist (EXCL, TRUNC, CREAT, DIRECTORY) are passed in as an argument. file_open() first converts the rights, the persistent flags and the non-persistent flags to fflags. It then calls into vn_open(). If successful, it installs the file descriptor with the requested rights, trimming off rights that don't apply to the type of the file that has been opened. Unlike kern_openat(), this function does not support /dev/fd/*. I can't think of a reason why we need to support this for CloudABI. Obtained from: https://github.com/NuxiNL/freebsd Differential Revision: https://reviews.freebsd.org/D3235 Notes: svn path=/head/; revision=286359
* Correct the previous commit: remove the DECLARE_MODULE().Ed Schouten2015-08-051-8/+0
| | | | | | | | | It looks like a MODULE_VERSION() can also appear on its own -- there is no need to use explicitly use DECLARE_MODULE(). Looking at other modules, this seems common practice. Notes: svn path=/head/; revision=286325
* Add DECLARE_MODULE() to the "cloudabi" kernel module.Ed Schouten2015-08-051-0/+11
| | | | | | | | | | | This kernel module does not require any explicit initialization, but a module declaration is needed to let the "cloudabi64" kernel module automatically pull this in. Obtained from: https://github.com/NuxiNL/freebsd Notes: svn path=/head/; revision=286324
* Make fcntl(F_SETFL) work.Ed Schouten2015-08-051-2/+19
| | | | | | | | | | | | The stat_put() system call can be used to modify file descriptor attributes, such as flags, but also Capsicum permission bits. Support for changing Capsicum bits will be added as soon as its dependent changes have been pushed through code review. Obtained from: https://github.com/NuxiNL/freebsd Notes: svn path=/head/; revision=286323
* Add the remaining pointer size independent CloudABI socket system calls.Ed Schouten2015-08-052-4/+120
| | | | | | | | | | | | | | | | | CloudABI uses a structure called cloudabi_sockstat_t. Think of it as 'struct stat' for sockets. It is used by functions such as getsockname(), getpeername(), some of the getsockopt() values, etc. This change implements the sock_stat_get() system call that returns a copy of this structure. The accept() system call should also return a full copy of this structure eventually, but for now we're only interested in the peer address. Add a TODO() to make sure this is patched up later on. Differential Revision: https://reviews.freebsd.org/D3218 Notes: svn path=/head/; revision=286312
* Allow the creation of polling descriptors (kqueues) on CloudABI.Ed Schouten2015-08-051-0/+3
| | | | Notes: svn path=/head/; revision=286310
* Let the CloudABI futex code use umtx_keys.Ed Schouten2015-08-041-72/+11
| | | | | | | | | | The CloudABI kernel still passes all of the cloudlibc unit tests. Reviewed by: vangyzen Differential Revision: https://reviews.freebsd.org/D3286 Notes: svn path=/head/; revision=286278
* Allow CloudABI processes to create shared memory objects.Ed Schouten2015-08-011-0/+6
| | | | | | | | | | | | | | | Summary: Use the newly created `kern_shm_open()` function to create objects with just the rights that are actually needed. Reviewers: jhb, kib Subscribers: imp Differential Revision: https://reviews.freebsd.org/D3260 Notes: svn path=/head/; revision=286147
* Limit rights on process descriptors.Ed Schouten2015-07-311-1/+5
| | | | | | | | | | | | | | | | | | | | | On CloudABI, the rights bits returned by cap_rights_get() match up with the operations that you can actually perform on the file descriptor. Limiting the rights is good, because it makes it easier to get uniform behaviour across different operating systems. If process descriptors on FreeBSD would suddenly gain support for any new file operation, this wouldn't become exposed to CloudABI processes without first extending the rights. Extend fork1() to gain a 'struct filecaps' argument that allows you to construct process descriptors with custom rights. Use this in cloudabi_sys_proc_fork() to limit the rights to just fstat() and pdwait(). Obtained from: https://github.com/NuxiNL/freebsd Notes: svn path=/head/; revision=286122
* Make pipes in CloudABI work.Ed Schouten2015-07-291-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Pipes in CloudABI are unidirectional. The reason for this is that CloudABI attempts to provide a uniform runtime environment across different flavours of UNIX. Instead of implementing a custom pipe that is unidirectional, we can simply reuse Capsicum permission bits to support this. This is nice, because CloudABI already attempts to restrict permission bits to correspond with the operations that apply to a certain file descriptor. Replace kern_pipe() and kern_pipe2() by a single kern_pipe() that takes a pair of filecaps. These filecaps are passed to the newly introduced falloc_caps() function that creates the descriptors with rights in place. Test Plan: CloudABI pipes seem to be created with proper rights in place: https://github.com/NuxiNL/cloudlibc/blob/master/src/libc/unistd/pipe_test.c#L44 Reviewers: jilles, mjg Reviewed By: mjg Subscribers: imp Differential Revision: https://reviews.freebsd.org/D3236 Notes: svn path=/head/; revision=286021
* Split up Capsicum to CloudABI rights conversion into two separate routines.Ed Schouten2015-07-291-30/+85
| | | | | | | | | | | CloudABI's openat() ensures that files are opened with the smallest set of relevant rights. For example, when opening a FIFO, unrelated rights like CAP_RECV are automatically removed. To remove unrelated rights, we can just reuse the code for this that was already present in the rights conversion function. Notes: svn path=/head/; revision=286006
* Implement CloudABI's readdir().Ed Schouten2015-07-291-2/+174
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: CloudABI's readdir() system call could be thought of as a mixture between FreeBSD's getdents(2) and pread(). Instead of using the file descriptor offset, userspace provides a 64-bit cloudabi_dircookie_t continue reading at a given point. CLOUDABI_DIRCOOKIE_START, having value 0, can be used to return entries at the start of the directory. The file descriptor offset is not used to store the cookie for the reason that in a file descriptor centric environment, it would make sense to allow concurrent use of a single file descriptor. The remaining space returned by the system call should be filled with a partially truncated copy of the next entry. The advantage of doing this is that it gracefully deals with long filenames. If the C library provides a buffer that is too small to hold a single entry, it can still extract the directory entry header, meaning that it can retry the read with a larger buffer or skip it using the cookie. Test Plan: This implementation passes the cloudlibc unit tests at: https://github.com/NuxiNL/cloudlibc/tree/master/src/libc/dirent Reviewers: marcel, kib Reviewed By: kib Subscribers: imp Differential Revision: https://reviews.freebsd.org/D3226 Notes: svn path=/head/; revision=285998
* Implement file attribute modification system calls for CloudABI.Ed Schouten2015-07-281-4/+79
| | | | | | | | | | | | | | | | | CloudABI uses a system call interface to modify file attributes that is more similar to KPI's/FUSE, namely where a stat structure is passed back to the kernel, together with a bitmask of attributes that should be changed. This would allow us to update any set of attributes atomically. That said, I'd rather not go as far as to actually implement it that way, as it would require us to duplicate more code than strictly needed. Let's just stick to the combinations that are actually used by cloudlibc. Obtained from: https://github.com/NuxiNL/freebsd Notes: svn path=/head/; revision=285954
* Implement directory and FIFO creation.Ed Schouten2015-07-281-2/+24
| | | | | | | | | | The file_create() system call can be used to create files of a given type. Right now it can only be used to create directories and FIFOs. As CloudABI does not expose filesystem permissions, this system call lacks a mode argument. Simply use 0777 or 0666 depending on the file type. Notes: svn path=/head/; revision=285931
* Make fstat() and friends work.Ed Schouten2015-07-283-6/+336
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: CloudABI provides access to two different stat structures: - fdstat, containing file descriptor level status: oflags, file descriptor type and Capsicum rights, used by cap_rights_get(), fcntl(F_GETFL), getsockopt(SO_TYPE). - filestat, containing your regular file status: timestamps, inode number, used by fstat(). Unlike FreeBSD's stat::st_mode, CloudABI file descriptor types don't have overloaded meanings (e.g., returning S_ISCHR() for kqueues). Add a utility function to extract the type of a file descriptor accurately. CloudABI does not work with O_ACCMODEs. File descriptors have two sets of Capsicum-style rights: rights that apply to the file descriptor itself ('base') and rights that apply to any new file descriptors yielded through openat() ('inheriting'). Though not perfect, we can pretty safely decompose Capsicum rights to such a pair. This is done in convert_capabilities(). Test Plan: Tests for these system calls are fairly extensive in cloudlibc. Reviewers: jonathan, mjg, #manpages Reviewed By: mjg Subscribers: imp Differential Revision: https://reviews.freebsd.org/D3171 Notes: svn path=/head/; revision=285930
* Add a futex implementation for CloudABI.Ed Schouten2015-07-274-19/+1237
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: CloudABI provides two different types of futex objects: read-write locks and condition variables. There is no need to provide separate support for once objects and thread joining, as these are efficiently simulated by blocking on a read-write lock. Mutexes simply use read-write locks. Condition variables always have a lock object associated to them. They always know to which lock a thread needs to be migrated if woken up. This allows us to implement requeueing. A broadcast on a condition variable will never cause multiple threads to be woken up at once. They will be woken up iteratively. This implementation still has lots of room for improvement. Locking is coarse and right now we use linked lists to store all of the locks and condition variables, instead of using a hash table. The primary goal of this implementation was to behave correctly. Performance will be improved as we go. Test Plan: This futex implementation has been in use for the last couple of months and seems to work pretty well. All of the cloudlibc and libc++ unit tests seem to pass. Reviewers: dchagin, kib, vangyzen Subscribers: imp Differential Revision: https://reviews.freebsd.org/D3148 Notes: svn path=/head/; revision=285908
* Implement the basic system calls that operate on pathnames.Ed Schouten2015-07-243-15/+166
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Unlike FreeBSD, CloudABI does not use null terminated strings for its pathnames. Introduce a function called copyin_path() that can be used by all of the filesystem system calls that use pathnames. This change already implements the system calls that don't depend on any additional functionality (e.g., conversion of struct stat). Also implement the socket system calls that operate on pathnames, namely the ones used by the C library functions bindat() and connectat(). These don't receive a 'struct sockaddr_un', but just the pathname, meaning they could be implemented in such a way that they don't depend on the size of sun_path. For now, just use the existing interfaces. Add a missing #include to cloudabi_syscalldefs.h to get this code to build, as one of its macros depends on UINT64_C(). Test Plan: These implementations have already been tested in the CloudABI branch on GitHub. They pass all of the tests. Reviewers: kib, pjd Subscribers: imp Differential Revision: https://reviews.freebsd.org/D3097 Notes: svn path=/head/; revision=285834
* Allow us to create UNIX sockets and socketpairs in CloudABI processes.Ed Schouten2015-07-231-4/+37
| | | | Notes: svn path=/head/; revision=285812