nokolexbor 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/ext/nokolexbor/config.h +186 -0
- data/ext/nokolexbor/extconf.rb +131 -0
- data/ext/nokolexbor/libxml/HTMLparser.h +320 -0
- data/ext/nokolexbor/libxml/SAX2.h +173 -0
- data/ext/nokolexbor/libxml/chvalid.h +230 -0
- data/ext/nokolexbor/libxml/debugXML.h +217 -0
- data/ext/nokolexbor/libxml/dict.h +81 -0
- data/ext/nokolexbor/libxml/encoding.h +232 -0
- data/ext/nokolexbor/libxml/entities.h +153 -0
- data/ext/nokolexbor/libxml/globals.h +529 -0
- data/ext/nokolexbor/libxml/hash.h +236 -0
- data/ext/nokolexbor/libxml/list.h +137 -0
- data/ext/nokolexbor/libxml/parser.h +1264 -0
- data/ext/nokolexbor/libxml/parserInternals.h +641 -0
- data/ext/nokolexbor/libxml/pattern.h +100 -0
- data/ext/nokolexbor/libxml/threads.h +94 -0
- data/ext/nokolexbor/libxml/tree.h +1315 -0
- data/ext/nokolexbor/libxml/uri.h +94 -0
- data/ext/nokolexbor/libxml/valid.h +448 -0
- data/ext/nokolexbor/libxml/xmlIO.h +369 -0
- data/ext/nokolexbor/libxml/xmlautomata.h +146 -0
- data/ext/nokolexbor/libxml/xmlerror.h +919 -0
- data/ext/nokolexbor/libxml/xmlexports.h +79 -0
- data/ext/nokolexbor/libxml/xmlmemory.h +226 -0
- data/ext/nokolexbor/libxml/xmlregexp.h +222 -0
- data/ext/nokolexbor/libxml/xmlstring.h +140 -0
- data/ext/nokolexbor/libxml/xmlversion.h +526 -0
- data/ext/nokolexbor/libxml/xpath.h +575 -0
- data/ext/nokolexbor/libxml/xpathInternals.h +632 -0
- data/ext/nokolexbor/libxml/xpointer.h +137 -0
- data/ext/nokolexbor/libxml.h +76 -0
- data/ext/nokolexbor/memory.c +39 -0
- data/ext/nokolexbor/nl_document.c +51 -0
- data/ext/nokolexbor/nl_node.c +790 -0
- data/ext/nokolexbor/nl_node_set.c +368 -0
- data/ext/nokolexbor/nl_xpath_context.c +200 -0
- data/ext/nokolexbor/nokolexbor.c +63 -0
- data/ext/nokolexbor/nokolexbor.h +37 -0
- data/ext/nokolexbor/private/buf.h +70 -0
- data/ext/nokolexbor/private/dict.h +11 -0
- data/ext/nokolexbor/private/enc.h +17 -0
- data/ext/nokolexbor/private/error.h +21 -0
- data/ext/nokolexbor/private/globals.h +9 -0
- data/ext/nokolexbor/private/memory.h +9 -0
- data/ext/nokolexbor/private/parser.h +27 -0
- data/ext/nokolexbor/private/string.h +9 -0
- data/ext/nokolexbor/private/threads.h +50 -0
- data/ext/nokolexbor/private/tree.h +18 -0
- data/ext/nokolexbor/private/xpath.h +7 -0
- data/ext/nokolexbor/timsort.h +601 -0
- data/ext/nokolexbor/xml_SAX2.c +80 -0
- data/ext/nokolexbor/xml_buf.c +363 -0
- data/ext/nokolexbor/xml_chvalid.c +334 -0
- data/ext/nokolexbor/xml_dict.c +1264 -0
- data/ext/nokolexbor/xml_encoding.c +124 -0
- data/ext/nokolexbor/xml_error.c +134 -0
- data/ext/nokolexbor/xml_globals.c +1085 -0
- data/ext/nokolexbor/xml_hash.c +1141 -0
- data/ext/nokolexbor/xml_memory.c +203 -0
- data/ext/nokolexbor/xml_parser.c +127 -0
- data/ext/nokolexbor/xml_parserInternals.c +338 -0
- data/ext/nokolexbor/xml_pattern.c +2375 -0
- data/ext/nokolexbor/xml_string.c +1051 -0
- data/ext/nokolexbor/xml_threads.c +881 -0
- data/ext/nokolexbor/xml_tree.c +148 -0
- data/ext/nokolexbor/xml_xpath.c +14743 -0
- data/lib/nokolexbor/attribute.rb +18 -0
- data/lib/nokolexbor/document.rb +6 -0
- data/lib/nokolexbor/node.rb +264 -0
- data/lib/nokolexbor/node_set.rb +124 -0
- data/lib/nokolexbor/version.rb +5 -0
- data/lib/nokolexbor/xpath_context.rb +14 -0
- data/lib/nokolexbor.rb +17 -0
- data/patches/0001-lexbor-support-text-pseudo-element.patch +137 -0
- data/patches/0002-lexbor-match-id-class-case-sensitive.patch +22 -0
- data/patches/0003-lexbor-attach-template-content-to-self.patch +13 -0
- data/vendor/lexbor/CMakeLists.txt +331 -0
- data/vendor/lexbor/config.cmake +890 -0
- data/vendor/lexbor/feature.cmake +134 -0
- data/vendor/lexbor/source/lexbor/core/array.c +208 -0
- data/vendor/lexbor/source/lexbor/core/array.h +100 -0
- data/vendor/lexbor/source/lexbor/core/array_obj.c +216 -0
- data/vendor/lexbor/source/lexbor/core/array_obj.h +134 -0
- data/vendor/lexbor/source/lexbor/core/avl.c +442 -0
- data/vendor/lexbor/source/lexbor/core/avl.h +82 -0
- data/vendor/lexbor/source/lexbor/core/base.h +86 -0
- data/vendor/lexbor/source/lexbor/core/bst.c +468 -0
- data/vendor/lexbor/source/lexbor/core/bst.h +108 -0
- data/vendor/lexbor/source/lexbor/core/bst_map.c +238 -0
- data/vendor/lexbor/source/lexbor/core/bst_map.h +87 -0
- data/vendor/lexbor/source/lexbor/core/config.cmake +12 -0
- data/vendor/lexbor/source/lexbor/core/conv.c +203 -0
- data/vendor/lexbor/source/lexbor/core/conv.h +53 -0
- data/vendor/lexbor/source/lexbor/core/core.h +35 -0
- data/vendor/lexbor/source/lexbor/core/def.h +57 -0
- data/vendor/lexbor/source/lexbor/core/diyfp.c +153 -0
- data/vendor/lexbor/source/lexbor/core/diyfp.h +258 -0
- data/vendor/lexbor/source/lexbor/core/dobject.c +187 -0
- data/vendor/lexbor/source/lexbor/core/dobject.h +92 -0
- data/vendor/lexbor/source/lexbor/core/dtoa.c +404 -0
- data/vendor/lexbor/source/lexbor/core/dtoa.h +28 -0
- data/vendor/lexbor/source/lexbor/core/fs.h +60 -0
- data/vendor/lexbor/source/lexbor/core/hash.c +476 -0
- data/vendor/lexbor/source/lexbor/core/hash.h +218 -0
- data/vendor/lexbor/source/lexbor/core/in.c +267 -0
- data/vendor/lexbor/source/lexbor/core/in.h +172 -0
- data/vendor/lexbor/source/lexbor/core/lexbor.h +35 -0
- data/vendor/lexbor/source/lexbor/core/mem.c +228 -0
- data/vendor/lexbor/source/lexbor/core/mem.h +141 -0
- data/vendor/lexbor/source/lexbor/core/mraw.c +428 -0
- data/vendor/lexbor/source/lexbor/core/mraw.h +114 -0
- data/vendor/lexbor/source/lexbor/core/perf.h +45 -0
- data/vendor/lexbor/source/lexbor/core/plog.c +73 -0
- data/vendor/lexbor/source/lexbor/core/plog.h +102 -0
- data/vendor/lexbor/source/lexbor/core/print.c +168 -0
- data/vendor/lexbor/source/lexbor/core/print.h +39 -0
- data/vendor/lexbor/source/lexbor/core/sbst.h +59 -0
- data/vendor/lexbor/source/lexbor/core/serialize.c +27 -0
- data/vendor/lexbor/source/lexbor/core/serialize.h +32 -0
- data/vendor/lexbor/source/lexbor/core/shs.c +118 -0
- data/vendor/lexbor/source/lexbor/core/shs.h +82 -0
- data/vendor/lexbor/source/lexbor/core/str.c +617 -0
- data/vendor/lexbor/source/lexbor/core/str.h +247 -0
- data/vendor/lexbor/source/lexbor/core/str_res.h +369 -0
- data/vendor/lexbor/source/lexbor/core/strtod.c +326 -0
- data/vendor/lexbor/source/lexbor/core/strtod.h +28 -0
- data/vendor/lexbor/source/lexbor/core/types.h +39 -0
- data/vendor/lexbor/source/lexbor/core/utils.c +43 -0
- data/vendor/lexbor/source/lexbor/core/utils.h +36 -0
- data/vendor/lexbor/source/lexbor/css/base.h +44 -0
- data/vendor/lexbor/source/lexbor/css/config.cmake +2 -0
- data/vendor/lexbor/source/lexbor/css/css.h +25 -0
- data/vendor/lexbor/source/lexbor/css/log.c +336 -0
- data/vendor/lexbor/source/lexbor/css/log.h +103 -0
- data/vendor/lexbor/source/lexbor/css/node.h +29 -0
- data/vendor/lexbor/source/lexbor/css/parser.c +473 -0
- data/vendor/lexbor/source/lexbor/css/parser.h +368 -0
- data/vendor/lexbor/source/lexbor/css/selectors/base.h +48 -0
- data/vendor/lexbor/source/lexbor/css/selectors/pseudo.c +91 -0
- data/vendor/lexbor/source/lexbor/css/selectors/pseudo.h +66 -0
- data/vendor/lexbor/source/lexbor/css/selectors/pseudo_const.h +109 -0
- data/vendor/lexbor/source/lexbor/css/selectors/pseudo_res.h +302 -0
- data/vendor/lexbor/source/lexbor/css/selectors/pseudo_state.c +279 -0
- data/vendor/lexbor/source/lexbor/css/selectors/pseudo_state.h +85 -0
- data/vendor/lexbor/source/lexbor/css/selectors/selector.c +927 -0
- data/vendor/lexbor/source/lexbor/css/selectors/selector.h +200 -0
- data/vendor/lexbor/source/lexbor/css/selectors/selectors.c +340 -0
- data/vendor/lexbor/source/lexbor/css/selectors/selectors.h +137 -0
- data/vendor/lexbor/source/lexbor/css/selectors/state.c +1718 -0
- data/vendor/lexbor/source/lexbor/css/selectors/state.h +79 -0
- data/vendor/lexbor/source/lexbor/css/stylesheet.h +37 -0
- data/vendor/lexbor/source/lexbor/css/syntax/anb.c +443 -0
- data/vendor/lexbor/source/lexbor/css/syntax/anb.h +45 -0
- data/vendor/lexbor/source/lexbor/css/syntax/base.h +33 -0
- data/vendor/lexbor/source/lexbor/css/syntax/parser.c +9 -0
- data/vendor/lexbor/source/lexbor/css/syntax/parser.h +25 -0
- data/vendor/lexbor/source/lexbor/css/syntax/res.h +48 -0
- data/vendor/lexbor/source/lexbor/css/syntax/state.c +2603 -0
- data/vendor/lexbor/source/lexbor/css/syntax/state.h +140 -0
- data/vendor/lexbor/source/lexbor/css/syntax/state_res.h +273 -0
- data/vendor/lexbor/source/lexbor/css/syntax/syntax.c +67 -0
- data/vendor/lexbor/source/lexbor/css/syntax/token.c +618 -0
- data/vendor/lexbor/source/lexbor/css/syntax/token.h +298 -0
- data/vendor/lexbor/source/lexbor/css/syntax/token_res.h +68 -0
- data/vendor/lexbor/source/lexbor/css/syntax/tokenizer/error.c +30 -0
- data/vendor/lexbor/source/lexbor/css/syntax/tokenizer/error.h +58 -0
- data/vendor/lexbor/source/lexbor/css/syntax/tokenizer.c +278 -0
- data/vendor/lexbor/source/lexbor/css/syntax/tokenizer.h +121 -0
- data/vendor/lexbor/source/lexbor/dom/base.h +32 -0
- data/vendor/lexbor/source/lexbor/dom/collection.c +97 -0
- data/vendor/lexbor/source/lexbor/dom/collection.h +112 -0
- data/vendor/lexbor/source/lexbor/dom/config.cmake +3 -0
- data/vendor/lexbor/source/lexbor/dom/dom.h +29 -0
- data/vendor/lexbor/source/lexbor/dom/exception.c +18 -0
- data/vendor/lexbor/source/lexbor/dom/exception.h +73 -0
- data/vendor/lexbor/source/lexbor/dom/interface.c +110 -0
- data/vendor/lexbor/source/lexbor/dom/interface.h +88 -0
- data/vendor/lexbor/source/lexbor/dom/interfaces/attr.c +445 -0
- data/vendor/lexbor/source/lexbor/dom/interfaces/attr.h +152 -0
- data/vendor/lexbor/source/lexbor/dom/interfaces/attr_const.h +62 -0
- data/vendor/lexbor/source/lexbor/dom/interfaces/attr_res.h +143 -0
- data/vendor/lexbor/source/lexbor/dom/interfaces/cdata_section.c +55 -0
- data/vendor/lexbor/source/lexbor/dom/interfaces/cdata_section.h +38 -0
- data/vendor/lexbor/source/lexbor/dom/interfaces/character_data.c +110 -0
- data/vendor/lexbor/source/lexbor/dom/interfaces/character_data.h +51 -0
- data/vendor/lexbor/source/lexbor/dom/interfaces/comment.c +64 -0
- data/vendor/lexbor/source/lexbor/dom/interfaces/comment.h +42 -0
- data/vendor/lexbor/source/lexbor/dom/interfaces/document.c +536 -0
- data/vendor/lexbor/source/lexbor/dom/interfaces/document.h +243 -0
- data/vendor/lexbor/source/lexbor/dom/interfaces/document_fragment.c +36 -0
- data/vendor/lexbor/source/lexbor/dom/interfaces/document_fragment.h +36 -0
- data/vendor/lexbor/source/lexbor/dom/interfaces/document_type.c +125 -0
- data/vendor/lexbor/source/lexbor/dom/interfaces/document_type.h +108 -0
- data/vendor/lexbor/source/lexbor/dom/interfaces/element.c +1411 -0
- data/vendor/lexbor/source/lexbor/dom/interfaces/element.h +319 -0
- data/vendor/lexbor/source/lexbor/dom/interfaces/event_target.c +32 -0
- data/vendor/lexbor/source/lexbor/dom/interfaces/event_target.h +34 -0
- data/vendor/lexbor/source/lexbor/dom/interfaces/node.c +661 -0
- data/vendor/lexbor/source/lexbor/dom/interfaces/node.h +192 -0
- data/vendor/lexbor/source/lexbor/dom/interfaces/processing_instruction.c +87 -0
- data/vendor/lexbor/source/lexbor/dom/interfaces/processing_instruction.h +66 -0
- data/vendor/lexbor/source/lexbor/dom/interfaces/shadow_root.c +36 -0
- data/vendor/lexbor/source/lexbor/dom/interfaces/shadow_root.h +44 -0
- data/vendor/lexbor/source/lexbor/dom/interfaces/text.c +63 -0
- data/vendor/lexbor/source/lexbor/dom/interfaces/text.h +42 -0
- data/vendor/lexbor/source/lexbor/encoding/base.h +218 -0
- data/vendor/lexbor/source/lexbor/encoding/big5.c +42839 -0
- data/vendor/lexbor/source/lexbor/encoding/config.cmake +12 -0
- data/vendor/lexbor/source/lexbor/encoding/const.h +65 -0
- data/vendor/lexbor/source/lexbor/encoding/decode.c +3193 -0
- data/vendor/lexbor/source/lexbor/encoding/decode.h +370 -0
- data/vendor/lexbor/source/lexbor/encoding/encode.c +1931 -0
- data/vendor/lexbor/source/lexbor/encoding/encode.h +377 -0
- data/vendor/lexbor/source/lexbor/encoding/encoding.c +252 -0
- data/vendor/lexbor/source/lexbor/encoding/encoding.h +475 -0
- data/vendor/lexbor/source/lexbor/encoding/euc_kr.c +53883 -0
- data/vendor/lexbor/source/lexbor/encoding/gb18030.c +47905 -0
- data/vendor/lexbor/source/lexbor/encoding/iso_2022_jp_katakana.c +159 -0
- data/vendor/lexbor/source/lexbor/encoding/jis0208.c +22477 -0
- data/vendor/lexbor/source/lexbor/encoding/jis0212.c +15787 -0
- data/vendor/lexbor/source/lexbor/encoding/multi.h +53 -0
- data/vendor/lexbor/source/lexbor/encoding/range.c +71 -0
- data/vendor/lexbor/source/lexbor/encoding/range.h +34 -0
- data/vendor/lexbor/source/lexbor/encoding/res.c +222 -0
- data/vendor/lexbor/source/lexbor/encoding/res.h +34 -0
- data/vendor/lexbor/source/lexbor/encoding/single.c +13748 -0
- data/vendor/lexbor/source/lexbor/encoding/single.h +116 -0
- data/vendor/lexbor/source/lexbor/html/base.h +44 -0
- data/vendor/lexbor/source/lexbor/html/config.cmake +3 -0
- data/vendor/lexbor/source/lexbor/html/encoding.c +574 -0
- data/vendor/lexbor/source/lexbor/html/encoding.h +106 -0
- data/vendor/lexbor/source/lexbor/html/html.h +107 -0
- data/vendor/lexbor/source/lexbor/html/interface.c +165 -0
- data/vendor/lexbor/source/lexbor/html/interface.h +186 -0
- data/vendor/lexbor/source/lexbor/html/interface_res.h +4449 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/anchor_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/anchor_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/area_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/area_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/audio_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/audio_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/base_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/base_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/body_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/body_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/br_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/br_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/button_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/button_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/canvas_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/canvas_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/d_list_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/d_list_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/data_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/data_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/data_list_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/data_list_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/details_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/details_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/dialog_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/dialog_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/directory_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/directory_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/div_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/div_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/document.c +444 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/document.h +256 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/element.c +64 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/element.h +54 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/embed_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/embed_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/field_set_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/field_set_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/font_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/font_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/form_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/form_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/frame_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/frame_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/frame_set_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/frame_set_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/head_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/head_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/heading_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/heading_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/hr_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/hr_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/html_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/html_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/iframe_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/iframe_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/image_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/image_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/input_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/input_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/label_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/label_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/legend_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/legend_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/li_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/li_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/link_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/link_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/map_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/map_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/marquee_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/marquee_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/media_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/media_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/menu_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/menu_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/meta_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/meta_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/meter_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/meter_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/mod_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/mod_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/o_list_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/o_list_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/object_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/object_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/opt_group_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/opt_group_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/option_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/option_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/output_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/output_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/paragraph_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/paragraph_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/param_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/param_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/picture_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/picture_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/pre_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/pre_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/progress_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/progress_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/quote_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/quote_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/script_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/script_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/select_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/select_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/slot_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/slot_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/source_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/source_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/span_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/span_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/style_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/style_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/table_caption_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/table_caption_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/table_cell_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/table_cell_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/table_col_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/table_col_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/table_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/table_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/table_row_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/table_row_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/table_section_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/table_section_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/template_element.c +46 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/template_element.h +38 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/text_area_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/text_area_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/time_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/time_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/title_element.c +133 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/title_element.h +42 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/track_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/track_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/u_list_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/u_list_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/unknown_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/unknown_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/video_element.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/video_element.h +34 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/window.c +36 -0
- data/vendor/lexbor/source/lexbor/html/interfaces/window.h +34 -0
- data/vendor/lexbor/source/lexbor/html/node.c +14 -0
- data/vendor/lexbor/source/lexbor/html/node.h +67 -0
- data/vendor/lexbor/source/lexbor/html/parser.c +469 -0
- data/vendor/lexbor/source/lexbor/html/parser.h +170 -0
- data/vendor/lexbor/source/lexbor/html/serialize.c +1510 -0
- data/vendor/lexbor/source/lexbor/html/serialize.h +93 -0
- data/vendor/lexbor/source/lexbor/html/tag.h +103 -0
- data/vendor/lexbor/source/lexbor/html/tag_res.h +2262 -0
- data/vendor/lexbor/source/lexbor/html/token.c +386 -0
- data/vendor/lexbor/source/lexbor/html/token.h +130 -0
- data/vendor/lexbor/source/lexbor/html/token_attr.c +44 -0
- data/vendor/lexbor/source/lexbor/html/token_attr.h +67 -0
- data/vendor/lexbor/source/lexbor/html/tokenizer/error.c +28 -0
- data/vendor/lexbor/source/lexbor/html/tokenizer/error.h +141 -0
- data/vendor/lexbor/source/lexbor/html/tokenizer/res.h +4956 -0
- data/vendor/lexbor/source/lexbor/html/tokenizer/state.c +2171 -0
- data/vendor/lexbor/source/lexbor/html/tokenizer/state.h +225 -0
- data/vendor/lexbor/source/lexbor/html/tokenizer/state_comment.c +489 -0
- data/vendor/lexbor/source/lexbor/html/tokenizer/state_comment.h +27 -0
- data/vendor/lexbor/source/lexbor/html/tokenizer/state_doctype.c +1654 -0
- data/vendor/lexbor/source/lexbor/html/tokenizer/state_doctype.h +27 -0
- data/vendor/lexbor/source/lexbor/html/tokenizer/state_rawtext.c +303 -0
- data/vendor/lexbor/source/lexbor/html/tokenizer/state_rawtext.h +32 -0
- data/vendor/lexbor/source/lexbor/html/tokenizer/state_rcdata.c +311 -0
- data/vendor/lexbor/source/lexbor/html/tokenizer/state_rcdata.h +32 -0
- data/vendor/lexbor/source/lexbor/html/tokenizer/state_script.c +1209 -0
- data/vendor/lexbor/source/lexbor/html/tokenizer/state_script.h +32 -0
- data/vendor/lexbor/source/lexbor/html/tokenizer.c +499 -0
- data/vendor/lexbor/source/lexbor/html/tokenizer.h +343 -0
- data/vendor/lexbor/source/lexbor/html/tree/active_formatting.c +241 -0
- data/vendor/lexbor/source/lexbor/html/tree/active_formatting.h +117 -0
- data/vendor/lexbor/source/lexbor/html/tree/error.c +26 -0
- data/vendor/lexbor/source/lexbor/html/tree/error.h +114 -0
- data/vendor/lexbor/source/lexbor/html/tree/insertion_mode/after_after_body.c +62 -0
- data/vendor/lexbor/source/lexbor/html/tree/insertion_mode/after_after_frameset.c +63 -0
- data/vendor/lexbor/source/lexbor/html/tree/insertion_mode/after_body.c +82 -0
- data/vendor/lexbor/source/lexbor/html/tree/insertion_mode/after_frameset.c +88 -0
- data/vendor/lexbor/source/lexbor/html/tree/insertion_mode/after_head.c +222 -0
- data/vendor/lexbor/source/lexbor/html/tree/insertion_mode/before_head.c +144 -0
- data/vendor/lexbor/source/lexbor/html/tree/insertion_mode/before_html.c +166 -0
- data/vendor/lexbor/source/lexbor/html/tree/insertion_mode/foreign_content.c +358 -0
- data/vendor/lexbor/source/lexbor/html/tree/insertion_mode/in_body.c +1974 -0
- data/vendor/lexbor/source/lexbor/html/tree/insertion_mode/in_caption.c +158 -0
- data/vendor/lexbor/source/lexbor/html/tree/insertion_mode/in_cell.c +187 -0
- data/vendor/lexbor/source/lexbor/html/tree/insertion_mode/in_column_group.c +194 -0
- data/vendor/lexbor/source/lexbor/html/tree/insertion_mode/in_frameset.c +149 -0
- data/vendor/lexbor/source/lexbor/html/tree/insertion_mode/in_head.c +374 -0
- data/vendor/lexbor/source/lexbor/html/tree/insertion_mode/in_head_noscript.c +121 -0
- data/vendor/lexbor/source/lexbor/html/tree/insertion_mode/in_row.c +211 -0
- data/vendor/lexbor/source/lexbor/html/tree/insertion_mode/in_select.c +341 -0
- data/vendor/lexbor/source/lexbor/html/tree/insertion_mode/in_select_in_table.c +115 -0
- data/vendor/lexbor/source/lexbor/html/tree/insertion_mode/in_table.c +451 -0
- data/vendor/lexbor/source/lexbor/html/tree/insertion_mode/in_table_body.c +208 -0
- data/vendor/lexbor/source/lexbor/html/tree/insertion_mode/in_table_text.c +127 -0
- data/vendor/lexbor/source/lexbor/html/tree/insertion_mode/in_template.c +189 -0
- data/vendor/lexbor/source/lexbor/html/tree/insertion_mode/initial.c +411 -0
- data/vendor/lexbor/source/lexbor/html/tree/insertion_mode/text.c +61 -0
- data/vendor/lexbor/source/lexbor/html/tree/insertion_mode.h +135 -0
- data/vendor/lexbor/source/lexbor/html/tree/open_elements.c +251 -0
- data/vendor/lexbor/source/lexbor/html/tree/open_elements.h +105 -0
- data/vendor/lexbor/source/lexbor/html/tree/template_insertion.c +10 -0
- data/vendor/lexbor/source/lexbor/html/tree/template_insertion.h +100 -0
- data/vendor/lexbor/source/lexbor/html/tree.c +1726 -0
- data/vendor/lexbor/source/lexbor/html/tree.h +431 -0
- data/vendor/lexbor/source/lexbor/html/tree_res.h +111 -0
- data/vendor/lexbor/source/lexbor/ns/base.h +32 -0
- data/vendor/lexbor/source/lexbor/ns/config.cmake +2 -0
- data/vendor/lexbor/source/lexbor/ns/const.h +37 -0
- data/vendor/lexbor/source/lexbor/ns/ns.c +154 -0
- data/vendor/lexbor/source/lexbor/ns/ns.h +66 -0
- data/vendor/lexbor/source/lexbor/ns/res.h +97 -0
- data/vendor/lexbor/source/lexbor/ports/posix/config.cmake +11 -0
- data/vendor/lexbor/source/lexbor/ports/posix/lexbor/core/fs.c +236 -0
- data/vendor/lexbor/source/lexbor/ports/posix/lexbor/core/memory.c +33 -0
- data/vendor/lexbor/source/lexbor/ports/posix/lexbor/core/perf.c +158 -0
- data/vendor/lexbor/source/lexbor/ports/windows_nt/config.cmake +18 -0
- data/vendor/lexbor/source/lexbor/ports/windows_nt/lexbor/core/fs.c +239 -0
- data/vendor/lexbor/source/lexbor/ports/windows_nt/lexbor/core/memory.c +33 -0
- data/vendor/lexbor/source/lexbor/ports/windows_nt/lexbor/core/perf.c +81 -0
- data/vendor/lexbor/source/lexbor/selectors/base.h +30 -0
- data/vendor/lexbor/source/lexbor/selectors/config.cmake +2 -0
- data/vendor/lexbor/source/lexbor/selectors/selectors.c +1591 -0
- data/vendor/lexbor/source/lexbor/selectors/selectors.h +71 -0
- data/vendor/lexbor/source/lexbor/tag/base.h +32 -0
- data/vendor/lexbor/source/lexbor/tag/config.cmake +2 -0
- data/vendor/lexbor/source/lexbor/tag/const.h +225 -0
- data/vendor/lexbor/source/lexbor/tag/res.h +562 -0
- data/vendor/lexbor/source/lexbor/tag/tag.c +144 -0
- data/vendor/lexbor/source/lexbor/tag/tag.h +123 -0
- data/vendor/lexbor/source/lexbor/utils/base.h +32 -0
- data/vendor/lexbor/source/lexbor/utils/config.cmake +2 -0
- data/vendor/lexbor/source/lexbor/utils/http.c +534 -0
- data/vendor/lexbor/source/lexbor/utils/http.h +90 -0
- data/vendor/lexbor/source/lexbor/utils/utils.h +15 -0
- data/vendor/lexbor/source/lexbor/utils/warc.c +817 -0
- data/vendor/lexbor/source/lexbor/utils/warc.h +126 -0
- data/vendor/lexbor/utils/lexbor/css/selectors/pseudo.py +231 -0
- data/vendor/lexbor/utils/lexbor/css/selectors/tmp/const.h +21 -0
- data/vendor/lexbor/utils/lexbor/css/selectors/tmp/res.h +26 -0
- data/vendor/lexbor/utils/lexbor/css/syntax/definitions.py +49 -0
- data/vendor/lexbor/utils/lexbor/css/syntax/token_res.py +54 -0
- data/vendor/lexbor/utils/lexbor/css/syntax/tokenizer_code_map.py +36 -0
- data/vendor/lexbor/version +1 -0
- metadata +542 -0
@@ -0,0 +1,881 @@
|
|
1
|
+
/**
|
2
|
+
* threads.c: set of generic threading related routines
|
3
|
+
*
|
4
|
+
* See Copyright for the status of this software.
|
5
|
+
*
|
6
|
+
* Gary Pennington <Gary.Pennington@uk.sun.com>
|
7
|
+
* daniel@veillard.com
|
8
|
+
*/
|
9
|
+
|
10
|
+
#define IN_LIBXML
|
11
|
+
#include "libxml.h"
|
12
|
+
|
13
|
+
#include <string.h>
|
14
|
+
#include <stdlib.h>
|
15
|
+
|
16
|
+
#include "libxml/threads.h"
|
17
|
+
#include "libxml/globals.h"
|
18
|
+
|
19
|
+
#if defined(SOLARIS)
|
20
|
+
#include <note.h>
|
21
|
+
#endif
|
22
|
+
|
23
|
+
#include "private/dict.h"
|
24
|
+
#include "private/threads.h"
|
25
|
+
|
26
|
+
/* #define DEBUG_THREADS */
|
27
|
+
|
28
|
+
#if defined(HAVE_POSIX_THREADS) && \
|
29
|
+
defined(__GLIBC__) && \
|
30
|
+
__GLIBC__ * 100 + __GLIBC_MINOR__ >= 234
|
31
|
+
|
32
|
+
/*
|
33
|
+
* The modern way available since glibc 2.32.
|
34
|
+
*
|
35
|
+
* The check above is for glibc 2.34 which merged the pthread symbols into
|
36
|
+
* libc. Since we still allow linking without pthread symbols (see below),
|
37
|
+
* this only works if pthread symbols are guaranteed to be available.
|
38
|
+
*/
|
39
|
+
|
40
|
+
#include <sys/single_threaded.h>
|
41
|
+
|
42
|
+
#define XML_IS_THREADED() (!__libc_single_threaded)
|
43
|
+
|
44
|
+
#elif defined(HAVE_POSIX_THREADS) && \
|
45
|
+
defined(__GLIBC__) && \
|
46
|
+
defined(__GNUC__)
|
47
|
+
|
48
|
+
/*
|
49
|
+
* The traditional way to check for single-threaded applications with
|
50
|
+
* glibc was to check whether the separate libpthread library is
|
51
|
+
* linked in. This works by not linking libxml2 with libpthread (see
|
52
|
+
* BASE_THREAD_LIBS in configure.ac and Makefile.am) and declaring
|
53
|
+
* pthread functions as weak symbols.
|
54
|
+
*
|
55
|
+
* In glibc 2.34, the pthread symbols were moved from libpthread to libc,
|
56
|
+
* so this doesn't work anymore.
|
57
|
+
*
|
58
|
+
* At some point, this legacy code and the BASE_THREAD_LIBS hack in
|
59
|
+
* configure.ac can probably be removed.
|
60
|
+
*/
|
61
|
+
|
62
|
+
#pragma weak pthread_getspecific
|
63
|
+
#pragma weak pthread_setspecific
|
64
|
+
#pragma weak pthread_key_create
|
65
|
+
#pragma weak pthread_key_delete
|
66
|
+
#pragma weak pthread_mutex_init
|
67
|
+
#pragma weak pthread_mutex_destroy
|
68
|
+
#pragma weak pthread_mutex_lock
|
69
|
+
#pragma weak pthread_mutex_unlock
|
70
|
+
#pragma weak pthread_cond_init
|
71
|
+
#pragma weak pthread_cond_destroy
|
72
|
+
#pragma weak pthread_cond_wait
|
73
|
+
#pragma weak pthread_equal
|
74
|
+
#pragma weak pthread_self
|
75
|
+
#pragma weak pthread_key_create
|
76
|
+
#pragma weak pthread_key_delete
|
77
|
+
#pragma weak pthread_cond_signal
|
78
|
+
|
79
|
+
#define XML_PTHREAD_WEAK
|
80
|
+
#define XML_IS_THREADED() libxml_is_threaded
|
81
|
+
|
82
|
+
static int libxml_is_threaded = -1;
|
83
|
+
|
84
|
+
#else /* other POSIX platforms */
|
85
|
+
|
86
|
+
#define XML_IS_THREADED() 1
|
87
|
+
|
88
|
+
#endif
|
89
|
+
|
90
|
+
/*
|
91
|
+
* TODO: this module still uses malloc/free and not xmlMalloc/xmlFree
|
92
|
+
* to avoid some craziness since xmlMalloc/xmlFree may actually
|
93
|
+
* be hosted on allocated blocks needing them for the allocation ...
|
94
|
+
*/
|
95
|
+
|
96
|
+
/*
|
97
|
+
* xmlRMutex are reentrant mutual exception locks
|
98
|
+
*/
|
99
|
+
struct _xmlRMutex {
|
100
|
+
#ifdef HAVE_POSIX_THREADS
|
101
|
+
pthread_mutex_t lock;
|
102
|
+
unsigned int held;
|
103
|
+
unsigned int waiters;
|
104
|
+
pthread_t tid;
|
105
|
+
pthread_cond_t cv;
|
106
|
+
#elif defined HAVE_WIN32_THREADS
|
107
|
+
CRITICAL_SECTION cs;
|
108
|
+
#else
|
109
|
+
int empty;
|
110
|
+
#endif
|
111
|
+
};
|
112
|
+
|
113
|
+
/*
|
114
|
+
* This module still has some internal static data.
|
115
|
+
* - xmlLibraryLock a global lock
|
116
|
+
* - globalkey used for per-thread data
|
117
|
+
*/
|
118
|
+
|
119
|
+
#ifdef HAVE_POSIX_THREADS
|
120
|
+
static pthread_key_t globalkey;
|
121
|
+
static pthread_t mainthread;
|
122
|
+
static pthread_mutex_t global_init_lock = PTHREAD_MUTEX_INITIALIZER;
|
123
|
+
#elif defined HAVE_WIN32_THREADS
|
124
|
+
#if defined(HAVE_COMPILER_TLS)
|
125
|
+
static __declspec(thread) xmlGlobalState tlstate;
|
126
|
+
static __declspec(thread) int tlstate_inited = 0;
|
127
|
+
#else /* HAVE_COMPILER_TLS */
|
128
|
+
static DWORD globalkey = TLS_OUT_OF_INDEXES;
|
129
|
+
#endif /* HAVE_COMPILER_TLS */
|
130
|
+
static DWORD mainthread;
|
131
|
+
static volatile LPCRITICAL_SECTION global_init_lock = NULL;
|
132
|
+
#endif
|
133
|
+
|
134
|
+
static xmlRMutexPtr xmlLibraryLock = NULL;
|
135
|
+
|
136
|
+
/**
|
137
|
+
* xmlInitMutex:
|
138
|
+
* @mutex: the mutex
|
139
|
+
*
|
140
|
+
* Initialize a mutex.
|
141
|
+
*/
|
142
|
+
void
|
143
|
+
xmlInitMutex(xmlMutexPtr mutex)
|
144
|
+
{
|
145
|
+
#ifdef HAVE_POSIX_THREADS
|
146
|
+
pthread_mutex_init(&mutex->lock, NULL);
|
147
|
+
#elif defined HAVE_WIN32_THREADS
|
148
|
+
InitializeCriticalSection(&mutex->cs);
|
149
|
+
#else
|
150
|
+
(void) mutex;
|
151
|
+
#endif
|
152
|
+
}
|
153
|
+
|
154
|
+
/**
|
155
|
+
* xmlNewMutex:
|
156
|
+
*
|
157
|
+
* xmlNewMutex() is used to allocate a libxml2 token struct for use in
|
158
|
+
* synchronizing access to data.
|
159
|
+
*
|
160
|
+
* Returns a new simple mutex pointer or NULL in case of error
|
161
|
+
*/
|
162
|
+
xmlMutexPtr
|
163
|
+
xmlNewMutex(void)
|
164
|
+
{
|
165
|
+
xmlMutexPtr tok;
|
166
|
+
|
167
|
+
if ((tok = malloc(sizeof(xmlMutex))) == NULL)
|
168
|
+
return (NULL);
|
169
|
+
xmlInitMutex(tok);
|
170
|
+
return (tok);
|
171
|
+
}
|
172
|
+
|
173
|
+
/**
|
174
|
+
* xmlCleanupMutex:
|
175
|
+
* @mutex: the simple mutex
|
176
|
+
*
|
177
|
+
* Reclaim resources associated with a mutex.
|
178
|
+
*/
|
179
|
+
void
|
180
|
+
xmlCleanupMutex(xmlMutexPtr mutex)
|
181
|
+
{
|
182
|
+
#ifdef HAVE_POSIX_THREADS
|
183
|
+
pthread_mutex_destroy(&mutex->lock);
|
184
|
+
#elif defined HAVE_WIN32_THREADS
|
185
|
+
DeleteCriticalSection(&mutex->cs);
|
186
|
+
#else
|
187
|
+
(void) mutex;
|
188
|
+
#endif
|
189
|
+
}
|
190
|
+
|
191
|
+
/**
|
192
|
+
* xmlFreeMutex:
|
193
|
+
* @tok: the simple mutex
|
194
|
+
*
|
195
|
+
* Free a mutex.
|
196
|
+
*/
|
197
|
+
void
|
198
|
+
xmlFreeMutex(xmlMutexPtr tok)
|
199
|
+
{
|
200
|
+
if (tok == NULL)
|
201
|
+
return;
|
202
|
+
|
203
|
+
xmlCleanupMutex(tok);
|
204
|
+
free(tok);
|
205
|
+
}
|
206
|
+
|
207
|
+
/**
|
208
|
+
* xmlMutexLock:
|
209
|
+
* @tok: the simple mutex
|
210
|
+
*
|
211
|
+
* xmlMutexLock() is used to lock a libxml2 token.
|
212
|
+
*/
|
213
|
+
void
|
214
|
+
xmlMutexLock(xmlMutexPtr tok)
|
215
|
+
{
|
216
|
+
if (tok == NULL)
|
217
|
+
return;
|
218
|
+
#ifdef HAVE_POSIX_THREADS
|
219
|
+
/*
|
220
|
+
* This assumes that __libc_single_threaded won't change while the
|
221
|
+
* lock is held.
|
222
|
+
*/
|
223
|
+
if (XML_IS_THREADED() != 0)
|
224
|
+
pthread_mutex_lock(&tok->lock);
|
225
|
+
#elif defined HAVE_WIN32_THREADS
|
226
|
+
EnterCriticalSection(&tok->cs);
|
227
|
+
#endif
|
228
|
+
|
229
|
+
}
|
230
|
+
|
231
|
+
/**
|
232
|
+
* xmlMutexUnlock:
|
233
|
+
* @tok: the simple mutex
|
234
|
+
*
|
235
|
+
* xmlMutexUnlock() is used to unlock a libxml2 token.
|
236
|
+
*/
|
237
|
+
void
|
238
|
+
xmlMutexUnlock(xmlMutexPtr tok)
|
239
|
+
{
|
240
|
+
if (tok == NULL)
|
241
|
+
return;
|
242
|
+
#ifdef HAVE_POSIX_THREADS
|
243
|
+
if (XML_IS_THREADED() != 0)
|
244
|
+
pthread_mutex_unlock(&tok->lock);
|
245
|
+
#elif defined HAVE_WIN32_THREADS
|
246
|
+
LeaveCriticalSection(&tok->cs);
|
247
|
+
#endif
|
248
|
+
}
|
249
|
+
|
250
|
+
/**
|
251
|
+
* xmlNewRMutex:
|
252
|
+
*
|
253
|
+
* xmlRNewMutex() is used to allocate a reentrant mutex for use in
|
254
|
+
* synchronizing access to data. token_r is a re-entrant lock and thus useful
|
255
|
+
* for synchronizing access to data structures that may be manipulated in a
|
256
|
+
* recursive fashion.
|
257
|
+
*
|
258
|
+
* Returns the new reentrant mutex pointer or NULL in case of error
|
259
|
+
*/
|
260
|
+
xmlRMutexPtr
|
261
|
+
xmlNewRMutex(void)
|
262
|
+
{
|
263
|
+
xmlRMutexPtr tok;
|
264
|
+
|
265
|
+
if ((tok = malloc(sizeof(xmlRMutex))) == NULL)
|
266
|
+
return (NULL);
|
267
|
+
#ifdef HAVE_POSIX_THREADS
|
268
|
+
pthread_mutex_init(&tok->lock, NULL);
|
269
|
+
tok->held = 0;
|
270
|
+
tok->waiters = 0;
|
271
|
+
pthread_cond_init(&tok->cv, NULL);
|
272
|
+
#elif defined HAVE_WIN32_THREADS
|
273
|
+
InitializeCriticalSection(&tok->cs);
|
274
|
+
#endif
|
275
|
+
return (tok);
|
276
|
+
}
|
277
|
+
|
278
|
+
/**
|
279
|
+
* xmlFreeRMutex:
|
280
|
+
* @tok: the reentrant mutex
|
281
|
+
*
|
282
|
+
* xmlRFreeMutex() is used to reclaim resources associated with a
|
283
|
+
* reentrant mutex.
|
284
|
+
*/
|
285
|
+
void
|
286
|
+
xmlFreeRMutex(xmlRMutexPtr tok ATTRIBUTE_UNUSED)
|
287
|
+
{
|
288
|
+
if (tok == NULL)
|
289
|
+
return;
|
290
|
+
#ifdef HAVE_POSIX_THREADS
|
291
|
+
pthread_mutex_destroy(&tok->lock);
|
292
|
+
pthread_cond_destroy(&tok->cv);
|
293
|
+
#elif defined HAVE_WIN32_THREADS
|
294
|
+
DeleteCriticalSection(&tok->cs);
|
295
|
+
#endif
|
296
|
+
free(tok);
|
297
|
+
}
|
298
|
+
|
299
|
+
/**
|
300
|
+
* xmlRMutexLock:
|
301
|
+
* @tok: the reentrant mutex
|
302
|
+
*
|
303
|
+
* xmlRMutexLock() is used to lock a libxml2 token_r.
|
304
|
+
*/
|
305
|
+
void
|
306
|
+
xmlRMutexLock(xmlRMutexPtr tok)
|
307
|
+
{
|
308
|
+
if (tok == NULL)
|
309
|
+
return;
|
310
|
+
#ifdef HAVE_POSIX_THREADS
|
311
|
+
if (XML_IS_THREADED() == 0)
|
312
|
+
return;
|
313
|
+
|
314
|
+
pthread_mutex_lock(&tok->lock);
|
315
|
+
if (tok->held) {
|
316
|
+
if (pthread_equal(tok->tid, pthread_self())) {
|
317
|
+
tok->held++;
|
318
|
+
pthread_mutex_unlock(&tok->lock);
|
319
|
+
return;
|
320
|
+
} else {
|
321
|
+
tok->waiters++;
|
322
|
+
while (tok->held)
|
323
|
+
pthread_cond_wait(&tok->cv, &tok->lock);
|
324
|
+
tok->waiters--;
|
325
|
+
}
|
326
|
+
}
|
327
|
+
tok->tid = pthread_self();
|
328
|
+
tok->held = 1;
|
329
|
+
pthread_mutex_unlock(&tok->lock);
|
330
|
+
#elif defined HAVE_WIN32_THREADS
|
331
|
+
EnterCriticalSection(&tok->cs);
|
332
|
+
#endif
|
333
|
+
}
|
334
|
+
|
335
|
+
/**
|
336
|
+
* xmlRMutexUnlock:
|
337
|
+
* @tok: the reentrant mutex
|
338
|
+
*
|
339
|
+
* xmlRMutexUnlock() is used to unlock a libxml2 token_r.
|
340
|
+
*/
|
341
|
+
void
|
342
|
+
xmlRMutexUnlock(xmlRMutexPtr tok ATTRIBUTE_UNUSED)
|
343
|
+
{
|
344
|
+
if (tok == NULL)
|
345
|
+
return;
|
346
|
+
#ifdef HAVE_POSIX_THREADS
|
347
|
+
if (XML_IS_THREADED() == 0)
|
348
|
+
return;
|
349
|
+
|
350
|
+
pthread_mutex_lock(&tok->lock);
|
351
|
+
tok->held--;
|
352
|
+
if (tok->held == 0) {
|
353
|
+
if (tok->waiters)
|
354
|
+
pthread_cond_signal(&tok->cv);
|
355
|
+
memset(&tok->tid, 0, sizeof(tok->tid));
|
356
|
+
}
|
357
|
+
pthread_mutex_unlock(&tok->lock);
|
358
|
+
#elif defined HAVE_WIN32_THREADS
|
359
|
+
LeaveCriticalSection(&tok->cs);
|
360
|
+
#endif
|
361
|
+
}
|
362
|
+
|
363
|
+
/**
|
364
|
+
* xmlGlobalInitMutexLock
|
365
|
+
*
|
366
|
+
* Makes sure that the global initialization mutex is initialized and
|
367
|
+
* locks it.
|
368
|
+
*/
|
369
|
+
void
|
370
|
+
__xmlGlobalInitMutexLock(void)
|
371
|
+
{
|
372
|
+
/* Make sure the global init lock is initialized and then lock it. */
|
373
|
+
#ifdef HAVE_POSIX_THREADS
|
374
|
+
#ifdef XML_PTHREAD_WEAK
|
375
|
+
if (pthread_mutex_lock == NULL)
|
376
|
+
return;
|
377
|
+
#else
|
378
|
+
if (XML_IS_THREADED() == 0)
|
379
|
+
return;
|
380
|
+
#endif
|
381
|
+
/* The mutex is statically initialized, so we just lock it. */
|
382
|
+
pthread_mutex_lock(&global_init_lock);
|
383
|
+
#elif defined HAVE_WIN32_THREADS
|
384
|
+
LPCRITICAL_SECTION cs;
|
385
|
+
|
386
|
+
/* Create a new critical section */
|
387
|
+
if (global_init_lock == NULL) {
|
388
|
+
cs = malloc(sizeof(CRITICAL_SECTION));
|
389
|
+
if (cs == NULL) {
|
390
|
+
xmlGenericError(xmlGenericErrorContext,
|
391
|
+
"xmlGlobalInitMutexLock: out of memory\n");
|
392
|
+
return;
|
393
|
+
}
|
394
|
+
InitializeCriticalSection(cs);
|
395
|
+
|
396
|
+
/* Swap it into the global_init_lock */
|
397
|
+
#ifdef InterlockedCompareExchangePointer
|
398
|
+
InterlockedCompareExchangePointer((void **) &global_init_lock,
|
399
|
+
cs, NULL);
|
400
|
+
#else /* Use older void* version */
|
401
|
+
InterlockedCompareExchange((void **) &global_init_lock,
|
402
|
+
(void *) cs, NULL);
|
403
|
+
#endif /* InterlockedCompareExchangePointer */
|
404
|
+
|
405
|
+
/* If another thread successfully recorded its critical
|
406
|
+
* section in the global_init_lock then discard the one
|
407
|
+
* allocated by this thread. */
|
408
|
+
if (global_init_lock != cs) {
|
409
|
+
DeleteCriticalSection(cs);
|
410
|
+
free(cs);
|
411
|
+
}
|
412
|
+
}
|
413
|
+
|
414
|
+
/* Lock the chosen critical section */
|
415
|
+
EnterCriticalSection(global_init_lock);
|
416
|
+
#endif
|
417
|
+
}
|
418
|
+
|
419
|
+
void
|
420
|
+
__xmlGlobalInitMutexUnlock(void)
|
421
|
+
{
|
422
|
+
#ifdef HAVE_POSIX_THREADS
|
423
|
+
#ifdef XML_PTHREAD_WEAK
|
424
|
+
if (pthread_mutex_lock == NULL)
|
425
|
+
return;
|
426
|
+
#else
|
427
|
+
if (XML_IS_THREADED() == 0)
|
428
|
+
return;
|
429
|
+
#endif
|
430
|
+
pthread_mutex_unlock(&global_init_lock);
|
431
|
+
#elif defined HAVE_WIN32_THREADS
|
432
|
+
if (global_init_lock != NULL) {
|
433
|
+
LeaveCriticalSection(global_init_lock);
|
434
|
+
}
|
435
|
+
#endif
|
436
|
+
}
|
437
|
+
|
438
|
+
/**
|
439
|
+
* xmlGlobalInitMutexDestroy
|
440
|
+
*
|
441
|
+
* Makes sure that the global initialization mutex is destroyed before
|
442
|
+
* application termination.
|
443
|
+
*/
|
444
|
+
void
|
445
|
+
__xmlGlobalInitMutexDestroy(void)
|
446
|
+
{
|
447
|
+
#ifdef HAVE_POSIX_THREADS
|
448
|
+
#elif defined HAVE_WIN32_THREADS
|
449
|
+
if (global_init_lock != NULL) {
|
450
|
+
DeleteCriticalSection(global_init_lock);
|
451
|
+
free(global_init_lock);
|
452
|
+
global_init_lock = NULL;
|
453
|
+
}
|
454
|
+
#endif
|
455
|
+
}
|
456
|
+
|
457
|
+
/************************************************************************
|
458
|
+
* *
|
459
|
+
* Per thread global state handling *
|
460
|
+
* *
|
461
|
+
************************************************************************/
|
462
|
+
|
463
|
+
#ifdef LIBXML_THREAD_ENABLED
|
464
|
+
#ifdef xmlLastError
|
465
|
+
#undef xmlLastError
|
466
|
+
#endif
|
467
|
+
|
468
|
+
/**
|
469
|
+
* xmlFreeGlobalState:
|
470
|
+
* @state: a thread global state
|
471
|
+
*
|
472
|
+
* xmlFreeGlobalState() is called when a thread terminates with a non-NULL
|
473
|
+
* global state. It is is used here to reclaim memory resources.
|
474
|
+
*/
|
475
|
+
static void
|
476
|
+
xmlFreeGlobalState(void *state)
|
477
|
+
{
|
478
|
+
xmlGlobalState *gs = (xmlGlobalState *) state;
|
479
|
+
|
480
|
+
/* free any memory allocated in the thread's xmlLastError */
|
481
|
+
xmlResetError(&(gs->xmlLastError));
|
482
|
+
free(state);
|
483
|
+
}
|
484
|
+
|
485
|
+
/**
|
486
|
+
* xmlNewGlobalState:
|
487
|
+
*
|
488
|
+
* xmlNewGlobalState() allocates a global state. This structure is used to
|
489
|
+
* hold all data for use by a thread when supporting backwards compatibility
|
490
|
+
* of libxml2 to pre-thread-safe behaviour.
|
491
|
+
*
|
492
|
+
* Returns the newly allocated xmlGlobalStatePtr or NULL in case of error
|
493
|
+
*/
|
494
|
+
static xmlGlobalStatePtr
|
495
|
+
xmlNewGlobalState(void)
|
496
|
+
{
|
497
|
+
xmlGlobalState *gs;
|
498
|
+
|
499
|
+
gs = malloc(sizeof(xmlGlobalState));
|
500
|
+
if (gs == NULL) {
|
501
|
+
xmlGenericError(xmlGenericErrorContext,
|
502
|
+
"xmlGetGlobalState: out of memory\n");
|
503
|
+
return (NULL);
|
504
|
+
}
|
505
|
+
|
506
|
+
memset(gs, 0, sizeof(xmlGlobalState));
|
507
|
+
xmlInitializeGlobalState(gs);
|
508
|
+
return (gs);
|
509
|
+
}
|
510
|
+
#endif /* LIBXML_THREAD_ENABLED */
|
511
|
+
|
512
|
+
#ifdef HAVE_POSIX_THREADS
|
513
|
+
#elif defined HAVE_WIN32_THREADS
|
514
|
+
#if !defined(HAVE_COMPILER_TLS)
|
515
|
+
#if defined(LIBXML_STATIC) && !defined(LIBXML_STATIC_FOR_DLL)
|
516
|
+
typedef struct _xmlGlobalStateCleanupHelperParams {
|
517
|
+
HANDLE thread;
|
518
|
+
void *memory;
|
519
|
+
} xmlGlobalStateCleanupHelperParams;
|
520
|
+
|
521
|
+
static void XMLCDECL
|
522
|
+
xmlGlobalStateCleanupHelper(void *p)
|
523
|
+
{
|
524
|
+
xmlGlobalStateCleanupHelperParams *params =
|
525
|
+
(xmlGlobalStateCleanupHelperParams *) p;
|
526
|
+
WaitForSingleObject(params->thread, INFINITE);
|
527
|
+
CloseHandle(params->thread);
|
528
|
+
xmlFreeGlobalState(params->memory);
|
529
|
+
free(params);
|
530
|
+
_endthread();
|
531
|
+
}
|
532
|
+
#else /* LIBXML_STATIC && !LIBXML_STATIC_FOR_DLL */
|
533
|
+
|
534
|
+
typedef struct _xmlGlobalStateCleanupHelperParams {
|
535
|
+
void *memory;
|
536
|
+
struct _xmlGlobalStateCleanupHelperParams *prev;
|
537
|
+
struct _xmlGlobalStateCleanupHelperParams *next;
|
538
|
+
} xmlGlobalStateCleanupHelperParams;
|
539
|
+
|
540
|
+
static xmlGlobalStateCleanupHelperParams *cleanup_helpers_head = NULL;
|
541
|
+
static CRITICAL_SECTION cleanup_helpers_cs;
|
542
|
+
|
543
|
+
#endif /* LIBXMLSTATIC && !LIBXML_STATIC_FOR_DLL */
|
544
|
+
#endif /* HAVE_COMPILER_TLS */
|
545
|
+
#endif /* HAVE_WIN32_THREADS */
|
546
|
+
|
547
|
+
/**
|
548
|
+
* xmlGetGlobalState:
|
549
|
+
*
|
550
|
+
* DEPRECATED: Internal function, do not use.
|
551
|
+
*
|
552
|
+
* xmlGetGlobalState() is called to retrieve the global state for a thread.
|
553
|
+
*
|
554
|
+
* Returns the thread global state or NULL in case of error
|
555
|
+
*/
|
556
|
+
xmlGlobalStatePtr
|
557
|
+
xmlGetGlobalState(void)
|
558
|
+
{
|
559
|
+
#ifdef HAVE_POSIX_THREADS
|
560
|
+
xmlGlobalState *globalval;
|
561
|
+
|
562
|
+
if (XML_IS_THREADED() == 0)
|
563
|
+
return (NULL);
|
564
|
+
|
565
|
+
if ((globalval = (xmlGlobalState *)
|
566
|
+
pthread_getspecific(globalkey)) == NULL) {
|
567
|
+
xmlGlobalState *tsd = xmlNewGlobalState();
|
568
|
+
if (tsd == NULL)
|
569
|
+
return(NULL);
|
570
|
+
|
571
|
+
pthread_setspecific(globalkey, tsd);
|
572
|
+
return (tsd);
|
573
|
+
}
|
574
|
+
return (globalval);
|
575
|
+
#elif defined HAVE_WIN32_THREADS
|
576
|
+
#if defined(HAVE_COMPILER_TLS)
|
577
|
+
if (!tlstate_inited) {
|
578
|
+
tlstate_inited = 1;
|
579
|
+
xmlInitializeGlobalState(&tlstate);
|
580
|
+
}
|
581
|
+
return &tlstate;
|
582
|
+
#else /* HAVE_COMPILER_TLS */
|
583
|
+
xmlGlobalState *globalval;
|
584
|
+
xmlGlobalStateCleanupHelperParams *p;
|
585
|
+
#if defined(LIBXML_STATIC) && !defined(LIBXML_STATIC_FOR_DLL)
|
586
|
+
globalval = (xmlGlobalState *) TlsGetValue(globalkey);
|
587
|
+
#else
|
588
|
+
p = (xmlGlobalStateCleanupHelperParams *) TlsGetValue(globalkey);
|
589
|
+
globalval = (xmlGlobalState *) (p ? p->memory : NULL);
|
590
|
+
#endif
|
591
|
+
if (globalval == NULL) {
|
592
|
+
xmlGlobalState *tsd = xmlNewGlobalState();
|
593
|
+
|
594
|
+
if (tsd == NULL)
|
595
|
+
return(NULL);
|
596
|
+
p = (xmlGlobalStateCleanupHelperParams *)
|
597
|
+
malloc(sizeof(xmlGlobalStateCleanupHelperParams));
|
598
|
+
if (p == NULL) {
|
599
|
+
xmlGenericError(xmlGenericErrorContext,
|
600
|
+
"xmlGetGlobalState: out of memory\n");
|
601
|
+
xmlFreeGlobalState(tsd);
|
602
|
+
return(NULL);
|
603
|
+
}
|
604
|
+
p->memory = tsd;
|
605
|
+
#if defined(LIBXML_STATIC) && !defined(LIBXML_STATIC_FOR_DLL)
|
606
|
+
DuplicateHandle(GetCurrentProcess(), GetCurrentThread(),
|
607
|
+
GetCurrentProcess(), &p->thread, 0, TRUE,
|
608
|
+
DUPLICATE_SAME_ACCESS);
|
609
|
+
TlsSetValue(globalkey, tsd);
|
610
|
+
_beginthread(xmlGlobalStateCleanupHelper, 0, p);
|
611
|
+
#else
|
612
|
+
EnterCriticalSection(&cleanup_helpers_cs);
|
613
|
+
if (cleanup_helpers_head != NULL) {
|
614
|
+
cleanup_helpers_head->prev = p;
|
615
|
+
}
|
616
|
+
p->next = cleanup_helpers_head;
|
617
|
+
p->prev = NULL;
|
618
|
+
cleanup_helpers_head = p;
|
619
|
+
TlsSetValue(globalkey, p);
|
620
|
+
LeaveCriticalSection(&cleanup_helpers_cs);
|
621
|
+
#endif
|
622
|
+
|
623
|
+
return (tsd);
|
624
|
+
}
|
625
|
+
return (globalval);
|
626
|
+
#endif /* HAVE_COMPILER_TLS */
|
627
|
+
#else
|
628
|
+
return (NULL);
|
629
|
+
#endif
|
630
|
+
}
|
631
|
+
|
632
|
+
/************************************************************************
|
633
|
+
* *
|
634
|
+
* Library wide thread interfaces *
|
635
|
+
* *
|
636
|
+
************************************************************************/
|
637
|
+
|
638
|
+
/**
|
639
|
+
* xmlGetThreadId:
|
640
|
+
*
|
641
|
+
* DEPRECATED: Internal function, do not use.
|
642
|
+
*
|
643
|
+
* xmlGetThreadId() find the current thread ID number
|
644
|
+
* Note that this is likely to be broken on some platforms using pthreads
|
645
|
+
* as the specification doesn't mandate pthread_t to be an integer type
|
646
|
+
*
|
647
|
+
* Returns the current thread ID number
|
648
|
+
*/
|
649
|
+
int
|
650
|
+
xmlGetThreadId(void)
|
651
|
+
{
|
652
|
+
#ifdef HAVE_POSIX_THREADS
|
653
|
+
pthread_t id;
|
654
|
+
int ret;
|
655
|
+
|
656
|
+
if (XML_IS_THREADED() == 0)
|
657
|
+
return (0);
|
658
|
+
id = pthread_self();
|
659
|
+
/* horrible but preserves compat, see warning above */
|
660
|
+
memcpy(&ret, &id, sizeof(ret));
|
661
|
+
return (ret);
|
662
|
+
#elif defined HAVE_WIN32_THREADS
|
663
|
+
return GetCurrentThreadId();
|
664
|
+
#else
|
665
|
+
return ((int) 0);
|
666
|
+
#endif
|
667
|
+
}
|
668
|
+
|
669
|
+
/**
|
670
|
+
* xmlIsMainThread:
|
671
|
+
*
|
672
|
+
* DEPRECATED: Internal function, do not use.
|
673
|
+
*
|
674
|
+
* xmlIsMainThread() check whether the current thread is the main thread.
|
675
|
+
*
|
676
|
+
* Returns 1 if the current thread is the main thread, 0 otherwise
|
677
|
+
*/
|
678
|
+
int
|
679
|
+
xmlIsMainThread(void)
|
680
|
+
{
|
681
|
+
xmlInitParser();
|
682
|
+
|
683
|
+
#ifdef DEBUG_THREADS
|
684
|
+
xmlGenericError(xmlGenericErrorContext, "xmlIsMainThread()\n");
|
685
|
+
#endif
|
686
|
+
#ifdef HAVE_POSIX_THREADS
|
687
|
+
if (XML_IS_THREADED() == 0)
|
688
|
+
return (1);
|
689
|
+
return (pthread_equal(mainthread,pthread_self()));
|
690
|
+
#elif defined HAVE_WIN32_THREADS
|
691
|
+
return (mainthread == GetCurrentThreadId());
|
692
|
+
#else
|
693
|
+
return (1);
|
694
|
+
#endif
|
695
|
+
}
|
696
|
+
|
697
|
+
/**
|
698
|
+
* xmlLockLibrary:
|
699
|
+
*
|
700
|
+
* xmlLockLibrary() is used to take out a re-entrant lock on the libxml2
|
701
|
+
* library.
|
702
|
+
*/
|
703
|
+
void
|
704
|
+
xmlLockLibrary(void)
|
705
|
+
{
|
706
|
+
#ifdef DEBUG_THREADS
|
707
|
+
xmlGenericError(xmlGenericErrorContext, "xmlLockLibrary()\n");
|
708
|
+
#endif
|
709
|
+
xmlRMutexLock(xmlLibraryLock);
|
710
|
+
}
|
711
|
+
|
712
|
+
/**
|
713
|
+
* xmlUnlockLibrary:
|
714
|
+
*
|
715
|
+
* xmlUnlockLibrary() is used to release a re-entrant lock on the libxml2
|
716
|
+
* library.
|
717
|
+
*/
|
718
|
+
void
|
719
|
+
xmlUnlockLibrary(void)
|
720
|
+
{
|
721
|
+
#ifdef DEBUG_THREADS
|
722
|
+
xmlGenericError(xmlGenericErrorContext, "xmlUnlockLibrary()\n");
|
723
|
+
#endif
|
724
|
+
xmlRMutexUnlock(xmlLibraryLock);
|
725
|
+
}
|
726
|
+
|
727
|
+
/**
|
728
|
+
* xmlInitThreads:
|
729
|
+
*
|
730
|
+
* DEPRECATED: Alias for xmlInitParser.
|
731
|
+
*/
|
732
|
+
void
|
733
|
+
xmlInitThreads(void)
|
734
|
+
{
|
735
|
+
xmlInitParser();
|
736
|
+
}
|
737
|
+
|
738
|
+
/**
|
739
|
+
* xmlInitThreadsInternal:
|
740
|
+
*
|
741
|
+
* Used to to initialize all the thread related data.
|
742
|
+
*/
|
743
|
+
void
|
744
|
+
xmlInitThreadsInternal(void)
|
745
|
+
{
|
746
|
+
#ifdef HAVE_POSIX_THREADS
|
747
|
+
#ifdef XML_PTHREAD_WEAK
|
748
|
+
/*
|
749
|
+
* This is somewhat unreliable since libpthread could be loaded
|
750
|
+
* later with dlopen() and threads could be created. But it's
|
751
|
+
* long-standing behavior and hard to work around.
|
752
|
+
*/
|
753
|
+
if (libxml_is_threaded == -1)
|
754
|
+
libxml_is_threaded = (pthread_mutex_lock != NULL);
|
755
|
+
#endif /* XML_PTHREAD_WEAK */
|
756
|
+
pthread_key_create(&globalkey, xmlFreeGlobalState);
|
757
|
+
mainthread = pthread_self();
|
758
|
+
#elif defined(HAVE_WIN32_THREADS)
|
759
|
+
#if !defined(HAVE_COMPILER_TLS)
|
760
|
+
#if !defined(LIBXML_STATIC) || defined(LIBXML_STATIC_FOR_DLL)
|
761
|
+
InitializeCriticalSection(&cleanup_helpers_cs);
|
762
|
+
#endif
|
763
|
+
globalkey = TlsAlloc();
|
764
|
+
#endif
|
765
|
+
mainthread = GetCurrentThreadId();
|
766
|
+
#endif
|
767
|
+
}
|
768
|
+
|
769
|
+
/**
|
770
|
+
* xmlCleanupThreads:
|
771
|
+
*
|
772
|
+
* DEPRECATED: This function is a no-op. Call xmlCleanupParser
|
773
|
+
* to free global state but see the warnings there. xmlCleanupParser
|
774
|
+
* should be only called once at program exit. In most cases, you don't
|
775
|
+
* have call cleanup functions at all.
|
776
|
+
*/
|
777
|
+
void
|
778
|
+
xmlCleanupThreads(void)
|
779
|
+
{
|
780
|
+
}
|
781
|
+
|
782
|
+
/**
|
783
|
+
* xmlCleanupThreadsInternal:
|
784
|
+
*
|
785
|
+
* Used to to cleanup all the thread related data.
|
786
|
+
*/
|
787
|
+
void
|
788
|
+
xmlCleanupThreadsInternal(void)
|
789
|
+
{
|
790
|
+
#ifdef HAVE_POSIX_THREADS
|
791
|
+
pthread_key_delete(globalkey);
|
792
|
+
#elif defined(HAVE_WIN32_THREADS)
|
793
|
+
#if !defined(HAVE_COMPILER_TLS)
|
794
|
+
if (globalkey != TLS_OUT_OF_INDEXES) {
|
795
|
+
#if !defined(LIBXML_STATIC) || defined(LIBXML_STATIC_FOR_DLL)
|
796
|
+
xmlGlobalStateCleanupHelperParams *p;
|
797
|
+
|
798
|
+
EnterCriticalSection(&cleanup_helpers_cs);
|
799
|
+
p = cleanup_helpers_head;
|
800
|
+
while (p != NULL) {
|
801
|
+
xmlGlobalStateCleanupHelperParams *temp = p;
|
802
|
+
|
803
|
+
p = p->next;
|
804
|
+
xmlFreeGlobalState(temp->memory);
|
805
|
+
free(temp);
|
806
|
+
}
|
807
|
+
cleanup_helpers_head = 0;
|
808
|
+
LeaveCriticalSection(&cleanup_helpers_cs);
|
809
|
+
#endif
|
810
|
+
TlsFree(globalkey);
|
811
|
+
globalkey = TLS_OUT_OF_INDEXES;
|
812
|
+
}
|
813
|
+
#if !defined(LIBXML_STATIC) || defined(LIBXML_STATIC_FOR_DLL)
|
814
|
+
DeleteCriticalSection(&cleanup_helpers_cs);
|
815
|
+
#endif
|
816
|
+
#endif
|
817
|
+
#endif
|
818
|
+
}
|
819
|
+
|
820
|
+
/**
|
821
|
+
* DllMain:
|
822
|
+
* @hinstDLL: handle to DLL instance
|
823
|
+
* @fdwReason: Reason code for entry
|
824
|
+
* @lpvReserved: generic pointer (depends upon reason code)
|
825
|
+
*
|
826
|
+
* Entry point for Windows library. It is being used to free thread-specific
|
827
|
+
* storage.
|
828
|
+
*
|
829
|
+
* Returns TRUE always
|
830
|
+
*/
|
831
|
+
#ifdef HAVE_POSIX_THREADS
|
832
|
+
#elif defined(HAVE_WIN32_THREADS) && !defined(HAVE_COMPILER_TLS) && (!defined(LIBXML_STATIC) || defined(LIBXML_STATIC_FOR_DLL))
|
833
|
+
#if defined(LIBXML_STATIC_FOR_DLL)
|
834
|
+
int XMLCALL
|
835
|
+
xmlDllMain(ATTRIBUTE_UNUSED void *hinstDLL, unsigned long fdwReason,
|
836
|
+
ATTRIBUTE_UNUSED void *lpvReserved)
|
837
|
+
#else
|
838
|
+
/* declare to avoid "no previous prototype for 'DllMain'" warning */
|
839
|
+
/* Note that we do NOT want to include this function declaration in
|
840
|
+
a public header because it's meant to be called by Windows itself,
|
841
|
+
not a program that uses this library. This also has to be exported. */
|
842
|
+
|
843
|
+
XMLPUBFUN BOOL WINAPI
|
844
|
+
DllMain (HINSTANCE hinstDLL,
|
845
|
+
DWORD fdwReason,
|
846
|
+
LPVOID lpvReserved);
|
847
|
+
|
848
|
+
BOOL WINAPI
|
849
|
+
DllMain(ATTRIBUTE_UNUSED HINSTANCE hinstDLL, DWORD fdwReason,
|
850
|
+
ATTRIBUTE_UNUSED LPVOID lpvReserved)
|
851
|
+
#endif
|
852
|
+
{
|
853
|
+
switch (fdwReason) {
|
854
|
+
case DLL_THREAD_DETACH:
|
855
|
+
if (globalkey != TLS_OUT_OF_INDEXES) {
|
856
|
+
xmlGlobalState *globalval = NULL;
|
857
|
+
xmlGlobalStateCleanupHelperParams *p =
|
858
|
+
(xmlGlobalStateCleanupHelperParams *)
|
859
|
+
TlsGetValue(globalkey);
|
860
|
+
globalval = (xmlGlobalState *) (p ? p->memory : NULL);
|
861
|
+
if (globalval) {
|
862
|
+
xmlFreeGlobalState(globalval);
|
863
|
+
TlsSetValue(globalkey, NULL);
|
864
|
+
}
|
865
|
+
if (p) {
|
866
|
+
EnterCriticalSection(&cleanup_helpers_cs);
|
867
|
+
if (p == cleanup_helpers_head)
|
868
|
+
cleanup_helpers_head = p->next;
|
869
|
+
else
|
870
|
+
p->prev->next = p->next;
|
871
|
+
if (p->next != NULL)
|
872
|
+
p->next->prev = p->prev;
|
873
|
+
LeaveCriticalSection(&cleanup_helpers_cs);
|
874
|
+
free(p);
|
875
|
+
}
|
876
|
+
}
|
877
|
+
break;
|
878
|
+
}
|
879
|
+
return TRUE;
|
880
|
+
}
|
881
|
+
#endif
|