<?xml version='1.0' encoding='UTF-8' standalone='no'?>
<doxygen xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="compound.xsd" version="1.8.16">
  <compounddef id="i386_2spinlock_8c" kind="file" language="C++">
    <compoundname>spinlock.c</compoundname>
    <includes refid="__null_8h" local="no">sys/_null.h</includes>
    <includes refid="spinlock_8h" local="no">ubixos/spinlock.h</includes>
    <includes refid="sched_8h" local="no">ubixos/sched.h</includes>
    <includes refid="string_8h" local="no">string.h</includes>
    <incdepgraph>
      <node id="23">
        <label>ufs/ufs.h</label>
        <link refid="ufs_8h"/>
        <childnode refid="4" relation="include">
        </childnode>
        <childnode refid="24" relation="include">
        </childnode>
      </node>
      <node id="27">
        <label>sys/tss.h</label>
        <link refid="tss_8h"/>
        <childnode refid="4" relation="include">
        </childnode>
      </node>
      <node id="26">
        <label>ubixos/tty.h</label>
        <link refid="tty_8h"/>
        <childnode refid="4" relation="include">
        </childnode>
      </node>
      <node id="29">
        <label>strings.h</label>
        <link refid="strings_8h"/>
        <childnode refid="4" relation="include">
        </childnode>
      </node>
      <node id="16">
        <label>i386/cpu.h</label>
        <link refid="i386_2cpu_8h"/>
        <childnode refid="4" relation="include">
        </childnode>
      </node>
      <node id="6">
        <label>sys/select.h</label>
        <link refid="select_8h"/>
        <childnode refid="7" relation="include">
        </childnode>
        <childnode refid="5" relation="include">
        </childnode>
        <childnode refid="8" relation="include">
        </childnode>
        <childnode refid="9" relation="include">
        </childnode>
        <childnode refid="10" relation="include">
        </childnode>
      </node>
      <node id="19">
        <label>vfs/inode.h</label>
        <link refid="inode_8h"/>
        <childnode refid="4" relation="include">
        </childnode>
        <childnode refid="20" relation="include">
        </childnode>
        <childnode refid="21" relation="include">
        </childnode>
        <childnode refid="22" relation="include">
        </childnode>
        <childnode refid="23" relation="include">
        </childnode>
      </node>
      <node id="1">
        <label>C:/Dev/git/UbixOS/sys/arch/i386/spinlock.c</label>
        <link refid="i386_2spinlock_8c"/>
        <childnode refid="2" relation="include">
        </childnode>
        <childnode refid="3" relation="include">
        </childnode>
        <childnode refid="11" relation="include">
        </childnode>
        <childnode refid="28" relation="include">
        </childnode>
      </node>
      <node id="3">
        <label>ubixos/spinlock.h</label>
        <link refid="spinlock_8h"/>
        <childnode refid="4" relation="include">
        </childnode>
      </node>
      <node id="10">
        <label>sys/_sigset.h</label>
        <link refid="__sigset_8h"/>
        <childnode refid="5" relation="include">
        </childnode>
      </node>
      <node id="25">
        <label>vfs/mount.h</label>
        <link refid="mount_8h"/>
        <childnode refid="4" relation="include">
        </childnode>
      </node>
      <node id="18">
        <label>sys/resource.h</label>
        <link refid="resource_8h"/>
        <childnode refid="5" relation="include">
        </childnode>
      </node>
      <node id="15">
        <label>sys/trap.h</label>
        <link refid="trap_8h"/>
        <childnode refid="16" relation="include">
        </childnode>
      </node>
      <node id="2">
        <label>sys/_null.h</label>
        <link refid="__null_8h"/>
      </node>
      <node id="28">
        <label>string.h</label>
        <link refid="string_8h"/>
        <childnode refid="4" relation="include">
        </childnode>
        <childnode refid="29" relation="include">
        </childnode>
      </node>
      <node id="4">
        <label>sys/types.h</label>
        <link refid="include_2sys_2types_8h"/>
        <childnode refid="5" relation="include">
        </childnode>
        <childnode refid="6" relation="include">
        </childnode>
      </node>
      <node id="12">
        <label>vfs/file.h</label>
        <link refid="include_2vfs_2file_8h"/>
        <childnode refid="4" relation="include">
        </childnode>
        <childnode refid="13" relation="include">
        </childnode>
        <childnode refid="14" relation="include">
        </childnode>
        <childnode refid="19" relation="include">
        </childnode>
        <childnode refid="25" relation="include">
        </childnode>
        <childnode refid="23" relation="include">
        </childnode>
      </node>
      <node id="22">
        <label>fs/msdos_fs.h</label>
        <link refid="msdos__fs_8h"/>
      </node>
      <node id="17">
        <label>sys/signal.h</label>
        <link refid="sys_2signal_8h"/>
        <childnode refid="4" relation="include">
        </childnode>
      </node>
      <node id="21">
        <label>fs/pipe_fs.h</label>
        <link refid="pipe__fs_8h"/>
      </node>
      <node id="20">
        <label>ubixos/wait.h</label>
        <link refid="wait_8h"/>
      </node>
      <node id="14">
        <label>sys/thread.h</label>
        <link refid="thread_8h"/>
        <childnode refid="4" relation="include">
        </childnode>
        <childnode refid="15" relation="include">
        </childnode>
        <childnode refid="17" relation="include">
        </childnode>
        <childnode refid="18" relation="include">
        </childnode>
      </node>
      <node id="7">
        <label>sys/cdefs.h</label>
        <link refid="cdefs_8h"/>
      </node>
      <node id="11">
        <label>ubixos/sched.h</label>
        <link refid="sched_8h"/>
        <childnode refid="4" relation="include">
        </childnode>
        <childnode refid="12" relation="include">
        </childnode>
        <childnode refid="26" relation="include">
        </childnode>
        <childnode refid="27" relation="include">
        </childnode>
        <childnode refid="14" relation="include">
        </childnode>
      </node>
      <node id="5">
        <label>sys/_types.h</label>
        <link refid="__types_8h"/>
      </node>
      <node id="8">
        <label>sys/_timespec.h</label>
        <link refid="__timespec_8h"/>
        <childnode refid="5" relation="include">
        </childnode>
      </node>
      <node id="24">
        <label>sys/device.h</label>
        <link refid="include_2sys_2device_8h"/>
        <childnode refid="4" relation="include">
        </childnode>
      </node>
      <node id="13">
        <label>ubixfs/dirCache.h</label>
        <link refid="dirCache_8h"/>
        <childnode refid="4" relation="include">
        </childnode>
      </node>
      <node id="9">
        <label>sys/_timeval.h</label>
        <link refid="__timeval_8h"/>
        <childnode refid="5" relation="include">
        </childnode>
      </node>
    </incdepgraph>
      <sectiondef kind="define">
      <memberdef kind="define" id="i386_2spinlock_8c_1a98eeefbec68bcb915a01f12e4ebdefd5" prot="public" static="no">
        <name>atomic_add</name>
        <param><defname>P</defname></param>
        <param><defname>V</defname></param>
        <initializer>__sync_add_and_fetch((P), (V))</initializer>
        <briefdescription>
        </briefdescription>
        <detaileddescription>
        </detaileddescription>
        <inbodydescription>
        </inbodydescription>
        <location file="C:/Dev/git/UbixOS/sys/arch/i386/spinlock.c" line="38" column="9" bodyfile="C:/Dev/git/UbixOS/sys/arch/i386/spinlock.c" bodystart="38" bodyend="-1"/>
      </memberdef>
      <memberdef kind="define" id="i386_2spinlock_8c_1ac3b21a79504f9ee98f451f9f7092170d" prot="public" static="no">
        <name>atomic_clear_bit</name>
        <param><defname>P</defname></param>
        <param><defname>V</defname></param>
        <initializer>__sync_and_and_fetch((P), ~(1&lt;&lt;(V)))</initializer>
        <briefdescription>
        </briefdescription>
        <detaileddescription>
        </detaileddescription>
        <inbodydescription>
        </inbodydescription>
        <location file="C:/Dev/git/UbixOS/sys/arch/i386/spinlock.c" line="40" column="9" bodyfile="C:/Dev/git/UbixOS/sys/arch/i386/spinlock.c" bodystart="40" bodyend="-1"/>
      </memberdef>
      <memberdef kind="define" id="i386_2spinlock_8c_1a59c16c0e6ca2a4509a89b4095897f29f" prot="public" static="no">
        <name>atomic_dec</name>
        <param><defname>P</defname></param>
        <initializer>__sync_add_and_fetch((P), -1)</initializer>
        <briefdescription>
        </briefdescription>
        <detaileddescription>
        </detaileddescription>
        <inbodydescription>
        </inbodydescription>
        <location file="C:/Dev/git/UbixOS/sys/arch/i386/spinlock.c" line="37" column="9" bodyfile="C:/Dev/git/UbixOS/sys/arch/i386/spinlock.c" bodystart="37" bodyend="-1"/>
      </memberdef>
      <memberdef kind="define" id="i386_2spinlock_8c_1a45a583ebc7ce181c15688c871f955e98" prot="public" static="no">
        <name>atomic_inc</name>
        <param><defname>P</defname></param>
        <initializer>__sync_add_and_fetch((P), 1)</initializer>
        <briefdescription>
        </briefdescription>
        <detaileddescription>
        </detaileddescription>
        <inbodydescription>
        </inbodydescription>
        <location file="C:/Dev/git/UbixOS/sys/arch/i386/spinlock.c" line="36" column="9" bodyfile="C:/Dev/git/UbixOS/sys/arch/i386/spinlock.c" bodystart="36" bodyend="-1"/>
      </memberdef>
      <memberdef kind="define" id="i386_2spinlock_8c_1ac8aeecdc7ff00f1c46d5a91a73db87dd" prot="public" static="no">
        <name>atomic_set_bit</name>
        <param><defname>P</defname></param>
        <param><defname>V</defname></param>
        <initializer>__sync_or_and_fetch((P), 1&lt;&lt;(V))</initializer>
        <briefdescription>
        </briefdescription>
        <detaileddescription>
        </detaileddescription>
        <inbodydescription>
        </inbodydescription>
        <location file="C:/Dev/git/UbixOS/sys/arch/i386/spinlock.c" line="39" column="9" bodyfile="C:/Dev/git/UbixOS/sys/arch/i386/spinlock.c" bodystart="39" bodyend="-1"/>
      </memberdef>
      <memberdef kind="define" id="i386_2spinlock_8c_1a97c020c88ee892bb5a3055d5a68c9788" prot="public" static="no">
        <name>atomic_xadd</name>
        <param><defname>P</defname></param>
        <param><defname>V</defname></param>
        <initializer>__sync_fetch_and_add((P), (V))</initializer>
        <briefdescription>
        </briefdescription>
        <detaileddescription>
        </detaileddescription>
        <inbodydescription>
        </inbodydescription>
        <location file="C:/Dev/git/UbixOS/sys/arch/i386/spinlock.c" line="34" column="9" bodyfile="C:/Dev/git/UbixOS/sys/arch/i386/spinlock.c" bodystart="34" bodyend="-1"/>
      </memberdef>
      <memberdef kind="define" id="i386_2spinlock_8c_1a53290ac2df2384738b8769c76622f803" prot="public" static="no">
        <name>barrier</name>
        <param></param>
        <initializer><ref refid="idt_8c_1af03c996a639f5610a8514c6e6f8d15e6" kindref="member">asm</ref> <ref refid="cdefs_8h_1af55a5e48555be7d32ad73e76cf5d4db0" kindref="member">volatile</ref>(&quot;&quot;: : :&quot;memory&quot;)</initializer>
        <briefdescription>
        </briefdescription>
        <detaileddescription>
        </detaileddescription>
        <inbodydescription>
        </inbodydescription>
        <location file="C:/Dev/git/UbixOS/sys/arch/i386/spinlock.c" line="42" column="9" bodyfile="C:/Dev/git/UbixOS/sys/arch/i386/spinlock.c" bodystart="42" bodyend="-1"/>
      </memberdef>
      <memberdef kind="define" id="i386_2spinlock_8c_1a2ecfcce98539a0b972d6fa2586c4e67f" prot="public" static="no">
        <name>cmpxchg</name>
        <param><defname>P</defname></param>
        <param><defname>O</defname></param>
        <param><defname>N</defname></param>
        <initializer>__sync_val_compare_and_swap((P), (O), (N))</initializer>
        <briefdescription>
        </briefdescription>
        <detaileddescription>
        </detaileddescription>
        <inbodydescription>
        </inbodydescription>
        <location file="C:/Dev/git/UbixOS/sys/arch/i386/spinlock.c" line="35" column="9" bodyfile="C:/Dev/git/UbixOS/sys/arch/i386/spinlock.c" bodystart="35" bodyend="-1"/>
      </memberdef>
      <memberdef kind="define" id="i386_2spinlock_8c_1a89af7a9ebf21399bcbd8e892b6f3d41a" prot="public" static="no">
        <name>cpu_relax</name>
        <param></param>
        <initializer><ref refid="idt_8c_1af03c996a639f5610a8514c6e6f8d15e6" kindref="member">asm</ref> <ref refid="cdefs_8h_1af55a5e48555be7d32ad73e76cf5d4db0" kindref="member">volatile</ref>(&quot;pause\n&quot;: : :&quot;memory&quot;)</initializer>
        <briefdescription>
        </briefdescription>
        <detaileddescription>
        </detaileddescription>
        <inbodydescription>
        </inbodydescription>
        <location file="C:/Dev/git/UbixOS/sys/arch/i386/spinlock.c" line="45" column="9" bodyfile="C:/Dev/git/UbixOS/sys/arch/i386/spinlock.c" bodystart="45" bodyend="-1"/>
      </memberdef>
      </sectiondef>
      <sectiondef kind="func">
      <memberdef kind="function" id="i386_2spinlock_8c_1a0c58bcf16e5750a53054b545f314c3dc" prot="public" static="no" const="no" explicit="no" inline="no" virt="non-virtual">
        <type>void</type>
        <definition>void spinLock</definition>
        <argsstring>(spinLock_t lock)</argsstring>
        <name>spinLock</name>
        <param>
          <type><ref refid="spinlock_8h_1a205601d674593c0fff0a54719d27465b" kindref="member">spinLock_t</ref></type>
          <declname>lock</declname>
        </param>
        <briefdescription>
        </briefdescription>
        <detaileddescription>
        </detaileddescription>
        <inbodydescription>
        </inbodydescription>
        <location file="C:/Dev/git/UbixOS/sys/arch/i386/spinlock.c" line="64" column="6" bodyfile="C:/Dev/git/UbixOS/sys/arch/i386/spinlock.c" bodystart="64" bodyend="71"/>
      </memberdef>
      <memberdef kind="function" id="i386_2spinlock_8c_1ae17adaacb59f9cc8f63d81373be35a99" prot="public" static="no" const="no" explicit="no" inline="no" virt="non-virtual">
        <type>void</type>
        <definition>void spinLockInit</definition>
        <argsstring>(spinLock_t lock)</argsstring>
        <name>spinLockInit</name>
        <param>
          <type><ref refid="spinlock_8h_1a205601d674593c0fff0a54719d27465b" kindref="member">spinLock_t</ref></type>
          <declname>lock</declname>
        </param>
        <briefdescription>
        </briefdescription>
        <detaileddescription>
        </detaileddescription>
        <inbodydescription>
        </inbodydescription>
        <location file="C:/Dev/git/UbixOS/sys/arch/i386/spinlock.c" line="47" column="6" bodyfile="C:/Dev/git/UbixOS/sys/arch/i386/spinlock.c" bodystart="47" bodyend="49"/>
        <references refid="string_8h_1ace4b911463887af5e748326323e99a23">memset</references>
      </memberdef>
      <memberdef kind="function" id="i386_2spinlock_8c_1afd90c47975d942a2fdf7c2bc0ff58ea1" prot="public" static="no" const="no" explicit="no" inline="no" virt="non-virtual">
        <type>int</type>
        <definition>int spinTryLock</definition>
        <argsstring>(spinLock_t lock)</argsstring>
        <name>spinTryLock</name>
        <param>
          <type><ref refid="spinlock_8h_1a205601d674593c0fff0a54719d27465b" kindref="member">spinLock_t</ref></type>
          <declname>lock</declname>
        </param>
        <briefdescription>
        </briefdescription>
        <detaileddescription>
        </detaileddescription>
        <inbodydescription>
        </inbodydescription>
        <location file="C:/Dev/git/UbixOS/sys/arch/i386/spinlock.c" line="51" column="5" bodyfile="C:/Dev/git/UbixOS/sys/arch/i386/spinlock.c" bodystart="51" bodyend="57"/>
        <references refid="i386_2spinlock_8c_1a2ecfcce98539a0b972d6fa2586c4e67f" compoundref="i386_2spinlock_8c" startline="35">cmpxchg</references>
        <references refid="spinlock_8h_1aef31df4fa10911959af449d9f3ccf78f" compoundref="spinlock_8h" startline="37">LLOCK_FLAG</references>
        <references refid="spinlock_8h_1a00de8f7e0b615f88335573ba3909583d" compoundref="spinlock_8h" startline="34">LOCKED</references>
        <references refid="structspinLock_1a243edf7f3d81de2a9c7e3852768e5847" compoundref="spinlock_8h" startline="43">spinLock::locked</references>
        <references refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" compoundref="fat__string_8h" startline="17">NULL</references>
      </memberdef>
      <memberdef kind="function" id="i386_2spinlock_8c_1ac2d032c89ee37bb624eb87b9954f4a1e" prot="public" static="no" const="no" explicit="no" inline="no" virt="non-virtual">
        <type>void</type>
        <definition>void spinUnlock</definition>
        <argsstring>(spinLock_t lock)</argsstring>
        <name>spinUnlock</name>
        <param>
          <type><ref refid="spinlock_8h_1a205601d674593c0fff0a54719d27465b" kindref="member">spinLock_t</ref></type>
          <declname>lock</declname>
        </param>
        <briefdescription>
        </briefdescription>
        <detaileddescription>
        </detaileddescription>
        <inbodydescription>
        </inbodydescription>
        <location file="C:/Dev/git/UbixOS/sys/arch/i386/spinlock.c" line="59" column="6" bodyfile="C:/Dev/git/UbixOS/sys/arch/i386/spinlock.c" bodystart="59" bodyend="62"/>
        <references refid="i386_2spinlock_8c_1a53290ac2df2384738b8769c76622f803" compoundref="i386_2spinlock_8c" startline="42">barrier</references>
        <references refid="structspinLock_1a243edf7f3d81de2a9c7e3852768e5847" compoundref="spinlock_8h" startline="43">spinLock::locked</references>
      </memberdef>
      </sectiondef>
    <briefdescription>
    </briefdescription>
    <detaileddescription>
    </detaileddescription>
    <programlisting>
