From: Matt Birkholz Date: Sat, 18 Jul 2015 23:32:41 +0000 (-0700) Subject: Add COPY-SELECT-REGISTRY primitive. X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=528c6df6e202cb6812e444c0a15644327001c55d;p=mit-scheme.git Add COPY-SELECT-REGISTRY primitive. --- diff --git a/src/microcode/osio.h b/src/microcode/osio.h index da0d862a2..9fa7af06d 100644 --- a/src/microcode/osio.h +++ b/src/microcode/osio.h @@ -109,6 +109,10 @@ extern int OS_test_select_registry (select_registry_t registry, int blockp); extern int OS_test_select_descriptor (int fd, int blockp, unsigned int mode); +#ifdef ENABLE_SMP +extern void OS_copy_select_registry + (select_registry_t from, select_registry_t to); +#endif extern int OS_pause (bool ignore_status_change); #endif /* SCM_OSIO_H */ diff --git a/src/microcode/prosio.c b/src/microcode/prosio.c index 9fcfea72f..258ac1c99 100644 --- a/src/microcode/prosio.c +++ b/src/microcode/prosio.c @@ -316,6 +316,18 @@ DEFINE_PRIMITIVE ("SELECT-REGISTRY-LENGTH", Prim_selreg_length, 1, 1, 0) (ulong_to_integer (OS_select_registry_length (arg_select_registry (1)))); } +DEFINE_PRIMITIVE ("COPY-SELECT-REGISTRY", Prim_copy_selreg, 2, 2, 0) +{ + PRIMITIVE_HEADER (2); +#ifdef ENABLE_SMP + OS_copy_select_registry ((arg_select_registry (1)), + (arg_select_registry (2))); + PRIMITIVE_RETURN (UNSPECIFIC); +#else + signal_error_from_primitive (ERR_UNIMPLEMENTED_PRIMITIVE); +#endif +} + DEFINE_PRIMITIVE ("TEST-SELECT-REGISTRY", Prim_test_selreg, 4, 4, 0) { PRIMITIVE_HEADER (4); diff --git a/src/microcode/uxio.c b/src/microcode/uxio.c index 83304b300..027f7c7e5 100644 --- a/src/microcode/uxio.c +++ b/src/microcode/uxio.c @@ -538,6 +538,25 @@ OS_select_registry_length (select_registry_t registry) return (SR_N_FDS (r)); } +#ifdef ENABLE_SMP +void +OS_copy_select_registry (select_registry_t from, select_registry_t to) +{ + struct select_registry_s * f = from; + struct select_registry_s * t = to; + int fl = SR_LENGTH (f); + int tl = SR_LENGTH (t); + if (tl < fl) + { + free (SR_ENTRIES (t)); + (SR_ENTRIES (t)) = (UX_malloc (SR_BYTES (fl))); + (SR_LENGTH (t)) = fl; + } + memcpy ((SR_ENTRIES (t)), (SR_ENTRIES (f)), (SR_BYTES (SR_N_FDS (f)))); + (SR_N_FDS (t)) = (SR_N_FDS (f)); +} +#endif + void OS_select_registry_result (select_registry_t registry, unsigned int index, @@ -722,6 +741,21 @@ OS_select_registry_length (select_registry_t registry) return (SR_N_FDS (r)); } +#ifdef ENABLE_SMP +void +OS_copy_select_registry (select_registry_t from, select_registry_t to) +{ + struct select_registry_s * f = from; + struct select_registry_s * t = to; + + (* (SR_QREADERS (t))) = (* (SR_QREADERS (f))); + (* (SR_QWRITERS (t))) = (* (SR_QWRITERS (f))); + (* (SR_RREADERS (t))) = (* (SR_RREADERS (f))); + (* (SR_RWRITERS (t))) = (* (SR_RWRITERS (f))); + (SR_N_FDS (t)) = (SR_N_FDS (r)); +} +#endif + void OS_select_registry_result (select_registry_t registry, unsigned int index,