Skip to content

Commit 48d9dd9

Browse files
HertzDevilCTC97
authored andcommitted
Use per-thread libxml2 global state on all platforms (crystal-lang#15121)
libxml2's build files enable threads by default, so I'd be surprised if any platform still disables them (embedded systems don't count yet).
1 parent da3df17 commit 48d9dd9

File tree

2 files changed

+4
-20
lines changed

2 files changed

+4
-20
lines changed

src/xml.cr

+2-12
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,7 @@ module XML
107107
end
108108

109109
protected def self.with_indent_tree_output(indent : Bool, &)
110-
ptr = {% if flag?(:win32) %}
111-
LibXML.__xmlIndentTreeOutput
112-
{% else %}
113-
pointerof(LibXML.xmlIndentTreeOutput)
114-
{% end %}
115-
110+
ptr = LibXML.__xmlIndentTreeOutput
116111
old, ptr.value = ptr.value, indent ? 1 : 0
117112
begin
118113
yield
@@ -122,12 +117,7 @@ module XML
122117
end
123118

124119
protected def self.with_tree_indent_string(string : String, &)
125-
ptr = {% if flag?(:win32) %}
126-
LibXML.__xmlTreeIndentString
127-
{% else %}
128-
pointerof(LibXML.xmlTreeIndentString)
129-
{% end %}
130-
120+
ptr = LibXML.__xmlTreeIndentString
131121
old, ptr.value = ptr.value, string.to_unsafe
132122
begin
133123
yield

src/xml/libxml2.cr

+2-8
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,8 @@ lib LibXML
1313

1414
fun xmlInitParser
1515

16-
# TODO: check if other platforms also support per-thread globals
17-
{% if flag?(:win32) %}
18-
fun __xmlIndentTreeOutput : Int*
19-
fun __xmlTreeIndentString : UInt8**
20-
{% else %}
21-
$xmlIndentTreeOutput : Int
22-
$xmlTreeIndentString : UInt8*
23-
{% end %}
16+
fun __xmlIndentTreeOutput : Int*
17+
fun __xmlTreeIndentString : UInt8**
2418

2519
alias Dtd = Void*
2620
alias Dict = Void*

0 commit comments

Comments
 (0)