<codeline lineno="1"><highlight class="comment">/*-</highlight></codeline>
<codeline lineno="2"><highlight class="comment"><sp/>*<sp/>Copyright<sp/>(c)<sp/>2002-2018<sp/>The<sp/>UbixOS<sp/>Project.</highlight></codeline>
<codeline lineno="3"><highlight class="comment"><sp/>*<sp/>All<sp/>rights<sp/>reserved.</highlight></codeline>
<codeline lineno="4"><highlight class="comment"><sp/>*</highlight></codeline>
<codeline lineno="5"><highlight class="comment"><sp/>*<sp/>This<sp/>was<sp/>developed<sp/>by<sp/>Christopher<sp/>W.<sp/>Olsen<sp/>for<sp/>the<sp/>UbixOS<sp/>Project.</highlight></codeline>
<codeline lineno="6"><highlight class="comment"><sp/>*</highlight></codeline>
<codeline lineno="7"><highlight class="comment"><sp/>*<sp/>Redistribution<sp/>and<sp/>use<sp/>in<sp/>source<sp/>and<sp/>binary<sp/>forms,<sp/>with<sp/>or<sp/>without<sp/>modification,<sp/>are<sp/>permitted</highlight></codeline>
<codeline lineno="8"><highlight class="comment"><sp/>*<sp/>provided<sp/>that<sp/>the<sp/>following<sp/>conditions<sp/>are<sp/>met:</highlight></codeline>
<codeline lineno="9"><highlight class="comment"><sp/>*</highlight></codeline>
<codeline lineno="10"><highlight class="comment"><sp/>*<sp/>1)<sp/>Redistributions<sp/>of<sp/>source<sp/>code<sp/>must<sp/>retain<sp/>the<sp/>above<sp/>copyright<sp/>notice,<sp/>this<sp/>list<sp/>of</highlight></codeline>
<codeline lineno="11"><highlight class="comment"><sp/>*<sp/><sp/><sp/><sp/>conditions,<sp/>the<sp/>following<sp/>disclaimer<sp/>and<sp/>the<sp/>list<sp/>of<sp/>authors.</highlight></codeline>
<codeline lineno="12"><highlight class="comment"><sp/>*<sp/>2)<sp/>Redistributions<sp/>in<sp/>binary<sp/>form<sp/>must<sp/>reproduce<sp/>the<sp/>above<sp/>copyright<sp/>notice,<sp/>this<sp/>list<sp/>of</highlight></codeline>
<codeline lineno="13"><highlight class="comment"><sp/>*<sp/><sp/><sp/><sp/>conditions,<sp/>the<sp/>following<sp/>disclaimer<sp/>and<sp/>the<sp/>list<sp/>of<sp/>authors<sp/>in<sp/>the<sp/>documentation<sp/>and/or</highlight></codeline>
<codeline lineno="14"><highlight class="comment"><sp/>*<sp/><sp/><sp/><sp/>other<sp/>materials<sp/>provided<sp/>with<sp/>the<sp/>distribution.</highlight></codeline>
<codeline lineno="15"><highlight class="comment"><sp/>*<sp/>3)<sp/>Neither<sp/>the<sp/>name<sp/>of<sp/>the<sp/>UbixOS<sp/>Project<sp/>nor<sp/>the<sp/>names<sp/>of<sp/>its<sp/>contributors<sp/>may<sp/>be<sp/>used<sp/>to</highlight></codeline>
<codeline lineno="16"><highlight class="comment"><sp/>*<sp/><sp/><sp/><sp/>endorse<sp/>or<sp/>promote<sp/>products<sp/>derived<sp/>from<sp/>this<sp/>software<sp/>without<sp/>specific<sp/>prior<sp/>written</highlight></codeline>
<codeline lineno="17"><highlight class="comment"><sp/>*<sp/><sp/><sp/><sp/>permission.</highlight></codeline>
<codeline lineno="18"><highlight class="comment"><sp/>*</highlight></codeline>
<codeline lineno="19"><highlight class="comment"><sp/>*<sp/>THIS<sp/>SOFTWARE<sp/>IS<sp/>PROVIDED<sp/>BY<sp/>THE<sp/>AUTHOR<sp/>AND<sp/>CONTRIBUTORS<sp/>&quot;AS<sp/>IS&quot;<sp/>AND<sp/>ANY<sp/>EXPRESS<sp/>OR<sp/>IMPLIED</highlight></codeline>
<codeline lineno="20"><highlight class="comment"><sp/>*<sp/>WARRANTIES,<sp/>INCLUDING,<sp/>BUT<sp/>NOT<sp/>LIMITED<sp/>TO,<sp/>THE<sp/>IMPLIED<sp/>WARRANTIES<sp/>OF<sp/>MERCHANTABILITY<sp/>AND<sp/>FITNESS</highlight></codeline>
<codeline lineno="21"><highlight class="comment"><sp/>*<sp/>FOR<sp/>A<sp/>PARTICULAR<sp/>PURPOSE<sp/>ARE<sp/>DISCLAIMED.<sp/>IN<sp/>NO<sp/>EVENT<sp/>SHALL<sp/>THE<sp/>COPYRIGHT<sp/>OWNER<sp/>OR<sp/>CONTRIBUTORS</highlight></codeline>
<codeline lineno="22"><highlight class="comment"><sp/>*<sp/>BE<sp/>LIABLE<sp/>FOR<sp/>ANY<sp/>DIRECT,<sp/>INDIRECT,<sp/>INCIDENTAL,<sp/>SPECIAL,<sp/>EXEMPLARY,<sp/>OR<sp/>CONSEQUENTIAL<sp/>DAMAGES</highlight></codeline>
<codeline lineno="23"><highlight class="comment"><sp/>*<sp/>(INCLUDING,<sp/>BUT<sp/>NOT<sp/>LIMITED<sp/>TO,<sp/>PROCUREMENT<sp/>OF<sp/>SUBSTITUTE<sp/>GOODS<sp/>OR<sp/>SERVICES;<sp/>LOSS<sp/>OF<sp/>USE,<sp/>DATA,</highlight></codeline>
<codeline lineno="24"><highlight class="comment"><sp/>*<sp/>OR<sp/>PROFITS;<sp/>OR<sp/>BUSINESS<sp/>INTERRUPTION)<sp/>HOWEVER<sp/>CAUSED<sp/>AND<sp/>ON<sp/>ANY<sp/>THEORY<sp/>OF<sp/>LIABILITY,<sp/>WHETHER<sp/>IN</highlight></codeline>
<codeline lineno="25"><highlight class="comment"><sp/>*<sp/>CONTRACT,<sp/>STRICT<sp/>LIABILITY,<sp/>OR<sp/>TORT<sp/>(INCLUDING<sp/>NEGLIGENCE<sp/>OR<sp/>OTHERWISE)<sp/>ARISING<sp/>IN<sp/>ANY<sp/>WAY<sp/>OUT</highlight></codeline>
<codeline lineno="26"><highlight class="comment"><sp/>*<sp/>OF<sp/>THE<sp/>USE<sp/>OF<sp/>THIS<sp/>SOFTWARE,<sp/>EVEN<sp/>IF<sp/>ADVISED<sp/>OF<sp/>THE<sp/>POSSIBILITY<sp/>OF<sp/>SUCH<sp/>DAMAGE.</highlight></codeline>
<codeline lineno="27"><highlight class="comment"><sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="28"><highlight class="normal"></highlight></codeline>
<codeline lineno="29"><highlight class="normal"></highlight><highlight class="preprocessor">#include<sp/>&lt;<ref refid="__null_8h" kindref="compound">sys/_null.h</ref>&gt;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="30"><highlight class="normal"></highlight><highlight class="preprocessor">#include<sp/>&lt;<ref refid="spinlock_8h" kindref="compound">ubixos/spinlock.h</ref>&gt;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="31"><highlight class="normal"></highlight><highlight class="preprocessor">#include<sp/>&lt;<ref refid="sched_8h" kindref="compound">ubixos/sched.h</ref>&gt;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="32"><highlight class="normal"></highlight><highlight class="preprocessor">#include<sp/>&lt;<ref refid="string_8h" kindref="compound">string.h</ref>&gt;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="33"><highlight class="normal"></highlight></codeline>
<codeline lineno="34" refid="i386_2spinlock_8c_1a97c020c88ee892bb5a3055d5a68c9788" refkind="member"><highlight class="normal"></highlight><highlight class="preprocessor">#define<sp/>atomic_xadd(P,<sp/>V)<sp/>__sync_fetch_and_add((P),<sp/>(V))</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="35" refid="i386_2spinlock_8c_1a2ecfcce98539a0b972d6fa2586c4e67f" refkind="member"><highlight class="normal"></highlight><highlight class="preprocessor">#define<sp/>cmpxchg(P,<sp/>O,<sp/>N)<sp/>__sync_val_compare_and_swap((P),<sp/>(O),<sp/>(N))</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="36" refid="i386_2spinlock_8c_1a45a583ebc7ce181c15688c871f955e98" refkind="member"><highlight class="normal"></highlight><highlight class="preprocessor">#define<sp/>atomic_inc(P)<sp/>__sync_add_and_fetch((P),<sp/>1)</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="37" refid="i386_2spinlock_8c_1a59c16c0e6ca2a4509a89b4095897f29f" refkind="member"><highlight class="normal"></highlight><highlight class="preprocessor">#define<sp/>atomic_dec(P)<sp/>__sync_add_and_fetch((P),<sp/>-1)</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="38" refid="i386_2spinlock_8c_1a98eeefbec68bcb915a01f12e4ebdefd5" refkind="member"><highlight class="normal"></highlight><highlight class="preprocessor">#define<sp/>atomic_add(P,<sp/>V)<sp/>__sync_add_and_fetch((P),<sp/>(V))</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="39" refid="i386_2spinlock_8c_1ac8aeecdc7ff00f1c46d5a91a73db87dd" refkind="member"><highlight class="normal"></highlight><highlight class="preprocessor">#define<sp/>atomic_set_bit(P,<sp/>V)<sp/>__sync_or_and_fetch((P),<sp/>1&lt;&lt;(V))</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="40" refid="i386_2spinlock_8c_1ac3b21a79504f9ee98f451f9f7092170d" refkind="member"><highlight class="normal"></highlight><highlight class="preprocessor">#define<sp/>atomic_clear_bit(P,<sp/>V)<sp/>__sync_and_and_fetch((P),<sp/>~(1&lt;&lt;(V)))</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="41"><highlight class="normal"></highlight></codeline>
<codeline lineno="42" refid="i386_2spinlock_8c_1a53290ac2df2384738b8769c76622f803" refkind="member"><highlight class="normal"></highlight><highlight class="preprocessor">#define<sp/>barrier()<sp/>asm<sp/>volatile(&quot;&quot;:<sp/>:<sp/>:&quot;memory&quot;)</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="43"><highlight class="normal"></highlight></codeline>
<codeline lineno="44"><highlight class="normal"></highlight><highlight class="comment">/*<sp/>Pause<sp/>instruction<sp/>to<sp/>prevent<sp/>excess<sp/>processor<sp/>bus<sp/>usage<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="45" refid="i386_2spinlock_8c_1a89af7a9ebf21399bcbd8e892b6f3d41a" refkind="member"><highlight class="normal"></highlight><highlight class="preprocessor">#define<sp/>cpu_relax()<sp/>asm<sp/>volatile(&quot;pause\n&quot;:<sp/>:<sp/>:&quot;memory&quot;)</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="46"><highlight class="normal"></highlight></codeline>
<codeline lineno="47" refid="spinlock_8h_1a3ed033ffdc33d480e77190d424149415" refkind="member"><highlight class="normal"></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/><ref refid="armv6_2spinlock_8c_1a2d24a3613a1841bfa55a7b235fb5d78f" kindref="member">spinLockInit</ref>(<ref refid="structspinLock" kindref="compound">spinLock_t</ref><sp/>lock)<sp/>{</highlight></codeline>
<codeline lineno="48"><highlight class="normal"><sp/><sp/><ref refid="string_8h_1ace4b911463887af5e748326323e99a23" kindref="member">memset</ref>(lock,<sp/>0x0,<sp/></highlight><highlight class="keyword">sizeof</highlight><highlight class="normal">(</highlight><highlight class="keyword">struct</highlight><highlight class="normal"><sp/><ref refid="structspinLock" kindref="compound">spinLock</ref>));</highlight></codeline>
<codeline lineno="49"><highlight class="normal">}</highlight></codeline>
<codeline lineno="50"><highlight class="normal"></highlight></codeline>
<codeline lineno="51" refid="spinlock_8h_1aed6e978dc2762fbf062e37670b8fa04d" refkind="member"><highlight class="normal"></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/><ref refid="armv6_2spinlock_8c_1a740766af5da58616f700fffab6768a78" kindref="member">spinTryLock</ref>(<ref refid="structspinLock" kindref="compound">spinLock_t</ref><sp/>lock)<sp/>{</highlight></codeline>
<codeline lineno="52"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(!<ref refid="i386_2spinlock_8c_1a2ecfcce98539a0b972d6fa2586c4e67f" kindref="member">cmpxchg</ref>(&amp;lock-&gt;<ref refid="structspinLock_1a243edf7f3d81de2a9c7e3852768e5847" kindref="member">locked</ref>,<sp/><ref refid="fat__string_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4" kindref="member">NULL</ref>,<sp/><ref refid="spinlock_8h_1aef31df4fa10911959af449d9f3ccf78f" kindref="member">LLOCK_FLAG</ref>))</highlight></codeline>
<codeline lineno="53"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>0;</highlight></codeline>
<codeline lineno="54"><highlight class="normal"></highlight></codeline>
<codeline lineno="55"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*<sp/>Failure!<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="56"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/><ref refid="spinlock_8h_1a00de8f7e0b615f88335573ba3909583d" kindref="member">LOCKED</ref>;</highlight></codeline>
<codeline lineno="57"><highlight class="normal">}</highlight></codeline>
<codeline lineno="58"><highlight class="normal"></highlight></codeline>
<codeline lineno="59" refid="spinlock_8h_1a02e11882c06e98ee0e7ff1a9b4626fb3" refkind="member"><highlight class="normal"></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/><ref refid="armv6_2spinlock_8c_1ae29ab191c93f9ead066cb462dd2e7247" kindref="member">spinUnlock</ref>(<ref refid="structspinLock" kindref="compound">spinLock_t</ref><sp/>lock)<sp/>{</highlight></codeline>
<codeline lineno="60"><highlight class="normal"><sp/><sp/><ref refid="i386_2spinlock_8c_1a53290ac2df2384738b8769c76622f803" kindref="member">barrier</ref>();</highlight></codeline>
<codeline lineno="61"><highlight class="normal"><sp/><sp/>lock-&gt;<ref refid="structspinLock_1a243edf7f3d81de2a9c7e3852768e5847" kindref="member">locked</ref><sp/>=<sp/>0x0;</highlight></codeline>
<codeline lineno="62"><highlight class="normal">}</highlight></codeline>
<codeline lineno="63"><highlight class="normal"></highlight></codeline>
<codeline lineno="64" refid="spinlock_8h_1a623e97c04239abcce11cdd2826525f2e" refkind="member"><highlight class="normal"></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/><ref refid="armv6_2spinlock_8c_1a71f03d2ba55111c715b6068254847a53" kindref="member">spinLock</ref>(<ref refid="structspinLock" kindref="compound">spinLock_t</ref><sp/>lock)<sp/>{</highlight></codeline>
<codeline lineno="65"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">while</highlight><highlight class="normal"><sp/>(1)<sp/>{</highlight></codeline>
<codeline lineno="66"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(!xchg_32(&amp;lock-&gt;<ref refid="structspinLock_1a243edf7f3d81de2a9c7e3852768e5847" kindref="member">locked</ref>,<sp/><ref refid="spinlock_8h_1a00de8f7e0b615f88335573ba3909583d" kindref="member">LOCKED</ref>))</highlight></codeline>
<codeline lineno="67"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="68"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">while</highlight><highlight class="normal"><sp/>(lock-&gt;<ref refid="structspinLock_1a243edf7f3d81de2a9c7e3852768e5847" kindref="member">locked</ref><sp/>==<sp/>1)</highlight></codeline>
<codeline lineno="69"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="armv6_2sched_8c_1a08933fe6d593a1c78b9080359f15a0b7" kindref="member">sched_yield</ref>();</highlight></codeline>
<codeline lineno="70"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="71"><highlight class="normal">}</highlight></codeline>
<codeline lineno="72"><highlight class="normal"></highlight></codeline>
    </programlisting>
    <location file="C:/Dev/git/UbixOS/sys/arch/i386/spinlock.c"/>
  </compounddef>
</doxygen>
