summaryrefslogtreecommitdiff
path: root/libguile/atomics-internal.h
Commit message (Collapse)AuthorAgeFilesLines
* Switch to use atomic_compare_exchange_strongAndy Wingo2019-05-251-13/+13
| | | | | | | | | * libguile/atomics-internal.h (scm_atomic_compare_and_swap_scm): Change to use same API as atomic-box-compare-and-swap!. * libguile/intrinsics.c (atomic_compare_and_swap_scm): Remove loop, as we're using the strong variant now. * libguile/async.c (scm_i_async_pop, scm_i_async_push): Adapt to new API of scm_atomic_compare_and_swap_scm.
* Update license notices in all C filesAndy Wingo2018-06-201-17/+17
| | | | | Update to newest recommended license notices from the FSF. Everything stays LGPLv3+ except guile-readline which is GPLv3+.
* Remove (C) from copyright statementsAndy Wingo2018-06-201-2/+2
| | | | | | As the FSF advises, 'There is no legal significance to using the three-character sequence “(C)”, but it does no harm.' It does take up space though! For that reason, we remove it here from our C files.
* Rationalize include order in C filesAndy Wingo2018-06-201-2/+2
| | | | | Include config.h first, then system includes, then libguile includes, in alphabetical order, then the include for the file in question.
* Fix atomics compilation on clangAndy Wingo2017-03-101-8/+19
| | | | | | | | | * libguile/atomics-internal.h (scm_atomic_subtract_uint32): (scm_atomic_compare_and_swap_uint32, scm_atomic_set_pointer): (scm_atomic_ref_pointer, scm_atomic_set_scm): (scm_atomic_ref_scm, scm_atomic_swap_scm): (scm_atomic_compare_and_swap_scm): Use C11 atomic types if we have loaded C11 stdatomic.h.
* Refine check for when atomics are available.Andy Wingo2016-12-061-5/+3
| | | | | | * configure.ac: * libguile/atomics-internal.h: Use HAVE_STDATOMIC_H to know when to use atomics.
* Use atomics for async interruptsAndy Wingo2016-10-261-0/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | * libguile/__scm.h (SCM_TICK): Always define as scm_async_tick(). * libguile/error.c (scm_syserror, scm_syserror_msg): * libguile/fports.c (fport_read, fport_write): * libguile/_scm.h (SCM_SYSCALL): Replace SCM_ASYNC_TICK with scm_async_tick (). (SCM_ASYNC_TICK, SCM_ASYNC_TICK_WITH_CODE) (SCM_ASYNC_TICK_WITH_GUARD_CODE): Remove internal definitions. We inline into vm-engine.c, the only place where it matters. * libguile/async.h: * libguile/async.c (scm_async_tick, scm_i_setup_sleep): (scm_i_reset_sleep, scm_system_async_mark_for_thread): * libguile/threads.h (struct scm_thread_wake_data): * libguile/threads.h (scm_i_thread): * libguile/threads.c (block_self, guilify_self_1, scm_std_select): Rewrite to use sequentially-consistent atomic references. * libguile/atomics-internal.h (scm_atomic_set_pointer): (scm_atomic_ref_pointer): New definitions. * libguile/finalizers.c (queue_finalizer_async): We can allocate, so just use scm_system_async_mark_for_thread instead of the set-cdr! shenanigans. * libguile/scmsigs.c (take_signal): * libguile/gc.c (queue_after_gc_hook): Adapt to new asyncs mechanism. Can't allocate but we're just manipulating the current thread when no other threads are running so we should be good. * libguile/vm-engine.c (VM_HANDLE_INTERRUPTS): Inline the async_tick business.
* Add atomic boxesAndy Wingo2016-09-061-12/+76
| | | | | | | | | | | | | | | | | | | | | * doc/ref/api-scheduling.texi (Atomics): New manual section. * libguile.h: Include atomic.h. * libguile/Makefile.am (libguile_@GUILE_EFFECTIVE_VERSION@_la_SOURCES): (DOT_X_FILES, DOT_DOC_FILES, modinclude_HEADERS): Add atomic. * libguile/atomic.c: * libguile/atomic.h: New files. * libguile/atomics-internal.h (scm_atomic_set_scm, scm_atomic_ref_scm) (scm_atomic_swap_scm, scm_atomic_compare_and_swap_scm): New facilities. * libguile/goops.c (class_atomic_box, scm_sys_goops_early_init): Add support for <atomic-box>. Remove duplicate <keyword> fetch. * libguile/init.c (scm_i_init_guile): Call scm_register_atomic_box. * libguile/print.c (iprin1): Add atomic box case. * libguile/tags.h (scm_tc7_atomic_box): New tag. * libguile/validate.h (SCM_VALIDATE_ATOMIC_BOX): New macro. * module/Makefile.am (SOURCES): Add ice-9/atomic.scm. * module/ice-9/atomic.scm: New file. * module/oop/goops.scm (<atomic-box>): New var.
* Only ptob->close() after read/write finishAndy Wingo2016-08-311-0/+85
* libguile/Makefile.am (noinst_HEADERS): Add atomics-internal.h. * libguile/atomics-internal.h: New file. * libguile/ports-internal.h (refcount): New member. * libguile/ports.c (release_port, scm_dynwind_acquire_port): New facility for acquiring a port within a dynwind. (scm_port_poll, scm_i_read_bytes, scm_setvbuf, scm_end_input) (scm_i_write_bytes, scm_char_ready_p, scm_seek) (scm_truncate_file, trampoline_to_c_read) (trampoline_to_c_write): Acquire port. (scm_c_make_port_with_encoding): Init refcount to 1. (scm_close_port): Release port. * doc/ref/api-io.texi (I/O Extensions): Add documentation