From: Max M. <ma...@op...> - 2006-07-28 19:13:07
|
Here is a proposed patch for review. I verified that it compiles and passes the tests both multi-threaded and unithreaded on amd64. It's intended to solve the problem which comes up every time someone uses threads and special variables: that is that there is no way to influence which special variables are bound in the thread if you are not in control of the thread's main function. Also it allows library/package developer to designate which specials inside their package should be bound on thread entry. Summary: New parameter 'default-bindings' added to make-thread, defaults to sb-ext:*default-special-bindings* New macro sb-ext:define-thread-local-var with exactly same syntax as defvar, except in addition to doing what defvar does, symbol and value is also added to *default-special-bindings*. On uni-threaded build it does same thing as defvar. Changed the fixed to make printer thread-safe to use the new feature. Note: I personally think that having a macro named (make-variable-thread-local) is a better convention to changing *default-special-bindings* then having a (def....) form, but I was told on #lisp to change it to mimic defvar so thats why its done this way. IMHO make-...local is simularly named to Emacs's make-variable-...-local. Also it reflects better what code does ie it adds variable to *default-special-bindings* thus "making" it thread local for new threads. Regards, Max SW5kZXg6IHBhY2thZ2UtZGF0YS1saXN0Lmxpc3AtZXhwcgo9PT09PT09PT09PT09PT09PT09PT09 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09ClJDUyBmaWxlOiAv Y3Zzcm9vdC9zYmNsL3NiY2wvcGFja2FnZS1kYXRhLWxpc3QubGlzcC1leHByLHYKcmV0cmlldmlu ZyByZXZpc2lvbiAxLjM1NwpkaWZmIC11IC1yMS4zNTcgcGFja2FnZS1kYXRhLWxpc3QubGlzcC1l eHByCi0tLSBwYWNrYWdlLWRhdGEtbGlzdC5saXNwLWV4cHIJMjAgSnVuIDIwMDYgMDU6Mzg6NDIg LTAwMDAJMS4zNTcKKysrIHBhY2thZ2UtZGF0YS1saXN0Lmxpc3AtZXhwcgkyNyBKdWwgMjAwNiAy MzozNDo1OSAtMDAwMApAQCAtNzQ5LDcgKzc0OSwxMiBAQAogCiAgICAgICAgICAgICAgICA7OyB0 aW1lcgogICAgICAgICAgICAgICAgIlRJTUVSIiAiTUFLRS1USU1FUiIgIlRJTUVSLU5BTUUiICJU SU1FUi1TQ0hFRFVMRUQtUCIKLSAgICAgICAgICAgICAgICJTQ0hFRFVMRS1USU1FUiIgIlVOU0NI RURVTEUtVElNRVIiICJMSVNULUFMTC1USU1FUlMiKSkKKyAgICAgICAgICAgICAgICJTQ0hFRFVM RS1USU1FUiIgIlVOU0NIRURVTEUtVElNRVIiICJMSVNULUFMTC1USU1FUlMiCisKKyAgICAgICAg ICAgICAgIDs7IHRocmVhZC1sb2NhbAorICAgICAgICAgICAgICAgIkRFRklORS1USFJFQUQtTE9D QUwtVkFSIgorICAgICAgICAgICAgICAgIipERUZBVUxULVNQRUNJQUwtQklORElOR1MqIgorICAg ICAgICAgICAgICAgKSkKIAogICAgI3Moc2ItY29sZDpwYWNrYWdlLWRhdGEKICAgICAgIDpuYW1l ICJTQiFGT1JNQVQiCkBAIC0xNjI1LDcgKzE2MzAsMTAgQEAKICAgICAgIDpuYW1lICJTQiFUSFJF QUQiCiAgICAgICA6dXNlICgiQ0wiICJTQiFBTElFTiIgIlNCIUlOVCIgIlNCIVNZUyIpCiAgICAg ICA6ZG9jICJwdWJsaWMgKGJ1dCBsb3ctbGV2ZWwpOiBuYXRpdmUgdGhyZWFkIHN1cHBvcnQiCi0g ICAgICA6ZXhwb3J0ICgiKkNVUlJFTlQtVEhSRUFEKiIgIlRIUkVBRCIgIk1BS0UtVEhSRUFEIgor ICAgICAgOmltcG9ydC1mcm9tICgoIlNCIUVYVCIgIipERUZBVUxULVNQRUNJQUwtQklORElOR1Mq IikpCisgICAgICA6cmVleHBvcnQgKCIqREVGQVVMVC1TUEVDSUFMLUJJTkRJTkdTKiIpCisgICAg ICA6ZXhwb3J0ICgiKkNVUlJFTlQtVEhSRUFEKiIKKyAgICAgICAgICAgICAgICJUSFJFQUQiICJN QUtFLVRIUkVBRCIKICAgICAgICAgICAgICAgICJUSFJFQUQtTkFNRSIgIlRIUkVBRC1BTElWRS1Q IgogICAgICAgICAgICAgICAgIkxJU1QtQUxMLVRIUkVBRFMiC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ikKICAgKHNiIXhjOnByb2NsYWltIGAoc3BlY2lhbCAsdmFyKSkpCiAKICMtc2IteGMtaG9z dAotKGRlZnVuICVkZWZ2YXIgKHZhciB2YWwgdmFscCBkb2MgZG9jcCBzb3VyY2UtbG9jYXRpb24p CisoZGVmdW4gJWRlZnZhciAodmFyIHZhbCB2YWxwIGRvYyBkb2NwIHNvdXJjZS1sb2NhdGlvbiB0 aHJlYWQtbG9jYWwtcCkKICAgKCVjb21waWxlci1kZWZ2YXIgdmFyKQogICAod2hlbiB2YWxwCiAg ICAgKHVubGVzcyAoYm91bmRwIHZhcikKQEAgLTI2OSwxNiArMzAxLDMzIEBACiAgICAgKHNldGYg KGZkb2N1bWVudGF0aW9uIHZhciAndmFyaWFibGUpIGRvYykpCiAgIChzYiFjOndpdGgtc291cmNl LWxvY2F0aW9uIChzb3VyY2UtbG9jYXRpb24pCiAgICAgKHNldGYgKGluZm8gOnNvdXJjZS1sb2Nh dGlvbiA6dmFyaWFibGUgdmFyKSBzb3VyY2UtbG9jYXRpb24pKQorICAod2hlbiB0aHJlYWQtbG9j YWwtcAorICAgIChsZXQgKChwcmV2IChhc3NvYyB2YXIgc2IhdGhyZWFkOjoqZGVmYXVsdC1zcGVj aWFsLWJpbmRpbmdzKikpCisgICAgICAgICAgKHZhbHVlIChjb25kICh2YWxwIHZhbCkKKyAgICAg ICAgICAgICAgICAgICAgICAgOzsgcGlja3VwIHRoZSBvbGQgdmFsdWUgaWYgYm91bmQKKyAgICAg ICAgICAgICAgICAgICAgICAgKChhbmQgKG5vdCB2YWxwKSAoYm91bmRwIHZhcikpIChzeW1ib2wt dmFsdWUgdmFyKSkKKyAgICAgICAgICAgICAgICAgICAgICAgKHQgKHNiIWtlcm5lbDptYWtlLWxp c3Atb2JqCisgICAgICAgICAgICAgICAgICAgICAgICAgICBzYiF2bTo6bm8tdGxzLXZhbHVlLW1h cmtlci13aWRldGFnKSkpKSkKKyAgICAgIChpZiBwcmV2CisgICAgICAgICAgKHJwbG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kKLSAgICAgICAgICAgICAgICAgIChzYiFpbXBsOjoqaW50ZXJuYWwtc3lt Ym9sLW91dHB1dC1mdW4qIG5pbCkKLSAgICAgICAgICAgICAgICAgIChzYiFpbXBsOjoqZGVzY3Jp cHRvci1oYW5kbGVycyogbmlsKSkgOyBzZXJ2ZS1ldmVudAotICAgICAgICAgICAgICAoc2V0ZiAo dGhyZWFkLW9zLXRocmVhZCB0aHJlYWQpIChjdXJyZW50LXRocmVhZC1zYXAtaWQpKQotICAgICAg ICAgICAgICAod2l0aC1tdXRleCAoKmFsbC10aHJlYWRzLWxvY2sqKQotICAgICAgICAgICAgICAg IChwdXNoIHRocmVhZCAqYWxsLXRocmVhZHMqKSkKLSAgICAgICAgICAgICAgKHdpdGgtc2Vzc2lv bi1sb2NrICgqc2Vzc2lvbiopCi0gICAgICAgICAgICAgICAgKHB1c2ggdGhyZWFkIChzZXNzaW9u LXRocmVhZHMgKnNlc3Npb24qKSkpCi0gICAgICAgICAgICAgIChzZXRmICh0aHJlYWQtJWFsaXZl LXAgdGhyZWFkKSB0KQotICAgICAgICAgICAgICAoc2lnbmFsLXNlbWFwaG9yZSBzZXR1cC1zZW0p Ci0gICAgICAgICAgICAgIDs7IGNhbid0IHVzZSBoYW5kbGluZy1lbmQtb2YtdGhlLXdvcmxkLCBi ZWNhdXNlIHRoYXQgZmx1c2hlcwotICAgICAgICAgICAgICA7OyBvdXRwdXQgc3RyZWFtcywgYW5k IHdlIGRvbid0IG5lY2Vzc2FyaWx5IGhhdmUgYW55IChvciB3ZQotICAgICAgICAgICAgICA7OyBj b3VsZCBiZSBzaGFyaW5nIHRoZW0pCi0gICAgICAgICAgICAgIChjYXRjaCAnc2IhaW1wbDo6dG9w bGV2ZWwtY2F0Y2hlcgotICAgICAgICAgICAgICAgIChjYXRjaCAnc2IhaW1wbDo6JWVuZC1vZi10 aGUtd29ybGQKLSAgICAgICAgICAgICAgICAgICh3aXRoLXNpbXBsZS1yZXN0YXJ0Ci0gICAgICAg ICAgICAgICAgICAgICAgKHRlcm1pbmF0ZS10aHJlYWQKLSAgICAgICAgICAgICAgICAgICAgICAg KGZvcm1hdCBuaWwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAifn5APFRlcm1pbmF0 ZSB0aGlzIHRocmVhZCAofkEpfn5AOj4iCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg KmN1cnJlbnQtdGhyZWFkKikpCi0gICAgICAgICAgICAgICAgICAgICh1bndpbmQtcHJvdGVjdAot ICAgICAgICAgICAgICAgICAgICAgICAgIChwcm9nbgotICAgICAgICAgICAgICAgICAgICAgICAg ICAgOzsgbm93IHRoYXQgbW9zdCB0aGluZ3MgaGF2ZSBhIGNoYW5jZSB0bwotICAgICAgICAgICAg ICAgICAgICAgICAgICAgOzsgd29yayBwcm9wZXJseSB3aXRob3V0IG1lc3NpbmcgdXAgb3RoZXIK LSAgICAgICAgICAgICAgICAgICAgICAgICAgIDs7IHRocmVhZHMsIGl0J3MgdGltZSB0byBlbmFi bGUgc2lnbmFscwotICAgICAgICAgICAgICAgICAgICAgICAgICAgKHNiIXVuaXg6OnJlc2V0LXNp Z25hbC1tYXNrKQotICAgICAgICAgICAgICAgICAgICAgICAgICAgKGZ1bmNhbGwgcmVhbC1mdW5j dGlvbikpCi0gICAgICAgICAgICAgICAgICAgICAgOzsgd2UncmUgZ29pbmcgZG93biwgY2FuJ3Qg aGFuZGxlCi0gICAgICAgICAgICAgICAgICAgICAgOzsgaW50ZXJydXB0cyBzYW5lbHkgYW55bW9y ZQotICAgICAgICAgICAgICAgICAgICAgIChsZXQgKChzYiFpbXBsOjoqZ2MtaW5oaWJpdCogdCkp Ci0gICAgICAgICAgICAgICAgICAgICAgICAoYmxvY2stYmxvY2thYmxlLXNpZ25hbHMpCi0gICAg ICAgICAgICAgICAgICAgICAgICAoc2V0ZiAodGhyZWFkLSVhbGl2ZS1wIHRocmVhZCkgbmlsKQot ICAgICAgICAgICAgICAgICAgICAgICAgKHNldGYgKHRocmVhZC1vcy10aHJlYWQgdGhyZWFkKSBu aWwpCi0gICAgICAgICAgICAgICAgICAgICAgICA7OyBhbmQgcmVtb3ZlIHdoYXQgY2FuIGJlIHRo ZSBsYXN0Ci0gICAgICAgICAgICAgICAgICAgICAgICA7OyByZWZlcmVuY2UgdG8gdGhpcyB0aHJl YWQKLSAgICAgICAgICAgICAgICAgICAgICAgIChoYW5kbGUtdGhyZWFkLWV4aXQgdGhyZWFkKSkp KSkpKQotICAgICAgICAgICAgKHZhbHVlcykpKSkKLSAgICA7OyBLZWVwIElOSVRJQUwtRlVOQ1RJ T04gcGlubmVkIHVudGlsIHRoZSBjaGlsZCB0aHJlYWQgaXMKLSAgICA7OyBpbml0aWFsaXplZCBw cm9wZXJseS4KLSAgICAod2l0aC1waW5uZWQtb2JqZWN0cyAoaW5pdGlhbC1mdW5jdGlvbikKLSAg ICAgIChsZXQgKChvcy10aHJlYWQKLSAgICAgICAgICAgICAoJWNyZWF0ZS10aHJlYWQKLSAgICAg ICAgICAgICAgKHNiIWtlcm5lbDpnZXQtbGlzcC1vYmotYWRkcmVzcyBpbml0aWFsLWZ1bmN0aW9u KSkpKQotICAgICAgICAod2hlbiAoemVyb3Agb3MtdGhyZWFkKQotICAgICAgICAgIChlcnJvciAi Q2FuJ3QgY3JlYXRlIGEgbmV3IHRocmVhZCIpKQotICAgICAgICAod2FpdC1vbi1zZW1hcGhvcmUg c2V0dXAtc2VtKQotICAgICAgICB0aHJlYWQpKSkpCisgIChtdWx0aXBsZS12YWx1ZS1iaW5kIChk ZWZhdWx0LWJpbmRpbmdzLXZhcnMgZGVmYXVsdC1iaW5kaW5ncy12YWxzKQorICAgICAgKCVtYWtl LWJpbmRpbmdzLWZvci10aHJlYWQgZGVmYXVsdC1iaW5kaW5ncykKKyAgICAobGV0KiAoKHRocmVh ZCAoJW1ha2UtdGhyZWFkIDpuYW1lIG5hbWUpKQorICAgICAgICAgICAoc2V0dXAtc2VtIChtYWtl LXNlbWFwaG9yZSA6bmFtZSAiVGhyZWFkIHNldHVwIHNlbWFwaG9yZSIpKQorICAgICAgICAgICAo cmVhbC1mdW5jdGlvbiAoY29lcmNlIGZ1bmN0aW9uICdmdW5jdGlvbikpCisgICAgICAgICAgIChp bml0aWFsLWZ1bmN0aW9uCisgICAgICAgICAgICAobGFtYmRhICgpCisgICAgICAgICAgICAgIDs7 IEluIHRpbWUgd2UnbGwgbW92ZSBzb21lIG9mIHRoZSBiaW5kaW5nIHByZXNlbnRseSBkb25lIGlu IEMKKyAgICAgICAgICAgICAgOzsgaGVyZSB0b28uCisgICAgICAgICAgICAgIDs7CisgICAgICAg ICAgICAgIDs7IEJpbmQgc29tZSBzdXBlci1jcml0aWFsIHZhcmlhYmxlcyBtYW51YWxseSwgdGhl IHJlc3QKKyAgICAgICAgICAgICAgOzsgYXJlIGhhbmRsZWQgdmlhICpERUZBVUxULVNQRUNJQUwt QklORElOR1MqCisgICAgICAgICAgICAgIDs7CisgICAgICAgICAgICAgIDs7IFRoZSByZWFzb24g aXMgdGhhdCB3ZSB3YW50IHRocmVhZGluZyBhdCBsZWFzdAorICAgICAgICAgICAgICA7OyBzb21l d2hhdCB3b3JraW5nIGV2ZW4gaWYgdXNlciBzaG9vdHMgdGhlbXNlbGYKKyAgICAgICAgICAgICAg OzsgaW4gYSBmb290IGFuZCBwYXNzZXMgREVGQVVMVC1CSU5ESU5HUyBhcyBuaWwKKyAgICAgICAg ICAgICAgOzsgb3Igc2V0cyAqREVGQVVMVC1TUEVDSUFMLUJJTkRJTkdTKiBuaWwKKyAgICAgICAg ICAgICAgKGxldCAoKCpjdXJyZW50LXRocmVhZCogdGhyZWFkKQorICAgICAgICAgICAgICAgICAg ICAoc2Iha2VybmVsOjoqcmVzdGFydC1jbHVzdGVycyogbmlsKQorICAgICAgICAgICAgICAgICAg ICAoc2Iha2VybmVsOjoqaGFuZGxlci1jbHVzdGVycyogbmlsKQorICAgICAgICAgICAgICAgICAg ICAoc2Iha2VybmVsOjoqY29uZGl0aW9uLXJlc3RhcnRzKiBuaWwpCisgICAgICAgICAgICAgICAg ICAgIChzYiFpbXBsOjoqZGVzY3JpcHRvci1oYW5kbGVycyogbmlsKSkgOyBzZXJ2ZS1ldmVudAor ICAgICAgICAgICAgICAgIChzZXRmICh0aHJlYWQtb3MtdGhyZWFkIHRocmVhZCkgKGN1cnJlbnQt dGhyZWFkLXNhcC1pZCkpCisgICAgICAgICAgICAgICAgKHdpdGgtbXV0ZXggKCphbGwtdGhyZWFk cy1sb2NrKikKKyAgICAgICAgICAgICAgICAgIChwdXNoIHRocmVhZCAqYWxsLXRocmVhZHMqKSkK KyAgICAgICAgICAgICAgICAod2l0aC1zZXNzaW9uLWxvY2sgKCpzZXNzaW9uKikKKyAgICAgICAg ICAgICAgICAgIChwdXNoIHRocmVhZCAoc2Vzc2lvbi10aHJlYWRzICpzZXNzaW9uKikpKQorICAg ICAgICAgICAgICAgIChzZXRmICh0aHJlYWQtJWFsaXZlLXAgdGhyZWFkKSB0KQorICAgICAgICAg ICAgICAgIDs7IGNhbid0IHVzZSBoYW5kbGluZy1lbmQtb2YtdGhlLXdvcmxkLCBiZWNhdXNlIHRo YXQgZmx1c2hlcworICAgICAgICAgICAgICAgIDs7IG91dHB1dCBzdHJlYW1zLCBhbmQgd2UgZG9u J3QgbmVjZXNzYXJpbHkgaGF2ZSBhbnkgKG9yIHdlCisgICAgICAgICAgICAgICAgOzsgY291bGQg YmUgc2hhcmluZyB0aGVtKQorICAgICAgICAgICAgICAgIChwcm9ndiBkZWZhdWx0LWJpbmRpbmdz LXZhcnMgZGVmYXVsdC1iaW5kaW5ncy12YWxzCisgICAgICAgICAgICAgICAgICAoc2lnbmFsLXNl bWFwaG9yZSBzZXR1cC1zZW0pCisgICAgICAgICAgICAgICAgICAoY2F0Y2ggJ3NiIWltcGw6OnRv cGxldmVsLWNhdGNoZXIKKyAgICAgICAgICAgICAgICAgICAgKGNhdGNoICdzYiFpbXBsOjolZW5k LW9mLXRoZS13b3JsZAorICAgICAgICAgICAgICAgICAgICAgICh3aXRoLXNpbXBsZS1yZXN0YXJ0 CisgICAgICAgICAgICAgICAgICAgICAgICAgICh0ZXJtaW5hdGUtdGhyZWFkCisgICAgICAgICAg ICAgICAgICAgICAgICAgICAoZm9ybWF0IG5pbAorICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAifn5APFRlcm1pbmF0ZSB0aGlzIHRocmVhZCAofkEpfn5AOj4iCisgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICpjdXJyZW50LXRocmVhZCopKQorICAgICAgICAgICAg ICAgICAgICAgICAgKHVud2luZC1wcm90ZWN0CisgICAgICAgICAgICAgICAgICAgICAgICAgICAg IChwcm9nbgorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIDs7IG5vdyB0aGF0IG1vc3Qg dGhpbmdzIGhhdmUgYSBjaGFuY2UgdG8KKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA7 OyB3b3JrIHByb3Blcmx5IHdpdGhvdXQgbWVzc2luZyB1cCBvdGhlcgorICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgIDs7IHRocmVhZHMsIGl0J3MgdGltZSB0byBlbmFibGUgc2lnbmFscwor ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIChzYiF1bml4OjpyZXNldC1zaWduYWwtbWFz aykKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoZnVuY2FsbCByZWFsLWZ1bmN0aW9u KSkKKyAgICAgICAgICAgICAgICAgICAgICAgICAgOzsgd2UncmUgZ29pbmcgZG93biwgY2FuJ3Qg aGFuZGxlCisgICAgICAgICAgICAgICAgICAgICAgICAgIDs7IGludGVycnVwdHMgc2FuZWx5IGFu eW1vcmUKKyAgICAgICAgICAgICAgICAgICAgICAgICAgKGxldCAoKHNiIWltcGw6OipnYy1pbmhp Yml0KiB0KSkKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAoYmxvY2stYmxvY2thYmxlLXNp Z25hbHMpCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgKHNldGYgKHRocmVhZC0lYWxpdmUt cCB0aHJlYWQpIG5pbCkKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAoc2V0ZiAodGhyZWFk LW9zLXRocmVhZCB0aHJlYWQpIG5pbCkKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICA7OyBh bmQgcmVtb3ZlIHdoYXQgY2FuIGJlIHRoZSBsYXN0CisgICAgICAgICAgICAgICAgICAgICAgICAg ICAgOzsgcmVmZXJlbmNlIHRvIHRoaXMgdGhyZWFkCisgICAgICAgICAgICAgICAgICAgICAgICAg ICAgKGhhbmRsZS10aHJlYWQtZXhpdCB0aHJlYWQpKSkpKSkpKQorICAgICAgICAgICAgICAodmFs dWVzKSkpKQorICAgICAgOzsgS2VlcCBJTklUSUFMLUZVTkNUSU9OIHBpbm5lZCB1bnRpbCB0aGUg Y2hpbGQgdGhyZWFkIGlzCisgICAgICA7OyBpbml0aWFsaXplZCBwcm9wZXJseS4KKyAgICAgICh3 aXRoLXBpbm5lZC1vYmplY3RzIChpbml0aWFsLWZ1bmN0aW9uKQorICAgICAgICAobGV0ICgob3Mt dGhyZWFkCisgICAgICAgICAgICAgICAoJWNyZWF0ZS10aHJlYWQKKyAgICAgICAgICAgICAgICAo c2Iha2VybmVsOmdldC1saXNwLW9iai1hZGRyZXNzIGluaXRpYWwtZnVuY3Rpb24pKSkpCisgICAg ICAgICAgKHdoZW4gKHplcm9wIG9zLXRocmVhZCkKKyAgICAgICAgICAgIChlcnJvciAiQ2FuJ3Qg Y3JlYXRlIGEgbmV3IHRocmVhZCIpKQorICAgICAgICAgICh3YWl0LW9uLXNlbWFwaG9yZSBzZXR1 cC1zZW0pCisgICAgICAgICAgdGhyZWFkKSkpKSkKIAogKGRlZnVuIGRlc3Ryb3ktdGhyZWFkICh0 aHJlYWQpCiAgICMhK3NiLWRvYwo= ===File ~/cvs/sbcl/default-special-bindings.patch=========== Index: package-data-list.lisp-expr =================================================================== RCS file: /cvsroot/sbcl/sbcl/package-data-list.lisp-expr,v retrieving revision 1.357 diff -u -r1.357 package-data-list.lisp-expr --- package-data-list.lisp-expr 20 Jun 2006 05:38:42 -0000 1.357 +++ package-data-list.lisp-expr 27 Jul 2006 23:34:59 -0000 @@ -749,7 +749,12 @@ ;; timer "TIMER" "MAKE-TIMER" "TIMER-NAME" "TIMER-SCHEDULED-P" - "SCHEDULE-TIMER" "UNSCHEDULE-TIMER" "LIST-ALL-TIMERS")) + "SCHEDULE-TIMER" "UNSCHEDULE-TIMER" "LIST-ALL-TIMERS" + + ;; thread-local + "DEFINE-THREAD-LOCAL-VAR" + "*DEFAULT-SPECIAL-BINDINGS*" + )) #s(sb-cold:package-data :name "SB!FORMAT" @@ -1625,7 +1630,10 @@ :name "SB!THREAD" :use ("CL" "SB!ALIEN" "SB!INT" "SB!SYS") :doc "public (but low-level): native thread support" - :export ("*CURRENT-THREAD*" "THREAD" "MAKE-THREAD" + :import-from (("SB!EXT" "*DEFAULT-SPECIAL-BINDINGS*")) + :reexport ("*DEFAULT-SPECIAL-BINDINGS*") + :export ("*CURRENT-THREAD*" + "THREAD" "MAKE-THREAD" "THREAD-NAME" "THREAD-ALIVE-P" "LIST-ALL-THREADS" "INTERRUPT-THREAD-ERROR" Index: src/code/defboot.lisp =================================================================== RCS file: /cvsroot/sbcl/sbcl/src/code/defboot.lisp,v retrieving revision 1.52 diff -u -r1.52 defboot.lisp --- src/code/defboot.lisp 15 May 2006 16:11:38 -0000 1.52 +++ src/code/defboot.lisp 27 Jul 2006 23:35:00 -0000 @@ -241,7 +241,24 @@ (eval-when (:load-toplevel :execute) (%defvar ',var (unless (boundp ',var) ,val) ',valp ,doc ',docp - (sb!c:source-location))))) + (sb!c:source-location) nil)))) + +(defmacro-mundanely define-thread-local-var (var &optional (val nil valp) (doc nil docp)) + #!+sb-doc + "Define a global variable at top level. Declare the variable + SPECIAL and, optionally, initialize it. In addition add the variable + to *default-special-bindings* a-list. If the variable already has a + value, the old value is not clobbered. The third argument is an optional + documentation string for the variable. " + `(progn + (eval-when (:compile-toplevel) + (%compiler-defvar ',var)) + (eval-when (:load-toplevel :execute) + (%defvar ',var (unless (boundp ',var) ,val) + ',valp ,doc ',docp + (sb!c:source-location) + #+sb-thread t + #-sb-thread nil)))) (defmacro-mundanely defparameter (var val &optional (doc nil docp)) #!+sb-doc @@ -254,13 +271,28 @@ (eval-when (:compile-toplevel) (%compiler-defvar ',var)) (eval-when (:load-toplevel :execute) - (%defparameter ',var ,val ,doc ',docp (sb!c:source-location))))) + (%defparameter ',var ,val ,doc ',docp (sb!c:source-location) nil)))) + +(defmacro-mundanely define-thread-local-parameter (var val &optional (doc nil docp)) + #!+sb-doc + "Define a parameter that is not normally changed by the program, + but that may be changed without causing an error. Declare the + variable special and sets its value to VAL, overwriting any + previous value. Also add the variable to *default-special-bindings*. + The third argument is an optional documentation string for the parameter." + `(progn + (eval-when (:compile-toplevel) + (%compiler-defvar ',var)) + (eval-when (:load-toplevel :execute) + (%defparameter ',var ,val ,doc ',docp (sb!c:source-location) + #+sb-thread t + #-sb-thread nil)))) (defun %compiler-defvar (var) (sb!xc:proclaim `(special ,var))) #-sb-xc-host -(defun %defvar (var val valp doc docp source-location) +(defun %defvar (var val valp doc docp source-location thread-local-p) (%compiler-defvar var) (when valp (unless (boundp var) @@ -269,16 +301,33 @@ (setf (fdocumentation var 'variable) doc)) (sb!c:with-source-location (source-location) (setf (info :source-location :variable var) source-location)) + (when thread-local-p + (let ((prev (assoc var sb!thread::*default-special-bindings*)) + (value (cond (valp val) + ;; pickup the old value if bound + ((and (not valp) (boundp var)) (symbol-value var)) + (t (sb!kernel:make-lisp-obj + sb!vm::no-tls-value-marker-widetag))))) + (if prev + (rplacd prev value) + (push (cons var value) + sb!thread::*default-special-bindings*)))) var) #-sb-xc-host -(defun %defparameter (var val doc docp source-location) +(defun %defparameter (var val doc docp source-location thread-local-p) (%compiler-defvar var) (set var val) (when docp (setf (fdocumentation var 'variable) doc)) (sb!c:with-source-location (source-location) (setf (info :source-location :variable var) source-location)) + (when thread-local-p + (let ((prev (assoc var sb!thread::*default-special-bindings*))) + (if prev + (rplacd prev val) + (push (cons var val) + sb!thread::*default-special-bindings*)))) var) ;;;; iteration constructs Index: src/code/early-thread.lisp =================================================================== RCS file: /cvsroot/sbcl/sbcl/src/code/early-thread.lisp,v retrieving revision 1.1 diff -u -r1.1 early-thread.lisp --- src/code/early-thread.lisp 1 Jul 2005 08:48:33 -0000 1.1 +++ src/code/early-thread.lisp 27 Jul 2006 23:35:00 -0000 @@ -10,3 +10,4 @@ (in-package "SB!THREAD") (defvar *current-thread*) +(defvar *default-special-bindings* nil) Index: src/code/print.lisp =================================================================== RCS file: /cvsroot/sbcl/sbcl/src/code/print.lisp,v retrieving revision 1.68 diff -u -r1.68 print.lisp --- src/code/print.lisp 16 Mar 2006 03:24:18 -0000 1.68 +++ src/code/print.lisp 27 Jul 2006 23:35:01 -0000 @@ -399,12 +399,12 @@ ;;; values of *PRINT-CASE* and (READTABLE-CASE *READTABLE*) the last ;;; time the printer was called -(defvar *previous-case* nil) -(defvar *previous-readtable-case* nil) +(define-thread-local-var *previous-case* nil) +(define-thread-local-var *previous-readtable-case* nil) ;;; This variable contains the current definition of one of three ;;; symbol printers. SETUP-PRINTER-STATE sets this variable. -(defvar *internal-symbol-output-fun* nil) +(define-thread-local-var *internal-symbol-output-fun* nil) ;;; This function sets the internal global symbol ;;; *INTERNAL-SYMBOL-OUTPUT-FUN* to the right function depending on Index: src/code/target-thread.lisp =================================================================== RCS file: /cvsroot/sbcl/sbcl/src/code/target-thread.lisp,v retrieving revision 1.57 diff -u -r1.57 target-thread.lisp --- src/code/target-thread.lisp 15 Jul 2006 17:40:09 -0000 1.57 +++ src/code/target-thread.lisp 27 Jul 2006 23:35:01 -0000 @@ -577,85 +577,95 @@ (sb!int:flush-standard-output-streams)))))) (make-thread #'thread-repl)))) + +#+sb-thread +(defun %make-bindings-for-thread (bindings) + (loop for binding in bindings + if (not (symbolp (first binding))) + do (error "Non-symbol in default-bindings") + else collect (first binding) into vars + and collect (rest binding) into vals + finally (return (values vars vals)))) + ;;;; the beef -(defun make-thread (function &key name) +(defun make-thread (function &key name + (default-bindings sb!thread::*default-special-bindings*)) #!+sb-doc "Create a new thread of NAME that runs FUNCTION. When the function -returns the thread exits." - #!-sb-thread (declare (ignore function name)) +returns the thread exits. DEFAULT-BINDINGS is an list of (variable . value) +bindings which will be bound while FUNCTION is executed." + #!-sb-thread (declare (ignore function name default-bindings)) #!-sb-thread (error "Not supported in unithread builds.") + #!+sb-thread (declare (type list default-bindings)) #!+sb-thread - (let* ((thread (%make-thread :name name)) - (setup-sem (make-semaphore :name "Thread setup semaphore")) - (real-function (coerce function 'function)) - (initial-function - (lambda () - ;; In time we'll move some of the binding presently done in C - ;; here too. - ;; - ;; KLUDGE: Here we have a magic list of variables that are - ;; not thread-safe for one reason or another. As people - ;; report problems with the thread safety of certain - ;; variables, (e.g. "*print-case* in multiple threads - ;; broken", sbcl-devel 2006-07-14), we add a few more - ;; bindings here. The Right Thing is probably some variant - ;; of Allegro's *cl-default-special-bindings*, as that is at - ;; least accessible to users to secure their own libraries. - ;; --njf, 2006-07-15 - (let ((*current-thread* thread) - (sb!kernel::*restart-clusters* nil) - (sb!kernel::*handler-clusters* nil) - (sb!kernel::*condition-restarts* nil) - ;; internal printer variables - (sb!impl::*previous-case* nil) - (sb!impl::*previous-readtable-case* nil) - (sb!impl::*internal-symbol-output-fun* nil) - (sb!impl::*descriptor-handlers* nil)) ; serve-event - (setf (thread-os-thread thread) (current-thread-sap-id)) - (with-mutex (*all-threads-lock*) - (push thread *all-threads*)) - (with-session-lock (*session*) - (push thread (session-threads *session*))) - (setf (thread-%alive-p thread) t) - (signal-semaphore setup-sem) - ;; can't use handling-end-of-the-world, because that flushes - ;; output streams, and we don't necessarily have any (or we - ;; could be sharing them) - (catch 'sb!impl::toplevel-catcher - (catch 'sb!impl::%end-of-the-world - (with-simple-restart - (terminate-thread - (format nil - "~~@<Terminate this thread (~A)~~@:>" - *current-thread*)) - (unwind-protect - (progn - ;; now that most things have a chance to - ;; work properly without messing up other - ;; threads, it's time to enable signals - (sb!unix::reset-signal-mask) - (funcall real-function)) - ;; we're going down, can't handle - ;; interrupts sanely anymore - (let ((sb!impl::*gc-inhibit* t)) - (block-blockable-signals) - (setf (thread-%alive-p thread) nil) - (setf (thread-os-thread thread) nil) - ;; and remove what can be the last - ;; reference to this thread - (handle-thread-exit thread))))))) - (values)))) - ;; Keep INITIAL-FUNCTION pinned until the child thread is - ;; initialized properly. - (with-pinned-objects (initial-function) - (let ((os-thread - (%create-thread - (sb!kernel:get-lisp-obj-address initial-function)))) - (when (zerop os-thread) - (error "Can't create a new thread")) - (wait-on-semaphore setup-sem) - thread)))) + (multiple-value-bind (default-bindings-vars default-bindings-vals) + (%make-bindings-for-thread default-bindings) + (let* ((thread (%make-thread :name name)) + (setup-sem (make-semaphore :name "Thread setup semaphore")) + (real-function (coerce function 'function)) + (initial-function + (lambda () + ;; In time we'll move some of the binding presently done in C + ;; here too. + ;; + ;; Bind some super-critial variables manually, the rest + ;; are handled via *DEFAULT-SPECIAL-BINDINGS* + ;; + ;; The reason is that we want threading at least + ;; somewhat working even if user shoots themself + ;; in a foot and passes DEFAULT-BINDINGS as nil + ;; or sets *DEFAULT-SPECIAL-BINDINGS* nil + (let ((*current-thread* thread) + (sb!kernel::*restart-clusters* nil) + (sb!kernel::*handler-clusters* nil) + (sb!kernel::*condition-restarts* nil) + (sb!impl::*descriptor-handlers* nil)) ; serve-event + (setf (thread-os-thread thread) (current-thread-sap-id)) + (with-mutex (*all-threads-lock*) + (push thread *all-threads*)) + (with-session-lock (*session*) + (push thread (session-threads *session*))) + (setf (thread-%alive-p thread) t) + ;; can't use handling-end-of-the-world, because that flushes + ;; output streams, and we don't necessarily have any (or we + ;; could be sharing them) + (progv default-bindings-vars default-bindings-vals + (signal-semaphore setup-sem) + (catch 'sb!impl::toplevel-catcher + (catch 'sb!impl::%end-of-the-world + (with-simple-restart + (terminate-thread + (format nil + "~~@<Terminate this thread (~A)~~@:>" + *current-thread*)) + (unwind-protect + (progn + ;; now that most things have a chance to + ;; work properly without messing up other + ;; threads, it's time to enable signals + (sb!unix::reset-signal-mask) + (funcall real-function)) + ;; we're going down, can't handle + ;; interrupts sanely anymore + (let ((sb!impl::*gc-inhibit* t)) + (block-blockable-signals) + (setf (thread-%alive-p thread) nil) + (setf (thread-os-thread thread) nil) + ;; and remove what can be the last + ;; reference to this thread + (handle-thread-exit thread)))))))) + (values)))) + ;; Keep INITIAL-FUNCTION pinned until the child thread is + ;; initialized properly. + (with-pinned-objects (initial-function) + (let ((os-thread + (%create-thread + (sb!kernel:get-lisp-obj-address initial-function)))) + (when (zerop os-thread) + (error "Can't create a new thread")) + (wait-on-semaphore setup-sem) + thread))))) (defun destroy-thread (thread) #!+sb-doc ============================================================ |