From: Matt Birkholz Date: Wed, 17 Dec 2014 08:48:39 +0000 (-0700) Subject: smp: Add primitive copy-select-registry. X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=3c2a4e710edb5b73966f0f814ce112ecb0c5afc4;p=mit-scheme.git smp: Add primitive copy-select-registry. --- diff --git a/src/microcode/osio.h b/src/microcode/osio.h index a0e28ae5f..ee8d32af4 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 (void); #endif /* SCM_OSIO_H */ diff --git a/src/microcode/prosio.c b/src/microcode/prosio.c index 08389fa70..ea14020f5 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 8bbb260bc..c60ce906f 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, @@ -717,6 +736,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,